diff --git a/Docs/source/usage/parameters.rst b/Docs/source/usage/parameters.rst index af45080ee59..87c2ca16f7a 100644 --- a/Docs/source/usage/parameters.rst +++ b/Docs/source/usage/parameters.rst @@ -3129,6 +3129,9 @@ The checkpoint capability can be turned with regular diagnostics: ``. Name of the checkpoint file to restart from. Returns an error if the folder does not exist or if it is not properly formatted. +* ``warpx.write_diagonstics_on_restart`` (`bool`) optional (default `false`) + When `true`, write the diagnostics after restart at the time of the restart. + Intervals parser ---------------- diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp index 0e1bb4aa785..233d03a0c58 100644 --- a/Source/Initialization/WarpXInitData.cpp +++ b/Source/Initialization/WarpXInitData.cpp @@ -483,15 +483,17 @@ WarpX::InitData () // looks at field values will see the composite of the field // solution and any external field AddExternalFields(); + } + if (restart_chkfile.empty() || write_diagonstics_on_restart) { // Write full diagnostics before the first iteration. - multi_diags->FilterComputePackFlush( -1 ); + multi_diags->FilterComputePackFlush(istep[0] - 1); // Write reduced diagnostics before the first iteration. if (reduced_diags->m_plot_rd != 0) { - reduced_diags->ComputeDiags(-1); - reduced_diags->WriteToFile(-1); + reduced_diags->ComputeDiags(istep[0] - 1); + reduced_diags->WriteToFile(istep[0] - 1); } } diff --git a/Source/WarpX.H b/Source/WarpX.H index eeb71f042bd..3a740d1b000 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -1540,6 +1540,9 @@ private: std::string restart_chkfile; + /** When `true`, write the diagnostics after restart at the time of the restart. */ + bool write_diagonstics_on_restart = false; + amrex::VisMF::Header::Version plotfile_headerversion = amrex::VisMF::Header::Version_v1; amrex::VisMF::Header::Version slice_plotfile_headerversion = amrex::VisMF::Header::Version_v1; diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 8d4e9846239..27d463c12f0 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -617,6 +617,8 @@ WarpX::ReadParameters () } } + pp_warpx.query("write_diagonstics_on_restart", write_diagonstics_on_restart); + pp_warpx.queryarr("checkpoint_signals", signals_in); #if defined(__linux__) || defined(__APPLE__) for (const std::string &str : signals_in) {