Hi Scot,
   thank you for the pointer!

I see from the example how to write a ragged array, when I try to use
the same idea for my derived type I am not sure how to handle the
various fields. Elaborating on my previous example, let us assume for
instance

type :: t_data
  logical :: l
  integer :: i
  real, allocatable :: vals(:)
  complex, allocatable :: xyz(:,:)
end type t_data

type(t_data) :: data(100) ! the array which I want to save

One possibility would be treating each field separately, creating four
arrays, which in this specific case would be two ordinary arrays and
two ragged arrays. Unless I am missing something, this could be done
as in the example.

However, I would prefer writing one single HDF5 array keeping the same
structure as in the fortran derived type. Is it possible?

My main concern about isolating each field in a dedicated array is
that it seems to become awkward when derived data types are nested,
such as

type :: t_otherdata
  integer :: n
  type(t_data) :: loc_data
end tyep t_otherdata

type(t_otherdata) :: odata(1000) ! array to be saved

since I should extract all the components of the nested structures. In
practice, I often have ~5 or more nesting levels, and I would like to
be able to treat each of them independently.

Marco





2015-06-09 16:36 GMT+0200, Scot Breitenfeld <[email protected]>:
> Hi Marco,
>
> I think the example program h5ex_t_vlen_F03.f90  at,
>
> https://www.hdfgroup.org/HDF5/examples/api18-fortran.html
>
> shows how to handle this.
>
> Scot
>
>
> On Jun 9, 2015, at 5:42 AM, marco restelli
> <[email protected]<mailto:[email protected]>> wrote:
>
> Hi all,
>   I am not very experienced with HDF5 and I need some advice for the
> following problem.
>
> Consider the fortran code
>
> type :: t_data
> integer :: i
> real, allocatable :: vals(:)
> end type t_data
>
> type(t_data) :: data(100) ! the array which I want to save
>
> where the vals component has a different dimension for each element:
>
> allocate( data(1)%vals(3) )
> allocate( data(2)%vals(1) )
> allocate( data(3)%vals(0) )
> allocate( data(4)%vals(10) )
> ...
>
> How could I save the array data in an HDF5 file? I read that there are
> "ragged arrays" as well as "fractal arrays", but I can't find any
> example about how to use them. Can anybody give my any reference?
>
> Thank you!
> Marco
>
> _______________________________________________
> Hdf-forum is for HDF software users discussion.
> [email protected]<mailto:[email protected]>
> http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
> Twitter: https://twitter.com/hdf5
>
>

_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

Reply via email to