! -*- coding: utf-8; mode: f90 -*-
!-------------------------------------------------------------------------------------
! Copyright (c) 2000-2016 Gtool Development Group. All rights reserved.
!-------------------------------------------------------------------------------------
! ** Important**
!
! This file is generated from gdncvarputnum.erb by ERB included Ruby 2.3.1.
! Please do not edit this file directly. @see "gdncvarputnum.erb"
!-------------------------------------------------------------------------------------
!
!
!= GD_NC_VARIABLES の出力
!
!= Put GD_NC_VARIABLES
!
! Authors::   Yasuhiro MORIKAWA, Eizi TOYODA
! Version::   $Id: gdncvarputnum.rb2f90,v 1.3 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]
!
subroutine GDNcVarPutReal(var, start, count, stride, imap, siz, value, iostat)
  use dc_types, only: SP
  use gtdata_netcdf_types, only: GD_NC_VARIABLE
  use gtdata_netcdf_internal, only: GD_NC_VARIABLE_ENTRY, vtable_lookup
  use netcdf, only: NF90_NOERR, NF90_EINVAL, NF90_PUT_VAR
  use gtdata_netcdf_file_generic, only: GDNcFileDataMode
  use dc_trace, only: DbgMessage
  implicit none
  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(SP), intent(in):: value(siz)
  integer, intent(out):: iostat
  integer:: ndims
  type(GD_NC_VARIABLE_ENTRY):: ent
  character(len = *), parameter:: subname = "GDNcVarPutReal"
  continue
  iostat = vtable_lookup(var, ent)
  if (iostat /= NF90_NOERR) goto 999
  ndims = 0
  if (associated(ent%dimids)) ndims = size(ent%dimids)
  if (min(size(start), size(count), size(stride), size(imap)) < ndims) then
    iostat = NF90_EINVAL
    goto 999
  endif
  call DbgMessage("f=%d v=%d sta=%*d c=%*d str=%*d imap=%*d", &
    & i=(/ent%fileid, ent%varid, start, count, stride, imap/), &
    & n=(/ndims, ndims, ndims, ndims/))
  iostat = GDNcFileDataMode(ent%fileid)
  if (iostat /= NF90_NOERR) return
  iostat = NF90_PUT_VAR(ent%fileid, ent%varid, value, &
    & start, count, stride, imap)
999 continue
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
  use gtdata_netcdf_internal, only: GD_NC_VARIABLE_ENTRY, vtable_lookup
  use netcdf, only: NF90_NOERR, NF90_EINVAL, NF90_PUT_VAR
  use gtdata_netcdf_file_generic, only: GDNcFileDataMode
  use dc_trace, only: DbgMessage
  implicit none
  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
  integer:: ndims
  type(GD_NC_VARIABLE_ENTRY):: ent
  character(len = *), parameter:: subname = "GDNcVarPutDouble"
  continue
  iostat = vtable_lookup(var, ent)
  if (iostat /= NF90_NOERR) goto 999
  ndims = 0
  if (associated(ent%dimids)) ndims = size(ent%dimids)
  if (min(size(start), size(count), size(stride), size(imap)) < ndims) then
    iostat = NF90_EINVAL
    goto 999
  endif
  call DbgMessage("f=%d v=%d sta=%*d c=%*d str=%*d imap=%*d", &
    & i=(/ent%fileid, ent%varid, start, count, stride, imap/), &
    & n=(/ndims, ndims, ndims, ndims/))
  iostat = GDNcFileDataMode(ent%fileid)
  if (iostat /= NF90_NOERR) return
  iostat = NF90_PUT_VAR(ent%fileid, ent%varid, value, &
    & start, count, stride, imap)
999 continue
end subroutine GDNcVarPutDouble

subroutine GDNcVarPutInt(var, start, count, stride, imap, siz, value, iostat)
  use gtdata_netcdf_types, only: GD_NC_VARIABLE
  use gtdata_netcdf_internal, only: GD_NC_VARIABLE_ENTRY, vtable_lookup
  use netcdf, only: NF90_NOERR, NF90_EINVAL, NF90_PUT_VAR
  use gtdata_netcdf_file_generic, only: GDNcFileDataMode
  use dc_trace, only: DbgMessage
  implicit none
  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
  integer:: ndims
  type(GD_NC_VARIABLE_ENTRY):: ent
  character(len = *), parameter:: subname = "GDNcVarPutInt"
  continue
  iostat = vtable_lookup(var, ent)
  if (iostat /= NF90_NOERR) goto 999
  ndims = 0
  if (associated(ent%dimids)) ndims = size(ent%dimids)
  if (min(size(start), size(count), size(stride), size(imap)) < ndims) then
    iostat = NF90_EINVAL
    goto 999
  endif
  call DbgMessage("f=%d v=%d sta=%*d c=%*d str=%*d imap=%*d", &
    & i=(/ent%fileid, ent%varid, start, count, stride, imap/), &
    & n=(/ndims, ndims, ndims, ndims/))
  iostat = GDNcFileDataMode(ent%fileid)
  if (iostat /= NF90_NOERR) return
  iostat = NF90_PUT_VAR(ent%fileid, ent%varid, value, &
    & start, count, stride, imap)
999 continue
end subroutine GDNcVarPutInt

subroutine GDNcVarPutChar(var, start, count, stride, imap, siz, value, iostat)
  use gtdata_netcdf_types, only: GD_NC_VARIABLE
  use gtdata_netcdf_internal, only: GD_NC_VARIABLE_ENTRY, vtable_lookup
  use netcdf, only: NF90_NOERR, NF90_EINVAL, NF90_PUT_VAR
  use gtdata_netcdf_file_generic, only: GDNcFileDataMode
  use dc_trace, only: DbgMessage
  implicit none
  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
  integer:: ndims
  type(GD_NC_VARIABLE_ENTRY):: ent
  character(len = *), parameter:: subname = "GDNcVarPutChar"
  continue
  iostat = vtable_lookup(var, ent)
  if (iostat /= NF90_NOERR) goto 999
  ndims = 0
  if (associated(ent%dimids)) ndims = size(ent%dimids)
  if (min(size(start), size(count), size(stride), size(imap)) < ndims) then
    iostat = NF90_EINVAL
    goto 999
  endif
  call DbgMessage("f=%d v=%d sta=%*d c=%*d str=%*d imap=%*d", &
    & i=(/ent%fileid, ent%varid, start, count, stride, imap/), &
    & n=(/ndims, ndims, ndims, ndims/))
  iostat = GDNcFileDataMode(ent%fileid)
  if (iostat /= NF90_NOERR) return
  iostat = NF90_PUT_VAR(ent%fileid, ent%varid, value, &
    & start, count, stride, imap)
999 continue
end subroutine GDNcVarPutChar

