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

Clean up PFT-related data structures and migrate k-loop out of interior_tendency_compute() #318

Merged

Conversation

mnlevy1981
Copy link
Collaborator

Many data structures had names that were not descriptive, so it was confusing what the purpose of the structures were. Also, there were several datatypes that were declared as arrays when it made more sense to have the array dimensions inside the datatype.

These changes go hand-in-hand with moving the k loop out of interior_tendency_compute() -- moving the array dimensions inside the type will make it easier to vectorize computations across a single column rather than needing to loop over each level.

This pull request is restricted to being bit-for-bit, so there will likely be additional vector-based optimizations to make at a later date.

Addresses #53 (perhaps not entirely) and #317. The Fortran interface will not change, but the names of variables in the settings file will - that will affect the GCMs and also require documentation updates.

Added a constructor to the type to allocate memory, and also moved the
local variable from marbl_interior_tendency_compute() to
marbl_interface_class.
Added a constructor to the type to allocate memory, and also moved the
local variable from marbl_interior_tendency_compute() to
marbl_interface_class. Similar to 69384dd, but with a different structure.
Added a constructor to the type to allocate memory, and also moved the
local variable from marbl_interior_tendency_compute() to
marbl_interface_class. Similar to 69384dd and e2ff90a.
One instance where autotroph_local was being passed with the wrong
intent.
compute_autotroph_elemental_ratios, compute_function_scaling, and
compute_Pprime are outside the k loop in interior_tendency_compute().
compute_autotroph_elemental_ratios has its own k-loop that I need to
clean up, but the other two routines act on vectors.
* autotroph_secondary_species_type -> autotroph_derived_terms_type
* zooplankton_secondary_species_type -> zooplankton_derived_terms_type
* autotroph_type -> autotroph_settings_type (and autotrophs ->
  autotroph_settings)
Biggest changes are

* autotrophs -> autotroph_settings
* zooplankton -> zooplankton_settings
* grazing -> grazer_settings

Those three require YAML (and JSON) changes, and then python
modifications due to the changes in the JSON. Plus updates to the POP
python wrappers.

This commit is still bit-for-bit in POP testing, but all tests will now
fail the namelist comparison due to changes in the variable names.
@mnlevy1981
Copy link
Collaborator Author

This pull request is not ready to be merged yet, but I want

  1. to start checking the Travis CI test results
  2. leaving PR-specific comments on work that needs to be done here instead of spread across the issue tickets being addressed

I had inadvertently changed the _CESM2_PFT_keys options in the cesm2.0
default settings file (wanted to keep autotrophs and zooplankton but
change grazing -> grazer, accidentally added _settings for all of them).
Caught by the POP test trying to use the old settings - could also have
seen the issue running MARBL_generate_settings_file.py with the cesm2.0
default file, but that isn't part of any automated testing.
instead of passing domain and autotroph_derived_terms, just pass the
values we need out of those structures (km, zt, and Pprime)
Use vector arithmetic instead of computing these ratios level by level
in an explicit loop. (Still passing km to the routine so we can
explicitly declare array lengths.)
Talking to Keith, removing the k-loop in favor of vector arithmetic
isn't useful given the ordering of the dimensions. I've put the k-loop
back in, though I find it more readable to have the k-loop inside the
associate statement.
Also, explicitly declare dimensions of arrays being passed.
@mnlevy1981
Copy link
Collaborator Author

Address #158 with compute_autotroph_nutrient_uptake() when I get to that subroutine

Also, explicitly declare dimensions of arrays being passed
compute_autotroph_photosynthesis does not need VNtot from
autotroph_derived_terms.
compute_autotroph_nutrient_uptake() is a more accurate name
Added a constructor to the type to allocate memory and moved the local
variable from marbl_interior_tendency_compute() onto
marbl_interface_class. Similar to 5105a79
Call this subroutine immediately after compute_particulate_terms(); when
we push k-loop into the latter, will also roll in the call to the
former.
Added a constructor to the type to allocate memory, and also moved the
local variable from marbl_interior_tendency_compute() to
marbl_interface_class. Similar to 69384dd, e2ff90a, and 5105a79
Also, explicitly declare dimensions of arrays being passed
Went back to c53ba4d for this routine, as the changes in 33eb778 were not
bit-for-bit on intel, gnu, or pgi (they were on nag, for some reason). So
compute_dissolved_organic_matter() is back inside the k-loop.
Added a constructor to the type to allocate memory and moved the local variable
from marbl_interior_tendency_compute() onto marbl_interface_class. Similar to
lots of prior commits (c53ba4d, 69384dd, e2ff90a, and 5105a79)
Added a constructor to the type to allocate memory and moved the local
variable from marbl_interior_tendency_compute() onto
marbl_interface_class. Similar to lots of prior commits, including the
last one.
particulate_share, surface_flux_share, and surface_flux_internal are
constructed in marbl_interface%init() rather than in marbl_init_*().
Further, surface_flux_share (and interior_tendency_share) only need to
be constructed / destructed when ciso_on is true.

Note that particulate_share is used for bury coefficients regardless of
the state of ciso_on (so perhaps it needs to be renamed).
Pull marbl_interior_tendency_share_export_variables from k loop
Added a constructor to the type to allocate memory and moved the local
variable from marbl_interior_tendency_compute onto
marbl_interface_class. Similar to lots of prior commits, most recently
bd130b4.
Pull marbl_interior_tendency_share_export_zooplankton from k loop
Take two: this time, associate with PAR%interface(0,:) to avoid issues with
array indexing (this commit is still bit-for-bit, whereas 33eb778 changed
answers)
This is a better name for the variable, as it pertains to a predator /
prey pair rather than simply the grazer (i.e. the predator).

Also, I cleaned up some of the logic behind setting up the PFT keys
(like "((grazer_sname))") in MARBL_settings_file_class.py
Switch to vector notation now that vector dimensions have been pulled
into data types.
@mnlevy1981
Copy link
Collaborator Author

6a4b02e is bit-for-bit with aux_pop_MARBL baselines on hobart; NLCOMP failures (as expected) because grazer_settings was renamed grazing_relationship_settings in marbl_in. I will continue down my list of comments from the code review, but the goal is to launch aux_pop tests on cheyenne at the end of the day and make new issue tickets for whatever clean-up I don't get to. (I'll update documentation after the POP tag is made.)

loops should be auto_ind first and k second. Also, by making zero_mask
an array of length column_kmt, we can reduce the calls to the marbl_ciso
consistency_enforce routine to once per autotroph instead of once per
level per autotroph.
marbl_ciso_interior_tendency_autotroph_zero_consistency_enforce only
needs a single element of marbl_tracer_indices%auto_inds(:), not the
entire array.
Loop over auto_ind, use vector notation for k dimension (since it's all
contiguous memory)
Given memory layout, loop over k inside auto_ind loop rather than vice
versa for compute_autotroph_photosynthesis()
Loop over auto_ind, use vector notation for k dimension (since it's all
contiguous memory)
Loop over auto_ind, use vector notation for k dimension (since it's all
contiguous memory)
Loop over auto_ind, use vector notation for k dimension (since it's all
contiguous memory)
Loop over auto_ind, use vector notation for k dimension
Loop over auto_ind, use vector notation for k dimension
Loop over zoo_ind, use vector notation for k dimension. Also, compute
f_loss_thres with min(max(..., c0), c1) rather than where statements (in
both compute_Zprime and compute_Pprime, which had been vectorized in a
previous commit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant