21 nst_files_input_grid, &
22 sfc_files_input_grid, &
23 atm_files_input_grid, &
24 grib2_file_input_grid, &
25 atm_core_files_input_grid, &
26 atm_tracer_files_input_grid, &
28 orog_dir_input_grid, &
29 orog_files_input_grid, &
30 tracers_input, num_tracers_input, &
31 input_type, tracers, &
33 geogrid_file_input_grid, &
36 minmax_vgfrc_from_climo, &
41 ip1_input, jp1_input, &
42 num_tiles_input_grid, &
43 latitude_input_grid, &
44 longitude_input_grid, &
53 type(esmf_field
),
public :: dzdt_input_grid
54 type(esmf_field) :: dpres_input_grid
55 type(esmf_field),
public :: pres_input_grid
56 type(esmf_field),
public :: ps_input_grid
57 type(esmf_field),
public :: terrain_input_grid
58 type(esmf_field),
public :: temp_input_grid
60 type(esmf_field
),
public :: u_input_grid
61 type(esmf_field),
public :: v_input_grid
62 type(esmf_field),
public :: wind_input_grid
63 type(esmf_field),
allocatable,
public :: tracers_input_grid(:)
65 integer,
public :: lev_input
66 integer,
public :: levp1_input
70 integer,
public :: veg_type_landice_input = 15
73 integer,
parameter :: ICET_DEFAULT = 265.0
75 type(esmf_field),
public :: canopy_mc_input_grid
76 type(esmf_field),
public :: f10m_input_grid
77 type(esmf_field),
public :: ffmm_input_grid
79 type(esmf_field),
public :: landsea_mask_input_grid
81 type(esmf_field),
public :: q2m_input_grid
82 type(esmf_field),
public :: seaice_depth_input_grid
83 type(esmf_field),
public :: seaice_fract_input_grid
84 type(esmf_field),
public :: seaice_skin_temp_input_grid
85 type(esmf_field),
public :: skin_temp_input_grid
86 type(esmf_field),
public :: snow_depth_input_grid
87 type(esmf_field),
public :: snow_liq_equiv_input_grid
88 type(esmf_field),
public :: soil_temp_input_grid
89 type(esmf_field),
public :: soil_type_input_grid
90 type(esmf_field),
public :: soilm_liq_input_grid
91 type(esmf_field),
public :: soilm_tot_input_grid
92 type(esmf_field),
public :: srflag_input_grid
93 type(esmf_field),
public :: t2m_input_grid
94 type(esmf_field),
public :: tprcp_input_grid
95 type(esmf_field),
public :: ustar_input_grid
96 type(esmf_field),
public :: veg_type_input_grid
97 type(esmf_field),
public :: z0_input_grid
98 type(esmf_field),
public :: veg_greenness_input_grid
99 type(esmf_field),
public :: lai_input_grid
100 type(esmf_field),
public :: max_veg_greenness_input_grid
101 type(esmf_field),
public :: min_veg_greenness_input_grid
103 integer,
public :: lsoil_input=4
106 character(len=50),
private,
allocatable :: slevs(:)
110 type(esmf_field
),
public :: c_d_input_grid
111 type(esmf_field),
public :: c_0_input_grid
112 type(esmf_field),
public :: d_conv_input_grid
113 type(esmf_field),
public :: dt_cool_input_grid
114 type(esmf_field),
public :: ifd_input_grid
116 type(esmf_field),
public :: qrain_input_grid
117 type(esmf_field),
public :: tref_input_grid
118 type(esmf_field),
public :: w_d_input_grid
119 type(esmf_field),
public :: w_0_input_grid
120 type(esmf_field),
public :: xs_input_grid
121 type(esmf_field),
public :: xt_input_grid
122 type(esmf_field),
public :: xu_input_grid
123 type(esmf_field),
public :: xv_input_grid
124 type(esmf_field),
public :: xz_input_grid
125 type(esmf_field),
public :: xtts_input_grid
126 type(esmf_field),
public :: xzts_input_grid
127 type(esmf_field),
public :: z_c_input_grid
128 type(esmf_field),
public :: zm_input_grid
152 integer,
intent(in) :: localpet
158 if (trim(input_type) ==
"restart")
then
166 elseif (trim(input_type) ==
"gaussian_netcdf")
then
174 elseif (trim(input_type) ==
"history")
then
182 elseif (trim(input_type) ==
"gaussian_nemsio")
then
190 elseif (trim(input_type) ==
"gfs_gaussian_nemsio")
then
198 elseif (trim(input_type) ==
"gfs_sigio")
then
206 elseif (trim(input_type) ==
"grib2")
then
222 integer,
intent(in) :: localpet
226 print*,
"- READ INPUT GRID NST DATA."
228 print*,
"- CALL FieldCreate FOR INPUT GRID C_D."
229 c_d_input_grid = esmf_fieldcreate(input_grid, &
230 typekind=esmf_typekind_r8, &
231 staggerloc=esmf_staggerloc_center, rc=rc)
232 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
235 print*,
"- CALL FieldCreate FOR INPUT GRID C_0."
236 c_0_input_grid = esmf_fieldcreate(input_grid, &
237 typekind=esmf_typekind_r8, &
238 staggerloc=esmf_staggerloc_center, rc=rc)
239 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
242 print*,
"- CALL FieldCreate FOR INPUT GRID D_CONV."
243 d_conv_input_grid = esmf_fieldcreate(input_grid, &
244 typekind=esmf_typekind_r8, &
245 staggerloc=esmf_staggerloc_center, rc=rc)
246 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
249 print*,
"- CALL FieldCreate FOR INPUT GRID DT_COOL."
250 dt_cool_input_grid = esmf_fieldcreate(input_grid, &
251 typekind=esmf_typekind_r8, &
252 staggerloc=esmf_staggerloc_center, rc=rc)
253 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
256 print*,
"- CALL FieldCreate FOR INPUT GRID IFD."
257 ifd_input_grid = esmf_fieldcreate(input_grid, &
258 typekind=esmf_typekind_r8, &
259 staggerloc=esmf_staggerloc_center, rc=rc)
260 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
263 print*,
"- CALL FieldCreate FOR INPUT GRID QRAIN."
264 qrain_input_grid = esmf_fieldcreate(input_grid, &
265 typekind=esmf_typekind_r8, &
266 staggerloc=esmf_staggerloc_center, rc=rc)
267 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
270 print*,
"- CALL FieldCreate FOR INPUT GRID TREF."
271 tref_input_grid = esmf_fieldcreate(input_grid, &
272 typekind=esmf_typekind_r8, &
273 staggerloc=esmf_staggerloc_center, rc=rc)
274 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
277 print*,
"- CALL FieldCreate FOR INPUT GRID W_D."
278 w_d_input_grid = esmf_fieldcreate(input_grid, &
279 typekind=esmf_typekind_r8, &
280 staggerloc=esmf_staggerloc_center, rc=rc)
281 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
284 print*,
"- CALL FieldCreate FOR INPUT GRID W_0."
285 w_0_input_grid = esmf_fieldcreate(input_grid, &
286 typekind=esmf_typekind_r8, &
287 staggerloc=esmf_staggerloc_center, rc=rc)
288 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
291 print*,
"- CALL FieldCreate FOR INPUT GRID XS."
292 xs_input_grid = esmf_fieldcreate(input_grid, &
293 typekind=esmf_typekind_r8, &
294 staggerloc=esmf_staggerloc_center, rc=rc)
295 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
298 print*,
"- CALL FieldCreate FOR INPUT GRID XT."
299 xt_input_grid = esmf_fieldcreate(input_grid, &
300 typekind=esmf_typekind_r8, &
301 staggerloc=esmf_staggerloc_center, rc=rc)
302 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
305 print*,
"- CALL FieldCreate FOR INPUT GRID XU."
306 xu_input_grid = esmf_fieldcreate(input_grid, &
307 typekind=esmf_typekind_r8, &
308 staggerloc=esmf_staggerloc_center, rc=rc)
309 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
312 print*,
"- CALL FieldCreate FOR INPUT GRID XV."
313 xv_input_grid = esmf_fieldcreate(input_grid, &
314 typekind=esmf_typekind_r8, &
315 staggerloc=esmf_staggerloc_center, rc=rc)
316 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
319 print*,
"- CALL FieldCreate FOR INPUT GRID XZ."
320 xz_input_grid = esmf_fieldcreate(input_grid, &
321 typekind=esmf_typekind_r8, &
322 staggerloc=esmf_staggerloc_center, rc=rc)
323 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
326 print*,
"- CALL FieldCreate FOR INPUT GRID XTTS."
327 xtts_input_grid = esmf_fieldcreate(input_grid, &
328 typekind=esmf_typekind_r8, &
329 staggerloc=esmf_staggerloc_center, rc=rc)
330 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
333 print*,
"- CALL FieldCreate FOR INPUT GRID XZTS."
334 xzts_input_grid = esmf_fieldcreate(input_grid, &
335 typekind=esmf_typekind_r8, &
336 staggerloc=esmf_staggerloc_center, rc=rc)
337 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
340 print*,
"- CALL FieldCreate FOR INPUT GRID Z_C."
341 z_c_input_grid = esmf_fieldcreate(input_grid, &
342 typekind=esmf_typekind_r8, &
343 staggerloc=esmf_staggerloc_center, rc=rc)
344 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
347 print*,
"- CALL FieldCreate FOR INPUT GRID ZM."
348 zm_input_grid = esmf_fieldcreate(input_grid, &
349 typekind=esmf_typekind_r8, &
350 staggerloc=esmf_staggerloc_center, rc=rc)
351 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
359 if (trim(input_type) ==
"gaussian_nemsio" .or. trim(input_type) ==
"gfs_gaussian_nemsio")
then
384 integer,
intent(in) :: localpet
394 if (trim(input_type) ==
"restart")
then
402 elseif (trim(input_type) ==
"history" .or. trim(input_type) == &
403 "gaussian_netcdf")
then
411 elseif (trim(input_type) ==
"gaussian_nemsio")
then
419 elseif (trim(input_type) ==
"gfs_gaussian_nemsio")
then
427 elseif (trim(input_type) ==
"gfs_sigio")
then
435 elseif (trim(input_type) ==
"grib2")
then
452 print*,
"- INITIALIZE ATMOSPHERIC ESMF FIELDS."
454 print*,
"- CALL FieldCreate FOR INPUT GRID 3-D WIND."
455 wind_input_grid = esmf_fieldcreate(input_grid, &
456 typekind=esmf_typekind_r8, &
457 staggerloc=esmf_staggerloc_center, &
458 ungriddedlbound=(/1,1/), &
459 ungriddedubound=(/lev_input,3/), rc=rc)
460 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
463 print*,
"- CALL FieldCreate FOR INPUT GRID SURFACE PRESSURE."
464 ps_input_grid = esmf_fieldcreate(input_grid, &
465 typekind=esmf_typekind_r8, &
466 staggerloc=esmf_staggerloc_center, rc=rc)
467 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
470 print*,
"- CALL FieldCreate FOR INPUT GRID TERRAIN."
471 terrain_input_grid = esmf_fieldcreate(input_grid, &
472 typekind=esmf_typekind_r8, &
473 staggerloc=esmf_staggerloc_center, rc=rc)
474 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
477 print*,
"- CALL FieldCreate FOR INPUT GRID TEMPERATURE."
478 temp_input_grid = esmf_fieldcreate(input_grid, &
479 typekind=esmf_typekind_r8, &
480 staggerloc=esmf_staggerloc_center, &
481 ungriddedlbound=(/1/), &
482 ungriddedubound=(/lev_input/), rc=rc)
483 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
486 allocate(tracers_input_grid(num_tracers_input))
488 do i = 1, num_tracers_input
489 print*,
"- CALL FieldCreate FOR INPUT GRID TRACER ", trim(tracers_input(i))
490 tracers_input_grid(i) = esmf_fieldcreate(input_grid, &
491 typekind=esmf_typekind_r8, &
492 staggerloc=esmf_staggerloc_center, &
493 ungriddedlbound=(/1/), &
494 ungriddedubound=(/lev_input/), rc=rc)
495 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
499 print*,
"- CALL FieldCreate FOR INPUT GRID DZDT."
500 dzdt_input_grid = esmf_fieldcreate(input_grid, &
501 typekind=esmf_typekind_r8, &
502 staggerloc=esmf_staggerloc_center, &
503 ungriddedlbound=(/1/), &
504 ungriddedubound=(/lev_input/), rc=rc)
505 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
508 print*,
"- CALL FieldCreate FOR INPUT GRID U."
509 u_input_grid = esmf_fieldcreate(input_grid, &
510 typekind=esmf_typekind_r8, &
511 staggerloc=esmf_staggerloc_center, &
512 ungriddedlbound=(/1/), &
513 ungriddedubound=(/lev_input/), rc=rc)
514 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
517 print*,
"- CALL FieldCreate FOR INPUT GRID V."
518 v_input_grid = esmf_fieldcreate(input_grid, &
519 typekind=esmf_typekind_r8, &
520 staggerloc=esmf_staggerloc_center, &
521 ungriddedlbound=(/1/), &
522 ungriddedubound=(/lev_input/), rc=rc)
523 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
526 print*,
"- CALL FieldCreate FOR INPUT GRID PRESSURE."
527 pres_input_grid = esmf_fieldcreate(input_grid, &
528 typekind=esmf_typekind_r8, &
529 staggerloc=esmf_staggerloc_center, &
530 ungriddedlbound=(/1/), &
531 ungriddedubound=(/lev_input/), rc=rc)
532 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
546 print*,
"- CALL FieldCreate FOR INPUT GRID LANDSEA MASK."
547 landsea_mask_input_grid = esmf_fieldcreate(input_grid, &
548 typekind=esmf_typekind_r8, &
549 staggerloc=esmf_staggerloc_center, rc=rc)
550 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
553 print*,
"- CALL FieldCreate FOR INPUT GRID Z0."
554 z0_input_grid = esmf_fieldcreate(input_grid, &
555 typekind=esmf_typekind_r8, &
556 staggerloc=esmf_staggerloc_center, rc=rc)
557 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
560 print*,
"- CALL FieldCreate FOR INPUT GRID VEGETATION TYPE."
561 veg_type_input_grid = esmf_fieldcreate(input_grid, &
562 typekind=esmf_typekind_r8, &
563 staggerloc=esmf_staggerloc_center, rc=rc)
564 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
567 print*,
"- CALL FieldCreate FOR INPUT GRID CANOPY MOISTURE CONTENT."
568 canopy_mc_input_grid = esmf_fieldcreate(input_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 INPUT GRID SEAICE FRACTION."
575 seaice_fract_input_grid = esmf_fieldcreate(input_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__)) &
581 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE DEPTH."
582 seaice_depth_input_grid = esmf_fieldcreate(input_grid, &
583 typekind=esmf_typekind_r8, &
584 staggerloc=esmf_staggerloc_center, rc=rc)
585 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
588 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE SKIN TEMPERATURE."
589 seaice_skin_temp_input_grid = esmf_fieldcreate(input_grid, &
590 typekind=esmf_typekind_r8, &
591 staggerloc=esmf_staggerloc_center, rc=rc)
592 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
595 print*,
"- CALL FieldCreate FOR INPUT GRID SNOW DEPTH."
596 snow_depth_input_grid = esmf_fieldcreate(input_grid, &
597 typekind=esmf_typekind_r8, &
598 staggerloc=esmf_staggerloc_center, rc=rc)
599 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
602 print*,
"- CALL FieldCreate FOR INPUT GRID SNOW LIQUID EQUIVALENT."
603 snow_liq_equiv_input_grid = esmf_fieldcreate(input_grid, &
604 typekind=esmf_typekind_r8, &
605 staggerloc=esmf_staggerloc_center, rc=rc)
606 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
609 print*,
"- CALL FieldCreate FOR INPUT GRID T2M."
610 t2m_input_grid = esmf_fieldcreate(input_grid, &
611 typekind=esmf_typekind_r8, &
612 staggerloc=esmf_staggerloc_center, rc=rc)
613 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
616 print*,
"- CALL FieldCreate FOR INPUT GRID Q2M."
617 q2m_input_grid = esmf_fieldcreate(input_grid, &
618 typekind=esmf_typekind_r8, &
619 staggerloc=esmf_staggerloc_center, rc=rc)
620 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
623 print*,
"- CALL FieldCreate FOR INPUT GRID TPRCP."
624 tprcp_input_grid = esmf_fieldcreate(input_grid, &
625 typekind=esmf_typekind_r8, &
626 staggerloc=esmf_staggerloc_center, rc=rc)
627 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
630 print*,
"- CALL FieldCreate FOR INPUT GRID F10M."
631 f10m_input_grid = esmf_fieldcreate(input_grid, &
632 typekind=esmf_typekind_r8, &
633 staggerloc=esmf_staggerloc_center, rc=rc)
634 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
637 print*,
"- CALL FieldCreate FOR INPUT GRID USTAR."
638 ustar_input_grid = esmf_fieldcreate(input_grid, &
639 typekind=esmf_typekind_r8, &
640 staggerloc=esmf_staggerloc_center, rc=rc)
641 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
644 print*,
"- CALL FieldCreate FOR INPUT GRID FFMM."
645 ffmm_input_grid = esmf_fieldcreate(input_grid, &
646 typekind=esmf_typekind_r8, &
647 staggerloc=esmf_staggerloc_center, rc=rc)
648 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
651 print*,
"- CALL FieldCreate FOR INPUT GRID SRFLAG."
652 srflag_input_grid = esmf_fieldcreate(input_grid, &
653 typekind=esmf_typekind_r8, &
654 staggerloc=esmf_staggerloc_center, rc=rc)
655 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
658 print*,
"- CALL FieldCreate FOR INPUT SKIN TEMPERATURE."
659 skin_temp_input_grid = esmf_fieldcreate(input_grid, &
660 typekind=esmf_typekind_r8, &
661 staggerloc=esmf_staggerloc_center, rc=rc)
662 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
665 print*,
"- CALL FieldCreate FOR INPUT SOIL TYPE."
666 soil_type_input_grid = esmf_fieldcreate(input_grid, &
667 typekind=esmf_typekind_r8, &
668 staggerloc=esmf_staggerloc_center, rc=rc)
669 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
672 print*,
"- CALL FieldCreate FOR INPUT TERRAIN."
673 terrain_input_grid = esmf_fieldcreate(input_grid, &
674 typekind=esmf_typekind_r8, &
675 staggerloc=esmf_staggerloc_center, rc=rc)
676 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
679 print*,
"- CALL FieldCreate FOR INPUT SOIL TEMPERATURE."
680 soil_temp_input_grid = esmf_fieldcreate(input_grid, &
681 typekind=esmf_typekind_r8, &
682 staggerloc=esmf_staggerloc_center, &
683 ungriddedlbound=(/1/), &
684 ungriddedubound=(/lsoil_input/), rc=rc)
685 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
688 print*,
"- CALL FieldCreate FOR INPUT TOTAL SOIL MOISTURE."
689 soilm_tot_input_grid = esmf_fieldcreate(input_grid, &
690 typekind=esmf_typekind_r8, &
691 staggerloc=esmf_staggerloc_center, &
692 ungriddedlbound=(/1/), &
693 ungriddedubound=(/lsoil_input/), rc=rc)
694 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
697 print*,
"- CALL FieldCreate FOR INPUT LIQUID SOIL MOISTURE."
698 soilm_liq_input_grid = esmf_fieldcreate(input_grid, &
699 typekind=esmf_typekind_r8, &
700 staggerloc=esmf_staggerloc_center, &
701 ungriddedlbound=(/1/), &
702 ungriddedubound=(/lsoil_input/), rc=rc)
703 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
708 if (.not. vgfrc_from_climo)
then
709 print*,
"- CALL FieldCreate FOR INPUT VEGETATION GREENNESS."
710 veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
711 typekind=esmf_typekind_r8, &
712 staggerloc=esmf_staggerloc_center, rc=rc)
713 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
717 if (.not. minmax_vgfrc_from_climo)
then
718 print*,
"- CALL FieldCreate FOR INPUT MIN VEGETATION GREENNESS."
719 min_veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
720 typekind=esmf_typekind_r8, &
721 staggerloc=esmf_staggerloc_center, rc=rc)
722 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
725 print*,
"- CALL FieldCreate FOR INPUT MAX VEGETATION GREENNESS."
726 max_veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
727 typekind=esmf_typekind_r8, &
728 staggerloc=esmf_staggerloc_center, rc=rc)
729 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
733 if (.not. lai_from_climo)
then
734 print*,
"- CALL FieldCreate FOR INPUT LEAF AREA INDEX."
735 lai_input_grid = esmf_fieldcreate(input_grid, &
736 typekind=esmf_typekind_r8, &
737 staggerloc=esmf_staggerloc_center, rc=rc)
738 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
754 integer,
intent(in) :: localpet
756 character(len=300) :: the_file
758 integer(sigio_intkind) :: iret
759 integer :: rc, i, j, k
760 integer :: clb(3), cub(3)
762 real(esmf_kind_r8) :: ak, bk
763 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
764 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
765 real(esmf_kind_r8),
allocatable :: dummy3d2(:,:,:)
766 real(esmf_kind_r8),
pointer :: pptr(:,:,:), psptr(:,:)
767 real(esmf_kind_r8),
allocatable :: pi(:,:,:)
769 type(sigio_head
) :: sighead
770 type(sigio_dbta
) :: sigdata
772 the_file = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
774 print*,
"- ATMOSPHERIC DATA IN SIGIO FORMAT."
775 print*,
"- OPEN AND READ: ", trim(the_file)
777 call sigio_sropen(21, trim(the_file), iret)
782 call sigio_srhead(21, sighead, iret)
788 lev_input = sighead%levs
789 levp1_input = lev_input + 1
791 if (num_tracers_input /= sighead%ntrac)
then
795 if (sighead%idvt == 0 .or. sighead%idvt == 21)
then
796 if (trim(tracers_input(1)) /=
'spfh' .or. &
797 trim(tracers_input(2)) /=
'o3mr' .or. &
798 trim(tracers_input(3)) /=
'clwmr')
then
799 call
error_handler(
"TRACERS SELECTED DO NOT MATCH FILE CONTENTS.", 99)
802 print*,
'- UNRECOGNIZED IDVT: ', sighead%idvt
812 if (localpet == 0)
then
813 allocate(dummy2d(i_input,j_input))
814 allocate(dummy3d(i_input,j_input,lev_input))
815 allocate(dummy3d2(i_input,j_input,lev_input))
817 allocate(dummy2d(0,0))
818 allocate(dummy3d(0,0,0))
819 allocate(dummy3d2(0,0,0))
822 if (localpet == 0)
then
823 call sigio_aldbta(sighead, sigdata, iret)
828 call sigio_srdbta(21, sighead, sigdata, iret)
833 call sptez(0,sighead%jcap,4,i_input, j_input, sigdata%ps, dummy2d, 1)
834 dummy2d = exp(dummy2d) * 1000.0
835 print*,
'surface pres ',maxval(dummy2d),minval(dummy2d)
838 print*,
"- CALL FieldScatter FOR SURFACE PRESSURE."
839 call esmf_fieldscatter(ps_input_grid, dummy2d, rootpet=0, rc=rc)
840 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
843 if (localpet == 0)
then
844 call sptez(0,sighead%jcap,4,i_input, j_input, sigdata%hs, dummy2d, 1)
845 print*,
'terrain ',maxval(dummy2d),minval(dummy2d)
848 print*,
"- CALL FieldScatter FOR TERRAIN."
849 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
850 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
853 do k = 1, num_tracers_input
855 if (localpet == 0)
then
856 call sptezm(0,sighead%jcap,4,i_input, j_input, lev_input, sigdata%q(:,:,k), dummy3d, 1)
857 print*,trim(tracers_input(k)),maxval(dummy3d),minval(dummy3d)
860 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(k))
861 call esmf_fieldscatter(tracers_input_grid(k), dummy3d, rootpet=0, rc=rc)
862 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
867 if (localpet == 0)
then
868 call sptezm(0,sighead%jcap,4,i_input, j_input, lev_input, sigdata%t, dummy3d, 1)
869 print*,
'temp ',maxval(dummy3d),minval(dummy3d)
872 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
873 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
874 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
882 if (localpet == 0)
then
883 print*,
"- NO VERTICAL VELOCITY RECORD. SET TO ZERO."
887 print*,
"- CALL FieldScatter FOR INPUT DZDT."
888 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
889 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
892 if (localpet == 0)
then
893 call sptezmv(0, sighead%jcap, 4, i_input, j_input, lev_input, sigdata%d, sigdata%z, dummy3d, dummy3d2, 1)
894 print*,
'u ',maxval(dummy3d),minval(dummy3d)
895 print*,
'v ',maxval(dummy3d2),minval(dummy3d2)
898 print*,
"- CALL FieldScatter FOR INPUT U-WIND."
899 call esmf_fieldscatter(u_input_grid, dummy3d, rootpet=0, rc=rc)
900 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
903 print*,
"- CALL FieldScatter FOR INPUT V-WIND."
904 call esmf_fieldscatter(v_input_grid, dummy3d2, rootpet=0, rc=rc)
905 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
908 deallocate(dummy2d, dummy3d, dummy3d2)
910 if (localpet == 0) call sigio_axdbta(sigdata, iret)
912 call sigio_sclose(21, iret)
924 print*,
"- COMPUTE 3-D PRESSURE."
926 print*,
"- CALL FieldGet FOR 3-D PRES."
928 call esmf_fieldget(pres_input_grid, &
929 computationallbound=clb, &
930 computationalubound=cub, &
931 farrayptr=pptr, rc=rc)
932 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
935 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
937 call esmf_fieldget(ps_input_grid, &
938 farrayptr=psptr, rc=rc)
939 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
946 allocate(pi(clb(1):cub(1),clb(2):cub(2),1:levp1_input),stat=rc)
949 ak = sighead%vcoord(k,1)
950 bk = sighead%vcoord(k,2)
953 pi(i,j,k) = ak + bk*psptr(i,j)
958 if (localpet == 0)
then
959 print*,
'pres int ',psptr(clb(1),clb(2)),pi(clb(1),clb(2),:)
969 pptr(i,j,k) = (pi(i,j,k)+pi(i,j,k+1))/2.0_esmf_kind_r8
976 if (localpet == 0)
then
977 print*,
'pres ',psptr(clb(1),clb(2)),pptr(clb(1),clb(2),:)
991 integer,
intent(in) :: localpet
993 character(len=300) :: the_file
994 character(len=20) :: vlevtyp, vname
996 integer(nemsio_intkind) :: vlev, iret
997 integer :: i, j, k, n, rc
998 integer :: clb(3), cub(3)
1000 real(nemsio_realkind),
allocatable :: vcoord(:,:,:)
1001 real(nemsio_realkind),
allocatable :: dummy(:)
1002 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
1003 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
1004 real(esmf_kind_r8) :: ak, bk
1005 real(esmf_kind_r8),
allocatable :: pi(:,:,:)
1006 real(esmf_kind_r8),
pointer :: pptr(:,:,:), psptr(:,:)
1008 type(nemsio_gfile
) :: gfile
1010 the_file = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
1012 print*,
"- READ ATMOS DATA FROM SPECTRAL GFS NEMSIO FILE: ", trim(the_file)
1014 print*,
"- OPEN FILE."
1015 call nemsio_open(gfile, the_file,
"read", iret=iret)
1016 if (iret /= 0) call
error_handler(
"OPENING SPECTRAL GFS NEMSIO ATM FILE.", iret)
1018 print*,
"- READ NUMBER OF VERTICAL LEVELS."
1019 call nemsio_getfilehead(gfile, iret=iret, dimz=lev_input)
1020 if (iret /= 0) call
error_handler(
"READING NUMBER OF VERTICAL LEVLES.", iret)
1022 levp1_input = lev_input + 1
1024 allocate(vcoord(levp1_input,3,2))
1026 print*,
"- READ VERTICAL COORDINATE INFO."
1027 call nemsio_getfilehead(gfile, iret=iret, vcoord=vcoord)
1028 if (iret /= 0) call
error_handler(
"READING VERTICAL COORDINATE INFO.", iret)
1036 if (localpet == 0)
then
1037 allocate(dummy(i_input*j_input))
1038 allocate(dummy2d(i_input,j_input))
1039 allocate(dummy3d(i_input,j_input,lev_input))
1042 allocate(dummy2d(0,0))
1043 allocate(dummy3d(0,0,0))
1051 if (localpet == 0)
then
1052 print*,
"- READ TEMPERATURE."
1054 vlevtyp =
"mid layer"
1055 do vlev = 1, lev_input
1056 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1057 if (iret /= 0) call
error_handler(
"READING TEMPERATURE RECORD.", iret)
1058 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1063 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
1064 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
1065 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1068 do n = 1, num_tracers_input
1070 if (localpet == 0)
then
1071 print*,
"- READ ", trim(tracers_input(n))
1072 vname = trim(tracers_input(n))
1073 vlevtyp =
"mid layer"
1074 do vlev = 1, lev_input
1075 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1076 if (iret /= 0) call
error_handler(
"READING TRACER RECORD.", iret)
1078 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1082 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(n))
1083 call esmf_fieldscatter(tracers_input_grid(n), dummy3d, rootpet=0, rc=rc)
1084 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1089 if (localpet == 0)
then
1090 print*,
"- READ U-WINDS."
1092 vlevtyp =
"mid layer"
1093 do vlev = 1, lev_input
1094 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1095 if (iret /= 0) call
error_handler(
"READING U-WIND RECORD.", iret)
1097 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1101 print*,
"- CALL FieldScatter FOR INPUT U-WIND."
1102 call esmf_fieldscatter(u_input_grid, dummy3d, rootpet=0, rc=rc)
1103 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1106 if (localpet == 0)
then
1107 print*,
"- READ V-WINDS."
1109 vlevtyp =
"mid layer"
1110 do vlev = 1, lev_input
1111 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1112 if (iret /= 0) call
error_handler(
"READING V-WIND RECORD.", iret)
1114 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1118 print*,
"- CALL FieldScatter FOR INPUT V-WIND."
1119 call esmf_fieldscatter(v_input_grid, dummy3d, rootpet=0, rc=rc)
1120 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1128 if (localpet == 0)
then
1129 print*,
"- NO VERTICAL VELOCITY RECORD. SET TO ZERO."
1133 print*,
"- CALL FieldScatter FOR INPUT DZDT."
1134 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
1135 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1138 if (localpet == 0)
then
1139 print*,
"- READ HGT."
1143 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1144 if (iret /= 0) call
error_handler(
"READING HGT RECORD.", iret)
1146 dummy2d = reshape(dummy, (/i_input,j_input/))
1149 print*,
"- CALL FieldScatter FOR TERRAIN."
1150 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
1151 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1154 if (localpet == 0)
then
1155 print*,
"- READ PRES."
1159 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1160 if (iret /= 0) call
error_handler(
"READING PRES RECORD.", iret)
1162 dummy2d = reshape(dummy, (/i_input,j_input/))
1165 print*,
"- CALL FieldScatter FOR SURFACE PRESSURE."
1166 call esmf_fieldscatter(ps_input_grid, dummy2d, rootpet=0, rc=rc)
1167 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1170 call nemsio_close(gfile)
1172 deallocate(dummy, dummy2d, dummy3d)
1184 print*,
"- COMPUTE 3-D PRESSURE."
1186 print*,
"- CALL FieldGet FOR 3-D PRES."
1188 call esmf_fieldget(pres_input_grid, &
1189 computationallbound=clb, &
1190 computationalubound=cub, &
1191 farrayptr=pptr, rc=rc)
1192 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1195 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
1197 call esmf_fieldget(ps_input_grid, &
1198 farrayptr=psptr, rc=rc)
1199 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1206 allocate(pi(clb(1):cub(1),clb(2):cub(2),1:levp1_input))
1211 do i= clb(1), cub(1)
1212 do j= clb(2), cub(2)
1213 pi(i,j,k) = ak + bk*psptr(i,j)
1225 do i= clb(1), cub(1)
1226 do j= clb(2), cub(2)
1227 pptr(i,j,k) = (pi(i,j,k)+pi(i,j,k+1))/2.0
1244 integer,
intent(in) :: localpet
1246 character(len=300) :: the_file
1247 character(len=20) :: vlevtyp, vname
1249 integer :: i, j, k, n
1250 integer :: rc, clb(3), cub(3)
1251 integer(nemsio_intkind) :: vlev, iret
1253 real(nemsio_realkind),
allocatable :: vcoord(:,:,:)
1254 real(nemsio_realkind),
allocatable :: dummy(:)
1255 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
1256 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
1257 real(esmf_kind_r8),
pointer :: presptr(:,:,:), psptr(:,:)
1258 real(esmf_kind_r8),
pointer :: dpresptr(:,:,:)
1259 real(esmf_kind_r8),
allocatable :: pres_interface(:)
1261 type(nemsio_gfile
) :: gfile
1263 the_file = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
1265 print*,
"- READ ATMOS DATA FROM GAUSSIAN NEMSIO FILE: ", trim(the_file)
1267 print*,
"- OPEN FILE."
1268 call nemsio_open(gfile, the_file,
"read", iret=iret)
1269 if (iret /= 0) call
error_handler(
"OPENING GAUSSIAN NEMSIO ATM FILE.", iret)
1271 print*,
"- READ NUMBER OF VERTICAL LEVELS."
1272 call nemsio_getfilehead(gfile, iret=iret, dimz=lev_input)
1273 if (iret /= 0) call
error_handler(
"READING NUMBER OF VERTICAL LEVLES.", iret)
1275 levp1_input = lev_input + 1
1277 allocate(vcoord(levp1_input,3,2))
1279 print*,
"- READ VERTICAL COORDINATE INFO."
1280 call nemsio_getfilehead(gfile, iret=iret, vcoord=vcoord)
1281 if (iret /= 0) call
error_handler(
"READING VERTICAL COORDINATE INFO.", iret)
1289 print*,
"- CALL FieldCreate FOR INPUT DPRES."
1290 dpres_input_grid = esmf_fieldcreate(input_grid, &
1291 typekind=esmf_typekind_r8, &
1292 staggerloc=esmf_staggerloc_center, &
1293 ungriddedlbound=(/1/), &
1294 ungriddedubound=(/lev_input/), rc=rc)
1295 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1298 if (localpet == 0)
then
1299 allocate(dummy(i_input*j_input))
1300 allocate(dummy2d(i_input,j_input))
1301 allocate(dummy3d(i_input,j_input,lev_input))
1304 allocate(dummy2d(0,0))
1305 allocate(dummy3d(0,0,0))
1313 if (localpet == 0)
then
1314 print*,
"- READ TEMPERATURE."
1316 vlevtyp =
"mid layer"
1317 do vlev = 1, lev_input
1318 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1319 if (iret /= 0) call
error_handler(
"READING TEMPERATURE RECORD.", iret)
1320 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1321 print*,
'temp check after read ',vlev, dummy3d(1,1,vlev)
1325 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
1326 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
1327 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1330 do n = 1, num_tracers_input
1332 if (localpet == 0)
then
1333 print*,
"- READ ", trim(tracers_input(n))
1334 vname = trim(tracers_input(n))
1335 vlevtyp =
"mid layer"
1336 do vlev = 1, lev_input
1337 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1338 if (iret /= 0) call
error_handler(
"READING TRACER RECORD.", iret)
1339 print*,
'tracer ',vlev, maxval(dummy),minval(dummy)
1340 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1344 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(n))
1345 call esmf_fieldscatter(tracers_input_grid(n), dummy3d, rootpet=0, rc=rc)
1346 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1351 if (localpet == 0)
then
1352 print*,
"- READ U-WINDS."
1354 vlevtyp =
"mid layer"
1355 do vlev = 1, lev_input
1356 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1357 if (iret /= 0) call
error_handler(
"READING U-WIND RECORD.", iret)
1358 print*,
'ugrd ',vlev, maxval(dummy),minval(dummy)
1359 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1363 print*,
"- CALL FieldScatter FOR INPUT U-WIND."
1364 call esmf_fieldscatter(u_input_grid, dummy3d, rootpet=0, rc=rc)
1365 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1368 if (localpet == 0)
then
1369 print*,
"- READ V-WINDS."
1371 vlevtyp =
"mid layer"
1372 do vlev = 1, lev_input
1373 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1374 if (iret /= 0) call
error_handler(
"READING V-WIND RECORD.", iret)
1375 print*,
'vgrd ',vlev, maxval(dummy),minval(dummy)
1376 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1380 print*,
"- CALL FieldScatter FOR INPUT V-WIND."
1381 call esmf_fieldscatter(v_input_grid, dummy3d, rootpet=0, rc=rc)
1382 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1385 if (localpet == 0)
then
1386 print*,
"- READ DPRES."
1388 vlevtyp =
"mid layer"
1389 do vlev = 1, lev_input
1390 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1391 if (iret /= 0) call
error_handler(
"READING DPRES RECORD.", iret)
1392 print*,
'dpres ',vlev, maxval(dummy),minval(dummy)
1393 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1397 print*,
"- CALL FieldScatter FOR INPUT DPRES."
1398 call esmf_fieldscatter(dpres_input_grid, dummy3d, rootpet=0, rc=rc)
1399 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1402 if (localpet == 0)
then
1403 print*,
"- READ DZDT."
1405 vlevtyp =
"mid layer"
1406 do vlev = 1, lev_input
1407 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1408 if (iret /= 0) call
error_handler(
"READING DZDT RECORD.", iret)
1409 print*,
'dzdt ',vlev, maxval(dummy),minval(dummy)
1410 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1414 print*,
"- CALL FieldScatter FOR INPUT DZDT."
1415 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
1416 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1419 if (localpet == 0)
then
1420 print*,
"- READ HGT."
1424 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1425 if (iret /= 0) call
error_handler(
"READING HGT RECORD.", iret)
1426 print*,
'hgt ',vlev, maxval(dummy),minval(dummy)
1427 dummy2d = reshape(dummy, (/i_input,j_input/))
1430 print*,
"- CALL FieldScatter FOR TERRAIN."
1431 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
1432 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1435 call nemsio_close(gfile)
1437 deallocate(dummy, dummy2d, dummy3d)
1453 print*,
"- COMPUTE 3-D PRESSURE."
1455 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
1457 call esmf_fieldget(dpres_input_grid, &
1458 computationallbound=clb, &
1459 computationalubound=cub, &
1460 farrayptr=dpresptr, rc=rc)
1461 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1464 print*,
"- CALL FieldGet FOR 3-D PRESSURE."
1466 call esmf_fieldget(pres_input_grid, &
1467 farrayptr=presptr, rc=rc)
1468 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1471 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
1473 call esmf_fieldget(ps_input_grid, &
1474 farrayptr=psptr, rc=rc)
1475 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1478 allocate(pres_interface(levp1_input))
1480 if (localpet == 0)
then
1481 do k = clb(3), cub(3)
1482 print*,
'dpres is ',cub(1),cub(2),k, dpresptr(cub(1),cub(2),k)
1486 do i = clb(1), cub(1)
1487 do j = clb(2), cub(2)
1488 pres_interface(levp1_input) = vcoord(levp1_input,1,1)
1489 do k = lev_input, 1, -1
1490 pres_interface(k) = pres_interface(k+1) + dpresptr(i,j,k)
1492 psptr(i,j) = pres_interface(1)
1494 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
1501 if (localpet == 0)
then
1502 print*,
'psfc is ',clb(1),clb(2),psptr(clb(1),clb(2))
1503 print*,
'pres is ',clb(1),clb(2),presptr(clb(1),clb(2),:)
1506 print*,
'pres check 1',localpet,maxval(presptr(:,:,1)),minval(presptr(:,:,1))
1507 print*,
'pres check lev',localpet,maxval(presptr(:,:,lev_input)),minval(presptr(:,:,lev_input))
1509 deallocate(pres_interface)
1511 call esmf_fielddestroy(dpres_input_grid, rc=rc)
1527 integer,
intent(in) :: localpet
1529 character(len=500) :: tilefile
1532 integer :: clb(3), cub(3)
1533 integer :: rc, tile, ncid, id_var
1534 integer :: error, id_dim
1536 real(esmf_kind_r8),
allocatable :: ak(:)
1537 real(esmf_kind_r8),
pointer :: presptr(:,:,:), psptr(:,:)
1538 real(esmf_kind_r8),
pointer :: dpresptr(:,:,:)
1539 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
1540 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
1541 real(esmf_kind_r8),
allocatable :: pres_interface(:)
1547 tilefile = trim(data_dir_input_grid) //
"/" // trim(atm_core_files_input_grid(7))
1548 print*,
"- READ ATM VERTICAL LEVELS FROM: ", trim(tilefile)
1549 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1550 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1552 error=nf90_inq_dimid(ncid,
'xaxis_1', id_dim)
1553 call
netcdf_err(error,
'reading xaxis_1 id' )
1554 error=nf90_inquire_dimension(ncid,id_dim,len=levp1_input)
1555 call
netcdf_err(error,
'reading xaxis_1 value' )
1557 lev_input = levp1_input - 1
1559 allocate(ak(levp1_input))
1561 error=nf90_inq_varid(ncid,
'ak', id_var)
1563 error=nf90_get_var(ncid, id_var, ak)
1566 error = nf90_close(ncid)
1574 print*,
"- CALL FieldCreate FOR INPUT GRID DELTA PRESSURE."
1575 dpres_input_grid = esmf_fieldcreate(input_grid, &
1576 typekind=esmf_typekind_r8, &
1577 staggerloc=esmf_staggerloc_center, &
1578 ungriddedlbound=(/1/), &
1579 ungriddedubound=(/lev_input/), rc=rc)
1580 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1583 if (localpet < num_tiles_input_grid)
then
1584 allocate(data_one_tile_3d(i_input,j_input,lev_input))
1585 allocate(data_one_tile(i_input,j_input))
1587 allocate(data_one_tile_3d(0,0,0))
1588 allocate(data_one_tile(0,0))
1591 if (localpet < num_tiles_input_grid)
then
1593 tilefile= trim(data_dir_input_grid) //
"/" // trim(atm_core_files_input_grid(tile))
1594 print*,
"- READ ATMOSPHERIC CORE FILE: ", trim(tilefile)
1595 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1596 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1599 if (localpet < num_tiles_input_grid)
then
1600 error=nf90_inq_varid(ncid,
'phis', id_var)
1602 error=nf90_get_var(ncid, id_var, data_one_tile)
1604 data_one_tile = data_one_tile / 9.806_8
1607 do tile = 1, num_tiles_input_grid
1608 print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN for tile ",tile
1609 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=tile-1, tile=tile, rc=rc)
1610 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1614 if (localpet < num_tiles_input_grid)
then
1622 data_one_tile_3d = 0.0_8
1625 do tile = 1, num_tiles_input_grid
1626 print*,
"- CALL FieldScatter FOR INPUT GRID VERTICAL VELOCITY for tile ",tile
1627 call esmf_fieldscatter(dzdt_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1628 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1632 if (localpet < num_tiles_input_grid)
then
1633 error=nf90_inq_varid(ncid,
'T', id_var)
1635 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1637 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1640 do tile = 1, num_tiles_input_grid
1641 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
1642 call esmf_fieldscatter(temp_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1643 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1647 if (localpet < num_tiles_input_grid)
then
1648 error=nf90_inq_varid(ncid,
'delp', id_var)
1650 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1652 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1655 do tile = 1, num_tiles_input_grid
1656 print*,
"- CALL FieldScatter FOR INPUT DELTA PRESSURE."
1657 call esmf_fieldscatter(dpres_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1658 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1662 if (localpet < num_tiles_input_grid)
then
1663 error=nf90_inq_varid(ncid,
'ua', id_var)
1665 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1667 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1670 do tile = 1, num_tiles_input_grid
1671 print*,
"- CALL FieldScatter FOR INPUT GRID U."
1672 call esmf_fieldscatter(u_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1673 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1677 if (localpet < num_tiles_input_grid)
then
1678 error=nf90_inq_varid(ncid,
'va', id_var)
1680 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1682 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1685 do tile = 1, num_tiles_input_grid
1686 print*,
"- CALL FieldScatter FOR INPUT GRID V."
1687 call esmf_fieldscatter(v_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1688 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1692 if (localpet < num_tiles_input_grid) error = nf90_close(ncid)
1694 if (localpet < num_tiles_input_grid)
then
1696 tilefile= trim(data_dir_input_grid) //
"/" // trim(atm_tracer_files_input_grid(tile))
1697 print*,
"- READ ATMOSPHERIC TRACER FILE: ", trim(tilefile)
1698 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1699 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1702 do i = 1, num_tracers_input
1704 if (localpet < num_tiles_input_grid)
then
1705 error=nf90_inq_varid(ncid, tracers_input(i), id_var)
1707 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1709 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1712 do tile = 1, num_tiles_input_grid
1713 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(i))
1714 call esmf_fieldscatter(tracers_input_grid(i), data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1715 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1721 if (localpet < num_tiles_input_grid) error=nf90_close(ncid)
1733 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
1734 call esmf_fieldget(ps_input_grid, &
1735 farrayptr=psptr, rc=rc)
1736 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1739 print*,
"- CALL FieldGet FOR PRESSURE."
1740 call esmf_fieldget(pres_input_grid, &
1741 computationallbound=clb, &
1742 computationalubound=cub, &
1743 farrayptr=presptr, rc=rc)
1744 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1747 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
1748 call esmf_fieldget(dpres_input_grid, &
1749 farrayptr=dpresptr, rc=rc)
1750 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1753 allocate(pres_interface(levp1_input))
1755 do i = clb(1), cub(1)
1756 do j = clb(2), cub(2)
1757 pres_interface(levp1_input) = ak(1)
1758 do k = (levp1_input-1), 1, -1
1759 pres_interface(k) = pres_interface(k+1) + dpresptr(i,j,k)
1762 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
1764 psptr(i,j) = pres_interface(1)
1769 deallocate(pres_interface)
1771 call esmf_fielddestroy(dpres_input_grid, rc=rc)
1773 deallocate(data_one_tile_3d, data_one_tile)
1788 integer,
intent(in) :: localpet
1790 character(len=500) :: tilefile
1792 integer :: start(3), count(3), iscnt
1793 integer :: error, ncid, num_tracers_file
1794 integer :: id_dim, idim_input, jdim_input
1795 integer :: id_var, rc, nprocs, max_procs
1796 integer :: kdim, remainder, myrank, i, j, k, n
1797 integer :: clb(3), cub(3)
1798 integer,
allocatable :: kcount(:), startk(:), displ(:)
1799 integer,
allocatable :: ircnt(:)
1801 real(esmf_kind_r8),
allocatable :: phalf(:)
1802 real(esmf_kind_r8),
allocatable :: pres_interface(:)
1803 real(kind=4),
allocatable :: dummy3d(:,:,:)
1804 real(kind=4),
allocatable :: dummy3dall(:,:,:)
1805 real(esmf_kind_r8),
allocatable :: dummy3dflip(:,:,:)
1806 real(esmf_kind_r8),
allocatable :: dummy(:,:)
1807 real(esmf_kind_r8),
pointer :: presptr(:,:,:), dpresptr(:,:,:)
1808 real(esmf_kind_r8),
pointer :: psptr(:,:)
1810 print*,
"- READ INPUT ATMOS DATA FROM GAUSSIAN NETCDF FILE."
1812 tilefile = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
1813 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1814 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1816 error=nf90_inq_dimid(ncid,
'grid_xt', id_dim)
1817 call
netcdf_err(error,
'reading grid_xt id' )
1818 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
1819 call
netcdf_err(error,
'reading grid_xt value' )
1821 error=nf90_inq_dimid(ncid,
'grid_yt', id_dim)
1822 call
netcdf_err(error,
'reading grid_yt id' )
1823 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
1824 call
netcdf_err(error,
'reading grid_yt value' )
1826 if (idim_input /= i_input .or. jdim_input /= j_input)
then
1827 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 2)
1830 error=nf90_inq_dimid(ncid,
'pfull', id_dim)
1832 error=nf90_inquire_dimension(ncid,id_dim,len=lev_input)
1833 call
netcdf_err(error,
'reading pfull value' )
1835 error=nf90_inq_dimid(ncid,
'phalf', id_dim)
1837 error=nf90_inquire_dimension(ncid,id_dim,len=levp1_input)
1838 call
netcdf_err(error,
'reading phalf value' )
1839 allocate(phalf(levp1_input))
1840 error=nf90_inq_varid(ncid,
'phalf', id_var)
1841 call
netcdf_err(error,
'getting phalf varid' )
1842 error=nf90_get_var(ncid, id_var, phalf)
1843 call
netcdf_err(error,
'reading phalf varid' )
1845 error=nf90_get_att(ncid, nf90_global,
'ncnsto', num_tracers_file)
1846 call
netcdf_err(error,
'reading ntracer value' )
1848 call mpi_comm_size(mpi_comm_world, nprocs, error)
1849 print*,
'- Running with ', nprocs,
' processors'
1851 call mpi_comm_rank(mpi_comm_world, myrank, error)
1852 print*,
'- myrank/localpet is ',myrank,localpet
1855 if (nprocs > lev_input)
then
1856 max_procs = lev_input
1859 kdim = lev_input / max_procs
1860 remainder = lev_input - (max_procs*kdim)
1862 allocate(kcount(0:nprocs-1))
1864 allocate(startk(0:nprocs-1))
1866 allocate(displ(0:nprocs-1))
1868 allocate(ircnt(0:nprocs-1))
1871 do k = 0, max_procs-2
1874 kcount(max_procs-1) = kdim + remainder
1877 do k = 1, max_procs-1
1878 startk(k) = startk(k-1) + kcount(k-1)
1881 ircnt(:) = idim_input * jdim_input * kcount(:)
1884 do k = 1, max_procs-1
1885 displ(k) = displ(k-1) + ircnt(k-1)
1888 iscnt=idim_input*jdim_input*kcount(myrank)
1892 if (myrank <= max_procs-1)
then
1893 allocate(dummy3d(idim_input,jdim_input,kcount(myrank)))
1895 allocate(dummy3d(0,0,0))
1898 if (myrank == 0)
then
1899 allocate(dummy3dall(idim_input,jdim_input,lev_input))
1901 allocate(dummy3dflip(idim_input,jdim_input,lev_input))
1903 allocate(dummy(idim_input,jdim_input))
1906 allocate(dummy3dall(0,0,0))
1907 allocate(dummy3dflip(0,0,0))
1908 allocate(dummy(0,0))
1917 print*,
"- CALL FieldCreate FOR INPUT GRID DELTA PRESSURE."
1918 dpres_input_grid = esmf_fieldcreate(input_grid, &
1919 typekind=esmf_typekind_r8, &
1920 staggerloc=esmf_staggerloc_center, &
1921 ungriddedlbound=(/1/), &
1922 ungriddedubound=(/lev_input/), rc=rc)
1923 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1928 if (myrank <= max_procs-1)
then
1929 start = (/1,1,startk(myrank)/)
1930 count = (/idim_input,jdim_input,kcount(myrank)/)
1931 error=nf90_inq_varid(ncid,
'tmp', id_var)
1932 call
netcdf_err(error,
'reading tmp field id' )
1933 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
1937 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
1938 dummy3dall, ircnt, displ, mpi_real, &
1939 0, mpi_comm_world, error)
1940 if (error /= 0) call
error_handler(
"IN mpi_gatherv of temperature", error)
1942 if (myrank == 0)
then
1943 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
1946 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE "
1947 call esmf_fieldscatter(temp_input_grid, dummy3dflip, rootpet=0, rc=rc)
1948 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1953 if (myrank <= max_procs-1)
then
1954 error=nf90_inq_varid(ncid,
'dpres', id_var)
1955 call
netcdf_err(error,
'reading dpres field id' )
1956 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
1957 call
netcdf_err(error,
'reading dpres field' )
1960 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
1961 dummy3dall, ircnt, displ, mpi_real, &
1962 0, mpi_comm_world, error)
1963 if (error /= 0) call
error_handler(
"IN mpi_gatherv of dpres", error)
1965 if (myrank == 0)
then
1966 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
1969 print*,
"- CALL FieldScatter FOR INPUT GRID DPRES "
1970 call esmf_fieldscatter(dpres_input_grid, dummy3dflip, rootpet=0, rc=rc)
1971 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1976 if (myrank <= max_procs-1)
then
1977 error=nf90_inq_varid(ncid,
'ugrd', id_var)
1978 call
netcdf_err(error,
'reading ugrd field id' )
1979 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
1980 call
netcdf_err(error,
'reading ugrd field' )
1983 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
1984 dummy3dall, ircnt, displ, mpi_real, &
1985 0, mpi_comm_world, error)
1986 if (error /= 0) call
error_handler(
"IN mpi_gatherv of ugrd", error)
1988 if (myrank == 0)
then
1989 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
1992 print*,
"- CALL FieldScatter FOR INPUT GRID UGRD "
1993 call esmf_fieldscatter(u_input_grid, dummy3dflip, rootpet=0, rc=rc)
1994 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1999 if (myrank <= max_procs-1)
then
2000 error=nf90_inq_varid(ncid,
'vgrd', id_var)
2001 call
netcdf_err(error,
'reading vgrd field id' )
2002 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
2003 call
netcdf_err(error,
'reading vgrd field' )
2006 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
2007 dummy3dall, ircnt, displ, mpi_real, &
2008 0, mpi_comm_world, error)
2009 if (error /= 0) call
error_handler(
"IN mpi_gatherv of vgrd", error)
2011 if (myrank == 0)
then
2012 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
2015 print*,
"- CALL FieldScatter FOR INPUT GRID VGRD "
2016 call esmf_fieldscatter(v_input_grid, dummy3dflip, rootpet=0, rc=rc)
2017 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2022 do n = 1, num_tracers_input
2024 if (myrank <= max_procs-1)
then
2025 error=nf90_inq_varid(ncid, tracers_input(n), id_var)
2026 call
netcdf_err(error,
'reading tracer field id' )
2027 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
2028 call
netcdf_err(error,
'reading tracer field' )
2031 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
2032 dummy3dall, ircnt, displ, mpi_real, &
2033 0, mpi_comm_world, error)
2034 if (error /= 0) call
error_handler(
"IN mpi_gatherv of tracer", error)
2036 if (myrank == 0)
then
2037 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
2038 where(dummy3dflip < 0.0) dummy3dflip = 0.0
2041 print*,
"- CALL FieldScatter FOR INPUT GRID ", tracers_input(n)
2042 call esmf_fieldscatter(tracers_input_grid(n), dummy3dflip, rootpet=0, rc=rc)
2043 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2050 if (myrank == 0)
then
2054 print*,
"- CALL FieldScatter FOR INPUT GRID DZDT"
2055 call esmf_fieldscatter(dzdt_input_grid, dummy3dflip, rootpet=0, rc=rc)
2056 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2059 deallocate(dummy3dflip, dummy3dall, dummy3d)
2064 print*,
"- READ TERRAIN."
2065 error=nf90_inq_varid(ncid,
'hgtsfc', id_var)
2066 call
netcdf_err(error,
'reading hgtsfc field id' )
2067 error=nf90_get_var(ncid, id_var, dummy)
2068 call
netcdf_err(error,
'reading hgtsfc field' )
2071 print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN."
2072 call esmf_fieldscatter(terrain_input_grid, dummy, rootpet=0, rc=rc)
2073 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2079 print*,
"- READ SURFACE P."
2080 error=nf90_inq_varid(ncid,
'pressfc', id_var)
2081 call
netcdf_err(error,
'reading pressfc field id' )
2082 error=nf90_get_var(ncid, id_var, dummy)
2083 call
netcdf_err(error,
'reading pressfc field' )
2086 print*,
"- CALL FieldScatter FOR INPUT GRID SURFACE P."
2087 call esmf_fieldscatter(ps_input_grid, dummy, rootpet=0, rc=rc)
2088 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2091 deallocate(kcount, startk, displ, ircnt, dummy)
2103 print*,
"- CALL FieldGet FOR PRESSURE."
2104 call esmf_fieldget(pres_input_grid, &
2105 computationallbound=clb, &
2106 computationalubound=cub, &
2107 farrayptr=presptr, rc=rc)
2108 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2111 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
2112 call esmf_fieldget(dpres_input_grid, &
2113 farrayptr=dpresptr, rc=rc)
2114 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2117 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
2118 call esmf_fieldget(ps_input_grid, &
2119 farrayptr=psptr, rc=rc)
2120 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2123 allocate(pres_interface(levp1_input))
2138 do i = clb(1), cub(1)
2139 do j = clb(2), cub(2)
2140 pres_interface(levp1_input) = phalf(1) * 100.0_8
2141 do k = lev_input, 1, -1
2142 pres_interface(k) = pres_interface(k+1) + dpresptr(i,j,k)
2144 psptr(i,j) = pres_interface(1)
2146 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
2151 deallocate(pres_interface, phalf)
2153 call esmf_fielddestroy(dpres_input_grid, rc=rc)
2172 integer,
intent(in) :: localpet
2174 character(len=500) :: tilefile
2176 integer :: error, ncid, rc, tile
2177 integer :: id_dim, idim_input, jdim_input
2178 integer :: id_var, i, j, k, n
2179 integer :: clb(3), cub(3), num_tracers_file
2181 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
2182 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
2183 real(esmf_kind_r8),
pointer :: presptr(:,:,:), dpresptr(:,:,:)
2184 real(esmf_kind_r8),
pointer :: psptr(:,:)
2185 real(esmf_kind_r8),
allocatable :: pres_interface(:), phalf(:)
2187 print*,
"- READ INPUT ATMOS DATA FROM TILED HISTORY FILES."
2189 tilefile = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
2190 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
2191 call
netcdf_err(error,
'opening: '//trim(tilefile) )
2193 error=nf90_inq_dimid(ncid,
'grid_xt', id_dim)
2194 call
netcdf_err(error,
'reading grid_xt id' )
2195 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
2196 call
netcdf_err(error,
'reading grid_xt value' )
2198 error=nf90_inq_dimid(ncid,
'grid_yt', id_dim)
2199 call
netcdf_err(error,
'reading grid_yt id' )
2200 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
2201 call
netcdf_err(error,
'reading grid_yt value' )
2203 if (idim_input /= i_input .or. jdim_input /= j_input)
then
2204 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 2)
2207 error=nf90_inq_dimid(ncid,
'pfull', id_dim)
2209 error=nf90_inquire_dimension(ncid,id_dim,len=lev_input)
2210 call
netcdf_err(error,
'reading pfull value' )
2212 error=nf90_inq_dimid(ncid,
'phalf', id_dim)
2214 error=nf90_inquire_dimension(ncid,id_dim,len=levp1_input)
2215 call
netcdf_err(error,
'reading phalf value' )
2216 allocate(phalf(levp1_input))
2217 error=nf90_inq_varid(ncid,
'phalf', id_var)
2218 call
netcdf_err(error,
'getting phalf varid' )
2219 error=nf90_get_var(ncid, id_var, phalf)
2220 call
netcdf_err(error,
'reading phalf varid' )
2222 error=nf90_get_att(ncid, nf90_global,
'ncnsto', num_tracers_file)
2223 call
netcdf_err(error,
'reading ntracer value' )
2225 error = nf90_close(ncid)
2227 print*,
'- FILE HAS ', num_tracers_file,
' TRACERS.'
2228 print*,
'- WILL PROCESS ', num_tracers_input,
' TRACERS.'
2236 print*,
"- CALL FieldCreate FOR INPUT GRID DELTA PRESSURE."
2237 dpres_input_grid = esmf_fieldcreate(input_grid, &
2238 typekind=esmf_typekind_r8, &
2239 staggerloc=esmf_staggerloc_center, &
2240 ungriddedlbound=(/1/), &
2241 ungriddedubound=(/lev_input/), rc=rc)
2242 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2245 if (localpet < num_tiles_input_grid)
then
2246 allocate(data_one_tile(i_input,j_input))
2247 allocate(data_one_tile_3d(i_input,j_input,lev_input))
2249 allocate(data_one_tile(0,0))
2250 allocate(data_one_tile_3d(0,0,0))
2253 if (localpet < num_tiles_input_grid)
then
2255 tilefile= trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(tile))
2256 print*,
"- READ ATMOSPHERIC DATA FROM: ", trim(tilefile)
2257 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
2258 call
netcdf_err(error,
'opening: '//trim(tilefile) )
2261 if (localpet < num_tiles_input_grid)
then
2271 data_one_tile_3d = 0.0_8
2274 do tile = 1, num_tiles_input_grid
2275 print*,
"- CALL FieldScatter FOR INPUT GRID VERTICAL VELOCITY."
2276 call esmf_fieldscatter(dzdt_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2277 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2281 do n = 1, num_tracers_input
2283 if (localpet < num_tiles_input_grid)
then
2284 print*,
"- READ ", trim(tracers_input(n))
2285 error=nf90_inq_varid(ncid, tracers_input(n), id_var)
2287 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2289 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2292 do tile = 1, num_tiles_input_grid
2293 print*,
"- CALL FieldScatter FOR INPUT GRID TRACER ", trim(tracers_input(n))
2294 call esmf_fieldscatter(tracers_input_grid(n), data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2295 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2301 if (localpet < num_tiles_input_grid)
then
2302 print*,
"- READ TEMPERATURE."
2303 error=nf90_inq_varid(ncid,
'tmp', id_var)
2305 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2307 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2310 do tile = 1, num_tiles_input_grid
2311 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
2312 call esmf_fieldscatter(temp_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2313 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2317 if (localpet < num_tiles_input_grid)
then
2318 print*,
"- READ U-WIND."
2319 error=nf90_inq_varid(ncid,
'ugrd', id_var)
2321 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2323 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2326 do tile = 1, num_tiles_input_grid
2327 print*,
"- CALL FieldScatter FOR INPUT GRID U."
2328 call esmf_fieldscatter(u_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2329 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2333 if (localpet < num_tiles_input_grid)
then
2334 print*,
"- READ V-WIND."
2335 error=nf90_inq_varid(ncid,
'vgrd', id_var)
2337 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2339 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2342 do tile = 1, num_tiles_input_grid
2343 print*,
"- CALL FieldScatter FOR INPUT GRID V."
2344 call esmf_fieldscatter(v_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2345 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2349 if (localpet < num_tiles_input_grid)
then
2350 print*,
"- READ SURFACE PRESSURE."
2351 error=nf90_inq_varid(ncid,
'pressfc', id_var)
2353 error=nf90_get_var(ncid, id_var, data_one_tile)
2357 do tile = 1, num_tiles_input_grid
2358 print*,
"- CALL FieldScatter FOR INPUT GRID SURFACE PRESSURE."
2359 call esmf_fieldscatter(ps_input_grid, data_one_tile, rootpet=tile-1, tile=tile, rc=rc)
2360 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2364 if (localpet < num_tiles_input_grid)
then
2365 print*,
"- READ TERRAIN."
2366 error=nf90_inq_varid(ncid,
'hgtsfc', id_var)
2368 error=nf90_get_var(ncid, id_var, data_one_tile)
2372 do tile = 1, num_tiles_input_grid
2373 print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN."
2374 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=tile-1, tile=tile, rc=rc)
2375 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2379 if (localpet < num_tiles_input_grid)
then
2380 print*,
"- READ DELTA PRESSURE."
2381 error=nf90_inq_varid(ncid,
'dpres', id_var)
2383 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2385 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2388 do tile = 1, num_tiles_input_grid
2389 print*,
"- CALL FieldScatter FOR INPUT DELTA PRESSURE."
2390 call esmf_fieldscatter(dpres_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2391 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2395 if (localpet < num_tiles_input_grid) error = nf90_close(ncid)
2397 deallocate(data_one_tile_3d, data_one_tile)
2409 print*,
"- CALL FieldGet FOR PRESSURE."
2410 call esmf_fieldget(pres_input_grid, &
2411 computationallbound=clb, &
2412 computationalubound=cub, &
2413 farrayptr=presptr, rc=rc)
2414 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2417 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
2418 call esmf_fieldget(dpres_input_grid, &
2419 farrayptr=dpresptr, rc=rc)
2420 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2423 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
2424 call esmf_fieldget(ps_input_grid, &
2425 farrayptr=psptr, rc=rc)
2426 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2429 allocate(pres_interface(levp1_input))
2435 do i = clb(1), cub(1)
2436 do j = clb(2), cub(2)
2437 pres_interface(1) = psptr(i,j)
2438 do k = 2, levp1_input
2439 pres_interface(k) = pres_interface(k-1) - dpresptr(i,j,k-1)
2442 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
2447 deallocate(pres_interface, phalf)
2449 call esmf_fielddestroy(dpres_input_grid, rc=rc)
2465 integer,
intent(in) :: localpet
2467 integer,
parameter :: ntrac_max=14
2469 character(len=300) :: the_file
2470 character(len=20) :: vlevtyp, vname, lvl_str,lvl_str_space, &
2471 trac_names_grib_1(ntrac_max), &
2472 trac_names_grib_2(ntrac_max), &
2473 trac_names_vmap(ntrac_max), &
2474 tracers_input_grib_1(num_tracers_input), &
2475 tracers_input_grib_2(num_tracers_input), &
2477 method, tracers_input_vmap(num_tracers_input), &
2478 tracers_default(ntrac_max), vname2
2479 character (len=500) :: metadata
2481 integer :: i, j, k, n, lvl_str_space_len
2482 integer :: rc, clb(3), cub(3)
2483 integer :: vlev, iret,varnum
2488 logical :: conv_omega=.false., &
2492 real(esmf_kind_r8),
allocatable :: rlevs(:)
2493 real(esmf_kind_r4),
allocatable :: dummy2d(:,:)
2494 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:), dummy2d_8(:,:),&
2495 u_tmp_3d(:,:,:), v_tmp_3d(:,:,:)
2496 real(esmf_kind_r8),
pointer :: presptr(:,:,:), psptr(:,:),tptr(:,:,:), &
2497 qptr(:,:,:), wptr(:,:,:), &
2498 uptr(:,:,:), vptr(:,:,:)
2499 real(esmf_kind_r4) :: value
2500 real(esmf_kind_r8),
parameter :: p0 = 100000.0
2506 trac_names_grib_1 = (/
":var0_2",
":var0_2",
":var0_2",
":var0_2",
":var0_2",
":var0_2", \
2507 ":var0_2",
":var0_2",
":var0_2",
":var0_2",
":var0_2",
":var0_2", \
2508 ":var0_2",
":var0_2"/)
2509 trac_names_grib_2 = (/
"_1_0: ",
"_1_22: ",
"_14_192:",
"_1_23: ",
"_1_24: ",
"_1_25: ", \
2510 "_1_32: ",
"_6_1: ",
"_6_29: ",
"_1_100: ",
"_6_28: ",
"_13_193:", \
2511 "_13_192:",
"_2_2: "/)
2512 trac_names_vmap = (/
"sphum ",
"liq_wat ",
"o3mr ",
"ice_wat ", &
2513 "rainwat ",
"snowwat ",
"graupel ",
"cld_amt ",
"ice_nc ", &
2514 "rain_nc ",
"water_nc",
"liq_aero",
"ice_aero", &
2516 tracers_default = (/
"sphum ",
"liq_wat ",
"o3mr ",
"ice_wat ", &
2517 "rainwat ",
"snowwat ",
"graupel ",
"cld_amt ",
"ice_nc ", &
2518 "rain_nc ",
"water_nc",
"liq_aero",
"ice_aero", &
2521 the_file = trim(data_dir_input_grid) //
"/" // trim(grib2_file_input_grid)
2523 print*,
"- READ ATMOS DATA FROM GRIB2 FILE: ", trim(the_file)
2524 print*,
"- USE INVENTORY FILE ", inv_file
2526 print*,
"- OPEN FILE."
2527 inquire(file=the_file,exist=lret)
2528 if (.not.lret) call
error_handler(
"OPENING GRIB2 ATM FILE.", iret)
2530 print*,
"- READ VERTICAL COORDINATE."
2531 iret = grb2_inq(the_file,inv_file,
":var0_2",
"_0_0:",
":10 hybrid level:")
2535 lvl_str_space =
" mb:"
2536 lvl_str_space_len = 4
2538 iret = grb2_inq(the_file,inv_file,
":UGRD:",lvl_str_space)
2540 if (localpet == 0) print*,
"- DATA IS ON ", lev_input,
" ISOBARIC LEVELS."
2543 lvl_str_space =
" hybrid "
2544 lvl_str_space_len = 7
2546 iret = grb2_inq(the_file,inv_file,
":UGRD:",lvl_str_space,
" level:")
2547 if (iret < 0) call
error_handler(
"READING VERTICAL LEVEL TYPE.", iret)
2551 allocate(slevs(lev_input))
2552 allocate(rlevs(lev_input))
2553 levp1_input = lev_input + 1
2558 iret=grb2_inq(the_file,inv_file,
':UGRD:',trim(lvl_str),sequential=i-1,desc=metadata)
2559 if (iret.ne.1) call
error_handler(
" IN SEQUENTIAL FILE READ.", iret)
2561 j = index(metadata,
':UGRD:') + len(
':UGRD:')
2562 k = index(metadata,trim(lvl_str_space)) + len(trim(lvl_str_space))-1
2564 read(metadata(j:k),*) rlevs(i)
2566 slevs(i) = metadata(j-1:k)
2567 if (.not. isnative) rlevs(i) = rlevs(i) * 100.0
2568 if (localpet==0) print*,
"- LEVEL = ", slevs(i)
2575 if (.not. isnative)
then
2577 write(slevs(i),
"(F20.10)") rlevs(i)/100.0
2578 len_str = len_trim(slevs(i))
2580 do while (slevs(i)(len_str:len_str) .eq.
'0')
2581 slevs(i) = slevs(i)(:len_str-1)
2582 len_str = len_str - 1
2585 if (slevs(i)(len_str:len_str) .eq.
'.')
then
2586 slevs(i) = slevs(i)(:len_str-1)
2587 len_str = len_str - 1
2590 slevs(i) = trim(slevs(i))
2592 slevs(i) =
":"//trim(adjustl(slevs(i)))//
" mb:"
2593 if (localpet==0) print*,
"- LEVEL AFTER SORT = ",slevs(i)
2597 if (localpet == 0) print*,
"- FIND SPFH OR RH IN FILE"
2598 iret = grb2_inq(the_file,inv_file,trim(trac_names_grib_1(1)),trac_names_grib_2(1),lvl_str_space)
2601 iret = grb2_inq(the_file,inv_file,
':var0_2',
'_1_1:',lvl_str_space)
2602 if (iret <= 0) call
error_handler(
"READING ATMOSPHERIC WATER VAPOR VARIABLE.", iret)
2604 trac_names_grib_2(1)=
'_1_1:'
2605 if (localpet == 0) print*,
"- FILE CONTAINS RH."
2607 if (localpet == 0) print*,
"- FILE CONTAINS SPFH."
2610 if (localpet == 0) print*,
"- FIND ICMR, SCLIWC, OR CICE IN FILE"
2611 iret = grb2_inq(the_file,inv_file,trac_names_grib_1(4),trac_names_grib_2(4),lvl_str_space)
2614 vname = trac_names_vmap(4)
2615 print*,
"vname = ", vname
2616 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
2617 this_field_var_name=tmpstr,loc=varnum)
2618 iret = grb2_inq(the_file,inv_file,
':var0_2',
'_1_84:',lvl_str_space)
2620 iret = grb2_inq(the_file,inv_file,
':var0_2',
'_6_0:',lvl_str_space)
2621 if (iret <= 0 )
then
2624 trac_names_grib_2(4) =
'_6_0'
2625 if (localpet == 0) print*,
"- FILE CONTAINS CICE."
2628 trac_names_grib_2(4)=
'_1_84:'
2629 if (localpet == 0) print*,
"- FILE CONTAINS SCLIWC."
2632 if (localpet == 0) print*,
"- FILE CONTAINS ICMR."
2635 if (localpet == 0) print*,
"- FIND CLWMR or SCLLWC IN FILE"
2636 iret = grb2_inq(the_file,inv_file,trac_names_grib_1(5),trac_names_grib_2(5),lvl_str_space)
2639 vname = trac_names_vmap(5)
2640 print*,
"vname = ", vname
2641 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
2642 this_field_var_name=tmpstr,loc=varnum)
2643 iret = grb2_inq(the_file,inv_file,
':var0_2',
'_1_83:',lvl_str_space)
2646 elseif (iret <=0 .and. rc .ne. 1)
then
2649 trac_names_grib_2(4)=
'_1_83:'
2650 if (localpet == 0) print*,
"- FILE CONTAINS SCLLWC."
2653 if (localpet == 0) print*,
"- FILE CONTAINS CLWMR."
2656 print*,
"- COUNT NUMBER OF TRACERS TO BE READ IN BASED ON PHYSICS SUITE TABLE"
2657 do n = 1, num_tracers_input
2659 vname = tracers_input(n)
2661 i = maxloc(merge(1.,0.,trac_names_vmap == vname),dim=1)
2663 tracers_input_grib_1(n) = trac_names_grib_1(i)
2664 tracers_input_grib_2(n) = trac_names_grib_2(i)
2665 tracers_input_vmap(n)=trac_names_vmap(i)
2666 tracers(n)=tracers_default(i)
2670 if (localpet==0)
then
2671 print*,
"- NUMBER OF TRACERS IN THE INPUT FILE = ", num_tracers_input
2680 if (localpet == 0)
then
2681 allocate(dummy2d(i_input,j_input))
2682 allocate(dummy2d_8(i_input,j_input))
2683 allocate(dummy3d(i_input,j_input,lev_input))
2685 allocate(dummy2d(0,0))
2686 allocate(dummy2d_8(0,0))
2687 allocate(dummy3d(0,0,0))
2696 if (localpet == 0)
then
2697 print*,
"- READ TEMPERATURE."
2699 do vlev = 1, lev_input
2700 iret = grb2_inq(the_file,inv_file,vname,slevs(vlev),data2=dummy2d)
2702 call
error_handler(
"READING IN TEMPERATURE AT LEVEL "//trim(slevs(vlev)),iret)
2704 dummy3d(:,:,vlev) =
real(dummy2d,esmf_kind_r8)
2705 print*,
'temp check after read ',vlev, dummy3d(1,1,vlev)
2709 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
2710 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
2711 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2714 do n = 1, num_tracers_input
2716 if (localpet == 0) print*,
"- READ ", trim(tracers_input_vmap(n))
2717 vname = tracers_input_vmap(n)
2718 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
2719 this_field_var_name=tmpstr,loc=varnum)
2720 if (n==1 .and. .not. hasspfh)
then
2721 print*,
"- CALL FieldGather TEMPERATURE."
2722 call esmf_fieldgather(temp_input_grid,dummy3d,rootpet=0, tile=1, rc=rc)
2723 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2727 if (localpet == 0)
then
2728 vname = trim(tracers_input_grib_1(n))
2729 vname2 = trim(tracers_input_grib_2(n))
2731 do vlev = 1, lev_input
2732 iret = grb2_inq(the_file,inv_file,vname,slevs(vlev),vname2,data2=dummy2d)
2737 if (trim(vname2)==
"_1_0:" .or. trim(vname2) ==
"_1_1:" .or. &
2738 trim(vname2) ==
":14:192:")
then
2739 call
error_handler(
"READING IN "//trim(vname)//
" AT LEVEL "//trim(slevs(vlev))&
2740 //
". SET A FILL VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",iret)
2745 if (n==1 .and. .not. hasspfh)
then
2746 call
rh2spfh(dummy2d,rlevs(vlev),dummy3d(:,:,vlev))
2749 print*,
'tracer ',vlev, maxval(dummy2d),minval(dummy2d)
2750 dummy3d(:,:,vlev) =
real(dummy2d,esmf_kind_r8)
2754 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input_vmap(n))
2755 call esmf_fieldscatter(tracers_input_grid(n), dummy3d, rootpet=0, rc=rc)
2756 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2761 call
read_winds(the_file,inv_file,u_tmp_3d,v_tmp_3d, localpet)
2763 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT U-WIND."
2764 call esmf_fieldscatter(u_input_grid, u_tmp_3d, rootpet=0, rc=rc)
2765 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2768 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT V-WIND."
2769 call esmf_fieldscatter(v_input_grid, v_tmp_3d, rootpet=0, rc=rc)
2770 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2773 if (localpet == 0)
then
2774 print*,
"- READ SURFACE PRESSURE."
2777 vlevtyp =
":surface:"
2778 iret = grb2_inq(the_file,inv_file,vname,vname2,vlevtyp,data2=dummy2d)
2779 if (iret <= 0) call
error_handler(
"READING SURFACE PRESSURE RECORD.", iret)
2780 dummy2d_8 =
real(dummy2d,esmf_kind_r8)
2783 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID SURFACE PRESSURE."
2784 call esmf_fieldscatter(ps_input_grid, dummy2d_8, rootpet=0, rc=rc)
2785 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2788 if (localpet == 0)
then
2789 print*,
"- READ DZDT."
2791 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
2795 do vlev = 1, lev_input
2796 iret = grb2_inq(the_file,inv_file,vname,vname2,slevs(vlev),data2=dummy2d)
2797 if (iret <= 0 )
then
2798 print*,
"DZDT not available at level ", trim(slevs(vlev)),
" so checking for VVEL"
2800 iret = grb2_inq(the_file,inv_file,vname,vname2,slevs(vlev),data2=dummy2d)
2811 print*,
'dzdt ',vlev, maxval(dummy2d),minval(dummy2d)
2812 dummy3d(:,:,vlev) = dummy2d
2816 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT DZDT."
2817 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
2818 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2821 if (localpet == 0)
then
2822 print*,
"- READ TERRAIN."
2825 vlevtyp =
":surface:"
2826 iret = grb2_inq(the_file,inv_file,vname,vname2,vlevtyp,data2=dummy2d)
2827 if (iret <= 0) call
error_handler(
"READING TERRAIN HEIGHT RECORD.", iret)
2828 dummy2d_8 =
real(dummy2d,esmf_kind_r8)
2831 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN."
2832 call esmf_fieldscatter(terrain_input_grid, dummy2d_8, rootpet=0, rc=rc)
2833 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2836 deallocate(dummy2d, dummy2d_8)
2838 if (.not. isnative)
then
2844 if (localpet == 0) print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
2846 call esmf_fieldget(ps_input_grid, &
2847 farrayptr=psptr, rc=rc)
2848 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2852 if (localpet == 0) print*,
"- CALL FieldGet FOR 3-D PRESSURE."
2853 call esmf_fieldget(pres_input_grid, &
2854 computationallbound=clb, &
2855 computationalubound=cub, &
2856 farrayptr=presptr, rc=rc)
2857 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2861 if (localpet == 0) print*,
"- CALL FieldGet TEMPERATURE."
2862 call esmf_fieldget(temp_input_grid, &
2863 farrayptr=tptr, rc=rc)
2864 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2868 if (localpet == 0) print*,
"- CALL FieldGet FOR U"
2869 call esmf_fieldget(u_input_grid, &
2870 farrayptr=uptr, rc=rc)
2871 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2875 if (localpet == 0) print*,
"- CALL FieldGet FOR V"
2876 call esmf_fieldget(v_input_grid, &
2877 farrayptr=vptr, rc=rc)
2878 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2882 if (localpet == 0) print*,
"- CALL FieldGet FOR W"
2883 call esmf_fieldget(dzdt_input_grid, &
2884 farrayptr=wptr, rc=rc)
2885 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2888 if (localpet == 0) print*,
"- CALL FieldGet FOR TRACERS."
2889 do n=1,num_tracers_input
2891 call esmf_fieldget(tracers_input_grid(n), &
2892 farrayptr=qptr, rc=rc)
2893 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2895 do i = clb(1),cub(1)
2896 do j = clb(2),cub(2)
2897 qptr(i,j,:) = qptr(i,j,lev_input:1:-1)
2902 do i = clb(1),cub(1)
2903 do j = clb(2),cub(2)
2904 presptr(i,j,:) = rlevs(lev_input:1:-1)
2905 tptr(i,j,:) = tptr(i,j,lev_input:1:-1)
2906 uptr(i,j,:) = uptr(i,j,lev_input:1:-1)
2907 vptr(i,j,:) = vptr(i,j,lev_input:1:-1)
2908 wptr(i,j,:) = wptr(i,j,lev_input:1:-1)
2912 if (localpet == 0)
then
2913 print*,
'psfc is ',clb(1),clb(2),psptr(clb(1),clb(2))
2914 print*,
'pres is ',cub(1),cub(2),presptr(cub(1),cub(2),:)
2916 print*,
'pres check 1',localpet,maxval(presptr(clb(1):cub(1),clb(2):cub(2),1)), &
2917 minval(presptr(clb(1):cub(1),clb(2):cub(2),1))
2918 print*,
'pres check lev',localpet,maxval(presptr(clb(1):cub(1),clb(2):cub(2), &
2919 lev_input)),minval(presptr(clb(1):cub(1),clb(2):cub(2),lev_input))
2924 if (localpet == 0)
then
2925 print*,
"- READ PRESSURE."
2927 do vlev = 1, lev_input
2928 iret = grb2_inq(the_file,inv_file,vname,slevs(vlev),data2=dummy2d)
2930 call
error_handler(
"READING IN PRESSURE AT LEVEL "//trim(slevs(vlev)),iret)
2932 dummy3d(:,:,vlev) =
real(dummy2d,esmf_kind_r8)
2933 print*,
'pres check after read ',vlev, dummy3d(1,1,vlev)
2937 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID PRESSURE."
2938 call esmf_fieldscatter(pres_input_grid, dummy3d, rootpet=0, rc=rc)
2939 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2954 if (conv_omega)
then
2956 if (localpet == 0) print*,
"- CONVERT FROM OMEGA TO DZDT."
2959 if (localpet == 0) print*,
"- CALL FieldGet TEMPERATURE."
2960 call esmf_fieldget(temp_input_grid, &
2961 farrayptr=tptr, rc=rc)
2962 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2966 if (localpet == 0) print*,
"- CALL FieldGet SPECIFIC HUMIDITY."
2967 call esmf_fieldget(tracers_input_grid(1), &
2968 computationallbound=clb, &
2969 computationalubound=cub, &
2970 farrayptr=qptr, rc=rc)
2971 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2975 if (localpet == 0) print*,
"- CALL FieldGet DZDT."
2976 call esmf_fieldget(dzdt_input_grid, &
2977 computationallbound=clb, &
2978 computationalubound=cub, &
2979 farrayptr=wptr, rc=rc)
2980 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2984 call esmf_fieldget(pres_input_grid, &
2985 farrayptr=presptr, rc=rc)
2986 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3008 integer,
intent(in) :: localpet
3010 character(len=300) :: the_file
3012 integer(sfcio_intkind) :: iret
3015 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
3016 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
3018 type(sfcio_head
) :: sfchead
3019 type(sfcio_dbta
) :: sfcdata
3021 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
3023 print*,
"- READ SURFACE DATA IN SFCIO FORMAT."
3024 print*,
"- OPEN AND READ: ",trim(the_file)
3025 call sfcio_sropen(23, trim(the_file), iret)
3031 call sfcio_srhead(23, sfchead, iret)
3037 if (localpet == 0)
then
3038 call sfcio_aldbta(sfchead, sfcdata, iret)
3043 call sfcio_srdbta(23, sfchead, sfcdata, iret)
3048 allocate(dummy2d(i_input,j_input))
3049 allocate(dummy3d(i_input,j_input,lsoil_input))
3051 allocate(dummy2d(0,0))
3052 allocate(dummy3d(0,0,0))
3055 if (localpet == 0) dummy2d = sfcdata%slmsk
3057 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
3058 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
3059 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3062 if (localpet == 0) dummy2d = sfcdata%zorl
3064 print*,
"- CALL FieldScatter FOR INPUT Z0."
3065 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
3066 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3069 if (localpet == 0) dummy2d = nint(sfcdata%vtype)
3071 print*,
"- CALL FieldScatter FOR INPUT VEG TYPE."
3072 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
3073 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3077 veg_type_landice_input = 13
3079 if (localpet == 0) dummy2d = sfcdata%canopy
3081 print*,
"- CALL FieldScatter FOR INPUT CANOPY MC."
3082 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
3083 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3086 if (localpet == 0) dummy2d = sfcdata%fice
3088 print*,
"- CALL FieldScatter FOR INPUT ICE FRACTION."
3089 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
3090 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3093 if (localpet == 0) dummy2d = sfcdata%hice
3095 print*,
"- CALL FieldScatter FOR INPUT ICE DEPTH."
3096 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3097 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3100 if (localpet == 0) dummy2d = sfcdata%tisfc
3102 print*,
"- CALL FieldScatter FOR INPUT ICE SKIN TEMP."
3103 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3104 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3107 if (localpet == 0) dummy2d = sfcdata%snwdph
3109 print*,
"- CALL FieldScatter FOR INPUT SNOW DEPTH."
3110 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3111 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3114 if (localpet == 0) dummy2d = sfcdata%sheleg
3116 print*,
"- CALL FieldScatter FOR INPUT SNOW LIQUID EQUIV."
3117 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
3118 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3121 if (localpet == 0) dummy2d = sfcdata%t2m
3123 print*,
"- CALL FieldScatter FOR INPUT T2M."
3124 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
3125 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3128 if (localpet == 0) dummy2d = sfcdata%q2m
3130 print*,
"- CALL FieldScatter FOR INPUT Q2M."
3131 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
3132 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3135 if (localpet == 0) dummy2d = sfcdata%tprcp
3137 print*,
"- CALL FieldScatter FOR INPUT TPRCP."
3138 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
3139 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3142 if (localpet == 0) dummy2d = sfcdata%f10m
3144 print*,
"- CALL FieldScatter FOR INPUT F10M."
3145 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
3146 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3149 if (localpet == 0) dummy2d = sfcdata%uustar
3151 print*,
"- CALL FieldScatter FOR INPUT USTAR."
3152 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
3153 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3156 if (localpet == 0) dummy2d = sfcdata%ffmm
3158 print*,
"- CALL FieldScatter FOR INPUT FFMM."
3159 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
3160 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3163 if (localpet == 0) dummy2d = sfcdata%srflag
3165 print*,
"- CALL FieldScatter FOR INPUT SRFLAG."
3166 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
3167 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3170 if (localpet == 0) dummy2d = sfcdata%tsea
3172 print*,
"- CALL FieldScatter FOR INPUT SKIN TEMP."
3173 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3174 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3177 if (localpet == 0) dummy2d = nint(sfcdata%stype)
3179 print*,
"- CALL FieldScatter FOR INPUT SOIL TYPE."
3180 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
3181 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3184 if (localpet == 0) dummy2d = sfcdata%orog
3186 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
3187 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
3188 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3191 if (localpet == 0) dummy3d = sfcdata%slc
3193 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
3194 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
3195 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3198 if (localpet == 0) dummy3d = sfcdata%smc
3200 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
3201 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
3202 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3205 if (localpet == 0) dummy3d = sfcdata%stc
3207 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
3208 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
3209 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3212 deallocate(dummy2d, dummy3d)
3213 call sfcio_axdbta(sfcdata, iret)
3215 call sfcio_sclose(23, iret)
3230 integer,
intent(in) :: localpet
3232 character(len=300) :: the_file
3236 real(nemsio_realkind),
allocatable :: dummy(:)
3237 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
3238 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
3240 type(nemsio_gfile
) :: gfile
3242 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
3244 if (localpet == 0)
then
3245 allocate(dummy3d(i_input,j_input,lsoil_input))
3246 allocate(dummy2d(i_input,j_input))
3247 allocate(dummy(i_input*j_input))
3248 print*,
"- OPEN FILE ", trim(the_file)
3249 call nemsio_open(gfile, the_file,
"read", iret=rc)
3252 allocate(dummy3d(0,0,0))
3253 allocate(dummy2d(0,0))
3257 if (localpet == 0)
then
3258 print*,
"- READ TERRAIN."
3259 call nemsio_readrecv(gfile,
"orog",
"sfc", 1, dummy, 0, iret=rc)
3261 dummy2d = reshape(dummy, (/i_input,j_input/))
3262 print*,
'orog ',maxval(dummy2d),minval(dummy2d)
3265 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
3266 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
3267 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3270 if (localpet == 0)
then
3271 print*,
"- READ LANDSEA MASK."
3272 call nemsio_readrecv(gfile,
"land",
"sfc", 1, dummy, 0, iret=rc)
3273 if (rc /= 0) call
error_handler(
"READING LANDSEA MASK.", rc)
3274 dummy2d = reshape(dummy, (/i_input,j_input/))
3275 print*,
'landmask ',maxval(dummy2d),minval(dummy2d)
3278 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
3279 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
3280 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3283 if (localpet == 0)
then
3284 print*,
"- READ SEAICE FRACTION."
3285 call nemsio_readrecv(gfile,
"icec",
"sfc", 1, dummy, 0, iret=rc)
3286 if (rc /= 0) call
error_handler(
"READING SEAICE FRACTION.", rc)
3287 dummy2d = reshape(dummy, (/i_input,j_input/))
3288 print*,
'icec ',maxval(dummy2d),minval(dummy2d)
3291 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
3292 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
3293 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3296 if (localpet == 0)
then
3297 print*,
"- READ SEAICE DEPTH."
3298 call nemsio_readrecv(gfile,
"icetk",
"sfc", 1, dummy, 0, iret=rc)
3299 if (rc /= 0) call
error_handler(
"READING SEAICE DEPTH.", rc)
3300 dummy2d = reshape(dummy, (/i_input,j_input/))
3301 print*,
'icetk ',maxval(dummy2d),minval(dummy2d)
3304 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
3305 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3306 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3309 if (localpet == 0)
then
3310 print*,
"- READ SEAICE SKIN TEMPERATURE."
3311 call nemsio_readrecv(gfile,
"tisfc",
"sfc", 1, dummy, 0, iret=rc)
3312 if (rc /= 0) call
error_handler(
"READING SEAICE SKIN TEMP.", rc)
3313 dummy2d = reshape(dummy, (/i_input,j_input/))
3314 print*,
'ti ',maxval(dummy2d),minval(dummy2d)
3317 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
3318 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3319 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3322 if (localpet == 0)
then
3323 print*,
"- READ SNOW LIQUID EQUIVALENT."
3324 call nemsio_readrecv(gfile,
"weasd",
"sfc", 1, dummy, 0, iret=rc)
3325 if (rc /= 0) call
error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
3326 dummy2d = reshape(dummy, (/i_input,j_input/))
3327 print*,
'weasd ',maxval(dummy2d),minval(dummy2d)
3330 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
3331 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
3332 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3335 if (localpet == 0)
then
3336 print*,
"- READ SNOW DEPTH."
3337 call nemsio_readrecv(gfile,
"snod",
"sfc", 1, dummy, 0, iret=rc)
3339 dummy2d = reshape(dummy, (/i_input,j_input/))
3340 print*,
'snod ',maxval(dummy2d),minval(dummy2d)
3343 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
3344 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3345 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3348 if (localpet == 0)
then
3349 print*,
"- READ VEG TYPE."
3350 call nemsio_readrecv(gfile,
"vtype",
"sfc", 1, dummy, 0, iret=rc)
3352 dummy2d = reshape(dummy, (/i_input,j_input/))
3353 print*,
'vtype ',maxval(dummy2d),minval(dummy2d)
3356 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
3357 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
3358 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3361 if (localpet == 0)
then
3362 print*,
"- READ SOIL TYPE."
3363 call nemsio_readrecv(gfile,
"sotyp",
"sfc", 1, dummy, 0, iret=rc)
3365 dummy2d = reshape(dummy, (/i_input,j_input/))
3366 print*,
'sotype ',maxval(dummy2d),minval(dummy2d)
3369 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
3370 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
3371 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3374 if (localpet == 0)
then
3375 print*,
"- READ T2M."
3376 call nemsio_readrecv(gfile,
"tmp",
"2 m above gnd", 1, dummy, 0, iret=rc)
3378 dummy2d = reshape(dummy, (/i_input,j_input/))
3379 print*,
't2m ',maxval(dummy2d),minval(dummy2d)
3382 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
3383 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
3384 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3387 if (localpet == 0)
then
3388 print*,
"- READ Q2M."
3389 call nemsio_readrecv(gfile,
"spfh",
"2 m above gnd", 1, dummy, 0, iret=rc)
3391 dummy2d = reshape(dummy, (/i_input,j_input/))
3392 print*,
'q2m ',maxval(dummy2d),minval(dummy2d)
3395 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
3396 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
3397 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3400 if (localpet == 0)
then
3401 print*,
"- READ TPRCP."
3402 call nemsio_readrecv(gfile,
"tprcp",
"sfc", 1, dummy, 0, iret=rc)
3404 dummy2d = reshape(dummy, (/i_input,j_input/))
3405 print*,
'tprcp ',maxval(dummy2d),minval(dummy2d)
3408 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
3409 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
3410 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3413 if (localpet == 0)
then
3414 print*,
"- READ FFMM."
3415 call nemsio_readrecv(gfile,
"ffmm",
"sfc", 1, dummy, 0, iret=rc)
3417 dummy2d = reshape(dummy, (/i_input,j_input/))
3418 print*,
'ffmm ',maxval(dummy2d),minval(dummy2d)
3421 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
3422 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
3423 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3426 if (localpet == 0)
then
3427 print*,
"- READ USTAR."
3428 call nemsio_readrecv(gfile,
"fricv",
"sfc", 1, dummy, 0, iret=rc)
3430 dummy2d = reshape(dummy, (/i_input,j_input/))
3431 print*,
'fricv ',maxval(dummy2d),minval(dummy2d)
3434 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
3435 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
3436 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3439 if (localpet == 0) dummy2d = 0.0
3440 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
3441 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
3442 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3445 if (localpet == 0)
then
3446 print*,
"- READ SKIN TEMPERATURE."
3447 call nemsio_readrecv(gfile,
"tmp",
"sfc", 1, dummy, 0, iret=rc)
3448 if (rc /= 0) call
error_handler(
"READING SKIN TEMPERATURE.", rc)
3449 dummy2d = reshape(dummy, (/i_input,j_input/))
3450 print*,
'tmp ',maxval(dummy2d),minval(dummy2d)
3453 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
3454 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3455 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3458 if (localpet == 0)
then
3459 print*,
"- READ F10M."
3460 call nemsio_readrecv(gfile,
"f10m",
"10 m above gnd", 1, dummy, 0, iret=rc)
3462 dummy2d = reshape(dummy, (/i_input,j_input/))
3463 print*,
'f10m ',maxval(dummy2d),minval(dummy2d)
3466 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
3467 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
3468 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3471 if (localpet == 0)
then
3472 print*,
"- READ CANOPY MOISTURE CONTENT."
3473 call nemsio_readrecv(gfile,
"cnwat",
"sfc", 1, dummy, 0, iret=rc)
3474 if (rc /= 0) call
error_handler(
"READING CANOPY MOISTURE CONTENT.", rc)
3475 dummy2d = reshape(dummy, (/i_input,j_input/))
3476 print*,
'cnwat ',maxval(dummy2d),minval(dummy2d)
3479 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
3480 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
3481 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3484 if (localpet == 0)
then
3486 call nemsio_readrecv(gfile,
"sfcr",
"sfc", 1, dummy, 0, iret=rc)
3488 dummy2d = reshape(dummy, (/i_input,j_input/))
3489 print*,
'sfcr ',maxval(dummy2d),minval(dummy2d)
3492 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
3493 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
3494 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3499 if (localpet == 0)
then
3500 print*,
"- READ LIQUID SOIL MOISTURE."
3501 call nemsio_readrecv(gfile,
"slc",
"soil layer", 1, dummy, 0, iret=rc)
3502 if (rc /= 0) call
error_handler(
"READING LAYER 1 LIQUID SOIL MOIST.", rc)
3503 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3504 call nemsio_readrecv(gfile,
"slc",
"soil layer", 2, dummy, 0, iret=rc)
3505 if (rc /= 0) call
error_handler(
"READING LAYER 2 LIQUID SOIL MOIST.", rc)
3506 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3507 call nemsio_readrecv(gfile,
"slc",
"soil layer", 3, dummy, 0, iret=rc)
3508 if (rc /= 0) call
error_handler(
"READING LAYER 3 LIQUID SOIL MOIST.", rc)
3509 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3510 call nemsio_readrecv(gfile,
"slc",
"soil layer", 4, dummy, 0, iret=rc)
3511 if (rc /= 0) call
error_handler(
"READING LAYER 4 LIQUID SOIL MOIST.", rc)
3512 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3513 print*,
'slc ',maxval(dummy3d),minval(dummy3d)
3516 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
3517 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
3518 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3521 if (localpet == 0)
then
3522 print*,
"- READ TOTAL SOIL MOISTURE."
3523 call nemsio_readrecv(gfile,
"smc",
"soil layer", 1, dummy, 0, iret=rc)
3524 if (rc /= 0) call
error_handler(
"READING LAYER 1 TOTAL SOIL MOIST.", rc)
3525 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3526 call nemsio_readrecv(gfile,
"smc",
"soil layer", 2, dummy, 0, iret=rc)
3527 if (rc /= 0) call
error_handler(
"READING LAYER 2 TOTAL SOIL MOIST.", rc)
3528 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3529 call nemsio_readrecv(gfile,
"smc",
"soil layer", 3, dummy, 0, iret=rc)
3530 if (rc /= 0) call
error_handler(
"READING LAYER 3 TOTAL SOIL MOIST.", rc)
3531 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3532 call nemsio_readrecv(gfile,
"smc",
"soil layer", 4, dummy, 0, iret=rc)
3533 if (rc /= 0) call
error_handler(
"READING LAYER 4 TOTAL SOIL MOIST.", rc)
3534 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3535 print*,
'smc ',maxval(dummy3d),minval(dummy3d)
3538 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
3539 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
3540 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3543 if (localpet == 0)
then
3544 print*,
"- READ SOIL TEMPERATURE."
3545 call nemsio_readrecv(gfile,
"stc",
"soil layer", 1, dummy, 0, iret=rc)
3546 if (rc /= 0) call
error_handler(
"READING LAYER 1 SOIL TEMP.", rc)
3547 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3548 call nemsio_readrecv(gfile,
"stc",
"soil layer", 2, dummy, 0, iret=rc)
3549 if (rc /= 0) call
error_handler(
"READING LAYER 2 SOIL TEMP.", rc)
3550 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3551 call nemsio_readrecv(gfile,
"stc",
"soil layer", 3, dummy, 0, iret=rc)
3552 if (rc /= 0) call
error_handler(
"READING LAYER 3 SOIL TEMP.", rc)
3553 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3554 call nemsio_readrecv(gfile,
"stc",
"soil layer", 4, dummy, 0, iret=rc)
3555 if (rc /= 0) call
error_handler(
"READING LAYER 4 SOIL TEMP.", rc)
3556 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3557 print*,
'stc ',maxval(dummy3d),minval(dummy3d)
3560 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
3561 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
3562 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3565 deallocate(dummy3d, dummy)
3567 if (localpet == 0) call nemsio_close(gfile)
3579 integer,
intent(in) :: localpet
3581 character(len=250) :: the_file
3585 real(nemsio_realkind),
allocatable :: dummy(:)
3586 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
3587 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
3589 type(nemsio_gfile
) :: gfile
3591 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
3593 if (localpet == 0)
then
3594 allocate(dummy3d(i_input,j_input,lsoil_input))
3595 allocate(dummy2d(i_input,j_input))
3596 allocate(dummy(i_input*j_input))
3597 print*,
"- OPEN FILE ", trim(the_file)
3598 call nemsio_open(gfile, the_file,
"read", iret=rc)
3601 allocate(dummy3d(0,0,0))
3602 allocate(dummy2d(0,0))
3606 if (localpet == 0)
then
3607 print*,
"- READ TERRAIN."
3608 call nemsio_readrecv(gfile,
"orog",
"sfc", 1, dummy, 0, iret=rc)
3610 dummy2d = reshape(dummy, (/i_input,j_input/))
3611 print*,
'orog ',maxval(dummy2d),minval(dummy2d)
3614 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
3615 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
3616 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3619 if (localpet == 0)
then
3620 print*,
"- READ LANDSEA MASK."
3621 call nemsio_readrecv(gfile,
"land",
"sfc", 1, dummy, 0, iret=rc)
3622 if (rc /= 0) call
error_handler(
"READING LANDSEA MASK.", rc)
3623 dummy2d = reshape(dummy, (/i_input,j_input/))
3624 print*,
'landmask ',maxval(dummy2d),minval(dummy2d)
3627 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
3628 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
3629 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3632 if (localpet == 0)
then
3633 print*,
"- READ SEAICE FRACTION."
3634 call nemsio_readrecv(gfile,
"icec",
"sfc", 1, dummy, 0, iret=rc)
3635 if (rc /= 0) call
error_handler(
"READING SEAICE FRACTION.", rc)
3636 dummy2d = reshape(dummy, (/i_input,j_input/))
3637 print*,
'icec ',maxval(dummy2d),minval(dummy2d)
3640 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
3641 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
3642 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3645 if (localpet == 0)
then
3646 print*,
"- READ SEAICE DEPTH."
3647 call nemsio_readrecv(gfile,
"icetk",
"sfc", 1, dummy, 0, iret=rc)
3648 if (rc /= 0) call
error_handler(
"READING SEAICE DEPTH.", rc)
3649 dummy2d = reshape(dummy, (/i_input,j_input/))
3650 print*,
'icetk ',maxval(dummy2d),minval(dummy2d)
3653 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
3654 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3655 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3658 if (localpet == 0)
then
3659 print*,
"- READ SEAICE SKIN TEMPERATURE."
3660 call nemsio_readrecv(gfile,
"ti",
"sfc", 1, dummy, 0, iret=rc)
3661 if (rc /= 0) call
error_handler(
"READING SEAICE SKIN TEMP.", rc)
3662 dummy2d = reshape(dummy, (/i_input,j_input/))
3663 print*,
'ti ',maxval(dummy2d),minval(dummy2d)
3666 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
3667 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3668 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3671 if (localpet == 0)
then
3672 print*,
"- READ SNOW LIQUID EQUIVALENT."
3673 call nemsio_readrecv(gfile,
"weasd",
"sfc", 1, dummy, 0, iret=rc)
3674 if (rc /= 0) call
error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
3675 dummy2d = reshape(dummy, (/i_input,j_input/))
3676 print*,
'weasd ',maxval(dummy2d),minval(dummy2d)
3679 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
3680 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
3681 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3684 if (localpet == 0)
then
3685 print*,
"- READ SNOW DEPTH."
3686 call nemsio_readrecv(gfile,
"snod",
"sfc", 1, dummy, 0, iret=rc)
3688 dummy2d = reshape(dummy, (/i_input,j_input/)) * 1000.0_8
3689 print*,
'snod ',maxval(dummy2d),minval(dummy2d)
3692 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
3693 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3694 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3697 if (localpet == 0)
then
3698 print*,
"- READ VEG TYPE."
3699 call nemsio_readrecv(gfile,
"vtype",
"sfc", 1, dummy, 0, iret=rc)
3701 dummy2d = reshape(dummy, (/i_input,j_input/))
3702 print*,
'vtype ',maxval(dummy2d),minval(dummy2d)
3705 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
3706 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
3707 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3710 if (localpet == 0)
then
3711 print*,
"- READ SOIL TYPE."
3712 call nemsio_readrecv(gfile,
"sotyp",
"sfc", 1, dummy, 0, iret=rc)
3714 dummy2d = reshape(dummy, (/i_input,j_input/))
3715 print*,
'sotype ',maxval(dummy2d),minval(dummy2d)
3718 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
3719 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
3720 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3723 if (localpet == 0)
then
3724 print*,
"- READ T2M."
3725 call nemsio_readrecv(gfile,
"tmp",
"2 m above gnd", 1, dummy, 0, iret=rc)
3727 dummy2d = reshape(dummy, (/i_input,j_input/))
3728 print*,
't2m ',maxval(dummy2d),minval(dummy2d)
3731 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
3732 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
3733 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3736 if (localpet == 0)
then
3737 print*,
"- READ Q2M."
3738 call nemsio_readrecv(gfile,
"spfh",
"2 m above gnd", 1, dummy, 0, iret=rc)
3740 dummy2d = reshape(dummy, (/i_input,j_input/))
3741 print*,
'q2m ',maxval(dummy2d),minval(dummy2d)
3744 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
3745 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
3746 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3749 if (localpet == 0)
then
3750 print*,
"- READ TPRCP."
3751 call nemsio_readrecv(gfile,
"tprcp",
"sfc", 1, dummy, 0, iret=rc)
3753 dummy2d = reshape(dummy, (/i_input,j_input/))
3754 print*,
'tprcp ',maxval(dummy2d),minval(dummy2d)
3757 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
3758 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
3759 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3762 if (localpet == 0)
then
3763 print*,
"- READ FFMM."
3764 call nemsio_readrecv(gfile,
"ffmm",
"sfc", 1, dummy, 0, iret=rc)
3766 dummy2d = reshape(dummy, (/i_input,j_input/))
3767 print*,
'ffmm ',maxval(dummy2d),minval(dummy2d)
3770 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
3771 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
3772 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3775 if (localpet == 0)
then
3776 print*,
"- READ USTAR."
3777 call nemsio_readrecv(gfile,
"fricv",
"sfc", 1, dummy, 0, iret=rc)
3779 dummy2d = reshape(dummy, (/i_input,j_input/))
3780 print*,
'fricv ',maxval(dummy2d),minval(dummy2d)
3783 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
3784 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
3785 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3788 if (localpet == 0) dummy2d = 0.0
3789 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
3790 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
3791 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3794 if (localpet == 0)
then
3795 print*,
"- READ SKIN TEMPERATURE."
3796 call nemsio_readrecv(gfile,
"tmp",
"sfc", 1, dummy, 0, iret=rc)
3797 if (rc /= 0) call
error_handler(
"READING SKIN TEMPERATURE.", rc)
3798 dummy2d = reshape(dummy, (/i_input,j_input/))
3799 print*,
'tmp ',maxval(dummy2d),minval(dummy2d)
3802 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
3803 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3804 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3807 if (localpet == 0)
then
3808 print*,
"- READ F10M."
3809 call nemsio_readrecv(gfile,
"f10m",
"10 m above gnd", 1, dummy, 0, iret=rc)
3811 dummy2d = reshape(dummy, (/i_input,j_input/))
3812 print*,
'f10m ',maxval(dummy2d),minval(dummy2d)
3815 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
3816 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
3817 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3820 if (localpet == 0)
then
3821 print*,
"- READ CANOPY MOISTURE CONTENT."
3822 call nemsio_readrecv(gfile,
"cnwat",
"sfc", 1, dummy, 0, iret=rc)
3823 if (rc /= 0) call
error_handler(
"READING CANOPY MOISTURE CONTENT.", rc)
3824 dummy2d = reshape(dummy, (/i_input,j_input/))
3825 print*,
'cnwat ',maxval(dummy2d),minval(dummy2d)
3828 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
3829 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
3830 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3833 if (localpet == 0)
then
3835 call nemsio_readrecv(gfile,
"sfcr",
"sfc", 1, dummy, 0, iret=rc)
3837 dummy2d = reshape(dummy, (/i_input,j_input/)) * 100.0_8
3838 print*,
'sfcr ',maxval(dummy2d),minval(dummy2d)
3841 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
3842 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
3843 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3848 if (localpet == 0)
then
3849 print*,
"- READ LIQUID SOIL MOISTURE."
3850 call nemsio_readrecv(gfile,
"soill",
"0-10 cm down", 1, dummy, 0, iret=rc)
3851 if (rc /= 0) call
error_handler(
"READING LAYER 1 LIQUID SOIL MOIST.", rc)
3852 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3853 call nemsio_readrecv(gfile,
"soill",
"10-40 cm down", 1, dummy, 0, iret=rc)
3854 if (rc /= 0) call
error_handler(
"READING LAYER 2 LIQUID SOIL MOIST.", rc)
3855 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3856 call nemsio_readrecv(gfile,
"soill",
"40-100 cm down", 1, dummy, 0, iret=rc)
3857 if (rc /= 0) call
error_handler(
"READING LAYER 3 LIQUID SOIL MOIST.", rc)
3858 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3859 call nemsio_readrecv(gfile,
"soill",
"100-200 cm down", 1, dummy, 0, iret=rc)
3860 if (rc /= 0) call
error_handler(
"READING LAYER 4 LIQUID SOIL MOIST.", rc)
3861 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3862 print*,
'soill ',maxval(dummy3d),minval(dummy3d)
3865 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
3866 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
3867 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3870 if (localpet == 0)
then
3871 print*,
"- READ TOTAL SOIL MOISTURE."
3872 call nemsio_readrecv(gfile,
"soilw",
"0-10 cm down", 1, dummy, 0, iret=rc)
3873 if (rc /= 0) call
error_handler(
"READING LAYER 1 TOTAL SOIL MOIST.", rc)
3874 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3875 call nemsio_readrecv(gfile,
"soilw",
"10-40 cm down", 1, dummy, 0, iret=rc)
3876 if (rc /= 0) call
error_handler(
"READING LAYER 2 TOTAL SOIL MOIST.", rc)
3877 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3878 call nemsio_readrecv(gfile,
"soilw",
"40-100 cm down", 1, dummy, 0, iret=rc)
3879 if (rc /= 0) call
error_handler(
"READING LAYER 3 TOTAL SOIL MOIST.", rc)
3880 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3881 call nemsio_readrecv(gfile,
"soilw",
"100-200 cm down", 1, dummy, 0, iret=rc)
3882 if (rc /= 0) call
error_handler(
"READING LAYER 4 TOTAL SOIL MOIST.", rc)
3883 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3884 print*,
'soilm ',maxval(dummy3d),minval(dummy3d)
3887 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
3888 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
3889 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3892 if (localpet == 0)
then
3893 print*,
"- READ SOIL TEMPERATURE."
3894 call nemsio_readrecv(gfile,
"tmp",
"0-10 cm down", 1, dummy, 0, iret=rc)
3895 if (rc /= 0) call
error_handler(
"READING LAYER 1 SOIL TEMP.", rc)
3896 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3897 call nemsio_readrecv(gfile,
"tmp",
"10-40 cm down", 1, dummy, 0, iret=rc)
3898 if (rc /= 0) call
error_handler(
"READING LAYER 2 SOIL TEMP.", rc)
3899 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3900 call nemsio_readrecv(gfile,
"tmp",
"40-100 cm down", 1, dummy, 0, iret=rc)
3901 if (rc /= 0) call
error_handler(
"READING LAYER 3 SOIL TEMP.", rc)
3902 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3903 call nemsio_readrecv(gfile,
"tmp",
"100-200 cm down", 1, dummy, 0, iret=rc)
3904 if (rc /= 0) call
error_handler(
"READING LAYER 4 SOIL TEMP.", rc)
3905 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3906 print*,
'soilt ',maxval(dummy3d),minval(dummy3d)
3909 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
3910 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
3911 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3914 deallocate(dummy3d, dummy)
3916 if (localpet == 0) call nemsio_close(gfile)
3928 integer,
intent(in) :: localpet
3930 character(len=500) :: tilefile
3932 integer :: error, rc
3933 integer :: id_dim, idim_input, jdim_input
3934 integer :: ncid, tile, id_var
3936 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
3937 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
3944 tilefile = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
3945 print*,
"- READ GRID DIMENSIONS FROM: ", trim(tilefile)
3946 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
3947 call
netcdf_err(error,
'opening: '//trim(tilefile) )
3949 error=nf90_inq_dimid(ncid,
'xaxis_1', id_dim)
3950 call
netcdf_err(error,
'reading xaxis_1 id' )
3951 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
3952 call
netcdf_err(error,
'reading xaxis_1 value' )
3954 error=nf90_inq_dimid(ncid,
'yaxis_1', id_dim)
3955 call
netcdf_err(error,
'reading yaxis_1 id' )
3956 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
3957 call
netcdf_err(error,
'reading yaxis_1 value' )
3959 if (idim_input /= i_input .or. jdim_input /= j_input)
then
3960 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 1)
3963 error = nf90_close(ncid)
3965 if (localpet == 0)
then
3966 allocate(data_one_tile(idim_input,jdim_input))
3967 allocate(data_one_tile_3d(idim_input,jdim_input,lsoil_input))
3969 allocate(data_one_tile(0,0))
3970 allocate(data_one_tile_3d(0,0,0))
3973 terrain_loop:
do tile = 1, num_tiles_input_grid
3975 if (localpet == 0)
then
3976 tilefile = trim(orog_dir_input_grid) // trim(orog_files_input_grid(tile))
3977 print*,
'- OPEN OROGRAPHY FILE: ', trim(tilefile)
3978 error=nf90_open(tilefile,nf90_nowrite,ncid)
3979 call
netcdf_err(error,
'OPENING OROGRAPHY FILE' )
3980 error=nf90_inq_varid(ncid,
'orog_raw', id_var)
3981 call
netcdf_err(error,
'READING OROG RECORD ID' )
3982 error=nf90_get_var(ncid, id_var, data_one_tile)
3983 call
netcdf_err(error,
'READING OROG RECORD' )
3984 print*,
'terrain check ',tile, maxval(data_one_tile)
3985 error=nf90_close(ncid)
3988 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
3989 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
3990 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3995 tile_loop :
do tile = 1, num_tiles_input_grid
3999 if (localpet == 0)
then
4001 lsoil_input, sfcdata_3d=data_one_tile_3d)
4004 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
4005 call esmf_fieldscatter(soilm_liq_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4006 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4009 if (localpet == 0)
then
4011 lsoil_input, sfcdata_3d=data_one_tile_3d)
4014 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
4015 call esmf_fieldscatter(soilm_tot_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4016 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4019 if (localpet == 0)
then
4021 lsoil_input, sfcdata_3d=data_one_tile_3d)
4024 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
4025 call esmf_fieldscatter(soil_temp_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4026 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4031 if (localpet == 0)
then
4033 lsoil_input, sfcdata=data_one_tile)
4036 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
4037 call esmf_fieldscatter(landsea_mask_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4038 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4043 if (localpet == 0)
then
4045 lsoil_input, sfcdata=data_one_tile)
4048 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
4049 call esmf_fieldscatter(seaice_fract_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4050 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4055 if (localpet == 0)
then
4057 lsoil_input, sfcdata=data_one_tile)
4060 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
4061 call esmf_fieldscatter(seaice_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4062 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4067 if (localpet == 0)
then
4069 lsoil_input, sfcdata=data_one_tile)
4072 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
4073 call esmf_fieldscatter(seaice_skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4074 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4079 if (localpet == 0)
then
4081 lsoil_input, sfcdata=data_one_tile)
4084 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
4085 call esmf_fieldscatter(snow_liq_equiv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4086 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4091 if (localpet == 0)
then
4093 lsoil_input, sfcdata=data_one_tile)
4094 data_one_tile = data_one_tile
4097 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
4098 call esmf_fieldscatter(snow_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4099 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4104 if (localpet == 0)
then
4106 lsoil_input, sfcdata=data_one_tile)
4109 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
4110 call esmf_fieldscatter(veg_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4111 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4116 if (localpet == 0)
then
4118 lsoil_input, sfcdata=data_one_tile)
4121 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
4122 call esmf_fieldscatter(soil_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4123 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4128 if (localpet == 0)
then
4130 lsoil_input, sfcdata=data_one_tile)
4133 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
4134 call esmf_fieldscatter(t2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4135 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4140 if (localpet == 0)
then
4142 lsoil_input, sfcdata=data_one_tile)
4145 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
4146 call esmf_fieldscatter(q2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4147 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4150 if (localpet == 0)
then
4152 lsoil_input, sfcdata=data_one_tile)
4155 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
4156 call esmf_fieldscatter(tprcp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4157 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4160 if (localpet == 0)
then
4162 lsoil_input, sfcdata=data_one_tile)
4165 print*,
"- CALL FieldScatter FOR INPUT GRID F10M"
4166 call esmf_fieldscatter(f10m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4167 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4170 if (localpet == 0)
then
4172 lsoil_input, sfcdata=data_one_tile)
4175 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
4176 call esmf_fieldscatter(ffmm_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4177 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4180 if (localpet == 0)
then
4182 lsoil_input, sfcdata=data_one_tile)
4185 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
4186 call esmf_fieldscatter(ustar_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4187 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4190 if (localpet == 0)
then
4192 lsoil_input, sfcdata=data_one_tile)
4195 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
4196 call esmf_fieldscatter(srflag_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4197 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4200 if (localpet == 0)
then
4202 lsoil_input, sfcdata=data_one_tile)
4205 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
4206 call esmf_fieldscatter(skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4207 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4210 if (localpet == 0)
then
4212 lsoil_input, sfcdata=data_one_tile)
4215 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
4216 call esmf_fieldscatter(canopy_mc_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4217 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4220 if (localpet == 0)
then
4222 lsoil_input, sfcdata=data_one_tile)
4225 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
4226 call esmf_fieldscatter(z0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4227 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4232 deallocate(data_one_tile, data_one_tile_3d)
4245 integer,
intent(in) :: localpet
4247 character(len=500) :: tilefile
4249 integer :: error, id_var
4250 integer :: id_dim, idim_input, jdim_input
4251 integer :: ncid, rc, tile
4253 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
4254 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
4261 tilefile = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
4262 print*,
"- READ GRID DIMENSIONS FROM: ", trim(tilefile)
4263 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
4264 call
netcdf_err(error,
'opening: '//trim(tilefile) )
4266 error=nf90_inq_dimid(ncid,
'grid_xt', id_dim)
4267 call
netcdf_err(error,
'reading grid_xt id' )
4268 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
4269 call
netcdf_err(error,
'reading grid_xt value' )
4271 error=nf90_inq_dimid(ncid,
'grid_yt', id_dim)
4272 call
netcdf_err(error,
'reading grid_yt id' )
4273 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
4274 call
netcdf_err(error,
'reading grid_yt value' )
4276 if (idim_input /= i_input .or. jdim_input /= j_input)
then
4277 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 3)
4280 error = nf90_close(ncid)
4282 if (localpet == 0)
then
4283 allocate(data_one_tile(idim_input,jdim_input))
4284 allocate(data_one_tile_3d(idim_input,jdim_input,lsoil_input))
4286 allocate(data_one_tile(0,0))
4287 allocate(data_one_tile_3d(0,0,0))
4290 terrain_loop:
do tile = 1, num_tiles_input_grid
4292 if (trim(input_type) ==
"gaussian_netcdf")
then
4293 if (localpet == 0)
then
4295 lsoil_input, sfcdata=data_one_tile)
4300 if (localpet == 0)
then
4301 tilefile = trim(orog_dir_input_grid) // trim(orog_files_input_grid(tile))
4302 print*,
'- OPEN OROGRAPHY FILE: ', trim(tilefile)
4303 error=nf90_open(tilefile,nf90_nowrite,ncid)
4304 call
netcdf_err(error,
'OPENING OROGRAPHY FILE.' )
4305 error=nf90_inq_varid(ncid,
'orog_raw', id_var)
4306 call
netcdf_err(error,
'READING OROGRAPHY RECORD ID.' )
4307 error=nf90_get_var(ncid, id_var, data_one_tile)
4308 call
netcdf_err(error,
'READING OROGRAPHY RECORD.' )
4309 print*,
'terrain check history ',tile, maxval(data_one_tile)
4310 error=nf90_close(ncid)
4315 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
4316 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4317 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4322 tile_loop :
do tile = 1, num_tiles_input_grid
4326 if (localpet == 0)
then
4328 lsoil_input, sfcdata=data_one_tile)
4329 data_one_tile_3d(:,:,1) = data_one_tile
4331 lsoil_input, sfcdata=data_one_tile)
4332 data_one_tile_3d(:,:,2) = data_one_tile
4334 lsoil_input, sfcdata=data_one_tile)
4335 data_one_tile_3d(:,:,3) = data_one_tile
4337 lsoil_input, sfcdata=data_one_tile)
4338 data_one_tile_3d(:,:,4) = data_one_tile
4341 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
4342 call esmf_fieldscatter(soilm_liq_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4343 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4348 if (localpet == 0)
then
4350 lsoil_input, sfcdata=data_one_tile)
4351 data_one_tile_3d(:,:,1) = data_one_tile
4353 lsoil_input, sfcdata=data_one_tile)
4354 data_one_tile_3d(:,:,2) = data_one_tile
4356 lsoil_input, sfcdata=data_one_tile)
4357 data_one_tile_3d(:,:,3) = data_one_tile
4359 lsoil_input, sfcdata=data_one_tile)
4360 data_one_tile_3d(:,:,4) = data_one_tile
4363 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
4364 call esmf_fieldscatter(soilm_tot_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4365 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4370 if (localpet == 0)
then
4372 lsoil_input, sfcdata=data_one_tile)
4373 data_one_tile_3d(:,:,1) = data_one_tile
4375 lsoil_input, sfcdata=data_one_tile)
4376 data_one_tile_3d(:,:,2) = data_one_tile
4378 lsoil_input, sfcdata=data_one_tile)
4379 data_one_tile_3d(:,:,3) = data_one_tile
4381 lsoil_input, sfcdata=data_one_tile)
4382 data_one_tile_3d(:,:,4) = data_one_tile
4385 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
4386 call esmf_fieldscatter(soil_temp_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4387 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4392 if (localpet == 0)
then
4394 lsoil_input, sfcdata=data_one_tile)
4397 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
4398 call esmf_fieldscatter(landsea_mask_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4399 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4404 if (localpet == 0)
then
4406 lsoil_input, sfcdata=data_one_tile)
4409 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
4410 call esmf_fieldscatter(seaice_fract_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4411 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4416 if (localpet == 0)
then
4418 lsoil_input, sfcdata=data_one_tile)
4421 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
4422 call esmf_fieldscatter(seaice_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4423 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4428 if (localpet == 0)
then
4430 lsoil_input, sfcdata=data_one_tile)
4433 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
4434 call esmf_fieldscatter(seaice_skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4435 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4440 if (localpet == 0)
then
4442 lsoil_input, sfcdata=data_one_tile)
4445 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
4446 call esmf_fieldscatter(snow_liq_equiv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4447 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4452 if (localpet == 0)
then
4454 lsoil_input, sfcdata=data_one_tile)
4455 data_one_tile = data_one_tile * 1000.0
4458 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
4459 call esmf_fieldscatter(snow_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4460 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4465 if (localpet == 0)
then
4467 lsoil_input, sfcdata=data_one_tile)
4470 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
4471 call esmf_fieldscatter(veg_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4472 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4477 if (localpet == 0)
then
4479 lsoil_input, sfcdata=data_one_tile)
4482 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
4483 call esmf_fieldscatter(soil_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4484 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4489 if (localpet == 0)
then
4491 lsoil_input, sfcdata=data_one_tile)
4494 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
4495 call esmf_fieldscatter(t2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4496 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4501 if (localpet == 0)
then
4503 lsoil_input, sfcdata=data_one_tile)
4506 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
4507 call esmf_fieldscatter(q2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4508 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4511 if (localpet == 0)
then
4513 lsoil_input, sfcdata=data_one_tile)
4516 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
4517 call esmf_fieldscatter(tprcp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4518 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4521 if (localpet == 0)
then
4523 lsoil_input, sfcdata=data_one_tile)
4526 print*,
"- CALL FieldScatter FOR INPUT GRID F10M"
4527 call esmf_fieldscatter(f10m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4528 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4531 if (localpet == 0)
then
4533 lsoil_input, sfcdata=data_one_tile)
4536 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
4537 call esmf_fieldscatter(ffmm_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4538 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4541 if (localpet == 0)
then
4543 lsoil_input, sfcdata=data_one_tile)
4546 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
4547 call esmf_fieldscatter(ustar_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4548 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4551 if (localpet == 0)
then
4557 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
4558 call esmf_fieldscatter(srflag_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4559 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4562 if (localpet == 0)
then
4564 lsoil_input, sfcdata=data_one_tile)
4567 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
4568 call esmf_fieldscatter(skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4569 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4572 if (localpet == 0)
then
4574 lsoil_input, sfcdata=data_one_tile)
4577 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
4578 call esmf_fieldscatter(canopy_mc_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4579 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4582 if (localpet == 0)
then
4584 lsoil_input, sfcdata=data_one_tile)
4587 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
4588 call esmf_fieldscatter(z0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4589 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4594 deallocate(data_one_tile, data_one_tile_3d)
4605 use program_setup, only : vgtyp_from_climo, sotyp_from_climo
4612 integer,
intent(in) :: localpet
4614 character(len=250) :: the_file
4615 character(len=250) :: geo_file
4616 character(len=20) :: vname, vname_file,slev
4617 character(len=50) :: method
4620 integer :: rc, varnum, iret, i, j,k
4621 integer :: ncid2d, varid, varsize
4623 logical :: exist, rap_latlon
4625 real(esmf_kind_r4) :: value
4627 real(esmf_kind_r4),
allocatable :: dummy2d(:,:),icec_save(:,:)
4628 real(esmf_kind_r4),
allocatable :: dummy1d(:)
4629 real(esmf_kind_r8),
allocatable :: dummy2d_8(:,:),dummy2d_82(:,:),tsk_save(:,:)
4630 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:), dummy3d_stype(:,:,:)
4631 integer(esmf_kind_i4),
allocatable :: slmsk_save(:,:)
4632 integer(esmf_kind_i8),
allocatable :: dummy2d_i(:,:)
4635 rap_latlon = trim(
to_upper(external_model))==
"RAP" .and. trim(input_grid_type) ==
"rotated_latlon"
4637 the_file = trim(data_dir_input_grid) //
"/" // trim(grib2_file_input_grid)
4638 geo_file = trim(geogrid_file_input_grid)
4641 print*,
"- READ SFC DATA FROM GRIB2 FILE: ", trim(the_file)
4642 inquire(file=the_file,exist=exist)
4643 if (.not.exist)
then
4648 lsoil_input = grb2_inq(the_file, inv_file,
':TSOIL:',
' below ground:')
4649 print*,
"- FILE HAS ", lsoil_input,
" SOIL LEVELS"
4650 if (lsoil_input <= 0) call
error_handler(
"COUNTING SOIL LEVELS.", rc)
4653 if (lsoil_input /= 4)
then
4655 call esmf_fielddestroy(soil_temp_input_grid, rc=rc)
4656 call esmf_fielddestroy(soilm_tot_input_grid, rc=rc)
4657 call esmf_fielddestroy(soilm_liq_input_grid, rc=rc)
4659 print*,
"- CALL FieldCreate FOR INPUT SOIL TEMPERATURE."
4660 soil_temp_input_grid = esmf_fieldcreate(input_grid, &
4661 typekind=esmf_typekind_r8, &
4662 staggerloc=esmf_staggerloc_center, &
4663 ungriddedlbound=(/1/), &
4664 ungriddedubound=(/lsoil_input/), rc=rc)
4665 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4668 print*,
"- CALL FieldCreate FOR INPUT TOTAL SOIL MOISTURE."
4669 soilm_tot_input_grid = esmf_fieldcreate(input_grid, &
4670 typekind=esmf_typekind_r8, &
4671 staggerloc=esmf_staggerloc_center, &
4672 ungriddedlbound=(/1/), &
4673 ungriddedubound=(/lsoil_input/), rc=rc)
4674 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4677 print*,
"- CALL FieldCreate FOR INPUT LIQUID SOIL MOISTURE."
4678 soilm_liq_input_grid = esmf_fieldcreate(input_grid, &
4679 typekind=esmf_typekind_r8, &
4680 staggerloc=esmf_staggerloc_center, &
4681 ungriddedlbound=(/1/), &
4682 ungriddedubound=(/lsoil_input/), rc=rc)
4683 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4688 if (localpet == 0)
then
4689 allocate(dummy2d(i_input,j_input))
4690 allocate(slmsk_save(i_input,j_input))
4691 allocate(dummy2d_i(i_input,j_input))
4692 allocate(tsk_save(i_input,j_input))
4693 allocate(icec_save(i_input,j_input))
4694 allocate(dummy2d_8(i_input,j_input))
4695 allocate(dummy2d_82(i_input,j_input))
4696 allocate(dummy3d(i_input,j_input,lsoil_input))
4697 allocate(dummy3d_stype(i_input,j_input,16))
4698 allocate(dummy1d(16))
4700 allocate(dummy3d(0,0,0))
4701 allocate(dummy2d_8(0,0))
4702 allocate(dummy2d_82(0,0))
4703 allocate(dummy2d(0,0))
4712 if (localpet == 0)
then
4713 print*,
"- READ TERRAIN."
4714 rc = grb2_inq(the_file, inv_file,
':HGT:',
':surface:', data2=dummy2d)
4716 print*,
'orog ',maxval(dummy2d),minval(dummy2d)
4719 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
4720 call esmf_fieldscatter(terrain_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4721 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4724 if (localpet == 0)
then
4725 print*,
"- READ SEAICE FRACTION."
4726 rc = grb2_inq(the_file, inv_file,
':ICEC:',
':surface:', data2=dummy2d)
4727 if (rc /= 1) call
error_handler(
"READING SEAICE FRACTION.", rc)
4729 print*,
'icec ',maxval(dummy2d),minval(dummy2d)
4733 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
4734 call esmf_fieldscatter(seaice_fract_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4735 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4746 if (localpet == 0)
then
4747 print*,
"- READ LANDSEA MASK."
4748 rc = grb2_inq(the_file, inv_file,
':LANDN:',
':surface:', data2=dummy2d)
4751 rc = grb2_inq(the_file, inv_file,
':LAND:',
':surface:', data2=dummy2d)
4752 if (rc /= 1) call
error_handler(
"READING LANDSEA MASK.", rc)
4757 if(dummy2d(i,j) < 0.5_esmf_kind_r4) dummy2d(i,j)=0.0_esmf_kind_r4
4758 if(icec_save(i,j) > 0.15_esmf_kind_r4)
then
4760 dummy2d(i,j) = 2.0_esmf_kind_r4
4765 slmsk_save = nint(dummy2d)
4767 deallocate(icec_save)
4770 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
4771 call esmf_fieldscatter(landsea_mask_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4772 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4775 if (localpet == 0)
then
4776 print*,
"- READ SEAICE SKIN TEMPERATURE."
4777 rc = grb2_inq(the_file, inv_file,
':TMP:',
':surface:', data2=dummy2d)
4778 if (rc /= 1) call
error_handler(
"READING SEAICE SKIN TEMP.", rc)
4779 print*,
'ti ',maxval(dummy2d),minval(dummy2d)
4782 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
4783 call esmf_fieldscatter(seaice_skin_temp_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4784 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4793 if (localpet == 0)
then
4794 print*,
"- READ SNOW LIQUID EQUIVALENT."
4795 rc = grb2_inq(the_file, inv_file,
':WEASD:',
':surface:',
':anl:',data2=dummy2d)
4797 rc = grb2_inq(the_file, inv_file,
':WEASD:',
':surface:',
'hour fcst:',data2=dummy2d)
4798 if (rc /= 1) call
error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
4802 if(slmsk_save(i,j) == 0) dummy2d(i,j) = 0.0_esmf_kind_r4
4803 if(dummy2d(i,j) == grb2_undefined) dummy2d(i,j) = 0.0_esmf_kind_r4
4806 print*,
'weasd ',maxval(dummy2d),minval(dummy2d)
4809 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
4810 call esmf_fieldscatter(snow_liq_equiv_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4811 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4814 if (localpet == 0)
then
4815 print*,
"- READ SNOW DEPTH."
4816 rc = grb2_inq(the_file, inv_file,
':SNOD:',
':surface:', data2=dummy2d)
4818 where(dummy2d == grb2_undefined) dummy2d = 0.0_esmf_kind_r4
4819 dummy2d = dummy2d*1000.0
4820 where(slmsk_save == 0) dummy2d = 0.0_esmf_kind_r4
4821 print*,
'snod ',maxval(dummy2d),minval(dummy2d)
4824 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
4825 call esmf_fieldscatter(snow_depth_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4826 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4829 if (localpet == 0)
then
4830 print*,
"- READ T2M."
4831 rc = grb2_inq(the_file, inv_file,
':TMP:',
':2 m above ground:',data2=dummy2d)
4834 print*,
't2m ',maxval(dummy2d),minval(dummy2d)
4837 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
4838 call esmf_fieldscatter(t2m_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0,rc=rc)
4839 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4842 if (localpet == 0)
then
4843 print*,
"- READ Q2M."
4844 rc = grb2_inq(the_file, inv_file,
':SPFH:',
':2 m above ground:',data2=dummy2d)
4846 print*,
'q2m ',maxval(dummy2d),minval(dummy2d)
4849 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
4850 call esmf_fieldscatter(q2m_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0,rc=rc)
4851 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4854 if (localpet == 0)
then
4855 print*,
"- READ SKIN TEMPERATURE."
4856 rc = grb2_inq(the_file, inv_file,
':TMP:',
':surface:', data2=dummy2d)
4857 if (rc <= 0 ) call
error_handler(
"READING SKIN TEMPERATURE.", rc)
4858 tsk_save(:,:) =
real(dummy2d,esmf_kind_r8)
4859 dummy2d_8 =
real(dummy2d,esmf_kind_r8)
4862 if(slmsk_save(i,j) == 0 .and. dummy2d(i,j) < 271.2)
then
4864 dummy2d(i,j) = 271.2
4866 if(slmsk_save(i,j) == 0 .and. dummy2d(i,j) > 310.)
then
4868 dummy2d(i,j) = 310.0
4874 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
4875 call esmf_fieldscatter(skin_temp_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4876 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4879 if (localpet == 0) dummy2d = 0.0
4881 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
4882 call esmf_fieldscatter(srflag_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0,rc=rc)
4883 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4886 if (localpet == 0)
then
4887 print*,
"- READ SOIL TYPE."
4890 rc = grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
4892 if (rc <= 0 .and. (trim(
to_upper(external_model))==
"HRRR" .or. rap_latlon) .and. geo_file .ne.
"NULL")
then
4896 print*,
"OPEN GEOGRID FILE ", trim(geo_file)
4897 rc = nf90_open(geo_file,nf90_nowrite,ncid2d)
4900 print*,
"INQURE ABOUT DIM IDS"
4901 rc = nf90_inq_dimid(ncid2d,
"west_east",varid)
4902 call
netcdf_err(rc,
"READING west_east DIMENSION FROM GEOGRID FILE")
4904 rc = nf90_inquire_dimension(ncid2d,varid,len=varsize)
4905 call
netcdf_err(rc,
"READING west_east DIMENSION SIZE")
4906 if (varsize .ne. i_input) call
error_handler(
"GEOGRID FILE GRID SIZE DIFFERS FROM INPUT DATA.", -1)
4908 print*,
"INQUIRE ABOUT SOIL TYPE FROM GEOGRID FILE"
4909 rc = nf90_inq_varid(ncid2d,
"SCT_DOM",varid)
4910 call
netcdf_err(rc,
"FINDING SCT_DOM IN GEOGRID FILE")
4912 print*,
"READ SOIL TYPE FROM GEOGRID FILE "
4913 rc = nf90_get_var(ncid2d,varid,dummy2d)
4914 call
netcdf_err(rc,
"READING SCT_DOM FROM FILE")
4916 print*,
"INQUIRE ABOUT SOIL TYPE FRACTIONS FROM GEOGRID FILE"
4917 rc = nf90_inq_varid(ncid2d,
"SOILCTOP",varid)
4918 call
netcdf_err(rc,
"FINDING SOILCTOP IN GEOGRID FILE")
4920 print*,
"READ SOIL TYPE FRACTIONS FROM GEOGRID FILE "
4921 rc = nf90_get_var(ncid2d,varid,dummy3d_stype)
4922 call
netcdf_err(rc,
"READING SCT_DOM FROM FILE")
4924 print*,
"CLOSE GEOGRID FILE "
4925 iret = nf90_close(ncid2d)
4933 if(dummy2d(i,j) == 14.0_esmf_kind_r4 .and. slmsk_save(i,j) == 1)
then
4934 dummy1d(:) = dummy3d_stype(i,j,:)
4935 dummy1d(14) = 0.0_esmf_kind_r4
4936 dummy2d(i,j) =
real(MAXLOC(dummy1d, 1),esmf_kind_r4)
4942 if ((rc <= 0 .and. trim(
to_upper(external_model)) /=
"HRRR" .and. .not. rap_latlon) &
4943 .or. (rc < 0 .and. (trim(
to_upper(external_model)) ==
"HRRR" .or. rap_latlon)))
then
4944 if (.not. sotyp_from_climo)
then
4945 call
error_handler(
"COULD NOT FIND SOIL TYPE IN FILE. PLEASE SET SOTYP_FROM_CLIMO=.TRUE. . EXITING", rc)
4948 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
4952 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. WILL NOT "//&
4953 "SCALE SOIL MOISTURE FOR DIFFERENCES IN SOIL TYPE. "
4954 dummy2d(:,:) = -99999.0_esmf_kind_r4
4962 if (.not. sotyp_from_climo)
then
4965 if(dummy2d(i,j) == 14.0_esmf_kind_r4 .and. slmsk_save(i,j) == 1) dummy2d(i,j) = -99999.9
4969 dummy2d_8 =
real(dummy2d,esmf_kind_r8)
4971 where(slmsk_save == 1) dummy2d_i = 1
4973 call
search(dummy2d_8,dummy2d_i,i_input,j_input,1,230)
4975 dummy2d_8=
real(dummy2d,esmf_kind_r8)
4978 print*,
'sotype ',maxval(dummy2d_8),minval(dummy2d_8)
4979 deallocate(dummy2d_i)
4980 deallocate(dummy3d_stype)
4984 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
4985 call esmf_fieldscatter(soil_type_input_grid,dummy2d_8, rootpet=0, rc=rc)
4986 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4994 if (.not. vgfrc_from_climo)
then
4995 if (localpet == 0)
then
4996 print*,
"- READ VEG FRACTION."
4999 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
5003 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5006 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1105:', data2=dummy2d)
5008 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1101:', data2=dummy2d)
5010 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1151:', data2=dummy2d)
5011 if (rc <= 0) call
error_handler(
"COULD NOT DETERMINE VEGETATION FRACTION IN FILE. &
5012 RECORD NUMBERS MAY HAVE CHANGED. PLEASE SET VGFRC_FROM_CLIMO=.TRUE. EXITING", rc)
5015 elseif (rc <= 0)
then
5016 call
error_handler(
"COULD NOT FIND VEGETATION FRACTION IN FILE. &
5017 PLEASE SET VGFRC_FROM_CLIMO=.TRUE. EXITING", rc)
5019 if(maxval(dummy2d) > 2.0) dummy2d = dummy2d / 100.0_esmf_kind_r4
5020 print*,
'vfrac ',maxval(dummy2d),minval(dummy2d)
5024 print*,
"- CALL FieldScatter FOR INPUT GRID VEG GREENNESS."
5025 call esmf_fieldscatter(veg_greenness_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0, rc=rc)
5026 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5030 if (.not. minmax_vgfrc_from_climo)
then
5031 if (localpet == 0)
then
5032 print*,
"- READ MIN VEG FRACTION."
5035 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5038 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1106:',data2=dummy2d)
5041 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1102:',data2=dummy2d)
5043 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1152:',data2=dummy2d)
5044 if (rc<=0) call
error_handler(
"COULD NOT FIND MIN VEGETATION FRACTION IN FILE. &
5045 PLEASE SET MINMAX_VGFRC_FROM_CLIMO=.TRUE. . EXITING",rc)
5048 if(maxval(dummy2d) > 2.0) dummy2d = dummy2d / 100.0_esmf_kind_r4
5049 print*,
'vfrac min',maxval(dummy2d),minval(dummy2d)
5053 print*,
"- CALL FieldScatter FOR INPUT GRID MIN VEG GREENNESS."
5054 call esmf_fieldscatter(min_veg_greenness_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0, rc=rc)
5055 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5058 if (localpet == 0)
then
5059 print*,
"- READ MAX VEG FRACTION."
5062 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5066 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1107:',data2=dummy2d)
5068 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1103:',data2=dummy2d)
5070 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1153:',data2=dummy2d)
5071 if (rc <= 0) call
error_handler(
"COULD NOT FIND MAX VEGETATION FRACTION IN FILE. &
5072 PLEASE SET MINMAX_VGFRC_FROM_CLIMO=.TRUE. . EXITING",rc)
5075 if(maxval(dummy2d) > 2.0) dummy2d = dummy2d / 100.0_esmf_kind_r4
5076 print*,
'vfrac max',maxval(dummy2d),minval(dummy2d)
5080 print*,
"- CALL FieldScatter FOR INPUT GRID MAX VEG GREENNESS."
5081 call esmf_fieldscatter(max_veg_greenness_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
5082 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5086 if (.not. lai_from_climo)
then
5087 if (localpet == 0)
then
5088 print*,
"- READ LAI."
5091 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5093 vname=
":var0_7_198:"
5094 rc= grb2_inq(the_file, inv_file, vname,slev,
':n=1108:',data2=dummy2d)
5096 rc= grb2_inq(the_file, inv_file, vname,slev,
':n=1104:',data2=dummy2d)
5098 rc= grb2_inq(the_file, inv_file, vname,slev,
':n=1154:',data2=dummy2d)
5099 if (rc <= 0) call
error_handler(
"COULD NOT FIND LAI IN FILE. &
5100 PLEASE SET LAI_FROM_CLIMO=.TRUE. . EXITING",rc)
5103 print*,
'lai',maxval(dummy2d),minval(dummy2d)
5106 print*,
"- CALL FieldScatter FOR INPUT GRID LAI."
5107 call esmf_fieldscatter(lai_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
5108 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5112 if (localpet == 0)
then
5113 print*,
"- READ SEAICE DEPTH."
5116 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5119 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5123 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL BE"//&
5124 " REPLACED WITH CLIMO. SET A FILL "// &
5125 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5126 dummy2d(:,:) = 0.0_esmf_kind_r4
5129 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5130 print*,
'hice ',maxval(dummy2d),minval(dummy2d)
5134 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
5135 call esmf_fieldscatter(seaice_depth_input_grid,dummy2d_8, rootpet=0, rc=rc)
5136 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5139 if (localpet == 0)
then
5140 print*,
"- READ TPRCP."
5143 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5146 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5150 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
5151 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
5152 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5153 dummy2d(:,:) = 0.0_esmf_kind_r4
5156 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5157 print*,
'tprcp ',maxval(dummy2d),minval(dummy2d)
5160 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
5161 call esmf_fieldscatter(tprcp_input_grid,dummy2d_8, rootpet=0, rc=rc)
5162 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5165 if (localpet == 0)
then
5166 print*,
"- READ FFMM."
5169 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5172 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5176 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
5177 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
5178 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5179 dummy2d(:,:) = 0.0_esmf_kind_r4
5182 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5183 print*,
'ffmm ',maxval(dummy2d),minval(dummy2d)
5186 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
5187 call esmf_fieldscatter(ffmm_input_grid,dummy2d_8, rootpet=0, rc=rc)
5188 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5191 if (localpet == 0)
then
5192 print*,
"- READ USTAR."
5195 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5198 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5202 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL "//&
5203 "REPLACED WITH CLIMO. SET A FILL "// &
5204 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5205 dummy2d(:,:) = 0.0_esmf_kind_r4
5208 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5209 print*,
'fricv ',maxval(dummy2d),minval(dummy2d)
5212 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
5213 call esmf_fieldscatter(ustar_input_grid,dummy2d_8, rootpet=0, rc=rc)
5214 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5217 if (localpet == 0)
then
5218 print*,
"- READ F10M."
5220 slev=
":10 m above ground:"
5221 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5224 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5228 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
5229 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
5230 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5231 dummy2d(:,:) = 0.0_esmf_kind_r4
5234 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5235 print*,
'f10m ',maxval(dummy2d),minval(dummy2d)
5238 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
5239 call esmf_fieldscatter(f10m_input_grid,dummy2d_8, rootpet=0, rc=rc)
5240 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5243 if (localpet == 0)
then
5244 print*,
"- READ CANOPY MOISTURE CONTENT."
5247 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5250 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5254 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL"//&
5255 " REPLACED WITH CLIMO. SET A FILL "// &
5256 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5257 dummy2d(:,:) = 0.0_esmf_kind_r4
5261 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5262 print*,
'cnwat ',maxval(dummy2d),minval(dummy2d)
5265 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
5266 call esmf_fieldscatter(canopy_mc_input_grid,dummy2d_8, rootpet=0, rc=rc)
5267 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5270 if (localpet == 0)
then
5274 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5277 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5281 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL BE"//&
5282 " REPLACED WITH CLIMO. SET A FILL "// &
5283 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5284 dummy2d(:,:) = 0.0_esmf_kind_r4
5288 dummy2d(:,:) = dummy2d(:,:)*10.0
5290 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5291 print*,
'sfcr ',maxval(dummy2d),minval(dummy2d)
5295 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
5296 call esmf_fieldscatter(z0_input_grid,dummy2d_8, rootpet=0, rc=rc)
5297 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5301 if (localpet == 0)
then
5302 print*,
"- READ LIQUID SOIL MOISTURE."
5304 vname_file =
":SOILL:"
5305 call
read_grib_soil(the_file,inv_file,vname,vname_file,dummy3d,rc)
5307 print*,
'soill ',maxval(dummy3d),minval(dummy3d)
5310 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
5311 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
5312 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5315 if (localpet == 0)
then
5316 print*,
"- READ TOTAL SOIL MOISTURE."
5319 vname_file =
"var2_2_1_"
5320 call
read_grib_soil(the_file,inv_file,vname,vname_file,dummy3d,rc)
5321 print*,
'soilm ',maxval(dummy3d),minval(dummy3d)
5324 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
5325 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
5326 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5335 print*,
"- CALL FieldGather for INPUT SOIL TYPE."
5336 call esmf_fieldgather(soil_type_input_grid, dummy2d_82, rootpet=0, tile=1, rc=rc)
5337 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5339 if (localpet == 0)
then
5340 print*,
"- READ VEG TYPE."
5343 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
5349 rc= grb2_inq(the_file, inv_file, vname,
"_0_198:",slev,
' hour fcst:', data2=dummy2d)
5351 rc= grb2_inq(the_file, inv_file, vname,
"_0_198:",slev,
':anl:', data2=dummy2d)
5353 if (.not. vgtyp_from_climo)
then
5354 call
error_handler(
"COULD NOT FIND VEGETATION TYPE IN FILE. PLEASE SET VGTYP_FROM_CLIMO=.TRUE. . EXITING", rc)
5358 dummy2d(i,j) = 0.0_esmf_kind_r4
5359 if(slmsk_save(i,j) == 1 .and. dummy3d(i,j,1) > 0.99) &
5360 dummy2d(i,j) =
real(veg_type_landice_input,esmf_kind_r4)
5367 if (trim(external_model) .ne.
"GFS")
then
5370 if (dummy2d(i,j) == 15.0_esmf_kind_r4 .and. slmsk_save(i,j) == 1)
then
5371 if (dummy3d(i,j,1) < 0.6)
then
5372 dummy2d(i,j) =
real(veg_type_landice_input,esmf_kind_r4)
5373 elseif (dummy3d(i,j,1) > 0.99)
then
5375 dummy2d(i,j) = 0.0_esmf_kind_r4
5376 dummy2d_82(i,j) = 0.0_esmf_kind_r8
5378 elseif (dummy2d(i,j) == 17.0_esmf_kind_r4 .and. slmsk_save(i,j)==0)
then
5379 dummy2d(i,j) = 0.0_esmf_kind_r4
5384 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5385 print*,
'vgtyp ',maxval(dummy2d),minval(dummy2d)
5388 print*,
"- CALL FieldScatter FOR INPUT VEG TYPE."
5389 call esmf_fieldscatter(veg_type_input_grid, dummy2d_8, rootpet=0, rc=rc)
5390 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5393 print*,
"- CALL FieldScatter FOR INPUT VEG TYPE."
5394 call esmf_fieldscatter(soil_type_input_grid, dummy2d_82, rootpet=0, rc=rc)
5395 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5398 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
5399 call esmf_fieldscatter(landsea_mask_input_grid,
real(slmsk_save,esmf_kind_r8),rootpet=0, rc=rc)
5400 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5410 if (localpet == 0)
then
5411 print*,
"- READ SOIL TEMPERATURE."
5413 vname_file =
":TSOIL:"
5414 call
read_grib_soil(the_file,inv_file,vname,vname_file,dummy3d,rc)
5416 print*,
'soilt ',maxval(dummy3d),minval(dummy3d)
5418 deallocate(tsk_save, slmsk_save)
5421 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
5422 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
5423 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5427 deallocate(dummy2d_8)
5440 integer,
intent(in) :: localpet
5442 character(len=10) :: field
5446 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
5448 if (localpet == 0)
then
5449 allocate(data_one_tile(i_input,j_input))
5451 allocate(data_one_tile(0,0))
5454 tile_loop :
do tile = 1, num_tiles_input_grid
5458 if (localpet == 0)
then
5459 if (trim(input_type) ==
"restart")
then
5465 lsoil_input, sfcdata=data_one_tile)
5468 print*,
"- CALL FieldScatter FOR INPUT C_D"
5469 call esmf_fieldscatter(c_d_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5470 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5475 if (localpet == 0)
then
5476 if (trim(input_type) ==
"restart")
then
5482 lsoil_input, sfcdata=data_one_tile)
5485 print*,
"- CALL FieldScatter FOR INPUT C_0"
5486 call esmf_fieldscatter(c_0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5487 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5492 if (localpet == 0)
then
5493 if (trim(input_type) ==
"restart")
then
5499 lsoil_input, sfcdata=data_one_tile)
5502 print*,
"- CALL FieldScatter FOR INPUT D_CONV."
5503 call esmf_fieldscatter(d_conv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5504 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5509 if (localpet == 0)
then
5510 if (trim(input_type) ==
"restart")
then
5516 lsoil_input, sfcdata=data_one_tile)
5519 print*,
"- CALL FieldScatter FOR INPUT DT_COOL."
5520 call esmf_fieldscatter(dt_cool_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5521 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5526 if (localpet == 0)
then
5530 print*,
"- CALL FieldScatter FOR INPUT IFD."
5531 call esmf_fieldscatter(ifd_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5532 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5537 if (localpet == 0)
then
5539 lsoil_input, sfcdata=data_one_tile)
5542 print*,
"- CALL FieldScatter FOR INPUT QRAIN."
5543 call esmf_fieldscatter(qrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5544 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5549 if (localpet == 0)
then
5551 lsoil_input, sfcdata=data_one_tile)
5554 print*,
"- CALL FieldScatter FOR INPUT TREF"
5555 call esmf_fieldscatter(tref_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5556 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5561 if (localpet == 0)
then
5562 if (trim(input_type) ==
"restart")
then
5568 lsoil_input, sfcdata=data_one_tile)
5571 print*,
"- CALL FieldScatter FOR INPUT W_D"
5572 call esmf_fieldscatter(w_d_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5573 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5578 if (localpet == 0)
then
5579 if (trim(input_type) ==
"restart")
then
5585 lsoil_input, sfcdata=data_one_tile)
5588 print*,
"- CALL FieldScatter FOR INPUT W_0"
5589 call esmf_fieldscatter(w_0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5590 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5595 if (localpet == 0)
then
5597 lsoil_input, sfcdata=data_one_tile)
5600 print*,
"- CALL FieldScatter FOR INPUT XS"
5601 call esmf_fieldscatter(xs_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5602 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5607 if (localpet == 0)
then
5609 lsoil_input, sfcdata=data_one_tile)
5612 print*,
"- CALL FieldScatter FOR INPUT XT"
5613 call esmf_fieldscatter(xt_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5614 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5619 if (localpet == 0)
then
5621 lsoil_input, sfcdata=data_one_tile)
5624 print*,
"- CALL FieldScatter FOR INPUT XU"
5625 call esmf_fieldscatter(xu_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5626 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5631 if (localpet == 0)
then
5633 lsoil_input, sfcdata=data_one_tile)
5636 print*,
"- CALL FieldScatter FOR INPUT XV"
5637 call esmf_fieldscatter(xv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5638 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5643 if (localpet == 0)
then
5645 lsoil_input, sfcdata=data_one_tile)
5648 print*,
"- CALL FieldScatter FOR INPUT XZ"
5649 call esmf_fieldscatter(xz_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5650 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5655 if (localpet == 0)
then
5657 lsoil_input, sfcdata=data_one_tile)
5660 print*,
"- CALL FieldScatter FOR INPUT XTTS"
5661 call esmf_fieldscatter(xtts_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5662 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5667 if (localpet == 0)
then
5669 lsoil_input, sfcdata=data_one_tile)
5672 print*,
"- CALL FieldScatter FOR INPUT XZTS"
5673 call esmf_fieldscatter(xzts_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5674 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5679 if (localpet == 0)
then
5680 if (trim(input_type) ==
"restart")
then
5686 lsoil_input, sfcdata=data_one_tile)
5689 print*,
"- CALL FieldScatter FOR INPUT Z_C"
5690 call esmf_fieldscatter(z_c_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5691 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5696 if (localpet == 0)
then
5700 print*,
"- CALL FieldScatter FOR INPUT ZM"
5701 call esmf_fieldscatter(zm_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5702 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5707 deallocate(data_one_tile)
5724 integer,
intent(in) :: localpet
5726 character(len=300) :: the_file
5730 real(nemsio_realkind),
allocatable :: dummy(:)
5731 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
5733 type(nemsio_gfile
) :: gfile
5735 if (trim(input_type) ==
"gfs_gaussian_nemsio")
then
5737 the_file = trim(data_dir_input_grid) //
"/" // trim(nst_files_input_grid)
5739 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
5742 print*,
"- READ NST DATA FROM: ", trim(the_file)
5744 if (localpet == 0)
then
5745 allocate(dummy(i_input*j_input))
5746 allocate(dummy2d(i_input,j_input))
5747 call nemsio_open(gfile, the_file,
"read", iret=rc)
5750 allocate(dummy2d(0,0))
5753 if (localpet == 0)
then
5754 print*,
"- READ TREF"
5755 call nemsio_readrecv(gfile,
"tref",
"sfc", 1, dummy, 0, iret=rc)
5757 dummy2d = reshape(dummy, (/i_input,j_input/))
5758 print*,
'tref ',maxval(dummy2d),minval(dummy2d)
5761 print*,
"- CALL FieldScatter FOR INPUT TREF."
5762 call esmf_fieldscatter(tref_input_grid, dummy2d, rootpet=0, rc=rc)
5763 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5766 if (localpet == 0)
then
5768 call nemsio_readrecv(gfile,
"cd",
"sfc", 1, dummy, 0, iret=rc)
5770 dummy2d = reshape(dummy, (/i_input,j_input/))
5771 print*,
'cd ',maxval(dummy2d),minval(dummy2d)
5774 print*,
"- CALL FieldScatter FOR INPUT C_D."
5775 call esmf_fieldscatter(c_d_input_grid, dummy2d, rootpet=0, rc=rc)
5776 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5779 if (localpet == 0)
then
5781 call nemsio_readrecv(gfile,
"c0",
"sfc", 1, dummy, 0, iret=rc)
5783 dummy2d = reshape(dummy, (/i_input,j_input/))
5784 print*,
'c0 ',maxval(dummy2d),minval(dummy2d)
5787 print*,
"- CALL FieldScatter FOR INPUT C_0."
5788 call esmf_fieldscatter(c_0_input_grid, dummy2d, rootpet=0, rc=rc)
5789 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5792 if (localpet == 0)
then
5793 print*,
"- READ DCONV"
5794 call nemsio_readrecv(gfile,
"dconv",
"sfc", 1, dummy, 0, iret=rc)
5796 dummy2d = reshape(dummy, (/i_input,j_input/))
5797 print*,
'dconv ',maxval(dummy2d),minval(dummy2d)
5800 print*,
"- CALL FieldScatter FOR INPUT D_CONV."
5801 call esmf_fieldscatter(d_conv_input_grid, dummy2d, rootpet=0, rc=rc)
5802 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5805 if (localpet == 0)
then
5806 print*,
"- READ DTCOOL"
5807 call nemsio_readrecv(gfile,
"dtcool",
"sfc", 1, dummy, 0, iret=rc)
5809 dummy2d = reshape(dummy, (/i_input,j_input/))
5810 print*,
'dtcool ',maxval(dummy2d),minval(dummy2d)
5813 print*,
"- CALL FieldScatter FOR INPUT DT_COOL."
5814 call esmf_fieldscatter(dt_cool_input_grid, dummy2d, rootpet=0, rc=rc)
5815 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5818 if (localpet == 0)
then
5822 print*,
"- CALL FieldScatter FOR INPUT IFD."
5823 call esmf_fieldscatter(ifd_input_grid, dummy2d, rootpet=0, rc=rc)
5824 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5827 if (localpet == 0)
then
5828 print*,
"- READ QRAIN"
5829 call nemsio_readrecv(gfile,
"qrain",
"sfc", 1, dummy, 0, iret=rc)
5831 dummy2d = reshape(dummy, (/i_input,j_input/))
5832 print*,
'qrain ',maxval(dummy2d),minval(dummy2d)
5835 print*,
"- CALL FieldScatter FOR INPUT QRAIN."
5836 call esmf_fieldscatter(qrain_input_grid, dummy2d, rootpet=0, rc=rc)
5837 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5840 if (localpet == 0)
then
5842 call nemsio_readrecv(gfile,
"wd",
"sfc", 1, dummy, 0, iret=rc)
5844 dummy2d = reshape(dummy, (/i_input,j_input/))
5845 print*,
'wd ',maxval(dummy2d),minval(dummy2d)
5848 print*,
"- CALL FieldScatter FOR INPUT WD."
5849 call esmf_fieldscatter(w_d_input_grid, dummy2d, rootpet=0, rc=rc)
5850 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5853 if (localpet == 0)
then
5855 call nemsio_readrecv(gfile,
"w0",
"sfc", 1, dummy, 0, iret=rc)
5857 dummy2d = reshape(dummy, (/i_input,j_input/))
5858 print*,
'w0 ',maxval(dummy2d),minval(dummy2d)
5861 print*,
"- CALL FieldScatter FOR INPUT W0."
5862 call esmf_fieldscatter(w_0_input_grid, dummy2d, rootpet=0, rc=rc)
5863 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5866 if (localpet == 0)
then
5868 call nemsio_readrecv(gfile,
"xs",
"sfc", 1, dummy, 0, iret=rc)
5870 dummy2d = reshape(dummy, (/i_input,j_input/))
5871 print*,
'xs ',maxval(dummy2d),minval(dummy2d)
5874 print*,
"- CALL FieldScatter FOR INPUT XS."
5875 call esmf_fieldscatter(xs_input_grid, dummy2d, rootpet=0, rc=rc)
5876 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5879 if (localpet == 0)
then
5881 call nemsio_readrecv(gfile,
"xt",
"sfc", 1, dummy, 0, iret=rc)
5883 dummy2d = reshape(dummy, (/i_input,j_input/))
5884 print*,
'xt ',maxval(dummy2d),minval(dummy2d)
5887 print*,
"- CALL FieldScatter FOR INPUT XT."
5888 call esmf_fieldscatter(xt_input_grid, dummy2d, rootpet=0, rc=rc)
5889 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5892 if (localpet == 0)
then
5894 call nemsio_readrecv(gfile,
"xu",
"sfc", 1, dummy, 0, iret=rc)
5896 dummy2d = reshape(dummy, (/i_input,j_input/))
5897 print*,
'xu ',maxval(dummy2d),minval(dummy2d)
5900 print*,
"- CALL FieldScatter FOR INPUT XU."
5901 call esmf_fieldscatter(xu_input_grid, dummy2d, rootpet=0, rc=rc)
5902 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5905 if (localpet == 0)
then
5907 call nemsio_readrecv(gfile,
"xv",
"sfc", 1, dummy, 0, iret=rc)
5909 dummy2d = reshape(dummy, (/i_input,j_input/))
5910 print*,
'xv ',maxval(dummy2d),minval(dummy2d)
5913 print*,
"- CALL FieldScatter FOR INPUT XV."
5914 call esmf_fieldscatter(xv_input_grid, dummy2d, rootpet=0, rc=rc)
5915 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5918 if (localpet == 0)
then
5920 call nemsio_readrecv(gfile,
"xz",
"sfc", 1, dummy, 0, iret=rc)
5922 dummy2d = reshape(dummy, (/i_input,j_input/))
5923 print*,
'xz ',maxval(dummy2d),minval(dummy2d)
5926 print*,
"- CALL FieldScatter FOR INPUT XZ."
5927 call esmf_fieldscatter(xz_input_grid, dummy2d, rootpet=0, rc=rc)
5928 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5931 if (localpet == 0)
then
5932 print*,
"- READ XTTS"
5933 call nemsio_readrecv(gfile,
"xtts",
"sfc", 1, dummy, 0, iret=rc)
5935 dummy2d = reshape(dummy, (/i_input,j_input/))
5936 print*,
'xtts ',maxval(dummy2d),minval(dummy2d)
5939 print*,
"- CALL FieldScatter FOR INPUT XTTS."
5940 call esmf_fieldscatter(xtts_input_grid, dummy2d, rootpet=0, rc=rc)
5941 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5944 if (localpet == 0)
then
5945 print*,
"- READ XZTS"
5946 call nemsio_readrecv(gfile,
"xzts",
"sfc", 1, dummy, 0, iret=rc)
5948 dummy2d = reshape(dummy, (/i_input,j_input/))
5949 print*,
'xzts ',maxval(dummy2d),minval(dummy2d)
5952 print*,
"- CALL FieldScatter FOR INPUT XZTS."
5953 call esmf_fieldscatter(xzts_input_grid, dummy2d, rootpet=0, rc=rc)
5954 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5957 if (localpet == 0)
then
5959 call nemsio_readrecv(gfile,
"zc",
"sfc", 1, dummy, 0, iret=rc)
5961 dummy2d = reshape(dummy, (/i_input,j_input/))
5962 print*,
'zc ',maxval(dummy2d),minval(dummy2d)
5965 print*,
"- CALL FieldScatter FOR INPUT Z_C."
5966 call esmf_fieldscatter(z_c_input_grid, dummy2d, rootpet=0, rc=rc)
5967 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5970 if (localpet == 0)
then
5974 print*,
"- CALL FieldScatter FOR INPUT ZM."
5975 call esmf_fieldscatter(zm_input_grid, dummy2d, rootpet=0, rc=rc)
5976 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5979 deallocate(dummy, dummy2d)
5981 if (localpet == 0) call nemsio_close(gfile)
5996 sfcdata, sfcdata_3d)
6000 CHARACTER(LEN=*),
INTENT(IN) :: field
6002 INTEGER,
INTENT(IN) :: imo, jmo, lmo, tile_num
6004 REAL(ESMF_KIND_R8),
INTENT(OUT),
OPTIONAL :: sfcdata(imo,jmo)
6005 REAL(ESMF_KIND_R8),
INTENT(OUT),
OPTIONAL :: sfcdata_3d(imo,jmo,lmo)
6007 CHARACTER(LEN=256) :: tilefile
6009 INTEGER :: error, ncid, id_var
6011 tilefile = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(tile_num))
6013 print*,
'WILL READ ',trim(field),
' FROM: ', trim(tilefile)
6015 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
6016 CALL
netcdf_err(error,
'OPENING: '//trim(tilefile) )
6018 error=nf90_inq_varid(ncid, field, id_var)
6021 IF (present(sfcdata_3d))
THEN
6022 error=nf90_get_var(ncid, id_var, sfcdata_3d)
6025 error=nf90_get_var(ncid, id_var, sfcdata)
6029 error = nf90_close(ncid)
6050 character(len=250),
intent(in) :: file
6051 character(len=10),
intent(in) :: inv
6052 integer,
intent(in) :: localpet
6053 real(esmf_kind_r8),
intent(inout),
allocatable :: u(:,:,:),v(:,:,:)
6055 real(esmf_kind_r4),
dimension(i_input,j_input) :: alpha
6056 real(esmf_kind_r8),
dimension(i_input,j_input) :: lon, lat
6057 real(esmf_kind_r4),
allocatable :: u_tmp(:,:),v_tmp(:,:)
6058 real(esmf_kind_r4),
dimension(i_input,j_input) :: ws,wd
6059 real(esmf_kind_r4) :: value_u, value_v,lov,latin1,latin2
6060 real(esmf_kind_r8) :: d2r
6062 integer :: varnum_u, varnum_v, vlev, &
6065 character(len=20) :: vname
6066 character(len=50) :: method_u, method_v
6067 character(len=250) :: file_coord
6068 character(len=10000) :: temp_msg
6070 d2r=acos(-1.0_esmf_kind_r8) / 180.0_esmf_kind_r8
6071 if (localpet==0)
then
6072 allocate(u(i_input,j_input,lev_input))
6073 allocate(v(i_input,j_input,lev_input))
6079 file_coord = trim(fix_dir_input_grid)//
"/latlon_grid3.32769.nc"
6082 call
get_var_cond(vname,this_miss_var_method=method_u, this_miss_var_value=value_u, &
6085 call
get_var_cond(vname,this_miss_var_method=method_v, this_miss_var_value=value_v, &
6088 if (trim(input_grid_type)==
"rotated_latlon")
then
6089 print*,
"- CALL FieldGather FOR INPUT GRID LONGITUDE"
6090 call esmf_fieldgather(longitude_input_grid, lon, rootpet=0, tile=1, rc=error)
6091 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6093 print*,
"- CALL FieldGather FOR INPUT GRID LATITUDE"
6094 call esmf_fieldgather(latitude_input_grid, lat, rootpet=0, tile=1, rc=error)
6095 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6098 if (localpet==0)
then
6099 print*,
"- CALCULATE ROTATION ANGLE FOR ROTATED_LATLON INPUT GRID"
6100 error = grb2_inq(file, inv,grid_desc=temp_msg)
6109 istr = index(temp_msg,
"lat-center ") + len(
"lat_center ")
6110 read(temp_msg(istr:istr+9),
"(F8.5)") latin1
6111 istr = index(temp_msg,
"lon-center ") + len(
"lon-center ")
6112 read(temp_msg(istr:istr+10),
"(F9.6)") lov
6114 print*,
"- CALL CALCALPHA_ROTLATLON with center lat,lon = ",latin1,lov
6116 print*,
" alpha min/max = ",minval(alpha),maxval(alpha)
6118 elseif (trim(input_grid_type) ==
"lambert")
then
6121 print*,
"- CALL FieldGather FOR INPUT GRID LONGITUDE"
6122 call esmf_fieldgather(longitude_input_grid, lon, rootpet=0, tile=1, rc=error)
6123 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6126 if (localpet==0)
then
6127 error = grb2_inq(file, inv,grid_desc=temp_msg)
6135 istr = index(temp_msg,
"LoV ") + len(
"LoV ")
6136 read(temp_msg(istr:istr+10),
"(F9.6)") lov
6137 istr = index(temp_msg,
"Latin1 ") + len(
"Latin1 ")
6138 read(temp_msg(istr:istr+9),
"(F8.5)") latin1
6139 istr = index(temp_msg,
"Latin2 ") + len(
"Latin2 ")
6140 read(temp_msg(istr:istr+9),
"(F8.5)") latin2
6142 print*,
"- CALL GRIDROT for LC grid with lov,latin1/2 = ",lov,latin1,latin2
6143 call
gridrot(lov,latin1,latin2,lon,alpha)
6144 print*,
" alpha min/max = ",minval(alpha),maxval(alpha)
6148 if (localpet==0)
then
6149 do vlev = 1, lev_input
6152 iret = grb2_inq(file,inv,vname,slevs(vlev),data2=u_tmp)
6154 call
handle_grib_error(vname, slevs(vlev),method_u,value_u,varnum_u,iret,var=u_tmp)
6156 call
error_handler(
"READING IN U AT LEVEL "//trim(slevs(vlev))//
". SET A FILL "// &
6157 "VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",iret)
6162 iret = grb2_inq(file,inv,vname,slevs(vlev),data2=v_tmp)
6164 call
handle_grib_error(vname, slevs(vlev),method_v,value_v,varnum_v,iret,var=v_tmp)
6166 call
error_handler(
"READING IN V AT LEVEL "//trim(slevs(vlev))//
". SET A FILL "// &
6167 "VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",iret)
6171 if (trim(input_grid_type) ==
"latlon")
then
6172 if (external_model ==
'UKMET')
then
6174 v(:,:,vlev) = (v_tmp(:,2:jp1_input) + v_tmp(:,1:j_input))/2
6179 else if (trim(input_grid_type) ==
"rotated_latlon")
then
6180 ws = sqrt(u_tmp**2 + v_tmp**2)
6181 wd = atan2(-u_tmp,-v_tmp) / d2r
6182 wd = wd + alpha + 180.0
6184 u(:,:,vlev) = -ws*cos(wd*d2r)
6185 v(:,:,vlev) = -ws*sin(wd*d2r)
6187 u(:,:,vlev) =
real(u_tmp * cos(alpha) + v_tmp * sin(alpha),esmf_kind_r8)
6188 v(:,:,vlev) =
real(v_tmp * cos(alpha) - u_tmp * sin(alpha),esmf_kind_r8)
6191 print*,
'max, min U ', minval(u(:,:,vlev)), maxval(u(:,:,vlev))
6192 print*,
'max, min V ', minval(v(:,:,vlev)), maxval(v(:,:,vlev))
6205 integer :: clb(4), cub(4)
6206 integer :: i, j, k, rc
6208 real(esmf_kind_r8) :: latrad, lonrad
6209 real(esmf_kind_r8),
pointer :: windptr(:,:,:,:)
6210 real(esmf_kind_r8),
pointer :: uptr(:,:,:)
6211 real(esmf_kind_r8),
pointer :: vptr(:,:,:)
6212 real(esmf_kind_r8),
pointer :: latptr(:,:)
6213 real(esmf_kind_r8),
pointer :: lonptr(:,:)
6215 print*,
"- CALL FieldGet FOR 3-D WIND."
6216 call esmf_fieldget(wind_input_grid, &
6217 computationallbound=clb, &
6218 computationalubound=cub, &
6219 farrayptr=windptr, rc=rc)
6220 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6223 print*,
"- CALL FieldGet FOR U."
6224 call esmf_fieldget(u_input_grid, &
6225 farrayptr=uptr, rc=rc)
6226 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6229 print*,
"- CALL FieldGet FOR V."
6230 call esmf_fieldget(v_input_grid, &
6231 farrayptr=vptr, rc=rc)
6232 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6235 print*,
"- CALL FieldGet FOR LATITUDE."
6236 call esmf_fieldget(latitude_input_grid, &
6237 farrayptr=latptr, rc=rc)
6238 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6241 print*,
"- CALL FieldGet FOR LONGITUDE."
6242 call esmf_fieldget(longitude_input_grid, &
6243 farrayptr=lonptr, rc=rc)
6244 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6247 do i = clb(1), cub(1)
6248 do j = clb(2), cub(2)
6249 latrad = latptr(i,j) * acos(-1.) / 180.0
6250 lonrad = lonptr(i,j) * acos(-1.) / 180.0
6251 do k = clb(3), cub(3)
6252 windptr(i,j,k,1) = uptr(i,j,k) * cos(lonrad) - vptr(i,j,k) * sin(latrad) * sin(lonrad)
6253 windptr(i,j,k,2) = uptr(i,j,k) * sin(lonrad) + vptr(i,j,k) * sin(latrad) * cos(lonrad)
6254 windptr(i,j,k,3) = vptr(i,j,k) * cos(latrad)
6259 call esmf_fielddestroy(u_input_grid, rc=rc)
6260 call esmf_fielddestroy(v_input_grid, rc=rc)
6283 real(esmf_kind_r4),
intent(in) :: lov,latin1,latin2
6284 real(esmf_kind_r4),
intent(inout) :: rot(i_input,j_input)
6285 real(esmf_kind_r8),
intent(in) :: lon(i_input,j_input)
6287 real(esmf_kind_r4) :: trot(i_input,j_input), tlon(i_input,j_input)
6288 real(esmf_kind_r4) :: dtor = 3.14159265359/180.0_esmf_kind_r4
6289 real(esmf_kind_r4) :: an
6295 if ( (latin1 - latin2) .lt. 0.000001 )
then
6296 an = sin(latin1*dtor)
6298 an = log( cos(latin1*dtor) / cos(latin2*dtor) ) / &
6299 log( tan(dtor*(90.0-latin1)/2.) / tan(dtor*(90.0-latin2)/2.))
6302 tlon = mod(lon - lov + 180. + 3600., 360.) - 180.
6323 real(esmf_kind_r8),
intent(in) :: latgrid(i_input,j_input), &
6324 longrid(i_input,j_input)
6325 real(esmf_kind_r4),
intent(in) :: cenlat, cenlon
6326 real(esmf_kind_r4),
intent(out) :: alpha(i_input,j_input)
6329 real(esmf_kind_r8) :: d2r,lon0_r,lat0_r,sphi0,cphi0
6330 real(esmf_kind_r8),
DIMENSION(i_input,j_input) :: tlat,tlon,tph,sinalpha
6332 d2r = acos(-1.0_esmf_kind_r8) / 180.0_esmf_kind_r8
6333 if (cenlon .lt. 0)
then
6334 lon0_r = (cenlon + 360.0)*d2r
6343 tlat = latgrid * d2r
6344 tlon = longrid * d2r
6347 tlon = -tlon + lon0_r
6348 tph = asin(cphi0*sin(tlat) - sphi0*cos(tlat)*cos(tlon))
6349 sinalpha = sphi0 * sin(tlon) / cos(tph)
6350 alpha = -asin(sinalpha)/d2r
6369 use,
intrinsic :: ieee_arithmetic
6373 real(esmf_kind_r4),
intent(in) :: value
6374 real(esmf_kind_r4),
intent(inout),
optional :: var(:,:)
6375 real(esmf_kind_r8),
intent(inout),
optional :: var8(:,:)
6376 real(esmf_kind_r8),
intent(inout),
optional :: var3d(:,:,:)
6378 character(len=20),
intent(in) :: vname, lev, method
6380 integer,
intent(in) :: varnum
6381 integer,
intent(inout) :: iret
6384 if (varnum == 9999)
then
6385 print*,
"WARNING: ", trim(vname),
" NOT FOUND AT LEVEL ", lev,
" IN EXTERNAL FILE ", &
6386 "AND NO ENTRY EXISTS IN VARMAP TABLE. VARIABLE WILL NOT BE USED."
6392 if (trim(method) ==
"skip" )
then
6393 print*,
"WARNING: SKIPPING ", trim(vname),
" IN FILE"
6394 read_from_input(varnum) = .false.
6396 elseif (trim(method) ==
"set_to_fill")
then
6397 print*,
"WARNING: ,", trim(vname),
" NOT AVILABLE AT LEVEL ", trim(lev), &
6398 ". SETTING EQUAL TO FILL VALUE OF ", value
6399 if(present(var)) var(:,:) = value
6400 if(present(var8)) var8(:,:) = value
6401 if(present(var3d)) var3d(:,:,:) = value
6402 elseif (trim(method) ==
"set_to_NaN")
then
6403 print*,
"WARNING: ,", trim(vname),
" NOT AVILABLE AT LEVEL ", trim(lev), &
6404 ". SETTING EQUAL TO NaNs"
6405 if(present(var)) var(:,:) = ieee_value(var,ieee_quiet_nan)
6406 if(present(var8)) var8(:,:) = ieee_value(var8,ieee_quiet_nan)
6407 if(present(var3d)) var3d(:,:,:) = ieee_value(var3d,ieee_quiet_nan)
6408 elseif (trim(method) ==
"stop")
then
6409 call
error_handler(
"READING "//trim(vname)//
" at level "//lev//
". TO MAKE THIS NON- &
6410 FATAL, CHANGE STOP TO SKIP FOR THIS VARIABLE IN YOUR VARMAP &
6413 call
error_handler(
"ERROR USING MISSING_VAR_METHOD. PLEASE SET VALUES IN" // &
6414 " VARMAP TABLE TO ONE OF: set_to_fill, set_to_NaN,"// &
6415 " , skip, or stop.", 1)
6434 character(len=*),
intent(in) :: the_file, inv_file
6435 character(len=20),
intent(in) :: vname,vname_file
6437 integer,
intent(out) :: rc
6439 real(esmf_kind_r8),
intent(inout) :: dummy3d(:,:,:)
6441 real(esmf_kind_r4),
allocatable :: dummy2d(:,:)
6442 real(esmf_kind_r4) :: value
6444 character(len=50) :: slevs(lsoil_input)
6445 character(len=50) :: method
6447 allocate(dummy2d(i_input,j_input))
6449 if(lsoil_input == 4)
then
6450 slevs = (/
character(24)::
':0-0.1 m below ground:',
':0.1-0.4 m below ground:', &
6451 ':0.4-1 m below ground:',
':1-2 m below ground:'/)
6452 elseif(lsoil_input == 9)
then
6453 slevs = (/
character(26)::
':0-0 m below ground',
':0.01-0.01 m below ground:',
':0.04-0.04 m below ground:', &
6454 ':0.1-0.1 m below ground:',
':0.3-0.3 m below ground:',
':0.6-0.6 m below ground:', &
6455 ':1-1 m below ground:',
':1.6-1.6 m below ground:',
':3-3 m below ground:'/)
6458 call
error_handler(
"reading soil levels. File must have 4 or 9 soil levels.", rc)
6461 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
6463 do i = 1,lsoil_input
6464 if (vname_file==
"var2_2_1_")
then
6465 rc = grb2_inq(the_file,inv_file,vname_file,
"_0_192:",slevs(i),data2=dummy2d)
6467 rc = grb2_inq(the_file,inv_file,vname_file,slevs(i),data2=dummy2d)
6471 if (rc==1 .and. trim(vname) /=
"soill")
then
6473 call
error_handler(
"READING IN "//trim(vname)//
". SET A FILL "// &
6474 "VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",rc)
6476 dummy3d(:,:,:) = 0.0_esmf_kind_r8
6481 dummy3d(:,:,i) =
real(dummy2d,esmf_kind_r8)
6497 print*,
'- DESTROY ATMOSPHERIC INPUT DATA.'
6499 call esmf_fielddestroy(terrain_input_grid, rc=rc)
6500 call esmf_fielddestroy(pres_input_grid, rc=rc)
6501 call esmf_fielddestroy(dzdt_input_grid, rc=rc)
6502 call esmf_fielddestroy(temp_input_grid, rc=rc)
6503 call esmf_fielddestroy(wind_input_grid, rc=rc)
6504 call esmf_fielddestroy(ps_input_grid, rc=rc)
6506 do n = 1, num_tracers_input
6507 call esmf_fielddestroy(tracers_input_grid(n), rc=rc)
6509 deallocate(tracers_input_grid)
6522 print*,
'- DESTROY NST INPUT DATA.'
6524 call esmf_fielddestroy(landsea_mask_input_grid, rc=rc)
6525 call esmf_fielddestroy(c_d_input_grid, rc=rc)
6526 call esmf_fielddestroy(c_0_input_grid, rc=rc)
6527 call esmf_fielddestroy(d_conv_input_grid, rc=rc)
6528 call esmf_fielddestroy(dt_cool_input_grid, rc=rc)
6529 call esmf_fielddestroy(ifd_input_grid, rc=rc)
6530 call esmf_fielddestroy(qrain_input_grid, rc=rc)
6531 call esmf_fielddestroy(tref_input_grid, rc=rc)
6532 call esmf_fielddestroy(w_d_input_grid, rc=rc)
6533 call esmf_fielddestroy(w_0_input_grid, rc=rc)
6534 call esmf_fielddestroy(xs_input_grid, rc=rc)
6535 call esmf_fielddestroy(xt_input_grid, rc=rc)
6536 call esmf_fielddestroy(xu_input_grid, rc=rc)
6537 call esmf_fielddestroy(xv_input_grid, rc=rc)
6538 call esmf_fielddestroy(xz_input_grid, rc=rc)
6539 call esmf_fielddestroy(xtts_input_grid, rc=rc)
6540 call esmf_fielddestroy(xzts_input_grid, rc=rc)
6541 call esmf_fielddestroy(z_c_input_grid, rc=rc)
6542 call esmf_fielddestroy(zm_input_grid, rc=rc)
6555 print*,
"- CALL FieldDestroy FOR INPUT GRID FIELDS."
6557 call esmf_fielddestroy(canopy_mc_input_grid, rc=rc)
6558 call esmf_fielddestroy(f10m_input_grid, rc=rc)
6559 call esmf_fielddestroy(ffmm_input_grid, rc=rc)
6560 if (.not. convert_nst)
then
6561 call esmf_fielddestroy(landsea_mask_input_grid, rc=rc)
6563 call esmf_fielddestroy(q2m_input_grid, rc=rc)
6564 call esmf_fielddestroy(seaice_depth_input_grid, rc=rc)
6565 call esmf_fielddestroy(seaice_fract_input_grid, rc=rc)
6566 call esmf_fielddestroy(seaice_skin_temp_input_grid, rc=rc)
6567 call esmf_fielddestroy(skin_temp_input_grid, rc=rc)
6568 call esmf_fielddestroy(snow_depth_input_grid, rc=rc)
6569 call esmf_fielddestroy(snow_liq_equiv_input_grid, rc=rc)
6570 call esmf_fielddestroy(soil_temp_input_grid, rc=rc)
6571 call esmf_fielddestroy(soil_type_input_grid, rc=rc)
6572 call esmf_fielddestroy(soilm_liq_input_grid, rc=rc)
6573 call esmf_fielddestroy(soilm_tot_input_grid, rc=rc)
6574 call esmf_fielddestroy(srflag_input_grid, rc=rc)
6575 call esmf_fielddestroy(t2m_input_grid, rc=rc)
6576 call esmf_fielddestroy(tprcp_input_grid, rc=rc)
6577 call esmf_fielddestroy(ustar_input_grid, rc=rc)
6578 call esmf_fielddestroy(veg_type_input_grid, rc=rc)
6579 call esmf_fielddestroy(z0_input_grid, rc=rc)
6580 call esmf_fielddestroy(terrain_input_grid, rc=rc)
6581 if (.not. vgfrc_from_climo)
then
6582 call esmf_fielddestroy(veg_greenness_input_grid, rc=rc)
6584 if (.not. minmax_vgfrc_from_climo)
then
6585 call esmf_fielddestroy(min_veg_greenness_input_grid, rc=rc)
6586 call esmf_fielddestroy(max_veg_greenness_input_grid, rc=rc)
6588 if (.not. lai_from_climo)
then
6589 call esmf_fielddestroy(lai_input_grid, rc=rc)
6606 x = a( (first+last) / 2 )
6617 t = a(i); a(i) = a(j); a(j) = t
6621 if (first < i-1) call
quicksort(a, first, i-1)
6622 if (j+1 < last) call
quicksort(a, j+1, last)
6641 real(esmf_kind_r8),
intent(inout) :: soilt(i_input,j_input,lsoil_input)
6642 real(esmf_kind_r8),
intent(in) :: skint(i_input,j_input)
6643 integer(esmf_kind_i4),
intent(in) :: landmask(i_input,j_input)
6650 if (landmask(i,j) == 0_esmf_kind_i4 )
then
6651 soilt(i,j,k) = skint(i,j)
6652 else if (landmask(i,j) == 1_esmf_kind_i4 .and. soilt(i,j,k) > 350.0_esmf_kind_r8)
then
6653 soilt(i,j,k) = skint(i,j)
6654 else if (landmask(i,j) == 2_esmf_kind_i4 )
then
6655 soilt(i,j,k) = icet_default
6671 real(esmf_kind_r4),
intent(inout) :: cnwat(i_input,j_input)
6673 real(esmf_kind_r4) :: max_cnwat = 0.5
6679 if (cnwat(i,j) .gt. max_cnwat) cnwat(i,j) = 0.0_esmf_kind_r4
Sets up the ESMF grid objects for the input data grid and target FV3 grid.
Replace undefined values with a valid value.
subroutine netcdf_err(err, string)
Error handler for netcdf.
character(len=len(strin)) function to_upper(strIn)
Convert string from lower to uppercase.
subroutine error_handler(string, rc)
General error handler.
This module contains code to read the setup namelist file, handle the varmap file for GRIB2 data...
subroutine rh2spfh(rh_sphum, p, t)
Convert relative humidity to specific humidity.
subroutine, public get_var_cond(var_name, this_miss_var_method, this_miss_var_value, this_field_var_name, loc)
Search the variable mapping table to find conditions for handling missing variables.
Utilities for use when reading grib2 data.
subroutine convert_omega(omega, p, t, q, clb, cub)
Convert omega to vertical velocity.
subroutine, public search(field, mask, idim, jdim, tile, field_num, latitude, terrain_land, soilt_climo)
Replace undefined surface values.
subroutine convert_winds
Convert 3-d component winds to u and v.