[Paraview] Fortran wrapper of HDF5

Burlen Loring bloring at lbl.gov
Wed Mar 13 15:10:16 EDT 2013


This has more to do with language differences than hdf5 itself. In C vs 
FORTRAN multidimensional *array access operators* expect dimensions 
reversed, so *if you use the array access operators* you simpy need to 
know which you're using and pass the dimensions correctly. However, you 
can completely avoid the issue if you write(and read) your data 
flattened. It works very well with VTK. VTK expects flat multi-dimension 
arrays, with x-dir changing fastest, then y then z, write your data that 
way. Then you can use the vtkDataArray allocate memory and GetPointer to 
it, and laod the data directly into the vtk array, which is more 
efficient then copying it around.

On 03/13/2013 11:50 AM, Jason Fleming wrote:
> I've read the section of the hdf5 page that Pradeep linked to (C vs
> Fortran ordering) several times, and for the life of me, I can't figure
> out whether the hdf5 format ordering is transparent to the application
> or not.
>
> It seems really silly that hdf5 can take care of endianness so that app
> developers don't have to worry about it, but on the other hand, app
> developers now have to know whether a particular hdf5 file was written
> by a C or Fortran app in order to be able to read it properly. And yet
> hdf5 seems to work that way. Is that right?
>
> Cheers
> Jason
>
>
>
> On Thu, 2013-03-14 at 00:08 +0900, Pradeep Jha wrote:
>> Are you implying that if I use the HDF5 fortran wrapper to convert the
>> fortran binary data in h5 format and then visualize this h5 file using
>> Paraview, I am looking at the the actual data with correct dimensions?
>> Or I have to make some modifications so that I see the data correctly
>> in Paraview?
>>
>>
>> I dont want to transpose the data. I just want to visualize what I
>> wrote using Fortran without any alterations.
>>
>>
>> Pradeep
>>
>>
>>
>>
>> 2013/3/13 Biddiscombe, John A. <biddisco at cscs.ch>
>>          “How do I write the h5 file data in exactly the same way as it
>>          was written in original binary file written by Fortran?”
>>          
>>           
>>          
>>          It is writing the file the same, the problem is that fortran
>>          stores arrays in column major, and C in row major order. You
>>          state “it automatically transposes the matrix” – not true – it
>>          transposes the dimensions so that the data is still stored the
>>          same, but when you write array[z,y,x] from fortran, you want
>>          to read it as array[x,y,z] from C. The actual data on disk is
>>          the same as your binary fortran data, but the dimensions are
>>          reversed compared to the same data from C.
>>          
>>           
>>          
>>          Does that help? – the short answer is just swap the order of
>>          the dimensions in your read function in the C version and then
>>          things should appear the same. (but you must declare your
>>          arrays with the dimensions flipped).
>>          
>>           
>>          
>>          If you want to actually transpose the data, then I’m sure
>>          google will provide a code snippet
>>          
>>           
>>          
>>          I hope I’m not remembering this wrong.
>>          
>>           
>>          
>>          JB
>>          
>>           
>>          
>>           
>>          
>>           
>>          
>>           
>>          
>>          From: paraview-bounces at paraview.org
>>          [mailto:paraview-bounces at paraview.org] On Behalf Of Pradeep
>>          Jha
>>          Sent: 13 March 2013 10:58
>>          To: paraview at paraview.org
>>          Subject: [Paraview] Fortran wrapper of HDF5
>>          
>>           
>>          
>>          I recently noticed that when I am using the fortran wrapper of
>>          HDF5 to convert a binary file written by fortran into the "h5"
>>          format, it automatically transposes the matrix. Apparently,
>>          this is because HDF5 uses the C convention for writing binary
>>          files, as explained in section: 7.3.2.5. of this page.
>>          
>>           
>>          
>>          
>>          Is anyone aware of this situation? And any solutions for this
>>          problem? How do I write the h5 file data in exactly the same
>>          way as it was written in original binary file written by
>>          Fortran?
>>          
>>          
>>
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.paraview.org/mailman/listinfo/paraview



More information about the ParaView mailing list