1 | !----------------------------------------------------------------------- |
---|
2 | ! |
---|
3 | !NCEP_MESO:MEDIATION_LAYER:SOLVER |
---|
4 | ! |
---|
5 | !----------------------------------------------------------------------- |
---|
6 | #include "nmm_loop_basemacros.h" |
---|
7 | #include "nmm_loop_macros.h" |
---|
8 | !----------------------------------------------------------------------- |
---|
9 | ! |
---|
10 | SUBROUTINE SOLVE_NMM(GRID,CONFIG_FLAGS & |
---|
11 | ! |
---|
12 | #include "dummy_new_args.inc" |
---|
13 | ! |
---|
14 | & ) |
---|
15 | !----------------------------------------------------------------------- |
---|
16 | USE MODULE_DOMAIN, ONLY : DOMAIN, GET_IJK_FROM_GRID |
---|
17 | USE MODULE_CONFIGURE, ONLY : GRID_CONFIG_REC_TYPE |
---|
18 | USE MODULE_MODEL_CONSTANTS |
---|
19 | USE MODULE_STATE_DESCRIPTION |
---|
20 | USE MODULE_CTLBLK |
---|
21 | #ifdef DM_PARALLEL |
---|
22 | USE MODULE_DM, ONLY : LOCAL_COMMUNICATOR & |
---|
23 | ,MYTASK,NTASKS,NTASKS_X & |
---|
24 | ,NTASKS_Y |
---|
25 | USE MODULE_COMM_DM |
---|
26 | #endif |
---|
27 | USE MODULE_IGWAVE_ADJUST, ONLY: PDTE,PFDHT,DDAMP,VTOA |
---|
28 | USE MODULE_ADVECTION, ONLY: ADVE,VAD2,HAD2 & |
---|
29 | ,ADV2,MONO & |
---|
30 | ,VAD2_SCAL,HAD2_SCAL |
---|
31 | USE MODULE_NONHY_DYNAM, ONLY: EPS,VADZ,HADZ |
---|
32 | USE MODULE_DIFFUSION_NMM, ONLY: HDIFF |
---|
33 | USE MODULE_BNDRY_COND, ONLY: BOCOH,BOCOV |
---|
34 | USE MODULE_PHYSICS_CALLS |
---|
35 | USE MODULE_EXT_INTERNAL |
---|
36 | USE MODULE_PRECIP_ADJUST |
---|
37 | USE MODULE_NEST_UTIL ! USEs module_MPP (contains MYPE,NPES,MPI_COMM_COMP) |
---|
38 | #ifdef WRF_CHEM |
---|
39 | USE MODULE_INPUT_CHEM_DATA, ONLY: GET_LAST_GAS |
---|
40 | #endif |
---|
41 | !----------------------------------------------------------------------- |
---|
42 | ! |
---|
43 | IMPLICIT NONE |
---|
44 | ! |
---|
45 | !----------------------------------------------------------------------- |
---|
46 | ! |
---|
47 | !*** INPUT DATA |
---|
48 | ! |
---|
49 | !----------------------------------------------------------------------- |
---|
50 | ! |
---|
51 | TYPE(DOMAIN),TARGET :: GRID |
---|
52 | ! |
---|
53 | !*** DEFINITIONS OF DUMMY ARGUMENTS TO THIS ROUTINE (GENERATED FROM REGISTRY) |
---|
54 | ! |
---|
55 | ! NOTE, REGISTRY NO LONGER GENERATES DUMMY ARGUMENTS OR DUMMY ARGUMENT |
---|
56 | ! DECLARATIONS FOR RCONFIG ENTRIES. THEY ARE STILL PART OF STATE. ACCESS |
---|
57 | ! TO THESE VARIABLES IS NOW THROUGH GRID STRUCTURE, AS MODIFIED BELOW. |
---|
58 | ! AFFECTED VARIABLES: SIGMA, DT, NPHS, IDTAD, NRADS, NRADL, JULDAY, |
---|
59 | ! JULYR, NUM_SOIL_LAYERS, NCNVC, ENSDIM, DY, AND SPEC_BDY_WIDTH. |
---|
60 | ! JM, 20050819 |
---|
61 | ! |
---|
62 | !---------------------------- |
---|
63 | #include <dummy_new_decl.inc> |
---|
64 | !---------------------------- |
---|
65 | ! |
---|
66 | !*** STRUCTURE THAT CONTAINS RUN-TIME CONFIGURATION (NAMELIST) DATA FOR DOMAIN |
---|
67 | ! |
---|
68 | TYPE(GRID_CONFIG_REC_TYPE),INTENT(IN) :: CONFIG_FLAGS |
---|
69 | #ifdef WRF_CHEM |
---|
70 | INTEGER :: NUMGAS |
---|
71 | #endif |
---|
72 | ! |
---|
73 | !----------------------------------------------------------------------- |
---|
74 | ! |
---|
75 | !*** LOCAL VARIABLES |
---|
76 | ! |
---|
77 | !----------------------------------------------------------------------- |
---|
78 | ! |
---|
79 | INTEGER :: IDS,IDE,JDS,JDE,KDS,KDE & |
---|
80 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
81 | & ,IPS,IPE,JPS,JPE,KPS,KPE & |
---|
82 | & ,ITS,ITE,JTS,JTE,KTS,KTE |
---|
83 | ! |
---|
84 | INTEGER :: I,ICLTEND,IDF,IRTN,J,JC,JDF,K,KDF,LB,N_MOIST & |
---|
85 | & ,NTSD_current,L |
---|
86 | #ifdef HWRF |
---|
87 | !zhang's doing |
---|
88 | INTEGER,SAVE :: NTSD_restart1,NTSD_restart2,NTSD_restart3 |
---|
89 | #endif |
---|
90 | integer :: ierr |
---|
91 | INTEGER,SAVE :: NTSD_restart |
---|
92 | ! INTEGER :: MPI_COMM_COMP,MYPE,MYPROC,NPES |
---|
93 | INTEGER :: MYPROC |
---|
94 | INTEGER :: KVH,NTSD_rad,RC |
---|
95 | INTEGER :: NUM_OZMIXM,NUM_AEROSOLC |
---|
96 | ! |
---|
97 | REAL :: DT_INV,FICE,FRAIN,GPS,QI,QR,QW,WC,WP |
---|
98 | ! |
---|
99 | LOGICAL :: LAST_TIME,OPERATIONAL_PHYSICS |
---|
100 | ! |
---|
101 | CHARACTER(80) :: MESSAGE |
---|
102 | ! |
---|
103 | !*** For precip assimilation: |
---|
104 | INTEGER :: ISTAT |
---|
105 | REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: PPTDAT |
---|
106 | ! |
---|
107 | !----------------------------------------------------------------------- |
---|
108 | !*** For physics compatibility with other packages |
---|
109 | !----------------------------------------------------------------------- |
---|
110 | ! |
---|
111 | REAL,ALLOCATABLE,DIMENSION(:,:,:) :: TTEN,QTEN |
---|
112 | REAL,ALLOCATABLE,DIMENSION(:,:,:) :: RTHRATEN,RTHBLTEN,RQVBLTEN |
---|
113 | ! |
---|
114 | !----------------------------------------------------------------------- |
---|
115 | ! |
---|
116 | LOGICAL wrf_dm_on_monitor |
---|
117 | EXTERNAL wrf_dm_on_monitor |
---|
118 | ! |
---|
119 | !----------------------------------------------------------------------- |
---|
120 | !*** TIMING VARIABLES |
---|
121 | !----------------------------------------------------------------------- |
---|
122 | real,save :: solve_tim,exch_tim,pdte_tim,adve_tim,vtoa_tim & |
---|
123 | &, vadz_tim,hadz_tim,eps_tim,vad2_tim,had2_tim & |
---|
124 | &, radiation_tim,rdtemp_tim,turbl_tim,cltend_tim & |
---|
125 | &, cucnvc_tim,gsmdrive_tim,hdiff_tim,bocoh_tim & |
---|
126 | &, pfdht_tim,ddamp_tim,bocov_tim,uv_htov_tim,sum_tim & |
---|
127 | #ifdef HWRF |
---|
128 | &, adjppt_tim,sst_tim,flux_tim |
---|
129 | #else |
---|
130 | &, adjppt_tim |
---|
131 | #endif |
---|
132 | real,save :: exch_tim_max |
---|
133 | real :: btim,btimx |
---|
134 | real :: et_max,this_tim |
---|
135 | integer :: n_print_time |
---|
136 | ! |
---|
137 | #ifdef RSL |
---|
138 | integer rsl_internal_milliclock |
---|
139 | external rsl_internal_milliclock |
---|
140 | # define timef rsl_internal_milliclock |
---|
141 | #else |
---|
142 | real*8 :: timef |
---|
143 | #endif |
---|
144 | !----------------------------------------------------------------------- |
---|
145 | ! |
---|
146 | !#ifdef DEREF_KLUDGE |
---|
147 | !! SEE http://www.mmm.ucar.edu/wrf/WG2/topics/deref_kludge.htm |
---|
148 | ! INTEGER :: SM31,EM31,SM32,EM32,SM33,EM33 |
---|
149 | ! INTEGER :: SM31X,EM31X,SM32X,EM32X,SM33X,EM33X |
---|
150 | ! INTEGER :: SM31Y,EM31Y,SM32Y,EM32Y,SM33Y,EM33Y |
---|
151 | !#endif |
---|
152 | ! |
---|
153 | !----------------------------------------------------------------------- |
---|
154 | !*** Passive substance variables |
---|
155 | !----------------------------------------------------------------------- |
---|
156 | ! |
---|
157 | LOGICAL :: EULER |
---|
158 | INTEGER :: IDTADT |
---|
159 | INTEGER :: IDTADC |
---|
160 | INTEGER :: KS ! species index in 4d tracer array |
---|
161 | ! |
---|
162 | REAL,SAVE :: SUMDRRW |
---|
163 | ! |
---|
164 | #ifdef WRF_CHEM |
---|
165 | REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:,:) :: & ! i,j,k,ks |
---|
166 | CHE & ! 4d i,j,k chem tracers |
---|
167 | ,CH1 & ! intermediate tracer variable |
---|
168 | ,CHP & ! ch1 at previous time level |
---|
169 | ,TCC ! time change of tracers |
---|
170 | #endif |
---|
171 | !----------------------------------------------------------------------- |
---|
172 | ! |
---|
173 | ! LIMIT THE NUMBER OF ARGUMENTS IF COMPILED WITH -DLIMIT_ARGS BY COPYING |
---|
174 | ! SCALAR (NON-ARRAY) ARGUMENTS OUT OF THE GRID DATA STRUCTURE INTO LOCALLY |
---|
175 | ! DEFINED COPIES (DEFINED IN EM_DUMMY_DECL.INC, ABOVE, AS THEY ARE IF THEY |
---|
176 | ! ARE ARGUMENTS). AN EQUIVALENT INCLUDE OF EM_SCALAR_DEREFS.INC APPEARS |
---|
177 | ! AT THE END OF THE ROUTINE TO COPY BACK ANY CHNAGED NON-ARRAY VALUES. |
---|
178 | ! THE DEFINITION OF COPY_IN OR COPY_OUT BEFORE THE INCLUDE DEFINES THE |
---|
179 | ! DIRECTION OF THE COPY. NMM_SCALAR_DEREFS IS GENERATED FROM REGISTRY. |
---|
180 | ! |
---|
181 | !----------------------------------------------------------------------- |
---|
182 | !#define COPY_IN |
---|
183 | !#include <scalar_derefs.inc> |
---|
184 | !----------------------------------------------------------------------- |
---|
185 | ! |
---|
186 | ! TRICK PROBLEMATIC COMPILERS INTO NOT PERFORMING COPY-IN/COPY-OUT BY ADDING |
---|
187 | ! INDICES TO ARRAY ARGUMENTS IN THE CALL STATEMENTS IN THIS ROUTINE. |
---|
188 | ! IT HAS THE EFFECT OF PASSING ONLY THE FIRST ELEMENT OF THE ARRAY, RATHER |
---|
189 | ! THAN THE ENTIRE ARRAY. SEE: |
---|
190 | ! http://www.mmm.ucar.edu/wrf/WG2/topics/deref_kludge.htm |
---|
191 | ! |
---|
192 | !----------------------------------------------------------------------- |
---|
193 | #include "deref_kludge.h" |
---|
194 | !----------------------------------------------------------------------- |
---|
195 | ! |
---|
196 | ! NEEDED BY SOME COMM LAYERS, E.G. RSL. IF NEEDED, nmm_data_calls.inc IS |
---|
197 | ! GENERATED FROM THE REGISTRY. THE DEFINITION OF REGISTER_I1 ALLOWS |
---|
198 | ! I1 DATA TO BE COMMUNICATED IN THIS ROUTINE IF NECESSARY. |
---|
199 | ! |
---|
200 | !----------------------------------------------------------------------- |
---|
201 | !----------------------------------------------------------------------- |
---|
202 | !*********************************************************************** |
---|
203 | !*** |
---|
204 | !*** THE MAIN TIME INTEGRATION LOOP |
---|
205 | !*** |
---|
206 | !----------------------------------------------------------------------- |
---|
207 | ! |
---|
208 | !*** ntsd IS THE TIMESTEP COUNTER (Number of Time Steps Done) |
---|
209 | ! |
---|
210 | !----------------------------------------------------------------------- |
---|
211 | !*** |
---|
212 | !*** ADVANCE_count STARTS AT ZERO FOR ALL RUNS (REGULAR AND RESTART). |
---|
213 | !*** |
---|
214 | !----------------------------------------------------------------------- |
---|
215 | ! |
---|
216 | CALL DOMAIN_CLOCK_GET(GRID,ADVANCEcOUNT=NTSD_current) |
---|
217 | ! |
---|
218 | IF(NTSD_current==0)THEN |
---|
219 | IF(GRID%RESTART.AND.GRID%TSTART>0.)THEN |
---|
220 | #ifdef HWRF |
---|
221 | !zhang's doing: temporarily hardwired for two domains |
---|
222 | if( grid%id .eq. 1 ) NTSD_restart1=INT(grid%TSTART*3600./GRID%DT+0.5) |
---|
223 | if( grid%id .eq. 2 ) NTSD_restart2=INT(grid%TSTART*3600./GRID%DT+0.5) |
---|
224 | if( grid%id .eq. 3 ) NTSD_restart3=INT(grid%TSTART*3600./GRID%DT+0.5) |
---|
225 | #endif |
---|
226 | IHRST=grid%nstart_hour |
---|
227 | NTSD_restart=grid%ntsd |
---|
228 | ELSE |
---|
229 | IHRST=GRID%GMT |
---|
230 | grid%nstart_hour=IHRST |
---|
231 | #ifdef HWRF |
---|
232 | !zhang's doing |
---|
233 | NTSD_restart1=0 |
---|
234 | NTSD_restart2=0 |
---|
235 | NTSD_restart3=0 |
---|
236 | #else |
---|
237 | NTSD_restart=0 |
---|
238 | #endif |
---|
239 | ENDIF |
---|
240 | ENDIF |
---|
241 | #ifdef HWRF |
---|
242 | !zhang's doing |
---|
243 | if( grid%id .eq. 1 ) grid%ntsd=NTSD_restart1+NTSD_current |
---|
244 | if( grid%id .eq. 2 ) grid%ntsd=NTSD_restart2+NTSD_current |
---|
245 | if( grid%id .eq. 3 ) grid%ntsd=NTSD_restart3+NTSD_current |
---|
246 | #else |
---|
247 | grid%ntsd=NTSD_restart+NTSD_current |
---|
248 | #endif |
---|
249 | LAST_TIME=domain_last_time_step(GRID) |
---|
250 | ! |
---|
251 | !----------------------------------------------------------------------- |
---|
252 | ! |
---|
253 | !!!!! IF(WRF_DM_ON_MONITOR() )THEN |
---|
254 | WRITE(MESSAGE,125)grid%ntsd,grid%ntsd*GRID%DT/3600. |
---|
255 | 125 FORMAT(' SOLVE_NMM: TIMESTEP IS ',I5,' TIME IS ',F7.3,' HOURS') |
---|
256 | CALL WRF_MESSAGE(TRIM(MESSAGE)) |
---|
257 | !!!! ENDIF |
---|
258 | ! |
---|
259 | !----------------------------------------------------------------------- |
---|
260 | ! |
---|
261 | EULER=model_config_rec%EULER_ADV |
---|
262 | IDTADT=model_config_rec%IDTADT |
---|
263 | IDTADC=model_config_rec%IDTADC |
---|
264 | WP=model_config_rec%WP(grid%id) |
---|
265 | ! |
---|
266 | !----------------------------------------------------------------------- |
---|
267 | CALL WRF_GET_DM_COMMUNICATOR(MPI_COMM_COMP) |
---|
268 | CALL WRF_GET_NPROC(NPES) |
---|
269 | CALL WRF_GET_MYPROC(MYPROC) |
---|
270 | MYPE=MYPROC |
---|
271 | !----------------------------------------------------------------------- |
---|
272 | ! |
---|
273 | !*** OBTAIN DIMENSION INFORMATION STORED IN THE GRID DATA STRUCTURE. |
---|
274 | ! |
---|
275 | CALL GET_IJK_FROM_GRID(GRID & |
---|
276 | & ,IDS,IDE,JDS,JDE,KDS,KDE & |
---|
277 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
278 | & ,IPS,IPE,JPS,JPE,KPS,KPE ) |
---|
279 | !----------------------------------------------------------------------- |
---|
280 | ! |
---|
281 | !*** COMPUTE THESE STARTING AND STOPPING LOCATIONS FOR EACH TILE AND |
---|
282 | !*** NUMBER OF TILES. |
---|
283 | !*** SEE: http://www.mmm.ucar.edu/wrf/WG2/topics/settiles |
---|
284 | ! |
---|
285 | CALL SET_TILES(GRID,IDS,IDE,JDS,JDE,IPS,IPE,JPS,JPE) |
---|
286 | ! |
---|
287 | !----------------------------------------------------------------------- |
---|
288 | !*** SET FLAG FOR THE OPERATIONAL PHYSICS SUITE. |
---|
289 | !*** THIS WILL BE USED TO SAVE CLOCKTIME BY SKIPPING |
---|
290 | !*** FREQUENT UPDATES OF THE MOIST ARRAY AND INSTEAD |
---|
291 | !*** UPDATE IT ONLY WHEN IT IS NEEDED FOR PHYSICS. |
---|
292 | !----------------------------------------------------------------------- |
---|
293 | ! |
---|
294 | OPERATIONAL_PHYSICS=.FALSE. |
---|
295 | ! |
---|
296 | IF(CONFIG_FLAGS%RA_SW_PHYSICS ==GFDLSWSCHEME.AND. & |
---|
297 | & CONFIG_FLAGS%RA_LW_PHYSICS ==GFDLLWSCHEME.AND. & |
---|
298 | & CONFIG_FLAGS%SF_SFCLAY_PHYSICS==MYJSFCSCHEME.AND. & |
---|
299 | & CONFIG_FLAGS%BL_PBL_PHYSICS ==MYJPBLSCHEME.AND. & |
---|
300 | & CONFIG_FLAGS%CU_PHYSICS ==BMJSCHEME.AND. & |
---|
301 | & (CONFIG_FLAGS%MP_PHYSICS ==ETAMPNEW.or. & |
---|
302 | & CONFIG_FLAGS%MP_PHYSICS==ETAMP_HWRF))THEN |
---|
303 | ! |
---|
304 | OPERATIONAL_PHYSICS=.TRUE. |
---|
305 | ! |
---|
306 | ENDIF |
---|
307 | ! |
---|
308 | !----------------------------------------------------------------------- |
---|
309 | ! |
---|
310 | !*** TTEN, QTEN are used by GD convection scheme |
---|
311 | ! |
---|
312 | ALLOCATE(TTEN(IMS:IME,KMS:KME,JMS:JME),STAT=ISTAT) |
---|
313 | ALLOCATE(QTEN(IMS:IME,KMS:KME,JMS:JME),STAT=ISTAT) |
---|
314 | ALLOCATE(RTHBLTEN(IMS:IME,KMS:KME,JMS:JME),STAT=ISTAT) |
---|
315 | ALLOCATE(RQVBLTEN(IMS:IME,KMS:KME,JMS:JME),STAT=ISTAT) |
---|
316 | ALLOCATE(RTHRATEN(IMS:IME,KMS:KME,JMS:JME),STAT=ISTAT) |
---|
317 | #ifdef WRF_CHEM |
---|
318 | NUMGAS = GET_LAST_GAS(CONFIG_FLAGS%CHEM_OPT) |
---|
319 | #endif |
---|
320 | ! |
---|
321 | IF(CONFIG_FLAGS%CU_PHYSICS==GDSCHEME)THEN |
---|
322 | DO J=JMS,JME |
---|
323 | DO K=KMS,KME |
---|
324 | DO I=IMS,IME |
---|
325 | TTEN(I,K,J)=grid%t(I,J,K) |
---|
326 | QTEN(I,K,J)=grid%q(I,J,K) |
---|
327 | ENDDO |
---|
328 | ENDDO |
---|
329 | ENDDO |
---|
330 | ENDIF |
---|
331 | ! |
---|
332 | GRID%SIGMA=1 |
---|
333 | grid%hydro=.FALSE. |
---|
334 | ! |
---|
335 | ! |
---|
336 | IDF=IDE-1 |
---|
337 | JDF=JDE-1 |
---|
338 | KDF=KDE-1 |
---|
339 | ! |
---|
340 | !----------------------------------------------------------------------- |
---|
341 | ! |
---|
342 | !*** FOR NOW SET CONTROLS FOR TILES TO PATCHES |
---|
343 | ! |
---|
344 | !----------------------------------------------------------------------- |
---|
345 | ITS=IPS |
---|
346 | ITE=MIN(IPE,IDF) |
---|
347 | JTS=JPS |
---|
348 | JTE=MIN(JPE,JDF) |
---|
349 | KTS=KPS |
---|
350 | KTE=MIN(KPE,KDF) |
---|
351 | !----------------------------------------------------------------------- |
---|
352 | ! |
---|
353 | write(0,*)'grid%ntsd=',grid%ntsd |
---|
354 | if(grid%ntsd==0)then |
---|
355 | write(message,*)' its=',its,' ite=',ite |
---|
356 | call wrf_message(trim(message)) |
---|
357 | write(message,*)' jts=',jts,' jte=',jte |
---|
358 | call wrf_message(trim(message)) |
---|
359 | write(message,*)' kts=',kts,' kte=',kte |
---|
360 | call wrf_message(trim(message)) |
---|
361 | ! |
---|
362 | #ifdef WRF_CHEM |
---|
363 | ALLOCATE (CHE(IMS:IME,JMS:JME,KMS:KME,1:NUM_CHEM),STAT=ISTAT) |
---|
364 | ALLOCATE (CH1(IMS:IME,JMS:JME,KMS:KME,1:NUM_CHEM),STAT=ISTAT) |
---|
365 | ALLOCATE (CHP(IMS:IME,JMS:JME,KMS:KME,1:NUM_CHEM),STAT=ISTAT) |
---|
366 | ALLOCATE (TCC(IMS:IME,JMS:JME,KMS:KME,1:NUM_CHEM),STAT=ISTAT) |
---|
367 | #endif |
---|
368 | !----------------------------------------------------------------------- |
---|
369 | endif |
---|
370 | !----------------------------------------------------------------------- |
---|
371 | !*** SET TIMING VARIABLES TO ZERO AT START OF FORECAST. |
---|
372 | !----------------------------------------------------------------------- |
---|
373 | if(grid%ntsd==0)then |
---|
374 | solve_tim=0. |
---|
375 | exch_tim=0. |
---|
376 | pdte_tim=0. |
---|
377 | adve_tim=0. |
---|
378 | vtoa_tim=0. |
---|
379 | vadz_tim=0. |
---|
380 | hadz_tim=0. |
---|
381 | eps_tim=0. |
---|
382 | vad2_tim=0. |
---|
383 | had2_tim=0. |
---|
384 | radiation_tim=0. |
---|
385 | rdtemp_tim=0. |
---|
386 | turbl_tim=0. |
---|
387 | cltend_tim=0. |
---|
388 | cucnvc_tim=0. |
---|
389 | gsmdrive_tim=0. |
---|
390 | hdiff_tim=0. |
---|
391 | bocoh_tim=0. |
---|
392 | pfdht_tim=0. |
---|
393 | ddamp_tim=0. |
---|
394 | bocov_tim=0. |
---|
395 | uv_htov_tim=0. |
---|
396 | exch_tim_max=0. |
---|
397 | adjppt_tim=0. |
---|
398 | endif |
---|
399 | !----------------------------------------------------------------------- |
---|
400 | N_MOIST=NUM_MOIST |
---|
401 | ! |
---|
402 | DO J=MYJS_P4,MYJE_P4 |
---|
403 | grid%iheg(J)=MOD(J+1,2) |
---|
404 | grid%ihwg(J)=grid%iheg(J)-1 |
---|
405 | grid%iveg(J)=MOD(J,2) |
---|
406 | grid%ivwg(J)=grid%iveg(J)-1 |
---|
407 | ENDDO |
---|
408 | |
---|
409 | DO J=MYJS_P4,MYJE_P4 |
---|
410 | grid%ivw(J)=grid%ivwg(J) |
---|
411 | grid%ive(J)=grid%iveg(J) |
---|
412 | grid%ihe(J)=grid%iheg(J) |
---|
413 | grid%ihw(J)=grid%ihwg(J) |
---|
414 | ENDDO |
---|
415 | ! |
---|
416 | !*** LATERAL POINTS IN THE BOUNDARY ARRAYS |
---|
417 | ! |
---|
418 | LB=2*(IDF-IDS+1)+(JDF-JDS+1)-3 |
---|
419 | ! |
---|
420 | !*** APPROXIMATE GRIDPOINT SPACING (METERS) |
---|
421 | ! |
---|
422 | JC=JMS+(JME-JMS)/2 |
---|
423 | GPS=SQRT(grid%dx_nmm(IMS,JC)**2+grid%dy_nmm**2) |
---|
424 | ! |
---|
425 | !*** TIMESTEPS PER HOUR |
---|
426 | ! |
---|
427 | TSPH=3600./GRID%DT |
---|
428 | ! |
---|
429 | n_print_time=nint(3600./grid%dt) ! Print stats once per hour |
---|
430 | !----------------------------------------------------------------------- |
---|
431 | ! |
---|
432 | NBOCO=0 |
---|
433 | ! |
---|
434 | !----------------------------------------------------------------------- |
---|
435 | ! |
---|
436 | #if (NMM_NEST == 1) |
---|
437 | !----------------------------------------------------------------------------- |
---|
438 | !*** PATCHING NESTED BOUNDARIES. |
---|
439 | !----------------------------------------------------------------------------- |
---|
440 | ! |
---|
441 | CALL wrf_debug ( 100 , 'nmm: in patch' ) |
---|
442 | |
---|
443 | btimx=timef() |
---|
444 | #ifdef DM_PARALLEL |
---|
445 | # include "HALO_NMM_ZZ.inc" |
---|
446 | #endif |
---|
447 | |
---|
448 | IF(GRID%ID/=1)THEN |
---|
449 | ! |
---|
450 | CALL NESTBC_PATCH (grid%PD_BXS,grid%PD_BXE,grid%PD_BYS,grid%PD_BYE,grid%T_BXS,grid%T_BXE,grid%T_BYS,grid%T_BYE,grid%Q_BXS,grid%Q_BXE & |
---|
451 | ,grid%Q_BYS,grid%Q_BYE,grid%U_BXS,grid%U_BXE,grid%U_BYS,grid%U_BYE,grid%V_BXS,grid%V_BXE,grid%V_BYS,grid%V_BYE & |
---|
452 | ,grid%Q2_BXS,grid%Q2_BXE,grid%Q2_BYS,grid%Q2_BYE,grid%CWM_BXS,grid%CWM_BXE,grid%CWM_BYS,grid%CWM_BYE & |
---|
453 | ,grid%PD_BTXS,grid%PD_BTXE,grid%PD_BTYS,grid%PD_BTYE,grid%T_BTXS,grid%T_BTXE,grid%T_BTYS,grid%T_BTYE & |
---|
454 | ,grid%Q_BTXS,grid%Q_BTXE,grid%Q_BTYS,grid%Q_BTYE,grid%U_BTXS,grid%U_BTXE,grid%U_BTYS,grid%U_BTYE & |
---|
455 | ,grid%V_BTXS,grid%V_BTXE,grid%V_BTYS,grid%V_BTYE,grid%Q2_BTXS,grid%Q2_BTXE,grid%Q2_BTYS,grid%Q2_BTYE & |
---|
456 | ,grid%CWM_BTXS,grid%CWM_BTXE,grid%CWM_BTYS,grid%CWM_BTYE,grid%pdnest_b,grid%tnest_b,grid%qnest_b,grid%unest_b & |
---|
457 | ,grid%vnest_b,grid%q2nest_b,grid%cwmnest_b,grid%pdnest_bt,grid%tnest_bt,grid%qnest_bt & |
---|
458 | ,grid%unest_bt,grid%vnest_bt,grid%q2nest_bt,grid%cwmnest_bt & |
---|
459 | ,GRID%SPEC_BDY_WIDTH & |
---|
460 | ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
461 | ,IMS,IME,JMS,JME,KMS,KME & |
---|
462 | ,ITS,ITE,JTS,JTE,KTS,KTE ) |
---|
463 | |
---|
464 | ! |
---|
465 | #ifdef MOVE_NESTS |
---|
466 | |
---|
467 | IF(GRID%ID/=1.AND.MOD(grid%ntsd,1)==0.AND.GRID%NUM_MOVES==-99)THEN |
---|
468 | grid%XLOC_1=(IDE-1)/2 ! This maneuvers the storm to the center of the nest quickly |
---|
469 | grid%YLOC_1=(JDE-1)/2 ! This maneuvers the storm to the center of the nest quickly |
---|
470 | ENDIF |
---|
471 | #endif |
---|
472 | |
---|
473 | ENDIF |
---|
474 | #endif |
---|
475 | ! |
---|
476 | !----------------------------------------------------------------------- |
---|
477 | !*** ALLOCATE PPTDAT ARRAY (PRECIP ASSIM): |
---|
478 | !----------------------------------------------------------------------- |
---|
479 | ! |
---|
480 | IF(GRID%PCPFLG.AND..NOT.ALLOCATED(PPTDAT))THEN |
---|
481 | ALLOCATE(PPTDAT(IMS:IME,JMS:JME,3),STAT=ISTAT) |
---|
482 | ENDIF |
---|
483 | ! |
---|
484 | !----------------------------------------------------------------------- |
---|
485 | !*** |
---|
486 | !*** Call READPCP to |
---|
487 | !*** 1) READ IN PRECIPITATION FOR HOURS 1, 2 and 3; |
---|
488 | !*** 2) Initialize grid%ddata to 999. (this is the amount |
---|
489 | !*** of input precip allocated to each physics time step |
---|
490 | !*** in ADJPPT; TURBL/SURFCE, which uses grid%ddata, is called |
---|
491 | !*** before ADJPPT) |
---|
492 | !*** 3) Initialize grid%lspa to zero |
---|
493 | !*** |
---|
494 | !----------------------------------------------------------------------- |
---|
495 | |
---|
496 | IF (grid%ntsd==0) THEN |
---|
497 | IF (GRID%PCPFLG) THEN |
---|
498 | CALL READPCP(PPTDAT,grid%ddata,grid%lspa & |
---|
499 | & ,IDS,IDE,JDS,JDE,KDS,KDE & |
---|
500 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
501 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
502 | ENDIF |
---|
503 | ENDIF |
---|
504 | !----------------------------------------------------------------------- |
---|
505 | ! |
---|
506 | btim=timef() |
---|
507 | ! |
---|
508 | !----------------------------------------------------------------------- |
---|
509 | !*** ZERO OUT ACCUMULATED QUANTITIES WHEN NEEDED. |
---|
510 | !----------------------------------------------------------------------- |
---|
511 | ! |
---|
512 | CALL BUCKETS(grid%ntsd,grid%nprec,grid%nsrfc,grid%nrdsw,grid%nrdlw & |
---|
513 | & ,GRID%RESTART,GRID%TSTART & |
---|
514 | & ,grid%nclod,grid%nheat,GRID%NPHS,TSPH & |
---|
515 | & ,grid%acprec,grid%cuprec,grid%acsnow,grid%acsnom,grid%ssroff,grid%bgroff & |
---|
516 | & ,grid%sfcevp,grid%potevp,grid%sfcshx,grid%sfclhx,grid%subshx,grid%snopcx & |
---|
517 | & ,grid%sfcuvx,grid%potflx & |
---|
518 | & ,grid%ardsw,grid%aswin,grid%aswout,grid%aswtoa & |
---|
519 | & ,grid%ardlw,grid%alwin,grid%alwout,grid%alwtoa & |
---|
520 | & ,grid%acfrst,grid%ncfrst,grid%acfrcv,grid%ncfrcv & |
---|
521 | & ,grid%avcnvc,grid%avrain,grid%tcucn,grid%train & |
---|
522 | & ,grid%asrfc & |
---|
523 | & ,grid%t,grid%tlmax,grid%tlmin,grid%tshltr,grid%pshltr,grid%qshltr & |
---|
524 | & ,grid%t02_max,grid%t02_min,grid%rh02_max,grid%rh02_min & |
---|
525 | & ,IDS,IDE,JDS,JDE,KDS,KDE & |
---|
526 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
527 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
528 | !----------------------------------------------------------------------- |
---|
529 | ! |
---|
530 | #ifdef HWRF |
---|
531 | !zhang |
---|
532 | IF(NTSD_current==0)THEN |
---|
533 | #else |
---|
534 | IF(grid%ntsd==0)THEN |
---|
535 | #endif |
---|
536 | FIRST=.TRUE. |
---|
537 | ! call hpm_init() |
---|
538 | btimx=timef() |
---|
539 | !emc_2010_bugfix_h50 |
---|
540 | grid%mommix=amin1(grid%mommix,1.0) |
---|
541 | !emc_2010_bugfix_h50 |
---|
542 | ! |
---|
543 | !----------------------------------------------------------------------- |
---|
544 | !*** FIRST STEP INITIALIZATION OF PASSIVE SUBSTANCE VARIABLES |
---|
545 | !----------------------------------------------------------------------- |
---|
546 | ! |
---|
547 | IF(EULER) THEN |
---|
548 | SUMDRRW=0. |
---|
549 | ! |
---|
550 | DO K=KTS,KTE |
---|
551 | DO J=JMS,JME |
---|
552 | DO I=IMS,IME |
---|
553 | grid%rrw(I,J,K)=0. |
---|
554 | ! |
---|
555 | IF(I>=IDE/2-6.AND.I<=IDE/2+6.AND. & |
---|
556 | J>=JDE/2-6.AND.J<=JDE/2+6 ) THEN |
---|
557 | grid%rrw(I,J,K)=10.0 !youhua |
---|
558 | ! grid%rrw(I,J,K)=0.9 !zj |
---|
559 | ENDIF |
---|
560 | ! |
---|
561 | ENDDO |
---|
562 | ENDDO |
---|
563 | ENDDO |
---|
564 | ! |
---|
565 | DO KS=PARAM_FIRST_SCALAR,NUM_SZJ |
---|
566 | DO K=KMS,KME |
---|
567 | DO J=JMS,JME |
---|
568 | DO I=IMS,IME |
---|
569 | SZJ(I,J,K,KS)=0. |
---|
570 | S1Z(I,J,K,KS)=0. |
---|
571 | SPZ(I,J,K,KS)=0. |
---|
572 | TCS(I,J,K,KS)=0. |
---|
573 | ENDDO |
---|
574 | ENDDO |
---|
575 | ENDDO |
---|
576 | ENDDO |
---|
577 | ! |
---|
578 | ENDIF |
---|
579 | ! |
---|
580 | !----------------------------------------------------------------------- |
---|
581 | ! |
---|
582 | #ifdef WRF_CHEM |
---|
583 | DO KS=1,NUM_CHEM |
---|
584 | DO K=KMS,KME |
---|
585 | DO J=JMS,JME |
---|
586 | DO I=IMS,IME |
---|
587 | CHE(I,J,K,KS)=0. |
---|
588 | CH1(I,J,K,KS)=0. |
---|
589 | CHP(I,J,K,KS)=0. |
---|
590 | TCC(I,J,K,KS)=0. |
---|
591 | ENDDO |
---|
592 | ENDDO |
---|
593 | ENDDO |
---|
594 | ENDDO |
---|
595 | #endif |
---|
596 | ! |
---|
597 | !----------------------------------------------------------------------- |
---|
598 | #ifdef DM_PARALLEL |
---|
599 | # include "HALO_NMM_A.inc" |
---|
600 | #endif |
---|
601 | ! |
---|
602 | !----------------------------------------------------------------------- |
---|
603 | #ifdef DM_PARALLEL |
---|
604 | IF(CONFIG_FLAGS%MP_PHYSICS/=ETAMPNEW.and.CONFIG_FLAGS%MP_PHYSICS/=ETAMP_HWRF)THEN |
---|
605 | # include "HALO_NMM_A_3.inc" |
---|
606 | ENDIF |
---|
607 | #endif |
---|
608 | !----------------------------------------------------------------------- |
---|
609 | !*** FIRST STEP INITIALIZATION OF PASSIVE SUBSTANCE VARIABLES |
---|
610 | !----------------------------------------------------------------------- |
---|
611 | ! |
---|
612 | IF(EULER) THEN |
---|
613 | ! |
---|
614 | DO K=KTS,KTE |
---|
615 | DO J=JMS,JME |
---|
616 | DO I=IMS,IME |
---|
617 | SPZ(I,J,K,P_SPZ1)=SQRT(MAX(grid%q (I,J,K),EPSQ)) |
---|
618 | SPZ(I,J,K,P_SPZ2)=SQRT(MAX(grid%cwm(I,J,K),EPSQ)) |
---|
619 | SPZ(I,J,K,P_SPZ4)=SQRT(MAX(grid%rrw(I,J,K),0. )) |
---|
620 | ENDDO |
---|
621 | ENDDO |
---|
622 | ENDDO |
---|
623 | ! |
---|
624 | DO J=JMS,JME |
---|
625 | DO I=IMS,IME |
---|
626 | SPZ(I,J,KTE,P_SPZ3)=SQRT(MAX((grid%q2(I,J,KTE)+EPSQ2)*0.5,EPSQ2)) |
---|
627 | ENDDO |
---|
628 | ENDDO |
---|
629 | ! |
---|
630 | DO K=KTE-1,KTS,-1 |
---|
631 | DO J=JMS,JME |
---|
632 | DO I=IMS,IME |
---|
633 | SPZ(I,J,K,P_SPZ3)=SQRT(MAX((grid%q2(I,J,K)+grid%q2(I,J,K+1))*0.5,EPSQ2)) |
---|
634 | ENDDO |
---|
635 | ENDDO |
---|
636 | ENDDO |
---|
637 | ! |
---|
638 | ENDIF |
---|
639 | ! |
---|
640 | !----------------------------------------------------------------------- |
---|
641 | ! |
---|
642 | #ifdef WRF_CHEM |
---|
643 | DO KS=1,NUM_CHEM |
---|
644 | DO K=KMS,KME |
---|
645 | DO J=JMS,JME |
---|
646 | DO I=IMS,IME |
---|
647 | CHP(I,J,K,KS)=SQRT(MAX(CHEM(I,K,J,KS),0. )) |
---|
648 | ENDDO |
---|
649 | ENDDO |
---|
650 | ENDDO |
---|
651 | ENDDO |
---|
652 | #endif |
---|
653 | ! |
---|
654 | !----------------------------------------------------------------------- |
---|
655 | ! |
---|
656 | !*** Only for chemistry: |
---|
657 | ! |
---|
658 | #ifdef WRF_CHEM |
---|
659 | #ifdef DM_PARALLEL |
---|
660 | # include "HALO_NMM_A_2.inc" |
---|
661 | #endif |
---|
662 | #endif |
---|
663 | ! |
---|
664 | !----------------------------------------------------------------------- |
---|
665 | !*** USE THE FOLLOWING VARIABLES TO KEEP TRACK OF EXCHANGE TIMES. |
---|
666 | !----------------------------------------------------------------------- |
---|
667 | exch_tim=exch_tim+timef()-btimx |
---|
668 | ! this_tim=timef()-btimx |
---|
669 | ! call mpi_allreduce(this_tim,et_max,1,mpi_real,mpi_max & |
---|
670 | ! & ,mpi_comm_comp,irtn) |
---|
671 | ! exch_tim_max=exch_tim_max+et_max |
---|
672 | !----------------------------------------------------------------------- |
---|
673 | ! |
---|
674 | #ifdef HWRF |
---|
675 | !zhang's doing |
---|
676 | if(GRID%RESTART) then |
---|
677 | FIRST=.FALSE. |
---|
678 | else |
---|
679 | GO TO 2003 |
---|
680 | endif |
---|
681 | !end of zhang's doing |
---|
682 | #else |
---|
683 | GO TO 2003 |
---|
684 | #endif |
---|
685 | ENDIF |
---|
686 | ! |
---|
687 | !----------------------------------------------------------------------- |
---|
688 | !----------------------------------------------------------------------- |
---|
689 | 2000 CONTINUE |
---|
690 | !----------------------------------------------------------------------- |
---|
691 | !----------------------------------------------------------------------- |
---|
692 | #ifdef HWRF |
---|
693 | ! Coupling insertion:-> |
---|
694 | ! |
---|
695 | !zhang's doing call ATM_TSTEP_INIT(NTSD,grid%NPHS,GRID%ID,grid%NPHS*grid%dt, & |
---|
696 | call ATM_TSTEP_INIT(NTSD_current,grid%NPHS,GRID%ID,grid%NPHS*grid%dt, & |
---|
697 | !end of zhang's doing |
---|
698 | ids,idf,jds,jdf,its,ite,jts,jte,ims,ime,jms,jme, & |
---|
699 | kds,kde,kts,kte,kms,kme, & |
---|
700 | grid%HLON,grid%HLAT,grid%VLON,grid%VLAT,grid%sm, & |
---|
701 | grid%i_parent_start,grid%j_parent_start) |
---|
702 | ! CALL ATM_RECVdtc(NPHS*dt) <- now called from ATM_TSTEP_INIT with no arg. |
---|
703 | ! CALL ATM_SENDGRIDS(HLON,HLAT,VLON,VLAT) <- now called from ATM_TSTEP_INIT |
---|
704 | ! CALL ATM_SENDSLM(grid%sm) <- now called from ATM_TSTEP_INIT |
---|
705 | !<-:coupling insertion |
---|
706 | ! |
---|
707 | #endif |
---|
708 | !----------------------------------------------------------------------- |
---|
709 | !*** PRESSURE TENDENCY, SIGMA DOT, VERTICAL PART OF OMEGA-ALPHA |
---|
710 | !----------------------------------------------------------------------- |
---|
711 | ! |
---|
712 | btimx=timef() |
---|
713 | !----------------- |
---|
714 | #ifdef DM_PARALLEL |
---|
715 | # include "HALO_NMM_D.inc" |
---|
716 | #endif |
---|
717 | !----------------- |
---|
718 | exch_tim=exch_tim+timef()-btimx |
---|
719 | ! this_tim=timef()-btimx |
---|
720 | ! call mpi_allreduce(this_tim,et_max,1,mpi_real,mpi_max & |
---|
721 | ! & ,mpi_comm_comp,irtn) |
---|
722 | ! exch_tim_max=exch_tim_max+et_max |
---|
723 | ! |
---|
724 | btimx=timef() |
---|
725 | ! |
---|
726 | CALL PDTE( & |
---|
727 | #ifdef DM_PARALLEL |
---|
728 | & GRID,MYPE,MPI_COMM_COMP, & |
---|
729 | #endif |
---|
730 | & grid%ntsd,GRID%DT,grid%pt,grid%eta2,grid%res,grid%hydro,grid%hbm2 & |
---|
731 | & ,grid%pd,grid%pdsl,grid%pdslo & |
---|
732 | & ,grid%petdt,grid%div,grid%psdt & |
---|
733 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
734 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
735 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
736 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
737 | |
---|
738 | |
---|
739 | pdte_tim=pdte_tim+timef()-btimx |
---|
740 | ! |
---|
741 | !----------------------------------------------------------------------- |
---|
742 | !*** ADVECTION OF grid%t, grid%u, AND grid%v |
---|
743 | !----------------------------------------------------------------------- |
---|
744 | ! |
---|
745 | btimx=timef() |
---|
746 | !----------------- |
---|
747 | #ifdef DM_PARALLEL |
---|
748 | # include "HALO_NMM_F.inc" |
---|
749 | # include "HALO_NMM_F1.inc" |
---|
750 | #endif |
---|
751 | !----------------- |
---|
752 | exch_tim=exch_tim+timef()-btimx |
---|
753 | ! this_tim=timef()-btimx |
---|
754 | ! call mpi_allreduce(this_tim,et_max,1,mpi_real,mpi_max & |
---|
755 | ! & ,mpi_comm_comp,irtn) |
---|
756 | ! exch_tim_max=exch_tim_max+et_max |
---|
757 | btimx=timef() |
---|
758 | ! |
---|
759 | CALL ADVE(grid%ntsd,GRID%DT,grid%deta1,grid%deta2,grid%pdtop & |
---|
760 | & ,grid%curv,grid%f,grid%fad,grid%f4d,grid%em_loc,grid%emt_loc,grid%en,grid%ent,grid%dx_nmm,grid%dy_nmm & |
---|
761 | & ,grid%hbm2,grid%vbm2 & |
---|
762 | & ,grid%t,grid%u,grid%v,grid%pdslo,grid%told,grid%uold,grid%vold & |
---|
763 | & ,grid%petdt,grid%upstrm & |
---|
764 | & ,grid%few,grid%fns,grid%fne,grid%fse & |
---|
765 | & ,grid%adt,grid%adu,grid%adv & |
---|
766 | & ,grid%n_iup_h,grid%n_iup_v & |
---|
767 | & ,grid%n_iup_adh,grid%n_iup_adv & |
---|
768 | & ,grid%iup_h,grid%iup_v,grid%iup_adh,grid%iup_adv & |
---|
769 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
770 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
771 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
772 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
773 | ! |
---|
774 | adve_tim=adve_tim+timef()-btimx |
---|
775 | ! |
---|
776 | !----------------------------------------------------------------------- |
---|
777 | !*** PASSIVE SUBSTANCE WORKING PART |
---|
778 | !----------------------------------------------------------------------- |
---|
779 | ! |
---|
780 | eulerian: IF(EULER) THEN ! Eulerian advection for model tracers |
---|
781 | ! |
---|
782 | !----------------------------------------------------------------------- |
---|
783 | ! |
---|
784 | !mp - allow for it to be applied in the no-physics realm |
---|
785 | IF(config_flags%MP_PHYSICS/=ETAMPNEW.and.CONFIG_FLAGS%MP_PHYSICS/=ETAMP_HWRF.and.CONFIG_FLAGS%MP_PHYSICS/=0) THEN |
---|
786 | WRITE( wrf_err_message , * ) 'EULER advection works only with ETAMPNEW microphysics.' |
---|
787 | CALL wrf_error_fatal ( wrf_err_message ) |
---|
788 | ENDIF |
---|
789 | ! |
---|
790 | !----------------------------------------------------------------------- |
---|
791 | idtadt_block: IF(MOD(grid%ntsd,IDTADT)==0) THEN |
---|
792 | !----------------------------------------------------------------------- |
---|
793 | btimx=timef() |
---|
794 | #ifdef DM_PARALLEL |
---|
795 | # include "HALO_NMM_I.inc" |
---|
796 | #endif |
---|
797 | exch_tim=exch_tim+timef()-btimx |
---|
798 | ! |
---|
799 | btimx=timef() |
---|
800 | ! |
---|
801 | DO K=KTS,KTE |
---|
802 | DO J=JMS,JME |
---|
803 | DO I=IMS,IME |
---|
804 | SZJ(I,J,K,P_SPZ1)=MAX(grid%q (I,J,K),EPSQ) |
---|
805 | SZJ(I,J,K,P_SPZ2)=MAX(grid%cwm(I,J,K),EPSQ) |
---|
806 | SZJ(I,J,K,P_SPZ4)=MAX(grid%rrw(I,J,K),0. ) |
---|
807 | ENDDO |
---|
808 | ENDDO |
---|
809 | ENDDO |
---|
810 | ! |
---|
811 | DO J=JMS,JME |
---|
812 | DO I=IMS,IME |
---|
813 | SZJ(I,J,KTE,P_SPZ3)=MAX((grid%q2 (I,J,KTE)+EPSQ2)*0.5,EPSQ2) |
---|
814 | ENDDO |
---|
815 | ENDDO |
---|
816 | ! |
---|
817 | DO K=KTE-1,KTS,-1 |
---|
818 | DO J=JMS,JME |
---|
819 | DO I=IMS,IME |
---|
820 | SZJ(I,J,K,P_SPZ3)=MAX((grid%q2 (I,J,K)+grid%q2 (I,J,K+1))*0.5,EPSQ2) |
---|
821 | ENDDO |
---|
822 | ENDDO |
---|
823 | ENDDO |
---|
824 | ! |
---|
825 | #ifdef DM_PARALLEL |
---|
826 | # include "HALO_TRACERS.inc" |
---|
827 | #endif |
---|
828 | CALL ADV2 & |
---|
829 | (grid%upstrm & |
---|
830 | ,MYPE,PARAM_FIRST_SCALAR,NUM_SZJ & |
---|
831 | ,IDS,IDE,JDS,JDE,KDS,KDE & |
---|
832 | ,IMS,IME,JMS,JME,KMS,KME & |
---|
833 | ,ITS,ITE,JTS,JTE,KTS,KTE & |
---|
834 | ,grid%n_iup_h & |
---|
835 | ,grid%n_iup_adh & |
---|
836 | ,grid%iup_h,grid%iup_adh & |
---|
837 | ,grid%ent & |
---|
838 | ,IDTADT & |
---|
839 | ,grid%DT,grid%pdtop & |
---|
840 | ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
841 | ,grid%deta1,grid%deta2 & |
---|
842 | ,grid%emt_loc & |
---|
843 | ,grid%fad,grid%hbm2,grid%pdsl,grid%pdslo & |
---|
844 | ,grid%petdt & |
---|
845 | ,grid%uold,grid%vold & |
---|
846 | ,SZJ,SPZ & |
---|
847 | !temporary arguments |
---|
848 | ,grid%fne,grid%fse,grid%few,grid%fns,S1Z,TCS) |
---|
849 | ! |
---|
850 | #ifdef DM_PARALLEL |
---|
851 | # include "HALO_TRACERS.inc" |
---|
852 | #endif |
---|
853 | CALL MONO & |
---|
854 | ( & |
---|
855 | #if defined(DM_PARALLEL) |
---|
856 | GRID%DOMDESC, & |
---|
857 | #endif |
---|
858 | MYPE,grid%ntsd,grid%ntsd*GRID%DT/3600.,PARAM_FIRST_SCALAR,NUM_SZJ & |
---|
859 | ,IDS,IDE,JDS,JDE,KDS,KDE & |
---|
860 | ,IMS,IME,JMS,JME,KMS,KME & |
---|
861 | ,ITS,ITE,JTS,JTE,KTS,KTE & |
---|
862 | ,IDTADT & |
---|
863 | ,grid%dy_nmm,grid%pdtop & |
---|
864 | ,SUMDRRW & |
---|
865 | ,grid%ihe,grid%ihw & |
---|
866 | ,grid%deta1,grid%deta2 & |
---|
867 | ,grid%dx_nmm,grid%hbm2,grid%pdsl & |
---|
868 | ,SZJ & |
---|
869 | !temporary arguments |
---|
870 | ,S1Z,TCS) |
---|
871 | ! |
---|
872 | DO KS=PARAM_FIRST_SCALAR,NUM_SZJ ! loop by species |
---|
873 | DO K=KTS,KTE |
---|
874 | DO J=MYJS2,MYJE2 |
---|
875 | DO I=MYIS1,MYIE1 |
---|
876 | SZJ(I,J,K,KS)=SZJ(I,J,K,KS)+TCS(I,J,K,KS) |
---|
877 | ENDDO |
---|
878 | ENDDO |
---|
879 | ENDDO |
---|
880 | ENDDO ! end of the loop by the species |
---|
881 | ! |
---|
882 | DO K=KTS,KTE |
---|
883 | DO J=MYJS2,MYJE2 |
---|
884 | DO I=MYIS1,MYIE1 |
---|
885 | grid%q (I,J,K)=SZJ(I,J,K,P_SZJ1) |
---|
886 | grid%cwm(I,J,K)=SZJ(I,J,K,P_SZJ2) |
---|
887 | grid%rrw(I,J,K)=SZJ(I,J,K,P_SZJ4) |
---|
888 | ENDDO |
---|
889 | ENDDO |
---|
890 | ENDDO |
---|
891 | ! |
---|
892 | DO J=MYJS2,MYJE2 |
---|
893 | DO I=MYIS1,MYIE1 |
---|
894 | grid%q2(I,J,KTE)=MAX(SZJ(I,J,KTE,P_SZJ3)+SZJ(I,J,KTE,P_SZJ3)-EPSQ2 & |
---|
895 | ,EPSQ2) |
---|
896 | ENDDO |
---|
897 | ENDDO |
---|
898 | ! |
---|
899 | DO K=KTE-1,KTS+1,-1 |
---|
900 | DO J=MYJS2,MYJE2 |
---|
901 | DO I=MYIS1,MYIE1 |
---|
902 | IF(K>KTS)THEN |
---|
903 | grid%q2(I,J,K)=MAX(SZJ(I,J,K,P_SZJ3)+SZJ(I,J,K,P_SZJ3)-grid%q2(I,J,K+1) & |
---|
904 | ,EPSQ2) |
---|
905 | ELSE |
---|
906 | grid%q2(I,J,K)=grid%q2(I,J,K+1) |
---|
907 | ENDIF |
---|
908 | ENDDO |
---|
909 | ENDDO |
---|
910 | ENDDO |
---|
911 | !----------------------------------------------------------------------- |
---|
912 | |
---|
913 | ! |
---|
914 | !*** UPDATE MOIST ARRAY. |
---|
915 | !*** REMEMBER THAT MOIST IS ONLY USED WITH THE PHYSICS AND THUS |
---|
916 | !*** THE P_QV SLOT (=2) IS MIXING RATIO, NOT SPECIFIC HUMIDITY. |
---|
917 | !*** ALTHOUGH MOIST IS ONLY USED FOR PHYSICS IN OPERATIONS, IT IS |
---|
918 | !*** UPDATED HERE FROM grid%q EVERY ADVECTION TIMESTEP FOR NON-OPERATIONAL |
---|
919 | !*** CONFIGURATIONS WHERE IT MAY BE USED OUTSIDE OF THE PHYSICS. |
---|
920 | ! |
---|
921 | IF(.NOT.OPERATIONAL_PHYSICS)THEN |
---|
922 | DO K=KTS,KTE |
---|
923 | DO J=MYJS,MYJE |
---|
924 | DO I=MYIS,MYIE |
---|
925 | MOIST(I,J,K,P_QV)=grid%q(I,J,K)/(1.-grid%q(I,J,K)) |
---|
926 | WC = grid%cwm(I,J,K) |
---|
927 | QI = 0. |
---|
928 | QR = 0. |
---|
929 | QW = 0. |
---|
930 | FICE=grid%f_ice(I,K,J) |
---|
931 | FRAIN=grid%f_rain(I,K,J) |
---|
932 | ! |
---|
933 | IF(FICE>=1.)THEN |
---|
934 | QI=WC |
---|
935 | ELSEIF(FICE<=0.)THEN |
---|
936 | QW=WC |
---|
937 | ELSE |
---|
938 | QI=FICE*WC |
---|
939 | QW=WC-QI |
---|
940 | ENDIF |
---|
941 | ! |
---|
942 | IF(QW>0..AND.FRAIN>0.)THEN |
---|
943 | IF(FRAIN>=1.)THEN |
---|
944 | QR=QW |
---|
945 | QW=0. |
---|
946 | ELSE |
---|
947 | QR=FRAIN*QW |
---|
948 | QW=QW-QR |
---|
949 | ENDIF |
---|
950 | ENDIF |
---|
951 | ! |
---|
952 | MOIST(I,J,K,P_QC)=QW |
---|
953 | MOIST(I,J,K,P_QR)=QR |
---|
954 | MOIST(I,J,K,P_QI)=0. |
---|
955 | MOIST(I,J,K,P_QS)=QI |
---|
956 | MOIST(I,J,K,P_QG)=0. |
---|
957 | ENDDO |
---|
958 | ENDDO |
---|
959 | ENDDO |
---|
960 | ENDIF |
---|
961 | ! |
---|
962 | had2_tim=had2_tim+timef()-btimx |
---|
963 | !----------------------------------------------------------------------- |
---|
964 | ! |
---|
965 | ENDIF idtadt_block |
---|
966 | ! |
---|
967 | !----------------------------------------------------------------------- |
---|
968 | ! |
---|
969 | ENDIF eulerian ! eulerian advection for model tracers |
---|
970 | ! |
---|
971 | !----------------------------------------------------------------------- |
---|
972 | ! |
---|
973 | #ifdef WRF_CHEM |
---|
974 | !----------------------------------------------------------------------- |
---|
975 | ! |
---|
976 | idtadc_block: IF(MOD(grid%ntsd,IDTADC)==0) THEN |
---|
977 | ! |
---|
978 | !----------------------------------------------------------------------- |
---|
979 | btimx=timef() |
---|
980 | #ifdef DM_PARALLEL |
---|
981 | # include "HALO_NMM_I_2.inc" |
---|
982 | #endif |
---|
983 | exch_tim=exch_tim+timef()-btimx |
---|
984 | ! |
---|
985 | btimx=timef() |
---|
986 | ! |
---|
987 | do KS=1,NUM_CHEM |
---|
988 | DO K=KTS,KTE |
---|
989 | DO J=JMS,JME |
---|
990 | DO I=IMS,IME |
---|
991 | CHE(I,J,K,KS)=MAX(CHEM(I,K,J,KS),0. ) |
---|
992 | ENDDO |
---|
993 | ENDDO |
---|
994 | ENDDO |
---|
995 | ENDDO |
---|
996 | ! |
---|
997 | CALL ADV2 & |
---|
998 | (grid%upstrm & |
---|
999 | ,MYPE,1,NUM_CHEM & |
---|
1000 | ,IDS,IDE,JDS,JDE,KDS,KDE & |
---|
1001 | ,IMS,IME,JMS,JME,KMS,KME & |
---|
1002 | ,ITS,ITE,JTS,JTE,KTS,KTE & |
---|
1003 | ,grid%n_iup_h & |
---|
1004 | ,grid%n_iup_adh & |
---|
1005 | ,grid%iup_h,grid%iup_adh & |
---|
1006 | ,grid%ent & |
---|
1007 | ,IDTADC & |
---|
1008 | ,grid%DT,grid%pdtop & |
---|
1009 | ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
1010 | ,grid%deta1,grid%deta2 & |
---|
1011 | ,grid%emt_loc & |
---|
1012 | ,grid%fad,grid%hbm2,grid%pdsl,grid%pdslo & |
---|
1013 | ,grid%petdt & |
---|
1014 | ,grid%uold,grid%vold & |
---|
1015 | ,CHE,CHP & |
---|
1016 | !temporary arguments |
---|
1017 | ,grid%fne,grid%fse,grid%few,grid%fns,CH1,TCC) |
---|
1018 | ! |
---|
1019 | CALL MONO & |
---|
1020 | ( & |
---|
1021 | #if defined(DM_PARALLEL) |
---|
1022 | GRID%DOMDESC, & |
---|
1023 | #endif |
---|
1024 | MYPE,grid%ntsd,grid%ntsd*GRID%DT/3600.,1,NUM_CHEM & |
---|
1025 | ,IDS,IDE,JDS,JDE,KDS,KDE & |
---|
1026 | ,IMS,IME,JMS,JME,KMS,KME & |
---|
1027 | ,ITS,ITE,JTS,JTE,KTS,KTE & |
---|
1028 | ,IDTADT & |
---|
1029 | ,grid%dy_nmm,grid%pdtop & |
---|
1030 | ,SUMDRRW & |
---|
1031 | ,grid%ihe,grid%ihw & |
---|
1032 | ,grid%deta1,grid%deta2 & |
---|
1033 | ,grid%dx_nmm,grid%hbm2,grid%pdsl & |
---|
1034 | ,CHE & |
---|
1035 | !temporary arguments |
---|
1036 | ,CH1,TCC) |
---|
1037 | ! |
---|
1038 | DO KS=1,NUM_CHEM |
---|
1039 | DO K=KTS,KTE |
---|
1040 | DO J=JMS,JME |
---|
1041 | DO I=IMS,IME |
---|
1042 | CHEM(I,K,J,KS)=CHE(I,J,K,KS)+TCC(I,J,K,KS) |
---|
1043 | ENDDO |
---|
1044 | ENDDO |
---|
1045 | ENDDO |
---|
1046 | ENDDO |
---|
1047 | !----------------------------------------------------------------------- |
---|
1048 | ! |
---|
1049 | ENDIF idtadc_block |
---|
1050 | ! |
---|
1051 | !----------------------------------------------------------------------- |
---|
1052 | #endif |
---|
1053 | ! |
---|
1054 | !----------------------------------------------------------------------- |
---|
1055 | !*** PRESSURE TENDENCY, ETA/SIGMADOT, VERTICAL PART OF OMEGA-ALPHA TERM |
---|
1056 | !----------------------------------------------------------------------- |
---|
1057 | ! |
---|
1058 | btimx=timef() |
---|
1059 | ! |
---|
1060 | CALL VTOA( & |
---|
1061 | #ifdef DM_PARALLEL |
---|
1062 | & GRID, & |
---|
1063 | #endif |
---|
1064 | & grid%ntsd,GRID%DT,grid%pt,grid%eta2 & |
---|
1065 | & ,grid%hbm2,grid%ef4t & |
---|
1066 | & ,grid%t,grid%dwdt,grid%rtop,grid%omgalf & |
---|
1067 | & ,grid%pint,grid%div,grid%psdt,grid%res & |
---|
1068 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
1069 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1070 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1071 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1072 | ! |
---|
1073 | vtoa_tim=vtoa_tim+timef()-btimx |
---|
1074 | ! |
---|
1075 | !----------------------------------------------------------------------- |
---|
1076 | !*** VERTICAL ADVECTION OF HEIGHT |
---|
1077 | !----------------------------------------------------------------------- |
---|
1078 | ! |
---|
1079 | btimx=timef() |
---|
1080 | ! |
---|
1081 | |
---|
1082 | |
---|
1083 | |
---|
1084 | CALL VADZ(grid%ntsd,GRID%DT,grid%fis,GRID%SIGMA,grid%dfl,grid%hbm2 & |
---|
1085 | & ,grid%deta1,grid%deta2,grid%pdtop & |
---|
1086 | & ,grid%pint,grid%pdsl,grid%pdslo,grid%petdt & |
---|
1087 | & ,grid%rtop,grid%t,grid%q,grid%cwm,grid%z,grid%w,grid%dwdt,grid%pdwdt & |
---|
1088 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
1089 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1090 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1091 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1092 | |
---|
1093 | vadz_tim=vadz_tim+timef()-btimx |
---|
1094 | ! |
---|
1095 | !----------------------------------------------------------------------- |
---|
1096 | !*** HORIZONTAL ADVECTION OF HEIGHT |
---|
1097 | !----------------------------------------------------------------------- |
---|
1098 | ! |
---|
1099 | btimx=timef() |
---|
1100 | !----------------- |
---|
1101 | #ifdef DM_PARALLEL |
---|
1102 | # include "HALO_NMM_G.inc" |
---|
1103 | #endif |
---|
1104 | !----------------- |
---|
1105 | exch_tim=exch_tim+timef()-btimx |
---|
1106 | ! this_tim=timef()-btimx |
---|
1107 | ! call mpi_allreduce(this_tim,et_max,1,mpi_real,mpi_max & |
---|
1108 | ! & ,mpi_comm_comp,irtn) |
---|
1109 | ! exch_tim_max=exch_tim_max+et_max |
---|
1110 | ! |
---|
1111 | btimx=timef() |
---|
1112 | ! |
---|
1113 | CALL HADZ(grid%ntsd,GRID%DT,grid%hydro,grid%hbm2,grid%deta1,grid%deta2,grid%pdtop & |
---|
1114 | & ,grid%dx_nmm,grid%dy_nmm,grid%fad & |
---|
1115 | & ,grid%few,grid%fns,grid%fne,grid%fse & |
---|
1116 | & ,grid%pdsl,grid%u,grid%v,grid%w,grid%z,WP & |
---|
1117 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
1118 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1119 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1120 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1121 | ! |
---|
1122 | hadz_tim=hadz_tim+timef()-btimx |
---|
1123 | ! |
---|
1124 | !----------------------------------------------------------------------- |
---|
1125 | !*** ADVECTION OF grid%w |
---|
1126 | !----------------------------------------------------------------------- |
---|
1127 | ! |
---|
1128 | btimx=timef() |
---|
1129 | !----------------- |
---|
1130 | #ifdef DM_PARALLEL |
---|
1131 | # include "HALO_NMM_H.inc" |
---|
1132 | #endif |
---|
1133 | !----------------- |
---|
1134 | exch_tim=exch_tim+timef()-btimx |
---|
1135 | ! this_tim=timef()-btimx |
---|
1136 | ! call mpi_allreduce(this_tim,et_max,1,mpi_real,mpi_max & |
---|
1137 | ! & ,mpi_comm_comp,irtn) |
---|
1138 | ! exch_tim_max=exch_tim_max+et_max |
---|
1139 | ! |
---|
1140 | btimx=timef() |
---|
1141 | ! |
---|
1142 | |
---|
1143 | CALL EPS(grid%ntsd,GRID%DT,grid%hydro,grid%dx_nmm,grid%dy_nmm,grid%fad & |
---|
1144 | & ,grid%deta1,grid%deta2,grid%pdtop,grid%pt & |
---|
1145 | & ,grid%hbm2,grid%hbm3 & |
---|
1146 | & ,grid%pdsl,grid%pdslo,grid%pint,grid%rtop,grid%petdt,grid%pdwdt & |
---|
1147 | & ,grid%dwdt,grid%dwdtmn,grid%dwdtmx & |
---|
1148 | & ,grid%fns,grid%few,grid%fne,grid%fse & |
---|
1149 | & ,grid%t,grid%u,grid%v,grid%w,grid%q,grid%cwm & |
---|
1150 | & ,grid%def3d,grid%hdac & |
---|
1151 | & ,WP & |
---|
1152 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
1153 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1154 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1155 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1156 | ! |
---|
1157 | eps_tim=eps_tim+timef()-btimx |
---|
1158 | ! |
---|
1159 | !----------------------------------------------------------------------- |
---|
1160 | ! |
---|
1161 | not_euler: IF(.NOT.EULER) THEN ! Lagrangian model tracer advection |
---|
1162 | ! |
---|
1163 | !----------------------------------------------------------------------- |
---|
1164 | !*** VERTICAL ADVECTION OF grid%q, TKE, AND CLOUD WATER |
---|
1165 | !----------------------------------------------------------------------- |
---|
1166 | ! |
---|
1167 | IF(MOD(grid%ntsd,GRID%IDTAD)==0)THEN |
---|
1168 | btimx=timef() |
---|
1169 | ! |
---|
1170 | vad2_micro_check: IF(CONFIG_FLAGS%MP_PHYSICS==ETAMPNEW.or.CONFIG_FLAGS%MP_PHYSICS==ETAMP_HWRF)THEN |
---|
1171 | CALL VAD2(grid%ntsd,GRID%DT,GRID%IDTAD,grid%dx_nmm,grid%dy_nmm & |
---|
1172 | & ,grid%aeta1,grid%aeta2,grid%deta1,grid%deta2,grid%pdsl,grid%pdtop,grid%hbm2 & |
---|
1173 | & ,grid%q,grid%q2,grid%cwm,grid%petdt & |
---|
1174 | & ,grid%n_iup_h,grid%n_iup_v & |
---|
1175 | & ,grid%n_iup_adh,grid%n_iup_adv & |
---|
1176 | & ,grid%iup_h,grid%iup_v,grid%iup_adh,grid%iup_adv & |
---|
1177 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
1178 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1179 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1180 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1181 | ! |
---|
1182 | ELSE vad2_micro_check |
---|
1183 | CALL VAD2_SCAL(grid%ntsd,GRID%DT,GRID%IDTAD,grid%dx_nmm,grid%dy_nmm & |
---|
1184 | & ,grid%aeta1,grid%aeta2,grid%deta1,grid%deta2,grid%pdsl,grid%pdtop & |
---|
1185 | & ,grid%hbm2 & |
---|
1186 | & ,grid%q2,grid%petdt & |
---|
1187 | & ,grid%n_iup_h,grid%n_iup_v & |
---|
1188 | & ,grid%n_iup_adh,grid%n_iup_adv & |
---|
1189 | & ,grid%iup_h,grid%iup_v,grid%iup_adh,grid%iup_adv & |
---|
1190 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
1191 | & ,1,1 & |
---|
1192 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1193 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1194 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1195 | |
---|
1196 | CALL VAD2_SCAL(grid%ntsd,GRID%DT,GRID%IDTAD,grid%dx_nmm,grid%dy_nmm & |
---|
1197 | & ,grid%aeta1,grid%aeta2,grid%deta1,grid%deta2,grid%pdsl,grid%pdtop & |
---|
1198 | & ,grid%hbm2 & |
---|
1199 | & ,MOIST,grid%petdt & |
---|
1200 | & ,grid%n_iup_h,grid%n_iup_v & |
---|
1201 | & ,grid%n_iup_adh,grid%n_iup_adv & |
---|
1202 | & ,grid%iup_h,grid%iup_v,grid%iup_adh,grid%iup_adv & |
---|
1203 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
1204 | & ,NUM_MOIST,2 & |
---|
1205 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1206 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1207 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1208 | ! |
---|
1209 | CALL VAD2_SCAL(grid%ntsd,GRID%DT,GRID%IDTAD,grid%dx_nmm,grid%dy_nmm & |
---|
1210 | & ,grid%aeta1,grid%aeta2,grid%deta1,grid%deta2,grid%pdsl,grid%pdtop & |
---|
1211 | & ,grid%hbm2 & |
---|
1212 | & ,SCALAR,grid%petdt & |
---|
1213 | & ,grid%n_iup_h,grid%n_iup_v & |
---|
1214 | & ,grid%n_iup_adh,grid%n_iup_adv & |
---|
1215 | & ,grid%iup_h,grid%iup_v,grid%iup_adh,grid%iup_adv & |
---|
1216 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
1217 | & ,NUM_SCALAR,2 & |
---|
1218 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1219 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1220 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1221 | ! |
---|
1222 | |
---|
1223 | DO K=KTS,KTE |
---|
1224 | DO J=MYJS,MYJE |
---|
1225 | DO I=MYIS,MYIE |
---|
1226 | grid%q(I,J,K)=MOIST(I,J,K,P_QV)/(1.+MOIST(I,J,K,P_QV)) |
---|
1227 | ENDDO |
---|
1228 | ENDDO |
---|
1229 | ENDDO |
---|
1230 | ! |
---|
1231 | ENDIF vad2_micro_check |
---|
1232 | ! |
---|
1233 | vad2_tim=vad2_tim+timef()-btimx |
---|
1234 | ! |
---|
1235 | ENDIF |
---|
1236 | ! |
---|
1237 | !----------------------------------------------------------------------- |
---|
1238 | !*** HORIZONTAL ADVECTION OF grid%q, TKE, AND CLOUD WATER |
---|
1239 | !----------------------------------------------------------------------- |
---|
1240 | ! |
---|
1241 | idtad_block: IF(MOD(grid%ntsd,GRID%IDTAD)==0)THEN |
---|
1242 | btimx=timef() |
---|
1243 | !----------------- |
---|
1244 | #ifdef DM_PARALLEL |
---|
1245 | # include "HALO_NMM_I.inc" |
---|
1246 | #endif |
---|
1247 | ! |
---|
1248 | #ifdef DM_PARALLEL |
---|
1249 | IF(CONFIG_FLAGS%MP_PHYSICS/=ETAMPNEW.and.CONFIG_FLAGS%MP_PHYSICS/=ETAMP_HWRF)THEN |
---|
1250 | # include "HALO_NMM_I_3.inc" |
---|
1251 | ENDIF |
---|
1252 | #endif |
---|
1253 | ! |
---|
1254 | !----------------- |
---|
1255 | exch_tim=exch_tim+timef()-btimx |
---|
1256 | ! this_tim=timef()-btimx |
---|
1257 | ! call mpi_allreduce(this_tim,et_max,1,mpi_real,mpi_max & |
---|
1258 | ! & ,mpi_comm_comp,irtn) |
---|
1259 | ! exch_tim_max=exch_tim_max+et_max |
---|
1260 | ! |
---|
1261 | btimx=timef() |
---|
1262 | ! |
---|
1263 | !----------------------------------------------------------------------- |
---|
1264 | had2_micro_check: IF(CONFIG_FLAGS%MP_PHYSICS==ETAMPNEW.or.CONFIG_FLAGS%MP_PHYSICS==ETAMP_HWRF)THEN |
---|
1265 | !----------------------------------------------------------------------- |
---|
1266 | ! |
---|
1267 | CALL HAD2( & |
---|
1268 | #if defined(DM_PARALLEL) |
---|
1269 | & GRID%DOMDESC, & |
---|
1270 | #endif |
---|
1271 | & grid%ntsd,GRID%DT,GRID%IDTAD,grid%dx_nmm,grid%dy_nmm & |
---|
1272 | & ,grid%aeta1,grid%aeta2,grid%deta1,grid%deta2,grid%pdsl,grid%pdtop & |
---|
1273 | & ,grid%hbm2,grid%hbm3 & |
---|
1274 | & ,grid%q,grid%q2,grid%cwm,grid%u,grid%v,grid%z,grid%hydro & |
---|
1275 | & ,grid%n_iup_h,grid%n_iup_v & |
---|
1276 | & ,grid%n_iup_adh,grid%n_iup_adv & |
---|
1277 | & ,grid%iup_h,grid%iup_v,grid%iup_adh,grid%iup_adv & |
---|
1278 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
1279 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1280 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1281 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1282 | ! |
---|
1283 | !*** UPDATE MOIST ARRAY. |
---|
1284 | !*** REMEMBER THAT MOIST IS ONLY USED WITH THE PHYSICS AND THUS |
---|
1285 | !*** THE P_QV SLOT (=2) IS MIXING RATIO, NOT SPECIFIC HUMIDITY. |
---|
1286 | !*** ALTHOUGH MOIST IS ONLY USED FOR PHYSICS IN OPERATIONS, IT IS |
---|
1287 | !*** UPDATED HERE FROM grid%q EVERY ADVECTION TIMESTEP FOR NON-OPERATIONAL |
---|
1288 | !*** CONFIGURATIONS WHERE IT MAY BE USED OUTSIDE OF THE PHYSICS. |
---|
1289 | ! |
---|
1290 | IF(.NOT.OPERATIONAL_PHYSICS)THEN |
---|
1291 | DO K=KTS,KTE |
---|
1292 | DO J=MYJS,MYJE |
---|
1293 | DO I=MYIS,MYIE |
---|
1294 | MOIST(I,J,K,P_QV)=grid%q(I,J,K)/(1.-grid%q(I,J,K)) |
---|
1295 | WC = grid%cwm(I,J,K) |
---|
1296 | QI = 0. |
---|
1297 | QR = 0. |
---|
1298 | QW = 0. |
---|
1299 | FICE=grid%f_ice(I,K,J) |
---|
1300 | FRAIN=grid%f_rain(I,K,J) |
---|
1301 | ! |
---|
1302 | IF(FICE>=1.)THEN |
---|
1303 | QI=WC |
---|
1304 | ELSEIF(FICE<=0.)THEN |
---|
1305 | QW=WC |
---|
1306 | ELSE |
---|
1307 | QI=FICE*WC |
---|
1308 | QW=WC-QI |
---|
1309 | ENDIF |
---|
1310 | ! |
---|
1311 | IF(QW>0..AND.FRAIN>0.)THEN |
---|
1312 | IF(FRAIN>=1.)THEN |
---|
1313 | QR=QW |
---|
1314 | QW=0. |
---|
1315 | ELSE |
---|
1316 | QR=FRAIN*QW |
---|
1317 | QW=QW-QR |
---|
1318 | ENDIF |
---|
1319 | ENDIF |
---|
1320 | ! |
---|
1321 | MOIST(I,J,K,P_QC)=QW |
---|
1322 | MOIST(I,J,K,P_QR)=QR |
---|
1323 | |
---|
1324 | if (CONFIG_FLAGS%MP_PHYSICS==ETAMPNEW.or.CONFIG_FLAGS%MP_PHYSICS==ETAMP_HWRF)then |
---|
1325 | #ifdef HWRF |
---|
1326 | MOIST(I,J,K,P_QI)=QI |
---|
1327 | MOIST(I,J,K,P_QS)=0. |
---|
1328 | #else |
---|
1329 | MOIST(I,J,K,P_QI)=0. |
---|
1330 | MOIST(I,J,K,P_QS)=QI |
---|
1331 | #endif |
---|
1332 | endif |
---|
1333 | MOIST(I,J,K,P_QG)=0. |
---|
1334 | ENDDO |
---|
1335 | ENDDO |
---|
1336 | ENDDO |
---|
1337 | ENDIF |
---|
1338 | ! |
---|
1339 | !----------------------------------------------------------------------- |
---|
1340 | ELSE had2_micro_check |
---|
1341 | !----------------------------------------------------------------------- |
---|
1342 | ! |
---|
1343 | CALL HAD2_SCAL( & |
---|
1344 | #if defined(DM_PARALLEL) |
---|
1345 | & GRID%DOMDESC, & |
---|
1346 | #endif |
---|
1347 | & grid%ntsd,GRID%DT,GRID%IDTAD,grid%dx_nmm,grid%dy_nmm & |
---|
1348 | & ,grid%aeta1,grid%aeta2,grid%deta1,grid%deta2,grid%pdsl,grid%pdtop & |
---|
1349 | & ,grid%hbm2,grid%hbm3 & |
---|
1350 | & ,grid%q2,grid%u,grid%v,grid%z,grid%hydro & |
---|
1351 | & ,grid%n_iup_h,grid%n_iup_v & |
---|
1352 | & ,grid%n_iup_adh,grid%n_iup_adv & |
---|
1353 | & ,grid%iup_h,grid%iup_v,grid%iup_adh,grid%iup_adv & |
---|
1354 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
1355 | & ,1,1 & |
---|
1356 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1357 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1358 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1359 | ! |
---|
1360 | CALL HAD2_SCAL( & |
---|
1361 | #if defined(DM_PARALLEL) |
---|
1362 | & GRID%DOMDESC, & |
---|
1363 | #endif |
---|
1364 | & grid%ntsd,GRID%DT,GRID%IDTAD,grid%dx_nmm,grid%dy_nmm & |
---|
1365 | & ,grid%aeta1,grid%aeta2,grid%deta1,grid%deta2,grid%pdsl,grid%pdtop & |
---|
1366 | & ,grid%hbm2,grid%hbm3 & |
---|
1367 | & ,MOIST,grid%u,grid%v,grid%z,grid%hydro & |
---|
1368 | & ,grid%n_iup_h,grid%n_iup_v & |
---|
1369 | & ,grid%n_iup_adh,grid%n_iup_adv & |
---|
1370 | & ,grid%iup_h,grid%iup_v,grid%iup_adh,grid%iup_adv & |
---|
1371 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
1372 | & ,NUM_MOIST,2 & |
---|
1373 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1374 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1375 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1376 | ! |
---|
1377 | CALL HAD2_SCAL( & |
---|
1378 | #if defined(DM_PARALLEL) |
---|
1379 | & GRID%DOMDESC, & |
---|
1380 | #endif |
---|
1381 | & grid%ntsd,GRID%DT,GRID%IDTAD,grid%dx_nmm,grid%dy_nmm & |
---|
1382 | & ,grid%aeta1,grid%aeta2,grid%deta1,grid%deta2,grid%pdsl,grid%pdtop & |
---|
1383 | & ,grid%hbm2,grid%hbm3 & |
---|
1384 | & ,SCALAR,grid%u,grid%v,grid%z,grid%hydro & |
---|
1385 | & ,grid%n_iup_h,grid%n_iup_v & |
---|
1386 | & ,grid%n_iup_adh,grid%n_iup_adv & |
---|
1387 | & ,grid%iup_h,grid%iup_v,grid%iup_adh,grid%iup_adv & |
---|
1388 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
1389 | & ,NUM_SCALAR,2 & |
---|
1390 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1391 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1392 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1393 | ! |
---|
1394 | DO K=KTS,KTE |
---|
1395 | DO J=MYJS,MYJE |
---|
1396 | DO I=MYIS,MYIE |
---|
1397 | grid%q(I,J,K)=MOIST(I,J,K,P_QV)/(1.+MOIST(I,J,K,P_QV)) |
---|
1398 | ENDDO |
---|
1399 | ENDDO |
---|
1400 | ENDDO |
---|
1401 | ! |
---|
1402 | !----------------------------------------------------------------------- |
---|
1403 | ENDIF had2_micro_check |
---|
1404 | !----------------------------------------------------------------------- |
---|
1405 | had2_tim=had2_tim+timef()-btimx |
---|
1406 | !----------------------------------------------------------------------- |
---|
1407 | ! |
---|
1408 | ENDIF idtad_block |
---|
1409 | ! |
---|
1410 | !---------------------------------------------------------------------- |
---|
1411 | ! |
---|
1412 | ENDIF not_euler ! Lagrangian model tracer advection |
---|
1413 | ! |
---|
1414 | !---------------------------------------------------------------------- |
---|
1415 | !*** RADIATION |
---|
1416 | !---------------------------------------------------------------------- |
---|
1417 | ! |
---|
1418 | !*** When allocating CAM radiation 4d arrays (ozmixm, aerosolc), |
---|
1419 | !*** the following two scalars are not needed. |
---|
1420 | ! |
---|
1421 | NUM_OZMIXM=1 |
---|
1422 | NUM_AEROSOLC=1 |
---|
1423 | ! |
---|
1424 | IF(grid%ntsd<=0)THEN |
---|
1425 | NTSD_rad=grid%ntsd |
---|
1426 | ELSE |
---|
1427 | ! |
---|
1428 | !*** Call radiation just BEFORE the top of the hour |
---|
1429 | !*** so that updated fields are written to history files. |
---|
1430 | ! |
---|
1431 | NTSD_rad=grid%ntsd+1 |
---|
1432 | ENDIF |
---|
1433 | ! |
---|
1434 | #ifdef HWRF |
---|
1435 | !emc_2010_bugfix_h50 |
---|
1436 | ! remove this - not needed for V3.2 |
---|
1437 | ! call nl_get_start_hour(1,IHRST) |
---|
1438 | !emc_2010_bugfix_h50 |
---|
1439 | #endif |
---|
1440 | |
---|
1441 | IF(MOD(NTSD_rad,GRID%NRADS)==0.OR. & |
---|
1442 | & MOD(NTSD_rad,GRID%NRADL)==0)THEN |
---|
1443 | ! |
---|
1444 | btimx=timef() |
---|
1445 | IF(OPERATIONAL_PHYSICS)THEN |
---|
1446 | CALL UPDATE_MOIST(MOIST,grid%q,grid%cwm,grid%f_ice,grid%f_rain,N_MOIST & |
---|
1447 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1448 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1449 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1450 | ENDIF |
---|
1451 | ! |
---|
1452 | CALL RADIATION(NTSD_rad,GRID%DT,GRID%JULDAY,GRID%JULYR & |
---|
1453 | & ,GRID%XTIME,GRID%JULIAN & |
---|
1454 | & ,IHRST,GRID%NPHS & |
---|
1455 | & ,grid%glat,grid%glon,GRID%NRADS,GRID%NRADL & |
---|
1456 | & ,grid%deta1,grid%deta2,grid%aeta1,grid%aeta2,grid%eta1,grid%eta2,grid%pdtop,grid%pt & |
---|
1457 | & ,grid%pd,grid%res,grid%pint,grid%t,grid%q,MOIST,grid%ths,grid%albedo,grid%epsr & |
---|
1458 | & ,grid%f_ice,grid%f_rain & |
---|
1459 | #ifdef WRF_CHEM |
---|
1460 | & ,GD_CLOUD,GD_CLOUD2 & |
---|
1461 | #endif |
---|
1462 | & ,grid%sm,grid%hbm2,grid%cldfra,N_MOIST,RESTRT & |
---|
1463 | & ,grid%rlwtt,grid%rswtt,grid%rlwin,grid%rswin,grid%rswinc,grid%rswout & |
---|
1464 | & ,grid%rlwtoa,grid%rswtoa,grid%czmean & |
---|
1465 | & ,grid%cfracl,grid%cfracm,grid%cfrach,grid%sigt4 & |
---|
1466 | & ,grid%acfrst,grid%ncfrst,grid%acfrcv,grid%ncfrcv & |
---|
1467 | & ,grid%cuppt,grid%vegfrc,grid%sno,grid%htop,grid%hbot & |
---|
1468 | & ,grid%z,grid%sice,NUM_AEROSOLC,NUM_OZMIXM & |
---|
1469 | & ,GRID,CONFIG_FLAGS & |
---|
1470 | & ,RTHRATEN & |
---|
1471 | #ifdef WRF_CHEM |
---|
1472 | & ,PM2_5_DRY, PM2_5_WATER, PM2_5_DRY_EC & |
---|
1473 | & ,TAUAER1, TAUAER2, TAUAER3, TAUAER4 & |
---|
1474 | & ,GAER1, GAER2, GAER3, GAER4 & |
---|
1475 | & ,WAER1, WAER2, WAER3, WAER4 & |
---|
1476 | #endif |
---|
1477 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1478 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1479 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1480 | ! |
---|
1481 | DO J=JMS,JME |
---|
1482 | DO I=IMS,IME |
---|
1483 | grid%gsw(I,J)=grid%rswin(I,J)-grid%rswout(I,J) |
---|
1484 | ENDDO |
---|
1485 | ENDDO |
---|
1486 | ! |
---|
1487 | ! *** NOTE *** |
---|
1488 | ! grid%rlwin/grid%rswin - downward longwave/shortwave at the surface (formerly TOTLWDN/TOTSWDN) |
---|
1489 | ! grid%rswinc - CLEAR-SKY downward shortwave at the surface (new for AQ) |
---|
1490 | ! *** NOTE *** |
---|
1491 | ! |
---|
1492 | radiation_tim=radiation_tim+timef()-btimx |
---|
1493 | ENDIF |
---|
1494 | ! |
---|
1495 | !---------------------------------------------------------------------- |
---|
1496 | !*** APPLY TEMPERATURE TENDENCY DUE TO RADIATION |
---|
1497 | !---------------------------------------------------------------------- |
---|
1498 | ! |
---|
1499 | btimx=timef() |
---|
1500 | ! |
---|
1501 | ! Pass in XTIME (elapsed time from start of parent) to compute |
---|
1502 | ! the time passed into the zenith angle code consistently between |
---|
1503 | ! RDTEMP and RADIATION. |
---|
1504 | |
---|
1505 | CALL RDTEMP(grid%ntsd,GRID%DT,GRID%JULDAY,GRID%JULYR & |
---|
1506 | & ,GRID%XTIME,IHRST,grid%glat,grid%glon & |
---|
1507 | & ,grid%czen,grid%czmean,grid%t,grid%rswtt,grid%rlwtt,grid%hbm2 & |
---|
1508 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1509 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1510 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1511 | ! |
---|
1512 | rdtemp_tim=rdtemp_tim+timef()-btimx |
---|
1513 | ! |
---|
1514 | ! |
---|
1515 | #ifdef HWRF |
---|
1516 | ! |
---|
1517 | !------------------------------------------------------------------------------------- |
---|
1518 | !*** GET SSTs FROM DMITRY's COUPLER ON TO THE PARENT AND NESTED GRID |
---|
1519 | !------------------------------------------------------------------------------------- |
---|
1520 | ! Coupling insertion:-> |
---|
1521 | CALL ATM_GETSST(grid%sst,grid%sm) |
---|
1522 | !<-:Coupling insertion |
---|
1523 | IF(GRID%ID .EQ. 1 .AND. MOD(grid%ntsd,grid%NPHS)==0)THEN |
---|
1524 | btimx=timef() |
---|
1525 | sst_tim=sst_tim+timef()-btimx |
---|
1526 | ENDIF |
---|
1527 | |
---|
1528 | #endif |
---|
1529 | !---------------------------------------------------------------------- |
---|
1530 | !*** TURBULENT PROCESSES |
---|
1531 | !---------------------------------------------------------------------- |
---|
1532 | ! |
---|
1533 | IF(MOD(grid%ntsd,GRID%NPHS)==0)THEN |
---|
1534 | ! |
---|
1535 | btimx=timef() |
---|
1536 | ! |
---|
1537 | IF(OPERATIONAL_PHYSICS & |
---|
1538 | & .AND.MOD(NTSD_rad,GRID%NRADS)/=0 & |
---|
1539 | & .AND.MOD(NTSD_rad,GRID%NRADL)/=0)THEN |
---|
1540 | CALL UPDATE_MOIST(MOIST,grid%q,grid%cwm,grid%f_ice,grid%f_rain,N_MOIST & |
---|
1541 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1542 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1543 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1544 | ENDIF |
---|
1545 | ! |
---|
1546 | CALL TURBL(grid%ntsd,GRID%DT,GRID%NPHS,RESTRT & |
---|
1547 | & ,N_MOIST,GRID%NUM_SOIL_LAYERS,grid%sldpth,grid%dzsoil & |
---|
1548 | & ,grid%deta1,grid%deta2,grid%aeta1,grid%aeta2,grid%eta1,grid%eta2,grid%pdtop,grid%pt & |
---|
1549 | & ,grid%sm,grid%hbm2,grid%vbm2,grid%dx_nmm,grid%dfrlg & |
---|
1550 | & ,grid%czen,grid%czmean,grid%sigt4,grid%rlwin,grid%rswin,grid%radot & |
---|
1551 | & ,grid%pd,grid%res,grid%pint,grid%t,grid%q,grid%cwm,grid%f_ice,grid%f_rain,grid%sr & |
---|
1552 | & ,grid%q2,grid%u,grid%v,grid%ths,grid%nmm_tsk,grid%sst,grid%prec,grid%sno & |
---|
1553 | & ,grid%fis,grid%z0,grid%z0base,grid%ustar,grid%mixht,grid%pblh,grid%lpbl,grid%el_pbl & !PLee (3/07) |
---|
1554 | & ,MOIST,grid%rmol,grid%mol & |
---|
1555 | & ,grid%exch_h,grid%exch_m,grid%f,grid%akhs,grid%akms,grid%akhs_out,grid%akms_out & |
---|
1556 | & ,grid%thz0,grid%qz0,grid%uz0,grid%vz0,grid%qsh,grid%mavail & |
---|
1557 | & ,grid%stc,grid%smc,grid%cmc,grid%smstav,grid%smstot,grid%ssroff,grid%bgroff & |
---|
1558 | & ,grid%ivgtyp,grid%isltyp,grid%vegfrc,grid%shdmin,grid%shdmax,grid%grnflx & |
---|
1559 | & ,grid%snotime & |
---|
1560 | & ,grid%sfcexc,grid%acsnow,grid%acsnom,grid%snopcx,grid%sice,grid%tg,grid%soiltb & |
---|
1561 | & ,grid%albase,grid%mxsnal,grid%albedo,grid%sh2o,grid%si,grid%epsr,grid%embck & |
---|
1562 | & ,grid%u10,grid%v10,grid%th10,grid%q10,grid%tshltr,grid%qshltr,grid%pshltr & |
---|
1563 | & ,grid%t2,grid%qsg,grid%qvg,grid%qcg,grid%soilt1,grid%tsnav,grid%smfr3d,grid%keepfr3dflag & |
---|
1564 | #if (NMM_CORE==1) |
---|
1565 | & ,grid%twbs,grid%qwbs,grid%taux,grid%tauy,grid%sfcshx,grid%sfclhx,grid%sfcevp & |
---|
1566 | #else |
---|
1567 | & ,grid%twbs,grid%qwbs,grid%sfcshx,grid%sfclhx,grid%sfcevp & |
---|
1568 | #endif |
---|
1569 | & ,grid%potevp,grid%potflx,grid%subshx & |
---|
1570 | & ,grid%aphtim,grid%ardsw,grid%ardlw,grid%asrfc & |
---|
1571 | & ,grid%rswout,grid%rswtoa,grid%rlwtoa & |
---|
1572 | & ,grid%aswin,grid%aswout,grid%aswtoa,grid%alwin,grid%alwout,grid%alwtoa & |
---|
1573 | #if (NMM_CORE==1) |
---|
1574 | & ,grid%uz0h,grid%vz0h,grid%dudt,grid%dvdt,grid%ugwdsfc,grid%vgwdsfc,grid%sfenth & |
---|
1575 | #else |
---|
1576 | & ,grid%uz0h,grid%vz0h,grid%dudt,grid%dvdt & |
---|
1577 | #endif |
---|
1578 | & ,RTHBLTEN,RQVBLTEN & |
---|
1579 | & ,GRID%PCPFLG,grid%ddata & |
---|
1580 | & ,grid%hstdv,grid%hcnvx,grid%hasyw,grid%hasys,grid%hasysw,grid%hasynw,grid%hlenw,grid%hlens & ! GWD |
---|
1581 | & ,grid%hlensw,grid%hlennw,grid%hangl,grid%hanis,grid%hslop,grid%hzmax,grid%crot,grid%srot & ! GWD |
---|
1582 | & ,grid%dew & ! RUC LSM |
---|
1583 | & ,GRID,CONFIG_FLAGS & |
---|
1584 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
1585 | & ,GRID%DISHEAT & |
---|
1586 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1587 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1588 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1589 | ! |
---|
1590 | ! *** NOTE *** |
---|
1591 | ! grid%rlwin/grid%rswin - downward longwave/shortwave at the surface |
---|
1592 | ! *** NOTE *** |
---|
1593 | ! |
---|
1594 | turbl_tim=turbl_tim+timef()-btimx |
---|
1595 | #ifdef HWRF |
---|
1596 | |
---|
1597 | |
---|
1598 | !------------------------------------------------------------------------------ |
---|
1599 | !*** ATMOSPHERIC MODEL OUTPUTS FROM PARENT AND NESTED GRID FOR DMITRYs COUPLER |
---|
1600 | !------------------------------------------------------------------------------ |
---|
1601 | ! |
---|
1602 | !-- grid%twbs : surface sensible heat flux, positive downward (grid%w/m2) |
---|
1603 | !-- grid%qwbs : surface latent heat flux, positive downward (grid%w/m2) |
---|
1604 | !-- grid%rlwin : downward long wave flux at ground surface,positive downward (grid%w/m2) |
---|
1605 | !-- grid%rswin : downward short wave flux at ground surface, positive downward (grid%w/m2) |
---|
1606 | !-- grid%radot : outgoing long wave flux at ground surface, positive upward (grid%w/m2) |
---|
1607 | !-- grid%rswout: outgoing short wave flux at ground surface, positive upward (grid%w/m2) |
---|
1608 | !-- grid%taux : x component of surface stress, grid%u positive Eastward |
---|
1609 | !-- grid%tauy : y component of surface stress, grid%v positive Northward |
---|
1610 | !-- grid%pint : 3d array of interface pressure (pascals) |
---|
1611 | !-- grid%prec : grid%prec (m/timestep;timestep on grid1=60 sec) |
---|
1612 | |
---|
1613 | ! |
---|
1614 | ! |
---|
1615 | |
---|
1616 | ! Coupling insertion:-> |
---|
1617 | call ATM_DOFLUXES(grid%twbs,grid%qwbs,grid%rlwin,grid%rswin,grid%radot,grid%rswout, & |
---|
1618 | grid%taux,grid%tauy,grid%pint(:,:,1),grid%prec,grid%u10,grid%v10) |
---|
1619 | !<-:Coupling insertion |
---|
1620 | ! |
---|
1621 | |
---|
1622 | IF(GRID%ID .EQ. 1 .AND. MOD(grid%ntsd,grid%NPHS)==0)THEN |
---|
1623 | btimx=timef() |
---|
1624 | flux_tim=flux_tim+timef()-btimx |
---|
1625 | ENDIF |
---|
1626 | |
---|
1627 | #endif |
---|
1628 | ! |
---|
1629 | btimx=timef() |
---|
1630 | !----------------- |
---|
1631 | #ifdef DM_PARALLEL |
---|
1632 | # include "HALO_NMM_TURBL_A.inc" |
---|
1633 | #endif |
---|
1634 | !----------------- |
---|
1635 | #ifdef DM_PARALLEL |
---|
1636 | # include "HALO_NMM_TURBL_B.inc" |
---|
1637 | #endif |
---|
1638 | !----------------- |
---|
1639 | exch_tim=exch_tim+timef()-btimx |
---|
1640 | ! this_tim=timef()-btimx |
---|
1641 | ! call mpi_allreduce(this_tim,et_max,1,mpi_real,mpi_max & |
---|
1642 | ! & ,mpi_comm_comp,irtn) |
---|
1643 | ! exch_tim_max=exch_tim_max+et_max |
---|
1644 | ! |
---|
1645 | !*** INTERPOLATE WINDS FROM H POINTS BACK TO grid%v POINTS. |
---|
1646 | ! |
---|
1647 | btimx=timef() |
---|
1648 | CALL UV_H_TO_V(grid%ntsd,GRID%DT,GRID%NPHS,grid%uz0h,grid%vz0h,grid%uz0,grid%vz0 & |
---|
1649 | & ,grid%dudt,grid%dvdt,grid%u,grid%v,grid%hbm2,grid%ive,grid%ivw & |
---|
1650 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1651 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1652 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1653 | uv_htov_tim=uv_htov_tim+timef()-btimx |
---|
1654 | ! |
---|
1655 | !---------------------------------------------------------------------- |
---|
1656 | !*** STORE ORIGINAL TEMPERATURE ARRAY |
---|
1657 | !---------------------------------------------------------------------- |
---|
1658 | ! |
---|
1659 | btimx=timef() |
---|
1660 | !----------------- |
---|
1661 | #ifdef DM_PARALLEL |
---|
1662 | # include "HALO_NMM_J.inc" |
---|
1663 | #endif |
---|
1664 | ! |
---|
1665 | #ifdef DM_PARALLEL |
---|
1666 | IF(CONFIG_FLAGS%MP_PHYSICS/=ETAMPNEW.and.CONFIG_FLAGS%MP_PHYSICS/=ETAMP_HWRF)THEN |
---|
1667 | # include "HALO_NMM_J_3.inc" |
---|
1668 | ENDIF |
---|
1669 | #endif |
---|
1670 | ! |
---|
1671 | #ifdef WRF_CHEM |
---|
1672 | #ifdef DM_PARALLEL |
---|
1673 | # include "HALO_NMM_J_2.inc" |
---|
1674 | #endif |
---|
1675 | #endif |
---|
1676 | !----------------- |
---|
1677 | exch_tim=exch_tim+timef()-btimx |
---|
1678 | ! this_tim=timef()-btimx |
---|
1679 | ! call mpi_allreduce(this_tim,et_max,1,mpi_real,mpi_max & |
---|
1680 | ! & ,mpi_comm_comp,irtn) |
---|
1681 | ! exch_tim_max=exch_tim_max+et_max |
---|
1682 | ! |
---|
1683 | ICLTEND=-1 |
---|
1684 | btimx=timef() |
---|
1685 | ! |
---|
1686 | CALL CLTEND(ICLTEND,GRID%NPHS,grid%t,grid%t_old,grid%t_adj & |
---|
1687 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1688 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1689 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1690 | ! |
---|
1691 | cltend_tim=cltend_tim+timef()-btimx |
---|
1692 | ENDIF |
---|
1693 | ! |
---|
1694 | !---------------------------------------------------------------------- |
---|
1695 | !*** CONVECTIVE PRECIPITATION |
---|
1696 | !---------------------------------------------------------------------- |
---|
1697 | ! |
---|
1698 | IF(MOD(grid%ntsd,GRID%NCNVC)==0.AND. & |
---|
1699 | & (CONFIG_FLAGS%CU_PHYSICS==KFETASCHEME .or. & |
---|
1700 | CONFIG_FLAGS%CU_PHYSICS==SASSCHEME))THEN ! Kwon's doing for SAS |
---|
1701 | ! |
---|
1702 | btimx=timef() |
---|
1703 | !----------------- |
---|
1704 | #ifdef DM_PARALLEL |
---|
1705 | # include "HALO_NMM_C.inc" |
---|
1706 | #endif |
---|
1707 | !----------------- |
---|
1708 | exch_tim=exch_tim+timef()-btimx |
---|
1709 | ! this_tim=timef()-btimx |
---|
1710 | ! call mpi_allreduce(this_tim,et_max,1,mpi_real,mpi_max & |
---|
1711 | ! & ,mpi_comm_comp,irtn) |
---|
1712 | ! exch_tim_max=exch_tim_max+et_max |
---|
1713 | ENDIF |
---|
1714 | ! |
---|
1715 | convection: IF(CONFIG_FLAGS%CU_PHYSICS/=0)THEN |
---|
1716 | btimx=timef() |
---|
1717 | ! |
---|
1718 | !*** GET TENDENCIES FOR GD SCHEME. |
---|
1719 | ! |
---|
1720 | IF(CONFIG_FLAGS%CU_PHYSICS==GDSCHEME)THEN |
---|
1721 | DT_INV=1./GRID%DT |
---|
1722 | DO J=JMS,JME |
---|
1723 | DO K=KMS,KME |
---|
1724 | DO I=IMS,IME |
---|
1725 | TTEN(I,K,J)=(grid%t(I,J,K)-TTEN(I,K,J))*DT_INV |
---|
1726 | QTEN(I,K,J)=(grid%q(I,J,K)-QTEN(I,K,J))*DT_INV |
---|
1727 | ENDDO |
---|
1728 | ENDDO |
---|
1729 | ENDDO |
---|
1730 | ENDIF |
---|
1731 | ! |
---|
1732 | !*** UPDATE THE MOIST ARRAY IF NEEDED. |
---|
1733 | ! |
---|
1734 | IF(OPERATIONAL_PHYSICS & |
---|
1735 | & .AND.MOD(NTSD_rad,GRID%NRADS)/=0 & |
---|
1736 | & .AND.MOD(NTSD_rad,GRID%NRADL)/=0 & |
---|
1737 | & .AND.MOD(grid%ntsd,GRID%NPHS)/=0)THEN |
---|
1738 | CALL UPDATE_MOIST(MOIST,grid%q,grid%cwm,grid%f_ice,grid%f_rain,N_MOIST & |
---|
1739 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1740 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1741 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1742 | ENDIF |
---|
1743 | ! |
---|
1744 | !---------------------------------------------------------------------- |
---|
1745 | CALL CUCNVC(grid%ntsd,GRID%DT,GRID%NCNVC,GRID%NRADS,GRID%NRADL & |
---|
1746 | & ,GPS,RESTRT,grid%hydro,grid%cldefi,N_MOIST,GRID%ENSDIM & |
---|
1747 | & ,MOIST & |
---|
1748 | & ,grid%deta1,grid%deta2,grid%aeta1,grid%aeta2,grid%eta1,grid%eta2 & |
---|
1749 | & ,grid%f_ice,grid%f_rain & |
---|
1750 | !*** Changes for other cu schemes, most for GD scheme |
---|
1751 | & ,grid%apr_gr,grid%apr_w,grid%apr_mc,TTEN,QTEN & |
---|
1752 | & ,grid%apr_st,grid%apr_as,grid%apr_capma & |
---|
1753 | & ,grid%apr_capme,grid%apr_capmi & |
---|
1754 | & ,grid%mass_flux,grid%xf_ens & |
---|
1755 | & ,grid%pr_ens,grid%gsw & |
---|
1756 | #ifdef WRF_CHEM |
---|
1757 | & ,GD_CLOUD,GD_CLOUD2,RAINCV & |
---|
1758 | #endif |
---|
1759 | ! |
---|
1760 | & ,grid%pdtop,grid%pt,grid%pd,grid%res,grid%pint,grid%t,grid%q,grid%cwm,grid%tcucn & |
---|
1761 | & ,grid%omgalf,grid%u,grid%v,grid%w,grid%z,grid%fis,grid%w0avg & |
---|
1762 | & ,grid%prec,grid%acprec,grid%cuprec,grid%cuppt,grid%cprate & |
---|
1763 | & ,grid%sm,grid%hbm2,grid%lpbl,grid%cnvbot,grid%cnvtop & |
---|
1764 | & ,grid%htop,grid%hbot,grid%htopd,grid%hbotd,grid%htops,grid%hbots & |
---|
1765 | & ,RTHBLTEN,RQVBLTEN,RTHRATEN & |
---|
1766 | #if (NMM_CORE==1) |
---|
1767 | & ,grid%DUCUDT, grid%DVCUDT, GRID%MOMMIX, grid%store_rand & |
---|
1768 | #endif |
---|
1769 | & ,grid%avcnvc,grid%acutim,grid%ihe,grid%ihw & |
---|
1770 | & ,GRID,CONFIG_FLAGS & |
---|
1771 | & ,grid%NRND1 & ! NRND1 for random num restart |
---|
1772 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1773 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1774 | & ,IPS,IPE,JPS,JPE,KPS,KPE & |
---|
1775 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1776 | !---------------------------------------------------------------------- |
---|
1777 | ! |
---|
1778 | cucnvc_tim=cucnvc_tim+timef()-btimx |
---|
1779 | ! |
---|
1780 | |
---|
1781 | |
---|
1782 | #if (NMM_CORE==1) |
---|
1783 | !#ifdef HWRF |
---|
1784 | !------------------------------------------------------------------------------------- |
---|
1785 | ! This is gopal's doing for HWRFSAS |
---|
1786 | |
---|
1787 | ! IF(MOD(grid%ntsd,GRID%NCNVC).eq.0.and.(CONFIG_FLAGS%CU_PHYSICS.eq.SASSCHEME))THEN |
---|
1788 | ! update to match HWRFV2 behaviour - review later (1/15/10) |
---|
1789 | ! |
---|
1790 | !emc_2010_bugfix_h50 |
---|
1791 | IF(MOD(grid%ntsd, GRID%NCNVC).eq.0.and.CONFIG_FLAGS%CU_PHYSICS.eq.SASSCHEME)THEN |
---|
1792 | !emc_2010_bugfix_h50 |
---|
1793 | ! |
---|
1794 | btimx=timef() |
---|
1795 | !----------------- |
---|
1796 | #ifdef DM_PARALLEL |
---|
1797 | # include "HALO_NMM_SAS_A.inc" |
---|
1798 | #endif |
---|
1799 | !----------------- |
---|
1800 | #ifdef DM_PARALLEL |
---|
1801 | # include "HALO_NMM_SAS_B.inc" |
---|
1802 | #endif |
---|
1803 | !----------------- |
---|
1804 | exch_tim=exch_tim+timef()-btimx |
---|
1805 | |
---|
1806 | ! |
---|
1807 | !*** INTERPOLATE WINDS FROM H POINTS BACK TO V POINTS AFTER SAS |
---|
1808 | ! |
---|
1809 | btimx=timef() |
---|
1810 | |
---|
1811 | !emc_2010_bugfix_h50 |
---|
1812 | CALL UV_H_TO_V(grid%NTSD,GRID%DT,GRID%NCNVC,grid%UZ0H,grid%VZ0H,grid%UZ0,grid%VZ0 & |
---|
1813 | & ,grid%DUCUDT,grid%DVCUDT,grid%U,grid%V,grid%HBM2,grid%IVE,grid%IVW & |
---|
1814 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1815 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1816 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1817 | uv_htov_tim=uv_htov_tim+timef()-btimx |
---|
1818 | !emc_2010_bugfix_h50 |
---|
1819 | |
---|
1820 | ENDIF ! for SAS only |
---|
1821 | !#endif |
---|
1822 | #endif |
---|
1823 | !-------------------------------------------------------------------------------- |
---|
1824 | ! |
---|
1825 | ENDIF convection |
---|
1826 | ! |
---|
1827 | !---------------------------------------------------------------------- |
---|
1828 | !*** GRIDSCALE MICROPHYSICS (CONDENSATION & PRECIPITATION) |
---|
1829 | !---------------------------------------------------------------------- |
---|
1830 | ! |
---|
1831 | IF(MOD(grid%ntsd,GRID%NPHS)==0)THEN |
---|
1832 | btimx=timef() |
---|
1833 | ! |
---|
1834 | CALL GSMDRIVE(grid%ntsd,GRID%DT,GRID%NPHS,N_MOIST & |
---|
1835 | & ,grid%dx_nmm(ITS,JC),GRID%DY,grid%sm,grid%hbm2,grid%fis & |
---|
1836 | & ,grid%deta1,grid%deta2,grid%aeta1,grid%aeta2,grid%eta1,grid%eta2 & |
---|
1837 | & ,grid%pdtop,grid%pt,grid%pd,grid%res,grid%pint,grid%t,grid%q,grid%cwm,grid%train & |
---|
1838 | & ,MOIST,SCALAR,NUM_SCALAR & |
---|
1839 | & ,grid%f_ice,grid%f_rain,grid%f_rimef,grid%sr & |
---|
1840 | & ,grid%prec,grid%acprec,grid%avrain & |
---|
1841 | & ,grid%mp_restart_state & |
---|
1842 | & ,grid%tbpvs_state & |
---|
1843 | & ,grid%tbpvs0_state & |
---|
1844 | & ,GRID,CONFIG_FLAGS & |
---|
1845 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1846 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1847 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1848 | ! |
---|
1849 | gsmdrive_tim=gsmdrive_tim+timef()-btimx |
---|
1850 | ! |
---|
1851 | !----------------------------------------------------------------------- |
---|
1852 | !---------PRECIPITATION ASSIMILATION------------------------------------ |
---|
1853 | !----------------------------------------------------------------------- |
---|
1854 | ! |
---|
1855 | IF (GRID%PCPFLG) THEN |
---|
1856 | btimx=timef() |
---|
1857 | ! |
---|
1858 | CALL CHKSNOW(grid%ntsd,GRID%DT,GRID%NPHS,grid%sr,PPTDAT & |
---|
1859 | & ,IDS,IDE,JDS,JDE,KDS,KDE & |
---|
1860 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1861 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1862 | CALL ADJPPT(grid%ntsd,GRID%DT,GRID%NPHS,grid%prec,grid%lspa,PPTDAT,grid%ddata & |
---|
1863 | & ,IDS,IDE,JDS,JDE,KDS,KDE & |
---|
1864 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1865 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1866 | ! |
---|
1867 | adjppt_tim=adjppt_tim+timef()-btimx |
---|
1868 | ENDIF |
---|
1869 | ! |
---|
1870 | !---------------------------------------------------------------------- |
---|
1871 | !*** CALCULATE TEMP TENDENCIES AND RESTORE ORIGINAL TEMPS |
---|
1872 | !---------------------------------------------------------------------- |
---|
1873 | ! |
---|
1874 | ICLTEND=0 |
---|
1875 | btimx=timef() |
---|
1876 | ! |
---|
1877 | CALL CLTEND(ICLTEND,GRID%NPHS,grid%t,grid%t_old,grid%t_adj & |
---|
1878 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1879 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1880 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1881 | ! |
---|
1882 | cltend_tim=cltend_tim+timef()-btimx |
---|
1883 | ENDIF |
---|
1884 | ! |
---|
1885 | !---------------------------------------------------------------------- |
---|
1886 | !*** UPDATE TEMP TENDENCIES FROM CLOUD PROCESSES EVERY TIME STEP |
---|
1887 | !---------------------------------------------------------------------- |
---|
1888 | ! |
---|
1889 | ICLTEND=1 |
---|
1890 | btimx=timef() |
---|
1891 | ! |
---|
1892 | CALL CLTEND(ICLTEND,GRID%NPHS,grid%t,grid%t_old,grid%t_adj & |
---|
1893 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1894 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1895 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1896 | ! |
---|
1897 | cltend_tim=cltend_tim+timef()-btimx |
---|
1898 | ! |
---|
1899 | !---------------------------------------------------------------------- |
---|
1900 | !*** LATERAL DIFFUSION |
---|
1901 | !---------------------------------------------------------------------- |
---|
1902 | ! |
---|
1903 | btimx=timef() |
---|
1904 | !----------------- |
---|
1905 | #ifdef DM_PARALLEL |
---|
1906 | # include "HALO_NMM_K.inc" |
---|
1907 | #endif |
---|
1908 | !----------------- |
---|
1909 | exch_tim=exch_tim+timef()-btimx |
---|
1910 | ! this_tim=timef()-btimx |
---|
1911 | ! call mpi_allreduce(this_tim,et_max,1,mpi_real,mpi_max & |
---|
1912 | ! & ,mpi_comm_comp,irtn) |
---|
1913 | ! exch_tim_max=exch_tim_max+et_max |
---|
1914 | ! |
---|
1915 | btimx=timef() |
---|
1916 | ! |
---|
1917 | CALL HDIFF(grid%ntsd,GRID%DT,grid%fis,grid%dy_nmm,grid%hdac,grid%hdacv & |
---|
1918 | & ,grid%hbm2,grid%deta1,GRID%SIGMA & |
---|
1919 | #ifdef HWRF |
---|
1920 | & ,grid%t,grid%q,grid%u,grid%v,grid%q2,grid%z,grid%w,grid%sm,grid%sice,grid%h_diff & |
---|
1921 | #else |
---|
1922 | & ,grid%t,grid%q,grid%u,grid%v,grid%q2,grid%z,grid%w,grid%sm,grid%sice & |
---|
1923 | #endif |
---|
1924 | & ,grid%def3d & |
---|
1925 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
1926 | & ,CONFIG_FLAGS & |
---|
1927 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1928 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1929 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1930 | ! |
---|
1931 | IF(.NOT.OPERATIONAL_PHYSICS)THEN |
---|
1932 | DO K=KTS,KTE |
---|
1933 | DO J=MYJS,MYJE |
---|
1934 | DO I=MYIS,MYIE |
---|
1935 | !!! MOIST(I,J,K,P_QV)=MAX(0.,grid%q(I,J,K)/(1.-grid%q(I,J,K))) |
---|
1936 | MOIST(I,J,K,P_QV)=grid%q(I,J,K)/(1.-grid%q(I,J,K)) !<-- Update mixing ratio |
---|
1937 | ENDDO |
---|
1938 | ENDDO |
---|
1939 | ENDDO |
---|
1940 | ENDIF |
---|
1941 | ! |
---|
1942 | hdiff_tim=hdiff_tim+timef()-btimx |
---|
1943 | ! |
---|
1944 | !---------------------------------------------------------------------- |
---|
1945 | !*** UPDATING BOUNDARY VALUES AT HEIGHT POINTS |
---|
1946 | !---------------------------------------------------------------------- |
---|
1947 | ! |
---|
1948 | btimx=timef() |
---|
1949 | !----------------- |
---|
1950 | #ifdef DM_PARALLEL |
---|
1951 | # include "HALO_NMM_L.inc" |
---|
1952 | #endif |
---|
1953 | ! |
---|
1954 | #ifdef DM_PARALLEL |
---|
1955 | # include "HALO_NMM_L_3.inc" |
---|
1956 | #endif |
---|
1957 | ! |
---|
1958 | #ifdef WRF_CHEM |
---|
1959 | #ifdef DM_PARALLEL |
---|
1960 | # include "HALO_NMM_L_2.inc" |
---|
1961 | #endif |
---|
1962 | #endif |
---|
1963 | !----------------- |
---|
1964 | exch_tim=exch_tim+timef()-btimx |
---|
1965 | ! this_tim=timef()-btimx |
---|
1966 | ! call mpi_allreduce(this_tim,et_max,1,mpi_real,mpi_max & |
---|
1967 | ! & ,mpi_comm_comp,irtn) |
---|
1968 | ! exch_tim_max=exch_tim_max+et_max |
---|
1969 | ! |
---|
1970 | btimx=timef() |
---|
1971 | ! |
---|
1972 | CALL BOCOH(GRID%ID,grid%ntsd,GRID%DT,NEST,NUNIT_NBC,NBOCO,LAST_TIME,TSPH & |
---|
1973 | & ,LB,grid%eta1,grid%eta2,grid%pdtop,grid%pt,grid%res & |
---|
1974 | & ,grid%PD_BXS,grid%PD_BXE,grid%PD_BYS,grid%PD_BYE,grid%T_BXS,grid%T_BXE,grid%T_BYS,grid%T_BYE & |
---|
1975 | & ,grid%Q_BXS,grid%Q_BXE,grid%Q_BYS,grid%Q_BYE,grid%U_BXS,grid%U_BXE,grid%U_BYS,grid%U_BYE,grid%V_BXS & |
---|
1976 | & ,grid%V_BXE,grid%V_BYS,grid%V_BYE,grid%Q2_BXS,grid%Q2_BXE,grid%Q2_BYS,grid%Q2_BYE,grid%CWM_BXS & |
---|
1977 | & ,grid%CWM_BXE,grid%CWM_BYS,grid%CWM_BYE,grid%PD_BTXS,grid%PD_BTXE,grid%PD_BTYS & |
---|
1978 | & ,grid%PD_BTYE,grid%T_BTXS,grid%T_BTXE,grid%T_BTYS,grid%T_BTYE,grid%Q_BTXS,grid%Q_BTXE & |
---|
1979 | & ,grid%Q_BTYS,grid%Q_BTYE,grid%U_BTXS,grid%U_BTXE,grid%U_BTYS,grid%U_BTYE,grid%V_BTXS & |
---|
1980 | & ,grid%V_BTXE,grid%V_BTYS,grid%V_BTYE,grid%Q2_BTXS,grid%Q2_BTXE,grid%Q2_BTYS,grid%Q2_BTYE & |
---|
1981 | & ,grid%CWM_BTXS,grid%CWM_BTXE,grid%CWM_BTYS,grid%CWM_BTYE,grid%pd,grid%t,grid%q,grid%q2,grid%cwm,grid%pint & |
---|
1982 | & ,MOIST,N_MOIST,SCALAR,NUM_SCALAR & |
---|
1983 | #ifdef WRF_CHEM |
---|
1984 | & ,CHEM,NUMGAS,CONFIG_FLAGS & |
---|
1985 | #endif |
---|
1986 | & ,GRID%SPEC_BDY_WIDTH,grid%z & |
---|
1987 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
1988 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
1989 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
1990 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
1991 | |
---|
1992 | |
---|
1993 | ! |
---|
1994 | bocoh_tim=bocoh_tim+timef()-btimx |
---|
1995 | ! if(mod(grid%ntsd,n_print_time)==0)then |
---|
1996 | ! call twr(grid%t,0,'grid%t',grid%ntsd,mype,npes,mpi_comm_comp & |
---|
1997 | ! & ,ids,ide,jds,jde,kds,kde & |
---|
1998 | ! & ,ims,ime,jms,jme,kms,kme & |
---|
1999 | ! & ,its,ite,jts,jte,kts,kte) |
---|
2000 | ! endif |
---|
2001 | ! |
---|
2002 | !---------------------------------------------------------------------- |
---|
2003 | !*** IS IT TIME FOR A CHECK POINT ON THE MODEL HISTORY FILE? |
---|
2004 | !---------------------------------------------------------------------- |
---|
2005 | ! |
---|
2006 | 2003 CONTINUE |
---|
2007 | ! |
---|
2008 | !---------------------------------------------------------------------- |
---|
2009 | !*** PRESSURE GRD, CORIOLIS, DIVERGENCE, AND HORIZ PART OF OMEGA-ALPHA |
---|
2010 | !---------------------------------------------------------------------- |
---|
2011 | ! |
---|
2012 | btimx=timef() |
---|
2013 | !----------------- |
---|
2014 | #ifdef DM_PARALLEL |
---|
2015 | # include "HALO_NMM_A.inc" |
---|
2016 | #endif |
---|
2017 | ! |
---|
2018 | #ifdef DM_PARALLEL |
---|
2019 | IF(CONFIG_FLAGS%MP_PHYSICS/=ETAMPNEW.and.CONFIG_FLAGS%MP_PHYSICS/=ETAMP_HWRF)THEN |
---|
2020 | # include "HALO_NMM_A_3.inc" |
---|
2021 | ENDIF |
---|
2022 | #endif |
---|
2023 | ! |
---|
2024 | #ifdef WRF_CHEM |
---|
2025 | #ifdef DM_PARALLEL |
---|
2026 | # include "HALO_NMM_A_2.inc" |
---|
2027 | #endif |
---|
2028 | #endif |
---|
2029 | !----------------- |
---|
2030 | exch_tim=exch_tim+timef()-btimx |
---|
2031 | ! this_tim=timef()-btimx |
---|
2032 | ! call mpi_allreduce(this_tim,et_max,1,mpi_real,mpi_max & |
---|
2033 | ! & ,mpi_comm_comp,irtn) |
---|
2034 | ! exch_tim_max=exch_tim_max+et_max |
---|
2035 | ! |
---|
2036 | btimx=timef() |
---|
2037 | ! |
---|
2038 | CALL PFDHT(grid%ntsd,LAST_TIME,grid%pt,grid%deta1,grid%deta2,grid%pdtop,grid%res,grid%fis & |
---|
2039 | & ,grid%hydro,GRID%SIGMA,FIRST,grid%dx_nmm,grid%dy_nmm & |
---|
2040 | & ,grid%hbm2,grid%vbm2,grid%vbm3 & |
---|
2041 | & ,grid%fdiv,grid%fcp,grid%wpdar,grid%dfl,grid%cpgfu,grid%cpgfv & |
---|
2042 | & ,grid%pd,grid%pdsl,grid%t,grid%q,grid%u,grid%v,grid%cwm,grid%omgalf,grid%pint,grid%dwdt & |
---|
2043 | & ,grid%rtop,grid%div,grid%few,grid%fns,grid%fne,grid%fse & |
---|
2044 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
2045 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
2046 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
2047 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
2048 | |
---|
2049 | ! |
---|
2050 | pfdht_tim=pfdht_tim+timef()-btimx |
---|
2051 | ! |
---|
2052 | !---------------------------------------------------------------------- |
---|
2053 | !*** DIVERGENCE DAMPING |
---|
2054 | !---------------------------------------------------------------------- |
---|
2055 | ! |
---|
2056 | btimx=timef() |
---|
2057 | !----------------- |
---|
2058 | #ifdef DM_PARALLEL |
---|
2059 | # include "HALO_NMM_B.inc" |
---|
2060 | #endif |
---|
2061 | !----------------- |
---|
2062 | exch_tim=exch_tim+timef()-btimx |
---|
2063 | ! this_tim=timef()-btimx |
---|
2064 | ! call mpi_allreduce(this_tim,et_max,1,mpi_real,mpi_max & |
---|
2065 | ! & ,mpi_comm_comp,irtn) |
---|
2066 | ! exch_tim_max=exch_tim_max+et_max |
---|
2067 | ! |
---|
2068 | btimx=timef() |
---|
2069 | ! |
---|
2070 | CALL DDAMP(grid%ntsd,GRID%DT,grid%deta1,grid%deta2,grid%pdsl,grid%pdtop,grid%div,grid%hbm2 & |
---|
2071 | & ,grid%t,grid%u,grid%v,grid%ddmpu,grid%ddmpv & |
---|
2072 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
2073 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
2074 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
2075 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
2076 | ! |
---|
2077 | ddamp_tim=ddamp_tim+timef()-btimx |
---|
2078 | ! |
---|
2079 | !---------------------------------------------------------------------- |
---|
2080 | !---------------------------------------------------------------------- |
---|
2081 | ! |
---|
2082 | IF(FIRST.AND.grid%ntsd==0)THEN |
---|
2083 | FIRST=.FALSE. |
---|
2084 | btimx=timef() |
---|
2085 | !----------------- |
---|
2086 | #ifdef DM_PARALLEL |
---|
2087 | # include "HALO_NMM_A.inc" |
---|
2088 | #endif |
---|
2089 | #ifdef WRF_CHEM |
---|
2090 | #ifdef DM_PARALLEL |
---|
2091 | # include "HALO_NMM_A_2.inc" |
---|
2092 | #endif |
---|
2093 | #endif |
---|
2094 | !----------------- |
---|
2095 | exch_tim=exch_tim+timef()-btimx |
---|
2096 | ! this_tim=timef()-btimx |
---|
2097 | ! call mpi_allreduce(this_tim,et_max,1,mpi_real,mpi_max & |
---|
2098 | ! & ,mpi_comm_comp,irtn) |
---|
2099 | ! exch_tim_max=exch_tim_max+et_max |
---|
2100 | ! |
---|
2101 | GO TO 2000 |
---|
2102 | ENDIF |
---|
2103 | ! |
---|
2104 | !---------------------------------------------------------------------- |
---|
2105 | !*** UPDATING BOUNDARY VALUES AT VELOCITY POINTS |
---|
2106 | !---------------------------------------------------------------------- |
---|
2107 | ! |
---|
2108 | btimx=timef() |
---|
2109 | !----------------- |
---|
2110 | #ifdef DM_PARALLEL |
---|
2111 | # include "HALO_NMM_C.inc" |
---|
2112 | #endif |
---|
2113 | !----------------- |
---|
2114 | exch_tim=exch_tim+timef()-btimx |
---|
2115 | ! this_tim=timef()-btimx |
---|
2116 | ! call mpi_allreduce(this_tim,et_max,1,mpi_real,mpi_max & |
---|
2117 | ! & ,mpi_comm_comp,irtn) |
---|
2118 | ! exch_tim_max=exch_tim_max+et_max |
---|
2119 | ! |
---|
2120 | btimx=timef() |
---|
2121 | ! |
---|
2122 | CALL BOCOV(GRID%ID,grid%ntsd,GRID%DT,LB,grid%U_BXS,grid%U_BXE,grid%U_BYS,grid%U_BYE,grid%V_BXS & |
---|
2123 | & ,grid%V_BXE,grid%V_BYS,grid%V_BYE,grid%U_BTXS,grid%U_BTXE,grid%U_BTYS,grid%U_BTYE,grid%V_BTXS & |
---|
2124 | & ,grid%V_BTXE,grid%V_BTYS,grid%V_BTYE,grid%u,grid%v & |
---|
2125 | & ,GRID%SPEC_BDY_WIDTH & |
---|
2126 | & ,grid%ihe,grid%ihw,grid%ive,grid%ivw & |
---|
2127 | & ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
2128 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
2129 | & ,ITS,ITE,JTS,JTE,KTS,KTE ) |
---|
2130 | |
---|
2131 | ! |
---|
2132 | bocov_tim=bocov_tim+timef()-btimx |
---|
2133 | ! |
---|
2134 | !---------------------------------------------------------------------- |
---|
2135 | !*** COPY THE NMM VARIABLE grid%q2 TO THE WRF VARIABLE grid%tke_pbl |
---|
2136 | !---------------------------------------------------------------------- |
---|
2137 | ! |
---|
2138 | DO K=KTS,KTE |
---|
2139 | DO J=JTS,JTE |
---|
2140 | DO I=ITS,ITE |
---|
2141 | grid%tke_pbl(I,J,K)=0.5*grid%q2(I,J,K) !TKE is grid%q squared over 2 |
---|
2142 | ENDDO |
---|
2143 | ENDDO |
---|
2144 | ENDDO |
---|
2145 | ! |
---|
2146 | !---------------------------------------------------------------------- |
---|
2147 | ! |
---|
2148 | IF(LAST_TIME.AND.ALLOCATED(PPTDAT))THEN |
---|
2149 | DEALLOCATE(PPTDAT,STAT=ISTAT) |
---|
2150 | ENDIF |
---|
2151 | ! |
---|
2152 | !---------------------------------------------------------------------- |
---|
2153 | ! |
---|
2154 | solve_tim=solve_tim+timef()-btim |
---|
2155 | ! |
---|
2156 | !---------------------------------------------------------------------- |
---|
2157 | !*** PRINT TIMING VARIABLES WHEN DESIRED. |
---|
2158 | !---------------------------------------------------------------------- |
---|
2159 | ! |
---|
2160 | sum_tim=pdte_tim+adve_tim+vtoa_tim+vadz_tim+hadz_tim+eps_tim & |
---|
2161 | & +vad2_tim+had2_tim+radiation_tim+rdtemp_tim+turbl_tim & |
---|
2162 | & +cltend_tim+cucnvc_tim+gsmdrive_tim+hdiff_tim & |
---|
2163 | & +bocoh_tim+pfdht_tim+ddamp_tim+bocov_tim+uv_htov_tim & |
---|
2164 | & +exch_tim+adjppt_tim |
---|
2165 | ! |
---|
2166 | if(mod(grid%ntsd,n_print_time)==0)then |
---|
2167 | write(message,*)' grid%ntsd=',grid%ntsd,' solve_tim=',solve_tim*1.e-3 & |
---|
2168 | & ,' sum_tim=',sum_tim*1.e-3 |
---|
2169 | call wrf_message(trim(message)) |
---|
2170 | write(message,*)' pdte_tim=',pdte_tim*1.e-3,' pct=',pdte_tim/sum_tim*100. |
---|
2171 | call wrf_message(trim(message)) |
---|
2172 | write(message,*)' adve_tim=',adve_tim*1.e-3,' pct=',adve_tim/sum_tim*100. |
---|
2173 | call wrf_message(trim(message)) |
---|
2174 | write(message,*)' vtoa_tim=',vtoa_tim*1.e-3,' pct=',vtoa_tim/sum_tim*100. |
---|
2175 | call wrf_message(trim(message)) |
---|
2176 | write(message,*)' vadz_tim=',vadz_tim*1.e-3,' pct=',vadz_tim/sum_tim*100. |
---|
2177 | call wrf_message(trim(message)) |
---|
2178 | write(message,*)' hadz_tim=',hadz_tim*1.e-3,' pct=',hadz_tim/sum_tim*100. |
---|
2179 | call wrf_message(trim(message)) |
---|
2180 | write(message,*)' eps_tim=',eps_tim*1.e-3,' pct=',eps_tim/sum_tim*100. |
---|
2181 | call wrf_message(trim(message)) |
---|
2182 | write(message,*)' vad2_tim=',vad2_tim*1.e-3,' pct=',vad2_tim/sum_tim*100. |
---|
2183 | call wrf_message(trim(message)) |
---|
2184 | write(message,*)' had2_tim=',had2_tim*1.e-3,' pct=',had2_tim/sum_tim*100. |
---|
2185 | call wrf_message(trim(message)) |
---|
2186 | write(message,*)' radiation_tim=',radiation_tim*1.e-3,' pct=',radiation_tim/sum_tim*100. |
---|
2187 | call wrf_message(trim(message)) |
---|
2188 | write(message,*)' rdtemp_tim=',rdtemp_tim*1.e-3,' pct=',rdtemp_tim/sum_tim*100. |
---|
2189 | call wrf_message(trim(message)) |
---|
2190 | write(message,*)' turbl_tim=',turbl_tim*1.e-3,' pct=',turbl_tim/sum_tim*100. |
---|
2191 | call wrf_message(trim(message)) |
---|
2192 | write(message,*)' cltend_tim=',cltend_tim*1.e-3,' pct=',cltend_tim/sum_tim*100. |
---|
2193 | call wrf_message(trim(message)) |
---|
2194 | write(message,*)' cucnvc_tim=',cucnvc_tim*1.e-3,' pct=',cucnvc_tim/sum_tim*100. |
---|
2195 | call wrf_message(trim(message)) |
---|
2196 | write(message,*)' gsmdrive_tim=',gsmdrive_tim*1.e-3,' pct=',gsmdrive_tim/sum_tim*100. |
---|
2197 | call wrf_message(trim(message)) |
---|
2198 | write(message,*)' adjppt_tim=',adjppt_tim*1.e-3,' pct=',adjppt_tim/sum_tim*100. |
---|
2199 | call wrf_message(trim(message)) |
---|
2200 | write(message,*)' hdiff_tim=',hdiff_tim*1.e-3,' pct=',hdiff_tim/sum_tim*100. |
---|
2201 | call wrf_message(trim(message)) |
---|
2202 | write(message,*)' bocoh_tim=',bocoh_tim*1.e-3,' pct=',bocoh_tim/sum_tim*100. |
---|
2203 | call wrf_message(trim(message)) |
---|
2204 | write(message,*)' pfdht_tim=',pfdht_tim*1.e-3,' pct=',pfdht_tim/sum_tim*100. |
---|
2205 | call wrf_message(trim(message)) |
---|
2206 | write(message,*)' ddamp_tim=',ddamp_tim*1.e-3,' pct=',ddamp_tim/sum_tim*100. |
---|
2207 | call wrf_message(trim(message)) |
---|
2208 | write(message,*)' bocov_tim=',bocov_tim*1.e-3,' pct=',bocov_tim/sum_tim*100. |
---|
2209 | call wrf_message(trim(message)) |
---|
2210 | write(message,*)' uv_h_to_v_tim=',uv_htov_tim*1.e-3,' pct=',uv_htov_tim/sum_tim*100. |
---|
2211 | call wrf_message(trim(message)) |
---|
2212 | write(message,*)' exch_tim=',exch_tim*1.e-3,' pct=',exch_tim/sum_tim*100. |
---|
2213 | call wrf_message(trim(message)) |
---|
2214 | ! call time_stats(exch_tim,'exchange',grid%ntsd,mype,npes,mpi_comm_comp) |
---|
2215 | ! write(message,*)' exch_tim_max=',exch_tim_max*1.e-3 |
---|
2216 | ! call wrf_message(trim(message)) |
---|
2217 | ! |
---|
2218 | call field_stats(grid%t,mype,mpi_comm_comp & |
---|
2219 | & ,ids,ide,jds,jde,kds,kde & |
---|
2220 | & ,ims,ime,jms,jme,kms,kme & |
---|
2221 | & ,its,ite,jts,jte,kts,kte) |
---|
2222 | endif |
---|
2223 | ! |
---|
2224 | ! if(last_time)then |
---|
2225 | DEALLOCATE(TTEN,STAT=ISTAT) |
---|
2226 | DEALLOCATE(QTEN,STAT=ISTAT) |
---|
2227 | DEALLOCATE(RTHRATEN,STAT=ISTAT) |
---|
2228 | DEALLOCATE(RTHBLTEN,STAT=ISTAT) |
---|
2229 | DEALLOCATE(RQVBLTEN,STAT=ISTAT) |
---|
2230 | #ifdef WRF_CHEM |
---|
2231 | #endif |
---|
2232 | ! |
---|
2233 | ! FOR VORTEX FOLLOWING MOVING NEST |
---|
2234 | ! |
---|
2235 | !----------------------------------------------------------------------------- |
---|
2236 | !*** CRITERIA SET FOR GRID MOTION. This is gopal's doing |
---|
2237 | !----------------------------------------------------------------------------- |
---|
2238 | ! |
---|
2239 | #ifdef MOVE_NESTS |
---|
2240 | IF(grid%id .NE. 1 .AND. MOD(grid%ntsd,1)==0 .AND. grid%num_moves.EQ.-99)THEN |
---|
2241 | !----------------- |
---|
2242 | #ifdef DM_PARALLEL |
---|
2243 | # include "HALO_NMM_TRACK.inc" |
---|
2244 | #endif |
---|
2245 | !----------------- |
---|
2246 | |
---|
2247 | CALL STATS_FOR_MOVE (grid%XLOC_2,grid%YLOC_2,grid%PDYN,grid%MSLP,grid%SQWS & |
---|
2248 | ,grid%pint,grid%t,grid%q,grid%u,grid%v & |
---|
2249 | ,grid%fis,grid%pd,grid%sm,grid%pdtop,grid%pt & |
---|
2250 | ,grid%deta1,grid%deta2 & |
---|
2251 | #ifdef HWRF |
---|
2252 | ,GRID%RESTART,grid%NTIME0 & ! zhang's doing |
---|
2253 | ,GRID%MOVED,grid%MVNEST,grid%ntsd,GRID%NPHS,GRID%MOVEMIN & ! MOVEMIN*DT*NPHS=540s |
---|
2254 | #else |
---|
2255 | ,GRID%MOVED,grid%MVNEST,grid%ntsd,GRID%NPHS & |
---|
2256 | #endif |
---|
2257 | ,IDS,IDF,JDS,JDF,KDS,KDE & ! MOVEMIN is defined in |
---|
2258 | ,IMS,IME,JMS,JME,KMS,KME & ! Registry |
---|
2259 | ,ITS,ITE,JTS,JTE,KTS,KTE ) ! FOR NEST:DT=18,NPHS=3 |
---|
2260 | CALL wrf_debug ( 100 , 'nmm stats_for_move: after advection' ) |
---|
2261 | ENDIF |
---|
2262 | #endif |
---|
2263 | |
---|
2264 | #ifdef HWRFX |
---|
2265 | ! output MSLP over parent domain for diagonostic purposes. outputs are hourly. |
---|
2266 | ! This is gopal's doing |
---|
2267 | |
---|
2268 | IF(grid%id .EQ. 1 .AND. MOD(grid%NTSD,n_print_time)==0)THEN |
---|
2269 | WRITE(0,*)'COMPUTING MSLP OVER THE PARENT DOMAIN' |
---|
2270 | |
---|
2271 | CALL MSLP_DIAG (grid%MSLP,grid%PINT,grid%T,grid%Q & |
---|
2272 | ,grid%FIS,grid%PD,grid%DETA1,grid%DETA2,grid%PDTOP & |
---|
2273 | ,IDS,IDF,JDS,JDF,KDS,KDE & |
---|
2274 | ,IMS,IME,JMS,JME,KMS,KME & |
---|
2275 | ,ITS,ITE,JTS,JTE,KTS,KTE ) |
---|
2276 | |
---|
2277 | |
---|
2278 | ENDIF |
---|
2279 | |
---|
2280 | #endif |
---|
2281 | |
---|
2282 | !#define COPY_OUT |
---|
2283 | !#include <scalar_derefs.inc> |
---|
2284 | #ifdef HWRF |
---|
2285 | !----------------------------------------------------------------------- |
---|
2286 | !*** ACCUMULATED ATMOSPHERIC MODEL FLUXES FOR DMITRYs COUPLER |
---|
2287 | !----------------------------------------------------------------------- |
---|
2288 | ! |
---|
2289 | ! |
---|
2290 | ! |
---|
2291 | ! Coupling insertion:-> |
---|
2292 | call ATM_SENDFLUXES |
---|
2293 | !<-:Coupling insertion |
---|
2294 | ! |
---|
2295 | ! Kwon's doing to check heat flux |
---|
2296 | ! |
---|
2297 | ! IF(grid%id==2)WRITE(0,*)'AFTER ATM_SENDFLUX grid%qwbs grid%twbs AT 10 10 ',grid%ntsd,grid%qwbs(10,10),grid%twbs(10,10) |
---|
2298 | ! |
---|
2299 | #endif |
---|
2300 | |
---|
2301 | |
---|
2302 | Return |
---|
2303 | !---------------------------------------------------------------------- |
---|
2304 | !********************************************************************** |
---|
2305 | !********************************************************************** |
---|
2306 | !************* EXIT FROM THE TIME LOOP ************************** |
---|
2307 | !********************************************************************** |
---|
2308 | !********************************************************************** |
---|
2309 | !---------------------------------------------------------------------- |
---|
2310 | END SUBROUTINE SOLVE_NMM |
---|
2311 | !---------------------------------------------------------------------- |
---|
2312 | !********************************************************************** |
---|
2313 | !---------------------------------------------------------------------- |
---|
2314 | SUBROUTINE TWR(ARRAY,KK,FIELD,ntsd,MYPE,NPES,MPI_COMM_COMP & |
---|
2315 | & ,IDS,IDE,JDS,JDE,KDS,KDE & |
---|
2316 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
2317 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
2318 | !---------------------------------------------------------------------- |
---|
2319 | !********************************************************************** |
---|
2320 | USE MODULE_EXT_INTERNAL |
---|
2321 | ! |
---|
2322 | IMPLICIT NONE |
---|
2323 | #if defined(DM_PARALLEL) && !defined(STUBMPI) |
---|
2324 | INCLUDE "mpif.h" |
---|
2325 | #endif |
---|
2326 | !---------------------------------------------------------------------- |
---|
2327 | !---------------------------------------------------------------------- |
---|
2328 | INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE & |
---|
2329 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
2330 | & ,ITS,ITE,JTS,JTE,KTS,KTE & |
---|
2331 | & ,KK,MPI_COMM_COMP,MYPE,NPES,ntsd |
---|
2332 | ! |
---|
2333 | REAL,DIMENSION(IMS:IME,JMS:JME,KMS:KME+KK),INTENT(IN) :: ARRAY |
---|
2334 | ! |
---|
2335 | CHARACTER(*),INTENT(IN) :: FIELD |
---|
2336 | ! |
---|
2337 | !*** LOCAL VARIABLES |
---|
2338 | ! |
---|
2339 | #if defined(DM_PARALLEL) && !defined(STUBMPI) |
---|
2340 | INTEGER,DIMENSION(MPI_STATUS_SIZE) :: JSTAT |
---|
2341 | INTEGER,DIMENSION(MPI_STATUS_SIZE,4) :: STATUS_ARRAY |
---|
2342 | #endif |
---|
2343 | INTEGER,DIMENSION(2) :: IM_REM,JM_REM,IT_REM,JT_REM |
---|
2344 | ! |
---|
2345 | INTEGER :: I,IENDX,IER,IPE,IRECV,IRTN,ISEND,IUNIT & |
---|
2346 | & ,J,K,N,NLEN,NSIZE |
---|
2347 | INTEGER :: ITS_REM,ITE_REM,JTS_REM,JTE_REM |
---|
2348 | ! |
---|
2349 | REAL,DIMENSION(IDS:IDE,JDS:JDE) :: TWRITE |
---|
2350 | REAL,ALLOCATABLE,DIMENSION(:) :: VALUES |
---|
2351 | CHARACTER(5) :: TIMESTEP |
---|
2352 | CHARACTER(6) :: FMT |
---|
2353 | CHARACTER(12) :: FILENAME |
---|
2354 | !---------------------------------------------------------------------- |
---|
2355 | !********************************************************************** |
---|
2356 | !---------------------------------------------------------------------- |
---|
2357 | ! |
---|
2358 | IF(ntsd<=9)THEN |
---|
2359 | FMT='(I1.1)' |
---|
2360 | NLEN=1 |
---|
2361 | ELSEIF(ntsd<=99)THEN |
---|
2362 | FMT='(I2.2)' |
---|
2363 | NLEN=2 |
---|
2364 | ELSEIF(ntsd<=999)THEN |
---|
2365 | FMT='(I3.3)' |
---|
2366 | NLEN=3 |
---|
2367 | ELSEIF(ntsd<=9999)THEN |
---|
2368 | FMT='(I4.4)' |
---|
2369 | NLEN=4 |
---|
2370 | ELSEIF(ntsd<=99999)THEN |
---|
2371 | FMT='(I5.5)' |
---|
2372 | NLEN=5 |
---|
2373 | ENDIF |
---|
2374 | WRITE(TIMESTEP,FMT)ntsd |
---|
2375 | FILENAME=FIELD//'_'//TIMESTEP(1:NLEN) |
---|
2376 | ! |
---|
2377 | IF(MYPE==0)THEN |
---|
2378 | CALL INT_GET_FRESH_HANDLE(IUNIT) |
---|
2379 | CLOSE(IUNIT) |
---|
2380 | OPEN(UNIT=IUNIT,FILE=FILENAME,FORM='UNFORMATTED',IOSTAT=IER) |
---|
2381 | ENDIF |
---|
2382 | ! |
---|
2383 | !---------------------------------------------------------------------- |
---|
2384 | !!!! DO 500 K=KTS,KTE+KK !Unflipped |
---|
2385 | !!!! DO 500 K=KTE+KK,KTS,-1 |
---|
2386 | DO 500 K=KDE-1,KDS,-1 !Write LM layers top down for checking |
---|
2387 | !---------------------------------------------------------------------- |
---|
2388 | ! |
---|
2389 | #if defined(DM_PARALLEL) && !defined(STUBMPI) |
---|
2390 | IF(MYPE==0)THEN |
---|
2391 | DO J=JTS,JTE |
---|
2392 | DO I=ITS,ITE |
---|
2393 | TWRITE(I,J)=ARRAY(I,J,K) |
---|
2394 | ENDDO |
---|
2395 | ENDDO |
---|
2396 | ! |
---|
2397 | DO IPE=1,NPES-1 |
---|
2398 | CALL MPI_RECV(IT_REM,2,MPI_INTEGER,IPE,IPE & |
---|
2399 | & ,MPI_COMM_COMP,JSTAT,IRECV) |
---|
2400 | CALL MPI_RECV(JT_REM,2,MPI_INTEGER,IPE,IPE & |
---|
2401 | & ,MPI_COMM_COMP,JSTAT,IRECV) |
---|
2402 | ! |
---|
2403 | ITS_REM=IT_REM(1) |
---|
2404 | ITE_REM=IT_REM(2) |
---|
2405 | JTS_REM=JT_REM(1) |
---|
2406 | JTE_REM=JT_REM(2) |
---|
2407 | ! |
---|
2408 | NSIZE=(ITE_REM-ITS_REM+1)*(JTE_REM-JTS_REM+1) |
---|
2409 | ALLOCATE(VALUES(1:NSIZE)) |
---|
2410 | ! |
---|
2411 | CALL MPI_RECV(VALUES,NSIZE,MPI_REAL,IPE,IPE & |
---|
2412 | & ,MPI_COMM_COMP,JSTAT,IRECV) |
---|
2413 | N=0 |
---|
2414 | DO J=JTS_REM,JTE_REM |
---|
2415 | DO I=ITS_REM,ITE_REM |
---|
2416 | N=N+1 |
---|
2417 | TWRITE(I,J)=VALUES(N) |
---|
2418 | ENDDO |
---|
2419 | ENDDO |
---|
2420 | ! |
---|
2421 | DEALLOCATE(VALUES) |
---|
2422 | ! |
---|
2423 | ENDDO |
---|
2424 | ! |
---|
2425 | !---------------------------------------------------------------------- |
---|
2426 | ELSE |
---|
2427 | NSIZE=(ITE-ITS+1)*(JTE-JTS+1) |
---|
2428 | ALLOCATE(VALUES(1:NSIZE)) |
---|
2429 | ! |
---|
2430 | N=0 |
---|
2431 | DO J=JTS,JTE |
---|
2432 | DO I=ITS,ITE |
---|
2433 | N=N+1 |
---|
2434 | VALUES(N)=ARRAY(I,J,K) |
---|
2435 | ENDDO |
---|
2436 | ENDDO |
---|
2437 | ! |
---|
2438 | IT_REM(1)=ITS |
---|
2439 | IT_REM(2)=ITE |
---|
2440 | JT_REM(1)=JTS |
---|
2441 | JT_REM(2)=JTE |
---|
2442 | ! |
---|
2443 | CALL MPI_SEND(IT_REM,2,MPI_INTEGER,0,MYPE & |
---|
2444 | & ,MPI_COMM_COMP,ISEND) |
---|
2445 | CALL MPI_SEND(JT_REM,2,MPI_INTEGER,0,MYPE & |
---|
2446 | & ,MPI_COMM_COMP,ISEND) |
---|
2447 | ! |
---|
2448 | CALL MPI_SEND(VALUES,NSIZE,MPI_REAL,0,MYPE & |
---|
2449 | & ,MPI_COMM_COMP,ISEND) |
---|
2450 | ! |
---|
2451 | DEALLOCATE(VALUES) |
---|
2452 | ! |
---|
2453 | ENDIF |
---|
2454 | !---------------------------------------------------------------------- |
---|
2455 | ! |
---|
2456 | CALL MPI_BARRIER(MPI_COMM_COMP,IRTN) |
---|
2457 | ! |
---|
2458 | IF(MYPE==0)THEN |
---|
2459 | ! |
---|
2460 | DO J=JDS,JDE-1 |
---|
2461 | IENDX=IDE-1 |
---|
2462 | IF(MOD(J,2)==0)IENDX=IENDX-1 |
---|
2463 | WRITE(IUNIT)(TWRITE(I,J),I=1,IENDX) |
---|
2464 | ENDDO |
---|
2465 | ! |
---|
2466 | ENDIF |
---|
2467 | #else |
---|
2468 | |
---|
2469 | DO J=JDS,JDE-1 |
---|
2470 | IENDX=IDE-1 |
---|
2471 | IF(MOD(J,2)==0)IENDX=IENDX-1 |
---|
2472 | WRITE(IUNIT)(ARRAY(I,K,J),I=1,IENDX) |
---|
2473 | ENDDO |
---|
2474 | |
---|
2475 | #endif |
---|
2476 | |
---|
2477 | ! |
---|
2478 | !---------------------------------------------------------------------- |
---|
2479 | 500 CONTINUE |
---|
2480 | ! |
---|
2481 | IF(MYPE==0)CLOSE(IUNIT) |
---|
2482 | !---------------------------------------------------------------------- |
---|
2483 | ! |
---|
2484 | END SUBROUTINE TWR |
---|
2485 | !---------------------------------------------------------------------- |
---|
2486 | !********************************************************************** |
---|
2487 | !---------------------------------------------------------------------- |
---|
2488 | SUBROUTINE VWR(ARRAY,KK,FIELD,ntsd,MYPE,NPES,MPI_COMM_COMP & |
---|
2489 | & ,IDS,IDE,JDS,JDE,KDS,KDE & |
---|
2490 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
2491 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
2492 | !---------------------------------------------------------------------- |
---|
2493 | !********************************************************************** |
---|
2494 | USE MODULE_EXT_INTERNAL |
---|
2495 | ! |
---|
2496 | IMPLICIT NONE |
---|
2497 | #if defined(DM_PARALLEL) && !defined(STUBMPI) |
---|
2498 | INCLUDE "mpif.h" |
---|
2499 | #endif |
---|
2500 | !---------------------------------------------------------------------- |
---|
2501 | !---------------------------------------------------------------------- |
---|
2502 | INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE & |
---|
2503 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
2504 | & ,ITS,ITE,JTS,JTE,KTS,KTE & |
---|
2505 | & ,KK,MPI_COMM_COMP,MYPE,NPES,ntsd |
---|
2506 | ! |
---|
2507 | REAL,DIMENSION(IMS:IME,JMS:JME,KMS:KME+KK),INTENT(IN) :: ARRAY |
---|
2508 | ! |
---|
2509 | CHARACTER(*),INTENT(IN) :: FIELD |
---|
2510 | ! |
---|
2511 | !*** LOCAL VARIABLES |
---|
2512 | ! |
---|
2513 | #if defined(DM_PARALLEL) && !defined(STUBMPI) |
---|
2514 | INTEGER,DIMENSION(MPI_STATUS_SIZE) :: JSTAT |
---|
2515 | INTEGER,DIMENSION(MPI_STATUS_SIZE,4) :: STATUS_ARRAY |
---|
2516 | #endif |
---|
2517 | INTEGER,DIMENSION(2) :: IM_REM,JM_REM,IT_REM,JT_REM |
---|
2518 | ! |
---|
2519 | INTEGER :: I,IENDX,IER,IPE,IRECV,IRTN,ISEND,IUNIT & |
---|
2520 | & ,J,K,L,N,NLEN,NSIZE |
---|
2521 | INTEGER :: ITS_REM,ITE_REM,JTS_REM,JTE_REM |
---|
2522 | ! |
---|
2523 | REAL,DIMENSION(IDS:IDE,JDS:JDE) :: TWRITE |
---|
2524 | REAL,ALLOCATABLE,DIMENSION(:) :: VALUES |
---|
2525 | CHARACTER(5) :: TIMESTEP |
---|
2526 | CHARACTER(6) :: FMT |
---|
2527 | CHARACTER(12) :: FILENAME |
---|
2528 | LOGICAL :: OPENED |
---|
2529 | !---------------------------------------------------------------------- |
---|
2530 | !********************************************************************** |
---|
2531 | !---------------------------------------------------------------------- |
---|
2532 | ! |
---|
2533 | IF(ntsd<=9)THEN |
---|
2534 | FMT='(I1.1)' |
---|
2535 | NLEN=1 |
---|
2536 | ELSEIF(ntsd<=99)THEN |
---|
2537 | FMT='(I2.2)' |
---|
2538 | NLEN=2 |
---|
2539 | ELSEIF(ntsd<=999)THEN |
---|
2540 | FMT='(I3.3)' |
---|
2541 | NLEN=3 |
---|
2542 | ELSEIF(ntsd<=9999)THEN |
---|
2543 | FMT='(I4.4)' |
---|
2544 | NLEN=4 |
---|
2545 | ELSEIF(ntsd<=99999)THEN |
---|
2546 | FMT='(I5.5)' |
---|
2547 | NLEN=5 |
---|
2548 | ENDIF |
---|
2549 | WRITE(TIMESTEP,FMT)ntsd |
---|
2550 | FILENAME=FIELD//'_'//TIMESTEP(1:NLEN) |
---|
2551 | ! |
---|
2552 | IF(MYPE==0)THEN |
---|
2553 | CALL INT_GET_FRESH_HANDLE(IUNIT) |
---|
2554 | CLOSE(IUNIT) |
---|
2555 | OPEN(UNIT=IUNIT,FILE=FILENAME,FORM='UNFORMATTED',IOSTAT=IER) |
---|
2556 | ENDIF |
---|
2557 | ! IF(MYPE==0)THEN |
---|
2558 | ! OPEN_UNIT: DO L=51,99 |
---|
2559 | ! INQUIRE(L,OPENED=OPENED) |
---|
2560 | ! IF(.NOT.OPENED)THEN |
---|
2561 | ! IUNIT=L |
---|
2562 | ! OPEN(UNIT=IUNIT,FILE=FILENAME,STATUS='NEW' & |
---|
2563 | ! ,FORM='UNFORMATTED',IOSTAT=IER) |
---|
2564 | ! IF(IER/=0)THEN |
---|
2565 | ! WRITE(message,*)' Opening file error=',IER |
---|
2566 | ! CALL wrf_message(trim(message)) |
---|
2567 | ! ENDIF |
---|
2568 | ! EXIT OPEN_UNIT |
---|
2569 | ! ENDIF |
---|
2570 | ! ENDDO OPEN_UNIT |
---|
2571 | ! ENDIF |
---|
2572 | ! |
---|
2573 | !---------------------------------------------------------------------- |
---|
2574 | !!!! DO 500 K=KTS,KTE+KK !Unflipped |
---|
2575 | !!!! DO 500 K=KTE+KK,KTS,-1 |
---|
2576 | DO 500 K=KDE-1,KDS,-1 !Write LM layers top down for checking |
---|
2577 | !---------------------------------------------------------------------- |
---|
2578 | ! |
---|
2579 | #if defined(DM_PARALLEL) && !defined(STUBMPI) |
---|
2580 | IF(MYPE==0)THEN |
---|
2581 | DO J=JTS,JTE |
---|
2582 | DO I=ITS,ITE |
---|
2583 | TWRITE(I,J)=ARRAY(I,J,K) |
---|
2584 | ENDDO |
---|
2585 | ENDDO |
---|
2586 | ! |
---|
2587 | DO IPE=1,NPES-1 |
---|
2588 | CALL MPI_RECV(IT_REM,2,MPI_INTEGER,IPE,IPE & |
---|
2589 | & ,MPI_COMM_COMP,JSTAT,IRECV) |
---|
2590 | CALL MPI_RECV(JT_REM,2,MPI_INTEGER,IPE,IPE & |
---|
2591 | & ,MPI_COMM_COMP,JSTAT,IRECV) |
---|
2592 | ! |
---|
2593 | ITS_REM=IT_REM(1) |
---|
2594 | ITE_REM=IT_REM(2) |
---|
2595 | JTS_REM=JT_REM(1) |
---|
2596 | JTE_REM=JT_REM(2) |
---|
2597 | ! |
---|
2598 | NSIZE=(ITE_REM-ITS_REM+1)*(JTE_REM-JTS_REM+1) |
---|
2599 | ALLOCATE(VALUES(1:NSIZE)) |
---|
2600 | ! |
---|
2601 | CALL MPI_RECV(VALUES,NSIZE,MPI_REAL,IPE,IPE & |
---|
2602 | & ,MPI_COMM_COMP,JSTAT,IRECV) |
---|
2603 | N=0 |
---|
2604 | DO J=JTS_REM,JTE_REM |
---|
2605 | DO I=ITS_REM,ITE_REM |
---|
2606 | N=N+1 |
---|
2607 | TWRITE(I,J)=VALUES(N) |
---|
2608 | ENDDO |
---|
2609 | ENDDO |
---|
2610 | ! |
---|
2611 | DEALLOCATE(VALUES) |
---|
2612 | ! |
---|
2613 | ENDDO |
---|
2614 | ! |
---|
2615 | !---------------------------------------------------------------------- |
---|
2616 | ELSE |
---|
2617 | NSIZE=(ITE-ITS+1)*(JTE-JTS+1) |
---|
2618 | ALLOCATE(VALUES(1:NSIZE)) |
---|
2619 | ! |
---|
2620 | N=0 |
---|
2621 | DO J=JTS,JTE |
---|
2622 | DO I=ITS,ITE |
---|
2623 | N=N+1 |
---|
2624 | VALUES(N)=ARRAY(I,J,K) |
---|
2625 | ENDDO |
---|
2626 | ENDDO |
---|
2627 | ! |
---|
2628 | IT_REM(1)=ITS |
---|
2629 | IT_REM(2)=ITE |
---|
2630 | JT_REM(1)=JTS |
---|
2631 | JT_REM(2)=JTE |
---|
2632 | ! |
---|
2633 | CALL MPI_SEND(IT_REM,2,MPI_INTEGER,0,MYPE & |
---|
2634 | & ,MPI_COMM_COMP,ISEND) |
---|
2635 | CALL MPI_SEND(JT_REM,2,MPI_INTEGER,0,MYPE & |
---|
2636 | & ,MPI_COMM_COMP,ISEND) |
---|
2637 | ! |
---|
2638 | CALL MPI_SEND(VALUES,NSIZE,MPI_REAL,0,MYPE & |
---|
2639 | & ,MPI_COMM_COMP,ISEND) |
---|
2640 | ! |
---|
2641 | DEALLOCATE(VALUES) |
---|
2642 | ! |
---|
2643 | ENDIF |
---|
2644 | !---------------------------------------------------------------------- |
---|
2645 | ! |
---|
2646 | CALL MPI_BARRIER(MPI_COMM_COMP,IRTN) |
---|
2647 | ! |
---|
2648 | IF(MYPE==0)THEN |
---|
2649 | ! |
---|
2650 | DO J=JDS,JDE-1 |
---|
2651 | IENDX=IDE-1 |
---|
2652 | IF(MOD(J,2)==1)IENDX=IENDX-1 |
---|
2653 | WRITE(IUNIT)(TWRITE(I,J),I=1,IENDX) |
---|
2654 | ENDDO |
---|
2655 | ! |
---|
2656 | ENDIF |
---|
2657 | #else |
---|
2658 | |
---|
2659 | DO J=JDS,JDE-1 |
---|
2660 | IENDX=IDE-1 |
---|
2661 | IF(MOD(J,2)==0)IENDX=IENDX-1 |
---|
2662 | WRITE(IUNIT)(ARRAY(I,K,J),I=1,IENDX) |
---|
2663 | ENDDO |
---|
2664 | |
---|
2665 | #endif |
---|
2666 | ! |
---|
2667 | !---------------------------------------------------------------------- |
---|
2668 | 500 CONTINUE |
---|
2669 | ! |
---|
2670 | IF(MYPE==0)CLOSE(IUNIT) |
---|
2671 | !---------------------------------------------------------------------- |
---|
2672 | ! |
---|
2673 | END SUBROUTINE VWR |
---|
2674 | !---------------------------------------------------------------------- |
---|
2675 | !********************************************************************** |
---|
2676 | !---------------------------------------------------------------------- |
---|
2677 | SUBROUTINE EXIT(NAME,pint,t,q,u,v,q2,w & |
---|
2678 | & ,ntsd,MYPE,MPI_COMM_COMP & |
---|
2679 | & ,IDS,IDE,JDS,JDE,KDS,KDE & |
---|
2680 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
2681 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
2682 | !---------------------------------------------------------------------- |
---|
2683 | !********************************************************************** |
---|
2684 | USE MODULE_EXT_INTERNAL |
---|
2685 | ! |
---|
2686 | !---------------------------------------------------------------------- |
---|
2687 | IMPLICIT NONE |
---|
2688 | !---------------------------------------------------------------------- |
---|
2689 | #if defined(DM_PARALLEL) && !defined(STUBMPI) |
---|
2690 | INCLUDE "mpif.h" |
---|
2691 | #endif |
---|
2692 | !---------------------------------------------------------------------- |
---|
2693 | INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE & |
---|
2694 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
2695 | & ,ITS,ITE,JTS,JTE,KTS,KTE & |
---|
2696 | & ,MYPE,MPI_COMM_COMP,ntsd |
---|
2697 | ! |
---|
2698 | REAL,DIMENSION(IMS:IME,JMS:JME,KMS:KME),INTENT(IN) :: pint,t,q & |
---|
2699 | ,u,v,q2,w |
---|
2700 | CHARACTER(*),INTENT(IN) :: NAME |
---|
2701 | ! |
---|
2702 | INTEGER :: I,J,K,IEND,IERR,IRET |
---|
2703 | CHARACTER(256) :: ERRMESS |
---|
2704 | LOGICAL :: E_BDY,S_BDY |
---|
2705 | !---------------------------------------------------------------------- |
---|
2706 | IRET=0 |
---|
2707 | 100 FORMAT(' EXIT ',A,' AT ntsd=',I5) |
---|
2708 | IEND=ITE |
---|
2709 | S_BDY=(JTS==JDS) |
---|
2710 | E_BDY=(ITE==IDE-1) |
---|
2711 | ! |
---|
2712 | DO K=KTS,KTE |
---|
2713 | DO J=JTS,JTE |
---|
2714 | IEND=ITE |
---|
2715 | IF(E_BDY.AND.MOD(J,2)==0)IEND=ITE-1 |
---|
2716 | ! |
---|
2717 | DO I=ITS,IEND |
---|
2718 | IF(t(I,J,K)>330..OR.t(I,J,K)<180..OR.t(I,J,K)/=t(I,J,K))THEN |
---|
2719 | WRITE(errmess,100)NAME,ntsd |
---|
2720 | CALL wrf_message(trim(errmess)) |
---|
2721 | WRITE(errmess,200)I,J,K,t(I,J,K),MYPE,ntsd |
---|
2722 | CALL wrf_message(trim(errmess)) |
---|
2723 | 200 FORMAT(' BAD VALUE I=',I3,' J=',I3,' K=',I2,' t=',E12.5 & |
---|
2724 | &, ' MYPE=',I3,' ntsd=',I5) |
---|
2725 | IRET=666 |
---|
2726 | return |
---|
2727 | ! WRITE(ERRMESS,205)NAME,t(I,J,K),I,J,K,MYPE |
---|
2728 | 205 FORMAT(' EXIT ',A,' TEMPERATURE=',E12.5 & |
---|
2729 | &, ' AT (',I3,',',I2,',',I3,')',' MYPE=',I3) |
---|
2730 | ! CALL WRF_ERROR_FATAL(ERRMESS) |
---|
2731 | ! CALL MPI_ABORT(MPI_COMM_WORLD,1,IERR) |
---|
2732 | ELSEIF(q(I,J,K)<-1.E-4.OR.q(I,J,K)>30.E-3 & |
---|
2733 | & .OR.q(I,J,K)/=q(I,J,K))THEN |
---|
2734 | WRITE(errmess,100)NAME,ntsd |
---|
2735 | CALL wrf_message(trim(errmess)) |
---|
2736 | WRITE(errmess,300)I,J,K,q(I,J,K),MYPE,ntsd |
---|
2737 | CALL wrf_message(trim(errmess)) |
---|
2738 | 300 FORMAT(' BAD VALUE I=',I3,' J=',I3,' K=',I2,' q=',E12.5 & |
---|
2739 | &, ' MYPE=',I3,' ntsd=',I5) |
---|
2740 | IRET=666 |
---|
2741 | return |
---|
2742 | ! WRITE(ERRMESS,305)NAME,q(I,J,K),I,J,K,MYPE |
---|
2743 | 305 FORMAT(' EXIT ',A,' SPEC HUMIDITY=',E12.5 & |
---|
2744 | &, ' AT (',I3,',',I2,',',I3,')',' MYPE=',I3) |
---|
2745 | ! CALL WRF_ERROR_FATAL(ERRMESS) |
---|
2746 | ! CALL MPI_ABORT(MPI_COMM_WORLD,1,IERR) |
---|
2747 | ELSEIF(pint(I,J,K)<0..OR.pint(I,J,K)/=pint(I,J,K))THEN |
---|
2748 | WRITE(errmess,100)NAME,ntsd |
---|
2749 | CALL wrf_message(trim(errmess)) |
---|
2750 | WRITE(errmess,315)I,J,K,pint(I,J,K),MYPE,ntsd |
---|
2751 | CALL wrf_message(trim(errmess)) |
---|
2752 | 315 FORMAT(' BAD VALUE I=',I3,' J=',I3,' K=',I2,' pint=',E12.5 & |
---|
2753 | &, ' MYPE=',I3,' ntsd=',I5) |
---|
2754 | IRET=666 |
---|
2755 | return |
---|
2756 | ! CALL WRF_ERROR_FATAL(ERRMESS) |
---|
2757 | ! CALL MPI_ABORT(MPI_COMM_WORLD,1,IERR) |
---|
2758 | ELSEIF(w(I,J,K)/=w(I,J,K))THEN |
---|
2759 | WRITE(errmess,100)NAME,ntsd |
---|
2760 | CALL wrf_message(trim(errmess)) |
---|
2761 | WRITE(errmess,325)I,J,K,w(I,J,K),MYPE,ntsd |
---|
2762 | CALL wrf_message(trim(errmess)) |
---|
2763 | 325 FORMAT(' BAD VALUE I=',I3,' J=',I3,' K=',I2,' w=',E12.5 & |
---|
2764 | &, ' MYPE=',I3,' ntsd=',I5) |
---|
2765 | IRET=666 |
---|
2766 | return |
---|
2767 | ! CALL WRF_ERROR_FATAL(ERRMESS) |
---|
2768 | ! CALL MPI_ABORT(MPI_COMM_WORLD,1,IERR) |
---|
2769 | ENDIF |
---|
2770 | ENDDO |
---|
2771 | ENDDO |
---|
2772 | ENDDO |
---|
2773 | ! |
---|
2774 | DO K=KTS,KTE |
---|
2775 | DO J=JTS,JTE |
---|
2776 | IEND=ITE |
---|
2777 | IF(E_BDY.AND.MOD(J,2)==1)IEND=ITE-1 |
---|
2778 | DO I=ITS,IEND |
---|
2779 | IF(ABS(u(I,J,K))>125..OR.ABS(v(I,J,K))>125. & |
---|
2780 | & .OR.u(I,J,K)/=u(I,J,K).OR.v(I,J,K)/=v(I,J,K))THEN |
---|
2781 | WRITE(errmess,100)NAME,ntsd |
---|
2782 | CALL wrf_message(trim(errmess)) |
---|
2783 | WRITE(errmess,400)I,J,K,u(I,J,K),v(I,J,K),MYPE,ntsd |
---|
2784 | CALL wrf_message(trim(errmess)) |
---|
2785 | 400 FORMAT(' BAD VALUE I=',I3,' J=',I3,' K=',I2,' u=',E12.5 & |
---|
2786 | &, ' v=',E12.5,' MYPE=',I3,' ntsd=',I5) |
---|
2787 | IRET=666 |
---|
2788 | return |
---|
2789 | ! WRITE(ERRMESS,405)NAME,u(I,J,K),v(I,J,K),I,J,K,MYPE |
---|
2790 | 405 FORMAT(' EXIT ',A,' u=',E12.5,' v=',E12.5 & |
---|
2791 | &, ' AT (',I3,',',I2,',',I3,')',' MYPE=',I3) |
---|
2792 | ! CALL WRF_ERROR_FATAL(ERRMESS) |
---|
2793 | ! CALL MPI_ABORT(MPI_COMM_WORLD,1,IERR) |
---|
2794 | ENDIF |
---|
2795 | ENDDO |
---|
2796 | ENDDO |
---|
2797 | ENDDO |
---|
2798 | !---------------------------------------------------------------------- |
---|
2799 | END SUBROUTINE EXIT |
---|
2800 | !---------------------------------------------------------------------- |
---|
2801 | !********************************************************************** |
---|
2802 | !---------------------------------------------------------------------- |
---|
2803 | SUBROUTINE TIME_STATS(TIME_LCL,NAME,ntsd,MYPE,NPES,MPI_COMM_COMP) |
---|
2804 | !---------------------------------------------------------------------- |
---|
2805 | !********************************************************************** |
---|
2806 | USE MODULE_EXT_INTERNAL |
---|
2807 | ! |
---|
2808 | !---------------------------------------------------------------------- |
---|
2809 | IMPLICIT NONE |
---|
2810 | !---------------------------------------------------------------------- |
---|
2811 | #if defined(DM_PARALLEL) && !defined(STUBMPI) |
---|
2812 | INCLUDE "mpif.h" |
---|
2813 | #endif |
---|
2814 | !---------------------------------------------------------------------- |
---|
2815 | INTEGER,INTENT(IN) :: MPI_COMM_COMP,MYPE,NPES,ntsd |
---|
2816 | REAL,INTENT(IN) :: TIME_LCL |
---|
2817 | ! |
---|
2818 | CHARACTER(*),INTENT(IN) :: NAME |
---|
2819 | ! |
---|
2820 | !*** LOCAL VARIABLES |
---|
2821 | ! |
---|
2822 | #if defined(DM_PARALLEL) && !defined(STUBMPI) |
---|
2823 | INTEGER,DIMENSION(MPI_STATUS_SIZE) :: JSTAT |
---|
2824 | INTEGER,DIMENSION(MPI_STATUS_SIZE,4) :: STATUS_ARRAY |
---|
2825 | #endif |
---|
2826 | INTEGER,ALLOCATABLE,DIMENSION(:) :: ID_PE,IPE_SORT |
---|
2827 | ! |
---|
2828 | INTEGER :: IPE,IPE_MAX,IPE_MEDIAN,IPE_MIN,IRECV,IRTN,ISEND & |
---|
2829 | & ,N,N_MEDIAN,NLEN |
---|
2830 | ! |
---|
2831 | REAL,ALLOCATABLE,DIMENSION(:) :: TIME,SORT_TIME |
---|
2832 | REAL,DIMENSION(2) :: REMOTE |
---|
2833 | REAL :: TIME_MAX,TIME_MEAN,TIME_MEDIAN,TIME_MIN |
---|
2834 | ! |
---|
2835 | CHARACTER(5) :: TIMESTEP |
---|
2836 | CHARACTER(6) :: FMT |
---|
2837 | CHARACTER(25) :: TITLE |
---|
2838 | CHARACTER(LEN=256) :: message |
---|
2839 | !---------------------------------------------------------------------- |
---|
2840 | !********************************************************************** |
---|
2841 | !---------------------------------------------------------------------- |
---|
2842 | ! |
---|
2843 | IF(ntsd<=9)THEN |
---|
2844 | FMT='(I1.1)' |
---|
2845 | NLEN=1 |
---|
2846 | ELSEIF(ntsd<=99)THEN |
---|
2847 | FMT='(I2.2)' |
---|
2848 | NLEN=2 |
---|
2849 | ELSEIF(ntsd<=999)THEN |
---|
2850 | FMT='(I3.3)' |
---|
2851 | NLEN=3 |
---|
2852 | ELSEIF(ntsd<=9999)THEN |
---|
2853 | FMT='(I4.4)' |
---|
2854 | NLEN=4 |
---|
2855 | ELSEIF(ntsd<=99999)THEN |
---|
2856 | FMT='(I5.5)' |
---|
2857 | NLEN=5 |
---|
2858 | ENDIF |
---|
2859 | WRITE(TIMESTEP,FMT)ntsd |
---|
2860 | TITLE=NAME//'_'//TIMESTEP(1:NLEN) |
---|
2861 | ! |
---|
2862 | !---------------------------------------------------------------------- |
---|
2863 | ! |
---|
2864 | #if defined(DM_PARALLEL) && !defined(STUBMPI) |
---|
2865 | IF(MYPE==0)THEN |
---|
2866 | ALLOCATE(TIME(1:NPES)) |
---|
2867 | ALLOCATE(SORT_TIME(1:NPES)) |
---|
2868 | ALLOCATE(ID_PE(1:NPES)) |
---|
2869 | ALLOCATE(IPE_SORT(1:NPES)) |
---|
2870 | ! |
---|
2871 | TIME(1)=TIME_LCL |
---|
2872 | ID_PE(1)=MYPE |
---|
2873 | ! |
---|
2874 | !*** COLLECT TIMES AND PE VALUES FROM OTHER PEs |
---|
2875 | ! |
---|
2876 | DO IPE=1,NPES-1 |
---|
2877 | CALL MPI_RECV(REMOTE,2,MPI_REAL,IPE,IPE & |
---|
2878 | & ,MPI_COMM_COMP,JSTAT,IRECV) |
---|
2879 | ! |
---|
2880 | TIME(IPE+1)=REMOTE(1) |
---|
2881 | ID_PE(IPE+1)=NINT(REMOTE(2)) |
---|
2882 | ENDDO |
---|
2883 | ! |
---|
2884 | !*** NOW GET STATS. |
---|
2885 | !*** FIRST THE MAX, MIN, AND MEAN TIMES. |
---|
2886 | ! |
---|
2887 | TIME_MEAN=0. |
---|
2888 | TIME_MAX=-1. |
---|
2889 | TIME_MIN=1.E10 |
---|
2890 | IPE_MAX=-1 |
---|
2891 | IPE_MIN=-1 |
---|
2892 | ! |
---|
2893 | DO N=1,NPES |
---|
2894 | TIME_MEAN=TIME_MEAN+TIME(N) |
---|
2895 | ! |
---|
2896 | IF(TIME(N)>TIME_MAX)THEN |
---|
2897 | TIME_MAX=TIME(N) |
---|
2898 | IPE_MAX=ID_PE(N) |
---|
2899 | ENDIF |
---|
2900 | ! |
---|
2901 | IF(TIME(N)<TIME_MIN)THEN |
---|
2902 | TIME_MIN=TIME(N) |
---|
2903 | IPE_MIN=ID_PE(N) |
---|
2904 | ENDIF |
---|
2905 | ! |
---|
2906 | ENDDO |
---|
2907 | ! |
---|
2908 | TIME_MAX=TIME_MAX*1.E-3 |
---|
2909 | TIME_MIN=TIME_MIN*1.E-3 |
---|
2910 | TIME_MEAN=TIME_MEAN*1.E-3/REAL(NPES) |
---|
2911 | ! |
---|
2912 | !*** THEN THE MEDIAN TIME. |
---|
2913 | ! |
---|
2914 | CALL SORT(TIME,NPES,SORT_TIME,IPE_SORT) |
---|
2915 | N_MEDIAN=(NPES+1)/2 |
---|
2916 | TIME_MEDIAN=SORT_TIME(N_MEDIAN)*1.E-3 |
---|
2917 | IPE_MEDIAN=IPE_SORT(N_MEDIAN) |
---|
2918 | ! |
---|
2919 | !---------------------------------------------------------------------- |
---|
2920 | ELSE |
---|
2921 | ! |
---|
2922 | !*** SEND TIME AND PE VALUE TO PE0. |
---|
2923 | ! |
---|
2924 | REMOTE(1)=TIME_LCL |
---|
2925 | REMOTE(2)=REAL(MYPE) |
---|
2926 | ! |
---|
2927 | CALL MPI_SEND(REMOTE,2,MPI_REAL,0,MYPE,MPI_COMM_COMP,ISEND) |
---|
2928 | ! |
---|
2929 | ENDIF |
---|
2930 | !---------------------------------------------------------------------- |
---|
2931 | ! |
---|
2932 | CALL MPI_BARRIER(MPI_COMM_COMP,IRTN) |
---|
2933 | ! |
---|
2934 | !*** WRITE RESULTS |
---|
2935 | ! |
---|
2936 | IF(MYPE==0)THEN |
---|
2937 | WRITE(message,100)TITLE |
---|
2938 | CALL wrf_message(trim(message)) |
---|
2939 | WRITE(message,105)TIME_MAX,IPE_MAX |
---|
2940 | CALL wrf_message(trim(message)) |
---|
2941 | WRITE(message,110)TIME_MIN,IPE_MIN |
---|
2942 | CALL wrf_message(trim(message)) |
---|
2943 | WRITE(message,115)TIME_MEDIAN,IPE_MEDIAN |
---|
2944 | CALL wrf_message(trim(message)) |
---|
2945 | WRITE(message,120)TIME_MEAN |
---|
2946 | CALL wrf_message(trim(message)) |
---|
2947 | 100 FORMAT(' Time for ',A) |
---|
2948 | 105 FORMAT(' Maximum=',G11.5,' for PE ',I2.2) |
---|
2949 | 110 FORMAT(' Minimum=',G11.5,' for PE ',I2.2) |
---|
2950 | 115 FORMAT(' Median =',G11.5,' for PE ',I2.2) |
---|
2951 | 120 FORMAT(' Mean =',G11.5) |
---|
2952 | ENDIF |
---|
2953 | !---------------------------------------------------------------------- |
---|
2954 | ! |
---|
2955 | #endif |
---|
2956 | END SUBROUTINE TIME_STATS |
---|
2957 | ! |
---|
2958 | !---------------------------------------------------------------------- |
---|
2959 | !********************************************************************** |
---|
2960 | !---------------------------------------------------------------------- |
---|
2961 | SUBROUTINE SORT(DATA,NPES,DATA_SORTED,IPE_SORTED) |
---|
2962 | !---------------------------------------------------------------------- |
---|
2963 | !*** |
---|
2964 | !*** SORT DATA FROM MULTIPLE PEs. SEND BACK THE SORTED DATA ITEMS |
---|
2965 | !*** ALONG WITH THE ASSOCIATED TASK IDs. |
---|
2966 | !*** |
---|
2967 | !---------------------------------------------------------------------- |
---|
2968 | IMPLICIT NONE |
---|
2969 | !---------------------------------------------------------------------- |
---|
2970 | INTEGER,INTENT(IN) :: NPES |
---|
2971 | REAL,DIMENSION(NPES),INTENT(IN) :: DATA |
---|
2972 | ! |
---|
2973 | INTEGER,DIMENSION(NPES),INTENT(OUT) :: IPE_SORTED |
---|
2974 | REAL,DIMENSION(NPES),INTENT(OUT) :: DATA_SORTED |
---|
2975 | !---------------------------------------------------------------------- |
---|
2976 | TYPE :: DATA_LINK |
---|
2977 | REAL :: VALUE |
---|
2978 | INTEGER :: IPE |
---|
2979 | TYPE(DATA_LINK),POINTER :: NEXT_VALUE |
---|
2980 | END TYPE |
---|
2981 | !---------------------------------------------------------------------- |
---|
2982 | ! |
---|
2983 | !*** LOCAL VARIABLES |
---|
2984 | ! |
---|
2985 | !---------------------------------------------------------------------- |
---|
2986 | INTEGER :: ISTAT,N |
---|
2987 | ! |
---|
2988 | TYPE(DATA_LINK),POINTER :: HEAD,TAIL ! Smallest, largest |
---|
2989 | TYPE(DATA_LINK),POINTER :: PTR_NEW ! Each new value |
---|
2990 | TYPE(DATA_LINK),POINTER :: PTR1,PTR2 ! Working pointers |
---|
2991 | !---------------------------------------------------------------------- |
---|
2992 | !********************************************************************** |
---|
2993 | !---------------------------------------------------------------------- |
---|
2994 | pe_loop: DO N=1,NPES |
---|
2995 | ALLOCATE(PTR_NEW,STAT=ISTAT) ! Location for next data items |
---|
2996 | PTR_NEW%VALUE=DATA(N) |
---|
2997 | PTR_NEW%IPE=N-1 |
---|
2998 | ! |
---|
2999 | !---------------------------------------------------------------------- |
---|
3000 | !*** DETERMINE WHERE IN LIST TO INSERT VALUE. |
---|
3001 | !*** FIRST THE INITIAL DATA VALUE. |
---|
3002 | !---------------------------------------------------------------------- |
---|
3003 | ! |
---|
3004 | ! main: IF(.NOT.ASSOCIATED(HEAD))THEN |
---|
3005 | main: IF(N==1)THEN |
---|
3006 | HEAD=>PTR_NEW |
---|
3007 | TAIL=>HEAD |
---|
3008 | NULLIFY(PTR_NEW%NEXT_VALUE) |
---|
3009 | ! |
---|
3010 | !---------------------------------------------------------------------- |
---|
3011 | !*** THE NEW VALUE IS LESS THAN THE SMALLEST VALUE ALREADY SORTED. |
---|
3012 | !---------------------------------------------------------------------- |
---|
3013 | ! |
---|
3014 | ELSE |
---|
3015 | check: IF(PTR_NEW%VALUE<HEAD%VALUE)THEN |
---|
3016 | PTR_NEW%NEXT_VALUE=>HEAD |
---|
3017 | HEAD=>PTR_NEW |
---|
3018 | ! |
---|
3019 | !---------------------------------------------------------------------- |
---|
3020 | !*** THE NEW VALUE IS GREATER THAN THE LARGEST VALUE ALREADY SORTED. |
---|
3021 | !---------------------------------------------------------------------- |
---|
3022 | ! |
---|
3023 | ELSEIF(PTR_NEW%VALUE>=TAIL%VALUE)THEN |
---|
3024 | TAIL%NEXT_VALUE=>PTR_NEW ! This is what connects the former |
---|
3025 | ! final value in the list to |
---|
3026 | ! the new value being appended. |
---|
3027 | TAIL=>PTR_NEW |
---|
3028 | NULLIFY(TAIL%NEXT_VALUE) |
---|
3029 | ! |
---|
3030 | !---------------------------------------------------------------------- |
---|
3031 | !*** THE NEW VALUE IS IN BETWEEN VALUES ALREADY SORTED. |
---|
3032 | !---------------------------------------------------------------------- |
---|
3033 | ! |
---|
3034 | ELSE |
---|
3035 | PTR1=>HEAD |
---|
3036 | PTR2=>PTR1%NEXT_VALUE |
---|
3037 | ! |
---|
3038 | search: DO |
---|
3039 | IF((PTR_NEW%VALUE>=PTR1%VALUE).AND. & |
---|
3040 | & (PTR_NEW%VALUE<PTR2%VALUE))THEN |
---|
3041 | PTR_NEW%NEXT_VALUE=>PTR2 |
---|
3042 | PTR1%NEXT_VALUE=>PTR_NEW |
---|
3043 | EXIT search |
---|
3044 | ENDIF |
---|
3045 | ! |
---|
3046 | PTR1=>PTR2 |
---|
3047 | PTR2=>PTR2%NEXT_VALUE |
---|
3048 | ENDDO search |
---|
3049 | ! |
---|
3050 | ENDIF check |
---|
3051 | ! |
---|
3052 | ENDIF main |
---|
3053 | ! |
---|
3054 | ENDDO pe_loop |
---|
3055 | ! |
---|
3056 | !---------------------------------------------------------------------- |
---|
3057 | !*** COLLECT THE SORTED NUMBERS FROM THE LINKED LIST. |
---|
3058 | !---------------------------------------------------------------------- |
---|
3059 | ! |
---|
3060 | PTR1=>HEAD |
---|
3061 | ! |
---|
3062 | DO N=1,NPES |
---|
3063 | ! IF(.NOT.ASSOCIATED(PTR_NEW))EXIT |
---|
3064 | DATA_SORTED(N)=PTR1%VALUE |
---|
3065 | IPE_SORTED(N)=PTR1%IPE |
---|
3066 | PTR1=>PTR1%NEXT_VALUE |
---|
3067 | ENDDO |
---|
3068 | ! |
---|
3069 | DEALLOCATE(PTR_NEW) |
---|
3070 | NULLIFY (HEAD,TAIL,PTR1,PTR2) |
---|
3071 | !---------------------------------------------------------------------- |
---|
3072 | END SUBROUTINE SORT |
---|
3073 | !---------------------------------------------------------------------- |
---|
3074 | !********************************************************************** |
---|
3075 | !---------------------------------------------------------------------- |
---|
3076 | SUBROUTINE FIELD_STATS(FIELD,MYPE,MPI_COMM_COMP & |
---|
3077 | & ,IDS,IDE,JDS,JDE,KDS,KDE & |
---|
3078 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
3079 | & ,ITS,ITE,JTS,JTE,KTS,KTE) |
---|
3080 | !---------------------------------------------------------------------- |
---|
3081 | !*** |
---|
3082 | !*** GENERATE STANDARD LAYER STATISTICS FOR THE DESIRED FIELD. |
---|
3083 | !*** |
---|
3084 | !---------------------------------------------------------------------- |
---|
3085 | IMPLICIT NONE |
---|
3086 | !---------------------------------------------------------------------- |
---|
3087 | #if defined(DM_PARALLEL) && !defined(STUBMPI) |
---|
3088 | INCLUDE "mpif.h" |
---|
3089 | #endif |
---|
3090 | !---------------------------------------------------------------------- |
---|
3091 | ! |
---|
3092 | INTEGER,INTENT(IN) :: MPI_COMM_COMP,MYPE |
---|
3093 | INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE & |
---|
3094 | & ,IMS,IME,JMS,JME,KMS,KME & |
---|
3095 | & ,ITS,ITE,JTS,JTE,KTS,KTE |
---|
3096 | ! |
---|
3097 | REAL,DIMENSION(IMS:IME,JMS:JME,KMS:KME),INTENT(IN) :: FIELD |
---|
3098 | ! |
---|
3099 | !---------------------------------------------------------------------- |
---|
3100 | !*** LOCAL |
---|
3101 | !---------------------------------------------------------------------- |
---|
3102 | ! |
---|
3103 | INTEGER,PARAMETER :: DOUBLE=SELECTED_REAL_KIND(15,300) |
---|
3104 | ! |
---|
3105 | INTEGER :: I,IEND,IRTN,I_BY_J,J,K,KFLIP |
---|
3106 | ! |
---|
3107 | REAL :: FIKJ,FMAXK,FMINK |
---|
3108 | REAL(KIND=DOUBLE) :: F_MEAN,POINTS,RMS,ST_DEV,SUMFK,SUMF2K |
---|
3109 | REAL,DIMENSION(KTS:KTE) :: FMAX,FMAX_0,FMIN,FMIN_0 |
---|
3110 | REAL(KIND=DOUBLE),DIMENSION(KTS:KTE) :: SUMF,SUMF_0,SUMF2,SUMF2_0 |
---|
3111 | |
---|
3112 | CHARACTER(LEN=256) :: message |
---|
3113 | !---------------------------------------------------------------------- |
---|
3114 | ! |
---|
3115 | I_BY_J=(IDE-IDS)*(JDE-JDS)-(JDE-JDS-1)/2 ! This assumes that |
---|
3116 | ! IDE and JDE are each |
---|
3117 | ! one greater than the |
---|
3118 | ! true grid size. |
---|
3119 | #if defined(DM_PARALLEL) && !defined(STUBMPI) |
---|
3120 | ! |
---|
3121 | layer_loop: DO K=KTS,KTE |
---|
3122 | ! |
---|
3123 | FMAXK=-1.E10 |
---|
3124 | FMINK=1.E10 |
---|
3125 | SUMFK=0. |
---|
3126 | SUMF2K=0. |
---|
3127 | ! |
---|
3128 | DO J=JTS,JTE |
---|
3129 | IEND=MIN(ITE,IDE-1) |
---|
3130 | IF(MOD(J,2)==0.AND.ITE==IDE-1)IEND=IEND-1 |
---|
3131 | DO I=ITS,IEND |
---|
3132 | FIKJ=FIELD(I,J,K) |
---|
3133 | FMAXK=MAX(FMAXK,FIKJ) |
---|
3134 | FMINK=MIN(FMINK,FIKJ) |
---|
3135 | SUMFK=SUMFK+FIKJ |
---|
3136 | SUMF2K=SUMF2K+FIKJ*FIKJ |
---|
3137 | ENDDO |
---|
3138 | ENDDO |
---|
3139 | ! |
---|
3140 | FMAX(K)=FMAXK |
---|
3141 | FMIN(K)=FMINK |
---|
3142 | SUMF(K)=SUMFK |
---|
3143 | SUMF2(K)=SUMF2K |
---|
3144 | ! |
---|
3145 | ENDDO layer_loop |
---|
3146 | ! |
---|
3147 | !---------------------------------------------------------------------- |
---|
3148 | !*** GLOBAL STATS |
---|
3149 | !---------------------------------------------------------------------- |
---|
3150 | ! |
---|
3151 | CALL MPI_REDUCE(SUMF,SUMF_0,KTE,MPI_REAL8,MPI_SUM,0 & |
---|
3152 | & ,MPI_COMM_COMP,IRTN) |
---|
3153 | CALL MPI_REDUCE(SUMF2,SUMF2_0,KTE,MPI_REAL8,MPI_SUM,0 & |
---|
3154 | & ,MPI_COMM_COMP,IRTN) |
---|
3155 | CALL MPI_REDUCE(FMAX,FMAX_0,KTE,MPI_REAL,MPI_MAX,0 & |
---|
3156 | & ,MPI_COMM_COMP,IRTN) |
---|
3157 | CALL MPI_REDUCE(FMIN,FMIN_0,KTE,MPI_REAL,MPI_MIN,0 & |
---|
3158 | & ,MPI_COMM_COMP,IRTN) |
---|
3159 | ! |
---|
3160 | IF(MYPE==0)THEN |
---|
3161 | POINTS=I_BY_J |
---|
3162 | DO K=KTE,KTS,-1 |
---|
3163 | F_MEAN=SUMF_0(K)/POINTS |
---|
3164 | ST_DEV=SQRT((POINTS*SUMF2_0(K)-SUMF_0(K)*SUMF_0(K))/ & |
---|
3165 | & (POINTS*(POINTS-1))) |
---|
3166 | RMS=SQRT(SUMF2_0(K)/POINTS) |
---|
3167 | KFLIP=KTE-K+1 |
---|
3168 | WRITE(message,101)KFLIP,FMAX_0(K),FMIN_0(K) |
---|
3169 | CALL wrf_message(trim(message)) |
---|
3170 | WRITE(message,102)F_MEAN,ST_DEV,RMS |
---|
3171 | CALL wrf_message(trim(message)) |
---|
3172 | 101 FORMAT(' LAYER=',I2,' MAX=',E13.6,' MIN=',E13.6) |
---|
3173 | 102 FORMAT(9X,' MEAN=',E13.6,' STDEV=',E13.6,' RMS=',E13.6) |
---|
3174 | ENDDO |
---|
3175 | ENDIF |
---|
3176 | #endif |
---|
3177 | !---------------------------------------------------------------------- |
---|
3178 | END SUBROUTINE FIELD_STATS |
---|
3179 | !---------------------------------------------------------------------- |
---|
3180 | FUNCTION TIMEF() |
---|
3181 | REAL*8 TIMEF |
---|
3182 | INTEGER :: IC,IR |
---|
3183 | CALL SYSTEM_CLOCK(COUNT=IC,COUNT_RATE=IR) |
---|
3184 | TIMEF=REAL(IC)/REAL(IR)*1000.0 |
---|
3185 | END |
---|