gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
Functions/Subroutines
gdncvarattrtrue.f90 File Reference

論理 (真偽値) 属性の取得 More...

Go to the source code of this file.

Functions/Subroutines

subroutine gdncvargetattrlogical (var, name, value, default)
 

Detailed Description

論理 (真偽値) 属性の取得

Author
GFD Dennou Club

Definition in file gdncvarattrtrue.f90.

Function/Subroutine Documentation

◆ gdncvargetattrlogical()

subroutine gdncvargetattrlogical ( type(gd_nc_variable), intent(in)  var,
character(len = *), intent(in)  name,
logical, intent(out)  value,
logical, intent(in), optional  default 
)

属性値を論理値として取得

属性値を真偽値として解釈します。以下は偽として解釈されます (大文字小文字無視):

  • 数値: 0, 0.0
  • 文字列: "0", "0.0", ".0", "0.", "0.0D0", "FALSE", ".FALSE.", "F"

それ以外の値は全て真として解釈されます。

Parameters
[in]var変数ハンドル
[in]name属性名
[out]value論理値結果
[in]default

iline 42 属性未検出時のデフォルト値 (省略可能)

Definition at line 44 of file gdncvarattrtrue.f90.

45
49 use dc_types, only: string
50 use netcdf, only: nf90_max_name, nf90_noerr, nf90_char, nf90_inquire_attribute, nf90_get_att
51 use dc_error
52 use dc_string
53 implicit none
54 type(GD_NC_VARIABLE), intent(in):: var
55 character(len = *), intent(in):: name
56 logical, intent(out):: value
57 logical, intent(in), optional:: default
58 type(GD_NC_VARIABLE_ENTRY):: ent
59 character(len = STRING):: cbuffer
60 character(len = 7):: c_default
61 character(len = NF90_MAX_NAME):: aname
62 real, allocatable:: rbuf(:)
63 integer:: stat, xtype, attrlen
64 integer:: varid
65 stat = vtable_lookup(var, ent)
66 if (stat /= nf90_noerr) goto 999
67 ! 大域属性サポート
68 call inquireplus(var, name, &
69 & varid=varid, nf_attrname=aname)
70 stat = nf90_inquire_attribute(ent%fileid, varid, aname, xtype=xtype, len=attrlen)
71 if (stat /= nf90_noerr) goto 999
72 if (xtype == nf90_char) then
73 c_default = "0"
74 if (present(default)) then
75 if (default) c_default = "1"
76 endif
77 call get_attr(var, name, cbuffer, c_default, stat)
78 ! もうちょっとましな方法があるべきだが。
79 select case(cbuffer)
80 case("", "0", "0.0", "0.", ".0", "FALSE", "false", ".FALSE.", &
81 & ".false.", "F", "f", "0.0D0", "0.0d0")
82 value = .false.
83 case default
84 value = .true.
85 end select
86 else
87 allocate(rbuf(attrlen))
88 stat = nf90_get_att(ent%fileid, varid, aname, rbuf)
89 if (stat /= nf90_noerr) goto 999
90 value = (abs(rbuf(1)) > tiny(0.0))
91 endif
92 return
93
94999 continue
95 value = .false.
96 if (present(default)) value = default
エラー処理用モジュール
Definition dc_error.f90:454
文字型変数の操作
Definition dc_string.f90:83
種別型パラメタを提供します。
Definition dc_types.f90:55
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition dc_types.f90:137
integer function, public vtable_lookup(var, entry)

References dc_types::string, and gtdata_netcdf_internal::vtable_lookup().

Here is the call graph for this function: