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
151 integer,
intent(in) :: localpet
157 if (trim(input_type) ==
"restart")
then
165 elseif (trim(input_type) ==
"gaussian_netcdf")
then
173 elseif (trim(input_type) ==
"history")
then
181 elseif (trim(input_type) ==
"gaussian_nemsio")
then
189 elseif (trim(input_type) ==
"gfs_gaussian_nemsio")
then
197 elseif (trim(input_type) ==
"gfs_sigio")
then
205 elseif (trim(input_type) ==
"grib2")
then
221 integer,
intent(in) :: localpet
225 print*,
"- READ INPUT GRID NST DATA."
227 print*,
"- CALL FieldCreate FOR INPUT GRID C_D."
228 c_d_input_grid = esmf_fieldcreate(input_grid, &
229 typekind=esmf_typekind_r8, &
230 staggerloc=esmf_staggerloc_center, rc=rc)
231 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
234 print*,
"- CALL FieldCreate FOR INPUT GRID C_0."
235 c_0_input_grid = esmf_fieldcreate(input_grid, &
236 typekind=esmf_typekind_r8, &
237 staggerloc=esmf_staggerloc_center, rc=rc)
238 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
241 print*,
"- CALL FieldCreate FOR INPUT GRID D_CONV."
242 d_conv_input_grid = esmf_fieldcreate(input_grid, &
243 typekind=esmf_typekind_r8, &
244 staggerloc=esmf_staggerloc_center, rc=rc)
245 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
248 print*,
"- CALL FieldCreate FOR INPUT GRID DT_COOL."
249 dt_cool_input_grid = esmf_fieldcreate(input_grid, &
250 typekind=esmf_typekind_r8, &
251 staggerloc=esmf_staggerloc_center, rc=rc)
252 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
255 print*,
"- CALL FieldCreate FOR INPUT GRID IFD."
256 ifd_input_grid = esmf_fieldcreate(input_grid, &
257 typekind=esmf_typekind_r8, &
258 staggerloc=esmf_staggerloc_center, rc=rc)
259 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
262 print*,
"- CALL FieldCreate FOR INPUT GRID QRAIN."
263 qrain_input_grid = esmf_fieldcreate(input_grid, &
264 typekind=esmf_typekind_r8, &
265 staggerloc=esmf_staggerloc_center, rc=rc)
266 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
269 print*,
"- CALL FieldCreate FOR INPUT GRID TREF."
270 tref_input_grid = esmf_fieldcreate(input_grid, &
271 typekind=esmf_typekind_r8, &
272 staggerloc=esmf_staggerloc_center, rc=rc)
273 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
276 print*,
"- CALL FieldCreate FOR INPUT GRID W_D."
277 w_d_input_grid = esmf_fieldcreate(input_grid, &
278 typekind=esmf_typekind_r8, &
279 staggerloc=esmf_staggerloc_center, rc=rc)
280 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
283 print*,
"- CALL FieldCreate FOR INPUT GRID W_0."
284 w_0_input_grid = esmf_fieldcreate(input_grid, &
285 typekind=esmf_typekind_r8, &
286 staggerloc=esmf_staggerloc_center, rc=rc)
287 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
290 print*,
"- CALL FieldCreate FOR INPUT GRID XS."
291 xs_input_grid = esmf_fieldcreate(input_grid, &
292 typekind=esmf_typekind_r8, &
293 staggerloc=esmf_staggerloc_center, rc=rc)
294 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
297 print*,
"- CALL FieldCreate FOR INPUT GRID XT."
298 xt_input_grid = esmf_fieldcreate(input_grid, &
299 typekind=esmf_typekind_r8, &
300 staggerloc=esmf_staggerloc_center, rc=rc)
301 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
304 print*,
"- CALL FieldCreate FOR INPUT GRID XU."
305 xu_input_grid = esmf_fieldcreate(input_grid, &
306 typekind=esmf_typekind_r8, &
307 staggerloc=esmf_staggerloc_center, rc=rc)
308 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
311 print*,
"- CALL FieldCreate FOR INPUT GRID XV."
312 xv_input_grid = esmf_fieldcreate(input_grid, &
313 typekind=esmf_typekind_r8, &
314 staggerloc=esmf_staggerloc_center, rc=rc)
315 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
318 print*,
"- CALL FieldCreate FOR INPUT GRID XZ."
319 xz_input_grid = esmf_fieldcreate(input_grid, &
320 typekind=esmf_typekind_r8, &
321 staggerloc=esmf_staggerloc_center, rc=rc)
322 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
325 print*,
"- CALL FieldCreate FOR INPUT GRID XTTS."
326 xtts_input_grid = esmf_fieldcreate(input_grid, &
327 typekind=esmf_typekind_r8, &
328 staggerloc=esmf_staggerloc_center, rc=rc)
329 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
332 print*,
"- CALL FieldCreate FOR INPUT GRID XZTS."
333 xzts_input_grid = esmf_fieldcreate(input_grid, &
334 typekind=esmf_typekind_r8, &
335 staggerloc=esmf_staggerloc_center, rc=rc)
336 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
339 print*,
"- CALL FieldCreate FOR INPUT GRID Z_C."
340 z_c_input_grid = esmf_fieldcreate(input_grid, &
341 typekind=esmf_typekind_r8, &
342 staggerloc=esmf_staggerloc_center, rc=rc)
343 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
346 print*,
"- CALL FieldCreate FOR INPUT GRID ZM."
347 zm_input_grid = esmf_fieldcreate(input_grid, &
348 typekind=esmf_typekind_r8, &
349 staggerloc=esmf_staggerloc_center, rc=rc)
350 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
358 if (trim(input_type) ==
"gaussian_nemsio" .or. trim(input_type) ==
"gfs_gaussian_nemsio")
then
383 integer,
intent(in) :: localpet
387 print*,
"- CALL FieldCreate FOR INPUT GRID LANDSEA MASK."
388 landsea_mask_input_grid = esmf_fieldcreate(input_grid, &
389 typekind=esmf_typekind_r8, &
390 staggerloc=esmf_staggerloc_center, rc=rc)
391 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
394 print*,
"- CALL FieldCreate FOR INPUT GRID Z0."
395 z0_input_grid = esmf_fieldcreate(input_grid, &
396 typekind=esmf_typekind_r8, &
397 staggerloc=esmf_staggerloc_center, rc=rc)
398 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
401 print*,
"- CALL FieldCreate FOR INPUT GRID VEGETATION TYPE."
402 veg_type_input_grid = esmf_fieldcreate(input_grid, &
403 typekind=esmf_typekind_r8, &
404 staggerloc=esmf_staggerloc_center, rc=rc)
405 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
408 print*,
"- CALL FieldCreate FOR INPUT GRID CANOPY MOISTURE CONTENT."
409 canopy_mc_input_grid = esmf_fieldcreate(input_grid, &
410 typekind=esmf_typekind_r8, &
411 staggerloc=esmf_staggerloc_center, rc=rc)
412 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
415 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE FRACTION."
416 seaice_fract_input_grid = esmf_fieldcreate(input_grid, &
417 typekind=esmf_typekind_r8, &
418 staggerloc=esmf_staggerloc_center, rc=rc)
419 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
422 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE DEPTH."
423 seaice_depth_input_grid = esmf_fieldcreate(input_grid, &
424 typekind=esmf_typekind_r8, &
425 staggerloc=esmf_staggerloc_center, rc=rc)
426 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
429 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE SKIN TEMPERATURE."
430 seaice_skin_temp_input_grid = esmf_fieldcreate(input_grid, &
431 typekind=esmf_typekind_r8, &
432 staggerloc=esmf_staggerloc_center, rc=rc)
433 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
436 print*,
"- CALL FieldCreate FOR INPUT GRID SNOW DEPTH."
437 snow_depth_input_grid = esmf_fieldcreate(input_grid, &
438 typekind=esmf_typekind_r8, &
439 staggerloc=esmf_staggerloc_center, rc=rc)
440 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
443 print*,
"- CALL FieldCreate FOR INPUT GRID SNOW LIQUID EQUIVALENT."
444 snow_liq_equiv_input_grid = esmf_fieldcreate(input_grid, &
445 typekind=esmf_typekind_r8, &
446 staggerloc=esmf_staggerloc_center, rc=rc)
447 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
450 print*,
"- CALL FieldCreate FOR INPUT GRID T2M."
451 t2m_input_grid = esmf_fieldcreate(input_grid, &
452 typekind=esmf_typekind_r8, &
453 staggerloc=esmf_staggerloc_center, rc=rc)
454 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
457 print*,
"- CALL FieldCreate FOR INPUT GRID Q2M."
458 q2m_input_grid = esmf_fieldcreate(input_grid, &
459 typekind=esmf_typekind_r8, &
460 staggerloc=esmf_staggerloc_center, rc=rc)
461 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
464 print*,
"- CALL FieldCreate FOR INPUT GRID TPRCP."
465 tprcp_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 F10M."
472 f10m_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 USTAR."
479 ustar_input_grid = esmf_fieldcreate(input_grid, &
480 typekind=esmf_typekind_r8, &
481 staggerloc=esmf_staggerloc_center, rc=rc)
482 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
485 print*,
"- CALL FieldCreate FOR INPUT GRID FFMM."
486 ffmm_input_grid = esmf_fieldcreate(input_grid, &
487 typekind=esmf_typekind_r8, &
488 staggerloc=esmf_staggerloc_center, rc=rc)
489 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
492 print*,
"- CALL FieldCreate FOR INPUT GRID SRFLAG."
493 srflag_input_grid = esmf_fieldcreate(input_grid, &
494 typekind=esmf_typekind_r8, &
495 staggerloc=esmf_staggerloc_center, rc=rc)
496 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
499 print*,
"- CALL FieldCreate FOR INPUT SKIN TEMPERATURE."
500 skin_temp_input_grid = esmf_fieldcreate(input_grid, &
501 typekind=esmf_typekind_r8, &
502 staggerloc=esmf_staggerloc_center, rc=rc)
503 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
506 print*,
"- CALL FieldCreate FOR INPUT SOIL TYPE."
507 soil_type_input_grid = esmf_fieldcreate(input_grid, &
508 typekind=esmf_typekind_r8, &
509 staggerloc=esmf_staggerloc_center, rc=rc)
510 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
513 print*,
"- CALL FieldCreate FOR INPUT TERRAIN."
514 terrain_input_grid = esmf_fieldcreate(input_grid, &
515 typekind=esmf_typekind_r8, &
516 staggerloc=esmf_staggerloc_center, rc=rc)
517 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
520 print*,
"- CALL FieldCreate FOR INPUT SOIL TEMPERATURE."
521 soil_temp_input_grid = esmf_fieldcreate(input_grid, &
522 typekind=esmf_typekind_r8, &
523 staggerloc=esmf_staggerloc_center, &
524 ungriddedlbound=(/1/), &
525 ungriddedubound=(/lsoil_input/), rc=rc)
526 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
529 print*,
"- CALL FieldCreate FOR INPUT TOTAL SOIL MOISTURE."
530 soilm_tot_input_grid = esmf_fieldcreate(input_grid, &
531 typekind=esmf_typekind_r8, &
532 staggerloc=esmf_staggerloc_center, &
533 ungriddedlbound=(/1/), &
534 ungriddedubound=(/lsoil_input/), rc=rc)
535 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
538 print*,
"- CALL FieldCreate FOR INPUT LIQUID SOIL MOISTURE."
539 soilm_liq_input_grid = esmf_fieldcreate(input_grid, &
540 typekind=esmf_typekind_r8, &
541 staggerloc=esmf_staggerloc_center, &
542 ungriddedlbound=(/1/), &
543 ungriddedubound=(/lsoil_input/), rc=rc)
544 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
549 if (.not. vgfrc_from_climo)
then
550 print*,
"- CALL FieldCreate FOR INPUT VEGETATION GREENNESS."
551 veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
552 typekind=esmf_typekind_r8, &
553 staggerloc=esmf_staggerloc_center, rc=rc)
554 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
558 if (.not. minmax_vgfrc_from_climo)
then
559 print*,
"- CALL FieldCreate FOR INPUT MIN VEGETATION GREENNESS."
560 min_veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
561 typekind=esmf_typekind_r8, &
562 staggerloc=esmf_staggerloc_center, rc=rc)
563 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
566 print*,
"- CALL FieldCreate FOR INPUT MAX VEGETATION GREENNESS."
567 max_veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
568 typekind=esmf_typekind_r8, &
569 staggerloc=esmf_staggerloc_center, rc=rc)
570 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
574 if (.not. lai_from_climo)
then
575 print*,
"- CALL FieldCreate FOR INPUT LEAF AREA INDEX."
576 lai_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__))&
587 if (trim(input_type) ==
"restart")
then
595 elseif (trim(input_type) ==
"history" .or. trim(input_type) == &
596 "gaussian_netcdf")
then
604 elseif (trim(input_type) ==
"gaussian_nemsio")
then
612 elseif (trim(input_type) ==
"gfs_gaussian_nemsio")
then
620 elseif (trim(input_type) ==
"gfs_sigio")
then
628 elseif (trim(input_type) ==
"grib2")
then
645 print*,
"- INITIALIZE ATMOSPHERIC ESMF FIELDS."
647 print*,
"- CALL FieldCreate FOR INPUT GRID 3-D WIND."
648 wind_input_grid = esmf_fieldcreate(input_grid, &
649 typekind=esmf_typekind_r8, &
650 staggerloc=esmf_staggerloc_center, &
651 ungriddedlbound=(/1,1/), &
652 ungriddedubound=(/lev_input,3/), rc=rc)
653 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
656 print*,
"- CALL FieldCreate FOR INPUT GRID SURFACE PRESSURE."
657 ps_input_grid = esmf_fieldcreate(input_grid, &
658 typekind=esmf_typekind_r8, &
659 staggerloc=esmf_staggerloc_center, rc=rc)
660 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
663 print*,
"- CALL FieldCreate FOR INPUT GRID TERRAIN."
664 terrain_input_grid = esmf_fieldcreate(input_grid, &
665 typekind=esmf_typekind_r8, &
666 staggerloc=esmf_staggerloc_center, rc=rc)
667 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
670 print*,
"- CALL FieldCreate FOR INPUT GRID TEMPERATURE."
671 temp_input_grid = esmf_fieldcreate(input_grid, &
672 typekind=esmf_typekind_r8, &
673 staggerloc=esmf_staggerloc_center, &
674 ungriddedlbound=(/1/), &
675 ungriddedubound=(/lev_input/), rc=rc)
676 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
679 allocate(tracers_input_grid(num_tracers_input))
681 do i = 1, num_tracers_input
682 print*,
"- CALL FieldCreate FOR INPUT GRID TRACER ", trim(tracers_input(i))
683 tracers_input_grid(i) = esmf_fieldcreate(input_grid, &
684 typekind=esmf_typekind_r8, &
685 staggerloc=esmf_staggerloc_center, &
686 ungriddedlbound=(/1/), &
687 ungriddedubound=(/lev_input/), rc=rc)
688 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
692 print*,
"- CALL FieldCreate FOR INPUT GRID DZDT."
693 dzdt_input_grid = esmf_fieldcreate(input_grid, &
694 typekind=esmf_typekind_r8, &
695 staggerloc=esmf_staggerloc_center, &
696 ungriddedlbound=(/1/), &
697 ungriddedubound=(/lev_input/), rc=rc)
698 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
701 print*,
"- CALL FieldCreate FOR INPUT GRID U."
702 u_input_grid = esmf_fieldcreate(input_grid, &
703 typekind=esmf_typekind_r8, &
704 staggerloc=esmf_staggerloc_center, &
705 ungriddedlbound=(/1/), &
706 ungriddedubound=(/lev_input/), rc=rc)
707 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
710 print*,
"- CALL FieldCreate FOR INPUT GRID V."
711 v_input_grid = esmf_fieldcreate(input_grid, &
712 typekind=esmf_typekind_r8, &
713 staggerloc=esmf_staggerloc_center, &
714 ungriddedlbound=(/1/), &
715 ungriddedubound=(/lev_input/), rc=rc)
716 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
719 print*,
"- CALL FieldCreate FOR INPUT GRID PRESSURE."
720 pres_input_grid = esmf_fieldcreate(input_grid, &
721 typekind=esmf_typekind_r8, &
722 staggerloc=esmf_staggerloc_center, &
723 ungriddedlbound=(/1/), &
724 ungriddedubound=(/lev_input/), rc=rc)
725 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
741 integer,
intent(in) :: localpet
743 character(len=300) :: the_file
745 integer(sigio_intkind) :: iret
746 integer :: rc, i, j, k
747 integer :: clb(3), cub(3)
749 real(esmf_kind_r8) :: ak, bk
750 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
751 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
752 real(esmf_kind_r8),
allocatable :: dummy3d2(:,:,:)
753 real(esmf_kind_r8),
pointer :: pptr(:,:,:), psptr(:,:)
754 real(esmf_kind_r8),
allocatable :: pi(:,:,:)
756 type(sigio_head
) :: sighead
757 type(sigio_dbta
) :: sigdata
759 the_file = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
761 print*,
"- ATMOSPHERIC DATA IN SIGIO FORMAT."
762 print*,
"- OPEN AND READ: ", trim(the_file)
764 call sigio_sropen(21, trim(the_file), iret)
769 call sigio_srhead(21, sighead, iret)
775 lev_input = sighead%levs
776 levp1_input = lev_input + 1
778 if (num_tracers_input /= sighead%ntrac)
then
782 if (sighead%idvt == 0 .or. sighead%idvt == 21)
then
783 if (trim(tracers_input(1)) /=
'spfh' .or. &
784 trim(tracers_input(2)) /=
'o3mr' .or. &
785 trim(tracers_input(3)) /=
'clwmr')
then
786 call
error_handler(
"TRACERS SELECTED DO NOT MATCH FILE CONTENTS.", 99)
789 print*,
'- UNRECOGNIZED IDVT: ', sighead%idvt
799 if (localpet == 0)
then
800 allocate(dummy2d(i_input,j_input))
801 allocate(dummy3d(i_input,j_input,lev_input))
802 allocate(dummy3d2(i_input,j_input,lev_input))
804 allocate(dummy2d(0,0))
805 allocate(dummy3d(0,0,0))
806 allocate(dummy3d2(0,0,0))
809 if (localpet == 0)
then
810 call sigio_aldbta(sighead, sigdata, iret)
815 call sigio_srdbta(21, sighead, sigdata, iret)
820 call sptez(0,sighead%jcap,4,i_input, j_input, sigdata%ps, dummy2d, 1)
821 dummy2d = exp(dummy2d) * 1000.0
822 print*,
'surface pres ',maxval(dummy2d),minval(dummy2d)
825 print*,
"- CALL FieldScatter FOR SURFACE PRESSURE."
826 call esmf_fieldscatter(ps_input_grid, dummy2d, rootpet=0, rc=rc)
827 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
830 if (localpet == 0)
then
831 call sptez(0,sighead%jcap,4,i_input, j_input, sigdata%hs, dummy2d, 1)
832 print*,
'terrain ',maxval(dummy2d),minval(dummy2d)
835 print*,
"- CALL FieldScatter FOR TERRAIN."
836 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
837 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
840 do k = 1, num_tracers_input
842 if (localpet == 0)
then
843 call sptezm(0,sighead%jcap,4,i_input, j_input, lev_input, sigdata%q(:,:,k), dummy3d, 1)
844 print*,trim(tracers_input(k)),maxval(dummy3d),minval(dummy3d)
847 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(k))
848 call esmf_fieldscatter(tracers_input_grid(k), dummy3d, rootpet=0, rc=rc)
849 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
854 if (localpet == 0)
then
855 call sptezm(0,sighead%jcap,4,i_input, j_input, lev_input, sigdata%t, dummy3d, 1)
856 print*,
'temp ',maxval(dummy3d),minval(dummy3d)
859 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
860 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
861 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
869 if (localpet == 0)
then
870 print*,
"- NO VERTICAL VELOCITY RECORD. SET TO ZERO."
874 print*,
"- CALL FieldScatter FOR INPUT DZDT."
875 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
876 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
879 if (localpet == 0)
then
880 call sptezmv(0, sighead%jcap, 4, i_input, j_input, lev_input, sigdata%d, sigdata%z, dummy3d, dummy3d2, 1)
881 print*,
'u ',maxval(dummy3d),minval(dummy3d)
882 print*,
'v ',maxval(dummy3d2),minval(dummy3d2)
885 print*,
"- CALL FieldScatter FOR INPUT U-WIND."
886 call esmf_fieldscatter(u_input_grid, dummy3d, rootpet=0, rc=rc)
887 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
890 print*,
"- CALL FieldScatter FOR INPUT V-WIND."
891 call esmf_fieldscatter(v_input_grid, dummy3d2, rootpet=0, rc=rc)
892 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
895 deallocate(dummy2d, dummy3d, dummy3d2)
897 if (localpet == 0) call sigio_axdbta(sigdata, iret)
899 call sigio_sclose(21, iret)
911 print*,
"- COMPUTE 3-D PRESSURE."
913 print*,
"- CALL FieldGet FOR 3-D PRES."
915 call esmf_fieldget(pres_input_grid, &
916 computationallbound=clb, &
917 computationalubound=cub, &
918 farrayptr=pptr, rc=rc)
919 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
922 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
924 call esmf_fieldget(ps_input_grid, &
925 farrayptr=psptr, rc=rc)
926 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
933 allocate(pi(clb(1):cub(1),clb(2):cub(2),1:levp1_input),stat=rc)
936 ak = sighead%vcoord(k,1)
937 bk = sighead%vcoord(k,2)
940 pi(i,j,k) = ak + bk*psptr(i,j)
945 if (localpet == 0)
then
946 print*,
'pres int ',psptr(clb(1),clb(2)),pi(clb(1),clb(2),:)
956 pptr(i,j,k) = (pi(i,j,k)+pi(i,j,k+1))/2.0_esmf_kind_r8
963 if (localpet == 0)
then
964 print*,
'pres ',psptr(clb(1),clb(2)),pptr(clb(1),clb(2),:)
978 integer,
intent(in) :: localpet
980 character(len=300) :: the_file
981 character(len=20) :: vlevtyp, vname
983 integer(nemsio_intkind) :: vlev, iret
984 integer :: i, j, k, n, rc
985 integer :: clb(3), cub(3)
987 real(nemsio_realkind),
allocatable :: vcoord(:,:,:)
988 real(nemsio_realkind),
allocatable :: dummy(:)
989 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
990 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
991 real(esmf_kind_r8) :: ak, bk
992 real(esmf_kind_r8),
allocatable :: pi(:,:,:)
993 real(esmf_kind_r8),
pointer :: pptr(:,:,:), psptr(:,:)
995 type(nemsio_gfile
) :: gfile
997 the_file = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
999 print*,
"- READ ATMOS DATA FROM SPECTRAL GFS NEMSIO FILE: ", trim(the_file)
1001 print*,
"- OPEN FILE."
1002 call nemsio_open(gfile, the_file,
"read", iret=iret)
1003 if (iret /= 0) call
error_handler(
"OPENING SPECTRAL GFS NEMSIO ATM FILE.", iret)
1005 print*,
"- READ NUMBER OF VERTICAL LEVELS."
1006 call nemsio_getfilehead(gfile, iret=iret, dimz=lev_input)
1007 if (iret /= 0) call
error_handler(
"READING NUMBER OF VERTICAL LEVLES.", iret)
1009 levp1_input = lev_input + 1
1011 allocate(vcoord(levp1_input,3,2))
1013 print*,
"- READ VERTICAL COORDINATE INFO."
1014 call nemsio_getfilehead(gfile, iret=iret, vcoord=vcoord)
1015 if (iret /= 0) call
error_handler(
"READING VERTICAL COORDINATE INFO.", iret)
1023 if (localpet == 0)
then
1024 allocate(dummy(i_input*j_input))
1025 allocate(dummy2d(i_input,j_input))
1026 allocate(dummy3d(i_input,j_input,lev_input))
1029 allocate(dummy2d(0,0))
1030 allocate(dummy3d(0,0,0))
1038 if (localpet == 0)
then
1039 print*,
"- READ TEMPERATURE."
1041 vlevtyp =
"mid layer"
1042 do vlev = 1, lev_input
1043 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1044 if (iret /= 0) call
error_handler(
"READING TEMPERATURE RECORD.", iret)
1045 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1050 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
1051 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
1052 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1055 do n = 1, num_tracers_input
1057 if (localpet == 0)
then
1058 print*,
"- READ ", trim(tracers_input(n))
1059 vname = trim(tracers_input(n))
1060 vlevtyp =
"mid layer"
1061 do vlev = 1, lev_input
1062 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1063 if (iret /= 0) call
error_handler(
"READING TRACER RECORD.", iret)
1065 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1069 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(n))
1070 call esmf_fieldscatter(tracers_input_grid(n), dummy3d, rootpet=0, rc=rc)
1071 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1076 if (localpet == 0)
then
1077 print*,
"- READ U-WINDS."
1079 vlevtyp =
"mid layer"
1080 do vlev = 1, lev_input
1081 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1082 if (iret /= 0) call
error_handler(
"READING U-WIND RECORD.", iret)
1084 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1088 print*,
"- CALL FieldScatter FOR INPUT U-WIND."
1089 call esmf_fieldscatter(u_input_grid, dummy3d, rootpet=0, rc=rc)
1090 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1093 if (localpet == 0)
then
1094 print*,
"- READ V-WINDS."
1096 vlevtyp =
"mid layer"
1097 do vlev = 1, lev_input
1098 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1099 if (iret /= 0) call
error_handler(
"READING V-WIND RECORD.", iret)
1101 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1105 print*,
"- CALL FieldScatter FOR INPUT V-WIND."
1106 call esmf_fieldscatter(v_input_grid, dummy3d, rootpet=0, rc=rc)
1107 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1115 if (localpet == 0)
then
1116 print*,
"- NO VERTICAL VELOCITY RECORD. SET TO ZERO."
1120 print*,
"- CALL FieldScatter FOR INPUT DZDT."
1121 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
1122 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1125 if (localpet == 0)
then
1126 print*,
"- READ HGT."
1130 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1131 if (iret /= 0) call
error_handler(
"READING HGT RECORD.", iret)
1133 dummy2d = reshape(dummy, (/i_input,j_input/))
1136 print*,
"- CALL FieldScatter FOR TERRAIN."
1137 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
1138 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1141 if (localpet == 0)
then
1142 print*,
"- READ PRES."
1146 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1147 if (iret /= 0) call
error_handler(
"READING PRES RECORD.", iret)
1149 dummy2d = reshape(dummy, (/i_input,j_input/))
1152 print*,
"- CALL FieldScatter FOR SURFACE PRESSURE."
1153 call esmf_fieldscatter(ps_input_grid, dummy2d, rootpet=0, rc=rc)
1154 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1157 call nemsio_close(gfile)
1159 deallocate(dummy, dummy2d, dummy3d)
1171 print*,
"- COMPUTE 3-D PRESSURE."
1173 print*,
"- CALL FieldGet FOR 3-D PRES."
1175 call esmf_fieldget(pres_input_grid, &
1176 computationallbound=clb, &
1177 computationalubound=cub, &
1178 farrayptr=pptr, rc=rc)
1179 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1182 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
1184 call esmf_fieldget(ps_input_grid, &
1185 farrayptr=psptr, rc=rc)
1186 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1193 allocate(pi(clb(1):cub(1),clb(2):cub(2),1:levp1_input))
1198 do i= clb(1), cub(1)
1199 do j= clb(2), cub(2)
1200 pi(i,j,k) = ak + bk*psptr(i,j)
1212 do i= clb(1), cub(1)
1213 do j= clb(2), cub(2)
1214 pptr(i,j,k) = (pi(i,j,k)+pi(i,j,k+1))/2.0
1231 integer,
intent(in) :: localpet
1233 character(len=300) :: the_file
1234 character(len=20) :: vlevtyp, vname
1236 integer :: i, j, k, n
1237 integer :: rc, clb(3), cub(3)
1238 integer(nemsio_intkind) :: vlev, iret
1240 real(nemsio_realkind),
allocatable :: vcoord(:,:,:)
1241 real(nemsio_realkind),
allocatable :: dummy(:)
1242 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
1243 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
1244 real(esmf_kind_r8),
pointer :: presptr(:,:,:), psptr(:,:)
1245 real(esmf_kind_r8),
pointer :: dpresptr(:,:,:)
1246 real(esmf_kind_r8),
allocatable :: pres_interface(:)
1248 type(nemsio_gfile
) :: gfile
1250 the_file = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
1252 print*,
"- READ ATMOS DATA FROM GAUSSIAN NEMSIO FILE: ", trim(the_file)
1254 print*,
"- OPEN FILE."
1255 call nemsio_open(gfile, the_file,
"read", iret=iret)
1256 if (iret /= 0) call
error_handler(
"OPENING GAUSSIAN NEMSIO ATM FILE.", iret)
1258 print*,
"- READ NUMBER OF VERTICAL LEVELS."
1259 call nemsio_getfilehead(gfile, iret=iret, dimz=lev_input)
1260 if (iret /= 0) call
error_handler(
"READING NUMBER OF VERTICAL LEVLES.", iret)
1262 levp1_input = lev_input + 1
1264 allocate(vcoord(levp1_input,3,2))
1266 print*,
"- READ VERTICAL COORDINATE INFO."
1267 call nemsio_getfilehead(gfile, iret=iret, vcoord=vcoord)
1268 if (iret /= 0) call
error_handler(
"READING VERTICAL COORDINATE INFO.", iret)
1276 print*,
"- CALL FieldCreate FOR INPUT DPRES."
1277 dpres_input_grid = esmf_fieldcreate(input_grid, &
1278 typekind=esmf_typekind_r8, &
1279 staggerloc=esmf_staggerloc_center, &
1280 ungriddedlbound=(/1/), &
1281 ungriddedubound=(/lev_input/), rc=rc)
1282 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1285 if (localpet == 0)
then
1286 allocate(dummy(i_input*j_input))
1287 allocate(dummy2d(i_input,j_input))
1288 allocate(dummy3d(i_input,j_input,lev_input))
1291 allocate(dummy2d(0,0))
1292 allocate(dummy3d(0,0,0))
1300 if (localpet == 0)
then
1301 print*,
"- READ TEMPERATURE."
1303 vlevtyp =
"mid layer"
1304 do vlev = 1, lev_input
1305 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1306 if (iret /= 0) call
error_handler(
"READING TEMPERATURE RECORD.", iret)
1307 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1308 print*,
'temp check after read ',vlev, dummy3d(1,1,vlev)
1312 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
1313 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
1314 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1317 do n = 1, num_tracers_input
1319 if (localpet == 0)
then
1320 print*,
"- READ ", trim(tracers_input(n))
1321 vname = trim(tracers_input(n))
1322 vlevtyp =
"mid layer"
1323 do vlev = 1, lev_input
1324 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1325 if (iret /= 0) call
error_handler(
"READING TRACER RECORD.", iret)
1326 print*,
'tracer ',vlev, maxval(dummy),minval(dummy)
1327 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1331 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(n))
1332 call esmf_fieldscatter(tracers_input_grid(n), dummy3d, rootpet=0, rc=rc)
1333 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1338 if (localpet == 0)
then
1339 print*,
"- READ U-WINDS."
1341 vlevtyp =
"mid layer"
1342 do vlev = 1, lev_input
1343 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1344 if (iret /= 0) call
error_handler(
"READING U-WIND RECORD.", iret)
1345 print*,
'ugrd ',vlev, maxval(dummy),minval(dummy)
1346 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1350 print*,
"- CALL FieldScatter FOR INPUT U-WIND."
1351 call esmf_fieldscatter(u_input_grid, dummy3d, rootpet=0, rc=rc)
1352 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1355 if (localpet == 0)
then
1356 print*,
"- READ V-WINDS."
1358 vlevtyp =
"mid layer"
1359 do vlev = 1, lev_input
1360 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1361 if (iret /= 0) call
error_handler(
"READING V-WIND RECORD.", iret)
1362 print*,
'vgrd ',vlev, maxval(dummy),minval(dummy)
1363 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1367 print*,
"- CALL FieldScatter FOR INPUT V-WIND."
1368 call esmf_fieldscatter(v_input_grid, dummy3d, rootpet=0, rc=rc)
1369 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1372 if (localpet == 0)
then
1373 print*,
"- READ DPRES."
1375 vlevtyp =
"mid layer"
1376 do vlev = 1, lev_input
1377 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1378 if (iret /= 0) call
error_handler(
"READING DPRES RECORD.", iret)
1379 print*,
'dpres ',vlev, maxval(dummy),minval(dummy)
1380 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1384 print*,
"- CALL FieldScatter FOR INPUT DPRES."
1385 call esmf_fieldscatter(dpres_input_grid, dummy3d, rootpet=0, rc=rc)
1386 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1389 if (localpet == 0)
then
1390 print*,
"- READ DZDT."
1392 vlevtyp =
"mid layer"
1393 do vlev = 1, lev_input
1394 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1395 if (iret /= 0) call
error_handler(
"READING DZDT RECORD.", iret)
1396 print*,
'dzdt ',vlev, maxval(dummy),minval(dummy)
1397 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1401 print*,
"- CALL FieldScatter FOR INPUT DZDT."
1402 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
1403 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1406 if (localpet == 0)
then
1407 print*,
"- READ HGT."
1411 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1412 if (iret /= 0) call
error_handler(
"READING HGT RECORD.", iret)
1413 print*,
'hgt ',vlev, maxval(dummy),minval(dummy)
1414 dummy2d = reshape(dummy, (/i_input,j_input/))
1417 print*,
"- CALL FieldScatter FOR TERRAIN."
1418 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
1419 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1422 call nemsio_close(gfile)
1424 deallocate(dummy, dummy2d, dummy3d)
1440 print*,
"- COMPUTE 3-D PRESSURE."
1442 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
1444 call esmf_fieldget(dpres_input_grid, &
1445 computationallbound=clb, &
1446 computationalubound=cub, &
1447 farrayptr=dpresptr, rc=rc)
1448 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1451 print*,
"- CALL FieldGet FOR 3-D PRESSURE."
1453 call esmf_fieldget(pres_input_grid, &
1454 farrayptr=presptr, rc=rc)
1455 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1458 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
1460 call esmf_fieldget(ps_input_grid, &
1461 farrayptr=psptr, rc=rc)
1462 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1465 allocate(pres_interface(levp1_input))
1467 if (localpet == 0)
then
1468 do k = clb(3), cub(3)
1469 print*,
'dpres is ',cub(1),cub(2),k, dpresptr(cub(1),cub(2),k)
1473 do i = clb(1), cub(1)
1474 do j = clb(2), cub(2)
1475 pres_interface(levp1_input) = vcoord(levp1_input,1,1)
1476 do k = lev_input, 1, -1
1477 pres_interface(k) = pres_interface(k+1) + dpresptr(i,j,k)
1479 psptr(i,j) = pres_interface(1)
1481 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
1488 if (localpet == 0)
then
1489 print*,
'psfc is ',clb(1),clb(2),psptr(clb(1),clb(2))
1490 print*,
'pres is ',clb(1),clb(2),presptr(clb(1),clb(2),:)
1493 print*,
'pres check 1',localpet,maxval(presptr(:,:,1)),minval(presptr(:,:,1))
1494 print*,
'pres check lev',localpet,maxval(presptr(:,:,lev_input)),minval(presptr(:,:,lev_input))
1496 deallocate(pres_interface)
1498 call esmf_fielddestroy(dpres_input_grid, rc=rc)
1514 integer,
intent(in) :: localpet
1516 character(len=500) :: tilefile
1519 integer :: clb(3), cub(3)
1520 integer :: rc, tile, ncid, id_var
1521 integer :: error, id_dim
1523 real(esmf_kind_r8),
allocatable :: ak(:)
1524 real(esmf_kind_r8),
pointer :: presptr(:,:,:), psptr(:,:)
1525 real(esmf_kind_r8),
pointer :: dpresptr(:,:,:)
1526 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
1527 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
1528 real(esmf_kind_r8),
allocatable :: pres_interface(:)
1534 tilefile = trim(data_dir_input_grid) //
"/" // trim(atm_core_files_input_grid(7))
1535 print*,
"- READ ATM VERTICAL LEVELS FROM: ", trim(tilefile)
1536 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1537 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1539 error=nf90_inq_dimid(ncid,
'xaxis_1', id_dim)
1540 call
netcdf_err(error,
'reading xaxis_1 id' )
1541 error=nf90_inquire_dimension(ncid,id_dim,len=levp1_input)
1542 call
netcdf_err(error,
'reading xaxis_1 value' )
1544 lev_input = levp1_input - 1
1546 allocate(ak(levp1_input))
1548 error=nf90_inq_varid(ncid,
'ak', id_var)
1550 error=nf90_get_var(ncid, id_var, ak)
1553 error = nf90_close(ncid)
1561 print*,
"- CALL FieldCreate FOR INPUT GRID DELTA PRESSURE."
1562 dpres_input_grid = esmf_fieldcreate(input_grid, &
1563 typekind=esmf_typekind_r8, &
1564 staggerloc=esmf_staggerloc_center, &
1565 ungriddedlbound=(/1/), &
1566 ungriddedubound=(/lev_input/), rc=rc)
1567 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1570 if (localpet < num_tiles_input_grid)
then
1571 allocate(data_one_tile_3d(i_input,j_input,lev_input))
1572 allocate(data_one_tile(i_input,j_input))
1574 allocate(data_one_tile_3d(0,0,0))
1575 allocate(data_one_tile(0,0))
1578 if (localpet < num_tiles_input_grid)
then
1580 tilefile= trim(data_dir_input_grid) //
"/" // trim(atm_core_files_input_grid(tile))
1581 print*,
"- READ ATMOSPHERIC CORE FILE: ", trim(tilefile)
1582 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1583 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1586 if (localpet < num_tiles_input_grid)
then
1587 error=nf90_inq_varid(ncid,
'phis', id_var)
1589 error=nf90_get_var(ncid, id_var, data_one_tile)
1591 data_one_tile = data_one_tile / 9.806_8
1594 do tile = 1, num_tiles_input_grid
1595 print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN for tile ",tile
1596 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=tile-1, tile=tile, rc=rc)
1597 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1601 if (localpet < num_tiles_input_grid)
then
1609 data_one_tile_3d = 0.0_8
1612 do tile = 1, num_tiles_input_grid
1613 print*,
"- CALL FieldScatter FOR INPUT GRID VERTICAL VELOCITY for tile ",tile
1614 call esmf_fieldscatter(dzdt_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1615 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1619 if (localpet < num_tiles_input_grid)
then
1620 error=nf90_inq_varid(ncid,
'T', id_var)
1622 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1624 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1627 do tile = 1, num_tiles_input_grid
1628 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
1629 call esmf_fieldscatter(temp_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1630 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1634 if (localpet < num_tiles_input_grid)
then
1635 error=nf90_inq_varid(ncid,
'delp', id_var)
1637 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1639 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1642 do tile = 1, num_tiles_input_grid
1643 print*,
"- CALL FieldScatter FOR INPUT DELTA PRESSURE."
1644 call esmf_fieldscatter(dpres_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1645 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1649 if (localpet < num_tiles_input_grid)
then
1650 error=nf90_inq_varid(ncid,
'ua', id_var)
1652 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1654 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1657 do tile = 1, num_tiles_input_grid
1658 print*,
"- CALL FieldScatter FOR INPUT GRID U."
1659 call esmf_fieldscatter(u_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1660 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1664 if (localpet < num_tiles_input_grid)
then
1665 error=nf90_inq_varid(ncid,
'va', id_var)
1667 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1669 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1672 do tile = 1, num_tiles_input_grid
1673 print*,
"- CALL FieldScatter FOR INPUT GRID V."
1674 call esmf_fieldscatter(v_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1675 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1679 if (localpet < num_tiles_input_grid) error = nf90_close(ncid)
1681 if (localpet < num_tiles_input_grid)
then
1683 tilefile= trim(data_dir_input_grid) //
"/" // trim(atm_tracer_files_input_grid(tile))
1684 print*,
"- READ ATMOSPHERIC TRACER FILE: ", trim(tilefile)
1685 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1686 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1689 do i = 1, num_tracers_input
1691 if (localpet < num_tiles_input_grid)
then
1692 error=nf90_inq_varid(ncid, tracers_input(i), id_var)
1694 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1696 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1699 do tile = 1, num_tiles_input_grid
1700 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(i))
1701 call esmf_fieldscatter(tracers_input_grid(i), data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1702 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1708 if (localpet < num_tiles_input_grid) error=nf90_close(ncid)
1720 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
1721 call esmf_fieldget(ps_input_grid, &
1722 farrayptr=psptr, rc=rc)
1723 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1726 print*,
"- CALL FieldGet FOR PRESSURE."
1727 call esmf_fieldget(pres_input_grid, &
1728 computationallbound=clb, &
1729 computationalubound=cub, &
1730 farrayptr=presptr, rc=rc)
1731 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1734 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
1735 call esmf_fieldget(dpres_input_grid, &
1736 farrayptr=dpresptr, rc=rc)
1737 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1740 allocate(pres_interface(levp1_input))
1742 do i = clb(1), cub(1)
1743 do j = clb(2), cub(2)
1744 pres_interface(levp1_input) = ak(1)
1745 do k = (levp1_input-1), 1, -1
1746 pres_interface(k) = pres_interface(k+1) + dpresptr(i,j,k)
1749 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
1751 psptr(i,j) = pres_interface(1)
1756 deallocate(pres_interface)
1758 call esmf_fielddestroy(dpres_input_grid, rc=rc)
1760 deallocate(data_one_tile_3d, data_one_tile)
1775 integer,
intent(in) :: localpet
1777 character(len=500) :: tilefile
1779 integer :: start(3), count(3), iscnt
1780 integer :: error, ncid, num_tracers_file
1781 integer :: id_dim, idim_input, jdim_input
1782 integer :: id_var, rc, nprocs, max_procs
1783 integer :: kdim, remainder, myrank, i, j, k, n
1784 integer :: clb(3), cub(3)
1785 integer,
allocatable :: kcount(:), startk(:), displ(:)
1786 integer,
allocatable :: ircnt(:)
1788 real(esmf_kind_r8),
allocatable :: phalf(:)
1789 real(esmf_kind_r8),
allocatable :: pres_interface(:)
1790 real(kind=4),
allocatable :: dummy3d(:,:,:)
1791 real(kind=4),
allocatable :: dummy3dall(:,:,:)
1792 real(esmf_kind_r8),
allocatable :: dummy3dflip(:,:,:)
1793 real(esmf_kind_r8),
allocatable :: dummy(:,:)
1794 real(esmf_kind_r8),
pointer :: presptr(:,:,:), dpresptr(:,:,:)
1795 real(esmf_kind_r8),
pointer :: psptr(:,:)
1797 print*,
"- READ INPUT ATMOS DATA FROM GAUSSIAN NETCDF FILE."
1799 tilefile = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
1800 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1801 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1803 error=nf90_inq_dimid(ncid,
'grid_xt', id_dim)
1804 call
netcdf_err(error,
'reading grid_xt id' )
1805 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
1806 call
netcdf_err(error,
'reading grid_xt value' )
1808 error=nf90_inq_dimid(ncid,
'grid_yt', id_dim)
1809 call
netcdf_err(error,
'reading grid_yt id' )
1810 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
1811 call
netcdf_err(error,
'reading grid_yt value' )
1813 if (idim_input /= i_input .or. jdim_input /= j_input)
then
1814 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 2)
1817 error=nf90_inq_dimid(ncid,
'pfull', id_dim)
1819 error=nf90_inquire_dimension(ncid,id_dim,len=lev_input)
1820 call
netcdf_err(error,
'reading pfull value' )
1822 error=nf90_inq_dimid(ncid,
'phalf', id_dim)
1824 error=nf90_inquire_dimension(ncid,id_dim,len=levp1_input)
1825 call
netcdf_err(error,
'reading phalf value' )
1826 allocate(phalf(levp1_input))
1827 error=nf90_inq_varid(ncid,
'phalf', id_var)
1828 call
netcdf_err(error,
'getting phalf varid' )
1829 error=nf90_get_var(ncid, id_var, phalf)
1830 call
netcdf_err(error,
'reading phalf varid' )
1832 error=nf90_get_att(ncid, nf90_global,
'ncnsto', num_tracers_file)
1833 call
netcdf_err(error,
'reading ntracer value' )
1835 call mpi_comm_size(mpi_comm_world, nprocs, error)
1836 print*,
'- Running with ', nprocs,
' processors'
1838 call mpi_comm_rank(mpi_comm_world, myrank, error)
1839 print*,
'- myrank/localpet is ',myrank,localpet
1842 if (nprocs > lev_input)
then
1843 max_procs = lev_input
1846 kdim = lev_input / max_procs
1847 remainder = lev_input - (max_procs*kdim)
1849 allocate(kcount(0:nprocs-1))
1851 allocate(startk(0:nprocs-1))
1853 allocate(displ(0:nprocs-1))
1855 allocate(ircnt(0:nprocs-1))
1858 do k = 0, max_procs-2
1861 kcount(max_procs-1) = kdim + remainder
1864 do k = 1, max_procs-1
1865 startk(k) = startk(k-1) + kcount(k-1)
1868 ircnt(:) = idim_input * jdim_input * kcount(:)
1871 do k = 1, max_procs-1
1872 displ(k) = displ(k-1) + ircnt(k-1)
1875 iscnt=idim_input*jdim_input*kcount(myrank)
1879 if (myrank <= max_procs-1)
then
1880 allocate(dummy3d(idim_input,jdim_input,kcount(myrank)))
1882 allocate(dummy3d(0,0,0))
1885 if (myrank == 0)
then
1886 allocate(dummy3dall(idim_input,jdim_input,lev_input))
1888 allocate(dummy3dflip(idim_input,jdim_input,lev_input))
1890 allocate(dummy(idim_input,jdim_input))
1893 allocate(dummy3dall(0,0,0))
1894 allocate(dummy3dflip(0,0,0))
1895 allocate(dummy(0,0))
1904 print*,
"- CALL FieldCreate FOR INPUT GRID DELTA PRESSURE."
1905 dpres_input_grid = esmf_fieldcreate(input_grid, &
1906 typekind=esmf_typekind_r8, &
1907 staggerloc=esmf_staggerloc_center, &
1908 ungriddedlbound=(/1/), &
1909 ungriddedubound=(/lev_input/), rc=rc)
1910 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1915 if (myrank <= max_procs-1)
then
1916 start = (/1,1,startk(myrank)/)
1917 count = (/idim_input,jdim_input,kcount(myrank)/)
1918 error=nf90_inq_varid(ncid,
'tmp', id_var)
1919 call
netcdf_err(error,
'reading tmp field id' )
1920 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
1924 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
1925 dummy3dall, ircnt, displ, mpi_real, &
1926 0, mpi_comm_world, error)
1927 if (error /= 0) call
error_handler(
"IN mpi_gatherv of temperature", error)
1929 if (myrank == 0)
then
1930 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
1933 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE "
1934 call esmf_fieldscatter(temp_input_grid, dummy3dflip, rootpet=0, rc=rc)
1935 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1940 if (myrank <= max_procs-1)
then
1941 error=nf90_inq_varid(ncid,
'dpres', id_var)
1942 call
netcdf_err(error,
'reading dpres field id' )
1943 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
1944 call
netcdf_err(error,
'reading dpres field' )
1947 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
1948 dummy3dall, ircnt, displ, mpi_real, &
1949 0, mpi_comm_world, error)
1950 if (error /= 0) call
error_handler(
"IN mpi_gatherv of dpres", error)
1952 if (myrank == 0)
then
1953 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
1956 print*,
"- CALL FieldScatter FOR INPUT GRID DPRES "
1957 call esmf_fieldscatter(dpres_input_grid, dummy3dflip, rootpet=0, rc=rc)
1958 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1963 if (myrank <= max_procs-1)
then
1964 error=nf90_inq_varid(ncid,
'ugrd', id_var)
1965 call
netcdf_err(error,
'reading ugrd field id' )
1966 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
1967 call
netcdf_err(error,
'reading ugrd field' )
1970 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
1971 dummy3dall, ircnt, displ, mpi_real, &
1972 0, mpi_comm_world, error)
1973 if (error /= 0) call
error_handler(
"IN mpi_gatherv of ugrd", error)
1975 if (myrank == 0)
then
1976 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
1979 print*,
"- CALL FieldScatter FOR INPUT GRID UGRD "
1980 call esmf_fieldscatter(u_input_grid, dummy3dflip, rootpet=0, rc=rc)
1981 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1986 if (myrank <= max_procs-1)
then
1987 error=nf90_inq_varid(ncid,
'vgrd', id_var)
1988 call
netcdf_err(error,
'reading vgrd field id' )
1989 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
1990 call
netcdf_err(error,
'reading vgrd field' )
1993 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
1994 dummy3dall, ircnt, displ, mpi_real, &
1995 0, mpi_comm_world, error)
1996 if (error /= 0) call
error_handler(
"IN mpi_gatherv of vgrd", error)
1998 if (myrank == 0)
then
1999 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
2002 print*,
"- CALL FieldScatter FOR INPUT GRID VGRD "
2003 call esmf_fieldscatter(v_input_grid, dummy3dflip, rootpet=0, rc=rc)
2004 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2009 do n = 1, num_tracers_input
2011 if (myrank <= max_procs-1)
then
2012 error=nf90_inq_varid(ncid, tracers_input(n), id_var)
2013 call
netcdf_err(error,
'reading tracer field id' )
2014 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
2015 call
netcdf_err(error,
'reading tracer field' )
2018 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
2019 dummy3dall, ircnt, displ, mpi_real, &
2020 0, mpi_comm_world, error)
2021 if (error /= 0) call
error_handler(
"IN mpi_gatherv of tracer", error)
2023 if (myrank == 0)
then
2024 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
2025 where(dummy3dflip < 0.0) dummy3dflip = 0.0
2028 print*,
"- CALL FieldScatter FOR INPUT GRID ", tracers_input(n)
2029 call esmf_fieldscatter(tracers_input_grid(n), dummy3dflip, rootpet=0, rc=rc)
2030 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2037 if (myrank == 0)
then
2041 print*,
"- CALL FieldScatter FOR INPUT GRID DZDT"
2042 call esmf_fieldscatter(dzdt_input_grid, dummy3dflip, rootpet=0, rc=rc)
2043 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2046 deallocate(dummy3dflip, dummy3dall, dummy3d)
2051 print*,
"- READ TERRAIN."
2052 error=nf90_inq_varid(ncid,
'hgtsfc', id_var)
2053 call
netcdf_err(error,
'reading hgtsfc field id' )
2054 error=nf90_get_var(ncid, id_var, dummy)
2055 call
netcdf_err(error,
'reading hgtsfc field' )
2058 print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN."
2059 call esmf_fieldscatter(terrain_input_grid, dummy, rootpet=0, rc=rc)
2060 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2066 print*,
"- READ SURFACE P."
2067 error=nf90_inq_varid(ncid,
'pressfc', id_var)
2068 call
netcdf_err(error,
'reading pressfc field id' )
2069 error=nf90_get_var(ncid, id_var, dummy)
2070 call
netcdf_err(error,
'reading pressfc field' )
2073 print*,
"- CALL FieldScatter FOR INPUT GRID SURFACE P."
2074 call esmf_fieldscatter(ps_input_grid, dummy, rootpet=0, rc=rc)
2075 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2078 deallocate(kcount, startk, displ, ircnt, dummy)
2090 print*,
"- CALL FieldGet FOR PRESSURE."
2091 call esmf_fieldget(pres_input_grid, &
2092 computationallbound=clb, &
2093 computationalubound=cub, &
2094 farrayptr=presptr, rc=rc)
2095 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2098 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
2099 call esmf_fieldget(dpres_input_grid, &
2100 farrayptr=dpresptr, rc=rc)
2101 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2104 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
2105 call esmf_fieldget(ps_input_grid, &
2106 farrayptr=psptr, rc=rc)
2107 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2110 allocate(pres_interface(levp1_input))
2125 do i = clb(1), cub(1)
2126 do j = clb(2), cub(2)
2127 pres_interface(levp1_input) = phalf(1) * 100.0_8
2128 do k = lev_input, 1, -1
2129 pres_interface(k) = pres_interface(k+1) + dpresptr(i,j,k)
2131 psptr(i,j) = pres_interface(1)
2133 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
2138 deallocate(pres_interface, phalf)
2140 call esmf_fielddestroy(dpres_input_grid, rc=rc)
2159 integer,
intent(in) :: localpet
2161 character(len=500) :: tilefile
2163 integer :: error, ncid, rc, tile
2164 integer :: id_dim, idim_input, jdim_input
2165 integer :: id_var, i, j, k, n
2166 integer :: clb(3), cub(3), num_tracers_file
2168 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
2169 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
2170 real(esmf_kind_r8),
pointer :: presptr(:,:,:), dpresptr(:,:,:)
2171 real(esmf_kind_r8),
pointer :: psptr(:,:)
2172 real(esmf_kind_r8),
allocatable :: pres_interface(:), phalf(:)
2174 print*,
"- READ INPUT ATMOS DATA FROM TILED HISTORY FILES."
2176 tilefile = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
2177 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
2178 call
netcdf_err(error,
'opening: '//trim(tilefile) )
2180 error=nf90_inq_dimid(ncid,
'grid_xt', id_dim)
2181 call
netcdf_err(error,
'reading grid_xt id' )
2182 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
2183 call
netcdf_err(error,
'reading grid_xt value' )
2185 error=nf90_inq_dimid(ncid,
'grid_yt', id_dim)
2186 call
netcdf_err(error,
'reading grid_yt id' )
2187 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
2188 call
netcdf_err(error,
'reading grid_yt value' )
2190 if (idim_input /= i_input .or. jdim_input /= j_input)
then
2191 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 2)
2194 error=nf90_inq_dimid(ncid,
'pfull', id_dim)
2196 error=nf90_inquire_dimension(ncid,id_dim,len=lev_input)
2197 call
netcdf_err(error,
'reading pfull value' )
2199 error=nf90_inq_dimid(ncid,
'phalf', id_dim)
2201 error=nf90_inquire_dimension(ncid,id_dim,len=levp1_input)
2202 call
netcdf_err(error,
'reading phalf value' )
2203 allocate(phalf(levp1_input))
2204 error=nf90_inq_varid(ncid,
'phalf', id_var)
2205 call
netcdf_err(error,
'getting phalf varid' )
2206 error=nf90_get_var(ncid, id_var, phalf)
2207 call
netcdf_err(error,
'reading phalf varid' )
2209 error=nf90_get_att(ncid, nf90_global,
'ncnsto', num_tracers_file)
2210 call
netcdf_err(error,
'reading ntracer value' )
2212 error = nf90_close(ncid)
2214 print*,
'- FILE HAS ', num_tracers_file,
' TRACERS.'
2215 print*,
'- WILL PROCESS ', num_tracers_input,
' TRACERS.'
2223 print*,
"- CALL FieldCreate FOR INPUT GRID DELTA PRESSURE."
2224 dpres_input_grid = esmf_fieldcreate(input_grid, &
2225 typekind=esmf_typekind_r8, &
2226 staggerloc=esmf_staggerloc_center, &
2227 ungriddedlbound=(/1/), &
2228 ungriddedubound=(/lev_input/), rc=rc)
2229 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2232 if (localpet < num_tiles_input_grid)
then
2233 allocate(data_one_tile(i_input,j_input))
2234 allocate(data_one_tile_3d(i_input,j_input,lev_input))
2236 allocate(data_one_tile(0,0))
2237 allocate(data_one_tile_3d(0,0,0))
2240 if (localpet < num_tiles_input_grid)
then
2242 tilefile= trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(tile))
2243 print*,
"- READ ATMOSPHERIC DATA FROM: ", trim(tilefile)
2244 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
2245 call
netcdf_err(error,
'opening: '//trim(tilefile) )
2248 if (localpet < num_tiles_input_grid)
then
2258 data_one_tile_3d = 0.0_8
2261 do tile = 1, num_tiles_input_grid
2262 print*,
"- CALL FieldScatter FOR INPUT GRID VERTICAL VELOCITY."
2263 call esmf_fieldscatter(dzdt_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2264 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2268 do n = 1, num_tracers_input
2270 if (localpet < num_tiles_input_grid)
then
2271 print*,
"- READ ", trim(tracers_input(n))
2272 error=nf90_inq_varid(ncid, tracers_input(n), id_var)
2274 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2276 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2279 do tile = 1, num_tiles_input_grid
2280 print*,
"- CALL FieldScatter FOR INPUT GRID TRACER ", trim(tracers_input(n))
2281 call esmf_fieldscatter(tracers_input_grid(n), data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2282 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2288 if (localpet < num_tiles_input_grid)
then
2289 print*,
"- READ TEMPERATURE."
2290 error=nf90_inq_varid(ncid,
'tmp', id_var)
2292 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2294 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2297 do tile = 1, num_tiles_input_grid
2298 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
2299 call esmf_fieldscatter(temp_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2300 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2304 if (localpet < num_tiles_input_grid)
then
2305 print*,
"- READ U-WIND."
2306 error=nf90_inq_varid(ncid,
'ugrd', id_var)
2308 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2310 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2313 do tile = 1, num_tiles_input_grid
2314 print*,
"- CALL FieldScatter FOR INPUT GRID U."
2315 call esmf_fieldscatter(u_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2316 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2320 if (localpet < num_tiles_input_grid)
then
2321 print*,
"- READ V-WIND."
2322 error=nf90_inq_varid(ncid,
'vgrd', id_var)
2324 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2326 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2329 do tile = 1, num_tiles_input_grid
2330 print*,
"- CALL FieldScatter FOR INPUT GRID V."
2331 call esmf_fieldscatter(v_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2332 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2336 if (localpet < num_tiles_input_grid)
then
2337 print*,
"- READ SURFACE PRESSURE."
2338 error=nf90_inq_varid(ncid,
'pressfc', id_var)
2340 error=nf90_get_var(ncid, id_var, data_one_tile)
2344 do tile = 1, num_tiles_input_grid
2345 print*,
"- CALL FieldScatter FOR INPUT GRID SURFACE PRESSURE."
2346 call esmf_fieldscatter(ps_input_grid, data_one_tile, rootpet=tile-1, tile=tile, rc=rc)
2347 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2351 if (localpet < num_tiles_input_grid)
then
2352 print*,
"- READ TERRAIN."
2353 error=nf90_inq_varid(ncid,
'hgtsfc', id_var)
2355 error=nf90_get_var(ncid, id_var, data_one_tile)
2359 do tile = 1, num_tiles_input_grid
2360 print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN."
2361 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=tile-1, tile=tile, rc=rc)
2362 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2366 if (localpet < num_tiles_input_grid)
then
2367 print*,
"- READ DELTA PRESSURE."
2368 error=nf90_inq_varid(ncid,
'dpres', id_var)
2370 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2372 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2375 do tile = 1, num_tiles_input_grid
2376 print*,
"- CALL FieldScatter FOR INPUT DELTA PRESSURE."
2377 call esmf_fieldscatter(dpres_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2378 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2382 if (localpet < num_tiles_input_grid) error = nf90_close(ncid)
2384 deallocate(data_one_tile_3d, data_one_tile)
2396 print*,
"- CALL FieldGet FOR PRESSURE."
2397 call esmf_fieldget(pres_input_grid, &
2398 computationallbound=clb, &
2399 computationalubound=cub, &
2400 farrayptr=presptr, rc=rc)
2401 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2404 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
2405 call esmf_fieldget(dpres_input_grid, &
2406 farrayptr=dpresptr, rc=rc)
2407 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2410 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
2411 call esmf_fieldget(ps_input_grid, &
2412 farrayptr=psptr, rc=rc)
2413 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2416 allocate(pres_interface(levp1_input))
2422 do i = clb(1), cub(1)
2423 do j = clb(2), cub(2)
2424 pres_interface(1) = psptr(i,j)
2425 do k = 2, levp1_input
2426 pres_interface(k) = pres_interface(k-1) - dpresptr(i,j,k-1)
2429 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
2434 deallocate(pres_interface, phalf)
2436 call esmf_fielddestroy(dpres_input_grid, rc=rc)
2452 integer,
intent(in) :: localpet
2454 integer,
parameter :: ntrac_max=14
2456 character(len=300) :: the_file
2457 character(len=20) :: vlevtyp, vname, lvl_str,lvl_str_space, &
2458 trac_names_grib_1(ntrac_max), &
2459 trac_names_grib_2(ntrac_max), &
2460 trac_names_vmap(ntrac_max), &
2461 tracers_input_grib_1(num_tracers_input), &
2462 tracers_input_grib_2(num_tracers_input), &
2464 method, tracers_input_vmap(num_tracers_input), &
2465 tracers_default(ntrac_max), vname2
2466 character (len=500) :: metadata
2468 integer :: i, j, k, n, lvl_str_space_len
2469 integer :: rc, clb(3), cub(3)
2470 integer :: vlev, iret,varnum
2475 logical :: conv_omega=.false., &
2479 real(esmf_kind_r8),
allocatable :: rlevs(:)
2480 real(esmf_kind_r4),
allocatable :: dummy2d(:,:)
2481 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:), dummy2d_8(:,:),&
2482 u_tmp_3d(:,:,:), v_tmp_3d(:,:,:)
2483 real(esmf_kind_r8),
pointer :: presptr(:,:,:), psptr(:,:),tptr(:,:,:), &
2484 qptr(:,:,:), wptr(:,:,:), &
2485 uptr(:,:,:), vptr(:,:,:)
2486 real(esmf_kind_r4) :: value
2487 real(esmf_kind_r8),
parameter :: p0 = 100000.0
2493 trac_names_grib_1 = (/
":var0_2",
":var0_2",
":var0_2",
":var0_2",
":var0_2",
":var0_2", \
2494 ":var0_2",
":var0_2",
":var0_2",
":var0_2",
":var0_2",
":var0_2", \
2495 ":var0_2",
":var0_2"/)
2496 trac_names_grib_2 = (/
"_1_0: ",
"_1_22: ",
"_14_192:",
"_1_23: ",
"_1_24: ",
"_1_25: ", \
2497 "_1_32: ",
"_6_1: ",
"_6_29: ",
"_1_100: ",
"_6_28: ",
"_13_193:", \
2498 "_13_192:",
"_2_2: "/)
2499 trac_names_vmap = (/
"sphum ",
"liq_wat ",
"o3mr ",
"ice_wat ", &
2500 "rainwat ",
"snowwat ",
"graupel ",
"cld_amt ",
"ice_nc ", &
2501 "rain_nc ",
"water_nc",
"liq_aero",
"ice_aero", &
2503 tracers_default = (/
"sphum ",
"liq_wat ",
"o3mr ",
"ice_wat ", &
2504 "rainwat ",
"snowwat ",
"graupel ",
"cld_amt ",
"ice_nc ", &
2505 "rain_nc ",
"water_nc",
"liq_aero",
"ice_aero", &
2508 the_file = trim(data_dir_input_grid) //
"/" // trim(grib2_file_input_grid)
2510 print*,
"- READ ATMOS DATA FROM GRIB2 FILE: ", trim(the_file)
2511 print*,
"- USE INVENTORY FILE ", inv_file
2513 print*,
"- OPEN FILE."
2514 inquire(file=the_file,exist=lret)
2515 if (.not.lret) call
error_handler(
"OPENING GRIB2 ATM FILE.", iret)
2517 print*,
"- READ VERTICAL COORDINATE."
2518 iret = grb2_inq(the_file,inv_file,
":var0_2",
"_0_0:",
":10 hybrid level:")
2522 lvl_str_space =
" mb:"
2523 lvl_str_space_len = 4
2525 iret = grb2_inq(the_file,inv_file,
":UGRD:",lvl_str_space)
2527 if (localpet == 0) print*,
"- DATA IS ON ", lev_input,
" ISOBARIC LEVELS."
2530 lvl_str_space =
" hybrid "
2531 lvl_str_space_len = 7
2533 iret = grb2_inq(the_file,inv_file,
":UGRD:",lvl_str_space,
" level:")
2534 if (iret < 0) call
error_handler(
"READING VERTICAL LEVEL TYPE.", iret)
2538 allocate(slevs(lev_input))
2539 allocate(rlevs(lev_input))
2540 levp1_input = lev_input + 1
2545 iret=grb2_inq(the_file,inv_file,
':UGRD:',trim(lvl_str),sequential=i-1,desc=metadata)
2546 if (iret.ne.1) call
error_handler(
" IN SEQUENTIAL FILE READ.", iret)
2548 j = index(metadata,
':UGRD:') + len(
':UGRD:')
2549 k = index(metadata,trim(lvl_str_space)) + len(trim(lvl_str_space))-1
2551 read(metadata(j:k),*) rlevs(i)
2553 slevs(i) = metadata(j-1:k)
2554 if (.not. isnative) rlevs(i) = rlevs(i) * 100.0
2555 if (localpet==0) print*,
"- LEVEL = ", slevs(i)
2562 if (.not. isnative)
then
2564 write(slevs(i),
"(F20.10)") rlevs(i)/100.0
2565 len_str = len_trim(slevs(i))
2567 do while (slevs(i)(len_str:len_str) .eq.
'0')
2568 slevs(i) = slevs(i)(:len_str-1)
2569 len_str = len_str - 1
2572 if (slevs(i)(len_str:len_str) .eq.
'.')
then
2573 slevs(i) = slevs(i)(:len_str-1)
2574 len_str = len_str - 1
2577 slevs(i) = trim(slevs(i))
2579 slevs(i) =
":"//trim(adjustl(slevs(i)))//
" mb:"
2580 if (localpet==0) print*,
"- LEVEL AFTER SORT = ",slevs(i)
2584 if (localpet == 0) print*,
"- FIND SPFH OR RH IN FILE"
2585 iret = grb2_inq(the_file,inv_file,trim(trac_names_grib_1(1)),trac_names_grib_2(1),lvl_str_space)
2588 iret = grb2_inq(the_file,inv_file,
':var0_2',
'_1_1:',lvl_str_space)
2589 if (iret <= 0) call
error_handler(
"READING ATMOSPHERIC WATER VAPOR VARIABLE.", iret)
2591 trac_names_grib_2(1)=
'_1_1:'
2592 if (localpet == 0) print*,
"- FILE CONTAINS RH."
2594 if (localpet == 0) print*,
"- FILE CONTAINS SPFH."
2597 if (localpet == 0) print*,
"- FIND ICMR, SCLIWC, OR CICE IN FILE"
2598 iret = grb2_inq(the_file,inv_file,trac_names_grib_1(4),trac_names_grib_2(4),lvl_str_space)
2601 vname = trac_names_vmap(4)
2602 print*,
"vname = ", vname
2603 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
2604 this_field_var_name=tmpstr,loc=varnum)
2605 iret = grb2_inq(the_file,inv_file,
':var0_2',
'_1_84:',lvl_str_space)
2607 iret = grb2_inq(the_file,inv_file,
':var0_2',
'_6_0:',lvl_str_space)
2608 if (iret <= 0 )
then
2611 trac_names_grib_2(4) =
'_6_0'
2612 if (localpet == 0) print*,
"- FILE CONTAINS CICE."
2615 trac_names_grib_2(4)=
'_1_84:'
2616 if (localpet == 0) print*,
"- FILE CONTAINS SCLIWC."
2619 if (localpet == 0) print*,
"- FILE CONTAINS ICMR."
2622 if (localpet == 0) print*,
"- FIND CLWMR or SCLLWC IN FILE"
2623 iret = grb2_inq(the_file,inv_file,trac_names_grib_1(5),trac_names_grib_2(5),lvl_str_space)
2626 vname = trac_names_vmap(5)
2627 print*,
"vname = ", vname
2628 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
2629 this_field_var_name=tmpstr,loc=varnum)
2630 iret = grb2_inq(the_file,inv_file,
':var0_2',
'_1_83:',lvl_str_space)
2633 elseif (iret <=0 .and. rc .ne. 1)
then
2636 trac_names_grib_2(4)=
'_1_83:'
2637 if (localpet == 0) print*,
"- FILE CONTAINS SCLLWC."
2640 if (localpet == 0) print*,
"- FILE CONTAINS CLWMR."
2643 print*,
"- COUNT NUMBER OF TRACERS TO BE READ IN BASED ON PHYSICS SUITE TABLE"
2644 do n = 1, num_tracers_input
2646 vname = tracers_input(n)
2648 i = maxloc(merge(1.,0.,trac_names_vmap == vname),dim=1)
2650 tracers_input_grib_1(n) = trac_names_grib_1(i)
2651 tracers_input_grib_2(n) = trac_names_grib_2(i)
2652 tracers_input_vmap(n)=trac_names_vmap(i)
2653 tracers(n)=tracers_default(i)
2657 if (localpet==0)
then
2658 print*,
"- NUMBER OF TRACERS IN THE INPUT FILE = ", num_tracers_input
2667 if (localpet == 0)
then
2668 allocate(dummy2d(i_input,j_input))
2669 allocate(dummy2d_8(i_input,j_input))
2670 allocate(dummy3d(i_input,j_input,lev_input))
2672 allocate(dummy2d(0,0))
2673 allocate(dummy2d_8(0,0))
2674 allocate(dummy3d(0,0,0))
2683 if (localpet == 0)
then
2684 print*,
"- READ TEMPERATURE."
2686 do vlev = 1, lev_input
2687 iret = grb2_inq(the_file,inv_file,vname,slevs(vlev),data2=dummy2d)
2689 call
error_handler(
"READING IN TEMPERATURE AT LEVEL "//trim(slevs(vlev)),iret)
2691 dummy3d(:,:,vlev) =
real(dummy2d,esmf_kind_r8)
2692 print*,
'temp check after read ',vlev, dummy3d(1,1,vlev)
2696 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
2697 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
2698 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2701 do n = 1, num_tracers_input
2703 if (localpet == 0) print*,
"- READ ", trim(tracers_input_vmap(n))
2704 vname = tracers_input_vmap(n)
2705 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
2706 this_field_var_name=tmpstr,loc=varnum)
2707 if (n==1 .and. .not. hasspfh)
then
2708 print*,
"- CALL FieldGather TEMPERATURE."
2709 call esmf_fieldgather(temp_input_grid,dummy3d,rootpet=0, tile=1, rc=rc)
2710 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2714 if (localpet == 0)
then
2715 vname = trim(tracers_input_grib_1(n))
2716 vname2 = trim(tracers_input_grib_2(n))
2718 do vlev = 1, lev_input
2719 iret = grb2_inq(the_file,inv_file,vname,slevs(vlev),vname2,data2=dummy2d)
2724 if (trim(vname2)==
"_1_0:" .or. trim(vname2) ==
"_1_1:" .or. &
2725 trim(vname2) ==
":14:192:")
then
2726 call
error_handler(
"READING IN "//trim(vname)//
" AT LEVEL "//trim(slevs(vlev))&
2727 //
". SET A FILL VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",iret)
2732 if (n==1 .and. .not. hasspfh)
then
2733 call
rh2spfh(dummy2d,rlevs(vlev),dummy3d(:,:,vlev))
2736 print*,
'tracer ',vlev, maxval(dummy2d),minval(dummy2d)
2737 dummy3d(:,:,vlev) =
real(dummy2d,esmf_kind_r8)
2741 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input_vmap(n))
2742 call esmf_fieldscatter(tracers_input_grid(n), dummy3d, rootpet=0, rc=rc)
2743 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2748 call
read_winds(the_file,inv_file,u_tmp_3d,v_tmp_3d, localpet)
2750 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT U-WIND."
2751 call esmf_fieldscatter(u_input_grid, u_tmp_3d, rootpet=0, rc=rc)
2752 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2755 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT V-WIND."
2756 call esmf_fieldscatter(v_input_grid, v_tmp_3d, rootpet=0, rc=rc)
2757 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2760 if (localpet == 0)
then
2761 print*,
"- READ SURFACE PRESSURE."
2764 vlevtyp =
":surface:"
2765 iret = grb2_inq(the_file,inv_file,vname,vname2,vlevtyp,data2=dummy2d)
2766 if (iret <= 0) call
error_handler(
"READING SURFACE PRESSURE RECORD.", iret)
2767 dummy2d_8 =
real(dummy2d,esmf_kind_r8)
2770 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID SURFACE PRESSURE."
2771 call esmf_fieldscatter(ps_input_grid, dummy2d_8, rootpet=0, rc=rc)
2772 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2775 if (localpet == 0)
then
2776 print*,
"- READ DZDT."
2778 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
2782 do vlev = 1, lev_input
2783 iret = grb2_inq(the_file,inv_file,vname,vname2,slevs(vlev),data2=dummy2d)
2784 if (iret <= 0 )
then
2785 print*,
"DZDT not available at level ", trim(slevs(vlev)),
" so checking for VVEL"
2787 iret = grb2_inq(the_file,inv_file,vname,vname2,slevs(vlev),data2=dummy2d)
2798 print*,
'dzdt ',vlev, maxval(dummy2d),minval(dummy2d)
2799 dummy3d(:,:,vlev) = dummy2d
2803 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT DZDT."
2804 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
2805 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2808 if (localpet == 0)
then
2809 print*,
"- READ TERRAIN."
2812 vlevtyp =
":surface:"
2813 iret = grb2_inq(the_file,inv_file,vname,vname2,vlevtyp,data2=dummy2d)
2814 if (iret <= 0) call
error_handler(
"READING TERRAIN HEIGHT RECORD.", iret)
2815 dummy2d_8 =
real(dummy2d,esmf_kind_r8)
2818 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN."
2819 call esmf_fieldscatter(terrain_input_grid, dummy2d_8, rootpet=0, rc=rc)
2820 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2823 deallocate(dummy2d, dummy2d_8)
2825 if (.not. isnative)
then
2831 if (localpet == 0) print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
2833 call esmf_fieldget(ps_input_grid, &
2834 farrayptr=psptr, rc=rc)
2835 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2839 if (localpet == 0) print*,
"- CALL FieldGet FOR 3-D PRESSURE."
2840 call esmf_fieldget(pres_input_grid, &
2841 computationallbound=clb, &
2842 computationalubound=cub, &
2843 farrayptr=presptr, rc=rc)
2844 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2848 if (localpet == 0) print*,
"- CALL FieldGet TEMPERATURE."
2849 call esmf_fieldget(temp_input_grid, &
2850 farrayptr=tptr, rc=rc)
2851 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2855 if (localpet == 0) print*,
"- CALL FieldGet FOR U"
2856 call esmf_fieldget(u_input_grid, &
2857 farrayptr=uptr, rc=rc)
2858 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2862 if (localpet == 0) print*,
"- CALL FieldGet FOR V"
2863 call esmf_fieldget(v_input_grid, &
2864 farrayptr=vptr, rc=rc)
2865 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2869 if (localpet == 0) print*,
"- CALL FieldGet FOR W"
2870 call esmf_fieldget(dzdt_input_grid, &
2871 farrayptr=wptr, rc=rc)
2872 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2875 if (localpet == 0) print*,
"- CALL FieldGet FOR TRACERS."
2876 do n=1,num_tracers_input
2878 call esmf_fieldget(tracers_input_grid(n), &
2879 farrayptr=qptr, rc=rc)
2880 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2882 do i = clb(1),cub(1)
2883 do j = clb(2),cub(2)
2884 qptr(i,j,:) = qptr(i,j,lev_input:1:-1)
2889 do i = clb(1),cub(1)
2890 do j = clb(2),cub(2)
2891 presptr(i,j,:) = rlevs(lev_input:1:-1)
2892 tptr(i,j,:) = tptr(i,j,lev_input:1:-1)
2893 uptr(i,j,:) = uptr(i,j,lev_input:1:-1)
2894 vptr(i,j,:) = vptr(i,j,lev_input:1:-1)
2895 wptr(i,j,:) = wptr(i,j,lev_input:1:-1)
2899 if (localpet == 0)
then
2900 print*,
'psfc is ',clb(1),clb(2),psptr(clb(1),clb(2))
2901 print*,
'pres is ',cub(1),cub(2),presptr(cub(1),cub(2),:)
2903 print*,
'pres check 1',localpet,maxval(presptr(clb(1):cub(1),clb(2):cub(2),1)), &
2904 minval(presptr(clb(1):cub(1),clb(2):cub(2),1))
2905 print*,
'pres check lev',localpet,maxval(presptr(clb(1):cub(1),clb(2):cub(2), &
2906 lev_input)),minval(presptr(clb(1):cub(1),clb(2):cub(2),lev_input))
2911 if (localpet == 0)
then
2912 print*,
"- READ PRESSURE."
2914 do vlev = 1, lev_input
2915 iret = grb2_inq(the_file,inv_file,vname,slevs(vlev),data2=dummy2d)
2917 call
error_handler(
"READING IN PRESSURE AT LEVEL "//trim(slevs(vlev)),iret)
2919 dummy3d(:,:,vlev) =
real(dummy2d,esmf_kind_r8)
2920 print*,
'pres check after read ',vlev, dummy3d(1,1,vlev)
2924 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID PRESSURE."
2925 call esmf_fieldscatter(pres_input_grid, dummy3d, rootpet=0, rc=rc)
2926 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2941 if (conv_omega)
then
2943 if (localpet == 0) print*,
"- CONVERT FROM OMEGA TO DZDT."
2946 if (localpet == 0) print*,
"- CALL FieldGet TEMPERATURE."
2947 call esmf_fieldget(temp_input_grid, &
2948 farrayptr=tptr, rc=rc)
2949 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2953 if (localpet == 0) print*,
"- CALL FieldGet SPECIFIC HUMIDITY."
2954 call esmf_fieldget(tracers_input_grid(1), &
2955 computationallbound=clb, &
2956 computationalubound=cub, &
2957 farrayptr=qptr, rc=rc)
2958 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2962 if (localpet == 0) print*,
"- CALL FieldGet DZDT."
2963 call esmf_fieldget(dzdt_input_grid, &
2964 computationallbound=clb, &
2965 computationalubound=cub, &
2966 farrayptr=wptr, rc=rc)
2967 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2971 call esmf_fieldget(pres_input_grid, &
2972 farrayptr=presptr, rc=rc)
2973 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2995 integer,
intent(in) :: localpet
2997 character(len=300) :: the_file
2999 integer(sfcio_intkind) :: iret
3002 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
3003 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
3005 type(sfcio_head
) :: sfchead
3006 type(sfcio_dbta
) :: sfcdata
3008 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
3010 print*,
"- READ SURFACE DATA IN SFCIO FORMAT."
3011 print*,
"- OPEN AND READ: ",trim(the_file)
3012 call sfcio_sropen(23, trim(the_file), iret)
3018 call sfcio_srhead(23, sfchead, iret)
3024 if (localpet == 0)
then
3025 call sfcio_aldbta(sfchead, sfcdata, iret)
3030 call sfcio_srdbta(23, sfchead, sfcdata, iret)
3035 allocate(dummy2d(i_input,j_input))
3036 allocate(dummy3d(i_input,j_input,lsoil_input))
3038 allocate(dummy2d(0,0))
3039 allocate(dummy3d(0,0,0))
3042 if (localpet == 0) dummy2d = sfcdata%slmsk
3044 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
3045 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
3046 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3049 if (localpet == 0) dummy2d = sfcdata%zorl
3051 print*,
"- CALL FieldScatter FOR INPUT Z0."
3052 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
3053 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3056 if (localpet == 0) dummy2d = nint(sfcdata%vtype)
3058 print*,
"- CALL FieldScatter FOR INPUT VEG TYPE."
3059 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
3060 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3064 veg_type_landice_input = 13
3066 if (localpet == 0) dummy2d = sfcdata%canopy
3068 print*,
"- CALL FieldScatter FOR INPUT CANOPY MC."
3069 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
3070 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3073 if (localpet == 0) dummy2d = sfcdata%fice
3075 print*,
"- CALL FieldScatter FOR INPUT ICE FRACTION."
3076 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
3077 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3080 if (localpet == 0) dummy2d = sfcdata%hice
3082 print*,
"- CALL FieldScatter FOR INPUT ICE DEPTH."
3083 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3084 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3087 if (localpet == 0) dummy2d = sfcdata%tisfc
3089 print*,
"- CALL FieldScatter FOR INPUT ICE SKIN TEMP."
3090 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3091 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3094 if (localpet == 0) dummy2d = sfcdata%snwdph
3096 print*,
"- CALL FieldScatter FOR INPUT SNOW DEPTH."
3097 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3098 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3101 if (localpet == 0) dummy2d = sfcdata%sheleg
3103 print*,
"- CALL FieldScatter FOR INPUT SNOW LIQUID EQUIV."
3104 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
3105 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3108 if (localpet == 0) dummy2d = sfcdata%t2m
3110 print*,
"- CALL FieldScatter FOR INPUT T2M."
3111 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
3112 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3115 if (localpet == 0) dummy2d = sfcdata%q2m
3117 print*,
"- CALL FieldScatter FOR INPUT Q2M."
3118 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
3119 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3122 if (localpet == 0) dummy2d = sfcdata%tprcp
3124 print*,
"- CALL FieldScatter FOR INPUT TPRCP."
3125 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
3126 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3129 if (localpet == 0) dummy2d = sfcdata%f10m
3131 print*,
"- CALL FieldScatter FOR INPUT F10M."
3132 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
3133 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3136 if (localpet == 0) dummy2d = sfcdata%uustar
3138 print*,
"- CALL FieldScatter FOR INPUT USTAR."
3139 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
3140 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3143 if (localpet == 0) dummy2d = sfcdata%ffmm
3145 print*,
"- CALL FieldScatter FOR INPUT FFMM."
3146 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
3147 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3150 if (localpet == 0) dummy2d = sfcdata%srflag
3152 print*,
"- CALL FieldScatter FOR INPUT SRFLAG."
3153 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
3154 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3157 if (localpet == 0) dummy2d = sfcdata%tsea
3159 print*,
"- CALL FieldScatter FOR INPUT SKIN TEMP."
3160 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3161 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3164 if (localpet == 0) dummy2d = nint(sfcdata%stype)
3166 print*,
"- CALL FieldScatter FOR INPUT SOIL TYPE."
3167 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
3168 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3171 if (localpet == 0) dummy2d = sfcdata%orog
3173 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
3174 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
3175 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3178 if (localpet == 0) dummy3d = sfcdata%slc
3180 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
3181 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
3182 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3185 if (localpet == 0) dummy3d = sfcdata%smc
3187 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
3188 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
3189 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3192 if (localpet == 0) dummy3d = sfcdata%stc
3194 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
3195 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
3196 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3199 deallocate(dummy2d, dummy3d)
3200 call sfcio_axdbta(sfcdata, iret)
3202 call sfcio_sclose(23, iret)
3217 integer,
intent(in) :: localpet
3219 character(len=300) :: the_file
3223 real(nemsio_realkind),
allocatable :: dummy(:)
3224 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
3225 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
3227 type(nemsio_gfile
) :: gfile
3229 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
3231 if (localpet == 0)
then
3232 allocate(dummy3d(i_input,j_input,lsoil_input))
3233 allocate(dummy2d(i_input,j_input))
3234 allocate(dummy(i_input*j_input))
3235 print*,
"- OPEN FILE ", trim(the_file)
3236 call nemsio_open(gfile, the_file,
"read", iret=rc)
3239 allocate(dummy3d(0,0,0))
3240 allocate(dummy2d(0,0))
3244 if (localpet == 0)
then
3245 print*,
"- READ TERRAIN."
3246 call nemsio_readrecv(gfile,
"orog",
"sfc", 1, dummy, 0, iret=rc)
3248 dummy2d = reshape(dummy, (/i_input,j_input/))
3249 print*,
'orog ',maxval(dummy2d),minval(dummy2d)
3252 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
3253 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
3254 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3257 if (localpet == 0)
then
3258 print*,
"- READ LANDSEA MASK."
3259 call nemsio_readrecv(gfile,
"land",
"sfc", 1, dummy, 0, iret=rc)
3260 if (rc /= 0) call
error_handler(
"READING LANDSEA MASK.", rc)
3261 dummy2d = reshape(dummy, (/i_input,j_input/))
3262 print*,
'landmask ',maxval(dummy2d),minval(dummy2d)
3265 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
3266 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
3267 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3270 if (localpet == 0)
then
3271 print*,
"- READ SEAICE FRACTION."
3272 call nemsio_readrecv(gfile,
"icec",
"sfc", 1, dummy, 0, iret=rc)
3273 if (rc /= 0) call
error_handler(
"READING SEAICE FRACTION.", rc)
3274 dummy2d = reshape(dummy, (/i_input,j_input/))
3275 print*,
'icec ',maxval(dummy2d),minval(dummy2d)
3278 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
3279 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
3280 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3283 if (localpet == 0)
then
3284 print*,
"- READ SEAICE DEPTH."
3285 call nemsio_readrecv(gfile,
"icetk",
"sfc", 1, dummy, 0, iret=rc)
3286 if (rc /= 0) call
error_handler(
"READING SEAICE DEPTH.", rc)
3287 dummy2d = reshape(dummy, (/i_input,j_input/))
3288 print*,
'icetk ',maxval(dummy2d),minval(dummy2d)
3291 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
3292 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3293 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3296 if (localpet == 0)
then
3297 print*,
"- READ SEAICE SKIN TEMPERATURE."
3298 call nemsio_readrecv(gfile,
"tisfc",
"sfc", 1, dummy, 0, iret=rc)
3299 if (rc /= 0) call
error_handler(
"READING SEAICE SKIN TEMP.", rc)
3300 dummy2d = reshape(dummy, (/i_input,j_input/))
3301 print*,
'ti ',maxval(dummy2d),minval(dummy2d)
3304 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
3305 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3306 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3309 if (localpet == 0)
then
3310 print*,
"- READ SNOW LIQUID EQUIVALENT."
3311 call nemsio_readrecv(gfile,
"weasd",
"sfc", 1, dummy, 0, iret=rc)
3312 if (rc /= 0) call
error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
3313 dummy2d = reshape(dummy, (/i_input,j_input/))
3314 print*,
'weasd ',maxval(dummy2d),minval(dummy2d)
3317 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
3318 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
3319 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3322 if (localpet == 0)
then
3323 print*,
"- READ SNOW DEPTH."
3324 call nemsio_readrecv(gfile,
"snod",
"sfc", 1, dummy, 0, iret=rc)
3326 dummy2d = reshape(dummy, (/i_input,j_input/))
3327 print*,
'snod ',maxval(dummy2d),minval(dummy2d)
3330 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
3331 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3332 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3335 if (localpet == 0)
then
3336 print*,
"- READ VEG TYPE."
3337 call nemsio_readrecv(gfile,
"vtype",
"sfc", 1, dummy, 0, iret=rc)
3339 dummy2d = reshape(dummy, (/i_input,j_input/))
3340 print*,
'vtype ',maxval(dummy2d),minval(dummy2d)
3343 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
3344 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
3345 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3348 if (localpet == 0)
then
3349 print*,
"- READ SOIL TYPE."
3350 call nemsio_readrecv(gfile,
"sotyp",
"sfc", 1, dummy, 0, iret=rc)
3352 dummy2d = reshape(dummy, (/i_input,j_input/))
3353 print*,
'sotype ',maxval(dummy2d),minval(dummy2d)
3356 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
3357 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
3358 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3361 if (localpet == 0)
then
3362 print*,
"- READ T2M."
3363 call nemsio_readrecv(gfile,
"tmp",
"2 m above gnd", 1, dummy, 0, iret=rc)
3365 dummy2d = reshape(dummy, (/i_input,j_input/))
3366 print*,
't2m ',maxval(dummy2d),minval(dummy2d)
3369 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
3370 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
3371 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3374 if (localpet == 0)
then
3375 print*,
"- READ Q2M."
3376 call nemsio_readrecv(gfile,
"spfh",
"2 m above gnd", 1, dummy, 0, iret=rc)
3378 dummy2d = reshape(dummy, (/i_input,j_input/))
3379 print*,
'q2m ',maxval(dummy2d),minval(dummy2d)
3382 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
3383 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
3384 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3387 if (localpet == 0)
then
3388 print*,
"- READ TPRCP."
3389 call nemsio_readrecv(gfile,
"tprcp",
"sfc", 1, dummy, 0, iret=rc)
3391 dummy2d = reshape(dummy, (/i_input,j_input/))
3392 print*,
'tprcp ',maxval(dummy2d),minval(dummy2d)
3395 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
3396 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
3397 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3400 if (localpet == 0)
then
3401 print*,
"- READ FFMM."
3402 call nemsio_readrecv(gfile,
"ffmm",
"sfc", 1, dummy, 0, iret=rc)
3404 dummy2d = reshape(dummy, (/i_input,j_input/))
3405 print*,
'ffmm ',maxval(dummy2d),minval(dummy2d)
3408 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
3409 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
3410 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3413 if (localpet == 0)
then
3414 print*,
"- READ USTAR."
3415 call nemsio_readrecv(gfile,
"fricv",
"sfc", 1, dummy, 0, iret=rc)
3417 dummy2d = reshape(dummy, (/i_input,j_input/))
3418 print*,
'fricv ',maxval(dummy2d),minval(dummy2d)
3421 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
3422 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
3423 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3426 if (localpet == 0) dummy2d = 0.0
3427 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
3428 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
3429 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3432 if (localpet == 0)
then
3433 print*,
"- READ SKIN TEMPERATURE."
3434 call nemsio_readrecv(gfile,
"tmp",
"sfc", 1, dummy, 0, iret=rc)
3435 if (rc /= 0) call
error_handler(
"READING SKIN TEMPERATURE.", rc)
3436 dummy2d = reshape(dummy, (/i_input,j_input/))
3437 print*,
'tmp ',maxval(dummy2d),minval(dummy2d)
3440 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
3441 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3442 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3445 if (localpet == 0)
then
3446 print*,
"- READ F10M."
3447 call nemsio_readrecv(gfile,
"f10m",
"10 m above gnd", 1, dummy, 0, iret=rc)
3449 dummy2d = reshape(dummy, (/i_input,j_input/))
3450 print*,
'f10m ',maxval(dummy2d),minval(dummy2d)
3453 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
3454 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
3455 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3458 if (localpet == 0)
then
3459 print*,
"- READ CANOPY MOISTURE CONTENT."
3460 call nemsio_readrecv(gfile,
"cnwat",
"sfc", 1, dummy, 0, iret=rc)
3461 if (rc /= 0) call
error_handler(
"READING CANOPY MOISTURE CONTENT.", rc)
3462 dummy2d = reshape(dummy, (/i_input,j_input/))
3463 print*,
'cnwat ',maxval(dummy2d),minval(dummy2d)
3466 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
3467 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
3468 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3471 if (localpet == 0)
then
3473 call nemsio_readrecv(gfile,
"sfcr",
"sfc", 1, dummy, 0, iret=rc)
3475 dummy2d = reshape(dummy, (/i_input,j_input/))
3476 print*,
'sfcr ',maxval(dummy2d),minval(dummy2d)
3479 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
3480 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
3481 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3486 if (localpet == 0)
then
3487 print*,
"- READ LIQUID SOIL MOISTURE."
3488 call nemsio_readrecv(gfile,
"slc",
"soil layer", 1, dummy, 0, iret=rc)
3489 if (rc /= 0) call
error_handler(
"READING LAYER 1 LIQUID SOIL MOIST.", rc)
3490 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3491 call nemsio_readrecv(gfile,
"slc",
"soil layer", 2, dummy, 0, iret=rc)
3492 if (rc /= 0) call
error_handler(
"READING LAYER 2 LIQUID SOIL MOIST.", rc)
3493 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3494 call nemsio_readrecv(gfile,
"slc",
"soil layer", 3, dummy, 0, iret=rc)
3495 if (rc /= 0) call
error_handler(
"READING LAYER 3 LIQUID SOIL MOIST.", rc)
3496 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3497 call nemsio_readrecv(gfile,
"slc",
"soil layer", 4, dummy, 0, iret=rc)
3498 if (rc /= 0) call
error_handler(
"READING LAYER 4 LIQUID SOIL MOIST.", rc)
3499 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3500 print*,
'slc ',maxval(dummy3d),minval(dummy3d)
3503 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
3504 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
3505 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3508 if (localpet == 0)
then
3509 print*,
"- READ TOTAL SOIL MOISTURE."
3510 call nemsio_readrecv(gfile,
"smc",
"soil layer", 1, dummy, 0, iret=rc)
3511 if (rc /= 0) call
error_handler(
"READING LAYER 1 TOTAL SOIL MOIST.", rc)
3512 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3513 call nemsio_readrecv(gfile,
"smc",
"soil layer", 2, dummy, 0, iret=rc)
3514 if (rc /= 0) call
error_handler(
"READING LAYER 2 TOTAL SOIL MOIST.", rc)
3515 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3516 call nemsio_readrecv(gfile,
"smc",
"soil layer", 3, dummy, 0, iret=rc)
3517 if (rc /= 0) call
error_handler(
"READING LAYER 3 TOTAL SOIL MOIST.", rc)
3518 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3519 call nemsio_readrecv(gfile,
"smc",
"soil layer", 4, dummy, 0, iret=rc)
3520 if (rc /= 0) call
error_handler(
"READING LAYER 4 TOTAL SOIL MOIST.", rc)
3521 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3522 print*,
'smc ',maxval(dummy3d),minval(dummy3d)
3525 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
3526 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
3527 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3530 if (localpet == 0)
then
3531 print*,
"- READ SOIL TEMPERATURE."
3532 call nemsio_readrecv(gfile,
"stc",
"soil layer", 1, dummy, 0, iret=rc)
3533 if (rc /= 0) call
error_handler(
"READING LAYER 1 SOIL TEMP.", rc)
3534 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3535 call nemsio_readrecv(gfile,
"stc",
"soil layer", 2, dummy, 0, iret=rc)
3536 if (rc /= 0) call
error_handler(
"READING LAYER 2 SOIL TEMP.", rc)
3537 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3538 call nemsio_readrecv(gfile,
"stc",
"soil layer", 3, dummy, 0, iret=rc)
3539 if (rc /= 0) call
error_handler(
"READING LAYER 3 SOIL TEMP.", rc)
3540 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3541 call nemsio_readrecv(gfile,
"stc",
"soil layer", 4, dummy, 0, iret=rc)
3542 if (rc /= 0) call
error_handler(
"READING LAYER 4 SOIL TEMP.", rc)
3543 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3544 print*,
'stc ',maxval(dummy3d),minval(dummy3d)
3547 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
3548 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
3549 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3552 deallocate(dummy3d, dummy)
3554 if (localpet == 0) call nemsio_close(gfile)
3566 integer,
intent(in) :: localpet
3568 character(len=250) :: the_file
3572 real(nemsio_realkind),
allocatable :: dummy(:)
3573 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
3574 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
3576 type(nemsio_gfile
) :: gfile
3578 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
3580 if (localpet == 0)
then
3581 allocate(dummy3d(i_input,j_input,lsoil_input))
3582 allocate(dummy2d(i_input,j_input))
3583 allocate(dummy(i_input*j_input))
3584 print*,
"- OPEN FILE ", trim(the_file)
3585 call nemsio_open(gfile, the_file,
"read", iret=rc)
3588 allocate(dummy3d(0,0,0))
3589 allocate(dummy2d(0,0))
3593 if (localpet == 0)
then
3594 print*,
"- READ TERRAIN."
3595 call nemsio_readrecv(gfile,
"orog",
"sfc", 1, dummy, 0, iret=rc)
3597 dummy2d = reshape(dummy, (/i_input,j_input/))
3598 print*,
'orog ',maxval(dummy2d),minval(dummy2d)
3601 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
3602 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
3603 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3606 if (localpet == 0)
then
3607 print*,
"- READ LANDSEA MASK."
3608 call nemsio_readrecv(gfile,
"land",
"sfc", 1, dummy, 0, iret=rc)
3609 if (rc /= 0) call
error_handler(
"READING LANDSEA MASK.", rc)
3610 dummy2d = reshape(dummy, (/i_input,j_input/))
3611 print*,
'landmask ',maxval(dummy2d),minval(dummy2d)
3614 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
3615 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
3616 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3619 if (localpet == 0)
then
3620 print*,
"- READ SEAICE FRACTION."
3621 call nemsio_readrecv(gfile,
"icec",
"sfc", 1, dummy, 0, iret=rc)
3622 if (rc /= 0) call
error_handler(
"READING SEAICE FRACTION.", rc)
3623 dummy2d = reshape(dummy, (/i_input,j_input/))
3624 print*,
'icec ',maxval(dummy2d),minval(dummy2d)
3627 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
3628 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
3629 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3632 if (localpet == 0)
then
3633 print*,
"- READ SEAICE DEPTH."
3634 call nemsio_readrecv(gfile,
"icetk",
"sfc", 1, dummy, 0, iret=rc)
3635 if (rc /= 0) call
error_handler(
"READING SEAICE DEPTH.", rc)
3636 dummy2d = reshape(dummy, (/i_input,j_input/))
3637 print*,
'icetk ',maxval(dummy2d),minval(dummy2d)
3640 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
3641 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3642 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3645 if (localpet == 0)
then
3646 print*,
"- READ SEAICE SKIN TEMPERATURE."
3647 call nemsio_readrecv(gfile,
"ti",
"sfc", 1, dummy, 0, iret=rc)
3648 if (rc /= 0) call
error_handler(
"READING SEAICE SKIN TEMP.", rc)
3649 dummy2d = reshape(dummy, (/i_input,j_input/))
3650 print*,
'ti ',maxval(dummy2d),minval(dummy2d)
3653 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
3654 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3655 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3658 if (localpet == 0)
then
3659 print*,
"- READ SNOW LIQUID EQUIVALENT."
3660 call nemsio_readrecv(gfile,
"weasd",
"sfc", 1, dummy, 0, iret=rc)
3661 if (rc /= 0) call
error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
3662 dummy2d = reshape(dummy, (/i_input,j_input/))
3663 print*,
'weasd ',maxval(dummy2d),minval(dummy2d)
3666 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
3667 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
3668 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3671 if (localpet == 0)
then
3672 print*,
"- READ SNOW DEPTH."
3673 call nemsio_readrecv(gfile,
"snod",
"sfc", 1, dummy, 0, iret=rc)
3675 dummy2d = reshape(dummy, (/i_input,j_input/)) * 1000.0_8
3676 print*,
'snod ',maxval(dummy2d),minval(dummy2d)
3679 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
3680 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3681 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3684 if (localpet == 0)
then
3685 print*,
"- READ VEG TYPE."
3686 call nemsio_readrecv(gfile,
"vtype",
"sfc", 1, dummy, 0, iret=rc)
3688 dummy2d = reshape(dummy, (/i_input,j_input/))
3689 print*,
'vtype ',maxval(dummy2d),minval(dummy2d)
3692 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
3693 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
3694 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3697 if (localpet == 0)
then
3698 print*,
"- READ SOIL TYPE."
3699 call nemsio_readrecv(gfile,
"sotyp",
"sfc", 1, dummy, 0, iret=rc)
3701 dummy2d = reshape(dummy, (/i_input,j_input/))
3702 print*,
'sotype ',maxval(dummy2d),minval(dummy2d)
3705 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
3706 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
3707 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3710 if (localpet == 0)
then
3711 print*,
"- READ T2M."
3712 call nemsio_readrecv(gfile,
"tmp",
"2 m above gnd", 1, dummy, 0, iret=rc)
3714 dummy2d = reshape(dummy, (/i_input,j_input/))
3715 print*,
't2m ',maxval(dummy2d),minval(dummy2d)
3718 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
3719 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
3720 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3723 if (localpet == 0)
then
3724 print*,
"- READ Q2M."
3725 call nemsio_readrecv(gfile,
"spfh",
"2 m above gnd", 1, dummy, 0, iret=rc)
3727 dummy2d = reshape(dummy, (/i_input,j_input/))
3728 print*,
'q2m ',maxval(dummy2d),minval(dummy2d)
3731 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
3732 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
3733 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3736 if (localpet == 0)
then
3737 print*,
"- READ TPRCP."
3738 call nemsio_readrecv(gfile,
"tprcp",
"sfc", 1, dummy, 0, iret=rc)
3740 dummy2d = reshape(dummy, (/i_input,j_input/))
3741 print*,
'tprcp ',maxval(dummy2d),minval(dummy2d)
3744 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
3745 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
3746 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3749 if (localpet == 0)
then
3750 print*,
"- READ FFMM."
3751 call nemsio_readrecv(gfile,
"ffmm",
"sfc", 1, dummy, 0, iret=rc)
3753 dummy2d = reshape(dummy, (/i_input,j_input/))
3754 print*,
'ffmm ',maxval(dummy2d),minval(dummy2d)
3757 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
3758 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
3759 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3762 if (localpet == 0)
then
3763 print*,
"- READ USTAR."
3764 call nemsio_readrecv(gfile,
"fricv",
"sfc", 1, dummy, 0, iret=rc)
3766 dummy2d = reshape(dummy, (/i_input,j_input/))
3767 print*,
'fricv ',maxval(dummy2d),minval(dummy2d)
3770 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
3771 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
3772 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3775 if (localpet == 0) dummy2d = 0.0
3776 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
3777 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
3778 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3781 if (localpet == 0)
then
3782 print*,
"- READ SKIN TEMPERATURE."
3783 call nemsio_readrecv(gfile,
"tmp",
"sfc", 1, dummy, 0, iret=rc)
3784 if (rc /= 0) call
error_handler(
"READING SKIN TEMPERATURE.", rc)
3785 dummy2d = reshape(dummy, (/i_input,j_input/))
3786 print*,
'tmp ',maxval(dummy2d),minval(dummy2d)
3789 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
3790 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3791 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3794 if (localpet == 0)
then
3795 print*,
"- READ F10M."
3796 call nemsio_readrecv(gfile,
"f10m",
"10 m above gnd", 1, dummy, 0, iret=rc)
3798 dummy2d = reshape(dummy, (/i_input,j_input/))
3799 print*,
'f10m ',maxval(dummy2d),minval(dummy2d)
3802 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
3803 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
3804 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3807 if (localpet == 0)
then
3808 print*,
"- READ CANOPY MOISTURE CONTENT."
3809 call nemsio_readrecv(gfile,
"cnwat",
"sfc", 1, dummy, 0, iret=rc)
3810 if (rc /= 0) call
error_handler(
"READING CANOPY MOISTURE CONTENT.", rc)
3811 dummy2d = reshape(dummy, (/i_input,j_input/))
3812 print*,
'cnwat ',maxval(dummy2d),minval(dummy2d)
3815 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
3816 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
3817 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3820 if (localpet == 0)
then
3822 call nemsio_readrecv(gfile,
"sfcr",
"sfc", 1, dummy, 0, iret=rc)
3824 dummy2d = reshape(dummy, (/i_input,j_input/)) * 100.0_8
3825 print*,
'sfcr ',maxval(dummy2d),minval(dummy2d)
3828 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
3829 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
3830 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3835 if (localpet == 0)
then
3836 print*,
"- READ LIQUID SOIL MOISTURE."
3837 call nemsio_readrecv(gfile,
"soill",
"0-10 cm down", 1, dummy, 0, iret=rc)
3838 if (rc /= 0) call
error_handler(
"READING LAYER 1 LIQUID SOIL MOIST.", rc)
3839 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3840 call nemsio_readrecv(gfile,
"soill",
"10-40 cm down", 1, dummy, 0, iret=rc)
3841 if (rc /= 0) call
error_handler(
"READING LAYER 2 LIQUID SOIL MOIST.", rc)
3842 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3843 call nemsio_readrecv(gfile,
"soill",
"40-100 cm down", 1, dummy, 0, iret=rc)
3844 if (rc /= 0) call
error_handler(
"READING LAYER 3 LIQUID SOIL MOIST.", rc)
3845 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3846 call nemsio_readrecv(gfile,
"soill",
"100-200 cm down", 1, dummy, 0, iret=rc)
3847 if (rc /= 0) call
error_handler(
"READING LAYER 4 LIQUID SOIL MOIST.", rc)
3848 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3849 print*,
'soill ',maxval(dummy3d),minval(dummy3d)
3852 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
3853 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
3854 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3857 if (localpet == 0)
then
3858 print*,
"- READ TOTAL SOIL MOISTURE."
3859 call nemsio_readrecv(gfile,
"soilw",
"0-10 cm down", 1, dummy, 0, iret=rc)
3860 if (rc /= 0) call
error_handler(
"READING LAYER 1 TOTAL SOIL MOIST.", rc)
3861 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3862 call nemsio_readrecv(gfile,
"soilw",
"10-40 cm down", 1, dummy, 0, iret=rc)
3863 if (rc /= 0) call
error_handler(
"READING LAYER 2 TOTAL SOIL MOIST.", rc)
3864 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3865 call nemsio_readrecv(gfile,
"soilw",
"40-100 cm down", 1, dummy, 0, iret=rc)
3866 if (rc /= 0) call
error_handler(
"READING LAYER 3 TOTAL SOIL MOIST.", rc)
3867 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3868 call nemsio_readrecv(gfile,
"soilw",
"100-200 cm down", 1, dummy, 0, iret=rc)
3869 if (rc /= 0) call
error_handler(
"READING LAYER 4 TOTAL SOIL MOIST.", rc)
3870 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3871 print*,
'soilm ',maxval(dummy3d),minval(dummy3d)
3874 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
3875 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
3876 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3879 if (localpet == 0)
then
3880 print*,
"- READ SOIL TEMPERATURE."
3881 call nemsio_readrecv(gfile,
"tmp",
"0-10 cm down", 1, dummy, 0, iret=rc)
3882 if (rc /= 0) call
error_handler(
"READING LAYER 1 SOIL TEMP.", rc)
3883 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3884 call nemsio_readrecv(gfile,
"tmp",
"10-40 cm down", 1, dummy, 0, iret=rc)
3885 if (rc /= 0) call
error_handler(
"READING LAYER 2 SOIL TEMP.", rc)
3886 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3887 call nemsio_readrecv(gfile,
"tmp",
"40-100 cm down", 1, dummy, 0, iret=rc)
3888 if (rc /= 0) call
error_handler(
"READING LAYER 3 SOIL TEMP.", rc)
3889 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3890 call nemsio_readrecv(gfile,
"tmp",
"100-200 cm down", 1, dummy, 0, iret=rc)
3891 if (rc /= 0) call
error_handler(
"READING LAYER 4 SOIL TEMP.", rc)
3892 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3893 print*,
'soilt ',maxval(dummy3d),minval(dummy3d)
3896 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
3897 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
3898 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3901 deallocate(dummy3d, dummy)
3903 if (localpet == 0) call nemsio_close(gfile)
3915 integer,
intent(in) :: localpet
3917 character(len=500) :: tilefile
3919 integer :: error, rc
3920 integer :: id_dim, idim_input, jdim_input
3921 integer :: ncid, tile, id_var
3923 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
3924 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
3931 tilefile = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
3932 print*,
"- READ GRID DIMENSIONS FROM: ", trim(tilefile)
3933 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
3934 call
netcdf_err(error,
'opening: '//trim(tilefile) )
3936 error=nf90_inq_dimid(ncid,
'xaxis_1', id_dim)
3937 call
netcdf_err(error,
'reading xaxis_1 id' )
3938 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
3939 call
netcdf_err(error,
'reading xaxis_1 value' )
3941 error=nf90_inq_dimid(ncid,
'yaxis_1', id_dim)
3942 call
netcdf_err(error,
'reading yaxis_1 id' )
3943 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
3944 call
netcdf_err(error,
'reading yaxis_1 value' )
3946 if (idim_input /= i_input .or. jdim_input /= j_input)
then
3947 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 1)
3950 error = nf90_close(ncid)
3952 if (localpet == 0)
then
3953 allocate(data_one_tile(idim_input,jdim_input))
3954 allocate(data_one_tile_3d(idim_input,jdim_input,lsoil_input))
3956 allocate(data_one_tile(0,0))
3957 allocate(data_one_tile_3d(0,0,0))
3960 terrain_loop:
do tile = 1, num_tiles_input_grid
3962 if (localpet == 0)
then
3963 tilefile = trim(orog_dir_input_grid) // trim(orog_files_input_grid(tile))
3964 print*,
'- OPEN OROGRAPHY FILE: ', trim(tilefile)
3965 error=nf90_open(tilefile,nf90_nowrite,ncid)
3966 call
netcdf_err(error,
'OPENING OROGRAPHY FILE' )
3967 error=nf90_inq_varid(ncid,
'orog_raw', id_var)
3968 call
netcdf_err(error,
'READING OROG RECORD ID' )
3969 error=nf90_get_var(ncid, id_var, data_one_tile)
3970 call
netcdf_err(error,
'READING OROG RECORD' )
3971 print*,
'terrain check ',tile, maxval(data_one_tile)
3972 error=nf90_close(ncid)
3975 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
3976 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
3977 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3982 tile_loop :
do tile = 1, num_tiles_input_grid
3986 if (localpet == 0)
then
3988 lsoil_input, sfcdata_3d=data_one_tile_3d)
3991 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
3992 call esmf_fieldscatter(soilm_liq_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
3993 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3996 if (localpet == 0)
then
3998 lsoil_input, sfcdata_3d=data_one_tile_3d)
4001 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
4002 call esmf_fieldscatter(soilm_tot_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4003 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4006 if (localpet == 0)
then
4008 lsoil_input, sfcdata_3d=data_one_tile_3d)
4011 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
4012 call esmf_fieldscatter(soil_temp_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4013 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4018 if (localpet == 0)
then
4020 lsoil_input, sfcdata=data_one_tile)
4023 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
4024 call esmf_fieldscatter(landsea_mask_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4025 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4030 if (localpet == 0)
then
4032 lsoil_input, sfcdata=data_one_tile)
4035 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
4036 call esmf_fieldscatter(seaice_fract_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4037 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4042 if (localpet == 0)
then
4044 lsoil_input, sfcdata=data_one_tile)
4047 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
4048 call esmf_fieldscatter(seaice_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4049 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4054 if (localpet == 0)
then
4056 lsoil_input, sfcdata=data_one_tile)
4059 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
4060 call esmf_fieldscatter(seaice_skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4061 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4066 if (localpet == 0)
then
4068 lsoil_input, sfcdata=data_one_tile)
4071 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
4072 call esmf_fieldscatter(snow_liq_equiv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4073 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4078 if (localpet == 0)
then
4080 lsoil_input, sfcdata=data_one_tile)
4081 data_one_tile = data_one_tile
4084 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
4085 call esmf_fieldscatter(snow_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4086 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4091 if (localpet == 0)
then
4093 lsoil_input, sfcdata=data_one_tile)
4096 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
4097 call esmf_fieldscatter(veg_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4098 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4103 if (localpet == 0)
then
4105 lsoil_input, sfcdata=data_one_tile)
4108 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
4109 call esmf_fieldscatter(soil_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4110 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4115 if (localpet == 0)
then
4117 lsoil_input, sfcdata=data_one_tile)
4120 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
4121 call esmf_fieldscatter(t2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4122 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4127 if (localpet == 0)
then
4129 lsoil_input, sfcdata=data_one_tile)
4132 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
4133 call esmf_fieldscatter(q2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4134 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4137 if (localpet == 0)
then
4139 lsoil_input, sfcdata=data_one_tile)
4142 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
4143 call esmf_fieldscatter(tprcp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4144 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4147 if (localpet == 0)
then
4149 lsoil_input, sfcdata=data_one_tile)
4152 print*,
"- CALL FieldScatter FOR INPUT GRID F10M"
4153 call esmf_fieldscatter(f10m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4154 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4157 if (localpet == 0)
then
4159 lsoil_input, sfcdata=data_one_tile)
4162 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
4163 call esmf_fieldscatter(ffmm_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4164 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)
4172 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
4173 call esmf_fieldscatter(ustar_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4174 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4177 if (localpet == 0)
then
4179 lsoil_input, sfcdata=data_one_tile)
4182 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
4183 call esmf_fieldscatter(srflag_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4184 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4187 if (localpet == 0)
then
4189 lsoil_input, sfcdata=data_one_tile)
4192 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
4193 call esmf_fieldscatter(skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4194 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4197 if (localpet == 0)
then
4199 lsoil_input, sfcdata=data_one_tile)
4202 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
4203 call esmf_fieldscatter(canopy_mc_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4204 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4207 if (localpet == 0)
then
4209 lsoil_input, sfcdata=data_one_tile)
4212 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
4213 call esmf_fieldscatter(z0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4214 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4219 deallocate(data_one_tile, data_one_tile_3d)
4232 integer,
intent(in) :: localpet
4234 character(len=500) :: tilefile
4236 integer :: error, id_var
4237 integer :: id_dim, idim_input, jdim_input
4238 integer :: ncid, rc, tile
4240 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
4241 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
4248 tilefile = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
4249 print*,
"- READ GRID DIMENSIONS FROM: ", trim(tilefile)
4250 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
4251 call
netcdf_err(error,
'opening: '//trim(tilefile) )
4253 error=nf90_inq_dimid(ncid,
'grid_xt', id_dim)
4254 call
netcdf_err(error,
'reading grid_xt id' )
4255 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
4256 call
netcdf_err(error,
'reading grid_xt value' )
4258 error=nf90_inq_dimid(ncid,
'grid_yt', id_dim)
4259 call
netcdf_err(error,
'reading grid_yt id' )
4260 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
4261 call
netcdf_err(error,
'reading grid_yt value' )
4263 if (idim_input /= i_input .or. jdim_input /= j_input)
then
4264 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 3)
4267 error = nf90_close(ncid)
4269 if (localpet == 0)
then
4270 allocate(data_one_tile(idim_input,jdim_input))
4271 allocate(data_one_tile_3d(idim_input,jdim_input,lsoil_input))
4273 allocate(data_one_tile(0,0))
4274 allocate(data_one_tile_3d(0,0,0))
4277 terrain_loop:
do tile = 1, num_tiles_input_grid
4279 if (trim(input_type) ==
"gaussian_netcdf")
then
4280 if (localpet == 0)
then
4282 lsoil_input, sfcdata=data_one_tile)
4287 if (localpet == 0)
then
4288 tilefile = trim(orog_dir_input_grid) // trim(orog_files_input_grid(tile))
4289 print*,
'- OPEN OROGRAPHY FILE: ', trim(tilefile)
4290 error=nf90_open(tilefile,nf90_nowrite,ncid)
4291 call
netcdf_err(error,
'OPENING OROGRAPHY FILE.' )
4292 error=nf90_inq_varid(ncid,
'orog_raw', id_var)
4293 call
netcdf_err(error,
'READING OROGRAPHY RECORD ID.' )
4294 error=nf90_get_var(ncid, id_var, data_one_tile)
4295 call
netcdf_err(error,
'READING OROGRAPHY RECORD.' )
4296 print*,
'terrain check history ',tile, maxval(data_one_tile)
4297 error=nf90_close(ncid)
4302 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
4303 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4304 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4309 tile_loop :
do tile = 1, num_tiles_input_grid
4313 if (localpet == 0)
then
4315 lsoil_input, sfcdata=data_one_tile)
4316 data_one_tile_3d(:,:,1) = data_one_tile
4318 lsoil_input, sfcdata=data_one_tile)
4319 data_one_tile_3d(:,:,2) = data_one_tile
4321 lsoil_input, sfcdata=data_one_tile)
4322 data_one_tile_3d(:,:,3) = data_one_tile
4324 lsoil_input, sfcdata=data_one_tile)
4325 data_one_tile_3d(:,:,4) = data_one_tile
4328 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
4329 call esmf_fieldscatter(soilm_liq_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4330 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4335 if (localpet == 0)
then
4337 lsoil_input, sfcdata=data_one_tile)
4338 data_one_tile_3d(:,:,1) = data_one_tile
4340 lsoil_input, sfcdata=data_one_tile)
4341 data_one_tile_3d(:,:,2) = data_one_tile
4343 lsoil_input, sfcdata=data_one_tile)
4344 data_one_tile_3d(:,:,3) = data_one_tile
4346 lsoil_input, sfcdata=data_one_tile)
4347 data_one_tile_3d(:,:,4) = data_one_tile
4350 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
4351 call esmf_fieldscatter(soilm_tot_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4352 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4357 if (localpet == 0)
then
4359 lsoil_input, sfcdata=data_one_tile)
4360 data_one_tile_3d(:,:,1) = data_one_tile
4362 lsoil_input, sfcdata=data_one_tile)
4363 data_one_tile_3d(:,:,2) = data_one_tile
4365 lsoil_input, sfcdata=data_one_tile)
4366 data_one_tile_3d(:,:,3) = data_one_tile
4368 lsoil_input, sfcdata=data_one_tile)
4369 data_one_tile_3d(:,:,4) = data_one_tile
4372 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
4373 call esmf_fieldscatter(soil_temp_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4374 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4379 if (localpet == 0)
then
4381 lsoil_input, sfcdata=data_one_tile)
4384 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
4385 call esmf_fieldscatter(landsea_mask_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4386 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4391 if (localpet == 0)
then
4393 lsoil_input, sfcdata=data_one_tile)
4396 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
4397 call esmf_fieldscatter(seaice_fract_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4398 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4403 if (localpet == 0)
then
4405 lsoil_input, sfcdata=data_one_tile)
4408 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
4409 call esmf_fieldscatter(seaice_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4410 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4415 if (localpet == 0)
then
4417 lsoil_input, sfcdata=data_one_tile)
4420 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
4421 call esmf_fieldscatter(seaice_skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4422 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4427 if (localpet == 0)
then
4429 lsoil_input, sfcdata=data_one_tile)
4432 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
4433 call esmf_fieldscatter(snow_liq_equiv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4434 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4439 if (localpet == 0)
then
4441 lsoil_input, sfcdata=data_one_tile)
4442 data_one_tile = data_one_tile * 1000.0
4445 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
4446 call esmf_fieldscatter(snow_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4447 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4452 if (localpet == 0)
then
4454 lsoil_input, sfcdata=data_one_tile)
4457 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
4458 call esmf_fieldscatter(veg_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4459 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4464 if (localpet == 0)
then
4466 lsoil_input, sfcdata=data_one_tile)
4469 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
4470 call esmf_fieldscatter(soil_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4471 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4476 if (localpet == 0)
then
4478 lsoil_input, sfcdata=data_one_tile)
4481 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
4482 call esmf_fieldscatter(t2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4483 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4488 if (localpet == 0)
then
4490 lsoil_input, sfcdata=data_one_tile)
4493 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
4494 call esmf_fieldscatter(q2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4495 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4498 if (localpet == 0)
then
4500 lsoil_input, sfcdata=data_one_tile)
4503 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
4504 call esmf_fieldscatter(tprcp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4505 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4508 if (localpet == 0)
then
4510 lsoil_input, sfcdata=data_one_tile)
4513 print*,
"- CALL FieldScatter FOR INPUT GRID F10M"
4514 call esmf_fieldscatter(f10m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4515 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4518 if (localpet == 0)
then
4520 lsoil_input, sfcdata=data_one_tile)
4523 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
4524 call esmf_fieldscatter(ffmm_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4525 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)
4533 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
4534 call esmf_fieldscatter(ustar_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4535 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4538 if (localpet == 0)
then
4544 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
4545 call esmf_fieldscatter(srflag_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4546 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4549 if (localpet == 0)
then
4551 lsoil_input, sfcdata=data_one_tile)
4554 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
4555 call esmf_fieldscatter(skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4556 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4559 if (localpet == 0)
then
4561 lsoil_input, sfcdata=data_one_tile)
4564 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
4565 call esmf_fieldscatter(canopy_mc_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4566 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4569 if (localpet == 0)
then
4571 lsoil_input, sfcdata=data_one_tile)
4574 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
4575 call esmf_fieldscatter(z0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4576 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4581 deallocate(data_one_tile, data_one_tile_3d)
4592 use program_setup, only : vgtyp_from_climo, sotyp_from_climo
4599 integer,
intent(in) :: localpet
4601 character(len=250) :: the_file
4602 character(len=250) :: geo_file
4603 character(len=20) :: vname, vname_file,slev
4604 character(len=50) :: method
4607 integer :: rc, varnum, iret, i, j,k
4608 integer :: ncid2d, varid, varsize
4610 logical :: exist, rap_latlon
4612 real(esmf_kind_r4) :: value
4614 real(esmf_kind_r4),
allocatable :: dummy2d(:,:),icec_save(:,:)
4615 real(esmf_kind_r4),
allocatable :: dummy1d(:)
4616 real(esmf_kind_r8),
allocatable :: dummy2d_8(:,:),dummy2d_82(:,:),tsk_save(:,:)
4617 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:), dummy3d_stype(:,:,:)
4618 integer(esmf_kind_i4),
allocatable :: slmsk_save(:,:)
4619 integer(esmf_kind_i8),
allocatable :: dummy2d_i(:,:)
4622 rap_latlon = trim(
to_upper(external_model))==
"RAP" .and. trim(input_grid_type) ==
"rotated_latlon"
4624 the_file = trim(data_dir_input_grid) //
"/" // trim(grib2_file_input_grid)
4625 geo_file = trim(geogrid_file_input_grid)
4628 print*,
"- READ SFC DATA FROM GRIB2 FILE: ", trim(the_file)
4629 inquire(file=the_file,exist=exist)
4630 if (.not.exist)
then
4635 lsoil_input = grb2_inq(the_file, inv_file,
':TSOIL:',
' below ground:')
4636 print*,
"- FILE HAS ", lsoil_input,
" SOIL LEVELS"
4637 if (lsoil_input <= 0) call
error_handler(
"COUNTING SOIL LEVELS.", rc)
4640 if (lsoil_input /= 4)
then
4642 call esmf_fielddestroy(soil_temp_input_grid, rc=rc)
4643 call esmf_fielddestroy(soilm_tot_input_grid, rc=rc)
4644 call esmf_fielddestroy(soilm_liq_input_grid, rc=rc)
4646 print*,
"- CALL FieldCreate FOR INPUT SOIL TEMPERATURE."
4647 soil_temp_input_grid = esmf_fieldcreate(input_grid, &
4648 typekind=esmf_typekind_r8, &
4649 staggerloc=esmf_staggerloc_center, &
4650 ungriddedlbound=(/1/), &
4651 ungriddedubound=(/lsoil_input/), rc=rc)
4652 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4655 print*,
"- CALL FieldCreate FOR INPUT TOTAL SOIL MOISTURE."
4656 soilm_tot_input_grid = esmf_fieldcreate(input_grid, &
4657 typekind=esmf_typekind_r8, &
4658 staggerloc=esmf_staggerloc_center, &
4659 ungriddedlbound=(/1/), &
4660 ungriddedubound=(/lsoil_input/), rc=rc)
4661 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4664 print*,
"- CALL FieldCreate FOR INPUT LIQUID SOIL MOISTURE."
4665 soilm_liq_input_grid = esmf_fieldcreate(input_grid, &
4666 typekind=esmf_typekind_r8, &
4667 staggerloc=esmf_staggerloc_center, &
4668 ungriddedlbound=(/1/), &
4669 ungriddedubound=(/lsoil_input/), rc=rc)
4670 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4675 if (localpet == 0)
then
4676 allocate(dummy2d(i_input,j_input))
4677 allocate(slmsk_save(i_input,j_input))
4678 allocate(dummy2d_i(i_input,j_input))
4679 allocate(tsk_save(i_input,j_input))
4680 allocate(icec_save(i_input,j_input))
4681 allocate(dummy2d_8(i_input,j_input))
4682 allocate(dummy2d_82(i_input,j_input))
4683 allocate(dummy3d(i_input,j_input,lsoil_input))
4684 allocate(dummy3d_stype(i_input,j_input,16))
4685 allocate(dummy1d(16))
4687 allocate(dummy3d(0,0,0))
4688 allocate(dummy2d_8(0,0))
4689 allocate(dummy2d_82(0,0))
4690 allocate(dummy2d(0,0))
4699 if (localpet == 0)
then
4700 print*,
"- READ TERRAIN."
4701 rc = grb2_inq(the_file, inv_file,
':HGT:',
':surface:', data2=dummy2d)
4703 print*,
'orog ',maxval(dummy2d),minval(dummy2d)
4706 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
4707 call esmf_fieldscatter(terrain_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4708 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4711 if (localpet == 0)
then
4712 print*,
"- READ SEAICE FRACTION."
4713 rc = grb2_inq(the_file, inv_file,
':ICEC:',
':surface:', data2=dummy2d)
4714 if (rc /= 1) call
error_handler(
"READING SEAICE FRACTION.", rc)
4716 print*,
'icec ',maxval(dummy2d),minval(dummy2d)
4720 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
4721 call esmf_fieldscatter(seaice_fract_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4722 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4733 if (localpet == 0)
then
4734 print*,
"- READ LANDSEA MASK."
4735 rc = grb2_inq(the_file, inv_file,
':LANDN:',
':surface:', data2=dummy2d)
4738 rc = grb2_inq(the_file, inv_file,
':LAND:',
':surface:', data2=dummy2d)
4739 if (rc /= 1) call
error_handler(
"READING LANDSEA MASK.", rc)
4744 if(dummy2d(i,j) < 0.5_esmf_kind_r4) dummy2d(i,j)=0.0_esmf_kind_r4
4745 if(icec_save(i,j) > 0.15_esmf_kind_r4)
then
4747 dummy2d(i,j) = 2.0_esmf_kind_r4
4752 slmsk_save = nint(dummy2d)
4754 deallocate(icec_save)
4757 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
4758 call esmf_fieldscatter(landsea_mask_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4759 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4762 if (localpet == 0)
then
4763 print*,
"- READ SEAICE SKIN TEMPERATURE."
4764 rc = grb2_inq(the_file, inv_file,
':TMP:',
':surface:', data2=dummy2d)
4765 if (rc /= 1) call
error_handler(
"READING SEAICE SKIN TEMP.", rc)
4766 print*,
'ti ',maxval(dummy2d),minval(dummy2d)
4769 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
4770 call esmf_fieldscatter(seaice_skin_temp_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4771 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4780 if (localpet == 0)
then
4781 print*,
"- READ SNOW LIQUID EQUIVALENT."
4782 rc = grb2_inq(the_file, inv_file,
':WEASD:',
':surface:',
':anl:',data2=dummy2d)
4784 rc = grb2_inq(the_file, inv_file,
':WEASD:',
':surface:',
'hour fcst:',data2=dummy2d)
4785 if (rc /= 1) call
error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
4789 if(slmsk_save(i,j) == 0) dummy2d(i,j) = 0.0_esmf_kind_r4
4790 if(dummy2d(i,j) == grb2_undefined) dummy2d(i,j) = 0.0_esmf_kind_r4
4793 print*,
'weasd ',maxval(dummy2d),minval(dummy2d)
4796 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
4797 call esmf_fieldscatter(snow_liq_equiv_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4798 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4801 if (localpet == 0)
then
4802 print*,
"- READ SNOW DEPTH."
4803 rc = grb2_inq(the_file, inv_file,
':SNOD:',
':surface:', data2=dummy2d)
4805 where(dummy2d == grb2_undefined) dummy2d = 0.0_esmf_kind_r4
4806 dummy2d = dummy2d*1000.0
4807 where(slmsk_save == 0) dummy2d = 0.0_esmf_kind_r4
4808 print*,
'snod ',maxval(dummy2d),minval(dummy2d)
4811 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
4812 call esmf_fieldscatter(snow_depth_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4813 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4816 if (localpet == 0)
then
4817 print*,
"- READ T2M."
4818 rc = grb2_inq(the_file, inv_file,
':TMP:',
':2 m above ground:',data2=dummy2d)
4821 print*,
't2m ',maxval(dummy2d),minval(dummy2d)
4824 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
4825 call esmf_fieldscatter(t2m_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0,rc=rc)
4826 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4829 if (localpet == 0)
then
4830 print*,
"- READ Q2M."
4831 rc = grb2_inq(the_file, inv_file,
':SPFH:',
':2 m above ground:',data2=dummy2d)
4833 print*,
'q2m ',maxval(dummy2d),minval(dummy2d)
4836 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
4837 call esmf_fieldscatter(q2m_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0,rc=rc)
4838 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4841 if (localpet == 0)
then
4842 print*,
"- READ SKIN TEMPERATURE."
4843 rc = grb2_inq(the_file, inv_file,
':TMP:',
':surface:', data2=dummy2d)
4844 if (rc <= 0 ) call
error_handler(
"READING SKIN TEMPERATURE.", rc)
4845 tsk_save(:,:) =
real(dummy2d,esmf_kind_r8)
4846 dummy2d_8 =
real(dummy2d,esmf_kind_r8)
4849 if(slmsk_save(i,j) == 0 .and. dummy2d(i,j) < 271.2)
then
4851 dummy2d(i,j) = 271.2
4853 if(slmsk_save(i,j) == 0 .and. dummy2d(i,j) > 310.)
then
4855 dummy2d(i,j) = 310.0
4861 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
4862 call esmf_fieldscatter(skin_temp_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4863 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4866 if (localpet == 0) dummy2d = 0.0
4868 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
4869 call esmf_fieldscatter(srflag_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0,rc=rc)
4870 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4873 if (localpet == 0)
then
4874 print*,
"- READ SOIL TYPE."
4877 rc = grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
4879 if (rc <= 0 .and. (trim(
to_upper(external_model))==
"HRRR" .or. rap_latlon) .and. geo_file .ne.
"NULL")
then
4883 print*,
"OPEN GEOGRID FILE ", trim(geo_file)
4884 rc = nf90_open(geo_file,nf90_nowrite,ncid2d)
4887 print*,
"INQURE ABOUT DIM IDS"
4888 rc = nf90_inq_dimid(ncid2d,
"west_east",varid)
4889 call
netcdf_err(rc,
"READING west_east DIMENSION FROM GEOGRID FILE")
4891 rc = nf90_inquire_dimension(ncid2d,varid,len=varsize)
4892 call
netcdf_err(rc,
"READING west_east DIMENSION SIZE")
4893 if (varsize .ne. i_input) call
error_handler(
"GEOGRID FILE GRID SIZE DIFFERS FROM INPUT DATA.", -1)
4895 print*,
"INQUIRE ABOUT SOIL TYPE FROM GEOGRID FILE"
4896 rc = nf90_inq_varid(ncid2d,
"SCT_DOM",varid)
4897 call
netcdf_err(rc,
"FINDING SCT_DOM IN GEOGRID FILE")
4899 print*,
"READ SOIL TYPE FROM GEOGRID FILE "
4900 rc = nf90_get_var(ncid2d,varid,dummy2d)
4901 call
netcdf_err(rc,
"READING SCT_DOM FROM FILE")
4903 print*,
"INQUIRE ABOUT SOIL TYPE FRACTIONS FROM GEOGRID FILE"
4904 rc = nf90_inq_varid(ncid2d,
"SOILCTOP",varid)
4905 call
netcdf_err(rc,
"FINDING SOILCTOP IN GEOGRID FILE")
4907 print*,
"READ SOIL TYPE FRACTIONS FROM GEOGRID FILE "
4908 rc = nf90_get_var(ncid2d,varid,dummy3d_stype)
4909 call
netcdf_err(rc,
"READING SCT_DOM FROM FILE")
4911 print*,
"CLOSE GEOGRID FILE "
4912 iret = nf90_close(ncid2d)
4920 if(dummy2d(i,j) == 14.0_esmf_kind_r4 .and. slmsk_save(i,j) == 1)
then
4921 dummy1d(:) = dummy3d_stype(i,j,:)
4922 dummy1d(14) = 0.0_esmf_kind_r4
4923 dummy2d(i,j) =
real(MAXLOC(dummy1d, 1),esmf_kind_r4)
4929 if ((rc <= 0 .and. trim(
to_upper(external_model)) /=
"HRRR" .and. .not. rap_latlon) &
4930 .or. (rc < 0 .and. (trim(
to_upper(external_model)) ==
"HRRR" .or. rap_latlon)))
then
4931 if (.not. sotyp_from_climo)
then
4932 call
error_handler(
"COULD NOT FIND SOIL TYPE IN FILE. PLEASE SET SOTYP_FROM_CLIMO=.TRUE. . EXITING", rc)
4935 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
4939 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. WILL NOT "//&
4940 "SCALE SOIL MOISTURE FOR DIFFERENCES IN SOIL TYPE. "
4941 dummy2d(:,:) = -99999.0_esmf_kind_r4
4949 if (.not. sotyp_from_climo)
then
4952 if(dummy2d(i,j) == 14.0_esmf_kind_r4 .and. slmsk_save(i,j) == 1) dummy2d(i,j) = -99999.9
4956 dummy2d_8 =
real(dummy2d,esmf_kind_r8)
4958 where(slmsk_save == 1) dummy2d_i = 1
4960 call
search(dummy2d_8,dummy2d_i,i_input,j_input,1,230)
4962 dummy2d_8=
real(dummy2d,esmf_kind_r8)
4965 print*,
'sotype ',maxval(dummy2d_8),minval(dummy2d_8)
4966 deallocate(dummy2d_i)
4967 deallocate(dummy3d_stype)
4971 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
4972 call esmf_fieldscatter(soil_type_input_grid,dummy2d_8, rootpet=0, rc=rc)
4973 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4981 if (.not. vgfrc_from_climo)
then
4982 if (localpet == 0)
then
4983 print*,
"- READ VEG FRACTION."
4986 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
4990 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
4993 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1105:', data2=dummy2d)
4995 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1101:', data2=dummy2d)
4997 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1151:', data2=dummy2d)
4998 if (rc <= 0) call
error_handler(
"COULD NOT DETERMINE VEGETATION FRACTION IN FILE. &
4999 RECORD NUMBERS MAY HAVE CHANGED. PLEASE SET VGFRC_FROM_CLIMO=.TRUE. EXITING", rc)
5002 elseif (rc <= 0)
then
5003 call
error_handler(
"COULD NOT FIND VEGETATION FRACTION IN FILE. &
5004 PLEASE SET VGFRC_FROM_CLIMO=.TRUE. EXITING", rc)
5006 if(maxval(dummy2d) > 2.0) dummy2d = dummy2d / 100.0_esmf_kind_r4
5007 print*,
'vfrac ',maxval(dummy2d),minval(dummy2d)
5011 print*,
"- CALL FieldScatter FOR INPUT GRID VEG GREENNESS."
5012 call esmf_fieldscatter(veg_greenness_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0, rc=rc)
5013 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5017 if (.not. minmax_vgfrc_from_climo)
then
5018 if (localpet == 0)
then
5019 print*,
"- READ MIN VEG FRACTION."
5022 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5025 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1106:',data2=dummy2d)
5028 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1102:',data2=dummy2d)
5030 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1152:',data2=dummy2d)
5031 if (rc<=0) call
error_handler(
"COULD NOT FIND MIN VEGETATION FRACTION IN FILE. &
5032 PLEASE SET MINMAX_VGFRC_FROM_CLIMO=.TRUE. . EXITING",rc)
5035 if(maxval(dummy2d) > 2.0) dummy2d = dummy2d / 100.0_esmf_kind_r4
5036 print*,
'vfrac min',maxval(dummy2d),minval(dummy2d)
5040 print*,
"- CALL FieldScatter FOR INPUT GRID MIN VEG GREENNESS."
5041 call esmf_fieldscatter(min_veg_greenness_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0, rc=rc)
5042 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5045 if (localpet == 0)
then
5046 print*,
"- READ MAX VEG FRACTION."
5049 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5053 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1107:',data2=dummy2d)
5055 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1103:',data2=dummy2d)
5057 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1153:',data2=dummy2d)
5058 if (rc <= 0) call
error_handler(
"COULD NOT FIND MAX VEGETATION FRACTION IN FILE. &
5059 PLEASE SET MINMAX_VGFRC_FROM_CLIMO=.TRUE. . EXITING",rc)
5062 if(maxval(dummy2d) > 2.0) dummy2d = dummy2d / 100.0_esmf_kind_r4
5063 print*,
'vfrac max',maxval(dummy2d),minval(dummy2d)
5067 print*,
"- CALL FieldScatter FOR INPUT GRID MAX VEG GREENNESS."
5068 call esmf_fieldscatter(max_veg_greenness_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
5069 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5073 if (.not. lai_from_climo)
then
5074 if (localpet == 0)
then
5075 print*,
"- READ LAI."
5078 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5080 vname=
":var0_7_198:"
5081 rc= grb2_inq(the_file, inv_file, vname,slev,
':n=1108:',data2=dummy2d)
5083 rc= grb2_inq(the_file, inv_file, vname,slev,
':n=1104:',data2=dummy2d)
5085 rc= grb2_inq(the_file, inv_file, vname,slev,
':n=1154:',data2=dummy2d)
5086 if (rc <= 0) call
error_handler(
"COULD NOT FIND LAI IN FILE. &
5087 PLEASE SET LAI_FROM_CLIMO=.TRUE. . EXITING",rc)
5090 print*,
'lai',maxval(dummy2d),minval(dummy2d)
5093 print*,
"- CALL FieldScatter FOR INPUT GRID LAI."
5094 call esmf_fieldscatter(lai_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
5095 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5099 if (localpet == 0)
then
5100 print*,
"- READ SEAICE DEPTH."
5103 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5106 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5110 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL BE"//&
5111 " REPLACED WITH CLIMO. SET A FILL "// &
5112 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5113 dummy2d(:,:) = 0.0_esmf_kind_r4
5116 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5117 print*,
'hice ',maxval(dummy2d),minval(dummy2d)
5121 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
5122 call esmf_fieldscatter(seaice_depth_input_grid,dummy2d_8, rootpet=0, rc=rc)
5123 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5126 if (localpet == 0)
then
5127 print*,
"- READ TPRCP."
5130 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5133 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5137 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
5138 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
5139 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5140 dummy2d(:,:) = 0.0_esmf_kind_r4
5143 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5144 print*,
'tprcp ',maxval(dummy2d),minval(dummy2d)
5147 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
5148 call esmf_fieldscatter(tprcp_input_grid,dummy2d_8, rootpet=0, rc=rc)
5149 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5152 if (localpet == 0)
then
5153 print*,
"- READ FFMM."
5156 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5159 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5163 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
5164 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
5165 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5166 dummy2d(:,:) = 0.0_esmf_kind_r4
5169 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5170 print*,
'ffmm ',maxval(dummy2d),minval(dummy2d)
5173 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
5174 call esmf_fieldscatter(ffmm_input_grid,dummy2d_8, rootpet=0, rc=rc)
5175 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5178 if (localpet == 0)
then
5179 print*,
"- READ USTAR."
5182 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5185 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5189 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL "//&
5190 "REPLACED WITH CLIMO. SET A FILL "// &
5191 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5192 dummy2d(:,:) = 0.0_esmf_kind_r4
5195 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5196 print*,
'fricv ',maxval(dummy2d),minval(dummy2d)
5199 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
5200 call esmf_fieldscatter(ustar_input_grid,dummy2d_8, rootpet=0, rc=rc)
5201 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5204 if (localpet == 0)
then
5205 print*,
"- READ F10M."
5207 slev=
":10 m above ground:"
5208 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5211 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5215 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
5216 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
5217 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5218 dummy2d(:,:) = 0.0_esmf_kind_r4
5221 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5222 print*,
'f10m ',maxval(dummy2d),minval(dummy2d)
5225 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
5226 call esmf_fieldscatter(f10m_input_grid,dummy2d_8, rootpet=0, rc=rc)
5227 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5230 if (localpet == 0)
then
5231 print*,
"- READ CANOPY MOISTURE CONTENT."
5234 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5237 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5241 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL"//&
5242 " REPLACED WITH CLIMO. SET A FILL "// &
5243 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5244 dummy2d(:,:) = 0.0_esmf_kind_r4
5248 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5249 print*,
'cnwat ',maxval(dummy2d),minval(dummy2d)
5252 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
5253 call esmf_fieldscatter(canopy_mc_input_grid,dummy2d_8, rootpet=0, rc=rc)
5254 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5257 if (localpet == 0)
then
5261 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5264 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5268 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL BE"//&
5269 " REPLACED WITH CLIMO. SET A FILL "// &
5270 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5271 dummy2d(:,:) = 0.0_esmf_kind_r4
5275 dummy2d(:,:) = dummy2d(:,:)*10.0
5277 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5278 print*,
'sfcr ',maxval(dummy2d),minval(dummy2d)
5282 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
5283 call esmf_fieldscatter(z0_input_grid,dummy2d_8, rootpet=0, rc=rc)
5284 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5288 if (localpet == 0)
then
5289 print*,
"- READ LIQUID SOIL MOISTURE."
5291 vname_file =
":SOILL:"
5292 call
read_grib_soil(the_file,inv_file,vname,vname_file,dummy3d,rc)
5294 print*,
'soill ',maxval(dummy3d),minval(dummy3d)
5297 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
5298 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
5299 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5302 if (localpet == 0)
then
5303 print*,
"- READ TOTAL SOIL MOISTURE."
5306 vname_file =
"var2_2_1_"
5307 call
read_grib_soil(the_file,inv_file,vname,vname_file,dummy3d,rc)
5308 print*,
'soilm ',maxval(dummy3d),minval(dummy3d)
5311 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
5312 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
5313 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5322 print*,
"- CALL FieldGather for INPUT SOIL TYPE."
5323 call esmf_fieldgather(soil_type_input_grid, dummy2d_82, rootpet=0, tile=1, rc=rc)
5324 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5326 if (localpet == 0)
then
5327 print*,
"- READ VEG TYPE."
5330 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
5336 rc= grb2_inq(the_file, inv_file, vname,
"_0_198:",slev,
' hour fcst:', data2=dummy2d)
5338 rc= grb2_inq(the_file, inv_file, vname,
"_0_198:",slev,
':anl:', data2=dummy2d)
5340 if (.not. vgtyp_from_climo)
then
5341 call
error_handler(
"COULD NOT FIND VEGETATION TYPE IN FILE. PLEASE SET VGTYP_FROM_CLIMO=.TRUE. . EXITING", rc)
5345 dummy2d(i,j) = 0.0_esmf_kind_r4
5346 if(slmsk_save(i,j) == 1 .and. dummy3d(i,j,1) > 0.99) &
5347 dummy2d(i,j) =
real(veg_type_landice_input,esmf_kind_r4)
5354 if (trim(external_model) .ne.
"GFS")
then
5357 if (dummy2d(i,j) == 15.0_esmf_kind_r4 .and. slmsk_save(i,j) == 1)
then
5358 if (dummy3d(i,j,1) < 0.6)
then
5359 dummy2d(i,j) =
real(veg_type_landice_input,esmf_kind_r4)
5360 elseif (dummy3d(i,j,1) > 0.99)
then
5362 dummy2d(i,j) = 0.0_esmf_kind_r4
5363 dummy2d_82(i,j) = 0.0_esmf_kind_r8
5365 elseif (dummy2d(i,j) == 17.0_esmf_kind_r4 .and. slmsk_save(i,j)==0)
then
5366 dummy2d(i,j) = 0.0_esmf_kind_r4
5371 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5372 print*,
'vgtyp ',maxval(dummy2d),minval(dummy2d)
5375 print*,
"- CALL FieldScatter FOR INPUT VEG TYPE."
5376 call esmf_fieldscatter(veg_type_input_grid, dummy2d_8, rootpet=0, rc=rc)
5377 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5380 print*,
"- CALL FieldScatter FOR INPUT VEG TYPE."
5381 call esmf_fieldscatter(soil_type_input_grid, dummy2d_82, rootpet=0, rc=rc)
5382 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5385 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
5386 call esmf_fieldscatter(landsea_mask_input_grid,
real(slmsk_save,esmf_kind_r8),rootpet=0, rc=rc)
5387 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5397 if (localpet == 0)
then
5398 print*,
"- READ SOIL TEMPERATURE."
5400 vname_file =
":TSOIL:"
5401 call
read_grib_soil(the_file,inv_file,vname,vname_file,dummy3d,rc)
5403 print*,
'soilt ',maxval(dummy3d),minval(dummy3d)
5405 deallocate(tsk_save, slmsk_save)
5408 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
5409 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
5410 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5414 deallocate(dummy2d_8)
5427 integer,
intent(in) :: localpet
5429 character(len=10) :: field
5433 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
5435 if (localpet == 0)
then
5436 allocate(data_one_tile(i_input,j_input))
5438 allocate(data_one_tile(0,0))
5441 tile_loop :
do tile = 1, num_tiles_input_grid
5445 if (localpet == 0)
then
5446 if (trim(input_type) ==
"restart")
then
5452 lsoil_input, sfcdata=data_one_tile)
5455 print*,
"- CALL FieldScatter FOR INPUT C_D"
5456 call esmf_fieldscatter(c_d_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5457 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5462 if (localpet == 0)
then
5463 if (trim(input_type) ==
"restart")
then
5469 lsoil_input, sfcdata=data_one_tile)
5472 print*,
"- CALL FieldScatter FOR INPUT C_0"
5473 call esmf_fieldscatter(c_0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5474 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5479 if (localpet == 0)
then
5480 if (trim(input_type) ==
"restart")
then
5486 lsoil_input, sfcdata=data_one_tile)
5489 print*,
"- CALL FieldScatter FOR INPUT D_CONV."
5490 call esmf_fieldscatter(d_conv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5491 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5496 if (localpet == 0)
then
5497 if (trim(input_type) ==
"restart")
then
5503 lsoil_input, sfcdata=data_one_tile)
5506 print*,
"- CALL FieldScatter FOR INPUT DT_COOL."
5507 call esmf_fieldscatter(dt_cool_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5508 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5513 if (localpet == 0)
then
5517 print*,
"- CALL FieldScatter FOR INPUT IFD."
5518 call esmf_fieldscatter(ifd_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5519 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5524 if (localpet == 0)
then
5526 lsoil_input, sfcdata=data_one_tile)
5529 print*,
"- CALL FieldScatter FOR INPUT QRAIN."
5530 call esmf_fieldscatter(qrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5531 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5536 if (localpet == 0)
then
5538 lsoil_input, sfcdata=data_one_tile)
5541 print*,
"- CALL FieldScatter FOR INPUT TREF"
5542 call esmf_fieldscatter(tref_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5543 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5548 if (localpet == 0)
then
5549 if (trim(input_type) ==
"restart")
then
5555 lsoil_input, sfcdata=data_one_tile)
5558 print*,
"- CALL FieldScatter FOR INPUT W_D"
5559 call esmf_fieldscatter(w_d_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5560 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5565 if (localpet == 0)
then
5566 if (trim(input_type) ==
"restart")
then
5572 lsoil_input, sfcdata=data_one_tile)
5575 print*,
"- CALL FieldScatter FOR INPUT W_0"
5576 call esmf_fieldscatter(w_0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5577 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5582 if (localpet == 0)
then
5584 lsoil_input, sfcdata=data_one_tile)
5587 print*,
"- CALL FieldScatter FOR INPUT XS"
5588 call esmf_fieldscatter(xs_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5589 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5594 if (localpet == 0)
then
5596 lsoil_input, sfcdata=data_one_tile)
5599 print*,
"- CALL FieldScatter FOR INPUT XT"
5600 call esmf_fieldscatter(xt_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5601 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5606 if (localpet == 0)
then
5608 lsoil_input, sfcdata=data_one_tile)
5611 print*,
"- CALL FieldScatter FOR INPUT XU"
5612 call esmf_fieldscatter(xu_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5613 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5618 if (localpet == 0)
then
5620 lsoil_input, sfcdata=data_one_tile)
5623 print*,
"- CALL FieldScatter FOR INPUT XV"
5624 call esmf_fieldscatter(xv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5625 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5630 if (localpet == 0)
then
5632 lsoil_input, sfcdata=data_one_tile)
5635 print*,
"- CALL FieldScatter FOR INPUT XZ"
5636 call esmf_fieldscatter(xz_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5637 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5642 if (localpet == 0)
then
5644 lsoil_input, sfcdata=data_one_tile)
5647 print*,
"- CALL FieldScatter FOR INPUT XTTS"
5648 call esmf_fieldscatter(xtts_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
5656 lsoil_input, sfcdata=data_one_tile)
5659 print*,
"- CALL FieldScatter FOR INPUT XZTS"
5660 call esmf_fieldscatter(xzts_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5661 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5666 if (localpet == 0)
then
5667 if (trim(input_type) ==
"restart")
then
5673 lsoil_input, sfcdata=data_one_tile)
5676 print*,
"- CALL FieldScatter FOR INPUT Z_C"
5677 call esmf_fieldscatter(z_c_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
5687 print*,
"- CALL FieldScatter FOR INPUT ZM"
5688 call esmf_fieldscatter(zm_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5689 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5694 deallocate(data_one_tile)
5711 integer,
intent(in) :: localpet
5713 character(len=300) :: the_file
5717 real(nemsio_realkind),
allocatable :: dummy(:)
5718 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
5720 type(nemsio_gfile
) :: gfile
5722 if (trim(input_type) ==
"gfs_gaussian_nemsio")
then
5724 the_file = trim(data_dir_input_grid) //
"/" // trim(nst_files_input_grid)
5726 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
5729 print*,
"- READ NST DATA FROM: ", trim(the_file)
5731 if (localpet == 0)
then
5732 allocate(dummy(i_input*j_input))
5733 allocate(dummy2d(i_input,j_input))
5734 call nemsio_open(gfile, the_file,
"read", iret=rc)
5737 allocate(dummy2d(0,0))
5740 if (localpet == 0)
then
5741 print*,
"- READ TREF"
5742 call nemsio_readrecv(gfile,
"tref",
"sfc", 1, dummy, 0, iret=rc)
5744 dummy2d = reshape(dummy, (/i_input,j_input/))
5745 print*,
'tref ',maxval(dummy2d),minval(dummy2d)
5748 print*,
"- CALL FieldScatter FOR INPUT TREF."
5749 call esmf_fieldscatter(tref_input_grid, dummy2d, rootpet=0, rc=rc)
5750 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5753 if (localpet == 0)
then
5755 call nemsio_readrecv(gfile,
"cd",
"sfc", 1, dummy, 0, iret=rc)
5757 dummy2d = reshape(dummy, (/i_input,j_input/))
5758 print*,
'cd ',maxval(dummy2d),minval(dummy2d)
5761 print*,
"- CALL FieldScatter FOR INPUT C_D."
5762 call esmf_fieldscatter(c_d_input_grid, dummy2d, rootpet=0, rc=rc)
5763 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5766 if (localpet == 0)
then
5768 call nemsio_readrecv(gfile,
"c0",
"sfc", 1, dummy, 0, iret=rc)
5770 dummy2d = reshape(dummy, (/i_input,j_input/))
5771 print*,
'c0 ',maxval(dummy2d),minval(dummy2d)
5774 print*,
"- CALL FieldScatter FOR INPUT C_0."
5775 call esmf_fieldscatter(c_0_input_grid, dummy2d, rootpet=0, rc=rc)
5776 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5779 if (localpet == 0)
then
5780 print*,
"- READ DCONV"
5781 call nemsio_readrecv(gfile,
"dconv",
"sfc", 1, dummy, 0, iret=rc)
5783 dummy2d = reshape(dummy, (/i_input,j_input/))
5784 print*,
'dconv ',maxval(dummy2d),minval(dummy2d)
5787 print*,
"- CALL FieldScatter FOR INPUT D_CONV."
5788 call esmf_fieldscatter(d_conv_input_grid, dummy2d, rootpet=0, rc=rc)
5789 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5792 if (localpet == 0)
then
5793 print*,
"- READ DTCOOL"
5794 call nemsio_readrecv(gfile,
"dtcool",
"sfc", 1, dummy, 0, iret=rc)
5796 dummy2d = reshape(dummy, (/i_input,j_input/))
5797 print*,
'dtcool ',maxval(dummy2d),minval(dummy2d)
5800 print*,
"- CALL FieldScatter FOR INPUT DT_COOL."
5801 call esmf_fieldscatter(dt_cool_input_grid, dummy2d, rootpet=0, rc=rc)
5802 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5805 if (localpet == 0)
then
5809 print*,
"- CALL FieldScatter FOR INPUT IFD."
5810 call esmf_fieldscatter(ifd_input_grid, dummy2d, rootpet=0, rc=rc)
5811 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5814 if (localpet == 0)
then
5815 print*,
"- READ QRAIN"
5816 call nemsio_readrecv(gfile,
"qrain",
"sfc", 1, dummy, 0, iret=rc)
5818 dummy2d = reshape(dummy, (/i_input,j_input/))
5819 print*,
'qrain ',maxval(dummy2d),minval(dummy2d)
5822 print*,
"- CALL FieldScatter FOR INPUT QRAIN."
5823 call esmf_fieldscatter(qrain_input_grid, dummy2d, rootpet=0, rc=rc)
5824 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5827 if (localpet == 0)
then
5829 call nemsio_readrecv(gfile,
"wd",
"sfc", 1, dummy, 0, iret=rc)
5831 dummy2d = reshape(dummy, (/i_input,j_input/))
5832 print*,
'wd ',maxval(dummy2d),minval(dummy2d)
5835 print*,
"- CALL FieldScatter FOR INPUT WD."
5836 call esmf_fieldscatter(w_d_input_grid, dummy2d, rootpet=0, rc=rc)
5837 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5840 if (localpet == 0)
then
5842 call nemsio_readrecv(gfile,
"w0",
"sfc", 1, dummy, 0, iret=rc)
5844 dummy2d = reshape(dummy, (/i_input,j_input/))
5845 print*,
'w0 ',maxval(dummy2d),minval(dummy2d)
5848 print*,
"- CALL FieldScatter FOR INPUT W0."
5849 call esmf_fieldscatter(w_0_input_grid, dummy2d, rootpet=0, rc=rc)
5850 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5853 if (localpet == 0)
then
5855 call nemsio_readrecv(gfile,
"xs",
"sfc", 1, dummy, 0, iret=rc)
5857 dummy2d = reshape(dummy, (/i_input,j_input/))
5858 print*,
'xs ',maxval(dummy2d),minval(dummy2d)
5861 print*,
"- CALL FieldScatter FOR INPUT XS."
5862 call esmf_fieldscatter(xs_input_grid, dummy2d, rootpet=0, rc=rc)
5863 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5866 if (localpet == 0)
then
5868 call nemsio_readrecv(gfile,
"xt",
"sfc", 1, dummy, 0, iret=rc)
5870 dummy2d = reshape(dummy, (/i_input,j_input/))
5871 print*,
'xt ',maxval(dummy2d),minval(dummy2d)
5874 print*,
"- CALL FieldScatter FOR INPUT XT."
5875 call esmf_fieldscatter(xt_input_grid, dummy2d, rootpet=0, rc=rc)
5876 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5879 if (localpet == 0)
then
5881 call nemsio_readrecv(gfile,
"xu",
"sfc", 1, dummy, 0, iret=rc)
5883 dummy2d = reshape(dummy, (/i_input,j_input/))
5884 print*,
'xu ',maxval(dummy2d),minval(dummy2d)
5887 print*,
"- CALL FieldScatter FOR INPUT XU."
5888 call esmf_fieldscatter(xu_input_grid, dummy2d, rootpet=0, rc=rc)
5889 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5892 if (localpet == 0)
then
5894 call nemsio_readrecv(gfile,
"xv",
"sfc", 1, dummy, 0, iret=rc)
5896 dummy2d = reshape(dummy, (/i_input,j_input/))
5897 print*,
'xv ',maxval(dummy2d),minval(dummy2d)
5900 print*,
"- CALL FieldScatter FOR INPUT XV."
5901 call esmf_fieldscatter(xv_input_grid, dummy2d, rootpet=0, rc=rc)
5902 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5905 if (localpet == 0)
then
5907 call nemsio_readrecv(gfile,
"xz",
"sfc", 1, dummy, 0, iret=rc)
5909 dummy2d = reshape(dummy, (/i_input,j_input/))
5910 print*,
'xz ',maxval(dummy2d),minval(dummy2d)
5913 print*,
"- CALL FieldScatter FOR INPUT XZ."
5914 call esmf_fieldscatter(xz_input_grid, dummy2d, rootpet=0, rc=rc)
5915 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5918 if (localpet == 0)
then
5919 print*,
"- READ XTTS"
5920 call nemsio_readrecv(gfile,
"xtts",
"sfc", 1, dummy, 0, iret=rc)
5922 dummy2d = reshape(dummy, (/i_input,j_input/))
5923 print*,
'xtts ',maxval(dummy2d),minval(dummy2d)
5926 print*,
"- CALL FieldScatter FOR INPUT XTTS."
5927 call esmf_fieldscatter(xtts_input_grid, dummy2d, rootpet=0, rc=rc)
5928 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5931 if (localpet == 0)
then
5932 print*,
"- READ XZTS"
5933 call nemsio_readrecv(gfile,
"xzts",
"sfc", 1, dummy, 0, iret=rc)
5935 dummy2d = reshape(dummy, (/i_input,j_input/))
5936 print*,
'xzts ',maxval(dummy2d),minval(dummy2d)
5939 print*,
"- CALL FieldScatter FOR INPUT XZTS."
5940 call esmf_fieldscatter(xzts_input_grid, dummy2d, rootpet=0, rc=rc)
5941 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5944 if (localpet == 0)
then
5946 call nemsio_readrecv(gfile,
"zc",
"sfc", 1, dummy, 0, iret=rc)
5948 dummy2d = reshape(dummy, (/i_input,j_input/))
5949 print*,
'zc ',maxval(dummy2d),minval(dummy2d)
5952 print*,
"- CALL FieldScatter FOR INPUT Z_C."
5953 call esmf_fieldscatter(z_c_input_grid, dummy2d, rootpet=0, rc=rc)
5954 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5957 if (localpet == 0)
then
5961 print*,
"- CALL FieldScatter FOR INPUT ZM."
5962 call esmf_fieldscatter(zm_input_grid, dummy2d, rootpet=0, rc=rc)
5963 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5966 deallocate(dummy, dummy2d)
5968 if (localpet == 0) call nemsio_close(gfile)
5983 sfcdata, sfcdata_3d)
5987 CHARACTER(LEN=*),
INTENT(IN) :: field
5989 INTEGER,
INTENT(IN) :: imo, jmo, lmo, tile_num
5991 REAL(ESMF_KIND_R8),
INTENT(OUT),
OPTIONAL :: sfcdata(imo,jmo)
5992 REAL(ESMF_KIND_R8),
INTENT(OUT),
OPTIONAL :: sfcdata_3d(imo,jmo,lmo)
5994 CHARACTER(LEN=256) :: tilefile
5996 INTEGER :: error, ncid, id_var
5998 tilefile = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(tile_num))
6000 print*,
'WILL READ ',trim(field),
' FROM: ', trim(tilefile)
6002 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
6003 CALL
netcdf_err(error,
'OPENING: '//trim(tilefile) )
6005 error=nf90_inq_varid(ncid, field, id_var)
6008 IF (present(sfcdata_3d))
THEN
6009 error=nf90_get_var(ncid, id_var, sfcdata_3d)
6012 error=nf90_get_var(ncid, id_var, sfcdata)
6016 error = nf90_close(ncid)
6037 character(len=250),
intent(in) :: file
6038 character(len=10),
intent(in) :: inv
6039 integer,
intent(in) :: localpet
6040 real(esmf_kind_r8),
intent(inout),
allocatable :: u(:,:,:),v(:,:,:)
6042 real(esmf_kind_r4),
dimension(i_input,j_input) :: alpha
6043 real(esmf_kind_r8),
dimension(i_input,j_input) :: lon, lat
6044 real(esmf_kind_r4),
allocatable :: u_tmp(:,:),v_tmp(:,:)
6045 real(esmf_kind_r4),
dimension(i_input,j_input) :: ws,wd
6046 real(esmf_kind_r4) :: value_u, value_v,lov,latin1,latin2
6047 real(esmf_kind_r8) :: d2r
6049 integer :: varnum_u, varnum_v, vlev, &
6052 character(len=20) :: vname
6053 character(len=50) :: method_u, method_v
6054 character(len=250) :: file_coord
6055 character(len=10000) :: temp_msg
6057 d2r=acos(-1.0_esmf_kind_r8) / 180.0_esmf_kind_r8
6058 if (localpet==0)
then
6059 allocate(u(i_input,j_input,lev_input))
6060 allocate(v(i_input,j_input,lev_input))
6066 file_coord = trim(fix_dir_input_grid)//
"/latlon_grid3.32769.nc"
6069 call
get_var_cond(vname,this_miss_var_method=method_u, this_miss_var_value=value_u, &
6072 call
get_var_cond(vname,this_miss_var_method=method_v, this_miss_var_value=value_v, &
6075 if (trim(input_grid_type)==
"rotated_latlon")
then
6076 print*,
"- CALL FieldGather FOR INPUT GRID LONGITUDE"
6077 call esmf_fieldgather(longitude_input_grid, lon, rootpet=0, tile=1, rc=error)
6078 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6080 print*,
"- CALL FieldGather FOR INPUT GRID LATITUDE"
6081 call esmf_fieldgather(latitude_input_grid, lat, rootpet=0, tile=1, rc=error)
6082 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6085 if (localpet==0)
then
6086 print*,
"- CALCULATE ROTATION ANGLE FOR ROTATED_LATLON INPUT GRID"
6087 error = grb2_inq(file, inv,grid_desc=temp_msg)
6096 istr = index(temp_msg,
"lat-center ") + len(
"lat_center ")
6097 read(temp_msg(istr:istr+9),
"(F8.5)") latin1
6098 istr = index(temp_msg,
"lon-center ") + len(
"lon-center ")
6099 read(temp_msg(istr:istr+10),
"(F9.6)") lov
6101 print*,
"- CALL CALCALPHA_ROTLATLON with center lat,lon = ",latin1,lov
6103 print*,
" alpha min/max = ",minval(alpha),maxval(alpha)
6105 elseif (trim(input_grid_type) ==
"lambert")
then
6108 print*,
"- CALL FieldGather FOR INPUT GRID LONGITUDE"
6109 call esmf_fieldgather(longitude_input_grid, lon, rootpet=0, tile=1, rc=error)
6110 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6113 if (localpet==0)
then
6114 error = grb2_inq(file, inv,grid_desc=temp_msg)
6122 istr = index(temp_msg,
"LoV ") + len(
"LoV ")
6123 read(temp_msg(istr:istr+10),
"(F9.6)") lov
6124 istr = index(temp_msg,
"Latin1 ") + len(
"Latin1 ")
6125 read(temp_msg(istr:istr+9),
"(F8.5)") latin1
6126 istr = index(temp_msg,
"Latin2 ") + len(
"Latin2 ")
6127 read(temp_msg(istr:istr+9),
"(F8.5)") latin2
6129 print*,
"- CALL GRIDROT for LC grid with lov,latin1/2 = ",lov,latin1,latin2
6130 call
gridrot(lov,latin1,latin2,lon,alpha)
6131 print*,
" alpha min/max = ",minval(alpha),maxval(alpha)
6135 if (localpet==0)
then
6136 do vlev = 1, lev_input
6139 iret = grb2_inq(file,inv,vname,slevs(vlev),data2=u_tmp)
6141 call
handle_grib_error(vname, slevs(vlev),method_u,value_u,varnum_u,iret,var=u_tmp)
6143 call
error_handler(
"READING IN U AT LEVEL "//trim(slevs(vlev))//
". SET A FILL "// &
6144 "VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",iret)
6149 iret = grb2_inq(file,inv,vname,slevs(vlev),data2=v_tmp)
6151 call
handle_grib_error(vname, slevs(vlev),method_v,value_v,varnum_v,iret,var=v_tmp)
6153 call
error_handler(
"READING IN V AT LEVEL "//trim(slevs(vlev))//
". SET A FILL "// &
6154 "VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",iret)
6158 if (trim(input_grid_type) ==
"latlon")
then
6159 if (external_model ==
'UKMET')
then
6161 v(:,:,vlev) = (v_tmp(:,2:jp1_input) + v_tmp(:,1:j_input))/2
6166 else if (trim(input_grid_type) ==
"rotated_latlon")
then
6167 ws = sqrt(u_tmp**2 + v_tmp**2)
6168 wd = atan2(-u_tmp,-v_tmp) / d2r
6169 wd = wd + alpha + 180.0
6171 u(:,:,vlev) = -ws*cos(wd*d2r)
6172 v(:,:,vlev) = -ws*sin(wd*d2r)
6174 u(:,:,vlev) =
real(u_tmp * cos(alpha) + v_tmp * sin(alpha),esmf_kind_r8)
6175 v(:,:,vlev) =
real(v_tmp * cos(alpha) - u_tmp * sin(alpha),esmf_kind_r8)
6178 print*,
'max, min U ', minval(u(:,:,vlev)), maxval(u(:,:,vlev))
6179 print*,
'max, min V ', minval(v(:,:,vlev)), maxval(v(:,:,vlev))
6192 integer :: clb(4), cub(4)
6193 integer :: i, j, k, rc
6195 real(esmf_kind_r8) :: latrad, lonrad
6196 real(esmf_kind_r8),
pointer :: windptr(:,:,:,:)
6197 real(esmf_kind_r8),
pointer :: uptr(:,:,:)
6198 real(esmf_kind_r8),
pointer :: vptr(:,:,:)
6199 real(esmf_kind_r8),
pointer :: latptr(:,:)
6200 real(esmf_kind_r8),
pointer :: lonptr(:,:)
6202 print*,
"- CALL FieldGet FOR 3-D WIND."
6203 call esmf_fieldget(wind_input_grid, &
6204 computationallbound=clb, &
6205 computationalubound=cub, &
6206 farrayptr=windptr, rc=rc)
6207 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6210 print*,
"- CALL FieldGet FOR U."
6211 call esmf_fieldget(u_input_grid, &
6212 farrayptr=uptr, rc=rc)
6213 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6216 print*,
"- CALL FieldGet FOR V."
6217 call esmf_fieldget(v_input_grid, &
6218 farrayptr=vptr, rc=rc)
6219 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6222 print*,
"- CALL FieldGet FOR LATITUDE."
6223 call esmf_fieldget(latitude_input_grid, &
6224 farrayptr=latptr, rc=rc)
6225 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6228 print*,
"- CALL FieldGet FOR LONGITUDE."
6229 call esmf_fieldget(longitude_input_grid, &
6230 farrayptr=lonptr, rc=rc)
6231 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6234 do i = clb(1), cub(1)
6235 do j = clb(2), cub(2)
6236 latrad = latptr(i,j) * acos(-1.) / 180.0
6237 lonrad = lonptr(i,j) * acos(-1.) / 180.0
6238 do k = clb(3), cub(3)
6239 windptr(i,j,k,1) = uptr(i,j,k) * cos(lonrad) - vptr(i,j,k) * sin(latrad) * sin(lonrad)
6240 windptr(i,j,k,2) = uptr(i,j,k) * sin(lonrad) + vptr(i,j,k) * sin(latrad) * cos(lonrad)
6241 windptr(i,j,k,3) = vptr(i,j,k) * cos(latrad)
6246 call esmf_fielddestroy(u_input_grid, rc=rc)
6247 call esmf_fielddestroy(v_input_grid, rc=rc)
6270 real(esmf_kind_r4),
intent(in) :: lov,latin1,latin2
6271 real(esmf_kind_r4),
intent(inout) :: rot(i_input,j_input)
6272 real(esmf_kind_r8),
intent(in) :: lon(i_input,j_input)
6274 real(esmf_kind_r4) :: trot(i_input,j_input), tlon(i_input,j_input)
6275 real(esmf_kind_r4) :: dtor = 3.14159265359/180.0_esmf_kind_r4
6276 real(esmf_kind_r4) :: an
6282 if ( (latin1 - latin2) .lt. 0.000001 )
then
6283 an = sin(latin1*dtor)
6285 an = log( cos(latin1*dtor) / cos(latin2*dtor) ) / &
6286 log( tan(dtor*(90.0-latin1)/2.) / tan(dtor*(90.0-latin2)/2.))
6289 tlon = mod(lon - lov + 180. + 3600., 360.) - 180.
6310 real(esmf_kind_r8),
intent(in) :: latgrid(i_input,j_input), &
6311 longrid(i_input,j_input)
6312 real(esmf_kind_r4),
intent(in) :: cenlat, cenlon
6313 real(esmf_kind_r4),
intent(out) :: alpha(i_input,j_input)
6316 real(esmf_kind_r8) :: d2r,lon0_r,lat0_r,sphi0,cphi0
6317 real(esmf_kind_r8),
DIMENSION(i_input,j_input) :: tlat,tlon,tph,sinalpha
6319 d2r = acos(-1.0_esmf_kind_r8) / 180.0_esmf_kind_r8
6320 if (cenlon .lt. 0)
then
6321 lon0_r = (cenlon + 360.0)*d2r
6330 tlat = latgrid * d2r
6331 tlon = longrid * d2r
6334 tlon = -tlon + lon0_r
6335 tph = asin(cphi0*sin(tlat) - sphi0*cos(tlat)*cos(tlon))
6336 sinalpha = sphi0 * sin(tlon) / cos(tph)
6337 alpha = -asin(sinalpha)/d2r
6356 use,
intrinsic :: ieee_arithmetic
6360 real(esmf_kind_r4),
intent(in) :: value
6361 real(esmf_kind_r4),
intent(inout),
optional :: var(:,:)
6362 real(esmf_kind_r8),
intent(inout),
optional :: var8(:,:)
6363 real(esmf_kind_r8),
intent(inout),
optional :: var3d(:,:,:)
6365 character(len=20),
intent(in) :: vname, lev, method
6367 integer,
intent(in) :: varnum
6368 integer,
intent(inout) :: iret
6371 if (varnum == 9999)
then
6372 print*,
"WARNING: ", trim(vname),
" NOT FOUND AT LEVEL ", lev,
" IN EXTERNAL FILE ", &
6373 "AND NO ENTRY EXISTS IN VARMAP TABLE. VARIABLE WILL NOT BE USED."
6379 if (trim(method) ==
"skip" )
then
6380 print*,
"WARNING: SKIPPING ", trim(vname),
" IN FILE"
6381 read_from_input(varnum) = .false.
6383 elseif (trim(method) ==
"set_to_fill")
then
6384 print*,
"WARNING: ,", trim(vname),
" NOT AVILABLE AT LEVEL ", trim(lev), &
6385 ". SETTING EQUAL TO FILL VALUE OF ", value
6386 if(present(var)) var(:,:) = value
6387 if(present(var8)) var8(:,:) = value
6388 if(present(var3d)) var3d(:,:,:) = value
6389 elseif (trim(method) ==
"set_to_NaN")
then
6390 print*,
"WARNING: ,", trim(vname),
" NOT AVILABLE AT LEVEL ", trim(lev), &
6391 ". SETTING EQUAL TO NaNs"
6392 if(present(var)) var(:,:) = ieee_value(var,ieee_quiet_nan)
6393 if(present(var8)) var8(:,:) = ieee_value(var8,ieee_quiet_nan)
6394 if(present(var3d)) var3d(:,:,:) = ieee_value(var3d,ieee_quiet_nan)
6395 elseif (trim(method) ==
"stop")
then
6396 call
error_handler(
"READING "//trim(vname)//
" at level "//lev//
". TO MAKE THIS NON- &
6397 FATAL, CHANGE STOP TO SKIP FOR THIS VARIABLE IN YOUR VARMAP &
6400 call
error_handler(
"ERROR USING MISSING_VAR_METHOD. PLEASE SET VALUES IN" // &
6401 " VARMAP TABLE TO ONE OF: set_to_fill, set_to_NaN,"// &
6402 " , skip, or stop.", 1)
6421 character(len=*),
intent(in) :: the_file, inv_file
6422 character(len=20),
intent(in) :: vname,vname_file
6424 integer,
intent(out) :: rc
6426 real(esmf_kind_r8),
intent(inout) :: dummy3d(:,:,:)
6428 real(esmf_kind_r4),
allocatable :: dummy2d(:,:)
6429 real(esmf_kind_r4) :: value
6431 character(len=50) :: slevs(lsoil_input)
6432 character(len=50) :: method
6434 allocate(dummy2d(i_input,j_input))
6436 if(lsoil_input == 4)
then
6437 slevs = (/
character(24)::
':0-0.1 m below ground:',
':0.1-0.4 m below ground:', &
6438 ':0.4-1 m below ground:',
':1-2 m below ground:'/)
6439 elseif(lsoil_input == 9)
then
6440 slevs = (/
character(26)::
':0-0 m below ground',
':0.01-0.01 m below ground:',
':0.04-0.04 m below ground:', &
6441 ':0.1-0.1 m below ground:',
':0.3-0.3 m below ground:',
':0.6-0.6 m below ground:', &
6442 ':1-1 m below ground:',
':1.6-1.6 m below ground:',
':3-3 m below ground:'/)
6445 call
error_handler(
"reading soil levels. File must have 4 or 9 soil levels.", rc)
6448 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
6450 do i = 1,lsoil_input
6451 if (vname_file==
"var2_2_1_")
then
6452 rc = grb2_inq(the_file,inv_file,vname_file,
"_0_192:",slevs(i),data2=dummy2d)
6454 rc = grb2_inq(the_file,inv_file,vname_file,slevs(i),data2=dummy2d)
6458 if (rc==1 .and. trim(vname) /=
"soill")
then
6460 call
error_handler(
"READING IN "//trim(vname)//
". SET A FILL "// &
6461 "VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",rc)
6463 dummy3d(:,:,:) = 0.0_esmf_kind_r8
6468 dummy3d(:,:,i) =
real(dummy2d,esmf_kind_r8)
6484 print*,
'- DESTROY ATMOSPHERIC INPUT DATA.'
6486 call esmf_fielddestroy(terrain_input_grid, rc=rc)
6487 call esmf_fielddestroy(pres_input_grid, rc=rc)
6488 call esmf_fielddestroy(dzdt_input_grid, rc=rc)
6489 call esmf_fielddestroy(temp_input_grid, rc=rc)
6490 call esmf_fielddestroy(wind_input_grid, rc=rc)
6491 call esmf_fielddestroy(ps_input_grid, rc=rc)
6493 do n = 1, num_tracers_input
6494 call esmf_fielddestroy(tracers_input_grid(n), rc=rc)
6496 deallocate(tracers_input_grid)
6509 print*,
'- DESTROY NST INPUT DATA.'
6511 call esmf_fielddestroy(landsea_mask_input_grid, rc=rc)
6512 call esmf_fielddestroy(c_d_input_grid, rc=rc)
6513 call esmf_fielddestroy(c_0_input_grid, rc=rc)
6514 call esmf_fielddestroy(d_conv_input_grid, rc=rc)
6515 call esmf_fielddestroy(dt_cool_input_grid, rc=rc)
6516 call esmf_fielddestroy(ifd_input_grid, rc=rc)
6517 call esmf_fielddestroy(qrain_input_grid, rc=rc)
6518 call esmf_fielddestroy(tref_input_grid, rc=rc)
6519 call esmf_fielddestroy(w_d_input_grid, rc=rc)
6520 call esmf_fielddestroy(w_0_input_grid, rc=rc)
6521 call esmf_fielddestroy(xs_input_grid, rc=rc)
6522 call esmf_fielddestroy(xt_input_grid, rc=rc)
6523 call esmf_fielddestroy(xu_input_grid, rc=rc)
6524 call esmf_fielddestroy(xv_input_grid, rc=rc)
6525 call esmf_fielddestroy(xz_input_grid, rc=rc)
6526 call esmf_fielddestroy(xtts_input_grid, rc=rc)
6527 call esmf_fielddestroy(xzts_input_grid, rc=rc)
6528 call esmf_fielddestroy(z_c_input_grid, rc=rc)
6529 call esmf_fielddestroy(zm_input_grid, rc=rc)
6542 print*,
"- CALL FieldDestroy FOR INPUT GRID FIELDS."
6544 call esmf_fielddestroy(canopy_mc_input_grid, rc=rc)
6545 call esmf_fielddestroy(f10m_input_grid, rc=rc)
6546 call esmf_fielddestroy(ffmm_input_grid, rc=rc)
6547 if (.not. convert_nst)
then
6548 call esmf_fielddestroy(landsea_mask_input_grid, rc=rc)
6550 call esmf_fielddestroy(q2m_input_grid, rc=rc)
6551 call esmf_fielddestroy(seaice_depth_input_grid, rc=rc)
6552 call esmf_fielddestroy(seaice_fract_input_grid, rc=rc)
6553 call esmf_fielddestroy(seaice_skin_temp_input_grid, rc=rc)
6554 call esmf_fielddestroy(skin_temp_input_grid, rc=rc)
6555 call esmf_fielddestroy(snow_depth_input_grid, rc=rc)
6556 call esmf_fielddestroy(snow_liq_equiv_input_grid, rc=rc)
6557 call esmf_fielddestroy(soil_temp_input_grid, rc=rc)
6558 call esmf_fielddestroy(soil_type_input_grid, rc=rc)
6559 call esmf_fielddestroy(soilm_liq_input_grid, rc=rc)
6560 call esmf_fielddestroy(soilm_tot_input_grid, rc=rc)
6561 call esmf_fielddestroy(srflag_input_grid, rc=rc)
6562 call esmf_fielddestroy(t2m_input_grid, rc=rc)
6563 call esmf_fielddestroy(tprcp_input_grid, rc=rc)
6564 call esmf_fielddestroy(ustar_input_grid, rc=rc)
6565 call esmf_fielddestroy(veg_type_input_grid, rc=rc)
6566 call esmf_fielddestroy(z0_input_grid, rc=rc)
6567 call esmf_fielddestroy(terrain_input_grid, rc=rc)
6568 if (.not. vgfrc_from_climo)
then
6569 call esmf_fielddestroy(veg_greenness_input_grid, rc=rc)
6571 if (.not. minmax_vgfrc_from_climo)
then
6572 call esmf_fielddestroy(min_veg_greenness_input_grid, rc=rc)
6573 call esmf_fielddestroy(max_veg_greenness_input_grid, rc=rc)
6575 if (.not. lai_from_climo)
then
6576 call esmf_fielddestroy(lai_input_grid, rc=rc)
6593 x = a( (first+last) / 2 )
6604 t = a(i); a(i) = a(j); a(j) = t
6608 if (first < i-1) call
quicksort(a, first, i-1)
6609 if (j+1 < last) call
quicksort(a, j+1, last)
6628 real(esmf_kind_r8),
intent(inout) :: soilt(i_input,j_input,lsoil_input)
6629 real(esmf_kind_r8),
intent(in) :: skint(i_input,j_input)
6630 integer(esmf_kind_i4),
intent(in) :: landmask(i_input,j_input)
6637 if (landmask(i,j) == 0_esmf_kind_i4 )
then
6638 soilt(i,j,k) = skint(i,j)
6639 else if (landmask(i,j) == 1_esmf_kind_i4 .and. soilt(i,j,k) > 350.0_esmf_kind_r8)
then
6640 soilt(i,j,k) = skint(i,j)
6641 else if (landmask(i,j) == 2_esmf_kind_i4 )
then
6642 soilt(i,j,k) = icet_default
6658 real(esmf_kind_r4),
intent(inout) :: cnwat(i_input,j_input)
6660 real(esmf_kind_r4) :: max_cnwat = 0.5
6666 if (cnwat(i,j) .gt. max_cnwat) cnwat(i,j) = 0.0_esmf_kind_r4
Sets up the ESMF grid objects for the input data grid and target FV3 grid.
Replace undefined values with a valid value.
subroutine netcdf_err(err, string)
Error handler for netcdf.
character(len=len(strin)) function to_upper(strIn)
Convert string from lower to uppercase.
subroutine error_handler(string, rc)
General error handler.
This module contains code to read the setup namelist file, handle the varmap file for GRIB2 data...
subroutine rh2spfh(rh_sphum, p, t)
Convert relative humidity to specific humidity.
subroutine, public get_var_cond(var_name, this_miss_var_method, this_miss_var_value, this_field_var_name, loc)
Search the variable mapping table to find conditions for handling missing variables.
Utilities for use when reading grib2 data.
subroutine convert_omega(omega, p, t, q, clb, cub)
Convert omega to vertical velocity.
subroutine, public search(field, mask, idim, jdim, tile, field_num, latitude, terrain_land, soilt_climo)
Replace undefined surface values.
subroutine convert_winds
Convert 3-d component winds to u and v.