dyn_mpas_get_constituent_index Function

private pure function dyn_mpas_get_constituent_index(self, constituent_name) result(constituent_index)

This function returns the constituent index that corresponds to the given constituent name. In case of errors, zero is produced.

Type Bound

mpas_dynamical_core_type

Arguments

Type IntentOptional Attributes Name
class(mpas_dynamical_core_type), intent(in) :: self
character(len=*), intent(in) :: constituent_name

Return Value integer


Variables

Type Visibility Attributes Name Initial
integer, private :: i

Source Code

    pure function dyn_mpas_get_constituent_index(self, constituent_name) result(constituent_index)
        class(mpas_dynamical_core_type), intent(in) :: self
        character(*), intent(in) :: constituent_name

        integer :: i
        integer :: constituent_index

        ! Catch segmentation fault.
        if (.not. allocated(self % constituent_name)) then
            constituent_index = 0

            return
        end if

        do i = 1, self % number_of_constituents
            if (trim(adjustl(constituent_name)) == trim(adjustl(self % constituent_name(i)))) then
                constituent_index = i

                return
            end if
        end do

        constituent_index = 0
    end function dyn_mpas_get_constituent_index