54 integer,
intent(in) :: localpet
56 integer :: error, tile, i, j
58 real(esmf_kind_r8),
allocatable :: data_one_tile(:,:)
59 real(esmf_kind_r8),
allocatable :: max_data_one_tile(:,:)
60 real(esmf_kind_r8),
allocatable :: min_data_one_tile(:,:)
65 allocate(data_one_tile(0,0))
75 if (localpet == 0)
then 78 print*,
"- CALL FieldScatter FOR TARGET GRID SLOPE TYPE." 80 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
89 if (localpet == 0)
then 92 print*,
"- CALL FieldScatter FOR TARGET GRID MAXIMUM SNOW ALBEDO." 94 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
103 if (localpet == 0)
then 106 print*,
"- CALL FieldScatter FOR TARGET GRID SOIL TYPE." 108 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
117 if (localpet == 0)
then 120 print*,
"- CALL FieldScatter FOR TARGET GRID VEGETATION TYPE." 122 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
130 if (localpet == 0)
then 134 allocate(max_data_one_tile(0,0))
135 allocate(min_data_one_tile(0,0))
139 if (localpet == 0)
then 141 max_data_one_tile, min_data_one_tile)
143 print*,
"- CALL FieldScatter FOR TARGET GRID VEGETATION GREENNESS." 145 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
147 print*,
"- CALL FieldScatter FOR TARGET GRID MAXIMUM VEGETATION GREENNESS." 149 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
151 print*,
"- CALL FieldScatter FOR TARGET GRID MINIMUM VEGETATION GREENNESS." 153 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
157 deallocate(max_data_one_tile, min_data_one_tile)
164 if (localpet == 0)
then 167 print*,
"- CALL FieldScatter FOR TARGET GRID SUBSTRATE TEMPERATURE." 169 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
178 if (localpet == 0)
then 181 print*,
"- CALL FieldScatter FOR TARGET GRID ALVSF." 182 call esmf_fieldscatter(
alvsf_target_grid, data_one_tile, rootpet=0, tile=tile, rc=error)
183 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
188 if (localpet == 0)
then 191 print*,
"- CALL FieldScatter FOR TARGET GRID ALVWF." 192 call esmf_fieldscatter(
alvwf_target_grid, data_one_tile, rootpet=0, tile=tile, rc=error)
193 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
198 if (localpet == 0)
then 201 print*,
"- CALL FieldScatter FOR TARGET GRID ALNSF." 202 call esmf_fieldscatter(
alnsf_target_grid, data_one_tile, rootpet=0, tile=tile, rc=error)
203 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
208 if (localpet == 0)
then 211 print*,
"- CALL FieldScatter FOR TARGET GRID ALNWF." 212 call esmf_fieldscatter(
alnwf_target_grid, data_one_tile, rootpet=0, tile=tile, rc=error)
213 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
222 if (localpet == 0)
then 225 print*,
"- CALL FieldScatter FOR TARGET GRID FACSF." 226 call esmf_fieldscatter(
facsf_target_grid, data_one_tile, rootpet=0, tile=tile, rc=error)
227 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
229 if (localpet == 0)
then 232 if (data_one_tile(i,j) >= 0.0)
then 233 data_one_tile(i,j) = 1.0 - data_one_tile(i,j)
238 call esmf_fieldscatter(
facwf_target_grid, data_one_tile, rootpet=0, tile=tile, rc=error)
239 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
243 deallocate(data_one_tile)
260 data_one_tile, max_data_one_tile, &
270 character(len=*),
intent(in) :: field
271 character(len=100) :: filename
272 character(len=500) :: the_file
274 integer,
intent(in) :: i_target, j_target, tile
276 real(esmf_kind_r8),
intent(out) :: data_one_tile(i_target,j_target)
277 real(esmf_kind_r8),
intent(out),
optional :: max_data_one_tile(i_target,j_target)
278 real(esmf_kind_r8),
intent(out),
optional :: min_data_one_tile(i_target,j_target)
280 integer :: bound1, bound2
281 integer :: error, ncid, id_var, n
282 integer :: i, j, id_time, num_times
283 integer :: idat(8), jdat(8)
284 integer,
allocatable :: days_since(:)
286 real(kind=4),
allocatable :: dummy(:,:,:)
287 real(esmf_kind_r8) :: num_days, num_days_rec1, rinc(5)
288 real(esmf_kind_r8) :: weight_rec1, weight_rec2
304 print*,
'- OPEN FILE ',trim(the_file)
305 error=nf90_open(trim(the_file),nf90_nowrite,ncid)
306 call netcdf_err(error,
'OPENING: '//trim(the_file) )
308 error=nf90_inq_dimid(ncid,
'time', id_time)
310 error=nf90_inquire_dimension(ncid, id_time, len=num_times)
311 call netcdf_err(error,
'READING TIME DIMENSION')
312 print*,
'- FILE CONTAINS ', num_times,
' TIME RECORDS.' 314 allocate(dummy(i_target,j_target,num_times))
315 error=nf90_inq_varid(ncid, field, id_var)
317 error=nf90_get_var(ncid, id_var, dummy)
320 if (num_times > 1)
then 321 allocate (days_since(num_times))
322 error=nf90_inq_varid(ncid,
'time', id_time)
323 error=nf90_get_var(ncid, id_time, days_since)
324 print*,
'- TIME RECORDS (DAYS SINCE): ', days_since
335 call w3difdat(jdat,idat,1,rinc)
337 if (rinc(1) <= days_since(n))
exit 341 if (bound1 == 0) bound1 = num_times
342 if (bound2 == num_times+1) bound2 = 1
343 print*,
"- BOUNDING TIME RECORDS: ", bound1, bound2
344 if (bound2 /= 1)
then 345 num_days = float(days_since(bound2)) - float(days_since(bound1))
346 num_days_rec1 = rinc(1) - float(days_since(bound1))
347 weight_rec2 = num_days_rec1 / num_days
348 weight_rec1 = 1.0 - weight_rec2
349 print*,
"- BOUNDING WEIGHTS ", weight_rec1, weight_rec2
351 num_days = (float(days_since(bound2)) + 1.0) + (365.0 - float(days_since(bound1)) - 1.0)
352 if (rinc(1) >= days_since(bound1))
then 353 num_days_rec1 = rinc(1) - float(days_since(bound1))
355 num_days_rec1 = (365.0 - float(days_since(bound1))) + rinc(1)
357 weight_rec2 = num_days_rec1 / num_days
358 weight_rec1 = 1.0 - weight_rec2
359 print*,
"- BOUNDING WEIGHTS ", weight_rec1, weight_rec2
364 data_one_tile(i,j) = (weight_rec1*dummy(i,j,bound1)) + (weight_rec2*dummy(i,j,bound2))
368 deallocate(days_since)
372 data_one_tile = dummy(:,:,1)
376 if (trim(field) ==
'vegetation_greenness')
then 380 max_data_one_tile(i,j) = maxval(dummy(i,j,:))
381 min_data_one_tile(i,j) = minval(dummy(i,j,:))
389 error = nf90_close(ncid)
404 print*,
"- CALL FieldCreate FOR TARGET GRID SLOPE TYPE." 406 typekind=esmf_typekind_r8, &
407 staggerloc=esmf_staggerloc_center, rc=error)
408 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
411 print*,
"- CALL FieldCreate FOR TARGET GRID MAXIMUM SNOW ALBEDO." 413 typekind=esmf_typekind_r8, &
414 staggerloc=esmf_staggerloc_center, rc=error)
415 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
418 print*,
"- CALL FieldCreate FOR TARGET GRID SOIL TYPE." 420 typekind=esmf_typekind_r8, &
421 staggerloc=esmf_staggerloc_center, rc=error)
422 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
425 print*,
"- CALL FieldCreate FOR TARGET GRID VEGETATION TYPE." 427 typekind=esmf_typekind_r8, &
428 staggerloc=esmf_staggerloc_center, rc=error)
429 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
432 print*,
"- CALL FieldCreate FOR TARGET GRID VEGETATION GREENNESS." 434 typekind=esmf_typekind_r8, &
435 staggerloc=esmf_staggerloc_center, rc=error)
436 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
439 print*,
"- CALL FieldCreate FOR TARGET GRID MAXIMUM VEGETATION GREENNESS." 441 typekind=esmf_typekind_r8, &
442 staggerloc=esmf_staggerloc_center, rc=error)
443 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
446 print*,
"- CALL FieldCreate FOR TARGET GRID MINIMUM VEGETATION GREENNESS." 448 typekind=esmf_typekind_r8, &
449 staggerloc=esmf_staggerloc_center, rc=error)
450 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
453 print*,
"- CALL FieldCreate FOR TARGET GRID SUBSTRATE TEMPERATURE." 455 typekind=esmf_typekind_r8, &
456 staggerloc=esmf_staggerloc_center, rc=error)
457 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
460 print*,
"- CALL FieldCreate FOR ALVSF." 462 typekind=esmf_typekind_r8, &
463 staggerloc=esmf_staggerloc_center, rc=error)
464 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
467 print*,
"- CALL FieldCreate FOR ALVWF." 469 typekind=esmf_typekind_r8, &
470 staggerloc=esmf_staggerloc_center, rc=error)
471 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
474 print*,
"- CALL FieldCreate FOR ALNSF." 476 typekind=esmf_typekind_r8, &
477 staggerloc=esmf_staggerloc_center, rc=error)
478 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
481 print*,
"- CALL FieldCreate FOR ALNWF." 483 typekind=esmf_typekind_r8, &
484 staggerloc=esmf_staggerloc_center, rc=error)
485 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
488 print*,
"- CALL FieldCreate FOR TARGET GRID FACSF." 490 typekind=esmf_typekind_r8, &
491 staggerloc=esmf_staggerloc_center, rc=error)
492 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
495 print*,
"- CALL FieldCreate FOR TARGET GRID FACWF." 497 typekind=esmf_typekind_r8, &
498 staggerloc=esmf_staggerloc_center, rc=error)
499 if(esmf_logfounderror(rctocheck=error,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
513 print*,
"- DESTROY STATIC FIELDS." integer, public j_target
j dimension of each global tile, or of a nest, target grid.
character(len=500), public fix_dir_target_grid
Directory containing target grid pre-computed fixed data (ex: soil type).
This module contains code to read the setup namelist file, handle the varmap file for GRIB2 data...
integer, public num_tiles_target_grid
Number of tiles, target grid.
subroutine, public create_static_fields
Create ESMF fields for static target grid data.
integer, public cycle_mon
Cycle month.
character(len=6), public cres_target_grid
Target grid resolution, i.e., C768.
type(esmf_field), public min_veg_greenness_target_grid
minimum annual greenness fraction
type(esmf_field), public max_veg_greenness_target_grid
maximum annual greenness fraction
type(esmf_field), public mxsno_albedo_target_grid
maximum snow albedo
Sets up the ESMF grid objects for the input data grid and target FV3 grid.
type(esmf_field), public alvwf_target_grid
visible white sky albedo
integer, public i_target
i dimension of each global tile, or of a nest, target grid.
integer, public cycle_day
Cycle day.
type(esmf_grid), public target_grid
target grid esmf grid object.
type(esmf_field), public alnsf_target_grid
near ir black sky albedo
subroutine, public cleanup_static_fields
Free up memory for fields in this module.
subroutine netcdf_err(err, string)
Error handler for netcdf.
type(esmf_field), public alvsf_target_grid
visible black sky albedo
type(esmf_field), public slope_type_target_grid
slope type
Reads static surface climatological data for the target FV3 grid (such as soil type and vegetation ty...
subroutine error_handler(string, rc)
General error handler.
type(esmf_field), public substrate_temp_target_grid
soil subtrate temperature
type(esmf_field), public veg_greenness_target_grid
vegetation greenness fraction
character(len=5), dimension(:), allocatable, public tiles_target_grid
Tile names of target grid.
type(esmf_field), public veg_type_target_grid
vegetation type
subroutine read_static_file(field, i_target, j_target, tile, data_one_tile, max_data_one_tile, min_data_one_tile)
Read static climatological data file.
integer, public cycle_hour
Cycle hour.
type(esmf_field), public facwf_target_grid
fractional coverage for weak zenith angle dependent albedo
subroutine, public get_static_fields(localpet)
Driver routine to read/time interpolate static/climo fields on the fv3 target grid.
type(esmf_field), public alnwf_target_grid
near ir white sky albedo
type(esmf_field), public facsf_target_grid
fractional coverage for strong zenith angle dependent albedo
type(esmf_field), public soil_type_target_grid
soil type