!-------------------------------------- LICENCE BEGIN ------------------------------------
!Environment Canada - Atmospheric Science and Technology License/Disclaimer,
! version 3; Last Modified: May 7, 2008.
!This is free but copyrighted software; you can use/redistribute/modify it under the terms
!of the Environment Canada - Atmospheric Science and Technology License/Disclaimer
!version 3 or (at your option) any later version that should be found at:
!http://collaboration.cmc.ec.gc.ca/science/rpn.comm/license.html
!
!This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
!without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
!See the above mentioned License/Disclaimer for more details.
!You should have received a copy of the License/Disclaimer along with this software;
!if not, you can write to: EC-RPN COMM Group, 2121 TransCanada, suite 500, Dorval (Quebec),
!CANADA, H9P 1J3; or send e-mail to service.rpn@ec.gc.ca
!-------------------------------------- LICENCE END --------------------------------------
***s/r v4d_scalpro - Compute distributed inner product <F_px,F_py>
*
#include "model_macros_f.h"
*
subroutine v4d_scalpro (Ndim,F_px,F_py,F_psc_8) 6,1
*
#include "impnone.cdk"
*
integer Ndim
real F_px(Ndim), F_py(Ndim)
real*8 F_psc_8
*
*author
* M.Tanguay
*
*revision
* v2_10 - Tanguay M. - initial MPI version
* v2_21 - Desgagne M. - rpn_comm stooge for MPI
* v2_31 - Tanguay M. - adapt for tracers in tr3d
* v3_03 - Tanguay M. - Adjoint NoHyd configuration
*
*object
* see id section
*
*arguments
* Name I/O Description
*----------------------------------------------------------------
* Ndim I Dimension
* F_px I Control variable 1
* F_py I Control variable 2
* F_psc_8 O Inner product
*----------------------------------------------------------------
*
*implicits
#include "glb_ld.cdk"
#include "lun.cdk"
#include "v4dc.cdk"
#include "tr3d.cdk"
#include "schm.cdk"
*
integer m,ierr,i,j,k,n
real*8 plocal_8, ZERO_8
*
parameter( ZERO_8 = 0.0 )
*
* Computes distributed inner product
* ----------------------------------
F_psc_8 = ZERO_8
*
m = 0
do k = 1,l_nk
do j = 1,l_nj
do i = 1,l_niu
m = m+1
F_psc_8 = F_psc_8 + F_px(m)*F_py(m)*V4dc_scalp(m)
end do
end do
end do
*
do k = 1,l_nk
do j = 1,l_njv
do i = 1,l_ni
m = m+1
F_psc_8 = F_psc_8 + F_px(m)*F_py(m)*V4dc_scalp(m)
end do
end do
end do
*
do k=1,l_nk
do j=1,l_nj
do i=1,l_ni
m = m+1
F_psc_8 = F_psc_8 + F_px(m)*F_py(m)*V4dc_scalp(m)
end do
end do
end do
*
do j=1,l_nj
do i=1,l_ni
m = m+1
F_psc_8 = F_psc_8 + F_px(m)*F_py(m)*V4dc_scalp(m)
end do
end do
*
if(.not. Schm_hydro_L) then
*
do k=1,l_nk
do j=1,l_nj
do i=1,l_ni
m = m+1
F_psc_8 = F_psc_8 + F_px(m)*F_py(m)*V4dc_scalp(m)
end do
end do
end do
*
endif
*
if (Tr3d_ntr.gt.0) then
do n=1,Tr3d_ntr
do k=1,l_nk
do j=1,l_nj
do i=1,l_ni
m = m+1
F_psc_8 = F_psc_8 + F_px(m)*F_py(m)*V4dc_scalp(m)
end do
end do
end do
end do
endif
* ______________________________________________________
*
if(m.ne.Ndim) call gem_stop
('v4d_scalpro',-1)
* ______________________________________________________
*
plocal_8 = F_psc_8
F_psc_8 = ZERO_8
call rpn_comm_Allreduce(plocal_8,F_psc_8,1,"MPI_DOUBLE_PRECISION",
$ "MPI_SUM","grid",ierr)
*
* ---------------------------------------------------------------
*
return
end