Skip to content

Commit

Permalink
Add logic to turn off the landice adjustments when
Browse files Browse the repository at this point in the history
processing fractional types.

Fixes ufs-community#709.
  • Loading branch information
GeorgeGayno-NOAA committed Nov 1, 2022
1 parent 2c8161a commit 3e147b5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 28 deletions.
54 changes: 32 additions & 22 deletions sorc/sfc_climo_gen.fd/interp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ subroutine interp(localpet, method, input_file)
use esmf
use netcdf
use model_grid
use program_setup, only : fract_vegsoil_type
use source_grid
use utils
use mpi
Expand Down Expand Up @@ -187,14 +188,16 @@ subroutine interp(localpet, method, input_file)

! These fields are adjusted at landice.

select case (trim(field_names(n)))
case ('substrate_temperature','vegetation_greenness','leaf_area_index','slope_type','soil_type')
if (localpet == 0) then
allocate(vegt_mdl_one_tile(i_mdl,j_mdl))
else
allocate(vegt_mdl_one_tile(0,0))
endif
end select
if (.not. fract_vegsoil_type) then
select case (trim(field_names(n)))
case ('substrate_temperature','vegetation_greenness','leaf_area_index','slope_type','soil_type')
if (localpet == 0) then
allocate(vegt_mdl_one_tile(i_mdl,j_mdl))
else
allocate(vegt_mdl_one_tile(0,0))
endif
end select
endif

OUTPUT_LOOP : do tile = 1, num_tiles

Expand All @@ -218,30 +221,37 @@ subroutine interp(localpet, method, input_file)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) &
call error_handler("IN FieldGather.", rc)

select case (trim(field_names(n)))
case ('substrate_temperature','vegetation_greenness','leaf_area_index','slope_type','soil_type')
print*,"- CALL FieldGather FOR MODEL GRID VEG TYPE."
call ESMF_FieldGather(vegt_field_mdl, vegt_mdl_one_tile, rootPet=0, tile=tile, rc=rc)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) &
if (.not. fract_vegsoil_type) then
select case (trim(field_names(n)))
case ('substrate_temperature','vegetation_greenness','leaf_area_index','slope_type','soil_type')
print*,"- CALL FieldGather FOR MODEL GRID VEG TYPE."
call ESMF_FieldGather(vegt_field_mdl, vegt_mdl_one_tile, rootPet=0, tile=tile, rc=rc)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) &
call error_handler("IN FieldGather.", rc)
end select
end select
endif

if (localpet == 0) then
print*,'- CALL SEARCH FOR TILE ',tile
call search (data_mdl_one_tile, mask_mdl_one_tile, i_mdl, j_mdl, tile, field_names(n))
select case (field_names(n))
case ('substrate_temperature','vegetation_greenness','leaf_area_index','slope_type','soil_type')
call adjust_for_landice (data_mdl_one_tile, vegt_mdl_one_tile, i_mdl, j_mdl, field_names(n))
end select
if (.not. fract_vegsoil_type) then
select case (field_names(n))
case ('substrate_temperature','vegetation_greenness','leaf_area_index','slope_type','soil_type')
print*,'before adjust ice ',maxval(vegt_mdl_one_tile),minval(vegt_mdl_one_tile)
call adjust_for_landice (data_mdl_one_tile, vegt_mdl_one_tile, i_mdl, j_mdl, field_names(n))
end select
endif
where(mask_mdl_one_tile == 0) data_mdl_one_tile = missing
call output (data_mdl_one_tile, lat_mdl_one_tile, lon_mdl_one_tile, i_mdl, j_mdl, tile, record, t, n)
endif

if (field_names(n) == 'vegetation_type') then
print*,"- CALL FieldScatter FOR MODEL GRID VEGETATION TYPE."
call ESMF_FieldScatter(vegt_field_mdl, data_mdl_one_tile, rootPet=0, tile=tile, rc=rc)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) &
if (.not. fract_vegsoil_type) then
if (field_names(n) == 'vegetation_type') then
print*,"- CALL FieldScatter FOR MODEL GRID VEGETATION TYPE."
call ESMF_FieldScatter(vegt_field_mdl, data_mdl_one_tile, rootPet=0, tile=tile, rc=rc)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) &
call error_handler("IN FieldScatter.", rc)
endif
endif

enddo OUTPUT_LOOP
Expand Down
14 changes: 9 additions & 5 deletions sorc/sfc_climo_gen.fd/model_grid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,16 @@ subroutine define_model_grid(localpet, npets)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) &
call error_handler("IN FieldCreate", rc)

print*,"- CALL FieldCreate FOR VEGETATION TYPE INTERPOLATED TO MODEL GRID."
vegt_field_mdl = ESMF_FieldCreate(grid_mdl, &
if (.not. fract_vegsoil_type) then
print*,"- CALL FieldCreate FOR VEGETATION TYPE INTERPOLATED TO MODEL GRID."
vegt_field_mdl = ESMF_FieldCreate(grid_mdl, &
typekind=ESMF_TYPEKIND_R4, &
staggerloc=ESMF_STAGGERLOC_CENTER, &
name="veg type on model grid", &
rc=rc)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) &
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) &
call error_handler("IN FieldCreate", rc)
endif

print*,"- CALL FieldCreate FOR MODEL GRID LATITUDE."
latitude_field_mdl = ESMF_FieldCreate(grid_mdl, &
Expand Down Expand Up @@ -399,8 +401,10 @@ subroutine model_grid_cleanup
print*,"- CALL FieldDestroy FOR MODEL GRID DATA FIELD."
call ESMF_FieldDestroy(data_field_mdl,rc=rc)

print*,"- CALL FieldDestroy FOR MODEL GRID VEGETATION TYPE."
call ESMF_FieldDestroy(vegt_field_mdl,rc=rc)
if (ESMF_FieldIsCreated(vegt_field_mdl)) then
print*,"- CALL FieldDestroy FOR MODEL GRID VEGETATION TYPE."
call ESMF_FieldDestroy(vegt_field_mdl,rc=rc)
endif

print*,"- CALL FieldDestroy FOR MODEL GRID LATITUDE."
call ESMF_FieldDestroy(latitude_field_mdl,rc=rc)
Expand Down
2 changes: 1 addition & 1 deletion sorc/sfc_climo_gen.fd/program_setup.f90
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module program_setup
integer, public :: halo = 0 !< Number of row/cols defining the lateral
!! boundary halo. Used for regional nests.

logical, public :: fract_vegsoil_type = .true. !< When true, output the percentage of each soil
logical, public :: fract_vegsoil_type = .false. !< When true, output the percentage of each soil
!! and vegetation type category.

public :: read_setup_namelist
Expand Down

0 comments on commit 3e147b5

Please sign in to comment.