@@ -184,6 +184,7 @@ VtkWriterBase::VtkWriterBase(unsigned int myrank, unsigned int num_processors,
184184 const std::string& restart_name, double restart_time, bool write_binary_output,
185185 LibB64::CompressionLevel compression_level)
186186 : currentPhase_(VAGUE),
187+ path_existing_working_directory_(path_existing_working_directory),
187188 num_timestep_digits_(LibB64::ndigits(max_number_timesteps_to_be_written)),
188189 num_processor_digits_(LibB64::ndigits(num_processors)),
189190 geometry_name_(geometry_name),
@@ -707,7 +708,7 @@ void VtkWriterBase::create_restarted_initial_collection_file_mid_section(
707708
708709 // open collection file
709710 std::ifstream restart_collection_file;
710- restart_collection_file.open (restartcollectionfilename.c_str (), std::ios::out );
711+ restart_collection_file.open (restartcollectionfilename.c_str (), std::ios::in );
711712
712713 // check if file was found
713714 if (not restart_collection_file) FOUR_C_THROW (" restart collection file could not be found" );
@@ -727,10 +728,12 @@ void VtkWriterBase::create_restarted_initial_collection_file_mid_section(
727728 std::filesystem::path p_filename (get_xml_option_value (line, " file" ));
728729
729730 // Choose base directory: on absolute restart select its parent directory
730- // otherwise keep relative with ".")
731+ // otherwise form relative path from current working directory to the restart directory
731732 const std::filesystem::path base_dir =
732- p_restart.is_absolute () ? p_restart.parent_path ()
733- : (std::filesystem::path (" ." ) / p_restart.parent_path ());
733+ p_restart.is_absolute ()
734+ ? p_restart.parent_path ()
735+ : std::filesystem::relative (std::filesystem::absolute (p_restart.parent_path ()),
736+ std::filesystem::absolute (path_existing_working_directory_));
734737
735738 // Resolve final path: select absolute file paths, otherwise anchor at base directory
736739 const std::filesystem::path resolved =
@@ -741,7 +744,9 @@ void VtkWriterBase::create_restarted_initial_collection_file_mid_section(
741744 resolved.lexically_normal ().generic_string (), readtime);
742745 }
743746 else
747+ {
744748 break ;
749+ }
745750 }
746751 }
747752
0 commit comments