57   character(STRING), 
parameter, 
public:: &
    58     & gtool4_netCDF_Conventions = &
    59     &     
"http://www.gfd-dennou.org/library/gtool4/conventions/"    61   character(STRING), 
parameter, 
public:: &
    62     & gtool4_netCDF_version = 
"4.3"   103     character(*),     
intent(in):: varname
   105     type(
gt_history), 
intent(inout), 
target, 
optional:: history
   108     character(*), 
parameter:: subname = 
"append_attrs"   110     call beginsub(subname, 
'varname=<%c>, size(attrs(:))=<%d>', &
   111       &        c1=trim(varname), i=(/
size(attrs(:))/))
   112     if (
present(history)) 
then   118     do i = 1, 
size( attrs(:) )
   120       if ( 
strhead( 
'char', trim(
lchar(attrs(i)%attrtype))) ) 
then   122           & varname, attrs(i)%attrname, &
   123           & trim(attrs(i)%Charvalue), hst )
   124       elseif ( 
strhead( 
'int', trim(
lchar(attrs(i)%attrtype))) ) 
then   125         if ( attrs(i)%array ) 
then   128             & varname, attrs(i)%attrname , &
   129             & attrs(i)%Intarray, hst       )
   133             & varname, attrs(i)%attrname , &
   134             & attrs(i)%Intvalue, hst      )
   136       elseif ( 
strhead( 
'real', trim(
lchar(attrs(i)%attrtype))) ) 
then   137         if ( attrs(i)%array ) 
then   140             & varname, attrs(i)%attrname, attrs(i)%Realarray, hst)
   144             & varname, attrs(i)%attrname, attrs(i)%Realvalue, hst)
   146       elseif ( 
strhead( 
'double', trim(
lchar(attrs(i)%attrtype))) ) 
then   147         if ( attrs(i)%array ) 
then   148           call dbgmessage(
'Doublearray(:) is selected.')
   150             & varname, attrs(i)%attrname, attrs(i)%Doublearray, hst)
   154             & varname, attrs(i)%attrname, attrs(i)%Doublevalue, hst)
   156       elseif ( 
strhead( 
'logical', trim(
lchar(attrs(i)%attrtype))) ) 
then   158           & varname, attrs(i)%attrname, attrs(i)%Logicalvalue, hst)
   160         call dbgmessage(
'attrtype=<%c>=<%c>is Invalid.'   , &
   161           &      c1=trim(attrs(i)%attrtype)         , &
   162           &      c2=trim(
lchar(attrs(i)%attrtype))      )
   184     logical,               
intent(out), 
optional :: err
   186     character(STRING) :: cause_c
   187     character(STRING), 
parameter:: subname = 
"copy_attrs"   192     call dbgmessage(
'size(from)=<%d>, size(to)=<%d>, So copy <%d> times.', &
   193       &       i=(/ 
size(from), 
size(to), min(
size(from),
size(to)) /) )
   194     if ( 
size(to) < 
size(from) ) 
then   196       cause_c = 
'from is larger than to'   200     do i = 1, min( 
size(from), 
size(to) )
   202       to(i)%attrname       = from(i)%attrname
   203       to(i)%attrtype       = from(i)%attrtype
   204       to(i)%array          = from(i)%array
   206       if ( 
strhead( 
'char', trim(
lchar(from(i)%attrtype))) ) 
then   207         to(i)%Charvalue      = from(i)%Charvalue
   209         &   
lchar(
'Int'), trim(
lchar(from(i)%attrtype)))) 
then   210         if ( from(i)%array ) 
then   211           allocate(  to(i)%Intarray( 
size(from(i)%Intarray) )  )
   212           to(i)%Intarray = from(i)%Intarray
   214           to(i)%Intvalue = from(i)%Intvalue
   217         &   
lchar(
'Real'), trim(
lchar(from(i)%attrtype)))) 
then   218         if ( from(i)%array ) 
then   219           allocate(  to(i)%Realarray( 
size(from(i)%Realarray) )  )
   220           to(i)%Realarray = from(i)%Realarray
   222           to(i)%Realvalue = from(i)%Realvalue
   225         &   
lchar(
'Double'), trim(
lchar(from(i)%attrtype)))) 
then   226         if ( from(i)%array ) 
then   227           allocate(  to(i)%Doublearray( 
size(from(i)%Doublearray) )  )
   228           to(i)%Doublearray = from(i)%Doublearray
   230           to(i)%Doublevalue = from(i)%Doublevalue
   232       elseif ( 
strhead( 
'logical', trim(
lchar(from(i)%attrtype))) ) 
then   233         to(i)%Logicalvalue = from(i)%Logicalvalue
   236         cause_c = from(i)%attrtype
   241     call storeerror(stat, subname, err, cause_c=cause_c)
   256     integer, 
