24 vcoord_target, delp_target_grid, &
25 dzdt_target_grid, ps_target_grid, &
26 temp_target_grid, tracers_target_grid, &
27 u_s_target_grid, v_s_target_grid, &
28 u_w_target_grid, v_w_target_grid, &
29 zh_target_grid, qnwfa_climo_target_grid, &
30 qnifa_climo_target_grid
47 latitude_s_target_grid, &
48 longitude_s_target_grid, &
49 latitude_w_target_grid, &
50 longitude_w_target_grid, &
54 wam_cold_start, wam_parm_file, &
55 cycle_year, cycle_mon, &
56 cycle_day, cycle_hour, &
58 tracers, num_tracers, &
65 qnifa_climo_input_grid, &
66 qnwfa_climo_input_grid, &
67 thomp_pres_climo_input_grid, &
80 type(esmf_field
) :: dzdt_b4adj_target_grid
81 type(esmf_field),
allocatable :: tracers_b4adj_target_grid(:)
82 type(esmf_field) :: ps_b4adj_target_grid
83 type(esmf_field) :: pres_target_grid
84 type(esmf_field) :: pres_b4adj_target_grid
85 type(esmf_field) :: temp_b4adj_target_grid
86 type(esmf_field) :: terrain_interp_to_target_grid
87 type(esmf_field) :: xwind_target_grid
88 type(esmf_field) :: ywind_target_grid
89 type(esmf_field) :: zwind_target_grid
90 type(esmf_field) :: xwind_b4adj_target_grid
91 type(esmf_field) :: ywind_b4adj_target_grid
92 type(esmf_field) :: zwind_b4adj_target_grid
93 type(esmf_field) :: xwind_s_target_grid
94 type(esmf_field) :: ywind_s_target_grid
95 type(esmf_field) :: zwind_s_target_grid
96 type(esmf_field) :: xwind_w_target_grid
97 type(esmf_field) :: ywind_w_target_grid
98 type(esmf_field) :: zwind_w_target_grid
102 type(esmf_field
) :: qnifa_climo_b4adj_target_grid
104 type(esmf_field) :: qnwfa_climo_b4adj_target_grid
106 type(esmf_field) :: thomp_pres_climo_b4adj_target_grid
124 integer,
intent(in) :: localpet
126 integer :: isrctermprocessing
129 type(esmf_regridmethod_flag
) :: method
130 type(esmf_routehandle
) :: regrid_bl
132 real(esmf_kind_r8),
parameter :: p0=101325.0
133 real(esmf_kind_r8),
parameter :: rd = 287.058
134 real(esmf_kind_r8),
parameter :: grav = 9.81
135 real(esmf_kind_r8),
parameter :: lapse = -6.5e-03
137 real(esmf_kind_r8),
parameter :: exponent = rd*lapse/grav
138 real(esmf_kind_r8),
parameter :: one_over_exponent = 1.0 / exponent
140 real(esmf_kind_r8),
pointer :: psptr(:,:), tempptr(:,:,:)
164 isrctermprocessing = 1
166 if (trim(atm_weight_file) /=
"NULL")
then
168 print*,
"- CALL FieldSMMStore FOR ATMOSPHERIC FIELDS."
170 call esmf_fieldsmmstore(temp_input_grid, &
171 temp_b4adj_target_grid, &
173 routehandle=regrid_bl, &
174 srctermprocessing=isrctermprocessing, rc=rc)
175 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
180 print*,
"- CALL FieldRegridStore FOR ATMOSPHERIC FIELDS."
182 method=esmf_regridmethod_bilinear
184 call esmf_fieldregridstore(temp_input_grid, &
185 temp_b4adj_target_grid, &
186 polemethod=esmf_polemethod_allavg, &
187 srctermprocessing=isrctermprocessing, &
188 routehandle=regrid_bl, &
189 regridmethod=method, rc=rc)
190 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
195 print*,
"- CALL Field_Regrid FOR TEMPERATURE."
196 call esmf_fieldregrid(temp_input_grid, &
197 temp_b4adj_target_grid, &
198 routehandle=regrid_bl, &
199 termorderflag=esmf_termorder_srcseq, &
201 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
204 print*,
"- CALL Field_Regrid FOR PRESSURE."
205 call esmf_fieldregrid(pres_input_grid, &
206 pres_b4adj_target_grid, &
207 routehandle=regrid_bl, &
208 termorderflag=esmf_termorder_srcseq, &
210 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
213 do n = 1, num_tracers_input
214 print*,
"- CALL Field_Regrid FOR TRACER ", trim(tracers(n))
215 call esmf_fieldregrid(tracers_input_grid(n), &
216 tracers_b4adj_target_grid(n), &
217 routehandle=regrid_bl, &
218 termorderflag=esmf_termorder_srcseq, rc=rc)
219 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
224 print*,
"- CALL Field_Regrid FOR VERTICAL VELOCITY."
225 call esmf_fieldregrid(dzdt_input_grid, &
226 dzdt_b4adj_target_grid, &
227 routehandle=regrid_bl, &
228 termorderflag=esmf_termorder_srcseq, rc=rc)
229 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
233 print*,
"- CALL FieldGet FOR INPUT GRID VERTICAL VEL."
234 call esmf_fieldget(dzdt_input_grid, &
235 farrayptr=tempptr, rc=rc)
236 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
239 print*,
"MIN MAX W INPUT = ", minval(tempptr), maxval(tempptr)
242 print*,
"- CALL FieldGet FOR VERTICAL VEL B4ADJ."
243 call esmf_fieldget(dzdt_b4adj_target_grid, &
244 farrayptr=tempptr, rc=rc)
245 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
248 print*,
"MIN MAX W B4ADJ = ", minval(tempptr), maxval(tempptr)
251 print*,
"- CALL FieldGet FOR INPUT SURFACE PRESSURE."
252 call esmf_fieldget(ps_input_grid, &
253 farrayptr=psptr, rc=rc)
254 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
261 psptr = (psptr/p0)**exponent
263 print*,
"- CALL Field_Regrid FOR SURFACE PRESSURE."
264 call esmf_fieldregrid(ps_input_grid, &
265 ps_b4adj_target_grid, &
266 routehandle=regrid_bl, &
267 termorderflag=esmf_termorder_srcseq, &
269 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
273 print*,
"- CALL FieldGet FOR INPUT SURFACE PRESSURE B4ADJ."
274 call esmf_fieldget(ps_b4adj_target_grid, &
275 farrayptr=psptr, rc=rc)
276 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
279 psptr = p0 * psptr**one_over_exponent
281 print*,
"- CALL Field_Regrid FOR TERRAIN."
282 call esmf_fieldregrid(terrain_input_grid, &
283 terrain_interp_to_target_grid, &
284 routehandle=regrid_bl, &
285 termorderflag=esmf_termorder_srcseq, &
287 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
290 print*,
"- CALL Field_Regrid FOR x WIND."
291 call esmf_fieldregrid(xwind_input_grid, &
292 xwind_b4adj_target_grid, &
293 routehandle=regrid_bl, &
294 termorderflag=esmf_termorder_srcseq, rc=rc)
295 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
298 print*,
"- CALL Field_Regrid FOR y WIND."
299 call esmf_fieldregrid(ywind_input_grid, &
300 ywind_b4adj_target_grid, &
301 routehandle=regrid_bl, &
302 termorderflag=esmf_termorder_srcseq, rc=rc)
303 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
306 print*,
"- CALL Field_Regrid FOR z WIND."
307 call esmf_fieldregrid(zwind_input_grid, &
308 zwind_b4adj_target_grid, &
309 routehandle=regrid_bl, &
310 termorderflag=esmf_termorder_srcseq, rc=rc)
311 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
316 print*,
"- CALL FieldRegridRelease."
317 call esmf_fieldregridrelease(routehandle=regrid_bl, rc=rc)
318 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
351 if( wam_cold_start )
then
352 call
vintg_wam(cycle_year,cycle_mon,cycle_day,cycle_hour,wam_parm_file)
371 isrctermprocessing = 1
372 method=esmf_regridmethod_bilinear
374 print*,
"- CALL FieldRegridStore FOR X-WIND WEST EDGE."
375 call esmf_fieldregridstore(xwind_target_grid, &
376 xwind_w_target_grid, &
377 polemethod=esmf_polemethod_allavg, &
378 srctermprocessing=isrctermprocessing, &
379 routehandle=regrid_bl, &
380 extrapmethod=esmf_extrapmethod_nearest_stod, &
381 regridmethod=method, rc=rc)
382 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
385 print*,
"- CALL Field_Regrid FOR X-WIND WEST EDGE."
386 call esmf_fieldregrid(xwind_target_grid, &
387 xwind_w_target_grid, &
388 routehandle=regrid_bl, &
389 termorderflag=esmf_termorder_srcseq, rc=rc)
390 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
393 print*,
"- CALL Field_Regrid FOR Y-WIND WEST EDGE."
394 call esmf_fieldregrid(ywind_target_grid, &
395 ywind_w_target_grid, &
396 routehandle=regrid_bl, &
397 termorderflag=esmf_termorder_srcseq, rc=rc)
398 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
401 print*,
"- CALL Field_Regrid FOR Z-WIND WEST EDGE."
402 call esmf_fieldregrid(zwind_target_grid, &
403 zwind_w_target_grid, &
404 routehandle=regrid_bl, &
405 termorderflag=esmf_termorder_srcseq, rc=rc)
406 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
409 print*,
"- CALL FieldRegridRelease."
410 call esmf_fieldregridrelease(routehandle=regrid_bl, rc=rc)
411 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
414 isrctermprocessing = 1
415 method=esmf_regridmethod_bilinear
417 print*,
"- CALL FieldRegridStore FOR X-WIND SOUTH EDGE."
418 call esmf_fieldregridstore(xwind_target_grid, &
419 xwind_s_target_grid, &
420 polemethod=esmf_polemethod_allavg, &
421 srctermprocessing=isrctermprocessing, &
422 routehandle=regrid_bl, &
423 extrapmethod=esmf_extrapmethod_nearest_stod, &
424 regridmethod=method, rc=rc)
425 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
428 print*,
"- CALL Field_Regrid FOR X-WIND SOUTH EDGE."
429 call esmf_fieldregrid(xwind_target_grid, &
430 xwind_s_target_grid, &
431 routehandle=regrid_bl, &
432 termorderflag=esmf_termorder_srcseq, rc=rc)
433 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
436 print*,
"- CALL Field_Regrid FOR Y-WIND SOUTH EDGE."
437 call esmf_fieldregrid(ywind_target_grid, &
438 ywind_s_target_grid, &
439 routehandle=regrid_bl, &
440 termorderflag=esmf_termorder_srcseq, rc=rc)
441 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
444 print*,
"- CALL Field_Regrid FOR Z-WIND SOUTH EDGE."
445 call esmf_fieldregrid(zwind_target_grid, &
446 zwind_s_target_grid, &
447 routehandle=regrid_bl, &
448 termorderflag=esmf_termorder_srcseq, rc=rc)
449 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
452 print*,
"- CALL FieldRegridRelease."
453 call esmf_fieldregridrelease(routehandle=regrid_bl, rc=rc)
454 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
467 if (use_thomp_mp_climo)
then
500 allocate(tracers_b4adj_target_grid(num_tracers_input))
502 do n = 1, num_tracers_input
503 print*,
"- CALL FieldCreate FOR TARGET GRID TRACER BEFORE ADJUSTMENT ", trim(tracers(n))
504 tracers_b4adj_target_grid(n) = esmf_fieldcreate(target_grid, &
505 typekind=esmf_typekind_r8, &
506 staggerloc=esmf_staggerloc_center, &
507 ungriddedlbound=(/1/), &
508 ungriddedubound=(/lev_input/), rc=rc)
509 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
513 print*,
"- CALL FieldCreate FOR TARGET GRID TEMPERATURE BEFORE ADJUSTMENT."
514 temp_b4adj_target_grid = esmf_fieldcreate(target_grid, &
515 typekind=esmf_typekind_r8, &
516 staggerloc=esmf_staggerloc_center, &
517 ungriddedlbound=(/1/), &
518 ungriddedubound=(/lev_input/), rc=rc)
519 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
522 print*,
"- CALL FieldCreate FOR TARGET GRID PRESSURE BEFORE ADJUSTMENT."
523 pres_b4adj_target_grid = esmf_fieldcreate(target_grid, &
524 typekind=esmf_typekind_r8, &
525 staggerloc=esmf_staggerloc_center, &
526 ungriddedlbound=(/1/), &
527 ungriddedubound=(/lev_input/), rc=rc)
528 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
531 print*,
"- CALL FieldCreate FOR TARGET GRID VERTICAL VELOCITY BEFORE ADJUSTMENT."
532 dzdt_b4adj_target_grid = esmf_fieldcreate(target_grid, &
533 typekind=esmf_typekind_r8, &
534 staggerloc=esmf_staggerloc_center, &
535 ungriddedlbound=(/1/), &
536 ungriddedubound=(/lev_input/), rc=rc)
537 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
540 print*,
"- CALL FieldCreate FOR TARGET GRID xwind."
541 xwind_b4adj_target_grid = esmf_fieldcreate(target_grid, &
542 typekind=esmf_typekind_r8, &
543 staggerloc=esmf_staggerloc_center, &
544 ungriddedlbound=(/1/), &
545 ungriddedubound=(/lev_input/), rc=rc)
546 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
549 print*,
"- CALL FieldCreate FOR TARGET GRID ywind."
550 ywind_b4adj_target_grid = esmf_fieldcreate(target_grid, &
551 typekind=esmf_typekind_r8, &
552 staggerloc=esmf_staggerloc_center, &
553 ungriddedlbound=(/1/), &
554 ungriddedubound=(/lev_input/), rc=rc)
555 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
558 print*,
"- CALL FieldCreate FOR TARGET GRID zwind."
559 zwind_b4adj_target_grid = esmf_fieldcreate(target_grid, &
560 typekind=esmf_typekind_r8, &
561 staggerloc=esmf_staggerloc_center, &
562 ungriddedlbound=(/1/), &
563 ungriddedubound=(/lev_input/), rc=rc)
564 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
567 print*,
"- CALL FieldCreate FOR TARGET TERRAIN."
568 terrain_interp_to_target_grid = esmf_fieldcreate(target_grid, &
569 typekind=esmf_typekind_r8, &
570 staggerloc=esmf_staggerloc_center, rc=rc)
571 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
574 print*,
"- CALL FieldCreate FOR TARGET SURFACE PRESSURE BEFORE ADJUSTMENT."
575 ps_b4adj_target_grid = esmf_fieldcreate(target_grid, &
576 typekind=esmf_typekind_r8, &
577 staggerloc=esmf_staggerloc_center, rc=rc)
578 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
592 allocate(tracers_target_grid(num_tracers))
594 do n = 1, num_tracers
595 print*,
"- CALL FieldCreate FOR TARGET GRID TRACERS ", trim(tracers(n))
596 tracers_target_grid(n) = esmf_fieldcreate(target_grid, &
597 typekind=esmf_typekind_r8, &
598 staggerloc=esmf_staggerloc_center, &
599 ungriddedlbound=(/1/), &
600 ungriddedubound=(/lev_target/), rc=rc)
601 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
605 print*,
"- CALL FieldCreate FOR TARGET GRID TEMPERATURE."
606 temp_target_grid = esmf_fieldcreate(target_grid, &
607 typekind=esmf_typekind_r8, &
608 staggerloc=esmf_staggerloc_center, &
609 ungriddedlbound=(/1/), &
610 ungriddedubound=(/lev_target/), rc=rc)
611 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
614 print*,
"- CALL FieldCreate FOR TARGET GRID PRESSURE."
615 pres_target_grid = esmf_fieldcreate(target_grid, &
616 typekind=esmf_typekind_r8, &
617 staggerloc=esmf_staggerloc_center, &
618 ungriddedlbound=(/1/), &
619 ungriddedubound=(/lev_target/), rc=rc)
620 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
623 print*,
"- CALL FieldCreate FOR TARGET GRID VERTICAL VELOCITY."
624 dzdt_target_grid = esmf_fieldcreate(target_grid, &
625 typekind=esmf_typekind_r8, &
626 staggerloc=esmf_staggerloc_center, &
627 ungriddedlbound=(/1/), &
628 ungriddedubound=(/lev_target/), rc=rc)
629 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
632 print*,
"- CALL FieldCreate FOR TARGET GRID DELP."
633 delp_target_grid = esmf_fieldcreate(target_grid, &
634 typekind=esmf_typekind_r8, &
635 staggerloc=esmf_staggerloc_center, &
636 ungriddedlbound=(/1/), &
637 ungriddedubound=(/lev_target/), rc=rc)
638 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
641 print*,
"- CALL FieldCreate FOR TARGET GRID xwind."
642 xwind_target_grid = esmf_fieldcreate(target_grid, &
643 typekind=esmf_typekind_r8, &
644 staggerloc=esmf_staggerloc_center, &
645 ungriddedlbound=(/1/), &
646 ungriddedubound=(/lev_target/), rc=rc)
647 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
650 print*,
"- CALL FieldCreate FOR TARGET GRID ywind."
651 ywind_target_grid = esmf_fieldcreate(target_grid, &
652 typekind=esmf_typekind_r8, &
653 staggerloc=esmf_staggerloc_center, &
654 ungriddedlbound=(/1/), &
655 ungriddedubound=(/lev_target/), rc=rc)
656 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
659 print*,
"- CALL FieldCreate FOR TARGET GRID zwind."
660 zwind_target_grid = esmf_fieldcreate(target_grid, &
661 typekind=esmf_typekind_r8, &
662 staggerloc=esmf_staggerloc_center, &
663 ungriddedlbound=(/1/), &
664 ungriddedubound=(/lev_target/), rc=rc)
665 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
668 print*,
"- CALL FieldCreate FOR TARGET HEIGHT."
669 zh_target_grid = esmf_fieldcreate(target_grid, &
670 typekind=esmf_typekind_r8, &
671 staggerloc=esmf_staggerloc_center, &
672 ungriddedlbound=(/1/), &
673 ungriddedubound=(/levp1_target/), rc=rc)
674 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
677 print*,
"- CALL FieldCreate FOR TARGET U_S."
678 u_s_target_grid = esmf_fieldcreate(target_grid, &
679 typekind=esmf_typekind_r8, &
680 staggerloc=esmf_staggerloc_edge2, &
681 ungriddedlbound=(/1/), &
682 ungriddedubound=(/lev_target/), rc=rc)
683 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
686 print*,
"- CALL FieldCreate FOR TARGET V_S."
687 v_s_target_grid = esmf_fieldcreate(target_grid, &
688 typekind=esmf_typekind_r8, &
689 staggerloc=esmf_staggerloc_edge2, &
690 ungriddedlbound=(/1/), &
691 ungriddedubound=(/lev_target/), rc=rc)
692 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
695 print*,
"- CALL FieldCreate FOR TARGET xwind_S."
696 xwind_s_target_grid = esmf_fieldcreate(target_grid, &
697 typekind=esmf_typekind_r8, &
698 staggerloc=esmf_staggerloc_edge2, &
699 ungriddedlbound=(/1/), &
700 ungriddedubound=(/lev_target/), rc=rc)
701 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
704 print*,
"- CALL FieldCreate FOR TARGET ywind_S."
705 ywind_s_target_grid = esmf_fieldcreate(target_grid, &
706 typekind=esmf_typekind_r8, &
707 staggerloc=esmf_staggerloc_edge2, &
708 ungriddedlbound=(/1/), &
709 ungriddedubound=(/lev_target/), rc=rc)
710 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
713 print*,
"- CALL FieldCreate FOR TARGET zwind_S."
714 zwind_s_target_grid = esmf_fieldcreate(target_grid, &
715 typekind=esmf_typekind_r8, &
716 staggerloc=esmf_staggerloc_edge2, &
717 ungriddedlbound=(/1/), &
718 ungriddedubound=(/lev_target/), rc=rc)
719 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
722 print*,
"- CALL FieldCreate FOR TARGET U_W."
723 u_w_target_grid = esmf_fieldcreate(target_grid, &
724 typekind=esmf_typekind_r8, &
725 staggerloc=esmf_staggerloc_edge1, &
726 ungriddedlbound=(/1/), &
727 ungriddedubound=(/lev_target/), rc=rc)
728 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
731 print*,
"- CALL FieldCreate FOR TARGET V_W."
732 v_w_target_grid = esmf_fieldcreate(target_grid, &
733 typekind=esmf_typekind_r8, &
734 staggerloc=esmf_staggerloc_edge1, &
735 ungriddedlbound=(/1/), &
736 ungriddedubound=(/lev_target/), rc=rc)
737 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
740 print*,
"- CALL FieldCreate FOR TARGET xwind_W."
741 xwind_w_target_grid = esmf_fieldcreate(target_grid, &
742 typekind=esmf_typekind_r8, &
743 staggerloc=esmf_staggerloc_edge1, &
744 ungriddedlbound=(/1/), &
745 ungriddedubound=(/lev_target/), rc=rc)
746 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
749 print*,
"- CALL FieldCreate FOR TARGET ywind_W."
750 ywind_w_target_grid = esmf_fieldcreate(target_grid, &
751 typekind=esmf_typekind_r8, &
752 staggerloc=esmf_staggerloc_edge1, &
753 ungriddedlbound=(/1/), &
754 ungriddedubound=(/lev_target/), rc=rc)
755 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
758 print*,
"- CALL FieldCreate FOR TARGET zwind_W."
759 zwind_w_target_grid = esmf_fieldcreate(target_grid, &
760 typekind=esmf_typekind_r8, &
761 staggerloc=esmf_staggerloc_edge1, &
762 ungriddedlbound=(/1/), &
763 ungriddedubound=(/lev_target/), rc=rc)
764 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
767 print*,
"- CALL FieldCreate FOR TARGET SURFACE PRESSURE."
768 ps_target_grid = esmf_fieldcreate(target_grid, &
769 typekind=esmf_typekind_r8, &
770 staggerloc=esmf_staggerloc_center, rc=rc)
771 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
783 integer :: clb(3), cub(3)
784 integer :: i, j, k, rc
786 real(esmf_kind_r8),
pointer :: latptr(:,:)
787 real(esmf_kind_r8),
pointer :: lonptr(:,:)
788 real(esmf_kind_r8),
pointer :: uptr(:,:,:)
789 real(esmf_kind_r8),
pointer :: vptr(:,:,:)
790 real(esmf_kind_r8),
pointer :: xwindptr(:,:,:)
791 real(esmf_kind_r8),
pointer :: ywindptr(:,:,:)
792 real(esmf_kind_r8),
pointer :: zwindptr(:,:,:)
793 real(esmf_kind_r8) :: latrad, lonrad
799 print*,
'- CONVERT WINDS.'
801 print*,
"- CALL FieldGet FOR xwind_S."
802 call esmf_fieldget(xwind_s_target_grid, &
803 computationallbound=clb, &
804 computationalubound=cub, &
805 farrayptr=xwindptr, rc=rc)
806 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
809 print*,
"- CALL FieldGet FOR ywind_S."
810 call esmf_fieldget(ywind_s_target_grid, &
811 farrayptr=ywindptr, rc=rc)
812 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
815 print*,
"- CALL FieldGet FOR zwind_S."
816 call esmf_fieldget(zwind_s_target_grid, &
817 farrayptr=zwindptr, rc=rc)
818 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
821 print*,
"- CALL FieldGet FOR U_S."
822 call esmf_fieldget(u_s_target_grid, &
823 farrayptr=uptr, rc=rc)
824 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
827 print*,
"- CALL FieldGet FOR V_S."
828 call esmf_fieldget(v_s_target_grid, &
829 farrayptr=vptr, rc=rc)
830 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
833 print*,
"- CALL FieldGet FOR LATITUDE_S."
834 call esmf_fieldget(latitude_s_target_grid, &
835 farrayptr=latptr, rc=rc)
836 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
839 print*,
"- CALL FieldGet FOR LONGITUDE_S."
840 call esmf_fieldget(longitude_s_target_grid, &
841 farrayptr=lonptr, rc=rc)
842 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
845 do i = clb(1), cub(1)
846 do j = clb(2), cub(2)
847 latrad = latptr(i,j) * acos(-1.) / 180.0
848 lonrad = lonptr(i,j) * acos(-1.) / 180.0
849 do k = clb(3), cub(3)
850 uptr(i,j,k) = xwindptr(i,j,k) * cos(lonrad) + ywindptr(i,j,k) * sin(lonrad)
851 vptr(i,j,k) = -xwindptr(i,j,k) * sin(latrad) * sin(lonrad) + &
852 ywindptr(i,j,k) * sin(latrad) * cos(lonrad) + &
853 zwindptr(i,j,k) * cos(latrad)
858 print*,
"- CALL FieldGet FOR xwind_w."
859 call esmf_fieldget(xwind_w_target_grid, &
860 computationallbound=clb, &
861 computationalubound=cub, &
862 farrayptr=xwindptr, rc=rc)
863 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
866 print*,
"- CALL FieldGet FOR ywind_w."
867 call esmf_fieldget(ywind_w_target_grid, &
868 farrayptr=ywindptr, rc=rc)
869 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
872 print*,
"- CALL FieldGet FOR zwind_w."
873 call esmf_fieldget(zwind_w_target_grid, &
874 farrayptr=zwindptr, rc=rc)
875 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
878 print*,
"- CALL FieldGet FOR U_W."
879 call esmf_fieldget(u_w_target_grid, &
880 farrayptr=uptr, rc=rc)
881 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
884 print*,
"- CALL FieldGet FOR V_W."
885 call esmf_fieldget(v_w_target_grid, &
886 farrayptr=vptr, rc=rc)
887 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
890 print*,
"- CALL FieldGet FOR LATITUDE_W."
891 call esmf_fieldget(latitude_w_target_grid, &
892 farrayptr=latptr, rc=rc)
893 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
896 print*,
"- CALL FieldGet FOR LONGITUDE_W."
897 call esmf_fieldget(longitude_w_target_grid, &
898 farrayptr=lonptr, rc=rc)
899 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
902 do i = clb(1), cub(1)
903 do j = clb(2), cub(2)
904 latrad = latptr(i,j) * acos(-1.) / 180.0
905 lonrad = lonptr(i,j) * acos(-1.) / 180.0
906 do k = clb(3), cub(3)
907 uptr(i,j,k) = xwindptr(i,j,k) * cos(lonrad) + ywindptr(i,j,k) * sin(lonrad)
908 vptr(i,j,k) = -xwindptr(i,j,k) * sin(latrad) * sin(lonrad) + &
909 ywindptr(i,j,k) * sin(latrad) * cos(lonrad) + &
910 zwindptr(i,j,k) * cos(latrad)
951 integer,
intent(in) :: localpet
953 integer :: idsl, idvc, rc
954 integer :: i, j, k, clb(3), cub(3)
956 real(esmf_kind_r8),
parameter :: rd=287.05
957 real(esmf_kind_r8),
parameter :: cp=1004.6
958 real(esmf_kind_r8),
parameter :: rocp=rd/cp
959 real(esmf_kind_r8),
parameter :: rocp1=rocp+1
960 real(esmf_kind_r8),
parameter :: rocpr=1/rocp
962 real(esmf_kind_r8),
pointer :: delp_ptr(:,:,:)
963 real(esmf_kind_r8),
pointer :: pptr(:,:,:)
964 real(esmf_kind_r8),
pointer :: psptr(:,:)
965 real(esmf_kind_r8) :: ak, bk
966 real(esmf_kind_r8),
allocatable :: pi(:,:,:)
968 print*,
"COMPUTE 3-D PRESSURE FROM ADJUSTED SURFACE PRESSURE."
973 print*,
"- CALL FieldGet FOR 3-D PRES."
974 call esmf_fieldget(pres_target_grid, &
975 computationallbound=clb, &
976 computationalubound=cub, &
977 farrayptr=pptr, rc=rc)
978 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
981 print*,
"- CALL FieldGet FOR DELP."
982 call esmf_fieldget(delp_target_grid, &
983 computationallbound=clb, &
984 computationalubound=cub, &
985 farrayptr=delp_ptr, rc=rc)
986 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
989 print*,
"- CALL FieldGet FOR SURFACE PRESSURE AFTER ADJUSTMENT"
990 call esmf_fieldget(ps_target_grid, &
991 farrayptr=psptr, rc=rc)
992 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
995 allocate(pi(clb(1):cub(1),clb(2):cub(2),1:levp1_target))
999 ak = vcoord_target(k,1)
1000 bk = vcoord_target(k,2)
1001 do i= clb(1), cub(1)
1002 do j= clb(2), cub(2)
1003 pi(i,j,k) = ak + bk*psptr(i,j)
1008 do i= clb(1), cub(1)
1009 do j= clb(2), cub(2)
1010 delp_ptr(i,j,k) = pi(i,j,k) - pi(i,j,k+1)
1020 do i= clb(1), cub(1)
1021 do j= clb(2), cub(2)
1022 pptr(i,j,k) = (pi(i,j,k)+pi(i,j,k+1))/2.0
1028 do i= clb(1), cub(1)
1029 do j= clb(2), cub(2)
1030 pptr(i,j,k) = ((pi(i,j,k)**rocp1-pi(i,j,k+1)**rocp1)/ &
1031 (rocp1*(pi(i,j,k)-pi(i,j,k+1))))**rocpr
1039 if (localpet == 0)
then
1040 print*,
'new pres ',pptr(clb(1),clb(2),:)
1041 print*,
'delp ',delp_ptr(clb(1),clb(2),:)
1063 integer,
intent(in) :: localpet
1064 integer :: i, j, k, ii
1065 integer :: clb(3), cub(3), ls, rc
1067 real(esmf_kind_r8),
pointer :: pptr(:,:,:)
1068 real(esmf_kind_r8),
pointer :: psptr(:,:)
1069 real(esmf_kind_r8),
pointer :: psnewptr(:,:)
1070 real(esmf_kind_r8),
pointer :: tptr(:,:,:)
1071 real(esmf_kind_r8),
pointer :: qptr(:,:,:)
1072 real(esmf_kind_r8),
pointer :: zsptr(:,:)
1073 real(esmf_kind_r8),
pointer :: zsnewptr(:,:)
1074 real(esmf_kind_r8),
allocatable :: zu(:,:)
1075 real(esmf_kind_r8),
parameter :: beta=-6.5e-3
1076 real(esmf_kind_r8),
parameter :: epsilon=1.e-9
1077 real(esmf_kind_r8),
parameter :: g=9.80665
1078 real(esmf_kind_r8),
parameter :: rd=287.05
1079 real(esmf_kind_r8),
parameter :: rv=461.50
1080 real(esmf_kind_r8),
parameter :: gor=g/rd
1081 real(esmf_kind_r8),
parameter :: fv=rv/rd-1.
1082 real(esmf_kind_r8) :: ftv, fgam, apu, fz0
1083 real(esmf_kind_r8) :: atvu, atv, fz1, fp0
1084 real(esmf_kind_r8) :: apd, azd, agam, azu
1085 real(esmf_kind_r8) :: atvd, fp1, gamma, pu
1086 real(esmf_kind_r8) :: tvu, pd, tvd
1087 real(esmf_kind_r8) :: at, aq, ap, az
1089 ftv(at,aq)=at*(1+fv*aq)
1090 fgam(apu,atvu,apd,atvd)=-gor*log(atvd/atvu)/log(apd/apu)
1091 fz0(ap,atv,azd,apd)=azd+atv/gor*log(apd/ap)
1092 fz1(ap,atv,azd,apd,agam)=azd-atv/agam*((apd/ap)**(-agam/gor)-1)
1093 fp0(az,azu,apu,atvu)=apu*exp(-gor/atvu*(az-azu))
1094 fp1(az,azu,apu,atvu,agam)=apu*(1+agam/atvu*(az-azu))**(-gor/agam)
1096 print*,
"- ADJUST SURFACE PRESSURE FOR NEW TERRAIN."
1098 print*,
"- CALL FieldGet FOR 3-D PRES."
1099 call esmf_fieldget(pres_b4adj_target_grid, &
1100 computationallbound=clb, &
1101 computationalubound=cub, &
1102 farrayptr=pptr, rc=rc)
1103 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1106 if(localpet==0)
then
1107 print*,
'old pres ',pptr(clb(1),clb(2),:)
1110 print*,
"- CALL FieldGet FOR TEMPERATURE"
1111 call esmf_fieldget(temp_b4adj_target_grid, &
1112 farrayptr=tptr, rc=rc)
1113 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1118 do ii = 1, num_tracers
1119 if (trim(tracers(ii)) ==
"sphum")
exit
1122 print*,
"- CALL FieldGet FOR SPECIFIC HUMIDITY"
1123 call esmf_fieldget(tracers_b4adj_target_grid(ii), &
1124 farrayptr=qptr, rc=rc)
1125 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1128 print*,
"- CALL FieldGet FOR SURFACE PRESSURE BEFORE ADJUSTMENT"
1129 call esmf_fieldget(ps_b4adj_target_grid, &
1130 farrayptr=psptr, rc=rc)
1131 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1134 print*,
"- CALL FieldGet FOR SURFACE PRESSURE AFTER ADJUSTMENT"
1135 call esmf_fieldget(ps_target_grid, &
1136 farrayptr=psnewptr, rc=rc)
1137 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1140 print*,
"- CALL FieldGet FOR OLD TERRAIN"
1141 call esmf_fieldget(terrain_interp_to_target_grid, &
1142 farrayptr=zsptr, rc=rc)
1143 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1146 print*,
"- CALL FieldGet FOR NEW TERRAIN"
1147 call esmf_fieldget(terrain_target_grid, &
1148 farrayptr=zsnewptr, rc=rc)
1149 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1152 allocate(zu(clb(1):cub(1),clb(2):cub(2)))
1169 tvu=ftv(tptr(i,j,k),qptr(i,j,k))
1170 zu(i,j)=fz1(pu,tvu,zsptr(i,j),psptr(i,j),gamma)
1171 if(zsnewptr(i,j).le.zu(i,j))
then
1173 tvu=ftv(tptr(i,j,k),qptr(i,j,k))
1174 if(abs(gamma).gt.epsilon)
then
1175 psnewptr(i,j)=fp1(zsnewptr(i,j),zu(i,j),pu,tvu,gamma)
1177 psnewptr(i,j)=fp0(zsnewptr(i,j),zu(i,j),pu,tvu)
1194 if(psnewptr(i,j).eq.0)
then
1196 tvu=ftv(tptr(i,j,k),qptr(i,j,k))
1198 tvd=ftv(tptr(i,j,k-1),qptr(i,j,k-1))
1199 gamma=fgam(pu,tvu,pd,tvd)
1200 if(abs(gamma).gt.epsilon)
then
1201 zu(i,j)=fz1(pu,tvu,zu(i,j),pd,gamma)
1203 zu(i,j)=fz0(pu,tvu,zu(i,j),pd)
1205 if(zsnewptr(i,j).le.zu(i,j))
then
1206 if(abs(gamma).gt.epsilon)
then
1207 psnewptr(i,j)=fp1(zsnewptr(i,j),zu(i,j),pu,tvu,gamma)
1209 psnewptr(i,j)=fp0(zsnewptr(i,j),zu(i,j),pu,tvu)
1229 if(psnewptr(i,j).eq.0)
then
1231 tvu=ftv(tptr(i,j,k),qptr(i,j,k))
1232 psnewptr(i,j)=fp0(zsnewptr(i,j),zu(i,j),pu,tvu)
1240 if (localpet == 0)
then
1245 print*,
'sfcp adjust ',(zsnewptr(i,j)-zsptr(i,j)), psptr(i,j),psnewptr(i,j)
1250 end subroutine newps
1259 integer :: istat, n, k
1262 print*,
"OPEN VERTICAL COORD FILE: ", trim(vcoord_file_target_grid)
1263 open(14, file=trim(vcoord_file_target_grid), form=
'formatted', iostat=istat, action=
'read')
1264 if (istat /= 0)
then
1268 read(14, *, iostat=istat) nvcoord_target, lev_target
1269 if (istat /= 0)
then
1273 levp1_target = lev_target + 1
1275 allocate(vcoord_target(levp1_target, nvcoord_target))
1276 read(14, *, iostat=istat) ((vcoord_target(n,k), k=1,nvcoord_target), n=1,levp1_target)
1277 if (istat /= 0)
then
1295 integer :: isrctermprocessing, rc
1297 type(esmf_regridmethod_flag
) :: method
1298 type(esmf_routehandle
) :: regrid_bl
1300 isrctermprocessing=1
1302 print*,
"- CALL FieldCreate FOR TARGET GRID THOMP CLIMO QNIFA BEFORE ADJUSTMENT."
1303 qnifa_climo_b4adj_target_grid = esmf_fieldcreate(target_grid, &
1304 typekind=esmf_typekind_r8, &
1305 staggerloc=esmf_staggerloc_center, &
1306 ungriddedlbound=(/1/), &
1307 ungriddedubound=(/lev_thomp_mp_climo/), rc=rc)
1308 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1311 print*,
"- CALL FieldCreate FOR TARGET GRID THOMP CLIMO QNWFA BEFORE ADJUSTMENT."
1312 qnwfa_climo_b4adj_target_grid = esmf_fieldcreate(target_grid, &
1313 typekind=esmf_typekind_r8, &
1314 staggerloc=esmf_staggerloc_center, &
1315 ungriddedlbound=(/1/), &
1316 ungriddedubound=(/lev_thomp_mp_climo/), rc=rc)
1317 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1320 print*,
"- CALL FieldCreate FOR TARGET GRID THOMP CLIMO PRESSURE BEFORE ADJUSTMENT."
1321 thomp_pres_climo_b4adj_target_grid = esmf_fieldcreate(target_grid, &
1322 typekind=esmf_typekind_r8, &
1323 staggerloc=esmf_staggerloc_center, &
1324 ungriddedlbound=(/1/), &
1325 ungriddedubound=(/lev_thomp_mp_climo/), rc=rc)
1326 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1329 print*,
"- CALL FieldCreate FOR TARGET GRID THOMP CLIMO QNIFA."
1330 qnifa_climo_target_grid = esmf_fieldcreate(target_grid, &
1331 typekind=esmf_typekind_r8, &
1332 staggerloc=esmf_staggerloc_center, &
1333 ungriddedlbound=(/1/), &
1334 ungriddedubound=(/lev_target/), rc=rc)
1335 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1338 print*,
"- CALL FieldCreate FOR TARGET GRID THOMP CLIMO QNWFA."
1339 qnwfa_climo_target_grid = esmf_fieldcreate(target_grid, &
1340 typekind=esmf_typekind_r8, &
1341 staggerloc=esmf_staggerloc_center, &
1342 ungriddedlbound=(/1/), &
1343 ungriddedubound=(/lev_target/), rc=rc)
1344 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1347 print*,
"- CALL FieldRegridStore FOR THOMPSON CLIMO FIELDS."
1349 method=esmf_regridmethod_bilinear
1351 call esmf_fieldregridstore(qnifa_climo_input_grid, &
1352 qnifa_climo_b4adj_target_grid, &
1353 polemethod=esmf_polemethod_allavg, &
1354 srctermprocessing=isrctermprocessing, &
1355 routehandle=regrid_bl, &
1356 regridmethod=method, rc=rc)
1357 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1360 print*,
"- CALL Field_Regrid FOR THOMP CLIMO QNIFA."
1361 call esmf_fieldregrid(qnifa_climo_input_grid, &
1362 qnifa_climo_b4adj_target_grid, &
1363 routehandle=regrid_bl, &
1364 termorderflag=esmf_termorder_srcseq, rc=rc)
1365 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1368 print*,
"- CALL Field_Regrid FOR THOMP CLIMO QNWFA."
1369 call esmf_fieldregrid(qnwfa_climo_input_grid, &
1370 qnwfa_climo_b4adj_target_grid, &
1371 routehandle=regrid_bl, &
1372 termorderflag=esmf_termorder_srcseq, rc=rc)
1373 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1376 print*,
"- CALL Field_Regrid FOR THOMP PRESSURE."
1377 call esmf_fieldregrid(thomp_pres_climo_input_grid, &
1378 thomp_pres_climo_b4adj_target_grid, &
1379 routehandle=regrid_bl, &
1380 termorderflag=esmf_termorder_srcseq, rc=rc)
1381 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1384 print*,
"- CALL FieldRegridRelease."
1385 call esmf_fieldregridrelease(routehandle=regrid_bl, rc=rc)
1386 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1407 INTEGER :: clb(3), cub(3), rc
1408 INTEGER :: im, km1, km2, nt
1411 REAL(ESMF_KIND_R8),
ALLOCATABLE :: z1(:,:,:), z2(:,:,:)
1412 REAL(ESMF_KIND_R8),
ALLOCATABLE :: c1(:,:,:,:),c2(:,:,:,:)
1414 REAL(ESMF_KIND_R8),
POINTER :: qnifa1ptr(:,:,:)
1415 REAL(ESMF_KIND_R8),
POINTER :: qnifa2ptr(:,:,:)
1416 REAL(ESMF_KIND_R8),
POINTER :: qnwfa1ptr(:,:,:)
1417 REAL(ESMF_KIND_R8),
POINTER :: qnwfa2ptr(:,:,:)
1418 REAL(ESMF_KIND_R8),
POINTER :: p1ptr(:,:,:)
1419 REAL(ESMF_KIND_R8),
POINTER :: p2ptr(:,:,:)
1421 print*,
"- VERTICALY INTERPOLATE THOMP MP CLIMO TRACERS."
1423 print*,
"- CALL FieldGet FOR 3-D THOMP PRES."
1424 call esmf_fieldget(thomp_pres_climo_b4adj_target_grid, &
1425 computationallbound=clb, &
1426 computationalubound=cub, &
1427 farrayptr=p1ptr, rc=rc)
1428 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1437 ALLOCATE(z1(clb(1):cub(1),clb(2):cub(2),lev_thomp_mp_climo))
1438 ALLOCATE(z2(clb(1):cub(1),clb(2):cub(2),lev_target))
1439 ALLOCATE(c1(clb(1):cub(1),clb(2):cub(2),lev_thomp_mp_climo,nt))
1440 ALLOCATE(c2(clb(1):cub(1),clb(2):cub(2),lev_target,nt))
1444 print*,
"- CALL FieldGet FOR 3-D ADJUSTED PRESS"
1445 call esmf_fieldget(pres_target_grid, &
1446 farrayptr=p2ptr, rc=rc)
1447 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1455 print*,
"- CALL FieldGet FOR qnifa before vertical adjustment."
1456 call esmf_fieldget(qnifa_climo_b4adj_target_grid, &
1457 farrayptr=qnifa1ptr, rc=rc)
1458 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1461 c1(:,:,:,1) = qnifa1ptr(:,:,:)
1463 print*,
"- CALL FieldGet FOR qnwfa before vertical adjustment."
1464 call esmf_fieldget(qnwfa_climo_b4adj_target_grid, &
1465 farrayptr=qnwfa1ptr, rc=rc)
1466 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1469 c1(:,:,:,2) = qnwfa1ptr(:,:,:)
1477 im = (cub(1)-clb(1)+1) * (cub(2)-clb(2)+1)
1478 km1= lev_thomp_mp_climo
1481 CALL
terp3(im,1,1,1,1,nt,(im*km1),(im*km2), &
1482 km1,im,im,z1,c1,km2,im,im,z2,c2)
1484 print*,
"- CALL FieldGet FOR ADJUSTED climo qnifa."
1485 call esmf_fieldget(qnifa_climo_target_grid, &
1486 farrayptr=qnifa2ptr, rc=rc)
1487 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1490 print*,
"- CALL FieldGet FOR ADJUSTED climo qnwfa."
1491 call esmf_fieldget(qnwfa_climo_target_grid, &
1492 farrayptr=qnwfa2ptr, rc=rc)
1493 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1499 qnifa2ptr(i,j,k) = c2(i,j,k,1)
1500 qnwfa2ptr(i,j,k) = c2(i,j,k,2)
1505 DEALLOCATE (z1, z2, c1, c2)
1507 call esmf_fielddestroy(qnifa_climo_b4adj_target_grid, rc=rc)
1508 call esmf_fielddestroy(qnwfa_climo_b4adj_target_grid, rc=rc)
1509 call esmf_fielddestroy(thomp_pres_climo_b4adj_target_grid, rc=rc)
1533 INTEGER,
INTENT(IN) :: year,month,day,hour
1534 CHARACTER(*),
INTENT(IN) :: pf
1536 REAL(ESMF_KIND_R8),
PARAMETER :: amo = 15.9994
1537 REAL(ESMF_KIND_R8),
PARAMETER :: amo2 = 31.999
1538 REAL(ESMF_KIND_R8),
PARAMETER :: amn2 = 28.013
1540 REAL(ESMF_KIND_R8) :: coe,wfun(10),deglat,hold
1541 REAL(ESMF_KIND_R8) :: summass,qvmass,o3mass
1542 INTEGER :: i, j, k, ii, clb(3), cub(3), rc, kref
1543 INTEGER :: idat(8),jdow,jday,icday
1545 REAL(ESMF_KIND_R8),
ALLOCATABLE :: temp(:),on(:),o2n(:),n2n(:),prmb(:)
1547 REAL(ESMF_KIND_R8),
POINTER :: latptr(:,:)
1548 REAL(ESMF_KIND_R8),
POINTER :: p1ptr(:,:,:)
1549 REAL(ESMF_KIND_R8),
POINTER :: p2ptr(:,:,:)
1550 REAL(ESMF_KIND_R8),
POINTER :: dzdt2ptr(:,:,:)
1551 REAL(ESMF_KIND_R8),
POINTER :: t2ptr(:,:,:)
1552 REAL(ESMF_KIND_R8),
POINTER :: q2ptr(:,:,:)
1553 REAL(ESMF_KIND_R8),
POINTER :: qvptr(:,:,:)
1554 REAL(ESMF_KIND_R8),
POINTER :: qoptr(:,:,:)
1555 REAL(ESMF_KIND_R8),
POINTER :: o2ptr(:,:,:)
1556 REAL(ESMF_KIND_R8),
POINTER :: o3ptr(:,:,:)
1557 REAL(ESMF_KIND_R8),
POINTER :: xwind2ptr(:,:,:)
1558 REAL(ESMF_KIND_R8),
POINTER :: ywind2ptr(:,:,:)
1559 REAL(ESMF_KIND_R8),
POINTER :: zwind2ptr(:,:,:)
1563 print*,
"VINTG_WAM:- VERTICALY EXTEND FIELDS FOR WAM COLD START."
1574 CALL w3doxdat(idat,jdow,icday,jday)
1575 print *,
"VINTG_WAM: WAM START DATE FOR ICDAY=",icday
1579 wfun(k) = (k-1.0) / 9.0
1582 ALLOCATE(temp(lev_target))
1583 ALLOCATE(prmb(lev_target))
1584 ALLOCATE( on(lev_target))
1585 ALLOCATE( o2n(lev_target))
1586 ALLOCATE( n2n(lev_target))
1589 print*,
"VINTG_WAM:- CALL FieldGet FOR 3-D PRES."
1590 call esmf_fieldget(pres_b4adj_target_grid, &
1591 computationallbound=clb, &
1592 computationalubound=cub, &
1593 farrayptr=p1ptr, rc=rc)
1594 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1599 print*,
"VINTG_WAM:- CALL FieldGet FOR 3-D ADJUSTED PRESS"
1600 call esmf_fieldget(pres_target_grid, &
1601 farrayptr=p2ptr, rc=rc)
1602 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1607 print*,
"VINTG_WAM - CALL FieldGet FOR LATITUDE_S."
1608 call esmf_fieldget(latitude_s_target_grid, &
1609 farrayptr=latptr, rc=rc)
1610 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1615 print*,
"VINTG_WAM:- CALL FieldGet FOR 3-D ADJUSTED TEMP."
1616 call esmf_fieldget(temp_target_grid, &
1617 farrayptr=t2ptr, rc=rc)
1618 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1622 print*,
"VINTG_WAM:- CALL FieldGet FOR ADJUSTED VERTICAL VELOCITY."
1623 call esmf_fieldget(dzdt_target_grid, &
1624 farrayptr=dzdt2ptr, rc=rc)
1625 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1629 print*,
"VINTG_WAM:- CALL FieldGet FOR ADJUSTED WIND COMPONENTS."
1631 call esmf_fieldget(xwind_target_grid, &
1632 farrayptr=xwind2ptr, rc=rc)
1633 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1636 call esmf_fieldget(ywind_target_grid, &
1637 farrayptr=ywind2ptr, rc=rc)
1638 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1641 call esmf_fieldget(zwind_target_grid, &
1642 farrayptr=zwind2ptr, rc=rc)
1643 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1653 IF(p2ptr(i,j,k).le.p1ptr(i,j,lev_input))
THEN
1659 DO k=kref,lev_target
1660 coe = p2ptr(i,j,k) / p2ptr(i,j,kref)
1661 xwind2ptr(i,j,k) = coe*xwind2ptr(i,j,k)
1662 ywind2ptr(i,j,k) = coe*ywind2ptr(i,j,k)
1663 zwind2ptr(i,j,k) = coe*zwind2ptr(i,j,k)
1664 dzdt2ptr(i,j,k) = coe*dzdt2ptr(i,j,k)
1673 DO ii = 1, num_tracers
1675 print*,
"VINTG_WAM:- CALL FieldGet FOR 3-D TRACER ", trim(tracers(ii))
1676 call esmf_fieldget(tracers_target_grid(ii), &
1677 farrayptr=q2ptr, rc=rc)
1678 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1684 IF(p2ptr(i,j,k).le.p1ptr(i,j,lev_input))
THEN
1690 DO k=kref,lev_target
1691 coe = min(1.0, p2ptr(i,j,k) / p2ptr(i,j,kref) )
1692 q2ptr(i,j,k) = coe * q2ptr(i,j,k)
1697 IF (trim(tracers(ii)) ==
"sphum") qvptr => q2ptr
1698 IF (trim(tracers(ii)) ==
"spo" ) qoptr => q2ptr
1699 IF (trim(tracers(ii)) ==
"spo2" ) o2ptr => q2ptr
1700 IF (trim(tracers(ii)) ==
"spo3" ) o3ptr => q2ptr
1710 deglat = latptr(i,j)
1712 prmb(k) = p2ptr(i,j,k) * 0.01
1714 CALL
gettemp(icday,deglat,prmb,lev_target,pf,temp,on,o2n,n2n)
1717 summass = on(k)*amo+o2n(k)*amo2+n2n(k)*amn2
1718 qvmass = summass*qvptr(i,j,k)/(1.-qvptr(i,j,k))
1719 summass = summass+qvmass
1720 o3mass = summass*o3ptr(i,j,k)
1721 summass = summass+o3mass
1722 hold = 1.0 / summass
1723 qoptr(i,j,k) = on(k)*amo *hold
1724 o2ptr(i,j,k) = o2n(k)*amo2*hold
1725 o3ptr(i,j,k) = o3mass * hold
1726 qvptr(i,j,k) = qvmass * hold
1730 IF(p2ptr(i,j,k).le.p1ptr(i,j,lev_input))
THEN
1736 DO k=kref,lev_target
1737 t2ptr(i,j,k) = temp(k)
1740 t2ptr(i,j,k) = wfun(k-kref+11) * temp(k) + &
1741 (1.- wfun(k-kref+11)) * t2ptr(i,j,k)
1746 DEALLOCATE (temp, prmb, on, o2n, n2n)
1768 REAL(ESMF_KIND_R8),
PARAMETER :: dltdz=-6.5e-3*287.05/9.80665
1769 REAL(ESMF_KIND_R8),
PARAMETER :: dlpvdrt=-2.5e6/461.50
1770 REAL(ESMF_KIND_R8),
PARAMETER :: one = 1.0_esmf_kind_r8
1772 INTEGER :: i, j, k, clb(3), cub(3), rc
1773 INTEGER :: im, km1, km2, nt, ii
1775 REAL(ESMF_KIND_R8) :: dz
1776 REAL(ESMF_KIND_R8),
ALLOCATABLE :: z1(:,:,:), z2(:,:,:)
1777 REAL(ESMF_KIND_R8),
ALLOCATABLE :: c1(:,:,:,:),c2(:,:,:,:)
1779 REAL(ESMF_KIND_R8),
POINTER :: p1ptr(:,:,:)
1780 REAL(ESMF_KIND_R8),
POINTER :: p2ptr(:,:,:)
1781 REAL(ESMF_KIND_R8),
POINTER :: dzdt1ptr(:,:,:)
1782 REAL(ESMF_KIND_R8),
POINTER :: dzdt2ptr(:,:,:)
1783 REAL(ESMF_KIND_R8),
POINTER :: t1ptr(:,:,:)
1784 REAL(ESMF_KIND_R8),
POINTER :: t2ptr(:,:,:)
1785 REAL(ESMF_KIND_R8),
POINTER :: q1ptr(:,:,:)
1786 REAL(ESMF_KIND_R8),
POINTER :: q2ptr(:,:,:)
1787 REAL(ESMF_KIND_R8),
POINTER :: xwind1ptr(:,:,:)
1788 REAL(ESMF_KIND_R8),
POINTER :: ywind1ptr(:,:,:)
1789 REAL(ESMF_KIND_R8),
POINTER :: zwind1ptr(:,:,:)
1790 REAL(ESMF_KIND_R8),
POINTER :: xwind2ptr(:,:,:)
1791 REAL(ESMF_KIND_R8),
POINTER :: ywind2ptr(:,:,:)
1792 REAL(ESMF_KIND_R8),
POINTER :: zwind2ptr(:,:,:)
1799 print*,
"- VERTICALY INTERPOLATE FIELDS."
1801 print*,
"- CALL FieldGet FOR 3-D PRES."
1802 call esmf_fieldget(pres_b4adj_target_grid, &
1803 computationallbound=clb, &
1804 computationalubound=cub, &
1805 farrayptr=p1ptr, rc=rc)
1806 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1815 ALLOCATE(z1(clb(1):cub(1),clb(2):cub(2),lev_input))
1816 ALLOCATE(z2(clb(1):cub(1),clb(2):cub(2),lev_target))
1817 ALLOCATE(c1(clb(1):cub(1),clb(2):cub(2),lev_input,num_tracers_input+5))
1818 ALLOCATE(c2(clb(1):cub(1),clb(2):cub(2),lev_target,num_tracers_input+5))
1822 print*,
"- CALL FieldGet FOR 3-D ADJUSTED PRESS"
1823 call esmf_fieldget(pres_target_grid, &
1824 farrayptr=p2ptr, rc=rc)
1825 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1830 print*,
"- CALL FieldGet FOR x WIND."
1831 call esmf_fieldget(xwind_b4adj_target_grid, &
1832 farrayptr=xwind1ptr, rc=rc)
1833 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1836 c1(:,:,:,1) = xwind1ptr(:,:,:)
1838 print*,
"- CALL FieldGet FOR y WIND."
1839 call esmf_fieldget(ywind_b4adj_target_grid, &
1840 farrayptr=ywind1ptr, rc=rc)
1841 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1844 c1(:,:,:,2) = ywind1ptr(:,:,:)
1846 print*,
"- CALL FieldGet FOR z WIND."
1847 call esmf_fieldget(zwind_b4adj_target_grid, &
1848 farrayptr=zwind1ptr, rc=rc)
1849 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1852 c1(:,:,:,3) = zwind1ptr(:,:,:)
1854 print*,
"- CALL FieldGet FOR VERTICAL VELOCITY."
1855 call esmf_fieldget(dzdt_b4adj_target_grid, &
1856 farrayptr=dzdt1ptr, rc=rc)
1857 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1860 c1(:,:,:,4) = dzdt1ptr(:,:,:)
1861 print*,
"MIN MAX W TARGETB4 IN VINTG = ", minval(dzdt1ptr(:,:,:)), maxval(dzdt1ptr(:,:,:))
1863 print*,
"- CALL FieldGet FOR 3-D TEMP."
1864 call esmf_fieldget(temp_b4adj_target_grid, &
1865 farrayptr=t1ptr, rc=rc)
1866 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1869 c1(:,:,:,5) = t1ptr(:,:,:)
1871 DO i = 1, num_tracers_input
1873 print*,
"- CALL FieldGet FOR 3-D TRACERS ", trim(tracers(i))
1874 call esmf_fieldget(tracers_b4adj_target_grid(i), &
1875 farrayptr=q1ptr, rc=rc)
1876 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1879 c1(:,:,:,5+i) = q1ptr(:,:,:)
1889 im = (cub(1)-clb(1)+1) * (cub(2)-clb(2)+1)
1892 nt= num_tracers_input + 1
1894 CALL
terp3(im,1,1,1,1,4+nt,(im*km1),(im*km2), &
1895 km1,im,im,z1,c1,km2,im,im,z2,c2)
1902 print*,
"- CALL FieldGet FOR 3-D ADJUSTED TEMP."
1903 call esmf_fieldget(temp_target_grid, &
1904 farrayptr=t2ptr, rc=rc)
1905 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1908 print*,
"- CALL FieldGet FOR ADJUSTED VERTICAL VELOCITY."
1909 call esmf_fieldget(dzdt_target_grid, &
1910 farrayptr=dzdt2ptr, rc=rc)
1911 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1914 print*,
"- CALL FieldGet FOR ADJUSTED xwind."
1915 call esmf_fieldget(xwind_target_grid, &
1916 farrayptr=xwind2ptr, rc=rc)
1917 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1920 print*,
"- CALL FieldGet FOR ADJUSTED ywind."
1921 call esmf_fieldget(ywind_target_grid, &
1922 farrayptr=ywind2ptr, rc=rc)
1923 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1926 print*,
"- CALL FieldGet FOR ADJUSTED zwind."
1927 call esmf_fieldget(zwind_target_grid, &
1928 farrayptr=zwind2ptr, rc=rc)
1929 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1935 xwind2ptr(i,j,k)=c2(i,j,k,1)
1936 ywind2ptr(i,j,k)=c2(i,j,k,2)
1937 zwind2ptr(i,j,k)=c2(i,j,k,3)
1938 dzdt2ptr(i,j,k)=c2(i,j,k,4)
1939 dz=z2(i,j,k)-z1(i,j,1)
1941 t2ptr(i,j,k)=c2(i,j,k,5)
1943 t2ptr(i,j,k)=c1(i,j,1,5)*exp(dltdz*dz)
1949 DO ii = 1, num_tracers_input
1951 print*,
"- CALL FieldGet FOR 3-D TRACER ", trim(tracers(ii))
1952 call esmf_fieldget(tracers_target_grid(ii), &
1953 farrayptr=q2ptr, rc=rc)
1954 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1957 IF (trim(tracers(ii)) ==
"sphum")
THEN
1962 dz=z2(i,j,k)-z1(i,j,1)
1964 q2ptr(i,j,k) = c2(i,j,k,5+ii)
1966 q2ptr(i,j,k) = c1(i,j,1,5+ii)*exp(dlpvdrt*(one/t2ptr(i,j,k)-one/t1ptr(i,j,1))-dz)
1977 q2ptr(i,j,k) = c2(i,j,k,5+ii)
1986 DEALLOCATE (z1, z2, c1, c2)
1988 END SUBROUTINE vintg
2026 SUBROUTINE terp3(IM,IXZ1,IXQ1,IXZ2,IXQ2,NM,NXQ1,NXQ2, &
2027 km1,kxz1,kxq1,z1,q1,km2,kxz2,kxq2,z2,q2)
2029 INTEGER im,ixz1,ixq1,ixz2,ixq2,nm,nxq1,nxq2
2030 INTEGER km1,kxz1,kxq1,km2,kxz2,kxq2
2033 REAL(ESMF_KIND_R8),
PARAMETER :: one = 1.0_esmf_kind_r8
2034 REAL(ESMF_KIND_R8) :: z1(1+(im-1)*ixz1+(km1-1)*kxz1)
2035 REAL(ESMF_KIND_R8) :: q1(1+(im-1)*ixq1+(km1-1)*kxq1+(nm-1)*nxq1)
2036 REAL(ESMF_KIND_R8) :: z2(1+(im-1)*ixz2+(km2-1)*kxz2)
2037 REAL(ESMF_KIND_R8) :: q2(1+(im-1)*ixq2+(km2-1)*kxq2+(nm-1)*nxq2)
2039 REAL(ESMF_KIND_R8) :: ffa(im),ffb(im),ffc(im),ffd(im)
2040 REAL(ESMF_KIND_R8) :: gga(im),ggb(im),ggc(im),ggd(im)
2041 REAL(ESMF_KIND_R8) :: z1a,z1b,z1c,z1d,q1a,q1b,q1c,q1d,z2s,q2s
2046 CALL
rsearch(im,km1,ixz1,kxz1,z1,km2,ixz2,kxz2,z2,1,im,k1s)
2060 IF(k1.EQ.1.OR.k1.EQ.km1-1)
THEN
2061 z2s=z2(1+(i-1)*ixz2+(k2-1)*kxz2)
2062 z1a=z1(1+(i-1)*ixz1+(k1-1)*kxz1)
2063 z1b=z1(1+(i-1)*ixz1+(k1+0)*kxz1)
2064 ffa(i)=(z2s-z1b)/(z1a-z1b)
2065 ffb(i)=(z2s-z1a)/(z1b-z1a)
2066 gga(i)=one/(z1a-z1b)
2067 ggb(i)=one/(z1b-z1a)
2068 ELSEIF(k1.GT.1.AND.k1.LT.km1-1)
THEN
2069 z2s=z2(1+(i-1)*ixz2+(k2-1)*kxz2)
2070 z1a=z1(1+(i-1)*ixz1+(k1-2)*kxz1)
2071 z1b=z1(1+(i-1)*ixz1+(k1-1)*kxz1)
2072 z1c=z1(1+(i-1)*ixz1+(k1+0)*kxz1)
2073 z1d=z1(1+(i-1)*ixz1+(k1+1)*kxz1)
2074 ffa(i)=(z2s-z1b)/(z1a-z1b)* &
2075 (z2s-z1c)/(z1a-z1c)* &
2077 ffb(i)=(z2s-z1a)/(z1b-z1a)* &
2078 (z2s-z1c)/(z1b-z1c)* &
2080 ffc(i)=(z2s-z1a)/(z1c-z1a)* &
2081 (z2s-z1b)/(z1c-z1b)* &
2083 ffd(i)=(z2s-z1a)/(z1d-z1a)* &
2084 (z2s-z1b)/(z1d-z1b)* &
2086 gga(i)= one/(z1a-z1b)* &
2087 (z2s-z1c)/(z1a-z1c)* &
2088 (z2s-z1d)/(z1a-z1d)+ &
2089 (z2s-z1b)/(z1a-z1b)* &
2091 (z2s-z1d)/(z1a-z1d)+ &
2092 (z2s-z1b)/(z1a-z1b)* &
2093 (z2s-z1c)/(z1a-z1c)* &
2095 ggb(i)= one/(z1b-z1a)* &
2096 (z2s-z1c)/(z1b-z1c)* &
2097 (z2s-z1d)/(z1b-z1d)+ &
2098 (z2s-z1a)/(z1b-z1a)* &
2100 (z2s-z1d)/(z1b-z1d)+ &
2101 (z2s-z1a)/(z1b-z1a)* &
2102 (z2s-z1c)/(z1b-z1c)* &
2104 ggc(i)= one/(z1c-z1a)* &
2105 (z2s-z1b)/(z1c-z1b)* &
2106 (z2s-z1d)/(z1c-z1d)+ &
2107 (z2s-z1a)/(z1c-z1a)* &
2109 (z2s-z1d)/(z1c-z1d)+ &
2110 (z2s-z1a)/(z1c-z1a)* &
2111 (z2s-z1b)/(z1c-z1b)* &
2113 ggd(i)= one/(z1d-z1a)* &
2114 (z2s-z1b)/(z1d-z1b)* &
2115 (z2s-z1c)/(z1d-z1c)+ &
2116 (z2s-z1a)/(z1d-z1a)* &
2118 (z2s-z1c)/(z1d-z1c)+ &
2119 (z2s-z1a)/(z1d-z1a)* &
2120 (z2s-z1b)/(z1d-z1b)* &
2130 q2s=q1(1+(i-1)*ixq1+(n-1)*nxq1)
2132 ELSEIF(k1.EQ.km1)
THEN
2133 q2s=q1(1+(i-1)*ixq1+(km1-1)*kxq1+(n-1)*nxq1)
2135 ELSEIF(k1.EQ.1.OR.k1.EQ.km1-1)
THEN
2136 q1a=q1(1+(i-1)*ixq1+(k1-1)*kxq1+(n-1)*nxq1)
2137 q1b=q1(1+(i-1)*ixq1+(k1+0)*kxq1+(n-1)*nxq1)
2138 q2s=ffa(i)*q1a+ffb(i)*q1b
2141 q1a=q1(1+(i-1)*ixq1+(k1-2)*kxq1+(n-1)*nxq1)
2142 q1b=q1(1+(i-1)*ixq1+(k1-1)*kxq1+(n-1)*nxq1)
2143 q1c=q1(1+(i-1)*ixq1+(k1+0)*kxq1+(n-1)*nxq1)
2144 q1d=q1(1+(i-1)*ixq1+(k1+1)*kxq1+(n-1)*nxq1)
2145 q2s=ffa(i)*q1a+ffb(i)*q1b+ffc(i)*q1c+ffd(i)*q1d
2147 IF(q2s.LT.min(q1b,q1c))
THEN
2150 ELSEIF(q2s.GT.max(q1b,q1c))
THEN
2155 q2(1+(i-1)*ixq2+(k2-1)*kxq2+(n-1)*nxq2)=q2s
2162 END SUBROUTINE terp3
2220 SUBROUTINE rsearch(IM,KM1,IXZ1,KXZ1,Z1,KM2,IXZ2,KXZ2,Z2,IXL2,KXL2,L2)
2223 INTEGER,
INTENT(IN) :: im,km1,ixz1,kxz1,km2,ixz2,kxz2,ixl2,kxl2
2224 INTEGER,
INTENT(OUT) :: l2(1+(im-1)*ixl2+(km2-1)*kxl2)
2226 REAL(ESMF_KIND_R8),
INTENT(IN) :: z1(1+(im-1)*ixz1+(km1-1)*kxz1)
2227 REAL(ESMF_KIND_R8),
INTENT(IN) :: z2(1+(im-1)*ixz2+(km2-1)*kxz2)
2231 REAL(ESMF_KIND_R8) :: z
2237 IF (z1(1+(i-1)*ixz1).LE.z1(1+(i-1)*ixz1+(km1-1)*kxz1))
THEN
2240 z=z2(1+(i-1)*ixz2+(k2-1)*kxz2)
2243 IF(z.LT.z1(1+(i-1)*ixz1+l*kxz1))
EXIT
2247 l2(1+(i-1)*ixl2+(k2-1)*kxl2)=l
2252 z=z2(1+(i-1)*ixz2+(k2-1)*kxz2)
2255 IF(z.GT.z1(1+(i-1)*ixz1+l*kxz1))
EXIT
2259 l2(1+(i-1)*ixl2+(k2-1)*kxl2)=l
2272 integer :: i,ii, j,k, rc, clb(2), cub(2)
2274 real(esmf_kind_r8),
allocatable :: pe0(:), pn0(:)
2275 real(esmf_kind_r8),
pointer :: psptr(:,:)
2276 real(esmf_kind_r8),
pointer :: zhsfcptr(:,:)
2277 real(esmf_kind_r8),
pointer :: zhptr(:,:,:)
2278 real(esmf_kind_r8),
pointer :: tptr(:,:,:)
2279 real(esmf_kind_r8),
pointer :: qptr(:,:,:)
2280 real(esmf_kind_r8) :: ak, bk, zvir, grd
2281 real(esmf_kind_r8),
parameter :: grav = 9.80665
2282 real(esmf_kind_r8),
parameter :: rdgas = 287.05
2283 real(esmf_kind_r8),
parameter :: rvgas = 461.50
2285 print*,
"- COMPUTE HEIGHT"
2287 print*,
"- CALL FieldGet FOR SURFACE PRESSURE"
2288 call esmf_fieldget(ps_target_grid, &
2289 computationallbound=clb, &
2290 computationalubound=cub, &
2291 farrayptr=psptr, rc=rc)
2292 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2295 print*,
"- CALL FieldGet FOR TERRAIN HEIGHT"
2296 call esmf_fieldget(terrain_target_grid, &
2297 farrayptr=zhsfcptr, rc=rc)
2298 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2301 print*,
"- CALL FieldGet FOR HEIGHT"
2302 call esmf_fieldget(zh_target_grid, &
2303 farrayptr=zhptr, rc=rc)
2304 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2307 print*,
"- CALL FieldGet FOR TEMPERATURE"
2308 call esmf_fieldget(temp_target_grid, &
2309 farrayptr=tptr, rc=rc)
2310 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2313 do ii = 1, num_tracers
2314 if (trim(tracers(ii)) ==
"sphum")
exit
2317 print*,
"- CALL FieldGet FOR SPECIFIC HUMIDITY"
2318 call esmf_fieldget(tracers_target_grid(ii), &
2319 farrayptr=qptr, rc=rc)
2320 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2324 zvir = rvgas/rdgas - 1.0_esmf_kind_r8
2326 allocate(pe0(levp1_target))
2327 allocate(pn0(levp1_target))
2329 do j = clb(2), cub(2)
2330 do i = clb(1), cub(1)
2332 do k = 1, levp1_target
2333 ak = vcoord_target(k,1)
2335 bk = vcoord_target(k,2)
2337 pe0(k) = ak + bk*psptr(i,j)
2338 pn0(k) = log(pe0(k))
2341 zhptr(i,j,1) = zhsfcptr(i,j)
2343 do k = 2, levp1_target
2344 zhptr(i,j,k) = zhptr(i,j,k-1)+tptr(i,j,k-1)*(1.+zvir*qptr(i,j,k-1))* &
2345 (pn0(k-1)-pn0(k))/grd
2351 deallocate(pe0, pn0)
2364 print*,
"- DESTROY TARGET GRID ATMOSPHERIC BEFORE ADJUSTMENT FIELDS."
2366 call esmf_fielddestroy(xwind_b4adj_target_grid, rc=rc)
2367 call esmf_fielddestroy(ywind_b4adj_target_grid, rc=rc)
2368 call esmf_fielddestroy(zwind_b4adj_target_grid, rc=rc)
2369 call esmf_fielddestroy(dzdt_b4adj_target_grid, rc=rc)
2370 call esmf_fielddestroy(ps_b4adj_target_grid, rc=rc)
2371 call esmf_fielddestroy(pres_b4adj_target_grid, rc=rc)
2372 call esmf_fielddestroy(temp_b4adj_target_grid, rc=rc)
2373 call esmf_fielddestroy(terrain_interp_to_target_grid, rc=rc)
2375 do i = 1, num_tracers_input
2376 call esmf_fielddestroy(tracers_b4adj_target_grid(i), rc=rc)
2379 deallocate(tracers_b4adj_target_grid)
2393 print*,
"- DESTROY LOCAL TARGET GRID ATMOSPHERIC FIELDS."
2395 call esmf_fielddestroy(pres_target_grid, rc=rc)
2396 call esmf_fielddestroy(xwind_target_grid, rc=rc)
2397 call esmf_fielddestroy(ywind_target_grid, rc=rc)
2398 call esmf_fielddestroy(zwind_target_grid, rc=rc)
2399 call esmf_fielddestroy(xwind_s_target_grid, rc=rc)
2400 call esmf_fielddestroy(ywind_s_target_grid, rc=rc)
2401 call esmf_fielddestroy(zwind_s_target_grid, rc=rc)
2402 call esmf_fielddestroy(xwind_w_target_grid, rc=rc)
2403 call esmf_fielddestroy(ywind_w_target_grid, rc=rc)
2404 call esmf_fielddestroy(zwind_w_target_grid, rc=rc)
subroutine cleanup_target_atm_b4adj_data
Cleanup atmospheric field (before adjustment) objects.
subroutine vintg
Vertically interpolate upper-air fields.
subroutine, public write_fv3_atm_bndy_data_netcdf(localpet)
Writes atmospheric fields along the lateral boundary.
subroutine convert_winds_to_uv
Convert 3-d component winds to u and v.
subroutine, public cleanup_atmosphere_target_data
Free up memory for fields and variables in this module.
subroutine, public write_fv3_atm_data_netcdf(localpet)
Write atmospheric coldstart files (netcdf format).
subroutine, public read_vcoord_info
Reads model vertical coordinate definition file (as specified by namelist variable vcoord_file_target...
subroutine vintg_thomp_mp_climo
Vertically interpolate atmospheric fields to target FV3 grid.
subroutine newps(localpet)
Computes adjusted surface pressure given a new terrain height.
subroutine create_atm_b4adj_esmf_fields
Create target grid field objects to hold data before vertical interpolation.
Sets up the ESMF grid objects for the input data grid and target FV3 grid.
Process atmospheric fields.
subroutine, public cleanup_thomp_mp_climo_input_data
Free up memory associated with this module.
subroutine terp3(IM, IXZ1, IXQ1, IXZ2, IXQ2, NM, NXQ1, NXQ2, KM1, KXZ1, KXQ1, Z1, Q1, KM2, KXZ2, KXQ2, Z2, Q2)
Cubically interpolate in one dimension.
subroutine, public write_fv3_atm_header_netcdf(localpet)
Writes atmospheric header file in netcdf format.
subroutine, public atmosphere_driver(localpet)
Driver routine to process for atmospheric fields.
Module to read the Thompson climatological MP data file and set up the associated esmf field and grid...
subroutine error_handler(string, rc)
General error handler.
subroutine, public read_thomp_mp_climo_data
Read Thompson climatological MP data file and time interpolate data to current cycle time...
subroutine vintg_wam(YEAR, MONTH, DAY, HOUR, PF)
Vertically extend model top into thermosphere for whole atmosphere model.
subroutine create_atm_esmf_fields
Create target grid field objects.
Module to hold variables and ESMF fields associated with the target grid atmospheric data...
subroutine gettemp(iday, xlat, pr, np, pf, temp, n_o, n_o2, n_n2)
Routine that computes temperature and neutral density values utilizing MSIS 2.1.
subroutine rsearch(IM, KM1, IXZ1, KXZ1, Z1, KM2, IXZ2, KXZ2, Z2, IXL2, KXL2, L2)
Search for a surrounding real interval.
subroutine cleanup_all_target_atm_data
Cleanup target grid atmospheric field objects.
subroutine horiz_interp_thomp_mp_climo
Horizontally interpolate thompson microphysics data to the target model grid.
This module contains code to read the setup namelist file, handle the varmap file for GRIB2 data...
subroutine compute_zh
Compute vertical level height.
subroutine newpr1(localpet)
Computes 3-D pressure given an adjusted surface pressure.