! Copyright (C) GFD Dennou Club, 2001.  All rights reserved.


integer function gtdim_name2ord(var, name) result(result)
    use gtdata_types, only: gt_variable
    use dc_string, only: stoi
    use an_generic, only: an_variable, search_dim
    use gt_map, only: var_class, vtb_class_netcdf
    implicit none
    type(gt_variable), intent(in):: var
    character(len = *), intent(in):: name
    integer:: class, cid
    result = -1
    if (name == ' ') return
    result = stoi(name)
    if (result /= 0) return
    ! 個別層に問い合わせて次元番号を得ようと試みる。
    call var_class(var, class, cid)
    if (class == vtb_class_netcdf) then
        result = search_dim(an_variable(cid), name)
    endif
    ! map 表から次元名を使って次元番号を得ようと試みる。
end function
