source: LMDZ6/trunk/libf/dyn3dmem/call_calfis_mod.f90 @ 5374

Last change on this file since 5374 was 5324, checked in by abarral, 5 weeks ago

[WIP] Remove uses of DEBUGIO cpp key (deprecated)

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
File size: 10.0 KB
RevLine 
[1632]1!#define DEBUG_IO
2MODULE call_calfis_mod
3
4    REAL,POINTER,SAVE :: ucov(:,:)
5    REAL,POINTER,SAVE :: vcov(:,:)
6    REAL,POINTER,SAVE :: teta(:,:)
7    REAL,POINTER,SAVE :: masse(:,:)
8    REAL,POINTER,SAVE :: ps(:)
9    REAL,POINTER,SAVE :: phis(:)
10    REAL,POINTER,SAVE :: q(:,:,:)
11    REAL,POINTER,SAVE :: flxw(:,:)
12
13    REAL,POINTER,SAVE :: p(:,:)
14    REAL,POINTER,SAVE :: pks(:)
15    REAL,POINTER,SAVE :: pk(:,:)
16    REAL,POINTER,SAVE :: pkf(:,:)
17    REAL,POINTER,SAVE :: phi(:,:)
18    REAL,POINTER,SAVE :: du(:,:)
19    REAL,POINTER,SAVE :: dv(:,:)
20    REAL,POINTER,SAVE :: dteta(:,:)
21    REAL,POINTER,SAVE :: dq(:,:,:)
22    REAL,POINTER,SAVE :: dufi(:,:)
23    REAL,POINTER,SAVE :: dvfi(:,:)
24    REAL,POINTER,SAVE :: dtetafi(:,:)
25    REAL,POINTER,SAVE :: dqfi(:,:,:)
26    REAL,POINTER,SAVE :: dpfi(:)
27   
28   
29   
30   
31   
32CONTAINS
33
34  SUBROUTINE call_calfis_allocate
35  USE bands
[1810]36  USE allocate_field_mod
[1823]37  USE parallel_lmdz
[5272]38  USE dimensions_mod, ONLY: iim, jjm, llm, ndm
[5285]39  USE paramet_mod_h
[5272]40  USE infotrac, ONLY: nqtot
[1632]41  IMPLICIT NONE
42    TYPE(distrib),POINTER :: d
43    d=>distrib_physic
44
45    CALL allocate_u(ucov,llm,d)
46    CALL allocate_v(vcov,llm,d)
47    CALL allocate_u(teta,llm,d)
48    CALL allocate_u(masse,llm,d)
49    CALL allocate_u(ps,d)
50    CALL allocate_u(phis,d)
51    CALL allocate_u(q,llm,nqtot,d)
52    CALL allocate_u(flxw,llm,d)
53    CALL allocate_u(p,llmp1,d)
54    CALL allocate_u(pks,d)
[3435]55    pks(:)=0
[1632]56    CALL allocate_u(pk,llm,d)
[3435]57    pk(:,:)=0
[1632]58    CALL allocate_u(pkf,llm,d)
59    CALL allocate_u(phi,llm,d)
60    CALL allocate_u(du,llm,d)
61    CALL allocate_v(dv,llm,d)
62    CALL allocate_u(dteta,llm,d)
63    CALL allocate_u(dq,llm,nqtot,d)
64    CALL allocate_u(dufi,llm,d)
65    CALL allocate_v(dvfi,llm,d)
66    CALL allocate_u(dtetafi,llm,d)
67    CALL allocate_u(dqfi,llm,nqtot,d)
68    CALL allocate_u(dpfi,d)
[5282]69
[1632]70  END SUBROUTINE call_calfis_allocate
[5282]71
72
[2221]73  SUBROUTINE call_calfis(itau,lafin,ucov_dyn,vcov_dyn,teta_dyn,masse_dyn,ps_dyn, &
[1632]74                         phis_dyn,q_dyn,flxw_dyn)
[5272]75  USE dimensions_mod, ONLY: iim, jjm, llm, ndm
[5285]76  USE paramet_mod_h
[5272]77  USE exner_hyb_loc_m, only: exner_hyb_loc
[2021]78  use exner_milieu_loc_m, only: exner_milieu_loc
[1823]79  USE parallel_lmdz
[1632]80  USE times
81  USE mod_hallo
82  USE Bands
83  USE vampir
[4050]84  USE infotrac, ONLY: nqtot
[1632]85  USE control_mod
86  USE write_field_loc
87  USE write_field
[2597]88  USE comconst_mod, ONLY: dtphys
[2603]89  USE logic_mod, ONLY: leapf, forward, ok_strato
[2600]90  USE comvert_mod, ONLY: ap, bp, pressure_exner
[2601]91  USE temps_mod, ONLY: day_ini, day_ref, jd_ref, jh_ref, start_time
[5324]92  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_PHYS
[5258]93  USE strings_mod, ONLY: int2str
[5282]94  USE iniprint_mod_h
[1632]95  IMPLICIT NONE
96
[1987]97    INTEGER,INTENT(IN) :: itau ! (time) iteration step number
98    LOGICAL,INTENT(IN) :: lafin ! .true. if final time step
99    REAL,INTENT(INOUT) :: ucov_dyn(ijb_u:ije_u,llm) ! covariant zonal wind
100    REAL,INTENT(INOUT) :: vcov_dyn(ijb_v:ije_v,llm) ! covariant meridional wind
101    REAL,INTENT(INOUT) :: teta_dyn(ijb_u:ije_u,llm) ! potential temperature
102    REAL,INTENT(INOUT) :: masse_dyn(ijb_u:ije_u,llm) ! air mass
103    REAL,INTENT(INOUT) :: ps_dyn(ijb_u:ije_u) ! surface pressure
104    REAL,INTENT(INOUT) :: phis_dyn(ijb_u:ije_u) ! surface geopotential
105    REAL,INTENT(INOUT) :: q_dyn(ijb_u:ije_u,llm,nqtot) ! advected tracers
106    REAL,INTENT(INOUT) :: flxw_dyn(ijb_u:ije_u,llm) ! vertical mass flux
[1632]107
108    REAL :: dufi_tmp(iip1,llm)   
109    REAL :: dvfi_tmp(iip1,llm) 
110    REAL :: dtetafi_tmp(iip1,llm)
111    REAL :: dpfi_tmp(iip1)
112    REAL :: dqfi_tmp(iip1,llm,nqtot)
113
114    REAL :: jD_cur, jH_cur
115    CHARACTER(LEN=15) :: ztit
[1848]116    TYPE(Request),SAVE :: Request_physic
117!$OMP THREADPRIVATE(Request_physic )
[4056]118    INTEGER :: ijb,ije,l,iq
[1632]119
120!
121!     .......   Ajout   P.Le Van ( 17/04/96 )   ...........
122!
123
124
125  !$OMP MASTER
126    CALL suspend_timer(timer_caldyn)
[1987]127    IF (prt_level >= 10) THEN
128      WRITE(lunout,*) 'leapfrog_p: Entree dans la physique : Iteration No ',itau
129    ENDIF
[1632]130  !$OMP END MASTER
131   
[1673]132           jD_cur = jD_ref + day_ini - day_ref                           &
[2375]133     &        + (itau+1)/day_step
[1676]134
135           IF (planet_type .eq."generic") THEN
136              ! AS: we make jD_cur to be pday
137              jD_cur = int(day_ini + itau/day_step)
138           ENDIF
139
[1673]140           jH_cur = jH_ref + start_time +                                &
[2375]141     &              mod(itau+1,day_step)/float(day_step)
[1673]142    if (jH_cur > 1.0 ) then
143      jD_cur = jD_cur +1.
144      jH_cur = jH_cur -1.
145    endif
[1632]146
147!   Inbterface avec les routines de phylmd (phymars ... )
148!   -----------------------------------------------------
149
150!+jld
151
152!  Diagnostique de conservation de l'energie : initialisation
153 
154!-jld
155  !$OMP BARRIER
156  !$OMP MASTER
157    CALL VTb(VThallo)
158  !$OMP END MASTER
159   
160    CALL SetTag(Request_physic,800)
161    CALL Register_SwapField_u(ucov_dyn,ucov,distrib_physic,Request_physic,up=2,down=2)
162    CALL Register_SwapField_v(vcov_dyn,vcov,distrib_physic,Request_physic,up=2,down=2)
163    CALL Register_SwapField_u(teta_dyn,teta,distrib_physic,Request_physic,up=2,down=2)
164    CALL Register_SwapField_u(masse_dyn,masse,distrib_physic,Request_physic,up=1,down=2)
165    CALL Register_SwapField_u(ps_dyn,ps,distrib_physic,Request_physic,up=2,down=2)
166    CALL Register_SwapField_u(phis_dyn,phis,distrib_physic,Request_physic,up=2,down=2)
167    CALL Register_SwapField_u(q_dyn,q,distrib_physic,Request_physic,up=2,down=2)
168    CALL Register_SwapField_u(flxw_dyn,flxw,distrib_physic,Request_physic,up=2,down=2)
169 
170    CALL SendRequest(Request_Physic)
171  !$OMP BARRIER
172    CALL WaitRequest(Request_Physic)       
173
174  !$OMP BARRIER
175  !$OMP MASTER
176    CALL Set_Distrib(distrib_Physic)
177    CALL VTe(VThallo)
178       
179    CALL VTb(VTphysiq)
180  !$OMP END MASTER
181  !$OMP BARRIER
182
183    CALL pression_loc (  ip1jmp1, ap, bp, ps,  p      )
184
185  !$OMP BARRIER
[2021]186    CALL exner_hyb_loc(  ip1jmp1, ps, p, pks, pk, pkf )
[1632]187  !$OMP BARRIER
188    CALL geopot_loc  ( ip1jmp1, teta  , pk , pks,  phis  , phi   )
189
190
191    CALL Register_Hallo_u(p,llmp1,2,2,2,2,Request_physic)
192    CALL Register_Hallo_u(pk,llm,2,2,2,2,Request_physic)
193    CALL Register_Hallo_u(phi,llm,2,2,2,2,Request_physic)
194       
195    CALL SendRequest(Request_Physic)
196  !$OMP BARRIER
197    CALL WaitRequest(Request_Physic)
198
199  !$OMP BARRIER
200
[5250]201IF (CPPKEY_PHYS) THEN
[1632]202    CALL calfis_loc(lafin ,jD_cur, jH_cur,                       &
203                     ucov,vcov,teta,q,masse,ps,p,pk,phis,phi ,   &
204                     du,dv,dteta,dq,                             &
[2221]205                     flxw, dufi,dvfi,dtetafi,dqfi,dpfi  )
[5250]206END IF
[1632]207    ijb=ij_begin
208    ije=ij_end 
209    IF ( .not. pole_nord) THEN
210 
211    !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
212      DO l=1,llm
213        dufi_tmp(1:iip1,l)   = dufi(ijb:ijb+iim,l)
214        dvfi_tmp(1:iip1,l)   = dvfi(ijb:ijb+iim,l) 
215        dtetafi_tmp(1:iip1,l)= dtetafi(ijb:ijb+iim,l) 
216        dqfi_tmp(1:iip1,l,:) = dqfi(ijb:ijb+iim,l,:) 
217      ENDDO
218    !$OMP END DO NOWAIT
219
220    !$OMP MASTER
221      dpfi_tmp(1:iip1)     = dpfi(ijb:ijb+iim) 
222    !$OMP END MASTER
223   
224    ENDIF ! of if ( .not. pole_nord)
225
226  !$OMP BARRIER
227  !$OMP MASTER
228    CALL Set_Distrib(distrib_Physic_bis)
229    CALL VTb(VThallo)
230  !$OMP END MASTER
231  !$OMP BARRIER
232 
233    CALL Register_Hallo_u(dufi,llm,1,0,0,1,Request_physic)
234    CALL Register_Hallo_v(dvfi,llm,1,0,0,1,Request_physic)
235    CALL Register_Hallo_u(dtetafi,llm,1,0,0,1,Request_physic)
236    CALL Register_Hallo_u(dpfi,1,1,0,0,1,Request_physic)
237
[4056]238    DO iq=1,nqtot
239      CALL Register_Hallo_u(dqfi(:,:,iq),llm,1,0,0,1,Request_physic)
[1632]240    ENDDO
241       
242    CALL SendRequest(Request_Physic)
243  !$OMP BARRIER
244    CALL WaitRequest(Request_Physic)
245             
246  !$OMP BARRIER
247  !$OMP MASTER
248    CALL VTe(VThallo)
249    CALL Set_Distrib(distrib_Physic)
250  !$OMP END MASTER
251  !$OMP BARRIER       
252    ijb=ij_begin
253    IF (.not. pole_nord) THEN
254       
255    !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
256      DO l=1,llm
257        dufi(ijb:ijb+iim,l) = dufi(ijb:ijb+iim,l)+dufi_tmp(1:iip1,l)
258        dvfi(ijb:ijb+iim,l) = dvfi(ijb:ijb+iim,l)+dvfi_tmp(1:iip1,l)
259        dtetafi(ijb:ijb+iim,l) = dtetafi(ijb:ijb+iim,l)+dtetafi_tmp(1:iip1,l)
260        dqfi(ijb:ijb+iim,l,:) = dqfi(ijb:ijb+iim,l,:) + dqfi_tmp(1:iip1,l,:)
261      ENDDO
262    !$OMP END DO NOWAIT
263
264    !$OMP MASTER
265      dpfi(ijb:ijb+iim)   = dpfi(ijb:ijb+iim)+ dpfi_tmp(1:iip1)
266    !$OMP END MASTER
267         
268    endif ! of if (.not. pole_nord)
269
[5324]270
[1632]271  !$OMP BARRIER
272
273!      ajout des tendances physiques:
274!      ------------------------------
275
276    CALL addfi_loc( dtphys, leapf, forward   ,              &
277                    ucov, vcov, teta , q   ,ps ,            &
278                    dufi, dvfi, dtetafi , dqfi ,dpfi  )
[1987]279    ! since addfi updates ps(), also update p(), masse() and pk()
280    CALL pression_loc(ip1jmp1,ap,bp,ps,p)
281!$OMP BARRIER
282    CALL massdair_loc(p,masse)
283!$OMP BARRIER
284    if (pressure_exner) then
[2021]285      CALL exner_hyb_loc(ijnb_u,ps,p,pks,pk,pkf)
[1987]286    else
[2021]287      CALL exner_milieu_loc(ijnb_u,ps,p,pks,pk,pkf)
[1987]288    endif
289!$OMP BARRIER
[1632]290
[1793]291    IF (ok_strato) THEN
292!      CALL top_bound_loc( vcov,ucov,teta,masse,dufi,dvfi,dtetafi)
293      CALL top_bound_loc(vcov,ucov,teta,masse,dtphys)
294    ENDIF
295
[1632]296  !$OMP BARRIER
297  !$OMP MASTER
298    CALL VTe(VTphysiq)
299    CALL VTb(VThallo)
300  !$OMP END MASTER
301
302    CALL SetTag(Request_physic,800)
303    CALL Register_SwapField_u(ucov,ucov_dyn,distrib_caldyn,Request_physic)
304    CALL Register_SwapField_v(vcov,vcov_dyn,distrib_caldyn,Request_physic)
305    CALL Register_SwapField_u(teta,teta_dyn,distrib_caldyn,Request_physic)
306    CALL Register_SwapField_u(masse,masse_dyn,distrib_caldyn,Request_physic)
307    CALL Register_SwapField_u(ps,ps_dyn,distrib_caldyn,Request_physic)
308    CALL Register_SwapField_u(q,q_dyn,distrib_caldyn,Request_physic)
309    CALL SendRequest(Request_Physic)
310  !$OMP BARRIER
311    CALL WaitRequest(Request_Physic)     
312
313  !$OMP BARRIER
314  !$OMP MASTER
315    CALL VTe(VThallo)
316    CALL set_distrib(distrib_caldyn)
317  !$OMP END MASTER
318  !$OMP BARRIER
319
320!
321!  Diagnostique de conservation de l'energie : difference
322    IF (ip_ebil_dyn.ge.1 ) THEN
323      ztit='bil phys'
[1857]324!      CALL diagedyn(ztit,2,1,1,dtphys,ucov, vcov , ps, p ,pk , teta , q(:,:,1), q(:,:,2))
325      write(lunout,*)"call_calfis: diagedyn disabled in dyn3dmem !!"
[5324]326    ENDIF
[1632]327
328!-jld
329    !$OMP MASTER
330      CALL resume_timer(timer_caldyn)
331    !$OMP END MASTER
332
333  END SUBROUTINE call_calfis
334 
335END MODULE call_calfis_mod
Note: See TracBrowser for help on using the repository browser.