!
!= å¤‰æ•°åã®è‡ªå‹•ä½œæˆ
!
! Authors::   Eizi TOYODA, Yasuhiro MORIKAWA
! Version::   $Id: gtvartmpnam.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#GTDataTmpNam
! ã¨ã—ã¦æä¾›ã•ã‚Œã¾ã™ã€‚
!

subroutine GTVarTmpNam(file, base, result)
  !
  !== å¤‰æ•°åã®è‡ªå‹•ä½œæˆ
  !
  ! ãƒ•ã‚¡ã‚¤ãƒ«å *file* ã¨å¤‰æ•°å *base* ã‹ã‚‰ <b>file@base</b> ã‚’
  ! ä½œæˆã—ã¦ *result* ã«è¿”ã™ã€‚
  ! *file* ãŒç©ºæ–‡å—ã®å ´åˆã¯ <b>gtool.nc</b> ãŒãƒ•ã‚¡ã‚¤ãƒ«åã¨ã—ã¦ä»£ç”¨ã•ã‚Œã€
  ! *base* ãŒç©ºæ–‡å—ã®å ´åˆã¯ <b>tmp</b> ãŒå¤‰æ•°åã¨ã—ã¦ä»£ç”¨ã•ã‚Œã‚‹ã€‚
  !
  use dc_types, only: STRING
  use dc_url, only: UrlMerge
  use gtdata_generic, only: Open, Close
  use gtdata_types, only: GT_VARIABLE
  implicit none
  character(len = *), intent(in):: file
  character(len = *), intent(in):: base
  character(len = *), intent(out):: result
  type(GT_VARIABLE):: var
  integer:: n
  logical:: failed
  character(len = STRING):: fnam, vnam, vnambase
continue
  if (file == "") then
    fnam = "gtool.nc"
  else
    fnam = file
  endif
  if (base == "") then
    vnambase = "tmp"
  else
    vnambase = base
  endif
  n = 0
  do
    n = n + 1
    ! compatibility note (2001-12-02, TOYODA Eizi)
    ! dc_string ã® toChar ã‚’ä½¿ã„ãŸã„ã®ã ãŒ FQS Fortran ãŒå¤±æ•—ã™ã‚‹
    write(unit=vnam, fmt="(i32)") n
    vnam = trim(vnambase) // trim(adjustl(vnam))
    result = UrlMerge(file=fnam, var=vnam)
    call Open(var, result, writable=.FALSE., err=failed)
    if (failed) return
    call Close(var)
  enddo
end subroutine GTVarTmpNam