Elena is correct, take a look at h5ex_t_stringC_F03.f90 instead.

On Jul 7, 2015, at 3:06 PM, Scot Breitenfeld <[email protected]> wrote:
> 
> You can have a look at the program h5ex_t_string_F03.f90 from:
> 
> https://www.hdfgroup.org/HDF5/examples/api18-fortran.html
> 
> You should be able to remove the writing section of the example and just 
> modify the reading part in order to read your dataset.
> 
> Scot
> 
> 
> 
> On Jul 7, 2015, at 2:42 PM, Blankenship, Clay B. (MSFC-ZP12)[USRA] 
> <[email protected]> wrote:
>> 
>> Hi,
>> I am trying to read an HDF5 file using Fortran.  I can read all the datasets 
>> I need except one which is a string.  What am I doing wrong?  I can’t find 
>> many examples of reading a fixed-length string array.
>> 
>> Thanks!
>> 
>> Here is the relevant output from h5dump:
>> 
>>     DATASET "spacecraft_overpass_time_utc" {
>>         DATATYPE  H5T_STRING {
>>               STRSIZE 24;
>>               STRPAD H5T_STR_NULLTERM;
>>               CSET H5T_CSET_ASCII;
>>               CTYPE H5T_C_S1;
>>            }
>> 
>> Here is my Fortran code:
>> 
>>  use hdf5
>> …
>>  integer :: istatus
>>  integer(HID_T) :: fileid,dsetid,datatype
>>  integer, parameter :: n_ease=267264
>>  character*80 :: dsetname(12)
>>  character(len=24), dimension(n_ease) :: tutc_ease
>>  integer(HSIZE_T), dimension(1) :: dims,maxdims,newdims
>>  integer(SIZE_T) :: mysize,sdim
>> 
>> 
>>  dims(1)=n_ease
>> 
>>  !Open fortran interface
>>  call h5open_f(istatus)
>>  call h5fopen_f(fname,H5F_ACC_RDWR_F,fileid,istatus)  
>>  dsetname(5)='Soil_Moisture_Retrieval_Data/spacecraft_overpass_time_utc'     
>>     
>>  call h5dopen_f(fileid,dsetname(5),dsetid,istatus)
>>  call h5dget_type_f(dsetid,datatype,istatus)        !datatype is not equal 
>> to H5T_STRING!
>>  call h5tget_size_f(datatype,mysize,istatus)          !mysize is good
>>  call h5dread_f(dsetid,H5T_STRING,tutc_ease,dims,istatus)   !errors here
>> 
>> The errors are:
>> HDF5-DIAG: Error detected in HDF5 (1.8.7) thread 0:
>>  #000: H5Dio.c line 174 in H5Dread(): can't read data
>>    major: Dataset
>>    minor: Read failed
>>  #001: H5Dio.c line 337 in H5D_read(): unable to set up type info
>>    major: Dataset
>>    minor: Unable to initialize object
>>  #002: H5Dio.c line 836 in H5D_typeinfo_init(): unable to convert between 
>> src and dest datatype
>>    major: Dataset
>>    minor: Feature is unsupported
>>  #003: H5T.c line 4459 in H5T_path_find(): no appropriate function for 
>> conversion path
>>    major: Datatype
>>    minor: Unable to initialize object
>> 
>> 
>> 
>> 
>> 
>> -- 
>> Clay Blankenship                *       USRA Research Scientist
>> [email protected]       *       256-961-7638
>> 320 Sparkman Drive              *       Huntsville, AL 35805 USA
>> NASA-MSFC Short-Term Prediction Research and Transition (SPoRT) Center 
>> _______________________________________________
>> 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
> 
> 
> _______________________________________________
> 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


_______________________________________________
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