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

Check VerticalDimSpec based on name #3054

Open
darianboggs opened this issue Sep 24, 2024 · 2 comments
Open

Check VerticalDimSpec based on name #3054

darianboggs opened this issue Sep 24, 2024 · 2 comments
Labels
📈 MAPL3 MAPL 3 Related 🎁 New Feature This is a new feature

Comments

@darianboggs
Copy link
Contributor

A VerticalDimSpec value is stored as a string in the ESMF_Info object in a ESMF_Field object. To check the VerticalDimSpec value of an ESMF_Field requires a string match to a string literal. The string literal can be stored in a parameter so that multiple string literals are created for the same VerticalDimSpec, but then matching requires knowing the parameter name. There is no guarantee that the parameter name or string literal match the name of the relevant VerticalDimSpec. This seems fragile.

Two options:

  1. Store the string literals in parameters in the module that defines type(VerticalDimSpec). The parameters would be used to create the ESMF_Info for the VerticalDimSpec objects, and the parameters used for the creation would be public for the sake of comparison. This still requires that the parameter names be known, but it does protect against changes in the string in the ESMF_Info object.
  2. Define type-bound logical function with a string argument that the verifies that the string corresponds to the VerticalDimSpec.
type :: VerticalDimSpec
   character(len=:), allocatable :: name_
...
contains
   module procedure :: matches => matches_spec
...
contains

   logical function matches_spec(this, string)
      class(VerticalDimSpec), intent(in) :: this
      character(len=*), intent(in) :: string
      
      matches_spec = (this%name_ == string)
      
   end function matches_spec
@darianboggs darianboggs added 🎁 New Feature This is a new feature 📈 MAPL3 MAPL 3 Related labels Sep 24, 2024
@tclune
Copy link
Collaborator

tclune commented Sep 24, 2024

How would option (2) work? At the point one is examining the info object the dim spec object would generally not be available. And if it was available, there is no reason to use the info object.

@tclune
Copy link
Collaborator

tclune commented Sep 24, 2024

I also don't understand this sentence:

The string literal can be stored in a parameter so that multiple string literals are created for the same VerticalDimSpec, but then matching requires knowing the parameter name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📈 MAPL3 MAPL 3 Related 🎁 New Feature This is a new feature
Projects
None yet
Development

No branches or pull requests

2 participants