-
Notifications
You must be signed in to change notification settings - Fork 64
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
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
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.
scripts/constituents.py
Outdated
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)
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.
updated.
src/ccpp_constituent_prop_mod.F90
Outdated
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.
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.
removed!
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"?
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.
added another testing code block to confirm that is_moist returns true (but keeping the test of is_dry() returning false)
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 Thanks for addressing my comments. Looks good!
(Running the UFS tests now, and will open PRs)
@gold2718 @mwaxmonsky Would you like to re-review before merging this? |
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.
Apologies for the delay, looks good to me!
Sorry, can I have today? |
Sure. We're trying to attach this to a set of UFS PRs that are on a queue to be final tested/merged early next week. If we can get final approval this week, it should be fine. |
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 have not looked at the test code yet but I have a couple of things that look like they should be changed (looking at 6e165e5).
cap.write("end if", 3) | ||
cap.write("end do", 2) | ||
# end if | ||
|
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.
Why not deallocate dyn_const_name
here? It does not seem to have any other uses and I do not see any call to {host_model.name}_ccpp_deallocate_dynamic_constituents
.
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.
we can't deallocate {dyn_const_name} here because that's the module-level variable that holds the data for the dynamic constituents; deallocating it would mean you could no longer access those constituent properties
scripts/constituents.py
Outdated
cap.write(f"do index = 1, size(dyn_const_prop_{idx}, 1)", 2) | ||
cap.write(f"{dyn_const_name}(index + index_start) = dyn_const_prop_{idx}(index)", 3) | ||
cap.write("end do", 2) | ||
cap.write(f"index_start = size(dyn_const_prop_{idx}, 1)", 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.
I see how this works if there are two entries in dyn_const_dict
but what about 3? Shouldn't this be:
cap.write(f"index_start = size(dyn_const_prop_{idx}, 1)", 2) | |
cap.write(f"index_start = index_start + size(dyn_const_prop_{idx}, 1)", 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.
yes good point! fixed
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'm still not sure I have covered all the corner cases (a simpler implementation would be easy to verify), but I have not found any more definite problems.
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