36 latitude_s_target_grid, &
37 longitude_s_target_grid, &
38 latitude_w_target_grid, &
39 longitude_w_target_grid, &
44 tracers, num_tracers, &
50 qnifa_climo_input_grid, &
51 qnwfa_climo_input_grid, &
52 thomp_pres_climo_input_grid, &
59 integer,
public :: lev_target
60 integer,
public :: levp1_target
61 integer,
public :: nvcoord_target
63 real(esmf_kind_r8),
allocatable,
public :: vcoord_target(:,:)
65 type(esmf_field
),
public :: delp_target_grid
66 type(esmf_field),
public :: dzdt_target_grid
67 type(esmf_field) :: dzdt_b4adj_target_grid
68 type(esmf_field),
allocatable,
public :: tracers_target_grid(:)
69 type(esmf_field),
allocatable :: tracers_b4adj_target_grid(:)
70 type(esmf_field),
public :: ps_target_grid
71 type(esmf_field) :: ps_b4adj_target_grid
72 type(esmf_field) :: pres_target_grid
73 type(esmf_field) :: pres_b4adj_target_grid
74 type(esmf_field),
public :: temp_target_grid
75 type(esmf_field) :: temp_b4adj_target_grid
76 type(esmf_field) :: terrain_interp_to_target_grid
77 type(esmf_field),
public :: u_s_target_grid
78 type(esmf_field),
public :: v_s_target_grid
79 type(esmf_field) :: wind_target_grid
80 type(esmf_field) :: wind_b4adj_target_grid
81 type(esmf_field) :: wind_s_target_grid
82 type(esmf_field),
public :: u_w_target_grid
83 type(esmf_field),
public :: v_w_target_grid
84 type(esmf_field) :: wind_w_target_grid
85 type(esmf_field),
public :: zh_target_grid
89 type(esmf_field
) :: qnifa_climo_b4adj_target_grid
91 type(esmf_field),
public :: qnifa_climo_target_grid
94 type(esmf_field) :: qnwfa_climo_b4adj_target_grid
96 type(esmf_field),
public :: qnwfa_climo_target_grid
99 type(esmf_field) :: thomp_pres_climo_b4adj_target_grid
116 integer,
intent(in) :: localpet
118 integer :: isrctermprocessing
121 type(esmf_regridmethod_flag
) :: method
122 type(esmf_routehandle
) :: regrid_bl
124 real(esmf_kind_r8),
parameter :: p0=101325.0
125 real(esmf_kind_r8),
parameter :: rd = 287.058
126 real(esmf_kind_r8),
parameter :: grav = 9.81
127 real(esmf_kind_r8),
parameter :: lapse = -6.5e-03
129 real(esmf_kind_r8),
parameter :: exponent = rd*lapse/grav
130 real(esmf_kind_r8),
parameter :: one_over_exponent = 1.0 / exponent
132 real(esmf_kind_r8),
pointer :: psptr(:,:), tempptr(:,:,:)
156 isrctermprocessing = 1
158 if (trim(atm_weight_file) /=
"NULL")
then
160 print*,
"- CALL FieldSMMStore FOR ATMOSPHERIC FIELDS."
162 call esmf_fieldsmmstore(temp_input_grid, &
163 temp_b4adj_target_grid, &
165 routehandle=regrid_bl, &
166 srctermprocessing=isrctermprocessing, rc=rc)
167 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
172 print*,
"- CALL FieldRegridStore FOR ATMOSPHERIC FIELDS."
174 method=esmf_regridmethod_bilinear
176 call esmf_fieldregridstore(temp_input_grid, &
177 temp_b4adj_target_grid, &
178 polemethod=esmf_polemethod_allavg, &
179 srctermprocessing=isrctermprocessing, &
180 routehandle=regrid_bl, &
181 regridmethod=method, rc=rc)
182 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
187 print*,
"- CALL Field_Regrid FOR TEMPERATURE."
188 call esmf_fieldregrid(temp_input_grid, &
189 temp_b4adj_target_grid, &
190 routehandle=regrid_bl, &
191 termorderflag=esmf_termorder_srcseq, &
193 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
196 print*,
"- CALL Field_Regrid FOR PRESSURE."
197 call esmf_fieldregrid(pres_input_grid, &
198 pres_b4adj_target_grid, &
199 routehandle=regrid_bl, &
200 termorderflag=esmf_termorder_srcseq, &
202 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
205 do n = 1, num_tracers
206 print*,
"- CALL Field_Regrid FOR TRACER ", trim(tracers(n))
207 call esmf_fieldregrid(tracers_input_grid(n), &
208 tracers_b4adj_target_grid(n), &
209 routehandle=regrid_bl, &
210 termorderflag=esmf_termorder_srcseq, rc=rc)
211 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
216 print*,
"- CALL Field_Regrid FOR VERTICAL VELOCITY."
217 call esmf_fieldregrid(dzdt_input_grid, &
218 dzdt_b4adj_target_grid, &
219 routehandle=regrid_bl, &
220 termorderflag=esmf_termorder_srcseq, rc=rc)
221 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
225 print*,
"- CALL FieldGet FOR INPUT GRID VERTICAL VEL."
226 call esmf_fieldget(dzdt_input_grid, &
227 farrayptr=tempptr, rc=rc)
228 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
231 print*,
"MIN MAX W INPUT = ", minval(tempptr), maxval(tempptr)
234 print*,
"- CALL FieldGet FOR VERTICAL VEL B4ADJ."
235 call esmf_fieldget(dzdt_b4adj_target_grid, &
236 farrayptr=tempptr, rc=rc)
237 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
240 print*,
"MIN MAX W B4ADJ = ", minval(tempptr), maxval(tempptr)
243 print*,
"- CALL FieldGet FOR INPUT SURFACE PRESSURE."
244 call esmf_fieldget(ps_input_grid, &
245 farrayptr=psptr, rc=rc)
246 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
253 psptr = (psptr/p0)**exponent
255 print*,
"- CALL Field_Regrid FOR SURFACE PRESSURE."
256 call esmf_fieldregrid(ps_input_grid, &
257 ps_b4adj_target_grid, &
258 routehandle=regrid_bl, &
259 termorderflag=esmf_termorder_srcseq, &
261 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
265 print*,
"- CALL FieldGet FOR INPUT SURFACE PRESSURE B4ADJ."
266 call esmf_fieldget(ps_b4adj_target_grid, &
267 farrayptr=psptr, rc=rc)
268 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
271 psptr = p0 * psptr**one_over_exponent
273 print*,
"- CALL Field_Regrid FOR TERRAIN."
274 call esmf_fieldregrid(terrain_input_grid, &
275 terrain_interp_to_target_grid, &
276 routehandle=regrid_bl, &
277 termorderflag=esmf_termorder_srcseq, &
279 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
282 print*,
"- CALL Field_Regrid FOR 3-D WIND."
283 call esmf_fieldregrid(wind_input_grid, &
284 wind_b4adj_target_grid, &
285 routehandle=regrid_bl, &
286 termorderflag=esmf_termorder_srcseq, rc=rc)
287 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
290 print*,
"- CALL FieldRegridRelease."
291 call esmf_fieldregridrelease(routehandle=regrid_bl, rc=rc)
292 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
341 isrctermprocessing = 1
342 method=esmf_regridmethod_bilinear
344 print*,
"- CALL FieldRegridStore FOR 3D-WIND WEST EDGE."
345 call esmf_fieldregridstore(wind_target_grid, &
346 wind_w_target_grid, &
347 polemethod=esmf_polemethod_allavg, &
348 srctermprocessing=isrctermprocessing, &
349 routehandle=regrid_bl, &
350 extrapmethod=esmf_extrapmethod_nearest_stod, &
351 regridmethod=method, rc=rc)
352 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
355 print*,
"- CALL Field_Regrid FOR 3-D WIND WEST EDGE."
356 call esmf_fieldregrid(wind_target_grid, &
357 wind_w_target_grid, &
358 routehandle=regrid_bl, &
359 termorderflag=esmf_termorder_srcseq, rc=rc)
360 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
363 print*,
"- CALL FieldRegridRelease."
364 call esmf_fieldregridrelease(routehandle=regrid_bl, rc=rc)
365 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
368 isrctermprocessing = 1
369 method=esmf_regridmethod_bilinear
371 print*,
"- CALL FieldRegridStore FOR 3D-WIND SOUTH EDGE."
372 call esmf_fieldregridstore(wind_target_grid, &
373 wind_s_target_grid, &
374 polemethod=esmf_polemethod_allavg, &
375 srctermprocessing=isrctermprocessing, &
376 routehandle=regrid_bl, &
377 extrapmethod=esmf_extrapmethod_nearest_stod, &
378 regridmethod=method, rc=rc)
379 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
382 print*,
"- CALL Field_Regrid FOR 3-D WIND SOUTH EDGE."
383 call esmf_fieldregrid(wind_target_grid, &
384 wind_s_target_grid, &
385 routehandle=regrid_bl, &
386 termorderflag=esmf_termorder_srcseq, rc=rc)
387 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
390 print*,
"- CALL FieldRegridRelease."
391 call esmf_fieldregridrelease(routehandle=regrid_bl, rc=rc)
392 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
405 if (use_thomp_mp_climo)
then
438 allocate(tracers_b4adj_target_grid(num_tracers))
440 do n = 1, num_tracers
441 print*,
"- CALL FieldCreate FOR TARGET GRID TRACER BEFORE ADJUSTMENT ", trim(tracers(n))
442 tracers_b4adj_target_grid(n) = esmf_fieldcreate(target_grid, &
443 typekind=esmf_typekind_r8, &
444 staggerloc=esmf_staggerloc_center, &
445 ungriddedlbound=(/1/), &
446 ungriddedubound=(/lev_input/), rc=rc)
447 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
451 print*,
"- CALL FieldCreate FOR TARGET GRID TEMPERATURE BEFORE ADJUSTMENT."
452 temp_b4adj_target_grid = esmf_fieldcreate(target_grid, &
453 typekind=esmf_typekind_r8, &
454 staggerloc=esmf_staggerloc_center, &
455 ungriddedlbound=(/1/), &
456 ungriddedubound=(/lev_input/), rc=rc)
457 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
460 print*,
"- CALL FieldCreate FOR TARGET GRID PRESSURE BEFORE ADJUSTMENT."
461 pres_b4adj_target_grid = esmf_fieldcreate(target_grid, &
462 typekind=esmf_typekind_r8, &
463 staggerloc=esmf_staggerloc_center, &
464 ungriddedlbound=(/1/), &
465 ungriddedubound=(/lev_input/), rc=rc)
466 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
469 print*,
"- CALL FieldCreate FOR TARGET GRID VERTICAL VELOCITY BEFORE ADJUSTMENT."
470 dzdt_b4adj_target_grid = esmf_fieldcreate(target_grid, &
471 typekind=esmf_typekind_r8, &
472 staggerloc=esmf_staggerloc_center, &
473 ungriddedlbound=(/1/), &
474 ungriddedubound=(/lev_input/), rc=rc)
475 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
478 print*,
"- CALL FieldCreate FOR TARGET GRID UNSTAGGERED WINDS BEFORE ADJUSTMENT."
479 wind_b4adj_target_grid = esmf_fieldcreate(target_grid, &
480 typekind=esmf_typekind_r8, &
481 staggerloc=esmf_staggerloc_center, &
482 ungriddedlbound=(/1,1/), &
483 ungriddedubound=(/lev_input,3/), rc=rc)
484 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
487 print*,
"- CALL FieldCreate FOR TARGET TERRAIN."
488 terrain_interp_to_target_grid = esmf_fieldcreate(target_grid, &
489 typekind=esmf_typekind_r8, &
490 staggerloc=esmf_staggerloc_center, rc=rc)
491 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
494 print*,
"- CALL FieldCreate FOR TARGET SURFACE PRESSURE BEFORE ADJUSTMENT."
495 ps_b4adj_target_grid = esmf_fieldcreate(target_grid, &
496 typekind=esmf_typekind_r8, &
497 staggerloc=esmf_staggerloc_center, rc=rc)
498 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
512 allocate(tracers_target_grid(num_tracers))
514 do n = 1, num_tracers
515 print*,
"- CALL FieldCreate FOR TARGET GRID TRACERS ", trim(tracers(n))
516 tracers_target_grid(n) = esmf_fieldcreate(target_grid, &
517 typekind=esmf_typekind_r8, &
518 staggerloc=esmf_staggerloc_center, &
519 ungriddedlbound=(/1/), &
520 ungriddedubound=(/lev_target/), rc=rc)
521 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
525 print*,
"- CALL FieldCreate FOR TARGET GRID TEMPERATURE."
526 temp_target_grid = esmf_fieldcreate(target_grid, &
527 typekind=esmf_typekind_r8, &
528 staggerloc=esmf_staggerloc_center, &
529 ungriddedlbound=(/1/), &
530 ungriddedubound=(/lev_target/), rc=rc)
531 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
534 print*,
"- CALL FieldCreate FOR TARGET GRID PRESSURE."
535 pres_target_grid = esmf_fieldcreate(target_grid, &
536 typekind=esmf_typekind_r8, &
537 staggerloc=esmf_staggerloc_center, &
538 ungriddedlbound=(/1/), &
539 ungriddedubound=(/lev_target/), rc=rc)
540 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
543 print*,
"- CALL FieldCreate FOR TARGET GRID VERTICAL VELOCITY."
544 dzdt_target_grid = esmf_fieldcreate(target_grid, &
545 typekind=esmf_typekind_r8, &
546 staggerloc=esmf_staggerloc_center, &
547 ungriddedlbound=(/1/), &
548 ungriddedubound=(/lev_target/), rc=rc)
549 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
552 print*,
"- CALL FieldCreate FOR TARGET GRID DELP."
553 delp_target_grid = esmf_fieldcreate(target_grid, &
554 typekind=esmf_typekind_r8, &
555 staggerloc=esmf_staggerloc_center, &
556 ungriddedlbound=(/1/), &
557 ungriddedubound=(/lev_target/), rc=rc)
558 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
561 print*,
"- CALL FieldCreate FOR TARGET HEIGHT."
562 zh_target_grid = esmf_fieldcreate(target_grid, &
563 typekind=esmf_typekind_r8, &
564 staggerloc=esmf_staggerloc_center, &
565 ungriddedlbound=(/1/), &
566 ungriddedubound=(/levp1_target/), rc=rc)
567 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
570 print*,
"- CALL FieldCreate FOR TARGET UNSTAGGERED 3D-WIND."
571 wind_target_grid = esmf_fieldcreate(target_grid, &
572 typekind=esmf_typekind_r8, &
573 staggerloc=esmf_staggerloc_center, &
574 ungriddedlbound=(/1,1/), &
575 ungriddedubound=(/lev_target,3/), rc=rc)
576 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
579 print*,
"- CALL FieldCreate FOR TARGET U_S."
580 u_s_target_grid = esmf_fieldcreate(target_grid, &
581 typekind=esmf_typekind_r8, &
582 staggerloc=esmf_staggerloc_edge2, &
583 ungriddedlbound=(/1/), &
584 ungriddedubound=(/lev_target/), rc=rc)
585 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
588 print*,
"- CALL FieldCreate FOR TARGET V_S."
589 v_s_target_grid = esmf_fieldcreate(target_grid, &
590 typekind=esmf_typekind_r8, &
591 staggerloc=esmf_staggerloc_edge2, &
592 ungriddedlbound=(/1/), &
593 ungriddedubound=(/lev_target/), rc=rc)
594 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
597 print*,
"- CALL FieldCreate FOR TARGET 3D-WIND_S."
598 wind_s_target_grid = esmf_fieldcreate(target_grid, &
599 typekind=esmf_typekind_r8, &
600 staggerloc=esmf_staggerloc_edge2, &
601 ungriddedlbound=(/1,1/), &
602 ungriddedubound=(/lev_target,3/), rc=rc)
603 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
606 print*,
"- CALL FieldCreate FOR TARGET U_W."
607 u_w_target_grid = esmf_fieldcreate(target_grid, &
608 typekind=esmf_typekind_r8, &
609 staggerloc=esmf_staggerloc_edge1, &
610 ungriddedlbound=(/1/), &
611 ungriddedubound=(/lev_target/), rc=rc)
612 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
615 print*,
"- CALL FieldCreate FOR TARGET V_W."
616 v_w_target_grid = esmf_fieldcreate(target_grid, &
617 typekind=esmf_typekind_r8, &
618 staggerloc=esmf_staggerloc_edge1, &
619 ungriddedlbound=(/1/), &
620 ungriddedubound=(/lev_target/), rc=rc)
621 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
624 print*,
"- CALL FieldCreate FOR TARGET 3D-WIND_W."
625 wind_w_target_grid = esmf_fieldcreate(target_grid, &
626 typekind=esmf_typekind_r8, &
627 staggerloc=esmf_staggerloc_edge1, &
628 ungriddedlbound=(/1,1/), &
629 ungriddedubound=(/lev_target,3/), rc=rc)
630 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
633 print*,
"- CALL FieldCreate FOR TARGET SURFACE PRESSURE."
634 ps_target_grid = esmf_fieldcreate(target_grid, &
635 typekind=esmf_typekind_r8, &
636 staggerloc=esmf_staggerloc_center, rc=rc)
637 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
649 integer :: clb(4), cub(4)
650 integer :: i, j, k, rc
652 real(esmf_kind_r8),
pointer :: latptr(:,:)
653 real(esmf_kind_r8),
pointer :: lonptr(:,:)
654 real(esmf_kind_r8),
pointer :: uptr(:,:,:)
655 real(esmf_kind_r8),
pointer :: vptr(:,:,:)
656 real(esmf_kind_r8),
pointer :: windptr(:,:,:,:)
657 real(esmf_kind_r8) :: latrad, lonrad
663 print*,
'- CONVERT WINDS.'
665 print*,
"- CALL FieldGet FOR 3-D WIND_S."
666 call esmf_fieldget(wind_s_target_grid, &
667 computationallbound=clb, &
668 computationalubound=cub, &
669 farrayptr=windptr, rc=rc)
670 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
673 print*,
"- CALL FieldGet FOR U_S."
674 call esmf_fieldget(u_s_target_grid, &
675 farrayptr=uptr, rc=rc)
676 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
679 print*,
"- CALL FieldGet FOR V_S."
680 call esmf_fieldget(v_s_target_grid, &
681 farrayptr=vptr, rc=rc)
682 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
685 print*,
"- CALL FieldGet FOR LATITUDE_S."
686 call esmf_fieldget(latitude_s_target_grid, &
687 farrayptr=latptr, rc=rc)
688 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
691 print*,
"- CALL FieldGet FOR LONGITUDE_S."
692 call esmf_fieldget(longitude_s_target_grid, &
693 farrayptr=lonptr, rc=rc)
694 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
697 do i = clb(1), cub(1)
698 do j = clb(2), cub(2)
699 latrad = latptr(i,j) * acos(-1.) / 180.0
700 lonrad = lonptr(i,j) * acos(-1.) / 180.0
701 do k = clb(3), cub(3)
702 uptr(i,j,k) = windptr(i,j,k,1) * cos(lonrad) + windptr(i,j,k,2) * sin(lonrad)
703 vptr(i,j,k) = -windptr(i,j,k,1) * sin(latrad) * sin(lonrad) + &
704 windptr(i,j,k,2) * sin(latrad) * cos(lonrad) + &
705 windptr(i,j,k,3) * cos(latrad)
711 print*,
"- CALL FieldGet FOR 3-D WIND_W."
712 call esmf_fieldget(wind_w_target_grid, &
713 computationallbound=clb, &
714 computationalubound=cub, &
715 farrayptr=windptr, rc=rc)
716 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
719 print*,
"- CALL FieldGet FOR U_W."
720 call esmf_fieldget(u_w_target_grid, &
721 farrayptr=uptr, rc=rc)
722 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
725 print*,
"- CALL FieldGet FOR V_W."
726 call esmf_fieldget(v_w_target_grid, &
727 farrayptr=vptr, rc=rc)
728 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
731 print*,
"- CALL FieldGet FOR LATITUDE_W."
732 call esmf_fieldget(latitude_w_target_grid, &
733 farrayptr=latptr, rc=rc)
734 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
737 print*,
"- CALL FieldGet FOR LONGITUDE_W."
738 call esmf_fieldget(longitude_w_target_grid, &
739 farrayptr=lonptr, rc=rc)
740 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
743 do i = clb(1), cub(1)
744 do j = clb(2), cub(2)
745 latrad = latptr(i,j) * acos(-1.) / 180.0
746 lonrad = lonptr(i,j) * acos(-1.) / 180.0
747 do k = clb(3), cub(3)
748 uptr(i,j,k) = windptr(i,j,k,1) * cos(lonrad) + windptr(i,j,k,2) * sin(lonrad)
749 vptr(i,j,k) = -windptr(i,j,k,1) * sin(latrad) * sin(lonrad) + &
750 windptr(i,j,k,2) * sin(latrad) * cos(lonrad) + &
751 windptr(i,j,k,3) * cos(latrad)
792 integer,
intent(in) :: localpet
794 integer :: idsl, idvc, rc
795 integer :: i, j, k, clb(3), cub(3)
797 real(esmf_kind_r8),
parameter :: rd=287.05
798 real(esmf_kind_r8),
parameter :: cp=1004.6
799 real(esmf_kind_r8),
parameter :: rocp=rd/cp
800 real(esmf_kind_r8),
parameter :: rocp1=rocp+1
801 real(esmf_kind_r8),
parameter :: rocpr=1/rocp
803 real(esmf_kind_r8),
pointer :: delp_ptr(:,:,:)
804 real(esmf_kind_r8),
pointer :: pptr(:,:,:)
805 real(esmf_kind_r8),
pointer :: psptr(:,:)
806 real(esmf_kind_r8) :: ak, bk
807 real(esmf_kind_r8),
allocatable :: pi(:,:,:)
809 print*,
"COMPUTE 3-D PRESSURE FROM ADJUSTED SURFACE PRESSURE."
814 print*,
"- CALL FieldGet FOR 3-D PRES."
815 call esmf_fieldget(pres_target_grid, &
816 computationallbound=clb, &
817 computationalubound=cub, &
818 farrayptr=pptr, rc=rc)
819 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
822 print*,
"- CALL FieldGet FOR DELP."
823 call esmf_fieldget(delp_target_grid, &
824 computationallbound=clb, &
825 computationalubound=cub, &
826 farrayptr=delp_ptr, rc=rc)
827 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
830 print*,
"- CALL FieldGet FOR SURFACE PRESSURE AFTER ADJUSTMENT"
831 call esmf_fieldget(ps_target_grid, &
832 farrayptr=psptr, rc=rc)
833 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
836 allocate(pi(clb(1):cub(1),clb(2):cub(2),1:levp1_target))
840 ak = vcoord_target(k,1)
841 bk = vcoord_target(k,2)
844 pi(i,j,k) = ak + bk*psptr(i,j)
851 delp_ptr(i,j,k) = pi(i,j,k) - pi(i,j,k+1)
863 pptr(i,j,k) = (pi(i,j,k)+pi(i,j,k+1))/2.0
871 pptr(i,j,k) = ((pi(i,j,k)**rocp1-pi(i,j,k+1)**rocp1)/ &
872 (rocp1*(pi(i,j,k)-pi(i,j,k+1))))**rocpr
880 if (localpet == 0)
then
881 print*,
'new pres ',pptr(clb(1),clb(2),:)
882 print*,
'delp ',delp_ptr(clb(1),clb(2),:)
904 integer,
intent(in) :: localpet
905 integer :: i, j, k, ii
906 integer :: clb(3), cub(3), ls, rc
908 real(esmf_kind_r8),
pointer :: pptr(:,:,:)
909 real(esmf_kind_r8),
pointer :: psptr(:,:)
910 real(esmf_kind_r8),
pointer :: psnewptr(:,:)
911 real(esmf_kind_r8),
pointer :: tptr(:,:,:)
912 real(esmf_kind_r8),
pointer :: qptr(:,:,:)
913 real(esmf_kind_r8),
pointer :: zsptr(:,:)
914 real(esmf_kind_r8),
pointer :: zsnewptr(:,:)
915 real(esmf_kind_r8),
allocatable :: zu(:,:)
916 real(esmf_kind_r8),
parameter :: beta=-6.5e-3
917 real(esmf_kind_r8),
parameter :: epsilon=1.e-9
918 real(esmf_kind_r8),
parameter :: g=9.80665
919 real(esmf_kind_r8),
parameter :: rd=287.05
920 real(esmf_kind_r8),
parameter :: rv=461.50
921 real(esmf_kind_r8),
parameter :: gor=g/rd
922 real(esmf_kind_r8),
parameter :: fv=rv/rd-1.
923 real(esmf_kind_r8) :: ftv, fgam, apu, fz0
924 real(esmf_kind_r8) :: atvu, atv, fz1, fp0
925 real(esmf_kind_r8) :: apd, azd, agam, azu
926 real(esmf_kind_r8) :: atvd, fp1, gamma, pu
927 real(esmf_kind_r8) :: tvu, pd, tvd
928 real(esmf_kind_r8) :: at, aq, ap, az
930 ftv(at,aq)=at*(1+fv*aq)
931 fgam(apu,atvu,apd,atvd)=-gor*log(atvd/atvu)/log(apd/apu)
932 fz0(ap,atv,azd,apd)=azd+atv/gor*log(apd/ap)
933 fz1(ap,atv,azd,apd,agam)=azd-atv/agam*((apd/ap)**(-agam/gor)-1)
934 fp0(az,azu,apu,atvu)=apu*exp(-gor/atvu*(az-azu))
935 fp1(az,azu,apu,atvu,agam)=apu*(1+agam/atvu*(az-azu))**(-gor/agam)
937 print*,
"- ADJUST SURFACE PRESSURE FOR NEW TERRAIN."
939 print*,
"- CALL FieldGet FOR 3-D PRES."
940 call esmf_fieldget(pres_b4adj_target_grid, &
941 computationallbound=clb, &
942 computationalubound=cub, &
943 farrayptr=pptr, rc=rc)
944 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
948 print*,
'old pres ',pptr(clb(1),clb(2),:)
951 print*,
"- CALL FieldGet FOR TEMPERATURE"
952 call esmf_fieldget(temp_b4adj_target_grid, &
953 farrayptr=tptr, rc=rc)
954 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
959 do ii = 1, num_tracers
960 if (trim(tracers(ii)) ==
"sphum")
exit
963 print*,
"- CALL FieldGet FOR SPECIFIC HUMIDITY"
964 call esmf_fieldget(tracers_b4adj_target_grid(ii), &
965 farrayptr=qptr, rc=rc)
966 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
969 print*,
"- CALL FieldGet FOR SURFACE PRESSURE BEFORE ADJUSTMENT"
970 call esmf_fieldget(ps_b4adj_target_grid, &
971 farrayptr=psptr, rc=rc)
972 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
975 print*,
"- CALL FieldGet FOR SURFACE PRESSURE AFTER ADJUSTMENT"
976 call esmf_fieldget(ps_target_grid, &
977 farrayptr=psnewptr, rc=rc)
978 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
981 print*,
"- CALL FieldGet FOR OLD TERRAIN"
982 call esmf_fieldget(terrain_interp_to_target_grid, &
983 farrayptr=zsptr, rc=rc)
984 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
987 print*,
"- CALL FieldGet FOR NEW TERRAIN"
988 call esmf_fieldget(terrain_target_grid, &
989 farrayptr=zsnewptr, rc=rc)
990 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
993 allocate(zu(clb(1):cub(1),clb(2):cub(2)))
1010 tvu=ftv(tptr(i,j,k),qptr(i,j,k))
1011 zu(i,j)=fz1(pu,tvu,zsptr(i,j),psptr(i,j),gamma)
1012 if(zsnewptr(i,j).le.zu(i,j))
then
1014 tvu=ftv(tptr(i,j,k),qptr(i,j,k))
1015 if(abs(gamma).gt.epsilon)
then
1016 psnewptr(i,j)=fp1(zsnewptr(i,j),zu(i,j),pu,tvu,gamma)
1018 psnewptr(i,j)=fp0(zsnewptr(i,j),zu(i,j),pu,tvu)
1035 if(psnewptr(i,j).eq.0)
then
1037 tvu=ftv(tptr(i,j,k),qptr(i,j,k))
1039 tvd=ftv(tptr(i,j,k-1),qptr(i,j,k-1))
1040 gamma=fgam(pu,tvu,pd,tvd)
1041 if(abs(gamma).gt.epsilon)
then
1042 zu(i,j)=fz1(pu,tvu,zu(i,j),pd,gamma)
1044 zu(i,j)=fz0(pu,tvu,zu(i,j),pd)
1046 if(zsnewptr(i,j).le.zu(i,j))
then
1047 if(abs(gamma).gt.epsilon)
then
1048 psnewptr(i,j)=fp1(zsnewptr(i,j),zu(i,j),pu,tvu,gamma)
1050 psnewptr(i,j)=fp0(zsnewptr(i,j),zu(i,j),pu,tvu)
1070 if(psnewptr(i,j).eq.0)
then
1072 tvu=ftv(tptr(i,j,k),qptr(i,j,k))
1073 psnewptr(i,j)=fp0(zsnewptr(i,j),zu(i,j),pu,tvu)
1081 if (localpet == 0)
then
1086 print*,
'sfcp adjust ',(zsnewptr(i,j)-zsptr(i,j)), psptr(i,j),psnewptr(i,j)
1091 end subroutine newps
1100 integer :: istat, n, k
1103 print*,
"OPEN VERTICAL COORD FILE: ", trim(vcoord_file_target_grid)
1104 open(14, file=trim(vcoord_file_target_grid), form=
'formatted', iostat=istat)
1105 if (istat /= 0)
then
1109 read(14, *, iostat=istat) nvcoord_target, lev_target
1110 if (istat /= 0)
then
1114 levp1_target = lev_target + 1
1116 allocate(vcoord_target(levp1_target, nvcoord_target))
1117 read(14, *, iostat=istat) ((vcoord_target(n,k), k=1,nvcoord_target), n=1,levp1_target)
1118 if (istat /= 0)
then
1136 integer :: isrctermprocessing, rc
1138 type(esmf_regridmethod_flag
) :: method
1139 type(esmf_routehandle
) :: regrid_bl
1141 isrctermprocessing=1
1143 print*,
"- CALL FieldCreate FOR TARGET GRID THOMP CLIMO QNIFA BEFORE ADJUSTMENT."
1144 qnifa_climo_b4adj_target_grid = esmf_fieldcreate(target_grid, &
1145 typekind=esmf_typekind_r8, &
1146 staggerloc=esmf_staggerloc_center, &
1147 ungriddedlbound=(/1/), &
1148 ungriddedubound=(/lev_thomp_mp_climo/), rc=rc)
1149 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1152 print*,
"- CALL FieldCreate FOR TARGET GRID THOMP CLIMO QNWFA BEFORE ADJUSTMENT."
1153 qnwfa_climo_b4adj_target_grid = esmf_fieldcreate(target_grid, &
1154 typekind=esmf_typekind_r8, &
1155 staggerloc=esmf_staggerloc_center, &
1156 ungriddedlbound=(/1/), &
1157 ungriddedubound=(/lev_thomp_mp_climo/), rc=rc)
1158 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1161 print*,
"- CALL FieldCreate FOR TARGET GRID THOMP CLIMO PRESSURE BEFORE ADJUSTMENT."
1162 thomp_pres_climo_b4adj_target_grid = esmf_fieldcreate(target_grid, &
1163 typekind=esmf_typekind_r8, &
1164 staggerloc=esmf_staggerloc_center, &
1165 ungriddedlbound=(/1/), &
1166 ungriddedubound=(/lev_thomp_mp_climo/), rc=rc)
1167 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1170 print*,
"- CALL FieldCreate FOR TARGET GRID THOMP CLIMO QNIFA."
1171 qnifa_climo_target_grid = esmf_fieldcreate(target_grid, &
1172 typekind=esmf_typekind_r8, &
1173 staggerloc=esmf_staggerloc_center, &
1174 ungriddedlbound=(/1/), &
1175 ungriddedubound=(/lev_target/), rc=rc)
1176 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1179 print*,
"- CALL FieldCreate FOR TARGET GRID THOMP CLIMO QNWFA."
1180 qnwfa_climo_target_grid = esmf_fieldcreate(target_grid, &
1181 typekind=esmf_typekind_r8, &
1182 staggerloc=esmf_staggerloc_center, &
1183 ungriddedlbound=(/1/), &
1184 ungriddedubound=(/lev_target/), rc=rc)
1185 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1188 print*,
"- CALL FieldRegridStore FOR THOMPSON CLIMO FIELDS."
1190 method=esmf_regridmethod_bilinear
1192 call esmf_fieldregridstore(qnifa_climo_input_grid, &
1193 qnifa_climo_b4adj_target_grid, &
1194 polemethod=esmf_polemethod_allavg, &
1195 srctermprocessing=isrctermprocessing, &
1196 routehandle=regrid_bl, &
1197 regridmethod=method, rc=rc)
1198 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1201 print*,
"- CALL Field_Regrid FOR THOMP CLIMO QNIFA."
1202 call esmf_fieldregrid(qnifa_climo_input_grid, &
1203 qnifa_climo_b4adj_target_grid, &
1204 routehandle=regrid_bl, &
1205 termorderflag=esmf_termorder_srcseq, rc=rc)
1206 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1209 print*,
"- CALL Field_Regrid FOR THOMP CLIMO QNWFA."
1210 call esmf_fieldregrid(qnwfa_climo_input_grid, &
1211 qnwfa_climo_b4adj_target_grid, &
1212 routehandle=regrid_bl, &
1213 termorderflag=esmf_termorder_srcseq, rc=rc)
1214 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1217 print*,
"- CALL Field_Regrid FOR THOMP PRESSURE."
1218 call esmf_fieldregrid(thomp_pres_climo_input_grid, &
1219 thomp_pres_climo_b4adj_target_grid, &
1220 routehandle=regrid_bl, &
1221 termorderflag=esmf_termorder_srcseq, rc=rc)
1222 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1225 print*,
"- CALL FieldRegridRelease."
1226 call esmf_fieldregridrelease(routehandle=regrid_bl, rc=rc)
1227 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1248 INTEGER :: clb(3), cub(3), rc
1249 INTEGER :: im, km1, km2, nt
1252 REAL(ESMF_KIND_R8),
ALLOCATABLE :: z1(:,:,:), z2(:,:,:)
1253 REAL(ESMF_KIND_R8),
ALLOCATABLE :: c1(:,:,:,:),c2(:,:,:,:)
1255 REAL(ESMF_KIND_R8),
POINTER :: qnifa1ptr(:,:,:)
1256 REAL(ESMF_KIND_R8),
POINTER :: qnifa2ptr(:,:,:)
1257 REAL(ESMF_KIND_R8),
POINTER :: qnwfa1ptr(:,:,:)
1258 REAL(ESMF_KIND_R8),
POINTER :: qnwfa2ptr(:,:,:)
1259 REAL(ESMF_KIND_R8),
POINTER :: p1ptr(:,:,:)
1260 REAL(ESMF_KIND_R8),
POINTER :: p2ptr(:,:,:)
1262 print*,
"- VERTICALY INTERPOLATE THOMP MP CLIMO TRACERS."
1264 print*,
"- CALL FieldGet FOR 3-D THOMP PRES."
1265 call esmf_fieldget(thomp_pres_climo_b4adj_target_grid, &
1266 computationallbound=clb, &
1267 computationalubound=cub, &
1268 farrayptr=p1ptr, rc=rc)
1269 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1278 ALLOCATE(z1(clb(1):cub(1),clb(2):cub(2),lev_thomp_mp_climo))
1279 ALLOCATE(z2(clb(1):cub(1),clb(2):cub(2),lev_target))
1280 ALLOCATE(c1(clb(1):cub(1),clb(2):cub(2),lev_thomp_mp_climo,nt))
1281 ALLOCATE(c2(clb(1):cub(1),clb(2):cub(2),lev_target,nt))
1285 print*,
"- CALL FieldGet FOR 3-D ADJUSTED PRESS"
1286 call esmf_fieldget(pres_target_grid, &
1287 farrayptr=p2ptr, rc=rc)
1288 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1296 print*,
"- CALL FieldGet FOR qnifa before vertical adjustment."
1297 call esmf_fieldget(qnifa_climo_b4adj_target_grid, &
1298 farrayptr=qnifa1ptr, rc=rc)
1299 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1302 c1(:,:,:,1) = qnifa1ptr(:,:,:)
1304 print*,
"- CALL FieldGet FOR qnwfa before vertical adjustment."
1305 call esmf_fieldget(qnwfa_climo_b4adj_target_grid, &
1306 farrayptr=qnwfa1ptr, rc=rc)
1307 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1310 c1(:,:,:,2) = qnwfa1ptr(:,:,:)
1318 im = (cub(1)-clb(1)+1) * (cub(2)-clb(2)+1)
1319 km1= lev_thomp_mp_climo
1322 CALL
terp3(im,1,1,1,1,nt,(im*km1),(im*km2), &
1323 km1,im,im,z1,c1,km2,im,im,z2,c2)
1325 print*,
"- CALL FieldGet FOR ADJUSTED climo qnifa."
1326 call esmf_fieldget(qnifa_climo_target_grid, &
1327 farrayptr=qnifa2ptr, rc=rc)
1328 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1331 print*,
"- CALL FieldGet FOR ADJUSTED climo qnwfa."
1332 call esmf_fieldget(qnwfa_climo_target_grid, &
1333 farrayptr=qnwfa2ptr, rc=rc)
1334 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1340 qnifa2ptr(i,j,k) = c2(i,j,k,1)
1341 qnwfa2ptr(i,j,k) = c2(i,j,k,2)
1346 DEALLOCATE (z1, z2, c1, c2)
1348 call esmf_fielddestroy(qnifa_climo_b4adj_target_grid, rc=rc)
1349 call esmf_fielddestroy(qnwfa_climo_b4adj_target_grid, rc=rc)
1350 call esmf_fielddestroy(thomp_pres_climo_b4adj_target_grid, rc=rc)
1372 REAL(ESMF_KIND_R8),
PARAMETER :: dltdz=-6.5e-3*287.05/9.80665
1373 REAL(ESMF_KIND_R8),
PARAMETER :: dlpvdrt=-2.5e6/461.50
1374 REAL(ESMF_KIND_R8),
PARAMETER :: one = 1.0_esmf_kind_r8
1376 INTEGER :: i, j, k, clb(3), cub(3), rc
1377 INTEGER :: im, km1, km2, nt, ii
1379 REAL(ESMF_KIND_R8) :: dz
1380 REAL(ESMF_KIND_R8),
ALLOCATABLE :: z1(:,:,:), z2(:,:,:)
1381 REAL(ESMF_KIND_R8),
ALLOCATABLE :: c1(:,:,:,:),c2(:,:,:,:)
1383 REAL(ESMF_KIND_R8),
POINTER :: p1ptr(:,:,:)
1384 REAL(ESMF_KIND_R8),
POINTER :: p2ptr(:,:,:)
1385 REAL(ESMF_KIND_R8),
POINTER :: dzdt1ptr(:,:,:)
1386 REAL(ESMF_KIND_R8),
POINTER :: dzdt2ptr(:,:,:)
1387 REAL(ESMF_KIND_R8),
POINTER :: t1ptr(:,:,:)
1388 REAL(ESMF_KIND_R8),
POINTER :: t2ptr(:,:,:)
1389 REAL(ESMF_KIND_R8),
POINTER :: q1ptr(:,:,:)
1390 REAL(ESMF_KIND_R8),
POINTER :: q2ptr(:,:,:)
1391 REAL(ESMF_KIND_R8),
POINTER :: wind1ptr(:,:,:,:)
1392 REAL(ESMF_KIND_R8),
POINTER :: wind2ptr(:,:,:,:)
1399 print*,
"- VERTICALY INTERPOLATE FIELDS."
1401 print*,
"- CALL FieldGet FOR 3-D PRES."
1402 call esmf_fieldget(pres_b4adj_target_grid, &
1403 computationallbound=clb, &
1404 computationalubound=cub, &
1405 farrayptr=p1ptr, rc=rc)
1406 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1415 ALLOCATE(z1(clb(1):cub(1),clb(2):cub(2),lev_input))
1416 ALLOCATE(z2(clb(1):cub(1),clb(2):cub(2),lev_target))
1417 ALLOCATE(c1(clb(1):cub(1),clb(2):cub(2),lev_input,num_tracers+5))
1418 ALLOCATE(c2(clb(1):cub(1),clb(2):cub(2),lev_target,num_tracers+5))
1422 print*,
"- CALL FieldGet FOR 3-D ADJUSTED PRESS"
1423 call esmf_fieldget(pres_target_grid, &
1424 farrayptr=p2ptr, rc=rc)
1425 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1430 print*,
"- CALL FieldGet FOR 3-D WIND."
1431 call esmf_fieldget(wind_b4adj_target_grid, &
1432 farrayptr=wind1ptr, rc=rc)
1433 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1436 c1(:,:,:,1) = wind1ptr(:,:,:,1)
1437 c1(:,:,:,2) = wind1ptr(:,:,:,2)
1438 c1(:,:,:,3) = wind1ptr(:,:,:,3)
1440 print*,
"- CALL FieldGet FOR VERTICAL VELOCITY."
1441 call esmf_fieldget(dzdt_b4adj_target_grid, &
1442 farrayptr=dzdt1ptr, rc=rc)
1443 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1446 c1(:,:,:,4) = dzdt1ptr(:,:,:)
1447 print*,
"MIN MAX W TARGETB4 IN VINTG = ", minval(dzdt1ptr(:,:,:)), maxval(dzdt1ptr(:,:,:))
1449 print*,
"- CALL FieldGet FOR 3-D TEMP."
1450 call esmf_fieldget(temp_b4adj_target_grid, &
1451 farrayptr=t1ptr, rc=rc)
1452 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1455 c1(:,:,:,5) = t1ptr(:,:,:)
1457 DO i = 1, num_tracers
1459 print*,
"- CALL FieldGet FOR 3-D TRACERS ", trim(tracers(i))
1460 call esmf_fieldget(tracers_b4adj_target_grid(i), &
1461 farrayptr=q1ptr, rc=rc)
1462 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1465 c1(:,:,:,5+i) = q1ptr(:,:,:)
1475 im = (cub(1)-clb(1)+1) * (cub(2)-clb(2)+1)
1480 CALL
terp3(im,1,1,1,1,4+nt,(im*km1),(im*km2), &
1481 km1,im,im,z1,c1,km2,im,im,z2,c2)
1488 print*,
"- CALL FieldGet FOR 3-D ADJUSTED TEMP."
1489 call esmf_fieldget(temp_target_grid, &
1490 farrayptr=t2ptr, rc=rc)
1491 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1494 print*,
"- CALL FieldGet FOR ADJUSTED VERTICAL VELOCITY."
1495 call esmf_fieldget(dzdt_target_grid, &
1496 farrayptr=dzdt2ptr, rc=rc)
1497 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1500 print*,
"- CALL FieldGet FOR 3-D ADJUSTED WIND."
1501 call esmf_fieldget(wind_target_grid, &
1502 farrayptr=wind2ptr, rc=rc)
1503 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1509 wind2ptr(i,j,k,1)=c2(i,j,k,1)
1510 wind2ptr(i,j,k,2)=c2(i,j,k,2)
1511 wind2ptr(i,j,k,3)=c2(i,j,k,3)
1512 dzdt2ptr(i,j,k)=c2(i,j,k,4)
1513 dz=z2(i,j,k)-z1(i,j,1)
1515 t2ptr(i,j,k)=c2(i,j,k,5)
1517 t2ptr(i,j,k)=c1(i,j,1,5)*exp(dltdz*dz)
1523 DO ii = 1, num_tracers
1525 print*,
"- CALL FieldGet FOR 3-D TRACER ", trim(tracers(ii))
1526 call esmf_fieldget(tracers_target_grid(ii), &
1527 farrayptr=q2ptr, rc=rc)
1528 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1531 IF (trim(tracers(ii)) ==
"sphum")
THEN
1536 dz=z2(i,j,k)-z1(i,j,1)
1538 q2ptr(i,j,k) = c2(i,j,k,5+ii)
1540 q2ptr(i,j,k) = c1(i,j,1,5+ii)*exp(dlpvdrt*(one/t2ptr(i,j,k)-one/t1ptr(i,j,1))-dz)
1551 q2ptr(i,j,k) = c2(i,j,k,5+ii)
1560 DEALLOCATE (z1, z2, c1, c2)
1562 END SUBROUTINE vintg
1600 SUBROUTINE terp3(IM,IXZ1,IXQ1,IXZ2,IXQ2,NM,NXQ1,NXQ2, &
1601 km1,kxz1,kxq1,z1,q1,km2,kxz2,kxq2,z2,q2)
1603 INTEGER im,ixz1,ixq1,ixz2,ixq2,nm,nxq1,nxq2
1604 INTEGER km1,kxz1,kxq1,km2,kxz2,kxq2
1607 REAL(ESMF_KIND_R8),
PARAMETER :: one = 1.0_esmf_kind_r8
1608 REAL(ESMF_KIND_R8) :: z1(1+(im-1)*ixz1+(km1-1)*kxz1)
1609 REAL(ESMF_KIND_R8) :: q1(1+(im-1)*ixq1+(km1-1)*kxq1+(nm-1)*nxq1)
1610 REAL(ESMF_KIND_R8) :: z2(1+(im-1)*ixz2+(km2-1)*kxz2)
1611 REAL(ESMF_KIND_R8) :: q2(1+(im-1)*ixq2+(km2-1)*kxq2+(nm-1)*nxq2)
1613 REAL(ESMF_KIND_R8) :: ffa(im),ffb(im),ffc(im),ffd(im)
1614 REAL(ESMF_KIND_R8) :: gga(im),ggb(im),ggc(im),ggd(im)
1615 REAL(ESMF_KIND_R8) :: z1a,z1b,z1c,z1d,q1a,q1b,q1c,q1d,z2s,q2s
1620 CALL
rsearch(im,km1,ixz1,kxz1,z1,km2,ixz2,kxz2,z2,1,im,k1s)
1634 IF(k1.EQ.1.OR.k1.EQ.km1-1)
THEN
1635 z2s=z2(1+(i-1)*ixz2+(k2-1)*kxz2)
1636 z1a=z1(1+(i-1)*ixz1+(k1-1)*kxz1)
1637 z1b=z1(1+(i-1)*ixz1+(k1+0)*kxz1)
1638 ffa(i)=(z2s-z1b)/(z1a-z1b)
1639 ffb(i)=(z2s-z1a)/(z1b-z1a)
1640 gga(i)=one/(z1a-z1b)
1641 ggb(i)=one/(z1b-z1a)
1642 ELSEIF(k1.GT.1.AND.k1.LT.km1-1)
THEN
1643 z2s=z2(1+(i-1)*ixz2+(k2-1)*kxz2)
1644 z1a=z1(1+(i-1)*ixz1+(k1-2)*kxz1)
1645 z1b=z1(1+(i-1)*ixz1+(k1-1)*kxz1)
1646 z1c=z1(1+(i-1)*ixz1+(k1+0)*kxz1)
1647 z1d=z1(1+(i-1)*ixz1+(k1+1)*kxz1)
1648 ffa(i)=(z2s-z1b)/(z1a-z1b)* &
1649 (z2s-z1c)/(z1a-z1c)* &
1651 ffb(i)=(z2s-z1a)/(z1b-z1a)* &
1652 (z2s-z1c)/(z1b-z1c)* &
1654 ffc(i)=(z2s-z1a)/(z1c-z1a)* &
1655 (z2s-z1b)/(z1c-z1b)* &
1657 ffd(i)=(z2s-z1a)/(z1d-z1a)* &
1658 (z2s-z1b)/(z1d-z1b)* &
1660 gga(i)= one/(z1a-z1b)* &
1661 (z2s-z1c)/(z1a-z1c)* &
1662 (z2s-z1d)/(z1a-z1d)+ &
1663 (z2s-z1b)/(z1a-z1b)* &
1665 (z2s-z1d)/(z1a-z1d)+ &
1666 (z2s-z1b)/(z1a-z1b)* &
1667 (z2s-z1c)/(z1a-z1c)* &
1669 ggb(i)= one/(z1b-z1a)* &
1670 (z2s-z1c)/(z1b-z1c)* &
1671 (z2s-z1d)/(z1b-z1d)+ &
1672 (z2s-z1a)/(z1b-z1a)* &
1674 (z2s-z1d)/(z1b-z1d)+ &
1675 (z2s-z1a)/(z1b-z1a)* &
1676 (z2s-z1c)/(z1b-z1c)* &
1678 ggc(i)= one/(z1c-z1a)* &
1679 (z2s-z1b)/(z1c-z1b)* &
1680 (z2s-z1d)/(z1c-z1d)+ &
1681 (z2s-z1a)/(z1c-z1a)* &
1683 (z2s-z1d)/(z1c-z1d)+ &
1684 (z2s-z1a)/(z1c-z1a)* &
1685 (z2s-z1b)/(z1c-z1b)* &
1687 ggd(i)= one/(z1d-z1a)* &
1688 (z2s-z1b)/(z1d-z1b)* &
1689 (z2s-z1c)/(z1d-z1c)+ &
1690 (z2s-z1a)/(z1d-z1a)* &
1692 (z2s-z1c)/(z1d-z1c)+ &
1693 (z2s-z1a)/(z1d-z1a)* &
1694 (z2s-z1b)/(z1d-z1b)* &
1704 q2s=q1(1+(i-1)*ixq1+(n-1)*nxq1)
1706 ELSEIF(k1.EQ.km1)
THEN
1707 q2s=q1(1+(i-1)*ixq1+(km1-1)*kxq1+(n-1)*nxq1)
1709 ELSEIF(k1.EQ.1.OR.k1.EQ.km1-1)
THEN
1710 q1a=q1(1+(i-1)*ixq1+(k1-1)*kxq1+(n-1)*nxq1)
1711 q1b=q1(1+(i-1)*ixq1+(k1+0)*kxq1+(n-1)*nxq1)
1712 q2s=ffa(i)*q1a+ffb(i)*q1b
1715 q1a=q1(1+(i-1)*ixq1+(k1-2)*kxq1+(n-1)*nxq1)
1716 q1b=q1(1+(i-1)*ixq1+(k1-1)*kxq1+(n-1)*nxq1)
1717 q1c=q1(1+(i-1)*ixq1+(k1+0)*kxq1+(n-1)*nxq1)
1718 q1d=q1(1+(i-1)*ixq1+(k1+1)*kxq1+(n-1)*nxq1)
1719 q2s=ffa(i)*q1a+ffb(i)*q1b+ffc(i)*q1c+ffd(i)*q1d
1721 IF(q2s.LT.min(q1b,q1c))
THEN
1724 ELSEIF(q2s.GT.max(q1b,q1c))
THEN
1729 q2(1+(i-1)*ixq2+(k2-1)*kxq2+(n-1)*nxq2)=q2s
1736 END SUBROUTINE terp3
1794 SUBROUTINE rsearch(IM,KM1,IXZ1,KXZ1,Z1,KM2,IXZ2,KXZ2,Z2,IXL2,KXL2,L2)
1797 INTEGER,
INTENT(IN) :: im,km1,ixz1,kxz1,km2,ixz2,kxz2,ixl2,kxl2
1798 INTEGER,
INTENT(OUT) :: l2(1+(im-1)*ixl2+(km2-1)*kxl2)
1800 REAL(ESMF_KIND_R8),
INTENT(IN) :: z1(1+(im-1)*ixz1+(km1-1)*kxz1)
1801 REAL(ESMF_KIND_R8),
INTENT(IN) :: z2(1+(im-1)*ixz2+(km2-1)*kxz2)
1805 REAL(ESMF_KIND_R8) :: z
1811 IF (z1(1+(i-1)*ixz1).LE.z1(1+(i-1)*ixz1+(km1-1)*kxz1))
THEN
1814 z=z2(1+(i-1)*ixz2+(k2-1)*kxz2)
1817 IF(z.LT.z1(1+(i-1)*ixz1+l*kxz1))
EXIT
1821 l2(1+(i-1)*ixl2+(k2-1)*kxl2)=l
1826 z=z2(1+(i-1)*ixz2+(k2-1)*kxz2)
1829 IF(z.GT.z1(1+(i-1)*ixz1+l*kxz1))
EXIT
1833 l2(1+(i-1)*ixl2+(k2-1)*kxl2)=l
1846 integer :: i,ii, j,k, rc, clb(2), cub(2)
1848 real(esmf_kind_r8),
allocatable :: pe0(:), pn0(:)
1849 real(esmf_kind_r8),
pointer :: psptr(:,:)
1850 real(esmf_kind_r8),
pointer :: zhsfcptr(:,:)
1851 real(esmf_kind_r8),
pointer :: zhptr(:,:,:)
1852 real(esmf_kind_r8),
pointer :: tptr(:,:,:)
1853 real(esmf_kind_r8),
pointer :: qptr(:,:,:)
1854 real(esmf_kind_r8) :: ak, bk, zvir, grd
1855 real(esmf_kind_r8),
parameter :: grav = 9.80665
1856 real(esmf_kind_r8),
parameter :: rdgas = 287.05
1857 real(esmf_kind_r8),
parameter :: rvgas = 461.50
1859 print*,
"- COMPUTE HEIGHT"
1861 print*,
"- CALL FieldGet FOR SURFACE PRESSURE"
1862 call esmf_fieldget(ps_target_grid, &
1863 computationallbound=clb, &
1864 computationalubound=cub, &
1865 farrayptr=psptr, rc=rc)
1866 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1869 print*,
"- CALL FieldGet FOR TERRAIN HEIGHT"
1870 call esmf_fieldget(terrain_target_grid, &
1871 farrayptr=zhsfcptr, rc=rc)
1872 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1875 print*,
"- CALL FieldGet FOR HEIGHT"
1876 call esmf_fieldget(zh_target_grid, &
1877 farrayptr=zhptr, rc=rc)
1878 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1881 print*,
"- CALL FieldGet FOR TEMPERATURE"
1882 call esmf_fieldget(temp_target_grid, &
1883 farrayptr=tptr, rc=rc)
1884 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1887 do ii = 1, num_tracers
1888 if (trim(tracers(ii)) ==
"sphum")
exit
1891 print*,
"- CALL FieldGet FOR SPECIFIC HUMIDITY"
1892 call esmf_fieldget(tracers_target_grid(ii), &
1893 farrayptr=qptr, rc=rc)
1894 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1898 zvir = rvgas/rdgas - 1.0_esmf_kind_r8
1900 allocate(pe0(levp1_target))
1901 allocate(pn0(levp1_target))
1903 do j = clb(2), cub(2)
1904 do i = clb(1), cub(1)
1906 do k = 1, levp1_target
1907 ak = vcoord_target(k,1)
1909 bk = vcoord_target(k,2)
1911 pe0(k) = ak + bk*psptr(i,j)
1912 pn0(k) = log(pe0(k))
1915 zhptr(i,j,1) = zhsfcptr(i,j)
1917 do k = 2, levp1_target
1918 zhptr(i,j,k) = zhptr(i,j,k-1)+tptr(i,j,k-1)*(1.+zvir*qptr(i,j,k-1))* &
1919 (pn0(k-1)-pn0(k))/grd
1925 deallocate(pe0, pn0)
1938 print*,
"- DESTROY TARGET GRID ATMOSPHERIC BEFORE ADJUSTMENT FIELDS."
1940 call esmf_fielddestroy(wind_b4adj_target_grid, rc=rc)
1941 call esmf_fielddestroy(dzdt_b4adj_target_grid, rc=rc)
1942 call esmf_fielddestroy(ps_b4adj_target_grid, rc=rc)
1943 call esmf_fielddestroy(pres_b4adj_target_grid, rc=rc)
1944 call esmf_fielddestroy(temp_b4adj_target_grid, rc=rc)
1945 call esmf_fielddestroy(terrain_interp_to_target_grid, rc=rc)
1947 do i = 1, num_tracers
1948 call esmf_fielddestroy(tracers_b4adj_target_grid(i), rc=rc)
1951 deallocate(tracers_b4adj_target_grid)
1963 print*,
"- DESTROY TARGET GRID ATMOSPHERIC FIELDS."
1965 call esmf_fielddestroy(delp_target_grid, rc=rc)
1966 call esmf_fielddestroy(dzdt_target_grid, rc=rc)
1967 call esmf_fielddestroy(ps_target_grid, rc=rc)
1968 call esmf_fielddestroy(pres_target_grid, rc=rc)
1969 call esmf_fielddestroy(temp_target_grid, rc=rc)
1970 call esmf_fielddestroy(u_s_target_grid, rc=rc)
1971 call esmf_fielddestroy(v_s_target_grid, rc=rc)
1972 call esmf_fielddestroy(wind_target_grid, rc=rc)
1973 call esmf_fielddestroy(wind_s_target_grid, rc=rc)
1974 call esmf_fielddestroy(wind_w_target_grid, rc=rc)
1975 call esmf_fielddestroy(u_w_target_grid, rc=rc)
1976 call esmf_fielddestroy(v_w_target_grid, rc=rc)
1977 call esmf_fielddestroy(zh_target_grid, rc=rc)
1979 do i = 1, num_tracers
1980 call esmf_fielddestroy(tracers_target_grid(i), rc=rc)
1983 deallocate(tracers_target_grid)
1985 if (esmf_fieldiscreated(qnifa_climo_target_grid))
then
1986 call esmf_fielddestroy(qnifa_climo_target_grid, rc=rc)
1989 if (esmf_fieldiscreated(qnwfa_climo_target_grid))
then
1990 call esmf_fielddestroy(qnwfa_climo_target_grid, rc=rc)
subroutine write_fv3_atm_bndy_data_netcdf(localpet)
Writes atmospheric fields along the lateral boundary.
subroutine cleanup_target_atm_b4adj_data
Cleanup atmospheric field (before adjustment) objects.
subroutine vintg
Vertically interpolate upper-air fields.
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.
subroutine read_vcoord_info
Reads model vertical coordinate definition file (as specified by namelist variable vcoord_file_target...
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 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 write_fv3_atm_data_netcdf(localpet)
Write atmospheric coldstart files (netcdf format).
subroutine, public read_thomp_mp_climo_data
Read Thompson climatological MP data file and time interpolate data to current cycle time...
subroutine create_atm_esmf_fields
Create target grid field objects.
subroutine write_fv3_atm_header_netcdf(localpet)
Writes atmospheric header file in netcdf format.
subroutine error_handler(string, rc)
General error handler.
subroutine rsearch(IM, KM1, IXZ1, KXZ1, Z1, KM2, IXZ2, KXZ2, Z2, IXL2, KXL2, L2)
Search for a surrounding real interval.
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.
subroutine convert_winds
Convert 3-d component winds to u and v.
subroutine cleanup_target_atm_data
Cleanup target grid atmospheric field objects.