!
!= æ¬¡å…ƒç›¸å¯¾åã‹ã‚‰æ¬¡å…ƒé †åºç•ªå·ã®å•ã„åˆã‚ã›
!
! Authors::   Eizi TOYODA, Yasuhiro MORIKAWA
! Version::   $Id: gtvardimname2ord.f90,v 1.1 2009-05-29 14:40:25 morikawa Exp $
! Tag Name::  $Name:  $
! Copyright:: Copyright (C) GFD Dennou Club, 2000-2005. All rights reserved.
! License::   See COPYRIGHT[link:../../COPYRIGHT]
!
! ä»¥ä¸‹ã®ã‚µãƒ–ãƒ«ãƒ¼ãƒãƒ³ã€é–¢æ•°ã¯ gtdata_generic ã‹ã‚‰ gtdata_generic#Dimname_to_Dimord
! ã¨ã—ã¦æä¾›ã•ã‚Œã¾ã™ã€‚

integer function GTVarDimName2Ord(var, name) result(result)
  !
  !== æ¬¡å…ƒç›¸å¯¾åã‹ã‚‰æ¬¡å…ƒé †åºç•ªå·ã®å•ã„åˆã‚ã›
  !
  ! å¤‰æ•°ã«ã¯è¤‡æ•°ã®æ¬¡å…ƒãŒæ‰€å±žã—ã¾ã™ã€‚æ¬¡å…ƒã¯é †åºç•ªå·ã§è˜åˆ¥ã•ã‚Œã¾ã™ãŒã€
  ! å¤‰æ•°ã«ãŠã‘ã‚‹æ¬¡å…ƒã®é †åºã¯å…¥ã‚Œæ›¿ãˆã‚‹ã“ã¨ã‚‚ã§ãã‚‹ãŸã‚ã€
  ! å¤‰æ•°ã«ç›¸å¯¾çš„çŸã„åå‰ã§è˜åˆ¥ã™ã‚‹ã“ã¨ãŒä¾¿åˆ©ãªå ´åˆã‚‚ã‚ã‚Šã¾ã™ã€‚
  ! ãŸã¨ãˆã°å¤‰æ•° <tt>filename?var</tt> ã«å¯¾ã—ã¦
  ! <tt>filename?var,dim=1</tt> ã®ã‚ˆã†ãª
  ! ã‚³ãƒ³ãƒžè¨˜æ³• ({gtool4 netCDF è¦ç´„}[link:../xref.htm#label-6] ã®
  ! ã€Œ5.4 ã‚³ãƒ³ãƒžè¨˜æ³•ã€å‚ç…§)
  ! ã§ç”¨ã„ã‚‰ã‚Œã‚‹ã‚‚ã®ã§ã™ã€‚(NetCDF å¤‰æ•° <tt>filename?varname</tt>
  ! ã«å¯¾ã™ã‚‹æ¬¡å…ƒå <tt>dim</tt> ã¯ <tt>filename?dim</tt>
  ! ã‚’æŒ‡ç¤ºã™ã‚‹ã§ã—ã‚‡ã†ãŒã€å¿…ãšã—ã‚‚ãã®ã‚ˆã†ãªé–¢ä¿‚ãŒæˆã‚Šç«‹ã¤ã¨ã¯é™ã‚Šã¾ã›ã‚“)
  !
  ! Dimname_to_Dimord æ‰‹ç¶šã¯ã“ã®ã‚ˆã†ãªç›¸å¯¾æ¬¡å…ƒåã‹ã‚‰æ¬¡å…ƒé †åºç•ªå·ã‚’ä¸Žãˆã¾ã™ã€‚
  ! æ£å½“ãªç•ªå·ã¯1ä»¥ä¸Šã§ã‚ã‚Šã€0ä»¥ä¸‹ã®ç•ªå·ã¯ã‚¨ãƒ©ãƒ¼ã‚’ç¤ºã—ã¾ã™ã€‚
  !
  use gtdata_types, only: gt_variable
  use dc_string, only: stoi
  use gtdata_netcdf_generic, only: search_dim
  use gtdata_netcdf_types, only: GD_NC_VARIABLE
  use gtdata_internal_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(GD_NC_VARIABLE(cid), name)
  endif
  ! map è¡¨ã‹ã‚‰æ¬¡å…ƒåã‚’ä½¿ã£ã¦æ¬¡å…ƒç•ªå·ã‚’å¾—ã‚ˆã†ã¨è©¦ã¿ã‚‹ã€‚
end function GTVarDimName2Ord