Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix constituent handling #272

Merged
merged 4 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
19 changes: 13 additions & 6 deletions src/physics/utils/physics_data.F90
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,20 @@ 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
constituent_index = find_input_name_idx
nusbaume marked this conversation as resolved.
Show resolved Hide resolved
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 +86,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 +99,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
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,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
Loading