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, &
52 type(esmf_field
),
public :: dzdt_input_grid
53 type(esmf_field) :: dpres_input_grid
54 type(esmf_field),
public :: pres_input_grid
55 type(esmf_field),
public :: ps_input_grid
56 type(esmf_field),
public :: terrain_input_grid
57 type(esmf_field),
public :: temp_input_grid
59 type(esmf_field
),
public :: u_input_grid
60 type(esmf_field),
public :: v_input_grid
61 type(esmf_field),
public :: wind_input_grid
62 type(esmf_field),
allocatable,
public :: tracers_input_grid(:)
64 integer,
public :: lev_input
65 integer,
public :: levp1_input
69 integer,
public :: veg_type_landice_input = 15
72 integer,
parameter :: ICET_DEFAULT = 265.0
74 type(esmf_field),
public :: canopy_mc_input_grid
75 type(esmf_field),
public :: f10m_input_grid
76 type(esmf_field),
public :: ffmm_input_grid
78 type(esmf_field),
public :: landsea_mask_input_grid
80 type(esmf_field),
public :: q2m_input_grid
81 type(esmf_field),
public :: seaice_depth_input_grid
82 type(esmf_field),
public :: seaice_fract_input_grid
83 type(esmf_field),
public :: seaice_skin_temp_input_grid
84 type(esmf_field),
public :: skin_temp_input_grid
85 type(esmf_field),
public :: snow_depth_input_grid
86 type(esmf_field),
public :: snow_liq_equiv_input_grid
87 type(esmf_field),
public :: soil_temp_input_grid
88 type(esmf_field),
public :: soil_type_input_grid
89 type(esmf_field),
public :: soilm_liq_input_grid
90 type(esmf_field),
public :: soilm_tot_input_grid
91 type(esmf_field),
public :: srflag_input_grid
92 type(esmf_field),
public :: t2m_input_grid
93 type(esmf_field),
public :: tprcp_input_grid
94 type(esmf_field),
public :: ustar_input_grid
95 type(esmf_field),
public :: veg_type_input_grid
96 type(esmf_field),
public :: z0_input_grid
97 type(esmf_field),
public :: veg_greenness_input_grid
98 type(esmf_field),
public :: lai_input_grid
99 type(esmf_field),
public :: max_veg_greenness_input_grid
100 type(esmf_field),
public :: min_veg_greenness_input_grid
102 integer,
public :: lsoil_input=4
105 character(len=50),
private,
allocatable :: slevs(:)
109 type(esmf_field
),
public :: c_d_input_grid
110 type(esmf_field),
public :: c_0_input_grid
111 type(esmf_field),
public :: d_conv_input_grid
112 type(esmf_field),
public :: dt_cool_input_grid
113 type(esmf_field),
public :: ifd_input_grid
115 type(esmf_field),
public :: qrain_input_grid
116 type(esmf_field),
public :: tref_input_grid
117 type(esmf_field),
public :: w_d_input_grid
118 type(esmf_field),
public :: w_0_input_grid
119 type(esmf_field),
public :: xs_input_grid
120 type(esmf_field),
public :: xt_input_grid
121 type(esmf_field),
public :: xu_input_grid
122 type(esmf_field),
public :: xv_input_grid
123 type(esmf_field),
public :: xz_input_grid
124 type(esmf_field),
public :: xtts_input_grid
125 type(esmf_field),
public :: xzts_input_grid
126 type(esmf_field),
public :: z_c_input_grid
127 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
392 if (trim(input_type) ==
"restart")
then
400 elseif (trim(input_type) ==
"history" .or. trim(input_type) == &
401 "gaussian_netcdf")
then
409 elseif (trim(input_type) ==
"gaussian_nemsio")
then
417 elseif (trim(input_type) ==
"gfs_gaussian_nemsio")
then
425 elseif (trim(input_type) ==
"gfs_sigio")
then
433 elseif (trim(input_type) ==
"grib2")
then
450 print*,
"- INITIALIZE ATMOSPHERIC ESMF FIELDS."
452 print*,
"- CALL FieldCreate FOR INPUT GRID 3-D WIND."
453 wind_input_grid = esmf_fieldcreate(input_grid, &
454 typekind=esmf_typekind_r8, &
455 staggerloc=esmf_staggerloc_center, &
456 ungriddedlbound=(/1,1/), &
457 ungriddedubound=(/lev_input,3/), rc=rc)
458 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
461 print*,
"- CALL FieldCreate FOR INPUT GRID SURFACE PRESSURE."
462 ps_input_grid = esmf_fieldcreate(input_grid, &
463 typekind=esmf_typekind_r8, &
464 staggerloc=esmf_staggerloc_center, rc=rc)
465 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
468 print*,
"- CALL FieldCreate FOR INPUT GRID TERRAIN."
469 terrain_input_grid = esmf_fieldcreate(input_grid, &
470 typekind=esmf_typekind_r8, &
471 staggerloc=esmf_staggerloc_center, rc=rc)
472 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
475 print*,
"- CALL FieldCreate FOR INPUT GRID TEMPERATURE."
476 temp_input_grid = esmf_fieldcreate(input_grid, &
477 typekind=esmf_typekind_r8, &
478 staggerloc=esmf_staggerloc_center, &
479 ungriddedlbound=(/1/), &
480 ungriddedubound=(/lev_input/), rc=rc)
481 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
484 allocate(tracers_input_grid(num_tracers_input))
486 do i = 1, num_tracers_input
487 print*,
"- CALL FieldCreate FOR INPUT GRID TRACER ", trim(tracers_input(i))
488 tracers_input_grid(i) = esmf_fieldcreate(input_grid, &
489 typekind=esmf_typekind_r8, &
490 staggerloc=esmf_staggerloc_center, &
491 ungriddedlbound=(/1/), &
492 ungriddedubound=(/lev_input/), rc=rc)
493 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
497 print*,
"- CALL FieldCreate FOR INPUT GRID DZDT."
498 dzdt_input_grid = esmf_fieldcreate(input_grid, &
499 typekind=esmf_typekind_r8, &
500 staggerloc=esmf_staggerloc_center, &
501 ungriddedlbound=(/1/), &
502 ungriddedubound=(/lev_input/), rc=rc)
503 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
506 print*,
"- CALL FieldCreate FOR INPUT GRID U."
507 u_input_grid = esmf_fieldcreate(input_grid, &
508 typekind=esmf_typekind_r8, &
509 staggerloc=esmf_staggerloc_center, &
510 ungriddedlbound=(/1/), &
511 ungriddedubound=(/lev_input/), rc=rc)
512 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
515 print*,
"- CALL FieldCreate FOR INPUT GRID V."
516 v_input_grid = esmf_fieldcreate(input_grid, &
517 typekind=esmf_typekind_r8, &
518 staggerloc=esmf_staggerloc_center, &
519 ungriddedlbound=(/1/), &
520 ungriddedubound=(/lev_input/), rc=rc)
521 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
524 print*,
"- CALL FieldCreate FOR INPUT GRID PRESSURE."
525 pres_input_grid = esmf_fieldcreate(input_grid, &
526 typekind=esmf_typekind_r8, &
527 staggerloc=esmf_staggerloc_center, &
528 ungriddedlbound=(/1/), &
529 ungriddedubound=(/lev_input/), rc=rc)
530 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
544 print*,
"- CALL FieldCreate FOR INPUT GRID LANDSEA MASK."
545 landsea_mask_input_grid = esmf_fieldcreate(input_grid, &
546 typekind=esmf_typekind_r8, &
547 staggerloc=esmf_staggerloc_center, rc=rc)
548 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
551 print*,
"- CALL FieldCreate FOR INPUT GRID Z0."
552 z0_input_grid = esmf_fieldcreate(input_grid, &
553 typekind=esmf_typekind_r8, &
554 staggerloc=esmf_staggerloc_center, rc=rc)
555 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
558 print*,
"- CALL FieldCreate FOR INPUT GRID VEGETATION TYPE."
559 veg_type_input_grid = esmf_fieldcreate(input_grid, &
560 typekind=esmf_typekind_r8, &
561 staggerloc=esmf_staggerloc_center, rc=rc)
562 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
565 print*,
"- CALL FieldCreate FOR INPUT GRID CANOPY MOISTURE CONTENT."
566 canopy_mc_input_grid = esmf_fieldcreate(input_grid, &
567 typekind=esmf_typekind_r8, &
568 staggerloc=esmf_staggerloc_center, rc=rc)
569 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
572 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE FRACTION."
573 seaice_fract_input_grid = esmf_fieldcreate(input_grid, &
574 typekind=esmf_typekind_r8, &
575 staggerloc=esmf_staggerloc_center, rc=rc)
576 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
579 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE DEPTH."
580 seaice_depth_input_grid = esmf_fieldcreate(input_grid, &
581 typekind=esmf_typekind_r8, &
582 staggerloc=esmf_staggerloc_center, rc=rc)
583 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
586 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE SKIN TEMPERATURE."
587 seaice_skin_temp_input_grid = esmf_fieldcreate(input_grid, &
588 typekind=esmf_typekind_r8, &
589 staggerloc=esmf_staggerloc_center, rc=rc)
590 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
593 print*,
"- CALL FieldCreate FOR INPUT GRID SNOW DEPTH."
594 snow_depth_input_grid = esmf_fieldcreate(input_grid, &
595 typekind=esmf_typekind_r8, &
596 staggerloc=esmf_staggerloc_center, rc=rc)
597 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
600 print*,
"- CALL FieldCreate FOR INPUT GRID SNOW LIQUID EQUIVALENT."
601 snow_liq_equiv_input_grid = esmf_fieldcreate(input_grid, &
602 typekind=esmf_typekind_r8, &
603 staggerloc=esmf_staggerloc_center, rc=rc)
604 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
607 print*,
"- CALL FieldCreate FOR INPUT GRID T2M."
608 t2m_input_grid = esmf_fieldcreate(input_grid, &
609 typekind=esmf_typekind_r8, &
610 staggerloc=esmf_staggerloc_center, rc=rc)
611 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
614 print*,
"- CALL FieldCreate FOR INPUT GRID Q2M."
615 q2m_input_grid = esmf_fieldcreate(input_grid, &
616 typekind=esmf_typekind_r8, &
617 staggerloc=esmf_staggerloc_center, rc=rc)
618 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
621 print*,
"- CALL FieldCreate FOR INPUT GRID TPRCP."
622 tprcp_input_grid = esmf_fieldcreate(input_grid, &
623 typekind=esmf_typekind_r8, &
624 staggerloc=esmf_staggerloc_center, rc=rc)
625 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
628 print*,
"- CALL FieldCreate FOR INPUT GRID F10M."
629 f10m_input_grid = esmf_fieldcreate(input_grid, &
630 typekind=esmf_typekind_r8, &
631 staggerloc=esmf_staggerloc_center, rc=rc)
632 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
635 print*,
"- CALL FieldCreate FOR INPUT GRID USTAR."
636 ustar_input_grid = esmf_fieldcreate(input_grid, &
637 typekind=esmf_typekind_r8, &
638 staggerloc=esmf_staggerloc_center, rc=rc)
639 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
642 print*,
"- CALL FieldCreate FOR INPUT GRID FFMM."
643 ffmm_input_grid = esmf_fieldcreate(input_grid, &
644 typekind=esmf_typekind_r8, &
645 staggerloc=esmf_staggerloc_center, rc=rc)
646 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
649 print*,
"- CALL FieldCreate FOR INPUT GRID SRFLAG."
650 srflag_input_grid = esmf_fieldcreate(input_grid, &
651 typekind=esmf_typekind_r8, &
652 staggerloc=esmf_staggerloc_center, rc=rc)
653 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
656 print*,
"- CALL FieldCreate FOR INPUT SKIN TEMPERATURE."
657 skin_temp_input_grid = esmf_fieldcreate(input_grid, &
658 typekind=esmf_typekind_r8, &
659 staggerloc=esmf_staggerloc_center, rc=rc)
660 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
663 print*,
"- CALL FieldCreate FOR INPUT SOIL TYPE."
664 soil_type_input_grid = esmf_fieldcreate(input_grid, &
665 typekind=esmf_typekind_r8, &
666 staggerloc=esmf_staggerloc_center, rc=rc)
667 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
670 print*,
"- CALL FieldCreate FOR INPUT TERRAIN."
671 terrain_input_grid = esmf_fieldcreate(input_grid, &
672 typekind=esmf_typekind_r8, &
673 staggerloc=esmf_staggerloc_center, rc=rc)
674 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
677 print*,
"- CALL FieldCreate FOR INPUT SOIL TEMPERATURE."
678 soil_temp_input_grid = esmf_fieldcreate(input_grid, &
679 typekind=esmf_typekind_r8, &
680 staggerloc=esmf_staggerloc_center, &
681 ungriddedlbound=(/1/), &
682 ungriddedubound=(/lsoil_input/), rc=rc)
683 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
686 print*,
"- CALL FieldCreate FOR INPUT TOTAL SOIL MOISTURE."
687 soilm_tot_input_grid = esmf_fieldcreate(input_grid, &
688 typekind=esmf_typekind_r8, &
689 staggerloc=esmf_staggerloc_center, &
690 ungriddedlbound=(/1/), &
691 ungriddedubound=(/lsoil_input/), rc=rc)
692 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
695 print*,
"- CALL FieldCreate FOR INPUT LIQUID SOIL MOISTURE."
696 soilm_liq_input_grid = esmf_fieldcreate(input_grid, &
697 typekind=esmf_typekind_r8, &
698 staggerloc=esmf_staggerloc_center, &
699 ungriddedlbound=(/1/), &
700 ungriddedubound=(/lsoil_input/), rc=rc)
701 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
706 if (.not. vgfrc_from_climo)
then
707 print*,
"- CALL FieldCreate FOR INPUT VEGETATION GREENNESS."
708 veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
709 typekind=esmf_typekind_r8, &
710 staggerloc=esmf_staggerloc_center, rc=rc)
711 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
715 if (.not. minmax_vgfrc_from_climo)
then
716 print*,
"- CALL FieldCreate FOR INPUT MIN VEGETATION GREENNESS."
717 min_veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
718 typekind=esmf_typekind_r8, &
719 staggerloc=esmf_staggerloc_center, rc=rc)
720 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
723 print*,
"- CALL FieldCreate FOR INPUT MAX VEGETATION GREENNESS."
724 max_veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
725 typekind=esmf_typekind_r8, &
726 staggerloc=esmf_staggerloc_center, rc=rc)
727 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
731 if (.not. lai_from_climo)
then
732 print*,
"- CALL FieldCreate FOR INPUT LEAF AREA INDEX."
733 lai_input_grid = esmf_fieldcreate(input_grid, &
734 typekind=esmf_typekind_r8, &
735 staggerloc=esmf_staggerloc_center, rc=rc)
736 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
752 integer,
intent(in) :: localpet
754 character(len=300) :: the_file
756 integer(sigio_intkind) :: iret
757 integer :: rc, i, j, k
758 integer :: clb(3), cub(3)
760 real(esmf_kind_r8) :: ak, bk
761 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
762 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
763 real(esmf_kind_r8),
allocatable :: dummy3d2(:,:,:)
764 real(esmf_kind_r8),
pointer :: pptr(:,:,:), psptr(:,:)
765 real(esmf_kind_r8),
allocatable :: pi(:,:,:)
767 type(sigio_head
) :: sighead
768 type(sigio_dbta
) :: sigdata
770 the_file = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
772 print*,
"- ATMOSPHERIC DATA IN SIGIO FORMAT."
773 print*,
"- OPEN AND READ: ", trim(the_file)
775 call sigio_sropen(21, trim(the_file), iret)
780 call sigio_srhead(21, sighead, iret)
786 lev_input = sighead%levs
787 levp1_input = lev_input + 1
789 if (num_tracers_input /= sighead%ntrac)
then
793 if (sighead%idvt == 0 .or. sighead%idvt == 21)
then
794 if (trim(tracers_input(1)) /=
'spfh' .or. &
795 trim(tracers_input(2)) /=
'o3mr' .or. &
796 trim(tracers_input(3)) /=
'clwmr')
then
797 call
error_handler(
"TRACERS SELECTED DO NOT MATCH FILE CONTENTS.", 99)
800 print*,
'- UNRECOGNIZED IDVT: ', sighead%idvt
810 if (localpet == 0)
then
811 allocate(dummy2d(i_input,j_input))
812 allocate(dummy3d(i_input,j_input,lev_input))
813 allocate(dummy3d2(i_input,j_input,lev_input))
815 allocate(dummy2d(0,0))
816 allocate(dummy3d(0,0,0))
817 allocate(dummy3d2(0,0,0))
820 if (localpet == 0)
then
821 call sigio_aldbta(sighead, sigdata, iret)
826 call sigio_srdbta(21, sighead, sigdata, iret)
831 call sptez(0,sighead%jcap,4,i_input, j_input, sigdata%ps, dummy2d, 1)
832 dummy2d = exp(dummy2d) * 1000.0
833 print*,
'surface pres ',maxval(dummy2d),minval(dummy2d)
836 print*,
"- CALL FieldScatter FOR SURFACE PRESSURE."
837 call esmf_fieldscatter(ps_input_grid, dummy2d, rootpet=0, rc=rc)
838 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
841 if (localpet == 0)
then
842 call sptez(0,sighead%jcap,4,i_input, j_input, sigdata%hs, dummy2d, 1)
843 print*,
'terrain ',maxval(dummy2d),minval(dummy2d)
846 print*,
"- CALL FieldScatter FOR TERRAIN."
847 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
848 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
851 do k = 1, num_tracers_input
853 if (localpet == 0)
then
854 call sptezm(0,sighead%jcap,4,i_input, j_input, lev_input, sigdata%q(:,:,k), dummy3d, 1)
855 print*,trim(tracers_input(k)),maxval(dummy3d),minval(dummy3d)
858 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(k))
859 call esmf_fieldscatter(tracers_input_grid(k), dummy3d, rootpet=0, rc=rc)
860 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
865 if (localpet == 0)
then
866 call sptezm(0,sighead%jcap,4,i_input, j_input, lev_input, sigdata%t, dummy3d, 1)
867 print*,
'temp ',maxval(dummy3d),minval(dummy3d)
870 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
871 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
872 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
880 if (localpet == 0)
then
881 print*,
"- NO VERTICAL VELOCITY RECORD. SET TO ZERO."
885 print*,
"- CALL FieldScatter FOR INPUT DZDT."
886 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
887 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
890 if (localpet == 0)
then
891 call sptezmv(0, sighead%jcap, 4, i_input, j_input, lev_input, sigdata%d, sigdata%z, dummy3d, dummy3d2, 1)
892 print*,
'u ',maxval(dummy3d),minval(dummy3d)
893 print*,
'v ',maxval(dummy3d2),minval(dummy3d2)
896 print*,
"- CALL FieldScatter FOR INPUT U-WIND."
897 call esmf_fieldscatter(u_input_grid, dummy3d, rootpet=0, rc=rc)
898 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
901 print*,
"- CALL FieldScatter FOR INPUT V-WIND."
902 call esmf_fieldscatter(v_input_grid, dummy3d2, rootpet=0, rc=rc)
903 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
906 deallocate(dummy2d, dummy3d, dummy3d2)
908 if (localpet == 0) call sigio_axdbta(sigdata, iret)
910 call sigio_sclose(21, iret)
922 print*,
"- COMPUTE 3-D PRESSURE."
924 print*,
"- CALL FieldGet FOR 3-D PRES."
926 call esmf_fieldget(pres_input_grid, &
927 computationallbound=clb, &
928 computationalubound=cub, &
929 farrayptr=pptr, rc=rc)
930 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
933 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
935 call esmf_fieldget(ps_input_grid, &
936 farrayptr=psptr, rc=rc)
937 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
944 allocate(pi(clb(1):cub(1),clb(2):cub(2),1:levp1_input),stat=rc)
947 ak = sighead%vcoord(k,1)
948 bk = sighead%vcoord(k,2)
951 pi(i,j,k) = ak + bk*psptr(i,j)
956 if (localpet == 0)
then
957 print*,
'pres int ',psptr(clb(1),clb(2)),pi(clb(1),clb(2),:)
967 pptr(i,j,k) = (pi(i,j,k)+pi(i,j,k+1))/2.0_esmf_kind_r8
974 if (localpet == 0)
then
975 print*,
'pres ',psptr(clb(1),clb(2)),pptr(clb(1),clb(2),:)
989 integer,
intent(in) :: localpet
991 character(len=300) :: the_file
992 character(len=20) :: vlevtyp, vname
994 integer(nemsio_intkind) :: vlev, iret
995 integer :: i, j, k, n, rc
996 integer :: clb(3), cub(3)
998 real(nemsio_realkind),
allocatable :: vcoord(:,:,:)
999 real(nemsio_realkind),
allocatable :: dummy(:)
1000 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
1001 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
1002 real(esmf_kind_r8) :: ak, bk
1003 real(esmf_kind_r8),
allocatable :: pi(:,:,:)
1004 real(esmf_kind_r8),
pointer :: pptr(:,:,:), psptr(:,:)
1006 type(nemsio_gfile
) :: gfile
1008 the_file = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
1010 print*,
"- READ ATMOS DATA FROM SPECTRAL GFS NEMSIO FILE: ", trim(the_file)
1012 print*,
"- OPEN FILE."
1013 call nemsio_open(gfile, the_file,
"read", iret=iret)
1014 if (iret /= 0) call
error_handler(
"OPENING SPECTRAL GFS NEMSIO ATM FILE.", iret)
1016 print*,
"- READ NUMBER OF VERTICAL LEVELS."
1017 call nemsio_getfilehead(gfile, iret=iret, dimz=lev_input)
1018 if (iret /= 0) call
error_handler(
"READING NUMBER OF VERTICAL LEVLES.", iret)
1020 levp1_input = lev_input + 1
1022 allocate(vcoord(levp1_input,3,2))
1024 print*,
"- READ VERTICAL COORDINATE INFO."
1025 call nemsio_getfilehead(gfile, iret=iret, vcoord=vcoord)
1026 if (iret /= 0) call
error_handler(
"READING VERTICAL COORDINATE INFO.", iret)
1034 if (localpet == 0)
then
1035 allocate(dummy(i_input*j_input))
1036 allocate(dummy2d(i_input,j_input))
1037 allocate(dummy3d(i_input,j_input,lev_input))
1040 allocate(dummy2d(0,0))
1041 allocate(dummy3d(0,0,0))
1049 if (localpet == 0)
then
1050 print*,
"- READ TEMPERATURE."
1052 vlevtyp =
"mid layer"
1053 do vlev = 1, lev_input
1054 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1055 if (iret /= 0) call
error_handler(
"READING TEMPERATURE RECORD.", iret)
1056 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1061 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
1062 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
1063 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1066 do n = 1, num_tracers_input
1068 if (localpet == 0)
then
1069 print*,
"- READ ", trim(tracers_input(n))
1070 vname = trim(tracers_input(n))
1071 vlevtyp =
"mid layer"
1072 do vlev = 1, lev_input
1073 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1074 if (iret /= 0) call
error_handler(
"READING TRACER RECORD.", iret)
1076 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1080 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(n))
1081 call esmf_fieldscatter(tracers_input_grid(n), dummy3d, rootpet=0, rc=rc)
1082 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1087 if (localpet == 0)
then
1088 print*,
"- READ U-WINDS."
1090 vlevtyp =
"mid layer"
1091 do vlev = 1, lev_input
1092 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1093 if (iret /= 0) call
error_handler(
"READING U-WIND RECORD.", iret)
1095 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1099 print*,
"- CALL FieldScatter FOR INPUT U-WIND."
1100 call esmf_fieldscatter(u_input_grid, dummy3d, rootpet=0, rc=rc)
1101 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1104 if (localpet == 0)
then
1105 print*,
"- READ V-WINDS."
1107 vlevtyp =
"mid layer"
1108 do vlev = 1, lev_input
1109 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1110 if (iret /= 0) call
error_handler(
"READING V-WIND RECORD.", iret)
1112 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1116 print*,
"- CALL FieldScatter FOR INPUT V-WIND."
1117 call esmf_fieldscatter(v_input_grid, dummy3d, rootpet=0, rc=rc)
1118 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1126 if (localpet == 0)
then
1127 print*,
"- NO VERTICAL VELOCITY RECORD. SET TO ZERO."
1131 print*,
"- CALL FieldScatter FOR INPUT DZDT."
1132 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
1133 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1136 if (localpet == 0)
then
1137 print*,
"- READ HGT."
1141 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1142 if (iret /= 0) call
error_handler(
"READING HGT RECORD.", iret)
1144 dummy2d = reshape(dummy, (/i_input,j_input/))
1147 print*,
"- CALL FieldScatter FOR TERRAIN."
1148 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
1149 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1152 if (localpet == 0)
then
1153 print*,
"- READ PRES."
1157 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1158 if (iret /= 0) call
error_handler(
"READING PRES RECORD.", iret)
1160 dummy2d = reshape(dummy, (/i_input,j_input/))
1163 print*,
"- CALL FieldScatter FOR SURFACE PRESSURE."
1164 call esmf_fieldscatter(ps_input_grid, dummy2d, rootpet=0, rc=rc)
1165 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1168 call nemsio_close(gfile)
1170 deallocate(dummy, dummy2d, dummy3d)
1182 print*,
"- COMPUTE 3-D PRESSURE."
1184 print*,
"- CALL FieldGet FOR 3-D PRES."
1186 call esmf_fieldget(pres_input_grid, &
1187 computationallbound=clb, &
1188 computationalubound=cub, &
1189 farrayptr=pptr, rc=rc)
1190 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1193 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
1195 call esmf_fieldget(ps_input_grid, &
1196 farrayptr=psptr, rc=rc)
1197 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1204 allocate(pi(clb(1):cub(1),clb(2):cub(2),1:levp1_input))
1209 do i= clb(1), cub(1)
1210 do j= clb(2), cub(2)
1211 pi(i,j,k) = ak + bk*psptr(i,j)
1223 do i= clb(1), cub(1)
1224 do j= clb(2), cub(2)
1225 pptr(i,j,k) = (pi(i,j,k)+pi(i,j,k+1))/2.0
1242 integer,
intent(in) :: localpet
1244 character(len=300) :: the_file
1245 character(len=20) :: vlevtyp, vname
1247 integer :: i, j, k, n
1248 integer :: rc, clb(3), cub(3)
1249 integer(nemsio_intkind) :: vlev, iret
1251 real(nemsio_realkind),
allocatable :: vcoord(:,:,:)
1252 real(nemsio_realkind),
allocatable :: dummy(:)
1253 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
1254 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
1255 real(esmf_kind_r8),
pointer :: presptr(:,:,:), psptr(:,:)
1256 real(esmf_kind_r8),
pointer :: dpresptr(:,:,:)
1257 real(esmf_kind_r8),
allocatable :: pres_interface(:)
1259 type(nemsio_gfile
) :: gfile
1261 the_file = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
1263 print*,
"- READ ATMOS DATA FROM GAUSSIAN NEMSIO FILE: ", trim(the_file)
1265 print*,
"- OPEN FILE."
1266 call nemsio_open(gfile, the_file,
"read", iret=iret)
1267 if (iret /= 0) call
error_handler(
"OPENING GAUSSIAN NEMSIO ATM FILE.", iret)
1269 print*,
"- READ NUMBER OF VERTICAL LEVELS."
1270 call nemsio_getfilehead(gfile, iret=iret, dimz=lev_input)
1271 if (iret /= 0) call
error_handler(
"READING NUMBER OF VERTICAL LEVLES.", iret)
1273 levp1_input = lev_input + 1
1275 allocate(vcoord(levp1_input,3,2))
1277 print*,
"- READ VERTICAL COORDINATE INFO."
1278 call nemsio_getfilehead(gfile, iret=iret, vcoord=vcoord)
1279 if (iret /= 0) call
error_handler(
"READING VERTICAL COORDINATE INFO.", iret)
1287 print*,
"- CALL FieldCreate FOR INPUT DPRES."
1288 dpres_input_grid = esmf_fieldcreate(input_grid, &
1289 typekind=esmf_typekind_r8, &
1290 staggerloc=esmf_staggerloc_center, &
1291 ungriddedlbound=(/1/), &
1292 ungriddedubound=(/lev_input/), rc=rc)
1293 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1296 if (localpet == 0)
then
1297 allocate(dummy(i_input*j_input))
1298 allocate(dummy2d(i_input,j_input))
1299 allocate(dummy3d(i_input,j_input,lev_input))
1302 allocate(dummy2d(0,0))
1303 allocate(dummy3d(0,0,0))
1311 if (localpet == 0)
then
1312 print*,
"- READ TEMPERATURE."
1314 vlevtyp =
"mid layer"
1315 do vlev = 1, lev_input
1316 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1317 if (iret /= 0) call
error_handler(
"READING TEMPERATURE RECORD.", iret)
1318 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1319 print*,
'temp check after read ',vlev, dummy3d(1,1,vlev)
1323 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
1324 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
1325 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1328 do n = 1, num_tracers_input
1330 if (localpet == 0)
then
1331 print*,
"- READ ", trim(tracers_input(n))
1332 vname = trim(tracers_input(n))
1333 vlevtyp =
"mid layer"
1334 do vlev = 1, lev_input
1335 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1336 if (iret /= 0) call
error_handler(
"READING TRACER RECORD.", iret)
1337 print*,
'tracer ',vlev, maxval(dummy),minval(dummy)
1338 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1342 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(n))
1343 call esmf_fieldscatter(tracers_input_grid(n), dummy3d, rootpet=0, rc=rc)
1344 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1349 if (localpet == 0)
then
1350 print*,
"- READ U-WINDS."
1352 vlevtyp =
"mid layer"
1353 do vlev = 1, lev_input
1354 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1355 if (iret /= 0) call
error_handler(
"READING U-WIND RECORD.", iret)
1356 print*,
'ugrd ',vlev, maxval(dummy),minval(dummy)
1357 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1361 print*,
"- CALL FieldScatter FOR INPUT U-WIND."
1362 call esmf_fieldscatter(u_input_grid, dummy3d, rootpet=0, rc=rc)
1363 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1366 if (localpet == 0)
then
1367 print*,
"- READ V-WINDS."
1369 vlevtyp =
"mid layer"
1370 do vlev = 1, lev_input
1371 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1372 if (iret /= 0) call
error_handler(
"READING V-WIND RECORD.", iret)
1373 print*,
'vgrd ',vlev, maxval(dummy),minval(dummy)
1374 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1378 print*,
"- CALL FieldScatter FOR INPUT V-WIND."
1379 call esmf_fieldscatter(v_input_grid, dummy3d, rootpet=0, rc=rc)
1380 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1383 if (localpet == 0)
then
1384 print*,
"- READ DPRES."
1386 vlevtyp =
"mid layer"
1387 do vlev = 1, lev_input
1388 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1389 if (iret /= 0) call
error_handler(
"READING DPRES RECORD.", iret)
1390 print*,
'dpres ',vlev, maxval(dummy),minval(dummy)
1391 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1395 print*,
"- CALL FieldScatter FOR INPUT DPRES."
1396 call esmf_fieldscatter(dpres_input_grid, dummy3d, rootpet=0, rc=rc)
1397 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1400 if (localpet == 0)
then
1401 print*,
"- READ DZDT."
1403 vlevtyp =
"mid layer"
1404 do vlev = 1, lev_input
1405 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1406 if (iret /= 0) call
error_handler(
"READING DZDT RECORD.", iret)
1407 print*,
'dzdt ',vlev, maxval(dummy),minval(dummy)
1408 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1412 print*,
"- CALL FieldScatter FOR INPUT DZDT."
1413 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
1414 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1417 if (localpet == 0)
then
1418 print*,
"- READ HGT."
1422 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1423 if (iret /= 0) call
error_handler(
"READING HGT RECORD.", iret)
1424 print*,
'hgt ',vlev, maxval(dummy),minval(dummy)
1425 dummy2d = reshape(dummy, (/i_input,j_input/))
1428 print*,
"- CALL FieldScatter FOR TERRAIN."
1429 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
1430 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1433 call nemsio_close(gfile)
1435 deallocate(dummy, dummy2d, dummy3d)
1451 print*,
"- COMPUTE 3-D PRESSURE."
1453 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
1455 call esmf_fieldget(dpres_input_grid, &
1456 computationallbound=clb, &
1457 computationalubound=cub, &
1458 farrayptr=dpresptr, rc=rc)
1459 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1462 print*,
"- CALL FieldGet FOR 3-D PRESSURE."
1464 call esmf_fieldget(pres_input_grid, &
1465 farrayptr=presptr, rc=rc)
1466 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1469 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
1471 call esmf_fieldget(ps_input_grid, &
1472 farrayptr=psptr, rc=rc)
1473 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1476 allocate(pres_interface(levp1_input))
1478 if (localpet == 0)
then
1479 do k = clb(3), cub(3)
1480 print*,
'dpres is ',cub(1),cub(2),k, dpresptr(cub(1),cub(2),k)
1484 do i = clb(1), cub(1)
1485 do j = clb(2), cub(2)
1486 pres_interface(levp1_input) = vcoord(levp1_input,1,1)
1487 do k = lev_input, 1, -1
1488 pres_interface(k) = pres_interface(k+1) + dpresptr(i,j,k)
1490 psptr(i,j) = pres_interface(1)
1492 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
1499 if (localpet == 0)
then
1500 print*,
'psfc is ',clb(1),clb(2),psptr(clb(1),clb(2))
1501 print*,
'pres is ',clb(1),clb(2),presptr(clb(1),clb(2),:)
1504 print*,
'pres check 1',localpet,maxval(presptr(:,:,1)),minval(presptr(:,:,1))
1505 print*,
'pres check lev',localpet,maxval(presptr(:,:,lev_input)),minval(presptr(:,:,lev_input))
1507 deallocate(pres_interface)
1509 call esmf_fielddestroy(dpres_input_grid, rc=rc)
1525 integer,
intent(in) :: localpet
1527 character(len=500) :: tilefile
1530 integer :: clb(3), cub(3)
1531 integer :: rc, tile, ncid, id_var
1532 integer :: error, id_dim
1534 real(esmf_kind_r8),
allocatable :: ak(:)
1535 real(esmf_kind_r8),
pointer :: presptr(:,:,:), psptr(:,:)
1536 real(esmf_kind_r8),
pointer :: dpresptr(:,:,:)
1537 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
1538 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
1539 real(esmf_kind_r8),
allocatable :: pres_interface(:)
1545 tilefile = trim(data_dir_input_grid) //
"/" // trim(atm_core_files_input_grid(7))
1546 print*,
"- READ ATM VERTICAL LEVELS FROM: ", trim(tilefile)
1547 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1548 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1550 error=nf90_inq_dimid(ncid,
'xaxis_1', id_dim)
1551 call
netcdf_err(error,
'reading xaxis_1 id' )
1552 error=nf90_inquire_dimension(ncid,id_dim,len=levp1_input)
1553 call
netcdf_err(error,
'reading xaxis_1 value' )
1555 lev_input = levp1_input - 1
1557 allocate(ak(levp1_input))
1559 error=nf90_inq_varid(ncid,
'ak', id_var)
1561 error=nf90_get_var(ncid, id_var, ak)
1564 error = nf90_close(ncid)
1572 print*,
"- CALL FieldCreate FOR INPUT GRID DELTA PRESSURE."
1573 dpres_input_grid = esmf_fieldcreate(input_grid, &
1574 typekind=esmf_typekind_r8, &
1575 staggerloc=esmf_staggerloc_center, &
1576 ungriddedlbound=(/1/), &
1577 ungriddedubound=(/lev_input/), rc=rc)
1578 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1581 if (localpet < num_tiles_input_grid)
then
1582 allocate(data_one_tile_3d(i_input,j_input,lev_input))
1583 allocate(data_one_tile(i_input,j_input))
1585 allocate(data_one_tile_3d(0,0,0))
1586 allocate(data_one_tile(0,0))
1589 if (localpet < num_tiles_input_grid)
then
1591 tilefile= trim(data_dir_input_grid) //
"/" // trim(atm_core_files_input_grid(tile))
1592 print*,
"- READ ATMOSPHERIC CORE FILE: ", trim(tilefile)
1593 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1594 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1597 if (localpet < num_tiles_input_grid)
then
1598 error=nf90_inq_varid(ncid,
'phis', id_var)
1600 error=nf90_get_var(ncid, id_var, data_one_tile)
1602 data_one_tile = data_one_tile / 9.806_8
1605 do tile = 1, num_tiles_input_grid
1606 print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN for tile ",tile
1607 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=tile-1, tile=tile, rc=rc)
1608 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1612 if (localpet < num_tiles_input_grid)
then
1620 data_one_tile_3d = 0.0_8
1623 do tile = 1, num_tiles_input_grid
1624 print*,
"- CALL FieldScatter FOR INPUT GRID VERTICAL VELOCITY for tile ",tile
1625 call esmf_fieldscatter(dzdt_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1626 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1630 if (localpet < num_tiles_input_grid)
then
1631 error=nf90_inq_varid(ncid,
'T', id_var)
1633 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1635 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1638 do tile = 1, num_tiles_input_grid
1639 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
1640 call esmf_fieldscatter(temp_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1641 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1645 if (localpet < num_tiles_input_grid)
then
1646 error=nf90_inq_varid(ncid,
'delp', id_var)
1648 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1650 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1653 do tile = 1, num_tiles_input_grid
1654 print*,
"- CALL FieldScatter FOR INPUT DELTA PRESSURE."
1655 call esmf_fieldscatter(dpres_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1656 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1660 if (localpet < num_tiles_input_grid)
then
1661 error=nf90_inq_varid(ncid,
'ua', id_var)
1663 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1665 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1668 do tile = 1, num_tiles_input_grid
1669 print*,
"- CALL FieldScatter FOR INPUT GRID U."
1670 call esmf_fieldscatter(u_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1671 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1675 if (localpet < num_tiles_input_grid)
then
1676 error=nf90_inq_varid(ncid,
'va', id_var)
1678 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1680 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1683 do tile = 1, num_tiles_input_grid
1684 print*,
"- CALL FieldScatter FOR INPUT GRID V."
1685 call esmf_fieldscatter(v_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1686 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1690 if (localpet < num_tiles_input_grid) error = nf90_close(ncid)
1692 if (localpet < num_tiles_input_grid)
then
1694 tilefile= trim(data_dir_input_grid) //
"/" // trim(atm_tracer_files_input_grid(tile))
1695 print*,
"- READ ATMOSPHERIC TRACER FILE: ", trim(tilefile)
1696 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1697 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1700 do i = 1, num_tracers_input
1702 if (localpet < num_tiles_input_grid)
then
1703 error=nf90_inq_varid(ncid, tracers_input(i), id_var)
1705 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1707 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1710 do tile = 1, num_tiles_input_grid
1711 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(i))
1712 call esmf_fieldscatter(tracers_input_grid(i), data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1713 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1719 if (localpet < num_tiles_input_grid) error=nf90_close(ncid)
1731 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
1732 call esmf_fieldget(ps_input_grid, &
1733 farrayptr=psptr, rc=rc)
1734 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1737 print*,
"- CALL FieldGet FOR PRESSURE."
1738 call esmf_fieldget(pres_input_grid, &
1739 computationallbound=clb, &
1740 computationalubound=cub, &
1741 farrayptr=presptr, rc=rc)
1742 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1745 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
1746 call esmf_fieldget(dpres_input_grid, &
1747 farrayptr=dpresptr, rc=rc)
1748 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1751 allocate(pres_interface(levp1_input))
1753 do i = clb(1), cub(1)
1754 do j = clb(2), cub(2)
1755 pres_interface(levp1_input) = ak(1)
1756 do k = (levp1_input-1), 1, -1
1757 pres_interface(k) = pres_interface(k+1) + dpresptr(i,j,k)
1760 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
1762 psptr(i,j) = pres_interface(1)
1767 deallocate(pres_interface)
1769 call esmf_fielddestroy(dpres_input_grid, rc=rc)
1771 deallocate(data_one_tile_3d, data_one_tile)
1786 integer,
intent(in) :: localpet
1788 character(len=500) :: tilefile
1790 integer :: start(3), count(3), iscnt
1791 integer :: error, ncid, num_tracers_file
1792 integer :: id_dim, idim_input, jdim_input
1793 integer :: id_var, rc, nprocs, max_procs
1794 integer :: kdim, remainder, myrank, i, j, k, n
1795 integer :: clb(3), cub(3)
1796 integer,
allocatable :: kcount(:), startk(:), displ(:)
1797 integer,
allocatable :: ircnt(:)
1799 real(esmf_kind_r8),
allocatable :: phalf(:)
1800 real(esmf_kind_r8),
allocatable :: pres_interface(:)
1801 real(kind=4),
allocatable :: dummy3d(:,:,:)
1802 real(kind=4),
allocatable :: dummy3dall(:,:,:)
1803 real(esmf_kind_r8),
allocatable :: dummy3dflip(:,:,:)
1804 real(esmf_kind_r8),
allocatable :: dummy(:,:)
1805 real(esmf_kind_r8),
pointer :: presptr(:,:,:), dpresptr(:,:,:)
1806 real(esmf_kind_r8),
pointer :: psptr(:,:)
1808 print*,
"- READ INPUT ATMOS DATA FROM GAUSSIAN NETCDF FILE."
1810 tilefile = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
1811 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1812 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1814 error=nf90_inq_dimid(ncid,
'grid_xt', id_dim)
1815 call
netcdf_err(error,
'reading grid_xt id' )
1816 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
1817 call
netcdf_err(error,
'reading grid_xt value' )
1819 error=nf90_inq_dimid(ncid,
'grid_yt', id_dim)
1820 call
netcdf_err(error,
'reading grid_yt id' )
1821 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
1822 call
netcdf_err(error,
'reading grid_yt value' )
1824 if (idim_input /= i_input .or. jdim_input /= j_input)
then
1825 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 2)
1828 error=nf90_inq_dimid(ncid,
'pfull', id_dim)
1830 error=nf90_inquire_dimension(ncid,id_dim,len=lev_input)
1831 call
netcdf_err(error,
'reading pfull value' )
1833 error=nf90_inq_dimid(ncid,
'phalf', id_dim)
1835 error=nf90_inquire_dimension(ncid,id_dim,len=levp1_input)
1836 call
netcdf_err(error,
'reading phalf value' )
1837 allocate(phalf(levp1_input))
1838 error=nf90_inq_varid(ncid,
'phalf', id_var)
1839 call
netcdf_err(error,
'getting phalf varid' )
1840 error=nf90_get_var(ncid, id_var, phalf)
1841 call
netcdf_err(error,
'reading phalf varid' )
1843 error=nf90_get_att(ncid, nf90_global,
'ncnsto', num_tracers_file)
1844 call
netcdf_err(error,
'reading ntracer value' )
1846 call mpi_comm_size(mpi_comm_world, nprocs, error)
1847 print*,
'- Running with ', nprocs,
' processors'
1849 call mpi_comm_rank(mpi_comm_world, myrank, error)
1850 print*,
'- myrank/localpet is ',myrank,localpet
1853 if (nprocs > lev_input)
then
1854 max_procs = lev_input
1857 kdim = lev_input / max_procs
1858 remainder = lev_input - (max_procs*kdim)
1860 allocate(kcount(0:nprocs-1))
1862 allocate(startk(0:nprocs-1))
1864 allocate(displ(0:nprocs-1))
1866 allocate(ircnt(0:nprocs-1))
1869 do k = 0, max_procs-2
1872 kcount(max_procs-1) = kdim + remainder
1875 do k = 1, max_procs-1
1876 startk(k) = startk(k-1) + kcount(k-1)
1879 ircnt(:) = idim_input * jdim_input * kcount(:)
1882 do k = 1, max_procs-1
1883 displ(k) = displ(k-1) + ircnt(k-1)
1886 iscnt=idim_input*jdim_input*kcount(myrank)
1890 if (myrank <= max_procs-1)
then
1891 allocate(dummy3d(idim_input,jdim_input,kcount(myrank)))
1893 allocate(dummy3d(0,0,0))
1896 if (myrank == 0)
then
1897 allocate(dummy3dall(idim_input,jdim_input,lev_input))
1899 allocate(dummy3dflip(idim_input,jdim_input,lev_input))
1901 allocate(dummy(idim_input,jdim_input))
1904 allocate(dummy3dall(0,0,0))
1905 allocate(dummy3dflip(0,0,0))
1906 allocate(dummy(0,0))
1915 print*,
"- CALL FieldCreate FOR INPUT GRID DELTA PRESSURE."
1916 dpres_input_grid = esmf_fieldcreate(input_grid, &
1917 typekind=esmf_typekind_r8, &
1918 staggerloc=esmf_staggerloc_center, &
1919 ungriddedlbound=(/1/), &
1920 ungriddedubound=(/lev_input/), rc=rc)
1921 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1926 if (myrank <= max_procs-1)
then
1927 start = (/1,1,startk(myrank)/)
1928 count = (/idim_input,jdim_input,kcount(myrank)/)
1929 error=nf90_inq_varid(ncid,
'tmp', id_var)
1930 call
netcdf_err(error,
'reading tmp field id' )
1931 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
1935 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
1936 dummy3dall, ircnt, displ, mpi_real, &
1937 0, mpi_comm_world, error)
1938 if (error /= 0) call
error_handler(
"IN mpi_gatherv of temperature", error)
1940 if (myrank == 0)
then
1941 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
1944 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE "
1945 call esmf_fieldscatter(temp_input_grid, dummy3dflip, rootpet=0, rc=rc)
1946 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1951 if (myrank <= max_procs-1)
then
1952 error=nf90_inq_varid(ncid,
'dpres', id_var)
1953 call
netcdf_err(error,
'reading dpres field id' )
1954 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
1955 call
netcdf_err(error,
'reading dpres field' )
1958 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
1959 dummy3dall, ircnt, displ, mpi_real, &
1960 0, mpi_comm_world, error)
1961 if (error /= 0) call
error_handler(
"IN mpi_gatherv of dpres", error)
1963 if (myrank == 0)
then
1964 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
1967 print*,
"- CALL FieldScatter FOR INPUT GRID DPRES "
1968 call esmf_fieldscatter(dpres_input_grid, dummy3dflip, rootpet=0, rc=rc)
1969 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1974 if (myrank <= max_procs-1)
then
1975 error=nf90_inq_varid(ncid,
'ugrd', id_var)
1976 call
netcdf_err(error,
'reading ugrd field id' )
1977 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
1978 call
netcdf_err(error,
'reading ugrd field' )
1981 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
1982 dummy3dall, ircnt, displ, mpi_real, &
1983 0, mpi_comm_world, error)
1984 if (error /= 0) call
error_handler(
"IN mpi_gatherv of ugrd", error)
1986 if (myrank == 0)
then
1987 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
1990 print*,
"- CALL FieldScatter FOR INPUT GRID UGRD "
1991 call esmf_fieldscatter(u_input_grid, dummy3dflip, rootpet=0, rc=rc)
1992 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1997 if (myrank <= max_procs-1)
then
1998 error=nf90_inq_varid(ncid,
'vgrd', id_var)
1999 call
netcdf_err(error,
'reading vgrd field id' )
2000 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
2001 call
netcdf_err(error,
'reading vgrd field' )
2004 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
2005 dummy3dall, ircnt, displ, mpi_real, &
2006 0, mpi_comm_world, error)
2007 if (error /= 0) call
error_handler(
"IN mpi_gatherv of vgrd", error)
2009 if (myrank == 0)
then
2010 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
2013 print*,
"- CALL FieldScatter FOR INPUT GRID VGRD "
2014 call esmf_fieldscatter(v_input_grid, dummy3dflip, rootpet=0, rc=rc)
2015 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2020 do n = 1, num_tracers_input
2022 if (myrank <= max_procs-1)
then
2023 error=nf90_inq_varid(ncid, tracers_input(n), id_var)
2024 call
netcdf_err(error,
'reading tracer field id' )
2025 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
2026 call
netcdf_err(error,
'reading tracer field' )
2029 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
2030 dummy3dall, ircnt, displ, mpi_real, &
2031 0, mpi_comm_world, error)
2032 if (error /= 0) call
error_handler(
"IN mpi_gatherv of tracer", error)
2034 if (myrank == 0)
then
2035 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
2036 where(dummy3dflip < 0.0) dummy3dflip = 0.0
2039 print*,
"- CALL FieldScatter FOR INPUT GRID ", tracers_input(n)
2040 call esmf_fieldscatter(tracers_input_grid(n), dummy3dflip, rootpet=0, rc=rc)
2041 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2048 if (myrank == 0)
then
2052 print*,
"- CALL FieldScatter FOR INPUT GRID DZDT"
2053 call esmf_fieldscatter(dzdt_input_grid, dummy3dflip, rootpet=0, rc=rc)
2054 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2057 deallocate(dummy3dflip, dummy3dall, dummy3d)
2062 print*,
"- READ TERRAIN."
2063 error=nf90_inq_varid(ncid,
'hgtsfc', id_var)
2064 call
netcdf_err(error,
'reading hgtsfc field id' )
2065 error=nf90_get_var(ncid, id_var, dummy)
2066 call
netcdf_err(error,
'reading hgtsfc field' )
2069 print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN."
2070 call esmf_fieldscatter(terrain_input_grid, dummy, rootpet=0, rc=rc)
2071 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2077 print*,
"- READ SURFACE P."
2078 error=nf90_inq_varid(ncid,
'pressfc', id_var)
2079 call
netcdf_err(error,
'reading pressfc field id' )
2080 error=nf90_get_var(ncid, id_var, dummy)
2081 call
netcdf_err(error,
'reading pressfc field' )
2084 print*,
"- CALL FieldScatter FOR INPUT GRID SURFACE P."
2085 call esmf_fieldscatter(ps_input_grid, dummy, rootpet=0, rc=rc)
2086 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2089 deallocate(kcount, startk, displ, ircnt, dummy)
2101 print*,
"- CALL FieldGet FOR PRESSURE."
2102 call esmf_fieldget(pres_input_grid, &
2103 computationallbound=clb, &
2104 computationalubound=cub, &
2105 farrayptr=presptr, rc=rc)
2106 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2109 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
2110 call esmf_fieldget(dpres_input_grid, &
2111 farrayptr=dpresptr, rc=rc)
2112 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2115 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
2116 call esmf_fieldget(ps_input_grid, &
2117 farrayptr=psptr, rc=rc)
2118 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2121 allocate(pres_interface(levp1_input))
2136 do i = clb(1), cub(1)
2137 do j = clb(2), cub(2)
2138 pres_interface(levp1_input) = phalf(1) * 100.0_8
2139 do k = lev_input, 1, -1
2140 pres_interface(k) = pres_interface(k+1) + dpresptr(i,j,k)
2142 psptr(i,j) = pres_interface(1)
2144 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
2149 deallocate(pres_interface, phalf)
2151 call esmf_fielddestroy(dpres_input_grid, rc=rc)
2170 integer,
intent(in) :: localpet
2172 character(len=500) :: tilefile
2174 integer :: error, ncid, rc, tile
2175 integer :: id_dim, idim_input, jdim_input
2176 integer :: id_var, i, j, k, n
2177 integer :: clb(3), cub(3), num_tracers_file
2179 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
2180 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
2181 real(esmf_kind_r8),
pointer :: presptr(:,:,:), dpresptr(:,:,:)
2182 real(esmf_kind_r8),
pointer :: psptr(:,:)
2183 real(esmf_kind_r8),
allocatable :: pres_interface(:), phalf(:)
2185 print*,
"- READ INPUT ATMOS DATA FROM TILED HISTORY FILES."
2187 tilefile = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
2188 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
2189 call
netcdf_err(error,
'opening: '//trim(tilefile) )
2191 error=nf90_inq_dimid(ncid,
'grid_xt', id_dim)
2192 call
netcdf_err(error,
'reading grid_xt id' )
2193 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
2194 call
netcdf_err(error,
'reading grid_xt value' )
2196 error=nf90_inq_dimid(ncid,
'grid_yt', id_dim)
2197 call
netcdf_err(error,
'reading grid_yt id' )
2198 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
2199 call
netcdf_err(error,
'reading grid_yt value' )
2201 if (idim_input /= i_input .or. jdim_input /= j_input)
then
2202 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 2)
2205 error=nf90_inq_dimid(ncid,
'pfull', id_dim)
2207 error=nf90_inquire_dimension(ncid,id_dim,len=lev_input)
2208 call
netcdf_err(error,
'reading pfull value' )
2210 error=nf90_inq_dimid(ncid,
'phalf', id_dim)
2212 error=nf90_inquire_dimension(ncid,id_dim,len=levp1_input)
2213 call
netcdf_err(error,
'reading phalf value' )
2214 allocate(phalf(levp1_input))
2215 error=nf90_inq_varid(ncid,
'phalf', id_var)
2216 call
netcdf_err(error,
'getting phalf varid' )
2217 error=nf90_get_var(ncid, id_var, phalf)
2218 call
netcdf_err(error,
'reading phalf varid' )
2220 error=nf90_get_att(ncid, nf90_global,
'ncnsto', num_tracers_file)
2221 call
netcdf_err(error,
'reading ntracer value' )
2223 error = nf90_close(ncid)
2225 print*,
'- FILE HAS ', num_tracers_file,
' TRACERS.'
2226 print*,
'- WILL PROCESS ', num_tracers_input,
' TRACERS.'
2234 print*,
"- CALL FieldCreate FOR INPUT GRID DELTA PRESSURE."
2235 dpres_input_grid = esmf_fieldcreate(input_grid, &
2236 typekind=esmf_typekind_r8, &
2237 staggerloc=esmf_staggerloc_center, &
2238 ungriddedlbound=(/1/), &
2239 ungriddedubound=(/lev_input/), rc=rc)
2240 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2243 if (localpet < num_tiles_input_grid)
then
2244 allocate(data_one_tile(i_input,j_input))
2245 allocate(data_one_tile_3d(i_input,j_input,lev_input))
2247 allocate(data_one_tile(0,0))
2248 allocate(data_one_tile_3d(0,0,0))
2251 if (localpet < num_tiles_input_grid)
then
2253 tilefile= trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(tile))
2254 print*,
"- READ ATMOSPHERIC DATA FROM: ", trim(tilefile)
2255 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
2256 call
netcdf_err(error,
'opening: '//trim(tilefile) )
2259 if (localpet < num_tiles_input_grid)
then
2269 data_one_tile_3d = 0.0_8
2272 do tile = 1, num_tiles_input_grid
2273 print*,
"- CALL FieldScatter FOR INPUT GRID VERTICAL VELOCITY."
2274 call esmf_fieldscatter(dzdt_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2275 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2279 do n = 1, num_tracers_input
2281 if (localpet < num_tiles_input_grid)
then
2282 print*,
"- READ ", trim(tracers_input(n))
2283 error=nf90_inq_varid(ncid, tracers_input(n), id_var)
2285 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2287 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2290 do tile = 1, num_tiles_input_grid
2291 print*,
"- CALL FieldScatter FOR INPUT GRID TRACER ", trim(tracers_input(n))
2292 call esmf_fieldscatter(tracers_input_grid(n), data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2293 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2299 if (localpet < num_tiles_input_grid)
then
2300 print*,
"- READ TEMPERATURE."
2301 error=nf90_inq_varid(ncid,
'tmp', id_var)
2303 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2305 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2308 do tile = 1, num_tiles_input_grid
2309 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
2310 call esmf_fieldscatter(temp_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2311 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2315 if (localpet < num_tiles_input_grid)
then
2316 print*,
"- READ U-WIND."
2317 error=nf90_inq_varid(ncid,
'ugrd', id_var)
2319 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2321 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2324 do tile = 1, num_tiles_input_grid
2325 print*,
"- CALL FieldScatter FOR INPUT GRID U."
2326 call esmf_fieldscatter(u_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2327 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2331 if (localpet < num_tiles_input_grid)
then
2332 print*,
"- READ V-WIND."
2333 error=nf90_inq_varid(ncid,
'vgrd', id_var)
2335 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2337 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2340 do tile = 1, num_tiles_input_grid
2341 print*,
"- CALL FieldScatter FOR INPUT GRID V."
2342 call esmf_fieldscatter(v_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2343 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2347 if (localpet < num_tiles_input_grid)
then
2348 print*,
"- READ SURFACE PRESSURE."
2349 error=nf90_inq_varid(ncid,
'pressfc', id_var)
2351 error=nf90_get_var(ncid, id_var, data_one_tile)
2355 do tile = 1, num_tiles_input_grid
2356 print*,
"- CALL FieldScatter FOR INPUT GRID SURFACE PRESSURE."
2357 call esmf_fieldscatter(ps_input_grid, data_one_tile, rootpet=tile-1, tile=tile, rc=rc)
2358 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2362 if (localpet < num_tiles_input_grid)
then
2363 print*,
"- READ TERRAIN."
2364 error=nf90_inq_varid(ncid,
'hgtsfc', id_var)
2366 error=nf90_get_var(ncid, id_var, data_one_tile)
2370 do tile = 1, num_tiles_input_grid
2371 print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN."
2372 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=tile-1, tile=tile, rc=rc)
2373 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2377 if (localpet < num_tiles_input_grid)
then
2378 print*,
"- READ DELTA PRESSURE."
2379 error=nf90_inq_varid(ncid,
'dpres', id_var)
2381 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2383 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2386 do tile = 1, num_tiles_input_grid
2387 print*,
"- CALL FieldScatter FOR INPUT DELTA PRESSURE."
2388 call esmf_fieldscatter(dpres_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2389 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2393 if (localpet < num_tiles_input_grid) error = nf90_close(ncid)
2395 deallocate(data_one_tile_3d, data_one_tile)
2407 print*,
"- CALL FieldGet FOR PRESSURE."
2408 call esmf_fieldget(pres_input_grid, &
2409 computationallbound=clb, &
2410 computationalubound=cub, &
2411 farrayptr=presptr, rc=rc)
2412 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2415 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
2416 call esmf_fieldget(dpres_input_grid, &
2417 farrayptr=dpresptr, rc=rc)
2418 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2421 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
2422 call esmf_fieldget(ps_input_grid, &
2423 farrayptr=psptr, rc=rc)
2424 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2427 allocate(pres_interface(levp1_input))
2433 do i = clb(1), cub(1)
2434 do j = clb(2), cub(2)
2435 pres_interface(1) = psptr(i,j)
2436 do k = 2, levp1_input
2437 pres_interface(k) = pres_interface(k-1) - dpresptr(i,j,k-1)
2440 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
2445 deallocate(pres_interface, phalf)
2447 call esmf_fielddestroy(dpres_input_grid, rc=rc)
2464 integer,
intent(in) :: localpet
2466 integer,
parameter :: ntrac_max=14
2467 integer,
parameter :: max_levs=1000
2469 character(len=300) :: the_file
2470 character(len=20) :: vname, &
2471 trac_names_vmap(ntrac_max), &
2473 method, tracers_input_vmap(num_tracers_input), &
2474 tracers_default(ntrac_max)
2476 integer :: i, j, k, n
2478 integer :: rc, clb(3), cub(3)
2479 integer :: vlev, iret,varnum, o3n
2480 integer :: intrp_ier, done_print
2481 integer :: trac_names_oct10(ntrac_max)
2482 integer :: tracers_input_oct10(num_tracers_input)
2483 integer :: trac_names_oct11(ntrac_max)
2484 integer :: tracers_input_oct11(num_tracers_input)
2485 integer :: lugb, lugi, jdisc, jpdt(200), jgdt(200), iscale
2486 integer :: jids(200), jpdtn, jgdtn, octet23, octet29
2487 integer :: count_spfh, count_rh, count_icmr, count_scliwc
2488 integer :: count_cice, count_rwmr, count_scllwc, count
2490 logical :: conv_omega=.false., &
2493 use_rh=.false. , unpack, &
2494 all_empty, is_missing
2496 real(esmf_kind_r8),
allocatable :: dum2d_1(:,:)
2499 real(esmf_kind_r8) :: rlevs_hold(max_levs)
2500 real(esmf_kind_r8),
allocatable :: rlevs(:)
2501 real(esmf_kind_r4),
allocatable :: dummy2d(:,:)
2502 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:), dummy2d_8(:,:),&
2503 u_tmp_3d(:,:,:), v_tmp_3d(:,:,:)
2504 real(esmf_kind_r8),
pointer :: presptr(:,:,:), psptr(:,:),tptr(:,:,:), &
2505 qptr(:,:,:), wptr(:,:,:), &
2506 uptr(:,:,:), vptr(:,:,:)
2507 real(esmf_kind_r4) :: value
2508 real(esmf_kind_r8),
parameter :: p0 = 100000.0
2509 real(esmf_kind_r8),
allocatable :: dummy3d_col_in(:),dummy3d_col_out(:)
2510 real(esmf_kind_r8),
parameter :: intrp_missing = -999.0
2511 real(esmf_kind_r4),
parameter :: lev_no_tr_fill = 20000.0
2512 real(esmf_kind_r4),
parameter :: lev_no_o3_fill = 40000.0
2514 type(gribfield
) :: gfld
2518 trac_names_oct10 = (/1, 1, 14, 1, 1, 1, 1, 6, 6, 1, 6, 13, 13, 2 /)
2519 trac_names_oct11 = (/0, 22, 192, 23, 24, 25, 32, 1, 29, 100, 28, 193, 192, 2 /)
2521 trac_names_vmap = (/
"sphum ",
"liq_wat ",
"o3mr ",
"ice_wat ", &
2522 "rainwat ",
"snowwat ",
"graupel ",
"cld_amt ",
"ice_nc ", &
2523 "rain_nc ",
"water_nc",
"liq_aero",
"ice_aero", &
2526 tracers_default = (/
"sphum ",
"liq_wat ",
"o3mr ",
"ice_wat ", &
2527 "rainwat ",
"snowwat ",
"graupel ",
"cld_amt ",
"ice_nc ", &
2528 "rain_nc ",
"water_nc",
"liq_aero",
"ice_aero", &
2531 the_file = trim(data_dir_input_grid) //
"/" // trim(grib2_file_input_grid)
2533 print*,
"- READ ATMOS DATA FROM GRIB2 FILE: ", trim(the_file)
2535 if (localpet == 0)
then
2539 call baopenr(lugb,the_file,iret)
2540 if (iret /= 0) call
error_handler(
"ERROR OPENING GRIB2 FILE.", iret)
2560 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2561 unpack, k, gfld, iret)
2582 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2583 unpack, k, gfld, iret)
2587 if (gfld%discipline == 0)
then
2588 if (gfld%ipdtnum == 0)
then
2590 if (gfld%ipdtmpl(1) == 2 .and. gfld%ipdtmpl(2) == 2)
then
2592 if (gfld%ipdtmpl(10) == octet23 .and. gfld%ipdtmpl(13) == octet29)
then
2595 lev_input = lev_input + 1
2596 iscale = 10 ** gfld%ipdtmpl(11)
2597 rlevs_hold(lev_input) = float(gfld%ipdtmpl(12))/float(iscale)
2608 call mpi_barrier(mpi_comm_world, iret)
2609 call mpi_bcast(isnative,1,mpi_logical,0,mpi_comm_world,iret)
2610 call mpi_bcast(lev_input,1,mpi_integer,0,mpi_comm_world,iret)
2611 call mpi_bcast(rlevs_hold, max_levs, mpi_integer,0,mpi_comm_world,iret)
2613 allocate(slevs(lev_input))
2614 allocate(rlevs(lev_input))
2615 allocate(dummy3d_col_in(lev_input))
2616 allocate(dummy3d_col_out(lev_input))
2618 levp1_input = lev_input + 1
2623 rlevs(i) = rlevs_hold(i)
2630 write(slevs(i),
'(i6)') nint(rlevs(i))
2631 slevs(i) = trim(slevs(i)) //
" hybrid"
2633 write(slevs(i),
'(f11.2)') rlevs(i)
2634 slevs(i) = trim(slevs(i)) //
" Pa"
2638 if(localpet == 0)
then
2640 print*,
"- LEVEL AFTER SORT = ",trim(slevs(i))
2646 if (localpet == 0)
then
2660 do vlev = 1, lev_input
2662 jpdt(12) = nint(rlevs(vlev))
2664 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2665 unpack, k, gfld, iret)
2668 count_spfh = count_spfh + 1
2677 do vlev = 1, lev_input
2679 jpdt(12) = nint(rlevs(vlev))
2681 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2682 unpack, k, gfld, iret)
2685 count_rh = count_rh + 1
2689 if (count_spfh /= lev_input)
then
2693 if (count_spfh == 0 .or. use_rh)
then
2694 if (count_rh == 0)
then
2695 call
error_handler(
"READING ATMOSPHERIC WATER VAPOR VARIABLE.", 2)
2698 trac_names_oct10(1) = 1
2699 trac_names_oct11(1) = 1
2700 print*,
"- FILE CONTAINS RH."
2702 print*,
"- FILE CONTAINS SPFH."
2707 call mpi_barrier(mpi_comm_world, rc)
2708 call mpi_bcast(hasspfh,1,mpi_logical,0,mpi_comm_world,rc)
2712 if (localpet == 0)
then
2728 do vlev = 1, lev_input
2733 jpdt(12) = nint(rlevs(vlev))
2735 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2736 unpack, k, gfld, iret)
2739 count_icmr = count_icmr + 1
2745 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2746 unpack, k, gfld, iret)
2749 count_scliwc = count_scliwc + 1
2755 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2756 unpack, k, gfld, iret)
2759 count_cice = count_cice + 1
2765 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2766 unpack, k, gfld, iret)
2769 count_rwmr = count_rwmr + 1
2776 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2777 unpack, k, gfld, iret)
2780 count_scllwc = count_scllwc + 1
2785 if (count_icmr == 0)
then
2786 if (count_scliwc == 0)
then
2787 if (count_cice == 0)
then
2788 print*,
'- FILE DOES NOT CONTAIN CICE.'
2790 trac_names_oct10(4) = 6
2791 trac_names_oct11(4) = 0
2792 print*,
"- FILE CONTAINS CICE."
2795 trac_names_oct10(4) = 1
2796 trac_names_oct11(4) = 84
2797 print*,
"- FILE CONTAINS SCLIWC."
2800 print*,
"- FILE CONTAINS ICMR."
2803 if (count_rwmr == 0)
then
2804 if (count_scllwc == 0)
then
2805 print*,
"- FILE DOES NOT CONTAIN SCLLWC."
2807 trac_names_oct10(4) = 1
2808 trac_names_oct11(4) = 83
2810 print*,
"- FILE CONTAINS SCLLWC."
2813 print*,
"- FILE CONTAINS CLWMR."
2818 call mpi_barrier(mpi_comm_world, rc)
2819 call mpi_bcast(trac_names_oct10,ntrac_max,mpi_integer,0,mpi_comm_world,rc)
2820 call mpi_bcast(trac_names_oct11,ntrac_max,mpi_integer,0,mpi_comm_world,rc)
2822 print*,
"- COUNT NUMBER OF TRACERS TO BE READ IN BASED ON PHYSICS SUITE TABLE"
2823 do n = 1, num_tracers_input
2825 vname = tracers_input(n)
2827 i = maxloc(merge(1.,0.,trac_names_vmap == vname),dim=1)
2829 tracers_input_vmap(n)=trac_names_vmap(i)
2830 tracers(n)=tracers_default(i)
2831 if(trim(tracers(n)) .eq.
"o3mr") o3n = n
2833 tracers_input_oct10(n) = trac_names_oct10(i)
2834 tracers_input_oct11(n) = trac_names_oct11(i)
2844 if (localpet == 0)
then
2845 allocate(dummy2d(i_input,j_input))
2846 allocate(dummy2d_8(i_input,j_input))
2847 allocate(dummy3d(i_input,j_input,lev_input))
2848 allocate(dum2d_1(i_input,j_input))
2850 allocate(dummy2d(0,0))
2851 allocate(dummy2d_8(0,0))
2852 allocate(dummy3d(0,0,0))
2853 allocate(dum2d_1(0,0))
2862 if (localpet == 0)
then
2864 print*,
"- READ TEMPERATURE."
2884 do vlev = 1, lev_input
2886 jpdt(12) = nint(rlevs(vlev))
2888 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2889 unpack, k, gfld, iret)
2891 call
error_handler(
"READING IN TEMPERATURE AT LEVEL "//trim(slevs(vlev)),iret)
2894 dum2d_1 = reshape(gfld%fld, (/i_input,j_input/) )
2896 dummy3d(:,:,vlev) = dum2d_1
2902 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
2903 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
2904 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2909 do n = 1, num_tracers_input
2911 if (localpet == 0) print*,
"- READ ", trim(tracers_input_vmap(n))
2913 vname = tracers_input_vmap(n)
2914 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
2915 this_field_var_name=tmpstr,loc=varnum)
2917 if (n==1 .and. .not. hasspfh)
then
2918 print*,
"- CALL FieldGather TEMPERATURE."
2919 call esmf_fieldgather(temp_input_grid,dummy3d,rootpet=0, tile=1, rc=rc)
2920 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2924 if (localpet == 0)
then
2941 do vlev = 1, lev_input
2944 jpdt(1) = tracers_input_oct10(n)
2945 jpdt(2) = tracers_input_oct11(n)
2946 jpdt(12) = nint(rlevs(vlev))
2948 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2949 unpack, k, gfld, iret)
2965 is_missing = .false.
2967 do vlev = 1, lev_input
2971 jpdt(1) = tracers_input_oct10(n)
2972 jpdt(2) = tracers_input_oct11(n)
2973 jpdt(12) = nint(rlevs(vlev) )
2975 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2976 unpack, k, gfld, iret)
2979 dummy2d = reshape(gfld%fld, (/i_input,j_input/) )
2981 if (trim(method) .eq.
'intrp' .and. .not.all_empty)
then
2982 dummy2d = intrp_missing
2987 if (.not.all_empty .and. n == o3n)
then
2988 if (rlevs(vlev) .lt. lev_no_o3_fill) &
2989 call
error_handler(
"TRACER "//trim(tracers(n))//
" HAS MISSING DATA AT "//trim(slevs(vlev))//&
2990 ". SET MISSING VARIABLE CONDITION TO 'INTRP' TO AVOID THIS ERROR", 1)
2991 elseif (.not.all_empty .and. n .ne. o3n)
then
2992 if (rlevs(vlev) .gt. lev_no_tr_fill) &
2993 call
error_handler(
"TRACER "//trim(tracers(n))//
" HAS MISSING DATA AT "//trim(slevs(vlev))//&
2994 ". SET MISSING VARIABLE CONDITION TO 'INTRP' TO AVOID THIS ERROR.", 1)
2997 if (trim(method) .eq.
'intrp' .and. all_empty) method=
'set_to_fill'
3001 if ( (tracers_input_oct10(n) == 1 .and. tracers_input_oct11(n) == 0) .or. &
3002 (tracers_input_oct10(n) == 1 .and. tracers_input_oct11(n) == 1) .or. &
3003 (tracers_input_oct10(n) == 14 .and. tracers_input_oct11(n) == 192) )
then
3004 call
error_handler(
"READING IN "//trim(tracers(n))//
" AT LEVEL "//trim(slevs(vlev))&
3005 //
". SET A FILL VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",iret)
3011 if (n==1 .and. .not. hasspfh)
then
3012 if (trim(external_model) .eq.
'GFS')
then
3013 print *,
'- CALL CALRH GFS'
3014 call
rh2spfh_gfs(dummy2d,rlevs(vlev),dummy3d(:,:,vlev))
3016 print *,
'- CALL CALRH non-GFS'
3017 call
rh2spfh(dummy2d,rlevs(vlev),dummy3d(:,:,vlev))
3021 dummy3d(:,:,vlev) =
real(dummy2d,esmf_kind_r8)
3026 if (is_missing .and. trim(method) .eq.
'intrp')
then
3027 print *,
'- INTERPOLATE TRACER '//trim(tracers(n))
3031 dummy3d_col_in=dummy3d(ii,jj,:)
3032 call
dint2p(rlevs,dummy3d_col_in,lev_input,rlevs,dummy3d_col_out, &
3033 lev_input, 2, intrp_missing, intrp_ier)
3034 if (intrp_ier .gt. 0) call
error_handler(
"Interpolation failed.",intrp_ier)
3035 dummy3d(ii,jj,:)=dummy3d_col_out
3039 dummy2d = dummy3d(:,:,n)
3040 if (any(dummy2d .eq. intrp_missing))
then
3042 if (n == o3n .and. rlevs(vlev) .lt. lev_no_o3_fill)
then
3043 call
error_handler(
"TRACER "//trim(tracers(n))//
" HAS MISSING DATA AT "//trim(slevs(vlev)),1)
3044 elseif (n .ne. o3n .and. rlevs(vlev) .gt. lev_no_tr_fill)
then
3045 call
error_handler(
"TRACER "//trim(tracers(n))//
" HAS MISSING DATA AT "//trim(slevs(vlev)),1)
3047 if (done_print .eq. 0)
then
3048 print*,
"Pressure out of range of existing data. Defaulting to fill value."
3051 where(dummy2d .eq. intrp_missing) dummy2d = value
3052 dummy3d(:,:,vlev) = dummy2d
3056 where(dummy3d(:,:,vlev) .lt. 0.0) dummy3d(:,:,vlev) = 0.0
3062 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input_vmap(n))
3063 call esmf_fieldscatter(tracers_input_grid(n), dummy3d, rootpet=0, rc=rc)
3064 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3069 deallocate(dummy3d_col_in, dummy3d_col_out)
3071 call
read_winds(u_tmp_3d,v_tmp_3d,localpet,isnative,rlevs,lugb)
3073 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT U-WIND."
3074 call esmf_fieldscatter(u_input_grid, u_tmp_3d, rootpet=0, rc=rc)
3075 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3078 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT V-WIND."
3079 call esmf_fieldscatter(v_input_grid, v_tmp_3d, rootpet=0, rc=rc)
3080 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3083 if (localpet == 0)
then
3085 print*,
"- READ SURFACE PRESSURE."
3098 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
3099 unpack, k, gfld, iret)
3100 if (iret /= 0) call
error_handler(
"READING SURFACE PRESSURE RECORD.", iret)
3102 dummy2d_8 = reshape(gfld%fld, (/i_input,j_input/) )
3106 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID SURFACE PRESSURE."
3107 call esmf_fieldscatter(ps_input_grid, dummy2d_8, rootpet=0, rc=rc)
3108 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3113 if (localpet == 0)
then
3115 print*,
"- READ DZDT."
3117 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
3138 do vlev = 1, lev_input
3140 jpdt(12) = nint(rlevs(vlev))
3142 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
3143 unpack, k, gfld, iret)
3146 print*,
"DZDT not available at level ", trim(slevs(vlev)),
" so checking for VVEL"
3148 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
3149 unpack, k, gfld, iret)
3151 call
handle_grib_error(vname, slevs(vlev),method,value,varnum,iret,var8=dum2d_1)
3157 dum2d_1 = reshape(gfld%fld, (/i_input,j_input/) )
3160 dum2d_1 = reshape(gfld%fld, (/i_input,j_input/) )
3163 dummy3d(:,:,vlev) = dum2d_1
3169 call mpi_bcast(conv_omega,1,mpi_logical,0,mpi_comm_world,rc)
3171 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT DZDT."
3172 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
3173 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3178 if (localpet == 0)
then
3180 print*,
"- READ TERRAIN."
3193 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
3194 unpack, k, gfld, iret)
3195 if (iret /= 0) call
error_handler(
"READING TERRAIN HEIGHT RECORD.", iret)
3197 dummy2d_8 = reshape(gfld%fld, (/i_input,j_input/) )
3201 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN."
3202 call esmf_fieldscatter(terrain_input_grid, dummy2d_8, rootpet=0, rc=rc)
3203 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3206 deallocate(dummy2d, dummy2d_8)
3208 if (.not. isnative)
then
3215 if (localpet == 0) print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
3217 call esmf_fieldget(ps_input_grid, &
3218 farrayptr=psptr, rc=rc)
3219 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3223 if (localpet == 0) print*,
"- CALL FieldGet FOR 3-D PRESSURE."
3224 call esmf_fieldget(pres_input_grid, &
3225 computationallbound=clb, &
3226 computationalubound=cub, &
3227 farrayptr=presptr, rc=rc)
3228 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3232 if (localpet == 0) print*,
"- CALL FieldGet TEMPERATURE."
3233 call esmf_fieldget(temp_input_grid, &
3234 farrayptr=tptr, rc=rc)
3235 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3239 if (localpet == 0) print*,
"- CALL FieldGet FOR U"
3240 call esmf_fieldget(u_input_grid, &
3241 farrayptr=uptr, rc=rc)
3242 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3246 if (localpet == 0) print*,
"- CALL FieldGet FOR V"
3247 call esmf_fieldget(v_input_grid, &
3248 farrayptr=vptr, rc=rc)
3249 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3253 if (localpet == 0) print*,
"- CALL FieldGet FOR W"
3254 call esmf_fieldget(dzdt_input_grid, &
3255 farrayptr=wptr, rc=rc)
3256 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3259 if (localpet == 0) print*,
"- CALL FieldGet FOR TRACERS."
3260 do n=1,num_tracers_input
3262 call esmf_fieldget(tracers_input_grid(n), &
3263 farrayptr=qptr, rc=rc)
3264 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3266 do i = clb(1),cub(1)
3267 do j = clb(2),cub(2)
3268 qptr(i,j,:) = qptr(i,j,lev_input:1:-1)
3273 do i = clb(1),cub(1)
3274 do j = clb(2),cub(2)
3275 presptr(i,j,:) = rlevs(lev_input:1:-1)
3276 tptr(i,j,:) = tptr(i,j,lev_input:1:-1)
3277 uptr(i,j,:) = uptr(i,j,lev_input:1:-1)
3278 vptr(i,j,:) = vptr(i,j,lev_input:1:-1)
3279 wptr(i,j,:) = wptr(i,j,lev_input:1:-1)
3283 if (localpet == 0)
then
3284 print*,
'psfc is ',clb(1),clb(2),psptr(clb(1),clb(2))
3285 print*,
'pres is ',cub(1),cub(2),presptr(cub(1),cub(2),:)
3287 print*,
'pres check 1',localpet,maxval(presptr(clb(1):cub(1),clb(2):cub(2),1)), &
3288 minval(presptr(clb(1):cub(1),clb(2):cub(2),1))
3289 print*,
'pres check lev',localpet,maxval(presptr(clb(1):cub(1),clb(2):cub(2), &
3290 lev_input)),minval(presptr(clb(1):cub(1),clb(2):cub(2),lev_input))
3297 if (localpet == 0)
then
3299 print*,
"- READ PRESSURE."
3313 do vlev = 1, lev_input
3315 jpdt(12) = nint(rlevs(vlev))
3316 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
3317 unpack, k, gfld, iret)
3319 call
error_handler(
"READING IN PRESSURE AT LEVEL "//trim(slevs(vlev)),iret)
3322 dum2d_1 = reshape(gfld%fld, (/i_input,j_input/) )
3324 dummy3d(:,:,vlev) = dum2d_1
3330 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID PRESSURE."
3331 call esmf_fieldscatter(pres_input_grid, dummy3d, rootpet=0, rc=rc)
3332 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3337 deallocate(dummy3d, dum2d_1)
3349 if (conv_omega)
then
3351 if (localpet == 0) print*,
"- CONVERT FROM OMEGA TO DZDT."
3354 if (localpet == 0) print*,
"- CALL FieldGet TEMPERATURE."
3355 call esmf_fieldget(temp_input_grid, &
3356 farrayptr=tptr, rc=rc)
3357 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3361 if (localpet == 0) print*,
"- CALL FieldGet SPECIFIC HUMIDITY."
3362 call esmf_fieldget(tracers_input_grid(1), &
3363 computationallbound=clb, &
3364 computationalubound=cub, &
3365 farrayptr=qptr, rc=rc)
3366 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3370 if (localpet == 0) print*,
"- CALL FieldGet DZDT."
3371 call esmf_fieldget(dzdt_input_grid, &
3372 computationallbound=clb, &
3373 computationalubound=cub, &
3374 farrayptr=wptr, rc=rc)
3375 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3379 call esmf_fieldget(pres_input_grid, &
3380 farrayptr=presptr, rc=rc)
3381 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3388 if (localpet == 0) call baclose(lugb, rc)
3405 integer,
intent(in) :: localpet
3407 character(len=300) :: the_file
3409 integer(sfcio_intkind) :: iret
3412 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
3413 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
3415 type(sfcio_head
) :: sfchead
3416 type(sfcio_dbta
) :: sfcdata
3418 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
3420 print*,
"- READ SURFACE DATA IN SFCIO FORMAT."
3421 print*,
"- OPEN AND READ: ",trim(the_file)
3422 call sfcio_sropen(23, trim(the_file), iret)
3428 call sfcio_srhead(23, sfchead, iret)
3434 if (localpet == 0)
then
3435 call sfcio_aldbta(sfchead, sfcdata, iret)
3440 call sfcio_srdbta(23, sfchead, sfcdata, iret)
3445 allocate(dummy2d(i_input,j_input))
3446 allocate(dummy3d(i_input,j_input,lsoil_input))
3448 allocate(dummy2d(0,0))
3449 allocate(dummy3d(0,0,0))
3452 if (localpet == 0) dummy2d = sfcdata%slmsk
3454 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
3455 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
3456 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3459 if (localpet == 0) dummy2d = sfcdata%zorl
3461 print*,
"- CALL FieldScatter FOR INPUT Z0."
3462 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
3463 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3466 if (localpet == 0) dummy2d = nint(sfcdata%vtype)
3468 print*,
"- CALL FieldScatter FOR INPUT VEG TYPE."
3469 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
3470 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3474 veg_type_landice_input = 13
3476 if (localpet == 0) dummy2d = sfcdata%canopy
3478 print*,
"- CALL FieldScatter FOR INPUT CANOPY MC."
3479 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
3480 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3483 if (localpet == 0) dummy2d = sfcdata%fice
3485 print*,
"- CALL FieldScatter FOR INPUT ICE FRACTION."
3486 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
3487 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3490 if (localpet == 0) dummy2d = sfcdata%hice
3492 print*,
"- CALL FieldScatter FOR INPUT ICE DEPTH."
3493 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3494 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3497 if (localpet == 0) dummy2d = sfcdata%tisfc
3499 print*,
"- CALL FieldScatter FOR INPUT ICE SKIN TEMP."
3500 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3501 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3504 if (localpet == 0) dummy2d = sfcdata%snwdph
3506 print*,
"- CALL FieldScatter FOR INPUT SNOW DEPTH."
3507 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3508 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3511 if (localpet == 0) dummy2d = sfcdata%sheleg
3513 print*,
"- CALL FieldScatter FOR INPUT SNOW LIQUID EQUIV."
3514 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
3515 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3518 if (localpet == 0) dummy2d = sfcdata%t2m
3520 print*,
"- CALL FieldScatter FOR INPUT T2M."
3521 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
3522 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3525 if (localpet == 0) dummy2d = sfcdata%q2m
3527 print*,
"- CALL FieldScatter FOR INPUT Q2M."
3528 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
3529 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3532 if (localpet == 0) dummy2d = sfcdata%tprcp
3534 print*,
"- CALL FieldScatter FOR INPUT TPRCP."
3535 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
3536 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3539 if (localpet == 0) dummy2d = sfcdata%f10m
3541 print*,
"- CALL FieldScatter FOR INPUT F10M."
3542 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
3543 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3546 if (localpet == 0) dummy2d = sfcdata%uustar
3548 print*,
"- CALL FieldScatter FOR INPUT USTAR."
3549 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
3550 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3553 if (localpet == 0) dummy2d = sfcdata%ffmm
3555 print*,
"- CALL FieldScatter FOR INPUT FFMM."
3556 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
3557 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3560 if (localpet == 0) dummy2d = sfcdata%srflag
3562 print*,
"- CALL FieldScatter FOR INPUT SRFLAG."
3563 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
3564 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3567 if (localpet == 0) dummy2d = sfcdata%tsea
3569 print*,
"- CALL FieldScatter FOR INPUT SKIN TEMP."
3570 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3571 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3574 if (localpet == 0) dummy2d = nint(sfcdata%stype)
3576 print*,
"- CALL FieldScatter FOR INPUT SOIL TYPE."
3577 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
3578 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3581 if (localpet == 0) dummy2d = sfcdata%orog
3583 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
3584 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
3585 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3588 if (localpet == 0) dummy3d = sfcdata%slc
3590 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
3591 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
3592 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3595 if (localpet == 0) dummy3d = sfcdata%smc
3597 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
3598 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
3599 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3602 if (localpet == 0) dummy3d = sfcdata%stc
3604 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
3605 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
3606 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3609 deallocate(dummy2d, dummy3d)
3610 call sfcio_axdbta(sfcdata, iret)
3612 call sfcio_sclose(23, iret)
3627 integer,
intent(in) :: localpet
3629 character(len=300) :: the_file
3633 real(nemsio_realkind),
allocatable :: dummy(:)
3634 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
3635 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
3637 type(nemsio_gfile
) :: gfile
3639 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
3641 if (localpet == 0)
then
3642 allocate(dummy3d(i_input,j_input,lsoil_input))
3643 allocate(dummy2d(i_input,j_input))
3644 allocate(dummy(i_input*j_input))
3645 print*,
"- OPEN FILE ", trim(the_file)
3646 call nemsio_open(gfile, the_file,
"read", iret=rc)
3649 allocate(dummy3d(0,0,0))
3650 allocate(dummy2d(0,0))
3654 if (localpet == 0)
then
3655 print*,
"- READ TERRAIN."
3656 call nemsio_readrecv(gfile,
"orog",
"sfc", 1, dummy, 0, iret=rc)
3658 dummy2d = reshape(dummy, (/i_input,j_input/))
3659 print*,
'orog ',maxval(dummy2d),minval(dummy2d)
3662 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
3663 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
3664 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3667 if (localpet == 0)
then
3668 print*,
"- READ LANDSEA MASK."
3669 call nemsio_readrecv(gfile,
"land",
"sfc", 1, dummy, 0, iret=rc)
3670 if (rc /= 0) call
error_handler(
"READING LANDSEA MASK.", rc)
3671 dummy2d = reshape(dummy, (/i_input,j_input/))
3672 print*,
'landmask ',maxval(dummy2d),minval(dummy2d)
3675 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
3676 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
3677 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3680 if (localpet == 0)
then
3681 print*,
"- READ SEAICE FRACTION."
3682 call nemsio_readrecv(gfile,
"icec",
"sfc", 1, dummy, 0, iret=rc)
3683 if (rc /= 0) call
error_handler(
"READING SEAICE FRACTION.", rc)
3684 dummy2d = reshape(dummy, (/i_input,j_input/))
3685 print*,
'icec ',maxval(dummy2d),minval(dummy2d)
3688 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
3689 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
3690 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3693 if (localpet == 0)
then
3694 print*,
"- READ SEAICE DEPTH."
3695 call nemsio_readrecv(gfile,
"icetk",
"sfc", 1, dummy, 0, iret=rc)
3696 if (rc /= 0) call
error_handler(
"READING SEAICE DEPTH.", rc)
3697 dummy2d = reshape(dummy, (/i_input,j_input/))
3698 print*,
'icetk ',maxval(dummy2d),minval(dummy2d)
3701 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
3702 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3703 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3706 if (localpet == 0)
then
3707 print*,
"- READ SEAICE SKIN TEMPERATURE."
3708 call nemsio_readrecv(gfile,
"tisfc",
"sfc", 1, dummy, 0, iret=rc)
3709 if (rc /= 0) call
error_handler(
"READING SEAICE SKIN TEMP.", rc)
3710 dummy2d = reshape(dummy, (/i_input,j_input/))
3711 print*,
'ti ',maxval(dummy2d),minval(dummy2d)
3714 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
3715 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3716 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3719 if (localpet == 0)
then
3720 print*,
"- READ SNOW LIQUID EQUIVALENT."
3721 call nemsio_readrecv(gfile,
"weasd",
"sfc", 1, dummy, 0, iret=rc)
3722 if (rc /= 0) call
error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
3723 dummy2d = reshape(dummy, (/i_input,j_input/))
3724 print*,
'weasd ',maxval(dummy2d),minval(dummy2d)
3727 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
3728 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
3729 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3732 if (localpet == 0)
then
3733 print*,
"- READ SNOW DEPTH."
3734 call nemsio_readrecv(gfile,
"snod",
"sfc", 1, dummy, 0, iret=rc)
3736 dummy2d = reshape(dummy, (/i_input,j_input/))
3737 print*,
'snod ',maxval(dummy2d),minval(dummy2d)
3740 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
3741 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3742 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3745 if (localpet == 0)
then
3746 print*,
"- READ VEG TYPE."
3747 call nemsio_readrecv(gfile,
"vtype",
"sfc", 1, dummy, 0, iret=rc)
3749 dummy2d = reshape(dummy, (/i_input,j_input/))
3750 print*,
'vtype ',maxval(dummy2d),minval(dummy2d)
3753 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
3754 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
3755 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3758 if (localpet == 0)
then
3759 print*,
"- READ SOIL TYPE."
3760 call nemsio_readrecv(gfile,
"sotyp",
"sfc", 1, dummy, 0, iret=rc)
3762 dummy2d = reshape(dummy, (/i_input,j_input/))
3763 print*,
'sotype ',maxval(dummy2d),minval(dummy2d)
3766 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
3767 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
3768 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3771 if (localpet == 0)
then
3772 print*,
"- READ T2M."
3773 call nemsio_readrecv(gfile,
"tmp",
"2 m above gnd", 1, dummy, 0, iret=rc)
3775 dummy2d = reshape(dummy, (/i_input,j_input/))
3776 print*,
't2m ',maxval(dummy2d),minval(dummy2d)
3779 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
3780 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
3781 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3784 if (localpet == 0)
then
3785 print*,
"- READ Q2M."
3786 call nemsio_readrecv(gfile,
"spfh",
"2 m above gnd", 1, dummy, 0, iret=rc)
3788 dummy2d = reshape(dummy, (/i_input,j_input/))
3789 print*,
'q2m ',maxval(dummy2d),minval(dummy2d)
3792 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
3793 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
3794 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3797 if (localpet == 0)
then
3798 print*,
"- READ TPRCP."
3799 call nemsio_readrecv(gfile,
"tprcp",
"sfc", 1, dummy, 0, iret=rc)
3801 dummy2d = reshape(dummy, (/i_input,j_input/))
3802 print*,
'tprcp ',maxval(dummy2d),minval(dummy2d)
3805 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
3806 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
3807 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3810 if (localpet == 0)
then
3811 print*,
"- READ FFMM."
3812 call nemsio_readrecv(gfile,
"ffmm",
"sfc", 1, dummy, 0, iret=rc)
3814 dummy2d = reshape(dummy, (/i_input,j_input/))
3815 print*,
'ffmm ',maxval(dummy2d),minval(dummy2d)
3818 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
3819 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
3820 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3823 if (localpet == 0)
then
3824 print*,
"- READ USTAR."
3825 call nemsio_readrecv(gfile,
"fricv",
"sfc", 1, dummy, 0, iret=rc)
3827 dummy2d = reshape(dummy, (/i_input,j_input/))
3828 print*,
'fricv ',maxval(dummy2d),minval(dummy2d)
3831 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
3832 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
3833 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3836 if (localpet == 0) dummy2d = 0.0
3837 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
3838 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
3839 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3842 if (localpet == 0)
then
3843 print*,
"- READ SKIN TEMPERATURE."
3844 call nemsio_readrecv(gfile,
"tmp",
"sfc", 1, dummy, 0, iret=rc)
3845 if (rc /= 0) call
error_handler(
"READING SKIN TEMPERATURE.", rc)
3846 dummy2d = reshape(dummy, (/i_input,j_input/))
3847 print*,
'tmp ',maxval(dummy2d),minval(dummy2d)
3850 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
3851 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3852 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3855 if (localpet == 0)
then
3856 print*,
"- READ F10M."
3857 call nemsio_readrecv(gfile,
"f10m",
"10 m above gnd", 1, dummy, 0, iret=rc)
3859 dummy2d = reshape(dummy, (/i_input,j_input/))
3860 print*,
'f10m ',maxval(dummy2d),minval(dummy2d)
3863 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
3864 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
3865 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3868 if (localpet == 0)
then
3869 print*,
"- READ CANOPY MOISTURE CONTENT."
3870 call nemsio_readrecv(gfile,
"cnwat",
"sfc", 1, dummy, 0, iret=rc)
3871 if (rc /= 0) call
error_handler(
"READING CANOPY MOISTURE CONTENT.", rc)
3872 dummy2d = reshape(dummy, (/i_input,j_input/))
3873 print*,
'cnwat ',maxval(dummy2d),minval(dummy2d)
3876 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
3877 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
3878 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3881 if (localpet == 0)
then
3883 call nemsio_readrecv(gfile,
"sfcr",
"sfc", 1, dummy, 0, iret=rc)
3885 dummy2d = reshape(dummy, (/i_input,j_input/))
3886 print*,
'sfcr ',maxval(dummy2d),minval(dummy2d)
3889 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
3890 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
3891 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3896 if (localpet == 0)
then
3897 print*,
"- READ LIQUID SOIL MOISTURE."
3898 call nemsio_readrecv(gfile,
"slc",
"soil layer", 1, dummy, 0, iret=rc)
3899 if (rc /= 0) call
error_handler(
"READING LAYER 1 LIQUID SOIL MOIST.", rc)
3900 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3901 call nemsio_readrecv(gfile,
"slc",
"soil layer", 2, dummy, 0, iret=rc)
3902 if (rc /= 0) call
error_handler(
"READING LAYER 2 LIQUID SOIL MOIST.", rc)
3903 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3904 call nemsio_readrecv(gfile,
"slc",
"soil layer", 3, dummy, 0, iret=rc)
3905 if (rc /= 0) call
error_handler(
"READING LAYER 3 LIQUID SOIL MOIST.", rc)
3906 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3907 call nemsio_readrecv(gfile,
"slc",
"soil layer", 4, dummy, 0, iret=rc)
3908 if (rc /= 0) call
error_handler(
"READING LAYER 4 LIQUID SOIL MOIST.", rc)
3909 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3910 print*,
'slc ',maxval(dummy3d),minval(dummy3d)
3913 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
3914 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
3915 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3918 if (localpet == 0)
then
3919 print*,
"- READ TOTAL SOIL MOISTURE."
3920 call nemsio_readrecv(gfile,
"smc",
"soil layer", 1, dummy, 0, iret=rc)
3921 if (rc /= 0) call
error_handler(
"READING LAYER 1 TOTAL SOIL MOIST.", rc)
3922 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3923 call nemsio_readrecv(gfile,
"smc",
"soil layer", 2, dummy, 0, iret=rc)
3924 if (rc /= 0) call
error_handler(
"READING LAYER 2 TOTAL SOIL MOIST.", rc)
3925 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3926 call nemsio_readrecv(gfile,
"smc",
"soil layer", 3, dummy, 0, iret=rc)
3927 if (rc /= 0) call
error_handler(
"READING LAYER 3 TOTAL SOIL MOIST.", rc)
3928 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3929 call nemsio_readrecv(gfile,
"smc",
"soil layer", 4, dummy, 0, iret=rc)
3930 if (rc /= 0) call
error_handler(
"READING LAYER 4 TOTAL SOIL MOIST.", rc)
3931 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3932 print*,
'smc ',maxval(dummy3d),minval(dummy3d)
3935 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
3936 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
3937 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3940 if (localpet == 0)
then
3941 print*,
"- READ SOIL TEMPERATURE."
3942 call nemsio_readrecv(gfile,
"stc",
"soil layer", 1, dummy, 0, iret=rc)
3943 if (rc /= 0) call
error_handler(
"READING LAYER 1 SOIL TEMP.", rc)
3944 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3945 call nemsio_readrecv(gfile,
"stc",
"soil layer", 2, dummy, 0, iret=rc)
3946 if (rc /= 0) call
error_handler(
"READING LAYER 2 SOIL TEMP.", rc)
3947 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3948 call nemsio_readrecv(gfile,
"stc",
"soil layer", 3, dummy, 0, iret=rc)
3949 if (rc /= 0) call
error_handler(
"READING LAYER 3 SOIL TEMP.", rc)
3950 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3951 call nemsio_readrecv(gfile,
"stc",
"soil layer", 4, dummy, 0, iret=rc)
3952 if (rc /= 0) call
error_handler(
"READING LAYER 4 SOIL TEMP.", rc)
3953 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3954 print*,
'stc ',maxval(dummy3d),minval(dummy3d)
3957 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
3958 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
3959 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3962 deallocate(dummy3d, dummy)
3964 if (localpet == 0) call nemsio_close(gfile)
3976 integer,
intent(in) :: localpet
3978 character(len=250) :: the_file
3982 real(nemsio_realkind),
allocatable :: dummy(:)
3983 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
3984 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
3986 type(nemsio_gfile
) :: gfile
3988 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
3990 if (localpet == 0)
then
3991 allocate(dummy3d(i_input,j_input,lsoil_input))
3992 allocate(dummy2d(i_input,j_input))
3993 allocate(dummy(i_input*j_input))
3994 print*,
"- OPEN FILE ", trim(the_file)
3995 call nemsio_open(gfile, the_file,
"read", iret=rc)
3998 allocate(dummy3d(0,0,0))
3999 allocate(dummy2d(0,0))
4003 if (localpet == 0)
then
4004 print*,
"- READ TERRAIN."
4005 call nemsio_readrecv(gfile,
"orog",
"sfc", 1, dummy, 0, iret=rc)
4007 dummy2d = reshape(dummy, (/i_input,j_input/))
4008 print*,
'orog ',maxval(dummy2d),minval(dummy2d)
4011 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
4012 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
4013 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4016 if (localpet == 0)
then
4017 print*,
"- READ LANDSEA MASK."
4018 call nemsio_readrecv(gfile,
"land",
"sfc", 1, dummy, 0, iret=rc)
4019 if (rc /= 0) call
error_handler(
"READING LANDSEA MASK.", rc)
4020 dummy2d = reshape(dummy, (/i_input,j_input/))
4021 print*,
'landmask ',maxval(dummy2d),minval(dummy2d)
4024 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
4025 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
4026 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4029 if (localpet == 0)
then
4030 print*,
"- READ SEAICE FRACTION."
4031 call nemsio_readrecv(gfile,
"icec",
"sfc", 1, dummy, 0, iret=rc)
4032 if (rc /= 0) call
error_handler(
"READING SEAICE FRACTION.", rc)
4033 dummy2d = reshape(dummy, (/i_input,j_input/))
4034 print*,
'icec ',maxval(dummy2d),minval(dummy2d)
4037 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
4038 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
4039 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4042 if (localpet == 0)
then
4043 print*,
"- READ SEAICE DEPTH."
4044 call nemsio_readrecv(gfile,
"icetk",
"sfc", 1, dummy, 0, iret=rc)
4045 if (rc /= 0) call
error_handler(
"READING SEAICE DEPTH.", rc)
4046 dummy2d = reshape(dummy, (/i_input,j_input/))
4047 print*,
'icetk ',maxval(dummy2d),minval(dummy2d)
4050 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
4051 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
4052 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4055 if (localpet == 0)
then
4056 print*,
"- READ SEAICE SKIN TEMPERATURE."
4057 call nemsio_readrecv(gfile,
"ti",
"sfc", 1, dummy, 0, iret=rc)
4058 if (rc /= 0) call
error_handler(
"READING SEAICE SKIN TEMP.", rc)
4059 dummy2d = reshape(dummy, (/i_input,j_input/))
4060 print*,
'ti ',maxval(dummy2d),minval(dummy2d)
4063 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
4064 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
4065 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4068 if (localpet == 0)
then
4069 print*,
"- READ SNOW LIQUID EQUIVALENT."
4070 call nemsio_readrecv(gfile,
"weasd",
"sfc", 1, dummy, 0, iret=rc)
4071 if (rc /= 0) call
error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
4072 dummy2d = reshape(dummy, (/i_input,j_input/))
4073 print*,
'weasd ',maxval(dummy2d),minval(dummy2d)
4076 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
4077 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
4078 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4081 if (localpet == 0)
then
4082 print*,
"- READ SNOW DEPTH."
4083 call nemsio_readrecv(gfile,
"snod",
"sfc", 1, dummy, 0, iret=rc)
4085 dummy2d = reshape(dummy, (/i_input,j_input/)) * 1000.0_8
4086 print*,
'snod ',maxval(dummy2d),minval(dummy2d)
4089 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
4090 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
4091 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4094 if (localpet == 0)
then
4095 print*,
"- READ VEG TYPE."
4096 call nemsio_readrecv(gfile,
"vtype",
"sfc", 1, dummy, 0, iret=rc)
4098 dummy2d = reshape(dummy, (/i_input,j_input/))
4099 print*,
'vtype ',maxval(dummy2d),minval(dummy2d)
4102 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
4103 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
4104 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4107 if (localpet == 0)
then
4108 print*,
"- READ SOIL TYPE."
4109 call nemsio_readrecv(gfile,
"sotyp",
"sfc", 1, dummy, 0, iret=rc)
4111 dummy2d = reshape(dummy, (/i_input,j_input/))
4112 print*,
'sotype ',maxval(dummy2d),minval(dummy2d)
4115 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
4116 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
4117 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4120 if (localpet == 0)
then
4121 print*,
"- READ T2M."
4122 call nemsio_readrecv(gfile,
"tmp",
"2 m above gnd", 1, dummy, 0, iret=rc)
4124 dummy2d = reshape(dummy, (/i_input,j_input/))
4125 print*,
't2m ',maxval(dummy2d),minval(dummy2d)
4128 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
4129 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
4130 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4133 if (localpet == 0)
then
4134 print*,
"- READ Q2M."
4135 call nemsio_readrecv(gfile,
"spfh",
"2 m above gnd", 1, dummy, 0, iret=rc)
4137 dummy2d = reshape(dummy, (/i_input,j_input/))
4138 print*,
'q2m ',maxval(dummy2d),minval(dummy2d)
4141 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
4142 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
4143 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4146 if (localpet == 0)
then
4147 print*,
"- READ TPRCP."
4148 call nemsio_readrecv(gfile,
"tprcp",
"sfc", 1, dummy, 0, iret=rc)
4150 dummy2d = reshape(dummy, (/i_input,j_input/))
4151 print*,
'tprcp ',maxval(dummy2d),minval(dummy2d)
4154 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
4155 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
4156 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4159 if (localpet == 0)
then
4160 print*,
"- READ FFMM."
4161 call nemsio_readrecv(gfile,
"ffmm",
"sfc", 1, dummy, 0, iret=rc)
4163 dummy2d = reshape(dummy, (/i_input,j_input/))
4164 print*,
'ffmm ',maxval(dummy2d),minval(dummy2d)
4167 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
4168 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
4169 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4172 if (localpet == 0)
then
4173 print*,
"- READ USTAR."
4174 call nemsio_readrecv(gfile,
"fricv",
"sfc", 1, dummy, 0, iret=rc)
4176 dummy2d = reshape(dummy, (/i_input,j_input/))
4177 print*,
'fricv ',maxval(dummy2d),minval(dummy2d)
4180 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
4181 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
4182 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4185 if (localpet == 0) dummy2d = 0.0
4186 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
4187 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
4188 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4191 if (localpet == 0)
then
4192 print*,
"- READ SKIN TEMPERATURE."
4193 call nemsio_readrecv(gfile,
"tmp",
"sfc", 1, dummy, 0, iret=rc)
4194 if (rc /= 0) call
error_handler(
"READING SKIN TEMPERATURE.", rc)
4195 dummy2d = reshape(dummy, (/i_input,j_input/))
4196 print*,
'tmp ',maxval(dummy2d),minval(dummy2d)
4199 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
4200 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
4201 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4204 if (localpet == 0)
then
4205 print*,
"- READ F10M."
4206 call nemsio_readrecv(gfile,
"f10m",
"10 m above gnd", 1, dummy, 0, iret=rc)
4208 dummy2d = reshape(dummy, (/i_input,j_input/))
4209 print*,
'f10m ',maxval(dummy2d),minval(dummy2d)
4212 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
4213 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
4214 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4217 if (localpet == 0)
then
4218 print*,
"- READ CANOPY MOISTURE CONTENT."
4219 call nemsio_readrecv(gfile,
"cnwat",
"sfc", 1, dummy, 0, iret=rc)
4220 if (rc /= 0) call
error_handler(
"READING CANOPY MOISTURE CONTENT.", rc)
4221 dummy2d = reshape(dummy, (/i_input,j_input/))
4222 print*,
'cnwat ',maxval(dummy2d),minval(dummy2d)
4225 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
4226 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
4227 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4230 if (localpet == 0)
then
4232 call nemsio_readrecv(gfile,
"sfcr",
"sfc", 1, dummy, 0, iret=rc)
4234 dummy2d = reshape(dummy, (/i_input,j_input/)) * 100.0_8
4235 print*,
'sfcr ',maxval(dummy2d),minval(dummy2d)
4238 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
4239 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
4240 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4245 if (localpet == 0)
then
4246 print*,
"- READ LIQUID SOIL MOISTURE."
4247 call nemsio_readrecv(gfile,
"soill",
"0-10 cm down", 1, dummy, 0, iret=rc)
4248 if (rc /= 0) call
error_handler(
"READING LAYER 1 LIQUID SOIL MOIST.", rc)
4249 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
4250 call nemsio_readrecv(gfile,
"soill",
"10-40 cm down", 1, dummy, 0, iret=rc)
4251 if (rc /= 0) call
error_handler(
"READING LAYER 2 LIQUID SOIL MOIST.", rc)
4252 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
4253 call nemsio_readrecv(gfile,
"soill",
"40-100 cm down", 1, dummy, 0, iret=rc)
4254 if (rc /= 0) call
error_handler(
"READING LAYER 3 LIQUID SOIL MOIST.", rc)
4255 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
4256 call nemsio_readrecv(gfile,
"soill",
"100-200 cm down", 1, dummy, 0, iret=rc)
4257 if (rc /= 0) call
error_handler(
"READING LAYER 4 LIQUID SOIL MOIST.", rc)
4258 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
4259 print*,
'soill ',maxval(dummy3d),minval(dummy3d)
4262 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
4263 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
4264 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4267 if (localpet == 0)
then
4268 print*,
"- READ TOTAL SOIL MOISTURE."
4269 call nemsio_readrecv(gfile,
"soilw",
"0-10 cm down", 1, dummy, 0, iret=rc)
4270 if (rc /= 0) call
error_handler(
"READING LAYER 1 TOTAL SOIL MOIST.", rc)
4271 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
4272 call nemsio_readrecv(gfile,
"soilw",
"10-40 cm down", 1, dummy, 0, iret=rc)
4273 if (rc /= 0) call
error_handler(
"READING LAYER 2 TOTAL SOIL MOIST.", rc)
4274 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
4275 call nemsio_readrecv(gfile,
"soilw",
"40-100 cm down", 1, dummy, 0, iret=rc)
4276 if (rc /= 0) call
error_handler(
"READING LAYER 3 TOTAL SOIL MOIST.", rc)
4277 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
4278 call nemsio_readrecv(gfile,
"soilw",
"100-200 cm down", 1, dummy, 0, iret=rc)
4279 if (rc /= 0) call
error_handler(
"READING LAYER 4 TOTAL SOIL MOIST.", rc)
4280 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
4281 print*,
'soilm ',maxval(dummy3d),minval(dummy3d)
4284 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
4285 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
4286 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4289 if (localpet == 0)
then
4290 print*,
"- READ SOIL TEMPERATURE."
4291 call nemsio_readrecv(gfile,
"tmp",
"0-10 cm down", 1, dummy, 0, iret=rc)
4292 if (rc /= 0) call
error_handler(
"READING LAYER 1 SOIL TEMP.", rc)
4293 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
4294 call nemsio_readrecv(gfile,
"tmp",
"10-40 cm down", 1, dummy, 0, iret=rc)
4295 if (rc /= 0) call
error_handler(
"READING LAYER 2 SOIL TEMP.", rc)
4296 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
4297 call nemsio_readrecv(gfile,
"tmp",
"40-100 cm down", 1, dummy, 0, iret=rc)
4298 if (rc /= 0) call
error_handler(
"READING LAYER 3 SOIL TEMP.", rc)
4299 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
4300 call nemsio_readrecv(gfile,
"tmp",
"100-200 cm down", 1, dummy, 0, iret=rc)
4301 if (rc /= 0) call
error_handler(
"READING LAYER 4 SOIL TEMP.", rc)
4302 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
4303 print*,
'soilt ',maxval(dummy3d),minval(dummy3d)
4306 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
4307 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
4308 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4311 deallocate(dummy3d, dummy)
4313 if (localpet == 0) call nemsio_close(gfile)
4325 integer,
intent(in) :: localpet
4327 character(len=500) :: tilefile
4329 integer :: error, rc
4330 integer :: id_dim, idim_input, jdim_input
4331 integer :: ncid, tile, id_var
4333 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
4334 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
4341 tilefile = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
4342 print*,
"- READ GRID DIMENSIONS FROM: ", trim(tilefile)
4343 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
4344 call
netcdf_err(error,
'opening: '//trim(tilefile) )
4346 error=nf90_inq_dimid(ncid,
'xaxis_1', id_dim)
4347 call
netcdf_err(error,
'reading xaxis_1 id' )
4348 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
4349 call
netcdf_err(error,
'reading xaxis_1 value' )
4351 error=nf90_inq_dimid(ncid,
'yaxis_1', id_dim)
4352 call
netcdf_err(error,
'reading yaxis_1 id' )
4353 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
4354 call
netcdf_err(error,
'reading yaxis_1 value' )
4356 if (idim_input /= i_input .or. jdim_input /= j_input)
then
4357 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 1)
4360 error = nf90_close(ncid)
4362 if (localpet == 0)
then
4363 allocate(data_one_tile(idim_input,jdim_input))
4364 allocate(data_one_tile_3d(idim_input,jdim_input,lsoil_input))
4366 allocate(data_one_tile(0,0))
4367 allocate(data_one_tile_3d(0,0,0))
4370 terrain_loop:
do tile = 1, num_tiles_input_grid
4372 if (localpet == 0)
then
4373 tilefile = trim(orog_dir_input_grid) // trim(orog_files_input_grid(tile))
4374 print*,
'- OPEN OROGRAPHY FILE: ', trim(tilefile)
4375 error=nf90_open(tilefile,nf90_nowrite,ncid)
4376 call
netcdf_err(error,
'OPENING OROGRAPHY FILE' )
4377 error=nf90_inq_varid(ncid,
'orog_raw', id_var)
4378 call
netcdf_err(error,
'READING OROG RECORD ID' )
4379 error=nf90_get_var(ncid, id_var, data_one_tile)
4380 call
netcdf_err(error,
'READING OROG RECORD' )
4381 print*,
'terrain check ',tile, maxval(data_one_tile)
4382 error=nf90_close(ncid)
4385 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
4386 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4387 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4392 tile_loop :
do tile = 1, num_tiles_input_grid
4396 if (localpet == 0)
then
4398 lsoil_input, sfcdata_3d=data_one_tile_3d)
4401 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
4402 call esmf_fieldscatter(soilm_liq_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4403 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4406 if (localpet == 0)
then
4408 lsoil_input, sfcdata_3d=data_one_tile_3d)
4411 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
4412 call esmf_fieldscatter(soilm_tot_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4413 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4416 if (localpet == 0)
then
4418 lsoil_input, sfcdata_3d=data_one_tile_3d)
4421 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
4422 call esmf_fieldscatter(soil_temp_input_grid, data_one_tile_3d, 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 LANDSEA MASK."
4434 call esmf_fieldscatter(landsea_mask_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 SEAICE FRACTION."
4446 call esmf_fieldscatter(seaice_fract_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)
4457 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
4458 call esmf_fieldscatter(seaice_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4459 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4464 if (localpet == 0)
then
4466 lsoil_input, sfcdata=data_one_tile)
4469 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
4470 call esmf_fieldscatter(seaice_skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4471 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4476 if (localpet == 0)
then
4478 lsoil_input, sfcdata=data_one_tile)
4481 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
4482 call esmf_fieldscatter(snow_liq_equiv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4483 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4488 if (localpet == 0)
then
4490 lsoil_input, sfcdata=data_one_tile)
4491 data_one_tile = data_one_tile
4494 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
4495 call esmf_fieldscatter(snow_depth_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 VEG TYPE."
4507 call esmf_fieldscatter(veg_type_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__)) &
4513 if (localpet == 0)
then
4515 lsoil_input, sfcdata=data_one_tile)
4518 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
4519 call esmf_fieldscatter(soil_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4520 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4525 if (localpet == 0)
then
4527 lsoil_input, sfcdata=data_one_tile)
4530 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
4531 call esmf_fieldscatter(t2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4532 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4537 if (localpet == 0)
then
4539 lsoil_input, sfcdata=data_one_tile)
4542 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
4543 call esmf_fieldscatter(q2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4544 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4547 if (localpet == 0)
then
4549 lsoil_input, sfcdata=data_one_tile)
4552 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
4553 call esmf_fieldscatter(tprcp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4554 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4557 if (localpet == 0)
then
4559 lsoil_input, sfcdata=data_one_tile)
4562 print*,
"- CALL FieldScatter FOR INPUT GRID F10M"
4563 call esmf_fieldscatter(f10m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4564 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4567 if (localpet == 0)
then
4569 lsoil_input, sfcdata=data_one_tile)
4572 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
4573 call esmf_fieldscatter(ffmm_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4574 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4577 if (localpet == 0)
then
4579 lsoil_input, sfcdata=data_one_tile)
4582 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
4583 call esmf_fieldscatter(ustar_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4584 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4587 if (localpet == 0)
then
4589 lsoil_input, sfcdata=data_one_tile)
4592 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
4593 call esmf_fieldscatter(srflag_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4594 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4597 if (localpet == 0)
then
4599 lsoil_input, sfcdata=data_one_tile)
4602 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
4603 call esmf_fieldscatter(skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4604 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4607 if (localpet == 0)
then
4609 lsoil_input, sfcdata=data_one_tile)
4612 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
4613 call esmf_fieldscatter(canopy_mc_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4614 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4617 if (localpet == 0)
then
4619 lsoil_input, sfcdata=data_one_tile)
4622 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
4623 call esmf_fieldscatter(z0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4624 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4629 deallocate(data_one_tile, data_one_tile_3d)
4642 integer,
intent(in) :: localpet
4644 character(len=500) :: tilefile
4646 integer :: error, id_var
4647 integer :: id_dim, idim_input, jdim_input
4648 integer :: ncid, rc, tile
4650 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
4651 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
4658 tilefile = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
4659 print*,
"- READ GRID DIMENSIONS FROM: ", trim(tilefile)
4660 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
4661 call
netcdf_err(error,
'opening: '//trim(tilefile) )
4663 error=nf90_inq_dimid(ncid,
'grid_xt', id_dim)
4664 call
netcdf_err(error,
'reading grid_xt id' )
4665 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
4666 call
netcdf_err(error,
'reading grid_xt value' )
4668 error=nf90_inq_dimid(ncid,
'grid_yt', id_dim)
4669 call
netcdf_err(error,
'reading grid_yt id' )
4670 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
4671 call
netcdf_err(error,
'reading grid_yt value' )
4673 if (idim_input /= i_input .or. jdim_input /= j_input)
then
4674 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 3)
4677 error = nf90_close(ncid)
4679 if (localpet == 0)
then
4680 allocate(data_one_tile(idim_input,jdim_input))
4681 allocate(data_one_tile_3d(idim_input,jdim_input,lsoil_input))
4683 allocate(data_one_tile(0,0))
4684 allocate(data_one_tile_3d(0,0,0))
4687 terrain_loop:
do tile = 1, num_tiles_input_grid
4689 if (trim(input_type) ==
"gaussian_netcdf")
then
4690 if (localpet == 0)
then
4692 lsoil_input, sfcdata=data_one_tile)
4697 if (localpet == 0)
then
4698 tilefile = trim(orog_dir_input_grid) // trim(orog_files_input_grid(tile))
4699 print*,
'- OPEN OROGRAPHY FILE: ', trim(tilefile)
4700 error=nf90_open(tilefile,nf90_nowrite,ncid)
4701 call
netcdf_err(error,
'OPENING OROGRAPHY FILE.' )
4702 error=nf90_inq_varid(ncid,
'orog_raw', id_var)
4703 call
netcdf_err(error,
'READING OROGRAPHY RECORD ID.' )
4704 error=nf90_get_var(ncid, id_var, data_one_tile)
4705 call
netcdf_err(error,
'READING OROGRAPHY RECORD.' )
4706 print*,
'terrain check history ',tile, maxval(data_one_tile)
4707 error=nf90_close(ncid)
4712 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
4713 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4714 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4719 tile_loop :
do tile = 1, num_tiles_input_grid
4723 if (localpet == 0)
then
4725 lsoil_input, sfcdata=data_one_tile)
4726 data_one_tile_3d(:,:,1) = data_one_tile
4728 lsoil_input, sfcdata=data_one_tile)
4729 data_one_tile_3d(:,:,2) = data_one_tile
4731 lsoil_input, sfcdata=data_one_tile)
4732 data_one_tile_3d(:,:,3) = data_one_tile
4734 lsoil_input, sfcdata=data_one_tile)
4735 data_one_tile_3d(:,:,4) = data_one_tile
4738 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
4739 call esmf_fieldscatter(soilm_liq_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4740 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4745 if (localpet == 0)
then
4747 lsoil_input, sfcdata=data_one_tile)
4748 data_one_tile_3d(:,:,1) = data_one_tile
4750 lsoil_input, sfcdata=data_one_tile)
4751 data_one_tile_3d(:,:,2) = data_one_tile
4753 lsoil_input, sfcdata=data_one_tile)
4754 data_one_tile_3d(:,:,3) = data_one_tile
4756 lsoil_input, sfcdata=data_one_tile)
4757 data_one_tile_3d(:,:,4) = data_one_tile
4760 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
4761 call esmf_fieldscatter(soilm_tot_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4762 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4767 if (localpet == 0)
then
4769 lsoil_input, sfcdata=data_one_tile)
4770 data_one_tile_3d(:,:,1) = data_one_tile
4772 lsoil_input, sfcdata=data_one_tile)
4773 data_one_tile_3d(:,:,2) = data_one_tile
4775 lsoil_input, sfcdata=data_one_tile)
4776 data_one_tile_3d(:,:,3) = data_one_tile
4778 lsoil_input, sfcdata=data_one_tile)
4779 data_one_tile_3d(:,:,4) = data_one_tile
4782 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
4783 call esmf_fieldscatter(soil_temp_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4784 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4789 if (localpet == 0)
then
4791 lsoil_input, sfcdata=data_one_tile)
4794 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
4795 call esmf_fieldscatter(landsea_mask_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4796 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4801 if (localpet == 0)
then
4803 lsoil_input, sfcdata=data_one_tile)
4806 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
4807 call esmf_fieldscatter(seaice_fract_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4808 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4813 if (localpet == 0)
then
4815 lsoil_input, sfcdata=data_one_tile)
4818 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
4819 call esmf_fieldscatter(seaice_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4820 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4825 if (localpet == 0)
then
4827 lsoil_input, sfcdata=data_one_tile)
4830 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
4831 call esmf_fieldscatter(seaice_skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4832 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4837 if (localpet == 0)
then
4839 lsoil_input, sfcdata=data_one_tile)
4842 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
4843 call esmf_fieldscatter(snow_liq_equiv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4844 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4849 if (localpet == 0)
then
4851 lsoil_input, sfcdata=data_one_tile)
4852 data_one_tile = data_one_tile * 1000.0
4855 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
4856 call esmf_fieldscatter(snow_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4857 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4862 if (localpet == 0)
then
4864 lsoil_input, sfcdata=data_one_tile)
4867 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
4868 call esmf_fieldscatter(veg_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4869 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4874 if (localpet == 0)
then
4876 lsoil_input, sfcdata=data_one_tile)
4879 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
4880 call esmf_fieldscatter(soil_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4881 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4886 if (localpet == 0)
then
4888 lsoil_input, sfcdata=data_one_tile)
4891 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
4892 call esmf_fieldscatter(t2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4893 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4898 if (localpet == 0)
then
4900 lsoil_input, sfcdata=data_one_tile)
4903 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
4904 call esmf_fieldscatter(q2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4905 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4908 if (localpet == 0)
then
4910 lsoil_input, sfcdata=data_one_tile)
4913 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
4914 call esmf_fieldscatter(tprcp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4915 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4918 if (localpet == 0)
then
4920 lsoil_input, sfcdata=data_one_tile)
4923 print*,
"- CALL FieldScatter FOR INPUT GRID F10M"
4924 call esmf_fieldscatter(f10m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4925 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4928 if (localpet == 0)
then
4930 lsoil_input, sfcdata=data_one_tile)
4933 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
4934 call esmf_fieldscatter(ffmm_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4935 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4938 if (localpet == 0)
then
4940 lsoil_input, sfcdata=data_one_tile)
4943 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
4944 call esmf_fieldscatter(ustar_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4945 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4948 if (localpet == 0)
then
4954 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
4955 call esmf_fieldscatter(srflag_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4956 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4959 if (localpet == 0)
then
4961 lsoil_input, sfcdata=data_one_tile)
4964 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
4965 call esmf_fieldscatter(skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4966 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4969 if (localpet == 0)
then
4971 lsoil_input, sfcdata=data_one_tile)
4974 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
4975 call esmf_fieldscatter(canopy_mc_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4976 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4979 if (localpet == 0)
then
4981 lsoil_input, sfcdata=data_one_tile)
4984 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
4985 call esmf_fieldscatter(z0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4986 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4991 deallocate(data_one_tile, data_one_tile_3d)
5003 use program_setup, only : vgtyp_from_climo, sotyp_from_climo
5009 integer,
intent(in) :: localpet
5011 character(len=250) :: the_file
5012 character(len=250) :: geo_file
5013 character(len=20) :: vname, vname_file, slev
5014 character(len=50) :: method
5017 integer :: rc, varnum, iret, i, j,k
5018 integer :: ncid2d, varid, varsize
5019 integer :: lugb, lugi
5020 integer :: jdisc, jgdtn, jpdtn
5021 integer :: jids(200), jgdt(200), jpdt(200)
5023 logical :: rap_latlon, unpack
5025 real(esmf_kind_r4) :: value
5026 real(esmf_kind_r4),
allocatable :: dummy2d(:,:)
5027 real(esmf_kind_r8),
allocatable :: icec_save(:,:)
5028 real(esmf_kind_r4),
allocatable :: dummy1d(:)
5029 real(esmf_kind_r8),
allocatable :: dummy2d_8(:,:),dummy2d_82(:,:),tsk_save(:,:)
5030 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:), dummy3d_stype(:,:,:)
5031 integer(esmf_kind_i4),
allocatable :: slmsk_save(:,:)
5032 integer(esmf_kind_i8),
allocatable :: dummy2d_i(:,:)
5034 type(gribfield
) :: gfld
5036 rap_latlon = trim(
to_upper(external_model))==
"RAP" .and. trim(input_grid_type) ==
"rotated_latlon"
5038 the_file = trim(data_dir_input_grid) //
"/" // trim(grib2_file_input_grid)
5039 geo_file = trim(geogrid_file_input_grid)
5041 print*,
"- READ SFC DATA FROM GRIB2 FILE: ", trim(the_file)
5045 if (localpet == 0)
then
5048 call baopenr(lugb,the_file,rc)
5049 if (rc /= 0) call
error_handler(
"ERROR OPENING GRIB2 FILE.", rc)
5064 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5065 unpack, k, gfld, rc)
5069 if (gfld%discipline == 2)
then
5070 if (gfld%ipdtnum == 0)
then
5071 if (gfld%ipdtmpl(1) == 0 .and. gfld%ipdtmpl(2) == 2)
then
5073 if (gfld%ipdtmpl(10) == 106 .and. gfld%ipdtmpl(13) == 106)
then
5075 lsoil_input = lsoil_input + 1
5085 print*,
"- FILE HAS ", lsoil_input,
" SOIL LEVELS."
5086 if (lsoil_input == 0) call
error_handler(
"COUNTING SOIL LEVELS.", rc)
5090 call mpi_barrier(mpi_comm_world, rc)
5091 call mpi_bcast(lsoil_input,1,mpi_integer,0,mpi_comm_world,rc)
5095 if (lsoil_input /= 4)
then
5097 call esmf_fielddestroy(soil_temp_input_grid, rc=rc)
5098 call esmf_fielddestroy(soilm_tot_input_grid, rc=rc)
5099 call esmf_fielddestroy(soilm_liq_input_grid, rc=rc)
5101 print*,
"- CALL FieldCreate FOR INPUT SOIL TEMPERATURE."
5102 soil_temp_input_grid = esmf_fieldcreate(input_grid, &
5103 typekind=esmf_typekind_r8, &
5104 staggerloc=esmf_staggerloc_center, &
5105 ungriddedlbound=(/1/), &
5106 ungriddedubound=(/lsoil_input/), rc=rc)
5107 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5110 print*,
"- CALL FieldCreate FOR INPUT TOTAL SOIL MOISTURE."
5111 soilm_tot_input_grid = esmf_fieldcreate(input_grid, &
5112 typekind=esmf_typekind_r8, &
5113 staggerloc=esmf_staggerloc_center, &
5114 ungriddedlbound=(/1/), &
5115 ungriddedubound=(/lsoil_input/), rc=rc)
5116 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5119 print*,
"- CALL FieldCreate FOR INPUT LIQUID SOIL MOISTURE."
5120 soilm_liq_input_grid = esmf_fieldcreate(input_grid, &
5121 typekind=esmf_typekind_r8, &
5122 staggerloc=esmf_staggerloc_center, &
5123 ungriddedlbound=(/1/), &
5124 ungriddedubound=(/lsoil_input/), rc=rc)
5125 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5130 if (localpet == 0)
then
5131 allocate(dummy2d(i_input,j_input))
5132 allocate(slmsk_save(i_input,j_input))
5133 allocate(tsk_save(i_input,j_input))
5134 allocate(icec_save(i_input,j_input))
5135 allocate(dummy2d_8(i_input,j_input))
5136 allocate(dummy2d_82(i_input,j_input))
5137 allocate(dummy3d(i_input,j_input,lsoil_input))
5139 allocate(dummy3d(0,0,0))
5140 allocate(dummy2d_8(0,0))
5141 allocate(dummy2d_82(0,0))
5142 allocate(dummy2d(0,0))
5143 allocate(slmsk_save(0,0))
5151 if (localpet == 0)
then
5153 print*,
"- READ TERRAIN."
5163 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5164 unpack, k, gfld, rc)
5167 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
5172 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
5173 call esmf_fieldscatter(terrain_input_grid, dummy2d_8, rootpet=0, rc=rc)
5174 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5177 if (localpet == 0)
then
5179 print*,
"- READ SEAICE FRACTION."
5189 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5190 unpack, k, gfld, rc)
5191 if (rc /= 0) call
error_handler(
"READING SEAICE FRACTION.", rc)
5193 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
5196 icec_save = dummy2d_8
5200 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
5201 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d_8 ,rootpet=0, rc=rc)
5202 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5213 if (localpet == 0)
then
5215 print*,
"- READ LANDSEA MASK."
5224 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5225 unpack, k, gfld, rc)
5229 print*,
'landnn ', maxval(gfld%fld),minval(gfld%fld)
5240 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5241 unpack, k, gfld, rc)
5242 if (rc /= 0) call
error_handler(
"READING LANDSEA MASK.", rc)
5248 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
5252 if(dummy2d_8(i,j) < 0.5_esmf_kind_r8) dummy2d_8(i,j)=0.0
5253 if(icec_save(i,j) > 0.15_esmf_kind_r8)
then
5254 dummy2d_8(i,j) = 2.0_esmf_kind_r8
5259 slmsk_save = nint(dummy2d_8)
5261 deallocate(icec_save)
5265 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
5266 call esmf_fieldscatter(landsea_mask_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
5272 print*,
"- READ SEAICE SKIN TEMPERATURE."
5282 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5283 unpack, k, gfld, rc)
5284 if (rc /= 0) call
error_handler(
"READING SEAICE SKIN TEMP.", rc)
5288 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
5292 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
5293 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d_8 ,rootpet=0, rc=rc)
5294 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5303 if (localpet == 0)
then
5305 print*,
"- READ SNOW LIQUID EQUIVALENT."
5316 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5317 unpack, k, gfld, rc)
5318 if (rc /= 0) call
error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
5322 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
5326 if(slmsk_save(i,j) == 0) dummy2d_8(i,j) = 0.0
5332 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
5333 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d_8 ,rootpet=0, rc=rc)
5334 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5337 if (localpet == 0)
then
5339 print*,
"- READ SNOW DEPTH."
5350 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5351 unpack, k, gfld, rc)
5356 gfld%fld = gfld%fld * 1000.0
5358 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
5363 if(slmsk_save(i,j) == 0) dummy2d_8(i,j) = 0.0
5369 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
5370 call esmf_fieldscatter(snow_depth_input_grid,dummy2d_8,rootpet=0, rc=rc)
5371 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5374 if (localpet == 0)
then
5376 print*,
"- READ T2M."
5388 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5389 unpack, k, gfld, rc)
5394 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
5398 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
5399 call esmf_fieldscatter(t2m_input_grid, dummy2d_8, rootpet=0,rc=rc)
5400 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5403 if (localpet == 0)
then
5405 print*,
"- READ Q2M."
5417 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5418 unpack, k, gfld, rc)
5423 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
5427 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
5428 call esmf_fieldscatter(q2m_input_grid,dummy2d_8, rootpet=0,rc=rc)
5429 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5432 if (localpet == 0)
then
5434 print*,
"- READ SKIN TEMPERATURE."
5445 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5446 unpack, k, gfld, rc)
5448 if (rc /= 0 ) call
error_handler(
"READING SKIN TEMPERATURE.", rc)
5451 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
5453 tsk_save(:,:) = dummy2d_8
5457 if(slmsk_save(i,j) == 0 .and. dummy2d_8(i,j) < 271.2)
then
5459 dummy2d_8(i,j) = 271.2
5461 if(slmsk_save(i,j) == 0 .and. dummy2d_8(i,j) > 310.)
then
5463 dummy2d_8(i,j) = 310.0
5470 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
5471 call esmf_fieldscatter(skin_temp_input_grid,dummy2d_8,rootpet=0, rc=rc)
5472 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5477 if (localpet == 0) dummy2d_8 = 0.0
5479 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
5480 call esmf_fieldscatter(srflag_input_grid,dummy2d_8, rootpet=0,rc=rc)
5481 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5484 if (localpet == 0)
then
5486 print*,
"- READ SOIL TYPE."
5497 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5498 unpack, k, gfld, rc)
5502 dummy2d = reshape(gfld%fld , (/i_input,j_input/))
5506 if (rc /= 0 .and. (trim(
to_upper(external_model))==
"HRRR" .or. rap_latlon) .and. geo_file .ne.
"NULL")
then
5510 print*,
"OPEN GEOGRID FILE ", trim(geo_file)
5511 rc = nf90_open(geo_file,nf90_nowrite,ncid2d)
5514 print*,
"INQURE ABOUT DIM IDS"
5515 rc = nf90_inq_dimid(ncid2d,
"west_east",varid)
5516 call
netcdf_err(rc,
"READING west_east DIMENSION FROM GEOGRID FILE")
5518 rc = nf90_inquire_dimension(ncid2d,varid,len=varsize)
5519 call
netcdf_err(rc,
"READING west_east DIMENSION SIZE")
5520 if (varsize .ne. i_input) call
error_handler(
"GEOGRID FILE GRID SIZE DIFFERS FROM INPUT DATA.", -1)
5522 print*,
"INQUIRE ABOUT SOIL TYPE FROM GEOGRID FILE"
5523 rc = nf90_inq_varid(ncid2d,
"SCT_DOM",varid)
5524 call
netcdf_err(rc,
"FINDING SCT_DOM IN GEOGRID FILE")
5526 print*,
"READ SOIL TYPE FROM GEOGRID FILE "
5527 rc = nf90_get_var(ncid2d,varid,dummy2d)
5528 call
netcdf_err(rc,
"READING SCT_DOM FROM FILE")
5530 print*,
"INQUIRE ABOUT SOIL TYPE FRACTIONS FROM GEOGRID FILE"
5531 rc = nf90_inq_varid(ncid2d,
"SOILCTOP",varid)
5532 call
netcdf_err(rc,
"FINDING SOILCTOP IN GEOGRID FILE")
5534 allocate(dummy3d_stype(i_input,j_input,16))
5535 print*,
"READ SOIL TYPE FRACTIONS FROM GEOGRID FILE "
5536 rc = nf90_get_var(ncid2d,varid,dummy3d_stype)
5537 call
netcdf_err(rc,
"READING SCT_DOM FROM FILE")
5539 print*,
"CLOSE GEOGRID FILE "
5540 iret = nf90_close(ncid2d)
5545 allocate(dummy1d(16))
5548 if(dummy2d(i,j) == 14.0_esmf_kind_r4 .and. slmsk_save(i,j) == 1)
then
5549 dummy1d(:) = dummy3d_stype(i,j,:)
5550 dummy1d(14) = 0.0_esmf_kind_r4
5551 dummy2d(i,j) =
real(MAXLOC(dummy1d, 1),esmf_kind_r4)
5556 deallocate(dummy3d_stype)
5559 if ((rc /= 0 .and. trim(
to_upper(external_model)) /=
"HRRR" .and. .not. rap_latlon) &
5560 .or. (rc /= 0 .and. (trim(
to_upper(external_model)) ==
"HRRR" .or. rap_latlon)))
then
5561 if (.not. sotyp_from_climo)
then
5562 call
error_handler(
"COULD NOT FIND SOIL TYPE IN FILE. PLEASE SET SOTYP_FROM_CLIMO=.TRUE. . EXITING", rc)
5566 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
5570 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. WILL NOT "//&
5571 "SCALE SOIL MOISTURE FOR DIFFERENCES IN SOIL TYPE. "
5572 dummy2d(:,:) = -99999.0_esmf_kind_r4
5581 if (.not. sotyp_from_climo)
then
5584 if(dummy2d(i,j) == 14.0_esmf_kind_r4 .and. slmsk_save(i,j) == 1) dummy2d(i,j) = -99999.9
5588 allocate(dummy2d_i(i_input,j_input))
5589 dummy2d_8 =
real(dummy2d,esmf_kind_r8)
5591 where(slmsk_save == 1) dummy2d_i = 1
5593 call
search(dummy2d_8,dummy2d_i,i_input,j_input,1,230)
5594 deallocate(dummy2d_i)
5596 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5599 print*,
'sotype ',maxval(dummy2d_8),minval(dummy2d_8)
5603 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
5604 call esmf_fieldscatter(soil_type_input_grid,dummy2d_8, rootpet=0, rc=rc)
5605 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5615 if (.not. vgfrc_from_climo)
then
5617 if (localpet == 0)
then
5619 print*,
"- READ VEG FRACTION."
5630 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5631 unpack, k, gfld, rc)
5634 call
error_handler(
"COULD NOT FIND VEGETATION FRACTION IN FILE. &
5635 PLEASE SET VGFRC_FROM_CLIMO=.TRUE. EXITING", rc)
5637 if (maxval(gfld%fld) > 2.0) gfld%fld = gfld%fld / 100.0
5639 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
5645 print*,
"- CALL FieldScatter FOR INPUT GRID VEG GREENNESS."
5646 call esmf_fieldscatter(veg_greenness_input_grid,dummy2d_8, rootpet=0, rc=rc)
5647 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5652 if (.not. minmax_vgfrc_from_climo)
then
5654 if (localpet == 0)
then
5656 print*,
"- READ MIN VEG FRACTION."
5668 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5669 unpack, k, gfld, rc)
5673 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5674 unpack, k, gfld, rc)
5677 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5678 unpack, k, gfld, rc)
5679 if (rc/=0) call
error_handler(
"COULD NOT FIND MIN VEGETATION FRACTION IN FILE. &
5680 PLEASE SET MINMAX_VGFRC_FROM_CLIMO=.TRUE. . EXITING",rc)
5684 if (maxval(gfld%fld) > 2.0) gfld%fld = gfld%fld / 100.0
5685 print*,
'vfrac min ', maxval(gfld%fld),minval(gfld%fld)
5686 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
5690 print*,
"- CALL FieldScatter FOR INPUT GRID MIN VEG GREENNESS."
5691 call esmf_fieldscatter(min_veg_greenness_input_grid,dummy2d_8, rootpet=0, rc=rc)
5692 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5695 if (localpet == 0)
then
5697 print*,
"- READ MAX VEG FRACTION."
5708 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5709 unpack, k, gfld, rc)
5712 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5713 unpack, k, gfld, rc)
5716 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5717 unpack, k, gfld, rc)
5718 if (rc <= 0) call
error_handler(
"COULD NOT FIND MAX VEGETATION FRACTION IN FILE. &
5719 PLEASE SET MINMAX_VGFRC_FROM_CLIMO=.TRUE. . EXITING",rc)
5723 if (maxval(gfld%fld) > 2.0) gfld%fld = gfld%fld / 100.0
5725 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
5729 print*,
"- CALL FieldScatter FOR INPUT GRID MAX VEG GREENNESS."
5730 call esmf_fieldscatter(max_veg_greenness_input_grid,dummy2d_8,rootpet=0, rc=rc)
5731 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5736 if (.not. lai_from_climo)
then
5738 if (localpet == 0)
then
5740 print*,
"- READ LAI."
5751 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5752 unpack, k, gfld, rc)
5754 if (rc /= 0) call
error_handler(
"COULD NOT FIND LAI IN FILE. &
5755 PLEASE SET LAI_FROM_CLIMO=.TRUE. . EXITING",rc)
5758 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
5762 print*,
"- CALL FieldScatter FOR INPUT GRID LAI."
5763 call esmf_fieldscatter(lai_input_grid,dummy2d_8,rootpet=0, rc=rc)
5764 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5769 if (localpet == 0)
then
5771 print*,
"- READ SEAICE DEPTH."
5774 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5786 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5787 unpack, k, gfld, rc)
5792 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL BE"//&
5793 " REPLACED WITH CLIMO. SET A FILL "// &
5794 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5795 dummy2d_8(:,:) = 0.0
5799 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
5804 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
5805 call esmf_fieldscatter(seaice_depth_input_grid,dummy2d_8, rootpet=0, rc=rc)
5806 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5809 if (localpet == 0)
then
5811 print*,
"- READ TPRCP."
5814 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5822 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
5823 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
5824 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5828 print*,
'tprcp ',maxval(dummy2d_8),minval(dummy2d_8)
5832 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
5833 call esmf_fieldscatter(tprcp_input_grid,dummy2d_8, rootpet=0, rc=rc)
5834 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5837 if (localpet == 0)
then
5839 print*,
"- READ FFMM."
5842 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5850 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
5851 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
5852 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5853 dummy2d_8(:,:) = 0.0
5856 print*,
'ffmm ',maxval(dummy2d_8),minval(dummy2d_8)
5860 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
5861 call esmf_fieldscatter(ffmm_input_grid,dummy2d_8, rootpet=0, rc=rc)
5862 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5865 if (localpet == 0)
then
5867 print*,
"- READ USTAR."
5870 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5882 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5883 unpack, k, gfld, rc)
5886 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5887 unpack, k, gfld, rc)
5892 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
5896 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL "//&
5897 "REPLACED WITH CLIMO. SET A FILL "// &
5898 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5899 dummy2d_8(:,:) = 0.0
5905 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
5906 call esmf_fieldscatter(ustar_input_grid,dummy2d_8, rootpet=0, rc=rc)
5907 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5910 if (localpet == 0)
then
5912 print*,
"- READ F10M."
5914 slev=
":10 m above ground:"
5915 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5922 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
5923 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
5924 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5925 dummy2d_8(:,:) = 0.0
5928 print*,
'f10m ',maxval(dummy2d_8),minval(dummy2d_8)
5932 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
5933 call esmf_fieldscatter(f10m_input_grid,dummy2d_8, rootpet=0, rc=rc)
5934 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5937 if (localpet == 0)
then
5939 print*,
"- READ CANOPY MOISTURE CONTENT."
5942 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5954 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5955 unpack, k, gfld, rc)
5959 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
5960 unpack, k, gfld, rc)
5964 print*,
'cnwat ', maxval(gfld%fld),minval(gfld%fld)
5965 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
5970 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL"//&
5971 " REPLACED WITH CLIMO. SET A FILL "// &
5972 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5979 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
5980 call esmf_fieldscatter(canopy_mc_input_grid,dummy2d_8, rootpet=0, rc=rc)
5981 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5984 if (localpet == 0)
then
5989 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
6001 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
6002 unpack, k, gfld, rc)
6007 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL BE"//&
6008 " REPLACED WITH CLIMO. SET A FILL "// &
6009 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
6010 dummy2d_8(:,:) = 0.0
6013 gfld%fld = gfld%fld * 10.0
6015 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
6020 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
6021 call esmf_fieldscatter(z0_input_grid,dummy2d_8, rootpet=0, rc=rc)
6022 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
6025 if (localpet == 0)
then
6026 print*,
"- READ LIQUID SOIL MOISTURE."
6028 vname_file =
":SOILL:"
6033 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
6034 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
6035 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
6038 if (localpet == 0)
then
6039 print*,
"- READ TOTAL SOIL MOISTURE."
6041 vname_file =
"var2_2_1_"
6045 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
6046 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
6047 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
6056 print*,
"- CALL FieldGather for INPUT SOIL TYPE."
6057 call esmf_fieldgather(soil_type_input_grid, dummy2d_82, rootpet=0, tile=1, rc=rc)
6058 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6061 if (localpet == 0)
then
6063 print*,
"- READ VEG TYPE."
6074 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
6075 unpack, k, gfld, rc)
6078 if (.not. vgtyp_from_climo)
then
6079 call
error_handler(
"COULD NOT FIND VEGETATION TYPE IN FILE. PLEASE SET VGTYP_FROM_CLIMO=.TRUE. . EXITING", rc)
6083 dummy2d_8(i,j) = 0.0
6084 if(slmsk_save(i,j) == 1 .and. dummy3d(i,j,1) > 0.99) &
6086 dummy2d_8(i,j) =
real(veg_type_landice_input,esmf_kind_r8)
6091 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
6094 if (trim(external_model) .ne.
"GFS")
then
6097 if (dummy2d_8(i,j) == 15.0_esmf_kind_r8 .and. slmsk_save(i,j) == 1)
then
6098 if (dummy3d(i,j,1) < 0.6)
then
6099 dummy2d_8(i,j) =
real(veg_type_landice_input,esmf_kind_r8)
6100 elseif (dummy3d(i,j,1) > 0.99)
then
6102 dummy2d_8(i,j) = 0.0_esmf_kind_r8
6103 dummy2d_82(i,j) = 0.0_esmf_kind_r8
6105 elseif (dummy2d_8(i,j) == 17.0_esmf_kind_r8 .and. slmsk_save(i,j)==0)
then
6106 dummy2d_8(i,j) = 0.0_esmf_kind_r8
6116 print*,
"- CALL FieldScatter FOR INPUT VEG TYPE."
6117 call esmf_fieldscatter(veg_type_input_grid, dummy2d_8, rootpet=0, rc=rc)
6118 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
6121 print*,
"- CALL FieldScatter FOR INPUT SOIL TYPE."
6122 call esmf_fieldscatter(soil_type_input_grid, dummy2d_82, rootpet=0, rc=rc)
6123 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
6126 deallocate(dummy2d_82)
6128 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
6129 call esmf_fieldscatter(landsea_mask_input_grid,
real(slmsk_save,esmf_kind_r8),rootpet=0, rc=rc)
6130 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
6140 if (localpet == 0)
then
6141 print*,
"- READ SOIL TEMPERATURE."
6143 vname_file =
":TSOIL:"
6146 deallocate(tsk_save)
6149 deallocate(slmsk_save)
6151 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
6152 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
6153 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
6157 deallocate(dummy2d_8)
6159 if (localpet == 0) call baclose(lugb, rc)
6172 integer,
intent(in) :: localpet
6174 character(len=10) :: field
6178 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
6180 if (localpet == 0)
then
6181 allocate(data_one_tile(i_input,j_input))
6183 allocate(data_one_tile(0,0))
6186 tile_loop :
do tile = 1, num_tiles_input_grid
6190 if (localpet == 0)
then
6191 if (trim(input_type) ==
"restart")
then
6197 lsoil_input, sfcdata=data_one_tile)
6200 print*,
"- CALL FieldScatter FOR INPUT C_D"
6201 call esmf_fieldscatter(c_d_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
6202 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6207 if (localpet == 0)
then
6208 if (trim(input_type) ==
"restart")
then
6214 lsoil_input, sfcdata=data_one_tile)
6217 print*,
"- CALL FieldScatter FOR INPUT C_0"
6218 call esmf_fieldscatter(c_0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
6219 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6224 if (localpet == 0)
then
6225 if (trim(input_type) ==
"restart")
then
6231 lsoil_input, sfcdata=data_one_tile)
6234 print*,
"- CALL FieldScatter FOR INPUT D_CONV."
6235 call esmf_fieldscatter(d_conv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
6236 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6241 if (localpet == 0)
then
6242 if (trim(input_type) ==
"restart")
then
6248 lsoil_input, sfcdata=data_one_tile)
6251 print*,
"- CALL FieldScatter FOR INPUT DT_COOL."
6252 call esmf_fieldscatter(dt_cool_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
6253 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6258 if (localpet == 0)
then
6262 print*,
"- CALL FieldScatter FOR INPUT IFD."
6263 call esmf_fieldscatter(ifd_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
6264 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6269 if (localpet == 0)
then
6271 lsoil_input, sfcdata=data_one_tile)
6274 print*,
"- CALL FieldScatter FOR INPUT QRAIN."
6275 call esmf_fieldscatter(qrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
6276 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6281 if (localpet == 0)
then
6283 lsoil_input, sfcdata=data_one_tile)
6286 print*,
"- CALL FieldScatter FOR INPUT TREF"
6287 call esmf_fieldscatter(tref_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
6288 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6293 if (localpet == 0)
then
6294 if (trim(input_type) ==
"restart")
then
6300 lsoil_input, sfcdata=data_one_tile)
6303 print*,
"- CALL FieldScatter FOR INPUT W_D"
6304 call esmf_fieldscatter(w_d_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
6305 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6310 if (localpet == 0)
then
6311 if (trim(input_type) ==
"restart")
then
6317 lsoil_input, sfcdata=data_one_tile)
6320 print*,
"- CALL FieldScatter FOR INPUT W_0"
6321 call esmf_fieldscatter(w_0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
6322 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6327 if (localpet == 0)
then
6329 lsoil_input, sfcdata=data_one_tile)
6332 print*,
"- CALL FieldScatter FOR INPUT XS"
6333 call esmf_fieldscatter(xs_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
6334 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6339 if (localpet == 0)
then
6341 lsoil_input, sfcdata=data_one_tile)
6344 print*,
"- CALL FieldScatter FOR INPUT XT"
6345 call esmf_fieldscatter(xt_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
6346 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6351 if (localpet == 0)
then
6353 lsoil_input, sfcdata=data_one_tile)
6356 print*,
"- CALL FieldScatter FOR INPUT XU"
6357 call esmf_fieldscatter(xu_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
6358 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6363 if (localpet == 0)
then
6365 lsoil_input, sfcdata=data_one_tile)
6368 print*,
"- CALL FieldScatter FOR INPUT XV"
6369 call esmf_fieldscatter(xv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
6370 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6375 if (localpet == 0)
then
6377 lsoil_input, sfcdata=data_one_tile)
6380 print*,
"- CALL FieldScatter FOR INPUT XZ"
6381 call esmf_fieldscatter(xz_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
6382 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6387 if (localpet == 0)
then
6389 lsoil_input, sfcdata=data_one_tile)
6392 print*,
"- CALL FieldScatter FOR INPUT XTTS"
6393 call esmf_fieldscatter(xtts_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
6394 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6399 if (localpet == 0)
then
6401 lsoil_input, sfcdata=data_one_tile)
6404 print*,
"- CALL FieldScatter FOR INPUT XZTS"
6405 call esmf_fieldscatter(xzts_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
6406 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6411 if (localpet == 0)
then
6412 if (trim(input_type) ==
"restart")
then
6418 lsoil_input, sfcdata=data_one_tile)
6421 print*,
"- CALL FieldScatter FOR INPUT Z_C"
6422 call esmf_fieldscatter(z_c_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
6423 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6428 if (localpet == 0)
then
6432 print*,
"- CALL FieldScatter FOR INPUT ZM"
6433 call esmf_fieldscatter(zm_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
6434 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6439 deallocate(data_one_tile)
6456 integer,
intent(in) :: localpet
6458 character(len=300) :: the_file
6462 real(nemsio_realkind),
allocatable :: dummy(:)
6463 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
6465 type(nemsio_gfile
) :: gfile
6467 if (trim(input_type) ==
"gfs_gaussian_nemsio")
then
6469 the_file = trim(data_dir_input_grid) //
"/" // trim(nst_files_input_grid)
6471 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
6474 print*,
"- READ NST DATA FROM: ", trim(the_file)
6476 if (localpet == 0)
then
6477 allocate(dummy(i_input*j_input))
6478 allocate(dummy2d(i_input,j_input))
6479 call nemsio_open(gfile, the_file,
"read", iret=rc)
6482 allocate(dummy2d(0,0))
6485 if (localpet == 0)
then
6486 print*,
"- READ TREF"
6487 call nemsio_readrecv(gfile,
"tref",
"sfc", 1, dummy, 0, iret=rc)
6489 dummy2d = reshape(dummy, (/i_input,j_input/))
6490 print*,
'tref ',maxval(dummy2d),minval(dummy2d)
6493 print*,
"- CALL FieldScatter FOR INPUT TREF."
6494 call esmf_fieldscatter(tref_input_grid, dummy2d, rootpet=0, rc=rc)
6495 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6498 if (localpet == 0)
then
6500 call nemsio_readrecv(gfile,
"cd",
"sfc", 1, dummy, 0, iret=rc)
6502 dummy2d = reshape(dummy, (/i_input,j_input/))
6503 print*,
'cd ',maxval(dummy2d),minval(dummy2d)
6506 print*,
"- CALL FieldScatter FOR INPUT C_D."
6507 call esmf_fieldscatter(c_d_input_grid, dummy2d, rootpet=0, rc=rc)
6508 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6511 if (localpet == 0)
then
6513 call nemsio_readrecv(gfile,
"c0",
"sfc", 1, dummy, 0, iret=rc)
6515 dummy2d = reshape(dummy, (/i_input,j_input/))
6516 print*,
'c0 ',maxval(dummy2d),minval(dummy2d)
6519 print*,
"- CALL FieldScatter FOR INPUT C_0."
6520 call esmf_fieldscatter(c_0_input_grid, dummy2d, rootpet=0, rc=rc)
6521 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6524 if (localpet == 0)
then
6525 print*,
"- READ DCONV"
6526 call nemsio_readrecv(gfile,
"dconv",
"sfc", 1, dummy, 0, iret=rc)
6528 dummy2d = reshape(dummy, (/i_input,j_input/))
6529 print*,
'dconv ',maxval(dummy2d),minval(dummy2d)
6532 print*,
"- CALL FieldScatter FOR INPUT D_CONV."
6533 call esmf_fieldscatter(d_conv_input_grid, dummy2d, rootpet=0, rc=rc)
6534 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6537 if (localpet == 0)
then
6538 print*,
"- READ DTCOOL"
6539 call nemsio_readrecv(gfile,
"dtcool",
"sfc", 1, dummy, 0, iret=rc)
6541 dummy2d = reshape(dummy, (/i_input,j_input/))
6542 print*,
'dtcool ',maxval(dummy2d),minval(dummy2d)
6545 print*,
"- CALL FieldScatter FOR INPUT DT_COOL."
6546 call esmf_fieldscatter(dt_cool_input_grid, dummy2d, rootpet=0, rc=rc)
6547 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6550 if (localpet == 0)
then
6554 print*,
"- CALL FieldScatter FOR INPUT IFD."
6555 call esmf_fieldscatter(ifd_input_grid, dummy2d, rootpet=0, rc=rc)
6556 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6559 if (localpet == 0)
then
6560 print*,
"- READ QRAIN"
6561 call nemsio_readrecv(gfile,
"qrain",
"sfc", 1, dummy, 0, iret=rc)
6563 dummy2d = reshape(dummy, (/i_input,j_input/))
6564 print*,
'qrain ',maxval(dummy2d),minval(dummy2d)
6567 print*,
"- CALL FieldScatter FOR INPUT QRAIN."
6568 call esmf_fieldscatter(qrain_input_grid, dummy2d, rootpet=0, rc=rc)
6569 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6572 if (localpet == 0)
then
6574 call nemsio_readrecv(gfile,
"wd",
"sfc", 1, dummy, 0, iret=rc)
6576 dummy2d = reshape(dummy, (/i_input,j_input/))
6577 print*,
'wd ',maxval(dummy2d),minval(dummy2d)
6580 print*,
"- CALL FieldScatter FOR INPUT WD."
6581 call esmf_fieldscatter(w_d_input_grid, dummy2d, rootpet=0, rc=rc)
6582 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6585 if (localpet == 0)
then
6587 call nemsio_readrecv(gfile,
"w0",
"sfc", 1, dummy, 0, iret=rc)
6589 dummy2d = reshape(dummy, (/i_input,j_input/))
6590 print*,
'w0 ',maxval(dummy2d),minval(dummy2d)
6593 print*,
"- CALL FieldScatter FOR INPUT W0."
6594 call esmf_fieldscatter(w_0_input_grid, dummy2d, rootpet=0, rc=rc)
6595 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6598 if (localpet == 0)
then
6600 call nemsio_readrecv(gfile,
"xs",
"sfc", 1, dummy, 0, iret=rc)
6602 dummy2d = reshape(dummy, (/i_input,j_input/))
6603 print*,
'xs ',maxval(dummy2d),minval(dummy2d)
6606 print*,
"- CALL FieldScatter FOR INPUT XS."
6607 call esmf_fieldscatter(xs_input_grid, dummy2d, rootpet=0, rc=rc)
6608 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6611 if (localpet == 0)
then
6613 call nemsio_readrecv(gfile,
"xt",
"sfc", 1, dummy, 0, iret=rc)
6615 dummy2d = reshape(dummy, (/i_input,j_input/))
6616 print*,
'xt ',maxval(dummy2d),minval(dummy2d)
6619 print*,
"- CALL FieldScatter FOR INPUT XT."
6620 call esmf_fieldscatter(xt_input_grid, dummy2d, rootpet=0, rc=rc)
6621 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6624 if (localpet == 0)
then
6626 call nemsio_readrecv(gfile,
"xu",
"sfc", 1, dummy, 0, iret=rc)
6628 dummy2d = reshape(dummy, (/i_input,j_input/))
6629 print*,
'xu ',maxval(dummy2d),minval(dummy2d)
6632 print*,
"- CALL FieldScatter FOR INPUT XU."
6633 call esmf_fieldscatter(xu_input_grid, dummy2d, rootpet=0, rc=rc)
6634 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6637 if (localpet == 0)
then
6639 call nemsio_readrecv(gfile,
"xv",
"sfc", 1, dummy, 0, iret=rc)
6641 dummy2d = reshape(dummy, (/i_input,j_input/))
6642 print*,
'xv ',maxval(dummy2d),minval(dummy2d)
6645 print*,
"- CALL FieldScatter FOR INPUT XV."
6646 call esmf_fieldscatter(xv_input_grid, dummy2d, rootpet=0, rc=rc)
6647 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6650 if (localpet == 0)
then
6652 call nemsio_readrecv(gfile,
"xz",
"sfc", 1, dummy, 0, iret=rc)
6654 dummy2d = reshape(dummy, (/i_input,j_input/))
6655 print*,
'xz ',maxval(dummy2d),minval(dummy2d)
6658 print*,
"- CALL FieldScatter FOR INPUT XZ."
6659 call esmf_fieldscatter(xz_input_grid, dummy2d, rootpet=0, rc=rc)
6660 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6663 if (localpet == 0)
then
6664 print*,
"- READ XTTS"
6665 call nemsio_readrecv(gfile,
"xtts",
"sfc", 1, dummy, 0, iret=rc)
6667 dummy2d = reshape(dummy, (/i_input,j_input/))
6668 print*,
'xtts ',maxval(dummy2d),minval(dummy2d)
6671 print*,
"- CALL FieldScatter FOR INPUT XTTS."
6672 call esmf_fieldscatter(xtts_input_grid, dummy2d, rootpet=0, rc=rc)
6673 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6676 if (localpet == 0)
then
6677 print*,
"- READ XZTS"
6678 call nemsio_readrecv(gfile,
"xzts",
"sfc", 1, dummy, 0, iret=rc)
6680 dummy2d = reshape(dummy, (/i_input,j_input/))
6681 print*,
'xzts ',maxval(dummy2d),minval(dummy2d)
6684 print*,
"- CALL FieldScatter FOR INPUT XZTS."
6685 call esmf_fieldscatter(xzts_input_grid, dummy2d, rootpet=0, rc=rc)
6686 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6689 if (localpet == 0)
then
6691 call nemsio_readrecv(gfile,
"zc",
"sfc", 1, dummy, 0, iret=rc)
6693 dummy2d = reshape(dummy, (/i_input,j_input/))
6694 print*,
'zc ',maxval(dummy2d),minval(dummy2d)
6697 print*,
"- CALL FieldScatter FOR INPUT Z_C."
6698 call esmf_fieldscatter(z_c_input_grid, dummy2d, rootpet=0, rc=rc)
6699 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6702 if (localpet == 0)
then
6706 print*,
"- CALL FieldScatter FOR INPUT ZM."
6707 call esmf_fieldscatter(zm_input_grid, dummy2d, rootpet=0, rc=rc)
6708 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6711 deallocate(dummy, dummy2d)
6713 if (localpet == 0) call nemsio_close(gfile)
6728 sfcdata, sfcdata_3d)
6732 CHARACTER(LEN=*),
INTENT(IN) :: field
6734 INTEGER,
INTENT(IN) :: imo, jmo, lmo, tile_num
6736 REAL(ESMF_KIND_R8),
INTENT(OUT),
OPTIONAL :: sfcdata(imo,jmo)
6737 REAL(ESMF_KIND_R8),
INTENT(OUT),
OPTIONAL :: sfcdata_3d(imo,jmo,lmo)
6739 CHARACTER(LEN=256) :: tilefile
6741 INTEGER :: error, ncid, id_var
6743 tilefile = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(tile_num))
6745 print*,
'WILL READ ',trim(field),
' FROM: ', trim(tilefile)
6747 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
6748 CALL
netcdf_err(error,
'OPENING: '//trim(tilefile) )
6750 error=nf90_inq_varid(ncid, field, id_var)
6753 IF (present(sfcdata_3d))
THEN
6754 error=nf90_get_var(ncid, id_var, sfcdata_3d)
6757 error=nf90_get_var(ncid, id_var, sfcdata)
6761 error = nf90_close(ncid)
6783 integer,
intent(in) :: localpet, lugb
6785 logical,
intent(in) :: isnative
6787 real(esmf_kind_r8),
intent(inout),
allocatable :: u(:,:,:),v(:,:,:)
6788 real(esmf_kind_r8),
intent(in),
dimension(lev_input) :: rlevs
6790 real(esmf_kind_r4),
dimension(i_input,j_input) :: alpha
6791 real(esmf_kind_r8),
dimension(i_input,j_input) :: lon, lat
6792 real(esmf_kind_r4),
allocatable :: u_tmp(:,:),v_tmp(:,:)
6793 real(esmf_kind_r8),
allocatable :: dum2d(:,:)
6794 real(esmf_kind_r4),
dimension(i_input,j_input) :: ws,wd
6795 real(esmf_kind_r4) :: value_u, value_v,lov,latin1,latin2
6796 real(esmf_kind_r8) :: d2r
6798 integer :: varnum_u, varnum_v, vlev, &
6800 integer :: j, k, lugi, jgdtn, jpdtn
6801 integer :: jdisc, jids(200), jgdt(200), jpdt(200)
6803 character(len=20) :: vname
6804 character(len=50) :: method_u, method_v
6808 type(gribfield
) :: gfld
6810 d2r=acos(-1.0_esmf_kind_r8) / 180.0_esmf_kind_r8
6811 if (localpet==0)
then
6812 allocate(u(i_input,j_input,lev_input))
6813 allocate(v(i_input,j_input,lev_input))
6820 call
get_var_cond(vname,this_miss_var_method=method_u, this_miss_var_value=value_u, &
6823 call
get_var_cond(vname,this_miss_var_method=method_v, this_miss_var_value=value_v, &
6826 print*,
"- CALL FieldGather FOR INPUT GRID LONGITUDE"
6827 call esmf_fieldgather(longitude_input_grid, lon, rootpet=0, tile=1, rc=error)
6828 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6831 print*,
"- CALL FieldGather FOR INPUT GRID LATITUDE"
6832 call esmf_fieldgather(latitude_input_grid, lat, rootpet=0, tile=1, rc=error)
6833 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6836 if (localpet==0)
then
6848 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
6849 unpack, k, gfld, iret)
6851 if (iret /= 0) call
error_handler(
"ERROR READING GRIB2 FILE.", iret)
6853 if (gfld%igdtnum == 32769)
then
6855 latin1 = float(gfld%igdtmpl(15))/1.0e6
6856 lov = float(gfld%igdtmpl(16))/1.0e6
6858 print*,
"- CALL CALCALPHA_ROTLATLON with center lat,lon = ",latin1,lov
6861 elseif (gfld%igdtnum == 30)
then
6863 lov = float(gfld%igdtmpl(14))/1.0e6
6864 latin1 = float(gfld%igdtmpl(19))/1.0e6
6865 latin2 = float(gfld%igdtmpl(20))/1.0e6
6867 print*,
"- CALL GRIDROT for LC grid with lov,latin1/2 = ",lov,latin1,latin2
6868 call
gridrot(lov,latin1,latin2,lon,alpha)
6880 allocate(dum2d(i_input,j_input))
6881 allocate(u_tmp(i_input,j_input))
6882 allocate(v_tmp(i_input,j_input))
6884 do vlev = 1, lev_input
6890 jpdt(12) = nint(rlevs(vlev))
6892 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
6893 unpack, k, gfld, iret)
6896 call
handle_grib_error(vname, slevs(vlev),method_u,value_u,varnum_u,iret,var=u_tmp)
6898 call
error_handler(
"READING IN U AT LEVEL "//trim(slevs(vlev))//
". SET A FILL "// &
6899 "VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",iret)
6902 dum2d = reshape(gfld%fld, (/i_input,j_input/) )
6910 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
6911 unpack, k, gfld, iret)
6914 call
handle_grib_error(vname, slevs(vlev),method_v,value_v,varnum_v,iret,var=v_tmp)
6916 call
error_handler(
"READING IN V AT LEVEL "//trim(slevs(vlev))//
". SET A FILL "// &
6917 "VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",iret)
6920 dum2d = reshape(gfld%fld, (/i_input,j_input/) )
6926 if (gfld%igdtnum == 0)
then
6927 if (external_model ==
'UKMET')
then
6929 v(:,:,vlev) = (v_tmp(:,2:jp1_input) + v_tmp(:,1:j_input))/2
6934 else if (gfld%igdtnum == 32769)
then
6935 ws = sqrt(u_tmp**2 + v_tmp**2)
6936 wd = atan2(-u_tmp,-v_tmp) / d2r
6937 wd = wd + alpha + 180.0
6939 u(:,:,vlev) = -ws*cos(wd*d2r)
6940 v(:,:,vlev) = -ws*sin(wd*d2r)
6942 u(:,:,vlev) =
real(u_tmp * cos(alpha) + v_tmp * sin(alpha),esmf_kind_r8)
6943 v(:,:,vlev) =
real(v_tmp * cos(alpha) - u_tmp * sin(alpha),esmf_kind_r8)
6946 print*,
'max, min U ', minval(u(:,:,vlev)), maxval(u(:,:,vlev))
6947 print*,
'max, min V ', minval(v(:,:,vlev)), maxval(v(:,:,vlev))
6960 integer :: clb(4), cub(4)
6961 integer :: i, j, k, rc
6963 real(esmf_kind_r8) :: latrad, lonrad
6964 real(esmf_kind_r8),
pointer :: windptr(:,:,:,:)
6965 real(esmf_kind_r8),
pointer :: uptr(:,:,:)
6966 real(esmf_kind_r8),
pointer :: vptr(:,:,:)
6967 real(esmf_kind_r8),
pointer :: latptr(:,:)
6968 real(esmf_kind_r8),
pointer :: lonptr(:,:)
6970 print*,
"- CALL FieldGet FOR 3-D WIND."
6971 call esmf_fieldget(wind_input_grid, &
6972 computationallbound=clb, &
6973 computationalubound=cub, &
6974 farrayptr=windptr, rc=rc)
6975 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6978 print*,
"- CALL FieldGet FOR U."
6979 call esmf_fieldget(u_input_grid, &
6980 farrayptr=uptr, rc=rc)
6981 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6984 print*,
"- CALL FieldGet FOR V."
6985 call esmf_fieldget(v_input_grid, &
6986 farrayptr=vptr, rc=rc)
6987 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6990 print*,
"- CALL FieldGet FOR LATITUDE."
6991 call esmf_fieldget(latitude_input_grid, &
6992 farrayptr=latptr, rc=rc)
6993 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6996 print*,
"- CALL FieldGet FOR LONGITUDE."
6997 call esmf_fieldget(longitude_input_grid, &
6998 farrayptr=lonptr, rc=rc)
6999 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
7002 do i = clb(1), cub(1)
7003 do j = clb(2), cub(2)
7004 latrad = latptr(i,j) * acos(-1.) / 180.0
7005 lonrad = lonptr(i,j) * acos(-1.) / 180.0
7006 do k = clb(3), cub(3)
7007 windptr(i,j,k,1) = uptr(i,j,k) * cos(lonrad) - vptr(i,j,k) * sin(latrad) * sin(lonrad)
7008 windptr(i,j,k,2) = uptr(i,j,k) * sin(lonrad) + vptr(i,j,k) * sin(latrad) * cos(lonrad)
7009 windptr(i,j,k,3) = vptr(i,j,k) * cos(latrad)
7014 call esmf_fielddestroy(u_input_grid, rc=rc)
7015 call esmf_fielddestroy(v_input_grid, rc=rc)
7038 real(esmf_kind_r4),
intent(in) :: lov,latin1,latin2
7039 real(esmf_kind_r4),
intent(inout) :: rot(i_input,j_input)
7040 real(esmf_kind_r8),
intent(in) :: lon(i_input,j_input)
7042 real(esmf_kind_r4) :: trot(i_input,j_input), tlon(i_input,j_input)
7043 real(esmf_kind_r4) :: dtor = 3.14159265359/180.0_esmf_kind_r4
7044 real(esmf_kind_r4) :: an
7050 if ( (latin1 - latin2) .lt. 0.000001 )
then
7051 an = sin(latin1*dtor)
7053 an = log( cos(latin1*dtor) / cos(latin2*dtor) ) / &
7054 log( tan(dtor*(90.0-latin1)/2.) / tan(dtor*(90.0-latin2)/2.))
7057 tlon = mod(lon - lov + 180. + 3600., 360.) - 180.
7078 real(esmf_kind_r8),
intent(in) :: latgrid(i_input,j_input), &
7079 longrid(i_input,j_input)
7080 real(esmf_kind_r4),
intent(in) :: cenlat, cenlon
7081 real(esmf_kind_r4),
intent(out) :: alpha(i_input,j_input)
7084 real(esmf_kind_r8) :: d2r,lon0_r,lat0_r,sphi0,cphi0
7085 real(esmf_kind_r8),
DIMENSION(i_input,j_input) :: tlat,tlon,tph,sinalpha
7087 d2r = acos(-1.0_esmf_kind_r8) / 180.0_esmf_kind_r8
7088 if (cenlon .lt. 0)
then
7089 lon0_r = (cenlon + 360.0)*d2r
7098 tlat = latgrid * d2r
7099 tlon = longrid * d2r
7102 tlon = -tlon + lon0_r
7103 tph = asin(cphi0*sin(tlat) - sphi0*cos(tlat)*cos(tlon))
7104 sinalpha = sphi0 * sin(tlon) / cos(tph)
7105 alpha = -asin(sinalpha)/d2r
7124 use,
intrinsic :: ieee_arithmetic
7128 real(esmf_kind_r4),
intent(in) :: value
7129 real(esmf_kind_r4),
intent(inout),
optional :: var(:,:)
7130 real(esmf_kind_r8),
intent(inout),
optional :: var8(:,:)
7131 real(esmf_kind_r8),
intent(inout),
optional :: var3d(:,:,:)
7133 character(len=20),
intent(in) :: vname, lev, method
7135 integer,
intent(in) :: varnum
7136 integer,
intent(inout) :: iret
7139 if (varnum == 9999)
then
7140 print*,
"WARNING: ", trim(vname),
" NOT FOUND AT LEVEL ", lev,
" IN EXTERNAL FILE ", &
7141 "AND NO ENTRY EXISTS IN VARMAP TABLE. VARIABLE WILL NOT BE USED."
7147 if (trim(method) ==
"skip" )
then
7148 print*,
"WARNING: SKIPPING ", trim(vname),
" IN FILE"
7149 read_from_input(varnum) = .false.
7151 elseif (trim(method) ==
"set_to_fill")
then
7152 print*,
"WARNING: ,", trim(vname),
" NOT AVAILABLE AT LEVEL ", trim(lev), &
7153 ". SETTING EQUAL TO FILL VALUE OF ", value
7154 if(present(var)) var(:,:) = value
7155 if(present(var8)) var8(:,:) = value
7156 if(present(var3d)) var3d(:,:,:) = value
7157 elseif (trim(method) ==
"set_to_NaN")
then
7158 print*,
"WARNING: ,", trim(vname),
" NOT AVAILABLE AT LEVEL ", trim(lev), &
7159 ". SETTING EQUAL TO NaNs"
7160 if(present(var)) var(:,:) = ieee_value(var,ieee_quiet_nan)
7161 if(present(var8)) var8(:,:) = ieee_value(var8,ieee_quiet_nan)
7162 if(present(var3d)) var3d(:,:,:) = ieee_value(var3d,ieee_quiet_nan)
7163 elseif (trim(method) ==
"stop")
then
7164 call
error_handler(
"READING "//trim(vname)//
" at level "//lev//
". TO MAKE THIS NON- &
7165 FATAL, CHANGE STOP TO SKIP FOR THIS VARIABLE IN YOUR VARMAP &
7167 elseif (trim(method) ==
"intrp")
then
7168 print*,
"WARNING: ,"//trim(vname)//
" NOT AVAILABLE AT LEVEL "//trim(lev)// &
7169 ". WILL INTERPOLATE INTERSPERSED MISSING LEVELS AND/OR FILL MISSING"//&
7172 call
error_handler(
"ERROR USING MISSING_VAR_METHOD. PLEASE SET VALUES IN" // &
7173 " VARMAP TABLE TO ONE OF: set_to_fill, set_to_NaN,"// &
7174 " , intrp, skip, or stop.", 1)
7192 character(len=20),
intent(in) :: vname,vname_file
7194 integer,
intent(in) :: lugb
7196 real(esmf_kind_r8),
intent(inout) :: dummy3d(:,:,:)
7198 character(len=50) :: slevs(lsoil_input)
7199 character(len=50) :: method
7201 integer :: varnum, i, j, k, rc, rc2
7202 integer :: jdisc, jgdtn, jpdtn, lugi
7203 integer :: jids(200), jgdt(200), jpdt(200)
7204 integer :: iscale1, iscale2
7208 real(esmf_kind_r4),
allocatable :: dummy2d(:,:)
7209 real(esmf_kind_r4) :: value
7211 type(gribfield
) :: gfld
7213 allocate(dummy2d(i_input,j_input))
7215 if(lsoil_input == 4)
then
7216 slevs = (/
character(24)::
':0-0.1 m below ground:',
':0.1-0.4 m below ground:', &
7217 ':0.4-1 m below ground:',
':1-2 m below ground:'/)
7218 elseif(lsoil_input == 9)
then
7219 slevs = (/
character(26)::
':0-0 m below ground',
':0.01-0.01 m below ground:',
':0.04-0.04 m below ground:', &
7220 ':0.1-0.1 m below ground:',
':0.3-0.3 m below ground:',
':0.6-0.6 m below ground:', &
7221 ':1-1 m below ground:',
':1.6-1.6 m below ground:',
':3-3 m below ground:'/)
7224 call
error_handler(
"reading soil levels. File must have 4 or 9 soil levels.", rc)
7227 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
7239 if (trim(vname) ==
'soilt') jpdt(2) = 2
7240 if (trim(vname) ==
'soilw') jpdt(2) = 192
7241 if (trim(vname) ==
'soill')
then
7249 do i = 1,lsoil_input
7251 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
7252 unpack, k, gfld, rc2)
7256 if (rc==1 .and. trim(vname) /=
"soill")
then
7258 call
error_handler(
"READING IN "//trim(vname)//
". SET A FILL "// &
7259 "VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",rc)
7261 dummy3d(:,:,:) = 0.0_esmf_kind_r8
7267 iscale1 = 10 ** gfld%ipdtmpl(11)
7268 iscale2 = 10 ** gfld%ipdtmpl(14)
7271 dummy2d = reshape(gfld%fld, (/i_input,j_input/) )
7276 dummy3d(:,:,i) =
real(dummy2d,esmf_kind_r8)
7293 print*,
'- DESTROY ATMOSPHERIC INPUT DATA.'
7295 call esmf_fielddestroy(terrain_input_grid, rc=rc)
7296 call esmf_fielddestroy(pres_input_grid, rc=rc)
7297 call esmf_fielddestroy(dzdt_input_grid, rc=rc)
7298 call esmf_fielddestroy(temp_input_grid, rc=rc)
7299 call esmf_fielddestroy(wind_input_grid, rc=rc)
7300 call esmf_fielddestroy(ps_input_grid, rc=rc)
7302 do n = 1, num_tracers_input
7303 call esmf_fielddestroy(tracers_input_grid(n), rc=rc)
7305 deallocate(tracers_input_grid)
7318 print*,
'- DESTROY NST INPUT DATA.'
7320 call esmf_fielddestroy(landsea_mask_input_grid, rc=rc)
7321 call esmf_fielddestroy(c_d_input_grid, rc=rc)
7322 call esmf_fielddestroy(c_0_input_grid, rc=rc)
7323 call esmf_fielddestroy(d_conv_input_grid, rc=rc)
7324 call esmf_fielddestroy(dt_cool_input_grid, rc=rc)
7325 call esmf_fielddestroy(ifd_input_grid, rc=rc)
7326 call esmf_fielddestroy(qrain_input_grid, rc=rc)
7327 call esmf_fielddestroy(tref_input_grid, rc=rc)
7328 call esmf_fielddestroy(w_d_input_grid, rc=rc)
7329 call esmf_fielddestroy(w_0_input_grid, rc=rc)
7330 call esmf_fielddestroy(xs_input_grid, rc=rc)
7331 call esmf_fielddestroy(xt_input_grid, rc=rc)
7332 call esmf_fielddestroy(xu_input_grid, rc=rc)
7333 call esmf_fielddestroy(xv_input_grid, rc=rc)
7334 call esmf_fielddestroy(xz_input_grid, rc=rc)
7335 call esmf_fielddestroy(xtts_input_grid, rc=rc)
7336 call esmf_fielddestroy(xzts_input_grid, rc=rc)
7337 call esmf_fielddestroy(z_c_input_grid, rc=rc)
7338 call esmf_fielddestroy(zm_input_grid, rc=rc)
7351 print*,
"- CALL FieldDestroy FOR INPUT GRID FIELDS."
7353 call esmf_fielddestroy(canopy_mc_input_grid, rc=rc)
7354 call esmf_fielddestroy(f10m_input_grid, rc=rc)
7355 call esmf_fielddestroy(ffmm_input_grid, rc=rc)
7356 if (.not. convert_nst)
then
7357 call esmf_fielddestroy(landsea_mask_input_grid, rc=rc)
7359 call esmf_fielddestroy(q2m_input_grid, rc=rc)
7360 call esmf_fielddestroy(seaice_depth_input_grid, rc=rc)
7361 call esmf_fielddestroy(seaice_fract_input_grid, rc=rc)
7362 call esmf_fielddestroy(seaice_skin_temp_input_grid, rc=rc)
7363 call esmf_fielddestroy(skin_temp_input_grid, rc=rc)
7364 call esmf_fielddestroy(snow_depth_input_grid, rc=rc)
7365 call esmf_fielddestroy(snow_liq_equiv_input_grid, rc=rc)
7366 call esmf_fielddestroy(soil_temp_input_grid, rc=rc)
7367 call esmf_fielddestroy(soil_type_input_grid, rc=rc)
7368 call esmf_fielddestroy(soilm_liq_input_grid, rc=rc)
7369 call esmf_fielddestroy(soilm_tot_input_grid, rc=rc)
7370 call esmf_fielddestroy(srflag_input_grid, rc=rc)
7371 call esmf_fielddestroy(t2m_input_grid, rc=rc)
7372 call esmf_fielddestroy(tprcp_input_grid, rc=rc)
7373 call esmf_fielddestroy(ustar_input_grid, rc=rc)
7374 call esmf_fielddestroy(veg_type_input_grid, rc=rc)
7375 call esmf_fielddestroy(z0_input_grid, rc=rc)
7376 call esmf_fielddestroy(terrain_input_grid, rc=rc)
7377 if (.not. vgfrc_from_climo)
then
7378 call esmf_fielddestroy(veg_greenness_input_grid, rc=rc)
7380 if (.not. minmax_vgfrc_from_climo)
then
7381 call esmf_fielddestroy(min_veg_greenness_input_grid, rc=rc)
7382 call esmf_fielddestroy(max_veg_greenness_input_grid, rc=rc)
7384 if (.not. lai_from_climo)
then
7385 call esmf_fielddestroy(lai_input_grid, rc=rc)
7402 x = a( (first+last) / 2 )
7413 t = a(i); a(i) = a(j); a(j) = t
7417 if (first < i-1) call
quicksort(a, first, i-1)
7418 if (j+1 < last) call
quicksort(a, j+1, last)
7437 real(esmf_kind_r8),
intent(inout) :: soilt(i_input,j_input,lsoil_input)
7438 real(esmf_kind_r8),
intent(in) :: skint(i_input,j_input)
7439 integer(esmf_kind_i4),
intent(in) :: landmask(i_input,j_input)
7446 if (landmask(i,j) == 0_esmf_kind_i4 )
then
7447 soilt(i,j,k) = skint(i,j)
7448 else if (landmask(i,j) == 1_esmf_kind_i4 .and. soilt(i,j,k) > 350.0_esmf_kind_r8)
then
7449 soilt(i,j,k) = skint(i,j)
7450 else if (landmask(i,j) == 2_esmf_kind_i4 )
then
7451 soilt(i,j,k) = icet_default
7467 real(esmf_kind_r8),
intent(inout) :: cnwat(i_input,j_input)
7469 real(esmf_kind_r8) :: max_cnwat = 0.5
7475 if (cnwat(i,j) .gt. max_cnwat) cnwat(i,j) = 0.0_esmf_kind_r8
7502 SUBROUTINE dint2p(PPIN,XXIN,NPIN,PPOUT,XXOUT,NPOUT &
7518 INTEGER npin,npout,linlog,ier
7519 real*8 ppin(npin),xxin(npin),ppout(npout),xmsg
7523 real*8 pin(npin),xin(npin),p(npin),x(npin)
7524 real*8 pout(npout),xout(npout)
7527 INTEGER j1,np,nl,nin,nlmax,nplvl,nlsave,np1,no1,n1,n2,loglin, &
7529 real*8 slope,pa,pb,pc
7531 loglin = abs(linlog)
7536 IF (npout.GT.0)
THEN
7545 IF (npin.LT.2 .OR. npout.LT.1) ier = ier + 1
7558 IF (ppin(1).LT.ppin(2))
THEN
7561 IF (ppout(1).LT.ppout(2))
THEN
7566 pin(np) = ppin(abs(np1-np))
7567 xin(np) = xxin(abs(np1-np))
7571 pout(np) = ppout(abs(no1-np))
7579 IF (xin(np).NE.xmsg .AND. pin(np).NE.xmsg)
THEN
7588 IF (nlmax.LT.2)
THEN
7590 print *,
'INT2P: ier=',ier
7609 DO nl = nlstrt,nlmax
7610 IF (pout(np).EQ.p(nl))
THEN
7619 IF (loglin.EQ.1)
THEN
7622 IF (pout(np).LT.p(nl) .AND. pout(np).GT.p(nl+1))
THEN
7623 slope = (x(nl)-x(nl+1))/ (p(nl)-p(nl+1))
7624 xout(np) = x(nl+1) + slope* (pout(np)-p(nl+1))
7631 IF (pout(np).LT.p(nl) .AND. pout(np).GT.p(nl+1))
THEN
7635 if (p(nl+1).gt.0.d0)
then
7641 slope = (x(nl)-x(nl+1))/ (pa-pc)
7642 xout(np) = x(nl+1) + slope* (pb-pc)
7651 IF (linlog.LT.0)
THEN
7654 IF (pout(np).GT.p(1))
THEN
7655 IF (loglin.EQ.1)
THEN
7656 slope = (x(2)-x(1))/ (p(2)-p(1))
7657 xout(np) = x(1) + slope* (pout(np)-p(1))
7662 slope = (x(2)-x(1))/ (pa-pc)
7663 xout(np) = x(1) + slope* (pb-pc)
7665 ELSE IF (pout(np).LT.p(nlmax))
THEN
7668 IF (loglin.EQ.1)
THEN
7669 slope = (x(n1)-x(n2))/ (p(n1)-p(n2))
7670 xout(np) = x(n1) + slope* (pout(np)-p(n1))
7675 slope = (x(n1)-x(n2))/ (pa-pc)
7677 xout(np) = x(n1) + slope* (pb-pa)
7690 ppout(np) = pout(n1)
7691 xxout(np) = xout(n1)
7695 ppout(np) = pout(np)
7696 xxout(np) = xout(np)
subroutine, public convert_omega(omega, p, t, q, clb, cub)
Convert omega to vertical velocity.
subroutine, public rh2spfh(rh_sphum, p, t)
Convert relative humidity to specific humidity.
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, public rh2spfh_gfs(rh_sphum, p, t)
Convert relative humidity to specific humidity (GFS formula) Calculation of saturation water vapor pr...
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, 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, 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.