20 sfc_files_input_grid, &
21 grib2_file_input_grid, &
23 orog_dir_input_grid, &
24 orog_files_input_grid, &
27 geogrid_file_input_grid, &
30 minmax_vgfrc_from_climo, &
36 ip1_input, jp1_input, &
49 integer,
public :: veg_type_landice_input = 15
52 real :: ICET_DEFAULT = 265.0
54 type(esmf_field),
public :: canopy_mc_input_grid
55 type(esmf_field),
public :: f10m_input_grid
56 type(esmf_field),
public :: ffmm_input_grid
58 type(esmf_field),
public :: landsea_mask_input_grid
60 type(esmf_field),
public :: q2m_input_grid
61 type(esmf_field),
public :: seaice_depth_input_grid
62 type(esmf_field),
public :: seaice_fract_input_grid
63 type(esmf_field),
public :: seaice_skin_temp_input_grid
64 type(esmf_field),
public :: skin_temp_input_grid
65 type(esmf_field),
public :: snow_depth_input_grid
66 type(esmf_field),
public :: snow_liq_equiv_input_grid
67 type(esmf_field),
public :: soil_temp_input_grid
68 type(esmf_field),
public :: soil_type_input_grid
69 type(esmf_field),
public :: soilm_liq_input_grid
70 type(esmf_field),
public :: soilm_tot_input_grid
71 type(esmf_field),
public :: srflag_input_grid
72 type(esmf_field),
public :: t2m_input_grid
73 type(esmf_field),
public :: tprcp_input_grid
74 type(esmf_field),
public :: ustar_input_grid
75 type(esmf_field),
public :: veg_type_input_grid
76 type(esmf_field),
public :: z0_input_grid
77 type(esmf_field),
public :: veg_greenness_input_grid
78 type(esmf_field),
public :: lai_input_grid
79 type(esmf_field),
public :: max_veg_greenness_input_grid
80 type(esmf_field),
public :: min_veg_greenness_input_grid
82 integer,
public :: lsoil_input=4
99 integer,
intent(in) :: localpet
107 if (trim(input_type) ==
"restart")
then
115 elseif (trim(input_type) ==
"history" .or. trim(input_type) == &
116 "gaussian_netcdf")
then
124 elseif (trim(input_type) ==
"gaussian_nemsio")
then
132 elseif (trim(input_type) ==
"gfs_gaussian_nemsio")
then
140 elseif (trim(input_type) ==
"gfs_sigio")
then
148 elseif (trim(input_type) ==
"grib2")
then
169 integer,
intent(in) :: localpet
171 character(len=300) :: the_file
173 integer(sfcio_intkind) :: iret
176 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
177 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
179 type(sfcio_head
) :: sfchead
180 type(sfcio_dbta
) :: sfcdata
182 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
184 print*,
"- READ SURFACE DATA IN SFCIO FORMAT."
185 print*,
"- OPEN AND READ: ",trim(the_file)
186 call sfcio_sropen(23, trim(the_file), iret)
192 call sfcio_srhead(23, sfchead, iret)
198 if (localpet == 0)
then
199 call sfcio_aldbta(sfchead, sfcdata, iret)
204 call sfcio_srdbta(23, sfchead, sfcdata, iret)
209 allocate(dummy2d(i_input,j_input))
210 allocate(dummy3d(i_input,j_input,lsoil_input))
212 allocate(dummy2d(0,0))
213 allocate(dummy3d(0,0,0))
216 if (localpet == 0) dummy2d = sfcdata%slmsk
218 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
219 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
220 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
223 if (localpet == 0) dummy2d = sfcdata%zorl
225 print*,
"- CALL FieldScatter FOR INPUT Z0."
226 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
227 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
230 if (localpet == 0) dummy2d = nint(sfcdata%vtype)
232 print*,
"- CALL FieldScatter FOR INPUT VEG TYPE."
233 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
234 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
238 veg_type_landice_input = 13
240 if (localpet == 0) dummy2d = sfcdata%canopy
242 print*,
"- CALL FieldScatter FOR INPUT CANOPY MC."
243 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
244 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
247 if (localpet == 0) dummy2d = sfcdata%fice
249 print*,
"- CALL FieldScatter FOR INPUT ICE FRACTION."
250 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
251 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
254 if (localpet == 0) dummy2d = sfcdata%hice
256 print*,
"- CALL FieldScatter FOR INPUT ICE DEPTH."
257 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
258 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
261 if (localpet == 0) dummy2d = sfcdata%tisfc
263 print*,
"- CALL FieldScatter FOR INPUT ICE SKIN TEMP."
264 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
265 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
268 if (localpet == 0) dummy2d = sfcdata%snwdph
270 print*,
"- CALL FieldScatter FOR INPUT SNOW DEPTH."
271 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
272 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
275 if (localpet == 0) dummy2d = sfcdata%sheleg
277 print*,
"- CALL FieldScatter FOR INPUT SNOW LIQUID EQUIV."
278 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
279 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
282 if (localpet == 0) dummy2d = sfcdata%t2m
284 print*,
"- CALL FieldScatter FOR INPUT T2M."
285 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
286 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
289 if (localpet == 0) dummy2d = sfcdata%q2m
291 print*,
"- CALL FieldScatter FOR INPUT Q2M."
292 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
293 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
296 if (localpet == 0) dummy2d = sfcdata%tprcp
298 print*,
"- CALL FieldScatter FOR INPUT TPRCP."
299 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
300 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
303 if (localpet == 0) dummy2d = sfcdata%f10m
305 print*,
"- CALL FieldScatter FOR INPUT F10M."
306 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
307 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
310 if (localpet == 0) dummy2d = sfcdata%uustar
312 print*,
"- CALL FieldScatter FOR INPUT USTAR."
313 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
314 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
317 if (localpet == 0) dummy2d = sfcdata%ffmm
319 print*,
"- CALL FieldScatter FOR INPUT FFMM."
320 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
321 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
324 if (localpet == 0) dummy2d = sfcdata%srflag
326 print*,
"- CALL FieldScatter FOR INPUT SRFLAG."
327 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
328 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
331 if (localpet == 0) dummy2d = sfcdata%tsea
333 print*,
"- CALL FieldScatter FOR INPUT SKIN TEMP."
334 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
335 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
338 if (localpet == 0) dummy2d = nint(sfcdata%stype)
340 print*,
"- CALL FieldScatter FOR INPUT SOIL TYPE."
341 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
342 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
345 if (localpet == 0) dummy2d = sfcdata%orog
347 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
348 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
349 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
352 if (localpet == 0) dummy3d = sfcdata%slc
354 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
355 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
356 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
359 if (localpet == 0) dummy3d = sfcdata%smc
361 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
362 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
363 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
366 if (localpet == 0) dummy3d = sfcdata%stc
368 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
369 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
370 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
373 deallocate(dummy2d, dummy3d)
374 call sfcio_axdbta(sfcdata, iret)
376 call sfcio_sclose(23, iret)
391 integer,
intent(in) :: localpet
393 character(len=300) :: the_file
397 real(nemsio_realkind),
allocatable :: dummy(:)
398 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
399 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
401 type(nemsio_gfile
) :: gfile
403 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
405 if (localpet == 0)
then
406 allocate(dummy3d(i_input,j_input,lsoil_input))
407 allocate(dummy2d(i_input,j_input))
408 allocate(dummy(i_input*j_input))
409 print*,
"- OPEN FILE ", trim(the_file)
410 call nemsio_open(gfile, the_file,
"read", iret=rc)
413 allocate(dummy3d(0,0,0))
414 allocate(dummy2d(0,0))
418 if (localpet == 0)
then
419 print*,
"- READ TERRAIN."
420 call nemsio_readrecv(gfile,
"orog",
"sfc", 1, dummy, 0, iret=rc)
422 dummy2d = reshape(dummy, (/i_input,j_input/))
423 print*,
'orog ',maxval(dummy2d),minval(dummy2d)
426 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
427 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
428 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
431 if (localpet == 0)
then
432 print*,
"- READ LANDSEA MASK."
433 call nemsio_readrecv(gfile,
"land",
"sfc", 1, dummy, 0, iret=rc)
435 dummy2d = reshape(dummy, (/i_input,j_input/))
436 print*,
'landmask ',maxval(dummy2d),minval(dummy2d)
439 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
440 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
441 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
444 if (localpet == 0)
then
445 print*,
"- READ SEAICE FRACTION."
446 call nemsio_readrecv(gfile,
"icec",
"sfc", 1, dummy, 0, iret=rc)
447 if (rc /= 0) call
error_handler(
"READING SEAICE FRACTION.", rc)
448 dummy2d = reshape(dummy, (/i_input,j_input/))
449 print*,
'icec ',maxval(dummy2d),minval(dummy2d)
452 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
453 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
454 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
457 if (localpet == 0)
then
458 print*,
"- READ SEAICE DEPTH."
459 call nemsio_readrecv(gfile,
"icetk",
"sfc", 1, dummy, 0, iret=rc)
461 dummy2d = reshape(dummy, (/i_input,j_input/))
462 print*,
'icetk ',maxval(dummy2d),minval(dummy2d)
465 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
466 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
467 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
470 if (localpet == 0)
then
471 print*,
"- READ SEAICE SKIN TEMPERATURE."
472 call nemsio_readrecv(gfile,
"tisfc",
"sfc", 1, dummy, 0, iret=rc)
473 if (rc /= 0) call
error_handler(
"READING SEAICE SKIN TEMP.", rc)
474 dummy2d = reshape(dummy, (/i_input,j_input/))
475 print*,
'ti ',maxval(dummy2d),minval(dummy2d)
478 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
479 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
480 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
483 if (localpet == 0)
then
484 print*,
"- READ SNOW LIQUID EQUIVALENT."
485 call nemsio_readrecv(gfile,
"weasd",
"sfc", 1, dummy, 0, iret=rc)
486 if (rc /= 0) call
error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
487 dummy2d = reshape(dummy, (/i_input,j_input/))
488 print*,
'weasd ',maxval(dummy2d),minval(dummy2d)
491 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
492 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
493 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
496 if (localpet == 0)
then
497 print*,
"- READ SNOW DEPTH."
498 call nemsio_readrecv(gfile,
"snod",
"sfc", 1, dummy, 0, iret=rc)
500 dummy2d = reshape(dummy, (/i_input,j_input/))
501 print*,
'snod ',maxval(dummy2d),minval(dummy2d)
504 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
505 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
506 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
509 if (localpet == 0)
then
510 print*,
"- READ VEG TYPE."
511 call nemsio_readrecv(gfile,
"vtype",
"sfc", 1, dummy, 0, iret=rc)
513 dummy2d = reshape(dummy, (/i_input,j_input/))
514 print*,
'vtype ',maxval(dummy2d),minval(dummy2d)
517 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
518 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
519 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
522 if (localpet == 0)
then
523 print*,
"- READ SOIL TYPE."
524 call nemsio_readrecv(gfile,
"sotyp",
"sfc", 1, dummy, 0, iret=rc)
526 dummy2d = reshape(dummy, (/i_input,j_input/))
527 print*,
'sotype ',maxval(dummy2d),minval(dummy2d)
530 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
531 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
532 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
535 if (localpet == 0)
then
537 call nemsio_readrecv(gfile,
"tmp",
"2 m above gnd", 1, dummy, 0, iret=rc)
539 dummy2d = reshape(dummy, (/i_input,j_input/))
540 print*,
't2m ',maxval(dummy2d),minval(dummy2d)
543 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
544 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
545 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
548 if (localpet == 0)
then
550 call nemsio_readrecv(gfile,
"spfh",
"2 m above gnd", 1, dummy, 0, iret=rc)
552 dummy2d = reshape(dummy, (/i_input,j_input/))
553 print*,
'q2m ',maxval(dummy2d),minval(dummy2d)
556 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
557 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
558 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
561 if (localpet == 0)
then
562 print*,
"- READ TPRCP."
563 call nemsio_readrecv(gfile,
"tprcp",
"sfc", 1, dummy, 0, iret=rc)
565 dummy2d = reshape(dummy, (/i_input,j_input/))
566 print*,
'tprcp ',maxval(dummy2d),minval(dummy2d)
569 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
570 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
571 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
574 if (localpet == 0)
then
575 print*,
"- READ FFMM."
576 call nemsio_readrecv(gfile,
"ffmm",
"sfc", 1, dummy, 0, iret=rc)
578 dummy2d = reshape(dummy, (/i_input,j_input/))
579 print*,
'ffmm ',maxval(dummy2d),minval(dummy2d)
582 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
583 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
584 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
587 if (localpet == 0)
then
588 print*,
"- READ USTAR."
589 call nemsio_readrecv(gfile,
"fricv",
"sfc", 1, dummy, 0, iret=rc)
591 dummy2d = reshape(dummy, (/i_input,j_input/))
592 print*,
'fricv ',maxval(dummy2d),minval(dummy2d)
595 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
596 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
597 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
600 if (localpet == 0) dummy2d = 0.0
601 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
602 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
603 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
606 if (localpet == 0)
then
607 print*,
"- READ SKIN TEMPERATURE."
608 call nemsio_readrecv(gfile,
"tmp",
"sfc", 1, dummy, 0, iret=rc)
609 if (rc /= 0) call
error_handler(
"READING SKIN TEMPERATURE.", rc)
610 dummy2d = reshape(dummy, (/i_input,j_input/))
611 print*,
'tmp ',maxval(dummy2d),minval(dummy2d)
614 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
615 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
616 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
619 if (localpet == 0)
then
620 print*,
"- READ F10M."
621 call nemsio_readrecv(gfile,
"f10m",
"10 m above gnd", 1, dummy, 0, iret=rc)
623 dummy2d = reshape(dummy, (/i_input,j_input/))
624 print*,
'f10m ',maxval(dummy2d),minval(dummy2d)
627 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
628 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
629 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
632 if (localpet == 0)
then
633 print*,
"- READ CANOPY MOISTURE CONTENT."
634 call nemsio_readrecv(gfile,
"cnwat",
"sfc", 1, dummy, 0, iret=rc)
635 if (rc /= 0) call
error_handler(
"READING CANOPY MOISTURE CONTENT.", rc)
636 dummy2d = reshape(dummy, (/i_input,j_input/))
637 print*,
'cnwat ',maxval(dummy2d),minval(dummy2d)
640 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
641 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
642 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
645 if (localpet == 0)
then
647 call nemsio_readrecv(gfile,
"sfcr",
"sfc", 1, dummy, 0, iret=rc)
649 dummy2d = reshape(dummy, (/i_input,j_input/))
650 print*,
'sfcr ',maxval(dummy2d),minval(dummy2d)
653 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
654 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
655 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
660 if (localpet == 0)
then
661 print*,
"- READ LIQUID SOIL MOISTURE."
662 call nemsio_readrecv(gfile,
"slc",
"soil layer", 1, dummy, 0, iret=rc)
663 if (rc /= 0) call
error_handler(
"READING LAYER 1 LIQUID SOIL MOIST.", rc)
664 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
665 call nemsio_readrecv(gfile,
"slc",
"soil layer", 2, dummy, 0, iret=rc)
666 if (rc /= 0) call
error_handler(
"READING LAYER 2 LIQUID SOIL MOIST.", rc)
667 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
668 call nemsio_readrecv(gfile,
"slc",
"soil layer", 3, dummy, 0, iret=rc)
669 if (rc /= 0) call
error_handler(
"READING LAYER 3 LIQUID SOIL MOIST.", rc)
670 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
671 call nemsio_readrecv(gfile,
"slc",
"soil layer", 4, dummy, 0, iret=rc)
672 if (rc /= 0) call
error_handler(
"READING LAYER 4 LIQUID SOIL MOIST.", rc)
673 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
674 print*,
'slc ',maxval(dummy3d),minval(dummy3d)
677 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
678 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
679 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
682 if (localpet == 0)
then
683 print*,
"- READ TOTAL SOIL MOISTURE."
684 call nemsio_readrecv(gfile,
"smc",
"soil layer", 1, dummy, 0, iret=rc)
685 if (rc /= 0) call
error_handler(
"READING LAYER 1 TOTAL SOIL MOIST.", rc)
686 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
687 call nemsio_readrecv(gfile,
"smc",
"soil layer", 2, dummy, 0, iret=rc)
688 if (rc /= 0) call
error_handler(
"READING LAYER 2 TOTAL SOIL MOIST.", rc)
689 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
690 call nemsio_readrecv(gfile,
"smc",
"soil layer", 3, dummy, 0, iret=rc)
691 if (rc /= 0) call
error_handler(
"READING LAYER 3 TOTAL SOIL MOIST.", rc)
692 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
693 call nemsio_readrecv(gfile,
"smc",
"soil layer", 4, dummy, 0, iret=rc)
694 if (rc /= 0) call
error_handler(
"READING LAYER 4 TOTAL SOIL MOIST.", rc)
695 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
696 print*,
'smc ',maxval(dummy3d),minval(dummy3d)
699 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
700 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
701 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
704 if (localpet == 0)
then
705 print*,
"- READ SOIL TEMPERATURE."
706 call nemsio_readrecv(gfile,
"stc",
"soil layer", 1, dummy, 0, iret=rc)
707 if (rc /= 0) call
error_handler(
"READING LAYER 1 SOIL TEMP.", rc)
708 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
709 call nemsio_readrecv(gfile,
"stc",
"soil layer", 2, dummy, 0, iret=rc)
710 if (rc /= 0) call
error_handler(
"READING LAYER 2 SOIL TEMP.", rc)
711 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
712 call nemsio_readrecv(gfile,
"stc",
"soil layer", 3, dummy, 0, iret=rc)
713 if (rc /= 0) call
error_handler(
"READING LAYER 3 SOIL TEMP.", rc)
714 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
715 call nemsio_readrecv(gfile,
"stc",
"soil layer", 4, dummy, 0, iret=rc)
716 if (rc /= 0) call
error_handler(
"READING LAYER 4 SOIL TEMP.", rc)
717 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
718 print*,
'stc ',maxval(dummy3d),minval(dummy3d)
721 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
722 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
723 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
726 deallocate(dummy3d, dummy)
728 if (localpet == 0) call nemsio_close(gfile)
740 integer,
intent(in) :: localpet
742 character(len=250) :: the_file
746 real(nemsio_realkind),
allocatable :: dummy(:)
747 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
748 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
750 type(nemsio_gfile
) :: gfile
752 the_file = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
754 if (localpet == 0)
then
755 allocate(dummy3d(i_input,j_input,lsoil_input))
756 allocate(dummy2d(i_input,j_input))
757 allocate(dummy(i_input*j_input))
758 print*,
"- OPEN FILE ", trim(the_file)
759 call nemsio_open(gfile, the_file,
"read", iret=rc)
762 allocate(dummy3d(0,0,0))
763 allocate(dummy2d(0,0))
767 if (localpet == 0)
then
768 print*,
"- READ TERRAIN."
769 call nemsio_readrecv(gfile,
"orog",
"sfc", 1, dummy, 0, iret=rc)
771 dummy2d = reshape(dummy, (/i_input,j_input/))
772 print*,
'orog ',maxval(dummy2d),minval(dummy2d)
775 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
776 call esmf_fieldscatter(terrain_input_grid, dummy2d, rootpet=0, rc=rc)
777 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
780 if (localpet == 0)
then
781 print*,
"- READ LANDSEA MASK."
782 call nemsio_readrecv(gfile,
"land",
"sfc", 1, dummy, 0, iret=rc)
784 dummy2d = reshape(dummy, (/i_input,j_input/))
785 print*,
'landmask ',maxval(dummy2d),minval(dummy2d)
788 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
789 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
790 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
793 if (localpet == 0)
then
794 print*,
"- READ SEAICE FRACTION."
795 call nemsio_readrecv(gfile,
"icec",
"sfc", 1, dummy, 0, iret=rc)
796 if (rc /= 0) call
error_handler(
"READING SEAICE FRACTION.", rc)
797 dummy2d = reshape(dummy, (/i_input,j_input/))
798 print*,
'icec ',maxval(dummy2d),minval(dummy2d)
801 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
802 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
803 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
806 if (localpet == 0)
then
807 print*,
"- READ SEAICE DEPTH."
808 call nemsio_readrecv(gfile,
"icetk",
"sfc", 1, dummy, 0, iret=rc)
810 dummy2d = reshape(dummy, (/i_input,j_input/))
811 print*,
'icetk ',maxval(dummy2d),minval(dummy2d)
814 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
815 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
816 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
819 if (localpet == 0)
then
820 print*,
"- READ SEAICE SKIN TEMPERATURE."
821 call nemsio_readrecv(gfile,
"ti",
"sfc", 1, dummy, 0, iret=rc)
822 if (rc /= 0) call
error_handler(
"READING SEAICE SKIN TEMP.", rc)
823 dummy2d = reshape(dummy, (/i_input,j_input/))
824 print*,
'ti ',maxval(dummy2d),minval(dummy2d)
827 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
828 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
829 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
832 if (localpet == 0)
then
833 print*,
"- READ SNOW LIQUID EQUIVALENT."
834 call nemsio_readrecv(gfile,
"weasd",
"sfc", 1, dummy, 0, iret=rc)
835 if (rc /= 0) call
error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
836 dummy2d = reshape(dummy, (/i_input,j_input/))
837 print*,
'weasd ',maxval(dummy2d),minval(dummy2d)
840 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
841 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
842 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
845 if (localpet == 0)
then
846 print*,
"- READ SNOW DEPTH."
847 call nemsio_readrecv(gfile,
"snod",
"sfc", 1, dummy, 0, iret=rc)
849 dummy2d = reshape(dummy, (/i_input,j_input/)) * 1000.0_8
850 print*,
'snod ',maxval(dummy2d),minval(dummy2d)
853 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
854 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
855 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
858 if (localpet == 0)
then
859 print*,
"- READ VEG TYPE."
860 call nemsio_readrecv(gfile,
"vtype",
"sfc", 1, dummy, 0, iret=rc)
862 dummy2d = reshape(dummy, (/i_input,j_input/))
863 print*,
'vtype ',maxval(dummy2d),minval(dummy2d)
866 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
867 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
868 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
871 if (localpet == 0)
then
872 print*,
"- READ SOIL TYPE."
873 call nemsio_readrecv(gfile,
"sotyp",
"sfc", 1, dummy, 0, iret=rc)
875 dummy2d = reshape(dummy, (/i_input,j_input/))
876 print*,
'sotype ',maxval(dummy2d),minval(dummy2d)
879 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
880 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
881 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
884 if (localpet == 0)
then
886 call nemsio_readrecv(gfile,
"tmp",
"2 m above gnd", 1, dummy, 0, iret=rc)
888 dummy2d = reshape(dummy, (/i_input,j_input/))
889 print*,
't2m ',maxval(dummy2d),minval(dummy2d)
892 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
893 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
894 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
897 if (localpet == 0)
then
899 call nemsio_readrecv(gfile,
"spfh",
"2 m above gnd", 1, dummy, 0, iret=rc)
901 dummy2d = reshape(dummy, (/i_input,j_input/))
902 print*,
'q2m ',maxval(dummy2d),minval(dummy2d)
905 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
906 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
907 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
910 if (localpet == 0)
then
911 print*,
"- READ TPRCP."
912 call nemsio_readrecv(gfile,
"tprcp",
"sfc", 1, dummy, 0, iret=rc)
914 dummy2d = reshape(dummy, (/i_input,j_input/))
915 print*,
'tprcp ',maxval(dummy2d),minval(dummy2d)
918 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
919 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
920 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
923 if (localpet == 0)
then
924 print*,
"- READ FFMM."
925 call nemsio_readrecv(gfile,
"ffmm",
"sfc", 1, dummy, 0, iret=rc)
927 dummy2d = reshape(dummy, (/i_input,j_input/))
928 print*,
'ffmm ',maxval(dummy2d),minval(dummy2d)
931 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
932 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
933 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
936 if (localpet == 0)
then
937 print*,
"- READ USTAR."
938 call nemsio_readrecv(gfile,
"fricv",
"sfc", 1, dummy, 0, iret=rc)
940 dummy2d = reshape(dummy, (/i_input,j_input/))
941 print*,
'fricv ',maxval(dummy2d),minval(dummy2d)
944 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
945 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
946 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
949 if (localpet == 0) dummy2d = 0.0
950 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
951 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
952 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
955 if (localpet == 0)
then
956 print*,
"- READ SKIN TEMPERATURE."
957 call nemsio_readrecv(gfile,
"tmp",
"sfc", 1, dummy, 0, iret=rc)
958 if (rc /= 0) call
error_handler(
"READING SKIN TEMPERATURE.", rc)
959 dummy2d = reshape(dummy, (/i_input,j_input/))
960 print*,
'tmp ',maxval(dummy2d),minval(dummy2d)
963 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
964 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
965 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
968 if (localpet == 0)
then
969 print*,
"- READ F10M."
970 call nemsio_readrecv(gfile,
"f10m",
"10 m above gnd", 1, dummy, 0, iret=rc)
972 dummy2d = reshape(dummy, (/i_input,j_input/))
973 print*,
'f10m ',maxval(dummy2d),minval(dummy2d)
976 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
977 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
978 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
981 if (localpet == 0)
then
982 print*,
"- READ CANOPY MOISTURE CONTENT."
983 call nemsio_readrecv(gfile,
"cnwat",
"sfc", 1, dummy, 0, iret=rc)
984 if (rc /= 0) call
error_handler(
"READING CANOPY MOISTURE CONTENT.", rc)
985 dummy2d = reshape(dummy, (/i_input,j_input/))
986 print*,
'cnwat ',maxval(dummy2d),minval(dummy2d)
989 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
990 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
991 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
994 if (localpet == 0)
then
996 call nemsio_readrecv(gfile,
"sfcr",
"sfc", 1, dummy, 0, iret=rc)
998 dummy2d = reshape(dummy, (/i_input,j_input/)) * 100.0_8
999 print*,
'sfcr ',maxval(dummy2d),minval(dummy2d)
1002 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
1003 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
1004 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1009 if (localpet == 0)
then
1010 print*,
"- READ LIQUID SOIL MOISTURE."
1011 call nemsio_readrecv(gfile,
"soill",
"0-10 cm down", 1, dummy, 0, iret=rc)
1012 if (rc /= 0) call
error_handler(
"READING LAYER 1 LIQUID SOIL MOIST.", rc)
1013 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
1014 call nemsio_readrecv(gfile,
"soill",
"10-40 cm down", 1, dummy, 0, iret=rc)
1015 if (rc /= 0) call
error_handler(
"READING LAYER 2 LIQUID SOIL MOIST.", rc)
1016 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
1017 call nemsio_readrecv(gfile,
"soill",
"40-100 cm down", 1, dummy, 0, iret=rc)
1018 if (rc /= 0) call
error_handler(
"READING LAYER 3 LIQUID SOIL MOIST.", rc)
1019 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
1020 call nemsio_readrecv(gfile,
"soill",
"100-200 cm down", 1, dummy, 0, iret=rc)
1021 if (rc /= 0) call
error_handler(
"READING LAYER 4 LIQUID SOIL MOIST.", rc)
1022 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
1023 print*,
'soill ',maxval(dummy3d),minval(dummy3d)
1026 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
1027 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
1028 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1031 if (localpet == 0)
then
1032 print*,
"- READ TOTAL SOIL MOISTURE."
1033 call nemsio_readrecv(gfile,
"soilw",
"0-10 cm down", 1, dummy, 0, iret=rc)
1034 if (rc /= 0) call
error_handler(
"READING LAYER 1 TOTAL SOIL MOIST.", rc)
1035 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
1036 call nemsio_readrecv(gfile,
"soilw",
"10-40 cm down", 1, dummy, 0, iret=rc)
1037 if (rc /= 0) call
error_handler(
"READING LAYER 2 TOTAL SOIL MOIST.", rc)
1038 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
1039 call nemsio_readrecv(gfile,
"soilw",
"40-100 cm down", 1, dummy, 0, iret=rc)
1040 if (rc /= 0) call
error_handler(
"READING LAYER 3 TOTAL SOIL MOIST.", rc)
1041 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
1042 call nemsio_readrecv(gfile,
"soilw",
"100-200 cm down", 1, dummy, 0, iret=rc)
1043 if (rc /= 0) call
error_handler(
"READING LAYER 4 TOTAL SOIL MOIST.", rc)
1044 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
1045 print*,
'soilm ',maxval(dummy3d),minval(dummy3d)
1048 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
1049 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
1050 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1053 if (localpet == 0)
then
1054 print*,
"- READ SOIL TEMPERATURE."
1055 call nemsio_readrecv(gfile,
"tmp",
"0-10 cm down", 1, dummy, 0, iret=rc)
1056 if (rc /= 0) call
error_handler(
"READING LAYER 1 SOIL TEMP.", rc)
1057 dummy3d(:,:,1) = reshape(dummy, (/i_input,j_input/))
1058 call nemsio_readrecv(gfile,
"tmp",
"10-40 cm down", 1, dummy, 0, iret=rc)
1059 if (rc /= 0) call
error_handler(
"READING LAYER 2 SOIL TEMP.", rc)
1060 dummy3d(:,:,2) = reshape(dummy, (/i_input,j_input/))
1061 call nemsio_readrecv(gfile,
"tmp",
"40-100 cm down", 1, dummy, 0, iret=rc)
1062 if (rc /= 0) call
error_handler(
"READING LAYER 3 SOIL TEMP.", rc)
1063 dummy3d(:,:,3) = reshape(dummy, (/i_input,j_input/))
1064 call nemsio_readrecv(gfile,
"tmp",
"100-200 cm down", 1, dummy, 0, iret=rc)
1065 if (rc /= 0) call
error_handler(
"READING LAYER 4 SOIL TEMP.", rc)
1066 dummy3d(:,:,4) = reshape(dummy, (/i_input,j_input/))
1067 print*,
'soilt ',maxval(dummy3d),minval(dummy3d)
1070 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
1071 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
1072 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1075 deallocate(dummy3d, dummy)
1077 if (localpet == 0) call nemsio_close(gfile)
1089 integer,
intent(in) :: localpet
1091 character(len=500) :: tilefile
1093 integer :: error, rc
1094 integer :: id_dim, idim_input, jdim_input
1095 integer :: ncid, tile, id_var
1097 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
1098 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
1105 tilefile = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
1106 print*,
"- READ GRID DIMENSIONS FROM: ", trim(tilefile)
1107 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1108 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1110 error=nf90_inq_dimid(ncid,
'xaxis_1', id_dim)
1111 call
netcdf_err(error,
'reading xaxis_1 id' )
1112 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
1113 call
netcdf_err(error,
'reading xaxis_1 value' )
1115 error=nf90_inq_dimid(ncid,
'yaxis_1', id_dim)
1116 call
netcdf_err(error,
'reading yaxis_1 id' )
1117 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
1118 call
netcdf_err(error,
'reading yaxis_1 value' )
1120 if (idim_input /= i_input .or. jdim_input /= j_input)
then
1121 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 1)
1124 error = nf90_close(ncid)
1126 if (localpet == 0)
then
1127 allocate(data_one_tile(idim_input,jdim_input))
1128 allocate(data_one_tile_3d(idim_input,jdim_input,lsoil_input))
1130 allocate(data_one_tile(0,0))
1131 allocate(data_one_tile_3d(0,0,0))
1134 terrain_loop:
do tile = 1, num_tiles_input_grid
1136 if (localpet == 0)
then
1137 tilefile = trim(orog_dir_input_grid) // trim(orog_files_input_grid(tile))
1138 print*,
'- OPEN OROGRAPHY FILE: ', trim(tilefile)
1139 error=nf90_open(tilefile,nf90_nowrite,ncid)
1140 call
netcdf_err(error,
'OPENING OROGRAPHY FILE' )
1141 error=nf90_inq_varid(ncid,
'orog_raw', id_var)
1142 call
netcdf_err(error,
'READING OROG RECORD ID' )
1143 error=nf90_get_var(ncid, id_var, data_one_tile)
1144 call
netcdf_err(error,
'READING OROG RECORD' )
1145 print*,
'terrain check ',tile, maxval(data_one_tile)
1146 error=nf90_close(ncid)
1149 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
1150 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1151 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1156 tile_loop :
do tile = 1, num_tiles_input_grid
1160 if (localpet == 0)
then
1162 lsoil_input, sfcdata_3d=data_one_tile_3d)
1165 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
1166 call esmf_fieldscatter(soilm_liq_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
1167 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1170 if (localpet == 0)
then
1172 lsoil_input, sfcdata_3d=data_one_tile_3d)
1175 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
1176 call esmf_fieldscatter(soilm_tot_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
1177 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1180 if (localpet == 0)
then
1182 lsoil_input, sfcdata_3d=data_one_tile_3d)
1185 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
1186 call esmf_fieldscatter(soil_temp_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
1187 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1192 if (localpet == 0)
then
1194 lsoil_input, sfcdata=data_one_tile)
1197 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
1198 call esmf_fieldscatter(landsea_mask_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1199 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1204 if (localpet == 0)
then
1206 lsoil_input, sfcdata=data_one_tile)
1209 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
1210 call esmf_fieldscatter(seaice_fract_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1211 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1216 if (localpet == 0)
then
1218 lsoil_input, sfcdata=data_one_tile)
1221 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
1222 call esmf_fieldscatter(seaice_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1223 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1228 if (localpet == 0)
then
1230 lsoil_input, sfcdata=data_one_tile)
1233 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
1234 call esmf_fieldscatter(seaice_skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1235 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1240 if (localpet == 0)
then
1242 lsoil_input, sfcdata=data_one_tile)
1245 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
1246 call esmf_fieldscatter(snow_liq_equiv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1247 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1252 if (localpet == 0)
then
1254 lsoil_input, sfcdata=data_one_tile)
1255 data_one_tile = data_one_tile
1258 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
1259 call esmf_fieldscatter(snow_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1260 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1265 if (localpet == 0)
then
1267 lsoil_input, sfcdata=data_one_tile)
1270 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
1271 call esmf_fieldscatter(veg_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1272 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1277 if (localpet == 0)
then
1279 lsoil_input, sfcdata=data_one_tile)
1282 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
1283 call esmf_fieldscatter(soil_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1284 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1289 if (localpet == 0)
then
1291 lsoil_input, sfcdata=data_one_tile)
1294 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
1295 call esmf_fieldscatter(t2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1296 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1301 if (localpet == 0)
then
1303 lsoil_input, sfcdata=data_one_tile)
1306 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
1307 call esmf_fieldscatter(q2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1308 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1311 if (localpet == 0)
then
1313 lsoil_input, sfcdata=data_one_tile)
1316 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
1317 call esmf_fieldscatter(tprcp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1318 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1321 if (localpet == 0)
then
1323 lsoil_input, sfcdata=data_one_tile)
1326 print*,
"- CALL FieldScatter FOR INPUT GRID F10M"
1327 call esmf_fieldscatter(f10m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1328 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1331 if (localpet == 0)
then
1333 lsoil_input, sfcdata=data_one_tile)
1336 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
1337 call esmf_fieldscatter(ffmm_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1338 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1341 if (localpet == 0)
then
1343 lsoil_input, sfcdata=data_one_tile)
1346 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
1347 call esmf_fieldscatter(ustar_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1348 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1351 if (localpet == 0)
then
1353 lsoil_input, sfcdata=data_one_tile)
1356 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
1357 call esmf_fieldscatter(srflag_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1358 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1361 if (localpet == 0)
then
1363 lsoil_input, sfcdata=data_one_tile)
1366 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
1367 call esmf_fieldscatter(skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1368 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1371 if (localpet == 0)
then
1373 lsoil_input, sfcdata=data_one_tile)
1376 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
1377 call esmf_fieldscatter(canopy_mc_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1378 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1381 if (localpet == 0)
then
1383 lsoil_input, sfcdata=data_one_tile)
1386 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
1387 call esmf_fieldscatter(z0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1388 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1393 deallocate(data_one_tile, data_one_tile_3d)
1406 integer,
intent(in) :: localpet
1408 character(len=500) :: tilefile
1410 integer :: error, id_var
1411 integer :: id_dim, idim_input, jdim_input
1412 integer :: ncid, rc, tile
1414 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
1415 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
1422 tilefile = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(1))
1423 print*,
"- READ GRID DIMENSIONS FROM: ", trim(tilefile)
1424 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1425 call
netcdf_err(error,
'opening: '//trim(tilefile) )
1427 error=nf90_inq_dimid(ncid,
'grid_xt', id_dim)
1428 call
netcdf_err(error,
'reading grid_xt id' )
1429 error=nf90_inquire_dimension(ncid,id_dim,len=idim_input)
1430 call
netcdf_err(error,
'reading grid_xt value' )
1432 error=nf90_inq_dimid(ncid,
'grid_yt', id_dim)
1433 call
netcdf_err(error,
'reading grid_yt id' )
1434 error=nf90_inquire_dimension(ncid,id_dim,len=jdim_input)
1435 call
netcdf_err(error,
'reading grid_yt value' )
1437 if (idim_input /= i_input .or. jdim_input /= j_input)
then
1438 call
error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 3)
1441 error = nf90_close(ncid)
1443 if (localpet == 0)
then
1444 allocate(data_one_tile(idim_input,jdim_input))
1445 allocate(data_one_tile_3d(idim_input,jdim_input,lsoil_input))
1447 allocate(data_one_tile(0,0))
1448 allocate(data_one_tile_3d(0,0,0))
1451 terrain_loop:
do tile = 1, num_tiles_input_grid
1453 if (trim(input_type) ==
"gaussian_netcdf")
then
1454 if (localpet == 0)
then
1456 lsoil_input, sfcdata=data_one_tile)
1461 if (localpet == 0)
then
1462 tilefile = trim(orog_dir_input_grid) // trim(orog_files_input_grid(tile))
1463 print*,
'- OPEN OROGRAPHY FILE: ', trim(tilefile)
1464 error=nf90_open(tilefile,nf90_nowrite,ncid)
1465 call
netcdf_err(error,
'OPENING OROGRAPHY FILE.' )
1466 error=nf90_inq_varid(ncid,
'orog_raw', id_var)
1467 call
netcdf_err(error,
'READING OROGRAPHY RECORD ID.' )
1468 error=nf90_get_var(ncid, id_var, data_one_tile)
1469 call
netcdf_err(error,
'READING OROGRAPHY RECORD.' )
1470 print*,
'terrain check history ',tile, maxval(data_one_tile)
1471 error=nf90_close(ncid)
1476 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
1477 call esmf_fieldscatter(terrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1478 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1483 tile_loop :
do tile = 1, num_tiles_input_grid
1487 if (localpet == 0)
then
1489 lsoil_input, sfcdata=data_one_tile)
1490 data_one_tile_3d(:,:,1) = data_one_tile
1492 lsoil_input, sfcdata=data_one_tile)
1493 data_one_tile_3d(:,:,2) = data_one_tile
1495 lsoil_input, sfcdata=data_one_tile)
1496 data_one_tile_3d(:,:,3) = data_one_tile
1498 lsoil_input, sfcdata=data_one_tile)
1499 data_one_tile_3d(:,:,4) = data_one_tile
1502 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
1503 call esmf_fieldscatter(soilm_liq_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
1504 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1509 if (localpet == 0)
then
1511 lsoil_input, sfcdata=data_one_tile)
1512 data_one_tile_3d(:,:,1) = data_one_tile
1514 lsoil_input, sfcdata=data_one_tile)
1515 data_one_tile_3d(:,:,2) = data_one_tile
1517 lsoil_input, sfcdata=data_one_tile)
1518 data_one_tile_3d(:,:,3) = data_one_tile
1520 lsoil_input, sfcdata=data_one_tile)
1521 data_one_tile_3d(:,:,4) = data_one_tile
1524 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
1525 call esmf_fieldscatter(soilm_tot_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
1526 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1531 if (localpet == 0)
then
1533 lsoil_input, sfcdata=data_one_tile)
1534 data_one_tile_3d(:,:,1) = data_one_tile
1536 lsoil_input, sfcdata=data_one_tile)
1537 data_one_tile_3d(:,:,2) = data_one_tile
1539 lsoil_input, sfcdata=data_one_tile)
1540 data_one_tile_3d(:,:,3) = data_one_tile
1542 lsoil_input, sfcdata=data_one_tile)
1543 data_one_tile_3d(:,:,4) = data_one_tile
1546 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
1547 call esmf_fieldscatter(soil_temp_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
1548 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1553 if (localpet == 0)
then
1555 lsoil_input, sfcdata=data_one_tile)
1558 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
1559 call esmf_fieldscatter(landsea_mask_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1560 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1565 if (localpet == 0)
then
1567 lsoil_input, sfcdata=data_one_tile)
1570 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
1571 call esmf_fieldscatter(seaice_fract_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1572 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1577 if (localpet == 0)
then
1579 lsoil_input, sfcdata=data_one_tile)
1582 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
1583 call esmf_fieldscatter(seaice_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1584 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1589 if (localpet == 0)
then
1591 lsoil_input, sfcdata=data_one_tile)
1594 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
1595 call esmf_fieldscatter(seaice_skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1596 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1601 if (localpet == 0)
then
1603 lsoil_input, sfcdata=data_one_tile)
1606 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
1607 call esmf_fieldscatter(snow_liq_equiv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1608 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1613 if (localpet == 0)
then
1615 lsoil_input, sfcdata=data_one_tile)
1616 data_one_tile = data_one_tile * 1000.0
1619 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
1620 call esmf_fieldscatter(snow_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1621 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1626 if (localpet == 0)
then
1628 lsoil_input, sfcdata=data_one_tile)
1631 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
1632 call esmf_fieldscatter(veg_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1633 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1638 if (localpet == 0)
then
1640 lsoil_input, sfcdata=data_one_tile)
1643 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
1644 call esmf_fieldscatter(soil_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1645 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1650 if (localpet == 0)
then
1652 lsoil_input, sfcdata=data_one_tile)
1655 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
1656 call esmf_fieldscatter(t2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1657 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1662 if (localpet == 0)
then
1664 lsoil_input, sfcdata=data_one_tile)
1667 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
1668 call esmf_fieldscatter(q2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1669 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1672 if (localpet == 0)
then
1674 lsoil_input, sfcdata=data_one_tile)
1677 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
1678 call esmf_fieldscatter(tprcp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1679 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1682 if (localpet == 0)
then
1684 lsoil_input, sfcdata=data_one_tile)
1687 print*,
"- CALL FieldScatter FOR INPUT GRID F10M"
1688 call esmf_fieldscatter(f10m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1689 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1692 if (localpet == 0)
then
1694 lsoil_input, sfcdata=data_one_tile)
1697 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
1698 call esmf_fieldscatter(ffmm_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1699 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1702 if (localpet == 0)
then
1704 lsoil_input, sfcdata=data_one_tile)
1707 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
1708 call esmf_fieldscatter(ustar_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1709 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1712 if (localpet == 0)
then
1718 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
1719 call esmf_fieldscatter(srflag_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1720 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1723 if (localpet == 0)
then
1725 lsoil_input, sfcdata=data_one_tile)
1728 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
1729 call esmf_fieldscatter(skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1730 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1733 if (localpet == 0)
then
1735 lsoil_input, sfcdata=data_one_tile)
1738 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
1739 call esmf_fieldscatter(canopy_mc_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1740 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1743 if (localpet == 0)
then
1745 lsoil_input, sfcdata=data_one_tile)
1748 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
1749 call esmf_fieldscatter(z0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1750 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1755 deallocate(data_one_tile, data_one_tile_3d)
1767 use program_setup, only : vgtyp_from_climo, sotyp_from_climo
1773 integer,
intent(in) :: localpet
1775 character(len=250) :: the_file
1776 character(len=250) :: geo_file
1777 character(len=200) :: err_msg
1778 character(len=20) :: vname, vname_file, slev
1779 character(len=50) :: method
1781 integer :: rc, varnum, iret, i, j,k
1782 integer :: ncid2d, varid, varsize
1783 integer :: lugb, lugi
1784 integer :: jdisc, jgdtn, jpdtn, pdt_num
1785 integer :: jids(200), jgdt(200), jpdt(200)
1787 logical :: rap_latlon, unpack
1789 real(esmf_kind_r4) :: value
1790 real(esmf_kind_r4),
allocatable :: dummy2d(:,:)
1791 real(esmf_kind_r8),
allocatable :: icec_save(:,:)
1792 real(esmf_kind_r4),
allocatable :: dummy1d(:)
1793 real(esmf_kind_r8),
allocatable :: dummy2d_8(:,:),dummy2d_82(:,:),tsk_save(:,:)
1794 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:), dummy3d_stype(:,:,:)
1795 integer(esmf_kind_i4),
allocatable :: slmsk_save(:,:)
1796 integer(esmf_kind_i8),
allocatable :: dummy2d_i(:,:)
1798 type(gribfield
) :: gfld
1800 rap_latlon = trim(
to_upper(external_model))==
"RAP" .and. trim(input_grid_type) ==
"rotated_latlon"
1802 the_file = trim(data_dir_input_grid) //
"/" // trim(grib2_file_input_grid)
1803 geo_file = trim(geogrid_file_input_grid)
1805 print*,
"- READ SFC DATA FROM GRIB2 FILE: ", trim(the_file)
1809 if (localpet == 0)
then
1812 call baopenr(lugb,the_file,rc)
1813 if (rc /= 0) call
error_handler(
"ERROR OPENING GRIB2 FILE.", rc)
1825 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
1826 unpack, k, gfld, rc)
1829 if (gfld%idsect(1) == 7 .and. gfld%idsect(2) == 2)
then
1830 print*,
'- THIS IS NCEP GEFS DATA.'
1836 if (rc /= 0) call
error_handler(
"ERROR READING GRIB2 FILE.", rc)
1844 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
1845 unpack, k, gfld, rc)
1849 if (gfld%discipline == 2)
then
1850 if (gfld%ipdtnum == pdt_num)
then
1851 if (gfld%ipdtmpl(1) == 0 .and. gfld%ipdtmpl(2) == 2)
then
1853 if (gfld%ipdtmpl(10) == 106 .and. gfld%ipdtmpl(13) == 106)
then
1855 lsoil_input = lsoil_input + 1
1865 print*,
"- FILE HAS ", lsoil_input,
" SOIL LEVELS."
1866 if (lsoil_input == 0) call
error_handler(
"COUNTING SOIL LEVELS.", rc)
1870 call mpi_barrier(mpi_comm_world, rc)
1871 call mpi_bcast(lsoil_input,1,mpi_integer,0,mpi_comm_world,rc)
1875 if (lsoil_input /= 4)
then
1877 call esmf_fielddestroy(soil_temp_input_grid, rc=rc)
1878 call esmf_fielddestroy(soilm_tot_input_grid, rc=rc)
1879 call esmf_fielddestroy(soilm_liq_input_grid, rc=rc)
1881 print*,
"- CALL FieldCreate FOR INPUT SOIL TEMPERATURE."
1882 soil_temp_input_grid = esmf_fieldcreate(input_grid, &
1883 typekind=esmf_typekind_r8, &
1884 staggerloc=esmf_staggerloc_center, &
1885 ungriddedlbound=(/1/), &
1886 ungriddedubound=(/lsoil_input/), rc=rc)
1887 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1890 print*,
"- CALL FieldCreate FOR INPUT TOTAL SOIL MOISTURE."
1891 soilm_tot_input_grid = esmf_fieldcreate(input_grid, &
1892 typekind=esmf_typekind_r8, &
1893 staggerloc=esmf_staggerloc_center, &
1894 ungriddedlbound=(/1/), &
1895 ungriddedubound=(/lsoil_input/), rc=rc)
1896 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1899 print*,
"- CALL FieldCreate FOR INPUT LIQUID SOIL MOISTURE."
1900 soilm_liq_input_grid = esmf_fieldcreate(input_grid, &
1901 typekind=esmf_typekind_r8, &
1902 staggerloc=esmf_staggerloc_center, &
1903 ungriddedlbound=(/1/), &
1904 ungriddedubound=(/lsoil_input/), rc=rc)
1905 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1910 if (localpet == 0)
then
1911 allocate(dummy2d(i_input,j_input))
1912 allocate(slmsk_save(i_input,j_input))
1913 allocate(tsk_save(i_input,j_input))
1914 allocate(icec_save(i_input,j_input))
1915 allocate(dummy2d_8(i_input,j_input))
1916 allocate(dummy2d_82(i_input,j_input))
1917 allocate(dummy3d(i_input,j_input,lsoil_input))
1919 allocate(dummy3d(0,0,0))
1920 allocate(dummy2d_8(0,0))
1921 allocate(dummy2d_82(0,0))
1922 allocate(dummy2d(0,0))
1923 allocate(slmsk_save(0,0))
1931 if (localpet == 0)
then
1933 print*,
"- READ TERRAIN."
1943 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
1944 unpack, k, gfld, rc)
1947 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
1952 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
1953 call esmf_fieldscatter(terrain_input_grid, dummy2d_8, rootpet=0, rc=rc)
1954 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1957 if (localpet == 0)
then
1959 print*,
"- READ SEAICE FRACTION."
1969 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
1970 unpack, k, gfld, rc)
1971 if (rc /= 0) call
error_handler(
"READING SEAICE FRACTION.", rc)
1973 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
1976 icec_save = dummy2d_8
1980 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
1981 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d_8 ,rootpet=0, rc=rc)
1982 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
1993 if (localpet == 0)
then
1995 print*,
"- READ LANDSEA MASK."
2004 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2005 unpack, k, gfld, rc)
2009 print*,
'landnn ', maxval(gfld%fld),minval(gfld%fld)
2020 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2021 unpack, k, gfld, rc)
2022 if (rc /= 0) call
error_handler(
"READING LANDSEA MASK.", rc)
2028 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
2032 if(dummy2d_8(i,j) < 0.5_esmf_kind_r8) dummy2d_8(i,j)=0.0
2033 if(icec_save(i,j) > 0.15_esmf_kind_r8)
then
2034 dummy2d_8(i,j) = 2.0_esmf_kind_r8
2039 slmsk_save = nint(dummy2d_8)
2041 deallocate(icec_save)
2045 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
2046 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d_8 ,rootpet=0, rc=rc)
2047 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2050 if (localpet == 0)
then
2052 print*,
"- READ SEAICE SKIN TEMPERATURE."
2062 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2063 unpack, k, gfld, rc)
2064 if (rc /= 0) call
error_handler(
"READING SEAICE SKIN TEMP.", rc)
2068 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
2072 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
2073 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d_8 ,rootpet=0, rc=rc)
2074 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2083 if (localpet == 0)
then
2085 print*,
"- READ SNOW LIQUID EQUIVALENT."
2096 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2097 unpack, k, gfld, rc)
2098 if (rc /= 0) call
error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
2102 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
2106 if(slmsk_save(i,j) == 0) dummy2d_8(i,j) = 0.0
2112 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
2113 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d_8 ,rootpet=0, rc=rc)
2114 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2117 if (localpet == 0)
then
2119 print*,
"- READ SNOW DEPTH."
2130 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2131 unpack, k, gfld, rc)
2136 gfld%fld = gfld%fld * 1000.0
2138 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
2143 if(slmsk_save(i,j) == 0) dummy2d_8(i,j) = 0.0
2149 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
2150 call esmf_fieldscatter(snow_depth_input_grid,dummy2d_8,rootpet=0, rc=rc)
2151 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2154 if (localpet == 0)
then
2156 print*,
"- READ T2M."
2168 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2169 unpack, k, gfld, rc)
2174 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
2178 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
2179 call esmf_fieldscatter(t2m_input_grid, dummy2d_8, rootpet=0,rc=rc)
2180 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2183 if (localpet == 0)
then
2185 print*,
"- READ Q2M."
2197 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2198 unpack, k, gfld, rc)
2203 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
2207 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
2208 call esmf_fieldscatter(q2m_input_grid,dummy2d_8, rootpet=0,rc=rc)
2209 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2212 if (localpet == 0)
then
2214 print*,
"- READ SKIN TEMPERATURE."
2225 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2226 unpack, k, gfld, rc)
2228 if (rc /= 0 ) call
error_handler(
"READING SKIN TEMPERATURE.", rc)
2231 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
2233 tsk_save(:,:) = dummy2d_8
2237 if(slmsk_save(i,j) == 0 .and. dummy2d_8(i,j) < 271.2)
then
2239 dummy2d_8(i,j) = 271.2
2241 if(slmsk_save(i,j) == 0 .and. dummy2d_8(i,j) > 310.)
then
2243 dummy2d_8(i,j) = 310.0
2250 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
2251 call esmf_fieldscatter(skin_temp_input_grid,dummy2d_8,rootpet=0, rc=rc)
2252 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2257 if (localpet == 0) dummy2d_8 = 0.0
2259 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
2260 call esmf_fieldscatter(srflag_input_grid,dummy2d_8, rootpet=0,rc=rc)
2261 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2264 if (localpet == 0)
then
2266 print*,
"- READ SOIL TYPE."
2277 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2278 unpack, k, gfld, rc)
2282 dummy2d = reshape(
real(gfld%fld,kind=esmf_kind_r4) , (/i_input,j_input/))
2286 if (rc /= 0 .and. (trim(
to_upper(external_model))==
"HRRR" .or. rap_latlon) .and. geo_file .ne.
"NULL")
then
2290 print*,
"OPEN GEOGRID FILE ", trim(geo_file)
2291 rc = nf90_open(geo_file,nf90_nowrite,ncid2d)
2294 print*,
"INQURE ABOUT DIM IDS"
2295 rc = nf90_inq_dimid(ncid2d,
"west_east",varid)
2296 call
netcdf_err(rc,
"READING west_east DIMENSION FROM GEOGRID FILE")
2298 rc = nf90_inquire_dimension(ncid2d,varid,len=varsize)
2299 call
netcdf_err(rc,
"READING west_east DIMENSION SIZE")
2300 if (varsize .ne. i_input) call
error_handler(
"GEOGRID FILE GRID SIZE DIFFERS FROM INPUT DATA.", -1)
2302 print*,
"INQUIRE ABOUT SOIL TYPE FROM GEOGRID FILE"
2303 rc = nf90_inq_varid(ncid2d,
"SCT_DOM",varid)
2304 call
netcdf_err(rc,
"FINDING SCT_DOM IN GEOGRID FILE")
2306 print*,
"READ SOIL TYPE FROM GEOGRID FILE "
2307 rc = nf90_get_var(ncid2d,varid,dummy2d)
2308 call
netcdf_err(rc,
"READING SCT_DOM FROM FILE")
2310 print*,
"INQUIRE ABOUT SOIL TYPE FRACTIONS FROM GEOGRID FILE"
2311 rc = nf90_inq_varid(ncid2d,
"SOILCTOP",varid)
2312 call
netcdf_err(rc,
"FINDING SOILCTOP IN GEOGRID FILE")
2314 allocate(dummy3d_stype(i_input,j_input,16))
2315 print*,
"READ SOIL TYPE FRACTIONS FROM GEOGRID FILE "
2316 rc = nf90_get_var(ncid2d,varid,dummy3d_stype)
2317 call
netcdf_err(rc,
"READING SCT_DOM FROM FILE")
2319 print*,
"CLOSE GEOGRID FILE "
2320 iret = nf90_close(ncid2d)
2325 allocate(dummy1d(16))
2328 if(dummy2d(i,j) == 14.0_esmf_kind_r4 .and. slmsk_save(i,j) == 1)
then
2329 dummy1d(:) =
real(dummy3d_stype(i,j,:),kind=esmf_kind_r4)
2330 dummy1d(14) = 0.0_esmf_kind_r4
2331 dummy2d(i,j) =
real(MAXLOC(dummy1d, 1),esmf_kind_r4)
2336 deallocate(dummy3d_stype)
2339 if ((rc /= 0 .and. trim(
to_upper(external_model)) /=
"HRRR" .and. .not. rap_latlon) &
2340 .or. (rc /= 0 .and. (trim(
to_upper(external_model)) ==
"HRRR" .or. rap_latlon)))
then
2341 if (.not. sotyp_from_climo)
then
2342 call
error_handler(
"COULD NOT FIND SOIL TYPE IN FILE. PLEASE SET SOTYP_FROM_CLIMO=.TRUE. . EXITING", rc)
2346 call
get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=value, &
2348 call
handle_grib_error(vname, slev ,method,value,varnum,read_from_input,rc, var= dummy2d)
2350 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. WILL NOT "//&
2351 "SCALE SOIL MOISTURE FOR DIFFERENCES IN SOIL TYPE. "
2352 dummy2d(:,:) = -99999.0_esmf_kind_r4
2361 if (.not. sotyp_from_climo)
then
2364 if(dummy2d(i,j) == 14.0_esmf_kind_r4 .and. slmsk_save(i,j) == 1) dummy2d(i,j) = -99999.9_esmf_kind_r4
2368 allocate(dummy2d_i(i_input,j_input))
2369 dummy2d_8 =
real(dummy2d,esmf_kind_r8)
2371 where(slmsk_save == 1) dummy2d_i = 1
2373 call
search(dummy2d_8,dummy2d_i,i_input,j_input,1,230)
2374 deallocate(dummy2d_i)
2376 dummy2d_8=
real(dummy2d,esmf_kind_r8)
2379 print*,
'sotype ',maxval(dummy2d_8),minval(dummy2d_8)
2383 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
2384 call esmf_fieldscatter(soil_type_input_grid,dummy2d_8, rootpet=0, rc=rc)
2385 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2395 if (.not. vgfrc_from_climo)
then
2397 if (localpet == 0)
then
2399 print*,
"- READ VEG FRACTION."
2410 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2411 unpack, k, gfld, rc)
2414 err_msg=
"COULD NOT FIND VEGETATION FRACTION IN FILE. PLEASE SET VGFRC_FROM_CLIMO=.TRUE."
2417 if (maxval(gfld%fld) > 2.0) gfld%fld = gfld%fld / 100.0
2419 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
2425 print*,
"- CALL FieldScatter FOR INPUT GRID VEG GREENNESS."
2426 call esmf_fieldscatter(veg_greenness_input_grid,dummy2d_8, rootpet=0, rc=rc)
2427 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2432 if (.not. minmax_vgfrc_from_climo)
then
2434 if (localpet == 0)
then
2436 print*,
"- READ MIN VEG FRACTION."
2448 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2449 unpack, k, gfld, rc)
2453 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2454 unpack, k, gfld, rc)
2457 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2458 unpack, k, gfld, rc)
2459 err_msg=
"COULD NOT FIND MIN VEGETATION FRACTION IN FILE. SET MINMAX_VGFRC_FROM_CLIMO=.TRUE."
2464 if (maxval(gfld%fld) > 2.0) gfld%fld = gfld%fld / 100.0
2465 print*,
'vfrac min ', maxval(gfld%fld),minval(gfld%fld)
2466 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
2470 print*,
"- CALL FieldScatter FOR INPUT GRID MIN VEG GREENNESS."
2471 call esmf_fieldscatter(min_veg_greenness_input_grid,dummy2d_8, rootpet=0, rc=rc)
2472 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2475 if (localpet == 0)
then
2477 print*,
"- READ MAX VEG FRACTION."
2488 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2489 unpack, k, gfld, rc)
2492 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2493 unpack, k, gfld, rc)
2496 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2497 unpack, k, gfld, rc)
2498 err_msg=
"COULD NOT FIND MAX VEGETATION FRACTION IN FILE. SET MINMAX_VGFRC_FROM_CLIMO=.TRUE."
2503 if (maxval(gfld%fld) > 2.0) gfld%fld = gfld%fld / 100.0
2505 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
2509 print*,
"- CALL FieldScatter FOR INPUT GRID MAX VEG GREENNESS."
2510 call esmf_fieldscatter(max_veg_greenness_input_grid,dummy2d_8,rootpet=0, rc=rc)
2511 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2516 if (.not. lai_from_climo)
then
2518 if (localpet == 0)
then
2520 print*,
"- READ LAI."
2531 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2532 unpack, k, gfld, rc)
2534 err_msg=
"COULD NOT FIND LAI IN FILE. SET LAI_FROM_CLIMO=.TRUE."
2538 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
2542 print*,
"- CALL FieldScatter FOR INPUT GRID LAI."
2543 call esmf_fieldscatter(lai_input_grid,dummy2d_8,rootpet=0, rc=rc)
2544 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2549 if (localpet == 0)
then
2551 print*,
"- READ SEAICE DEPTH."
2554 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
2566 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2567 unpack, k, gfld, rc)
2570 call
handle_grib_error(vname, slev ,method,value,varnum,read_from_input,rc,var8=dummy2d_8)
2572 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL BE"//&
2573 " REPLACED WITH CLIMO. SET A FILL "// &
2574 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
2575 dummy2d_8(:,:) = 0.0
2579 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
2584 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
2585 call esmf_fieldscatter(seaice_depth_input_grid,dummy2d_8, rootpet=0, rc=rc)
2586 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2589 if (localpet == 0)
then
2591 print*,
"- READ TPRCP."
2594 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
2600 call
handle_grib_error(vname, slev ,method,value,varnum,read_from_input,rc, var8=dummy2d_8)
2602 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
2603 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
2604 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
2608 print*,
'tprcp ',maxval(dummy2d_8),minval(dummy2d_8)
2612 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
2613 call esmf_fieldscatter(tprcp_input_grid,dummy2d_8, rootpet=0, rc=rc)
2614 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2617 if (localpet == 0)
then
2619 print*,
"- READ FFMM."
2622 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
2628 call
handle_grib_error(vname, slev ,method,value,varnum,read_from_input,rc, var8=dummy2d_8)
2630 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
2631 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
2632 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
2633 dummy2d_8(:,:) = 0.0
2636 print*,
'ffmm ',maxval(dummy2d_8),minval(dummy2d_8)
2640 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
2641 call esmf_fieldscatter(ffmm_input_grid,dummy2d_8, rootpet=0, rc=rc)
2642 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2645 if (localpet == 0)
then
2647 print*,
"- READ USTAR."
2650 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
2662 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2663 unpack, k, gfld, rc)
2666 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2667 unpack, k, gfld, rc)
2672 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
2674 call
handle_grib_error(vname, slev ,method,value,varnum,read_from_input,rc, var8=dummy2d_8)
2676 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL "//&
2677 "REPLACED WITH CLIMO. SET A FILL "// &
2678 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
2679 dummy2d_8(:,:) = 0.0
2685 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
2686 call esmf_fieldscatter(ustar_input_grid,dummy2d_8, rootpet=0, rc=rc)
2687 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2690 if (localpet == 0)
then
2692 print*,
"- READ F10M."
2694 slev=
":10 m above ground:"
2695 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
2700 call
handle_grib_error(vname, slev ,method,value,varnum,read_from_input,rc, var8=dummy2d_8)
2702 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
2703 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
2704 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
2705 dummy2d_8(:,:) = 0.0
2708 print*,
'f10m ',maxval(dummy2d_8),minval(dummy2d_8)
2712 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
2713 call esmf_fieldscatter(f10m_input_grid,dummy2d_8, rootpet=0, rc=rc)
2714 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2717 if (localpet == 0)
then
2719 print*,
"- READ CANOPY MOISTURE CONTENT."
2722 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
2734 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2735 unpack, k, gfld, rc)
2739 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2740 unpack, k, gfld, rc)
2744 print*,
'cnwat ', maxval(gfld%fld),minval(gfld%fld)
2745 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
2748 call
handle_grib_error(vname, slev ,method,value,varnum,read_from_input,rc, var8=dummy2d_8)
2750 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL"//&
2751 " REPLACED WITH CLIMO. SET A FILL "// &
2752 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
2759 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
2760 call esmf_fieldscatter(canopy_mc_input_grid,dummy2d_8, rootpet=0, rc=rc)
2761 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2764 if (localpet == 0)
then
2769 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
2781 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2782 unpack, k, gfld, rc)
2785 call
handle_grib_error(vname, slev ,method,value,varnum,read_from_input,rc, var8= dummy2d_8)
2787 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL BE"//&
2788 " REPLACED WITH CLIMO. SET A FILL "// &
2789 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
2790 dummy2d_8(:,:) = 0.0
2793 gfld%fld = gfld%fld * 10.0
2795 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
2800 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
2801 call esmf_fieldscatter(z0_input_grid,dummy2d_8, rootpet=0, rc=rc)
2802 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2805 if (localpet == 0)
then
2806 print*,
"- READ LIQUID SOIL MOISTURE."
2808 vname_file =
":SOILL:"
2813 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
2814 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
2815 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2818 if (localpet == 0)
then
2819 print*,
"- READ TOTAL SOIL MOISTURE."
2821 vname_file =
"var2_2_1_"
2825 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
2826 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
2827 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2836 print*,
"- CALL FieldGather for INPUT SOIL TYPE."
2837 call esmf_fieldgather(soil_type_input_grid, dummy2d_82, rootpet=0, tile=1, rc=rc)
2838 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2841 if (localpet == 0)
then
2843 print*,
"- READ VEG TYPE."
2854 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2855 unpack, k, gfld, rc)
2858 if (.not. vgtyp_from_climo)
then
2859 call
error_handler(
"COULD NOT FIND VEGETATION TYPE IN FILE. PLEASE SET VGTYP_FROM_CLIMO=.TRUE. . EXITING", rc)
2863 dummy2d_8(i,j) = 0.0
2864 if(slmsk_save(i,j) == 1 .and. dummy3d(i,j,1) > 0.99) &
2866 dummy2d_8(i,j) =
real(veg_type_landice_input,esmf_kind_r8)
2871 dummy2d_8 = reshape(gfld%fld , (/i_input,j_input/))
2874 if (trim(external_model) .ne.
"GFS")
then
2877 if (dummy2d_8(i,j) == 15.0_esmf_kind_r8 .and. slmsk_save(i,j) == 1)
then
2878 if (dummy3d(i,j,1) < 0.6)
then
2879 dummy2d_8(i,j) =
real(veg_type_landice_input,esmf_kind_r8)
2880 elseif (dummy3d(i,j,1) > 0.99)
then
2882 dummy2d_8(i,j) = 0.0_esmf_kind_r8
2883 dummy2d_82(i,j) = 0.0_esmf_kind_r8
2885 elseif (dummy2d_8(i,j) == 17.0_esmf_kind_r8 .and. slmsk_save(i,j)==0)
then
2886 dummy2d_8(i,j) = 0.0_esmf_kind_r8
2896 print*,
"- CALL FieldScatter FOR INPUT VEG TYPE."
2897 call esmf_fieldscatter(veg_type_input_grid, dummy2d_8, rootpet=0, rc=rc)
2898 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2901 print*,
"- CALL FieldScatter FOR INPUT SOIL TYPE."
2902 call esmf_fieldscatter(soil_type_input_grid, dummy2d_82, rootpet=0, rc=rc)
2903 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2906 deallocate(dummy2d_82)
2908 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
2909 call esmf_fieldscatter(landsea_mask_input_grid,
real(slmsk_save,esmf_kind_r8),rootpet=0, rc=rc)
2910 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2920 if (localpet == 0)
then
2921 print*,
"- READ SOIL TEMPERATURE."
2923 vname_file =
":TSOIL:"
2925 call
check_soilt(dummy3d,slmsk_save,tsk_save,icet_default,i_input,j_input,lsoil_input)
2926 deallocate(tsk_save)
2929 deallocate(slmsk_save)
2931 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
2932 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
2933 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2937 deallocate(dummy2d_8)
2939 if (localpet == 0) call baclose(lugb, rc)
2952 print*,
"- CALL FieldCreate FOR INPUT GRID LANDSEA MASK."
2953 landsea_mask_input_grid = esmf_fieldcreate(input_grid, &
2954 typekind=esmf_typekind_r8, &
2955 staggerloc=esmf_staggerloc_center, rc=rc)
2956 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2959 print*,
"- CALL FieldCreate FOR INPUT GRID Z0."
2960 z0_input_grid = esmf_fieldcreate(input_grid, &
2961 typekind=esmf_typekind_r8, &
2962 staggerloc=esmf_staggerloc_center, rc=rc)
2963 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2966 print*,
"- CALL FieldCreate FOR INPUT GRID VEGETATION TYPE."
2967 veg_type_input_grid = esmf_fieldcreate(input_grid, &
2968 typekind=esmf_typekind_r8, &
2969 staggerloc=esmf_staggerloc_center, rc=rc)
2970 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2973 print*,
"- CALL FieldCreate FOR INPUT GRID CANOPY MOISTURE CONTENT."
2974 canopy_mc_input_grid = esmf_fieldcreate(input_grid, &
2975 typekind=esmf_typekind_r8, &
2976 staggerloc=esmf_staggerloc_center, rc=rc)
2977 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2980 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE FRACTION."
2981 seaice_fract_input_grid = esmf_fieldcreate(input_grid, &
2982 typekind=esmf_typekind_r8, &
2983 staggerloc=esmf_staggerloc_center, rc=rc)
2984 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2987 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE DEPTH."
2988 seaice_depth_input_grid = esmf_fieldcreate(input_grid, &
2989 typekind=esmf_typekind_r8, &
2990 staggerloc=esmf_staggerloc_center, rc=rc)
2991 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2994 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE SKIN TEMPERATURE."
2995 seaice_skin_temp_input_grid = esmf_fieldcreate(input_grid, &
2996 typekind=esmf_typekind_r8, &
2997 staggerloc=esmf_staggerloc_center, rc=rc)
2998 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3001 print*,
"- CALL FieldCreate FOR INPUT GRID SNOW DEPTH."
3002 snow_depth_input_grid = esmf_fieldcreate(input_grid, &
3003 typekind=esmf_typekind_r8, &
3004 staggerloc=esmf_staggerloc_center, rc=rc)
3005 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3008 print*,
"- CALL FieldCreate FOR INPUT GRID SNOW LIQUID EQUIVALENT."
3009 snow_liq_equiv_input_grid = esmf_fieldcreate(input_grid, &
3010 typekind=esmf_typekind_r8, &
3011 staggerloc=esmf_staggerloc_center, rc=rc)
3012 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3015 print*,
"- CALL FieldCreate FOR INPUT GRID T2M."
3016 t2m_input_grid = esmf_fieldcreate(input_grid, &
3017 typekind=esmf_typekind_r8, &
3018 staggerloc=esmf_staggerloc_center, rc=rc)
3019 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3022 print*,
"- CALL FieldCreate FOR INPUT GRID Q2M."
3023 q2m_input_grid = esmf_fieldcreate(input_grid, &
3024 typekind=esmf_typekind_r8, &
3025 staggerloc=esmf_staggerloc_center, rc=rc)
3026 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3029 print*,
"- CALL FieldCreate FOR INPUT GRID TPRCP."
3030 tprcp_input_grid = esmf_fieldcreate(input_grid, &
3031 typekind=esmf_typekind_r8, &
3032 staggerloc=esmf_staggerloc_center, rc=rc)
3033 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3036 print*,
"- CALL FieldCreate FOR INPUT GRID F10M."
3037 f10m_input_grid = esmf_fieldcreate(input_grid, &
3038 typekind=esmf_typekind_r8, &
3039 staggerloc=esmf_staggerloc_center, rc=rc)
3040 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3043 print*,
"- CALL FieldCreate FOR INPUT GRID USTAR."
3044 ustar_input_grid = esmf_fieldcreate(input_grid, &
3045 typekind=esmf_typekind_r8, &
3046 staggerloc=esmf_staggerloc_center, rc=rc)
3047 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3050 print*,
"- CALL FieldCreate FOR INPUT GRID FFMM."
3051 ffmm_input_grid = esmf_fieldcreate(input_grid, &
3052 typekind=esmf_typekind_r8, &
3053 staggerloc=esmf_staggerloc_center, rc=rc)
3054 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3057 print*,
"- CALL FieldCreate FOR INPUT GRID SRFLAG."
3058 srflag_input_grid = esmf_fieldcreate(input_grid, &
3059 typekind=esmf_typekind_r8, &
3060 staggerloc=esmf_staggerloc_center, rc=rc)
3061 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3064 print*,
"- CALL FieldCreate FOR INPUT SKIN TEMPERATURE."
3065 skin_temp_input_grid = esmf_fieldcreate(input_grid, &
3066 typekind=esmf_typekind_r8, &
3067 staggerloc=esmf_staggerloc_center, rc=rc)
3068 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3071 print*,
"- CALL FieldCreate FOR INPUT SOIL TYPE."
3072 soil_type_input_grid = esmf_fieldcreate(input_grid, &
3073 typekind=esmf_typekind_r8, &
3074 staggerloc=esmf_staggerloc_center, rc=rc)
3075 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3078 print*,
"- CALL FieldCreate FOR INPUT TERRAIN."
3079 terrain_input_grid = esmf_fieldcreate(input_grid, &
3080 typekind=esmf_typekind_r8, &
3081 staggerloc=esmf_staggerloc_center, rc=rc)
3082 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3085 print*,
"- CALL FieldCreate FOR INPUT SOIL TEMPERATURE."
3086 soil_temp_input_grid = esmf_fieldcreate(input_grid, &
3087 typekind=esmf_typekind_r8, &
3088 staggerloc=esmf_staggerloc_center, &
3089 ungriddedlbound=(/1/), &
3090 ungriddedubound=(/lsoil_input/), rc=rc)
3091 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3094 print*,
"- CALL FieldCreate FOR INPUT TOTAL SOIL MOISTURE."
3095 soilm_tot_input_grid = esmf_fieldcreate(input_grid, &
3096 typekind=esmf_typekind_r8, &
3097 staggerloc=esmf_staggerloc_center, &
3098 ungriddedlbound=(/1/), &
3099 ungriddedubound=(/lsoil_input/), rc=rc)
3100 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3103 print*,
"- CALL FieldCreate FOR INPUT LIQUID SOIL MOISTURE."
3104 soilm_liq_input_grid = esmf_fieldcreate(input_grid, &
3105 typekind=esmf_typekind_r8, &
3106 staggerloc=esmf_staggerloc_center, &
3107 ungriddedlbound=(/1/), &
3108 ungriddedubound=(/lsoil_input/), rc=rc)
3109 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3114 if (.not. vgfrc_from_climo)
then
3115 print*,
"- CALL FieldCreate FOR INPUT VEGETATION GREENNESS."
3116 veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
3117 typekind=esmf_typekind_r8, &
3118 staggerloc=esmf_staggerloc_center, rc=rc)
3119 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3123 if (.not. minmax_vgfrc_from_climo)
then
3124 print*,
"- CALL FieldCreate FOR INPUT MIN VEGETATION GREENNESS."
3125 min_veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
3126 typekind=esmf_typekind_r8, &
3127 staggerloc=esmf_staggerloc_center, rc=rc)
3128 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3131 print*,
"- CALL FieldCreate FOR INPUT MAX VEGETATION GREENNESS."
3132 max_veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
3133 typekind=esmf_typekind_r8, &
3134 staggerloc=esmf_staggerloc_center, rc=rc)
3135 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3139 if (.not. lai_from_climo)
then
3140 print*,
"- CALL FieldCreate FOR INPUT LEAF AREA INDEX."
3141 lai_input_grid = esmf_fieldcreate(input_grid, &
3142 typekind=esmf_typekind_r8, &
3143 staggerloc=esmf_staggerloc_center, rc=rc)
3144 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3160 sfcdata, sfcdata_3d)
3164 CHARACTER(LEN=*),
INTENT(IN) :: field
3166 INTEGER,
INTENT(IN) :: imo, jmo, lmo, tile_num
3168 REAL(ESMF_KIND_R8),
INTENT(OUT),
OPTIONAL :: sfcdata(imo,jmo)
3169 REAL(ESMF_KIND_R8),
INTENT(OUT),
OPTIONAL :: sfcdata_3d(imo,jmo,lmo)
3171 CHARACTER(LEN=256) :: tilefile
3173 INTEGER :: error, ncid, id_var
3175 tilefile = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(tile_num))
3177 print*,
'WILL READ ',trim(field),
' FROM: ', trim(tilefile)
3179 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
3180 CALL
netcdf_err(error,
'OPENING: '//trim(tilefile) )
3182 error=nf90_inq_varid(ncid, field, id_var)
3185 IF (present(sfcdata_3d))
THEN
3186 error=nf90_get_var(ncid, id_var, sfcdata_3d)
3189 error=nf90_get_var(ncid, id_var, sfcdata)
3193 error = nf90_close(ncid)
3211 character(len=20),
intent(in) :: vname,vname_file
3213 integer,
intent(in) :: lugb, pdt_num
3215 real(esmf_kind_r8),
intent(inout) :: dummy3d(:,:,:)
3217 character(len=50) :: slevs(lsoil_input)
3218 character(len=50) :: method
3220 integer :: varnum, i, j, k, rc, rc2
3221 integer :: jdisc, jgdtn, jpdtn, lugi
3222 integer :: jids(200), jgdt(200), jpdt(200)
3223 integer :: iscale1, iscale2
3227 real(esmf_kind_r4),
allocatable :: dummy2d(:,:)
3228 real(esmf_kind_r4) :: value
3230 type(gribfield
) :: gfld
3232 allocate(dummy2d(i_input,j_input))
3234 if(lsoil_input == 4)
then
3235 slevs = (/
character(24)::
':0-0.1 m below ground:',
':0.1-0.4 m below ground:', &
3236 ':0.4-1 m below ground:',
':1-2 m below ground:'/)
3237 elseif(lsoil_input == 9)
then
3238 slevs = (/
character(26)::
':0-0 m below ground',
':0.01-0.01 m below ground:',
':0.04-0.04 m below ground:', &
3239 ':0.1-0.1 m below ground:',
':0.3-0.3 m below ground:',
':0.6-0.6 m below ground:', &
3240 ':1-1 m below ground:',
':1.6-1.6 m below ground:',
':3-3 m below ground:'/)
3243 call
error_handler(
"reading soil levels. File must have 4 or 9 soil levels.", rc)
3246 call
get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=value, &
3258 if (trim(vname) ==
'soilt') jpdt(2) = 2
3259 if (trim(vname) ==
'soilw') jpdt(2) = 192
3260 if (trim(vname) ==
'soill')
then
3268 do i = 1,lsoil_input
3270 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
3271 unpack, k, gfld, rc2)
3274 call
handle_grib_error(vname_file, slevs(i),method,value,varnum,read_from_input,rc,var=dummy2d)
3275 if (rc==1 .and. trim(vname) /=
"soill")
then
3277 call
error_handler(
"READING IN "//trim(vname)//
". SET A FILL "// &
3278 "VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",rc)
3280 dummy3d(:,:,:) = 0.0_esmf_kind_r8
3286 iscale1 = 10 ** gfld%ipdtmpl(11)
3287 iscale2 = 10 ** gfld%ipdtmpl(14)
3290 dummy2d = reshape(
real(gfld%fld,kind=esmf_kind_r4), (/i_input,j_input/) )
3295 dummy3d(:,:,i) =
real(dummy2d,esmf_kind_r8)
3312 print*,
"- CALL FieldDestroy FOR INPUT GRID FIELDS."
3314 call esmf_fielddestroy(canopy_mc_input_grid, rc=rc)
3315 call esmf_fielddestroy(f10m_input_grid, rc=rc)
3316 call esmf_fielddestroy(ffmm_input_grid, rc=rc)
3317 if (.not. convert_nst)
then
3318 call esmf_fielddestroy(landsea_mask_input_grid, rc=rc)
3320 call esmf_fielddestroy(q2m_input_grid, rc=rc)
3321 call esmf_fielddestroy(seaice_depth_input_grid, rc=rc)
3322 call esmf_fielddestroy(seaice_fract_input_grid, rc=rc)
3323 call esmf_fielddestroy(seaice_skin_temp_input_grid, rc=rc)
3324 call esmf_fielddestroy(skin_temp_input_grid, rc=rc)
3325 call esmf_fielddestroy(snow_depth_input_grid, rc=rc)
3326 call esmf_fielddestroy(snow_liq_equiv_input_grid, rc=rc)
3327 call esmf_fielddestroy(soil_temp_input_grid, rc=rc)
3328 call esmf_fielddestroy(soil_type_input_grid, rc=rc)
3329 call esmf_fielddestroy(soilm_liq_input_grid, rc=rc)
3330 call esmf_fielddestroy(soilm_tot_input_grid, rc=rc)
3331 call esmf_fielddestroy(srflag_input_grid, rc=rc)
3332 call esmf_fielddestroy(t2m_input_grid, rc=rc)
3333 call esmf_fielddestroy(tprcp_input_grid, rc=rc)
3334 call esmf_fielddestroy(ustar_input_grid, rc=rc)
3335 call esmf_fielddestroy(veg_type_input_grid, rc=rc)
3336 call esmf_fielddestroy(z0_input_grid, rc=rc)
3337 call esmf_fielddestroy(terrain_input_grid, rc=rc)
3338 if (.not. vgfrc_from_climo)
then
3339 call esmf_fielddestroy(veg_greenness_input_grid, rc=rc)
3341 if (.not. minmax_vgfrc_from_climo)
then
3342 call esmf_fielddestroy(min_veg_greenness_input_grid, rc=rc)
3343 call esmf_fielddestroy(max_veg_greenness_input_grid, rc=rc)
3345 if (.not. lai_from_climo)
then
3346 call esmf_fielddestroy(lai_input_grid, rc=rc)
subroutine check_cnwat(cnwat, i_input, j_input)
When using GEFS data, some points on the target grid have unreasonable canpy moisture content...
subroutine netcdf_err(err, string)
Error handler for netcdf.
Sets up the ESMF grid objects for the input data grid and target FV3 grid.
subroutine handle_grib_error(vname, lev, method, value, varnum, read_from_input, iret, var, var8, var3d)
Handle GRIB2 read error based on the user selected method in the varmap file.
Replace undefined values with a valid value.
subroutine error_handler(string, rc)
General error handler.
This module contains code to read the setup namelist file, handle the varmap file for GRIB2 data...
subroutine, public get_var_cond(var_name, this_miss_var_method, this_miss_var_value, this_field_var_name, loc)
Search the variable mapping table to find conditions for handling missing variables.
subroutine, public search(field, mask, idim, jdim, tile, field_num, latitude, terrain_land, soilt_climo)
Replace undefined surface values.
subroutine check_soilt(soilt, landmask, skint, ICET_DEFAULT, i_input, j_input, lsoil_input)
Check for and replace certain values in soil temperature.
character(len=len(strin)) function to_upper(strIn)
Convert string from lower to uppercase.