Skip to content

Commit

Permalink
A few more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinswales committed Sep 17, 2024
1 parent 50c38bc commit d863dbb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
11 changes: 6 additions & 5 deletions scm/src/scm.F90
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ subroutine scm_main_sub()
use scm_forcing
use scm_time_integration
use scm_output
use scm_type_defs
use scm_type_defs, only: physics_type, scm_state_type, scm_input_type, scm_reference_type
use ccpp_config, only: ty_ccpp_config
use mpi_f08
use ccpp_config, only: ty_ccpp_config

Expand Down Expand Up @@ -232,7 +233,7 @@ subroutine scm_main_sub()
if (.not. scm_state%model_ics) call calc_pres_exner_geopotential(1, scm_state)

!pass in state variables to be modified by forcing and physics
call do_time_step(scm_state, physics, ccpp_cfg, in_spinup, ccpp_errflg, ccpp_errmsg)
call do_time_step(scm_state, physics, ccpp_cfg, in_spinup, ccpp_errflg, ccpp_errmsg, ccpp_suite_parts)

else if (scm_state%time_scheme == 2) then
! !if using the leapfrog scheme, we initialize by taking one half forward time step and one half (unfiltered) leapfrog time step to get to the end of the first time step
Expand Down Expand Up @@ -324,7 +325,7 @@ subroutine scm_main_sub()
call physics%Diag%phys_zero (physics%Model)
endif

do isuite_part=1,ccpp_suite_parts
do isuite_part=1,len(ccpp_suite_parts)
call ccpp_physics_run(suite_name = trim(trim(adjustl(scm_state%physics_suite_name))), &
suite_part = ccpp_suite_parts(isuite_part), &
physics = physics, &
Expand Down Expand Up @@ -368,7 +369,7 @@ subroutine scm_main_sub()
scm_state%state_tracer(:,:,:,1) = scm_state%temp_tracer(:,:,:,1)

!go forward one leapfrog time step
call do_time_step(scm_state, physics, ccpp_cfg, in_spinup, ccpp_errflg, ccpp_errmsg)
call do_time_step(scm_state, physics, ccpp_cfg, in_spinup, ccpp_errflg, ccpp_errmsg, ccpp_suite_parts)

!for filtered-leapfrog scheme, call the filtering routine to calculate values of the state variables to save in slot 1 using slot 2 vars (updated, unfiltered) output from the physics
call filter(scm_state)
Expand Down Expand Up @@ -428,7 +429,7 @@ subroutine scm_main_sub()
!call physics%Diag%phys_zero(physics%Model)

!pass in state variables to be modified by forcing and physics
call do_time_step(scm_state, physics, ccpp_cfg, in_spinup, ccpp_errflg, ccpp_errmsg
call do_time_step(scm_state, physics, ccpp_cfg, in_spinup, ccpp_errflg, ccpp_errmsg, ccpp_suite_parts)

if (scm_state%time_scheme == 2) then
!for filtered-leapfrog scheme, call the filtering routine to calculate values of the state variables to save in slot 1 using slot 2 vars (updated, unfiltered) output from the physics
Expand Down
38 changes: 25 additions & 13 deletions scm/src/scm_time_integration.F90
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ subroutine filter(scm_state)
!! The subroutine nuopc_rad_update calculates the time-dependent parameters required to run radiation, and nuopc_rad_run calculates the radiative heating rate (but does not apply it). The
!! subroutine apply_forcing_leapfrog advances the state variables forward using the leapfrog method and nuopc_phys_run further changes the state variables using the forward method. By the end of
!! this subroutine, the unfiltered state variables will have been stepped forward in time.
subroutine do_time_step(scm_state, physics, ccpp_cfg, in_spinup, ccpp_errflg, ccpp_errmsg)
subroutine do_time_step(scm_state, physics, ccpp_cfg, in_spinup, ccpp_errflg, ccpp_errmsg, ccpp_suite_parts)
use scm_type_defs, only: scm_state_type, physics_type

type(scm_state_type), intent(inout) :: scm_state
Expand All @@ -61,8 +61,9 @@ subroutine do_time_step(scm_state, physics, ccpp_cfg, in_spinup, ccpp_errflg, cc
logical, intent(in) :: in_spinup
integer, intent(inout) :: ccpp_errflg
character(len=512), intent(inout) :: ccpp_errmsg
character(len=128), intent(in) :: ccpp_suite_parts(:)

integer :: i, ierr, kdt_rad, idtend, itrac
integer :: i, ierr, kdt_rad, idtend, itrac, isuite_part

!> \section do_time_step_alg Algorithm
!! @{
Expand Down Expand Up @@ -133,7 +134,11 @@ subroutine do_time_step(scm_state, physics, ccpp_cfg, in_spinup, ccpp_errflg, cc
endif
enddo

call ccpp_physics_timestep_init(suite_name=trim(trim(adjustl(scm_state%physics_suite_name))), physics=physics, ccpp_cfg=ccpp_cfg, errflg=ccpp_errflg, errmsg=ccpp_errmsg)
call ccpp_physics_timestep_init(suite_name = trim(trim(adjustl(scm_state%physics_suite_name))), &
physics = physics, &
ccpp_cfg = ccpp_cfg, &
errflg = ccpp_errflg, &
errmsg = ccpp_errmsg)
if (ccpp_errflg/=0) then
write(*,'(a,i0,a)') 'An error occurred in ccpp_physics_timestep_init: ' // trim(ccpp_errmsg) // '. Exiting...'
error stop trim(ccpp_errmsg)
Expand All @@ -155,18 +160,25 @@ subroutine do_time_step(scm_state, physics, ccpp_cfg, in_spinup, ccpp_errflg, cc
if (mod(physics%Model%kdt,physics%Model%nszero) == 1 .or. physics%Model%nszero == 1) then
call physics%Diag%phys_zero (physics%Model)
endif

!--- Reset interstitials
call physics%Interstitial%rad_reset(physics%Model)
call physics%Interstitial%phys_reset(physics%Model)

call ccpp_physics_run(suite_name=trim(trim(adjustl(scm_state%physics_suite_name))), physics=physics, ccpp_cfg=ccpp_cfg, errflg=ccpp_errflg, errmsg=ccpp_errmsg)
if (ccpp_errflg/=0) then
write(*,'(a,i0,a)') 'An error occurred in ccpp_physics_run: ' // trim(ccpp_errmsg) // '. Exiting...'
error stop trim(ccpp_errmsg)
end if
do isuite_part=1,len(ccpp_suite_parts)
call ccpp_physics_run(suite_name = trim(trim(adjustl(scm_state%physics_suite_name))), &
suite_part = ccpp_suite_parts(isuite_part), &
physics = physics, &
ccpp_cfg = ccpp_cfg, &
errflg = ccpp_errflg, &
errmsg = ccpp_errmsg)
if (ccpp_errflg/=0) then
write(*,'(a,i0,a)') 'An error occurred in ccpp_physics_run: ' // trim(ccpp_errmsg) // '. Exiting...'
error stop trim(ccpp_errmsg)
end if
enddo

call ccpp_physics_timestep_finalize(suite_name=trim(trim(adjustl(scm_state%physics_suite_name))), physics=physics, ccpp_cfg=ccpp_cfg, errflg=ccpp_errflg, errmsg=ccpp_errmsg)
call ccpp_physics_timestep_finalize(suite_name = trim(trim(adjustl(scm_state%physics_suite_name))), &
physics = physics, &
ccpp_cfg = ccpp_cfg, &
errflg = ccpp_errflg, &
errmsg = ccpp_errmsg)
if (ccpp_errflg/=0) then
write(*,'(a,i0,a)') 'An error occurred in ccpp_physics_timestep_finalize: ' // trim(ccpp_errmsg) // '. Exiting...'
error stop trim(ccpp_errmsg)
Expand Down

0 comments on commit d863dbb

Please sign in to comment.