diff --git a/src/control/cam_comp.F90 b/src/control/cam_comp.F90 index 85edc36c..4b677288 100644 --- a/src/control/cam_comp.F90 +++ b/src/control/cam_comp.F90 @@ -455,7 +455,7 @@ end subroutine cam_run4 ! !----------------------------------------------------------------------- ! - subroutine cam_timestep_final() + subroutine cam_timestep_final(do_ncdata_check) !----------------------------------------------------------------------- ! ! Purpose: Timestep final runs at the end of each timestep @@ -464,12 +464,15 @@ subroutine cam_timestep_final() use phys_comp, only: phys_timestep_final + !Flag for whether a snapshot (ncdata) check should be run or not + logical, intent(in) :: do_ncdata_check + ! !---------------------------------------------------------- ! PHYS_TIMESTEP_FINAL Call the Physics package !---------------------------------------------------------- ! - call phys_timestep_final() + call phys_timestep_final(do_ncdata_check) end subroutine cam_timestep_final diff --git a/src/cpl/nuopc/atm_comp_nuopc.F90 b/src/cpl/nuopc/atm_comp_nuopc.F90 index 818760eb..7cdd1247 100644 --- a/src/cpl/nuopc/atm_comp_nuopc.F90 +++ b/src/cpl/nuopc/atm_comp_nuopc.F90 @@ -1049,6 +1049,7 @@ subroutine ModelAdvance(gcomp, rc) integer :: lbnum integer :: localPet, localPeCount logical :: first_time = .true. + logical :: do_ncdata_check !Flag notifying SIMA if it is OK to perform a snapshot check character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' !------------------------------------------------------------------------------- @@ -1117,6 +1118,7 @@ subroutine ModelAdvance(gcomp, rc) end if dosend = .false. + do_ncdata_check = .false. do while (.not. dosend) ! TODO: This is currently hard-wired - is there a better way for nuopc? @@ -1124,6 +1126,7 @@ subroutine ModelAdvance(gcomp, rc) ! Note that the model clock is updated at the end of the time step not at the beginning if (get_nstep() > 0) then dosend = .true. + do_ncdata_check = .true. end if ! Determine if time to write restart @@ -1152,6 +1155,7 @@ subroutine ModelAdvance(gcomp, rc) endif ! Run CAM (run2, run3, run4) + ! This includes the "physics_after_coupler" CCPP physics group. call t_startf ('CAM_run2') call cam_run2( cam_out, cam_in ) @@ -1165,7 +1169,7 @@ subroutine ModelAdvance(gcomp, rc) call cam_run4( cam_out, cam_in, rstwr, nlend, & yr_spec=yr_sync, mon_spec=mon_sync, day_spec=day_sync, sec_spec=tod_sync) call t_stopf ('CAM_run4') - call cam_timestep_final() + call cam_timestep_final(do_ncdata_check=do_ncdata_check) ! Advance cam time step @@ -1174,7 +1178,8 @@ subroutine ModelAdvance(gcomp, rc) call t_stopf ('CAM_adv_timestep') call cam_timestep_init() - ! Run cam radiation/clouds (run1) + ! Run CAM (run1) + ! This includes the "physics_before_coupler" CCPP physics group. call t_startf ('CAM_run1') call cam_run1 ( cam_in, cam_out ) @@ -1401,11 +1406,11 @@ subroutine ModelFinalize(gcomp, rc) rc = ESMF_SUCCESS - call shr_log_getLogUnit (shrlogunit) - call shr_log_setLogUnit (iulog) + call shr_log_getLogUnit(shrlogunit) + call shr_log_setLogUnit(iulog) - call cam_timestep_final() - call cam_final( cam_out, cam_in ) + call cam_timestep_final(do_ncdata_check=.false.) + call cam_final(cam_out, cam_in) if (masterproc) then write(iulog,F91) diff --git a/src/data/registry.xml b/src/data/registry.xml index c9dd29e7..3d8b5bc0 100644 --- a/src/data/registry.xml +++ b/src/data/registry.xml @@ -313,12 +313,18 @@ phys_timestep_init_zero="true"> Total tendency from physics suite - + timestep for physics + + current timestep number + 0 + initial_file_get_id() - ! data_frame is the next input frame for physics input fields - ! Frame 1 is skipped for snapshot files - !!XXgoldyXX: This section needs to have better logic once we know if - !! this is a physics test bench run. - data_frame = get_nstep() + 2 + ! data_frame is the next input frame for + ! physics fields that must be read from a file: + data_frame = get_nstep() ! Initialize host model variables that must be done each time step: call physics_types_tstep_init() @@ -237,15 +235,18 @@ subroutine phys_run2() end subroutine phys_run2 - subroutine phys_timestep_final() + subroutine phys_timestep_final(do_ncdata_check) use time_manager, only: get_nstep use cam_abortutils, only: endrun use cam_initfiles, only: unset_path_str use cam_ccpp_cap, only: cam_ccpp_physics_timestep_final use physics_inputs, only: physics_check_data + ! Subroutine inputs + logical, intent(in) :: do_ncdata_check + ! Local variables - integer :: data_frame + integer :: data_frame ! Finalize the time step call cam_ccpp_physics_timestep_final(phys_suite_name) @@ -253,16 +254,16 @@ subroutine phys_timestep_final() call endrun('cam_ccpp_physics_timestep_final: '//trim(errmsg)) end if - ! data_frame is the next input frame for physics input fields - ! Frame 1 is skipped for snapshot files - !!XXgoldyXX: This section needs to have better logic once we know if - !! this is a physics test bench run. - data_frame = get_nstep() + 2 + ! data_frame is the next input frame for + ! physics snapshot validation fields + data_frame = get_nstep() ! Determine if physics_check should be run: if (trim(ncdata_check) /= trim(unset_path_str)) then - call physics_check_data(ncdata_check, suite_names, data_frame, & - min_difference, min_relative_value) + if (do_ncdata_check) then + call physics_check_data(ncdata_check, suite_names, data_frame, & + min_difference, min_relative_value) + end if end if end subroutine phys_timestep_final diff --git a/src/utils/time_manager.F90 b/src/utils/time_manager.F90 index 91114ccd..803a47e9 100644 --- a/src/utils/time_manager.F90 +++ b/src/utils/time_manager.F90 @@ -520,6 +520,13 @@ subroutine advance_timestep() ! Increment the timestep number. +! Use statements + 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' integer :: rc @@ -528,6 +535,17 @@ 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. + + if (masterproc) then + write(iulog,*) '------------------------' + write(iulog,*) 'CAM-SIMA time step advanced (nstep = '//stringify([nstep])//')' + write(iulog,*) '------------------------' + end if + ! Set first step flag off. tm_first_restart_step = .false.