Skip to content

Commit

Permalink
Merge branch 'development' into tj2016
Browse files Browse the repository at this point in the history
  • Loading branch information
mwaxmonsky committed Jul 11, 2024
2 parents 5a7c176 + 7bdc70e commit 0fe3378
Show file tree
Hide file tree
Showing 22 changed files with 85 additions and 64 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ test/include/*.o
test/unit/tmp
test/system/*.log
test/system/cime-tests.o*
test_driver_*.sh

# Ignore editor temporaries and backups
*.swp
Expand Down
21 changes: 10 additions & 11 deletions src/control/cam_comp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,17 @@ subroutine cam_timestep_init()
!-----------------------------------------------------------------------

use phys_comp, only: phys_timestep_init
use stepon, only: stepon_timestep_init

!----------------------------------------------------------
! First phase of dynamics (at least couple from dynamics to physics)
! Return time-step for physics from dynamics.
!----------------------------------------------------------
call t_barrierf('sync_stepon_timestep_init', mpicom)
call t_startf('stepon_timestep_init')
call stepon_timestep_init(dtime_phys, cam_runtime_opts, phys_state, phys_tend, &
dyn_in, dyn_out)
call t_stopf('stepon_timestep_init')
!
!----------------------------------------------------------
! PHYS_TIMESTEP_INIT Call the Physics package
Expand All @@ -274,22 +284,11 @@ subroutine cam_run1(cam_in, cam_out)
!-----------------------------------------------------------------------

use phys_comp, only: phys_run1
use stepon, only: stepon_run1
! use ionosphere_interface, only: ionosphere_run1

type(cam_in_t), pointer, intent(inout) :: cam_in ! Input from surface to CAM
type(cam_out_t), pointer, intent(inout) :: cam_out ! Output from CAM to surface

!----------------------------------------------------------
! First phase of dynamics (at least couple from dynamics to physics)
! Return time-step for physics from dynamics.
!----------------------------------------------------------
call t_barrierf('sync_stepon_run1', mpicom)
call t_startf('stepon_run1')
call stepon_run1(dtime_phys, cam_runtime_opts, phys_state, phys_tend, &
dyn_in, dyn_out)
call t_stopf('stepon_run1')

!----------------------------------------------------------
! first phase of ionosphere -- write to IC file if needed
!----------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/data/write_init_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,12 +1014,12 @@ def write_phys_read_subroutine(outfile, host_dict, host_vars, host_imports,
outfile.write("end if", 8)
outfile.write("field_data_ptr(:,:,constituent_idx) = constituent_default_value", 8)
outfile.write("if (masterproc) then", 8)
outfile.write("write(iulog,*) 'Consitituent ', ccpp_required_data(req_idx), ' initialized to default value: ', constituent_default_value", 9)
outfile.write("write(iulog,*) 'Consitituent ', trim(ccpp_required_data(req_idx)), ' initialized to default value: ', constituent_default_value", 9)
outfile.write("end if", 8)
outfile.write("else", 7)
outfile.write("field_data_ptr(:,:,constituent_idx) = 0._kind_phys", 8)
outfile.write("if (masterproc) then", 8)
outfile.write("write(iulog,*) 'Constituent ', ccpp_required_data(req_idx), ' default value not configured. Setting to 0.'", 9)
outfile.write("write(iulog,*) 'Constituent ', trim(ccpp_required_data(req_idx)), ' default value not configured. Setting to 0.'", 9)
outfile.write("end if", 8)
outfile.write("end if", 7)
outfile.write("end if", 6)
Expand Down
8 changes: 4 additions & 4 deletions src/dynamics/mpas/stepon.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module stepon
private
! Provide APIs required by CAM Control.
public :: stepon_init
public :: stepon_run1
public :: stepon_timestep_init
public :: stepon_run2
public :: stepon_run3
public :: stepon_final
Expand All @@ -23,15 +23,15 @@ subroutine stepon_init(cam_runtime_opts, dyn_in, dyn_out)
type(dyn_export_t), intent(in) :: dyn_out
end subroutine stepon_init

! Called by `cam_run1` in `src/control/cam_comp.F90`.
subroutine stepon_run1(dtime_phys, cam_runtime_opts, phys_state, phys_tend, dyn_in, dyn_out)
! Called by `cam_timestep_init` in `src/control/cam_comp.F90`.
subroutine stepon_timestep_init(dtime_phys, cam_runtime_opts, phys_state, phys_tend, dyn_in, dyn_out)
real(r8), intent(out) :: 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(dyn_import_t), intent(inout) :: dyn_in
type(dyn_export_t), intent(inout) :: dyn_out
end subroutine stepon_run1
end subroutine stepon_timestep_init

! Called by `cam_run2` in `src/control/cam_comp.F90`.
subroutine stepon_run2(cam_runtime_opts, phys_state, phys_tend, dyn_in, dyn_out)
Expand Down
10 changes: 5 additions & 5 deletions src/dynamics/none/stepon.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module stepon
private

public :: stepon_init
public :: stepon_run1
public :: stepon_timestep_init
public :: stepon_run2
public :: stepon_run3
public :: stepon_final
Expand All @@ -30,8 +30,8 @@ end subroutine stepon_init

!===========================================================================

subroutine stepon_run1(dtime_out, cam_runtime_opts, phys_state, phys_tend, &
dyn_in, dyn_out)
subroutine stepon_timestep_init(dtime_out, cam_runtime_opts, phys_state, &
phys_tend, dyn_in, dyn_out)

use runtime_obj, only: runtime_options
use time_manager, only: get_step_size
Expand All @@ -51,10 +51,10 @@ subroutine stepon_run1(dtime_out, cam_runtime_opts, phys_state, phys_tend, &

!Ensure that the time-step is a positive value:
if (iam < npes) then
if (dtime_out <= 0) call endrun('stepon_run1: bad dtime')
if (dtime_out <= 0) call endrun('stepon_timestep_init: bad dtime')
end if

end subroutine stepon_run1
end subroutine stepon_timestep_init

!===========================================================================

Expand Down
1 change: 1 addition & 0 deletions src/dynamics/se/namelist_definition_se_dycore.xml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@
</desc>
<values>
<value>0</value>
<value csne="3">3</value>
<value csne="5">5</value>
<value csne="16">16</value>
<value csne="30">30</value>
Expand Down
11 changes: 6 additions & 5 deletions src/dynamics/se/stepon.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module stepon
save

public stepon_init
public stepon_run1
public stepon_timestep_init
public stepon_run2
public stepon_run3
public stepon_final
Expand All @@ -36,7 +36,8 @@ end subroutine stepon_init

!=========================================================================================

subroutine stepon_run1(dtime_out, cam_runtime_opts, phys_state, phys_tend, dyn_in, dyn_out)
subroutine stepon_timestep_init(dtime_out, cam_runtime_opts, phys_state, &
phys_tend, dyn_in, dyn_out)

use time_manager, only: get_step_size
use cam_abortutils, only: endrun
Expand All @@ -59,8 +60,8 @@ subroutine stepon_run1(dtime_out, cam_runtime_opts, phys_state, phys_tend, dyn_i

!Ensure that the model and dynamics time-steps are positive values:
if (iam < par%nprocs) then
if (tstep <= 0) call endrun('stepon_run1: bad tstep')
if (dtime_out <= 0) call endrun('stepon_run1: bad dtime')
if (tstep <= 0) call endrun('stepon_timestep_init: bad tstep')
if (dtime_out <= 0) call endrun('stepon_timestep_init: bad dtime')

! write diagnostic fields on gll grid and initial file
call diag_dynvar_ic(dyn_out%elem, dyn_out%fvm)
Expand All @@ -73,7 +74,7 @@ subroutine stepon_run1(dtime_out, cam_runtime_opts, phys_state, phys_tend, dyn_i
call d_p_coupling(cam_runtime_opts, phys_state, phys_tend, dyn_out)
call t_stopf('d_p_coupling')

end subroutine stepon_run1
end subroutine stepon_timestep_init

!=========================================================================================

Expand Down
23 changes: 14 additions & 9 deletions src/physics/utils/physics_data.F90
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,18 @@ integer function find_input_name_idx(stdname, use_init_variables, constituent_in
integer :: idx
! to test read_from_file status
logical :: is_read
logical :: is_constituent

!Initialize function:
find_input_name_idx = no_exist_idx
constituent_index = no_exist_idx
is_constituent = .false.

!First check if quantity is a constituent:
call const_get_index(trim(stdname), find_input_name_idx, abort=.false., warning=.false.)
if (find_input_name_idx < 0) then
find_input_name_idx = no_exist_idx
else
if (find_input_name_idx >= 0) then
constituent_index = find_input_name_idx
find_input_name_idx = const_idx
!Return from function here,
!as variable has already been found:
return
is_constituent = .true.
end if

!Loop through physics variable standard names:
Expand All @@ -87,7 +84,11 @@ integer function find_input_name_idx(stdname, use_init_variables, constituent_in
end if
if (is_read) then
!If reading initialized variables, set to idx:
find_input_name_idx = idx
if (is_constituent) then
find_input_name_idx = const_idx
else
find_input_name_idx = idx
end if
else
!Otherwise, set to init_mark_idx:
find_input_name_idx = init_mark_idx
Expand All @@ -96,7 +97,11 @@ integer function find_input_name_idx(stdname, use_init_variables, constituent_in
find_input_name_idx = prot_no_init_idx
else
!If not already initialized, then pass on the real array index:
find_input_name_idx = idx
if (is_constituent) then
find_input_name_idx = const_idx
else
find_input_name_idx = idx
end if
end if
!Exit physics variable name loop:
exit
Expand Down
5 changes: 3 additions & 2 deletions test/unit/sample_files/write_init_files/physics_inputs_4D.F90
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,13 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia
end if
field_data_ptr(:,:,constituent_idx) = constituent_default_value
if (masterproc) then
write(iulog,*) 'Consitituent ', ccpp_required_data(req_idx), ' initialized to default value: ', constituent_default_value
write(iulog,*) 'Consitituent ', trim(ccpp_required_data(req_idx)), ' initialized to default value: ', &
constituent_default_value
end if
else
field_data_ptr(:,:,constituent_idx) = 0._kind_phys
if (masterproc) then
write(iulog,*) 'Constituent ', ccpp_required_data(req_idx), ' default value not configured. Setting to 0.'
write(iulog,*) 'Constituent ', trim(ccpp_required_data(req_idx)), ' default value not configured. Setting to 0.'
end if
end if
end if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,13 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia
end if
field_data_ptr(:,:,constituent_idx) = constituent_default_value
if (masterproc) then
write(iulog,*) 'Consitituent ', ccpp_required_data(req_idx), ' initialized to default value: ', constituent_default_value
write(iulog,*) 'Consitituent ', trim(ccpp_required_data(req_idx)), ' initialized to default value: ', &
constituent_default_value
end if
else
field_data_ptr(:,:,constituent_idx) = 0._kind_phys
if (masterproc) then
write(iulog,*) 'Constituent ', ccpp_required_data(req_idx), ' default value not configured. Setting to 0.'
write(iulog,*) 'Constituent ', trim(ccpp_required_data(req_idx)), ' default value not configured. Setting to 0.'
end if
end if
end if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,13 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia
end if
field_data_ptr(:,:,constituent_idx) = constituent_default_value
if (masterproc) then
write(iulog,*) 'Consitituent ', ccpp_required_data(req_idx), ' initialized to default value: ', constituent_default_value
write(iulog,*) 'Consitituent ', trim(ccpp_required_data(req_idx)), ' initialized to default value: ', &
constituent_default_value
end if
else
field_data_ptr(:,:,constituent_idx) = 0._kind_phys
if (masterproc) then
write(iulog,*) 'Constituent ', ccpp_required_data(req_idx), ' default value not configured. Setting to 0.'
write(iulog,*) 'Constituent ', trim(ccpp_required_data(req_idx)), ' default value not configured. Setting to 0.'
end if
end if
end if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,13 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia
end if
field_data_ptr(:,:,constituent_idx) = constituent_default_value
if (masterproc) then
write(iulog,*) 'Consitituent ', ccpp_required_data(req_idx), ' initialized to default value: ', constituent_default_value
write(iulog,*) 'Consitituent ', trim(ccpp_required_data(req_idx)), ' initialized to default value: ', &
constituent_default_value
end if
else
field_data_ptr(:,:,constituent_idx) = 0._kind_phys
if (masterproc) then
write(iulog,*) 'Constituent ', ccpp_required_data(req_idx), ' default value not configured. Setting to 0.'
write(iulog,*) 'Constituent ', trim(ccpp_required_data(req_idx)), ' default value not configured. Setting to 0.'
end if
end if
end if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,13 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia
end if
field_data_ptr(:,:,constituent_idx) = constituent_default_value
if (masterproc) then
write(iulog,*) 'Consitituent ', ccpp_required_data(req_idx), ' initialized to default value: ', constituent_default_value
write(iulog,*) 'Consitituent ', trim(ccpp_required_data(req_idx)), ' initialized to default value: ', &
constituent_default_value
end if
else
field_data_ptr(:,:,constituent_idx) = 0._kind_phys
if (masterproc) then
write(iulog,*) 'Constituent ', ccpp_required_data(req_idx), ' default value not configured. Setting to 0.'
write(iulog,*) 'Constituent ', trim(ccpp_required_data(req_idx)), ' default value not configured. Setting to 0.'
end if
end if
end if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,13 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia
end if
field_data_ptr(:,:,constituent_idx) = constituent_default_value
if (masterproc) then
write(iulog,*) 'Consitituent ', ccpp_required_data(req_idx), ' initialized to default value: ', constituent_default_value
write(iulog,*) 'Consitituent ', trim(ccpp_required_data(req_idx)), ' initialized to default value: ', &
constituent_default_value
end if
else
field_data_ptr(:,:,constituent_idx) = 0._kind_phys
if (masterproc) then
write(iulog,*) 'Constituent ', ccpp_required_data(req_idx), ' default value not configured. Setting to 0.'
write(iulog,*) 'Constituent ', trim(ccpp_required_data(req_idx)), ' default value not configured. Setting to 0.'
end if
end if
end if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,13 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia
end if
field_data_ptr(:,:,constituent_idx) = constituent_default_value
if (masterproc) then
write(iulog,*) 'Consitituent ', ccpp_required_data(req_idx), ' initialized to default value: ', constituent_default_value
write(iulog,*) 'Consitituent ', trim(ccpp_required_data(req_idx)), ' initialized to default value: ', &
constituent_default_value
end if
else
field_data_ptr(:,:,constituent_idx) = 0._kind_phys
if (masterproc) then
write(iulog,*) 'Constituent ', ccpp_required_data(req_idx), ' default value not configured. Setting to 0.'
write(iulog,*) 'Constituent ', trim(ccpp_required_data(req_idx)), ' default value not configured. Setting to 0.'
end if
end if
end if
Expand Down
5 changes: 3 additions & 2 deletions test/unit/sample_files/write_init_files/physics_inputs_mf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,13 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia
end if
field_data_ptr(:,:,constituent_idx) = constituent_default_value
if (masterproc) then
write(iulog,*) 'Consitituent ', ccpp_required_data(req_idx), ' initialized to default value: ', constituent_default_value
write(iulog,*) 'Consitituent ', trim(ccpp_required_data(req_idx)), ' initialized to default value: ', &
constituent_default_value
end if
else
field_data_ptr(:,:,constituent_idx) = 0._kind_phys
if (masterproc) then
write(iulog,*) 'Constituent ', ccpp_required_data(req_idx), ' default value not configured. Setting to 0.'
write(iulog,*) 'Constituent ', trim(ccpp_required_data(req_idx)), ' default value not configured. Setting to 0.'
end if
end if
end if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,13 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia
end if
field_data_ptr(:,:,constituent_idx) = constituent_default_value
if (masterproc) then
write(iulog,*) 'Consitituent ', ccpp_required_data(req_idx), ' initialized to default value: ', constituent_default_value
write(iulog,*) 'Consitituent ', trim(ccpp_required_data(req_idx)), ' initialized to default value: ', &
constituent_default_value
end if
else
field_data_ptr(:,:,constituent_idx) = 0._kind_phys
if (masterproc) then
write(iulog,*) 'Constituent ', ccpp_required_data(req_idx), ' default value not configured. Setting to 0.'
write(iulog,*) 'Constituent ', trim(ccpp_required_data(req_idx)), ' default value not configured. Setting to 0.'
end if
end if
end if
Expand Down
Loading

0 comments on commit 0fe3378

Please sign in to comment.