MAPL_SimpleBundleGetIndex Function

public function MAPL_SimpleBundleGetIndex(self, name, rank, rc, quiet) result(iq)

Finds the index of the first variable with name vname. This routine is case insensitive.

Arguments

Type IntentOptional Attributes Name
type(MAPL_SimpleBundle) :: self
character(len=*), intent(in) :: name

variable name

integer, intent(in) :: rank
integer, intent(out), optional :: rc
logical, intent(in), optional :: quiet

Return Value integer

index of variable


Calls

proc~~mapl_simplebundlegetindex~~CallsGraph proc~mapl_simplebundlegetindex MAPL_SimpleBundleGetIndex proc~mapl_return MAPL_Return proc~mapl_simplebundlegetindex->proc~mapl_return at at proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception

Source Code

  function MAPL_SimpleBundleGetIndex ( self, name, rank, rc, quiet ) result(iq)

    integer                                  :: iq    !! index of variable
    type(MAPL_SimpleBundle)                  :: self
    character(len=*),            intent(in)  :: name  !! variable name
    integer,                     intent(in)  :: rank
    integer, OPTIONAL,           intent(out) :: rc
    logical, OPTIONAL,           intent(in)  :: quiet
!
!-----------------------------------------------------------------------------

    character(len=ESMF_MAXSTR) :: message
    logical :: quiet_
    integer :: i

    if ( present(quiet) ) then
       quiet_ = quiet
    else
       quiet_ = .FALSE.
    end if

    iq = -1
    if ( rank == 1 ) then
       do i = 1, self%n1d
          if (trim(self%r1(i)%name) == trim(name) ) then
              iq = i
              exit
           endif
        end do
    else if ( rank == 2 ) then
       do i = 1, self%n2d
          if (trim(self%r2(i)%name) == trim(name) ) then
              iq = i
              exit
           endif
        end do
    else if ( rank == 3 ) then
       do i = 1, self%n3d
          if (trim(self%r3(i)%name) == trim(name) ) then
              iq = i
              exit
           endif
        end do
    else
       if ( present(rc) ) then
          __raise__(MAPL_RC_ERROR,"invalid rank")
       end if
    end if

    if ( present(rc) ) then
       if ( iq <= 0 ) then
          if ( quiet_ ) then
             rc = MAPL_RC_ERROR
             return
          else
             message = "could not find index for "//trim(name)// &
                  ' in Simple Bundle <'//trim(self%name)//'>'
             __raise__(MAPL_RC_ERROR,message)
          end if
       else
          _RETURN(ESMF_SUCCESS)
       end if
    end if
    _RETURN(_SUCCESS)

  end function MAPL_SimpleBundleGetIndex