!-------------------------------------- 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 sol_main_ad - ADJ of sol_main * #include "model_macros_f.h"*
subroutine sol_main_ad (iln) 1,5 * implicit none * integer iln * *author * M.Tanguay * *revision * v2_10 - Tanguay M. - initial MPI version * v2_21 - Tanguay M. - reduce standard output as in model * v2_31 - Tanguay M. - adapt to f90 native dynamic memory allocation * v3_11 - Tanguay M. - AIXport+Opti+OpenMP for TLM-ADJ * v3_21 - Tanguay M. - Revision Openmp * v3_30 - Tanguay M. - add parameter iln in sol_main * *object * see id section * *arguments * none * *implicits #include "glb_ld.cdk"
#include "ldnh.cdk"
#include "lun.cdk"
#include "vtx.cdk"
#include "rhsc.cdk"
#include "trp.cdk"
#include "fft.cdk"
#include "ptopo.cdk"
* *modules integer vmmlod, vmmget, vmmuld external vmmlod, vmmget, vmmuld * integer i,pnerr,keys(2),dim * real*8, dimension ((ldnh_maxx-ldnh_minx+1)*(ldnh_maxy-ldnh_miny+1)*l_nk) :: rhs,sol,wk1,wk2 real*8 fdg1((ldnh_maxy -ldnh_miny +1)*(trp_12smax-trp_12smin+1)*(G_ni+Ptopo_npex)) real*8 fdg2((trp_12smax-trp_12smin+1)*(trp_22max -trp_22min +1)*(G_nj+Ptopo_npey)) real*8 fdwfft((ldnh_maxy -ldnh_miny +1)*(trp_12smax-trp_12smin+1)*(G_ni+2+Ptopo_npex)) * real*8 ZERO_8 parameter( ZERO_8 = 0.0 ) * integer j,k * --------------------------------------------------------------- ** if (Lun_debug_L) write(Lun_out,1000) * !$omp parallel private(dim) * * Zero adjoint variables * ---------------------- dim = (ldnh_maxx-ldnh_minx+1)*(ldnh_maxy-ldnh_miny+1)*l_nk * !$omp do do i = 1,dim rhs(i)=ZERO_8 sol(i)=ZERO_8 wk1(i)=ZERO_8 wk2(i)=ZERO_8 enddo !$omp enddo * dim = (ldnh_maxy -ldnh_miny +1)*(trp_12smax-trp_12smin+1)*(G_ni+2+Ptopo_npex) !$omp do do i = 1,dim fdwfft(i)=ZERO_8 enddo !$omp enddo * if (.not.Fft_fast_L) then dim = (ldnh_maxy -ldnh_miny +1)*(trp_12smax-trp_12smin+1)*(G_ni+Ptopo_npex) !$omp do do i = 1,dim fdg1(i)=ZERO_8 enddo !$omp enddo endif * dim = (trp_12smax-trp_12smin+1)*(trp_22max -trp_22min +1)*(G_nj+Ptopo_npey) !$omp do do i = 1,dim fdg2(i)=ZERO_8 enddo !$omp enddo * !$omp end parallel * * Get needed fields in memory * --------------------------- keys(1) = VMM_KEY(rheln) keys(2) = VMM_KEY(gptx) * pnerr = vmmlod( keys, 2 ) pnerr = VMM_GET_VAR(rheln) pnerr = VMM_GET_VAR(gptx) * c if (Lun_out.gt.0) print *,'RHELN in solver before sol_hcr' c call glbstat (rheln,'RHS',LDIST_DIM,G_nk,1,G_ni,1,G_nj,1,G_nk) * * ADJ of * Transfering sol (real*8 without halo) into gptx (real*4 with halo) call sol_trsf_ad
(sol,gptx ,ldnh_minx,ldnh_maxx,ldnh_miny,ldnh_maxy, $ LDIST_DIM,l_nk,-1) * * ADJ of * Computing elliptic problem solution (sol) call tmg_start0
(56, 'SOL_0_AD ' ) call sol_hcr_ad
(sol,rhs,wk1,wk2,fdg1,fdg2,fdwfft,iln, $ ldnh_minx,ldnh_maxx, $ ldnh_miny,ldnh_maxy,ldnh_ni,ldnh_nj,l_nk) call tmg_stop0
(56) * * ADJ of * Transfering rheln (real*4 with halo) into rhs (real*8 without halo) call sol_trsf_ad
(rhs,rheln,ldnh_minx,ldnh_maxx,ldnh_miny,ldnh_maxy, $ LDIST_DIM,l_nk, 1) * c if (Lun_out.gt.0) print *,'GPTX in solver after sol_hcr' c call glbstat(gptx,'SOL',LDIST_DIM,G_nk,1,G_ni,1,G_nj,1,G_nk) * pnerr = vmmuld( -1, 0 ) * ********************************************************************** * 1000 format( +5X,' ADJ of SOLVING LINEAR HELMHOLTZ PROBLEM: (S/R SOL_MAIN_AD)') * return end