[Hdf-forum] how to write 4d array

Annop Wongwathanarat annop at MPA-Garching.MPG.DE
Fri Jan 22 07:05:47 EST 2010


Hi, 

I have a problem writing out a 4d array using the 
hdf5 lite fortran interface. I wrote a simple test 
program and it looks 

      use H5LT

      implicit none

      integer          :: ierr
      integer(HID_T)   :: file_id
      integer(HSIZE_T) :: dims(4) 

      character(*), parameter :: hdf5file='test4d.h5'
      real, dimension(2,2,2,2) :: var4d = 1.0

      call h5open_f(ierr) 
      call h5fcreate_f(hdf5file, H5F_ACC_TRUNC_F, file_id, ierr)

      dims(1) = 2
      dims(2) = 2
      dims(3) = 2
      dims(4) = 2

      call h5ltmake_dataset_float_f(file_id,"/var4d",4,dims,
     &     var4d(1:2,1:2,1:2,1:2),ierr)

      call h5fclose_f(file_id,ierr)
      call h5close_f(ierr) 

I got an error message when I compiled the program saying 

"tst4dhdf5.F", line 25.12: 1513-062 (S) Generic procedure reference
can not be resolved due to incorrect actual argument attributes.

However, if I only write out in 3d, e.g., I put one of the 
dimensions to 1 

      dims(1) = 2
      dims(2) = 2
      dims(3) = 2
      dims(4) = 1

      call h5ltmake_dataset_float_f(file_id,"/var4d",4,dims,
     &     var4d(1:2,1:2,1:2,1),ierr)

The program compiles without a problem and I could get the output
file. So am I missing something obvious here ? is there a 
solution to this ?

Thanks in advance. 

regards, 
Annop

-- 
==========================================
|  Annop Wongwathanarat                  |
|  Max-Planck-Institut für Astrophysik   |
|  Karl-Schwarzschild-Str. 1             |
|  85741 Garching, Germany               |
|  Tel: +49-89-30000-2206                |
|  Fax: +49-89-30000-2235                |
|  E-mail: annop at mpa-garching.mpg.de     |
==========================================



More information about the Hdf-forum mailing list