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

Constituent index lookup #622

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Conversation

gold2718
Copy link
Collaborator

@gold2718 gold2718 commented Jan 6, 2025

Implement constituent index lookup routines

  • Created a new CCPP source file, src/ccpp_scheme_utils.F90
    • This file contains interfaces available to CCPP schemes
    • It contains a private pointer to the CCPP constituent object so many more interfaces could easily be created
  • Implemented two interface routines to find constituent indices from standard names
    • ccpp_constituent_index: Lookup index constituent by name
    • ccpp_constituent_indices: Lookup indices of consitutents by name
  • Add tests of this functionality into advection_test
  • Minor code cleanup

User interface changes?: Yes
- New routines available to CCPP schemes

Addresses #597

Testing:
test removed: None
unit tests: PASS
system tests: Added functionality to advection test, PASS
manual testing: NA

ccpp_constituent_index: Lookup index constituent by name
ccpp_constituent_indices: Lookup indices of consitutents by name
Add tests of this functionality into advection_test
Minor code cleanup
Update DDThost test for new CCPP source file
Copy link
Collaborator

@peverwhee peverwhee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @gold2718 ! A couple of comments

src/ccpp_scheme_utils.F90 Show resolved Hide resolved
if (initialized) then
if (size(const_inds) < size(standard_names)) then
errcode = 1
errmsg = subname//': const_inds too small'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a slightly clearer error message?

errmsg = subname//': const_inds array too small. Must be greater than or equal to the size of standard_names'

end if
end subroutine ccpp_initialize_constituent_ptr

subroutine ccpp_constituent_index(standard_name, const_index, errcode, errmsg)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General design question - what is the anticipated usage of these interfaces on the physics side?

As written, the code would return int_unassigned for the index if the provided constituent isn't present. So would it be expected that the physics would check for int_unassigned after calling ccpp_constituent_index?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great question. The benefit I see in returning int_unassigned is you can include logic for handling configurations that do not have all the constituents you might be looking for. On the other hand, it complicates just looking for errcode. Feedback @climbfuji, @dustinswales, everyone?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gold2718 @peverwhee I haven't thought through how we would tackle implementing the constituents feature in the UFS, so I don't have a strong opinion. On the physics side, having to check that index ne int_unassigned before using index seems sensible to me. At least with my (limited) understanding.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense. Someone may want to iterate over constituents to see what is available and what not. That is, not every call to this scheme should result in errflg /= success.

call ccpp_constituent_index(const_std_name, const_index, errflg, errmsg)
if (errflg == 0) then
call ccpp_constituent_indices(test_stdname_array, const_inds, errflg, errmsg)
end if
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be worthwhile to also test that calling ccpp_constituent_indices with a constituent that's NOT in the object doesn't produce an error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, will do, good call.

Copy link
Collaborator

@dustinswales dustinswales left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gold2718 These changes look good to me.

end if
end subroutine ccpp_initialize_constituent_ptr

subroutine ccpp_constituent_index(standard_name, const_index, errcode, errmsg)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gold2718 @peverwhee I haven't thought through how we would tackle implementing the constituents feature in the UFS, so I don't have a strong opinion. On the physics side, having to check that index ne int_unassigned before using index seems sensible to me. At least with my (limited) understanding.

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.

4 participants