Skip to content

Commit

Permalink
Fix some comment typos and add missing close call
Browse files Browse the repository at this point in the history
  • Loading branch information
hokkanen committed Apr 15, 2024
1 parent c9f55f4 commit 656419b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions parallel-io/hdf5-writerank/hdf5-writerank.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ program hdf5_writerank
call mpi_init(err)
call mpi_comm_rank(MPI_COMM_WORLD, myproc, err)
call mpi_comm_size(MPI_COMM_WORLD, numprocs, err)

! Initialize Fortran HDF5 interface
call h5open_f(err)
! Create a new property list for file acccess
! Create a new property list for file access
call h5pcreate_f(H5P_FILE_ACCESS_F, plist, err)
! Store MPI IO communicator info to the file access property list
call h5pset_fapl_mpio_f(plist, MPI_COMM_WORLD, MPI_INFO_NULL, err)
! Create a new HDF5 file named "parallel_out.h5"
call h5fcreate_f("parallel_out.h5", H5F_ACC_TRUNC_F, file, err, access_prp=plist)
! Create a new simple dataspace for the file and open for access
call h5screate_simple_f(1, int([numprocs], hsize_t), dataspace, err)
! creates a new dataset named "MPI_RANKS" for 'file'
! Create a new dataset named "MPI_RANKS" for 'file'
call h5dcreate_f(file, "MPI_RANKS", H5T_NATIVE_INTEGER, dataspace, dataset, err)
! Number of blocks to be included in the hyperslab region
counts(1) = 1
Expand All @@ -35,6 +35,7 @@ program hdf5_writerank
! Close all handles
call h5dclose_f(dataset, err)
call h5sclose_f(dataspace, err)
call h5sclose_f(memspace, err)
call h5fclose_f(file, err)
call h5pclose_f(plist, err)
call h5close_f(err)
Expand Down
5 changes: 3 additions & 2 deletions parallel-io/hdf5-writerank/hdf5-writerank.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ int main(int argc, char **argv) {
MPI_Comm_rank(MPI_COMM_WORLD, &myproc);
MPI_Comm_size(MPI_COMM_WORLD, &numprocs);

// Create a new property list for file acccess
// Create a new property list for file access
hid_t plist = H5Pcreate(H5P_FILE_ACCESS);
// Store MPI IO communicator info to the file access property list
H5Pset_fapl_mpio(plist, MPI_COMM_WORLD, MPI_INFO_NULL);
// Create a new HDF5 file named "parallel_out.h5"
hid_t file = H5Fcreate("parallel_out.h5", H5F_ACC_TRUNC, H5P_DEFAULT, plist);
// Create a new simple dataspace for the file and open for access
hid_t dataspace = H5Screate_simple(1, (const hsize_t[]){numprocs}, NULL);
// creates a new dataset named "MPI_RANKS" for 'file'
// Create a new dataset named "MPI_RANKS" for 'file'
hid_t dataset = H5Dcreate(file, "MPI_RANKS", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
// Number of blocks to be included in the hyperslab region
hsize_t count[] = {1};
Expand All @@ -31,6 +31,7 @@ int main(int argc, char **argv) {
// Close all handles and return
H5Dclose(dataset);
H5Sclose(dataspace);
H5Sclose(memspace);
H5Fclose(file);
H5Pclose(plist);
MPI_Finalize();
Expand Down

0 comments on commit 656419b

Please sign in to comment.