USE HDF5 ! This module contains all necessary modules CHARACTER filename*100 ! CHARACTER(LEN=8), PARAMETER :: filename = "dsetf.h5" ! File name CHARACTER(LEN=3) dsetname ! Dataset name
CALL h5open_f(error) ! Initialize FORTRAN interface. CALL h5fopen_f (filename, H5F_ACC_RDWR_F, file_id, error) ! Open an existing file.
CALL h5gopen_f (file_id, "Calibration", grp_id, error) ! Open an existing group.
CALL h5dopen_f(grp_id, "EARTH_OBSERVE_BT_10_to_89GHz", dset_id, error) !open dataset 就是变量 ! Figure out the size of the EARTH_OBSERVE_BT_10_to_89GHz. CALL h5dget_space_f(dset_id,dspace_id,error) ! Get the dataspace ID
! Get dims from dataspace CALL h5sget_simple_extent_dims_f(dspace_id, tb_dims, maxdims, error)
! Allocate memory for the array. ALLOCATE(tb_out(tb_dims(1),tb_dims(2),tb_dims(3))) ! Read the dataset. CALL h5dread_f(dset_id, H5T_NATIVE_INTEGER, tb_out, tb_dims, error)
!! do something PRINT*,tb_out(1,1)*0.01+327.68!! record(short型) * scalefactor+ offset CALL h5dclose_f(dset_id, error) ! Close the dataset. DEALLOCATE(tb_out) !! 读取 DEM数据,这个是固定已知大小的读取 CALL h5dopen_f(grp_id, "DEM", dem_id, error) !open dem dem_dims=(/1826,240/) CALL h5dread_f(dem_id, H5T_NATIVE_INTEGER, DEM, dem_dims, error) ! Read the dem PRINT*,DEM(1,1)
CALL h5dclose_f(dem_id, error) ! Close the dataset.
!!!!! CALL h5gclose_f(grp_id, error) ! Close the dataset. CALL h5fclose_f(file_id, error) ! Close the file. CALL h5close_f(error) ! Close FORTRAN interface.