Commit b34f55e6 authored by Robert Schweppe's avatar Robert Schweppe
Browse files

- should work now

parent 692d7e25
Pipeline #54222 passed with stages
in 42 minutes and 54 seconds
......@@ -1084,12 +1084,12 @@ contains
character(256), dimension(:), allocatable :: attributeNames
integer(i4), parameter :: maxNames = 100_i4
integer(i4) :: nAtts = 0_i4
character(256) :: attName
integer(i4) :: nAtts
integer(i4) :: status
! assume a maximum number of 100 attributes that are checked
allocate(attributeNames(maxNames))
nAtts = 0_i4
do while (nAtts < maxNames)
select type (self)
class is (NcGroup)
......
......@@ -849,10 +849,8 @@ contains
select type (self)
class is (NcGroup)
print*, 'hasAttribute group'
status = nf90_inquire_attribute(self%id, NF90_GLOBAL, name, xtype=xtype, len=len, attnum=attnum)
class is (NcVariable)
print*, 'hasAttribute var'
status = nf90_inquire_attribute(self%parent%id, self%id, name, xtype=xtype, len=len, attnum=attnum)
end select
......@@ -873,10 +871,8 @@ contains
do while (nAtts < maxNames)
select type (self)
class is (NcGroup)
print*, 'is group', nAtts + 1_i4
status = nf90_inq_attname(self%id, NF90_GLOBAL, nAtts + 1_i4, attributeNames(nAtts + 1_i4))
class is (NcVariable)
print*, 'is variable', nAtts + 1_i4
status = nf90_inq_attname(self%parent%id, self%id, nAtts + 1_i4, attributeNames(nAtts + 1_i4))
end select
! if the status is negative, exit loop, else increase counter
......
......@@ -17,7 +17,7 @@ module test_mo_netcdf
! see netcdf-fortran repo: /fortran/netcdf_constants.f90
logical, dimension(3), parameter :: wahasatt = [.true., .true., .false.]
integer(i4), dimension(3), parameter :: waglobaltype = [2_i4, 4_i4, -1_i4]
integer(i4), dimension(3), parameter :: wagloballen = [14_i4, 1_i4, -1_i4]
integer(i4), dimension(3), parameter :: wagloballen = [64_i4, 1_i4, -1_i4]
integer(i4), dimension(3) :: raglobaltype, ragloballen, raglobalnum
logical, dimension(3) :: rahasatt
character(64), dimension(2), parameter :: wavarnames = [character(64) :: 'units', 'scaling']
......@@ -123,31 +123,17 @@ contains
call var_lon%getData(rlon)
call var_data%getData(rdata)
print*, 'getting var_data attributes...'
ravarnames = var_data%getAttributeNames()
do i=1, size(ravarnames)
print*, 'got attribute ', i, ' named', trim(ravarnames(i))
end do
print*, 'getting var_data fillvalue...'
! read the fill value
call var_data%getFillValue(rfvalue)
print*, 'getting global attributes...'
! read a global attribute
raglobalnames = nc%getAttributeNames()
do i=1, size(raglobalnames)
print*, 'got attribute ', i, ' named', trim(raglobalnames(i))
end do
print*, 'checking global attributes...'
rahasatt(1) = nc%hasAttribute(name=waglobalnames(1), xtype=raglobaltype(1), len=ragloballen(1), attnum=raglobalnum(1))
rahasatt(2) = nc%hasAttribute(name=waglobalnames(2), xtype=raglobaltype(2), len=ragloballen(2), attnum=raglobalnum(2))
rahasatt(3) = nc%hasAttribute(name=waglobalnames(3), xtype=raglobaltype(3), len=ragloballen(3), attnum=raglobalnum(3))
do i=1, 3
print*, 'hasAttribute ', i, trim(waglobalnames(i)), raglobaltype(i), ragloballen(i), raglobalnum(i)
end do
rahasatt(1) = nc%hasAttribute(name=waglobalnames(1), xtype=raglobaltype(1), len=ragloballen(1))
rahasatt(2) = nc%hasAttribute(name=waglobalnames(2), xtype=raglobaltype(2), len=ragloballen(2))
rahasatt(3) = nc%hasAttribute(name=waglobalnames(3), xtype=raglobaltype(3), len=ragloballen(3))
call nc%getAttribute(trim(waglobalnames(1)), ravalue)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment