Skip to content

Commit 9865ef6

Browse files
jimmielinnusbaume
andauthored
Change prescribed chemistry/aerosol schemes to use ccpp_scheme_utils; fully use diagnostic names in sima_state_diagnostics (#424)
Tag name (The PR title should also include the tag name): Originator(s): @jimmielin Description (include issue title and the keyword ['closes', 'fixes', 'resolves'] and issue number): - Change prescribed chemistry/aerosol schemes to use ccpp_scheme_utils so they are case-insensitive - companion PR to ESCOMP/CAM-SIMA#518 - #397 (in 979c6bc) changed `sima_state_diagnostics` to use `%diagnostic_name` to add field but not the write loop, so if the two cases mismatched (due to the case-insensitivity fixes they now do) the `history_out_field` would be mismatched and would write uninitialized heap memory into the netCDF file rather than the variable. List all namelist files that were added or changed: List all files eliminated and why: List all files added and what they do: List all existing files that have been modified, and describe the changes: (Helpful git command: `git diff --name-status main...<your_branch_name>`) ``` M schemes/chemistry/prescribed_aerosols.F90 M schemes/chemistry/prescribed_aerosols.meta M schemes/chemistry/prescribed_ozone.F90 M schemes/chemistry/prescribed_ozone.meta - change to use ccpp_scheme_utils. M schemes/sima_diagnostics/sima_state_diagnostics.F90 - change to use diagnostic_name in history_out_field. ``` List all automated tests that failed, as well as an explanation for why they weren't fixed: Is this an answer-changing PR? If so, is it a new physics package, algorithm change, tuning change, etc? If yes to the above question, describe how this code was validated with the new/modified features: --------- Co-authored-by: Jesse Nusbaumer <nusbaume@ucar.edu>
1 parent 78e2017 commit 9865ef6

5 files changed

Lines changed: 18 additions & 36 deletions

File tree

schemes/chemistry/prescribed_aerosols.F90

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ end subroutine prescribed_aerosols_init
457457
!! \htmlinclude prescribed_aerosols_run.html
458458
subroutine prescribed_aerosols_run( &
459459
ncol, pver, pcnst, &
460-
const_props, &
461460
pi, &
462461
pmid, pint, phis, zi, & ! necessary fields for trcdata read.
463462
constituents, &
@@ -469,17 +468,12 @@ subroutine prescribed_aerosols_run( &
469468
! host model dependency for history output
470469
use cam_history, only: history_out_field
471470

472-
! framework dependency for const_props
473-
use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t
474-
475-
! dependency to get constituent index
476-
use ccpp_const_utils, only: ccpp_const_get_idx
471+
! framework dependency to get constituent index
472+
use ccpp_scheme_utils, only: ccpp_constituent_index
477473

478474
integer, intent(in) :: ncol
479475
integer, intent(in) :: pver
480476
integer, intent(in) :: pcnst ! # of CCPP constituents [count]
481-
type(ccpp_constituent_prop_ptr_t), &
482-
intent(in) :: const_props(:) ! CCPP constituent properties pointer
483477
real(kind_phys), intent(in) :: pi
484478
real(kind_phys), intent(in) :: pmid(:,:) ! air pressure [Pa]
485479
real(kind_phys), intent(in) :: pint(:,:) ! air pressure at interfaces [Pa]
@@ -513,11 +507,18 @@ subroutine prescribed_aerosols_run( &
513507
! the logv and logm values read from tracer_data (port of rand_sample_prescribed_aero)
514508
do i = 1, aero_count
515509
! Get constituent index
516-
call ccpp_const_get_idx(const_props, &
517-
trim(aero_map_list(i)%constituent_name), &
518-
const_idx, errmsg, errflg)
510+
call ccpp_constituent_index(trim(aero_map_list(i)%constituent_name), &
511+
const_idx, errmsg=errmsg, errcode=errflg)
519512
if (errflg /= 0) return
520513

514+
! Guard against an unresolved constituent index, which would otherwise be
515+
! used as a negative array subscript below.
516+
if (const_idx < 0) then
517+
errflg = 1
518+
errmsg = subname // ': could not find constituent "' // trim(aero_map_list(i)%constituent_name)//'"'
519+
return
520+
end if
521+
521522
if (.not. aero_map_list(i)%is_modal_aero_interstitial) then
522523
! For non-interstitial species (cloud-borne or bulk aerosols),
523524
! directly copy field data from tracer_data container

schemes/chemistry/prescribed_aerosols.meta

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,6 @@
190190
type = integer
191191
dimensions = ()
192192
intent = in
193-
[ const_props ]
194-
standard_name = ccpp_constituent_properties
195-
units = none
196-
type = ccpp_constituent_prop_ptr_t
197-
dimensions = (number_of_ccpp_constituents)
198-
intent = in
199193
[ pi ]
200194
standard_name = pi_constant
201195
units = 1

schemes/chemistry/prescribed_ozone.F90

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ end subroutine prescribed_ozone_init
153153
!! \htmlinclude prescribed_ozone_run.html
154154
subroutine prescribed_ozone_run( &
155155
ncol, pver, &
156-
const_props, &
157156
mwdry, boltz, &
158157
t, pmiddry, &
159158
pmid, pint, phis, zi, & ! necessary fields for trcdata read.
@@ -166,16 +165,11 @@ subroutine prescribed_ozone_run( &
166165
! host model dependency for history output
167166
use cam_history, only: history_out_field
168167

169-
! framework dependency for const_props
170-
use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t
171-
172-
! dependency to get constituent index
173-
use ccpp_const_utils, only: ccpp_const_get_idx
168+
! framework dependency to get constituent index
169+
use ccpp_scheme_utils, only: ccpp_constituent_index
174170

175171
integer, intent(in) :: ncol
176172
integer, intent(in) :: pver
177-
type(ccpp_constituent_prop_ptr_t), &
178-
intent(in) :: const_props(:) ! CCPP constituent properties pointer
179173
real(kind_phys), intent(in) :: mwdry ! molecular_weight_of_dry_air [g mol-1]
180174
real(kind_phys), intent(in) :: boltz ! boltzmann_constant [J K-1]
181175
real(kind_phys), intent(in) :: t(:,:) ! air temperature [K]
@@ -210,9 +204,8 @@ subroutine prescribed_ozone_run( &
210204

211205
! check for 'O3' constituent where prescribed ozone will be written to
212206
! which will be read by radiation.
213-
call ccpp_const_get_idx(const_props, &
214-
trim(ozone_name), &
215-
id_o3, errmsg, errflg)
207+
call ccpp_constituent_index(trim(ozone_name), &
208+
id_o3, errmsg=errmsg, errcode=errflg)
216209
if (errflg /= 0) return
217210

218211
! could not find the constituent, but the specifier is active.

schemes/chemistry/prescribed_ozone.meta

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,6 @@
136136
type = integer
137137
dimensions = ()
138138
intent = in
139-
[ const_props ]
140-
standard_name = ccpp_constituent_properties
141-
units = none
142-
type = ccpp_constituent_prop_ptr_t
143-
dimensions = (number_of_ccpp_constituents)
144-
intent = in
145139
[ mwdry ]
146140
standard_name = molecular_weight_of_dry_air
147141
units = g mol-1

schemes/sima_diagnostics/sima_state_diagnostics.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,11 @@ subroutine sima_state_diagnostics_run(ps, psdry, phis, T, u, v, dse, omega, &
227227
! Capture all other constituent fields
228228
do const_idx = 1, size(const_props)
229229
if (.not. const_found(const_idx)) then
230-
call const_props(const_idx)%standard_name(standard_name, errflg, errmsg)
230+
! Must match the name registered in sima_state_diagnostics_init.
231+
call const_props(const_idx)%diagnostic_name(diagnostic_name, errflg, errmsg)
231232
if (errflg /= 0) then
232233
return
233234
end if
234-
diagnostic_name = standard_name
235235
call history_out_field(trim(diagnostic_name), const_array(:,:,const_idx))
236236
end if
237237
end do

0 commit comments

Comments
 (0)