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

Utilize constituent object const_index routine #137

Open
peverwhee opened this issue Oct 17, 2024 · 0 comments
Open

Utilize constituent object const_index routine #137

peverwhee opened this issue Oct 17, 2024 · 0 comments

Comments

@peverwhee
Copy link
Collaborator

Once we have exposed the full constituent (ccpp_model_constituents_t) object via metadata (NCAR/ccpp-framework#597), we should update the following schemes to use the const_index method to grab a constituent index by its standard name (instead of what we're doing now, which is looping over all the constituents to get the index):

  • sima_diagnostics/sima_state_diagnostics.F90
    • remove const_std_names and const_diag_names
    • grab the index using the newly exposed interface
    • if the constituent is present, call history_out_field/history_add_field
  • any scheme that uses ccpp_const_get_idx
    • possible candidates: check_energy_chng, zm_diagnostics

const_index routine in the constituents object (in the CCPP framework):

subroutine ccp_model_const_index(this, index, standard_name, errcode, errmsg)
      ! Return index of metadata matching <standard_name>.
      ! <this> must be locked to execute this function

      ! Dummy arguments
      class(ccpp_model_constituents_t), intent(in)  :: this
      character(len=*),                 intent(in)  :: standard_name
      integer,                          intent(out) :: index
      integer,          optional,       intent(out) :: errcode
      character(len=*), optional,       intent(out) :: errmsg
      ! Local variables
      type(ccpp_constituent_properties_t), pointer  :: cprop => NULL()
      character(len=*), parameter :: subname = "ccp_model_const_index"

      if (this%const_props_locked(errcode=errcode, errmsg=errmsg, warn_func=subname)) then
         cprop => this%find_const(standard_name)
         if (associated(cprop)) then
            index = cprop%const_index()
         else
            index = int_unassigned
         end if
      else
         index = int_unassigned
      end if

   end subroutine ccp_model_const_index
@peverwhee peverwhee changed the title Utilize constituent object get_index routine Utilize constituent object const_index routine Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant