underworldcode / underworld3

https://underworldcode.github.io/underworld3/
Other
21 stars 10 forks source link

PETSc error thrown when filename is incorrectly set during mesh/mesh variable write_timestep() or read_timestep() #179

Closed jcgraciosa closed 7 months ago

jcgraciosa commented 7 months ago

Description:

When the filename argument for mesh/mesh variable write_timestep() and read_timestep() is not written correctly, e.g. filename = "/sample_out", a PETSc error may be thrown:

[0]PETSC ERROR: [1]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
 [1]PETSC ERROR: Error in external library
 [1]PETSC ERROR: Error in HDF5 call H5Fcreate() Status -1
 [1]PETSC ERROR: WARNING! There are unused option(s) set! Could be the program crashed before usage or a spelling mistake, etc!
 [1]PETSC ERROR:   Option left: name:-dm_plex_gmsh_mark_vertices value: true source: code
 [1]PETSC ERROR:   Option left: name:-dm_plex_gmsh_multiple_tags value: true source: code
 [1]PETSC ERROR:   Option left: name:-dm_plex_gmsh_use_regions (no value) source: code
 [1]PETSC ERROR:   Option left: name:-viewer_hdf5_collective value: false source: code
 [1]PETSC ERROR:   Option left: name:-viewer_hdf5_sp_output value: true source: code
 [1]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
 [1]PETSC ERROR: Petsc Development GIT revision: unknown  GIT Date: unknown
 [1]PETSC ERROR: Unknown Name on a arch-linux-c-opt named gadi-cpu-clx-1795.gadi.nci.org.au by jg0883 Thu Apr  4 15:42:42 

Cause:

The root of the problem is not related to PETSc, but with the full input/output path not being found or not having write access to it. For example, if filename = /sample_out; outputPath = "out_path" the resulting output_base_name inside write_timestep or read_timestep will be /sample_out instead of out_path/sample_out.

Note that a similar PETSc error will be thrown if the outputPath does not exist.

Fix:

Before proceeding with write_timestep and read_timestep, check if the directory referenced in output_base_name exists.