41 use utilities,
only : error_handler, &
50 integer,
public :: veg_type_landice_input = 15
53 real :: icet_default = 265.0
55 type(esmf_field),
public :: canopy_mc_input_grid
56 type(esmf_field),
public :: f10m_input_grid
57 type(esmf_field),
public :: ffmm_input_grid
59 type(esmf_field),
public :: landsea_mask_input_grid
61 type(esmf_field),
public :: q2m_input_grid
62 type(esmf_field),
public :: seaice_depth_input_grid
63 type(esmf_field),
public :: seaice_fract_input_grid
64 type(esmf_field),
public :: seaice_skin_temp_input_grid
65 type(esmf_field),
public :: skin_temp_input_grid
66 type(esmf_field),
public :: snow_depth_input_grid
67 type(esmf_field),
public :: snow_liq_equiv_input_grid
68 type(esmf_field),
public :: soil_temp_input_grid
69 type(esmf_field),
public :: soil_type_input_grid
70 type(esmf_field),
public :: soilm_liq_input_grid
71 type(esmf_field),
public :: soilm_tot_input_grid
72 type(esmf_field),
public :: srflag_input_grid
73 type(esmf_field),
public :: t2m_input_grid
74 type(esmf_field),
public :: tprcp_input_grid
75 type(esmf_field),
public :: ustar_input_grid
76 type(esmf_field),
public :: veg_type_input_grid
77 type(esmf_field),
public :: z0_input_grid
78 type(esmf_field),
public :: veg_greenness_input_grid
79 type(esmf_field),
public :: lai_input_grid
80 type(esmf_field),
public :: max_veg_greenness_input_grid
81 type(esmf_field),
public :: min_veg_greenness_input_grid
83 integer,
public :: lsoil_input=4
86 public :: read_input_sfc_data
87 public :: cleanup_input_sfc_data
88 public :: init_sfc_esmf_fields
96 subroutine read_input_sfc_data(localpet)
100 integer,
intent(in) :: localpet
102 call init_sfc_esmf_fields()
110 call read_input_sfc_restart_file(localpet)
117 "gaussian_netcdf")
then
119 call read_input_sfc_netcdf_file(localpet)
126 elseif (trim(
input_type) ==
"gaussian_nemsio")
then
128 call read_input_sfc_gaussian_nemsio_file(localpet)
134 elseif (trim(
input_type) ==
"gfs_gaussian_nemsio")
then
136 call read_input_sfc_gfs_gaussian_nemsio_file(localpet)
144 call read_input_sfc_gfs_sfcio_file(localpet)
153 call read_input_sfc_grib2_file(localpet)
157 end subroutine read_input_sfc_data
167 subroutine read_input_sfc_gfs_sfcio_file(localpet)
173 integer,
intent(in) :: localpet
175 character(len=300) :: the_file
177 integer(sfcio_intkind) :: iret
180 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
181 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
183 type(sfcio_head) :: sfchead
184 type(sfcio_dbta) :: sfcdata
188 print*,
"- READ SURFACE DATA IN SFCIO FORMAT."
189 print*,
"- OPEN AND READ: ",trim(the_file)
190 call sfcio_sropen(23, trim(the_file), iret)
193 call error_handler(
"OPENING FILE", rc)
196 call sfcio_srhead(23, sfchead, iret)
199 call error_handler(
"READING HEADER", rc)
202 if (localpet == 0)
then
203 call sfcio_aldbta(sfchead, sfcdata, iret)
206 call error_handler(
"ALLOCATING DATA.", rc)
208 call sfcio_srdbta(23, sfchead, sfcdata, iret)
211 call error_handler(
"READING DATA.", rc)
216 allocate(dummy2d(0,0))
217 allocate(dummy3d(0,0,0))
220 if (localpet == 0) dummy2d = sfcdata%slmsk
222 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
223 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
224 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
225 call error_handler(
"IN FieldScatter", rc)
227 if (localpet == 0) dummy2d = sfcdata%zorl
229 print*,
"- CALL FieldScatter FOR INPUT Z0."
230 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
231 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
232 call error_handler(
"IN FieldScatter", rc)
234 if (localpet == 0) dummy2d = nint(sfcdata%vtype)
236 print*,
"- CALL FieldScatter FOR INPUT VEG TYPE."
237 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
238 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
239 call error_handler(
"IN FieldScatter", rc)
242 veg_type_landice_input = 13
244 if (localpet == 0) dummy2d = sfcdata%canopy
246 print*,
"- CALL FieldScatter FOR INPUT CANOPY MC."
247 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
248 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
249 call error_handler(
"IN FieldScatter", rc)
251 if (localpet == 0) dummy2d = sfcdata%fice
253 print*,
"- CALL FieldScatter FOR INPUT ICE FRACTION."
254 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
255 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
256 call error_handler(
"IN FieldScatter", rc)
258 if (localpet == 0) dummy2d = sfcdata%hice
260 print*,
"- CALL FieldScatter FOR INPUT ICE DEPTH."
261 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
262 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
263 call error_handler(
"IN FieldScatter", rc)
265 if (localpet == 0) dummy2d = sfcdata%tisfc
267 print*,
"- CALL FieldScatter FOR INPUT ICE SKIN TEMP."
268 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
269 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
270 call error_handler(
"IN FieldScatter", rc)
272 if (localpet == 0) dummy2d = sfcdata%snwdph
274 print*,
"- CALL FieldScatter FOR INPUT SNOW DEPTH."
275 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
276 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
277 call error_handler(
"IN FieldScatter", rc)
279 if (localpet == 0) dummy2d = sfcdata%sheleg
281 print*,
"- CALL FieldScatter FOR INPUT SNOW LIQUID EQUIV."
282 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
283 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
284 call error_handler(
"IN FieldScatter", rc)
286 if (localpet == 0) dummy2d = sfcdata%t2m
288 print*,
"- CALL FieldScatter FOR INPUT T2M."
289 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
290 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
291 call error_handler(
"IN FieldScatter", rc)
293 if (localpet == 0) dummy2d = sfcdata%q2m
295 print*,
"- CALL FieldScatter FOR INPUT Q2M."
296 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
297 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
298 call error_handler(
"IN FieldScatter", rc)
300 if (localpet == 0) dummy2d = sfcdata%tprcp
302 print*,
"- CALL FieldScatter FOR INPUT TPRCP."
303 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
304 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
305 call error_handler(
"IN FieldScatter", rc)
307 if (localpet == 0) dummy2d = sfcdata%f10m
309 print*,
"- CALL FieldScatter FOR INPUT F10M."
310 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
311 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
312 call error_handler(
"IN FieldScatter", rc)
314 if (localpet == 0) dummy2d = sfcdata%uustar
316 print*,
"- CALL FieldScatter FOR INPUT USTAR."
317 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
318 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
319 call error_handler(
"IN FieldScatter", rc)
321 if (localpet == 0) dummy2d = sfcdata%ffmm
323 print*,
"- CALL FieldScatter FOR INPUT FFMM."
324 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
325 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
326 call error_handler(
"IN FieldScatter", rc)
328 if (localpet == 0) dummy2d = sfcdata%srflag
330 print*,
"- CALL FieldScatter FOR INPUT SRFLAG."
331 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
332 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
333 call error_handler(
"IN FieldScatter", rc)
335 if (localpet == 0) dummy2d = sfcdata%tsea
337 print*,
"- CALL FieldScatter FOR INPUT SKIN TEMP."
338 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
339 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
340 call error_handler(
"IN FieldScatter", rc)
342 if (localpet == 0) dummy2d = nint(sfcdata%stype)
344 print*,
"- CALL FieldScatter FOR INPUT SOIL TYPE."
345 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
346 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
347 call error_handler(
"IN FieldScatter", rc)
349 if (localpet == 0) dummy2d = sfcdata%orog
351 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
353 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
354 call error_handler(
"IN FieldScatter", rc)
356 if (localpet == 0) dummy3d = sfcdata%slc
358 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
359 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
360 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
361 call error_handler(
"IN FieldScatter", rc)
363 if (localpet == 0) dummy3d = sfcdata%smc
365 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
366 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
367 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
368 call error_handler(
"IN FieldScatter", rc)
370 if (localpet == 0) dummy3d = sfcdata%stc
372 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
373 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
374 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
375 call error_handler(
"IN FieldScatter", rc)
377 deallocate(dummy2d, dummy3d)
378 call sfcio_axdbta(sfcdata, iret)
380 call sfcio_sclose(23, iret)
382 end subroutine read_input_sfc_gfs_sfcio_file
393 subroutine read_input_sfc_gfs_gaussian_nemsio_file(localpet)
397 integer,
intent(in) :: localpet
399 character(len=300) :: the_file
403 real(nemsio_realkind),
allocatable :: dummy(:)
404 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
405 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
407 type(nemsio_gfile) :: gfile
411 if (localpet == 0)
then
415 print*,
"- OPEN FILE ", trim(the_file)
416 call nemsio_open(gfile, the_file,
"read", iret=rc)
417 if (rc /= 0)
call error_handler(
"OPENING FILE.", rc)
419 allocate(dummy3d(0,0,0))
420 allocate(dummy2d(0,0))
424 if (localpet == 0)
then
425 print*,
"- READ TERRAIN."
426 call nemsio_readrecv(gfile,
"orog",
"sfc", 1, dummy, 0, iret=rc)
427 if (rc /= 0)
call error_handler(
"READING TERRAIN.", rc)
429 print*,
'orog ',maxval(dummy2d),minval(dummy2d)
432 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
434 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
435 call error_handler(
"IN FieldScatter", rc)
437 if (localpet == 0)
then
438 print*,
"- READ LANDSEA MASK."
439 call nemsio_readrecv(gfile,
"land",
"sfc", 1, dummy, 0, iret=rc)
440 if (rc /= 0)
call error_handler(
"READING LANDSEA MASK.", rc)
442 print*,
'landmask ',maxval(dummy2d),minval(dummy2d)
445 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
446 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
447 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
448 call error_handler(
"IN FieldScatter", rc)
450 if (localpet == 0)
then
451 print*,
"- READ SEAICE FRACTION."
452 call nemsio_readrecv(gfile,
"icec",
"sfc", 1, dummy, 0, iret=rc)
453 if (rc /= 0)
call error_handler(
"READING SEAICE FRACTION.", rc)
455 print*,
'icec ',maxval(dummy2d),minval(dummy2d)
458 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
459 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
460 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
461 call error_handler(
"IN FieldScatter", rc)
463 if (localpet == 0)
then
464 print*,
"- READ SEAICE DEPTH."
465 call nemsio_readrecv(gfile,
"icetk",
"sfc", 1, dummy, 0, iret=rc)
466 if (rc /= 0)
call error_handler(
"READING SEAICE DEPTH.", rc)
468 print*,
'icetk ',maxval(dummy2d),minval(dummy2d)
471 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
472 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
473 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
474 call error_handler(
"IN FieldScatter", rc)
476 if (localpet == 0)
then
477 print*,
"- READ SEAICE SKIN TEMPERATURE."
478 call nemsio_readrecv(gfile,
"tisfc",
"sfc", 1, dummy, 0, iret=rc)
479 if (rc /= 0)
call error_handler(
"READING SEAICE SKIN TEMP.", rc)
481 print*,
'ti ',maxval(dummy2d),minval(dummy2d)
484 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
485 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
486 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
487 call error_handler(
"IN FieldScatter", rc)
489 if (localpet == 0)
then
490 print*,
"- READ SNOW LIQUID EQUIVALENT."
491 call nemsio_readrecv(gfile,
"weasd",
"sfc", 1, dummy, 0, iret=rc)
492 if (rc /= 0)
call error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
494 print*,
'weasd ',maxval(dummy2d),minval(dummy2d)
497 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
498 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
499 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
500 call error_handler(
"IN FieldScatter", rc)
502 if (localpet == 0)
then
503 print*,
"- READ SNOW DEPTH."
504 call nemsio_readrecv(gfile,
"snod",
"sfc", 1, dummy, 0, iret=rc)
505 if (rc /= 0)
call error_handler(
"READING SNOW DEPTH.", rc)
507 print*,
'snod ',maxval(dummy2d),minval(dummy2d)
510 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
511 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
512 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
513 call error_handler(
"IN FieldScatter", rc)
515 if (localpet == 0)
then
516 print*,
"- READ VEG TYPE."
517 call nemsio_readrecv(gfile,
"vtype",
"sfc", 1, dummy, 0, iret=rc)
518 if (rc /= 0)
call error_handler(
"READING VEG TYPE", rc)
520 print*,
'vtype ',maxval(dummy2d),minval(dummy2d)
523 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
524 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
525 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
526 call error_handler(
"IN FieldScatter", rc)
528 if (localpet == 0)
then
529 print*,
"- READ SOIL TYPE."
530 call nemsio_readrecv(gfile,
"sotyp",
"sfc", 1, dummy, 0, iret=rc)
531 if (rc /= 0)
call error_handler(
"READING SOIL TYPE.", rc)
533 print*,
'sotype ',maxval(dummy2d),minval(dummy2d)
536 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
537 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
538 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
539 call error_handler(
"IN FieldScatter", rc)
541 if (localpet == 0)
then
543 call nemsio_readrecv(gfile,
"tmp",
"2 m above gnd", 1, dummy, 0, iret=rc)
544 if (rc /= 0)
call error_handler(
"READING T2M.", rc)
546 print*,
't2m ',maxval(dummy2d),minval(dummy2d)
549 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
550 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
551 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
552 call error_handler(
"IN FieldScatter", rc)
554 if (localpet == 0)
then
556 call nemsio_readrecv(gfile,
"spfh",
"2 m above gnd", 1, dummy, 0, iret=rc)
557 if (rc /= 0)
call error_handler(
"READING Q2M.", rc)
559 print*,
'q2m ',maxval(dummy2d),minval(dummy2d)
562 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
563 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
564 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
565 call error_handler(
"IN FieldScatter", rc)
567 if (localpet == 0)
then
568 print*,
"- READ TPRCP."
569 call nemsio_readrecv(gfile,
"tprcp",
"sfc", 1, dummy, 0, iret=rc)
570 if (rc /= 0)
call error_handler(
"READING TPRCP.", rc)
572 print*,
'tprcp ',maxval(dummy2d),minval(dummy2d)
575 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
576 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
577 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
578 call error_handler(
"IN FieldScatter", rc)
580 if (localpet == 0)
then
581 print*,
"- READ FFMM."
582 call nemsio_readrecv(gfile,
"ffmm",
"sfc", 1, dummy, 0, iret=rc)
583 if (rc /= 0)
call error_handler(
"READING FFMM.", rc)
585 print*,
'ffmm ',maxval(dummy2d),minval(dummy2d)
588 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
589 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
590 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
591 call error_handler(
"IN FieldScatter", rc)
593 if (localpet == 0)
then
594 print*,
"- READ USTAR."
595 call nemsio_readrecv(gfile,
"fricv",
"sfc", 1, dummy, 0, iret=rc)
596 if (rc /= 0)
call error_handler(
"READING USTAR.", rc)
598 print*,
'fricv ',maxval(dummy2d),minval(dummy2d)
601 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
602 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
603 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
604 call error_handler(
"IN FieldScatter", rc)
606 if (localpet == 0) dummy2d = 0.0
607 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
608 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
609 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
610 call error_handler(
"IN FieldScatter", rc)
612 if (localpet == 0)
then
613 print*,
"- READ SKIN TEMPERATURE."
614 call nemsio_readrecv(gfile,
"tmp",
"sfc", 1, dummy, 0, iret=rc)
615 if (rc /= 0)
call error_handler(
"READING SKIN TEMPERATURE.", rc)
617 print*,
'tmp ',maxval(dummy2d),minval(dummy2d)
620 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
621 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
622 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
623 call error_handler(
"IN FieldScatter", rc)
625 if (localpet == 0)
then
626 print*,
"- READ F10M."
627 call nemsio_readrecv(gfile,
"f10m",
"10 m above gnd", 1, dummy, 0, iret=rc)
628 if (rc /= 0)
call error_handler(
"READING F10M.", rc)
630 print*,
'f10m ',maxval(dummy2d),minval(dummy2d)
633 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
634 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
635 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
636 call error_handler(
"IN FieldScatter", rc)
638 if (localpet == 0)
then
639 print*,
"- READ CANOPY MOISTURE CONTENT."
640 call nemsio_readrecv(gfile,
"cnwat",
"sfc", 1, dummy, 0, iret=rc)
641 if (rc /= 0)
call error_handler(
"READING CANOPY MOISTURE CONTENT.", rc)
643 print*,
'cnwat ',maxval(dummy2d),minval(dummy2d)
646 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
647 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
648 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
649 call error_handler(
"IN FieldScatter", rc)
651 if (localpet == 0)
then
653 call nemsio_readrecv(gfile,
"sfcr",
"sfc", 1, dummy, 0, iret=rc)
654 if (rc /= 0)
call error_handler(
"READING Z0.", rc)
656 print*,
'sfcr ',maxval(dummy2d),minval(dummy2d)
659 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
660 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
661 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
662 call error_handler(
"IN FieldScatter", rc)
666 if (localpet == 0)
then
667 print*,
"- READ LIQUID SOIL MOISTURE."
668 call nemsio_readrecv(gfile,
"slc",
"soil layer", 1, dummy, 0, iret=rc)
669 if (rc /= 0)
call error_handler(
"READING LAYER 1 LIQUID SOIL MOIST.", rc)
671 call nemsio_readrecv(gfile,
"slc",
"soil layer", 2, dummy, 0, iret=rc)
672 if (rc /= 0)
call error_handler(
"READING LAYER 2 LIQUID SOIL MOIST.", rc)
674 call nemsio_readrecv(gfile,
"slc",
"soil layer", 3, dummy, 0, iret=rc)
675 if (rc /= 0)
call error_handler(
"READING LAYER 3 LIQUID SOIL MOIST.", rc)
677 call nemsio_readrecv(gfile,
"slc",
"soil layer", 4, dummy, 0, iret=rc)
678 if (rc /= 0)
call error_handler(
"READING LAYER 4 LIQUID SOIL MOIST.", rc)
680 print*,
'slc ',maxval(dummy3d),minval(dummy3d)
683 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
684 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
685 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
686 call error_handler(
"IN FieldScatter", rc)
688 if (localpet == 0)
then
689 print*,
"- READ TOTAL SOIL MOISTURE."
690 call nemsio_readrecv(gfile,
"smc",
"soil layer", 1, dummy, 0, iret=rc)
691 if (rc /= 0)
call error_handler(
"READING LAYER 1 TOTAL SOIL MOIST.", rc)
693 call nemsio_readrecv(gfile,
"smc",
"soil layer", 2, dummy, 0, iret=rc)
694 if (rc /= 0)
call error_handler(
"READING LAYER 2 TOTAL SOIL MOIST.", rc)
696 call nemsio_readrecv(gfile,
"smc",
"soil layer", 3, dummy, 0, iret=rc)
697 if (rc /= 0)
call error_handler(
"READING LAYER 3 TOTAL SOIL MOIST.", rc)
699 call nemsio_readrecv(gfile,
"smc",
"soil layer", 4, dummy, 0, iret=rc)
700 if (rc /= 0)
call error_handler(
"READING LAYER 4 TOTAL SOIL MOIST.", rc)
702 print*,
'smc ',maxval(dummy3d),minval(dummy3d)
705 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
706 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
707 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
708 call error_handler(
"IN FieldScatter", rc)
710 if (localpet == 0)
then
711 print*,
"- READ SOIL TEMPERATURE."
712 call nemsio_readrecv(gfile,
"stc",
"soil layer", 1, dummy, 0, iret=rc)
713 if (rc /= 0)
call error_handler(
"READING LAYER 1 SOIL TEMP.", rc)
715 call nemsio_readrecv(gfile,
"stc",
"soil layer", 2, dummy, 0, iret=rc)
716 if (rc /= 0)
call error_handler(
"READING LAYER 2 SOIL TEMP.", rc)
718 call nemsio_readrecv(gfile,
"stc",
"soil layer", 3, dummy, 0, iret=rc)
719 if (rc /= 0)
call error_handler(
"READING LAYER 3 SOIL TEMP.", rc)
721 call nemsio_readrecv(gfile,
"stc",
"soil layer", 4, dummy, 0, iret=rc)
722 if (rc /= 0)
call error_handler(
"READING LAYER 4 SOIL TEMP.", rc)
724 print*,
'stc ',maxval(dummy3d),minval(dummy3d)
727 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
728 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
729 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
730 call error_handler(
"IN FieldScatter", rc)
732 deallocate(dummy3d, dummy)
734 if (localpet == 0)
call nemsio_close(gfile)
736 end subroutine read_input_sfc_gfs_gaussian_nemsio_file
744 subroutine read_input_sfc_gaussian_nemsio_file(localpet)
748 integer,
intent(in) :: localpet
750 character(len=250) :: the_file
754 real(nemsio_realkind),
allocatable :: dummy(:)
755 real(esmf_kind_r8),
allocatable :: dummy2d(:,:)
756 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:)
758 type(nemsio_gfile) :: gfile
762 if (localpet == 0)
then
766 print*,
"- OPEN FILE ", trim(the_file)
767 call nemsio_open(gfile, the_file,
"read", iret=rc)
768 if (rc /= 0)
call error_handler(
"OPENING FILE.", rc)
770 allocate(dummy3d(0,0,0))
771 allocate(dummy2d(0,0))
775 if (localpet == 0)
then
776 print*,
"- READ TERRAIN."
777 call nemsio_readrecv(gfile,
"orog",
"sfc", 1, dummy, 0, iret=rc)
778 if (rc /= 0)
call error_handler(
"READING TERRAIN.", rc)
780 print*,
'orog ',maxval(dummy2d),minval(dummy2d)
783 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
785 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
786 call error_handler(
"IN FieldScatter", rc)
788 if (localpet == 0)
then
789 print*,
"- READ LANDSEA MASK."
790 call nemsio_readrecv(gfile,
"land",
"sfc", 1, dummy, 0, iret=rc)
791 if (rc /= 0)
call error_handler(
"READING LANDSEA MASK.", rc)
793 print*,
'landmask ',maxval(dummy2d),minval(dummy2d)
796 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
797 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d, rootpet=0, rc=rc)
798 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
799 call error_handler(
"IN FieldScatter", rc)
801 if (localpet == 0)
then
802 print*,
"- READ SEAICE FRACTION."
803 call nemsio_readrecv(gfile,
"icec",
"sfc", 1, dummy, 0, iret=rc)
804 if (rc /= 0)
call error_handler(
"READING SEAICE FRACTION.", rc)
806 print*,
'icec ',maxval(dummy2d),minval(dummy2d)
809 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
810 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d, rootpet=0, rc=rc)
811 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
812 call error_handler(
"IN FieldScatter", rc)
814 if (localpet == 0)
then
815 print*,
"- READ SEAICE DEPTH."
816 call nemsio_readrecv(gfile,
"icetk",
"sfc", 1, dummy, 0, iret=rc)
817 if (rc /= 0)
call error_handler(
"READING SEAICE DEPTH.", rc)
819 print*,
'icetk ',maxval(dummy2d),minval(dummy2d)
822 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
823 call esmf_fieldscatter(seaice_depth_input_grid, dummy2d, rootpet=0, rc=rc)
824 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
825 call error_handler(
"IN FieldScatter", rc)
827 if (localpet == 0)
then
828 print*,
"- READ SEAICE SKIN TEMPERATURE."
829 call nemsio_readrecv(gfile,
"ti",
"sfc", 1, dummy, 0, iret=rc)
830 if (rc /= 0)
call error_handler(
"READING SEAICE SKIN TEMP.", rc)
832 print*,
'ti ',maxval(dummy2d),minval(dummy2d)
835 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
836 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
837 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
838 call error_handler(
"IN FieldScatter", rc)
840 if (localpet == 0)
then
841 print*,
"- READ SNOW LIQUID EQUIVALENT."
842 call nemsio_readrecv(gfile,
"weasd",
"sfc", 1, dummy, 0, iret=rc)
843 if (rc /= 0)
call error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
845 print*,
'weasd ',maxval(dummy2d),minval(dummy2d)
848 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
849 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d, rootpet=0, rc=rc)
850 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
851 call error_handler(
"IN FieldScatter", rc)
853 if (localpet == 0)
then
854 print*,
"- READ SNOW DEPTH."
855 call nemsio_readrecv(gfile,
"snod",
"sfc", 1, dummy, 0, iret=rc)
856 if (rc /= 0)
call error_handler(
"READING SNOW DEPTH.", rc)
858 print*,
'snod ',maxval(dummy2d),minval(dummy2d)
861 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
862 call esmf_fieldscatter(snow_depth_input_grid, dummy2d, rootpet=0, rc=rc)
863 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
864 call error_handler(
"IN FieldScatter", rc)
866 if (localpet == 0)
then
867 print*,
"- READ VEG TYPE."
868 call nemsio_readrecv(gfile,
"vtype",
"sfc", 1, dummy, 0, iret=rc)
869 if (rc /= 0)
call error_handler(
"READING VEG TYPE", rc)
871 print*,
'vtype ',maxval(dummy2d),minval(dummy2d)
874 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
875 call esmf_fieldscatter(veg_type_input_grid, dummy2d, rootpet=0, rc=rc)
876 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
877 call error_handler(
"IN FieldScatter", rc)
879 if (localpet == 0)
then
880 print*,
"- READ SOIL TYPE."
881 call nemsio_readrecv(gfile,
"sotyp",
"sfc", 1, dummy, 0, iret=rc)
882 if (rc /= 0)
call error_handler(
"READING SOIL TYPE.", rc)
884 print*,
'sotype ',maxval(dummy2d),minval(dummy2d)
887 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
888 call esmf_fieldscatter(soil_type_input_grid, dummy2d, rootpet=0, rc=rc)
889 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
890 call error_handler(
"IN FieldScatter", rc)
892 if (localpet == 0)
then
894 call nemsio_readrecv(gfile,
"tmp",
"2 m above gnd", 1, dummy, 0, iret=rc)
895 if (rc /= 0)
call error_handler(
"READING T2M.", rc)
897 print*,
't2m ',maxval(dummy2d),minval(dummy2d)
900 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
901 call esmf_fieldscatter(t2m_input_grid, dummy2d, rootpet=0, rc=rc)
902 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
903 call error_handler(
"IN FieldScatter", rc)
905 if (localpet == 0)
then
907 call nemsio_readrecv(gfile,
"spfh",
"2 m above gnd", 1, dummy, 0, iret=rc)
908 if (rc /= 0)
call error_handler(
"READING Q2M.", rc)
910 print*,
'q2m ',maxval(dummy2d),minval(dummy2d)
913 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
914 call esmf_fieldscatter(q2m_input_grid, dummy2d, rootpet=0, rc=rc)
915 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
916 call error_handler(
"IN FieldScatter", rc)
918 if (localpet == 0)
then
919 print*,
"- READ TPRCP."
920 call nemsio_readrecv(gfile,
"tprcp",
"sfc", 1, dummy, 0, iret=rc)
921 if (rc /= 0)
call error_handler(
"READING TPRCP.", rc)
923 print*,
'tprcp ',maxval(dummy2d),minval(dummy2d)
926 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
927 call esmf_fieldscatter(tprcp_input_grid, dummy2d, rootpet=0, rc=rc)
928 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
929 call error_handler(
"IN FieldScatter", rc)
931 if (localpet == 0)
then
932 print*,
"- READ FFMM."
933 call nemsio_readrecv(gfile,
"ffmm",
"sfc", 1, dummy, 0, iret=rc)
934 if (rc /= 0)
call error_handler(
"READING FFMM.", rc)
936 print*,
'ffmm ',maxval(dummy2d),minval(dummy2d)
939 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
940 call esmf_fieldscatter(ffmm_input_grid, dummy2d, rootpet=0, rc=rc)
941 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
942 call error_handler(
"IN FieldScatter", rc)
944 if (localpet == 0)
then
945 print*,
"- READ USTAR."
946 call nemsio_readrecv(gfile,
"fricv",
"sfc", 1, dummy, 0, iret=rc)
947 if (rc /= 0)
call error_handler(
"READING USTAR.", rc)
949 print*,
'fricv ',maxval(dummy2d),minval(dummy2d)
952 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
953 call esmf_fieldscatter(ustar_input_grid, dummy2d, rootpet=0, rc=rc)
954 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
955 call error_handler(
"IN FieldScatter", rc)
957 if (localpet == 0) dummy2d = 0.0
958 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
959 call esmf_fieldscatter(srflag_input_grid, dummy2d, rootpet=0, rc=rc)
960 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
961 call error_handler(
"IN FieldScatter", rc)
963 if (localpet == 0)
then
964 print*,
"- READ SKIN TEMPERATURE."
965 call nemsio_readrecv(gfile,
"tmp",
"sfc", 1, dummy, 0, iret=rc)
966 if (rc /= 0)
call error_handler(
"READING SKIN TEMPERATURE.", rc)
968 print*,
'tmp ',maxval(dummy2d),minval(dummy2d)
971 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
972 call esmf_fieldscatter(skin_temp_input_grid, dummy2d, rootpet=0, rc=rc)
973 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
974 call error_handler(
"IN FieldScatter", rc)
976 if (localpet == 0)
then
977 print*,
"- READ F10M."
978 call nemsio_readrecv(gfile,
"f10m",
"10 m above gnd", 1, dummy, 0, iret=rc)
979 if (rc /= 0)
call error_handler(
"READING F10M.", rc)
981 print*,
'f10m ',maxval(dummy2d),minval(dummy2d)
984 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
985 call esmf_fieldscatter(f10m_input_grid, dummy2d, rootpet=0, rc=rc)
986 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
987 call error_handler(
"IN FieldScatter", rc)
989 if (localpet == 0)
then
990 print*,
"- READ CANOPY MOISTURE CONTENT."
991 call nemsio_readrecv(gfile,
"cnwat",
"sfc", 1, dummy, 0, iret=rc)
992 if (rc /= 0)
call error_handler(
"READING CANOPY MOISTURE CONTENT.", rc)
994 print*,
'cnwat ',maxval(dummy2d),minval(dummy2d)
997 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
998 call esmf_fieldscatter(canopy_mc_input_grid, dummy2d, rootpet=0, rc=rc)
999 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1000 call error_handler(
"IN FieldScatter", rc)
1002 if (localpet == 0)
then
1004 call nemsio_readrecv(gfile,
"sfcr",
"sfc", 1, dummy, 0, iret=rc)
1005 if (rc /= 0)
call error_handler(
"READING Z0.", rc)
1007 print*,
'sfcr ',maxval(dummy2d),minval(dummy2d)
1010 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
1011 call esmf_fieldscatter(z0_input_grid, dummy2d, rootpet=0, rc=rc)
1012 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1013 call error_handler(
"IN FieldScatter", rc)
1017 if (localpet == 0)
then
1018 print*,
"- READ LIQUID SOIL MOISTURE."
1019 call nemsio_readrecv(gfile,
"soill",
"0-10 cm down", 1, dummy, 0, iret=rc)
1020 if (rc /= 0)
call error_handler(
"READING LAYER 1 LIQUID SOIL MOIST.", rc)
1022 call nemsio_readrecv(gfile,
"soill",
"10-40 cm down", 1, dummy, 0, iret=rc)
1023 if (rc /= 0)
call error_handler(
"READING LAYER 2 LIQUID SOIL MOIST.", rc)
1025 call nemsio_readrecv(gfile,
"soill",
"40-100 cm down", 1, dummy, 0, iret=rc)
1026 if (rc /= 0)
call error_handler(
"READING LAYER 3 LIQUID SOIL MOIST.", rc)
1028 call nemsio_readrecv(gfile,
"soill",
"100-200 cm down", 1, dummy, 0, iret=rc)
1029 if (rc /= 0)
call error_handler(
"READING LAYER 4 LIQUID SOIL MOIST.", rc)
1031 print*,
'soill ',maxval(dummy3d),minval(dummy3d)
1034 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
1035 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
1036 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1037 call error_handler(
"IN FieldScatter", rc)
1039 if (localpet == 0)
then
1040 print*,
"- READ TOTAL SOIL MOISTURE."
1041 call nemsio_readrecv(gfile,
"soilw",
"0-10 cm down", 1, dummy, 0, iret=rc)
1042 if (rc /= 0)
call error_handler(
"READING LAYER 1 TOTAL SOIL MOIST.", rc)
1044 call nemsio_readrecv(gfile,
"soilw",
"10-40 cm down", 1, dummy, 0, iret=rc)
1045 if (rc /= 0)
call error_handler(
"READING LAYER 2 TOTAL SOIL MOIST.", rc)
1047 call nemsio_readrecv(gfile,
"soilw",
"40-100 cm down", 1, dummy, 0, iret=rc)
1048 if (rc /= 0)
call error_handler(
"READING LAYER 3 TOTAL SOIL MOIST.", rc)
1050 call nemsio_readrecv(gfile,
"soilw",
"100-200 cm down", 1, dummy, 0, iret=rc)
1051 if (rc /= 0)
call error_handler(
"READING LAYER 4 TOTAL SOIL MOIST.", rc)
1053 print*,
'soilm ',maxval(dummy3d),minval(dummy3d)
1056 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
1057 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
1058 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1059 call error_handler(
"IN FieldScatter", rc)
1061 if (localpet == 0)
then
1062 print*,
"- READ SOIL TEMPERATURE."
1063 call nemsio_readrecv(gfile,
"tmp",
"0-10 cm down", 1, dummy, 0, iret=rc)
1064 if (rc /= 0)
call error_handler(
"READING LAYER 1 SOIL TEMP.", rc)
1066 call nemsio_readrecv(gfile,
"tmp",
"10-40 cm down", 1, dummy, 0, iret=rc)
1067 if (rc /= 0)
call error_handler(
"READING LAYER 2 SOIL TEMP.", rc)
1069 call nemsio_readrecv(gfile,
"tmp",
"40-100 cm down", 1, dummy, 0, iret=rc)
1070 if (rc /= 0)
call error_handler(
"READING LAYER 3 SOIL TEMP.", rc)
1072 call nemsio_readrecv(gfile,
"tmp",
"100-200 cm down", 1, dummy, 0, iret=rc)
1073 if (rc /= 0)
call error_handler(
"READING LAYER 4 SOIL TEMP.", rc)
1075 print*,
'soilt ',maxval(dummy3d),minval(dummy3d)
1078 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
1079 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
1080 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1081 call error_handler(
"IN FieldScatter", rc)
1083 deallocate(dummy3d, dummy)
1085 if (localpet == 0)
call nemsio_close(gfile)
1087 end subroutine read_input_sfc_gaussian_nemsio_file
1094 subroutine read_input_sfc_restart_file(localpet)
1098 integer,
intent(in) :: localpet
1100 character(len=500) :: tilefile
1102 integer :: error, rc
1103 integer :: id_dim, idim_input, jdim_input
1104 integer :: ncid, tile, id_var, id_var1, id_var2, idum(2)
1106 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
1107 real(esmf_kind_r8),
allocatable :: land_frac_one_tile(:,:), vtype_one_tile(:,:)
1108 real(esmf_kind_r4),
allocatable :: slmsk_orog_one_tile(:,:)
1109 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
1112 logical :: condition1_met, condition2_met
1119 print*,
"- CALL VMGetGlobal"
1120 call esmf_vmgetglobal(vm, rc=rc)
1121 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1122 call error_handler(
"IN VMGetGlobal", rc)
1126 if (localpet == 0)
then
1127 print*,
"- READ GRID DIMENSIONS FROM: ", trim(tilefile)
1128 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1129 call netcdf_err(error,
'opening: '//trim(tilefile) )
1131 error=nf90_inq_dimid(ncid,
'xaxis_1', id_dim)
1132 call netcdf_err(error,
'reading xaxis_1 id' )
1133 error=nf90_inquire_dimension(ncid,id_dim,len=idum(1))
1134 call netcdf_err(error,
'reading xaxis_1 value' )
1136 error=nf90_inq_dimid(ncid,
'yaxis_1', id_dim)
1137 call netcdf_err(error,
'reading yaxis_1 id' )
1138 error=nf90_inquire_dimension(ncid,id_dim,len=idum(2))
1139 call netcdf_err(error,
'reading yaxis_1 value' )
1141 error = nf90_close(ncid)
1144 call esmf_vmbroadcast(vm, idum, 2, 0, rc=rc)
1145 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1146 call error_handler(
"IN VMBroadcast", rc)
1152 call error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 1)
1155 if (localpet == 0)
then
1156 allocate(data_one_tile(idim_input,jdim_input))
1157 allocate(land_frac_one_tile(idim_input,jdim_input))
1158 allocate(slmsk_orog_one_tile(idim_input,jdim_input))
1159 allocate(vtype_one_tile(idim_input,jdim_input))
1160 allocate(data_one_tile_3d(idim_input,jdim_input,lsoil_input))
1162 allocate(data_one_tile(0,0))
1163 allocate(land_frac_one_tile(0,0))
1164 allocate(slmsk_orog_one_tile(0,0))
1165 allocate(vtype_one_tile(0,0))
1166 allocate(data_one_tile_3d(0,0,0))
1171 if (localpet == 0)
then
1173 print*,
'- OPEN OROGRAPHY FILE: ', trim(tilefile)
1174 error=nf90_open(tilefile,nf90_nowrite,ncid)
1175 call netcdf_err(error,
'OPENING OROGRAPHY FILE' )
1176 error=nf90_inq_varid(ncid,
'orog_raw', id_var)
1177 call netcdf_err(error,
'READING OROG RECORD ID' )
1178 error=nf90_inq_varid(ncid,
'land_frac', id_var1)
1179 call netcdf_err(error,
'READING OROG LAND_FRAC ID' )
1180 error=nf90_inq_varid(ncid,
'slmsk', id_var2)
1181 call netcdf_err(error,
'READING OROG SLMSK ID' )
1182 error=nf90_get_var(ncid, id_var, data_one_tile)
1183 call netcdf_err(error,
'READING OROG RECORD' )
1184 error=nf90_get_var(ncid, id_var1, land_frac_one_tile)
1185 call netcdf_err(error,
'READING OROG LAND_FRAC' )
1186 error=nf90_get_var(ncid, id_var2, slmsk_orog_one_tile)
1187 call netcdf_err(error,
'READING OROG SLMSK' )
1188 print*,
'terrain check ',tile, maxval(data_one_tile)
1189 error=nf90_close(ncid)
1193 call read_fv3_grid_data_netcdf(
'vtype', tile, idim_input, jdim_input, &
1194 lsoil_input, sfcdata=vtype_one_tile)
1196 condition1_met = all(((nint(vtype_one_tile) > 0) .and. (nint(slmsk_orog_one_tile) == 1)) .or. ((nint(vtype_one_tile) <= 0) .and. (nint(slmsk_orog_one_tile) == 0)))
1197 condition2_met = all(((land_frac_one_tile > 0.) .and. (nint(vtype_one_tile) > 0)) .or. ((land_frac_one_tile == 0.) .and. (nint(vtype_one_tile)<= 0)))
1199 if (condition1_met)
then
1200 print*,
'[Non-fractional grid]: mask check ',tile,
': consistent!'
1202 if (condition2_met)
then
1203 print*,
'[Fractional grid]: mask check ',tile,
': consistent!'
1206 if ((.not. condition1_met) .and. (.not. condition2_met))
then
1207 call error_handler(
"INCONSISTENT LAND/SEA MASK BETWEEN RESTART AND OROG FILES.", 10)
1212 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
1213 call esmf_fieldscatter(
terrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1214 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1215 call error_handler(
"IN FieldScatter", rc)
1223 if (localpet == 0)
then
1224 call read_fv3_grid_data_netcdf(
'slc', tile, idim_input, jdim_input, &
1225 lsoil_input, sfcdata_3d=data_one_tile_3d)
1228 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
1229 call esmf_fieldscatter(soilm_liq_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
1230 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1231 call error_handler(
"IN FieldScatter", rc)
1233 if (localpet == 0)
then
1234 call read_fv3_grid_data_netcdf(
'smc', tile, idim_input, jdim_input, &
1235 lsoil_input, sfcdata_3d=data_one_tile_3d)
1238 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
1239 call esmf_fieldscatter(soilm_tot_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
1240 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1241 call error_handler(
"IN FieldScatter", rc)
1243 if (localpet == 0)
then
1244 call read_fv3_grid_data_netcdf(
'stc', tile, idim_input, jdim_input, &
1245 lsoil_input, sfcdata_3d=data_one_tile_3d)
1248 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
1249 call esmf_fieldscatter(soil_temp_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
1250 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1251 call error_handler(
"IN FieldScatter", rc)
1255 if (localpet == 0)
then
1256 call read_fv3_grid_data_netcdf(
'slmsk', tile, idim_input, jdim_input, &
1257 lsoil_input, sfcdata=data_one_tile)
1260 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
1261 call esmf_fieldscatter(landsea_mask_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1262 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1263 call error_handler(
"IN FieldScatter", rc)
1267 if (localpet == 0)
then
1268 call read_fv3_grid_data_netcdf(
'fice', tile, idim_input, jdim_input, &
1269 lsoil_input, sfcdata=data_one_tile)
1272 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
1273 call esmf_fieldscatter(seaice_fract_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1274 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1275 call error_handler(
"IN FieldScatter", rc)
1279 if (localpet == 0)
then
1280 call read_fv3_grid_data_netcdf(
'hice', tile, idim_input, jdim_input, &
1281 lsoil_input, sfcdata=data_one_tile)
1284 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
1285 call esmf_fieldscatter(seaice_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1286 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1287 call error_handler(
"IN FieldScatter", rc)
1291 if (localpet == 0)
then
1292 call read_fv3_grid_data_netcdf(
'tisfc', tile, idim_input, jdim_input, &
1293 lsoil_input, sfcdata=data_one_tile)
1296 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
1297 call esmf_fieldscatter(seaice_skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1298 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1299 call error_handler(
"IN FieldScatter", rc)
1303 if (localpet == 0)
then
1304 call read_fv3_grid_data_netcdf(
'sheleg', tile, idim_input, jdim_input, &
1305 lsoil_input, sfcdata=data_one_tile)
1308 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
1309 call esmf_fieldscatter(snow_liq_equiv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1310 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1311 call error_handler(
"IN FieldScatter", rc)
1315 if (localpet == 0)
then
1316 call read_fv3_grid_data_netcdf(
'snwdph', tile, idim_input, jdim_input, &
1317 lsoil_input, sfcdata=data_one_tile)
1318 data_one_tile = data_one_tile
1321 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
1322 call esmf_fieldscatter(snow_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1323 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1324 call error_handler(
"IN FieldScatter", rc)
1328 if (localpet == 0)
then
1329 call read_fv3_grid_data_netcdf(
'vtype', tile, idim_input, jdim_input, &
1330 lsoil_input, sfcdata=data_one_tile)
1333 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
1334 call esmf_fieldscatter(veg_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1335 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1336 call error_handler(
"IN FieldScatter", rc)
1340 if (localpet == 0)
then
1341 call read_fv3_grid_data_netcdf(
'stype', tile, idim_input, jdim_input, &
1342 lsoil_input, sfcdata=data_one_tile)
1345 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
1346 call esmf_fieldscatter(soil_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1347 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1348 call error_handler(
"IN FieldScatter", rc)
1352 if (localpet == 0)
then
1353 call read_fv3_grid_data_netcdf(
't2m', tile, idim_input, jdim_input, &
1354 lsoil_input, sfcdata=data_one_tile)
1357 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
1358 call esmf_fieldscatter(t2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1359 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1360 call error_handler(
"IN FieldScatter", rc)
1364 if (localpet == 0)
then
1365 call read_fv3_grid_data_netcdf(
'q2m', tile, idim_input, jdim_input, &
1366 lsoil_input, sfcdata=data_one_tile)
1369 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
1370 call esmf_fieldscatter(q2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1371 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1372 call error_handler(
"IN FieldScatter", rc)
1374 if (localpet == 0)
then
1375 call read_fv3_grid_data_netcdf(
'tprcp', tile, idim_input, jdim_input, &
1376 lsoil_input, sfcdata=data_one_tile)
1379 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
1380 call esmf_fieldscatter(tprcp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1381 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1382 call error_handler(
"IN FieldScatter", rc)
1384 if (localpet == 0)
then
1385 call read_fv3_grid_data_netcdf(
'f10m', tile, idim_input, jdim_input, &
1386 lsoil_input, sfcdata=data_one_tile)
1389 print*,
"- CALL FieldScatter FOR INPUT GRID F10M"
1390 call esmf_fieldscatter(f10m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1391 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1392 call error_handler(
"IN FieldScatter", rc)
1394 if (localpet == 0)
then
1395 call read_fv3_grid_data_netcdf(
'ffmm', tile, idim_input, jdim_input, &
1396 lsoil_input, sfcdata=data_one_tile)
1399 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
1400 call esmf_fieldscatter(ffmm_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1401 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1402 call error_handler(
"IN FieldScatter", rc)
1404 if (localpet == 0)
then
1405 call read_fv3_grid_data_netcdf(
'uustar', tile, idim_input, jdim_input, &
1406 lsoil_input, sfcdata=data_one_tile)
1409 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
1410 call esmf_fieldscatter(ustar_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1411 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1412 call error_handler(
"IN FieldScatter", rc)
1414 if (localpet == 0)
then
1415 call read_fv3_grid_data_netcdf(
'srflag', tile, idim_input, jdim_input, &
1416 lsoil_input, sfcdata=data_one_tile)
1419 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
1420 call esmf_fieldscatter(srflag_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1421 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1422 call error_handler(
"IN FieldScatter", rc)
1424 if (localpet == 0)
then
1425 call read_fv3_grid_data_netcdf(
'tsea', tile, idim_input, jdim_input, &
1426 lsoil_input, sfcdata=data_one_tile)
1429 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
1430 call esmf_fieldscatter(skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1431 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1432 call error_handler(
"IN FieldScatter", rc)
1434 if (localpet == 0)
then
1435 call read_fv3_grid_data_netcdf(
'canopy', tile, idim_input, jdim_input, &
1436 lsoil_input, sfcdata=data_one_tile)
1439 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
1440 call esmf_fieldscatter(canopy_mc_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1441 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1442 call error_handler(
"IN FieldScatter", rc)
1444 if (localpet == 0)
then
1445 call read_fv3_grid_data_netcdf(
'zorl', tile, idim_input, jdim_input, &
1446 lsoil_input, sfcdata=data_one_tile)
1449 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
1450 call esmf_fieldscatter(z0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1451 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1452 call error_handler(
"IN FieldScatter", rc)
1456 deallocate(data_one_tile, data_one_tile_3d)
1457 deallocate(vtype_one_tile, land_frac_one_tile, slmsk_orog_one_tile)
1459 end subroutine read_input_sfc_restart_file
1466 subroutine read_input_sfc_netcdf_file(localpet)
1470 integer,
intent(in) :: localpet
1472 character(len=500) :: tilefile
1474 integer :: error, id_var
1475 integer :: id_dim, idim_input, jdim_input
1476 integer :: ncid, rc, tile, idum(2)
1478 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
1479 real(esmf_kind_r8),
allocatable :: data_one_tile_3d(:,:,:)
1488 print*,
"- CALL VMGetGlobal"
1489 call esmf_vmgetglobal(vm, rc=rc)
1490 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1491 call error_handler(
"IN VMGetGlobal", rc)
1495 if (localpet == 0)
then
1496 print*,
"- READ GRID DIMENSIONS FROM: ", trim(tilefile)
1497 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
1498 call netcdf_err(error,
'opening: '//trim(tilefile) )
1500 error=nf90_inq_dimid(ncid,
'grid_xt', id_dim)
1501 call netcdf_err(error,
'reading grid_xt id' )
1502 error=nf90_inquire_dimension(ncid,id_dim,len=idum(1))
1503 call netcdf_err(error,
'reading grid_xt value' )
1505 error=nf90_inq_dimid(ncid,
'grid_yt', id_dim)
1506 call netcdf_err(error,
'reading grid_yt id' )
1507 error=nf90_inquire_dimension(ncid,id_dim,len=idum(2))
1508 call netcdf_err(error,
'reading grid_yt value' )
1510 error = nf90_close(ncid)
1513 call esmf_vmbroadcast(vm, idum, 2, 0, rc=rc)
1514 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1515 call error_handler(
"IN VMBroadcast", rc)
1521 call error_handler(
"DIMENSION MISMATCH BETWEEN SFC AND OROG FILES.", 3)
1524 if (localpet == 0)
then
1525 allocate(data_one_tile(idim_input,jdim_input))
1526 allocate(data_one_tile_3d(idim_input,jdim_input,lsoil_input))
1528 allocate(data_one_tile(0,0))
1529 allocate(data_one_tile_3d(0,0,0))
1534 if (trim(
input_type) ==
"gaussian_netcdf")
then
1535 if (localpet == 0)
then
1536 call read_fv3_grid_data_netcdf(
'orog', tile, idim_input, jdim_input, &
1537 lsoil_input, sfcdata=data_one_tile)
1542 if (localpet == 0)
then
1544 print*,
'- OPEN OROGRAPHY FILE: ', trim(tilefile)
1545 error=nf90_open(tilefile,nf90_nowrite,ncid)
1546 call netcdf_err(error,
'OPENING OROGRAPHY FILE.' )
1547 error=nf90_inq_varid(ncid,
'orog_raw', id_var)
1548 call netcdf_err(error,
'READING OROGRAPHY RECORD ID.' )
1549 error=nf90_get_var(ncid, id_var, data_one_tile)
1550 call netcdf_err(error,
'READING OROGRAPHY RECORD.' )
1551 print*,
'terrain check history ',tile, maxval(data_one_tile)
1552 error=nf90_close(ncid)
1557 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
1558 call esmf_fieldscatter(
terrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1559 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1560 call error_handler(
"IN FieldScatter", rc)
1568 if (localpet == 0)
then
1569 call read_fv3_grid_data_netcdf(
'soill1', tile, idim_input, jdim_input, &
1570 lsoil_input, sfcdata=data_one_tile)
1571 data_one_tile_3d(:,:,1) = data_one_tile
1572 call read_fv3_grid_data_netcdf(
'soill2', tile, idim_input, jdim_input, &
1573 lsoil_input, sfcdata=data_one_tile)
1574 data_one_tile_3d(:,:,2) = data_one_tile
1575 call read_fv3_grid_data_netcdf(
'soill3', tile, idim_input, jdim_input, &
1576 lsoil_input, sfcdata=data_one_tile)
1577 data_one_tile_3d(:,:,3) = data_one_tile
1578 call read_fv3_grid_data_netcdf(
'soill4', tile, idim_input, jdim_input, &
1579 lsoil_input, sfcdata=data_one_tile)
1580 data_one_tile_3d(:,:,4) = data_one_tile
1583 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
1584 call esmf_fieldscatter(soilm_liq_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
1585 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1586 call error_handler(
"IN FieldScatter", rc)
1590 if (localpet == 0)
then
1591 call read_fv3_grid_data_netcdf(
'soilw1', tile, idim_input, jdim_input, &
1592 lsoil_input, sfcdata=data_one_tile)
1593 data_one_tile_3d(:,:,1) = data_one_tile
1594 call read_fv3_grid_data_netcdf(
'soilw2', tile, idim_input, jdim_input, &
1595 lsoil_input, sfcdata=data_one_tile)
1596 data_one_tile_3d(:,:,2) = data_one_tile
1597 call read_fv3_grid_data_netcdf(
'soilw3', tile, idim_input, jdim_input, &
1598 lsoil_input, sfcdata=data_one_tile)
1599 data_one_tile_3d(:,:,3) = data_one_tile
1600 call read_fv3_grid_data_netcdf(
'soilw4', tile, idim_input, jdim_input, &
1601 lsoil_input, sfcdata=data_one_tile)
1602 data_one_tile_3d(:,:,4) = data_one_tile
1605 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
1606 call esmf_fieldscatter(soilm_tot_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
1607 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1608 call error_handler(
"IN FieldScatter", rc)
1612 if (localpet == 0)
then
1613 call read_fv3_grid_data_netcdf(
'soilt1', tile, idim_input, jdim_input, &
1614 lsoil_input, sfcdata=data_one_tile)
1615 data_one_tile_3d(:,:,1) = data_one_tile
1616 call read_fv3_grid_data_netcdf(
'soilt2', tile, idim_input, jdim_input, &
1617 lsoil_input, sfcdata=data_one_tile)
1618 data_one_tile_3d(:,:,2) = data_one_tile
1619 call read_fv3_grid_data_netcdf(
'soilt3', tile, idim_input, jdim_input, &
1620 lsoil_input, sfcdata=data_one_tile)
1621 data_one_tile_3d(:,:,3) = data_one_tile
1622 call read_fv3_grid_data_netcdf(
'soilt4', tile, idim_input, jdim_input, &
1623 lsoil_input, sfcdata=data_one_tile)
1624 data_one_tile_3d(:,:,4) = data_one_tile
1627 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
1628 call esmf_fieldscatter(soil_temp_input_grid, data_one_tile_3d, rootpet=0, tile=tile, rc=rc)
1629 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1630 call error_handler(
"IN FieldScatter", rc)
1634 if (localpet == 0)
then
1635 call read_fv3_grid_data_netcdf(
'land', tile, idim_input, jdim_input, &
1636 lsoil_input, sfcdata=data_one_tile)
1639 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
1640 call esmf_fieldscatter(landsea_mask_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1641 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1642 call error_handler(
"IN FieldScatter", rc)
1646 if (localpet == 0)
then
1647 call read_fv3_grid_data_netcdf(
'icec', tile, idim_input, jdim_input, &
1648 lsoil_input, sfcdata=data_one_tile)
1651 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
1652 call esmf_fieldscatter(seaice_fract_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1653 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1654 call error_handler(
"IN FieldScatter", rc)
1658 if (localpet == 0)
then
1659 call read_fv3_grid_data_netcdf(
'icetk', tile, idim_input, jdim_input, &
1660 lsoil_input, sfcdata=data_one_tile)
1663 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
1664 call esmf_fieldscatter(seaice_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1665 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1666 call error_handler(
"IN FieldScatter", rc)
1670 if (localpet == 0)
then
1671 call read_fv3_grid_data_netcdf(
'tisfc', tile, idim_input, jdim_input, &
1672 lsoil_input, sfcdata=data_one_tile)
1675 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
1676 call esmf_fieldscatter(seaice_skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1677 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1678 call error_handler(
"IN FieldScatter", rc)
1682 if (localpet == 0)
then
1683 call read_fv3_grid_data_netcdf(
'weasd', tile, idim_input, jdim_input, &
1684 lsoil_input, sfcdata=data_one_tile)
1687 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
1688 call esmf_fieldscatter(snow_liq_equiv_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__)) &
1690 call error_handler(
"IN FieldScatter", rc)
1694 if (localpet == 0)
then
1695 call read_fv3_grid_data_netcdf(
'snod', tile, idim_input, jdim_input, &
1696 lsoil_input, sfcdata=data_one_tile)
1697 data_one_tile = data_one_tile * 1000.0
1700 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
1701 call esmf_fieldscatter(snow_depth_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1702 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1703 call error_handler(
"IN FieldScatter", rc)
1707 if (localpet == 0)
then
1708 call read_fv3_grid_data_netcdf(
'vtype', tile, idim_input, jdim_input, &
1709 lsoil_input, sfcdata=data_one_tile)
1712 print*,
"- CALL FieldScatter FOR INPUT GRID VEG TYPE."
1713 call esmf_fieldscatter(veg_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1714 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1715 call error_handler(
"IN FieldScatter", rc)
1719 if (localpet == 0)
then
1720 call read_fv3_grid_data_netcdf(
'sotyp', tile, idim_input, jdim_input, &
1721 lsoil_input, sfcdata=data_one_tile)
1724 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
1725 call esmf_fieldscatter(soil_type_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1726 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1727 call error_handler(
"IN FieldScatter", rc)
1731 if (localpet == 0)
then
1732 call read_fv3_grid_data_netcdf(
'tmp2m', tile, idim_input, jdim_input, &
1733 lsoil_input, sfcdata=data_one_tile)
1736 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
1737 call esmf_fieldscatter(t2m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1738 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1739 call error_handler(
"IN FieldScatter", rc)
1743 if (localpet == 0)
then
1744 call read_fv3_grid_data_netcdf(
'spfh2m', tile, idim_input, jdim_input, &
1745 lsoil_input, sfcdata=data_one_tile)
1748 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
1749 call esmf_fieldscatter(q2m_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__)) &
1751 call error_handler(
"IN FieldScatter", rc)
1753 if (localpet == 0)
then
1754 call read_fv3_grid_data_netcdf(
'tprcp', tile, idim_input, jdim_input, &
1755 lsoil_input, sfcdata=data_one_tile)
1758 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
1759 call esmf_fieldscatter(tprcp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1760 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1761 call error_handler(
"IN FieldScatter", rc)
1763 if (localpet == 0)
then
1764 call read_fv3_grid_data_netcdf(
'f10m', tile, idim_input, jdim_input, &
1765 lsoil_input, sfcdata=data_one_tile)
1768 print*,
"- CALL FieldScatter FOR INPUT GRID F10M"
1769 call esmf_fieldscatter(f10m_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1770 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1771 call error_handler(
"IN FieldScatter", rc)
1773 if (localpet == 0)
then
1774 call read_fv3_grid_data_netcdf(
'ffmm', tile, idim_input, jdim_input, &
1775 lsoil_input, sfcdata=data_one_tile)
1778 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
1779 call esmf_fieldscatter(ffmm_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1780 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1781 call error_handler(
"IN FieldScatter", rc)
1783 if (localpet == 0)
then
1784 call read_fv3_grid_data_netcdf(
'fricv', tile, idim_input, jdim_input, &
1785 lsoil_input, sfcdata=data_one_tile)
1788 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
1789 call esmf_fieldscatter(ustar_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1790 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1791 call error_handler(
"IN FieldScatter", rc)
1793 if (localpet == 0)
then
1799 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
1800 call esmf_fieldscatter(srflag_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1801 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1802 call error_handler(
"IN FieldScatter", rc)
1804 if (localpet == 0)
then
1805 call read_fv3_grid_data_netcdf(
'tmpsfc', tile, idim_input, jdim_input, &
1806 lsoil_input, sfcdata=data_one_tile)
1809 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
1810 call esmf_fieldscatter(skin_temp_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1811 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1812 call error_handler(
"IN FieldScatter", rc)
1814 if (localpet == 0)
then
1815 call read_fv3_grid_data_netcdf(
'cnwat', tile, idim_input, jdim_input, &
1816 lsoil_input, sfcdata=data_one_tile)
1819 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
1820 call esmf_fieldscatter(canopy_mc_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1821 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1822 call error_handler(
"IN FieldScatter", rc)
1824 if (localpet == 0)
then
1825 call read_fv3_grid_data_netcdf(
'sfcr', tile, idim_input, jdim_input, &
1826 lsoil_input, sfcdata=data_one_tile)
1829 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
1830 call esmf_fieldscatter(z0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
1831 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1832 call error_handler(
"IN FieldScatter", rc)
1836 deallocate(data_one_tile, data_one_tile_3d)
1838 end subroutine read_input_sfc_netcdf_file
1844 subroutine read_input_sfc_grib2_file(localpet)
1854 integer,
intent(in) :: localpet
1856 character(len=250) :: the_file
1857 character(len=250) :: geo_file
1858 character(len=200) :: err_msg
1859 character(len=20) :: vname, vname_file, slev
1860 character(len=50) :: method
1862 integer :: rc, varnum, iret, i, j,k
1863 integer :: ncid2d, varid, varsize
1864 integer :: lugb, lugi
1865 integer :: jdisc, jgdtn, jpdtn, pdt_num
1866 integer :: jids(200), jgdt(200), jpdt(200)
1868 logical :: rap_latlon, unpack
1870 real(esmf_kind_r4) :: value
1871 real(esmf_kind_r4),
allocatable :: dummy2d(:,:)
1872 real(esmf_kind_r8),
allocatable :: icec_save(:,:)
1873 real(esmf_kind_r4),
allocatable :: dummy1d(:)
1874 real(esmf_kind_r8),
allocatable :: dummy2d_8(:,:),dummy2d_82(:,:),tsk_save(:,:)
1875 real(esmf_kind_r8),
allocatable :: dummy3d(:,:,:), dummy3d_stype(:,:,:)
1876 integer(esmf_kind_i4),
allocatable :: slmsk_save(:,:)
1877 integer(esmf_kind_i8),
allocatable :: dummy2d_i(:,:)
1879 type(gribfield) :: gfld
1886 print*,
"- READ SFC DATA FROM GRIB2 FILE: ", trim(the_file)
1890 if (localpet == 0)
then
1893 call baopenr(lugb,the_file,rc)
1894 if (rc /= 0)
call error_handler(
"ERROR OPENING GRIB2 FILE.", rc)
1906 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
1907 unpack, k, gfld, rc)
1910 if (gfld%idsect(1) == 7 .and. gfld%idsect(2) == 2)
then
1911 print*,
'- THIS IS NCEP GEFS DATA.'
1917 if (rc /= 0)
call error_handler(
"ERROR READING GRIB2 FILE.", rc)
1925 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
1926 unpack, k, gfld, rc)
1930 if (gfld%discipline == 2)
then
1931 if (gfld%ipdtnum == pdt_num)
then
1932 if (gfld%ipdtmpl(1) == 0 .and. gfld%ipdtmpl(2) == 2)
then
1934 if (gfld%ipdtmpl(10) == 106 .and. gfld%ipdtmpl(13) == 106)
then
1936 lsoil_input = lsoil_input + 1
1946 print*,
"- FILE HAS ", lsoil_input,
" SOIL LEVELS."
1947 if (lsoil_input == 0)
call error_handler(
"COUNTING SOIL LEVELS.", rc)
1951 call mpi_barrier(mpi_comm_world, rc)
1952 call mpi_bcast(lsoil_input,1,mpi_integer,0,mpi_comm_world,rc)
1956 if (lsoil_input /= 4)
then
1958 call esmf_fielddestroy(soil_temp_input_grid, rc=rc)
1959 call esmf_fielddestroy(soilm_tot_input_grid, rc=rc)
1960 call esmf_fielddestroy(soilm_liq_input_grid, rc=rc)
1962 print*,
"- CALL FieldCreate FOR INPUT SOIL TEMPERATURE."
1963 soil_temp_input_grid = esmf_fieldcreate(
input_grid, &
1964 typekind=esmf_typekind_r8, &
1965 staggerloc=esmf_staggerloc_center, &
1966 ungriddedlbound=(/1/), &
1967 ungriddedubound=(/lsoil_input/), rc=rc)
1968 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1969 call error_handler(
"IN FieldCreate", rc)
1971 print*,
"- CALL FieldCreate FOR INPUT TOTAL SOIL MOISTURE."
1972 soilm_tot_input_grid = esmf_fieldcreate(
input_grid, &
1973 typekind=esmf_typekind_r8, &
1974 staggerloc=esmf_staggerloc_center, &
1975 ungriddedlbound=(/1/), &
1976 ungriddedubound=(/lsoil_input/), rc=rc)
1977 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1978 call error_handler(
"IN FieldCreate", rc)
1980 print*,
"- CALL FieldCreate FOR INPUT LIQUID SOIL MOISTURE."
1981 soilm_liq_input_grid = esmf_fieldcreate(
input_grid, &
1982 typekind=esmf_typekind_r8, &
1983 staggerloc=esmf_staggerloc_center, &
1984 ungriddedlbound=(/1/), &
1985 ungriddedubound=(/lsoil_input/), rc=rc)
1986 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
1987 call error_handler(
"IN FieldCreate", rc)
1991 if (localpet == 0)
then
2000 allocate(dummy3d(0,0,0))
2001 allocate(dummy2d_8(0,0))
2002 allocate(dummy2d_82(0,0))
2003 allocate(dummy2d(0,0))
2004 allocate(slmsk_save(0,0))
2012 if (localpet == 0)
then
2014 print*,
"- READ TERRAIN."
2024 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2025 unpack, k, gfld, rc)
2026 if (rc /= 0)
call error_handler(
"READING TERRAIN.", rc)
2033 print*,
"- CALL FieldScatter FOR INPUT TERRAIN."
2035 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2036 call error_handler(
"IN FieldScatter", rc)
2038 if (localpet == 0)
then
2040 print*,
"- READ SEAICE FRACTION."
2050 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2051 unpack, k, gfld, rc)
2052 if (rc /= 0)
call error_handler(
"READING SEAICE FRACTION.", rc)
2057 icec_save = dummy2d_8
2061 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE FRACTION."
2062 call esmf_fieldscatter(seaice_fract_input_grid, dummy2d_8 ,rootpet=0, rc=rc)
2063 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2064 call error_handler(
"IN FieldScatter", rc)
2074 if (localpet == 0)
then
2076 print*,
"- READ LANDSEA MASK."
2085 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2086 unpack, k, gfld, rc)
2090 print*,
'landnn ', maxval(gfld%fld),minval(gfld%fld)
2101 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2102 unpack, k, gfld, rc)
2103 if (rc /= 0)
call error_handler(
"READING LANDSEA MASK.", rc)
2113 if(dummy2d_8(i,j) < 0.5_esmf_kind_r8) dummy2d_8(i,j)=0.0
2114 if(icec_save(i,j) > 0.15_esmf_kind_r8)
then
2115 dummy2d_8(i,j) = 2.0_esmf_kind_r8
2120 slmsk_save = nint(dummy2d_8)
2122 deallocate(icec_save)
2126 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
2127 call esmf_fieldscatter(landsea_mask_input_grid, dummy2d_8 ,rootpet=0, rc=rc)
2128 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2129 call error_handler(
"IN FieldScatter", rc)
2131 if (localpet == 0)
then
2133 print*,
"- READ SEAICE SKIN TEMPERATURE."
2143 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2144 unpack, k, gfld, rc)
2145 if (rc /= 0)
call error_handler(
"READING SEAICE SKIN TEMP.", rc)
2153 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE SKIN TEMPERATURE."
2154 call esmf_fieldscatter(seaice_skin_temp_input_grid, dummy2d_8 ,rootpet=0, rc=rc)
2155 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2156 call error_handler(
"IN FieldScatter", rc)
2164 if (localpet == 0)
then
2166 print*,
"- READ SNOW LIQUID EQUIVALENT."
2177 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2178 unpack, k, gfld, rc)
2179 if (rc /= 0)
call error_handler(
"READING SNOW LIQUID EQUIVALENT.", rc)
2187 if(slmsk_save(i,j) == 0) dummy2d_8(i,j) = 0.0
2193 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW LIQUID EQUIVALENT."
2194 call esmf_fieldscatter(snow_liq_equiv_input_grid, dummy2d_8 ,rootpet=0, rc=rc)
2195 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2196 call error_handler(
"IN FieldScatter", rc)
2198 if (localpet == 0)
then
2200 print*,
"- READ SNOW DEPTH."
2211 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2212 unpack, k, gfld, rc)
2215 call error_handler(
"READING SNOW DEPTH.", rc)
2217 gfld%fld = gfld%fld * 1000.0
2224 if(slmsk_save(i,j) == 0) dummy2d_8(i,j) = 0.0
2230 print*,
"- CALL FieldScatter FOR INPUT GRID SNOW DEPTH."
2231 call esmf_fieldscatter(snow_depth_input_grid,dummy2d_8,rootpet=0, rc=rc)
2232 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2233 call error_handler(
"IN FieldScatter", rc)
2235 if (localpet == 0)
then
2237 print*,
"- READ T2M."
2249 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2250 unpack, k, gfld, rc)
2252 if (rc /= 0)
call error_handler(
"READING T2M.", rc)
2259 print*,
"- CALL FieldScatter FOR INPUT GRID T2M."
2260 call esmf_fieldscatter(t2m_input_grid, dummy2d_8, rootpet=0,rc=rc)
2261 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2262 call error_handler(
"IN FieldScatter", rc)
2264 if (localpet == 0)
then
2266 print*,
"- READ Q2M."
2278 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2279 unpack, k, gfld, rc)
2280 if (rc /=0)
call error_handler(
"READING Q2M.", rc)
2288 print*,
"- CALL FieldScatter FOR INPUT GRID Q2M."
2289 call esmf_fieldscatter(q2m_input_grid,dummy2d_8, rootpet=0,rc=rc)
2290 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2291 call error_handler(
"IN FieldScatter", rc)
2293 if (localpet == 0)
then
2295 print*,
"- READ SKIN TEMPERATURE."
2306 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2307 unpack, k, gfld, rc)
2309 if (rc /= 0 )
call error_handler(
"READING SKIN TEMPERATURE.", rc)
2314 tsk_save(:,:) = dummy2d_8
2318 if(slmsk_save(i,j) == 0 .and. dummy2d_8(i,j) < 271.2)
then
2320 dummy2d_8(i,j) = 271.2
2322 if(slmsk_save(i,j) == 0 .and. dummy2d_8(i,j) > 310.)
then
2324 dummy2d_8(i,j) = 310.0
2331 print*,
"- CALL FieldScatter FOR INPUT GRID SKIN TEMPERATURE"
2332 call esmf_fieldscatter(skin_temp_input_grid,dummy2d_8,rootpet=0, rc=rc)
2333 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2334 call error_handler(
"IN FieldScatter", rc)
2338 if (localpet == 0) dummy2d_8 = 0.0
2340 print*,
"- CALL FieldScatter FOR INPUT GRID SRFLAG"
2341 call esmf_fieldscatter(srflag_input_grid,dummy2d_8, rootpet=0,rc=rc)
2342 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2343 call error_handler(
"IN FieldScatter", rc)
2345 if (localpet == 0)
then
2347 print*,
"- READ SOIL TYPE."
2358 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2359 unpack, k, gfld, rc)
2363 dummy2d = reshape(real(gfld%fld,kind=esmf_kind_r4) , (/
i_input,
j_input/))
2367 if (rc /= 0 .and. (trim(to_upper(
external_model))==
"HRRR" .or. rap_latlon) .and. geo_file .ne.
"NULL")
then
2371 print*,
"OPEN GEOGRID FILE ", trim(geo_file)
2372 rc = nf90_open(geo_file,nf90_nowrite,ncid2d)
2373 call netcdf_err(rc,
"READING GEOGRID FILE")
2375 print*,
"INQURE ABOUT DIM IDS"
2376 rc = nf90_inq_dimid(ncid2d,
"west_east",varid)
2377 call netcdf_err(rc,
"READING west_east DIMENSION FROM GEOGRID FILE")
2379 rc = nf90_inquire_dimension(ncid2d,varid,len=varsize)
2380 call netcdf_err(rc,
"READING west_east DIMENSION SIZE")
2381 if (varsize .ne.
i_input)
call error_handler (
"GEOGRID FILE GRID SIZE DIFFERS FROM INPUT DATA.", -1)
2383 print*,
"INQUIRE ABOUT SOIL TYPE FROM GEOGRID FILE"
2384 rc = nf90_inq_varid(ncid2d,
"SCT_DOM",varid)
2385 call netcdf_err(rc,
"FINDING SCT_DOM IN GEOGRID FILE")
2387 print*,
"READ SOIL TYPE FROM GEOGRID FILE "
2388 rc = nf90_get_var(ncid2d,varid,dummy2d)
2389 call netcdf_err(rc,
"READING SCT_DOM FROM FILE")
2391 print*,
"INQUIRE ABOUT SOIL TYPE FRACTIONS FROM GEOGRID FILE"
2392 rc = nf90_inq_varid(ncid2d,
"SOILCTOP",varid)
2393 call netcdf_err(rc,
"FINDING SOILCTOP IN GEOGRID FILE")
2396 print*,
"READ SOIL TYPE FRACTIONS FROM GEOGRID FILE "
2397 rc = nf90_get_var(ncid2d,varid,dummy3d_stype)
2398 call netcdf_err(rc,
"READING SCT_DOM FROM FILE")
2400 print*,
"CLOSE GEOGRID FILE "
2401 iret = nf90_close(ncid2d)
2406 allocate(dummy1d(16))
2409 if(dummy2d(i,j) == 14.0_esmf_kind_r4 .and. slmsk_save(i,j) == 1)
then
2410 dummy1d(:) = real(dummy3d_stype(i,j,:),kind=esmf_kind_r4)
2411 dummy1d(14) = 0.0_esmf_kind_r4
2412 dummy2d(i,j) = real(maxloc(dummy1d, 1),esmf_kind_r4)
2417 deallocate(dummy3d_stype)
2420 if ((rc /= 0 .and. trim(to_upper(
external_model)) /=
"HRRR" .and. .not. rap_latlon) &
2421 .or. (rc /= 0 .and. (trim(to_upper(
external_model)) ==
"HRRR" .or. rap_latlon)))
then
2423 call error_handler(
"COULD NOT FIND SOIL TYPE IN FILE. PLEASE SET SOTYP_FROM_CLIMO=.TRUE. . EXITING", rc)
2427 call get_var_cond(vname,this_miss_var_method=method, this_miss_var_value=
value, &
2429 call handle_grib_error(vname, slev ,method,
value,varnum,
read_from_input,rc, var= dummy2d)
2431 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. WILL NOT "//&
2432 "SCALE SOIL MOISTURE FOR DIFFERENCES IN SOIL TYPE. "
2433 dummy2d(:,:) = -99999.0_esmf_kind_r4
2445 if(dummy2d(i,j) == 14.0_esmf_kind_r4 .and. slmsk_save(i,j) == 1) dummy2d(i,j) = -99999.9_esmf_kind_r4
2450 dummy2d_8 = real(dummy2d,esmf_kind_r8)
2452 where(slmsk_save == 1) dummy2d_i = 1
2455 deallocate(dummy2d_i)
2457 dummy2d_8=real(dummy2d,esmf_kind_r8)
2460 print*,
'sotype ',maxval(dummy2d_8),minval(dummy2d_8)
2464 print*,
"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
2465 call esmf_fieldscatter(soil_type_input_grid,dummy2d_8, rootpet=0, rc=rc)
2466 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2467 call error_handler(
"IN FieldScatter", rc)
2478 if (localpet == 0)
then
2480 print*,
"- READ VEG FRACTION."
2491 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2492 unpack, k, gfld, rc)
2495 err_msg=
"COULD NOT FIND VEGETATION FRACTION IN FILE. PLEASE SET VGFRC_FROM_CLIMO=.TRUE."
2496 call error_handler(err_msg, rc)
2498 if (maxval(gfld%fld) > 2.0) gfld%fld = gfld%fld / 100.0
2506 print*,
"- CALL FieldScatter FOR INPUT GRID VEG GREENNESS."
2507 call esmf_fieldscatter(veg_greenness_input_grid,dummy2d_8, rootpet=0, rc=rc)
2508 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2509 call error_handler(
"IN FieldScatter", rc)
2515 if (localpet == 0)
then
2517 print*,
"- READ MIN VEG FRACTION."
2529 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2530 unpack, k, gfld, rc)
2534 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2535 unpack, k, gfld, rc)
2538 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2539 unpack, k, gfld, rc)
2540 err_msg=
"COULD NOT FIND MIN VEGETATION FRACTION IN FILE. SET MINMAX_VGFRC_FROM_CLIMO=.TRUE."
2541 if (rc/=0)
call error_handler(err_msg, rc)
2545 if (maxval(gfld%fld) > 2.0) gfld%fld = gfld%fld / 100.0
2546 print*,
'vfrac min ', maxval(gfld%fld),minval(gfld%fld)
2551 print*,
"- CALL FieldScatter FOR INPUT GRID MIN VEG GREENNESS."
2552 call esmf_fieldscatter(min_veg_greenness_input_grid,dummy2d_8, rootpet=0, rc=rc)
2553 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2554 call error_handler(
"IN FieldScatter", rc)
2556 if (localpet == 0)
then
2558 print*,
"- READ MAX VEG FRACTION."
2569 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2570 unpack, k, gfld, rc)
2573 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2574 unpack, k, gfld, rc)
2577 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2578 unpack, k, gfld, rc)
2579 err_msg=
"COULD NOT FIND MAX VEGETATION FRACTION IN FILE. SET MINMAX_VGFRC_FROM_CLIMO=.TRUE."
2580 if (rc <= 0)
call error_handler(err_msg, rc)
2584 if (maxval(gfld%fld) > 2.0) gfld%fld = gfld%fld / 100.0
2590 print*,
"- CALL FieldScatter FOR INPUT GRID MAX VEG GREENNESS."
2591 call esmf_fieldscatter(max_veg_greenness_input_grid,dummy2d_8,rootpet=0, rc=rc)
2592 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2593 call error_handler(
"IN FieldScatter", rc)
2599 if (localpet == 0)
then
2601 print*,
"- READ LAI."
2612 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2613 unpack, k, gfld, rc)
2615 err_msg=
"COULD NOT FIND LAI IN FILE. SET LAI_FROM_CLIMO=.TRUE."
2616 if (rc /= 0)
call error_handler(err_msg, rc)
2623 print*,
"- CALL FieldScatter FOR INPUT GRID LAI."
2624 call esmf_fieldscatter(lai_input_grid,dummy2d_8,rootpet=0, rc=rc)
2625 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2626 call error_handler(
"IN FieldScatter", rc)
2630 if (localpet == 0)
then
2632 print*,
"- READ SEAICE DEPTH."
2635 call get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=
value, &
2647 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2648 unpack, k, gfld, rc)
2651 call handle_grib_error(vname, slev ,method,
value,varnum,
read_from_input,rc,var8=dummy2d_8)
2653 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL BE"//&
2654 " REPLACED WITH CLIMO. SET A FILL "// &
2655 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
2656 dummy2d_8(:,:) = 0.0
2665 print*,
"- CALL FieldScatter FOR INPUT GRID SEAICE DEPTH."
2666 call esmf_fieldscatter(seaice_depth_input_grid,dummy2d_8, rootpet=0, rc=rc)
2667 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2668 call error_handler(
"IN FieldScatter", rc)
2670 if (localpet == 0)
then
2672 print*,
"- READ TPRCP."
2675 call get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=
value, &
2681 call handle_grib_error(vname, slev ,method,
value,varnum,
read_from_input,rc, var8=dummy2d_8)
2683 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
2684 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
2685 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
2689 print*,
'tprcp ',maxval(dummy2d_8),minval(dummy2d_8)
2693 print*,
"- CALL FieldScatter FOR INPUT GRID TPRCP."
2694 call esmf_fieldscatter(tprcp_input_grid,dummy2d_8, rootpet=0, rc=rc)
2695 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2696 call error_handler(
"IN FieldScatter", rc)
2698 if (localpet == 0)
then
2700 print*,
"- READ FFMM."
2703 call get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=
value, &
2709 call handle_grib_error(vname, slev ,method,
value,varnum,
read_from_input,rc, var8=dummy2d_8)
2711 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
2712 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
2713 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
2714 dummy2d_8(:,:) = 0.0
2717 print*,
'ffmm ',maxval(dummy2d_8),minval(dummy2d_8)
2721 print*,
"- CALL FieldScatter FOR INPUT GRID FFMM"
2722 call esmf_fieldscatter(ffmm_input_grid,dummy2d_8, rootpet=0, rc=rc)
2723 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2724 call error_handler(
"IN FieldScatter", rc)
2726 if (localpet == 0)
then
2728 print*,
"- READ USTAR."
2731 call get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=
value, &
2743 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2744 unpack, k, gfld, rc)
2747 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2748 unpack, k, gfld, rc)
2755 call handle_grib_error(vname, slev ,method,
value,varnum,
read_from_input,rc, var8=dummy2d_8)
2757 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL "//&
2758 "REPLACED WITH CLIMO. SET A FILL "// &
2759 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
2760 dummy2d_8(:,:) = 0.0
2766 print*,
"- CALL FieldScatter FOR INPUT GRID USTAR"
2767 call esmf_fieldscatter(ustar_input_grid,dummy2d_8, rootpet=0, rc=rc)
2768 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2769 call error_handler(
"IN FieldScatter", rc)
2771 if (localpet == 0)
then
2773 print*,
"- READ F10M."
2775 slev=
":10 m above ground:"
2776 call get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=
value, &
2781 call handle_grib_error(vname, slev ,method,
value,varnum,
read_from_input,rc, var8=dummy2d_8)
2783 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL NOT"//&
2784 " BE WRITTEN TO THE INPUT FILE. SET A FILL "// &
2785 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
2786 dummy2d_8(:,:) = 0.0
2789 print*,
'f10m ',maxval(dummy2d_8),minval(dummy2d_8)
2793 print*,
"- CALL FieldScatter FOR INPUT GRID F10M."
2794 call esmf_fieldscatter(f10m_input_grid,dummy2d_8, rootpet=0, rc=rc)
2795 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2796 call error_handler(
"IN FieldScatter", rc)
2798 if (localpet == 0)
then
2800 print*,
"- READ CANOPY MOISTURE CONTENT."
2803 call get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=
value, &
2815 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2816 unpack, k, gfld, rc)
2820 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2821 unpack, k, gfld, rc)
2825 print*,
'cnwat ', maxval(gfld%fld),minval(gfld%fld)
2829 call handle_grib_error(vname, slev ,method,
value,varnum,
read_from_input,rc, var8=dummy2d_8)
2831 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL"//&
2832 " REPLACED WITH CLIMO. SET A FILL "// &
2833 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
2840 print*,
"- CALL FieldScatter FOR INPUT GRID CANOPY MOISTURE CONTENT."
2841 call esmf_fieldscatter(canopy_mc_input_grid,dummy2d_8, rootpet=0, rc=rc)
2842 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2843 call error_handler(
"IN FieldScatter", rc)
2845 if (localpet == 0)
then
2850 call get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=
value, &
2862 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2863 unpack, k, gfld, rc)
2866 call handle_grib_error(vname, slev ,method,
value,varnum,
read_from_input,rc, var8= dummy2d_8)
2868 print*,
"WARNING: "//trim(vname)//
" NOT AVAILABLE IN FILE. THIS FIELD WILL BE"//&
2869 " REPLACED WITH CLIMO. SET A FILL "// &
2870 "VALUE IN THE VARMAP TABLE IF THIS IS NOT DESIRABLE."
2871 dummy2d_8(:,:) = 0.0
2874 gfld%fld = gfld%fld * 10.0
2881 print*,
"- CALL FieldScatter FOR INPUT GRID Z0."
2882 call esmf_fieldscatter(z0_input_grid,dummy2d_8, rootpet=0, rc=rc)
2883 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2884 call error_handler(
"IN FieldScatter", rc)
2886 if (localpet == 0)
then
2887 print*,
"- READ LIQUID SOIL MOISTURE."
2889 vname_file =
":SOILL:"
2890 call read_grib_soil(vname,vname_file,lugb, pdt_num,dummy3d)
2894 print*,
"- CALL FieldScatter FOR INPUT LIQUID SOIL MOISTURE."
2895 call esmf_fieldscatter(soilm_liq_input_grid, dummy3d, rootpet=0, rc=rc)
2896 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2897 call error_handler(
"IN FieldScatter", rc)
2899 if (localpet == 0)
then
2900 print*,
"- READ TOTAL SOIL MOISTURE."
2902 vname_file =
"var2_2_1_"
2903 call read_grib_soil(vname,vname_file,lugb, pdt_num,dummy3d)
2906 print*,
"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE."
2907 call esmf_fieldscatter(soilm_tot_input_grid, dummy3d, rootpet=0, rc=rc)
2908 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2909 call error_handler(
"IN FieldScatter", rc)
2917 print*,
"- CALL FieldGather for INPUT SOIL TYPE."
2918 call esmf_fieldgather(soil_type_input_grid, dummy2d_82, rootpet=0, tile=1, rc=rc)
2919 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
2920 call error_handler(
"IN FieldGather", rc)
2922 if (localpet == 0)
then
2924 print*,
"- READ VEG TYPE."
2935 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
2936 unpack, k, gfld, rc)
2940 call error_handler(
"COULD NOT FIND VEGETATION TYPE IN FILE. PLEASE SET VGTYP_FROM_CLIMO=.TRUE. . EXITING", rc)
2944 dummy2d_8(i,j) = 0.0
2945 if(slmsk_save(i,j) == 1 .and. dummy3d(i,j,1) > 0.99) &
2947 dummy2d_8(i,j) = real(veg_type_landice_input,esmf_kind_r8)
2958 if (dummy2d_8(i,j) == 15.0_esmf_kind_r8 .and. slmsk_save(i,j) == 1)
then
2959 if (dummy3d(i,j,1) < 0.6)
then
2960 dummy2d_8(i,j) = real(veg_type_landice_input,esmf_kind_r8)
2961 elseif (dummy3d(i,j,1) > 0.99)
then
2963 dummy2d_8(i,j) = 0.0_esmf_kind_r8
2964 dummy2d_82(i,j) = 0.0_esmf_kind_r8
2966 elseif (dummy2d_8(i,j) == 17.0_esmf_kind_r8 .and. slmsk_save(i,j)==0)
then
2967 dummy2d_8(i,j) = 0.0_esmf_kind_r8
2977 print*,
"- CALL FieldScatter FOR INPUT VEG TYPE."
2978 call esmf_fieldscatter(veg_type_input_grid, dummy2d_8, rootpet=0, rc=rc)
2979 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2980 call error_handler(
"IN FieldScatter", rc)
2982 print*,
"- CALL FieldScatter FOR INPUT SOIL TYPE."
2983 call esmf_fieldscatter(soil_type_input_grid, dummy2d_82, rootpet=0, rc=rc)
2984 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2985 call error_handler(
"IN FieldScatter", rc)
2987 deallocate(dummy2d_82)
2989 print*,
"- CALL FieldScatter FOR INPUT LANDSEA MASK."
2990 call esmf_fieldscatter(landsea_mask_input_grid,real(slmsk_save,esmf_kind_r8),rootpet=0, rc=rc)
2991 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
2992 call error_handler(
"IN FieldScatter", rc)
3001 if (localpet == 0)
then
3002 print*,
"- READ SOIL TEMPERATURE."
3004 vname_file =
":TSOIL:"
3005 call read_grib_soil(vname,vname_file,lugb,pdt_num,dummy3d)
3006 call check_soilt(dummy3d,slmsk_save,tsk_save,icet_default,
i_input,
j_input,lsoil_input)
3007 deallocate(tsk_save)
3010 deallocate(slmsk_save)
3012 print*,
"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
3013 call esmf_fieldscatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
3014 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3015 call error_handler(
"IN FieldScatter", rc)
3018 deallocate(dummy2d_8)
3020 if (localpet == 0)
call baclose(lugb, rc)
3022 end subroutine read_input_sfc_grib2_file
3027 subroutine init_sfc_esmf_fields
3033 print*,
"- CALL FieldCreate FOR INPUT GRID LANDSEA MASK."
3034 landsea_mask_input_grid = esmf_fieldcreate(input_grid, &
3035 typekind=esmf_typekind_r8, &
3036 staggerloc=esmf_staggerloc_center, rc=rc)
3037 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3038 call error_handler(
"IN FieldCreate", rc)
3040 print*,
"- CALL FieldCreate FOR INPUT GRID Z0."
3041 z0_input_grid = esmf_fieldcreate(input_grid, &
3042 typekind=esmf_typekind_r8, &
3043 staggerloc=esmf_staggerloc_center, rc=rc)
3044 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3045 call error_handler(
"IN FieldCreate", rc)
3047 print*,
"- CALL FieldCreate FOR INPUT GRID VEGETATION TYPE."
3048 veg_type_input_grid = esmf_fieldcreate(input_grid, &
3049 typekind=esmf_typekind_r8, &
3050 staggerloc=esmf_staggerloc_center, rc=rc)
3051 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3052 call error_handler(
"IN FieldCreate", rc)
3054 print*,
"- CALL FieldCreate FOR INPUT GRID CANOPY MOISTURE CONTENT."
3055 canopy_mc_input_grid = esmf_fieldcreate(input_grid, &
3056 typekind=esmf_typekind_r8, &
3057 staggerloc=esmf_staggerloc_center, rc=rc)
3058 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3059 call error_handler(
"IN FieldCreate", rc)
3061 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE FRACTION."
3062 seaice_fract_input_grid = esmf_fieldcreate(input_grid, &
3063 typekind=esmf_typekind_r8, &
3064 staggerloc=esmf_staggerloc_center, rc=rc)
3065 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3066 call error_handler(
"IN FieldCreate", rc)
3068 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE DEPTH."
3069 seaice_depth_input_grid = esmf_fieldcreate(input_grid, &
3070 typekind=esmf_typekind_r8, &
3071 staggerloc=esmf_staggerloc_center, rc=rc)
3072 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3073 call error_handler(
"IN FieldCreate", rc)
3075 print*,
"- CALL FieldCreate FOR INPUT GRID SEAICE SKIN TEMPERATURE."
3076 seaice_skin_temp_input_grid = esmf_fieldcreate(input_grid, &
3077 typekind=esmf_typekind_r8, &
3078 staggerloc=esmf_staggerloc_center, rc=rc)
3079 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3080 call error_handler(
"IN FieldCreate", rc)
3082 print*,
"- CALL FieldCreate FOR INPUT GRID SNOW DEPTH."
3083 snow_depth_input_grid = esmf_fieldcreate(input_grid, &
3084 typekind=esmf_typekind_r8, &
3085 staggerloc=esmf_staggerloc_center, rc=rc)
3086 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3087 call error_handler(
"IN FieldCreate", rc)
3089 print*,
"- CALL FieldCreate FOR INPUT GRID SNOW LIQUID EQUIVALENT."
3090 snow_liq_equiv_input_grid = esmf_fieldcreate(input_grid, &
3091 typekind=esmf_typekind_r8, &
3092 staggerloc=esmf_staggerloc_center, rc=rc)
3093 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3094 call error_handler(
"IN FieldCreate", rc)
3096 print*,
"- CALL FieldCreate FOR INPUT GRID T2M."
3097 t2m_input_grid = esmf_fieldcreate(input_grid, &
3098 typekind=esmf_typekind_r8, &
3099 staggerloc=esmf_staggerloc_center, rc=rc)
3100 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3101 call error_handler(
"IN FieldCreate", rc)
3103 print*,
"- CALL FieldCreate FOR INPUT GRID Q2M."
3104 q2m_input_grid = esmf_fieldcreate(input_grid, &
3105 typekind=esmf_typekind_r8, &
3106 staggerloc=esmf_staggerloc_center, rc=rc)
3107 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3108 call error_handler(
"IN FieldCreate", rc)
3110 print*,
"- CALL FieldCreate FOR INPUT GRID TPRCP."
3111 tprcp_input_grid = esmf_fieldcreate(input_grid, &
3112 typekind=esmf_typekind_r8, &
3113 staggerloc=esmf_staggerloc_center, rc=rc)
3114 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3115 call error_handler(
"IN FieldCreate", rc)
3117 print*,
"- CALL FieldCreate FOR INPUT GRID F10M."
3118 f10m_input_grid = esmf_fieldcreate(input_grid, &
3119 typekind=esmf_typekind_r8, &
3120 staggerloc=esmf_staggerloc_center, rc=rc)
3121 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3122 call error_handler(
"IN FieldCreate", rc)
3124 print*,
"- CALL FieldCreate FOR INPUT GRID USTAR."
3125 ustar_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__)) &
3129 call error_handler(
"IN FieldCreate", rc)
3131 print*,
"- CALL FieldCreate FOR INPUT GRID FFMM."
3132 ffmm_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__)) &
3136 call error_handler(
"IN FieldCreate", rc)
3138 print*,
"- CALL FieldCreate FOR INPUT GRID SRFLAG."
3139 srflag_input_grid = esmf_fieldcreate(input_grid, &
3140 typekind=esmf_typekind_r8, &
3141 staggerloc=esmf_staggerloc_center, rc=rc)
3142 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3143 call error_handler(
"IN FieldCreate", rc)
3145 print*,
"- CALL FieldCreate FOR INPUT SKIN TEMPERATURE."
3146 skin_temp_input_grid = esmf_fieldcreate(input_grid, &
3147 typekind=esmf_typekind_r8, &
3148 staggerloc=esmf_staggerloc_center, rc=rc)
3149 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3150 call error_handler(
"IN FieldCreate", rc)
3152 print*,
"- CALL FieldCreate FOR INPUT SOIL TYPE."
3153 soil_type_input_grid = esmf_fieldcreate(input_grid, &
3154 typekind=esmf_typekind_r8, &
3155 staggerloc=esmf_staggerloc_center, rc=rc)
3156 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3157 call error_handler(
"IN FieldCreate", rc)
3159 print*,
"- CALL FieldCreate FOR INPUT TERRAIN."
3161 typekind=esmf_typekind_r8, &
3162 staggerloc=esmf_staggerloc_center, rc=rc)
3163 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3164 call error_handler(
"IN FieldCreate", rc)
3166 print*,
"- CALL FieldCreate FOR INPUT SOIL TEMPERATURE."
3167 soil_temp_input_grid = esmf_fieldcreate(input_grid, &
3168 typekind=esmf_typekind_r8, &
3169 staggerloc=esmf_staggerloc_center, &
3170 ungriddedlbound=(/1/), &
3171 ungriddedubound=(/lsoil_input/), rc=rc)
3172 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3173 call error_handler(
"IN FieldCreate", rc)
3175 print*,
"- CALL FieldCreate FOR INPUT TOTAL SOIL MOISTURE."
3176 soilm_tot_input_grid = esmf_fieldcreate(input_grid, &
3177 typekind=esmf_typekind_r8, &
3178 staggerloc=esmf_staggerloc_center, &
3179 ungriddedlbound=(/1/), &
3180 ungriddedubound=(/lsoil_input/), rc=rc)
3181 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3182 call error_handler(
"IN FieldCreate", rc)
3184 print*,
"- CALL FieldCreate FOR INPUT LIQUID SOIL MOISTURE."
3185 soilm_liq_input_grid = esmf_fieldcreate(input_grid, &
3186 typekind=esmf_typekind_r8, &
3187 staggerloc=esmf_staggerloc_center, &
3188 ungriddedlbound=(/1/), &
3189 ungriddedubound=(/lsoil_input/), rc=rc)
3190 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3191 call error_handler(
"IN FieldCreate", rc)
3195 if (.not. vgfrc_from_climo)
then
3196 print*,
"- CALL FieldCreate FOR INPUT VEGETATION GREENNESS."
3197 veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
3198 typekind=esmf_typekind_r8, &
3199 staggerloc=esmf_staggerloc_center, rc=rc)
3200 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
3201 call error_handler(
"IN FieldCreate", rc)
3204 if (.not. minmax_vgfrc_from_climo)
then
3205 print*,
"- CALL FieldCreate FOR INPUT MIN VEGETATION GREENNESS."
3206 min_veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
3207 typekind=esmf_typekind_r8, &
3208 staggerloc=esmf_staggerloc_center, rc=rc)
3209 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3210 call error_handler(
"IN FieldCreate", rc)
3212 print*,
"- CALL FieldCreate FOR INPUT MAX VEGETATION GREENNESS."
3213 max_veg_greenness_input_grid = esmf_fieldcreate(input_grid, &
3214 typekind=esmf_typekind_r8, &
3215 staggerloc=esmf_staggerloc_center, rc=rc)
3216 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3217 call error_handler(
"IN FieldCreate", rc)
3220 if (.not. lai_from_climo)
then
3221 print*,
"- CALL FieldCreate FOR INPUT LEAF AREA INDEX."
3222 lai_input_grid = esmf_fieldcreate(input_grid, &
3223 typekind=esmf_typekind_r8, &
3224 staggerloc=esmf_staggerloc_center, rc=rc)
3225 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__))&
3226 call error_handler(
"IN FieldCreate", rc)
3228 end subroutine init_sfc_esmf_fields
3240 SUBROUTINE read_fv3_grid_data_netcdf(FIELD,TILE_NUM,IMO,JMO,LMO, &
3241 SFCDATA, SFCDATA_3D)
3245 CHARACTER(LEN=*),
INTENT(IN) :: FIELD
3247 INTEGER,
INTENT(IN) :: IMO, JMO, LMO, TILE_NUM
3249 REAL(ESMF_KIND_R8),
INTENT(OUT),
OPTIONAL :: SFCDATA(IMO,JMO)
3250 REAL(ESMF_KIND_R8),
INTENT(OUT),
OPTIONAL :: SFCDATA_3D(IMO,JMO,LMO)
3252 CHARACTER(LEN=256) :: TILEFILE
3254 INTEGER :: ERROR, NCID, ID_VAR
3256 tilefile = trim(data_dir_input_grid) //
"/" // trim(sfc_files_input_grid(tile_num))
3258 print*,
'WILL READ ',trim(field),
' FROM: ', trim(tilefile)
3260 error=nf90_open(trim(tilefile),nf90_nowrite,ncid)
3261 CALL netcdf_err(error,
'OPENING: '//trim(tilefile) )
3263 error=nf90_inq_varid(ncid, field, id_var)
3264 CALL netcdf_err(error,
'READING FIELD ID' )
3266 IF (
PRESENT(sfcdata_3d))
THEN
3267 error=nf90_get_var(ncid, id_var, sfcdata_3d)
3268 CALL netcdf_err(error,
'READING FIELD' )
3270 error=nf90_get_var(ncid, id_var, sfcdata)
3271 CALL netcdf_err(error,
'READING FIELD' )
3274 error = nf90_close(ncid)
3276 END SUBROUTINE read_fv3_grid_data_netcdf
3286 subroutine read_grib_soil(vname, vname_file, lugb, pdt_num, dummy3d)
3292 character(len=20),
intent(in) :: vname,vname_file
3294 integer,
intent(in) :: lugb, pdt_num
3296 real(esmf_kind_r8),
intent(inout) :: dummy3d(:,:,:)
3298 character(len=50) :: slevs(lsoil_input)
3299 character(len=50) :: method
3301 integer :: varnum, i, j, k, rc, rc2
3302 integer :: jdisc, jgdtn, jpdtn, lugi
3303 integer :: jids(200), jgdt(200), jpdt(200)
3304 integer :: iscale1, iscale2
3308 real(esmf_kind_r4),
allocatable :: dummy2d(:,:)
3309 real(esmf_kind_r4) :: value
3311 type(gribfield) :: gfld
3313 allocate(dummy2d(i_input,j_input))
3315 if(lsoil_input == 4)
then
3316 slevs = (/
character(24)::
':0-0.1 m below ground:',
':0.1-0.4 m below ground:', &
3317 ':0.4-1 m below ground:',
':1-2 m below ground:'/)
3318 elseif(lsoil_input == 9)
then
3319 slevs = (/
character(26)::
':0-0 m below ground',
':0.01-0.01 m below ground:',
':0.04-0.04 m below ground:', &
3320 ':0.1-0.1 m below ground:',
':0.3-0.3 m below ground:',
':0.6-0.6 m below ground:', &
3321 ':1-1 m below ground:',
':1.6-1.6 m below ground:',
':3-3 m below ground:'/)
3324 call error_handler(
"reading soil levels. File must have 4 or 9 soil levels.", rc)
3327 call get_var_cond(vname,this_miss_var_method=method,this_miss_var_value=
value, &
3339 if (trim(vname) ==
'soilt') jpdt(2) = 2
3340 if (trim(vname) ==
'soilw') jpdt(2) = 192
3341 if (trim(vname) ==
'soill')
then
3349 do i = 1,lsoil_input
3351 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
3352 unpack, k, gfld, rc2)
3355 call handle_grib_error(vname_file, slevs(i),method,
value,varnum,read_from_input,rc,var=dummy2d)
3356 if (rc==1 .and. trim(vname) /=
"soill")
then
3358 call error_handler(
"READING IN "//trim(vname)//
". SET A FILL "// &
3359 "VALUE IN THE VARMAP TABLE IF THIS ERROR IS NOT DESIRABLE.",rc)
3361 dummy3d(:,:,:) = 0.0_esmf_kind_r8
3367 iscale1 = 10 ** gfld%ipdtmpl(11)
3368 iscale2 = 10 ** gfld%ipdtmpl(14)
3371 dummy2d = reshape(real(gfld%fld,kind=esmf_kind_r4), (/i_input,j_input/) )
3376 dummy3d(:,:,i) = real(dummy2d,esmf_kind_r8)
3382 end subroutine read_grib_soil
3387 subroutine cleanup_input_sfc_data
3393 print*,
"- CALL FieldDestroy FOR INPUT GRID FIELDS."
3395 call esmf_fielddestroy(canopy_mc_input_grid, rc=rc)
3396 call esmf_fielddestroy(f10m_input_grid, rc=rc)
3397 call esmf_fielddestroy(ffmm_input_grid, rc=rc)
3398 if (.not. convert_nst)
then
3399 call esmf_fielddestroy(landsea_mask_input_grid, rc=rc)
3401 call esmf_fielddestroy(q2m_input_grid, rc=rc)
3402 call esmf_fielddestroy(seaice_depth_input_grid, rc=rc)
3403 call esmf_fielddestroy(seaice_fract_input_grid, rc=rc)
3404 call esmf_fielddestroy(seaice_skin_temp_input_grid, rc=rc)
3405 call esmf_fielddestroy(skin_temp_input_grid, rc=rc)
3406 call esmf_fielddestroy(snow_depth_input_grid, rc=rc)
3407 call esmf_fielddestroy(snow_liq_equiv_input_grid, rc=rc)
3408 call esmf_fielddestroy(soil_temp_input_grid, rc=rc)
3409 call esmf_fielddestroy(soil_type_input_grid, rc=rc)
3410 call esmf_fielddestroy(soilm_liq_input_grid, rc=rc)
3411 call esmf_fielddestroy(soilm_tot_input_grid, rc=rc)
3412 call esmf_fielddestroy(srflag_input_grid, rc=rc)
3413 call esmf_fielddestroy(t2m_input_grid, rc=rc)
3414 call esmf_fielddestroy(tprcp_input_grid, rc=rc)
3415 call esmf_fielddestroy(ustar_input_grid, rc=rc)
3416 call esmf_fielddestroy(veg_type_input_grid, rc=rc)
3417 call esmf_fielddestroy(z0_input_grid, rc=rc)
3419 if (.not. vgfrc_from_climo)
then
3420 call esmf_fielddestroy(veg_greenness_input_grid, rc=rc)
3422 if (.not. minmax_vgfrc_from_climo)
then
3423 call esmf_fielddestroy(min_veg_greenness_input_grid, rc=rc)
3424 call esmf_fielddestroy(max_veg_greenness_input_grid, rc=rc)
3426 if (.not. lai_from_climo)
then
3427 call esmf_fielddestroy(lai_input_grid, rc=rc)
3430 end subroutine cleanup_input_sfc_data
3432 end module sfc_input_data
Sets up the ESMF grid objects for the input data grid and target FV3 grid.
type(esmf_grid), public input_grid
input grid esmf grid object
integer, public i_input
i-dimension of input grid (or of each global tile)
character(len=50), public input_grid_type
map projection of input grid
integer, public num_tiles_input_grid
Number of tiles, input grid.
integer, public j_input
j-dimension of input grid (or of each global tile)
This module contains code to read the setup namelist file, handle the varmap file for GRIB2 data,...
character(len=500), public geogrid_file_input_grid
Name of "geogrid" file, which contains static surface fields on the input grid.
character(len=500), dimension(6), public sfc_files_input_grid
File names containing input surface data.
character(len=500), public orog_dir_input_grid
Directory containing the input grid orography files.
logical, dimension(:), allocatable, public read_from_input
When false, variable was not read from GRIB2 input file.
character(len=500), public grib2_file_input_grid
REQUIRED.
character(len=500), dimension(6), public orog_files_input_grid
Input grid orography files.
logical, public lai_from_climo
If false, interpolate leaf area index from the input data to the target grid instead of using data fr...
logical, public vgfrc_from_climo
If false, interpolate vegetation fraction from the input data to the target grid instead of using dat...
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.
character(len=500), public data_dir_input_grid
Directory containing input atm or sfc files.
logical, public sotyp_from_climo
If false, interpolate soil type from the input data to the target grid instead of using data from sta...
logical, public vgtyp_from_climo
If false, interpolate vegetation type from the input data to the target grid instead of using data fr...
character(len=25), public input_type
Input data type:
character(len=20), public external_model
The model that the input data is derived from.
logical, public convert_nst
Convert nst data when true.
logical, public minmax_vgfrc_from_climo
If false, interpolate min/max vegetation fraction from the input data to the target grid instead of u...
Replace undefined values with a valid value.
subroutine, public search(field, mask, idim, jdim, tile, field_num, latitude, terrain_land, soilt_climo)
Replace undefined surface values.