how to write 4d array

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@mpa-garching.mpg.de |

==========================================

Hi,
The Fortran HL make_dataset routines only handle up to 3 dimensions, so if you need to write a 4D or higher array then you will have to use the standard Fortran APIs. Take a look at example h5ex_d_rdwr.f90 at:

http://www.hdfgroup.org/ftp/HDF5/examples/examples-by-api/api18-fortran.html

for a 2D example which can be easily modified to write a 4 dimensional array.

Annop Wongwathanarat wrote:

···

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

--

M. Scot Breitenfeld
The HDF Group
1901 So First ST.
Suite C-2
Champaign, IL 61820

brtnfld@hdfgroup.org
(217)244-5664 (office)
(217)333-9049 (fax)

Hi,

Thank you for the clarification. Now it's working.

regards,
Annop

···

Hi,
The Fortran HL make_dataset routines only handle up to 3 dimensions, so
if you need to write a 4D or higher array then you will have to use the
standard Fortran APIs. Take a look at example h5ex_d_rdwr.f90 at:

http://www.hdfgroup.org/ftp/HDF5/examples/examples-by-api/api18-fortran.html

for a 2D example which can be easily modified to write a 4 dimensional
array.

Annop Wongwathanarat wrote:
> 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
>
>

--

M. Scot Breitenfeld
The HDF Group
1901 So First ST.
Suite C-2
Champaign, IL 61820

brtnfld@hdfgroup.org
(217)244-5664 (office)
(217)333-9049 (fax)