@@ -245,7 +245,7 @@ void core::config_modules(pt::ptree &value, const pt::ptree &config, std::vector
245245 SPDLOG_DEBUG (" No config for {}" , module_name);
246246 }
247247
248- boost ::shared_ptr<module_base> module = module_factory::create (module_name, cfg);
248+ std ::shared_ptr<module_base> module = module_factory::create (module_name, cfg);
249249 // internal tracking of module initialization order
250250 module ->IDnum = modnum;
251251
@@ -504,6 +504,51 @@ void core::config_checkpoint( pt::ptree& value)
504504 }
505505 }
506506 }
507+
508+ if (_checkpoint_opts.load_from_checkpoint && !_checkpoint_opts.ugrid_outputs .empty ())
509+ {
510+ // Outputs are configured before we load checkpoint metadata, so apply ugrid state here.
511+ // Apply checkpoint ugrid rotation state now that outputs are configured.
512+ for (auto &out : _outputs)
513+ {
514+ if (out.mesh_output_formats != output_info::mesh_outputs::ugrid)
515+ {
516+ continue ;
517+ }
518+
519+ const chkptOp::ugrid_output_state* match = nullptr ;
520+ for (const auto &state : _checkpoint_opts.ugrid_outputs )
521+ {
522+ if (state.base_name == out.base_name )
523+ {
524+ match = &state;
525+ break ;
526+ }
527+ }
528+ if (!match && _checkpoint_opts.ugrid_outputs .size () == 1 )
529+ {
530+ match = &_checkpoint_opts.ugrid_outputs .front ();
531+ }
532+ if (!match)
533+ {
534+ // Warn if the checkpoint metadata doesn't match the configured ugrid outputs.
535+ SPDLOG_WARN (" No checkpoint ugrid state matches base_name={}" , out.base_name );
536+ continue ;
537+ }
538+
539+ if (!match->path .empty ())
540+ {
541+ auto & writer = boost::get<boost::shared_ptr<ugrid_writer>>(out.writer );
542+ writer->set_store_path (match->path );
543+ SPDLOG_DEBUG (" Resuming ugrid output from checkpoint file {}" , match->path );
544+ }
545+ if (match->rotate_offset )
546+ {
547+ out.rotate_offset = match->rotate_offset ;
548+ SPDLOG_DEBUG (" Resuming ugrid rotation with offset {}" , *match->rotate_offset );
549+ }
550+ }
551+ }
507552 }
508553}
509554void core::config_forcing (pt::ptree &value)
@@ -597,7 +642,7 @@ void core::config_forcing(pt::ptree &value)
597642 if (_use_netcdf)
598643 {
599644 std::string file = value.get <std::string>(" file" );
600- std::map<std::string, boost ::shared_ptr<filter_base> > netcdf_filters;
645+ std::map<std::string, std ::shared_ptr<filter_base> > netcdf_filters;
601646 try
602647 {
603648 auto filter_section = value.get_child (" filter" );
@@ -607,7 +652,7 @@ void core::config_forcing(pt::ptree &value)
607652 auto filter_name = jtr.first .data ();
608653 auto cfg = jtr.second ;
609654
610- boost ::shared_ptr<filter_base> filter = filter_factory::create (filter_name,cfg);
655+ std ::shared_ptr<filter_base> filter = filter_factory::create (filter_name,cfg);
611656 filter->init ();
612657 netcdf_filters[filter_name] = filter;
613658 }
@@ -688,7 +733,7 @@ void core::config_forcing(pt::ptree &value)
688733 auto filter_name = jtr.first .data ();
689734 auto cfg = jtr.second ;
690735
691- boost ::shared_ptr<filter_base> filter = filter_factory::create (filter_name,cfg);
736+ std ::shared_ptr<filter_base> filter = filter_factory::create (filter_name,cfg);
692737 filter->init ();
693738
694739 // save this filter to run later
@@ -832,7 +877,7 @@ bool core::config_meshes( pt::ptree &value)
832877{
833878 SPDLOG_DEBUG (" Found meshes sections" );
834879
835- _mesh = boost ::make_shared<triangulation>();
880+ _mesh = std ::make_shared<triangulation>();
836881
837882 _mesh->_global = _global;
838883
@@ -1192,7 +1237,7 @@ void core::config_output(pt::ptree &value)
11921237 boost::filesystem::create_directories (f.parent_path ());
11931238 out.fname = f.string ();
11941239 out.mesh_output_formats = output_info::mesh_outputs::vtu;
1195- out.writer = boost ::make_shared<vtk_writer>(_mesh);
1240+ out.writer = std ::make_shared<vtk_writer>(_mesh);
11961241 }
11971242 else
11981243 {
@@ -1216,15 +1261,15 @@ void core::config_output(pt::ptree &value)
12161261 out.mesh_output_formats = output_info::mesh_outputs::ugrid;
12171262 out.fname = ugrid_path.string ();
12181263
1219- out.writer = boost ::make_shared<ugrid_writer>(
1264+ out.writer = std ::make_shared<ugrid_writer>(
12201265 _mesh,
12211266 _global,
12221267 _mesh->write_param_to_output (),
12231268 out.fname ,
12241269 use_zarr);
12251270
1226- boost::get<boost ::shared_ptr<ugrid_writer>>(out.writer )->compress = itr.second .get <bool >(" compress" , true );
1227- boost::get<boost ::shared_ptr<ugrid_writer>>(out.writer )->bitgroom = itr.second .get <bool >(" bitgroom" , true );
1271+ boost::get<std ::shared_ptr<ugrid_writer>>(out.writer )->compress = itr.second .get <bool >(" compress" , true );
1272+ boost::get<std ::shared_ptr<ugrid_writer>>(out.writer )->bitgroom = itr.second .get <bool >(" bitgroom" , true );
12281273
12291274 }
12301275
@@ -1239,7 +1284,7 @@ void core::config_output(pt::ptree &value)
12391284 out.write_ghost_neighbors = write_ghost;
12401285 if (out.mesh_output_formats == output_info::mesh_outputs::vtu)
12411286 {
1242- boost::get<boost ::shared_ptr<vtk_writer>>(out.writer )->set_write_ghost_neighbors (write_ghost);
1287+ boost::get<std ::shared_ptr<vtk_writer>>(out.writer )->set_write_ghost_neighbors (write_ghost);
12431288 }
12441289
12451290 out.frequency = itr.second .get_optional <size_t >(" frequency" ); // defaults to every timestep
@@ -1284,37 +1329,6 @@ void core::config_output(pt::ptree &value)
12841329 ->set_chunking_override (chunk_len_steps, chunk_target_mb);
12851330 }
12861331
1287- if (_checkpoint_opts.load_from_checkpoint && out.mesh_output_formats == output_info::mesh_outputs::ugrid)
1288- {
1289- // Restore the output path and rotation offset captured in the checkpoint metadata.
1290- const chkptOp::ugrid_output_state* match = nullptr ;
1291- for (const auto &state : _checkpoint_opts.ugrid_outputs )
1292- {
1293- if (state.base_name == out.base_name )
1294- {
1295- match = &state;
1296- break ;
1297- }
1298- }
1299- if (!match && _checkpoint_opts.ugrid_outputs .size () == 1 )
1300- {
1301- match = &_checkpoint_opts.ugrid_outputs .front ();
1302- }
1303- if (match)
1304- {
1305- if (!match->path .empty ())
1306- {
1307- auto & writer = boost::get<boost::shared_ptr<ugrid_writer>>(out.writer );
1308- writer->set_store_path (match->path );
1309- SPDLOG_DEBUG (" Resuming ugrid output from checkpoint file {}" , match->path );
1310- }
1311- if (match->rotate_offset )
1312- {
1313- out.rotate_offset = match->rotate_offset ;
1314- }
1315- }
1316- }
1317-
13181332 auto specific_datetime = itr.second .get_optional <std::string>(" specific_datetime" );
13191333 if (specific_datetime)
13201334 {
@@ -1538,7 +1552,7 @@ void core::init(int argc, char **argv)
15381552 SPDLOG_DEBUG (" Logger initialized. Writing to cout and {}" , log_name);
15391553
15401554
1541- _global = boost ::make_shared<global>();
1555+ _global = std ::make_shared<global>();
15421556
15431557 // This needs to be set so that underflows in gsl math
15441558 // computations are not treated as errors. i.e.,
@@ -2567,7 +2581,7 @@ void core::run()
25672581 pt::ptree entry;
25682582 entry.put (" base_name" , out.base_name );
25692583
2570- auto & writer = boost::get<boost ::shared_ptr<ugrid_writer>>(out.writer );
2584+ auto & writer = boost::get<std ::shared_ptr<ugrid_writer>>(out.writer );
25712585 entry.put (" path" , writer->store_path ());
25722586
25732587 if (out.rotate_frequency )
@@ -2625,7 +2639,7 @@ void core::run()
26252639 {
26262640 std::string base_name = itr.fname + std::to_string (_global->posix_time_int ());
26272641 boost::filesystem::path p (base_name);
2628- auto & writer = boost::get<boost ::shared_ptr<vtk_writer>>(itr.writer );
2642+ auto & writer = boost::get<std ::shared_ptr<vtk_writer>>(itr.writer );
26292643 writer->set_write_ghost_neighbors (itr.write_ghost_neighbors );
26302644 writer->update_data (output);
26312645
@@ -2656,7 +2670,7 @@ void core::run()
26562670 // first, check if we need a new ugrid file
26572671 bool new_ugrid = itr.should_rotate (max_ts, current_ts, _global->_current_date );
26582672
2659- auto & writer = boost::get<boost ::shared_ptr<ugrid_writer>>(itr.writer );
2673+ auto & writer = boost::get<std ::shared_ptr<ugrid_writer>>(itr.writer );
26602674 if (new_ugrid)
26612675 {
26622676 auto rotated_path = [&]() {
@@ -2775,7 +2789,7 @@ void core::run()
27752789
27762790 if (itr.mesh_output_formats == output_info::mesh_outputs::ugrid)
27772791 {
2778- boost::get<boost ::shared_ptr<ugrid_writer>>(itr.writer )->close_ugrid ();
2792+ boost::get<std ::shared_ptr<ugrid_writer>>(itr.writer )->close_ugrid ();
27792793 }
27802794 }
27812795
0 commit comments