! -*- coding: utf-8; mode: f90 -*-
!-------------------------------------------------------------------------------------
! Copyright (c) 2000-2016 Gtool Development Group. All rights reserved.
!-------------------------------------------------------------------------------------
! ** Important**
!
! This file is generated from gtvargetnum.erb by ERB included Ruby 2.3.1.
! Please do not edit this file directly. @see "gtvargetnum.erb"
!-------------------------------------------------------------------------------------
!
!= 蝗ｺ螳夐聞驟榊�縺ｸ縺ｮ謨ｰ蛟､繝��繧ｿ縺ｮ蜈･蜉�
!
! Authors::   Yasuhiro MORIKAWA, Eizi TOYODA
! Version::   $Id: gtvargetnum.rb2f90,v 1.5 2009-05-25 09:55:58 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#Get
! 縺ｨ縺励※謠蝉ｾ帙＆繧後∪縺吶�
!

!== 蝗ｺ螳夐聞驟榊�縺ｸ縺ｮ謨ｰ蛟､繝��繧ｿ縺ｮ蜈･蜉�
!
! 螟画焚 *var* 縺九ｉ *value* 縺ｫ謨ｰ蛟､繝��繧ｿ縺悟�蜉帙＆繧後∪縺吶�
! *nvalue* 縺ｫ縺ｯ驟榊�髟ｷ繧剃ｻ｣蜈･縺吶ｋ蠢�ｦ√′縺ゅｊ縺ｾ縺吶�
!
! 謨ｰ蛟､繝��繧ｿ蜈･蜉帙�髫帙↓繧ｨ繝ｩ繝ｼ縺檎函縺倥◆蝣ｴ蜷医√Γ繝�そ繝ｼ繧ｸ繧貞�蜉�
! 縺励※繝励Ο繧ｰ繝ｩ繝�縺ｯ蠑ｷ蛻ｶ邨ゆｺ�＠縺ｾ縺吶�*err* 繧剃ｸ弱∴縺ｦ縺ゅｋ蝣ｴ蜷医↓縺ｯ
! 縺ｮ蠑墓焚縺ｫ .true. 縺瑚ｿ斐ｊ縲√�繝ｭ繧ｰ繝ｩ繝�縺ｯ邨ゆｺ�＠縺ｾ縺帙ｓ縲�
!
! 蜈･蜉帙＠繧医≧縺ｨ縺吶ｋ繝��繧ｿ縺ｮ蝙九′蠑墓焚縺ｮ蝙九→逡ｰ縺ｪ繧句�ｴ蜷医√ョ繝ｼ繧ｿ縺ｯ蠑墓焚縺ｮ
! 蝙九↓螟画鋤縺輔ｌ縺ｾ縺吶� 縺薙�螟画鋤縺ｯ netCDF 縺ｮ讖溯�繧堤畑縺�※縺�∪縺吶�
! 隧ｳ縺励￥縺ｯ {netCDF 譌･譛ｬ隱樒沿繝槭ル繝･繧｢繝ｫ}[link:../xref.htm#label-10]
! 縺ｮ 3.3 蝙句､画鋤 繧貞盾辣ｧ縺励※縺上□縺輔＞縲�
!
! *Get* 縺ｯ隍�焚縺ｮ繧ｵ繝悶Ν繝ｼ繝√Φ縺ｮ邱冗ｧｰ蜷阪〒縺ゅｊ縲�
! *value* 縺ｫ繝昴う繝ｳ繧ｿ蝙九�驟榊�繧剃ｸ弱∴繧九％縺ｨ繧ょ庄閭ｽ縺ｧ縺吶ゆｸ願ｨ倥�
! 繧ｵ繝悶Ν繝ｼ繝√Φ繧貞盾辣ｧ縺励※縺上□縺輔＞縲�

subroutine GTVarGetDouble(var, value, nvalue, err)
  use gtdata_types, only: GT_VARIABLE
  use gtdata_internal_map, only: &
    & var_class, &
    & vtb_class_netcdf, &
    & map_to_internal_specs, &
    & gtvar_dump
  use gtdata_netcdf_generic, only: Get
  use gtdata_netcdf_types, only: GD_NC_VARIABLE
  use dc_types,   only: STRING, DP
  use dc_error,   only: StoreError, DC_NOERR, DC_ENEGATIVE, GT_EFAKE
  implicit none
  type(GT_VARIABLE), intent(in)            :: var
  real(DP),          intent(out)           :: value(*)
  integer,           intent(in)            :: nvalue
  logical,           intent(out), optional :: err
  integer                                  :: class, cid, stat
  integer                  , pointer       :: specs(:, :)
  character(STRING):: cause_c
  character(len = *), parameter:: subname = 'GTVarGetDouble'
  continue
  call var_class(var, class, cid)
  stat = DC_NOERR
  cause_c = ''
  if (nvalue < 1) then
    stat = DC_ENEGATIVE
    cause_c = 'nvalue'
    goto 999
  end if
  call gtvar_dump(var)
  call map_to_internal_specs(var, specs)
  if (class == vtb_class_netcdf) then
    call Get(GD_NC_VARIABLE(cid), start=specs(:, 1), count=specs(:, 2), &
      & stride=specs(:, 3), imap=specs(:, 4), siz=nvalue, value=value, &
      & iostat=stat)
  else
    stat = GT_EFAKE
  endif
  if (associated(specs)) deallocate(specs)
999 continue
  call StoreError(stat, subname, cause_c = cause_c, err = err)
end subroutine GTVarGetDouble

subroutine GTVarGetReal(var, value, nvalue, err)
  use gtdata_types, only: GT_VARIABLE
  use gtdata_internal_map, only: &
    & var_class, &
    & vtb_class_netcdf, &
    & map_to_internal_specs, &
    & gtvar_dump
  use gtdata_netcdf_generic, only: Get
  use gtdata_netcdf_types, only: GD_NC_VARIABLE
  use dc_types,   only: STRING ,SP
  use dc_error,   only: StoreError, DC_NOERR, DC_ENEGATIVE, GT_EFAKE
  implicit none
  type(GT_VARIABLE), intent(in)            :: var
  real(SP),          intent(out)           :: value(*)
  integer,           intent(in)            :: nvalue
  logical,           intent(out), optional :: err
  integer                                  :: class, cid, stat
  integer                  , pointer       :: specs(:, :)
  character(STRING):: cause_c
  character(len = *), parameter:: subname = 'GTVarGetDouble'
  continue
  call var_class(var, class, cid)
  stat = DC_NOERR
  cause_c = ''
  if (nvalue < 1) then
    stat = DC_ENEGATIVE
    cause_c = 'nvalue'
    goto 999
  end if
  call gtvar_dump(var)
  call map_to_internal_specs(var, specs)
  if (class == vtb_class_netcdf) then
    call Get(GD_NC_VARIABLE(cid), start=specs(:, 1), count=specs(:, 2), &
      & stride=specs(:, 3), imap=specs(:, 4), siz=nvalue, value=value, &
      & iostat=stat)
  else
    stat = GT_EFAKE
  endif
  if (associated(specs)) deallocate(specs)
999 continue
  call StoreError(stat, subname, cause_c = cause_c, err = err)
end subroutine GTVarGetReal

subroutine GTVarGetInt(var, value, nvalue, err)
  use gtdata_types, only: GT_VARIABLE
  use gtdata_internal_map, only: &
    & var_class, &
    & vtb_class_netcdf, &
    & map_to_internal_specs, &
    & gtvar_dump
  use gtdata_netcdf_generic, only: Get
  use gtdata_netcdf_types, only: GD_NC_VARIABLE
  use dc_types,   only: STRING
  use dc_error,   only: StoreError, DC_NOERR, DC_ENEGATIVE, GT_EFAKE
  implicit none
  type(GT_VARIABLE), intent(in)            :: var
  integer,           intent(out)           :: value(*)
  integer,           intent(in)            :: nvalue
  logical,           intent(out), optional :: err
  integer                                  :: class, cid, stat
  integer                  , pointer       :: specs(:, :)
  character(STRING):: cause_c
  character(len = *), parameter:: subname = 'GTVarGetDouble'
  continue
  call var_class(var, class, cid)
  stat = DC_NOERR
  cause_c = ''
  if (nvalue < 1) then
    stat = DC_ENEGATIVE
    cause_c = 'nvalue'
    goto 999
  end if
  call gtvar_dump(var)
  call map_to_internal_specs(var, specs)
  if (class == vtb_class_netcdf) then
    call Get(GD_NC_VARIABLE(cid), start=specs(:, 1), count=specs(:, 2), &
      & stride=specs(:, 3), imap=specs(:, 4), siz=nvalue, value=value, &
      & iostat=stat)
  else
    stat = GT_EFAKE
  endif
  if (associated(specs)) deallocate(specs)
999 continue
  call StoreError(stat, subname, cause_c = cause_c, err = err)
end subroutine GTVarGetInt