!
!== æŠ½è±¡ (abstruct) netCDF ã‚¤ãƒ³ã‚¿ãƒ¼ãƒ•ã‚§ã‚¤ã‚¹ã®ç·ç§°å®£è¨€
!
! Authors::   Eizi TOYODA, Yasuhiro MORIKAWA
! Version::   $Id: gtdata_netcdf_generic.f90,v 1.2 2009-10-11 07:36:33 morikawa Exp $
! Tag Name::  $Name:  $
! Copyright:: Copyright (C) GFD Dennou Club, 2000-2005. All rights reserved.
! License::   See COPYRIGHT[link:../../COPYRIGHT]
!

module gtdata_netcdf_generic
  !
  !== æŠ½è±¡ netCDF ã‚¤ãƒ³ã‚¿ãƒ¼ãƒ•ã‚§ã‚¤ã‚¹ã®ç·ç§°å®£è¨€
  !

  implicit none
  !
  ! === åŸºæœ¬é–‹é–‰å‹•ä½œ ===
  !

  !
  ! an ãƒ©ã‚¤ãƒ–ãƒ©ãƒªã§ã¯ã€Œãƒ•ã‚¡ã‚¤ãƒ«ã€ã§ã¯ãªãã€Œå¤‰æ•°ã€ã‚’é–‹ã„ãŸã‚Šé–‰ã˜ãŸã‚Šã™ã‚‹ã€‚
  ! ã™ã¹ã¦ã®ã‚‚ã®ã¯å¤‰æ•°ã¨ãã®å±žæ€§ã§ã‚ã‚‹ã€‚

  interface Open
    !
    ! open(var, url, [writable], [err]) ã¯ url ã§è˜åˆ¥ã•ã‚Œã‚‹
    ! å¤‰æ•°ã‚’é–‹ã var ã«æ ¼ç´ã™ã‚‹ã€‚ã“ã“ã§å¤‰æ•°ã¨ã¯ netCDF å¤‰æ•°ã¾ãŸã¯
    ! netCDF æ¬¡å…ƒã§ã‚ã‚‹ã€‚æ¬¡å…ƒã¨åŒåã® netCDF å¤‰æ•°ãŒã‚ã‚‹å ´åˆã«ã¯ä¸¡è€…ã¯
    ! åŒä¸€è¦–ã•ã‚Œã‚‹ã€‚writable ã‚’çœŸã«æŒ‡å®šã™ã‚‹ã¨æ›¸ãè¾¼ã¿å¯ã§é–‹ã“ã†ã¨ã™ã‚‹ã€‚
    ! ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆã¯ writable=.FALSE. ã§ã‚ã‚‹ã€‚ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸå ´åˆã¯
    ! err ãŒçœŸã¨ãªã‚‹ã€‚err ã‚’ä¸Žãˆãªã‘ã‚Œã°ãƒ—ãƒã‚°ãƒ©ãƒ ã¯åœæ¢ã™ã‚‹ã€‚
    !
    recursive subroutine GDNcVarOpen(var, url, writable, err)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(out):: var
      character(len = *), intent(in):: url
      logical, intent(in), optional:: writable
      logical, intent(out), optional:: err
    end subroutine GDNcVarOpen
    !
    ! gdnc ãƒ©ã‚¤ãƒ–ãƒ©ãƒªã®å¤‰æ•°ã¯ netCDF ã®å¤‰æ•°ã¨æ¬¡å…ƒã‚’çµ±åˆã—ãŸã‚‚ã®
    ! ã§ã‚ã‚‹ã€‚æ¬¡å…ƒæ§‹é€ ä½“ã¯å˜åœ¨ã—ãªã„ã€‚ãã“ã§ã€gdnc ã®ç«‹å ´ã§ã¯
    ! å¤‰æ•°ã¯ä»»æ„å€‹ã®æ¬¡å…ƒã¨å‘¼ã°ã‚Œã‚‹å¤‰æ•°ã‚’æŒã¤ã¨ã„ã†ã“ã¨ã«ãªã‚‹ã€‚
    ! å¾“æ¥æ¬¡å…ƒå¤‰æ•°ã¨å‘¼ã°ã‚Œã¦ã„ãŸã‚‚ã®ã¯ã€å¤‰æ•°ãŒè‡ªåˆ†è‡ªèº«ã®ã¿ã‚’
    ! æ¬¡å…ƒã¨ã—ã¦ã‚‚ã¤å ´åˆã‚’æŒ‡ã™ã€‚
    !
    ! open(var, src_var, dimord, [count_compact], [err]) ã¯
    ! æ—¢ã«é–‹ã‹ã‚ŒãŸå¤‰æ•° src_var ã® ord ç•ªç›®ã®æ¬¡å…ƒã«ã‚ãŸã‚‹å¤‰æ•°ã‚’
    ! é–‹ã var ã«æ ¼ç´ã™ã‚‹ã€‚é †åº ord ã¯ç¾åœ¨ã®å…¥å‡ºåŠ›ç¯„å›²ãŒ
    ! å¹…ï¼‘ã«ãªã£ã¦ã„ã‚‹ (ã‚³ãƒ³ãƒ‘ã‚¯ãƒˆåŒ–ã—ã¦ã„ã‚‹ï¼‰ã‚’é£›ã°ã—ãŸ
    ! é †åºã§ã‚ã‚‹ãŒã€count_compact ã«çœŸã‚’æŒ‡å®šã™ã‚‹ã¨
    ! ã™ã¹ã¦ã®æ¬¡å…ƒã®ãªã‹ã®é †åºã«ãªã‚‹ã€‚
    !
    subroutine GDNcVarOpenByDimOrd(var, src_var, dimord, err)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(out):: var
      type(GD_NC_VARIABLE), intent(in):: src_var
      integer, intent(in):: dimord
      logical, intent(out), optional:: err
    end subroutine GDNcVarOpenByDimOrd
  end interface

  interface Search_dim
    integer function GDNcSearchDim(var, dimname)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      character(len = *), intent(in):: dimname
    end function GDNcSearchDim
  end interface

  interface Create
    !
    ! å¾“å±žå¤‰æ•° create
    !
    ! create(var, url, dims, [xtype], [overwrite], [err]) ã¯
    ! å ´æ‰€ url ã«æ¬¡å…ƒ dims ã‚’æŒã£ãŸå¤‰æ•°ã‚’ä½œæˆã—ã€ãã‚Œã‚’é–‹ã„ãŸ
    ! ã‚‚ã®ã‚’ var ã«æ ¼ç´ã™ã‚‹ã€‚åž‹ xtype ã‚’çœç•¥ã™ã‚‹ã¨ real ã¨
    ! ã¿ãªã•ã‚Œã‚‹ã€‚æ—¢å˜å¤‰æ•°ãŒã‚ã‚‹ã¨ãå¤±æ•—ã™ã‚‹ãŒ
    ! overwrite ãŒçœŸã§ã‚ã‚Œã°ç¶šè¡Œã™ã‚‹ã€‚
    ! ã‚¼ãƒæ¬¡å…ƒå¤‰æ•°ã‚’ä½œã‚‹ã«ã¯ dims ã«é•·ã•ã‚¼ãƒã®é…åˆ—ã‚’æ¸¡ã™ã“ã¨ã€‚
    !
    subroutine GDNcVarCreate(var, url, xtype, dims, overwrite, err)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(out):: var
      character(len = *), intent(in):: url
      character(len = *), intent(in):: xtype
      type(GD_NC_VARIABLE), intent(in):: dims(:)
      logical, intent(in), optional:: overwrite
      logical, intent(out), optional:: err
    end subroutine GDNcVarCreate
    !
    ! æ¬¡å…ƒå¤‰æ•° create
    !
    ! create(var, url, xtype, length, [overwrite], [err]) ã¯
    ! é•·ã• length ã®æ¬¡å…ƒå¤‰æ•°ã‚’ä½œæˆã™ã‚‹ã€‚
    !
    subroutine GDNcVarCreateD(var, url, xtype, length, overwrite, err)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(out):: var
      character(len = *), intent(in):: url
      character(len = *), intent(in):: xtype
      integer, intent(in):: length
      logical, intent(in), optional:: overwrite
      logical, intent(out), optional:: err
    end subroutine GDNcVarCreateD
  end interface

  interface
    subroutine GDNcVarDel(varname, hint, stat)
      character(len = *), intent(in):: varname
      character(len = *), intent(in):: hint
      integer, intent(out):: stat
    end subroutine GDNcVarDel
  end interface

  interface Close
    subroutine GDNcVarClose(var, err)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      logical, intent(out), optional:: err
    end subroutine GDNcVarClose
  end interface

  !
  ! === å¤‰æ•°ã«é–¢ã™ã‚‹å•ã„åˆã‚ã›ä¸‡èˆ¬ ===
  !

  ! mainly for PRINT debugging
  interface toString
    function GDNcVarToString(var) result(result)
      use dc_types, only: STRING
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      character(string):: result
      type(GD_NC_VARIABLE), intent(in):: var
    end function GDNcVarToString
  end interface

  interface Inquire

    subroutine GDNcVarInquire(var, ndims, dimlen, growable, name, url, xtype)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      ! å¤‰æ•°ã®æ¬¡å…ƒæ•°
      integer, intent(out), optional:: ndims
      ! å¤‰æ•°ãŒï¼‘æ¬¡å…ƒã§ã‚ã‚‹å ´åˆã€æ¬¡å…ƒé•·
      integer, intent(out), optional:: dimlen
      ! å¤‰æ•°ãŒæˆé•·å¯èƒ½æ¬¡å…ƒã‚’æŒã¤ã‹
      logical, intent(out), optional:: growable
      ! æ–‡å—åž‹å¼•æ•°ãŒçŸã„ã¨å€¤ã®åˆ‡ã‚Šè©°ã‚ãŒèµ·ã“ã‚Šã†ã‚‹
      ! '?' ã®ã‚ã¨ã®å¤‰æ•°å
      character(*), intent(out), optional:: name
      ! å¤‰æ•°åã€å°‘ãªãã¨ã‚‚ãƒ•ã‚¡ã‚¤ãƒ«åã‚’å«ã‚€ã€ãªã‚‹ã¹ãé•·ã„åå‰
      character(*), intent(out), optional:: url
      ! å¤‰æ•°ã®åž‹å
      character(*), intent(out), optional:: xtype
    end subroutine GDNcVarInquire

    ! å¼•æ•°ã¯ ndims å€‹ã§ãªã‘ã‚Œã°ãªã‚‰ãªã„
    subroutine GDNcVarInquireIA(var, dimlen)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      integer, intent(out):: dimlen(:)
    end subroutine GDNcVarInquireIA

    subroutine GDNcAttrInquire(var, attrname, xtype)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      character(len=*), intent(in):: attrname
      character(len=*), intent(out), optional:: xtype
    end subroutine GDNcAttrInquire

  end interface

  interface InquirePlus

    subroutine GDNcAttrInquirePlus(var, attrname, varid, nf_attrname)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      character(len=*), intent(in):: attrname
      integer, intent(out):: varid
      character(len=*), intent(out):: nf_attrname
    end subroutine GDNcAttrInquirePlus

  end interface

  !
  ! === å±žæ€§é–¢ä¿‚ ===
  !

  ! ã™ã¹ã¦ã¯å¤‰æ•°ã¨ã„ã† an ãƒ©ã‚¤ãƒ–ãƒ©ãƒªã®ç«‹å ´ã‹ã‚‰ã€
  ! å¤§åŸŸå±žæ€§ã¯å¤‰æ•°å±žæ€§ã¨ã¿ãªã•ã‚Œã‚‹ã€‚
  ! å±žæ€§èªã¿å–ã‚Šæ™‚ã«ã¯å¤‰æ•°å±žæ€§ã®æ¬¡ã«å¤§åŸŸå±žæ€§ã‚’æ¤œç´¢ã™ã‚‹ã€‚
  ! å±žæ€§æ›¸ãè¾¼ã¿æ™‚ã«ã¯ä¸€éƒ¨ã®ä¾‹å¤–ã‚’é™¤ãå¤‰æ•°å±žæ€§ã¨ã—ã¦æ›¸ãè¾¼ã‚€ã€‚
  ! gtool4 è¦ç´„ã§å¤§åŸŸå±žæ€§ã¨è¦å®šã•ã‚ŒãŸå±žæ€§ Conventions,
  ! gt_version, title, gt_subtitle, comment, source,
  ! institution, production, history ã«ã¤ã„ã¦ã¯ã¾ãš
  ! å¤§åŸŸå±žæ€§ã¨ã—ã¦æ›¸ãè¾¼ã‚‚ã†ã¨ã™ã‚‹ã€‚æ—¢å˜ã®å€¤ãŒã‚ã£ãŸ
  ! å ´åˆ Conventions, gt_version ã¯ gtool4 åŒå£«ãªã‚‰ã°
  ! ç‰ˆæ•°ãŒå¤§ãããªã‚‹ã‚ˆã†ã«ã™ã‚‹ã€‚history ã¯è¦å®šã©ãŠã‚Š
  ! è¿½åŠ å‹•ä½œã‚’è¡Œã†ã€‚ãã®ä»–ã®å±žæ€§åã«ã¤ã„ã¦ã¯æ—¢å˜ã¨ç•°ãªã‚‹
  ! å±žæ€§å€¤ãŒã‚ã‚Œã°å¤‰æ•°å±žæ€§ã¨ã—ã¦æ›¸ãè¾¼ã‚€ã€‚

  !
  ! --- å±žæ€§ã®åˆ—æŒ™ ---
  !

  ! ã‚ã‚‹å¤‰æ•° var ã«ä»˜éšã—ãŸå±žæ€§ã‚’ã™ã¹ã¦å–å¾—ã™ã‚‹ã«ã¯ã¾ãš
  ! attr_rewind(var) ã‚’å‘¼ã³å‡ºã—ã¦ã‹ã‚‰ç„¡é™ãƒ«ãƒ¼ãƒ—ã®ä¸ã§
  ! attr_next(var, name, [end]) ã‚’å‘¼ã³å‡ºã™ã€‚name ãŒã²ã¨ã¤
  ! ã²ã¨ã¤ã®å±žæ€§åã‚’ä¸Žãˆã‚‹ã€‚name ãŒç©ºæ–‡å—åˆ—ã«ãªã£ãŸã¨ãã€
  ! ã™ã¹ã¦ã®å±žæ€§ã‚’æŽ¢ç´¢ã—çµ‚ãˆãŸã“ã¨ã«ãªã‚‹ã€‚ã“ã®ã¨ã end ã‚’
  ! ä¸Žãˆã¦ã„ã‚Œã°ãã‚ŒãŒçœŸã«ãªã‚‹ã“ã¨ã§ã‚‚åˆ¤å®šã§ãã‚‹ã€‚

  interface attr_rewind
    subroutine GDNcVarAttrRewind(var)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
    end subroutine GDNcVarAttrRewind
  end interface

  interface attr_next
    subroutine GDNcVarAttrNext(var, name, end)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      character(len = *), intent(out):: name
      logical, intent(out), optional:: end
    end subroutine GDNcVarAttrNext
  end interface

  ! å¤‰æ•° var ã®å±žæ€§ name ã‚’å–å¾—ã—ã¦ value ã«æ ¼ç´ã™ã‚‹ã€‚
  ! å±žæ€§ãŒå˜åœ¨ã—ãªã„ã‹ value ã®é•·ã•ãŒä¸è¶³ã—ã¦ã„ã‚‹å ´åˆ
  ! default ãŒè£œã‚ã‚Œã‚‹ã€‚å±žæ€§ã®åž‹ã¯ãªã‚“ã§ã‚‚ã‚ˆãåž‹å¤‰æ›ã‚’ã™ã‚‹ã€‚

  interface get_attr

    subroutine GDNcAttrGetChar(var, name, value, default, stat)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      character(len = *), intent(in):: name
      character(len = *), intent(out):: value
      character(len = *), intent(in):: default
      integer, intent(out):: stat
    end subroutine GDNcAttrGetChar

    subroutine GDNcVarGetAttrLogical(var, name, value, default)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      character(len = *), intent(in):: name
      logical, intent(out):: value
      logical, intent(in), optional:: default
    end subroutine GDNcVarGetAttrLogical

    ! ãŠå®¢æ§˜å‘ãã§ã¯ãªã„ã‘ã‚Œã©ã€æƒ…å ±è½ã¡ã®ãªã„ã‚¤ãƒ³ã‚¿ãƒ¼ãƒ•ã‚§ã‚¤ã‚¹ã¨ã„ã†ã“ã¨ã§....
    ! stat = -1:  ãã®å±žæ€§ã¯å˜åœ¨ã—ãªã‹ã£ãŸ
    ! stat = 0 ... size(value):  ãã®å±žæ€§ã‚’å…¨éƒ¨èªã¿å–ã£ãŸã€‚ã‚µã‚¤ã‚ºã¯ stat å€‹
    ! stat > size(value):  é…åˆ—é•·ä¸è¶³ã®ãŸã‚å±žæ€§ãŒå…¨éƒ¨èªã¿å–ã‚Œãªã‹ã£ãŸã€‚
    !                      ã‚µã‚¤ã‚ºã¯ stat å€‹å¿…è¦

    subroutine GDNcAttrGetReal(var, name, value, stat, default)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      character(len = *), intent(in):: name
      real, intent(out):: value(:)
      integer, intent(out):: stat
      real, intent(in), optional:: default
    end subroutine GDNcAttrGetReal

    subroutine GDNcAttrGetDouble(var, name, value, stat, default)
      use dc_types, only: DP
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      character(len = *), intent(in):: name
      real(DP), intent(out):: value(:)
      integer, intent(out):: stat
      real(DP), intent(in), optional:: default
    end subroutine GDNcAttrGetDouble

    subroutine GDNcAttrGetInt(var, name, value, stat, default)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      character(len = *), intent(in):: name
      integer, intent(out):: value(:)
      integer, intent(out):: stat
      integer, intent(in), optional:: default
    end subroutine GDNcAttrGetInt

  end interface

  ! å¤‰æ•° var ã®å±žæ€§ name ã« value ã‚’æ ¼ç´ã™ã‚‹ã€‚
  ! å±žæ€§ã®åž‹ã¯ value ã®åž‹ã«é©åˆã™ã‚‹ã‚ˆã†ã«è¨å®šã•ã‚Œã‚‹ã€‚
  ! è«–ç†åž‹ã¯ 1 æ–‡å—ã®æ–‡å—åž‹ã¨ã—ã¦æ ¼ç´ã•ã‚Œã€çœŸã¯ T,
  ! å½ã¯ F ã¨ãªã‚‹ã€‚

  interface Put_Attr

    subroutine GDNcVarPutAttrReal(var, name, value, err)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      character(len = *), intent(in):: name
      real, intent(in):: value(:)
      logical, intent(out), optional:: err
    end subroutine GDNcVarPutAttrReal

    subroutine GDNcVarPutAttrDouble(var, name, value, err)
      use dc_types, only: DP
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      character(len = *), intent(in):: name
      real(DP), intent(in):: value(:)
      logical, intent(out), optional:: err
    end subroutine GDNcVarPutAttrDouble

    subroutine GDNcVarPutAttrInt(var, name, value, err)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      character(len = *), intent(in):: name
      integer, intent(in):: value(:)
      logical, intent(out), optional:: err
    end subroutine GDNcVarPutAttrInt

    subroutine GDNcVarPutAttrLogical(var, name, value, err)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      character(len = *), intent(in):: name
      logical, intent(in):: value
      logical, intent(out), optional:: err
    end subroutine GDNcVarPutAttrLogical

    subroutine GDNcVarPutAttrChar(var, name, value, xtype, err)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      character(len = *), intent(in):: name
      character(len = *), intent(in):: value
      character(len = *), intent(in), optional:: xtype
      logical, intent(out), optional:: err
    end subroutine GDNcVarPutAttrChar

  end interface

  interface del_attr
    subroutine GDNcVarDelAttr(var, name, err)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      character(len = *), intent(in):: name
      logical, intent(out), optional:: err
    end subroutine GDNcVarDelAttr
  end interface

  interface copy_attr
    subroutine GDNcVarAttrCopy(to, attrname, from, stat)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: to
      character(len = *), intent(in):: attrname
      type(GD_NC_VARIABLE), intent(in):: from
      integer, intent(out):: stat
    end subroutine GDNcVarAttrCopy
  end interface

  !
  ! å…¥å‡ºåŠ›
  !

  interface Get

    subroutine GDNcVarGetReal(var, start, count, stride, imap, &
      & siz, value, iostat)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      integer, intent(in):: start(:)
      integer, intent(in):: count(:)
      integer, intent(in):: stride(:)
      integer, intent(in):: imap(:)
      integer, intent(in):: siz
      real, intent(out):: value(siz)
      integer, intent(out):: iostat
    end subroutine GDNcVarGetReal

    subroutine GDNcVarGetDouble(var, start, count, stride, imap, &
      & siz, value, iostat)
      use dc_types, only: DP
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      integer, intent(in):: start(:)
      integer, intent(in):: count(:)
      integer, intent(in):: stride(:)
      integer, intent(in):: imap(:)
      integer, intent(in):: siz
      real(DP), intent(out):: value(siz)
      integer, intent(out):: iostat
    end subroutine GDNcVarGetDouble

    subroutine GDNcVarGetInt(var, start, count, stride, imap, &
      & siz, value, iostat)
      use dc_types, only: DP
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      integer, intent(in):: start(:)
      integer, intent(in):: count(:)
      integer, intent(in):: stride(:)
      integer, intent(in):: imap(:)
      integer, intent(in):: siz
      integer, intent(out):: value(siz)
      integer, intent(out):: iostat
    end subroutine GDNcVarGetInt

  end interface

  interface Put

    subroutine GDNcVarPutReal(var, start, count, stride, imap, &
      & siz, value, iostat)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      integer, intent(in):: start(:)
      integer, intent(in):: count(:)
      integer, intent(in):: stride(:)
      integer, intent(in):: imap(:)
      integer, intent(in):: siz
      real, intent(in):: value(siz)
      integer, intent(out):: iostat
    end subroutine GDNcVarPutReal

    subroutine GDNcVarPutDouble(var, start, count, stride, imap, &
      & siz, value, iostat)
      use dc_types, only: DP
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      integer, intent(in):: start(:)
      integer, intent(in):: count(:)
      integer, intent(in):: stride(:)
      integer, intent(in):: imap(:)
      integer, intent(in):: siz
      real(DP), intent(in):: value(siz)
      integer, intent(out):: iostat
    end subroutine GDNcVarPutDouble

    subroutine GDNcVarPutInt(var, start, count, stride, imap, &
      & siz, value, iostat)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      integer, intent(in):: start(:)
      integer, intent(in):: count(:)
      integer, intent(in):: stride(:)
      integer, intent(in):: imap(:)
      integer, intent(in):: siz
      integer, intent(in):: value(siz)
      integer, intent(out):: iostat
    end subroutine GDNcVarPutInt

    subroutine GDNcVarPutChar(var, start, count, stride, imap, &
      & siz, value, iostat)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in):: var
      integer, intent(in):: start(:)
      integer, intent(in):: count(:)
      integer, intent(in):: stride(:)
      integer, intent(in):: imap(:)
      integer, intent(in):: siz
      character(*), intent(in):: value(siz)
      integer, intent(out):: iostat
    end subroutine GDNcVarPutChar

  end interface

  !
  ! === ãƒ•ã‚¡ã‚¤ãƒ«åã‹ã‚‰å¤‰æ•°ã‚’ã•ãŒã™ ===
  !

  interface var_search

    subroutine GDNcVarSearchInit(iter, urlBase)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE_SEARCH
      type(GD_NC_VARIABLE_SEARCH), intent(out):: iter
      character(len = *), intent(in):: urlBase
    end subroutine GDNcVarSearchInit

    subroutine GDNcVarSearchNext(iter, url, end)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE_SEARCH
      type(GD_NC_VARIABLE_SEARCH), intent(inout):: iter
      character(len = *), intent(out):: url
      logical, intent(out):: end
    end subroutine GDNcVarSearchNext

  end interface

  !
  ! éžå¸¸è„±å‡ºç”¨ã€‚ã“ã®ãƒ«ãƒ¼ãƒãƒ³ã¯ SysDepAbort ã‹ã‚‰ã‚‚å‘¼ã°ã‚Œã‚‹ãŸã‚ã€
  ! è‡ªåˆ†ã§ StoreError ã™ã‚‹ã“ã¨ã¯ãªã„ã€‚
  !

  interface
    subroutine GDNcVarSync(var, stat)
      use gtdata_netcdf_types, only: GD_NC_VARIABLE
      type(GD_NC_VARIABLE), intent(in), optional:: var
      integer, intent(out), optional:: stat
    end subroutine GDNcVarSync
  end interface

  !
  ! an å±¤ã®å†…éƒ¨çš„ä½¿ç”¨ã®ãŸã‚ã®ãƒ«ãƒ¼ãƒãƒ³
  !
  interface
    subroutine GDNcXTypeName(ixtype, xtype)
      integer, intent(in):: ixtype
      character(*), intent(out):: xtype
    end subroutine GDNcXTypeName
  end interface

end module gtdata_netcdf_generic