Skip to content

Commit

Permalink
Move stream_gdd20_seasons to cropCalStreamMod.
Browse files Browse the repository at this point in the history
  • Loading branch information
samsrabin committed Jul 25, 2024
1 parent 7400d5b commit 388c7ed
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bld/namelist_files/namelist_definition_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1839,7 +1839,7 @@ Filename of input stream data for baseline GDD20 values
</entry>

<entry id="stream_gdd20_seasons" type="logical" category="datasets"
group="clm_inparm" valid_values="" >
group="cropcal_streams" valid_values="" >
Set this to true to read gdd20 accumulation season start and end dates from stream files, rather than using hard-coded hemisphere-specific "warm seasons."
</entry>

Expand Down
7 changes: 5 additions & 2 deletions src/biogeophys/TemperatureType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module TemperatureType
use decompMod , only : bounds_type
use abortutils , only : endrun
use clm_varctl , only : use_cndv, iulog, use_luna, use_crop, use_biomass_heat_storage
use clm_varctl , only : stream_gdd20_seasons, flush_gdd20
use clm_varctl , only : flush_gdd20
use clm_varpar , only : nlevsno, nlevgrnd, nlevlak, nlevurb, nlevmaxurbgrnd
use clm_varcon , only : spval, ispval
use GridcellType , only : grc
Expand Down Expand Up @@ -1401,6 +1401,7 @@ subroutine UpdateAccVars_CropGDDs(this, rbufslp, begp, endp, month, day, secs, d
real(r8) :: lat ! latitude
integer :: gdd20_season_start, gdd20_season_end
integer :: jday ! Julian day of year (1, ..., 366)
logical :: stream_gdd20_seasons_tt ! Local derivation of this to avoid circular dependency

associate( &
gdd20_season_starts => crop_inst%gdd20_season_start_patch, &
Expand Down Expand Up @@ -1432,6 +1433,8 @@ subroutine UpdateAccVars_CropGDDs(this, rbufslp, begp, endp, month, day, secs, d
end if
write(field_name, format_string) "GDD",basetemp_int

stream_gdd20_seasons_tt = any(gdd20_season_starts(begp:endp) > 0.5_r8) .and. any(gdd20_season_starts(begp:endp) < 366.5_r8)

do p = begp,endp

! Avoid unnecessary calculations over inactive points
Expand All @@ -1447,7 +1450,7 @@ subroutine UpdateAccVars_CropGDDs(this, rbufslp, begp, endp, month, day, secs, d
((month > 9 .or. month < 4) .and. lat < 0._r8)
! Replace with read-in gdd20 accumulation season, if needed and valid
! (If these aren't being read in or they're invalid, they'll be -1)
if (stream_gdd20_seasons .and. patch%itype(p) >= npcropmin) then
if (stream_gdd20_seasons_tt .and. patch%itype(p) >= npcropmin) then
gdd20_season_start = int(gdd20_season_starts(p))
gdd20_season_end = int(gdd20_season_ends(p))
if (gdd20_season_start >= 1 .and. gdd20_season_end >= 1) then
Expand Down
5 changes: 4 additions & 1 deletion src/cpl/share_esmf/cropcalStreamMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module cropcalStreamMod
use clm_varctl , only : iulog
use clm_varctl , only : use_cropcal_rx_swindows, use_cropcal_rx_cultivar_gdds, use_cropcal_streams
use clm_varctl , only : adapt_cropcal_rx_cultivar_gdds
use clm_varctl , only : stream_gdd20_seasons
use clm_varpar , only : mxpft
use clm_varpar , only : mxsowings
use perf_mod , only : t_startf, t_stopf
Expand Down Expand Up @@ -53,6 +52,7 @@ module cropcalStreamMod
character(len=CL) :: stream_fldFileName_gdd20_baseline ! GDD20 baseline stream filename to read
logical :: cropcals_rx ! Used only for setting input files in namelist; does nothing in code, but needs to be here so namelist read doesn't crash
logical :: cropcals_rx_adapt ! Used only for setting input files in namelist; does nothing in code, but needs to be here so namelist read doesn't crash
logical :: stream_gdd20_seasons ! Read start and end dates for gdd20 seasons from streams instead of using hemisphere-specific values
logical :: allow_invalid_gdd20_season_inputs ! Fall back on hemisphere "warm periods" in cases of invalid values in stream_fldFileName_gdd20_season_start and _end?
character(len=CL) :: stream_fldFileName_gdd20_season_start ! Stream filename to read for start of gdd20 season
character(len=CL) :: stream_fldFileName_gdd20_season_end ! Stream filename to read for end of gdd20 season
Expand Down Expand Up @@ -113,6 +113,7 @@ subroutine cropcal_init(bounds)
stream_meshfile_cropcal, &
cropcals_rx, &
cropcals_rx_adapt, &
stream_gdd20_seasons, &
allow_invalid_gdd20_season_inputs, &
stream_fldFileName_gdd20_season_start, &
stream_fldFileName_gdd20_season_end
Expand All @@ -130,6 +131,7 @@ subroutine cropcal_init(bounds)
stream_fldFileName_swindow_end = ''
stream_fldFileName_cultivar_gdds = ''
stream_fldFileName_gdd20_baseline = ''
stream_gdd20_seasons = .false.
allow_invalid_gdd20_season_inputs = .false.
stream_fldFileName_gdd20_season_start = ''
stream_fldFileName_gdd20_season_end = ''
Expand Down Expand Up @@ -173,6 +175,7 @@ subroutine cropcal_init(bounds)
call shr_mpi_bcast(stream_fldFileName_cultivar_gdds, mpicom)
call shr_mpi_bcast(stream_fldFileName_gdd20_baseline, mpicom)
call shr_mpi_bcast(stream_meshfile_cropcal , mpicom)
call shr_mpi_bcast(stream_gdd20_seasons, mpicom)
call shr_mpi_bcast(allow_invalid_gdd20_season_inputs, mpicom)
call shr_mpi_bcast(stream_fldFileName_gdd20_season_start, mpicom)
call shr_mpi_bcast(stream_fldFileName_gdd20_season_end, mpicom)
Expand Down
1 change: 0 additions & 1 deletion src/main/clm_varctl.F90
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ module clm_varctl
logical, public :: use_cropcal_rx_swindows = .false.
logical, public :: use_cropcal_rx_cultivar_gdds = .false.
logical, public :: adapt_cropcal_rx_cultivar_gdds = .false.
logical, public :: stream_gdd20_seasons = .false.
logical, public :: flush_gdd20 = .false.

!----------------------------------------------------------
Expand Down
4 changes: 1 addition & 3 deletions src/main/controlMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ subroutine control_init(dtime)
use_lch4, use_nitrif_denitrif, use_extralakelayers, &
use_vichydro, use_cn, use_cndv, use_crop, use_fertilizer, &
use_grainproduct, use_snicar_frc, use_vancouver, use_mexicocity, use_noio, &
use_nguardrail, crop_residue_removal_frac, stream_gdd20_seasons, flush_gdd20
use_nguardrail, crop_residue_removal_frac, flush_gdd20

! SNICAR
namelist /clm_inparm/ &
Expand Down Expand Up @@ -711,7 +711,6 @@ subroutine control_spmd()
call mpi_bcast (use_cndv, 1, MPI_LOGICAL, 0, mpicom, ier)
call mpi_bcast (use_nguardrail, 1, MPI_LOGICAL, 0, mpicom, ier)
call mpi_bcast (use_crop, 1, MPI_LOGICAL, 0, mpicom, ier)
call mpi_bcast (stream_gdd20_seasons, 1, MPI_LOGICAL, 0, mpicom, ier)
call mpi_bcast (flush_gdd20, 1, MPI_LOGICAL, 0, mpicom, ier)
call mpi_bcast (use_fertilizer, 1, MPI_LOGICAL, 0, mpicom, ier)
call mpi_bcast (use_grainproduct, 1, MPI_LOGICAL, 0, mpicom, ier)
Expand Down Expand Up @@ -985,7 +984,6 @@ subroutine control_print ()
write(iulog,*) ' use_cn = ', use_cn
write(iulog,*) ' use_cndv = ', use_cndv
write(iulog,*) ' use_crop = ', use_crop
write(iulog,*) ' stream_gdd20_seasons = ', stream_gdd20_seasons
write(iulog,*) ' flush_gdd20 = ', flush_gdd20
write(iulog,*) ' use_fertilizer = ', use_fertilizer
write(iulog,*) ' use_grainproduct = ', use_grainproduct
Expand Down

0 comments on commit 388c7ed

Please sign in to comment.