intent(in):: dimord
   258     real, 
allocatable:: 
value(:)
   261     if (dimord == history % unlimited_index) 
then   262       if (.not. 
associated(history % count)) 
return   263       length = maxval(history % count(:))
   265       call inquire(history % dimvars(dimord), size=length)
   267     if (length == 0) 
return   268     allocate(value(length))
   269     if (dimord == history % unlimited_index) 
then   270       value(:) = (/(
real(i), i = 1, length)/)
   273         & + (value(:) - 1.0) * history % interval
   278       call slice(history % dimvars(dimord), 1, start=1, count=length)
   280       value(:) = (/(
real(i), i = 1, length)/)
   282     call put(history % dimvars(dimord), 
value, 
size(
value), err)
   297     character(len = *), 
intent(in):: varname
   298     character(len = string):: name
   299     character(len = *), 
parameter:: subname = 
'lookup_variable_ord'   301     call beginsub(subname, 
'var=%c', c1 = trim(varname))
   302     if (
associated(history % vars)) 
then   303       do, result = 1, 
size(history % vars)
   304         call inquire(history % vars(result), name=name)
   305         if (name == varname) 
goto 999
   306         call dbgmessage(
'no match <%c> <%c>', c1=trim(name), c2=trim(varname))
   311     call endsub(subname, 
"result=%d", i=(/result/))
   313   type(
gt_variable) function lookup_variable(history, varname, ord) result(result)
   326     character(len = *), 
intent(in):: varname
   327     character(len = STRING) :: cause_c
   328     integer, 
intent(out), 
optional:: ord
   331     character(len = *), 
parameter:: subname = 
'lookup_variable'   333     call beginsub(subname, 
'%c', c1=trim(varname))
   336     if (
present(ord)) ord = 0
   340       result = history % vars(i)
   341       if (
present(ord)) ord = i
   344     if (
present(ord)) 
then   352     call storeerror(stat, subname, cause_c=cause_c)
   353     if (
present(ord)) ordwork = ord
   354     call endsub(subname, 
"ord=%d (0: not found)", i=(/ordwork/))
   356   type(gt_variable) function lookup_dimension(history, dimname, ord) result(result)
   366     type(gt_history), 
intent(in):: history
   367     character(len = *), 
intent(in):: dimname
   368     integer, 
intent(out), 
optional:: ord
   370     character(len = STRING):: name, cause_c
   372     character(len = *), 
parameter:: subname = 
'lookup_dimension'   374     call beginsub(subname, 
'dimname=%c', c1=trim(dimname))
   376     if (
present(ord)) ord = 0
   378     if (
associated(history % dimvars)) 
then   379       do, i = 1, 
size(history % dimvars)
   380         call inquire(history % dimvars(i), name=name)
   381         if (name == trim(dimname)) 
then   382           result = history % dimvars(i)
   383           if (
present(ord)) ord = i
   390     if (
present(ord)) 
then   397     call storeerror(stat, subname, cause_c=cause_c)
   398     if (
present(ord)) ordwork = ord
   399     call endsub(subname, 
'ord=%d (0:not found)', i=(/ordwork/))
   413     type(gt_history), 
intent(in):: history
   414     character(len = *), 
intent(in):: name
   415     type(gt_variable), 
intent(out):: var
   416     logical, 
intent(out):: err
   418     character(STRING) :: cause_c
   419     character(len = *), 
parameter:: subname = 
'lookup_var_or_dim'   421     call beginsub(subname, 
'name=<%c>', c1=trim(name))
   435     cause_c = 
"Any vars and dims are not found"   438     call endsub(subname, 
'ord=%d (0:not found)', i=(/ord/))
 
type(gt_history), target, save, public default
 
integer, parameter, public token
単語やキーワードを保持する文字型変数の種別型パラメタ 
 
subroutine, public storeerror(number, where, err, cause_c, cause_i)
 
integer, parameter, public dc_noerr
 
subroutine, public dbgmessage(fmt, i, r, d, L, n, c1, c2, c3, ca)
 
subroutine, public beginsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca, version)
 
integer, parameter, public gt_eargsizemismatch
 
integer, parameter, public gt_ebadattrname
 
integer, parameter, public gt_ebaddimname
 
subroutine, public endsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca)
 
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