gdmemvarattrtrue.f90

Path: gtdata/gtdata_memory/gdmemvarattrtrue.f90
Last Update: Mon May 25 18:47:27 +0900 2009

Methods

Included Modules

gtdata_memory_types gtdata_memory_internal dc_string netcdf_f77

Public Instance methods

Function :
result :logical
var :type(GD_MEM_VARIABLE), intent(in)
name :character(len = *), intent(in)
default :logical, intent(in), optional

[Source]

logical function GDMemVarAttrTrue(var, name, default) result(result)
  use gtdata_memory_types, only: GD_MEM_VARIABLE, GD_MEM_VARIABLE_ENTRY, GD_MEM_ATTR_CHAIN
  use gtdata_memory_internal, only: memtab_lookup
  use dc_string, only: str_to_logical
  use netcdf_f77, only: nf_noerr
  type(GD_MEM_VARIABLE), intent(in):: var
  character(len = *), intent(in):: name
  logical, intent(in), optional:: default
  type(GD_MEM_VARIABLE_ENTRY), pointer:: ent
  type(GD_MEM_ATTR_CHAIN), pointer:: p
  character(10):: s
  integer:: stat, i

  stat = memtab_lookup(var, ent)
  if (stat /= nf_noerr) goto 999
  p => ent%attr
  do
    if (.not. associated(p)) exit
    if (p%name == name) then
      if (associated(p%cbuf)) then
        s = ""
        do, i = 1, min(len(s), size(p%cbuf))
          s(i:i) = p%cbuf(i)
        enddo
        result = str_to_logical(s)
      else
        exit
      endif
      return
    endif
    p => p%next
  enddo
999 continue
  result = .false.
  if (present(default)) result = default
  return
end function GDMemVarAttrTrue

[Validate]