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, &
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, &
55 type(esmf_field
),
public :: dzdt_input_grid
56 type(esmf_field) :: dpres_input_grid
57 type(esmf_field),
public :: pres_input_grid
58 type(esmf_field),
public :: ps_input_grid
59 type(esmf_field),
public :: terrain_input_grid
60 type(esmf_field),
public :: temp_input_grid
61 type(esmf_field) :: u_input_grid
62 type(esmf_field) :: v_input_grid
63 type(esmf_field),
public :: wind_input_grid
64 type(esmf_field),
allocatable,
public :: tracers_input_grid(:)
66 integer,
public :: lev_input
67 integer,
public :: levp1_input
71 integer,
public :: veg_type_landice_input = 15
74 integer,
parameter :: ICET_DEFAULT = 265.0
76 type(esmf_field),
public :: canopy_mc_input_grid
77 type(esmf_field),
public :: f10m_input_grid
78 type(esmf_field),
public :: ffmm_input_grid
80 type(esmf_field),
public :: landsea_mask_input_grid
82 type(esmf_field),
public :: q2m_input_grid
83 type(esmf_field),
public :: seaice_depth_input_grid
84 type(esmf_field),
public :: seaice_fract_input_grid
85 type(esmf_field),
public :: seaice_skin_temp_input_grid
86 type(esmf_field),
public :: skin_temp_input_grid
87 type(esmf_field),
public :: snow_depth_input_grid
88 type(esmf_field),
public :: snow_liq_equiv_input_grid
89 type(esmf_field),
public :: soil_temp_input_grid
90 type(esmf_field),
public :: soil_type_input_grid
91 type(esmf_field),
public :: soilm_liq_input_grid
92 type(esmf_field),
public :: soilm_tot_input_grid
93 type(esmf_field),
public :: srflag_input_grid
94 type(esmf_field),
public :: t2m_input_grid
95 type(esmf_field),
public :: tprcp_input_grid
96 type(esmf_field),
public :: ustar_input_grid
97 type(esmf_field),
public :: veg_type_input_grid
98 type(esmf_field),
public :: z0_input_grid
99 type(esmf_field),
public :: veg_greenness_input_grid
100 type(esmf_field),
public :: lai_input_grid
101 type(esmf_field),
public :: max_veg_greenness_input_grid
102 type(esmf_field),
public :: min_veg_greenness_input_grid
104 integer,
public :: lsoil_input=4
107 character(len=50),
private,
allocatable :: slevs(:)
111 type(esmf_field
),
public :: c_d_input_grid
112 type(esmf_field),
public :: c_0_input_grid
113 type(esmf_field),
public :: d_conv_input_grid
114 type(esmf_field),
public :: dt_cool_input_grid
115 type(esmf_field),
public :: ifd_input_grid
117 type(esmf_field),
public :: qrain_input_grid
118 type(esmf_field),
public :: tref_input_grid
119 type(esmf_field),
public :: w_d_input_grid
120 type(esmf_field),
public :: w_0_input_grid
121 type(esmf_field),
public :: xs_input_grid
122 type(esmf_field),
public :: xt_input_grid
123 type(esmf_field),
public :: xu_input_grid
124 type(esmf_field),
public :: xv_input_grid
125 type(esmf_field),
public :: xz_input_grid
126 type(esmf_field),
public :: xtts_input_grid
127 type(esmf_field),
public :: xzts_input_grid
128 type(esmf_field),
public :: z_c_input_grid
129 type(esmf_field),
public :: zm_input_grid
148 integer,
intent(in) :: localpet
154 if (trim(input_type) ==
"restart")
then
162 elseif (trim(input_type) ==
"gaussian_netcdf")
then
170 elseif (trim(input_type) ==
"history")
then
178 elseif (trim(input_type) ==
"gaussian_nemsio")
then
186 elseif (trim(input_type) ==
"gfs_gaussian_nemsio")
then
194 elseif (trim(input_type) ==
"gfs_sigio")
then
202 elseif (trim(input_type) ==
"grib2")
then
218 integer,
intent(in) :: localpet
222 print*,
"- READ INPUT GRID NST DATA."
224 print*,
"- CALL FieldCreate FOR INPUT GRID C_D."
225 c_d_input_grid = esmf_fieldcreate(input_grid, &
226 typekind=esmf_typekind_r8, &
227 staggerloc=esmf_staggerloc_center, rc=rc)
228 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
231 print*,
"- CALL FieldCreate FOR INPUT GRID C_0."
232 c_0_input_grid = esmf_fieldcreate(input_grid, &
233 typekind=esmf_typekind_r8, &
234 staggerloc=esmf_staggerloc_center, rc=rc)
235 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
238 print*,
"- CALL FieldCreate FOR INPUT GRID D_CONV."
239 d_conv_input_grid = esmf_fieldcreate(input_grid, &
240 typekind=esmf_typekind_r8, &
241 staggerloc=esmf_staggerloc_center, rc=rc)
242 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
245 print*,
"- CALL FieldCreate FOR INPUT GRID DT_COOL."
246 dt_cool_input_grid = esmf_fieldcreate(input_grid, &
247 typekind=esmf_typekind_r8, &
248 staggerloc=esmf_staggerloc_center, rc=rc)
249 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
252 print*,
"- CALL FieldCreate FOR INPUT GRID IFD."
253 ifd_input_grid = esmf_fieldcreate(input_grid, &
254 typekind=esmf_typekind_r8, &
255 staggerloc=esmf_staggerloc_center, rc=rc)
256 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
259 print*,
"- CALL FieldCreate FOR INPUT GRID QRAIN."
260 qrain_input_grid = esmf_fieldcreate(input_grid, &
261 typekind=esmf_typekind_r8, &
262 staggerloc=esmf_staggerloc_center, rc=rc)
263 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
266 print*,
"- CALL FieldCreate FOR INPUT GRID TREF."
267 tref_input_grid = esmf_fieldcreate(input_grid, &
268 typekind=esmf_typekind_r8, &
269 staggerloc=esmf_staggerloc_center, rc=rc)
270 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
273 print*,
"- CALL FieldCreate FOR INPUT GRID W_D."
274 w_d_input_grid = esmf_fieldcreate(input_grid, &
275 typekind=esmf_typekind_r8, &
276 staggerloc=esmf_staggerloc_center, rc=rc)
277 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
280 print*,
"- CALL FieldCreate FOR INPUT GRID W_0."
281 w_0_input_grid = esmf_fieldcreate(input_grid, &
282 typekind=esmf_typekind_r8, &
283 staggerloc=esmf_staggerloc_center, rc=rc)
284 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
287 print*,
"- CALL FieldCreate FOR INPUT GRID XS."
288 xs_input_grid = esmf_fieldcreate(input_grid, &
289 typekind=esmf_typekind_r8, &
290 staggerloc=esmf_staggerloc_center, rc=rc)
291 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
294 print*,
"- CALL FieldCreate FOR INPUT GRID XT."
295 xt_input_grid = esmf_fieldcreate(input_grid, &
296 typekind=esmf_typekind_r8, &
297 staggerloc=esmf_staggerloc_center, rc=rc)
298 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
301 print*,
"- CALL FieldCreate FOR INPUT GRID XU."
302 xu_input_grid = esmf_fieldcreate(input_grid, &
303 typekind=esmf_typekind_r8, &
304 staggerloc=esmf_staggerloc_center, rc=rc)
305 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
308 print*,
"- CALL FieldCreate FOR INPUT GRID XV."
309 xv_input_grid = esmf_fieldcreate(input_grid, &
310 typekind=esmf_typekind_r8, &
311 staggerloc=esmf_staggerloc_center, rc=rc)
312 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
315 print*,
"- CALL FieldCreate FOR INPUT GRID XZ."
316 xz_input_grid = esmf_fieldcreate(input_grid, &
317 typekind=esmf_typekind_r8, &
318 staggerloc=esmf_staggerloc_center, rc=rc)
319 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
322 print*,
"- CALL FieldCreate FOR INPUT GRID XTTS."
323 xtts_input_grid = esmf_fieldcreate(input_grid, &
324 typekind=esmf_typekind_r8, &
325 staggerloc=esmf_staggerloc_center, rc=rc)
326 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
329 print*,
"- CALL FieldCreate FOR INPUT GRID XZTS."
330 xzts_input_grid = esmf_fieldcreate(input_grid, &
331 typekind=esmf_typekind_r8, &
332 staggerloc=esmf_staggerloc_center, rc=rc)
333 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
336 print*,
"- CALL FieldCreate FOR INPUT GRID Z_C."
337 z_c_input_grid = esmf_fieldcreate(input_grid, &
338 typekind=esmf_typekind_r8, &
339 staggerloc=esmf_staggerloc_center, rc=rc)
340 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
343 print*,
"- CALL FieldCreate FOR INPUT GRID ZM."
344 zm_input_grid = esmf_fieldcreate(input_grid, &
345 typekind=esmf_typekind_r8, &
346 staggerloc=esmf_staggerloc_center, rc=rc)
347 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
355 if (trim(input_type) ==
"gaussian_nemsio" .or. trim(input_type) ==
"gfs_gaussian_nemsio")
then
380 integer,
intent(in) :: localpet
384 print*,
"- CALL FieldCreate FOR INPUT GRID LANDSEA MASK."
385 landsea_mask_input_grid = esmf_fieldcreate(input_grid, &
386 typekind=esmf_typekind_r8, &
387 staggerloc=esmf_staggerloc_center, rc=rc)
388 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
391 print*,
"- CALL FieldCreate FOR INPUT GRID Z0."
392 z0_input_grid = esmf_fieldcreate(input_grid, &
393 typekind=esmf_typekind_r8, &
394 staggerloc=esmf_staggerloc_center, rc=rc)
395 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
398 print*,
"- CALL FieldCreate FOR INPUT GRID VEGETATION TYPE."
399 veg_type_input_grid = esmf_fieldcreate(input_grid, &
400 typekind=esmf_typekind_r8, &
401 staggerloc=esmf_staggerloc_center, rc=rc)
402 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
405 print*,
"- CALL FieldCreate FOR INPUT GRID CANOPY MOISTURE CONTENT."
406 canopy_mc_input_grid = esmf_fieldcreate(input_grid, &
407 typekind=esmf_typekind_r8, &
408 staggerloc=esmf_staggerloc_center, rc=rc)
409 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
412 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE FRACTION."
413 seaice_fract_input_grid = esmf_fieldcreate(input_grid, &
414 typekind=esmf_typekind_r8, &
415 staggerloc=esmf_staggerloc_center, rc=rc)
416 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
419 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE DEPTH."
420 seaice_depth_input_grid = esmf_fieldcreate(input_grid, &
421 typekind=esmf_typekind_r8, &
422 staggerloc=esmf_staggerloc_center, rc=rc)
423 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
426 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE SKIN TEMPERATURE."
427 seaice_skin_temp_input_grid = esmf_fieldcreate(input_grid, &
428 typekind=esmf_typekind_r8, &
429 staggerloc=esmf_staggerloc_center, rc=rc)
430 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
433 print*,
"- CALL FieldCreate FOR INPUT GRID SNOW DEPTH."
434 snow_depth_input_grid = esmf_fieldcreate(input_grid, &
435 typekind=esmf_typekind_r8, &
436 staggerloc=esmf_staggerloc_center, rc=rc)
437 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
440 print*,
"- CALL FieldCreate FOR INPUT GRID SNOW LIQUID EQUIVALENT."
441 snow_liq_equiv_input_grid = esmf_fieldcreate(input_grid, &
442 typekind=esmf_typekind_r8, &
443 staggerloc=esmf_staggerloc_center, rc=rc)
444 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
447 print*,
"- CALL FieldCreate FOR INPUT GRID T2M."
448 t2m_input_grid = esmf_fieldcreate(input_grid, &
449 typekind=esmf_typekind_r8, &
450 staggerloc=esmf_staggerloc_center, rc=rc)
451 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
454 print*,
"- CALL FieldCreate FOR INPUT GRID Q2M."
455 q2m_input_grid = esmf_fieldcreate(input_grid, &
456 typekind=esmf_typekind_r8, &
457 staggerloc=esmf_staggerloc_center, rc=rc)
458 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
461 print*,
"- CALL FieldCreate FOR INPUT GRID TPRCP."
462 tprcp_input_grid = esmf_fieldcreate(input_grid, &
463 typekind=esmf_typekind_r8, &
464 staggerloc=esmf_staggerloc_center, rc=rc)
465 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
468 print*,
"- CALL FieldCreate FOR INPUT GRID F10M."
469 f10m_input_grid = esmf_fieldcreate(input_grid, &
470 typekind=esmf_typekind_r8, &
471 staggerloc=esmf_staggerloc_center, rc=rc)
472 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
475 print*,
"- CALL FieldCreate FOR INPUT GRID USTAR."
476 ustar_input_grid = esmf_fieldcreate(input_grid, &
477 typekind=esmf_typekind_r8, &
478 staggerloc=esmf_staggerloc_center, rc=rc)
479 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
482 print*,
"- CALL FieldCreate FOR INPUT GRID FFMM."
483 ffmm_input_grid = esmf_fieldcreate(input_grid, &
484 typekind=esmf_typekind_r8, &
485 staggerloc=esmf_staggerloc_center, rc=rc)
486 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
489 print*,
"- CALL FieldCreate FOR INPUT GRID SRFLAG."
490 srflag_input_grid = esmf_fieldcreate(input_grid, &
491 typekind=esmf_typekind_r8, &
492 staggerloc=esmf_staggerloc_center, rc=rc)
493 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
496 print*,
"- CALL FieldCreate FOR INPUT SKIN TEMPERATURE."
497 skin_temp_input_grid = esmf_fieldcreate(input_grid, &
498 typekind=esmf_typekind_r8, &
499 staggerloc=esmf_staggerloc_center, rc=rc)
500 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
503 print*,
"- CALL FieldCreate FOR INPUT SOIL TYPE."
504 soil_type_input_grid = esmf_fieldcreate(input_grid, &
505 typekind=esmf_typekind_r8, &
506 staggerloc=esmf_staggerloc_center, rc=rc)
507 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
510 print*,
"- CALL FieldCreate FOR INPUT TERRAIN."
511 terrain_input_grid = esmf_fieldcreate(input_grid, &
512 typekind=esmf_typekind_r8, &
513 staggerloc=esmf_staggerloc_center, rc=rc)
514 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
517 print*,
"- CALL FieldCreate FOR INPUT SOIL TEMPERATURE."
518 soil_temp_input_grid = esmf_fieldcreate(input_grid, &
519 typekind=esmf_typekind_r8, &
520 staggerloc=esmf_staggerloc_center, &
521 ungriddedlbound=(/1/), &
522 ungriddedubound=(/lsoil_input/), rc=rc)
523 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
526 print*,
"- CALL FieldCreate FOR INPUT TOTAL SOIL MOISTURE."
527 soilm_tot_input_grid = esmf_fieldcreate(input_grid, &
528 typekind=esmf_typekind_r8, &
529 staggerloc=esmf_staggerloc_center, &
530 ungriddedlbound=(/1/), &
531 ungriddedubound=(/lsoil_input/), rc=rc)
532 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
535 print*,
"- CALL FieldCreate FOR INPUT LIQUID SOIL MOISTURE."
536 soilm_liq_input_grid = esmf_fieldcreate(input_grid, &
537 typekind=esmf_typekind_r8, &
538 staggerloc=esmf_staggerloc_center, &
539 ungriddedlbound=(/1/), &
540 ungriddedubound=(/lsoil_input/), rc=rc)
541 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
546 if (.not. vgfrc_from_climo)
then
547 print*,
"- CALL FieldCreate FOR INPUT VEGETATION GREENNESS."
548 veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
549 typekind=esmf_typekind_r8, &
550 staggerloc=esmf_staggerloc_center, rc=rc)
551 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
555 if (.not. minmax_vgfrc_from_climo)
then
556 print*,
"- CALL FieldCreate FOR INPUT MIN VEGETATION GREENNESS."
557 min_veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
558 typekind=esmf_typekind_r8, &
559 staggerloc=esmf_staggerloc_center, rc=rc)
560 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
563 print*,
"- CALL FieldCreate FOR INPUT MAX VEGETATION GREENNESS."
564 max_veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
565 typekind=esmf_typekind_r8, &
566 staggerloc=esmf_staggerloc_center, rc=rc)
567 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
571 if (.not. lai_from_climo)
then
572 print*,
"- CALL FieldCreate FOR INPUT LEAF AREA INDEX."
573 lai_input_grid = esmf_fieldcreate(input_grid, &
574 typekind=esmf_typekind_r8, &
575 staggerloc=esmf_staggerloc_center, rc=rc)
576 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
584 if (trim(input_type) ==
"restart")
then
592 elseif (trim(input_type) ==
"history" .or. trim(input_type) == &
593 "gaussian_netcdf")
then
601 elseif (trim(input_type) ==
"gaussian_nemsio")
then
609 elseif (trim(input_type) ==
"gfs_gaussian_nemsio")
then
617 elseif (trim(input_type) ==
"gfs_sigio")
then
625 elseif (trim(input_type) ==
"grib2")
then
642 print*,
"- INITIALIZE ATMOSPHERIC ESMF FIELDS."
644 print*,
"- CALL FieldCreate FOR INPUT GRID 3-D WIND."
645 wind_input_grid = esmf_fieldcreate(input_grid, &
646 typekind=esmf_typekind_r8, &
647 staggerloc=esmf_staggerloc_center, &
648 ungriddedlbound=(/1,1/), &
649 ungriddedubound=(/lev_input,3/), rc=rc)
650 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
653 print*,
"- CALL FieldCreate FOR INPUT GRID SURFACE PRESSURE."
654 ps_input_grid = esmf_fieldcreate(input_grid, &
655 typekind=esmf_typekind_r8, &
656 staggerloc=esmf_staggerloc_center, rc=rc)
657 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
660 print*,
"- CALL FieldCreate FOR INPUT GRID TERRAIN."
661 terrain_input_grid = esmf_fieldcreate(input_grid, &
662 typekind=esmf_typekind_r8, &
663 staggerloc=esmf_staggerloc_center, rc=rc)
664 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
667 print*,
"- CALL FieldCreate FOR INPUT GRID TEMPERATURE."
668 temp_input_grid = esmf_fieldcreate(input_grid, &
669 typekind=esmf_typekind_r8, &
670 staggerloc=esmf_staggerloc_center, &
671 ungriddedlbound=(/1/), &
672 ungriddedubound=(/lev_input/), rc=rc)
673 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
676 allocate(tracers_input_grid(num_tracers))
678 do i = 1, num_tracers
679 print*,
"- CALL FieldCreate FOR INPUT GRID TRACER ", trim(tracers_input(i))
680 tracers_input_grid(i) = esmf_fieldcreate(input_grid, &
681 typekind=esmf_typekind_r8, &
682 staggerloc=esmf_staggerloc_center, &
683 ungriddedlbound=(/1/), &
684 ungriddedubound=(/lev_input/), rc=rc)
685 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
689 print*,
"- CALL FieldCreate FOR INPUT GRID DZDT."
690 dzdt_input_grid = esmf_fieldcreate(input_grid, &
691 typekind=esmf_typekind_r8, &
692 staggerloc=esmf_staggerloc_center, &
693 ungriddedlbound=(/1/), &
694 ungriddedubound=(/lev_input/), rc=rc)
695 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
698 print*,
"- CALL FieldCreate FOR INPUT GRID U."
699 u_input_grid = esmf_fieldcreate(input_grid, &
700 typekind=esmf_typekind_r8, &
701 staggerloc=esmf_staggerloc_center, &
702 ungriddedlbound=(/1/), &
703 ungriddedubound=(/lev_input/), rc=rc)
704 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
707 print*,
"- CALL FieldCreate FOR INPUT GRID V."
708 v_input_grid = esmf_fieldcreate(input_grid, &
709 typekind=esmf_typekind_r8, &
710 staggerloc=esmf_staggerloc_center, &
711 ungriddedlbound=(/1/), &
712 ungriddedubound=(/lev_input/), rc=rc)
713 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
716 print*,
"- CALL FieldCreate FOR INPUT GRID PRESSURE."
717 pres_input_grid = esmf_fieldcreate(input_grid, &
718 typekind=esmf_typekind_r8, &
719 staggerloc=esmf_staggerloc_center, &
720 ungriddedlbound=(/1/), &
721 ungriddedubound=(/lev_input/), rc=rc)
722 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
738 integer,
intent(in) :: localpet
740 character(len=300) :: the_file
742 integer(sigio_intkind) :: iret
743 integer :: rc, i, j, k
744 integer :: clb(3), cub(3)
746 real(esmf_kind_r8) :: ak, bk
747 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
748 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
749 real(esmf_kind_r8),
allocatable :: dummy3d2(:,:,:)
750 real(esmf_kind_r8),
pointer :: pptr(:,:,:), psptr(:,:)
751 real(esmf_kind_r8),
allocatable :: pi(:,:,:)
753 type(sigio_head
) :: sighead
754 type(sigio_dbta
) :: sigdata
756 the_file = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
758 print*,
"- ATMOSPHERIC DATA IN SIGIO FORMAT."
759 print*,
"- OPEN AND READ: ", trim(the_file)
761 call sigio_sropen(21, trim(the_file), iret)
766 call sigio_srhead(21, sighead, iret)
772 lev_input = sighead%levs
773 levp1_input = lev_input + 1
775 if (num_tracers /= sighead%ntrac)
then
779 if (sighead%idvt == 0 .or. sighead%idvt == 21)
then
780 if (trim(tracers_input(1)) /=
'spfh' .or. &
781 trim(tracers_input(2)) /=
'o3mr' .or. &
782 trim(tracers_input(3)) /=
'clwmr')
then
783 call
error_handler(
"TRACERS SELECTED DO NOT MATCH FILE CONTENTS.", 99)
786 print*,
'- UNRECOGNIZED IDVT: ', sighead%idvt
796 if (localpet == 0)
then
797 allocate(dummy2d(i_input,j_input))
798 allocate(dummy3d(i_input,j_input,lev_input))
799 allocate(dummy3d2(i_input,j_input,lev_input))
801 allocate(dummy2d(0,0))
802 allocate(dummy3d(0,0,0))
803 allocate(dummy3d2(0,0,0))
806 if (localpet == 0)
then
807 call sigio_aldbta(sighead, sigdata, iret)
812 call sigio_srdbta(21, sighead, sigdata, iret)
817 call sptez(0,sighead%jcap,4,i_input, j_input, sigdata%ps, dummy2d, 1)
818 dummy2d = exp(dummy2d) * 1000.0
819 print*,
'surface pres ',maxval(dummy2d),minval(dummy2d)
822 print*,
"- CALL FieldScatter FOR SURFACE PRESSURE."
823 call esmf_fieldscatter(ps_input_grid, dummy2d, rootpet=0, rc=rc)
824 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
827 if (localpet == 0)
then
828 call sptez(0,sighead%jcap,4,i_input, j_input, sigdata%hs, dummy2d, 1)
829 print*,
'terrain ',maxval(dummy2d),minval(dummy2d)
832 print*,
"- CALL FieldScatter FOR TERRAIN."
833 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
834 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
837 do k = 1, num_tracers
839 if (localpet == 0)
then
840 call sptezm(0,sighead%jcap,4,i_input, j_input, lev_input, sigdata%q(:,:,k), dummy3d, 1)
841 print*,trim(tracers_input(k)),maxval(dummy3d),minval(dummy3d)
844 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(k))
845 call esmf_fieldscatter(tracers_input_grid(k), dummy3d, rootpet=0, rc=rc)
846 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
851 if (localpet == 0)
then
852 call sptezm(0,sighead%jcap,4,i_input, j_input, lev_input, sigdata%t, dummy3d, 1)
853 print*,
'temp ',maxval(dummy3d),minval(dummy3d)
856 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
857 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
858 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
866 if (localpet == 0)
then
867 print*,
"- NO VERTICAL VELOCITY RECORD. SET TO ZERO."
871 print*,
"- CALL FieldScatter FOR INPUT DZDT."
872 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
873 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
876 if (localpet == 0)
then
877 call sptezmv(0, sighead%jcap, 4, i_input, j_input, lev_input, sigdata%d, sigdata%z, dummy3d, dummy3d2, 1)
878 print*,
'u ',maxval(dummy3d),minval(dummy3d)
879 print*,
'v ',maxval(dummy3d2),minval(dummy3d2)
882 print*,
"- CALL FieldScatter FOR INPUT U-WIND."
883 call esmf_fieldscatter(u_input_grid, dummy3d, rootpet=0, rc=rc)
884 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
887 print*,
"- CALL FieldScatter FOR INPUT V-WIND."
888 call esmf_fieldscatter(v_input_grid, dummy3d2, rootpet=0, rc=rc)
889 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
892 deallocate(dummy2d, dummy3d, dummy3d2)
894 if (localpet == 0) call sigio_axdbta(sigdata, iret)
896 call sigio_sclose(21, iret)
908 print*,
"- COMPUTE 3-D PRESSURE."
910 print*,
"- CALL FieldGet FOR 3-D PRES."
912 call esmf_fieldget(pres_input_grid, &
913 computationallbound=clb, &
914 computationalubound=cub, &
915 farrayptr=pptr, rc=rc)
916 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
919 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
921 call esmf_fieldget(ps_input_grid, &
922 farrayptr=psptr, rc=rc)
923 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
930 allocate(pi(clb(1):cub(1),clb(2):cub(2),1:levp1_input),stat=rc)
933 ak = sighead%vcoord(k,1)
934 bk = sighead%vcoord(k,2)
937 pi(i,j,k) = ak + bk*psptr(i,j)
942 if (localpet == 0)
then
943 print*,
'pres int ',psptr(clb(1),clb(2)),pi(clb(1),clb(2),:)
953 pptr(i,j,k) = (pi(i,j,k)+pi(i,j,k+1))/2.0_esmf_kind_r8
960 if (localpet == 0)
then
961 print*,
'pres ',psptr(clb(1),clb(2)),pptr(clb(1),clb(2),:)
975 integer,
intent(in) :: localpet
977 character(len=300) :: the_file
978 character(len=20) :: vlevtyp, vname
980 integer(nemsio_intkind) :: vlev, iret
981 integer :: i, j, k, n, rc
982 integer :: clb(3), cub(3)
984 real(nemsio_realkind),
allocatable :: vcoord(:,:,:)
985 real(nemsio_realkind),
allocatable :: dummy(:)
986 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
987 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
988 real(esmf_kind_r8) :: ak, bk
989 real(esmf_kind_r8),
allocatable :: pi(:,:,:)
990 real(esmf_kind_r8),
pointer :: pptr(:,:,:), psptr(:,:)
992 type(nemsio_gfile
) :: gfile
994 the_file = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
996 print*,
"- READ ATMOS DATA FROM SPECTRAL GFS NEMSIO FILE: ", trim(the_file)
998 print*,
"- OPEN FILE."
999 call nemsio_open(gfile, the_file,
"read", iret=iret)
1000 if (iret /= 0) call
error_handler(
"OPENING SPECTRAL GFS NEMSIO ATM FILE.", iret)
1002 print*,
"- READ NUMBER OF VERTICAL LEVELS."
1003 call nemsio_getfilehead(gfile, iret=iret, dimz=lev_input)
1004 if (iret /= 0) call
error_handler(
"READING NUMBER OF VERTICAL LEVLES.", iret)
1006 levp1_input = lev_input + 1
1008 allocate(vcoord(levp1_input,3,2))
1010 print*,
"- READ VERTICAL COORDINATE INFO."
1011 call nemsio_getfilehead(gfile, iret=iret, vcoord=vcoord)
1012 if (iret /= 0) call
error_handler(
"READING VERTICAL COORDINATE INFO.", iret)
1020 if (localpet == 0)
then
1021 allocate(dummy(i_input*j_input))
1022 allocate(dummy2d(i_input,j_input))
1023 allocate(dummy3d(i_input,j_input,lev_input))
1026 allocate(dummy2d(0,0))
1027 allocate(dummy3d(0,0,0))
1035 if (localpet == 0)
then
1036 print*,
"- READ TEMPERATURE."
1038 vlevtyp =
"mid layer"
1039 do vlev = 1, lev_input
1040 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1041 if (iret /= 0) call
error_handler(
"READING TEMPERATURE RECORD.", iret)
1042 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1047 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
1048 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
1049 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1052 do n = 1, num_tracers
1054 if (localpet == 0)
then
1055 print*,
"- READ ", trim(tracers_input(n))
1056 vname = trim(tracers_input(n))
1057 vlevtyp =
"mid layer"
1058 do vlev = 1, lev_input
1059 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1060 if (iret /= 0) call
error_handler(
"READING TRACER RECORD.", iret)
1062 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1066 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(n))
1067 call esmf_fieldscatter(tracers_input_grid(n), dummy3d, rootpet=0, rc=rc)
1068 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1073 if (localpet == 0)
then
1074 print*,
"- READ U-WINDS."
1076 vlevtyp =
"mid layer"
1077 do vlev = 1, lev_input
1078 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1079 if (iret /= 0) call
error_handler(
"READING U-WIND RECORD.", iret)
1081 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1085 print*,
"- CALL FieldScatter FOR INPUT U-WIND."
1086 call esmf_fieldscatter(u_input_grid, dummy3d, rootpet=0, rc=rc)
1087 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1090 if (localpet == 0)
then
1091 print*,
"- READ V-WINDS."
1093 vlevtyp =
"mid layer"
1094 do vlev = 1, lev_input
1095 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1096 if (iret /= 0) call
error_handler(
"READING V-WIND RECORD.", iret)
1098 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1102 print*,
"- CALL FieldScatter FOR INPUT V-WIND."
1103 call esmf_fieldscatter(v_input_grid, dummy3d, rootpet=0, rc=rc)
1104 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1112 if (localpet == 0)
then
1113 print*,
"- NO VERTICAL VELOCITY RECORD. SET TO ZERO."
1117 print*,
"- CALL FieldScatter FOR INPUT DZDT."
1118 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
1119 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1122 if (localpet == 0)
then
1123 print*,
"- READ HGT."
1127 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1128 if (iret /= 0) call
error_handler(
"READING HGT RECORD.", iret)
1130 dummy2d = reshape(dummy, (/i_input,j_input/))
1133 print*,
"- CALL FieldScatter FOR TERRAIN."
1134 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
1135 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1138 if (localpet == 0)
then
1139 print*,
"- READ PRES."
1143 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1144 if (iret /= 0) call
error_handler(
"READING PRES RECORD.", iret)
1146 dummy2d = reshape(dummy, (/i_input,j_input/))
1149 print*,
"- CALL FieldScatter FOR SURFACE PRESSURE."
1150 call esmf_fieldscatter(ps_input_grid, dummy2d, rootpet=0, rc=rc)
1151 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1154 call nemsio_close(gfile)
1156 deallocate(dummy, dummy2d, dummy3d)
1168 print*,
"- COMPUTE 3-D PRESSURE."
1170 print*,
"- CALL FieldGet FOR 3-D PRES."
1172 call esmf_fieldget(pres_input_grid, &
1173 computationallbound=clb, &
1174 computationalubound=cub, &
1175 farrayptr=pptr, rc=rc)
1176 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1179 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
1181 call esmf_fieldget(ps_input_grid, &
1182 farrayptr=psptr, rc=rc)
1183 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1190 allocate(pi(clb(1):cub(1),clb(2):cub(2),1:levp1_input))
1195 do i= clb(1), cub(1)
1196 do j= clb(2), cub(2)
1197 pi(i,j,k) = ak + bk*psptr(i,j)
1209 do i= clb(1), cub(1)
1210 do j= clb(2), cub(2)
1211 pptr(i,j,k) = (pi(i,j,k)+pi(i,j,k+1))/2.0
1228 integer,
intent(in) :: localpet
1230 character(len=300) :: the_file
1231 character(len=20) :: vlevtyp, vname
1233 integer :: i, j, k, n
1234 integer :: rc, clb(3), cub(3)
1235 integer(nemsio_intkind) :: vlev, iret
1237 real(nemsio_realkind),
allocatable :: vcoord(:,:,:)
1238 real(nemsio_realkind),
allocatable :: dummy(:)
1239 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
1240 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
1241 real(esmf_kind_r8),
pointer :: presptr(:,:,:), psptr(:,:)
1242 real(esmf_kind_r8),
pointer :: dpresptr(:,:,:)
1243 real(esmf_kind_r8),
allocatable :: pres_interface(:)
1245 type(nemsio_gfile
) :: gfile
1247 the_file = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
1249 print*,
"- READ ATMOS DATA FROM GAUSSIAN NEMSIO FILE: ", trim(the_file)
1251 print*,
"- OPEN FILE."
1252 call nemsio_open(gfile, the_file,
"read", iret=iret)
1253 if (iret /= 0) call
error_handler(
"OPENING GAUSSIAN NEMSIO ATM FILE.", iret)
1255 print*,
"- READ NUMBER OF VERTICAL LEVELS."
1256 call nemsio_getfilehead(gfile, iret=iret, dimz=lev_input)
1257 if (iret /= 0) call
error_handler(
"READING NUMBER OF VERTICAL LEVLES.", iret)
1259 levp1_input = lev_input + 1
1261 allocate(vcoord(levp1_input,3,2))
1263 print*,
"- READ VERTICAL COORDINATE INFO."
1264 call nemsio_getfilehead(gfile, iret=iret, vcoord=vcoord)
1265 if (iret /= 0) call
error_handler(
"READING VERTICAL COORDINATE INFO.", iret)
1273 print*,
"- CALL FieldCreate FOR INPUT DPRES."
1274 dpres_input_grid = esmf_fieldcreate(input_grid, &
1275 typekind=esmf_typekind_r8, &
1276 staggerloc=esmf_staggerloc_center, &
1277 ungriddedlbound=(/1/), &
1278 ungriddedubound=(/lev_input/), rc=rc)
1279 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1282 if (localpet == 0)
then
1283 allocate(dummy(i_input*j_input))
1284 allocate(dummy2d(i_input,j_input))
1285 allocate(dummy3d(i_input,j_input,lev_input))
1288 allocate(dummy2d(0,0))
1289 allocate(dummy3d(0,0,0))
1297 if (localpet == 0)
then
1298 print*,
"- READ TEMPERATURE."
1300 vlevtyp =
"mid layer"
1301 do vlev = 1, lev_input
1302 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1303 if (iret /= 0) call
error_handler(
"READING TEMPERATURE RECORD.", iret)
1304 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1305 print*,
'temp check after read ',vlev, dummy3d(1,1,vlev)
1309 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
1310 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
1311 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1314 do n = 1, num_tracers
1316 if (localpet == 0)
then
1317 print*,
"- READ ", trim(tracers_input(n))
1318 vname = trim(tracers_input(n))
1319 vlevtyp =
"mid layer"
1320 do vlev = 1, lev_input
1321 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1322 if (iret /= 0) call
error_handler(
"READING TRACER RECORD.", iret)
1323 print*,
'tracer ',vlev, maxval(dummy),minval(dummy)
1324 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1328 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(n))
1329 call esmf_fieldscatter(tracers_input_grid(n), dummy3d, rootpet=0, rc=rc)
1330 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1335 if (localpet == 0)
then
1336 print*,
"- READ U-WINDS."
1338 vlevtyp =
"mid layer"
1339 do vlev = 1, lev_input
1340 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1341 if (iret /= 0) call
error_handler(
"READING U-WIND RECORD.", iret)
1342 print*,
'ugrd ',vlev, maxval(dummy),minval(dummy)
1343 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1347 print*,
"- CALL FieldScatter FOR INPUT U-WIND."
1348 call esmf_fieldscatter(u_input_grid, dummy3d, rootpet=0, rc=rc)
1349 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1352 if (localpet == 0)
then
1353 print*,
"- READ V-WINDS."
1355 vlevtyp =
"mid layer"
1356 do vlev = 1, lev_input
1357 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1358 if (iret /= 0) call
error_handler(
"READING V-WIND RECORD.", iret)
1359 print*,
'vgrd ',vlev, maxval(dummy),minval(dummy)
1360 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1364 print*,
"- CALL FieldScatter FOR INPUT V-WIND."
1365 call esmf_fieldscatter(v_input_grid, dummy3d, rootpet=0, rc=rc)
1366 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1369 if (localpet == 0)
then
1370 print*,
"- READ DPRES."
1372 vlevtyp =
"mid layer"
1373 do vlev = 1, lev_input
1374 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1375 if (iret /= 0) call
error_handler(
"READING DPRES RECORD.", iret)
1376 print*,
'dpres ',vlev, maxval(dummy),minval(dummy)
1377 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1381 print*,
"- CALL FieldScatter FOR INPUT DPRES."
1382 call esmf_fieldscatter(dpres_input_grid, dummy3d, rootpet=0, rc=rc)
1383 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1386 if (localpet == 0)
then
1387 print*,
"- READ DZDT."
1389 vlevtyp =
"mid layer"
1390 do vlev = 1, lev_input
1391 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1392 if (iret /= 0) call
error_handler(
"READING DZDT RECORD.", iret)
1393 print*,
'dzdt ',vlev, maxval(dummy),minval(dummy)
1394 dummy3d(:,:,vlev) = reshape(dummy, (/i_input,j_input/))
1398 print*,
"- CALL FieldScatter FOR INPUT DZDT."
1399 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
1400 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1403 if (localpet == 0)
then
1404 print*,
"- READ HGT."
1408 call nemsio_readrecv(gfile, vname, vlevtyp, vlev, dummy, 0, iret)
1409 if (iret /= 0) call
error_handler(
"READING HGT RECORD.", iret)
1410 print*,
'hgt ',vlev, maxval(dummy),minval(dummy)
1411 dummy2d = reshape(dummy, (/i_input,j_input/))
1414 print*,
"- CALL FieldScatter FOR TERRAIN."
1415 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
1416 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1419 call nemsio_close(gfile)
1421 deallocate(dummy, dummy2d, dummy3d)
1437 print*,
"- COMPUTE 3-D PRESSURE."
1439 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
1441 call esmf_fieldget(dpres_input_grid, &
1442 computationallbound=clb, &
1443 computationalubound=cub, &
1444 farrayptr=dpresptr, rc=rc)
1445 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1448 print*,
"- CALL FieldGet FOR 3-D PRESSURE."
1450 call esmf_fieldget(pres_input_grid, &
1451 farrayptr=presptr, rc=rc)
1452 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1455 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
1457 call esmf_fieldget(ps_input_grid, &
1458 farrayptr=psptr, rc=rc)
1459 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1462 allocate(pres_interface(levp1_input))
1464 if (localpet == 0)
then
1465 do k = clb(3), cub(3)
1466 print*,
'dpres is ',cub(1),cub(2),k, dpresptr(cub(1),cub(2),k)
1470 do i = clb(1), cub(1)
1471 do j = clb(2), cub(2)
1472 pres_interface(levp1_input) = vcoord(levp1_input,1,1)
1473 do k = lev_input, 1, -1
1474 pres_interface(k) = pres_interface(k+1) + dpresptr(i,j,k)
1476 psptr(i,j) = pres_interface(1)
1478 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
1485 if (localpet == 0)
then
1486 print*,
'psfc is ',clb(1),clb(2),psptr(clb(1),clb(2))
1487 print*,
'pres is ',clb(1),clb(2),presptr(clb(1),clb(2),:)
1490 print*,
'pres check 1',localpet,maxval(presptr(:,:,1)),minval(presptr(:,:,1))
1491 print*,
'pres check lev',localpet,maxval(presptr(:,:,lev_input)),minval(presptr(:,:,lev_input))
1493 deallocate(pres_interface)
1495 call esmf_fielddestroy(dpres_input_grid, rc=rc)
1511 integer,
intent(in) :: localpet
1513 character(len=500) :: tilefile
1516 integer :: clb(3), cub(3)
1517 integer :: rc, tile, ncid, id_var
1518 integer :: error, id_dim
1520 real(esmf_kind_r8),
allocatable :: ak(:)
1521 real(esmf_kind_r8),
pointer :: presptr(:,:,:), psptr(:,:)
1522 real(esmf_kind_r8),
pointer :: dpresptr(:,:,:)
1523 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
1524 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
1525 real(esmf_kind_r8),
allocatable :: pres_interface(:)
1531 tilefile = trim(data_dir_input_grid) //
"/" // trim(atm_core_files_input_grid(7))
1532 print*,
"- READ ATM VERTICAL LEVELS FROM: ", trim(tilefile)
1533 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1534 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1536 error=nf90_inq_dimid(ncid,
'xaxis_1', id_dim)
1537 call
netcdf_err(error,
'reading xaxis_1 id' )
1538 error=nf90_inquire_dimension(ncid,id_dim,len=levp1_input)
1539 call
netcdf_err(error,
'reading xaxis_1 value' )
1541 lev_input = levp1_input - 1
1543 allocate(ak(levp1_input))
1545 error=nf90_inq_varid(ncid,
'ak', id_var)
1547 error=nf90_get_var(ncid, id_var, ak)
1550 error = nf90_close(ncid)
1558 print*,
"- CALL FieldCreate FOR INPUT GRID DELTA PRESSURE."
1559 dpres_input_grid = esmf_fieldcreate(input_grid, &
1560 typekind=esmf_typekind_r8, &
1561 staggerloc=esmf_staggerloc_center, &
1562 ungriddedlbound=(/1/), &
1563 ungriddedubound=(/lev_input/), rc=rc)
1564 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1567 if (localpet < num_tiles_input_grid)
then
1568 allocate(data_one_tile_3d(i_input,j_input,lev_input))
1569 allocate(data_one_tile(i_input,j_input))
1571 allocate(data_one_tile_3d(0,0,0))
1572 allocate(data_one_tile(0,0))
1575 if (localpet < num_tiles_input_grid)
then
1577 tilefile= trim(data_dir_input_grid) //
"/" // trim(atm_core_files_input_grid(tile))
1578 print*,
"- READ ATMOSPHERIC CORE FILE: ", trim(tilefile)
1579 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1580 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1583 if (localpet < num_tiles_input_grid)
then
1584 error=nf90_inq_varid(ncid,
'phis', id_var)
1586 error=nf90_get_var(ncid, id_var, data_one_tile)
1588 data_one_tile = data_one_tile / 9.806_8
1591 do tile = 1, num_tiles_input_grid
1592 print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN for tile ",tile
1593 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=tile-1, tile=tile, rc=rc)
1594 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1598 if (localpet < num_tiles_input_grid)
then
1606 data_one_tile_3d = 0.0_8
1609 do tile = 1, num_tiles_input_grid
1610 print*,
"- CALL FieldScatter FOR INPUT GRID VERTICAL VELOCITY for tile ",tile
1611 call esmf_fieldscatter(dzdt_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1612 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1616 if (localpet < num_tiles_input_grid)
then
1617 error=nf90_inq_varid(ncid,
'T', id_var)
1619 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1621 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1624 do tile = 1, num_tiles_input_grid
1625 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
1626 call esmf_fieldscatter(temp_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1627 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1631 if (localpet < num_tiles_input_grid)
then
1632 error=nf90_inq_varid(ncid,
'delp', id_var)
1634 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1636 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1639 do tile = 1, num_tiles_input_grid
1640 print*,
"- CALL FieldScatter FOR INPUT DELTA PRESSURE."
1641 call esmf_fieldscatter(dpres_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1642 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1646 if (localpet < num_tiles_input_grid)
then
1647 error=nf90_inq_varid(ncid,
'ua', id_var)
1649 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1651 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1654 do tile = 1, num_tiles_input_grid
1655 print*,
"- CALL FieldScatter FOR INPUT GRID U."
1656 call esmf_fieldscatter(u_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1657 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1661 if (localpet < num_tiles_input_grid)
then
1662 error=nf90_inq_varid(ncid,
'va', id_var)
1664 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1666 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1669 do tile = 1, num_tiles_input_grid
1670 print*,
"- CALL FieldScatter FOR INPUT GRID V."
1671 call esmf_fieldscatter(v_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1672 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1676 if (localpet < num_tiles_input_grid) error = nf90_close(ncid)
1678 if (localpet < num_tiles_input_grid)
then
1680 tilefile= trim(data_dir_input_grid) //
"/" // trim(atm_tracer_files_input_grid(tile))
1681 print*,
"- READ ATMOSPHERIC TRACER FILE: ", trim(tilefile)
1682 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1683 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1686 do i = 1, num_tracers
1688 if (localpet < num_tiles_input_grid)
then
1689 error=nf90_inq_varid(ncid, tracers_input(i), id_var)
1691 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
1693 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
1696 do tile = 1, num_tiles_input_grid
1697 print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input(i))
1698 call esmf_fieldscatter(tracers_input_grid(i), data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
1699 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1705 if (localpet < num_tiles_input_grid) error=nf90_close(ncid)
1717 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
1718 call esmf_fieldget(ps_input_grid, &
1719 farrayptr=psptr, rc=rc)
1720 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1723 print*,
"- CALL FieldGet FOR PRESSURE."
1724 call esmf_fieldget(pres_input_grid, &
1725 computationallbound=clb, &
1726 computationalubound=cub, &
1727 farrayptr=presptr, rc=rc)
1728 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1731 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
1732 call esmf_fieldget(dpres_input_grid, &
1733 farrayptr=dpresptr, rc=rc)
1734 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1737 allocate(pres_interface(levp1_input))
1739 do i = clb(1), cub(1)
1740 do j = clb(2), cub(2)
1741 pres_interface(levp1_input) = ak(1)
1742 do k = (levp1_input-1), 1, -1
1743 pres_interface(k) = pres_interface(k+1) + dpresptr(i,j,k)
1746 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
1748 psptr(i,j) = pres_interface(1)
1753 deallocate(pres_interface)
1755 call esmf_fielddestroy(dpres_input_grid, rc=rc)
1757 deallocate(data_one_tile_3d, data_one_tile)
1772 integer,
intent(in) :: localpet
1774 character(len=500) :: tilefile
1776 integer :: start(3), count(3), iscnt
1777 integer :: error, ncid, num_tracers_file
1778 integer :: id_dim, idim_input, jdim_input
1779 integer :: id_var, rc, nprocs, max_procs
1780 integer :: kdim, remainder, myrank, i, j, k, n
1781 integer :: clb(3), cub(3)
1782 integer,
allocatable :: kcount(:), startk(:), displ(:)
1783 integer,
allocatable :: ircnt(:)
1785 real(esmf_kind_r8),
allocatable :: phalf(:)
1786 real(esmf_kind_r8),
allocatable :: pres_interface(:)
1787 real(kind=4),
allocatable :: dummy3d(:,:,:)
1788 real(kind=4),
allocatable :: dummy3dall(:,:,:)
1789 real(esmf_kind_r8),
allocatable :: dummy3dflip(:,:,:)
1790 real(esmf_kind_r8),
allocatable :: dummy(:,:)
1791 real(esmf_kind_r8),
pointer :: presptr(:,:,:), dpresptr(:,:,:)
1792 real(esmf_kind_r8),
pointer :: psptr(:,:)
1794 print*,
"- READ INPUT ATMOS DATA FROM GAUSSIAN NETCDF FILE."
1796 tilefile = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
1797 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1798 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1800 error=nf90_inq_dimid(ncid,
'grid_xt', id_dim)
1801 call
netcdf_err(error,
'reading grid_xt id' )
1802 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
1803 call
netcdf_err(error,
'reading grid_xt value' )
1805 error=nf90_inq_dimid(ncid,
'grid_yt', id_dim)
1806 call
netcdf_err(error,
'reading grid_yt id' )
1807 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
1808 call
netcdf_err(error,
'reading grid_yt value' )
1810 if (idim_input /= i_input .or. jdim_input /= j_input)
then
1811 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 2)
1814 error=nf90_inq_dimid(ncid,
'pfull', id_dim)
1816 error=nf90_inquire_dimension(ncid,id_dim,len=lev_input)
1817 call
netcdf_err(error,
'reading pfull value' )
1819 error=nf90_inq_dimid(ncid,
'phalf', id_dim)
1821 error=nf90_inquire_dimension(ncid,id_dim,len=levp1_input)
1822 call
netcdf_err(error,
'reading phalf value' )
1823 allocate(phalf(levp1_input))
1824 error=nf90_inq_varid(ncid,
'phalf', id_var)
1825 call
netcdf_err(error,
'getting phalf varid' )
1826 error=nf90_get_var(ncid, id_var, phalf)
1827 call
netcdf_err(error,
'reading phalf varid' )
1829 error=nf90_get_att(ncid, nf90_global,
'ncnsto', num_tracers_file)
1830 call
netcdf_err(error,
'reading ntracer value' )
1832 call mpi_comm_size(mpi_comm_world, nprocs, error)
1833 print*,
'- Running with ', nprocs,
' processors'
1835 call mpi_comm_rank(mpi_comm_world, myrank, error)
1836 print*,
'- myrank/localpet is ',myrank,localpet
1839 if (nprocs > lev_input)
then
1840 max_procs = lev_input
1843 kdim = lev_input / max_procs
1844 remainder = lev_input - (max_procs*kdim)
1846 allocate(kcount(0:nprocs-1))
1848 allocate(startk(0:nprocs-1))
1850 allocate(displ(0:nprocs-1))
1852 allocate(ircnt(0:nprocs-1))
1855 do k = 0, max_procs-2
1858 kcount(max_procs-1) = kdim + remainder
1861 do k = 1, max_procs-1
1862 startk(k) = startk(k-1) + kcount(k-1)
1865 ircnt(:) = idim_input * jdim_input * kcount(:)
1868 do k = 1, max_procs-1
1869 displ(k) = displ(k-1) + ircnt(k-1)
1872 iscnt=idim_input*jdim_input*kcount(myrank)
1876 if (myrank <= max_procs-1)
then
1877 allocate(dummy3d(idim_input,jdim_input,kcount(myrank)))
1879 allocate(dummy3d(0,0,0))
1882 if (myrank == 0)
then
1883 allocate(dummy3dall(idim_input,jdim_input,lev_input))
1885 allocate(dummy3dflip(idim_input,jdim_input,lev_input))
1887 allocate(dummy(idim_input,jdim_input))
1890 allocate(dummy3dall(0,0,0))
1891 allocate(dummy3dflip(0,0,0))
1892 allocate(dummy(0,0))
1901 print*,
"- CALL FieldCreate FOR INPUT GRID DELTA PRESSURE."
1902 dpres_input_grid = esmf_fieldcreate(input_grid, &
1903 typekind=esmf_typekind_r8, &
1904 staggerloc=esmf_staggerloc_center, &
1905 ungriddedlbound=(/1/), &
1906 ungriddedubound=(/lev_input/), rc=rc)
1907 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1912 if (myrank <= max_procs-1)
then
1913 start = (/1,1,startk(myrank)/)
1914 count = (/idim_input,jdim_input,kcount(myrank)/)
1915 error=nf90_inq_varid(ncid,
'tmp', id_var)
1916 call
netcdf_err(error,
'reading tmp field id' )
1917 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
1921 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
1922 dummy3dall, ircnt, displ, mpi_real, &
1923 0, mpi_comm_world, error)
1924 if (error /= 0) call
error_handler(
"IN mpi_gatherv of temperature", error)
1926 if (myrank == 0)
then
1927 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
1930 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE "
1931 call esmf_fieldscatter(temp_input_grid, dummy3dflip, rootpet=0, rc=rc)
1932 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1937 if (myrank <= max_procs-1)
then
1938 error=nf90_inq_varid(ncid,
'dpres', id_var)
1939 call
netcdf_err(error,
'reading dpres field id' )
1940 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
1941 call
netcdf_err(error,
'reading dpres field' )
1944 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
1945 dummy3dall, ircnt, displ, mpi_real, &
1946 0, mpi_comm_world, error)
1947 if (error /= 0) call
error_handler(
"IN mpi_gatherv of dpres", error)
1949 if (myrank == 0)
then
1950 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
1953 print*,
"- CALL FieldScatter FOR INPUT GRID DPRES "
1954 call esmf_fieldscatter(dpres_input_grid, dummy3dflip, rootpet=0, rc=rc)
1955 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1960 if (myrank <= max_procs-1)
then
1961 error=nf90_inq_varid(ncid,
'ugrd', id_var)
1962 call
netcdf_err(error,
'reading ugrd field id' )
1963 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
1964 call
netcdf_err(error,
'reading ugrd field' )
1967 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
1968 dummy3dall, ircnt, displ, mpi_real, &
1969 0, mpi_comm_world, error)
1970 if (error /= 0) call
error_handler(
"IN mpi_gatherv of ugrd", error)
1972 if (myrank == 0)
then
1973 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
1976 print*,
"- CALL FieldScatter FOR INPUT GRID UGRD "
1977 call esmf_fieldscatter(u_input_grid, dummy3dflip, rootpet=0, rc=rc)
1978 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1983 if (myrank <= max_procs-1)
then
1984 error=nf90_inq_varid(ncid,
'vgrd', id_var)
1985 call
netcdf_err(error,
'reading vgrd field id' )
1986 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
1987 call
netcdf_err(error,
'reading vgrd field' )
1990 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
1991 dummy3dall, ircnt, displ, mpi_real, &
1992 0, mpi_comm_world, error)
1993 if (error /= 0) call
error_handler(
"IN mpi_gatherv of vgrd", error)
1995 if (myrank == 0)
then
1996 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
1999 print*,
"- CALL FieldScatter FOR INPUT GRID VGRD "
2000 call esmf_fieldscatter(v_input_grid, dummy3dflip, rootpet=0, rc=rc)
2001 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2006 do n = 1, num_tracers
2008 if (myrank <= max_procs-1)
then
2009 error=nf90_inq_varid(ncid, tracers_input(n), id_var)
2010 call
netcdf_err(error,
'reading tracer field id' )
2011 error=nf90_get_var(ncid, id_var, dummy3d, start=start, count=count)
2012 call
netcdf_err(error,
'reading tracer field' )
2015 call mpi_gatherv(dummy3d, iscnt, mpi_real, &
2016 dummy3dall, ircnt, displ, mpi_real, &
2017 0, mpi_comm_world, error)
2018 if (error /= 0) call
error_handler(
"IN mpi_gatherv of tracer", error)
2020 if (myrank == 0)
then
2021 dummy3dflip(:,:,1:lev_input) = dummy3dall(:,:,lev_input:1:-1)
2022 where(dummy3dflip < 0.0) dummy3dflip = 0.0
2025 print*,
"- CALL FieldScatter FOR INPUT GRID ", tracers_input(n)
2026 call esmf_fieldscatter(tracers_input_grid(n), dummy3dflip, rootpet=0, rc=rc)
2027 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2034 if (myrank == 0)
then
2038 print*,
"- CALL FieldScatter FOR INPUT GRID DZDT"
2039 call esmf_fieldscatter(dzdt_input_grid, dummy3dflip, rootpet=0, rc=rc)
2040 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2043 deallocate(dummy3dflip, dummy3dall, dummy3d)
2048 print*,
"- READ TERRAIN."
2049 error=nf90_inq_varid(ncid,
'hgtsfc', id_var)
2050 call
netcdf_err(error,
'reading hgtsfc field id' )
2051 error=nf90_get_var(ncid, id_var, dummy)
2052 call
netcdf_err(error,
'reading hgtsfc field' )
2055 print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN."
2056 call esmf_fieldscatter(terrain_input_grid, dummy, rootpet=0, rc=rc)
2057 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2063 print*,
"- READ SURFACE P."
2064 error=nf90_inq_varid(ncid,
'pressfc', id_var)
2065 call
netcdf_err(error,
'reading pressfc field id' )
2066 error=nf90_get_var(ncid, id_var, dummy)
2067 call
netcdf_err(error,
'reading pressfc field' )
2070 print*,
"- CALL FieldScatter FOR INPUT GRID SURFACE P."
2071 call esmf_fieldscatter(ps_input_grid, dummy, rootpet=0, rc=rc)
2072 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2075 deallocate(kcount, startk, displ, ircnt, dummy)
2087 print*,
"- CALL FieldGet FOR PRESSURE."
2088 call esmf_fieldget(pres_input_grid, &
2089 computationallbound=clb, &
2090 computationalubound=cub, &
2091 farrayptr=presptr, rc=rc)
2092 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2095 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
2096 call esmf_fieldget(dpres_input_grid, &
2097 farrayptr=dpresptr, rc=rc)
2098 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2101 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
2102 call esmf_fieldget(ps_input_grid, &
2103 farrayptr=psptr, rc=rc)
2104 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2107 allocate(pres_interface(levp1_input))
2122 do i = clb(1), cub(1)
2123 do j = clb(2), cub(2)
2124 pres_interface(levp1_input) = phalf(1) * 100.0_8
2125 do k = lev_input, 1, -1
2126 pres_interface(k) = pres_interface(k+1) + dpresptr(i,j,k)
2128 psptr(i,j) = pres_interface(1)
2130 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
2135 deallocate(pres_interface, phalf)
2137 call esmf_fielddestroy(dpres_input_grid, rc=rc)
2156 integer,
intent(in) :: localpet
2158 character(len=500) :: tilefile
2160 integer :: error, ncid, rc, tile
2161 integer :: id_dim, idim_input, jdim_input
2162 integer :: id_var, i, j, k, n
2163 integer :: clb(3), cub(3), num_tracers_file
2165 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
2166 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
2167 real(esmf_kind_r8),
pointer :: presptr(:,:,:), dpresptr(:,:,:)
2168 real(esmf_kind_r8),
pointer :: psptr(:,:)
2169 real(esmf_kind_r8),
allocatable :: pres_interface(:), phalf(:)
2171 print*,
"- READ INPUT ATMOS DATA FROM TILED HISTORY FILES."
2173 tilefile = trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(1))
2174 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
2175 call
netcdf_err(error,
'opening: '//trim(tilefile) )
2177 error=nf90_inq_dimid(ncid,
'grid_xt', id_dim)
2178 call
netcdf_err(error,
'reading grid_xt id' )
2179 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
2180 call
netcdf_err(error,
'reading grid_xt value' )
2182 error=nf90_inq_dimid(ncid,
'grid_yt', id_dim)
2183 call
netcdf_err(error,
'reading grid_yt id' )
2184 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
2185 call
netcdf_err(error,
'reading grid_yt value' )
2187 if (idim_input /= i_input .or. jdim_input /= j_input)
then
2188 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 2)
2191 error=nf90_inq_dimid(ncid,
'pfull', id_dim)
2193 error=nf90_inquire_dimension(ncid,id_dim,len=lev_input)
2194 call
netcdf_err(error,
'reading pfull value' )
2196 error=nf90_inq_dimid(ncid,
'phalf', id_dim)
2198 error=nf90_inquire_dimension(ncid,id_dim,len=levp1_input)
2199 call
netcdf_err(error,
'reading phalf value' )
2200 allocate(phalf(levp1_input))
2201 error=nf90_inq_varid(ncid,
'phalf', id_var)
2202 call
netcdf_err(error,
'getting phalf varid' )
2203 error=nf90_get_var(ncid, id_var, phalf)
2204 call
netcdf_err(error,
'reading phalf varid' )
2206 error=nf90_get_att(ncid, nf90_global,
'ncnsto', num_tracers_file)
2207 call
netcdf_err(error,
'reading ntracer value' )
2209 error = nf90_close(ncid)
2211 print*,
'- FILE HAS ', num_tracers_file,
' TRACERS.'
2212 print*,
'- WILL PROCESS ', num_tracers,
' TRACERS.'
2220 print*,
"- CALL FieldCreate FOR INPUT GRID DELTA PRESSURE."
2221 dpres_input_grid = esmf_fieldcreate(input_grid, &
2222 typekind=esmf_typekind_r8, &
2223 staggerloc=esmf_staggerloc_center, &
2224 ungriddedlbound=(/1/), &
2225 ungriddedubound=(/lev_input/), rc=rc)
2226 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2229 if (localpet < num_tiles_input_grid)
then
2230 allocate(data_one_tile(i_input,j_input))
2231 allocate(data_one_tile_3d(i_input,j_input,lev_input))
2233 allocate(data_one_tile(0,0))
2234 allocate(data_one_tile_3d(0,0,0))
2237 if (localpet < num_tiles_input_grid)
then
2239 tilefile= trim(data_dir_input_grid) //
"/" // trim(atm_files_input_grid(tile))
2240 print*,
"- READ ATMOSPHERIC DATA FROM: ", trim(tilefile)
2241 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
2242 call
netcdf_err(error,
'opening: '//trim(tilefile) )
2245 if (localpet < num_tiles_input_grid)
then
2255 data_one_tile_3d = 0.0_8
2258 do tile = 1, num_tiles_input_grid
2259 print*,
"- CALL FieldScatter FOR INPUT GRID VERTICAL VELOCITY."
2260 call esmf_fieldscatter(dzdt_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2261 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2265 do n = 1, num_tracers
2267 if (localpet < num_tiles_input_grid)
then
2268 print*,
"- READ ", trim(tracers_input(n))
2269 error=nf90_inq_varid(ncid, tracers_input(n), id_var)
2271 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2273 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2276 do tile = 1, num_tiles_input_grid
2277 print*,
"- CALL FieldScatter FOR INPUT GRID TRACER ", trim(tracers_input(n))
2278 call esmf_fieldscatter(tracers_input_grid(n), data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2279 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2285 if (localpet < num_tiles_input_grid)
then
2286 print*,
"- READ TEMPERATURE."
2287 error=nf90_inq_varid(ncid,
'tmp', id_var)
2289 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2291 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2294 do tile = 1, num_tiles_input_grid
2295 print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
2296 call esmf_fieldscatter(temp_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2297 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2301 if (localpet < num_tiles_input_grid)
then
2302 print*,
"- READ U-WIND."
2303 error=nf90_inq_varid(ncid,
'ugrd', id_var)
2305 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2307 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2310 do tile = 1, num_tiles_input_grid
2311 print*,
"- CALL FieldScatter FOR INPUT GRID U."
2312 call esmf_fieldscatter(u_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2313 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2317 if (localpet < num_tiles_input_grid)
then
2318 print*,
"- READ V-WIND."
2319 error=nf90_inq_varid(ncid,
'vgrd', id_var)
2321 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2323 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2326 do tile = 1, num_tiles_input_grid
2327 print*,
"- CALL FieldScatter FOR INPUT GRID V."
2328 call esmf_fieldscatter(v_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2329 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2333 if (localpet < num_tiles_input_grid)
then
2334 print*,
"- READ SURFACE PRESSURE."
2335 error=nf90_inq_varid(ncid,
'pressfc', id_var)
2337 error=nf90_get_var(ncid, id_var, data_one_tile)
2341 do tile = 1, num_tiles_input_grid
2342 print*,
"- CALL FieldScatter FOR INPUT GRID SURFACE PRESSURE."
2343 call esmf_fieldscatter(ps_input_grid, data_one_tile, rootpet=tile-1, tile=tile, rc=rc)
2344 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2348 if (localpet < num_tiles_input_grid)
then
2349 print*,
"- READ TERRAIN."
2350 error=nf90_inq_varid(ncid,
'hgtsfc', id_var)
2352 error=nf90_get_var(ncid, id_var, data_one_tile)
2356 do tile = 1, num_tiles_input_grid
2357 print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN."
2358 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=tile-1, tile=tile, rc=rc)
2359 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2363 if (localpet < num_tiles_input_grid)
then
2364 print*,
"- READ DELTA PRESSURE."
2365 error=nf90_inq_varid(ncid,
'dpres', id_var)
2367 error=nf90_get_var(ncid, id_var, data_one_tile_3d)
2369 data_one_tile_3d(:,:,1:lev_input) = data_one_tile_3d(:,:,lev_input:1:-1)
2372 do tile = 1, num_tiles_input_grid
2373 print*,
"- CALL FieldScatter FOR INPUT DELTA PRESSURE."
2374 call esmf_fieldscatter(dpres_input_grid, data_one_tile_3d, rootpet=tile-1, tile=tile, rc=rc)
2375 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2379 if (localpet < num_tiles_input_grid) error = nf90_close(ncid)
2381 deallocate(data_one_tile_3d, data_one_tile)
2393 print*,
"- CALL FieldGet FOR PRESSURE."
2394 call esmf_fieldget(pres_input_grid, &
2395 computationallbound=clb, &
2396 computationalubound=cub, &
2397 farrayptr=presptr, rc=rc)
2398 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2401 print*,
"- CALL FieldGet FOR DELTA PRESSURE."
2402 call esmf_fieldget(dpres_input_grid, &
2403 farrayptr=dpresptr, rc=rc)
2404 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2407 print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
2408 call esmf_fieldget(ps_input_grid, &
2409 farrayptr=psptr, rc=rc)
2410 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2413 allocate(pres_interface(levp1_input))
2419 do i = clb(1), cub(1)
2420 do j = clb(2), cub(2)
2421 pres_interface(1) = psptr(i,j)
2422 do k = 2, levp1_input
2423 pres_interface(k) = pres_interface(k-1) - dpresptr(i,j,k-1)
2426 presptr(i,j,k) = (pres_interface(k) + pres_interface(k+1)) / 2.0_8
2431 deallocate(pres_interface, phalf)
2433 call esmf_fielddestroy(dpres_input_grid, rc=rc)
2449 integer,
intent(in) :: localpet
2451 integer,
parameter :: ntrac_max=14
2453 character(len=300) :: the_file
2454 character(len=20) :: vlevtyp, vname, lvl_str,lvl_str_space, &
2455 trac_names_grib_1(ntrac_max), &
2456 trac_names_grib_2(ntrac_max), &
2457 trac_names_vmap(ntrac_max), &
2458 tracers_input_grib_1(num_tracers), &
2459 tracers_input_grib_2(num_tracers), &
2461 method, tracers_input_vmap(num_tracers), &
2462 tracers_default(ntrac_max), vname2
2463 character (len=500) :: metadata
2465 integer :: i, j, k, n, lvl_str_space_len
2466 integer :: rc, clb(3), cub(3)
2467 integer :: vlev, iret,varnum
2472 logical :: conv_omega=.false., &
2476 real(esmf_kind_r8),
allocatable :: rlevs(:)
2477 real(esmf_kind_r4),
allocatable :: dummy2d(:,:)
2478 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:), dummy2d_8(:,:),&
2479 u_tmp_3d(:,:,:), v_tmp_3d(:,:,:)
2480 real(esmf_kind_r8),
pointer :: presptr(:,:,:), psptr(:,:),tptr(:,:,:), &
2481 qptr(:,:,:), wptr(:,:,:), &
2482 uptr(:,:,:), vptr(:,:,:)
2483 real(esmf_kind_r4) :: value
2484 real(esmf_kind_r8),
parameter :: p0 = 100000.0
2490 trac_names_grib_1 = (/
":var0_2",
":var0_2",
":var0_2",
":var0_2",
":var0_2",
":var0_2", \
2491 ":var0_2",
":var0_2",
":var0_2",
":var0_2",
":var0_2",
":var0_2", \
2492 ":var0_2",
":var0_2"/)
2493 trac_names_grib_2 = (/
"_1_0: ",
"_1_22: ",
"_14_192:",
"_1_23: ",
"_1_24: ",
"_1_25: ", \
2494 "_1_32: ",
"_6_1: ",
"_6_29: ",
"_1_100: ",
"_6_28: ",
"_13_193:", \
2495 "_13_192:",
"_2_2: "/)
2496 trac_names_vmap = (/
"sphum ",
"liq_wat ",
"o3mr ",
"ice_wat ", &
2497 "rainwat ",
"snowwat ",
"graupel ",
"cld_amt ",
"ice_nc ", &
2498 "rain_nc ",
"water_nc",
"liq_aero",
"ice_aero", &
2500 tracers_default = (/
"sphum ",
"liq_wat ",
"o3mr ",
"ice_wat ", &
2501 "rainwat ",
"snowwat ",
"graupel ",
"cld_amt ",
"ice_nc ", &
2502 "rain_nc ",
"water_nc",
"liq_aero",
"ice_aero", &
2505 the_file = trim(data_dir_input_grid) //
"/" // trim(grib2_file_input_grid)
2507 print*,
"- READ ATMOS DATA FROM GRIB2 FILE: ", trim(the_file)
2508 print*,
"- USE INVENTORY FILE ", inv_file
2510 print*,
"- OPEN FILE."
2511 inquire(file=the_file,exist=lret)
2512 if (.not.lret) call
error_handler(
"OPENING GRIB2 ATM FILE.", iret)
2514 print*,
"- READ VERTICAL COORDINATE."
2515 iret = grb2_inq(the_file,inv_file,
":var0_2",
"_0_0:",
":10 hybrid level:")
2519 lvl_str_space =
" mb:"
2520 lvl_str_space_len = 4
2522 iret = grb2_inq(the_file,inv_file,
":UGRD:",lvl_str_space)
2524 if (localpet == 0) print*,
"- DATA IS ON ", lev_input,
" ISOBARIC LEVELS."
2527 lvl_str_space =
" hybrid "
2528 lvl_str_space_len = 7
2530 iret = grb2_inq(the_file,inv_file,
":UGRD:",lvl_str_space,
" level:")
2531 if (iret < 0) call
error_handler(
"READING VERTICAL LEVEL TYPE.", iret)
2535 allocate(slevs(lev_input))
2536 allocate(rlevs(lev_input))
2537 levp1_input = lev_input + 1
2542 iret=grb2_inq(the_file,inv_file,
':UGRD:',trim(lvl_str),sequential=i-1,desc=metadata)
2543 if (iret.ne.1) call
error_handler(
" IN SEQUENTIAL FILE READ.", iret)
2545 j = index(metadata,
':UGRD:') + len(
':UGRD:')
2546 k = index(metadata,trim(lvl_str_space)) + len(trim(lvl_str_space))-1
2548 read(metadata(j:k),*) rlevs(i)
2550 slevs(i) = metadata(j-1:k)
2551 if (.not. isnative) rlevs(i) = rlevs(i) * 100.0
2552 if (localpet==0) print*,
"- LEVEL = ", slevs(i)
2559 if (.not. isnative)
then
2561 write(slevs(i),
"(F20.10)") rlevs(i)/100.0
2562 len_str = len_trim(slevs(i))
2564 do while (slevs(i)(len_str:len_str) .eq.
'0')
2565 slevs(i) = slevs(i)(:len_str-1)
2566 len_str = len_str - 1
2569 if (slevs(i)(len_str:len_str) .eq.
'.')
then
2570 slevs(i) = slevs(i)(:len_str-1)
2571 len_str = len_str - 1
2574 slevs(i) = trim(slevs(i))
2576 slevs(i) =
":"//trim(adjustl(slevs(i)))//
" mb:"
2577 if (localpet==0) print*,
"- LEVEL AFTER SORT = ",slevs(i)
2581 if (localpet == 0) print*,
"- FIND SPFH OR RH IN FILE"
2582 iret = grb2_inq(the_file,inv_file,trim(trac_names_grib_1(1)),trac_names_grib_2(1),lvl_str_space)
2585 iret = grb2_inq(the_file,inv_file,
':var0_2',
'_1_1:',lvl_str_space)
2586 if (iret <= 0) call
error_handler(
"READING ATMOSPHERIC WATER VAPOR VARIABLE.", iret)
2588 trac_names_grib_2(1)=
'_1_1:'
2589 if (localpet == 0) print*,
"- FILE CONTAINS RH."
2591 if (localpet == 0) print*,
"- FILE CONTAINS SPFH."
2594 if (localpet == 0) print*,
"- FIND ICMR, SCLIWC, OR CICE IN FILE"
2595 iret = grb2_inq(the_file,inv_file,trac_names_grib_1(4),trac_names_grib_2(4),lvl_str_space)
2598 vname = trac_names_vmap(4)
2599 print*,
"vname = ", vname
2600 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
2601 this_field_var_name=tmpstr,loc=varnum)
2602 iret = grb2_inq(the_file,inv_file,
':var0_2',
'_1_84:',lvl_str_space)
2604 iret = grb2_inq(the_file,inv_file,
':var0_2',
'_6_0:',lvl_str_space)
2605 if (iret <= 0 )
then
2608 trac_names_grib_2(4) =
'_6_0'
2609 if (localpet == 0) print*,
"- FILE CONTAINS CICE."
2612 trac_names_grib_2(4)=
'_1_84:'
2613 if (localpet == 0) print*,
"- FILE CONTAINS SCLIWC."
2616 if (localpet == 0) print*,
"- FILE CONTAINS ICMR."
2619 if (localpet == 0) print*,
"- FIND CLWMR or SCLLWC IN FILE"
2620 iret = grb2_inq(the_file,inv_file,trac_names_grib_1(5),trac_names_grib_2(5),lvl_str_space)
2623 vname = trac_names_vmap(5)
2624 print*,
"vname = ", vname
2625 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
2626 this_field_var_name=tmpstr,loc=varnum)
2627 iret = grb2_inq(the_file,inv_file,
':var0_2',
'_1_83:',lvl_str_space)
2630 elseif (iret <=0 .and. rc .ne. 1)
then
2633 trac_names_grib_2(4)=
'_1_83:'
2634 if (localpet == 0) print*,
"- FILE CONTAINS SCLLWC."
2637 if (localpet == 0) print*,
"- FILE CONTAINS CLWMR."
2640 do n = 1, num_tracers
2642 vname = tracers_input(n)
2644 i = maxloc(merge(1.,0.,trac_names_vmap == vname),dim=1)
2646 tracers_input_grib_1(n) = trac_names_grib_1(i)
2647 tracers_input_grib_2(n) = trac_names_grib_2(i)
2648 tracers_input_vmap(n)=trac_names_vmap(i)
2649 tracers(n)=tracers_default(i)
2653 if (localpet==0) print*,
"- NUMBER OF TRACERS TO BE PROCESSED = ", num_tracers
2661 if (localpet == 0)
then
2662 allocate(dummy2d(i_input,j_input))
2663 allocate(dummy2d_8(i_input,j_input))
2664 allocate(dummy3d(i_input,j_input,lev_input))
2666 allocate(dummy2d(0,0))
2667 allocate(dummy2d_8(0,0))
2668 allocate(dummy3d(0,0,0))
2677 if (localpet == 0)
then
2678 print*,
"- READ TEMPERATURE."
2680 do vlev = 1, lev_input
2681 iret = grb2_inq(the_file,inv_file,vname,slevs(vlev),data2=dummy2d)
2683 call
error_handler(
"READING IN TEMPERATURE AT LEVEL "//trim(slevs(vlev)),iret)
2685 dummy3d(:,:,vlev) =
real(dummy2d,esmf_kind_r8)
2686 print*,
'temp check after read ',vlev, dummy3d(1,1,vlev)
2690 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID TEMPERATURE."
2691 call esmf_fieldscatter(temp_input_grid, dummy3d, rootpet=0, rc=rc)
2692 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2695 do n = 1, num_tracers
2697 if (localpet == 0) print*,
"- READ ", trim(tracers_input_vmap(n))
2698 vname = tracers_input_vmap(n)
2699 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
2700 this_field_var_name=tmpstr,loc=varnum)
2701 if (n==1 .and. .not. hasspfh)
then
2702 print*,
"- CALL FieldGather TEMPERATURE."
2703 call esmf_fieldgather(temp_input_grid,dummy3d,rootpet=0, tile=1, rc=rc)
2704 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2708 if (localpet == 0)
then
2709 vname = trim(tracers_input_grib_1(n))
2710 vname2 = trim(tracers_input_grib_2(n))
2712 do vlev = 1, lev_input
2713 iret = grb2_inq(the_file,inv_file,vname,slevs(vlev),vname2,data2=dummy2d)
2718 if (trim(vname2)==
"_1_0:" .or. trim(vname2) ==
"_1_1:" .or. &
2719 trim(vname2) ==
":14:192:")
then
2720 call
error_handler(
"READING IN "//trim(vname)//
" AT LEVEL "//trim(slevs(vlev))&
2721 //
". SET A FILL VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",iret)
2726 if (n==1 .and. .not. hasspfh)
then
2727 call
rh2spfh(dummy2d,rlevs(vlev),dummy3d(:,:,vlev))
2730 print*,
'tracer ',vlev, maxval(dummy2d),minval(dummy2d)
2731 dummy3d(:,:,vlev) =
real(dummy2d,esmf_kind_r8)
2735 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT ", trim(tracers_input_vmap(n))
2736 call esmf_fieldscatter(tracers_input_grid(n), dummy3d, rootpet=0, rc=rc)
2737 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2742 call
read_winds(the_file,inv_file,u_tmp_3d,v_tmp_3d, localpet)
2744 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT U-WIND."
2745 call esmf_fieldscatter(u_input_grid, u_tmp_3d, rootpet=0, rc=rc)
2746 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2749 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT V-WIND."
2750 call esmf_fieldscatter(v_input_grid, v_tmp_3d, rootpet=0, rc=rc)
2751 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2754 if (localpet == 0)
then
2755 print*,
"- READ SURFACE PRESSURE."
2758 vlevtyp =
":surface:"
2759 iret = grb2_inq(the_file,inv_file,vname,vname2,vlevtyp,data2=dummy2d)
2760 if (iret <= 0) call
error_handler(
"READING SURFACE PRESSURE RECORD.", iret)
2761 dummy2d_8 =
real(dummy2d,esmf_kind_r8)
2764 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID SURFACE PRESSURE."
2765 call esmf_fieldscatter(ps_input_grid, dummy2d_8, rootpet=0, rc=rc)
2766 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2769 if (localpet == 0)
then
2770 print*,
"- READ DZDT."
2772 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
2776 do vlev = 1, lev_input
2777 iret = grb2_inq(the_file,inv_file,vname,vname2,slevs(vlev),data2=dummy2d)
2778 if (iret <= 0 )
then
2779 print*,
"DZDT not available at level ", trim(slevs(vlev)),
" so checking for VVEL"
2781 iret = grb2_inq(the_file,inv_file,vname,vname2,slevs(vlev),data2=dummy2d)
2792 print*,
'dzdt ',vlev, maxval(dummy2d),minval(dummy2d)
2793 dummy3d(:,:,vlev) = dummy2d
2797 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT DZDT."
2798 call esmf_fieldscatter(dzdt_input_grid, dummy3d, rootpet=0, rc=rc)
2799 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2802 if (localpet == 0)
then
2803 print*,
"- READ TERRAIN."
2806 vlevtyp =
":surface:"
2807 iret = grb2_inq(the_file,inv_file,vname,vname2,vlevtyp,data2=dummy2d)
2808 if (iret <= 0) call
error_handler(
"READING TERRAIN HEIGHT RECORD.", iret)
2809 dummy2d_8 =
real(dummy2d,esmf_kind_r8)
2812 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID TERRAIN."
2813 call esmf_fieldscatter(terrain_input_grid, dummy2d_8, rootpet=0, rc=rc)
2814 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2817 deallocate(dummy2d, dummy2d_8)
2819 if (.not. isnative)
then
2825 if (localpet == 0) print*,
"- CALL FieldGet FOR SURFACE PRESSURE."
2827 call esmf_fieldget(ps_input_grid, &
2828 farrayptr=psptr, rc=rc)
2829 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2833 if (localpet == 0) print*,
"- CALL FieldGet FOR 3-D PRESSURE."
2834 call esmf_fieldget(pres_input_grid, &
2835 computationallbound=clb, &
2836 computationalubound=cub, &
2837 farrayptr=presptr, rc=rc)
2838 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2842 if (localpet == 0) print*,
"- CALL FieldGet TEMPERATURE."
2843 call esmf_fieldget(temp_input_grid, &
2844 farrayptr=tptr, rc=rc)
2845 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2849 if (localpet == 0) print*,
"- CALL FieldGet FOR U"
2850 call esmf_fieldget(u_input_grid, &
2851 farrayptr=uptr, rc=rc)
2852 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2856 if (localpet == 0) print*,
"- CALL FieldGet FOR V"
2857 call esmf_fieldget(v_input_grid, &
2858 farrayptr=vptr, rc=rc)
2859 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2863 if (localpet == 0) print*,
"- CALL FieldGet FOR W"
2864 call esmf_fieldget(dzdt_input_grid, &
2865 farrayptr=wptr, rc=rc)
2866 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2869 if (localpet == 0) print*,
"- CALL FieldGet FOR TRACERS."
2872 call esmf_fieldget(tracers_input_grid(n), &
2873 farrayptr=qptr, rc=rc)
2874 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2876 do i = clb(1),cub(1)
2877 do j = clb(2),cub(2)
2878 qptr(i,j,:) = qptr(i,j,lev_input:1:-1)
2883 do i = clb(1),cub(1)
2884 do j = clb(2),cub(2)
2885 presptr(i,j,:) = rlevs(lev_input:1:-1)
2886 tptr(i,j,:) = tptr(i,j,lev_input:1:-1)
2887 uptr(i,j,:) = uptr(i,j,lev_input:1:-1)
2888 vptr(i,j,:) = vptr(i,j,lev_input:1:-1)
2889 wptr(i,j,:) = wptr(i,j,lev_input:1:-1)
2893 if (localpet == 0)
then
2894 print*,
'psfc is ',clb(1),clb(2),psptr(clb(1),clb(2))
2895 print*,
'pres is ',cub(1),cub(2),presptr(cub(1),cub(2),:)
2897 print*,
'pres check 1',localpet,maxval(presptr(clb(1):cub(1),clb(2):cub(2),1)), &
2898 minval(presptr(clb(1):cub(1),clb(2):cub(2),1))
2899 print*,
'pres check lev',localpet,maxval(presptr(clb(1):cub(1),clb(2):cub(2), &
2900 lev_input)),minval(presptr(clb(1):cub(1),clb(2):cub(2),lev_input))
2905 if (localpet == 0)
then
2906 print*,
"- READ PRESSURE."
2908 do vlev = 1, lev_input
2909 iret = grb2_inq(the_file,inv_file,vname,slevs(vlev),data2=dummy2d)
2911 call
error_handler(
"READING IN PRESSURE AT LEVEL "//trim(slevs(vlev)),iret)
2913 dummy3d(:,:,vlev) =
real(dummy2d,esmf_kind_r8)
2914 print*,
'pres check after read ',vlev, dummy3d(1,1,vlev)
2918 if (localpet == 0) print*,
"- CALL FieldScatter FOR INPUT GRID PRESSURE."
2919 call esmf_fieldscatter(pres_input_grid, dummy3d, rootpet=0, rc=rc)
2920 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2935 if (conv_omega)
then
2937 if (localpet == 0) print*,
"- CONVERT FROM OMEGA TO DZDT."
2940 if (localpet == 0) print*,
"- CALL FieldGet TEMPERATURE."
2941 call esmf_fieldget(temp_input_grid, &
2942 farrayptr=tptr, rc=rc)
2943 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2947 if (localpet == 0) print*,
"- CALL FieldGet SPECIFIC HUMIDITY."
2948 call esmf_fieldget(tracers_input_grid(1), &
2949 computationallbound=clb, &
2950 computationalubound=cub, &
2951 farrayptr=qptr, rc=rc)
2952 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2956 if (localpet == 0) print*,
"- CALL FieldGet DZDT."
2957 call esmf_fieldget(dzdt_input_grid, &
2958 computationallbound=clb, &
2959 computationalubound=cub, &
2960 farrayptr=wptr, rc=rc)
2961 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2965 call esmf_fieldget(pres_input_grid, &
2966 farrayptr=presptr, rc=rc)
2967 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2989 integer,
intent(in) :: localpet
2991 character(len=300) :: the_file
2993 integer(sfcio_intkind) :: iret
2996 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
2997 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
2999 type(sfcio_head
) :: sfchead
3000 type(sfcio_dbta
) :: sfcdata
3002 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
3004 print*,
"- READ SURFACE DATA IN SFCIO FORMAT."
3005 print*,
"- OPEN AND READ: ",trim(the_file)
3006 call sfcio_sropen(23, trim(the_file), iret)
3012 call sfcio_srhead(23, sfchead, iret)
3018 if (localpet == 0)
then
3019 call sfcio_aldbta(sfchead, sfcdata, iret)
3024 call sfcio_srdbta(23, sfchead, sfcdata, iret)
3029 allocate(dummy2d(i_input,j_input))
3030 allocate(dummy3d(i_input,j_input,lsoil_input))
3032 allocate(dummy2d(0,0))
3033 allocate(dummy3d(0,0,0))
3036 if (localpet == 0) dummy2d = sfcdata%slmsk
3038 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
3039 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
3040 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3043 if (localpet == 0) dummy2d = sfcdata%zorl
3045 print*,
"- CALL FieldScatter FOR INPUT Z0."
3046 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
3047 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3050 if (localpet == 0) dummy2d = nint(sfcdata%vtype)
3052 print*,
"- CALL FieldScatter FOR INPUT VEG TYPE."
3053 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
3054 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3058 veg_type_landice_input = 13
3060 if (localpet == 0) dummy2d = sfcdata%canopy
3062 print*,
"- CALL FieldScatter FOR INPUT CANOPY MC."
3063 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
3064 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3067 if (localpet == 0) dummy2d = sfcdata%fice
3069 print*,
"- CALL FieldScatter FOR INPUT ICE FRACTION."
3070 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
3071 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3074 if (localpet == 0) dummy2d = sfcdata%hice
3076 print*,
"- CALL FieldScatter FOR INPUT ICE DEPTH."
3077 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3078 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3081 if (localpet == 0) dummy2d = sfcdata%tisfc
3083 print*,
"- CALL FieldScatter FOR INPUT ICE SKIN TEMP."
3084 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3085 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3088 if (localpet == 0) dummy2d = sfcdata%snwdph
3090 print*,
"- CALL FieldScatter FOR INPUT SNOW DEPTH."
3091 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3092 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3095 if (localpet == 0) dummy2d = sfcdata%sheleg
3097 print*,
"- CALL FieldScatter FOR INPUT SNOW LIQUID EQUIV."
3098 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
3099 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3102 if (localpet == 0) dummy2d = sfcdata%t2m
3104 print*,
"- CALL FieldScatter FOR INPUT T2M."
3105 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
3106 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3109 if (localpet == 0) dummy2d = sfcdata%q2m
3111 print*,
"- CALL FieldScatter FOR INPUT Q2M."
3112 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
3113 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3116 if (localpet == 0) dummy2d = sfcdata%tprcp
3118 print*,
"- CALL FieldScatter FOR INPUT TPRCP."
3119 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
3120 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3123 if (localpet == 0) dummy2d = sfcdata%f10m
3125 print*,
"- CALL FieldScatter FOR INPUT F10M."
3126 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
3127 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3130 if (localpet == 0) dummy2d = sfcdata%uustar
3132 print*,
"- CALL FieldScatter FOR INPUT USTAR."
3133 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
3134 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3137 if (localpet == 0) dummy2d = sfcdata%ffmm
3139 print*,
"- CALL FieldScatter FOR INPUT FFMM."
3140 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
3141 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3144 if (localpet == 0) dummy2d = sfcdata%srflag
3146 print*,
"- CALL FieldScatter FOR INPUT SRFLAG."
3147 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
3148 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3151 if (localpet == 0) dummy2d = sfcdata%tsea
3153 print*,
"- CALL FieldScatter FOR INPUT SKIN TEMP."
3154 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3155 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3158 if (localpet == 0) dummy2d = nint(sfcdata%stype)
3160 print*,
"- CALL FieldScatter FOR INPUT SOIL TYPE."
3161 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
3162 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3165 if (localpet == 0) dummy2d = sfcdata%orog
3167 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
3168 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
3169 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3172 if (localpet == 0) dummy3d = sfcdata%slc
3174 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
3175 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
3176 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3179 if (localpet == 0) dummy3d = sfcdata%smc
3181 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
3182 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
3183 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3186 if (localpet == 0) dummy3d = sfcdata%stc
3188 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
3189 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
3190 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3193 deallocate(dummy2d, dummy3d)
3194 call sfcio_axdbta(sfcdata, iret)
3196 call sfcio_sclose(23, iret)
3211 integer,
intent(in) :: localpet
3213 character(len=300) :: the_file
3217 real(nemsio_realkind),
allocatable :: dummy(:)
3218 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
3219 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
3221 type(nemsio_gfile
) :: gfile
3223 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
3225 if (localpet == 0)
then
3226 allocate(dummy3d(i_input,j_input,lsoil_input))
3227 allocate(dummy2d(i_input,j_input))
3228 allocate(dummy(i_input*j_input))
3229 print*,
"- OPEN FILE ", trim(the_file)
3230 call nemsio_open(gfile, the_file,
"read", iret=rc)
3233 allocate(dummy3d(0,0,0))
3234 allocate(dummy2d(0,0))
3238 if (localpet == 0)
then
3239 print*,
"- READ TERRAIN."
3240 call nemsio_readrecv(gfile,
"orog",
"sfc", 1, dummy, 0, iret=rc)
3242 dummy2d = reshape(dummy, (/i_input,j_input/))
3243 print*,
'orog ',maxval(dummy2d),minval(dummy2d)
3246 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
3247 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
3248 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3251 if (localpet == 0)
then
3252 print*,
"- READ LANDSEA MASK."
3253 call nemsio_readrecv(gfile,
"land",
"sfc", 1, dummy, 0, iret=rc)
3254 if (rc /= 0) call
error_handler(
"READING LANDSEA MASK.", rc)
3255 dummy2d = reshape(dummy, (/i_input,j_input/))
3256 print*,
'landmask ',maxval(dummy2d),minval(dummy2d)
3259 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
3260 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
3261 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3264 if (localpet == 0)
then
3265 print*,
"- READ SEAICE FRACTION."
3266 call nemsio_readrecv(gfile,
"icec",
"sfc", 1, dummy, 0, iret=rc)
3267 if (rc /= 0) call
error_handler(
"READING SEAICE FRACTION.", rc)
3268 dummy2d = reshape(dummy, (/i_input,j_input/))
3269 print*,
'icec ',maxval(dummy2d),minval(dummy2d)
3272 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
3273 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
3274 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3277 if (localpet == 0)
then
3278 print*,
"- READ SEAICE DEPTH."
3279 call nemsio_readrecv(gfile,
"icetk",
"sfc", 1, dummy, 0, iret=rc)
3280 if (rc /= 0) call
error_handler(
"READING SEAICE DEPTH.", rc)
3281 dummy2d = reshape(dummy, (/i_input,j_input/))
3282 print*,
'icetk ',maxval(dummy2d),minval(dummy2d)
3285 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
3286 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3287 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3290 if (localpet == 0)
then
3291 print*,
"- READ SEAICE SKIN TEMPERATURE."
3292 call nemsio_readrecv(gfile,
"tisfc",
"sfc", 1, dummy, 0, iret=rc)
3293 if (rc /= 0) call
error_handler(
"READING SEAICE SKIN TEMP.", rc)
3294 dummy2d = reshape(dummy, (/i_input,j_input/))
3295 print*,
'ti ',maxval(dummy2d),minval(dummy2d)
3298 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
3299 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3300 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3303 if (localpet == 0)
then
3304 print*,
"- READ SNOW LIQUID EQUIVALENT."
3305 call nemsio_readrecv(gfile,
"weasd",
"sfc", 1, dummy, 0, iret=rc)
3306 if (rc /= 0) call
error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
3307 dummy2d = reshape(dummy, (/i_input,j_input/))
3308 print*,
'weasd ',maxval(dummy2d),minval(dummy2d)
3311 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
3312 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
3313 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3316 if (localpet == 0)
then
3317 print*,
"- READ SNOW DEPTH."
3318 call nemsio_readrecv(gfile,
"snod",
"sfc", 1, dummy, 0, iret=rc)
3320 dummy2d = reshape(dummy, (/i_input,j_input/))
3321 print*,
'snod ',maxval(dummy2d),minval(dummy2d)
3324 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
3325 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3326 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3329 if (localpet == 0)
then
3330 print*,
"- READ VEG TYPE."
3331 call nemsio_readrecv(gfile,
"vtype",
"sfc", 1, dummy, 0, iret=rc)
3333 dummy2d = reshape(dummy, (/i_input,j_input/))
3334 print*,
'vtype ',maxval(dummy2d),minval(dummy2d)
3337 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
3338 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
3339 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3342 if (localpet == 0)
then
3343 print*,
"- READ SOIL TYPE."
3344 call nemsio_readrecv(gfile,
"sotyp",
"sfc", 1, dummy, 0, iret=rc)
3346 dummy2d = reshape(dummy, (/i_input,j_input/))
3347 print*,
'sotype ',maxval(dummy2d),minval(dummy2d)
3350 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
3351 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
3352 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3355 if (localpet == 0)
then
3356 print*,
"- READ T2M."
3357 call nemsio_readrecv(gfile,
"tmp",
"2 m above gnd", 1, dummy, 0, iret=rc)
3359 dummy2d = reshape(dummy, (/i_input,j_input/))
3360 print*,
't2m ',maxval(dummy2d),minval(dummy2d)
3363 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
3364 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
3365 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3368 if (localpet == 0)
then
3369 print*,
"- READ Q2M."
3370 call nemsio_readrecv(gfile,
"spfh",
"2 m above gnd", 1, dummy, 0, iret=rc)
3372 dummy2d = reshape(dummy, (/i_input,j_input/))
3373 print*,
'q2m ',maxval(dummy2d),minval(dummy2d)
3376 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
3377 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
3378 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3381 if (localpet == 0)
then
3382 print*,
"- READ TPRCP."
3383 call nemsio_readrecv(gfile,
"tprcp",
"sfc", 1, dummy, 0, iret=rc)
3385 dummy2d = reshape(dummy, (/i_input,j_input/))
3386 print*,
'tprcp ',maxval(dummy2d),minval(dummy2d)
3389 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
3390 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
3391 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3394 if (localpet == 0)
then
3395 print*,
"- READ FFMM."
3396 call nemsio_readrecv(gfile,
"ffmm",
"sfc", 1, dummy, 0, iret=rc)
3398 dummy2d = reshape(dummy, (/i_input,j_input/))
3399 print*,
'ffmm ',maxval(dummy2d),minval(dummy2d)
3402 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
3403 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
3404 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3407 if (localpet == 0)
then
3408 print*,
"- READ USTAR."
3409 call nemsio_readrecv(gfile,
"fricv",
"sfc", 1, dummy, 0, iret=rc)
3411 dummy2d = reshape(dummy, (/i_input,j_input/))
3412 print*,
'fricv ',maxval(dummy2d),minval(dummy2d)
3415 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
3416 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
3417 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3420 if (localpet == 0) dummy2d = 0.0
3421 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
3422 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
3423 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3426 if (localpet == 0)
then
3427 print*,
"- READ SKIN TEMPERATURE."
3428 call nemsio_readrecv(gfile,
"tmp",
"sfc", 1, dummy, 0, iret=rc)
3429 if (rc /= 0) call
error_handler(
"READING SKIN TEMPERATURE.", rc)
3430 dummy2d = reshape(dummy, (/i_input,j_input/))
3431 print*,
'tmp ',maxval(dummy2d),minval(dummy2d)
3434 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
3435 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3436 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3439 if (localpet == 0)
then
3440 print*,
"- READ F10M."
3441 call nemsio_readrecv(gfile,
"f10m",
"10 m above gnd", 1, dummy, 0, iret=rc)
3443 dummy2d = reshape(dummy, (/i_input,j_input/))
3444 print*,
'f10m ',maxval(dummy2d),minval(dummy2d)
3447 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
3448 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
3449 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3452 if (localpet == 0)
then
3453 print*,
"- READ CANOPY MOISTURE CONTENT."
3454 call nemsio_readrecv(gfile,
"cnwat",
"sfc", 1, dummy, 0, iret=rc)
3455 if (rc /= 0) call
error_handler(
"READING CANOPY MOISTURE CONTENT.", rc)
3456 dummy2d = reshape(dummy, (/i_input,j_input/))
3457 print*,
'cnwat ',maxval(dummy2d),minval(dummy2d)
3460 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
3461 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
3462 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3465 if (localpet == 0)
then
3467 call nemsio_readrecv(gfile,
"sfcr",
"sfc", 1, dummy, 0, iret=rc)
3469 dummy2d = reshape(dummy, (/i_input,j_input/))
3470 print*,
'sfcr ',maxval(dummy2d),minval(dummy2d)
3473 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
3474 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
3475 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3480 if (localpet == 0)
then
3481 print*,
"- READ LIQUID SOIL MOISTURE."
3482 call nemsio_readrecv(gfile,
"slc",
"soil layer", 1, dummy, 0, iret=rc)
3483 if (rc /= 0) call
error_handler(
"READING LAYER 1 LIQUID SOIL MOIST.", rc)
3484 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3485 call nemsio_readrecv(gfile,
"slc",
"soil layer", 2, dummy, 0, iret=rc)
3486 if (rc /= 0) call
error_handler(
"READING LAYER 2 LIQUID SOIL MOIST.", rc)
3487 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3488 call nemsio_readrecv(gfile,
"slc",
"soil layer", 3, dummy, 0, iret=rc)
3489 if (rc /= 0) call
error_handler(
"READING LAYER 3 LIQUID SOIL MOIST.", rc)
3490 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3491 call nemsio_readrecv(gfile,
"slc",
"soil layer", 4, dummy, 0, iret=rc)
3492 if (rc /= 0) call
error_handler(
"READING LAYER 4 LIQUID SOIL MOIST.", rc)
3493 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3494 print*,
'slc ',maxval(dummy3d),minval(dummy3d)
3497 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
3498 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
3499 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3502 if (localpet == 0)
then
3503 print*,
"- READ TOTAL SOIL MOISTURE."
3504 call nemsio_readrecv(gfile,
"smc",
"soil layer", 1, dummy, 0, iret=rc)
3505 if (rc /= 0) call
error_handler(
"READING LAYER 1 TOTAL SOIL MOIST.", rc)
3506 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3507 call nemsio_readrecv(gfile,
"smc",
"soil layer", 2, dummy, 0, iret=rc)
3508 if (rc /= 0) call
error_handler(
"READING LAYER 2 TOTAL SOIL MOIST.", rc)
3509 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3510 call nemsio_readrecv(gfile,
"smc",
"soil layer", 3, dummy, 0, iret=rc)
3511 if (rc /= 0) call
error_handler(
"READING LAYER 3 TOTAL SOIL MOIST.", rc)
3512 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3513 call nemsio_readrecv(gfile,
"smc",
"soil layer", 4, dummy, 0, iret=rc)
3514 if (rc /= 0) call
error_handler(
"READING LAYER 4 TOTAL SOIL MOIST.", rc)
3515 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3516 print*,
'smc ',maxval(dummy3d),minval(dummy3d)
3519 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
3520 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
3521 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3524 if (localpet == 0)
then
3525 print*,
"- READ SOIL TEMPERATURE."
3526 call nemsio_readrecv(gfile,
"stc",
"soil layer", 1, dummy, 0, iret=rc)
3527 if (rc /= 0) call
error_handler(
"READING LAYER 1 SOIL TEMP.", rc)
3528 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3529 call nemsio_readrecv(gfile,
"stc",
"soil layer", 2, dummy, 0, iret=rc)
3530 if (rc /= 0) call
error_handler(
"READING LAYER 2 SOIL TEMP.", rc)
3531 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3532 call nemsio_readrecv(gfile,
"stc",
"soil layer", 3, dummy, 0, iret=rc)
3533 if (rc /= 0) call
error_handler(
"READING LAYER 3 SOIL TEMP.", rc)
3534 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3535 call nemsio_readrecv(gfile,
"stc",
"soil layer", 4, dummy, 0, iret=rc)
3536 if (rc /= 0) call
error_handler(
"READING LAYER 4 SOIL TEMP.", rc)
3537 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3538 print*,
'stc ',maxval(dummy3d),minval(dummy3d)
3541 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
3542 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
3543 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3546 deallocate(dummy3d, dummy)
3548 if (localpet == 0) call nemsio_close(gfile)
3560 integer,
intent(in) :: localpet
3562 character(len=250) :: the_file
3566 real(nemsio_realkind),
allocatable :: dummy(:)
3567 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
3568 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
3570 type(nemsio_gfile
) :: gfile
3572 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
3574 if (localpet == 0)
then
3575 allocate(dummy3d(i_input,j_input,lsoil_input))
3576 allocate(dummy2d(i_input,j_input))
3577 allocate(dummy(i_input*j_input))
3578 print*,
"- OPEN FILE ", trim(the_file)
3579 call nemsio_open(gfile, the_file,
"read", iret=rc)
3582 allocate(dummy3d(0,0,0))
3583 allocate(dummy2d(0,0))
3587 if (localpet == 0)
then
3588 print*,
"- READ TERRAIN."
3589 call nemsio_readrecv(gfile,
"orog",
"sfc", 1, dummy, 0, iret=rc)
3591 dummy2d = reshape(dummy, (/i_input,j_input/))
3592 print*,
'orog ',maxval(dummy2d),minval(dummy2d)
3595 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
3596 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
3597 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3600 if (localpet == 0)
then
3601 print*,
"- READ LANDSEA MASK."
3602 call nemsio_readrecv(gfile,
"land",
"sfc", 1, dummy, 0, iret=rc)
3603 if (rc /= 0) call
error_handler(
"READING LANDSEA MASK.", rc)
3604 dummy2d = reshape(dummy, (/i_input,j_input/))
3605 print*,
'landmask ',maxval(dummy2d),minval(dummy2d)
3608 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
3609 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
3610 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3613 if (localpet == 0)
then
3614 print*,
"- READ SEAICE FRACTION."
3615 call nemsio_readrecv(gfile,
"icec",
"sfc", 1, dummy, 0, iret=rc)
3616 if (rc /= 0) call
error_handler(
"READING SEAICE FRACTION.", rc)
3617 dummy2d = reshape(dummy, (/i_input,j_input/))
3618 print*,
'icec ',maxval(dummy2d),minval(dummy2d)
3621 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
3622 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
3623 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3626 if (localpet == 0)
then
3627 print*,
"- READ SEAICE DEPTH."
3628 call nemsio_readrecv(gfile,
"icetk",
"sfc", 1, dummy, 0, iret=rc)
3629 if (rc /= 0) call
error_handler(
"READING SEAICE DEPTH.", rc)
3630 dummy2d = reshape(dummy, (/i_input,j_input/))
3631 print*,
'icetk ',maxval(dummy2d),minval(dummy2d)
3634 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
3635 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3636 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3639 if (localpet == 0)
then
3640 print*,
"- READ SEAICE SKIN TEMPERATURE."
3641 call nemsio_readrecv(gfile,
"ti",
"sfc", 1, dummy, 0, iret=rc)
3642 if (rc /= 0) call
error_handler(
"READING SEAICE SKIN TEMP.", rc)
3643 dummy2d = reshape(dummy, (/i_input,j_input/))
3644 print*,
'ti ',maxval(dummy2d),minval(dummy2d)
3647 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
3648 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3649 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3652 if (localpet == 0)
then
3653 print*,
"- READ SNOW LIQUID EQUIVALENT."
3654 call nemsio_readrecv(gfile,
"weasd",
"sfc", 1, dummy, 0, iret=rc)
3655 if (rc /= 0) call
error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
3656 dummy2d = reshape(dummy, (/i_input,j_input/))
3657 print*,
'weasd ',maxval(dummy2d),minval(dummy2d)
3660 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
3661 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
3662 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3665 if (localpet == 0)
then
3666 print*,
"- READ SNOW DEPTH."
3667 call nemsio_readrecv(gfile,
"snod",
"sfc", 1, dummy, 0, iret=rc)
3669 dummy2d = reshape(dummy, (/i_input,j_input/)) * 1000.0_8
3670 print*,
'snod ',maxval(dummy2d),minval(dummy2d)
3673 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
3674 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
3675 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3678 if (localpet == 0)
then
3679 print*,
"- READ VEG TYPE."
3680 call nemsio_readrecv(gfile,
"vtype",
"sfc", 1, dummy, 0, iret=rc)
3682 dummy2d = reshape(dummy, (/i_input,j_input/))
3683 print*,
'vtype ',maxval(dummy2d),minval(dummy2d)
3686 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
3687 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
3688 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3691 if (localpet == 0)
then
3692 print*,
"- READ SOIL TYPE."
3693 call nemsio_readrecv(gfile,
"sotyp",
"sfc", 1, dummy, 0, iret=rc)
3695 dummy2d = reshape(dummy, (/i_input,j_input/))
3696 print*,
'sotype ',maxval(dummy2d),minval(dummy2d)
3699 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
3700 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
3701 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3704 if (localpet == 0)
then
3705 print*,
"- READ T2M."
3706 call nemsio_readrecv(gfile,
"tmp",
"2 m above gnd", 1, dummy, 0, iret=rc)
3708 dummy2d = reshape(dummy, (/i_input,j_input/))
3709 print*,
't2m ',maxval(dummy2d),minval(dummy2d)
3712 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
3713 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
3714 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3717 if (localpet == 0)
then
3718 print*,
"- READ Q2M."
3719 call nemsio_readrecv(gfile,
"spfh",
"2 m above gnd", 1, dummy, 0, iret=rc)
3721 dummy2d = reshape(dummy, (/i_input,j_input/))
3722 print*,
'q2m ',maxval(dummy2d),minval(dummy2d)
3725 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
3726 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
3727 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3730 if (localpet == 0)
then
3731 print*,
"- READ TPRCP."
3732 call nemsio_readrecv(gfile,
"tprcp",
"sfc", 1, dummy, 0, iret=rc)
3734 dummy2d = reshape(dummy, (/i_input,j_input/))
3735 print*,
'tprcp ',maxval(dummy2d),minval(dummy2d)
3738 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
3739 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
3740 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3743 if (localpet == 0)
then
3744 print*,
"- READ FFMM."
3745 call nemsio_readrecv(gfile,
"ffmm",
"sfc", 1, dummy, 0, iret=rc)
3747 dummy2d = reshape(dummy, (/i_input,j_input/))
3748 print*,
'ffmm ',maxval(dummy2d),minval(dummy2d)
3751 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
3752 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
3753 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3756 if (localpet == 0)
then
3757 print*,
"- READ USTAR."
3758 call nemsio_readrecv(gfile,
"fricv",
"sfc", 1, dummy, 0, iret=rc)
3760 dummy2d = reshape(dummy, (/i_input,j_input/))
3761 print*,
'fricv ',maxval(dummy2d),minval(dummy2d)
3764 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
3765 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
3766 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3769 if (localpet == 0) dummy2d = 0.0
3770 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
3771 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
3772 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3775 if (localpet == 0)
then
3776 print*,
"- READ SKIN TEMPERATURE."
3777 call nemsio_readrecv(gfile,
"tmp",
"sfc", 1, dummy, 0, iret=rc)
3778 if (rc /= 0) call
error_handler(
"READING SKIN TEMPERATURE.", rc)
3779 dummy2d = reshape(dummy, (/i_input,j_input/))
3780 print*,
'tmp ',maxval(dummy2d),minval(dummy2d)
3783 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
3784 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
3785 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3788 if (localpet == 0)
then
3789 print*,
"- READ F10M."
3790 call nemsio_readrecv(gfile,
"f10m",
"10 m above gnd", 1, dummy, 0, iret=rc)
3792 dummy2d = reshape(dummy, (/i_input,j_input/))
3793 print*,
'f10m ',maxval(dummy2d),minval(dummy2d)
3796 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
3797 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
3798 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3801 if (localpet == 0)
then
3802 print*,
"- READ CANOPY MOISTURE CONTENT."
3803 call nemsio_readrecv(gfile,
"cnwat",
"sfc", 1, dummy, 0, iret=rc)
3804 if (rc /= 0) call
error_handler(
"READING CANOPY MOISTURE CONTENT.", rc)
3805 dummy2d = reshape(dummy, (/i_input,j_input/))
3806 print*,
'cnwat ',maxval(dummy2d),minval(dummy2d)
3809 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
3810 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
3811 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3814 if (localpet == 0)
then
3816 call nemsio_readrecv(gfile,
"sfcr",
"sfc", 1, dummy, 0, iret=rc)
3818 dummy2d = reshape(dummy, (/i_input,j_input/)) * 100.0_8
3819 print*,
'sfcr ',maxval(dummy2d),minval(dummy2d)
3822 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
3823 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
3824 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3829 if (localpet == 0)
then
3830 print*,
"- READ LIQUID SOIL MOISTURE."
3831 call nemsio_readrecv(gfile,
"soill",
"0-10 cm down", 1, dummy, 0, iret=rc)
3832 if (rc /= 0) call
error_handler(
"READING LAYER 1 LIQUID SOIL MOIST.", rc)
3833 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3834 call nemsio_readrecv(gfile,
"soill",
"10-40 cm down", 1, dummy, 0, iret=rc)
3835 if (rc /= 0) call
error_handler(
"READING LAYER 2 LIQUID SOIL MOIST.", rc)
3836 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3837 call nemsio_readrecv(gfile,
"soill",
"40-100 cm down", 1, dummy, 0, iret=rc)
3838 if (rc /= 0) call
error_handler(
"READING LAYER 3 LIQUID SOIL MOIST.", rc)
3839 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3840 call nemsio_readrecv(gfile,
"soill",
"100-200 cm down", 1, dummy, 0, iret=rc)
3841 if (rc /= 0) call
error_handler(
"READING LAYER 4 LIQUID SOIL MOIST.", rc)
3842 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3843 print*,
'soill ',maxval(dummy3d),minval(dummy3d)
3846 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
3847 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
3848 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3851 if (localpet == 0)
then
3852 print*,
"- READ TOTAL SOIL MOISTURE."
3853 call nemsio_readrecv(gfile,
"soilw",
"0-10 cm down", 1, dummy, 0, iret=rc)
3854 if (rc /= 0) call
error_handler(
"READING LAYER 1 TOTAL SOIL MOIST.", rc)
3855 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3856 call nemsio_readrecv(gfile,
"soilw",
"10-40 cm down", 1, dummy, 0, iret=rc)
3857 if (rc /= 0) call
error_handler(
"READING LAYER 2 TOTAL SOIL MOIST.", rc)
3858 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3859 call nemsio_readrecv(gfile,
"soilw",
"40-100 cm down", 1, dummy, 0, iret=rc)
3860 if (rc /= 0) call
error_handler(
"READING LAYER 3 TOTAL SOIL MOIST.", rc)
3861 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3862 call nemsio_readrecv(gfile,
"soilw",
"100-200 cm down", 1, dummy, 0, iret=rc)
3863 if (rc /= 0) call
error_handler(
"READING LAYER 4 TOTAL SOIL MOIST.", rc)
3864 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3865 print*,
'soilm ',maxval(dummy3d),minval(dummy3d)
3868 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
3869 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
3870 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3873 if (localpet == 0)
then
3874 print*,
"- READ SOIL TEMPERATURE."
3875 call nemsio_readrecv(gfile,
"tmp",
"0-10 cm down", 1, dummy, 0, iret=rc)
3876 if (rc /= 0) call
error_handler(
"READING LAYER 1 SOIL TEMP.", rc)
3877 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
3878 call nemsio_readrecv(gfile,
"tmp",
"10-40 cm down", 1, dummy, 0, iret=rc)
3879 if (rc /= 0) call
error_handler(
"READING LAYER 2 SOIL TEMP.", rc)
3880 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
3881 call nemsio_readrecv(gfile,
"tmp",
"40-100 cm down", 1, dummy, 0, iret=rc)
3882 if (rc /= 0) call
error_handler(
"READING LAYER 3 SOIL TEMP.", rc)
3883 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
3884 call nemsio_readrecv(gfile,
"tmp",
"100-200 cm down", 1, dummy, 0, iret=rc)
3885 if (rc /= 0) call
error_handler(
"READING LAYER 4 SOIL TEMP.", rc)
3886 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
3887 print*,
'soilt ',maxval(dummy3d),minval(dummy3d)
3890 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
3891 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
3892 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3895 deallocate(dummy3d, dummy)
3897 if (localpet == 0) call nemsio_close(gfile)
3909 integer,
intent(in) :: localpet
3911 character(len=500) :: tilefile
3913 integer :: error, rc
3914 integer :: id_dim, idim_input, jdim_input
3915 integer :: ncid, tile, id_var
3917 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
3918 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
3925 tilefile = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
3926 print*,
"- READ GRID DIMENSIONS FROM: ", trim(tilefile)
3927 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
3928 call
netcdf_err(error,
'opening: '//trim(tilefile) )
3930 error=nf90_inq_dimid(ncid,
'xaxis_1', id_dim)
3931 call
netcdf_err(error,
'reading xaxis_1 id' )
3932 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
3933 call
netcdf_err(error,
'reading xaxis_1 value' )
3935 error=nf90_inq_dimid(ncid,
'yaxis_1', id_dim)
3936 call
netcdf_err(error,
'reading yaxis_1 id' )
3937 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
3938 call
netcdf_err(error,
'reading yaxis_1 value' )
3940 if (idim_input /= i_input .or. jdim_input /= j_input)
then
3941 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 1)
3944 error = nf90_close(ncid)
3946 if (localpet == 0)
then
3947 allocate(data_one_tile(idim_input,jdim_input))
3948 allocate(data_one_tile_3d(idim_input,jdim_input,lsoil_input))
3950 allocate(data_one_tile(0,0))
3951 allocate(data_one_tile_3d(0,0,0))
3954 terrain_loop:
do tile = 1, num_tiles_input_grid
3956 if (localpet == 0)
then
3957 tilefile = trim(orog_dir_input_grid) // trim(orog_files_input_grid(tile))
3958 print*,
'- OPEN OROGRAPHY FILE: ', trim(tilefile)
3959 error=nf90_open(tilefile,nf90_nowrite,ncid)
3960 call
netcdf_err(error,
'OPENING OROGRAPHY FILE' )
3961 error=nf90_inq_varid(ncid,
'orog_raw', id_var)
3962 call
netcdf_err(error,
'READING OROG RECORD ID' )
3963 error=nf90_get_var(ncid, id_var, data_one_tile)
3964 call
netcdf_err(error,
'READING OROG RECORD' )
3965 print*,
'terrain check ',tile, maxval(data_one_tile)
3966 error=nf90_close(ncid)
3969 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
3970 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
3971 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3976 tile_loop :
do tile = 1, num_tiles_input_grid
3980 if (localpet == 0)
then
3982 lsoil_input, sfcdata_3d=data_one_tile_3d)
3985 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
3986 call esmf_fieldscatter(soilm_liq_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
3987 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3990 if (localpet == 0)
then
3992 lsoil_input, sfcdata_3d=data_one_tile_3d)
3995 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
3996 call esmf_fieldscatter(soilm_tot_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
3997 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4000 if (localpet == 0)
then
4002 lsoil_input, sfcdata_3d=data_one_tile_3d)
4005 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
4006 call esmf_fieldscatter(soil_temp_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4007 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4012 if (localpet == 0)
then
4014 lsoil_input, sfcdata=data_one_tile)
4017 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
4018 call esmf_fieldscatter(landsea_mask_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4019 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4024 if (localpet == 0)
then
4026 lsoil_input, sfcdata=data_one_tile)
4029 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
4030 call esmf_fieldscatter(seaice_fract_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4031 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4036 if (localpet == 0)
then
4038 lsoil_input, sfcdata=data_one_tile)
4041 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
4042 call esmf_fieldscatter(seaice_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4043 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4048 if (localpet == 0)
then
4050 lsoil_input, sfcdata=data_one_tile)
4053 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
4054 call esmf_fieldscatter(seaice_skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4055 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4060 if (localpet == 0)
then
4062 lsoil_input, sfcdata=data_one_tile)
4065 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
4066 call esmf_fieldscatter(snow_liq_equiv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4067 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4072 if (localpet == 0)
then
4074 lsoil_input, sfcdata=data_one_tile)
4075 data_one_tile = data_one_tile
4078 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
4079 call esmf_fieldscatter(snow_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4080 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4085 if (localpet == 0)
then
4087 lsoil_input, sfcdata=data_one_tile)
4090 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
4091 call esmf_fieldscatter(veg_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4092 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4097 if (localpet == 0)
then
4099 lsoil_input, sfcdata=data_one_tile)
4102 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
4103 call esmf_fieldscatter(soil_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4104 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4109 if (localpet == 0)
then
4111 lsoil_input, sfcdata=data_one_tile)
4114 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
4115 call esmf_fieldscatter(t2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4116 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4121 if (localpet == 0)
then
4123 lsoil_input, sfcdata=data_one_tile)
4126 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
4127 call esmf_fieldscatter(q2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4128 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4131 if (localpet == 0)
then
4133 lsoil_input, sfcdata=data_one_tile)
4136 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
4137 call esmf_fieldscatter(tprcp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4138 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4141 if (localpet == 0)
then
4143 lsoil_input, sfcdata=data_one_tile)
4146 print*,
"- CALL FieldScatter FOR INPUT GRID F10M"
4147 call esmf_fieldscatter(f10m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4148 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4151 if (localpet == 0)
then
4153 lsoil_input, sfcdata=data_one_tile)
4156 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
4157 call esmf_fieldscatter(ffmm_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4158 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4161 if (localpet == 0)
then
4163 lsoil_input, sfcdata=data_one_tile)
4166 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
4167 call esmf_fieldscatter(ustar_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4168 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4171 if (localpet == 0)
then
4173 lsoil_input, sfcdata=data_one_tile)
4176 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
4177 call esmf_fieldscatter(srflag_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4178 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4181 if (localpet == 0)
then
4183 lsoil_input, sfcdata=data_one_tile)
4186 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
4187 call esmf_fieldscatter(skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4188 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4191 if (localpet == 0)
then
4193 lsoil_input, sfcdata=data_one_tile)
4196 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
4197 call esmf_fieldscatter(canopy_mc_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4198 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4201 if (localpet == 0)
then
4203 lsoil_input, sfcdata=data_one_tile)
4206 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
4207 call esmf_fieldscatter(z0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4208 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4213 deallocate(data_one_tile, data_one_tile_3d)
4226 integer,
intent(in) :: localpet
4228 character(len=500) :: tilefile
4230 integer :: error, id_var
4231 integer :: id_dim, idim_input, jdim_input
4232 integer :: ncid, rc, tile
4234 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
4235 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
4242 tilefile = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
4243 print*,
"- READ GRID DIMENSIONS FROM: ", trim(tilefile)
4244 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
4245 call
netcdf_err(error,
'opening: '//trim(tilefile) )
4247 error=nf90_inq_dimid(ncid,
'grid_xt', id_dim)
4248 call
netcdf_err(error,
'reading grid_xt id' )
4249 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
4250 call
netcdf_err(error,
'reading grid_xt value' )
4252 error=nf90_inq_dimid(ncid,
'grid_yt', id_dim)
4253 call
netcdf_err(error,
'reading grid_yt id' )
4254 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
4255 call
netcdf_err(error,
'reading grid_yt value' )
4257 if (idim_input /= i_input .or. jdim_input /= j_input)
then
4258 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 3)
4261 error = nf90_close(ncid)
4263 if (localpet == 0)
then
4264 allocate(data_one_tile(idim_input,jdim_input))
4265 allocate(data_one_tile_3d(idim_input,jdim_input,lsoil_input))
4267 allocate(data_one_tile(0,0))
4268 allocate(data_one_tile_3d(0,0,0))
4271 terrain_loop:
do tile = 1, num_tiles_input_grid
4273 if (trim(input_type) ==
"gaussian_netcdf")
then
4274 if (localpet == 0)
then
4276 lsoil_input, sfcdata=data_one_tile)
4281 if (localpet == 0)
then
4282 tilefile = trim(orog_dir_input_grid) // trim(orog_files_input_grid(tile))
4283 print*,
'- OPEN OROGRAPHY FILE: ', trim(tilefile)
4284 error=nf90_open(tilefile,nf90_nowrite,ncid)
4285 call
netcdf_err(error,
'OPENING OROGRAPHY FILE.' )
4286 error=nf90_inq_varid(ncid,
'orog_raw', id_var)
4287 call
netcdf_err(error,
'READING OROGRAPHY RECORD ID.' )
4288 error=nf90_get_var(ncid, id_var, data_one_tile)
4289 call
netcdf_err(error,
'READING OROGRAPHY RECORD.' )
4290 print*,
'terrain check history ',tile, maxval(data_one_tile)
4291 error=nf90_close(ncid)
4296 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
4297 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4298 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4303 tile_loop :
do tile = 1, num_tiles_input_grid
4307 if (localpet == 0)
then
4309 lsoil_input, sfcdata=data_one_tile)
4310 data_one_tile_3d(:,:,1) = data_one_tile
4312 lsoil_input, sfcdata=data_one_tile)
4313 data_one_tile_3d(:,:,2) = data_one_tile
4315 lsoil_input, sfcdata=data_one_tile)
4316 data_one_tile_3d(:,:,3) = data_one_tile
4318 lsoil_input, sfcdata=data_one_tile)
4319 data_one_tile_3d(:,:,4) = data_one_tile
4322 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
4323 call esmf_fieldscatter(soilm_liq_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4324 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4329 if (localpet == 0)
then
4331 lsoil_input, sfcdata=data_one_tile)
4332 data_one_tile_3d(:,:,1) = data_one_tile
4334 lsoil_input, sfcdata=data_one_tile)
4335 data_one_tile_3d(:,:,2) = data_one_tile
4337 lsoil_input, sfcdata=data_one_tile)
4338 data_one_tile_3d(:,:,3) = data_one_tile
4340 lsoil_input, sfcdata=data_one_tile)
4341 data_one_tile_3d(:,:,4) = data_one_tile
4344 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
4345 call esmf_fieldscatter(soilm_tot_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4346 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4351 if (localpet == 0)
then
4353 lsoil_input, sfcdata=data_one_tile)
4354 data_one_tile_3d(:,:,1) = data_one_tile
4356 lsoil_input, sfcdata=data_one_tile)
4357 data_one_tile_3d(:,:,2) = data_one_tile
4359 lsoil_input, sfcdata=data_one_tile)
4360 data_one_tile_3d(:,:,3) = data_one_tile
4362 lsoil_input, sfcdata=data_one_tile)
4363 data_one_tile_3d(:,:,4) = data_one_tile
4366 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
4367 call esmf_fieldscatter(soil_temp_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
4368 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4373 if (localpet == 0)
then
4375 lsoil_input, sfcdata=data_one_tile)
4378 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
4379 call esmf_fieldscatter(landsea_mask_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4380 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4385 if (localpet == 0)
then
4387 lsoil_input, sfcdata=data_one_tile)
4390 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
4391 call esmf_fieldscatter(seaice_fract_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4392 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4397 if (localpet == 0)
then
4399 lsoil_input, sfcdata=data_one_tile)
4402 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
4403 call esmf_fieldscatter(seaice_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4404 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4409 if (localpet == 0)
then
4411 lsoil_input, sfcdata=data_one_tile)
4414 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
4415 call esmf_fieldscatter(seaice_skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4416 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4421 if (localpet == 0)
then
4423 lsoil_input, sfcdata=data_one_tile)
4426 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
4427 call esmf_fieldscatter(snow_liq_equiv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4428 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4433 if (localpet == 0)
then
4435 lsoil_input, sfcdata=data_one_tile)
4436 data_one_tile = data_one_tile * 1000.0
4439 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
4440 call esmf_fieldscatter(snow_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4441 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4446 if (localpet == 0)
then
4448 lsoil_input, sfcdata=data_one_tile)
4451 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
4452 call esmf_fieldscatter(veg_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4453 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4458 if (localpet == 0)
then
4460 lsoil_input, sfcdata=data_one_tile)
4463 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
4464 call esmf_fieldscatter(soil_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4465 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4470 if (localpet == 0)
then
4472 lsoil_input, sfcdata=data_one_tile)
4475 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
4476 call esmf_fieldscatter(t2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4477 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4482 if (localpet == 0)
then
4484 lsoil_input, sfcdata=data_one_tile)
4487 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
4488 call esmf_fieldscatter(q2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4489 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4492 if (localpet == 0)
then
4494 lsoil_input, sfcdata=data_one_tile)
4497 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
4498 call esmf_fieldscatter(tprcp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4499 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4502 if (localpet == 0)
then
4504 lsoil_input, sfcdata=data_one_tile)
4507 print*,
"- CALL FieldScatter FOR INPUT GRID F10M"
4508 call esmf_fieldscatter(f10m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4509 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4512 if (localpet == 0)
then
4514 lsoil_input, sfcdata=data_one_tile)
4517 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
4518 call esmf_fieldscatter(ffmm_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4519 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4522 if (localpet == 0)
then
4524 lsoil_input, sfcdata=data_one_tile)
4527 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
4528 call esmf_fieldscatter(ustar_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4529 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4532 if (localpet == 0)
then
4538 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
4539 call esmf_fieldscatter(srflag_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4540 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4543 if (localpet == 0)
then
4545 lsoil_input, sfcdata=data_one_tile)
4548 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
4549 call esmf_fieldscatter(skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4550 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4553 if (localpet == 0)
then
4555 lsoil_input, sfcdata=data_one_tile)
4558 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
4559 call esmf_fieldscatter(canopy_mc_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4560 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4563 if (localpet == 0)
then
4565 lsoil_input, sfcdata=data_one_tile)
4568 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
4569 call esmf_fieldscatter(z0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
4570 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4575 deallocate(data_one_tile, data_one_tile_3d)
4586 use program_setup, only : vgtyp_from_climo, sotyp_from_climo
4593 integer,
intent(in) :: localpet
4595 character(len=250) :: the_file
4596 character(len=250) :: geo_file
4597 character(len=20) :: vname, vname_file,slev
4598 character(len=50) :: method
4601 integer :: rc, varnum, iret, i, j,k
4602 integer :: ncid2d, varid, varsize
4605 logical :: exist, rap_latlon
4607 real(esmf_kind_r4) :: value
4609 real(esmf_kind_r4),
allocatable :: dummy2d(:,:),icec_save(:,:)
4610 real(esmf_kind_r4),
allocatable :: dummy1d(:)
4611 real(esmf_kind_r8),
allocatable :: dummy2d_8(:,:),dummy2d_82(:,:),tsk_save(:,:)
4612 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:), dummy3d_stype(:,:,:)
4613 integer(esmf_kind_i4),
allocatable :: slmsk_save(:,:)
4614 integer(esmf_kind_i8),
allocatable :: dummy2d_i(:,:)
4617 rap_latlon = trim(
to_upper(external_model))==
"RAP" .and. trim(input_grid_type) ==
"rotated_latlon"
4619 the_file = trim(data_dir_input_grid) //
"/" // trim(grib2_file_input_grid)
4620 geo_file = trim(geogrid_file_input_grid)
4623 print*,
"- READ SFC DATA FROM GRIB2 FILE: ", trim(the_file)
4624 inquire(file=the_file,exist=exist)
4625 if (.not.exist)
then
4630 lsoil_input = grb2_inq(the_file, inv_file,
':TSOIL:',
' below ground:')
4631 print*,
"- FILE HAS ", lsoil_input,
" SOIL LEVELS"
4632 if (lsoil_input <= 0) call
error_handler(
"COUNTING SOIL LEVELS.", rc)
4635 if (lsoil_input /= 4)
then
4637 call esmf_fielddestroy(soil_temp_input_grid, rc=rc)
4638 call esmf_fielddestroy(soilm_tot_input_grid, rc=rc)
4639 call esmf_fielddestroy(soilm_liq_input_grid, rc=rc)
4641 print*,
"- CALL FieldCreate FOR INPUT SOIL TEMPERATURE."
4642 soil_temp_input_grid = esmf_fieldcreate(input_grid, &
4643 typekind=esmf_typekind_r8, &
4644 staggerloc=esmf_staggerloc_center, &
4645 ungriddedlbound=(/1/), &
4646 ungriddedubound=(/lsoil_input/), rc=rc)
4647 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4650 print*,
"- CALL FieldCreate FOR INPUT TOTAL SOIL MOISTURE."
4651 soilm_tot_input_grid = esmf_fieldcreate(input_grid, &
4652 typekind=esmf_typekind_r8, &
4653 staggerloc=esmf_staggerloc_center, &
4654 ungriddedlbound=(/1/), &
4655 ungriddedubound=(/lsoil_input/), rc=rc)
4656 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4659 print*,
"- CALL FieldCreate FOR INPUT LIQUID SOIL MOISTURE."
4660 soilm_liq_input_grid = esmf_fieldcreate(input_grid, &
4661 typekind=esmf_typekind_r8, &
4662 staggerloc=esmf_staggerloc_center, &
4663 ungriddedlbound=(/1/), &
4664 ungriddedubound=(/lsoil_input/), rc=rc)
4665 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
4670 if (localpet == 0)
then
4671 allocate(dummy2d(i_input,j_input))
4672 allocate(slmsk_save(i_input,j_input))
4673 allocate(dummy2d_i(i_input,j_input))
4674 allocate(tsk_save(i_input,j_input))
4675 allocate(icec_save(i_input,j_input))
4676 allocate(dummy2d_8(i_input,j_input))
4677 allocate(dummy2d_82(i_input,j_input))
4678 allocate(dummy3d(i_input,j_input,lsoil_input))
4679 allocate(dummy3d_stype(i_input,j_input,16))
4680 allocate(dummy1d(16))
4682 allocate(dummy3d(0,0,0))
4683 allocate(dummy2d_8(0,0))
4684 allocate(dummy2d_82(0,0))
4685 allocate(dummy2d(0,0))
4694 if (localpet == 0)
then
4695 print*,
"- READ TERRAIN."
4696 rc = grb2_inq(the_file, inv_file,
':HGT:',
':surface:', data2=dummy2d)
4698 print*,
'orog ',maxval(dummy2d),minval(dummy2d)
4701 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
4702 call esmf_fieldscatter(terrain_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4703 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4706 if (localpet == 0)
then
4707 print*,
"- READ SEAICE FRACTION."
4708 rc = grb2_inq(the_file, inv_file,
':ICEC:',
':surface:', data2=dummy2d)
4709 if (rc /= 1) call
error_handler(
"READING SEAICE FRACTION.", rc)
4711 print*,
'icec ',maxval(dummy2d),minval(dummy2d)
4715 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
4716 call esmf_fieldscatter(seaice_fract_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4717 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4728 if (localpet == 0)
then
4729 print*,
"- READ LANDSEA MASK."
4730 rc = grb2_inq(the_file, inv_file,
':LANDN:',
':surface:', data2=dummy2d)
4733 rc = grb2_inq(the_file, inv_file,
':LAND:',
':surface:', data2=dummy2d)
4734 if (rc /= 1) call
error_handler(
"READING LANDSEA MASK.", rc)
4739 if(dummy2d(i,j) < 0.5_esmf_kind_r4) dummy2d(i,j)=0.0_esmf_kind_r4
4740 if(icec_save(i,j) > 0.15_esmf_kind_r4)
then
4742 dummy2d(i,j) = 2.0_esmf_kind_r4
4747 slmsk_save = nint(dummy2d)
4749 deallocate(icec_save)
4752 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
4753 call esmf_fieldscatter(landsea_mask_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4754 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4757 if (localpet == 0)
then
4758 print*,
"- READ SEAICE SKIN TEMPERATURE."
4759 rc = grb2_inq(the_file, inv_file,
':TMP:',
':surface:', data2=dummy2d)
4760 if (rc /= 1) call
error_handler(
"READING SEAICE SKIN TEMP.", rc)
4761 print*,
'ti ',maxval(dummy2d),minval(dummy2d)
4764 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
4765 call esmf_fieldscatter(seaice_skin_temp_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4766 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4775 if (localpet == 0)
then
4776 print*,
"- READ SNOW LIQUID EQUIVALENT."
4777 rc = grb2_inq(the_file, inv_file,
':WEASD:',
':surface:',
':anl:',data2=dummy2d)
4779 rc = grb2_inq(the_file, inv_file,
':WEASD:',
':surface:',
'hour fcst:',data2=dummy2d)
4780 if (rc /= 1) call
error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
4784 if(slmsk_save(i,j) == 0) dummy2d(i,j) = 0.0_esmf_kind_r4
4785 if(dummy2d(i,j) == grb2_undefined) dummy2d(i,j) = 0.0_esmf_kind_r4
4788 print*,
'weasd ',maxval(dummy2d),minval(dummy2d)
4791 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
4792 call esmf_fieldscatter(snow_liq_equiv_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4793 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4796 if (localpet == 0)
then
4797 print*,
"- READ SNOW DEPTH."
4798 rc = grb2_inq(the_file, inv_file,
':SNOD:',
':surface:', data2=dummy2d)
4800 where(dummy2d == grb2_undefined) dummy2d = 0.0_esmf_kind_r4
4801 dummy2d = dummy2d*1000.0
4802 where(slmsk_save == 0) dummy2d = 0.0_esmf_kind_r4
4803 print*,
'snod ',maxval(dummy2d),minval(dummy2d)
4806 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
4807 call esmf_fieldscatter(snow_depth_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4808 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4811 if (localpet == 0)
then
4812 print*,
"- READ T2M."
4813 rc = grb2_inq(the_file, inv_file,
':TMP:',
':2 m above ground:',data2=dummy2d)
4816 print*,
't2m ',maxval(dummy2d),minval(dummy2d)
4819 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
4820 call esmf_fieldscatter(t2m_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0,rc=rc)
4821 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4824 if (localpet == 0)
then
4825 print*,
"- READ Q2M."
4826 rc = grb2_inq(the_file, inv_file,
':SPFH:',
':2 m above ground:',data2=dummy2d)
4828 print*,
'q2m ',maxval(dummy2d),minval(dummy2d)
4831 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
4832 call esmf_fieldscatter(q2m_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0,rc=rc)
4833 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4836 if (localpet == 0)
then
4837 print*,
"- READ SKIN TEMPERATURE."
4838 rc = grb2_inq(the_file, inv_file,
':TMP:',
':surface:', data2=dummy2d)
4839 if (rc <= 0 ) call
error_handler(
"READING SKIN TEMPERATURE.", rc)
4840 tsk_save(:,:) =
real(dummy2d,esmf_kind_r8)
4841 dummy2d_8 =
real(dummy2d,esmf_kind_r8)
4844 if(slmsk_save(i,j) == 0 .and. dummy2d(i,j) < 271.2)
then
4846 dummy2d(i,j) = 271.2
4848 if(slmsk_save(i,j) == 0 .and. dummy2d(i,j) > 310.)
then
4850 dummy2d(i,j) = 310.0
4856 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
4857 call esmf_fieldscatter(skin_temp_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
4858 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4861 if (localpet == 0) dummy2d = 0.0
4863 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
4864 call esmf_fieldscatter(srflag_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0,rc=rc)
4865 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4868 if (localpet == 0)
then
4869 print*,
"- READ SOIL TYPE."
4872 rc = grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
4874 if (rc <= 0 .and. (trim(
to_upper(external_model))==
"HRRR" .or. rap_latlon) .and. geo_file .ne.
"NULL")
then
4878 print*,
"OPEN GEOGRID FILE ", trim(geo_file)
4879 rc = nf90_open(geo_file,nf90_nowrite,ncid2d)
4882 print*,
"INQURE ABOUT DIM IDS"
4883 rc = nf90_inq_dimid(ncid2d,
"west_east",varid)
4884 call
netcdf_err(rc,
"READING west_east DIMENSION FROM GEOGRID FILE")
4886 rc = nf90_inquire_dimension(ncid2d,varid,len=varsize)
4887 call
netcdf_err(rc,
"READING west_east DIMENSION SIZE")
4888 if (varsize .ne. i_input) call
error_handler(
"GEOGRID FILE GRID SIZE DIFFERS FROM INPUT DATA.", -1)
4890 print*,
"INQUIRE ABOUT SOIL TYPE FROM GEOGRID FILE"
4891 rc = nf90_inq_varid(ncid2d,
"SCT_DOM",varid)
4892 call
netcdf_err(rc,
"FINDING SCT_DOM IN GEOGRID FILE")
4894 print*,
"READ SOIL TYPE FROM GEOGRID FILE "
4895 rc = nf90_get_var(ncid2d,varid,dummy2d)
4896 call
netcdf_err(rc,
"READING SCT_DOM FROM FILE")
4898 print*,
"INQUIRE ABOUT SOIL TYPE FRACTIONS FROM GEOGRID FILE"
4899 rc = nf90_inq_varid(ncid2d,
"SOILCTOP",varid)
4900 call
netcdf_err(rc,
"FINDING SOILCTOP IN GEOGRID FILE")
4902 print*,
"READ SOIL TYPE FRACTIONS FROM GEOGRID FILE "
4903 rc = nf90_get_var(ncid2d,varid,dummy3d_stype)
4904 call
netcdf_err(rc,
"READING SCT_DOM FROM FILE")
4906 print*,
"CLOSE GEOGRID FILE "
4907 iret = nf90_close(ncid2d)
4915 if(dummy2d(i,j) == 14.0_esmf_kind_r4 .and. slmsk_save(i,j) == 1)
then
4916 dummy1d(:) = dummy3d_stype(i,j,:)
4917 dummy1d(14) = 0.0_esmf_kind_r4
4918 dummy2d(i,j) =
real(MAXLOC(dummy1d, 1),esmf_kind_r4)
4924 if ((rc <= 0 .and. trim(
to_upper(external_model)) /=
"HRRR" .and. .not. rap_latlon) &
4925 .or. (rc < 0 .and. (trim(
to_upper(external_model)) ==
"HRRR" .or. rap_latlon)))
then
4926 if (.not. sotyp_from_climo)
then
4927 call
error_handler(
"COULD NOT FIND SOIL TYPE IN FILE. PLEASE SET SOTYP_FROM_CLIMO=.TRUE. . EXITING", rc)
4930 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
4934 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. WILL NOT "//&
4935 "SCALE SOIL MOISTURE FOR DIFFERENCES IN SOIL TYPE. "
4936 dummy2d(:,:) = -99999.0_esmf_kind_r4
4944 if (.not. sotyp_from_climo)
then
4947 if(dummy2d(i,j) == 14.0_esmf_kind_r4 .and. slmsk_save(i,j) == 1) dummy2d(i,j) = -99999.9
4951 dummy2d_8 =
real(dummy2d,esmf_kind_r8)
4953 where(slmsk_save == 1) dummy2d_i = 1
4955 call
search(dummy2d_8,dummy2d_i,i_input,j_input,1,230)
4957 dummy2d_8=
real(dummy2d,esmf_kind_r8)
4960 print*,
'sotype ',maxval(dummy2d_8),minval(dummy2d_8)
4961 deallocate(dummy2d_i)
4962 deallocate(dummy3d_stype)
4966 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
4967 call esmf_fieldscatter(soil_type_input_grid,dummy2d_8, rootpet=0, rc=rc)
4968 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
4976 if (.not. vgfrc_from_climo)
then
4977 if (localpet == 0)
then
4978 print*,
"- READ VEG FRACTION."
4981 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
4985 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
4988 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1105:', data2=dummy2d)
4990 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1101:', data2=dummy2d)
4992 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1151:', data2=dummy2d)
4993 if (rc <= 0) call
error_handler(
"COULD NOT DETERMINE VEGETATION FRACTION IN FILE. &
4994 RECORD NUMBERS MAY HAVE CHANGED. PLEASE SET VGFRC_FROM_CLIMO=.TRUE. EXITING", rc)
4997 elseif (rc <= 0)
then
4998 call
error_handler(
"COULD NOT FIND VEGETATION FRACTION IN FILE. &
4999 PLEASE SET VGFRC_FROM_CLIMO=.TRUE. EXITING", rc)
5001 if(maxval(dummy2d) > 2.0) dummy2d = dummy2d / 100.0_esmf_kind_r4
5002 print*,
'vfrac ',maxval(dummy2d),minval(dummy2d)
5006 print*,
"- CALL FieldScatter FOR INPUT GRID VEG GREENNESS."
5007 call esmf_fieldscatter(veg_greenness_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0, rc=rc)
5008 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5012 if (.not. minmax_vgfrc_from_climo)
then
5013 if (localpet == 0)
then
5014 print*,
"- READ MIN VEG FRACTION."
5017 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5020 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1106:',data2=dummy2d)
5023 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1102:',data2=dummy2d)
5025 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1152:',data2=dummy2d)
5026 if (rc<=0) call
error_handler(
"COULD NOT FIND MIN VEGETATION FRACTION IN FILE. &
5027 PLEASE SET MINMAX_VGFRC_FROM_CLIMO=.TRUE. . EXITING",rc)
5030 if(maxval(dummy2d) > 2.0) dummy2d = dummy2d / 100.0_esmf_kind_r4
5031 print*,
'vfrac min',maxval(dummy2d),minval(dummy2d)
5035 print*,
"- CALL FieldScatter FOR INPUT GRID MIN VEG GREENNESS."
5036 call esmf_fieldscatter(min_veg_greenness_input_grid,
real(dummy2d,esmf_kind_r8), rootpet=0, rc=rc)
5037 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5040 if (localpet == 0)
then
5041 print*,
"- READ MAX VEG FRACTION."
5044 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5048 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1107:',data2=dummy2d)
5050 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1103:',data2=dummy2d)
5052 rc= grb2_inq(the_file, inv_file, vname,slev,
'n=1153:',data2=dummy2d)
5053 if (rc <= 0) call
error_handler(
"COULD NOT FIND MAX VEGETATION FRACTION IN FILE. &
5054 PLEASE SET MINMAX_VGFRC_FROM_CLIMO=.TRUE. . EXITING",rc)
5057 if(maxval(dummy2d) > 2.0) dummy2d = dummy2d / 100.0_esmf_kind_r4
5058 print*,
'vfrac max',maxval(dummy2d),minval(dummy2d)
5062 print*,
"- CALL FieldScatter FOR INPUT GRID MAX VEG GREENNESS."
5063 call esmf_fieldscatter(max_veg_greenness_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
5064 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5068 if (.not. lai_from_climo)
then
5069 if (localpet == 0)
then
5070 print*,
"- READ LAI."
5073 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5075 vname=
":var0_7_198:"
5076 rc= grb2_inq(the_file, inv_file, vname,slev,
':n=1108:',data2=dummy2d)
5078 rc= grb2_inq(the_file, inv_file, vname,slev,
':n=1104:',data2=dummy2d)
5080 rc= grb2_inq(the_file, inv_file, vname,slev,
':n=1154:',data2=dummy2d)
5081 if (rc <= 0) call
error_handler(
"COULD NOT FIND LAI IN FILE. &
5082 PLEASE SET LAI_FROM_CLIMO=.TRUE. . EXITING",rc)
5085 print*,
'lai',maxval(dummy2d),minval(dummy2d)
5088 print*,
"- CALL FieldScatter FOR INPUT GRID LAI."
5089 call esmf_fieldscatter(lai_input_grid,
real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
5090 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5094 if (localpet == 0)
then
5095 print*,
"- READ SEAICE DEPTH."
5098 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5101 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5105 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL BE"//&
5106 " REPLACED WITH CLIMO. SET A FILL "// &
5107 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5108 dummy2d(:,:) = 0.0_esmf_kind_r4
5111 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5112 print*,
'hice ',maxval(dummy2d),minval(dummy2d)
5116 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
5117 call esmf_fieldscatter(seaice_depth_input_grid,dummy2d_8, rootpet=0, rc=rc)
5118 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5121 if (localpet == 0)
then
5122 print*,
"- READ TPRCP."
5125 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5128 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5132 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
5133 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
5134 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5135 dummy2d(:,:) = 0.0_esmf_kind_r4
5138 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5139 print*,
'tprcp ',maxval(dummy2d),minval(dummy2d)
5142 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
5143 call esmf_fieldscatter(tprcp_input_grid,dummy2d_8, rootpet=0, rc=rc)
5144 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5147 if (localpet == 0)
then
5148 print*,
"- READ FFMM."
5151 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5154 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5158 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
5159 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
5160 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5161 dummy2d(:,:) = 0.0_esmf_kind_r4
5164 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5165 print*,
'ffmm ',maxval(dummy2d),minval(dummy2d)
5168 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
5169 call esmf_fieldscatter(ffmm_input_grid,dummy2d_8, rootpet=0, rc=rc)
5170 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5173 if (localpet == 0)
then
5174 print*,
"- READ USTAR."
5177 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5180 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5184 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL "//&
5185 "REPLACED WITH CLIMO. SET A FILL "// &
5186 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5187 dummy2d(:,:) = 0.0_esmf_kind_r4
5190 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5191 print*,
'fricv ',maxval(dummy2d),minval(dummy2d)
5194 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
5195 call esmf_fieldscatter(ustar_input_grid,dummy2d_8, rootpet=0, rc=rc)
5196 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5199 if (localpet == 0)
then
5200 print*,
"- READ F10M."
5202 slev=
":10 m above ground:"
5203 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5206 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5210 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
5211 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
5212 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5213 dummy2d(:,:) = 0.0_esmf_kind_r4
5216 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5217 print*,
'f10m ',maxval(dummy2d),minval(dummy2d)
5220 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
5221 call esmf_fieldscatter(f10m_input_grid,dummy2d_8, rootpet=0, rc=rc)
5222 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5225 if (localpet == 0)
then
5226 print*,
"- READ CANOPY MOISTURE CONTENT."
5229 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5232 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5236 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL"//&
5237 " REPLACED WITH CLIMO. SET A FILL "// &
5238 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5239 dummy2d(:,:) = 0.0_esmf_kind_r4
5242 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5243 print*,
'cnwat ',maxval(dummy2d),minval(dummy2d)
5246 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
5247 call esmf_fieldscatter(canopy_mc_input_grid,dummy2d_8, rootpet=0, rc=rc)
5248 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5251 if (localpet == 0)
then
5255 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
5258 rc= grb2_inq(the_file, inv_file, vname,slev, data2=dummy2d)
5262 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL BE"//&
5263 " REPLACED WITH CLIMO. SET A FILL "// &
5264 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
5265 dummy2d(:,:) = 0.0_esmf_kind_r4
5269 dummy2d(:,:) = dummy2d(:,:)*10.0
5271 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5272 print*,
'sfcr ',maxval(dummy2d),minval(dummy2d)
5276 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
5277 call esmf_fieldscatter(z0_input_grid,dummy2d_8, rootpet=0, rc=rc)
5278 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5282 if (localpet == 0)
then
5283 print*,
"- READ LIQUID SOIL MOISTURE."
5285 vname_file =
":SOILL:"
5286 call
read_grib_soil(the_file,inv_file,vname,vname_file,dummy3d,rc)
5288 print*,
'soill ',maxval(dummy3d),minval(dummy3d)
5291 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
5292 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
5293 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5296 if (localpet == 0)
then
5297 print*,
"- READ TOTAL SOIL MOISTURE."
5300 vname_file =
"var2_2_1_"
5301 call
read_grib_soil(the_file,inv_file,vname,vname_file,dummy3d,rc)
5302 print*,
'soilm ',maxval(dummy3d),minval(dummy3d)
5305 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
5306 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
5307 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5316 print*,
"- CALL FieldGather for INPUT SOIL TYPE."
5317 call esmf_fieldgather(soil_type_input_grid, dummy2d_82, rootpet=0, tile=1, rc=rc)
5318 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5320 if (localpet == 0)
then
5321 print*,
"- READ VEG TYPE."
5324 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
5330 rc= grb2_inq(the_file, inv_file, vname,
"_0_198:",slev,
' hour fcst:', data2=dummy2d)
5332 rc= grb2_inq(the_file, inv_file, vname,
"_0_198:",slev,
':anl:', data2=dummy2d)
5334 if (.not. vgtyp_from_climo)
then
5335 call
error_handler(
"COULD NOT FIND VEGETATION TYPE IN FILE. PLEASE SET VGTYP_FROM_CLIMO=.TRUE. . EXITING", rc)
5339 dummy2d(i,j) = 0.0_esmf_kind_r4
5340 if(slmsk_save(i,j) == 1 .and. dummy3d(i,j,1) > 0.99) &
5341 dummy2d(i,j) =
real(veg_type_landice_input,esmf_kind_r4)
5348 if (trim(external_model) .ne.
"GFS")
then
5351 if (dummy2d(i,j) == 15.0_esmf_kind_r4 .and. slmsk_save(i,j) == 1)
then
5352 if (dummy3d(i,j,1) < 0.6)
then
5353 dummy2d(i,j) =
real(veg_type_landice_input,esmf_kind_r4)
5354 elseif (dummy3d(i,j,1) > 0.99)
then
5356 dummy2d(i,j) = 0.0_esmf_kind_r4
5357 dummy2d_82(i,j) = 0.0_esmf_kind_r8
5359 elseif (dummy2d(i,j) == 17.0_esmf_kind_r4 .and. slmsk_save(i,j)==0)
then
5360 dummy2d(i,j) = 0.0_esmf_kind_r4
5365 dummy2d_8=
real(dummy2d,esmf_kind_r8)
5366 print*,
'vgtyp ',maxval(dummy2d),minval(dummy2d)
5369 print*,
"- CALL FieldScatter FOR INPUT VEG TYPE."
5370 call esmf_fieldscatter(veg_type_input_grid, dummy2d_8, rootpet=0, rc=rc)
5371 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5374 print*,
"- CALL FieldScatter FOR INPUT VEG TYPE."
5375 call esmf_fieldscatter(soil_type_input_grid, dummy2d_82, rootpet=0, rc=rc)
5376 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5379 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
5380 call esmf_fieldscatter(landsea_mask_input_grid,
real(slmsk_save,esmf_kind_r8),rootpet=0, rc=rc)
5381 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5391 if (localpet == 0)
then
5392 print*,
"- READ SOIL TEMPERATURE."
5394 vname_file =
":TSOIL:"
5395 call
read_grib_soil(the_file,inv_file,vname,vname_file,dummy3d,rc)
5397 print*,
'soilt ',maxval(dummy3d),minval(dummy3d)
5399 deallocate(tsk_save, slmsk_save)
5402 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
5403 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
5404 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
5408 deallocate(dummy2d_8)
5421 integer,
intent(in) :: localpet
5423 character(len=10) :: field
5427 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
5429 if (localpet == 0)
then
5430 allocate(data_one_tile(i_input,j_input))
5432 allocate(data_one_tile(0,0))
5435 tile_loop :
do tile = 1, num_tiles_input_grid
5439 if (localpet == 0)
then
5440 if (trim(input_type) ==
"restart")
then
5446 lsoil_input, sfcdata=data_one_tile)
5449 print*,
"- CALL FieldScatter FOR INPUT C_D"
5450 call esmf_fieldscatter(c_d_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5451 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5456 if (localpet == 0)
then
5457 if (trim(input_type) ==
"restart")
then
5463 lsoil_input, sfcdata=data_one_tile)
5466 print*,
"- CALL FieldScatter FOR INPUT C_0"
5467 call esmf_fieldscatter(c_0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5468 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5473 if (localpet == 0)
then
5474 if (trim(input_type) ==
"restart")
then
5480 lsoil_input, sfcdata=data_one_tile)
5483 print*,
"- CALL FieldScatter FOR INPUT D_CONV."
5484 call esmf_fieldscatter(d_conv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5485 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5490 if (localpet == 0)
then
5491 if (trim(input_type) ==
"restart")
then
5497 lsoil_input, sfcdata=data_one_tile)
5500 print*,
"- CALL FieldScatter FOR INPUT DT_COOL."
5501 call esmf_fieldscatter(dt_cool_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5502 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5507 if (localpet == 0)
then
5511 print*,
"- CALL FieldScatter FOR INPUT IFD."
5512 call esmf_fieldscatter(ifd_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5513 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5518 if (localpet == 0)
then
5520 lsoil_input, sfcdata=data_one_tile)
5523 print*,
"- CALL FieldScatter FOR INPUT QRAIN."
5524 call esmf_fieldscatter(qrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5525 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5530 if (localpet == 0)
then
5532 lsoil_input, sfcdata=data_one_tile)
5535 print*,
"- CALL FieldScatter FOR INPUT TREF"
5536 call esmf_fieldscatter(tref_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5537 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5542 if (localpet == 0)
then
5543 if (trim(input_type) ==
"restart")
then
5549 lsoil_input, sfcdata=data_one_tile)
5552 print*,
"- CALL FieldScatter FOR INPUT W_D"
5553 call esmf_fieldscatter(w_d_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5554 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5559 if (localpet == 0)
then
5560 if (trim(input_type) ==
"restart")
then
5566 lsoil_input, sfcdata=data_one_tile)
5569 print*,
"- CALL FieldScatter FOR INPUT W_0"
5570 call esmf_fieldscatter(w_0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5571 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5576 if (localpet == 0)
then
5578 lsoil_input, sfcdata=data_one_tile)
5581 print*,
"- CALL FieldScatter FOR INPUT XS"
5582 call esmf_fieldscatter(xs_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5583 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5588 if (localpet == 0)
then
5590 lsoil_input, sfcdata=data_one_tile)
5593 print*,
"- CALL FieldScatter FOR INPUT XT"
5594 call esmf_fieldscatter(xt_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5595 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5600 if (localpet == 0)
then
5602 lsoil_input, sfcdata=data_one_tile)
5605 print*,
"- CALL FieldScatter FOR INPUT XU"
5606 call esmf_fieldscatter(xu_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5607 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5612 if (localpet == 0)
then
5614 lsoil_input, sfcdata=data_one_tile)
5617 print*,
"- CALL FieldScatter FOR INPUT XV"
5618 call esmf_fieldscatter(xv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5619 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5624 if (localpet == 0)
then
5626 lsoil_input, sfcdata=data_one_tile)
5629 print*,
"- CALL FieldScatter FOR INPUT XZ"
5630 call esmf_fieldscatter(xz_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5631 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5636 if (localpet == 0)
then
5638 lsoil_input, sfcdata=data_one_tile)
5641 print*,
"- CALL FieldScatter FOR INPUT XTTS"
5642 call esmf_fieldscatter(xtts_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5643 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5648 if (localpet == 0)
then
5650 lsoil_input, sfcdata=data_one_tile)
5653 print*,
"- CALL FieldScatter FOR INPUT XZTS"
5654 call esmf_fieldscatter(xzts_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5655 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5660 if (localpet == 0)
then
5661 if (trim(input_type) ==
"restart")
then
5667 lsoil_input, sfcdata=data_one_tile)
5670 print*,
"- CALL FieldScatter FOR INPUT Z_C"
5671 call esmf_fieldscatter(z_c_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5672 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5677 if (localpet == 0)
then
5681 print*,
"- CALL FieldScatter FOR INPUT ZM"
5682 call esmf_fieldscatter(zm_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
5683 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5688 deallocate(data_one_tile)
5705 integer,
intent(in) :: localpet
5707 character(len=300) :: the_file
5711 real(nemsio_realkind),
allocatable :: dummy(:)
5712 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
5714 type(nemsio_gfile
) :: gfile
5716 if (trim(input_type) ==
"gfs_gaussian_nemsio")
then
5718 the_file = trim(data_dir_input_grid) //
"/" // trim(nst_files_input_grid)
5720 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
5723 print*,
"- READ NST DATA FROM: ", trim(the_file)
5725 if (localpet == 0)
then
5726 allocate(dummy(i_input*j_input))
5727 allocate(dummy2d(i_input,j_input))
5728 call nemsio_open(gfile, the_file,
"read", iret=rc)
5731 allocate(dummy2d(0,0))
5734 if (localpet == 0)
then
5735 print*,
"- READ TREF"
5736 call nemsio_readrecv(gfile,
"tref",
"sfc", 1, dummy, 0, iret=rc)
5738 dummy2d = reshape(dummy, (/i_input,j_input/))
5739 print*,
'tref ',maxval(dummy2d),minval(dummy2d)
5742 print*,
"- CALL FieldScatter FOR INPUT TREF."
5743 call esmf_fieldscatter(tref_input_grid, dummy2d, rootpet=0, rc=rc)
5744 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5747 if (localpet == 0)
then
5749 call nemsio_readrecv(gfile,
"cd",
"sfc", 1, dummy, 0, iret=rc)
5751 dummy2d = reshape(dummy, (/i_input,j_input/))
5752 print*,
'cd ',maxval(dummy2d),minval(dummy2d)
5755 print*,
"- CALL FieldScatter FOR INPUT C_D."
5756 call esmf_fieldscatter(c_d_input_grid, dummy2d, rootpet=0, rc=rc)
5757 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5760 if (localpet == 0)
then
5762 call nemsio_readrecv(gfile,
"c0",
"sfc", 1, dummy, 0, iret=rc)
5764 dummy2d = reshape(dummy, (/i_input,j_input/))
5765 print*,
'c0 ',maxval(dummy2d),minval(dummy2d)
5768 print*,
"- CALL FieldScatter FOR INPUT C_0."
5769 call esmf_fieldscatter(c_0_input_grid, dummy2d, rootpet=0, rc=rc)
5770 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5773 if (localpet == 0)
then
5774 print*,
"- READ DCONV"
5775 call nemsio_readrecv(gfile,
"dconv",
"sfc", 1, dummy, 0, iret=rc)
5777 dummy2d = reshape(dummy, (/i_input,j_input/))
5778 print*,
'dconv ',maxval(dummy2d),minval(dummy2d)
5781 print*,
"- CALL FieldScatter FOR INPUT D_CONV."
5782 call esmf_fieldscatter(d_conv_input_grid, dummy2d, rootpet=0, rc=rc)
5783 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5786 if (localpet == 0)
then
5787 print*,
"- READ DTCOOL"
5788 call nemsio_readrecv(gfile,
"dtcool",
"sfc", 1, dummy, 0, iret=rc)
5790 dummy2d = reshape(dummy, (/i_input,j_input/))
5791 print*,
'dtcool ',maxval(dummy2d),minval(dummy2d)
5794 print*,
"- CALL FieldScatter FOR INPUT DT_COOL."
5795 call esmf_fieldscatter(dt_cool_input_grid, dummy2d, rootpet=0, rc=rc)
5796 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5799 if (localpet == 0)
then
5803 print*,
"- CALL FieldScatter FOR INPUT IFD."
5804 call esmf_fieldscatter(ifd_input_grid, dummy2d, rootpet=0, rc=rc)
5805 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5808 if (localpet == 0)
then
5809 print*,
"- READ QRAIN"
5810 call nemsio_readrecv(gfile,
"qrain",
"sfc", 1, dummy, 0, iret=rc)
5812 dummy2d = reshape(dummy, (/i_input,j_input/))
5813 print*,
'qrain ',maxval(dummy2d),minval(dummy2d)
5816 print*,
"- CALL FieldScatter FOR INPUT QRAIN."
5817 call esmf_fieldscatter(qrain_input_grid, dummy2d, rootpet=0, rc=rc)
5818 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5821 if (localpet == 0)
then
5823 call nemsio_readrecv(gfile,
"wd",
"sfc", 1, dummy, 0, iret=rc)
5825 dummy2d = reshape(dummy, (/i_input,j_input/))
5826 print*,
'wd ',maxval(dummy2d),minval(dummy2d)
5829 print*,
"- CALL FieldScatter FOR INPUT WD."
5830 call esmf_fieldscatter(w_d_input_grid, dummy2d, rootpet=0, rc=rc)
5831 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5834 if (localpet == 0)
then
5836 call nemsio_readrecv(gfile,
"w0",
"sfc", 1, dummy, 0, iret=rc)
5838 dummy2d = reshape(dummy, (/i_input,j_input/))
5839 print*,
'w0 ',maxval(dummy2d),minval(dummy2d)
5842 print*,
"- CALL FieldScatter FOR INPUT W0."
5843 call esmf_fieldscatter(w_0_input_grid, dummy2d, rootpet=0, rc=rc)
5844 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5847 if (localpet == 0)
then
5849 call nemsio_readrecv(gfile,
"xs",
"sfc", 1, dummy, 0, iret=rc)
5851 dummy2d = reshape(dummy, (/i_input,j_input/))
5852 print*,
'xs ',maxval(dummy2d),minval(dummy2d)
5855 print*,
"- CALL FieldScatter FOR INPUT XS."
5856 call esmf_fieldscatter(xs_input_grid, dummy2d, rootpet=0, rc=rc)
5857 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5860 if (localpet == 0)
then
5862 call nemsio_readrecv(gfile,
"xt",
"sfc", 1, dummy, 0, iret=rc)
5864 dummy2d = reshape(dummy, (/i_input,j_input/))
5865 print*,
'xt ',maxval(dummy2d),minval(dummy2d)
5868 print*,
"- CALL FieldScatter FOR INPUT XT."
5869 call esmf_fieldscatter(xt_input_grid, dummy2d, rootpet=0, rc=rc)
5870 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5873 if (localpet == 0)
then
5875 call nemsio_readrecv(gfile,
"xu",
"sfc", 1, dummy, 0, iret=rc)
5877 dummy2d = reshape(dummy, (/i_input,j_input/))
5878 print*,
'xu ',maxval(dummy2d),minval(dummy2d)
5881 print*,
"- CALL FieldScatter FOR INPUT XU."
5882 call esmf_fieldscatter(xu_input_grid, dummy2d, rootpet=0, rc=rc)
5883 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5886 if (localpet == 0)
then
5888 call nemsio_readrecv(gfile,
"xv",
"sfc", 1, dummy, 0, iret=rc)
5890 dummy2d = reshape(dummy, (/i_input,j_input/))
5891 print*,
'xv ',maxval(dummy2d),minval(dummy2d)
5894 print*,
"- CALL FieldScatter FOR INPUT XV."
5895 call esmf_fieldscatter(xv_input_grid, dummy2d, rootpet=0, rc=rc)
5896 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5899 if (localpet == 0)
then
5901 call nemsio_readrecv(gfile,
"xz",
"sfc", 1, dummy, 0, iret=rc)
5903 dummy2d = reshape(dummy, (/i_input,j_input/))
5904 print*,
'xz ',maxval(dummy2d),minval(dummy2d)
5907 print*,
"- CALL FieldScatter FOR INPUT XZ."
5908 call esmf_fieldscatter(xz_input_grid, dummy2d, rootpet=0, rc=rc)
5909 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5912 if (localpet == 0)
then
5913 print*,
"- READ XTTS"
5914 call nemsio_readrecv(gfile,
"xtts",
"sfc", 1, dummy, 0, iret=rc)
5916 dummy2d = reshape(dummy, (/i_input,j_input/))
5917 print*,
'xtts ',maxval(dummy2d),minval(dummy2d)
5920 print*,
"- CALL FieldScatter FOR INPUT XTTS."
5921 call esmf_fieldscatter(xtts_input_grid, dummy2d, rootpet=0, rc=rc)
5922 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5925 if (localpet == 0)
then
5926 print*,
"- READ XZTS"
5927 call nemsio_readrecv(gfile,
"xzts",
"sfc", 1, dummy, 0, iret=rc)
5929 dummy2d = reshape(dummy, (/i_input,j_input/))
5930 print*,
'xzts ',maxval(dummy2d),minval(dummy2d)
5933 print*,
"- CALL FieldScatter FOR INPUT XZTS."
5934 call esmf_fieldscatter(xzts_input_grid, dummy2d, rootpet=0, rc=rc)
5935 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5938 if (localpet == 0)
then
5940 call nemsio_readrecv(gfile,
"zc",
"sfc", 1, dummy, 0, iret=rc)
5942 dummy2d = reshape(dummy, (/i_input,j_input/))
5943 print*,
'zc ',maxval(dummy2d),minval(dummy2d)
5946 print*,
"- CALL FieldScatter FOR INPUT Z_C."
5947 call esmf_fieldscatter(z_c_input_grid, dummy2d, rootpet=0, rc=rc)
5948 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5951 if (localpet == 0)
then
5955 print*,
"- CALL FieldScatter FOR INPUT ZM."
5956 call esmf_fieldscatter(zm_input_grid, dummy2d, rootpet=0, rc=rc)
5957 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
5960 deallocate(dummy, dummy2d)
5962 if (localpet == 0) call nemsio_close(gfile)
5977 sfcdata, sfcdata_3d)
5981 CHARACTER(LEN=*),
INTENT(IN) :: field
5983 INTEGER,
INTENT(IN) :: imo, jmo, lmo, tile_num
5985 REAL(ESMF_KIND_R8),
INTENT(OUT),
OPTIONAL :: sfcdata(imo,jmo)
5986 REAL(ESMF_KIND_R8),
INTENT(OUT),
OPTIONAL :: sfcdata_3d(imo,jmo,lmo)
5988 CHARACTER(LEN=256) :: tilefile
5990 INTEGER :: error, ncid, id_var
5992 tilefile = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(tile_num))
5994 print*,
'WILL READ ',trim(field),
' FROM: ', trim(tilefile)
5996 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
5997 CALL
netcdf_err(error,
'OPENING: '//trim(tilefile) )
5999 error=nf90_inq_varid(ncid, field, id_var)
6002 IF (present(sfcdata_3d))
THEN
6003 error=nf90_get_var(ncid, id_var, sfcdata_3d)
6006 error=nf90_get_var(ncid, id_var, sfcdata)
6010 error = nf90_close(ncid)
6031 character(len=250),
intent(in) :: file
6032 character(len=10),
intent(in) :: inv
6033 integer,
intent(in) :: localpet
6034 real(esmf_kind_r8),
intent(inout),
allocatable :: u(:,:,:),v(:,:,:)
6036 real(esmf_kind_r4),
dimension(i_input,j_input) :: alpha
6037 real(esmf_kind_r8),
dimension(i_input,j_input) :: lon, lat
6038 real(esmf_kind_r4),
allocatable :: u_tmp(:,:),v_tmp(:,:)
6039 real(esmf_kind_r4),
dimension(i_input,j_input) :: ws,wd
6040 real(esmf_kind_r4) :: value_u, value_v,lov,latin1,latin2
6041 real(esmf_kind_r8) :: d2r
6043 integer :: varnum_u, varnum_v, vlev, &
6046 character(len=20) :: vname
6047 character(len=50) :: method_u, method_v
6048 character(len=250) :: file_coord
6049 character(len=10000) :: temp_msg
6051 d2r=acos(-1.0_esmf_kind_r8) / 180.0_esmf_kind_r8
6052 if (localpet==0)
then
6053 allocate(u(i_input,j_input,lev_input))
6054 allocate(v(i_input,j_input,lev_input))
6060 file_coord = trim(fix_dir_input_grid)//
"/latlon_grid3.32769.nc"
6063 call
get_var_cond(vname,this_miss_var_method=method_u, this_miss_var_value=value_u, &
6066 call
get_var_cond(vname,this_miss_var_method=method_v, this_miss_var_value=value_v, &
6069 if (trim(input_grid_type)==
"rotated_latlon")
then
6070 print*,
"- CALL FieldGather FOR INPUT GRID LONGITUDE"
6071 call esmf_fieldgather(longitude_input_grid, lon, rootpet=0, tile=1, rc=error)
6072 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6074 print*,
"- CALL FieldGather FOR INPUT GRID LATITUDE"
6075 call esmf_fieldgather(latitude_input_grid, lat, rootpet=0, tile=1, rc=error)
6076 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6079 if (localpet==0)
then
6080 print*,
"- CALCULATE ROTATION ANGLE FOR ROTATED_LATLON INPUT GRID"
6081 error = grb2_inq(file, inv,grid_desc=temp_msg)
6090 istr = index(temp_msg,
"lat-center ") + len(
"lat_center ")
6091 read(temp_msg(istr:istr+9),
"(F8.5)") latin1
6092 istr = index(temp_msg,
"lon-center ") + len(
"lon-center ")
6093 read(temp_msg(istr:istr+10),
"(F9.6)") lov
6095 print*,
"- CALL CALCALPHA_ROTLATLON with center lat,lon = ",latin1,lov
6097 print*,
" alpha min/max = ",minval(alpha),maxval(alpha)
6099 elseif (trim(input_grid_type) ==
"lambert")
then
6102 print*,
"- CALL FieldGather FOR INPUT GRID LONGITUDE"
6103 call esmf_fieldgather(longitude_input_grid, lon, rootpet=0, tile=1, rc=error)
6104 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6107 if (localpet==0)
then
6108 error = grb2_inq(file, inv,grid_desc=temp_msg)
6116 istr = index(temp_msg,
"LoV ") + len(
"LoV ")
6117 read(temp_msg(istr:istr+10),
"(F9.6)") lov
6118 istr = index(temp_msg,
"Latin1 ") + len(
"Latin1 ")
6119 read(temp_msg(istr:istr+9),
"(F8.5)") latin1
6120 istr = index(temp_msg,
"Latin2 ") + len(
"Latin2 ")
6121 read(temp_msg(istr:istr+9),
"(F8.5)") latin2
6123 print*,
"- CALL GRIDROT for LC grid with lov,latin1/2 = ",lov,latin1,latin2
6124 call
gridrot(lov,latin1,latin2,lon,alpha)
6125 print*,
" alpha min/max = ",minval(alpha),maxval(alpha)
6129 if (localpet==0)
then
6130 do vlev = 1, lev_input
6133 iret = grb2_inq(file,inv,vname,slevs(vlev),data2=u_tmp)
6135 call
handle_grib_error(vname, slevs(vlev),method_u,value_u,varnum_u,iret,var=u_tmp)
6137 call
error_handler(
"READING IN U AT LEVEL "//trim(slevs(vlev))//
". SET A FILL "// &
6138 "VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",iret)
6143 iret = grb2_inq(file,inv,vname,slevs(vlev),data2=v_tmp)
6145 call
handle_grib_error(vname, slevs(vlev),method_v,value_v,varnum_v,iret,var=v_tmp)
6147 call
error_handler(
"READING IN V AT LEVEL "//trim(slevs(vlev))//
". SET A FILL "// &
6148 "VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",iret)
6152 if (trim(input_grid_type) ==
"latlon")
then
6153 if (external_model ==
'UKMET')
then
6155 v(:,:,vlev) = (v_tmp(:,2:jp1_input) + v_tmp(:,1:j_input))/2
6160 else if (trim(input_grid_type) ==
"rotated_latlon")
then
6161 ws = sqrt(u_tmp**2 + v_tmp**2)
6162 wd = atan2(-u_tmp,-v_tmp) / d2r
6163 wd = wd + alpha + 180.0
6165 u(:,:,vlev) = -ws*cos(wd*d2r)
6166 v(:,:,vlev) = -ws*sin(wd*d2r)
6168 u(:,:,vlev) =
real(u_tmp * cos(alpha) + v_tmp * sin(alpha),esmf_kind_r8)
6169 v(:,:,vlev) =
real(v_tmp * cos(alpha) - u_tmp * sin(alpha),esmf_kind_r8)
6172 print*,
'max, min U ', minval(u(:,:,vlev)), maxval(u(:,:,vlev))
6173 print*,
'max, min V ', minval(v(:,:,vlev)), maxval(v(:,:,vlev))
6186 integer :: clb(4), cub(4)
6187 integer :: i, j, k, rc
6189 real(esmf_kind_r8) :: latrad, lonrad
6190 real(esmf_kind_r8),
pointer :: windptr(:,:,:,:)
6191 real(esmf_kind_r8),
pointer :: uptr(:,:,:)
6192 real(esmf_kind_r8),
pointer :: vptr(:,:,:)
6193 real(esmf_kind_r8),
pointer :: latptr(:,:)
6194 real(esmf_kind_r8),
pointer :: lonptr(:,:)
6196 print*,
"- CALL FieldGet FOR 3-D WIND."
6197 call esmf_fieldget(wind_input_grid, &
6198 computationallbound=clb, &
6199 computationalubound=cub, &
6200 farrayptr=windptr, rc=rc)
6201 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6204 print*,
"- CALL FieldGet FOR U."
6205 call esmf_fieldget(u_input_grid, &
6206 farrayptr=uptr, rc=rc)
6207 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6210 print*,
"- CALL FieldGet FOR V."
6211 call esmf_fieldget(v_input_grid, &
6212 farrayptr=vptr, rc=rc)
6213 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6216 print*,
"- CALL FieldGet FOR LATITUDE."
6217 call esmf_fieldget(latitude_input_grid, &
6218 farrayptr=latptr, rc=rc)
6219 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6222 print*,
"- CALL FieldGet FOR LONGITUDE."
6223 call esmf_fieldget(longitude_input_grid, &
6224 farrayptr=lonptr, rc=rc)
6225 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
6228 do i = clb(1), cub(1)
6229 do j = clb(2), cub(2)
6230 latrad = latptr(i,j) * acos(-1.) / 180.0
6231 lonrad = lonptr(i,j) * acos(-1.) / 180.0
6232 do k = clb(3), cub(3)
6233 windptr(i,j,k,1) = uptr(i,j,k) * cos(lonrad) - vptr(i,j,k) * sin(latrad) * sin(lonrad)
6234 windptr(i,j,k,2) = uptr(i,j,k) * sin(lonrad) + vptr(i,j,k) * sin(latrad) * cos(lonrad)
6235 windptr(i,j,k,3) = vptr(i,j,k) * cos(latrad)
6240 call esmf_fielddestroy(u_input_grid, rc=rc)
6241 call esmf_fielddestroy(v_input_grid, rc=rc)
6264 real(esmf_kind_r4),
intent(in) :: lov,latin1,latin2
6265 real(esmf_kind_r4),
intent(inout) :: rot(i_input,j_input)
6266 real(esmf_kind_r8),
intent(in) :: lon(i_input,j_input)
6268 real(esmf_kind_r4) :: trot(i_input,j_input), tlon(i_input,j_input)
6269 real(esmf_kind_r4) :: dtor = 3.14159265359/180.0_esmf_kind_r4
6270 real(esmf_kind_r4) :: an
6276 if ( (latin1 - latin2) .lt. 0.000001 )
then
6277 an = sin(latin1*dtor)
6279 an = log( cos(latin1*dtor) / cos(latin2*dtor) ) / &
6280 log( tan(dtor*(90.0-latin1)/2.) / tan(dtor*(90.0-latin2)/2.))
6283 tlon = mod(lon - lov + 180. + 3600., 360.) - 180.
6304 real(esmf_kind_r8),
intent(in) :: latgrid(i_input,j_input), &
6305 longrid(i_input,j_input)
6306 real(esmf_kind_r4),
intent(in) :: cenlat, cenlon
6307 real(esmf_kind_r4),
intent(out) :: alpha(i_input,j_input)
6310 real(esmf_kind_r8) :: d2r,lon0_r,lat0_r,sphi0,cphi0
6311 real(esmf_kind_r8),
DIMENSION(i_input,j_input) :: tlat,tlon,tph,sinalpha
6313 d2r = acos(-1.0_esmf_kind_r8) / 180.0_esmf_kind_r8
6314 if (cenlon .lt. 0)
then
6315 lon0_r = (cenlon + 360.0)*d2r
6324 tlat = latgrid * d2r
6325 tlon = longrid * d2r
6328 tlon = -tlon + lon0_r
6329 tph = asin(cphi0*sin(tlat) - sphi0*cos(tlat)*cos(tlon))
6330 sinalpha = sphi0 * sin(tlon) / cos(tph)
6331 alpha = -asin(sinalpha)/d2r
6350 use,
intrinsic :: ieee_arithmetic
6354 real(esmf_kind_r4),
intent(in) :: value
6355 real(esmf_kind_r4),
intent(inout),
optional :: var(:,:)
6356 real(esmf_kind_r8),
intent(inout),
optional :: var8(:,:)
6357 real(esmf_kind_r8),
intent(inout),
optional :: var3d(:,:,:)
6359 character(len=20),
intent(in) :: vname, lev, method
6361 integer,
intent(in) :: varnum
6362 integer,
intent(inout) :: iret
6365 if (varnum == 9999)
then
6366 print*,
"WARNING: ", trim(vname),
" NOT FOUND AT LEVEL ", lev,
" IN EXTERNAL FILE ", &
6367 "AND NO ENTRY EXISTS IN VARMAP TABLE. VARIABLE WILL NOT BE USED."
6373 if (trim(method) ==
"skip" )
then
6374 print*,
"WARNING: SKIPPING ", trim(vname),
" IN FILE"
6375 read_from_input(varnum) = .false.
6377 elseif (trim(method) ==
"set_to_fill")
then
6378 print*,
"WARNING: ,", trim(vname),
" NOT AVILABLE AT LEVEL ", trim(lev), &
6379 ". SETTING EQUAL TO FILL VALUE OF ", value
6380 if(present(var)) var(:,:) = value
6381 if(present(var8)) var8(:,:) = value
6382 if(present(var3d)) var3d(:,:,:) = value
6383 elseif (trim(method) ==
"set_to_NaN")
then
6384 print*,
"WARNING: ,", trim(vname),
" NOT AVILABLE AT LEVEL ", trim(lev), &
6385 ". SETTING EQUAL TO NaNs"
6386 if(present(var)) var(:,:) = ieee_value(var,ieee_quiet_nan)
6387 if(present(var8)) var8(:,:) = ieee_value(var8,ieee_quiet_nan)
6388 if(present(var3d)) var3d(:,:,:) = ieee_value(var3d,ieee_quiet_nan)
6389 elseif (trim(method) ==
"stop")
then
6390 call
error_handler(
"READING "//trim(vname)//
" at level "//lev//
". TO MAKE THIS NON- &
6391 FATAL, CHANGE STOP TO SKIP FOR THIS VARIABLE IN YOUR VARMAP &
6394 call
error_handler(
"ERROR USING MISSING_VAR_METHOD. PLEASE SET VALUES IN" // &
6395 " VARMAP TABLE TO ONE OF: set_to_fill, set_to_NaN,"// &
6396 " , skip, or stop.", 1)
6415 character(len=*),
intent(in) :: the_file, inv_file
6416 character(len=20),
intent(in) :: vname,vname_file
6418 integer,
intent(out) :: rc
6420 real(esmf_kind_r8),
intent(inout) :: dummy3d(:,:,:)
6422 real(esmf_kind_r4),
allocatable :: dummy2d(:,:)
6423 real(esmf_kind_r4) :: value
6425 character(len=50) :: slevs(lsoil_input)
6426 character(len=50) :: method
6428 allocate(dummy2d(i_input,j_input))
6430 if(lsoil_input == 4)
then
6431 slevs = (/
character(24)::
':0-0.1 m below ground:',
':0.1-0.4 m below ground:', &
6432 ':0.4-1 m below ground:',
':1-2 m below ground:'/)
6433 elseif(lsoil_input == 9)
then
6434 slevs = (/
character(26)::
':0-0 m below ground',
':0.01-0.01 m below ground:',
':0.04-0.04 m below ground:', &
6435 ':0.1-0.1 m below ground:',
':0.3-0.3 m below ground:',
':0.6-0.6 m below ground:', &
6436 ':1-1 m below ground:',
':1.6-1.6 m below ground:',
':3-3 m below ground:'/)
6439 call
error_handler(
"reading soil levels. File must have 4 or 9 soil levels.", rc)
6442 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
6444 do i = 1,lsoil_input
6445 if (vname_file==
"var2_2_1_")
then
6446 rc = grb2_inq(the_file,inv_file,vname_file,
"_0_192:",slevs(i),data2=dummy2d)
6448 rc = grb2_inq(the_file,inv_file,vname_file,slevs(i),data2=dummy2d)
6452 if (rc==1 .and. trim(vname) /=
"soill")
then
6454 call
error_handler(
"READING IN "//trim(vname)//
". SET A FILL "// &
6455 "VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",rc)
6457 dummy3d(:,:,:) = 0.0_esmf_kind_r8
6462 dummy3d(:,:,i) =
real(dummy2d,esmf_kind_r8)
6478 print*,
'- DESTROY ATMOSPHERIC INPUT DATA.'
6480 call esmf_fielddestroy(terrain_input_grid, rc=rc)
6481 call esmf_fielddestroy(pres_input_grid, rc=rc)
6482 call esmf_fielddestroy(dzdt_input_grid, rc=rc)
6483 call esmf_fielddestroy(temp_input_grid, rc=rc)
6484 call esmf_fielddestroy(wind_input_grid, rc=rc)
6485 call esmf_fielddestroy(ps_input_grid, rc=rc)
6487 do n = 1, num_tracers
6488 call esmf_fielddestroy(tracers_input_grid(n), rc=rc)
6490 deallocate(tracers_input_grid)
6503 print*,
'- DESTROY NST INPUT DATA.'
6505 call esmf_fielddestroy(landsea_mask_input_grid, rc=rc)
6506 call esmf_fielddestroy(c_d_input_grid, rc=rc)
6507 call esmf_fielddestroy(c_0_input_grid, rc=rc)
6508 call esmf_fielddestroy(d_conv_input_grid, rc=rc)
6509 call esmf_fielddestroy(dt_cool_input_grid, rc=rc)
6510 call esmf_fielddestroy(ifd_input_grid, rc=rc)
6511 call esmf_fielddestroy(qrain_input_grid, rc=rc)
6512 call esmf_fielddestroy(tref_input_grid, rc=rc)
6513 call esmf_fielddestroy(w_d_input_grid, rc=rc)
6514 call esmf_fielddestroy(w_0_input_grid, rc=rc)
6515 call esmf_fielddestroy(xs_input_grid, rc=rc)
6516 call esmf_fielddestroy(xt_input_grid, rc=rc)
6517 call esmf_fielddestroy(xu_input_grid, rc=rc)
6518 call esmf_fielddestroy(xv_input_grid, rc=rc)
6519 call esmf_fielddestroy(xz_input_grid, rc=rc)
6520 call esmf_fielddestroy(xtts_input_grid, rc=rc)
6521 call esmf_fielddestroy(xzts_input_grid, rc=rc)
6522 call esmf_fielddestroy(z_c_input_grid, rc=rc)
6523 call esmf_fielddestroy(zm_input_grid, rc=rc)
6536 print*,
"- CALL FieldDestroy FOR INPUT GRID FIELDS."
6538 call esmf_fielddestroy(canopy_mc_input_grid, rc=rc)
6539 call esmf_fielddestroy(f10m_input_grid, rc=rc)
6540 call esmf_fielddestroy(ffmm_input_grid, rc=rc)
6541 if (.not. convert_nst)
then
6542 call esmf_fielddestroy(landsea_mask_input_grid, rc=rc)
6544 call esmf_fielddestroy(q2m_input_grid, rc=rc)
6545 call esmf_fielddestroy(seaice_depth_input_grid, rc=rc)
6546 call esmf_fielddestroy(seaice_fract_input_grid, rc=rc)
6547 call esmf_fielddestroy(seaice_skin_temp_input_grid, rc=rc)
6548 call esmf_fielddestroy(skin_temp_input_grid, rc=rc)
6549 call esmf_fielddestroy(snow_depth_input_grid, rc=rc)
6550 call esmf_fielddestroy(snow_liq_equiv_input_grid, rc=rc)
6551 call esmf_fielddestroy(soil_temp_input_grid, rc=rc)
6552 call esmf_fielddestroy(soil_type_input_grid, rc=rc)
6553 call esmf_fielddestroy(soilm_liq_input_grid, rc=rc)
6554 call esmf_fielddestroy(soilm_tot_input_grid, rc=rc)
6555 call esmf_fielddestroy(srflag_input_grid, rc=rc)
6556 call esmf_fielddestroy(t2m_input_grid, rc=rc)
6557 call esmf_fielddestroy(tprcp_input_grid, rc=rc)
6558 call esmf_fielddestroy(ustar_input_grid, rc=rc)
6559 call esmf_fielddestroy(veg_type_input_grid, rc=rc)
6560 call esmf_fielddestroy(z0_input_grid, rc=rc)
6561 call esmf_fielddestroy(terrain_input_grid, rc=rc)
6562 if (.not. vgfrc_from_climo)
then
6563 call esmf_fielddestroy(veg_greenness_input_grid, rc=rc)
6565 if (.not. minmax_vgfrc_from_climo)
then
6566 call esmf_fielddestroy(min_veg_greenness_input_grid, rc=rc)
6567 call esmf_fielddestroy(max_veg_greenness_input_grid, rc=rc)
6569 if (.not. lai_from_climo)
then
6570 call esmf_fielddestroy(lai_input_grid, rc=rc)
6587 x = a( (first+last) / 2 )
6598 t = a(i); a(i) = a(j); a(j) = t
6602 if (first < i-1) call
quicksort(a, first, i-1)
6603 if (j+1 < last) call
quicksort(a, j+1, last)
6622 real(esmf_kind_r8),
intent(inout) :: soilt(i_input,j_input,lsoil_input)
6623 real(esmf_kind_r8),
intent(in) :: skint(i_input,j_input)
6624 integer(esmf_kind_i4),
intent(in) :: landmask(i_input,j_input)
6631 if (landmask(i,j) == 0_esmf_kind_i4 )
then
6632 soilt(i,j,k) = skint(i,j)
6633 else if (landmask(i,j) == 1_esmf_kind_i4 .and. soilt(i,j,k) > 350.0_esmf_kind_r8)
then
6634 soilt(i,j,k) = skint(i,j)
6635 else if (landmask(i,j) == 2_esmf_kind_i4 )
then
6636 soilt(i,j,k) = icet_default
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.