Skip to content

Commit

Permalink
Add new timestep number variable and root processor check.
Browse files Browse the repository at this point in the history
  • Loading branch information
nusbaume committed Jun 12, 2024
1 parent cb4f941 commit fc53040
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/data/registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,18 @@
phys_timestep_init_zero="true">
<long_name>Total tendency from physics suite</long_name>
</variable>
<!-- Physics timestep -->
<!-- Timestep variables -->
<variable local_name="dtime_phys"
standard_name="timestep_for_physics"
units="s" type="real" kind="kind_phys">
<long_name>timestep for physics</long_name>
</variable>
<variable local_name="nstep"
standard_name="current_timestep_number"
units="count" type="integer">
<long_name>current timestep number</long_name>
<initial_value>0</initial_value>
</variable>
<!-- Error handling variables -->
<variable local_name="errcode"
standard_name="ccpp_error_code"
Expand Down
17 changes: 13 additions & 4 deletions src/utils/time_manager.F90
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,11 @@ subroutine advance_timestep()
! Increment the timestep number.

! Use statements
use string_utils, only: stringify
use ESMF, only: ESMF_ClockAdvance
use cam_logfile, only: iulog
use physics_types, only: nstep
use spmd_utils, only: masterproc
use string_utils, only: stringify

! Local variables
character(len=*), parameter :: sub = 'advance_timestep'
Expand All @@ -531,11 +535,16 @@ subroutine advance_timestep()
call ESMF_ClockAdvance( tm_clock, rc=rc )
call chkrc(rc, sub//': error return from ESMF_ClockAdvance')

! Set current timestep number for use in CCPP physics schemes:
nstep = get_nstep()

! Write new timestep to CAM log file.

write(iulog,*) '------------------------'
write(iulog,*) 'CAM-SIMA time step advanced (nstep = '//stringify([get_nstep()])//')'
write(iulog,*) '------------------------'
if (masterproc) then
write(iulog,*) '------------------------'
write(iulog,*) 'CAM-SIMA time step advanced (nstep = '//stringify([nstep])//')'
write(iulog,*) '------------------------'
end if

! Set first step flag off.

Expand Down

0 comments on commit fc53040

Please sign in to comment.