gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
Functions/Subroutines
gdncvarattrtrue.f90 File Reference

Get logical (boolean) attribute value . More...

Go to the source code of this file.

Functions/Subroutines

subroutine gdncvargetattrlogical (var, name, value, default)
 

Detailed Description

Get logical (boolean) attribute value

.

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 
)

Get attribute value as logical

Interprets an attribute value as a boolean. The following are interpreted as false (case-insensitive):

  • Numeric: 0, 0.0
  • String: "0", "0.0", ".0", "0.", "0.0D0", "FALSE", ".FALSE.", "F"

All other values are interpreted as true.

Parameters
[in]varVariable handle
[in]nameAttribute name
[out]valueLogical result
[in]defaultDefault value if attribute not found (optional)

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
Error handling module.
Definition dc_error.f90:454
Handling character types.
Definition dc_string.f90:83
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public string
Character length for 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: