-
Notifications
You must be signed in to change notification settings - Fork 61
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
Constituent updates #549
base: main
Are you sure you want to change the base?
Constituent updates #549
Conversation
Allow schema file to be passed to validate Add Fortran comment write method Add metadata table type and name to CCPP datatable variable entries Improve generated constituent-handling code Fix issues with output of long comments Ensure more instance variables are 'private' Have capgen create database object Add line fill (target line length) interface to FortranWriter New Fortran interface, indent_size New Fortran interface, blank_line Added insert function for verbatim copy to file Allow arbitrary break for long lines Make sure call list variables have an intent Added link to constituent dictionary Add metadata to CCPP constituent object DDT Add Fortran writing unit tests and fix line break bugs Added constituent props array host interface, improved unit conversion error Use +ELLIPSIS instead of +IGNORE_EXCEPTION_DETAILS for doctests Constituent cleanup, no function side effects in interface Completed and optimized constituent accessor routines Added minimum allowed value property
Add molecular weight as variable and constituent property Fix missing property (advected) from database
…ariable in hash_table
Rename dir for var_action test to distinguish from ct_build
…d variable arrays
…nstituents variable in cap rather than provided by host
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @peverwhee!
Has a few suggestions and some things I just wanted to clarify but just let me know if these are not relevant and I can re-review. Thanks!
Added logic to the constituents object to check for compatibility before adding a new constituent. Right now, that logic only checks a logical and character properties (advected, water species, thermo active, units). And added the following tests to the advection_test:
Also added unit tests to test parsing and fortran vs metadata comparisons |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment I have is that this PR is quite big and it contains a lot of somewhat unrelated changes. It would be better imo to separate out these different changes into individual PRs: f-strings, sorted, the changes to the water/minval/units, and the dynamic constituents?
I am not suggesting to break up this PR, but maybe consider submitting smaller, less intimidating to review changes in the future (in full awareness that I am guilty of these catchall PRs from time to time ...).
I am also not suggesting to make any changes to the style of the comments. This could be a separate PR where we clean up just the formatting and re-enable the linter(s) in CI.
Overall this looks very good to me, but I don't understand it well enough. I requested a couple of small changes and I will approve afterwards, but someone with a better understanding should be reviewing and approving this (and of course the full testing needs to be done once the reviews are finalized) before it gets merged.
Thanks for all the hard work that went into this PR!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing my comments. This is a non-expert approval which on its own is not sufficient for merging ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peverwhee Some minor comments, but overall looks good. Thanks for these changes!
I will start testing in the UFS using this branch and push to get on the commit queue asap.
@@ -629,7 +679,24 @@ def capgen(run_env, return_db=False): | |||
scheme_files = [const_prop_mod] + scheme_files | |||
# end if | |||
# Next, parse the scheme files | |||
# We always need to parse the ccpp_constituent_prop_ptr_t DDT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if we aren't using the constituents feature?
cap.write(f"integer{spc} :: num_consts", 2) | ||
cap.write(f"integer{spc} :: num_dyn_consts", 2) | ||
cap.write(f"integer{spc} :: index, index_start", 2) | ||
cap.write(f"integer{spc} :: field_ind", 2) | ||
cap.write(f"type({CONST_PROP_TYPE}), pointer :: const_prop", 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be cap.write(f"type({CONST_PROP_TYPE}), pointer :: const_prop => null()", 2)
character(len=*), parameter :: subname = 'ccp_model_const_add_metadata' | ||
character(len=errmsg_len) :: error | ||
character(len=*), parameter :: subname = 'ccp_model_const_add_metadata' | ||
type(ccpp_constituent_properties_t), pointer :: cprop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initialize to null()
!!XXgoldyXX: Add check on key to see if incompatible item already there. | ||
! Check to see if standard name is already in the table | ||
call field_data%standard_name(standard_name, errcode, errmsg) | ||
cprop => this%find_const(standard_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that you nullify cprop at the start of this%find_const().
Is it best to pass in a null pointer, and return the null pointer if condition not met, otherwise return associated pointer. A purely stylistic question.
cprop => this%find_const(standard_name) | ||
if (associated(cprop)) then | ||
! Standard name already in table, let's see if the existing constituent is the same | ||
cindex = cprop%const_index() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used.
call test_host_ccpp_deallocate_dynamic_constituents() | ||
deallocate(host_constituents) | ||
allocate(host_constituents(2)) | ||
call host_constituents(1)%instantiate(std_name="specific_humidity", & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I probably don't understand the test here, but how is it allowed to have two host constituents with the same standard_name?
errflg = 0 | ||
end if | ||
! Check moist mixing ratio for a dynamic constituent | ||
call const_props(index_dyn2)%is_dry(const_log, errflg, errmsg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be calling "is_moist"?
@@ -0,0 +1,96 @@ | |||
! Test parameterization with no vertical level |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update the description?
Also, is this test exercising duplicates?
@@ -0,0 +1,75 @@ | |||
! Test parameterization with no vertical level |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update the description?
@@ -6,7 +6,7 @@ scriptdir="$( cd $( dirname $0 ); pwd -P )" | |||
## | |||
## Option default values | |||
## | |||
defdir="ct_build" | |||
defdir="va_build" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed?
Summary
Brings in optional metadata field to enable dynamic (run-time) constituents; also brings in a couple new methods for the constituent object.
closes #557
Description
Key dynamic constituent mods:
Includes additional constituent object methods:
Includes fixes to ensure consistent order of generated code (use statements, variables, etc)
Also brings back the .github/workflow/python.yaml workflow that got lost somehow
User interface changes?: Yes, but optional
User can now use "dynamic_constituent_routine" metadata header field to point to a function contained within the module fortran.
Testing:
Modified advection test to include dynamic constituent routines.
Added doctests to ccpp_datafile
Generated code snippet