Skip to content

Commit

Permalink
address reviewer comments; clean-up code
Browse files Browse the repository at this point in the history
  • Loading branch information
Courtney Peverley committed Mar 15, 2024
1 parent 069b493 commit a097e4e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 81 deletions.
18 changes: 7 additions & 11 deletions src/control/cam_comp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ subroutine cam_init(caseid, ctitle, model_doi_url, &
!!XXgoldyXX: ^ need to import this
end if

call phys_init(cam_runtime_opts, phys_state, phys_tend, cam_out)
call phys_init()

!!XXgoldyXX: v need to import this
! call bldfld () ! master field list (if branch, only does hash tables)
Expand Down Expand Up @@ -258,8 +258,7 @@ subroutine cam_timestep_init(cam_in, cam_out)
! PHYS_TIMESTEP_INIT Call the Physics package
!----------------------------------------------------------
!
call phys_timestep_init(dtime_phys, cam_runtime_opts, phys_state, phys_tend, &
cam_in, cam_out)
call phys_timestep_init(dtime_phys)

end subroutine cam_timestep_init
!
Expand Down Expand Up @@ -303,8 +302,7 @@ subroutine cam_run1(cam_in, cam_out)
!
call t_barrierf('sync_phys_run1', mpicom)
call t_startf('phys_run1')
call phys_run1(dtime_phys, cam_runtime_opts, phys_state, phys_tend, &
cam_in, cam_out)
call phys_run1(dtime_phys)
call t_stopf('phys_run1')

end subroutine cam_run1
Expand Down Expand Up @@ -336,8 +334,7 @@ subroutine cam_run2(cam_out, cam_in)
!
call t_barrierf('sync_phys_run2', mpicom)
call t_startf('phys_run2')
call phys_run2(dtime_phys, cam_runtime_opts, phys_state, phys_tend, &
cam_in, cam_out)
call phys_run2(dtime_phys)
call t_stopf('phys_run2')

!
Expand Down Expand Up @@ -461,7 +458,7 @@ end subroutine cam_run4
subroutine cam_timestep_final(cam_in, cam_out)
!-----------------------------------------------------------------------
!
! Purpose: Timestep final runs at the start of each timestep
! Purpose: Timestep final runs at the end of each timestep
!
!-----------------------------------------------------------------------

Expand All @@ -475,8 +472,7 @@ subroutine cam_timestep_final(cam_in, cam_out)
! PHYS_TIMESTEP_FINAL Call the Physics package
!----------------------------------------------------------
!
call phys_timestep_final(dtime_phys, cam_runtime_opts, phys_state, phys_tend, &
cam_in, cam_out)
call phys_timestep_final(dtime_phys)

end subroutine cam_timestep_final

Expand Down Expand Up @@ -509,7 +505,7 @@ subroutine cam_final(cam_out, cam_in)
integer :: nstep ! Current timestep number.
!-----------------------------------------------------------------------

call phys_final(cam_runtime_opts, phys_state, phys_tend)
call phys_final()
call stepon_final(cam_runtime_opts, dyn_in, dyn_out)
! call ionosphere_final()

Expand Down
5 changes: 3 additions & 2 deletions src/data/write_init_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
'ccpp_constituents',
'ccpp_constituent_properties',
'ccpp_constituent_minimum_values',
'ccpp_error_message',
'ccpp_error_code',
'log_output_unit', 'do_log_output',
'mpi_communicator', 'mpi_root', 'mpi_rank',
'number_of_mpi_tasks', 'ccpp_error_message',
'ccpp_error_code'}
'number_of_mpi_tasks'}
# Variable input types
_INPUT_TYPES = set(['in', 'inout'])

Expand Down
75 changes: 8 additions & 67 deletions src/physics/utils/phys_comp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ module phys_comp

subroutine phys_readnl(nlfilename)
! Read physics options, such as suite to run
use shr_kind_mod, only: r8 => shr_kind_r8
use shr_nl_mod, only: find_group_name => shr_nl_find_group_name
use shr_flux_mod, only: shr_flux_adjust_constants
use mpi, only: mpi_character, mpi_real8, mpi_logical
use mpi, only: mpi_character, mpi_real8
use spmd_utils, only: masterproc, masterprocid, mpicom
use cam_logfile, only: iulog
use cam_abortutils, only: endrun
Expand Down Expand Up @@ -131,27 +129,16 @@ subroutine phys_readnl(nlfilename)

end subroutine phys_readnl

subroutine phys_init(cam_runtime_opts, phys_state, phys_tend, cam_out)
subroutine phys_init()
use cam_abortutils, only: endrun
use runtime_obj, only: runtime_options
use physics_types, only: physics_state, physics_tend
use camsrfexch, only: cam_out_t
use physics_grid, only: columns_on_task
use vert_coord, only: pver, pverp
use cam_thermo, only: cam_thermo_init
use physics_types, only: allocate_physics_types_fields
use cam_ccpp_cap, only: cam_ccpp_physics_initialize
use cam_ccpp_cap, only: ccpp_physics_suite_part_list
use phys_vars_init_check, only: mark_as_initialized

! Dummy arguments
type(runtime_options), intent(in) :: cam_runtime_opts
type(physics_state), intent(inout) :: phys_state
type(physics_tend), intent(inout) :: phys_tend
type(cam_out_t), intent(inout) :: cam_out

! Local variables
real(kind_phys) :: dtime_phys = 0.0_kind_phys ! Not set yet
integer :: i_group

call cam_thermo_init(columns_on_task, pver, pverp)
Expand Down Expand Up @@ -179,28 +166,19 @@ subroutine phys_init(cam_runtime_opts, phys_state, phys_tend, cam_out)

end subroutine phys_init

subroutine phys_timestep_init(dtime_phys, cam_runtime_opts, phys_state, phys_tend, &
cam_in, cam_out)
subroutine phys_timestep_init(dtime_phys)
use pio, only: file_desc_t
use cam_initfiles, only: initial_file_get_id
use physics_types, only: physics_types_tstep_init
use physics_inputs, only: physics_read_data
use time_manager, only: is_first_restart_step
use time_manager, only: get_nstep
use cam_abortutils, only: endrun
use runtime_obj, only: runtime_options
use physics_types, only: physics_state, physics_tend
use cam_ccpp_cap, only: cam_ccpp_physics_timestep_initial
use camsrfexch, only: cam_in_t, cam_out_t
use time_manager, only: is_first_step

! Dummy arguments
real(kind_phys), intent(in) :: dtime_phys
type(runtime_options), intent(in) :: cam_runtime_opts
type(physics_state), intent(inout) :: phys_state
type(physics_tend), intent(inout) :: phys_tend
type(cam_in_t), intent(inout) :: cam_in
type(cam_out_t), intent(inout) :: cam_out
! Local variables
type(file_desc_t), pointer :: ncdata
integer :: data_frame
Expand Down Expand Up @@ -233,21 +211,12 @@ subroutine phys_timestep_init(dtime_phys, cam_runtime_opts, phys_state, phys_ten

end subroutine phys_timestep_init

subroutine phys_run1(dtime_phys, cam_runtime_opts, phys_state, phys_tend, &
cam_in, cam_out)
use runtime_obj, only: runtime_options
use physics_types, only: physics_state, physics_tend
subroutine phys_run1(dtime_phys)
use cam_ccpp_cap, only: cam_ccpp_physics_run
use camsrfexch, only: cam_in_t, cam_out_t
use cam_abortutils, only: endrun

! Dummy arguments
real(kind_phys), intent(in) :: dtime_phys
type(runtime_options), intent(in) :: cam_runtime_opts
type(physics_state), intent(inout) :: phys_state
type(physics_tend), intent(inout) :: phys_tend
type(cam_in_t), intent(inout) :: cam_in
type(cam_out_t), intent(inout) :: cam_out

! Run before coupler group if it exists
if (any('physics_before_coupler' == suite_parts)) then
Expand All @@ -259,21 +228,12 @@ subroutine phys_run1(dtime_phys, cam_runtime_opts, phys_state, phys_tend, &

end subroutine phys_run1

subroutine phys_run2(dtime_phys, cam_runtime_opts, phys_state, phys_tend, &
cam_in, cam_out)
use runtime_obj, only: runtime_options
use physics_types, only: physics_state, physics_tend
use camsrfexch, only: cam_in_t, cam_out_t
subroutine phys_run2(dtime_phys)
use cam_ccpp_cap, only: cam_ccpp_physics_run
use cam_abortutils, only: endrun

! Dummy arguments
real(kind_phys), intent(in) :: dtime_phys
type(runtime_options), intent(in) :: cam_runtime_opts
type(physics_state), intent(inout) :: phys_state
type(physics_tend), intent(inout) :: phys_tend
type(cam_out_t), intent(inout) :: cam_out
type(cam_in_t), intent(inout) :: cam_in

! Run after coupler group if it exists
if (any('physics_after_coupler' == suite_parts)) then
Expand All @@ -285,24 +245,15 @@ subroutine phys_run2(dtime_phys, cam_runtime_opts, phys_state, phys_tend, &

end subroutine phys_run2

subroutine phys_timestep_final(dtime_phys, cam_runtime_opts, phys_state, phys_tend, &
cam_in, cam_out)
subroutine phys_timestep_final(dtime_phys)
use time_manager, only: get_nstep
use cam_abortutils, only: endrun
use runtime_obj, only: runtime_options
use physics_types, only: physics_state, physics_tend
use camsrfexch, only: cam_in_t, cam_out_t
use cam_initfiles, only: unset_path_str
use cam_ccpp_cap, only: cam_ccpp_physics_timestep_final
use physics_inputs, only: physics_check_data

! Dummy arguments
real(kind_phys), intent(in) :: dtime_phys
type(runtime_options), intent(in) :: cam_runtime_opts
type(physics_state), intent(inout) :: phys_state
type(physics_tend), intent(inout) :: phys_tend
type(cam_in_t), intent(inout) :: cam_in
type(cam_out_t), intent(inout) :: cam_out
! Local variables
integer :: data_frame

Expand All @@ -326,19 +277,9 @@ subroutine phys_timestep_final(dtime_phys, cam_runtime_opts, phys_state, phys_te

end subroutine phys_timestep_final

subroutine phys_final(cam_runtime_opts, phys_state, phys_tend)
use cam_abortutils, only: endrun
use runtime_obj, only: runtime_options
use physics_types, only: physics_state, physics_tend
use camsrfexch, only: cam_in_t, cam_out_t
subroutine phys_final()
use cam_ccpp_cap, only: cam_ccpp_physics_finalize

! Dummy arguments
type(runtime_options), intent(in) :: cam_runtime_opts
type(physics_state), intent(inout) :: phys_state
type(physics_tend), intent(inout) :: phys_tend
! Local variables
real(kind_phys) :: dtime_phys = 0.0_kind_phys ! Not used
use cam_abortutils, only: endrun

call cam_ccpp_physics_finalize(phys_suite_name)
if (errcode /= 0) then
Expand Down
2 changes: 1 addition & 1 deletion src/physics/utils/physics_grid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ subroutine phys_grid_init(hdim1_d_in, hdim2_d_in, dycore_name_in, &

! Calculate number of columns on tasks:
columns_on_task = size(dyn_columns)
col_end = size(dyn_columns)
col_end = columns_on_task

! Allocate phys_columns:
allocate(phys_columns(columns_on_task), stat=ierr)
Expand Down

0 comments on commit a097e4e

Please sign in to comment.