pfio_get_att_string Function

public function pfio_get_att_string(ncid, varid, name, string) result(status)

Arguments

Type IntentOptional Attributes Name
integer(kind=C_INT), intent(in) :: ncid
integer(kind=C_INT), intent(in) :: varid
character(len=*), intent(in) :: name
character(len=:), intent(out), allocatable :: string

Return Value integer


Called by

proc~~pfio_get_att_string~~CalledByGraph proc~pfio_get_att_string pfio_get_att_string proc~get_attribute_from_group get_attribute_from_group proc~get_attribute_from_group->proc~pfio_get_att_string

Source Code

   function pfio_get_att_string(ncid, varid, name, string) result(status)
      integer :: status
      integer(kind=C_INT), intent(in) :: ncid
      integer(kind=C_INT), intent(in) :: varid
      character(*), intent(in) :: name
      character(:), allocatable, intent(out) :: string

      integer :: name_len
      integer(kind=C_INT),target :: attlen
      character(kind=C_CHAR, len=:), target, allocatable :: c_name
      character(len=512) :: tmp_str

      ! C requires null termination
      name_len = len_trim(name)
      allocate(character(kind=C_CHAR,len=name_len+1) :: c_name)
      c_name(1:name_len) = name(1:name_len)
      c_name(name_len+1:name_len+1) = C_NULL_CHAR
      tmp_str = ''
      ! This c-call would fill tmp_str with the global attribute
      status = c_f_pfio_get_att_string(ncid, varid, c_name, tmp_str, attlen)
      allocate(character(len=attlen) :: string)
      string = trim(tmp_str)
      deallocate(c_name)
   end function pfio_get_att_string