21 nst_files_input_grid, &
22 sfc_files_input_grid, &
23 atm_files_input_grid, &
24 grib2_file_input_grid, &
25 atm_core_files_input_grid, &
26 atm_tracer_files_input_grid, &
28 orog_dir_input_grid, &
29 orog_files_input_grid, &
30 tracers_input, num_tracers_input, &
31 input_type, tracers, &
33 geogrid_file_input_grid, &
36 minmax_vgfrc_from_climo, &
41 ip1_input, jp1_input, &
42 num_tiles_input_grid, &
43 latitude_input_grid, &
44 longitude_input_grid, &
53 type(esmf_field
),
public :: dzdt_input_grid
54 type(esmf_field) :: dpres_input_grid
55 type(esmf_field),
public :: pres_input_grid
56 type(esmf_field),
public :: ps_input_grid
57 type(esmf_field),
public :: terrain_input_grid
58 type(esmf_field),
public :: temp_input_grid
60 type(esmf_field
),
public :: u_input_grid
61 type(esmf_field),
public :: v_input_grid
62 type(esmf_field),
public :: wind_input_grid
63 type(esmf_field),
allocatable,
public :: tracers_input_grid(:)
65 integer,
public :: lev_input
66 integer,
public :: levp1_input
70 integer,
public :: veg_type_landice_input = 15
73 integer,
parameter :: ICET_DEFAULT = 265.0
75 type(esmf_field),
public :: canopy_mc_input_grid
76 type(esmf_field),
public :: f10m_input_grid
77 type(esmf_field),
public :: ffmm_input_grid
79 type(esmf_field),
public :: landsea_mask_input_grid
81 type(esmf_field),
public :: q2m_input_grid
82 type(esmf_field),
public :: seaice_depth_input_grid
83 type(esmf_field),
public :: seaice_fract_input_grid
84 type(esmf_field),
public :: seaice_skin_temp_input_grid
85 type(esmf_field),
public :: skin_temp_input_grid
86 type(esmf_field),
public :: snow_depth_input_grid
87 type(esmf_field),
public :: snow_liq_equiv_input_grid
88 type(esmf_field),
public :: soil_temp_input_grid
89 type(esmf_field),
public :: soil_type_input_grid
90 type(esmf_field),
public :: soilm_liq_input_grid
91 type(esmf_field),
public :: soilm_tot_input_grid
92 type(esmf_field),
public :: srflag_input_grid
93 type(esmf_field),
public :: t2m_input_grid
94 type(esmf_field),
public :: tprcp_input_grid
95 type(esmf_field),
public :: ustar_input_grid
96 type(esmf_field),
public :: veg_type_input_grid
97 type(esmf_field),
public :: z0_input_grid
98 type(esmf_field),
public :: veg_greenness_input_grid
99 type(esmf_field),
public :: lai_input_grid
100 type(esmf_field),
public :: max_veg_greenness_input_grid
101 type(esmf_field),
public :: min_veg_greenness_input_grid
103 integer,
public :: lsoil_input=4
106 character(len=50),
private,
allocatable :: slevs(:)
110 type(esmf_field
),
public :: c_d_input_grid
111 type(esmf_field),
public :: c_0_input_grid
112 type(esmf_field),
public :: d_conv_input_grid
113 type(esmf_field),
public :: dt_cool_input_grid
114 type(esmf_field),
public :: ifd_input_grid
116 type(esmf_field),
public :: qrain_input_grid
117 type(esmf_field),
public :: tref_input_grid
118 type(esmf_field),
public :: w_d_input_grid
119 type(esmf_field),
public :: w_0_input_grid
120 type(esmf_field),
public :: xs_input_grid
121 type(esmf_field),
public :: xt_input_grid
122 type(esmf_field),
public :: xu_input_grid
123 type(esmf_field),
public :: xv_input_grid
124 type(esmf_field),
public :: xz_input_grid
125 type(esmf_field),
public :: xtts_input_grid
126 type(esmf_field),
public :: xzts_input_grid
127 type(esmf_field),
public :: z_c_input_grid
128 type(esmf_field),
public :: zm_input_grid
153 integer,
intent(in) :: localpet
159 if (trim(input_type) ==
"restart")
then
167 elseif (trim(input_type) ==
"gaussian_netcdf")
then
175 elseif (trim(input_type) ==
"history")
then
183 elseif (trim(input_type) ==
"gaussian_nemsio")
then
191 elseif (trim(input_type) ==
"gfs_gaussian_nemsio")
then
199 elseif (trim(input_type) ==
"gfs_sigio")
then
207 elseif (trim(input_type) ==
"grib2")
then
223 integer,
intent(in) :: localpet
227 print*,
"- READ INPUT GRID NST DATA."
229 print*,
"- CALL FieldCreate FOR INPUT GRID C_D."
230 c_d_input_grid = esmf_fieldcreate(input_grid, &
231 typekind=esmf_typekind_r8, &
232 staggerloc=esmf_staggerloc_center, rc=rc)
233 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
236 print*,
"- CALL FieldCreate FOR INPUT GRID C_0."
237 c_0_input_grid = esmf_fieldcreate(input_grid, &
238 typekind=esmf_typekind_r8, &
239 staggerloc=esmf_staggerloc_center, rc=rc)
240 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
243 print*,
"- CALL FieldCreate FOR INPUT GRID D_CONV."
244 d_conv_input_grid = esmf_fieldcreate(input_grid, &
245 typekind=esmf_typekind_r8, &
246 staggerloc=esmf_staggerloc_center, rc=rc)
247 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
250 print*,
"- CALL FieldCreate FOR INPUT GRID DT_COOL."
251 dt_cool_input_grid = esmf_fieldcreate(input_grid, &
252 typekind=esmf_typekind_r8, &
253 staggerloc=esmf_staggerloc_center, rc=rc)
254 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
257 print*,
"- CALL FieldCreate FOR INPUT GRID IFD."
258 ifd_input_grid = esmf_fieldcreate(input_grid, &
259 typekind=esmf_typekind_r8, &
260 staggerloc=esmf_staggerloc_center, rc=rc)
261 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
264 print*,
"- CALL FieldCreate FOR INPUT GRID QRAIN."
265 qrain_input_grid = esmf_fieldcreate(input_grid, &
266 typekind=esmf_typekind_r8, &
267 staggerloc=esmf_staggerloc_center, rc=rc)
268 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
271 print*,
"- CALL FieldCreate FOR INPUT GRID TREF."
272 tref_input_grid = esmf_fieldcreate(input_grid, &
273 typekind=esmf_typekind_r8, &
274 staggerloc=esmf_staggerloc_center, rc=rc)
275 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
278 print*,
"- CALL FieldCreate FOR INPUT GRID W_D."
279 w_d_input_grid = esmf_fieldcreate(input_grid, &
280 typekind=esmf_typekind_r8, &
281 staggerloc=esmf_staggerloc_center, rc=rc)
282 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
285 print*,
"- CALL FieldCreate FOR INPUT GRID W_0."
286 w_0_input_grid = esmf_fieldcreate(input_grid, &
287 typekind=esmf_typekind_r8, &
288 staggerloc=esmf_staggerloc_center, rc=rc)
289 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
292 print*,
"- CALL FieldCreate FOR INPUT GRID XS."
293 xs_input_grid = esmf_fieldcreate(input_grid, &
294 typekind=esmf_typekind_r8, &
295 staggerloc=esmf_staggerloc_center, rc=rc)
296 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
299 print*,
"- CALL FieldCreate FOR INPUT GRID XT."
300 xt_input_grid = esmf_fieldcreate(input_grid, &
301 typekind=esmf_typekind_r8, &
302 staggerloc=esmf_staggerloc_center, rc=rc)
303 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
306 print*,
"- CALL FieldCreate FOR INPUT GRID XU."
307 xu_input_grid = esmf_fieldcreate(input_grid, &
308 typekind=esmf_typekind_r8, &
309 staggerloc=esmf_staggerloc_center, rc=rc)
310 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
313 print*,
"- CALL FieldCreate FOR INPUT GRID XV."
314 xv_input_grid = esmf_fieldcreate(input_grid, &
315 typekind=esmf_typekind_r8, &
316 staggerloc=esmf_staggerloc_center, rc=rc)
317 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
320 print*,
"- CALL FieldCreate FOR INPUT GRID XZ."
321 xz_input_grid = esmf_fieldcreate(input_grid, &
322 typekind=esmf_typekind_r8, &
323 staggerloc=esmf_staggerloc_center, rc=rc)
324 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
327 print*,
"- CALL FieldCreate FOR INPUT GRID XTTS."
328 xtts_input_grid = esmf_fieldcreate(input_grid, &
329 typekind=esmf_typekind_r8, &
330 staggerloc=esmf_staggerloc_center, rc=rc)
331 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
334 print*,
"- CALL FieldCreate FOR INPUT GRID XZTS."
335 xzts_input_grid = esmf_fieldcreate(input_grid, &
336 typekind=esmf_typekind_r8, &
337 staggerloc=esmf_staggerloc_center, rc=rc)
338 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
341 print*,
"- CALL FieldCreate FOR INPUT GRID Z_C."
342 z_c_input_grid = esmf_fieldcreate(input_grid, &
343 typekind=esmf_typekind_r8, &
344 staggerloc=esmf_staggerloc_center, rc=rc)
345 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
348 print*,
"- CALL FieldCreate FOR INPUT GRID ZM."
349 zm_input_grid = esmf_fieldcreate(input_grid, &
350 typekind=esmf_typekind_r8, &
351 staggerloc=esmf_staggerloc_center, rc=rc)
352 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
360 if (trim(input_type) ==
"gaussian_nemsio" .or. trim(input_type) ==
"gfs_gaussian_nemsio")
then
385 integer,
intent(in) :: localpet
395 if (trim(input_type) ==
"restart")
then
403 elseif (trim(input_type) ==
"history" .or. trim(input_type) == &
404 "gaussian_netcdf")
then
412 elseif (trim(input_type) ==
"gaussian_nemsio")
then
420 elseif (trim(input_type) ==
"gfs_gaussian_nemsio")
then
428 elseif (trim(input_type) ==
"gfs_sigio")
then
436 elseif (trim(input_type) ==
"grib2")
then
453 print*,
"- INITIALIZE ATMOSPHERIC ESMF FIELDS."
455 print*,
"- CALL FieldCreate FOR INPUT GRID 3-D WIND."
456 wind_input_grid = esmf_fieldcreate(input_grid, &
457 typekind=esmf_typekind_r8, &
458 staggerloc=esmf_staggerloc_center, &
459 ungriddedlbound=(/1,1/), &
460 ungriddedubound=(/lev_input,3/), rc=rc)
461 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
464 print*,
"- CALL FieldCreate FOR INPUT GRID SURFACE PRESSURE."
465 ps_input_grid = esmf_fieldcreate(input_grid, &
466 typekind=esmf_typekind_r8, &
467 staggerloc=esmf_staggerloc_center, rc=rc)
468 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
471 print*,
"- CALL FieldCreate FOR INPUT GRID TERRAIN."
472 terrain_input_grid = esmf_fieldcreate(input_grid, &
473 typekind=esmf_typekind_r8, &
474 staggerloc=esmf_staggerloc_center, rc=rc)
475 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
478 print*,
"- CALL FieldCreate FOR INPUT GRID TEMPERATURE."
479 temp_input_grid = esmf_fieldcreate(input_grid, &
480 typekind=esmf_typekind_r8, &
481 staggerloc=esmf_staggerloc_center, &
482 ungriddedlbound=(/1/), &
483 ungriddedubound=(/lev_input/), rc=rc)
484 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
487 allocate(tracers_input_grid(num_tracers_input))
489 do i = 1, num_tracers_input
490 print*,
"- CALL FieldCreate FOR INPUT GRID TRACER ", trim(tracers_input(i))
491 tracers_input_grid(i) = esmf_fieldcreate(input_grid, &
492 typekind=esmf_typekind_r8, &
493 staggerloc=esmf_staggerloc_center, &
494 ungriddedlbound=(/1/), &
495 ungriddedubound=(/lev_input/), rc=rc)
496 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
500 print*,
"- CALL FieldCreate FOR INPUT GRID DZDT."
501 dzdt_input_grid = esmf_fieldcreate(input_grid, &
502 typekind=esmf_typekind_r8, &
503 staggerloc=esmf_staggerloc_center, &
504 ungriddedlbound=(/1/), &
505 ungriddedubound=(/lev_input/), rc=rc)
506 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
509 print*,
"- CALL FieldCreate FOR INPUT GRID U."
510 u_input_grid = esmf_fieldcreate(input_grid, &
511 typekind=esmf_typekind_r8, &
512 staggerloc=esmf_staggerloc_center, &
513 ungriddedlbound=(/1/), &
514 ungriddedubound=(/lev_input/), rc=rc)
515 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
518 print*,
"- CALL FieldCreate FOR INPUT GRID V."
519 v_input_grid = esmf_fieldcreate(input_grid, &
520 typekind=esmf_typekind_r8, &
521 staggerloc=esmf_staggerloc_center, &
522 ungriddedlbound=(/1/), &
523 ungriddedubound=(/lev_input/), rc=rc)
524 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
527 print*,
"- CALL FieldCreate FOR INPUT GRID PRESSURE."
528 pres_input_grid = esmf_fieldcreate(input_grid, &
529 typekind=esmf_typekind_r8, &
530 staggerloc=esmf_staggerloc_center, &
531 ungriddedlbound=(/1/), &
532 ungriddedubound=(/lev_input/), rc=rc)
533 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
547 print*,
"- CALL FieldCreate FOR INPUT GRID LANDSEA MASK."
548 landsea_mask_input_grid = esmf_fieldcreate(input_grid, &
549 typekind=esmf_typekind_r8, &
550 staggerloc=esmf_staggerloc_center, rc=rc)
551 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
554 print*,
"- CALL FieldCreate FOR INPUT GRID Z0."
555 z0_input_grid = esmf_fieldcreate(input_grid, &
556 typekind=esmf_typekind_r8, &
557 staggerloc=esmf_staggerloc_center, rc=rc)
558 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
561 print*,
"- CALL FieldCreate FOR INPUT GRID VEGETATION TYPE."
562 veg_type_input_grid = esmf_fieldcreate(input_grid, &
563 typekind=esmf_typekind_r8, &
564 staggerloc=esmf_staggerloc_center, rc=rc)
565 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
568 print*,
"- CALL FieldCreate FOR INPUT GRID CANOPY MOISTURE CONTENT."
569 canopy_mc_input_grid = esmf_fieldcreate(input_grid, &
570 typekind=esmf_typekind_r8, &
571 staggerloc=esmf_staggerloc_center, rc=rc)
572 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
575 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE FRACTION."
576 seaice_fract_input_grid = esmf_fieldcreate(input_grid, &
577 typekind=esmf_typekind_r8, &
578 staggerloc=esmf_staggerloc_center, rc=rc)
579 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
582 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE DEPTH."
583 seaice_depth_input_grid = esmf_fieldcreate(input_grid, &
584 typekind=esmf_typekind_r8, &
585 staggerloc=esmf_staggerloc_center, rc=rc)
586 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
589 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE SKIN TEMPERATURE."
590 seaice_skin_temp_input_grid = esmf_fieldcreate(input_grid, &
591 typekind=esmf_typekind_r8, &
592 staggerloc=esmf_staggerloc_center, rc=rc)
593 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
596 print*,
"- CALL FieldCreate FOR INPUT GRID SNOW DEPTH."
597 snow_depth_input_grid = esmf_fieldcreate(input_grid, &
598 typekind=esmf_typekind_r8, &
599 staggerloc=esmf_staggerloc_center, rc=rc)
600 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
603 print*,
"- CALL FieldCreate FOR INPUT GRID SNOW LIQUID EQUIVALENT."
604 snow_liq_equiv_input_grid = esmf_fieldcreate(input_grid, &
605 typekind=esmf_typekind_r8, &
606 staggerloc=esmf_staggerloc_center, rc=rc)
607 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
610 print*,
"- CALL FieldCreate FOR INPUT GRID T2M."
611 t2m_input_grid = esmf_fieldcreate(input_grid, &
612 typekind=esmf_typekind_r8, &
613 staggerloc=esmf_staggerloc_center, rc=rc)
614 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
617 print*,
"- CALL FieldCreate FOR INPUT GRID Q2M."
618 q2m_input_grid = esmf_fieldcreate(input_grid, &
619 typekind=esmf_typekind_r8, &
620 staggerloc=esmf_staggerloc_center, rc=rc)
621 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
624 print*,
"- CALL FieldCreate FOR INPUT GRID TPRCP."
625 tprcp_input_grid = esmf_fieldcreate(input_grid, &
626 typekind=esmf_typekind_r8, &
627 staggerloc=esmf_staggerloc_center, rc=rc)
628 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
631 print*,
"- CALL FieldCreate FOR INPUT GRID F10M."
632 f10m_input_grid = esmf_fieldcreate(input_grid, &
633 typekind=esmf_typekind_r8, &
634 staggerloc=esmf_staggerloc_center, rc=rc)
635 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
638 print*,
"- CALL FieldCreate FOR INPUT GRID USTAR."
639 ustar_input_grid = esmf_fieldcreate(input_grid, &
640 typekind=esmf_typekind_r8, &
641 staggerloc=esmf_staggerloc_center, rc=rc)
642 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
645 print*,
"- CALL FieldCreate FOR INPUT GRID FFMM."
646 ffmm_input_grid = esmf_fieldcreate(input_grid, &
647 typekind=esmf_typekind_r8, &
648 staggerloc=esmf_staggerloc_center, rc=rc)
649 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
652 print*,
"- CALL FieldCreate FOR INPUT GRID SRFLAG."
653 srflag_input_grid = esmf_fieldcreate(input_grid, &
654 typekind=esmf_typekind_r8, &
655 staggerloc=esmf_staggerloc_center, rc=rc)
656 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
659 print*,
"- CALL FieldCreate FOR INPUT SKIN TEMPERATURE."
660 skin_temp_input_grid = esmf_fieldcreate(input_grid, &
661 typekind=esmf_typekind_r8, &
662 staggerloc=esmf_staggerloc_center, rc=rc)
663 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
666 print*,
"- CALL FieldCreate FOR INPUT SOIL TYPE."
667 soil_type_input_grid = esmf_fieldcreate(input_grid, &
668 typekind=esmf_typekind_r8, &
669 staggerloc=esmf_staggerloc_center, rc=rc)
670 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
673 print*,
"- CALL FieldCreate FOR INPUT TERRAIN."
674 terrain_input_grid = esmf_fieldcreate(input_grid, &
675 typekind=esmf_typekind_r8, &
676 staggerloc=esmf_staggerloc_center, rc=rc)
677 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
680 print*,
"- CALL FieldCreate FOR INPUT SOIL TEMPERATURE."
681 soil_temp_input_grid = esmf_fieldcreate(input_grid, &
682 typekind=esmf_typekind_r8, &
683 staggerloc=esmf_staggerloc_center, &
684 ungriddedlbound=(/1/), &
685 ungriddedubound=(/lsoil_input/), rc=rc)
686 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
689 print*,
"- CALL FieldCreate FOR INPUT TOTAL SOIL MOISTURE."
690 soilm_tot_input_grid = esmf_fieldcreate(input_grid, &
691 typekind=esmf_typekind_r8, &
692 staggerloc=esmf_staggerloc_center, &
693 ungriddedlbound=(/1/), &
694 ungriddedubound=(/lsoil_input/), rc=rc)
695 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
698 print*,
"- CALL FieldCreate FOR INPUT LIQUID SOIL MOISTURE."
699 soilm_liq_input_grid = esmf_fieldcreate(input_grid, &
700 typekind=esmf_typekind_r8, &
701 staggerloc=esmf_staggerloc_center, &
702 ungriddedlbound=(/1/), &
703 ungriddedubound=(/lsoil_input/), rc=rc)
704 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
709 if (.not. vgfrc_from_climo)
then
710 print*,
"- CALL FieldCreate FOR INPUT VEGETATION GREENNESS."
711 veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
712 typekind=esmf_typekind_r8, &
713 staggerloc=esmf_staggerloc_center, rc=rc)
714 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
718 if (.not. minmax_vgfrc_from_climo)
then
719 print*,
"- CALL FieldCreate FOR INPUT MIN VEGETATION GREENNESS."
720 min_veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
721 typekind=esmf_typekind_r8, &
722 staggerloc=esmf_staggerloc_center, rc=rc)
723 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
726 print*,
"- CALL FieldCreate FOR INPUT MAX VEGETATION GREENNESS."
727 max_veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
728 typekind=esmf_typekind_r8, &
729 staggerloc=esmf_staggerloc_center, rc=rc)
730 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
734 if (.not. lai_from_climo)
then
735 print*,
"- CALL FieldCreate FOR INPUT LEAF AREA INDEX."
736 lai_input_grid = esmf_fieldcreate(input_grid, &
737 typekind=esmf_typekind_r8, &
738 staggerloc=esmf_staggerloc_center, rc=rc)
739 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
755 integer,
intent(in) :: localpet
757 character(len=300) :: the_file
759 integer(sigio_intkind) :: iret
760 integer :: rc, i, j, k
761 integer :: clb(3), cub(3)
763 real(esmf_kind_r8) :: ak, bk
764 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
765 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
766 real(esmf_kind_r8),
allocatable :: dummy3d2(:,:,:)
767 real(esmf_kind_r8),
pointer :: pptr(:,:,:), psptr(:,:)
768 real(esmf_kind_r8),
allocatable :: pi(:,:,:)
770 type(sigio_head
) :: sighead
771 type(sigio_dbta
) :: sigdata
773 the_file = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
775 print*,
"- ATMOSPHERIC DATA IN SIGIO FORMAT."
776 print*,
"- OPEN AND READ: ", trim(the_file)
778 call sigio_sropen(21, trim(the_file), iret)
783 call sigio_srhead(21, sighead, iret)
789 lev_input = sighead%levs
790 levp1_input = lev_input + 1
792 if (num_tracers_input /= sighead%ntrac)
then
796 if (sighead%idvt == 0 .or. sighead%idvt == 21)
then
797 if (trim(tracers_input(1)) /=
'spfh' .or. &
798 trim(tracers_input(2)) /=
'o3mr' .or. &
799 trim(tracers_input(3)) /=
'clwmr')
then
800 call
error_handler(
"TRACERS SELECTED DO NOT MATCH FILE CONTENTS.", 99)
803 print*,
'- UNRECOGNIZED IDVT: ', sighead%idvt
813 if (localpet == 0)
then
814 allocate(dummy2d(i_input,j_input))
815 allocate(dummy3d(i_input,j_input,lev_input))
816 allocate(dummy3d2(i_input,j_input,lev_input))
818 allocate(dummy2d(0,0))
819 allocate(dummy3d(0,0,0))
820 allocate(dummy3d2(0,0,0))
823 if (localpet == 0)
then
824 call sigio_aldbta(sighead, sigdata, iret)
829 call sigio_srdbta(21, sighead, sigdata, iret)
834 call sptez(0,sighead%jcap,4,i_input, j_input, sigdata%ps, dummy2d, 1)
835 dummy2d = exp(dummy2d) * 1000.0
836 print*,
'surface pres ',maxval(dummy2d),minval(dummy2d)
839 print*,
"- CALL FieldScatter FOR SURFACE PRESSURE."
840 call esmf_fieldscatter(ps_input_grid, dummy2d, rootpet=0, rc=rc)
841 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
844 if (localpet == 0)
then
845 call sptez(0,sighead%jcap,4,i_input, j_input, sigdata%hs, dummy2d, 1)
846 print*,
'terrain ',maxval(dummy2d),minval(dummy2d)
849 print*,
"- CALL FieldScatter FOR TERRAIN."
850 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
851 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
854 do k = 1, num_tracers_input
856 if (localpet == 0)
then
857 call sptezm(0,sighead%jcap,4,i_input, j_input, lev_input, sigdata%q(:,:,k), dummy3d, 1)
858 print*,trim(tracers_input(k)),maxval(dummy3d),minval(dummy3d)
861 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(k))
862 call esmf_fieldscatter(tracers_input_grid(k), dummy3d, rootpet=0, rc=rc)
863 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
868 if (localpet == 0)
then
869 call sptezm(0,sighead%jcap,4,i_input, j_input, lev_input, sigdata%t, dummy3d, 1)
870 print*,
'temp ',maxval(dummy3d),minval(dummy3d)
873 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
874 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
875 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
883 if (localpet == 0)
then
884 print*,
"- NO VERTICAL VELOCITY RECORD. SET TO ZERO."
888 print*,
"- CALL FieldScatter FOR INPUT DZDT."
889 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
890 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
893 if (localpet == 0)
then
894 call sptezmv(0, sighead%jcap, 4, i_input, j_input, lev_input, sigdata%d, sigdata%z, dummy3d, dummy3d2, 1)
895 print*,
'u ',maxval(dummy3d),minval(dummy3d)
896 print*,
'v ',maxval(dummy3d2),minval(dummy3d2)
899 print*,
"- CALL FieldScatter FOR INPUT U-WIND."
900 call esmf_fieldscatter(u_input_grid, dummy3d, rootpet=0, rc=rc)
901 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
904 print*,
"- CALL FieldScatter FOR INPUT V-WIND."
905 call esmf_fieldscatter(v_input_grid, dummy3d2, rootpet=0, rc=rc)
906 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
909 deallocate(dummy2d, dummy3d, dummy3d2)
911 if (localpet == 0) call sigio_axdbta(sigdata, iret)
913 call sigio_sclose(21, iret)
925 print*,
"- COMPUTE 3-D PRESSURE."
927 print*,
"- CALL FieldGet FOR 3-D PRES."
929 call esmf_fieldget(pres_input_grid, &
930 computationallbound=clb, &
931 computationalubound=cub, &
932 farrayptr=pptr, rc=rc)
933 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
936 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
938 call esmf_fieldget(ps_input_grid, &
939 farrayptr=psptr, rc=rc)
940 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
947 allocate(pi(clb(1):cub(1),clb(2):cub(2),1:levp1_input),stat=rc)
950 ak = sighead%vcoord(k,1)
951 bk = sighead%vcoord(k,2)
954 pi(i,j,k) = ak + bk*psptr(i,j)
959 if (localpet == 0)
then
960 print*,
'pres int ',psptr(clb(1),clb(2)),pi(clb(1),clb(2),:)
970 pptr(i,j,k) = (pi(i,j,k)+pi(i,j,k+1))/2.0_esmf_kind_r8
977 if (localpet == 0)
then
978 print*,
'pres ',psptr(clb(1),clb(2)),pptr(clb(1),clb(2),:)
992 integer,
intent(in) :: localpet
994 character(len=300) :: the_file
995 character(len=20) :: vlevtyp, vname
997 integer(nemsio_intkind) :: vlev, iret
998 integer :: i, j, k, n, rc
999 integer :: clb(3), cub(3)
1001 real(nemsio_realkind),
allocatable :: vcoord(:,:,:)
1002 real(nemsio_realkind),
allocatable :: dummy(:)
1003 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
1004 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
1005 real(esmf_kind_r8) :: ak, bk
1006 real(esmf_kind_r8),
allocatable :: pi(:,:,:)
1007 real(esmf_kind_r8),
pointer :: pptr(:,:,:), psptr(:,:)
1009 type(nemsio_gfile
) :: gfile
1011 the_file = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
1013 print*,
"- READ ATMOS DATA FROM SPECTRAL GFS NEMSIO FILE: ", trim(the_file)
1015 print*,
"- OPEN FILE."
1016 call nemsio_open(gfile, the_file,
"read", iret=iret)
1017 if (iret /= 0) call
error_handler(
"OPENING SPECTRAL GFS NEMSIO ATM FILE.", iret)
1019 print*,
"- READ NUMBER OF VERTICAL LEVELS."
1020 call nemsio_getfilehead(gfile, iret=iret, dimz=lev_input)
1021 if (iret /= 0) call
error_handler(
"READING NUMBER OF VERTICAL LEVLES.", iret)
1023 levp1_input = lev_input + 1
1025 allocate(vcoord(levp1_input,3,2))
1027 print*,
"- READ VERTICAL COORDINATE INFO."
1028 call nemsio_getfilehead(gfile, iret=iret, vcoord=vcoord)
1029 if (iret /= 0) call
error_handler(
"READING VERTICAL COORDINATE INFO.", iret)
1037 if (localpet == 0)
then
1038 allocate(dummy(i_input*j_input))
1039 allocate(dummy2d(i_input,j_input))
1040 allocate(dummy3d(i_input,j_input,lev_input))
1043 allocate(dummy2d(0,0))
1044 allocate(dummy3d(0,0,0))
1052 if (localpet == 0)
then
1053 print*,
"- READ TEMPERATURE."
1055 vlevtyp =
"mid layer"
1056 do vlev = 1, lev_input
1057 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1058 if (iret /= 0) call
error_handler(
"READING TEMPERATURE RECORD.", iret)
1059 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1064 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
1065 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
1066 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1069 do n = 1, num_tracers_input
1071 if (localpet == 0)
then
1072 print*,
"- READ ", trim(tracers_input(n))
1073 vname = trim(tracers_input(n))
1074 vlevtyp =
"mid layer"
1075 do vlev = 1, lev_input
1076 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1077 if (iret /= 0) call
error_handler(
"READING TRACER RECORD.", iret)
1079 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1083 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(n))
1084 call esmf_fieldscatter(tracers_input_grid(n), dummy3d, rootpet=0, rc=rc)
1085 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1090 if (localpet == 0)
then
1091 print*,
"- READ U-WINDS."
1093 vlevtyp =
"mid layer"
1094 do vlev = 1, lev_input
1095 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1096 if (iret /= 0) call
error_handler(
"READING U-WIND RECORD.", iret)
1098 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1102 print*,
"- CALL FieldScatter FOR INPUT U-WIND."
1103 call esmf_fieldscatter(u_input_grid, dummy3d, rootpet=0, rc=rc)
1104 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1107 if (localpet == 0)
then
1108 print*,
"- READ V-WINDS."
1110 vlevtyp =
"mid layer"
1111 do vlev = 1, lev_input
1112 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1113 if (iret /= 0) call
error_handler(
"READING V-WIND RECORD.", iret)
1115 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1119 print*,
"- CALL FieldScatter FOR INPUT V-WIND."
1120 call esmf_fieldscatter(v_input_grid, dummy3d, rootpet=0, rc=rc)
1121 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1129 if (localpet == 0)
then
1130 print*,
"- NO VERTICAL VELOCITY RECORD. SET TO ZERO."
1134 print*,
"- CALL FieldScatter FOR INPUT DZDT."
1135 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
1136 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1139 if (localpet == 0)
then
1140 print*,
"- READ HGT."
1144 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1145 if (iret /= 0) call
error_handler(
"READING HGT RECORD.", iret)
1147 dummy2d = reshape(dummy, (/i_input,j_input/))
1150 print*,
"- CALL FieldScatter FOR TERRAIN."
1151 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
1152 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1155 if (localpet == 0)
then
1156 print*,
"- READ PRES."
1160 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1161 if (iret /= 0) call
error_handler(
"READING PRES RECORD.", iret)
1163 dummy2d = reshape(dummy, (/i_input,j_input/))
1166 print*,
"- CALL FieldScatter FOR SURFACE PRESSURE."
1167 call esmf_fieldscatter(ps_input_grid, dummy2d, rootpet=0, rc=rc)
1168 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1171 call nemsio_close(gfile)
1173 deallocate(dummy, dummy2d, dummy3d)
1185 print*,
"- COMPUTE 3-D PRESSURE."
1187 print*,
"- CALL FieldGet FOR 3-D PRES."
1189 call esmf_fieldget(pres_input_grid, &
1190 computationallbound=clb, &
1191 computationalubound=cub, &
1192 farrayptr=pptr, rc=rc)
1193 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1196 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
1198 call esmf_fieldget(ps_input_grid, &
1199 farrayptr=psptr, rc=rc)
1200 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1207 allocate(pi(clb(1):cub(1),clb(2):cub(2),1:levp1_input))
1212 do i= clb(1), cub(1)
1213 do j= clb(2), cub(2)
1214 pi(i,j,k) = ak + bk*psptr(i,j)
1226 do i= clb(1), cub(1)
1227 do j= clb(2), cub(2)
1228 pptr(i,j,k) = (pi(i,j,k)+pi(i,j,k+1))/2.0
1245 integer,
intent(in) :: localpet
1247 character(len=300) :: the_file
1248 character(len=20) :: vlevtyp, vname
1250 integer :: i, j, k, n
1251 integer :: rc, clb(3), cub(3)
1252 integer(nemsio_intkind) :: vlev, iret
1254 real(nemsio_realkind),
allocatable :: vcoord(:,:,:)
1255 real(nemsio_realkind),
allocatable :: dummy(:)
1256 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
1257 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
1258 real(esmf_kind_r8),
pointer :: presptr(:,:,:), psptr(:,:)
1259 real(esmf_kind_r8),
pointer :: dpresptr(:,:,:)
1260 real(esmf_kind_r8),
allocatable :: pres_interface(:)
1262 type(nemsio_gfile
) :: gfile
1264 the_file = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
1266 print*,
"- READ ATMOS DATA FROM GAUSSIAN NEMSIO FILE: ", trim(the_file)
1268 print*,
"- OPEN FILE."
1269 call nemsio_open(gfile, the_file,
"read", iret=iret)
1270 if (iret /= 0) call
error_handler(
"OPENING GAUSSIAN NEMSIO ATM FILE.", iret)
1272 print*,
"- READ NUMBER OF VERTICAL LEVELS."
1273 call nemsio_getfilehead(gfile, iret=iret, dimz=lev_input)
1274 if (iret /= 0) call
error_handler(
"READING NUMBER OF VERTICAL LEVLES.", iret)
1276 levp1_input = lev_input + 1
1278 allocate(vcoord(levp1_input,3,2))
1280 print*,
"- READ VERTICAL COORDINATE INFO."
1281 call nemsio_getfilehead(gfile, iret=iret, vcoord=vcoord)
1282 if (iret /= 0) call
error_handler(
"READING VERTICAL COORDINATE INFO.", iret)
1290 print*,
"- CALL FieldCreate FOR INPUT DPRES."
1291 dpres_input_grid = esmf_fieldcreate(input_grid, &
1292 typekind=esmf_typekind_r8, &
1293 staggerloc=esmf_staggerloc_center, &
1294 ungriddedlbound=(/1/), &
1295 ungriddedubound=(/lev_input/), rc=rc)
1296 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1299 if (localpet == 0)
then
1300 allocate(dummy(i_input*j_input))
1301 allocate(dummy2d(i_input,j_input))
1302 allocate(dummy3d(i_input,j_input,lev_input))
1305 allocate(dummy2d(0,0))
1306 allocate(dummy3d(0,0,0))
1314 if (localpet == 0)
then
1315 print*,
"- READ TEMPERATURE."
1317 vlevtyp =
"mid layer"
1318 do vlev = 1, lev_input
1319 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1320 if (iret /= 0) call
error_handler(
"READING TEMPERATURE RECORD.", iret)
1321 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1322 print*,
'temp check after read ',vlev, dummy3d(1,1,vlev)
1326 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
1327 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
1328 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1331 do n = 1, num_tracers_input
1333 if (localpet == 0)
then
1334 print*,
"- READ ", trim(tracers_input(n))
1335 vname = trim(tracers_input(n))
1336 vlevtyp =
"mid layer"
1337 do vlev = 1, lev_input
1338 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1339 if (iret /= 0) call
error_handler(
"READING TRACER RECORD.", iret)
1340 print*,
'tracer ',vlev, maxval(dummy),minval(dummy)
1341 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1345 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(n))
1346 call esmf_fieldscatter(tracers_input_grid(n), dummy3d, rootpet=0, rc=rc)
1347 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1352 if (localpet == 0)
then
1353 print*,
"- READ U-WINDS."
1355 vlevtyp =
"mid layer"
1356 do vlev = 1, lev_input
1357 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1358 if (iret /= 0) call
error_handler(
"READING U-WIND RECORD.", iret)
1359 print*,
'ugrd ',vlev, maxval(dummy),minval(dummy)
1360 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1364 print*,
"- CALL FieldScatter FOR INPUT U-WIND."
1365 call esmf_fieldscatter(u_input_grid, dummy3d, rootpet=0, rc=rc)
1366 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1369 if (localpet == 0)
then
1370 print*,
"- READ V-WINDS."
1372 vlevtyp =
"mid layer"
1373 do vlev = 1, lev_input
1374 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1375 if (iret /= 0) call
error_handler(
"READING V-WIND RECORD.", iret)
1376 print*,
'vgrd ',vlev, maxval(dummy),minval(dummy)
1377 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1381 print*,
"- CALL FieldScatter FOR INPUT V-WIND."
1382 call esmf_fieldscatter(v_input_grid, dummy3d, rootpet=0, rc=rc)
1383 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1386 if (localpet == 0)
then
1387 print*,
"- READ DPRES."
1389 vlevtyp =
"mid layer"
1390 do vlev = 1, lev_input
1391 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1392 if (iret /= 0) call
error_handler(
"READING DPRES RECORD.", iret)
1393 print*,
'dpres ',vlev, maxval(dummy),minval(dummy)
1394 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1398 print*,
"- CALL FieldScatter FOR INPUT DPRES."
1399 call esmf_fieldscatter(dpres_input_grid, dummy3d, rootpet=0, rc=rc)
1400 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1403 if (localpet == 0)
then
1404 print*,
"- READ DZDT."
1406 vlevtyp =
"mid layer"
1407 do vlev = 1, lev_input
1408 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1409 if (iret /= 0) call
error_handler(
"READING DZDT RECORD.", iret)
1410 print*,
'dzdt ',vlev, maxval(dummy),minval(dummy)
1411 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1415 print*,
"- CALL FieldScatter FOR INPUT DZDT."
1416 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
1417 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1420 if (localpet == 0)
then
1421 print*,
"- READ HGT."
1425 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1426 if (iret /= 0) call
error_handler(
"READING HGT RECORD.", iret)
1427 print*,
'hgt ',vlev, maxval(dummy),minval(dummy)
1428 dummy2d = reshape(dummy, (/i_input,j_input/))
1431 print*,
"- CALL FieldScatter FOR TERRAIN."
1432 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
1433 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1436 call nemsio_close(gfile)
1438 deallocate(dummy, dummy2d, dummy3d)
1454 print*,
"- COMPUTE 3-D PRESSURE."
1456 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
1458 call esmf_fieldget(dpres_input_grid, &
1459 computationallbound=clb, &
1460 computationalubound=cub, &
1461 farrayptr=dpresptr, rc=rc)
1462 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1465 print*,
"- CALL FieldGet FOR 3-D PRESSURE."
1467 call esmf_fieldget(pres_input_grid, &
1468 farrayptr=presptr, rc=rc)
1469 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1472 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
1474 call esmf_fieldget(ps_input_grid, &
1475 farrayptr=psptr, rc=rc)
1476 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1479 allocate(pres_interface(levp1_input))
1481 if (localpet == 0)
then
1482 do k = clb(3), cub(3)
1483 print*,
'dpres is ',cub(1),cub(2),k, dpresptr(cub(1),cub(2),k)
1487 do i = clb(1), cub(1)
1488 do j = clb(2), cub(2)
1489 pres_interface(levp1_input) = vcoord(levp1_input,1,1)
1490 do k = lev_input, 1, -1
1491 pres_interface(k) = pres_interface(k+1) + dpresptr(i,j,k)
1493 psptr(i,j) = pres_interface(1)
1495 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
1502 if (localpet == 0)
then
1503 print*,
'psfc is ',clb(1),clb(2),psptr(clb(1),clb(2))
1504 print*,
'pres is ',clb(1),clb(2),presptr(clb(1),clb(2),:)
1507 print*,
'pres check 1',localpet,maxval(presptr(:,:,1)),minval(presptr(:,:,1))
1508 print*,
'pres check lev',localpet,maxval(presptr(:,:,lev_input)),minval(presptr(:,:,lev_input))
1510 deallocate(pres_interface)
1512 call esmf_fielddestroy(dpres_input_grid, rc=rc)
1528 integer,
intent(in) :: localpet
1530 character(len=500) :: tilefile
1533 integer :: clb(3), cub(3)
1534 integer :: rc, tile, ncid, id_var
1535 integer :: error, id_dim
1537 real(esmf_kind_r8),
allocatable :: ak(:)
1538 real(esmf_kind_r8),
pointer :: presptr(:,:,:), psptr(:,:)
1539 real(esmf_kind_r8),
pointer :: dpresptr(:,:,:)
1540 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
1541 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
1542 real(esmf_kind_r8),
allocatable :: pres_interface(:)
1548 tilefile = trim(data_dir_input_grid) //
"/" // trim(atm_core_files_input_grid(7))
1549 print*,
"- READ ATM VERTICAL LEVELS FROM: ", trim(tilefile)
1550 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1551 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1553 error=nf90_inq_dimid(ncid,
'xaxis_1', id_dim)
1554 call
netcdf_err(error,
'reading xaxis_1 id' )
1555 error=nf90_inquire_dimension(ncid,id_dim,len=levp1_input)
1556 call
netcdf_err(error,
'reading xaxis_1 value' )
1558 lev_input = levp1_input - 1
1560 allocate(ak(levp1_input))
1562 error=nf90_inq_varid(ncid,
'ak', id_var)
1564 error=nf90_get_var(ncid, id_var, ak)
1567 error = nf90_close(ncid)
1575 print*,
"- CALL FieldCreate FOR INPUT GRID DELTA PRESSURE."
1576 dpres_input_grid = esmf_fieldcreate(input_grid, &
1577 typekind=esmf_typekind_r8, &
1578 staggerloc=esmf_staggerloc_center, &
1579 ungriddedlbound=(/1/), &
1580 ungriddedubound=(/lev_input/), rc=rc)
1581 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1584 if (localpet < num_tiles_input_grid)
then
1585 allocate(data_one_tile_3d(i_input,j_input,lev_input))
1586 allocate(data_one_tile(i_input,j_input))
1588 allocate(data_one_tile_3d(0,0,0))
1589 allocate(data_one_tile(0,0))
1592 if (localpet < num_tiles_input_grid)
then
1594 tilefile= trim(data_dir_input_grid) //
"/" // trim(atm_core_files_input_grid(tile))
1595 print*,
"- READ ATMOSPHERIC CORE FILE: ", trim(tilefile)
1596 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1597 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1600 if (localpet < num_tiles_input_grid)
then
1601 error=nf90_inq_varid(ncid,
'phis', id_var)
1603 error=nf90_get_var(ncid, id_var, data_one_tile)
1605 data_one_tile = data_one_tile / 9.806_8
1608 do tile = 1, num_tiles_input_grid
1609 print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN for tile ",tile
1610 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=tile-1, tile=tile, rc=rc)
1611 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1615 if (localpet < num_tiles_input_grid)
then
1623 data_one_tile_3d = 0.0_8
1626 do tile = 1, num_tiles_input_grid
1627 print*,
"- CALL FieldScatter FOR INPUT GRID VERTICAL VELOCITY for tile ",tile
1628 call esmf_fieldscatter(dzdt_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1629 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1633 if (localpet < num_tiles_input_grid)
then
1634 error=nf90_inq_varid(ncid,
'T', id_var)
1636 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1638 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1641 do tile = 1, num_tiles_input_grid
1642 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
1643 call esmf_fieldscatter(temp_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1644 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1648 if (localpet < num_tiles_input_grid)
then
1649 error=nf90_inq_varid(ncid,
'delp', id_var)
1651 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1653 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1656 do tile = 1, num_tiles_input_grid
1657 print*,
"- CALL FieldScatter FOR INPUT DELTA PRESSURE."
1658 call esmf_fieldscatter(dpres_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1659 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1663 if (localpet < num_tiles_input_grid)
then
1664 error=nf90_inq_varid(ncid,
'ua', id_var)
1666 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1668 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1671 do tile = 1, num_tiles_input_grid
1672 print*,
"- CALL FieldScatter FOR INPUT GRID U."
1673 call esmf_fieldscatter(u_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1674 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1678 if (localpet < num_tiles_input_grid)
then
1679 error=nf90_inq_varid(ncid,
'va', id_var)
1681 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1683 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1686 do tile = 1, num_tiles_input_grid
1687 print*,
"- CALL FieldScatter FOR INPUT GRID V."
1688 call esmf_fieldscatter(v_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1689 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1693 if (localpet < num_tiles_input_grid) error = nf90_close(ncid)
1695 if (localpet < num_tiles_input_grid)
then
1697 tilefile= trim(data_dir_input_grid) //
"/" // trim(atm_tracer_files_input_grid(tile))
1698 print*,
"- READ ATMOSPHERIC TRACER FILE: ", trim(tilefile)
1699 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1700 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1703 do i = 1, num_tracers_input
1705 if (localpet < num_tiles_input_grid)
then
1706 error=nf90_inq_varid(ncid, tracers_input(i), id_var)
1708 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1710 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1713 do tile = 1, num_tiles_input_grid
1714 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(i))
1715 call esmf_fieldscatter(tracers_input_grid(i), data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1716 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1722 if (localpet < num_tiles_input_grid) error=nf90_close(ncid)
1734 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
1735 call esmf_fieldget(ps_input_grid, &
1736 farrayptr=psptr, rc=rc)
1737 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1740 print*,
"- CALL FieldGet FOR PRESSURE."
1741 call esmf_fieldget(pres_input_grid, &
1742 computationallbound=clb, &
1743 computationalubound=cub, &
1744 farrayptr=presptr, rc=rc)
1745 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1748 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
1749 call esmf_fieldget(dpres_input_grid, &
1750 farrayptr=dpresptr, rc=rc)
1751 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1754 allocate(pres_interface(levp1_input))
1756 do i = clb(1), cub(1)
1757 do j = clb(2), cub(2)
1758 pres_interface(levp1_input) = ak(1)
1759 do k = (levp1_input-1), 1, -1
1760 pres_interface(k) = pres_interface(k+1) + dpresptr(i,j,k)
1763 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
1765 psptr(i,j) = pres_interface(1)
1770 deallocate(pres_interface)
1772 call esmf_fielddestroy(dpres_input_grid, rc=rc)
1774 deallocate(data_one_tile_3d, data_one_tile)
1789 integer,
intent(in) :: localpet
1791 character(len=500) :: tilefile
1793 integer :: start(3), count(3), iscnt
1794 integer :: error, ncid, num_tracers_file
1795 integer :: id_dim, idim_input, jdim_input
1796 integer :: id_var, rc, nprocs, max_procs
1797 integer :: kdim, remainder, myrank, i, j, k, n
1798 integer :: clb(3), cub(3)
1799 integer,
allocatable :: kcount(:), startk(:), displ(:)
1800 integer,
allocatable :: ircnt(:)
1802 real(esmf_kind_r8),
allocatable :: phalf(:)
1803 real(esmf_kind_r8),
allocatable :: pres_interface(:)
1804 real(kind=4),
allocatable :: dummy3d(:,:,:)
1805 real(kind=4),
allocatable :: dummy3dall(:,:,:)
1806 real(esmf_kind_r8),
allocatable :: dummy3dflip(:,:,:)
1807 real(esmf_kind_r8),
allocatable :: dummy(:,:)
1808 real(esmf_kind_r8),
pointer :: presptr(:,:,:), dpresptr(:,:,:)
1809 real(esmf_kind_r8),
pointer :: psptr(:,:)
1811 print*,
"- READ INPUT ATMOS DATA FROM GAUSSIAN NETCDF FILE."
1813 tilefile = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
1814 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1815 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1817 error=nf90_inq_dimid(ncid,
'grid_xt', id_dim)
1818 call
netcdf_err(error,
'reading grid_xt id' )
1819 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
1820 call
netcdf_err(error,
'reading grid_xt value' )
1822 error=nf90_inq_dimid(ncid,
'grid_yt', id_dim)
1823 call
netcdf_err(error,
'reading grid_yt id' )
1824 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
1825 call
netcdf_err(error,
'reading grid_yt value' )
1827 if (idim_input /= i_input .or. jdim_input /= j_input)
then
1828 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 2)
1831 error=nf90_inq_dimid(ncid,
'pfull', id_dim)
1833 error=nf90_inquire_dimension(ncid,id_dim,len=lev_input)
1834 call
netcdf_err(error,
'reading pfull value' )
1836 error=nf90_inq_dimid(ncid,
'phalf', id_dim)
1838 error=nf90_inquire_dimension(ncid,id_dim,len=levp1_input)
1839 call
netcdf_err(error,
'reading phalf value' )
1840 allocate(phalf(levp1_input))
1841 error=nf90_inq_varid(ncid,
'phalf', id_var)
1842 call
netcdf_err(error,
'getting phalf varid' )
1843 error=nf90_get_var(ncid, id_var, phalf)
1844 call
netcdf_err(error,
'reading phalf varid' )
1846 error=nf90_get_att(ncid, nf90_global,
'ncnsto', num_tracers_file)
1847 call
netcdf_err(error,
'reading ntracer value' )
1849 call mpi_comm_size(mpi_comm_world, nprocs, error)
1850 print*,
'- Running with ', nprocs,
' processors'
1852 call mpi_comm_rank(mpi_comm_world, myrank, error)
1853 print*,
'- myrank/localpet is ',myrank,localpet
1856 if (nprocs > lev_input)
then
1857 max_procs = lev_input
1860 kdim = lev_input / max_procs
1861 remainder = lev_input - (max_procs*kdim)
1863 allocate(kcount(0:nprocs-1))
1865 allocate(startk(0:nprocs-1))
1867 allocate(displ(0:nprocs-1))
1869 allocate(ircnt(0:nprocs-1))
1872 do k = 0, max_procs-2
1875 kcount(max_procs-1) = kdim + remainder
1878 do k = 1, max_procs-1
1879 startk(k) = startk(k-1) + kcount(k-1)
1882 ircnt(:) = idim_input * jdim_input * kcount(:)
1885 do k = 1, max_procs-1
1886 displ(k) = displ(k-1) + ircnt(k-1)
1889 iscnt=idim_input*jdim_input*kcount(myrank)
1893 if (myrank <= max_procs-1)
then
1894 allocate(dummy3d(idim_input,jdim_input,kcount(myrank)))
1896 allocate(dummy3d(0,0,0))
1899 if (myrank == 0)
then
1900 allocate(dummy3dall(idim_input,jdim_input,lev_input))
1902 allocate(dummy3dflip(idim_input,jdim_input,lev_input))
1904 allocate(dummy(idim_input,jdim_input))
1907 allocate(dummy3dall(0,0,0))
1908 allocate(dummy3dflip(0,0,0))
1909 allocate(dummy(0,0))
1918 print*,
"- CALL FieldCreate FOR INPUT GRID DELTA PRESSURE."
1919 dpres_input_grid = esmf_fieldcreate(input_grid, &
1920 typekind=esmf_typekind_r8, &
1921 staggerloc=esmf_staggerloc_center, &
1922 ungriddedlbound=(/1/), &
1923 ungriddedubound=(/lev_input/), rc=rc)
1924 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1929 if (myrank <= max_procs-1)
then
1930 start = (/1,1,startk(myrank)/)
1931 count = (/idim_input,jdim_input,kcount(myrank)/)
1932 error=nf90_inq_varid(ncid,
'tmp', id_var)
1933 call
netcdf_err(error,
'reading tmp field id' )
1934 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
1938 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
1939 dummy3dall, ircnt, displ, mpi_real, &
1940 0, mpi_comm_world, error)
1941 if (error /= 0) call
error_handler(
"IN mpi_gatherv of temperature", error)
1943 if (myrank == 0)
then
1944 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
1947 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE "
1948 call esmf_fieldscatter(temp_input_grid, dummy3dflip, rootpet=0, rc=rc)
1949 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1954 if (myrank <= max_procs-1)
then
1955 error=nf90_inq_varid(ncid,
'dpres', id_var)
1956 call
netcdf_err(error,
'reading dpres field id' )
1957 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
1958 call
netcdf_err(error,
'reading dpres field' )
1961 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
1962 dummy3dall, ircnt, displ, mpi_real, &
1963 0, mpi_comm_world, error)
1964 if (error /= 0) call
error_handler(
"IN mpi_gatherv of dpres", error)
1966 if (myrank == 0)
then
1967 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
1970 print*,
"- CALL FieldScatter FOR INPUT GRID DPRES "
1971 call esmf_fieldscatter(dpres_input_grid, dummy3dflip, rootpet=0, rc=rc)
1972 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1977 if (myrank <= max_procs-1)
then
1978 error=nf90_inq_varid(ncid,
'ugrd', id_var)
1979 call
netcdf_err(error,
'reading ugrd field id' )
1980 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
1981 call
netcdf_err(error,
'reading ugrd field' )
1984 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
1985 dummy3dall, ircnt, displ, mpi_real, &
1986 0, mpi_comm_world, error)
1987 if (error /= 0) call
error_handler(
"IN mpi_gatherv of ugrd", error)
1989 if (myrank == 0)
then
1990 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
1993 print*,
"- CALL FieldScatter FOR INPUT GRID UGRD "
1994 call esmf_fieldscatter(u_input_grid, dummy3dflip, rootpet=0, rc=rc)
1995 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2000 if (myrank <= max_procs-1)
then
2001 error=nf90_inq_varid(ncid,
'vgrd', id_var)
2002 call
netcdf_err(error,
'reading vgrd field id' )
2003 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
2004 call
netcdf_err(error,
'reading vgrd field' )
2007 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
2008 dummy3dall, ircnt, displ, mpi_real, &
2009 0, mpi_comm_world, error)
2010 if (error /= 0) call
error_handler(
"IN mpi_gatherv of vgrd", error)
2012 if (myrank == 0)
then
2013 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
2016 print*,
"- CALL FieldScatter FOR INPUT GRID VGRD "
2017 call esmf_fieldscatter(v_input_grid, dummy3dflip, rootpet=0, rc=rc)
2018 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2023 do n = 1, num_tracers_input
2025 if (myrank <= max_procs-1)
then
2026 error=nf90_inq_varid(ncid, tracers_input(n), id_var)
2027 call
netcdf_err(error,
'reading tracer field id' )
2028 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
2029 call
netcdf_err(error,
'reading tracer field' )
2032 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
2033 dummy3dall, ircnt, displ, mpi_real, &
2034 0, mpi_comm_world, error)
2035 if (error /= 0) call
error_handler(
"IN mpi_gatherv of tracer", error)
2037 if (myrank == 0)
then
2038 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
2039 where(dummy3dflip < 0.0) dummy3dflip = 0.0
2042 print*,
"- CALL FieldScatter FOR INPUT GRID ", tracers_input(n)
2043 call esmf_fieldscatter(tracers_input_grid(n), dummy3dflip, rootpet=0, rc=rc)
2044 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2051 if (myrank == 0)
then
2055 print*,
"- CALL FieldScatter FOR INPUT GRID DZDT"
2056 call esmf_fieldscatter(dzdt_input_grid, dummy3dflip, rootpet=0, rc=rc)
2057 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2060 deallocate(dummy3dflip, dummy3dall, dummy3d)
2065 print*,
"- READ TERRAIN."
2066 error=nf90_inq_varid(ncid,
'hgtsfc', id_var)
2067 call
netcdf_err(error,
'reading hgtsfc field id' )
2068 error=nf90_get_var(ncid, id_var, dummy)
2069 call
netcdf_err(error,
'reading hgtsfc field' )
2072 print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN."
2073 call esmf_fieldscatter(terrain_input_grid, dummy, rootpet=0, rc=rc)
2074 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2080 print*,
"- READ SURFACE P."
2081 error=nf90_inq_varid(ncid,
'pressfc', id_var)
2082 call
netcdf_err(error,
'reading pressfc field id' )
2083 error=nf90_get_var(ncid, id_var, dummy)
2084 call
netcdf_err(error,
'reading pressfc field' )
2087 print*,
"- CALL FieldScatter FOR INPUT GRID SURFACE P."
2088 call esmf_fieldscatter(ps_input_grid, dummy, rootpet=0, rc=rc)
2089 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2092 deallocate(kcount, startk, displ, ircnt, dummy)
2104 print*,
"- CALL FieldGet FOR PRESSURE."
2105 call esmf_fieldget(pres_input_grid, &
2106 computationallbound=clb, &
2107 computationalubound=cub, &
2108 farrayptr=presptr, rc=rc)
2109 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2112 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
2113 call esmf_fieldget(dpres_input_grid, &
2114 farrayptr=dpresptr, rc=rc)
2115 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2118 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
2119 call esmf_fieldget(ps_input_grid, &
2120 farrayptr=psptr, rc=rc)
2121 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2124 allocate(pres_interface(levp1_input))
2139 do i = clb(1), cub(1)
2140 do j = clb(2), cub(2)
2141 pres_interface(levp1_input) = phalf(1) * 100.0_8
2142 do k = lev_input, 1, -1
2143 pres_interface(k) = pres_interface(k+1) + dpresptr(i,j,k)
2145 psptr(i,j) = pres_interface(1)
2147 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
2152 deallocate(pres_interface, phalf)
2154 call esmf_fielddestroy(dpres_input_grid, rc=rc)
2173 integer,
intent(in) :: localpet
2175 character(len=500) :: tilefile
2177 integer :: error, ncid, rc, tile
2178 integer :: id_dim, idim_input, jdim_input
2179 integer :: id_var, i, j, k, n
2180 integer :: clb(3), cub(3), num_tracers_file
2182 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
2183 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
2184 real(esmf_kind_r8),
pointer :: presptr(:,:,:), dpresptr(:,:,:)
2185 real(esmf_kind_r8),
pointer :: psptr(:,:)
2186 real(esmf_kind_r8),
allocatable :: pres_interface(:), phalf(:)
2188 print*,
"- READ INPUT ATMOS DATA FROM TILED HISTORY FILES."
2190 tilefile = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
2191 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
2192 call
netcdf_err(error,
'opening: '//trim(tilefile) )
2194 error=nf90_inq_dimid(ncid,
'grid_xt', id_dim)
2195 call
netcdf_err(error,
'reading grid_xt id' )
2196 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
2197 call
netcdf_err(error,
'reading grid_xt value' )
2199 error=nf90_inq_dimid(ncid,
'grid_yt', id_dim)
2200 call
netcdf_err(error,
'reading grid_yt id' )
2201 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
2202 call
netcdf_err(error,
'reading grid_yt value' )
2204 if (idim_input /= i_input .or. jdim_input /= j_input)
then
2205 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 2)
2208 error=nf90_inq_dimid(ncid,
'pfull', id_dim)
2210 error=nf90_inquire_dimension(ncid,id_dim,len=lev_input)
2211 call
netcdf_err(error,
'reading pfull value' )
2213 error=nf90_inq_dimid(ncid,
'phalf', id_dim)
2215 error=nf90_inquire_dimension(ncid,id_dim,len=levp1_input)
2216 call
netcdf_err(error,
'reading phalf value' )
2217 allocate(phalf(levp1_input))
2218 error=nf90_inq_varid(ncid,
'phalf', id_var)
2219 call
netcdf_err(error,
'getting phalf varid' )
2220 error=nf90_get_var(ncid, id_var, phalf)
2221 call
netcdf_err(error,
'reading phalf varid' )
2223 error=nf90_get_att(ncid, nf90_global,
'ncnsto', num_tracers_file)
2224 call
netcdf_err(error,
'reading ntracer value' )
2226 error = nf90_close(ncid)
2228 print*,
'- FILE HAS ', num_tracers_file,
' TRACERS.'
2229 print*,
'- WILL PROCESS ', num_tracers_input,
' TRACERS.'
2237 print*,
"- CALL FieldCreate FOR INPUT GRID DELTA PRESSURE."
2238 dpres_input_grid = esmf_fieldcreate(input_grid, &
2239 typekind=esmf_typekind_r8, &
2240 staggerloc=esmf_staggerloc_center, &
2241 ungriddedlbound=(/1/), &
2242 ungriddedubound=(/lev_input/), rc=rc)
2243 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2246 if (localpet < num_tiles_input_grid)
then
2247 allocate(data_one_tile(i_input,j_input))
2248 allocate(data_one_tile_3d(i_input,j_input,lev_input))
2250 allocate(data_one_tile(0,0))
2251 allocate(data_one_tile_3d(0,0,0))
2254 if (localpet < num_tiles_input_grid)
then
2256 tilefile= trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(tile))
2257 print*,
"- READ ATMOSPHERIC DATA FROM: ", trim(tilefile)
2258 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
2259 call
netcdf_err(error,
'opening: '//trim(tilefile) )
2262 if (localpet < num_tiles_input_grid)
then
2272 data_one_tile_3d = 0.0_8
2275 do tile = 1, num_tiles_input_grid
2276 print*,
"- CALL FieldScatter FOR INPUT GRID VERTICAL VELOCITY."
2277 call esmf_fieldscatter(dzdt_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2278 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2282 do n = 1, num_tracers_input
2284 if (localpet < num_tiles_input_grid)
then
2285 print*,
"- READ ", trim(tracers_input(n))
2286 error=nf90_inq_varid(ncid, tracers_input(n), id_var)
2288 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2290 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2293 do tile = 1, num_tiles_input_grid
2294 print*,
"- CALL FieldScatter FOR INPUT GRID TRACER ", trim(tracers_input(n))
2295 call esmf_fieldscatter(tracers_input_grid(n), data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2296 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2302 if (localpet < num_tiles_input_grid)
then
2303 print*,
"- READ TEMPERATURE."
2304 error=nf90_inq_varid(ncid,
'tmp', id_var)
2306 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2308 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2311 do tile = 1, num_tiles_input_grid
2312 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
2313 call esmf_fieldscatter(temp_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2314 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2318 if (localpet < num_tiles_input_grid)
then
2319 print*,
"- READ U-WIND."
2320 error=nf90_inq_varid(ncid,
'ugrd', id_var)
2322 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2324 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2327 do tile = 1, num_tiles_input_grid
2328 print*,
"- CALL FieldScatter FOR INPUT GRID U."
2329 call esmf_fieldscatter(u_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2330 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2334 if (localpet < num_tiles_input_grid)
then
2335 print*,
"- READ V-WIND."
2336 error=nf90_inq_varid(ncid,
'vgrd', id_var)
2338 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2340 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2343 do tile = 1, num_tiles_input_grid
2344 print*,
"- CALL FieldScatter FOR INPUT GRID V."
2345 call esmf_fieldscatter(v_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2346 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2350 if (localpet < num_tiles_input_grid)
then
2351 print*,
"- READ SURFACE PRESSURE."
2352 error=nf90_inq_varid(ncid,
'pressfc', id_var)
2354 error=nf90_get_var(ncid, id_var, data_one_tile)
2358 do tile = 1, num_tiles_input_grid
2359 print*,
"- CALL FieldScatter FOR INPUT GRID SURFACE PRESSURE."
2360 call esmf_fieldscatter(ps_input_grid, data_one_tile, rootpet=tile-1, tile=tile, rc=rc)
2361 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2365 if (localpet < num_tiles_input_grid)
then
2366 print*,
"- READ TERRAIN."
2367 error=nf90_inq_varid(ncid,
'hgtsfc', id_var)
2369 error=nf90_get_var(ncid, id_var, data_one_tile)
2373 do tile = 1, num_tiles_input_grid
2374 print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN."
2375 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=tile-1, tile=tile, rc=rc)
2376 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2380 if (localpet < num_tiles_input_grid)
then
2381 print*,
"- READ DELTA PRESSURE."
2382 error=nf90_inq_varid(ncid,
'dpres', id_var)
2384 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2386 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2389 do tile = 1, num_tiles_input_grid
2390 print*,
"- CALL FieldScatter FOR INPUT DELTA PRESSURE."
2391 call esmf_fieldscatter(dpres_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2392 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2396 if (localpet < num_tiles_input_grid) error = nf90_close(ncid)
2398 deallocate(data_one_tile_3d, data_one_tile)
2410 print*,
"- CALL FieldGet FOR PRESSURE."
2411 call esmf_fieldget(pres_input_grid, &
2412 computationallbound=clb, &
2413 computationalubound=cub, &
2414 farrayptr=presptr, rc=rc)
2415 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2418 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
2419 call esmf_fieldget(dpres_input_grid, &
2420 farrayptr=dpresptr, rc=rc)
2421 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2424 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
2425 call esmf_fieldget(ps_input_grid, &
2426 farrayptr=psptr, rc=rc)
2427 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2430 allocate(pres_interface(levp1_input))
2436 do i = clb(1), cub(1)
2437 do j = clb(2), cub(2)
2438 pres_interface(1) = psptr(i,j)
2439 do k = 2, levp1_input
2440 pres_interface(k) = pres_interface(k-1) - dpresptr(i,j,k-1)
2443 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
2448 deallocate(pres_interface, phalf)
2450 call esmf_fielddestroy(dpres_input_grid, rc=rc)
2466 integer,
intent(in) :: localpet
2468 integer,
parameter :: ntrac_max=14
2470 character(len=300) :: the_file
2471 character(len=20) :: vlevtyp, vname, lvl_str,lvl_str_space, &
2472 trac_names_grib_1(ntrac_max), &
2473 trac_names_grib_2(ntrac_max), &
2474 trac_names_vmap(ntrac_max), &
2475 tracers_input_grib_1(num_tracers_input), &
2476 tracers_input_grib_2(num_tracers_input), &
2478 method, tracers_input_vmap(num_tracers_input), &
2479 tracers_default(ntrac_max), vname2
2480 character (len=500) :: metadata
2482 integer :: i, j, k, n, lvl_str_space_len
2484 integer :: rc, clb(3), cub(3)
2485 integer :: vlev, iret,varnum
2486 integer :: all_empty, o3n
2488 integer :: is_missing, intrp_ier, done_print
2491 logical :: conv_omega=.false., &
2495 real(esmf_kind_r8),
allocatable :: rlevs(:)
2496 real(esmf_kind_r4),
allocatable :: dummy2d(:,:)
2497 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:), dummy2d_8(:,:),&
2498 u_tmp_3d(:,:,:), v_tmp_3d(:,:,:)
2499 real(esmf_kind_r8),
pointer :: presptr(:,:,:), psptr(:,:),tptr(:,:,:), &
2500 qptr(:,:,:), wptr(:,:,:), &
2501 uptr(:,:,:), vptr(:,:,:)
2502 real(esmf_kind_r4) :: value
2503 real(esmf_kind_r8),
parameter :: p0 = 100000.0
2504 real(esmf_kind_r8),
allocatable :: dummy3d_col_in(:),dummy3d_col_out(:)
2505 real(esmf_kind_r8),
parameter :: intrp_missing = -999.0
2506 real(esmf_kind_r4),
parameter :: lev_no_tr_fill = 20000.0
2507 real(esmf_kind_r4),
parameter :: lev_no_o3_fill = 40000.0
2513 trac_names_grib_1 = (/
":var0_2",
":var0_2",
":var0_2",
":var0_2",
":var0_2",
":var0_2", \
2514 ":var0_2",
":var0_2",
":var0_2",
":var0_2",
":var0_2",
":var0_2", \
2515 ":var0_2",
":var0_2"/)
2516 trac_names_grib_2 = (/
"_1_0: ",
"_1_22: ",
"_14_192:",
"_1_23: ",
"_1_24: ",
"_1_25: ", \
2517 "_1_32: ",
"_6_1: ",
"_6_29: ",
"_1_100: ",
"_6_28: ",
"_13_193:", \
2518 "_13_192:",
"_2_2: "/)
2519 trac_names_vmap = (/
"sphum ",
"liq_wat ",
"o3mr ",
"ice_wat ", &
2520 "rainwat ",
"snowwat ",
"graupel ",
"cld_amt ",
"ice_nc ", &
2521 "rain_nc ",
"water_nc",
"liq_aero",
"ice_aero", &
2523 tracers_default = (/
"sphum ",
"liq_wat ",
"o3mr ",
"ice_wat ", &
2524 "rainwat ",
"snowwat ",
"graupel ",
"cld_amt ",
"ice_nc ", &
2525 "rain_nc ",
"water_nc",
"liq_aero",
"ice_aero", &
2528 the_file = trim(data_dir_input_grid) //
"/" // trim(grib2_file_input_grid)
2530 print*,
"- READ ATMOS DATA FROM GRIB2 FILE: ", trim(the_file)
2531 print*,
"- USE INVENTORY FILE ", inv_file
2533 print*,
"- OPEN FILE."
2534 inquire(file=the_file,exist=lret)
2535 if (.not.lret) call
error_handler(
"OPENING GRIB2 ATM FILE.", iret)
2537 print*,
"- READ VERTICAL COORDINATE."
2538 iret = grb2_inq(the_file,inv_file,
":var0_2",
"_0_0:",
":10 hybrid level:")
2542 lvl_str_space =
" mb:"
2543 lvl_str_space_len = 4
2545 iret = grb2_inq(the_file,inv_file,
":UGRD:",lvl_str_space)
2547 if (localpet == 0) print*,
"- DATA IS ON ", lev_input,
" ISOBARIC LEVELS."
2550 lvl_str_space =
" hybrid "
2551 lvl_str_space_len = 7
2553 iret = grb2_inq(the_file,inv_file,
":UGRD:",lvl_str_space,
" level:")
2554 if (iret < 0) call
error_handler(
"READING VERTICAL LEVEL TYPE.", iret)
2558 allocate(slevs(lev_input))
2559 allocate(rlevs(lev_input))
2560 allocate(dummy3d_col_in(lev_input))
2561 allocate(dummy3d_col_out(lev_input))
2563 levp1_input = lev_input + 1
2568 iret=grb2_inq(the_file,inv_file,
':UGRD:',trim(lvl_str),sequential=i-1,desc=metadata)
2569 if (iret.ne.1) call
error_handler(
" IN SEQUENTIAL FILE READ.", iret)
2571 j = index(metadata,
':UGRD:') + len(
':UGRD:')
2572 k = index(metadata,trim(lvl_str_space)) + len(trim(lvl_str_space))-1
2574 read(metadata(j:k),*) rlevs(i)
2576 slevs(i) = metadata(j-1:k)
2577 if (.not. isnative) rlevs(i) = rlevs(i) * 100.0
2578 if (localpet==0) print*,
"- LEVEL = ", slevs(i)
2585 if (.not. isnative)
then
2587 write(slevs(i),
"(F20.10)") rlevs(i)/100.0
2588 len_str = len_trim(slevs(i))
2590 do while (slevs(i)(len_str:len_str) .eq.
'0')
2591 slevs(i) = slevs(i)(:len_str-1)
2592 len_str = len_str - 1
2595 if (slevs(i)(len_str:len_str) .eq.
'.')
then
2596 slevs(i) = slevs(i)(:len_str-1)
2597 len_str = len_str - 1
2600 slevs(i) = trim(slevs(i))
2602 slevs(i) =
":"//trim(adjustl(slevs(i)))//
" mb:"
2603 if (localpet==0) print*,
"- LEVEL AFTER SORT = ",slevs(i)
2607 if (localpet == 0) print*,
"- FIND SPFH OR RH IN FILE"
2608 iret = grb2_inq(the_file,inv_file,trim(trac_names_grib_1(1)),trac_names_grib_2(1),lvl_str_space)
2611 iret = grb2_inq(the_file,inv_file,
':var0_2',
'_1_1:',lvl_str_space)
2612 if (iret <= 0) call
error_handler(
"READING ATMOSPHERIC WATER VAPOR VARIABLE.", iret)
2614 trac_names_grib_2(1)=
'_1_1:'
2615 if (localpet == 0) print*,
"- FILE CONTAINS RH."
2617 if (localpet == 0) print*,
"- FILE CONTAINS SPFH."
2620 if (localpet == 0) print*,
"- FIND ICMR, SCLIWC, OR CICE IN FILE"
2621 iret = grb2_inq(the_file,inv_file,trac_names_grib_1(4),trac_names_grib_2(4),lvl_str_space)
2624 vname = trac_names_vmap(4)
2625 print*,
"vname = ", vname
2626 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
2627 this_field_var_name=tmpstr,loc=varnum)
2628 iret = grb2_inq(the_file,inv_file,
':var0_2',
'_1_84:',lvl_str_space)
2630 iret = grb2_inq(the_file,inv_file,
':var0_2',
'_6_0:',lvl_str_space)
2631 if (iret <= 0 )
then
2634 trac_names_grib_2(4) =
'_6_0'
2635 if (localpet == 0) print*,
"- FILE CONTAINS CICE."
2638 trac_names_grib_2(4)=
'_1_84:'
2639 if (localpet == 0) print*,
"- FILE CONTAINS SCLIWC."
2642 if (localpet == 0) print*,
"- FILE CONTAINS ICMR."
2645 if (localpet == 0) print*,
"- FIND CLWMR or SCLLWC IN FILE"
2646 iret = grb2_inq(the_file,inv_file,trac_names_grib_1(5),trac_names_grib_2(5),lvl_str_space)
2649 vname = trac_names_vmap(5)
2650 print*,
"vname = ", vname
2651 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
2652 this_field_var_name=tmpstr,loc=varnum)
2653 iret = grb2_inq(the_file,inv_file,
':var0_2',
'_1_83:',lvl_str_space)
2656 elseif (iret <=0 .and. rc .ne. 1)
then
2659 trac_names_grib_2(4)=
'_1_83:'
2660 if (localpet == 0) print*,
"- FILE CONTAINS SCLLWC."
2663 if (localpet == 0) print*,
"- FILE CONTAINS CLWMR."
2666 print*,
"- COUNT NUMBER OF TRACERS TO BE READ IN BASED ON PHYSICS SUITE TABLE"
2667 do n = 1, num_tracers_input
2669 vname = tracers_input(n)
2671 i = maxloc(merge(1.,0.,trac_names_vmap == vname),dim=1)
2673 tracers_input_grib_1(n) = trac_names_grib_1(i)
2674 tracers_input_grib_2(n) = trac_names_grib_2(i)
2675 tracers_input_vmap(n)=trac_names_vmap(i)
2676 tracers(n)=tracers_default(i)
2677 if(trim(tracers(n)) .eq.
"o3mr") o3n = n
2681 if (localpet==0)
then
2682 print*,
"- NUMBER OF TRACERS IN THE INPUT FILE = ", num_tracers_input
2691 if (localpet == 0)
then
2692 allocate(dummy2d(i_input,j_input))
2693 allocate(dummy2d_8(i_input,j_input))
2694 allocate(dummy3d(i_input,j_input,lev_input))
2696 allocate(dummy2d(0,0))
2697 allocate(dummy2d_8(0,0))
2698 allocate(dummy3d(0,0,0))
2707 if (localpet == 0)
then
2708 print*,
"- READ TEMPERATURE."
2710 do vlev = 1, lev_input
2711 iret = grb2_inq(the_file,inv_file,vname,slevs(vlev),data2=dummy2d)
2713 call
error_handler(
"READING IN TEMPERATURE AT LEVEL "//trim(slevs(vlev)),iret)
2715 dummy3d(:,:,vlev) =
real(dummy2d,esmf_kind_r8)
2716 print*,
'temp check after read ',vlev, dummy3d(1,1,vlev)
2720 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
2721 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
2722 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2725 do n = 1, num_tracers_input
2727 if (localpet == 0) print*,
"- READ ", trim(tracers_input_vmap(n))
2728 vname = tracers_input_vmap(n)
2729 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
2730 this_field_var_name=tmpstr,loc=varnum)
2731 if (n==1 .and. .not. hasspfh)
then
2732 print*,
"- CALL FieldGather TEMPERATURE."
2733 call esmf_fieldgather(temp_input_grid,dummy3d,rootpet=0, tile=1, rc=rc)
2734 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2738 if (localpet == 0)
then
2739 vname = trim(tracers_input_grib_1(n))
2740 vname2 = trim(tracers_input_grib_2(n))
2741 iret = grb2_inq(the_file,inv_file,vname,lvl_str_space,vname2)
2751 do vlev = 1, lev_input
2752 iret = grb2_inq(the_file,inv_file,vname,slevs(vlev),vname2,data2=dummy2d)
2755 if (trim(method) .eq.
'intrp' .and. all_empty == 0)
then
2756 dummy2d = intrp_missing
2761 if (all_empty == 0 .and. n == o3n)
then
2762 if (rlevs(vlev) .lt. lev_no_o3_fill) &
2763 call
error_handler(
"TRACER "//trim(tracers(n))//
" HAS MISSING DATA AT "//trim(slevs(vlev))//&
2764 ". SET MISSING VARIABLE CONDITION TO 'INTRP' TO AVOID THIS ERROR", 1)
2765 elseif (all_empty == 0 .and. n .ne. o3n)
then
2766 if (rlevs(vlev) .gt. lev_no_tr_fill) &
2767 call
error_handler(
"TRACER "//trim(tracers(n))//
" HAS MISSING DATA AT "//trim(slevs(vlev))//&
2768 ". SET MISSING VARIABLE CONDITION TO 'INTRP' TO AVOID THIS ERROR.", 1)
2771 if (trim(method) .eq.
'intrp' .and. all_empty == 1) method=
'set_to_fill'
2775 if (trim(vname2)==
"_1_0:" .or. trim(vname2) ==
"_1_1:" .or. &
2776 trim(vname2) ==
":14:192:")
then
2777 call
error_handler(
"READING IN "//trim(tracers(n))//
" AT LEVEL "//trim(slevs(vlev))&
2778 //
". SET A FILL VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",iret)
2784 if (n==1 .and. .not. hasspfh)
then
2785 call
rh2spfh(dummy2d,rlevs(vlev),dummy3d(:,:,vlev))
2788 print*,
'tracer ',vlev, maxval(dummy2d),minval(dummy2d)
2789 dummy3d(:,:,vlev) =
real(dummy2d,esmf_kind_r8)
2792 if (is_missing .gt. 0 .and. trim(method) .eq.
'intrp')
then
2793 print *,
'intrp tracer '//trim(tracers(n))
2797 dummy3d_col_in=dummy3d(ii,jj,:)
2798 call
dint2p(rlevs,dummy3d_col_in,lev_input,rlevs,dummy3d_col_out, &
2799 lev_input, 2, intrp_missing, intrp_ier)
2800 if (intrp_ier .gt. 0) call
error_handler(
"Interpolation failed.",intrp_ier)
2801 dummy3d(ii,jj,:)=dummy3d_col_out
2805 dummy2d = dummy3d(:,:,n)
2806 if (any(dummy2d .eq. intrp_missing))
then
2808 if (n == o3n .and. rlevs(vlev) .lt. lev_no_o3_fill)
then
2809 call
error_handler(
"TRACER "//trim(tracers(n))//
" HAS MISSING DATA AT "//trim(slevs(vlev)),1)
2810 elseif (n .ne. o3n .and. rlevs(vlev) .gt. lev_no_tr_fill)
then
2811 call
error_handler(
"TRACER "//trim(tracers(n))//
" HAS MISSING DATA AT "//trim(slevs(vlev)),1)
2813 if (done_print .eq. 0)
then
2814 print*,
"Pressure out of range of existing data. Defaulting to fill value."
2817 where(dummy2d .eq. intrp_missing) dummy2d = value
2818 dummy3d(:,:,vlev) = dummy2d
2822 where(dummy3d(:,:,vlev) .lt. 0.0) dummy3d(:,:,vlev) = 0.0
2823 print*,
'tracer af intrp',vlev, maxval(dummy3d(:,:,vlev)),minval(dummy3d(:,:,vlev))
2828 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input_vmap(n))
2829 call esmf_fieldscatter(tracers_input_grid(n), dummy3d, rootpet=0, rc=rc)
2830 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2835 deallocate(dummy3d_col_in, dummy3d_col_out)
2837 call
read_winds(the_file,inv_file,u_tmp_3d,v_tmp_3d, localpet)
2839 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT U-WIND."
2840 call esmf_fieldscatter(u_input_grid, u_tmp_3d, rootpet=0, rc=rc)
2841 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2844 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT V-WIND."
2845 call esmf_fieldscatter(v_input_grid, v_tmp_3d, rootpet=0, rc=rc)
2846 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2849 if (localpet == 0)
then
2850 print*,
"- READ SURFACE PRESSURE."
2853 vlevtyp =
":surface:"
2854 iret = grb2_inq(the_file,inv_file,vname,vname2,vlevtyp,data2=dummy2d)
2855 if (iret <= 0) call
error_handler(
"READING SURFACE PRESSURE RECORD.", iret)
2856 dummy2d_8 =
real(dummy2d,esmf_kind_r8)
2859 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID SURFACE PRESSURE."
2860 call esmf_fieldscatter(ps_input_grid, dummy2d_8, rootpet=0, rc=rc)
2861 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2864 if (localpet == 0)
then
2865 print*,
"- READ DZDT."
2867 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
2871 do vlev = 1, lev_input
2872 iret = grb2_inq(the_file,inv_file,vname,vname2,slevs(vlev),data2=dummy2d)
2873 if (iret <= 0 )
then
2874 print*,
"DZDT not available at level ", trim(slevs(vlev)),
" so checking for VVEL"
2876 iret = grb2_inq(the_file,inv_file,vname,vname2,slevs(vlev),data2=dummy2d)
2887 print*,
'dzdt ',vlev, maxval(dummy2d),minval(dummy2d)
2888 dummy3d(:,:,vlev) = dummy2d
2892 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT DZDT."
2893 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
2894 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2897 if (localpet == 0)
then
2898 print*,
"- READ TERRAIN."
2901 vlevtyp =
":surface:"
2902 iret = grb2_inq(the_file,inv_file,vname,vname2,vlevtyp,data2=dummy2d)
2903 if (iret <= 0) call
error_handler(
"READING TERRAIN HEIGHT RECORD.", iret)
2904 dummy2d_8 =
real(dummy2d,esmf_kind_r8)
2907 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN."
2908 call esmf_fieldscatter(terrain_input_grid, dummy2d_8, rootpet=0, rc=rc)
2909 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2912 deallocate(dummy2d, dummy2d_8)
2914 if (.not. isnative)
then
2920 if (localpet == 0) print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
2922 call esmf_fieldget(ps_input_grid, &
2923 farrayptr=psptr, rc=rc)
2924 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2928 if (localpet == 0) print*,
"- CALL FieldGet FOR 3-D PRESSURE."
2929 call esmf_fieldget(pres_input_grid, &
2930 computationallbound=clb, &
2931 computationalubound=cub, &
2932 farrayptr=presptr, rc=rc)
2933 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2937 if (localpet == 0) print*,
"- CALL FieldGet TEMPERATURE."
2938 call esmf_fieldget(temp_input_grid, &
2939 farrayptr=tptr, rc=rc)
2940 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2944 if (localpet == 0) print*,
"- CALL FieldGet FOR U"
2945 call esmf_fieldget(u_input_grid, &
2946 farrayptr=uptr, rc=rc)
2947 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2951 if (localpet == 0) print*,
"- CALL FieldGet FOR V"
2952 call esmf_fieldget(v_input_grid, &
2953 farrayptr=vptr, rc=rc)
2954 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2958 if (localpet == 0) print*,
"- CALL FieldGet FOR W"
2959 call esmf_fieldget(dzdt_input_grid, &
2960 farrayptr=wptr, rc=rc)
2961 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2964 if (localpet == 0) print*,
"- CALL FieldGet FOR TRACERS."
2965 do n=1,num_tracers_input
2967 call esmf_fieldget(tracers_input_grid(n), &
2968 farrayptr=qptr, rc=rc)
2969 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2971 do i = clb(1),cub(1)
2972 do j = clb(2),cub(2)
2973 qptr(i,j,:) = qptr(i,j,lev_input:1:-1)
2978 do i = clb(1),cub(1)
2979 do j = clb(2),cub(2)
2980 presptr(i,j,:) = rlevs(lev_input:1:-1)
2981 tptr(i,j,:) = tptr(i,j,lev_input:1:-1)
2982 uptr(i,j,:) = uptr(i,j,lev_input:1:-1)
2983 vptr(i,j,:) = vptr(i,j,lev_input:1:-1)
2984 wptr(i,j,:) = wptr(i,j,lev_input:1:-1)
2988 if (localpet == 0)
then
2989 print*,
'psfc is ',clb(1),clb(2),psptr(clb(1),clb(2))
2990 print*,
'pres is ',cub(1),cub(2),presptr(cub(1),cub(2),:)
2992 print*,
'pres check 1',localpet,maxval(presptr(clb(1):cub(1),clb(2):cub(2),1)), &
2993 minval(presptr(clb(1):cub(1),clb(2):cub(2),1))
2994 print*,
'pres check lev',localpet,maxval(presptr(clb(1):cub(1),clb(2):cub(2), &
2995 lev_input)),minval(presptr(clb(1):cub(1),clb(2):cub(2),lev_input))
3000 if (localpet == 0)
then
3001 print*,
"- READ PRESSURE."
3003 do vlev = 1, lev_input
3004 iret = grb2_inq(the_file,inv_file,vname,slevs(vlev),data2=dummy2d)
3006 call
error_handler(
"READING IN PRESSURE AT LEVEL "//trim(slevs(vlev)),iret)
3008 dummy3d(:,:,vlev) =
real(dummy2d,esmf_kind_r8)
3009 print*,
'pres check after read ',vlev, dummy3d(1,1,vlev)
3013 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID PRESSURE."
3014 call esmf_fieldscatter(pres_input_grid, dummy3d, rootpet=0, rc=rc)
3015 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3030 if (conv_omega)
then
3032 if (localpet == 0) print*,
"- CONVERT FROM OMEGA TO DZDT."
3035 if (localpet == 0) print*,
"- CALL FieldGet TEMPERATURE."
3036 call esmf_fieldget(temp_input_grid, &
3037 farrayptr=tptr, rc=rc)
3038 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3042 if (localpet == 0) print*,
"- CALL FieldGet SPECIFIC HUMIDITY."
3043 call esmf_fieldget(tracers_input_grid(1), &
3044 computationallbound=clb, &
3045 computationalubound=cub, &
3046 farrayptr=qptr, rc=rc)
3047 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3051 if (localpet == 0) print*,
"- CALL FieldGet DZDT."
3052 call esmf_fieldget(dzdt_input_grid, &
3053 computationallbound=clb, &
3054 computationalubound=cub, &
3055 farrayptr=wptr, rc=rc)
3056 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3060 call esmf_fieldget(pres_input_grid, &
3061 farrayptr=presptr, rc=rc)
3062 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3084 integer,
intent(in) :: localpet
3086 character(len=300) :: the_file
3088 integer(sfcio_intkind) :: iret
3091 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
3092 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
3094 type(sfcio_head
) :: sfchead
3095 type(sfcio_dbta
) :: sfcdata
3097 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
3099 print*,
"- READ SURFACE DATA IN SFCIO FORMAT."
3100 print*,
"- OPEN AND READ: ",trim(the_file)
3101 call sfcio_sropen(23, trim(the_file), iret)
3107 call sfcio_srhead(23, sfchead, iret)
3113 if (localpet == 0)
then
3114 call sfcio_aldbta(sfchead, sfcdata, iret)
3119 call sfcio_srdbta(23, sfchead, sfcdata, iret)
3124 allocate(dummy2d(i_input,j_input))
3125 allocate(dummy3d(i_input,j_input,lsoil_input))
3127 allocate(dummy2d(0,0))
3128 allocate(dummy3d(0,0,0))
3131 if (localpet == 0) dummy2d = sfcdata%slmsk
3133 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
3134 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
3135 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3138 if (localpet == 0) dummy2d = sfcdata%zorl
3140 print*,
"- CALL FieldScatter FOR INPUT Z0."
3141 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
3142 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3145 if (localpet == 0) dummy2d = nint(sfcdata%vtype)
3147 print*,
"- CALL FieldScatter FOR INPUT VEG TYPE."
3148 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
3149 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3153 veg_type_landice_input = 13
3155 if (localpet == 0) dummy2d = sfcdata%canopy
3157 print*,
"- CALL FieldScatter FOR INPUT CANOPY MC."
3158 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
3159 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3162 if (localpet == 0) dummy2d = sfcdata%fice
3164 print*,
"- CALL FieldScatter FOR INPUT ICE FRACTION."
3165 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
3166 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3169 if (localpet == 0) dummy2d = sfcdata%hice
3171 print*,
"- CALL FieldScatter FOR INPUT ICE DEPTH."
3172 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3173 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3176 if (localpet == 0) dummy2d = sfcdata%tisfc
3178 print*,
"- CALL FieldScatter FOR INPUT ICE SKIN TEMP."
3179 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3180 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3183 if (localpet == 0) dummy2d = sfcdata%snwdph
3185 print*,
"- CALL FieldScatter FOR INPUT SNOW DEPTH."
3186 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3187 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3190 if (localpet == 0) dummy2d = sfcdata%sheleg
3192 print*,
"- CALL FieldScatter FOR INPUT SNOW LIQUID EQUIV."
3193 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
3194 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3197 if (localpet == 0) dummy2d = sfcdata%t2m
3199 print*,
"- CALL FieldScatter FOR INPUT T2M."
3200 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
3201 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3204 if (localpet == 0) dummy2d = sfcdata%q2m
3206 print*,
"- CALL FieldScatter FOR INPUT Q2M."
3207 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
3208 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3211 if (localpet == 0) dummy2d = sfcdata%tprcp
3213 print*,
"- CALL FieldScatter FOR INPUT TPRCP."
3214 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
3215 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3218 if (localpet == 0) dummy2d = sfcdata%f10m
3220 print*,
"- CALL FieldScatter FOR INPUT F10M."
3221 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
3222 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3225 if (localpet == 0) dummy2d = sfcdata%uustar
3227 print*,
"- CALL FieldScatter FOR INPUT USTAR."
3228 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
3229 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3232 if (localpet == 0) dummy2d = sfcdata%ffmm
3234 print*,
"- CALL FieldScatter FOR INPUT FFMM."
3235 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
3236 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3239 if (localpet == 0) dummy2d = sfcdata%srflag
3241 print*,
"- CALL FieldScatter FOR INPUT SRFLAG."
3242 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
3243 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3246 if (localpet == 0) dummy2d = sfcdata%tsea
3248 print*,
"- CALL FieldScatter FOR INPUT SKIN TEMP."
3249 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3250 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3253 if (localpet == 0) dummy2d = nint(sfcdata%stype)
3255 print*,
"- CALL FieldScatter FOR INPUT SOIL TYPE."
3256 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
3257 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3260 if (localpet == 0) dummy2d = sfcdata%orog
3262 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
3263 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
3264 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3267 if (localpet == 0) dummy3d = sfcdata%slc
3269 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
3270 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
3271 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3274 if (localpet == 0) dummy3d = sfcdata%smc
3276 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
3277 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
3278 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3281 if (localpet == 0) dummy3d = sfcdata%stc
3283 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
3284 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
3285 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3288 deallocate(dummy2d, dummy3d)
3289 call sfcio_axdbta(sfcdata, iret)
3291 call sfcio_sclose(23, iret)
3306 integer,
intent(in) :: localpet
3308 character(len=300) :: the_file
3312 real(nemsio_realkind),
allocatable :: dummy(:)
3313 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
3314 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
3316 type(nemsio_gfile
) :: gfile
3318 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
3320 if (localpet == 0)
then
3321 allocate(dummy3d(i_input,j_input,lsoil_input))
3322 allocate(dummy2d(i_input,j_input))
3323 allocate(dummy(i_input*j_input))
3324 print*,
"- OPEN FILE ", trim(the_file)
3325 call nemsio_open(gfile, the_file,
"read", iret=rc)
3328 allocate(dummy3d(0,0,0))
3329 allocate(dummy2d(0,0))
3333 if (localpet == 0)
then
3334 print*,
"- READ TERRAIN."
3335 call nemsio_readrecv(gfile,
"orog",
"sfc", 1, dummy, 0, iret=rc)
3337 dummy2d = reshape(dummy, (/i_input,j_input/))
3338 print*,
'orog ',maxval(dummy2d),minval(dummy2d)
3341 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
3342 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
3343 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3346 if (localpet == 0)
then
3347 print*,
"- READ LANDSEA MASK."
3348 call nemsio_readrecv(gfile,
"land",
"sfc", 1, dummy, 0, iret=rc)
3349 if (rc /= 0) call
error_handler(
"READING LANDSEA MASK.", rc)
3350 dummy2d = reshape(dummy, (/i_input,j_input/))
3351 print*,
'landmask ',maxval(dummy2d),minval(dummy2d)
3354 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
3355 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
3356 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3359 if (localpet == 0)
then
3360 print*,
"- READ SEAICE FRACTION."
3361 call nemsio_readrecv(gfile,
"icec",
"sfc", 1, dummy, 0, iret=rc)
3362 if (rc /= 0) call
error_handler(
"READING SEAICE FRACTION.", rc)
3363 dummy2d = reshape(dummy, (/i_input,j_input/))
3364 print*,
'icec ',maxval(dummy2d),minval(dummy2d)
3367 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
3368 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
3369 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3372 if (localpet == 0)
then
3373 print*,
"- READ SEAICE DEPTH."
3374 call nemsio_readrecv(gfile,
"icetk",
"sfc", 1, dummy, 0, iret=rc)
3375 if (rc /= 0) call
error_handler(
"READING SEAICE DEPTH.", rc)
3376 dummy2d = reshape(dummy, (/i_input,j_input/))
3377 print*,
'icetk ',maxval(dummy2d),minval(dummy2d)
3380 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
3381 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3382 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3385 if (localpet == 0)
then
3386 print*,
"- READ SEAICE SKIN TEMPERATURE."
3387 call nemsio_readrecv(gfile,
"tisfc",
"sfc", 1, dummy, 0, iret=rc)
3388 if (rc /= 0) call
error_handler(
"READING SEAICE SKIN TEMP.", rc)
3389 dummy2d = reshape(dummy, (/i_input,j_input/))
3390 print*,
'ti ',maxval(dummy2d),minval(dummy2d)
3393 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
3394 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3395 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3398 if (localpet == 0)
then
3399 print*,
"- READ SNOW LIQUID EQUIVALENT."
3400 call nemsio_readrecv(gfile,
"weasd",
"sfc", 1, dummy, 0, iret=rc)
3401 if (rc /= 0) call
error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
3402 dummy2d = reshape(dummy, (/i_input,j_input/))
3403 print*,
'weasd ',maxval(dummy2d),minval(dummy2d)
3406 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
3407 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
3408 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3411 if (localpet == 0)
then
3412 print*,
"- READ SNOW DEPTH."
3413 call nemsio_readrecv(gfile,
"snod",
"sfc", 1, dummy, 0, iret=rc)
3415 dummy2d = reshape(dummy, (/i_input,j_input/))
3416 print*,
'snod ',maxval(dummy2d),minval(dummy2d)
3419 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
3420 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3421 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3424 if (localpet == 0)
then
3425 print*,
"- READ VEG TYPE."
3426 call nemsio_readrecv(gfile,
"vtype",
"sfc", 1, dummy, 0, iret=rc)
3428 dummy2d = reshape(dummy, (/i_input,j_input/))
3429 print*,
'vtype ',maxval(dummy2d),minval(dummy2d)
3432 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
3433 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
3434 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3437 if (localpet == 0)
then
3438 print*,
"- READ SOIL TYPE."
3439 call nemsio_readrecv(gfile,
"sotyp",
"sfc", 1, dummy, 0, iret=rc)
3441 dummy2d = reshape(dummy, (/i_input,j_input/))
3442 print*,
'sotype ',maxval(dummy2d),minval(dummy2d)
3445 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
3446 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
3447 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3450 if (localpet == 0)
then
3451 print*,
"- READ T2M."
3452 call nemsio_readrecv(gfile,
"tmp",
"2 m above gnd", 1, dummy, 0, iret=rc)
3454 dummy2d = reshape(dummy, (/i_input,j_input/))
3455 print*,
't2m ',maxval(dummy2d),minval(dummy2d)
3458 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
3459 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
3460 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3463 if (localpet == 0)
then
3464 print*,
"- READ Q2M."
3465 call nemsio_readrecv(gfile,
"spfh",
"2 m above gnd", 1, dummy, 0, iret=rc)
3467 dummy2d = reshape(dummy, (/i_input,j_input/))
3468 print*,
'q2m ',maxval(dummy2d),minval(dummy2d)
3471 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
3472 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
3473 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3476 if (localpet == 0)
then
3477 print*,
"- READ TPRCP."
3478 call nemsio_readrecv(gfile,
"tprcp",
"sfc", 1, dummy, 0, iret=rc)
3480 dummy2d = reshape(dummy, (/i_input,j_input/))
3481 print*,
'tprcp ',maxval(dummy2d),minval(dummy2d)
3484 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
3485 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
3486 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3489 if (localpet == 0)
then
3490 print*,
"- READ FFMM."
3491 call nemsio_readrecv(gfile,
"ffmm",
"sfc", 1, dummy, 0, iret=rc)
3493 dummy2d = reshape(dummy, (/i_input,j_input/))
3494 print*,
'ffmm ',maxval(dummy2d),minval(dummy2d)
3497 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
3498 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
3499 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3502 if (localpet == 0)
then
3503 print*,
"- READ USTAR."
3504 call nemsio_readrecv(gfile,
"fricv",
"sfc", 1, dummy, 0, iret=rc)
3506 dummy2d = reshape(dummy, (/i_input,j_input/))
3507 print*,
'fricv ',maxval(dummy2d),minval(dummy2d)
3510 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
3511 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
3512 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3515 if (localpet == 0) dummy2d = 0.0
3516 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
3517 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
3518 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3521 if (localpet == 0)
then
3522 print*,
"- READ SKIN TEMPERATURE."
3523 call nemsio_readrecv(gfile,
"tmp",
"sfc", 1, dummy, 0, iret=rc)
3524 if (rc /= 0) call
error_handler(
"READING SKIN TEMPERATURE.", rc)
3525 dummy2d = reshape(dummy, (/i_input,j_input/))
3526 print*,
'tmp ',maxval(dummy2d),minval(dummy2d)
3529 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
3530 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3531 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3534 if (localpet == 0)
then
3535 print*,
"- READ F10M."
3536 call nemsio_readrecv(gfile,
"f10m",
"10 m above gnd", 1, dummy, 0, iret=rc)
3538 dummy2d = reshape(dummy, (/i_input,j_input/))
3539 print*,
'f10m ',maxval(dummy2d),minval(dummy2d)
3542 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
3543 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
3544 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3547 if (localpet == 0)
then
3548 print*,
"- READ CANOPY MOISTURE CONTENT."
3549 call nemsio_readrecv(gfile,
"cnwat",
"sfc", 1, dummy, 0, iret=rc)
3550 if (rc /= 0) call
error_handler(
"READING CANOPY MOISTURE CONTENT.", rc)
3551 dummy2d = reshape(dummy, (/i_input,j_input/))
3552 print*,
'cnwat ',maxval(dummy2d),minval(dummy2d)
3555 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
3556 call esmf_fieldscatter(canopy_mc_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)
then
3562 call nemsio_readrecv(gfile,
"sfcr",
"sfc", 1, dummy, 0, iret=rc)
3564 dummy2d = reshape(dummy, (/i_input,j_input/))
3565 print*,
'sfcr ',maxval(dummy2d),minval(dummy2d)
3568 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
3569 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
3570 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3575 if (localpet == 0)
then
3576 print*,
"- READ LIQUID SOIL MOISTURE."
3577 call nemsio_readrecv(gfile,
"slc",
"soil layer", 1, dummy, 0, iret=rc)
3578 if (rc /= 0) call
error_handler(
"READING LAYER 1 LIQUID SOIL MOIST.", rc)
3579 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3580 call nemsio_readrecv(gfile,
"slc",
"soil layer", 2, dummy, 0, iret=rc)
3581 if (rc /= 0) call
error_handler(
"READING LAYER 2 LIQUID SOIL MOIST.", rc)
3582 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3583 call nemsio_readrecv(gfile,
"slc",
"soil layer", 3, dummy, 0, iret=rc)
3584 if (rc /= 0) call
error_handler(
"READING LAYER 3 LIQUID SOIL MOIST.", rc)
3585 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3586 call nemsio_readrecv(gfile,
"slc",
"soil layer", 4, dummy, 0, iret=rc)
3587 if (rc /= 0) call
error_handler(
"READING LAYER 4 LIQUID SOIL MOIST.", rc)
3588 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3589 print*,
'slc ',maxval(dummy3d),minval(dummy3d)
3592 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
3593 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
3594 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3597 if (localpet == 0)
then
3598 print*,
"- READ TOTAL SOIL MOISTURE."
3599 call nemsio_readrecv(gfile,
"smc",
"soil layer", 1, dummy, 0, iret=rc)
3600 if (rc /= 0) call
error_handler(
"READING LAYER 1 TOTAL SOIL MOIST.", rc)
3601 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3602 call nemsio_readrecv(gfile,
"smc",
"soil layer", 2, dummy, 0, iret=rc)
3603 if (rc /= 0) call
error_handler(
"READING LAYER 2 TOTAL SOIL MOIST.", rc)
3604 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3605 call nemsio_readrecv(gfile,
"smc",
"soil layer", 3, dummy, 0, iret=rc)
3606 if (rc /= 0) call
error_handler(
"READING LAYER 3 TOTAL SOIL MOIST.", rc)
3607 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3608 call nemsio_readrecv(gfile,
"smc",
"soil layer", 4, dummy, 0, iret=rc)
3609 if (rc /= 0) call
error_handler(
"READING LAYER 4 TOTAL SOIL MOIST.", rc)
3610 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3611 print*,
'smc ',maxval(dummy3d),minval(dummy3d)
3614 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
3615 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
3616 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3619 if (localpet == 0)
then
3620 print*,
"- READ SOIL TEMPERATURE."
3621 call nemsio_readrecv(gfile,
"stc",
"soil layer", 1, dummy, 0, iret=rc)
3622 if (rc /= 0) call
error_handler(
"READING LAYER 1 SOIL TEMP.", rc)
3623 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3624 call nemsio_readrecv(gfile,
"stc",
"soil layer", 2, dummy, 0, iret=rc)
3625 if (rc /= 0) call
error_handler(
"READING LAYER 2 SOIL TEMP.", rc)
3626 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3627 call nemsio_readrecv(gfile,
"stc",
"soil layer", 3, dummy, 0, iret=rc)
3628 if (rc /= 0) call
error_handler(
"READING LAYER 3 SOIL TEMP.", rc)
3629 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3630 call nemsio_readrecv(gfile,
"stc",
"soil layer", 4, dummy, 0, iret=rc)
3631 if (rc /= 0) call
error_handler(
"READING LAYER 4 SOIL TEMP.", rc)
3632 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3633 print*,
'stc ',maxval(dummy3d),minval(dummy3d)
3636 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
3637 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
3638 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3641 deallocate(dummy3d, dummy)
3643 if (localpet == 0) call nemsio_close(gfile)
3655 integer,
intent(in) :: localpet
3657 character(len=250) :: the_file
3661 real(nemsio_realkind),
allocatable :: dummy(:)
3662 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
3663 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
3665 type(nemsio_gfile
) :: gfile
3667 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
3669 if (localpet == 0)
then
3670 allocate(dummy3d(i_input,j_input,lsoil_input))
3671 allocate(dummy2d(i_input,j_input))
3672 allocate(dummy(i_input*j_input))
3673 print*,
"- OPEN FILE ", trim(the_file)
3674 call nemsio_open(gfile, the_file,
"read", iret=rc)
3677 allocate(dummy3d(0,0,0))
3678 allocate(dummy2d(0,0))
3682 if (localpet == 0)
then
3683 print*,
"- READ TERRAIN."
3684 call nemsio_readrecv(gfile,
"orog",
"sfc", 1, dummy, 0, iret=rc)
3686 dummy2d = reshape(dummy, (/i_input,j_input/))
3687 print*,
'orog ',maxval(dummy2d),minval(dummy2d)
3690 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
3691 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
3692 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3695 if (localpet == 0)
then
3696 print*,
"- READ LANDSEA MASK."
3697 call nemsio_readrecv(gfile,
"land",
"sfc", 1, dummy, 0, iret=rc)
3698 if (rc /= 0) call
error_handler(
"READING LANDSEA MASK.", rc)
3699 dummy2d = reshape(dummy, (/i_input,j_input/))
3700 print*,
'landmask ',maxval(dummy2d),minval(dummy2d)
3703 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
3704 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
3705 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3708 if (localpet == 0)
then
3709 print*,
"- READ SEAICE FRACTION."
3710 call nemsio_readrecv(gfile,
"icec",
"sfc", 1, dummy, 0, iret=rc)
3711 if (rc /= 0) call
error_handler(
"READING SEAICE FRACTION.", rc)
3712 dummy2d = reshape(dummy, (/i_input,j_input/))
3713 print*,
'icec ',maxval(dummy2d),minval(dummy2d)
3716 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
3717 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
3718 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3721 if (localpet == 0)
then
3722 print*,
"- READ SEAICE DEPTH."
3723 call nemsio_readrecv(gfile,
"icetk",
"sfc", 1, dummy, 0, iret=rc)
3724 if (rc /= 0) call
error_handler(
"READING SEAICE DEPTH.", rc)
3725 dummy2d = reshape(dummy, (/i_input,j_input/))
3726 print*,
'icetk ',maxval(dummy2d),minval(dummy2d)
3729 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
3730 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3731 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3734 if (localpet == 0)
then
3735 print*,
"- READ SEAICE SKIN TEMPERATURE."
3736 call nemsio_readrecv(gfile,
"ti",
"sfc", 1, dummy, 0, iret=rc)
3737 if (rc /= 0) call
error_handler(
"READING SEAICE SKIN TEMP.", rc)
3738 dummy2d = reshape(dummy, (/i_input,j_input/))
3739 print*,
'ti ',maxval(dummy2d),minval(dummy2d)
3742 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
3743 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3744 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3747 if (localpet == 0)
then
3748 print*,
"- READ SNOW LIQUID EQUIVALENT."
3749 call nemsio_readrecv(gfile,
"weasd",
"sfc", 1, dummy, 0, iret=rc)
3750 if (rc /= 0) call
error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
3751 dummy2d = reshape(dummy, (/i_input,j_input/))
3752 print*,
'weasd ',maxval(dummy2d),minval(dummy2d)
3755 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
3756 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
3757 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3760 if (localpet == 0)
then
3761 print*,
"- READ SNOW DEPTH."
3762 call nemsio_readrecv(gfile,
"snod",
"sfc", 1, dummy, 0, iret=rc)
3764 dummy2d = reshape(dummy, (/i_input,j_input/)) * 1000.0_8
3765 print*,
'snod ',maxval(dummy2d),minval(dummy2d)
3768 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
3769 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3770 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3773 if (localpet == 0)
then
3774 print*,
"- READ VEG TYPE."
3775 call nemsio_readrecv(gfile,
"vtype",
"sfc", 1, dummy, 0, iret=rc)
3777 dummy2d = reshape(dummy, (/i_input,j_input/))
3778 print*,
'vtype ',maxval(dummy2d),minval(dummy2d)
3781 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
3782 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
3783 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3786 if (localpet == 0)
then
3787 print*,
"- READ SOIL TYPE."
3788 call nemsio_readrecv(gfile,
"sotyp",
"sfc", 1, dummy, 0, iret=rc)
3790 dummy2d = reshape(dummy, (/i_input,j_input/))
3791 print*,
'sotype ',maxval(dummy2d),minval(dummy2d)
3794 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
3795 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
3796 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3799 if (localpet == 0)
then
3800 print*,
"- READ T2M."
3801 call nemsio_readrecv(gfile,
"tmp",
"2 m above gnd", 1, dummy, 0, iret=rc)
3803 dummy2d = reshape(dummy, (/i_input,j_input/))
3804 print*,
't2m ',maxval(dummy2d),minval(dummy2d)
3807 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
3808 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
3809 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3812 if (localpet == 0)
then
3813 print*,
"- READ Q2M."
3814 call nemsio_readrecv(gfile,
"spfh",
"2 m above gnd", 1, dummy, 0, iret=rc)
3816 dummy2d = reshape(dummy, (/i_input,j_input/))
3817 print*,
'q2m ',maxval(dummy2d),minval(dummy2d)
3820 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
3821 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
3822 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3825 if (localpet == 0)
then
3826 print*,
"- READ TPRCP."
3827 call nemsio_readrecv(gfile,
"tprcp",
"sfc", 1, dummy, 0, iret=rc)
3829 dummy2d = reshape(dummy, (/i_input,j_input/))
3830 print*,
'tprcp ',maxval(dummy2d),minval(dummy2d)
3833 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
3834 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
3835 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3838 if (localpet == 0)
then
3839 print*,
"- READ FFMM."
3840 call nemsio_readrecv(gfile,
"ffmm",
"sfc", 1, dummy, 0, iret=rc)
3842 dummy2d = reshape(dummy, (/i_input,j_input/))
3843 print*,
'ffmm ',maxval(dummy2d),minval(dummy2d)
3846 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
3847 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
3848 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3851 if (localpet == 0)
then
3852 print*,
"- READ USTAR."
3853 call nemsio_readrecv(gfile,
"fricv",
"sfc", 1, dummy, 0, iret=rc)
3855 dummy2d = reshape(dummy, (/i_input,j_input/))
3856 print*,
'fricv ',maxval(dummy2d),minval(dummy2d)
3859 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
3860 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
3861 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3864 if (localpet == 0) dummy2d = 0.0
3865 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
3866 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
3867 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3870 if (localpet == 0)
then
3871 print*,
"- READ SKIN TEMPERATURE."
3872 call nemsio_readrecv(gfile,
"tmp",
"sfc", 1, dummy, 0, iret=rc)
3873 if (rc /= 0) call
error_handler(
"READING SKIN TEMPERATURE.", rc)
3874 dummy2d = reshape(dummy, (/i_input,j_input/))
3875 print*,
'tmp ',maxval(dummy2d),minval(dummy2d)
3878 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
3879 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3880 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3883 if (localpet == 0)
then
3884 print*,
"- READ F10M."
3885 call nemsio_readrecv(gfile,
"f10m",
"10 m above gnd", 1, dummy, 0, iret=rc)
3887 dummy2d = reshape(dummy, (/i_input,j_input/))
3888 print*,
'f10m ',maxval(dummy2d),minval(dummy2d)
3891 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
3892 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
3893 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3896 if (localpet == 0)
then
3897 print*,
"- READ CANOPY MOISTURE CONTENT."
3898 call nemsio_readrecv(gfile,
"cnwat",
"sfc", 1, dummy, 0, iret=rc)
3899 if (rc /= 0) call
error_handler(
"READING CANOPY MOISTURE CONTENT.", rc)
3900 dummy2d = reshape(dummy, (/i_input,j_input/))
3901 print*,
'cnwat ',maxval(dummy2d),minval(dummy2d)
3904 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
3905 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
3906 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3909 if (localpet == 0)
then
3911 call nemsio_readrecv(gfile,
"sfcr",
"sfc", 1, dummy, 0, iret=rc)
3913 dummy2d = reshape(dummy, (/i_input,j_input/)) * 100.0_8
3914 print*,
'sfcr ',maxval(dummy2d),minval(dummy2d)
3917 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
3918 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
3919 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3924 if (localpet == 0)
then
3925 print*,
"- READ LIQUID SOIL MOISTURE."
3926 call nemsio_readrecv(gfile,
"soill",
"0-10 cm down", 1, dummy, 0, iret=rc)
3927 if (rc /= 0) call
error_handler(
"READING LAYER 1 LIQUID SOIL MOIST.", rc)
3928 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3929 call nemsio_readrecv(gfile,
"soill",
"10-40 cm down", 1, dummy, 0, iret=rc)
3930 if (rc /= 0) call
error_handler(
"READING LAYER 2 LIQUID SOIL MOIST.", rc)
3931 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3932 call nemsio_readrecv(gfile,
"soill",
"40-100 cm down", 1, dummy, 0, iret=rc)
3933 if (rc /= 0) call
error_handler(
"READING LAYER 3 LIQUID SOIL MOIST.", rc)
3934 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3935 call nemsio_readrecv(gfile,
"soill",
"100-200 cm down", 1, dummy, 0, iret=rc)
3936 if (rc /= 0) call
error_handler(
"READING LAYER 4 LIQUID SOIL MOIST.", rc)
3937 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3938 print*,
'soill ',maxval(dummy3d),minval(dummy3d)
3941 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
3942 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
3943 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3946 if (localpet == 0)
then
3947 print*,
"- READ TOTAL SOIL MOISTURE."
3948 call nemsio_readrecv(gfile,
"soilw",
"0-10 cm down", 1, dummy, 0, iret=rc)
3949 if (rc /= 0) call
error_handler(
"READING LAYER 1 TOTAL SOIL MOIST.", rc)
3950 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3951 call nemsio_readrecv(gfile,
"soilw",
"10-40 cm down", 1, dummy, 0, iret=rc)
3952 if (rc /= 0) call
error_handler(
"READING LAYER 2 TOTAL SOIL MOIST.", rc)
3953 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3954 call nemsio_readrecv(gfile,
"soilw",
"40-100 cm down", 1, dummy, 0, iret=rc)
3955 if (rc /= 0) call
error_handler(
"READING LAYER 3 TOTAL SOIL MOIST.", rc)
3956 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3957 call nemsio_readrecv(gfile,
"soilw",
"100-200 cm down", 1, dummy, 0, iret=rc)
3958 if (rc /= 0) call
error_handler(
"READING LAYER 4 TOTAL SOIL MOIST.", rc)
3959 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3960 print*,
'soilm ',maxval(dummy3d),minval(dummy3d)
3963 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
3964 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
3965 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3968 if (localpet == 0)
then
3969 print*,
"- READ SOIL TEMPERATURE."
3970 call nemsio_readrecv(gfile,
"tmp",
"0-10 cm down", 1, dummy, 0, iret=rc)
3971 if (rc /= 0) call
error_handler(
"READING LAYER 1 SOIL TEMP.", rc)
3972 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3973 call nemsio_readrecv(gfile,
"tmp",
"10-40 cm down", 1, dummy, 0, iret=rc)
3974 if (rc /= 0) call
error_handler(
"READING LAYER 2 SOIL TEMP.", rc)
3975 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3976 call nemsio_readrecv(gfile,
"tmp",
"40-100 cm down", 1, dummy, 0, iret=rc)
3977 if (rc /= 0) call
error_handler(
"READING LAYER 3 SOIL TEMP.", rc)
3978 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3979 call nemsio_readrecv(gfile,
"tmp",
"100-200 cm down", 1, dummy, 0, iret=rc)
3980 if (rc /= 0) call
error_handler(
"READING LAYER 4 SOIL TEMP.", rc)
3981 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3982 print*,
'soilt ',maxval(dummy3d),minval(dummy3d)
3985 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
3986 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
3987 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3990 deallocate(dummy3d, dummy)
3992 if (localpet == 0) call nemsio_close(gfile)
4004 integer,
intent(in) :: localpet
4006 character(len=500) :: tilefile
4008 integer :: error, rc
4009 integer :: id_dim, idim_input, jdim_input
4010 integer :: ncid, tile, id_var
4012 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
4013 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
4020 tilefile = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
4021 print*,
"- READ GRID DIMENSIONS FROM: ", trim(tilefile)
4022 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
4023 call
netcdf_err(error,
'opening: '//trim(tilefile) )
4025 error=nf90_inq_dimid(ncid,
'xaxis_1', id_dim)
4026 call
netcdf_err(error,
'reading xaxis_1 id' )
4027 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
4028 call
netcdf_err(error,
'reading xaxis_1 value' )
4030 error=nf90_inq_dimid(ncid,
'yaxis_1', id_dim)
4031 call
netcdf_err(error,
'reading yaxis_1 id' )
4032 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
4033 call
netcdf_err(error,
'reading yaxis_1 value' )
4035 if (idim_input /= i_input .or. jdim_input /= j_input)
then
4036 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 1)
4039 error = nf90_close(ncid)
4041 if (localpet == 0)
then
4042 allocate(data_one_tile(idim_input,jdim_input))
4043 allocate(data_one_tile_3d(idim_input,jdim_input,lsoil_input))
4045 allocate(data_one_tile(0,0))
4046 allocate(data_one_tile_3d(0,0,0))
4049 terrain_loop:
do tile = 1, num_tiles_input_grid
4051 if (localpet == 0)
then
4052 tilefile = trim(orog_dir_input_grid) // trim(orog_files_input_grid(tile))
4053 print*,
'- OPEN OROGRAPHY FILE: ', trim(tilefile)
4054 error=nf90_open(tilefile,nf90_nowrite,ncid)
4055 call
netcdf_err(error,
'OPENING OROGRAPHY FILE' )
4056 error=nf90_inq_varid(ncid,
'orog_raw', id_var)
4057 call
netcdf_err(error,
'READING OROG RECORD ID' )
4058 error=nf90_get_var(ncid, id_var, data_one_tile)
4059 call
netcdf_err(error,
'READING OROG RECORD' )
4060 print*,
'terrain check ',tile, maxval(data_one_tile)
4061 error=nf90_close(ncid)
4064 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
4065 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4066 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4071 tile_loop :
do tile = 1, num_tiles_input_grid
4075 if (localpet == 0)
then
4077 lsoil_input, sfcdata_3d=data_one_tile_3d)
4080 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
4081 call esmf_fieldscatter(soilm_liq_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4082 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4085 if (localpet == 0)
then
4087 lsoil_input, sfcdata_3d=data_one_tile_3d)
4090 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
4091 call esmf_fieldscatter(soilm_tot_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4092 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4095 if (localpet == 0)
then
4097 lsoil_input, sfcdata_3d=data_one_tile_3d)
4100 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
4101 call esmf_fieldscatter(soil_temp_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4102 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4107 if (localpet == 0)
then
4109 lsoil_input, sfcdata=data_one_tile)
4112 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
4113 call esmf_fieldscatter(landsea_mask_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4114 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4119 if (localpet == 0)
then
4121 lsoil_input, sfcdata=data_one_tile)
4124 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
4125 call esmf_fieldscatter(seaice_fract_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4126 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4131 if (localpet == 0)
then
4133 lsoil_input, sfcdata=data_one_tile)
4136 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
4137 call esmf_fieldscatter(seaice_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4138 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4143 if (localpet == 0)
then
4145 lsoil_input, sfcdata=data_one_tile)
4148 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
4149 call esmf_fieldscatter(seaice_skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4150 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4155 if (localpet == 0)
then
4157 lsoil_input, sfcdata=data_one_tile)
4160 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
4161 call esmf_fieldscatter(snow_liq_equiv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4162 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4167 if (localpet == 0)
then
4169 lsoil_input, sfcdata=data_one_tile)
4170 data_one_tile = data_one_tile
4173 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
4174 call esmf_fieldscatter(snow_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4175 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4180 if (localpet == 0)
then
4182 lsoil_input, sfcdata=data_one_tile)
4185 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
4186 call esmf_fieldscatter(veg_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4187 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4192 if (localpet == 0)
then
4194 lsoil_input, sfcdata=data_one_tile)
4197 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
4198 call esmf_fieldscatter(soil_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4199 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4204 if (localpet == 0)
then
4206 lsoil_input, sfcdata=data_one_tile)
4209 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
4210 call esmf_fieldscatter(t2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4211 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4216 if (localpet == 0)
then
4218 lsoil_input, sfcdata=data_one_tile)
4221 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
4222 call esmf_fieldscatter(q2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4223 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4226 if (localpet == 0)
then
4228 lsoil_input, sfcdata=data_one_tile)
4231 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
4232 call esmf_fieldscatter(tprcp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4233 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4236 if (localpet == 0)
then
4238 lsoil_input, sfcdata=data_one_tile)
4241 print*,
"- CALL FieldScatter FOR INPUT GRID F10M"
4242 call esmf_fieldscatter(f10m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4243 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4246 if (localpet == 0)
then
4248 lsoil_input, sfcdata=data_one_tile)
4251 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
4252 call esmf_fieldscatter(ffmm_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4253 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4256 if (localpet == 0)
then
4258 lsoil_input, sfcdata=data_one_tile)
4261 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
4262 call esmf_fieldscatter(ustar_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4263 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4266 if (localpet == 0)
then
4268 lsoil_input, sfcdata=data_one_tile)
4271 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
4272 call esmf_fieldscatter(srflag_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4273 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4276 if (localpet == 0)
then
4278 lsoil_input, sfcdata=data_one_tile)
4281 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
4282 call esmf_fieldscatter(skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4283 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4286 if (localpet == 0)
then
4288 lsoil_input, sfcdata=data_one_tile)
4291 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
4292 call esmf_fieldscatter(canopy_mc_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4293 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4296 if (localpet == 0)
then
4298 lsoil_input, sfcdata=data_one_tile)
4301 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
4302 call esmf_fieldscatter(z0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4303 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4308 deallocate(data_one_tile, data_one_tile_3d)
4321 integer,
intent(in) :: localpet
4323 character(len=500) :: tilefile
4325 integer :: error, id_var
4326 integer :: id_dim, idim_input, jdim_input
4327 integer :: ncid, rc, tile
4329 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
4330 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
4337 tilefile = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
4338 print*,
"- READ GRID DIMENSIONS FROM: ", trim(tilefile)
4339 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
4340 call
netcdf_err(error,
'opening: '//trim(tilefile) )
4342 error=nf90_inq_dimid(ncid,
'grid_xt', id_dim)
4343 call
netcdf_err(error,
'reading grid_xt id' )
4344 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
4345 call
netcdf_err(error,
'reading grid_xt value' )
4347 error=nf90_inq_dimid(ncid,
'grid_yt', id_dim)
4348 call
netcdf_err(error,
'reading grid_yt id' )
4349 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
4350 call
netcdf_err(error,
'reading grid_yt value' )
4352 if (idim_input /= i_input .or. jdim_input /= j_input)
then
4353 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 3)
4356 error = nf90_close(ncid)
4358 if (localpet == 0)
then
4359 allocate(data_one_tile(idim_input,jdim_input))
4360 allocate(data_one_tile_3d(idim_input,jdim_input,lsoil_input))
4362 allocate(data_one_tile(0,0))
4363 allocate(data_one_tile_3d(0,0,0))
4366 terrain_loop:
do tile = 1, num_tiles_input_grid
4368 if (trim(input_type) ==
"gaussian_netcdf")
then
4369 if (localpet == 0)
then
4371 lsoil_input, sfcdata=data_one_tile)
4376 if (localpet == 0)
then
4377 tilefile = trim(orog_dir_input_grid) // trim(orog_files_input_grid(tile))
4378 print*,
'- OPEN OROGRAPHY FILE: ', trim(tilefile)
4379 error=nf90_open(tilefile,nf90_nowrite,ncid)
4380 call
netcdf_err(error,
'OPENING OROGRAPHY FILE.' )
4381 error=nf90_inq_varid(ncid,
'orog_raw', id_var)
4382 call
netcdf_err(error,
'READING OROGRAPHY RECORD ID.' )
4383 error=nf90_get_var(ncid, id_var, data_one_tile)
4384 call
netcdf_err(error,
'READING OROGRAPHY RECORD.' )
4385 print*,
'terrain check history ',tile, maxval(data_one_tile)
4386 error=nf90_close(ncid)
4391 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
4392 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4393 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4398 tile_loop :
do tile = 1, num_tiles_input_grid
4402 if (localpet == 0)
then
4404 lsoil_input, sfcdata=data_one_tile)
4405 data_one_tile_3d(:,:,1) = data_one_tile
4407 lsoil_input, sfcdata=data_one_tile)
4408 data_one_tile_3d(:,:,2) = data_one_tile
4410 lsoil_input, sfcdata=data_one_tile)
4411 data_one_tile_3d(:,:,3) = data_one_tile
4413 lsoil_input, sfcdata=data_one_tile)
4414 data_one_tile_3d(:,:,4) = data_one_tile
4417 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
4418 call esmf_fieldscatter(soilm_liq_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4419 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4424 if (localpet == 0)
then
4426 lsoil_input, sfcdata=data_one_tile)
4427 data_one_tile_3d(:,:,1) = data_one_tile
4429 lsoil_input, sfcdata=data_one_tile)
4430 data_one_tile_3d(:,:,2) = data_one_tile
4432 lsoil_input, sfcdata=data_one_tile)
4433 data_one_tile_3d(:,:,3) = data_one_tile
4435 lsoil_input, sfcdata=data_one_tile)
4436 data_one_tile_3d(:,:,4) = data_one_tile
4439 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
4440 call esmf_fieldscatter(soilm_tot_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4441 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4446 if (localpet == 0)
then
4448 lsoil_input, sfcdata=data_one_tile)
4449 data_one_tile_3d(:,:,1) = data_one_tile
4451 lsoil_input, sfcdata=data_one_tile)
4452 data_one_tile_3d(:,:,2) = data_one_tile
4454 lsoil_input, sfcdata=data_one_tile)
4455 data_one_tile_3d(:,:,3) = data_one_tile
4457 lsoil_input, sfcdata=data_one_tile)
4458 data_one_tile_3d(:,:,4) = data_one_tile
4461 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
4462 call esmf_fieldscatter(soil_temp_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4463 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4468 if (localpet == 0)
then
4470 lsoil_input, sfcdata=data_one_tile)
4473 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
4474 call esmf_fieldscatter(landsea_mask_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4475 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4480 if (localpet == 0)
then
4482 lsoil_input, sfcdata=data_one_tile)
4485 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
4486 call esmf_fieldscatter(seaice_fract_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4487 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4492 if (localpet == 0)
then
4494 lsoil_input, sfcdata=data_one_tile)
4497 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
4498 call esmf_fieldscatter(seaice_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4499 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4504 if (localpet == 0)
then
4506 lsoil_input, sfcdata=data_one_tile)
4509 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
4510 call esmf_fieldscatter(seaice_skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4511 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4516 if (localpet == 0)
then
4518 lsoil_input, sfcdata=data_one_tile)
4521 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
4522 call esmf_fieldscatter(snow_liq_equiv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4523 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4528 if (localpet == 0)
then
4530 lsoil_input, sfcdata=data_one_tile)
4531 data_one_tile = data_one_tile * 1000.0
4534 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
4535 call esmf_fieldscatter(snow_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4536 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4541 if (localpet == 0)
then
4543 lsoil_input, sfcdata=data_one_tile)
4546 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
4547 call esmf_fieldscatter(veg_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4548 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4553 if (localpet == 0)
then
4555 lsoil_input, sfcdata=data_one_tile)
4558 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
4559 call esmf_fieldscatter(soil_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4560 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4565 if (localpet == 0)
then
4567 lsoil_input, sfcdata=data_one_tile)
4570 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
4571 call esmf_fieldscatter(t2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4572 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 Q2M."
4583 call esmf_fieldscatter(q2m_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 TPRCP."
4593 call esmf_fieldscatter(tprcp_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 F10M"
4603 call esmf_fieldscatter(f10m_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 FFMM"
4613 call esmf_fieldscatter(ffmm_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 USTAR"
4623 call esmf_fieldscatter(ustar_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__)) &
4627 if (localpet == 0)
then
4633 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
4634 call esmf_fieldscatter(srflag_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4635 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4638 if (localpet == 0)
then
4640 lsoil_input, sfcdata=data_one_tile)
4643 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
4644 call esmf_fieldscatter(skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4645 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4648 if (localpet == 0)
then
4650 lsoil_input, sfcdata=data_one_tile)
4653 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
4654 call esmf_fieldscatter(canopy_mc_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4655 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4658 if (localpet == 0)
then
4660 lsoil_input, sfcdata=data_one_tile)
4663 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
4664 call esmf_fieldscatter(z0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4665 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4670 deallocate(data_one_tile, data_one_tile_3d)
4681 use program_setup, only : vgtyp_from_climo, sotyp_from_climo
4688 integer,
intent(in) :: localpet
4690 character(len=250) :: the_file
4691 character(len=250) :: geo_file
4692 character(len=20) :: vname, vname_file,slev
4693 character(len=50) :: method
4696 integer :: rc, varnum, iret, i, j,k
4697 integer :: ncid2d, varid, varsize
4699 logical :: exist, rap_latlon
4701 real(esmf_kind_r4) :: value
4703 real(esmf_kind_r4),
allocatable :: dummy2d(:,:),icec_save(:,:)
4704 real(esmf_kind_r4),
allocatable :: dummy1d(:)
4705 real(esmf_kind_r8),
allocatable :: dummy2d_8(:,:),dummy2d_82(:,:),tsk_save(:,:)
4706 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:), dummy3d_stype(:,:,:)
4707 integer(esmf_kind_i4),
allocatable :: slmsk_save(:,:)
4708 integer(esmf_kind_i8),
allocatable :: dummy2d_i(:,:)
4711 rap_latlon = trim(
to_upper(external_model))==
"RAP" .and. trim(input_grid_type) ==
"rotated_latlon"
4713 the_file = trim(data_dir_input_grid) //
"/" // trim(grib2_file_input_grid)
4714 geo_file = trim(geogrid_file_input_grid)
4717 print*,
"- READ SFC DATA FROM GRIB2 FILE: ", trim(the_file)
4718 inquire(file=the_file,exist=exist)
4719 if (.not.exist)
then
4724 lsoil_input = grb2_inq(the_file, inv_file,
':TSOIL:',
' below ground:')
4725 print*,
"- FILE HAS ", lsoil_input,
" SOIL LEVELS"
4726 if (lsoil_input <= 0) call
error_handler(
"COUNTING SOIL LEVELS.", rc)
4729 if (lsoil_input /= 4)
then
4731 call esmf_fielddestroy(soil_temp_input_grid, rc=rc)
4732 call esmf_fielddestroy(soilm_tot_input_grid, rc=rc)
4733 call esmf_fielddestroy(soilm_liq_input_grid, rc=rc)
4735 print*,
"- CALL FieldCreate FOR INPUT SOIL TEMPERATURE."
4736 soil_temp_input_grid = esmf_fieldcreate(input_grid, &
4737 typekind=esmf_typekind_r8, &
4738 staggerloc=esmf_staggerloc_center, &
4739 ungriddedlbound=(/1/), &
4740 ungriddedubound=(/lsoil_input/), rc=rc)
4741 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4744 print*,
"- CALL FieldCreate FOR INPUT TOTAL SOIL MOISTURE."
4745 soilm_tot_input_grid = esmf_fieldcreate(input_grid, &
4746 typekind=esmf_typekind_r8, &
4747 staggerloc=esmf_staggerloc_center, &
4748 ungriddedlbound=(/1/), &
4749 ungriddedubound=(/lsoil_input/), rc=rc)
4750 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4753 print*,
"- CALL FieldCreate FOR INPUT LIQUID SOIL MOISTURE."
4754 soilm_liq_input_grid = esmf_fieldcreate(input_grid, &
4755 typekind=esmf_typekind_r8, &
4756 staggerloc=esmf_staggerloc_center, &
4757 ungriddedlbound=(/1/), &
4758 ungriddedubound=(/lsoil_input/), rc=rc)
4759 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4764 if (localpet == 0)
then
4765 allocate(dummy2d(i_input,j_input))
4766 allocate(slmsk_save(i_input,j_input))
4767 allocate(dummy2d_i(i_input,j_input))
4768 allocate(tsk_save(i_input,j_input))
4769 allocate(icec_save(i_input,j_input))
4770 allocate(dummy2d_8(i_input,j_input))
4771 allocate(dummy2d_82(i_input,j_input))
4772 allocate(dummy3d(i_input,j_input,lsoil_input))
4773 allocate(dummy3d_stype(i_input,j_input,16))
4774 allocate(dummy1d(16))
4776 allocate(dummy3d(0,0,0))
4777 allocate(dummy2d_8(0,0))
4778 allocate(dummy2d_82(0,0))
4779 allocate(dummy2d(0,0))
4788 if (localpet == 0)
then
4789 print*,
"- READ TERRAIN."
4790 rc = grb2_inq(the_file, inv_file,
':HGT:',
':surface:', data2=dummy2d)
4792 print*,
'orog ',maxval(dummy2d),minval(dummy2d)
4795 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
4796 call esmf_fieldscatter(terrain_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4797 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4800 if (localpet == 0)
then
4801 print*,
"- READ SEAICE FRACTION."
4802 rc = grb2_inq(the_file, inv_file,
':ICEC:',
':surface:', data2=dummy2d)
4803 if (rc /= 1) call
error_handler(
"READING SEAICE FRACTION.", rc)
4805 print*,
'icec ',maxval(dummy2d),minval(dummy2d)
4809 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
4810 call esmf_fieldscatter(seaice_fract_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4811 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4822 if (localpet == 0)
then
4823 print*,
"- READ LANDSEA MASK."
4824 rc = grb2_inq(the_file, inv_file,
':LANDN:',
':surface:', data2=dummy2d)
4827 rc = grb2_inq(the_file, inv_file,
':LAND:',
':surface:', data2=dummy2d)
4828 if (rc /= 1) call
error_handler(
"READING LANDSEA MASK.", rc)
4833 if(dummy2d(i,j) < 0.5_esmf_kind_r4) dummy2d(i,j)=0.0_esmf_kind_r4
4834 if(icec_save(i,j) > 0.15_esmf_kind_r4)
then
4836 dummy2d(i,j) = 2.0_esmf_kind_r4
4841 slmsk_save = nint(dummy2d)
4843 deallocate(icec_save)
4846 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
4847 call esmf_fieldscatter(landsea_mask_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4848 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4851 if (localpet == 0)
then
4852 print*,
"- READ SEAICE SKIN TEMPERATURE."
4853 rc = grb2_inq(the_file, inv_file,
':TMP:',
':surface:', data2=dummy2d)
4854 if (rc /= 1) call
error_handler(
"READING SEAICE SKIN TEMP.", rc)
4855 print*,
'ti ',maxval(dummy2d),minval(dummy2d)
4858 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
4859 call esmf_fieldscatter(seaice_skin_temp_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4860 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4869 if (localpet == 0)
then
4870 print*,
"- READ SNOW LIQUID EQUIVALENT."
4871 rc = grb2_inq(the_file, inv_file,
':WEASD:',
':surface:',
':anl:',data2=dummy2d)
4873 rc = grb2_inq(the_file, inv_file,
':WEASD:',
':surface:',
'hour fcst:',data2=dummy2d)
4874 if (rc /= 1) call
error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
4878 if(slmsk_save(i,j) == 0) dummy2d(i,j) = 0.0_esmf_kind_r4
4879 if(dummy2d(i,j) == grb2_undefined) dummy2d(i,j) = 0.0_esmf_kind_r4
4882 print*,
'weasd ',maxval(dummy2d),minval(dummy2d)
4885 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
4886 call esmf_fieldscatter(snow_liq_equiv_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4887 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4890 if (localpet == 0)
then
4891 print*,
"- READ SNOW DEPTH."
4892 rc = grb2_inq(the_file, inv_file,
':SNOD:',
':surface:', data2=dummy2d)
4894 where(dummy2d == grb2_undefined) dummy2d = 0.0_esmf_kind_r4
4895 dummy2d = dummy2d*1000.0
4896 where(slmsk_save == 0) dummy2d = 0.0_esmf_kind_r4
4897 print*,
'snod ',maxval(dummy2d),minval(dummy2d)
4900 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
4901 call esmf_fieldscatter(snow_depth_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4902 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4905 if (localpet == 0)
then
4906 print*,
"- READ T2M."
4907 rc = grb2_inq(the_file, inv_file,
':TMP:',
':2 m above ground:',data2=dummy2d)
4910 print*,
't2m ',maxval(dummy2d),minval(dummy2d)
4913 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
4914 call esmf_fieldscatter(t2m_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0,rc=rc)
4915 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4918 if (localpet == 0)
then
4919 print*,
"- READ Q2M."
4920 rc = grb2_inq(the_file, inv_file,
':SPFH:',
':2 m above ground:',data2=dummy2d)
4922 print*,
'q2m ',maxval(dummy2d),minval(dummy2d)
4925 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
4926 call esmf_fieldscatter(q2m_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0,rc=rc)
4927 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4930 if (localpet == 0)
then
4931 print*,
"- READ SKIN TEMPERATURE."
4932 rc = grb2_inq(the_file, inv_file,
':TMP:',
':surface:', data2=dummy2d)
4933 if (rc <= 0 ) call
error_handler(
"READING SKIN TEMPERATURE.", rc)
4934 tsk_save(:,:) =
real(dummy2d,esmf_kind_r8)
4935 dummy2d_8 =
real(dummy2d,esmf_kind_r8)
4938 if(slmsk_save(i,j) == 0 .and. dummy2d(i,j) < 271.2)
then
4940 dummy2d(i,j) = 271.2
4942 if(slmsk_save(i,j) == 0 .and. dummy2d(i,j) > 310.)
then
4944 dummy2d(i,j) = 310.0
4950 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
4951 call esmf_fieldscatter(skin_temp_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4952 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4955 if (localpet == 0) dummy2d = 0.0
4957 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
4958 call esmf_fieldscatter(srflag_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0,rc=rc)
4959 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4962 if (localpet == 0)
then
4963 print*,
"- READ SOIL TYPE."
4966 rc = grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
4968 if (rc <= 0 .and. (trim(
to_upper(external_model))==
"HRRR" .or. rap_latlon) .and. geo_file .ne.
"NULL")
then
4972 print*,
"OPEN GEOGRID FILE ", trim(geo_file)
4973 rc = nf90_open(geo_file,nf90_nowrite,ncid2d)
4976 print*,
"INQURE ABOUT DIM IDS"
4977 rc = nf90_inq_dimid(ncid2d,
"west_east",varid)
4978 call
netcdf_err(rc,
"READING west_east DIMENSION FROM GEOGRID FILE")
4980 rc = nf90_inquire_dimension(ncid2d,varid,len=varsize)
4981 call
netcdf_err(rc,
"READING west_east DIMENSION SIZE")
4982 if (varsize .ne. i_input) call
error_handler(
"GEOGRID FILE GRID SIZE DIFFERS FROM INPUT DATA.", -1)
4984 print*,
"INQUIRE ABOUT SOIL TYPE FROM GEOGRID FILE"
4985 rc = nf90_inq_varid(ncid2d,
"SCT_DOM",varid)
4986 call
netcdf_err(rc,
"FINDING SCT_DOM IN GEOGRID FILE")
4988 print*,
"READ SOIL TYPE FROM GEOGRID FILE "
4989 rc = nf90_get_var(ncid2d,varid,dummy2d)
4990 call
netcdf_err(rc,
"READING SCT_DOM FROM FILE")
4992 print*,
"INQUIRE ABOUT SOIL TYPE FRACTIONS FROM GEOGRID FILE"
4993 rc = nf90_inq_varid(ncid2d,
"SOILCTOP",varid)
4994 call
netcdf_err(rc,
"FINDING SOILCTOP IN GEOGRID FILE")
4996 print*,
"READ SOIL TYPE FRACTIONS FROM GEOGRID FILE "
4997 rc = nf90_get_var(ncid2d,varid,dummy3d_stype)
4998 call
netcdf_err(rc,
"READING SCT_DOM FROM FILE")
5000 print*,
"CLOSE GEOGRID FILE "
5001 iret = nf90_close(ncid2d)
5009 if(dummy2d(i,j) == 14.0_esmf_kind_r4 .and. slmsk_save(i,j) == 1)
then
5010 dummy1d(:) = dummy3d_stype(i,j,:)
5011 dummy1d(14) = 0.0_esmf_kind_r4
5012 dummy2d(i,j) =
real(MAXLOC(dummy1d, 1),esmf_kind_r4)
5018 if ((rc <= 0 .and. trim(
to_upper(external_model)) /=
"HRRR" .and. .not. rap_latlon) &
5019 .or. (rc < 0 .and. (trim(
to_upper(external_model)) ==
"HRRR" .or. rap_latlon)))
then
5020 if (.not. sotyp_from_climo)
then
5021 call
error_handler(
"COULD NOT FIND SOIL TYPE IN FILE. PLEASE SET SOTYP_FROM_CLIMO=.TRUE. . EXITING", rc)
5024 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
5028 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. WILL NOT "//&
5029 "SCALE SOIL MOISTURE FOR DIFFERENCES IN SOIL TYPE. "
5030 dummy2d(:,:) = -99999.0_esmf_kind_r4
5038 if (.not. sotyp_from_climo)
then
5041 if(dummy2d(i,j) == 14.0_esmf_kind_r4 .and. slmsk_save(i,j) == 1) dummy2d(i,j) = -99999.9
5045 dummy2d_8 =
real(dummy2d,esmf_kind_r8)
5047 where(slmsk_save == 1) dummy2d_i = 1
5049 call
search(dummy2d_8,dummy2d_i,i_input,j_input,1,230)
5051 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5054 print*,
'sotype ',maxval(dummy2d_8),minval(dummy2d_8)
5055 deallocate(dummy2d_i)
5056 deallocate(dummy3d_stype)
5060 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
5061 call esmf_fieldscatter(soil_type_input_grid,dummy2d_8, rootpet=0, rc=rc)
5062 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5070 if (.not. vgfrc_from_climo)
then
5071 if (localpet == 0)
then
5072 print*,
"- READ VEG FRACTION."
5075 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
5079 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5082 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1105:', data2=dummy2d)
5084 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1101:', data2=dummy2d)
5086 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1151:', data2=dummy2d)
5087 if (rc <= 0) call
error_handler(
"COULD NOT DETERMINE VEGETATION FRACTION IN FILE. &
5088 RECORD NUMBERS MAY HAVE CHANGED. PLEASE SET VGFRC_FROM_CLIMO=.TRUE. EXITING", rc)
5091 elseif (rc <= 0)
then
5092 call
error_handler(
"COULD NOT FIND VEGETATION FRACTION IN FILE. &
5093 PLEASE SET VGFRC_FROM_CLIMO=.TRUE. EXITING", rc)
5095 if(maxval(dummy2d) > 2.0) dummy2d = dummy2d / 100.0_esmf_kind_r4
5096 print*,
'vfrac ',maxval(dummy2d),minval(dummy2d)
5100 print*,
"- CALL FieldScatter FOR INPUT GRID VEG GREENNESS."
5101 call esmf_fieldscatter(veg_greenness_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0, rc=rc)
5102 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5106 if (.not. minmax_vgfrc_from_climo)
then
5107 if (localpet == 0)
then
5108 print*,
"- READ MIN VEG FRACTION."
5111 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5114 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1106:',data2=dummy2d)
5117 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1102:',data2=dummy2d)
5119 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1152:',data2=dummy2d)
5120 if (rc<=0) call
error_handler(
"COULD NOT FIND MIN VEGETATION FRACTION IN FILE. &
5121 PLEASE SET MINMAX_VGFRC_FROM_CLIMO=.TRUE. . EXITING",rc)
5124 if(maxval(dummy2d) > 2.0) dummy2d = dummy2d / 100.0_esmf_kind_r4
5125 print*,
'vfrac min',maxval(dummy2d),minval(dummy2d)
5129 print*,
"- CALL FieldScatter FOR INPUT GRID MIN VEG GREENNESS."
5130 call esmf_fieldscatter(min_veg_greenness_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0, rc=rc)
5131 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5134 if (localpet == 0)
then
5135 print*,
"- READ MAX VEG FRACTION."
5138 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5142 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1107:',data2=dummy2d)
5144 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1103:',data2=dummy2d)
5146 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1153:',data2=dummy2d)
5147 if (rc <= 0) call
error_handler(
"COULD NOT FIND MAX VEGETATION FRACTION IN FILE. &
5148 PLEASE SET MINMAX_VGFRC_FROM_CLIMO=.TRUE. . EXITING",rc)
5151 if(maxval(dummy2d) > 2.0) dummy2d = dummy2d / 100.0_esmf_kind_r4
5152 print*,
'vfrac max',maxval(dummy2d),minval(dummy2d)
5156 print*,
"- CALL FieldScatter FOR INPUT GRID MAX VEG GREENNESS."
5157 call esmf_fieldscatter(max_veg_greenness_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
5158 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5162 if (.not. lai_from_climo)
then
5163 if (localpet == 0)
then
5164 print*,
"- READ LAI."
5167 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5169 vname=
":var0_7_198:"
5170 rc= grb2_inq(the_file, inv_file, vname,slev,
':n=1108:',data2=dummy2d)
5172 rc= grb2_inq(the_file, inv_file, vname,slev,
':n=1104:',data2=dummy2d)
5174 rc= grb2_inq(the_file, inv_file, vname,slev,
':n=1154:',data2=dummy2d)
5175 if (rc <= 0) call
error_handler(
"COULD NOT FIND LAI IN FILE. &
5176 PLEASE SET LAI_FROM_CLIMO=.TRUE. . EXITING",rc)
5179 print*,
'lai',maxval(dummy2d),minval(dummy2d)
5182 print*,
"- CALL FieldScatter FOR INPUT GRID LAI."
5183 call esmf_fieldscatter(lai_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
5184 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5188 if (localpet == 0)
then
5189 print*,
"- READ SEAICE DEPTH."
5192 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5195 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5199 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL BE"//&
5200 " REPLACED WITH CLIMO. SET A FILL "// &
5201 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5202 dummy2d(:,:) = 0.0_esmf_kind_r4
5205 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5206 print*,
'hice ',maxval(dummy2d),minval(dummy2d)
5210 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
5211 call esmf_fieldscatter(seaice_depth_input_grid,dummy2d_8, rootpet=0, rc=rc)
5212 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5215 if (localpet == 0)
then
5216 print*,
"- READ TPRCP."
5219 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5222 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5226 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
5227 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
5228 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5229 dummy2d(:,:) = 0.0_esmf_kind_r4
5232 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5233 print*,
'tprcp ',maxval(dummy2d),minval(dummy2d)
5236 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
5237 call esmf_fieldscatter(tprcp_input_grid,dummy2d_8, rootpet=0, rc=rc)
5238 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5241 if (localpet == 0)
then
5242 print*,
"- READ FFMM."
5245 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5248 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5252 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
5253 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
5254 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5255 dummy2d(:,:) = 0.0_esmf_kind_r4
5258 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5259 print*,
'ffmm ',maxval(dummy2d),minval(dummy2d)
5262 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
5263 call esmf_fieldscatter(ffmm_input_grid,dummy2d_8, rootpet=0, rc=rc)
5264 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5267 if (localpet == 0)
then
5268 print*,
"- READ USTAR."
5271 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5274 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5278 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL "//&
5279 "REPLACED WITH CLIMO. SET A FILL "// &
5280 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5281 dummy2d(:,:) = 0.0_esmf_kind_r4
5284 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5285 print*,
'fricv ',maxval(dummy2d),minval(dummy2d)
5288 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
5289 call esmf_fieldscatter(ustar_input_grid,dummy2d_8, rootpet=0, rc=rc)
5290 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5293 if (localpet == 0)
then
5294 print*,
"- READ F10M."
5296 slev=
":10 m above ground:"
5297 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5300 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5304 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
5305 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
5306 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5307 dummy2d(:,:) = 0.0_esmf_kind_r4
5310 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5311 print*,
'f10m ',maxval(dummy2d),minval(dummy2d)
5314 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
5315 call esmf_fieldscatter(f10m_input_grid,dummy2d_8, rootpet=0, rc=rc)
5316 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5319 if (localpet == 0)
then
5320 print*,
"- READ CANOPY MOISTURE CONTENT."
5323 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5326 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5330 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL"//&
5331 " REPLACED WITH CLIMO. SET A FILL "// &
5332 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5333 dummy2d(:,:) = 0.0_esmf_kind_r4
5337 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5338 print*,
'cnwat ',maxval(dummy2d),minval(dummy2d)
5341 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
5342 call esmf_fieldscatter(canopy_mc_input_grid,dummy2d_8, rootpet=0, rc=rc)
5343 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5346 if (localpet == 0)
then
5350 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5353 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5357 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL BE"//&
5358 " REPLACED WITH CLIMO. SET A FILL "// &
5359 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5360 dummy2d(:,:) = 0.0_esmf_kind_r4
5364 dummy2d(:,:) = dummy2d(:,:)*10.0
5366 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5367 print*,
'sfcr ',maxval(dummy2d),minval(dummy2d)
5371 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
5372 call esmf_fieldscatter(z0_input_grid,dummy2d_8, rootpet=0, rc=rc)
5373 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5377 if (localpet == 0)
then
5378 print*,
"- READ LIQUID SOIL MOISTURE."
5380 vname_file =
":SOILL:"
5381 call
read_grib_soil(the_file,inv_file,vname,vname_file,dummy3d,rc)
5383 print*,
'soill ',maxval(dummy3d),minval(dummy3d)
5386 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
5387 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
5388 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5391 if (localpet == 0)
then
5392 print*,
"- READ TOTAL SOIL MOISTURE."
5395 vname_file =
"var2_2_1_"
5396 call
read_grib_soil(the_file,inv_file,vname,vname_file,dummy3d,rc)
5397 print*,
'soilm ',maxval(dummy3d),minval(dummy3d)
5400 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
5401 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
5402 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5411 print*,
"- CALL FieldGather for INPUT SOIL TYPE."
5412 call esmf_fieldgather(soil_type_input_grid, dummy2d_82, rootpet=0, tile=1, rc=rc)
5413 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5415 if (localpet == 0)
then
5416 print*,
"- READ VEG TYPE."
5419 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
5425 rc= grb2_inq(the_file, inv_file, vname,
"_0_198:",slev,
' hour fcst:', data2=dummy2d)
5427 rc= grb2_inq(the_file, inv_file, vname,
"_0_198:",slev,
':anl:', data2=dummy2d)
5429 if (.not. vgtyp_from_climo)
then
5430 call
error_handler(
"COULD NOT FIND VEGETATION TYPE IN FILE. PLEASE SET VGTYP_FROM_CLIMO=.TRUE. . EXITING", rc)
5434 dummy2d(i,j) = 0.0_esmf_kind_r4
5435 if(slmsk_save(i,j) == 1 .and. dummy3d(i,j,1) > 0.99) &
5436 dummy2d(i,j) =
real(veg_type_landice_input,esmf_kind_r4)
5443 if (trim(external_model) .ne.
"GFS")
then
5446 if (dummy2d(i,j) == 15.0_esmf_kind_r4 .and. slmsk_save(i,j) == 1)
then
5447 if (dummy3d(i,j,1) < 0.6)
then
5448 dummy2d(i,j) =
real(veg_type_landice_input,esmf_kind_r4)
5449 elseif (dummy3d(i,j,1) > 0.99)
then
5451 dummy2d(i,j) = 0.0_esmf_kind_r4
5452 dummy2d_82(i,j) = 0.0_esmf_kind_r8
5454 elseif (dummy2d(i,j) == 17.0_esmf_kind_r4 .and. slmsk_save(i,j)==0)
then
5455 dummy2d(i,j) = 0.0_esmf_kind_r4
5460 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5461 print*,
'vgtyp ',maxval(dummy2d),minval(dummy2d)
5464 print*,
"- CALL FieldScatter FOR INPUT VEG TYPE."
5465 call esmf_fieldscatter(veg_type_input_grid, dummy2d_8, rootpet=0, rc=rc)
5466 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5469 print*,
"- CALL FieldScatter FOR INPUT VEG TYPE."
5470 call esmf_fieldscatter(soil_type_input_grid, dummy2d_82, rootpet=0, rc=rc)
5471 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5474 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
5475 call esmf_fieldscatter(landsea_mask_input_grid,
real(slmsk_save,esmf_kind_r8),rootpet=0, rc=rc)
5476 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5486 if (localpet == 0)
then
5487 print*,
"- READ SOIL TEMPERATURE."
5489 vname_file =
":TSOIL:"
5490 call
read_grib_soil(the_file,inv_file,vname,vname_file,dummy3d,rc)
5492 print*,
'soilt ',maxval(dummy3d),minval(dummy3d)
5494 deallocate(tsk_save, slmsk_save)
5497 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
5498 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
5499 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5503 deallocate(dummy2d_8)
5516 integer,
intent(in) :: localpet
5518 character(len=10) :: field
5522 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
5524 if (localpet == 0)
then
5525 allocate(data_one_tile(i_input,j_input))
5527 allocate(data_one_tile(0,0))
5530 tile_loop :
do tile = 1, num_tiles_input_grid
5534 if (localpet == 0)
then
5535 if (trim(input_type) ==
"restart")
then
5541 lsoil_input, sfcdata=data_one_tile)
5544 print*,
"- CALL FieldScatter FOR INPUT C_D"
5545 call esmf_fieldscatter(c_d_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5546 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5551 if (localpet == 0)
then
5552 if (trim(input_type) ==
"restart")
then
5558 lsoil_input, sfcdata=data_one_tile)
5561 print*,
"- CALL FieldScatter FOR INPUT C_0"
5562 call esmf_fieldscatter(c_0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5563 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5568 if (localpet == 0)
then
5569 if (trim(input_type) ==
"restart")
then
5575 lsoil_input, sfcdata=data_one_tile)
5578 print*,
"- CALL FieldScatter FOR INPUT D_CONV."
5579 call esmf_fieldscatter(d_conv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5580 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5585 if (localpet == 0)
then
5586 if (trim(input_type) ==
"restart")
then
5592 lsoil_input, sfcdata=data_one_tile)
5595 print*,
"- CALL FieldScatter FOR INPUT DT_COOL."
5596 call esmf_fieldscatter(dt_cool_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5597 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5602 if (localpet == 0)
then
5606 print*,
"- CALL FieldScatter FOR INPUT IFD."
5607 call esmf_fieldscatter(ifd_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5608 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5613 if (localpet == 0)
then
5615 lsoil_input, sfcdata=data_one_tile)
5618 print*,
"- CALL FieldScatter FOR INPUT QRAIN."
5619 call esmf_fieldscatter(qrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5620 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5625 if (localpet == 0)
then
5627 lsoil_input, sfcdata=data_one_tile)
5630 print*,
"- CALL FieldScatter FOR INPUT TREF"
5631 call esmf_fieldscatter(tref_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5632 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5637 if (localpet == 0)
then
5638 if (trim(input_type) ==
"restart")
then
5644 lsoil_input, sfcdata=data_one_tile)
5647 print*,
"- CALL FieldScatter FOR INPUT W_D"
5648 call esmf_fieldscatter(w_d_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5649 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5654 if (localpet == 0)
then
5655 if (trim(input_type) ==
"restart")
then
5661 lsoil_input, sfcdata=data_one_tile)
5664 print*,
"- CALL FieldScatter FOR INPUT W_0"
5665 call esmf_fieldscatter(w_0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5666 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5671 if (localpet == 0)
then
5673 lsoil_input, sfcdata=data_one_tile)
5676 print*,
"- CALL FieldScatter FOR INPUT XS"
5677 call esmf_fieldscatter(xs_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5678 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5683 if (localpet == 0)
then
5685 lsoil_input, sfcdata=data_one_tile)
5688 print*,
"- CALL FieldScatter FOR INPUT XT"
5689 call esmf_fieldscatter(xt_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5690 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5695 if (localpet == 0)
then
5697 lsoil_input, sfcdata=data_one_tile)
5700 print*,
"- CALL FieldScatter FOR INPUT XU"
5701 call esmf_fieldscatter(xu_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5702 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5707 if (localpet == 0)
then
5709 lsoil_input, sfcdata=data_one_tile)
5712 print*,
"- CALL FieldScatter FOR INPUT XV"
5713 call esmf_fieldscatter(xv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5714 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5719 if (localpet == 0)
then
5721 lsoil_input, sfcdata=data_one_tile)
5724 print*,
"- CALL FieldScatter FOR INPUT XZ"
5725 call esmf_fieldscatter(xz_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5726 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5731 if (localpet == 0)
then
5733 lsoil_input, sfcdata=data_one_tile)
5736 print*,
"- CALL FieldScatter FOR INPUT XTTS"
5737 call esmf_fieldscatter(xtts_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5738 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5743 if (localpet == 0)
then
5745 lsoil_input, sfcdata=data_one_tile)
5748 print*,
"- CALL FieldScatter FOR INPUT XZTS"
5749 call esmf_fieldscatter(xzts_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5750 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5755 if (localpet == 0)
then
5756 if (trim(input_type) ==
"restart")
then
5762 lsoil_input, sfcdata=data_one_tile)
5765 print*,
"- CALL FieldScatter FOR INPUT Z_C"
5766 call esmf_fieldscatter(z_c_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5767 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5772 if (localpet == 0)
then
5776 print*,
"- CALL FieldScatter FOR INPUT ZM"
5777 call esmf_fieldscatter(zm_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5778 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5783 deallocate(data_one_tile)
5800 integer,
intent(in) :: localpet
5802 character(len=300) :: the_file
5806 real(nemsio_realkind),
allocatable :: dummy(:)
5807 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
5809 type(nemsio_gfile
) :: gfile
5811 if (trim(input_type) ==
"gfs_gaussian_nemsio")
then
5813 the_file = trim(data_dir_input_grid) //
"/" // trim(nst_files_input_grid)
5815 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
5818 print*,
"- READ NST DATA FROM: ", trim(the_file)
5820 if (localpet == 0)
then
5821 allocate(dummy(i_input*j_input))
5822 allocate(dummy2d(i_input,j_input))
5823 call nemsio_open(gfile, the_file,
"read", iret=rc)
5826 allocate(dummy2d(0,0))
5829 if (localpet == 0)
then
5830 print*,
"- READ TREF"
5831 call nemsio_readrecv(gfile,
"tref",
"sfc", 1, dummy, 0, iret=rc)
5833 dummy2d = reshape(dummy, (/i_input,j_input/))
5834 print*,
'tref ',maxval(dummy2d),minval(dummy2d)
5837 print*,
"- CALL FieldScatter FOR INPUT TREF."
5838 call esmf_fieldscatter(tref_input_grid, dummy2d, rootpet=0, rc=rc)
5839 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5842 if (localpet == 0)
then
5844 call nemsio_readrecv(gfile,
"cd",
"sfc", 1, dummy, 0, iret=rc)
5846 dummy2d = reshape(dummy, (/i_input,j_input/))
5847 print*,
'cd ',maxval(dummy2d),minval(dummy2d)
5850 print*,
"- CALL FieldScatter FOR INPUT C_D."
5851 call esmf_fieldscatter(c_d_input_grid, dummy2d, rootpet=0, rc=rc)
5852 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5855 if (localpet == 0)
then
5857 call nemsio_readrecv(gfile,
"c0",
"sfc", 1, dummy, 0, iret=rc)
5859 dummy2d = reshape(dummy, (/i_input,j_input/))
5860 print*,
'c0 ',maxval(dummy2d),minval(dummy2d)
5863 print*,
"- CALL FieldScatter FOR INPUT C_0."
5864 call esmf_fieldscatter(c_0_input_grid, dummy2d, rootpet=0, rc=rc)
5865 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5868 if (localpet == 0)
then
5869 print*,
"- READ DCONV"
5870 call nemsio_readrecv(gfile,
"dconv",
"sfc", 1, dummy, 0, iret=rc)
5872 dummy2d = reshape(dummy, (/i_input,j_input/))
5873 print*,
'dconv ',maxval(dummy2d),minval(dummy2d)
5876 print*,
"- CALL FieldScatter FOR INPUT D_CONV."
5877 call esmf_fieldscatter(d_conv_input_grid, dummy2d, rootpet=0, rc=rc)
5878 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5881 if (localpet == 0)
then
5882 print*,
"- READ DTCOOL"
5883 call nemsio_readrecv(gfile,
"dtcool",
"sfc", 1, dummy, 0, iret=rc)
5885 dummy2d = reshape(dummy, (/i_input,j_input/))
5886 print*,
'dtcool ',maxval(dummy2d),minval(dummy2d)
5889 print*,
"- CALL FieldScatter FOR INPUT DT_COOL."
5890 call esmf_fieldscatter(dt_cool_input_grid, dummy2d, rootpet=0, rc=rc)
5891 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5894 if (localpet == 0)
then
5898 print*,
"- CALL FieldScatter FOR INPUT IFD."
5899 call esmf_fieldscatter(ifd_input_grid, dummy2d, rootpet=0, rc=rc)
5900 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5903 if (localpet == 0)
then
5904 print*,
"- READ QRAIN"
5905 call nemsio_readrecv(gfile,
"qrain",
"sfc", 1, dummy, 0, iret=rc)
5907 dummy2d = reshape(dummy, (/i_input,j_input/))
5908 print*,
'qrain ',maxval(dummy2d),minval(dummy2d)
5911 print*,
"- CALL FieldScatter FOR INPUT QRAIN."
5912 call esmf_fieldscatter(qrain_input_grid, dummy2d, rootpet=0, rc=rc)
5913 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5916 if (localpet == 0)
then
5918 call nemsio_readrecv(gfile,
"wd",
"sfc", 1, dummy, 0, iret=rc)
5920 dummy2d = reshape(dummy, (/i_input,j_input/))
5921 print*,
'wd ',maxval(dummy2d),minval(dummy2d)
5924 print*,
"- CALL FieldScatter FOR INPUT WD."
5925 call esmf_fieldscatter(w_d_input_grid, dummy2d, rootpet=0, rc=rc)
5926 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5929 if (localpet == 0)
then
5931 call nemsio_readrecv(gfile,
"w0",
"sfc", 1, dummy, 0, iret=rc)
5933 dummy2d = reshape(dummy, (/i_input,j_input/))
5934 print*,
'w0 ',maxval(dummy2d),minval(dummy2d)
5937 print*,
"- CALL FieldScatter FOR INPUT W0."
5938 call esmf_fieldscatter(w_0_input_grid, dummy2d, rootpet=0, rc=rc)
5939 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5942 if (localpet == 0)
then
5944 call nemsio_readrecv(gfile,
"xs",
"sfc", 1, dummy, 0, iret=rc)
5946 dummy2d = reshape(dummy, (/i_input,j_input/))
5947 print*,
'xs ',maxval(dummy2d),minval(dummy2d)
5950 print*,
"- CALL FieldScatter FOR INPUT XS."
5951 call esmf_fieldscatter(xs_input_grid, dummy2d, rootpet=0, rc=rc)
5952 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5955 if (localpet == 0)
then
5957 call nemsio_readrecv(gfile,
"xt",
"sfc", 1, dummy, 0, iret=rc)
5959 dummy2d = reshape(dummy, (/i_input,j_input/))
5960 print*,
'xt ',maxval(dummy2d),minval(dummy2d)
5963 print*,
"- CALL FieldScatter FOR INPUT XT."
5964 call esmf_fieldscatter(xt_input_grid, dummy2d, rootpet=0, rc=rc)
5965 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5968 if (localpet == 0)
then
5970 call nemsio_readrecv(gfile,
"xu",
"sfc", 1, dummy, 0, iret=rc)
5972 dummy2d = reshape(dummy, (/i_input,j_input/))
5973 print*,
'xu ',maxval(dummy2d),minval(dummy2d)
5976 print*,
"- CALL FieldScatter FOR INPUT XU."
5977 call esmf_fieldscatter(xu_input_grid, dummy2d, rootpet=0, rc=rc)
5978 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5981 if (localpet == 0)
then
5983 call nemsio_readrecv(gfile,
"xv",
"sfc", 1, dummy, 0, iret=rc)
5985 dummy2d = reshape(dummy, (/i_input,j_input/))
5986 print*,
'xv ',maxval(dummy2d),minval(dummy2d)
5989 print*,
"- CALL FieldScatter FOR INPUT XV."
5990 call esmf_fieldscatter(xv_input_grid, dummy2d, rootpet=0, rc=rc)
5991 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5994 if (localpet == 0)
then
5996 call nemsio_readrecv(gfile,
"xz",
"sfc", 1, dummy, 0, iret=rc)
5998 dummy2d = reshape(dummy, (/i_input,j_input/))
5999 print*,
'xz ',maxval(dummy2d),minval(dummy2d)
6002 print*,
"- CALL FieldScatter FOR INPUT XZ."
6003 call esmf_fieldscatter(xz_input_grid, dummy2d, rootpet=0, rc=rc)
6004 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6007 if (localpet == 0)
then
6008 print*,
"- READ XTTS"
6009 call nemsio_readrecv(gfile,
"xtts",
"sfc", 1, dummy, 0, iret=rc)
6011 dummy2d = reshape(dummy, (/i_input,j_input/))
6012 print*,
'xtts ',maxval(dummy2d),minval(dummy2d)
6015 print*,
"- CALL FieldScatter FOR INPUT XTTS."
6016 call esmf_fieldscatter(xtts_input_grid, dummy2d, rootpet=0, rc=rc)
6017 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6020 if (localpet == 0)
then
6021 print*,
"- READ XZTS"
6022 call nemsio_readrecv(gfile,
"xzts",
"sfc", 1, dummy, 0, iret=rc)
6024 dummy2d = reshape(dummy, (/i_input,j_input/))
6025 print*,
'xzts ',maxval(dummy2d),minval(dummy2d)
6028 print*,
"- CALL FieldScatter FOR INPUT XZTS."
6029 call esmf_fieldscatter(xzts_input_grid, dummy2d, rootpet=0, rc=rc)
6030 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6033 if (localpet == 0)
then
6035 call nemsio_readrecv(gfile,
"zc",
"sfc", 1, dummy, 0, iret=rc)
6037 dummy2d = reshape(dummy, (/i_input,j_input/))
6038 print*,
'zc ',maxval(dummy2d),minval(dummy2d)
6041 print*,
"- CALL FieldScatter FOR INPUT Z_C."
6042 call esmf_fieldscatter(z_c_input_grid, dummy2d, rootpet=0, rc=rc)
6043 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6046 if (localpet == 0)
then
6050 print*,
"- CALL FieldScatter FOR INPUT ZM."
6051 call esmf_fieldscatter(zm_input_grid, dummy2d, rootpet=0, rc=rc)
6052 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6055 deallocate(dummy, dummy2d)
6057 if (localpet == 0) call nemsio_close(gfile)
6072 sfcdata, sfcdata_3d)
6076 CHARACTER(LEN=*),
INTENT(IN) :: field
6078 INTEGER,
INTENT(IN) :: imo, jmo, lmo, tile_num
6080 REAL(ESMF_KIND_R8),
INTENT(OUT),
OPTIONAL :: sfcdata(imo,jmo)
6081 REAL(ESMF_KIND_R8),
INTENT(OUT),
OPTIONAL :: sfcdata_3d(imo,jmo,lmo)
6083 CHARACTER(LEN=256) :: tilefile
6085 INTEGER :: error, ncid, id_var
6087 tilefile = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(tile_num))
6089 print*,
'WILL READ ',trim(field),
' FROM: ', trim(tilefile)
6091 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
6092 CALL
netcdf_err(error,
'OPENING: '//trim(tilefile) )
6094 error=nf90_inq_varid(ncid, field, id_var)
6097 IF (present(sfcdata_3d))
THEN
6098 error=nf90_get_var(ncid, id_var, sfcdata_3d)
6101 error=nf90_get_var(ncid, id_var, sfcdata)
6105 error = nf90_close(ncid)
6126 character(len=250),
intent(in) :: file
6127 character(len=10),
intent(in) :: inv
6128 integer,
intent(in) :: localpet
6129 real(esmf_kind_r8),
intent(inout),
allocatable :: u(:,:,:),v(:,:,:)
6131 real(esmf_kind_r4),
dimension(i_input,j_input) :: alpha
6132 real(esmf_kind_r8),
dimension(i_input,j_input) :: lon, lat
6133 real(esmf_kind_r4),
allocatable :: u_tmp(:,:),v_tmp(:,:)
6134 real(esmf_kind_r4),
dimension(i_input,j_input) :: ws,wd
6135 real(esmf_kind_r4) :: value_u, value_v,lov,latin1,latin2
6136 real(esmf_kind_r8) :: d2r
6138 integer :: varnum_u, varnum_v, vlev, &
6141 character(len=20) :: vname
6142 character(len=50) :: method_u, method_v
6143 character(len=250) :: file_coord
6144 character(len=10000) :: temp_msg
6146 d2r=acos(-1.0_esmf_kind_r8) / 180.0_esmf_kind_r8
6147 if (localpet==0)
then
6148 allocate(u(i_input,j_input,lev_input))
6149 allocate(v(i_input,j_input,lev_input))
6155 file_coord = trim(fix_dir_input_grid)//
"/latlon_grid3.32769.nc"
6158 call
get_var_cond(vname,this_miss_var_method=method_u, this_miss_var_value=value_u, &
6161 call
get_var_cond(vname,this_miss_var_method=method_v, this_miss_var_value=value_v, &
6164 if (trim(input_grid_type)==
"rotated_latlon")
then
6165 print*,
"- CALL FieldGather FOR INPUT GRID LONGITUDE"
6166 call esmf_fieldgather(longitude_input_grid, lon, rootpet=0, tile=1, rc=error)
6167 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6169 print*,
"- CALL FieldGather FOR INPUT GRID LATITUDE"
6170 call esmf_fieldgather(latitude_input_grid, lat, rootpet=0, tile=1, rc=error)
6171 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6174 if (localpet==0)
then
6175 print*,
"- CALCULATE ROTATION ANGLE FOR ROTATED_LATLON INPUT GRID"
6176 error = grb2_inq(file, inv,grid_desc=temp_msg)
6185 istr = index(temp_msg,
"lat-center ") + len(
"lat_center ")
6186 read(temp_msg(istr:istr+9),
"(F8.5)") latin1
6187 istr = index(temp_msg,
"lon-center ") + len(
"lon-center ")
6188 read(temp_msg(istr:istr+10),
"(F9.6)") lov
6190 print*,
"- CALL CALCALPHA_ROTLATLON with center lat,lon = ",latin1,lov
6192 print*,
" alpha min/max = ",minval(alpha),maxval(alpha)
6194 elseif (trim(input_grid_type) ==
"lambert")
then
6197 print*,
"- CALL FieldGather FOR INPUT GRID LONGITUDE"
6198 call esmf_fieldgather(longitude_input_grid, lon, rootpet=0, tile=1, rc=error)
6199 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6202 if (localpet==0)
then
6203 error = grb2_inq(file, inv,grid_desc=temp_msg)
6211 istr = index(temp_msg,
"LoV ") + len(
"LoV ")
6212 read(temp_msg(istr:istr+10),
"(F9.6)") lov
6213 istr = index(temp_msg,
"Latin1 ") + len(
"Latin1 ")
6214 read(temp_msg(istr:istr+9),
"(F8.5)") latin1
6215 istr = index(temp_msg,
"Latin2 ") + len(
"Latin2 ")
6216 read(temp_msg(istr:istr+9),
"(F8.5)") latin2
6218 print*,
"- CALL GRIDROT for LC grid with lov,latin1/2 = ",lov,latin1,latin2
6219 call
gridrot(lov,latin1,latin2,lon,alpha)
6220 print*,
" alpha min/max = ",minval(alpha),maxval(alpha)
6224 if (localpet==0)
then
6225 do vlev = 1, lev_input
6228 iret = grb2_inq(file,inv,vname,slevs(vlev),data2=u_tmp)
6230 call
handle_grib_error(vname, slevs(vlev),method_u,value_u,varnum_u,iret,var=u_tmp)
6232 call
error_handler(
"READING IN U AT LEVEL "//trim(slevs(vlev))//
". SET A FILL "// &
6233 "VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",iret)
6238 iret = grb2_inq(file,inv,vname,slevs(vlev),data2=v_tmp)
6240 call
handle_grib_error(vname, slevs(vlev),method_v,value_v,varnum_v,iret,var=v_tmp)
6242 call
error_handler(
"READING IN V AT LEVEL "//trim(slevs(vlev))//
". SET A FILL "// &
6243 "VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",iret)
6247 if (trim(input_grid_type) ==
"latlon")
then
6248 if (external_model ==
'UKMET')
then
6250 v(:,:,vlev) = (v_tmp(:,2:jp1_input) + v_tmp(:,1:j_input))/2
6255 else if (trim(input_grid_type) ==
"rotated_latlon")
then
6256 ws = sqrt(u_tmp**2 + v_tmp**2)
6257 wd = atan2(-u_tmp,-v_tmp) / d2r
6258 wd = wd + alpha + 180.0
6260 u(:,:,vlev) = -ws*cos(wd*d2r)
6261 v(:,:,vlev) = -ws*sin(wd*d2r)
6263 u(:,:,vlev) =
real(u_tmp * cos(alpha) + v_tmp * sin(alpha),esmf_kind_r8)
6264 v(:,:,vlev) =
real(v_tmp * cos(alpha) - u_tmp * sin(alpha),esmf_kind_r8)
6267 print*,
'max, min U ', minval(u(:,:,vlev)), maxval(u(:,:,vlev))
6268 print*,
'max, min V ', minval(v(:,:,vlev)), maxval(v(:,:,vlev))
6281 integer :: clb(4), cub(4)
6282 integer :: i, j, k, rc
6284 real(esmf_kind_r8) :: latrad, lonrad
6285 real(esmf_kind_r8),
pointer :: windptr(:,:,:,:)
6286 real(esmf_kind_r8),
pointer :: uptr(:,:,:)
6287 real(esmf_kind_r8),
pointer :: vptr(:,:,:)
6288 real(esmf_kind_r8),
pointer :: latptr(:,:)
6289 real(esmf_kind_r8),
pointer :: lonptr(:,:)
6291 print*,
"- CALL FieldGet FOR 3-D WIND."
6292 call esmf_fieldget(wind_input_grid, &
6293 computationallbound=clb, &
6294 computationalubound=cub, &
6295 farrayptr=windptr, rc=rc)
6296 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6299 print*,
"- CALL FieldGet FOR U."
6300 call esmf_fieldget(u_input_grid, &
6301 farrayptr=uptr, rc=rc)
6302 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6305 print*,
"- CALL FieldGet FOR V."
6306 call esmf_fieldget(v_input_grid, &
6307 farrayptr=vptr, rc=rc)
6308 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6311 print*,
"- CALL FieldGet FOR LATITUDE."
6312 call esmf_fieldget(latitude_input_grid, &
6313 farrayptr=latptr, rc=rc)
6314 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6317 print*,
"- CALL FieldGet FOR LONGITUDE."
6318 call esmf_fieldget(longitude_input_grid, &
6319 farrayptr=lonptr, rc=rc)
6320 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6323 do i = clb(1), cub(1)
6324 do j = clb(2), cub(2)
6325 latrad = latptr(i,j) * acos(-1.) / 180.0
6326 lonrad = lonptr(i,j) * acos(-1.) / 180.0
6327 do k = clb(3), cub(3)
6328 windptr(i,j,k,1) = uptr(i,j,k) * cos(lonrad) - vptr(i,j,k) * sin(latrad) * sin(lonrad)
6329 windptr(i,j,k,2) = uptr(i,j,k) * sin(lonrad) + vptr(i,j,k) * sin(latrad) * cos(lonrad)
6330 windptr(i,j,k,3) = vptr(i,j,k) * cos(latrad)
6335 call esmf_fielddestroy(u_input_grid, rc=rc)
6336 call esmf_fielddestroy(v_input_grid, rc=rc)
6359 real(esmf_kind_r4),
intent(in) :: lov,latin1,latin2
6360 real(esmf_kind_r4),
intent(inout) :: rot(i_input,j_input)
6361 real(esmf_kind_r8),
intent(in) :: lon(i_input,j_input)
6363 real(esmf_kind_r4) :: trot(i_input,j_input), tlon(i_input,j_input)
6364 real(esmf_kind_r4) :: dtor = 3.14159265359/180.0_esmf_kind_r4
6365 real(esmf_kind_r4) :: an
6371 if ( (latin1 - latin2) .lt. 0.000001 )
then
6372 an = sin(latin1*dtor)
6374 an = log( cos(latin1*dtor) / cos(latin2*dtor) ) / &
6375 log( tan(dtor*(90.0-latin1)/2.) / tan(dtor*(90.0-latin2)/2.))
6378 tlon = mod(lon - lov + 180. + 3600., 360.) - 180.
6399 real(esmf_kind_r8),
intent(in) :: latgrid(i_input,j_input), &
6400 longrid(i_input,j_input)
6401 real(esmf_kind_r4),
intent(in) :: cenlat, cenlon
6402 real(esmf_kind_r4),
intent(out) :: alpha(i_input,j_input)
6405 real(esmf_kind_r8) :: d2r,lon0_r,lat0_r,sphi0,cphi0
6406 real(esmf_kind_r8),
DIMENSION(i_input,j_input) :: tlat,tlon,tph,sinalpha
6408 d2r = acos(-1.0_esmf_kind_r8) / 180.0_esmf_kind_r8
6409 if (cenlon .lt. 0)
then
6410 lon0_r = (cenlon + 360.0)*d2r
6419 tlat = latgrid * d2r
6420 tlon = longrid * d2r
6423 tlon = -tlon + lon0_r
6424 tph = asin(cphi0*sin(tlat) - sphi0*cos(tlat)*cos(tlon))
6425 sinalpha = sphi0 * sin(tlon) / cos(tph)
6426 alpha = -asin(sinalpha)/d2r
6445 use,
intrinsic :: ieee_arithmetic
6449 real(esmf_kind_r4),
intent(in) :: value
6450 real(esmf_kind_r4),
intent(inout),
optional :: var(:,:)
6451 real(esmf_kind_r8),
intent(inout),
optional :: var8(:,:)
6452 real(esmf_kind_r8),
intent(inout),
optional :: var3d(:,:,:)
6454 character(len=20),
intent(in) :: vname, lev, method
6456 integer,
intent(in) :: varnum
6457 integer,
intent(inout) :: iret
6460 if (varnum == 9999)
then
6461 print*,
"WARNING: ", trim(vname),
" NOT FOUND AT LEVEL ", lev,
" IN EXTERNAL FILE ", &
6462 "AND NO ENTRY EXISTS IN VARMAP TABLE. VARIABLE WILL NOT BE USED."
6468 if (trim(method) ==
"skip" )
then
6469 print*,
"WARNING: SKIPPING ", trim(vname),
" IN FILE"
6470 read_from_input(varnum) = .false.
6472 elseif (trim(method) ==
"set_to_fill")
then
6473 print*,
"WARNING: ,", trim(vname),
" NOT AVILABLE AT LEVEL ", trim(lev), &
6474 ". SETTING EQUAL TO FILL VALUE OF ", value
6475 if(present(var)) var(:,:) = value
6476 if(present(var8)) var8(:,:) = value
6477 if(present(var3d)) var3d(:,:,:) = value
6478 elseif (trim(method) ==
"set_to_NaN")
then
6479 print*,
"WARNING: ,", trim(vname),
" NOT AVILABLE AT LEVEL ", trim(lev), &
6480 ". SETTING EQUAL TO NaNs"
6481 if(present(var)) var(:,:) = ieee_value(var,ieee_quiet_nan)
6482 if(present(var8)) var8(:,:) = ieee_value(var8,ieee_quiet_nan)
6483 if(present(var3d)) var3d(:,:,:) = ieee_value(var3d,ieee_quiet_nan)
6484 elseif (trim(method) ==
"stop")
then
6485 call
error_handler(
"READING "//trim(vname)//
" at level "//lev//
". TO MAKE THIS NON- &
6486 FATAL, CHANGE STOP TO SKIP FOR THIS VARIABLE IN YOUR VARMAP &
6488 elseif (trim(method) ==
"intrp")
then
6489 print*,
"WARNING: ,"//trim(vname)//
" NOT AVAILABLE AT LEVEL "//trim(lev)// &
6490 ". WILL INTERPOLATE INTERSPERSED MISSING LEVELS AND/OR FILL MISSING"//&
6493 call
error_handler(
"ERROR USING MISSING_VAR_METHOD. PLEASE SET VALUES IN" // &
6494 " VARMAP TABLE TO ONE OF: set_to_fill, set_to_NaN,"// &
6495 " , skip, or stop.", 1)
6514 character(len=*),
intent(in) :: the_file, inv_file
6515 character(len=20),
intent(in) :: vname,vname_file
6517 integer,
intent(out) :: rc
6519 real(esmf_kind_r8),
intent(inout) :: dummy3d(:,:,:)
6521 real(esmf_kind_r4),
allocatable :: dummy2d(:,:)
6522 real(esmf_kind_r4) :: value
6524 character(len=50) :: slevs(lsoil_input)
6525 character(len=50) :: method
6527 allocate(dummy2d(i_input,j_input))
6529 if(lsoil_input == 4)
then
6530 slevs = (/
character(24)::
':0-0.1 m below ground:',
':0.1-0.4 m below ground:', &
6531 ':0.4-1 m below ground:',
':1-2 m below ground:'/)
6532 elseif(lsoil_input == 9)
then
6533 slevs = (/
character(26)::
':0-0 m below ground',
':0.01-0.01 m below ground:',
':0.04-0.04 m below ground:', &
6534 ':0.1-0.1 m below ground:',
':0.3-0.3 m below ground:',
':0.6-0.6 m below ground:', &
6535 ':1-1 m below ground:',
':1.6-1.6 m below ground:',
':3-3 m below ground:'/)
6538 call
error_handler(
"reading soil levels. File must have 4 or 9 soil levels.", rc)
6541 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
6543 do i = 1,lsoil_input
6544 if (vname_file==
"var2_2_1_")
then
6545 rc = grb2_inq(the_file,inv_file,vname_file,
"_0_192:",slevs(i),data2=dummy2d)
6547 rc = grb2_inq(the_file,inv_file,vname_file,slevs(i),data2=dummy2d)
6551 if (rc==1 .and. trim(vname) /=
"soill")
then
6553 call
error_handler(
"READING IN "//trim(vname)//
". SET A FILL "// &
6554 "VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",rc)
6556 dummy3d(:,:,:) = 0.0_esmf_kind_r8
6561 dummy3d(:,:,i) =
real(dummy2d,esmf_kind_r8)
6577 print*,
'- DESTROY ATMOSPHERIC INPUT DATA.'
6579 call esmf_fielddestroy(terrain_input_grid, rc=rc)
6580 call esmf_fielddestroy(pres_input_grid, rc=rc)
6581 call esmf_fielddestroy(dzdt_input_grid, rc=rc)
6582 call esmf_fielddestroy(temp_input_grid, rc=rc)
6583 call esmf_fielddestroy(wind_input_grid, rc=rc)
6584 call esmf_fielddestroy(ps_input_grid, rc=rc)
6586 do n = 1, num_tracers_input
6587 call esmf_fielddestroy(tracers_input_grid(n), rc=rc)
6589 deallocate(tracers_input_grid)
6602 print*,
'- DESTROY NST INPUT DATA.'
6604 call esmf_fielddestroy(landsea_mask_input_grid, rc=rc)
6605 call esmf_fielddestroy(c_d_input_grid, rc=rc)
6606 call esmf_fielddestroy(c_0_input_grid, rc=rc)
6607 call esmf_fielddestroy(d_conv_input_grid, rc=rc)
6608 call esmf_fielddestroy(dt_cool_input_grid, rc=rc)
6609 call esmf_fielddestroy(ifd_input_grid, rc=rc)
6610 call esmf_fielddestroy(qrain_input_grid, rc=rc)
6611 call esmf_fielddestroy(tref_input_grid, rc=rc)
6612 call esmf_fielddestroy(w_d_input_grid, rc=rc)
6613 call esmf_fielddestroy(w_0_input_grid, rc=rc)
6614 call esmf_fielddestroy(xs_input_grid, rc=rc)
6615 call esmf_fielddestroy(xt_input_grid, rc=rc)
6616 call esmf_fielddestroy(xu_input_grid, rc=rc)
6617 call esmf_fielddestroy(xv_input_grid, rc=rc)
6618 call esmf_fielddestroy(xz_input_grid, rc=rc)
6619 call esmf_fielddestroy(xtts_input_grid, rc=rc)
6620 call esmf_fielddestroy(xzts_input_grid, rc=rc)
6621 call esmf_fielddestroy(z_c_input_grid, rc=rc)
6622 call esmf_fielddestroy(zm_input_grid, rc=rc)
6635 print*,
"- CALL FieldDestroy FOR INPUT GRID FIELDS."
6637 call esmf_fielddestroy(canopy_mc_input_grid, rc=rc)
6638 call esmf_fielddestroy(f10m_input_grid, rc=rc)
6639 call esmf_fielddestroy(ffmm_input_grid, rc=rc)
6640 if (.not. convert_nst)
then
6641 call esmf_fielddestroy(landsea_mask_input_grid, rc=rc)
6643 call esmf_fielddestroy(q2m_input_grid, rc=rc)
6644 call esmf_fielddestroy(seaice_depth_input_grid, rc=rc)
6645 call esmf_fielddestroy(seaice_fract_input_grid, rc=rc)
6646 call esmf_fielddestroy(seaice_skin_temp_input_grid, rc=rc)
6647 call esmf_fielddestroy(skin_temp_input_grid, rc=rc)
6648 call esmf_fielddestroy(snow_depth_input_grid, rc=rc)
6649 call esmf_fielddestroy(snow_liq_equiv_input_grid, rc=rc)
6650 call esmf_fielddestroy(soil_temp_input_grid, rc=rc)
6651 call esmf_fielddestroy(soil_type_input_grid, rc=rc)
6652 call esmf_fielddestroy(soilm_liq_input_grid, rc=rc)
6653 call esmf_fielddestroy(soilm_tot_input_grid, rc=rc)
6654 call esmf_fielddestroy(srflag_input_grid, rc=rc)
6655 call esmf_fielddestroy(t2m_input_grid, rc=rc)
6656 call esmf_fielddestroy(tprcp_input_grid, rc=rc)
6657 call esmf_fielddestroy(ustar_input_grid, rc=rc)
6658 call esmf_fielddestroy(veg_type_input_grid, rc=rc)
6659 call esmf_fielddestroy(z0_input_grid, rc=rc)
6660 call esmf_fielddestroy(terrain_input_grid, rc=rc)
6661 if (.not. vgfrc_from_climo)
then
6662 call esmf_fielddestroy(veg_greenness_input_grid, rc=rc)
6664 if (.not. minmax_vgfrc_from_climo)
then
6665 call esmf_fielddestroy(min_veg_greenness_input_grid, rc=rc)
6666 call esmf_fielddestroy(max_veg_greenness_input_grid, rc=rc)
6668 if (.not. lai_from_climo)
then
6669 call esmf_fielddestroy(lai_input_grid, rc=rc)
6686 x = a( (first+last) / 2 )
6697 t = a(i); a(i) = a(j); a(j) = t
6701 if (first < i-1) call
quicksort(a, first, i-1)
6702 if (j+1 < last) call
quicksort(a, j+1, last)
6721 real(esmf_kind_r8),
intent(inout) :: soilt(i_input,j_input,lsoil_input)
6722 real(esmf_kind_r8),
intent(in) :: skint(i_input,j_input)
6723 integer(esmf_kind_i4),
intent(in) :: landmask(i_input,j_input)
6730 if (landmask(i,j) == 0_esmf_kind_i4 )
then
6731 soilt(i,j,k) = skint(i,j)
6732 else if (landmask(i,j) == 1_esmf_kind_i4 .and. soilt(i,j,k) > 350.0_esmf_kind_r8)
then
6733 soilt(i,j,k) = skint(i,j)
6734 else if (landmask(i,j) == 2_esmf_kind_i4 )
then
6735 soilt(i,j,k) = icet_default
6751 real(esmf_kind_r4),
intent(inout) :: cnwat(i_input,j_input)
6753 real(esmf_kind_r4) :: max_cnwat = 0.5
6759 if (cnwat(i,j) .gt. max_cnwat) cnwat(i,j) = 0.0_esmf_kind_r4
6786 SUBROUTINE dint2p(PPIN,XXIN,NPIN,PPOUT,XXOUT,NPOUT &
6802 INTEGER npin,npout,linlog,ier
6803 real*8 ppin(npin),xxin(npin),ppout(npout),xmsg
6807 real*8 pin(npin),xin(npin),p(npin),x(npin)
6808 real*8 pout(npout),xout(npout)
6811 INTEGER j1,np,nl,nin,nlmax,nplvl,nlsave,np1,no1,n1,n2,loglin, &
6813 real*8 slope,pa,pb,pc
6815 loglin = abs(linlog)
6820 IF (npout.GT.0)
THEN
6829 IF (npin.LT.2 .OR. npout.LT.1) ier = ier + 1
6842 IF (ppin(1).LT.ppin(2))
THEN
6845 IF (ppout(1).LT.ppout(2))
THEN
6850 pin(np) = ppin(abs(np1-np))
6851 xin(np) = xxin(abs(np1-np))
6855 pout(np) = ppout(abs(no1-np))
6863 IF (xin(np).NE.xmsg .AND. pin(np).NE.xmsg)
THEN
6872 IF (nlmax.LT.2)
THEN
6874 print *,
'INT2P: ier=',ier
6893 DO nl = nlstrt,nlmax
6894 IF (pout(np).EQ.p(nl))
THEN
6903 IF (loglin.EQ.1)
THEN
6906 IF (pout(np).LT.p(nl) .AND. pout(np).GT.p(nl+1))
THEN
6907 slope = (x(nl)-x(nl+1))/ (p(nl)-p(nl+1))
6908 xout(np) = x(nl+1) + slope* (pout(np)-p(nl+1))
6915 IF (pout(np).LT.p(nl) .AND. pout(np).GT.p(nl+1))
THEN
6919 if (p(nl+1).gt.0.d0)
then
6925 slope = (x(nl)-x(nl+1))/ (pa-pc)
6926 xout(np) = x(nl+1) + slope* (pb-pc)
6935 IF (linlog.LT.0)
THEN
6938 IF (pout(np).GT.p(1))
THEN
6939 IF (loglin.EQ.1)
THEN
6940 slope = (x(2)-x(1))/ (p(2)-p(1))
6941 xout(np) = x(1) + slope* (pout(np)-p(1))
6946 slope = (x(2)-x(1))/ (pa-pc)
6947 xout(np) = x(1) + slope* (pb-pc)
6949 ELSE IF (pout(np).LT.p(nlmax))
THEN
6952 IF (loglin.EQ.1)
THEN
6953 slope = (x(n1)-x(n2))/ (p(n1)-p(n2))
6954 xout(np) = x(n1) + slope* (pout(np)-p(n1))
6959 slope = (x(n1)-x(n2))/ (pa-pc)
6961 xout(np) = x(n1) + slope* (pb-pa)
6974 ppout(np) = pout(n1)
6975 xxout(np) = xout(n1)
6979 ppout(np) = pout(np)
6980 xxout(np) = xout(np)
Sets up the ESMF grid objects for the input data grid and target FV3 grid.
Replace undefined values with a valid value.
subroutine netcdf_err(err, string)
Error handler for netcdf.
character(len=len(strin)) function to_upper(strIn)
Convert string from lower to uppercase.
subroutine error_handler(string, rc)
General error handler.
This module contains code to read the setup namelist file, handle the varmap file for GRIB2 data...
subroutine rh2spfh(rh_sphum, p, t)
Convert relative humidity to specific humidity.
subroutine, public get_var_cond(var_name, this_miss_var_method, this_miss_var_value, this_field_var_name, loc)
Search the variable mapping table to find conditions for handling missing variables.
Utilities for use when reading grib2 data.
subroutine convert_omega(omega, p, t, q, clb, cub)
Convert omega to vertical velocity.
subroutine, public search(field, mask, idim, jdim, tile, field_num, latitude, terrain_land, soilt_climo)
Replace undefined surface values.
subroutine convert_winds
Convert 3-d component winds to u and v.