Refactor rad_constituents, aerosol_optics_cam for portability; extend abstract aerosol interface#1506
Conversation
…hrough 4f plus cleanup (interactive rebase on 64_156) rad_cnst/aerosol interface refactor phases 1 to 3 rad_cnst/aerosol interface refactor 1: make one aerosol property obj per list_idx rad_cnst/aerosol interface refactor 1b: make one aerosol state obj per list_idx rad_cnst/aerosol interface refactor 1c: remove list_idx argument from aerosol property objects rad_cnst/aerosol interface refactor 2a: migrate to aerosol_definition_mod.F90 (non-buildable) aer-gas split in rad_cnst (to test) split non-portable code by feature (to test) continued refactoring of rad_cnst/abstract aerosol interface. rad_cnst/aerosol interface refactor 3: gas-aerosol split; module reorg wip refactor 3c: move indexing-related to aerosol_mmr_cam aerosol abstract interface refactor 4a: prototypes for moving all access to abstract aerosol interface (aer_rad_props; microp_aero testbed) abstract aerosol interface refactor 4b: move initialization of state to avoid wrong ordering; revert bam validation logic in mirop abstract aerosol interface refactor 4c: move runtime to use aerosol_state when possible (excl register and init phases) abstract aerosol interface refactor 4c bugfix: aquaplanet sets; ODV_ diagnostic abstract aerosol interface refactor 4d bugfix: nucleate_ice_cam always active even when aerosol count is 0; implement nlogsig for BAM abstract aerosol interface refactor 4e: cleanup use statements; keyword args for get mmr for clarity; rename init1 init2 for clarity. abstract aerosol interface refactor 4f: cleanup use statements for radiative_aerosol; radiative_aerosol_definitions Continue cleanup of remnant rad_constituents; reorder comments, etc. Fix build for FCARMA (but introduces aerosol_mmr_cam dep into carma_aero/aero_model.F90) Fix OMP bug; cleanup Aerosol list renaming for clarity. Fix build error in var rename Comment cleanup Cleanup of dryrad, num_to_mass_aer leftover in modal, sectional_props. Change to globally held aerosol_state instance (to test threading) Fix build (remnant issue in microp_aero_final)
Draft optics some cleanup; move parameter 1.3 to be shared cleanup aerosol_optics_core Fix build; cleanup Make diag arguments non-optional
…r use in aerosol_optics_core.
fvitt
left a comment
There was a problem hiding this comment.
I started a review. You have done a lot of nice work on this. I have a couple of questions on some of this.
fvitt
left a comment
There was a problem hiding this comment.
A few more random things.
…further for idx_sw_diag duplication loop
|
|
||
| if (.not.(present(aero_props).and.present(aero_state))) then | ||
| call endrun('nucleate_ice_cam_calc: aero_props and aero_state must be present') | ||
| end if |
There was a problem hiding this comment.
Is there a need to remove this check?
There was a problem hiding this comment.
Good question, I was confused here. I put it back but moved it up to where aero_props is first used and merged the two if (clim_modal_carma) ... else ... clauses
| ! returns optics type and table parameters | ||
| !------------------------------------------------------------------------ | ||
| subroutine optics_params(self, list_ndx, bin_ndx, opticstype, extpsw, abspsw, asmpsw, absplw, & | ||
| subroutine optics_params(self, bin_ndx, opticstype, extpsw, abspsw, asmpsw, absplw, & |
There was a problem hiding this comment.
It seems to me that we could have a generalized optics_params method defined in the aersosol_properties abstract class module, rather than have each concrete class define it's own method.
There was a problem hiding this comment.
Thanks, this is a great idea. I implemented it in cf78638 and now can also remove radiative_aerosol::rad_aer_get_bin_props since optics_params was the only place using it.
update: verified to be b4b with izumi/nag and izumi/gnu
Co-authored-by: Francis Vitt <fvitt@ucar.edu>
Co-authored-by: Francis Vitt <fvitt@ucar.edu>
Co-authored-by: Francis Vitt <fvitt@ucar.edu>
Motivation for changes:
Purpose of changes (include the issue number and title text for each relevant GitHub issue):
Closes #1504, #1505
This pull request is an extensive refactor of
rad_constituents.F90to facilitate bringing into CAM-SIMA.rad_constituents.F90into aerosol-related modules; the original file will only handle gases. This is because RRTMGP port to CAM-SIMA split off radiatively active aerosols from gases+aerosols.aerosol_mmr_cam.F90, which can be modified to use whichever data structures are in other host models (e.g., the CCPP constituents object in CAM-SIMA will replace both pbuf and state for the purpose of radiatively active aerosol.)rad_aer_*for clarity.This pull request also extends the use of the abstract aerosol interface (
aerosol_propertiesandaerosol_state) into other physics and chemistry code, instead of the previous calls torad_cnst_*.aerosol_propertiesandaerosol_stateare now per-list_idx(climate or diagnostic list) instead of having separate_0listor_rlistfunctions; separate instantiations of the aerosol properties and state objects per(aero_model, list_idx)pair is available. This allows us to keep track of the objects themselves instead oflist_idx. Since most calls are on the climate list (list_idx=0) it will simplify calls and reduce repeating the "0" argument intorad_cnst_*.aerosol_instances_modowns bothaerosol_properties(per model/list) andaerosol_state(per model/list/chunk) as persistent module data. State objects store only pointers to the persistentphys_state(lchnk)andpbufarrays, and is thread-safe. A per-callcreate_states/destroy_statesfactory remains for transient states bound to local copies ofphysics_state(i.e.,microp_aero_run'sstate1).aerosol_instances_modand its use inphyspkg.F90most closely mimics the envisioned implementation under CAM-SIMA whereaerosol_propertiesandaerosol_statebecome inputs to CCPP physics schemes. Under CAM-SIMA the chunk dimension is removed and objects are passed directly — the factory pattern will be retired.This pull request also extracts the creation of optics objects and per-bin sw/lw property calculations from
aerosol_optics_camtoaerosol_optics_core.F90; the latter is fully-portable.After this refactoring, the following modules will be
fully-portable:
aerosol_properties_mod.F90- abstract base class.aerosol_state_mod.F90- abstract base class.radiative_aerosol_definitions.F90- base types for radiatively active aerosol.bulk_aerosol_properties_mod.F90modal_aerosol_properties_mod.F90aerosol_optics_core.F90almost-portable (need to remove
stateandpbufor minor CAM structures):bulk_aerosol_state_mod.F90- remove state and pbuf, use host-model MMR module (see below)radiative_aerosol.F90- use host-model MMR module to resolve indices; diagsaerosol_instances_mod.F90- dechunkize, change init_states to remove pbuf, remove create_states factory once unusedhost-model specific:
aerosol_mmr_cam.F90- pbuf and state%q indexing to replace with host-model specific code (i.e., CAM-SIMA CCPP constituents)needing some future work to separate out dependencies - MAM/CARMA changes were made at a best-effort here and need to be for another day:
modal_aerosol_state_mod.F90: need to CCPPizemodal_aero_wateruptake_drandmodal_aero_calcsize_diag; role ofmodal_aero_datais to be scoped out (out of scope for this work)carma_aerosol_properties_mod.F90: depends oncarma_intr(out of scope for this work)carma_aerosol_state_mod.F90: depends oncarma_intr(out of scope for this work)All changes are bit-for-bit unchanged with CAM (based off
cam6_4_156)List all files eliminated: N/A
List all files added and what they do:
List all existing files that have been modified, and describe the changes: