Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
bdf6b32
Changes to remove 0th timestep
olyson Jun 1, 2023
a9eb1e7
Changes for lilac
olyson Jul 25, 2023
b8be204
Remove do while loop and dosend variable.
olyson Jul 25, 2023
7f38c07
Fix unit tests for nstep starting at 1 instead of 0
billsacks Jul 25, 2023
55184f4
Merge pull request #1 from billsacks/zerothtstep
olyson Jul 26, 2023
750ed1d
Cleanup.
olyson Jul 27, 2023
198ac31
Merge branch 'zerothtstep' of https://github.com/olyson/ctsm into zer…
olyson Jul 27, 2023
caa384b
Remove comment.
olyson Aug 1, 2023
0dfd901
Remove BACKWARD COMPATIBILITY comment.
olyson Aug 3, 2023
d5b007f
Merge tag 'ctsm5.1.dev147' into zerothtstep
olyson Nov 1, 2023
c9c89a8
Correct a comment.
samsrabin Nov 1, 2023
d059220
Print error()s to console, not just log file.
samsrabin Nov 1, 2023
b311d1d
Rearrange search for h2 files in import_and_process_1yr().
samsrabin Nov 1, 2023
fa843e5
Fix h2 file patterns in import_and_process_1yr().
samsrabin Nov 1, 2023
11b6042
Merge pull request #2 from samsrabin/zerothtstep-fix-RXCROPMATURITY
olyson Nov 2, 2023
268ad5a
Merge tag 'ctsm5.3.010' into zerothtstep
slevis-lmwg Nov 12, 2024
d07fd9d
Removed comments with prefix !KO
slevis-lmwg Nov 12, 2024
0f54bc2
Merge tag 'ctsm5.3.011' into zerothtstep
slevis-lmwg Nov 12, 2024
a4b9dcf
Update docstring of is_first_step function
slevis-lmwg Nov 12, 2024
4d0ac48
New update of function's docstring
slevis-lmwg Nov 12, 2024
e578ae7
Fix typo in comment
slevis-lmwg Nov 12, 2024
bd51b8c
Correct a variable name that came in with a merge conflict
slevis-lmwg Nov 12, 2024
e87b119
Correct another error that came in with a merge conflict
slevis-lmwg Nov 13, 2024
c7e1366
Revert change I brought in with the conflicts
slevis-lmwg Nov 15, 2024
f85104b
Merge branch 'hist_time_mid_of_time_bounds' into zerothtstep
slevis-lmwg Nov 15, 2024
5148dbc
Update .gitmodules to the mosart/rtm tags corresponding to this ctsm
slevis-lmwg Nov 15, 2024
dc295f7
Correct variable name that came in with the conflicts
slevis-lmwg Nov 15, 2024
8b2f216
Merge remote-tracking branch 'escomp/master' into zerothtstep
slevis-lmwg Jan 11, 2025
f3a1dc6
call advance_timestep if startup or hybrid, not branch or continue
slevis-lmwg Jan 13, 2025
b66e1e9
Draft ChangeLog/Sum files
slevis-lmwg Jan 14, 2025
8d198cf
Update ChangeLog
slevis-lmwg Jan 14, 2025
71e56b9
Update ChangeLog
slevis-lmwg Jan 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/biogeochem/CNPhenologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,11 @@ subroutine CNPhenology (bounds, num_soilc, filter_soilc, num_soilp, &
! all restart files having been generated with
! https://github.com/ESCOMP/CTSM/issues/1623 resolved, or we stop having a time
! step 0 (https://github.com/ESCOMP/CTSM/issues/925).
if (num_pcropp > 0 .and. .not. is_first_step()) then
!KO if (num_pcropp > 0 .and. .not. is_first_step()) then
Comment thread
slevis-lmwg marked this conversation as resolved.
Outdated
!KO
! Unknown if all restart files have been generated with 1623 resolved but we no longer have a time step 0
if (num_pcropp > 0) then
Comment thread
slevis-lmwg marked this conversation as resolved.
!KO
call CropPhenology(num_pcropp, filter_pcropp, &
waterdiagnosticbulk_inst, temperature_inst, crop_inst, canopystate_inst, cnveg_state_inst, &
cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, &
Expand Down
12 changes: 10 additions & 2 deletions src/biogeochem/CNVegetationFacade.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,11 @@ subroutine EndOfTimeStepVegDynamics(this, bounds, num_natvegp, filter_natvegp, &
! Call dv (dynamic vegetation) at last time step of year

call t_startf('d2dgvm')
if (is_end_curr_year() .and. .not. is_first_step()) then
!KO if (is_end_curr_year() .and. .not. is_first_step()) then
Comment thread
slevis-lmwg marked this conversation as resolved.
Outdated
!KO
! is_first_step check no longer necessary since there is no nstep=0
if (is_end_curr_year()) then
!KO

! Get date info. kyr is used in lpj(). At end of first year, kyr = 2.
call get_curr_date(yr, mon, day, sec)
Expand Down Expand Up @@ -1281,7 +1285,11 @@ subroutine WriteHistory(this, bounds)

! Write to CNDV history buffer if appropriate
if (use_cndv) then
if (is_end_curr_year() .and. .not. is_first_step()) then
!KO if (is_end_curr_year() .and. .not. is_first_step()) then
!KO
! is_first_step check no longer necessary since there is no nstep=0
if (is_end_curr_year()) then
!KO
call t_startf('clm_drv_io_hdgvm')
call CNDVHist( bounds, this%dgvs_inst )
if (masterproc) write(iulog,*) 'Annual CNDV calculations are complete'
Expand Down
6 changes: 5 additions & 1 deletion src/biogeochem/CropType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,11 @@ subroutine CropIncrementYear (this, num_pcropp, filter_pcropp)
! Update nyrs when it's the end of the year (unless it's the very start of the
! run). This assumes that, if this patch is active at the end of the year, then it was
! active for the whole year.
if ((kmo == 1 .and. kda == 1 .and. mcsec == 0) .and. .not. is_first_step()) then
!KO if ((kmo == 1 .and. kda == 1 .and. mcsec == 0) .and. .not. is_first_step()) then
Comment thread
slevis-lmwg marked this conversation as resolved.
Outdated
!KO
! is_first_step check no longer necessary since there is no nstep=0
if ((kmo == 1 .and. kda == 1 .and. mcsec == 0)) then
!KO
do fp = 1, num_pcropp
p = filter_pcropp(fp)

Expand Down
6 changes: 5 additions & 1 deletion src/biogeochem/dynCNDVMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ subroutine dynCNDV_interp( bounds, dgvs_inst)
patch%wtcol(p) = dgvs_inst%fpcgrid_patch(p) + &
wt1 * (dgvs_inst%fpcgridold_patch(p) - dgvs_inst%fpcgrid_patch(p))

if (mon==1 .and. day==1 .and. sec==dtime .and. nstep>0) then
!KO ! I don't think this is necessary since there no longer an nstep=0
!KO if (mon==1 .and. day==1 .and. sec==dtime .and. nstep>0) then
!KO
if (mon==1 .and. day==1 .and. sec==dtime) then
!KO
dgvs_inst%fpcgridold_patch(p) = dgvs_inst%fpcgrid_patch(p)
end if
end if
Expand Down
1 change: 1 addition & 0 deletions src/biogeophys/WaterStateType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ subroutine Restart(this, bounds, ncid, flag, &

! If initial run -- ensure that water is properly bounded (read only)
if (flag == 'read' ) then
!KO ! I think leaving this in here is still necessary even though is_first_step is now based on nstep=1
Comment thread
slevis-lmwg marked this conversation as resolved.
Outdated
if ( is_first_step() .and. bound_h2osoi) then
do c = bounds%begc, bounds%endc
l = col%landunit(c)
Expand Down
242 changes: 113 additions & 129 deletions src/cpl/lilac/lnd_comp_esmf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,6 @@ subroutine lnd_run(gcomp, import_state, export_state, clock, rc)
integer :: nstep ! time step index
logical :: rstwr ! .true. ==> write restart file before returning
logical :: nlend ! .true. ==> last time-step
logical :: dosend ! true => send data back to driver
logical :: doalb ! .true. ==> do albedo calculation on this time step
real(r8) :: nextsw_cday ! calday from clock of next radiation computation
real(r8) :: caldayp1 ! ctsm calday plus dtime offset
Expand Down Expand Up @@ -621,161 +620,146 @@ subroutine lnd_run(gcomp, import_state, export_state, clock, rc)
!--------------------------------

dtime = get_step_size()
dosend = .false.
do while(.not. dosend)

! We assume that the land model time step matches the coupling interval. However,
! we still need this while loop to handle the initial time step (time 0). We may
! want to get rid of this time step 0 in the lilac coupling, at which point we
! should be able to remove this while loop and dosend variable.
!
! See also https://github.com/ESCOMP/CTSM/issues/925
nstep = get_nstep()
if (nstep > 0) then
dosend = .true.
end if

!--------------------------------
! Determine calendar day info
!--------------------------------
! We assume that the land model time step matches the coupling interval.
nstep = get_nstep()

calday = get_curr_calday(reuse_day_365_for_day_366=.true.)
caldayp1 = get_curr_calday(offset=dtime, reuse_day_365_for_day_366=.true.)
!--------------------------------
! Determine calendar day info
!--------------------------------

!--------------------------------
! Get time of next atmospheric shortwave calculation
!--------------------------------
calday = get_curr_calday(reuse_day_365_for_day_366=.true.)
caldayp1 = get_curr_calday(offset=dtime, reuse_day_365_for_day_366=.true.)

! TODO(NS): nextsw_cday should come directly from atmosphere!
! For now I am setting nextsw_cday to be the same caldayp1
!
! See also https://github.com/ESCOMP/CTSM/issues/860
!--------------------------------
! Get time of next atmospheric shortwave calculation
!--------------------------------

nextsw_cday = calday
if (masterproc) then
write(iulog,*) trim(subname) // '... nextsw_cday is : ', nextsw_cday
end if
! TODO(NS): nextsw_cday should come directly from atmosphere!
Comment thread
slevis-lmwg marked this conversation as resolved.
! For now I am setting nextsw_cday to be the same caldayp1
!
! See also https://github.com/ESCOMP/CTSM/issues/860

!--------------------------------
! Obtain orbital values
!--------------------------------

call shr_orb_decl( calday , eccen, mvelpp, lambm0, obliqr, declin , eccf )
call shr_orb_decl( nextsw_cday, eccen, mvelpp, lambm0, obliqr, declinp1, eccf )

if (masterproc) then
write(iulog,*) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
write(iulog,F02) 'nextsw_cday is : ', nextsw_cday
write(iulog,F02) 'calday is : ', calday
write(iulog,F02) 'eccen is : ', eccen
write(iulog,F02) 'mvelpp is : ', mvelpp
write(iulog,F02) 'lambm0 is : ', lambm0
write(iulog,F02) 'obliqr is : ', obliqr
write(iulog,F02) 'declin is : ', declin
write(iulog,F02) 'declinp1 is : ', declinp1
write(iulog,* ) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
end if
nextsw_cday = calday
if (masterproc) then
write(iulog,*) trim(subname) // '... nextsw_cday is : ', nextsw_cday
end if

!--------------------------------
! Determine doalb based on nextsw_cday sent from atm model
!--------------------------------

if (nstep == 0) then
doalb = .false.
nextsw_cday = caldayp1
else if (nstep == 1) then
!doalb = (abs(nextsw_cday- caldayp1) < 1.e-10_r8)
doalb = .false.
else
doalb = (nextsw_cday >= -0.5_r8)
end if
!--------------------------------
! Obtain orbital values
!--------------------------------

if (masterproc) then
write(iulog,*) '------------ LILAC ----------------'
write(iulog,*) 'nstep : ', nstep
write(iulog,*) 'calday : ', calday
write(iulog,*) 'caldayp1 : ', caldayp1
write(iulog,*) 'nextsw_cday : ', nextsw_cday
write(iulog,*) 'doalb : ', doalb
write(iulog,*) '-------------------------------------'
end if
call shr_orb_decl( calday , eccen, mvelpp, lambm0, obliqr, declin , eccf )
call shr_orb_decl( nextsw_cday, eccen, mvelpp, lambm0, obliqr, declinp1, eccf )

call update_rad_dtime(doalb)
if (masterproc) then
write(iulog,*) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
write(iulog,F02) 'nextsw_cday is : ', nextsw_cday
write(iulog,F02) 'calday is : ', calday
write(iulog,F02) 'eccen is : ', eccen
write(iulog,F02) 'mvelpp is : ', mvelpp
write(iulog,F02) 'lambm0 is : ', lambm0
write(iulog,F02) 'obliqr is : ', obliqr
write(iulog,F02) 'declin is : ', declin
write(iulog,F02) 'declinp1 is : ', declinp1
write(iulog,* ) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
end if

!--------------------------------
! Determine if time to write restart
!--------------------------------
!--------------------------------
! Determine doalb based on nextsw_cday sent from atm model
!--------------------------------

call ESMF_ClockGetAlarm(clock, alarmname='lilac_restart_alarm', alarm=alarm, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (nstep == 1) then
!doalb = (abs(nextsw_cday- caldayp1) < 1.e-10_r8)
doalb = .false.
else
doalb = (nextsw_cday >= -0.5_r8)
end if

if (ESMF_AlarmIsRinging(alarm, rc=rc)) then
if (ChkErr(rc,__LINE__,u_FILE_u)) return
rstwr = .true.
call ESMF_AlarmRingerOff( alarm, rc=rc )
if (ChkErr(rc,__LINE__,u_FILE_u)) return
else
rstwr = .false.
endif
if (masterproc) then
write(iulog,*)' restart alarm is ',rstwr
end if
if (masterproc) then
write(iulog,*) '------------ LILAC ----------------'
write(iulog,*) 'nstep : ', nstep
write(iulog,*) 'calday : ', calday
write(iulog,*) 'caldayp1 : ', caldayp1
write(iulog,*) 'nextsw_cday : ', nextsw_cday
write(iulog,*) 'doalb : ', doalb
write(iulog,*) '-------------------------------------'
end if

!--------------------------------
! Determine if time to stop
!--------------------------------
call update_rad_dtime(doalb)

call ESMF_ClockGetAlarm(clock, alarmname='lilac_stop_alarm', alarm=alarm, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
!--------------------------------
! Determine if time to write restart
!--------------------------------

if (ESMF_AlarmIsRinging(alarm, rc=rc)) then
if (ChkErr(rc,__LINE__,u_FILE_u)) return
nlend = .true.
call ESMF_AlarmRingerOff( alarm, rc=rc )
if (ChkErr(rc,__LINE__,u_FILE_u)) return
else
nlend = .false.
endif
if (masterproc) then
write(iulog,*)' stop alarm is ',nlend
end if
call ESMF_ClockGetAlarm(clock, alarmname='lilac_restart_alarm', alarm=alarm, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!--------------------------------
! Run CTSM
!--------------------------------
if (ESMF_AlarmIsRinging(alarm, rc=rc)) then
if (ChkErr(rc,__LINE__,u_FILE_u)) return
rstwr = .true.
call ESMF_AlarmRingerOff( alarm, rc=rc )
if (ChkErr(rc,__LINE__,u_FILE_u)) return
else
rstwr = .false.
endif
if (masterproc) then
write(iulog,*)' restart alarm is ',rstwr
end if

call t_barrierf('sync_ctsm_run1', mpicom)
!--------------------------------
! Determine if time to stop
!--------------------------------

! Restart File - use nexttimestr rather than currtimestr here since that is the time at the end of
! the timestep and is preferred for restart file names
! TODO: is this correct for lilac?
call ESMF_ClockGetAlarm(clock, alarmname='lilac_stop_alarm', alarm=alarm, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call ESMF_ClockGetNextTime(clock, nextTime=nextTime, rc=rc)
if (ESMF_AlarmIsRinging(alarm, rc=rc)) then
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_TimeGet(nexttime, yy=yr_lilac, mm=mon_lilac, dd=day_lilac, s=tod_lilac, rc=rc)
nlend = .true.
call ESMF_AlarmRingerOff( alarm, rc=rc )
if (ChkErr(rc,__LINE__,u_FILE_u)) return
write(rdate,'(i4.4,"-",i2.2,"-",i2.2,"-",i5.5)') yr_lilac, mon_lilac, day_lilac, tod_lilac
else
nlend = .false.
endif
if (masterproc) then
write(iulog,*)' stop alarm is ',nlend
end if

call t_startf ('ctsm_run')
call clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, rof_prognostic=.false.)
call t_stopf ('ctsm_run')
!--------------------------------
! Run CTSM
!--------------------------------

!--------------------------------
! Pack export state
!--------------------------------
call t_barrierf('sync_ctsm_run1', mpicom)

call t_startf ('lc_lnd_export')
call export_fields(export_state, bounds, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call t_stopf ('lc_lnd_export')
! Restart File - use nexttimestr rather than currtimestr here since that is the time at the end of
! the timestep and is preferred for restart file names
! TODO: is this correct for lilac?

!--------------------------------
! Advance ctsm time step
!--------------------------------
call ESMF_ClockGetNextTime(clock, nextTime=nextTime, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_TimeGet(nexttime, yy=yr_lilac, mm=mon_lilac, dd=day_lilac, s=tod_lilac, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
write(rdate,'(i4.4,"-",i2.2,"-",i2.2,"-",i5.5)') yr_lilac, mon_lilac, day_lilac, tod_lilac

call advance_timestep()
call t_startf ('ctsm_run')
call clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, rof_prognostic=.false.)
call t_stopf ('ctsm_run')

end do
!--------------------------------
! Pack export state
!--------------------------------

call t_startf ('lc_lnd_export')
call export_fields(export_state, bounds, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call t_stopf ('lc_lnd_export')

!--------------------------------
! Advance ctsm time step
!--------------------------------

call advance_timestep()

!--------------------------------
! Check that internal clock is in sync with lilac driver clock
Expand Down
Loading