Write hdf5 files to a new directory - fortran

Hello!

I am relatively new to HDF5, apologies if this is too basic. But I want to know if there is a way to write hdf5 files into a different directory than the current directory. I am trying the snippet below for example,

write(filename,'(a13,i5.5,a3)') '/data/swarms-',outnr,'.h5'
call h5open_f(error)
call h5fcreate_f(filename, H5F_ACC_TRUNC_F, file% id, file% error) ! creates file

When I do the same it throws an error that it is not able to create the file. I would be grateful if there is a way for the same.

Thank you

That looks like an absolute path, so you probably don’t have permission to write there. Either give the full path of the directory where you want to write to or a relative path with respect to the executable. If that is not the case, does /data exist and have the correct permissions?

Thank you! That solved it. I should have realised that! Now it works like I want it to! Thank you so much!