Skip to content

Commit

Permalink
Put the forcing shp/vtu into a separate directory. Ensure face-statio…
Browse files Browse the repository at this point in the history
…n relationship is built if we seek a nc on load. Ensure we compute the correct number of timesteps across a multipart nc
  • Loading branch information
Chrismarsh committed Jan 29, 2025
1 parent dd1e045 commit 053feb8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
19 changes: 13 additions & 6 deletions src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,9 +645,11 @@ void core::config_forcing(pt::ptree &value)
}


auto f = output_folder_path / std::format("stations_{}.vtp", _comm_world.rank());
_metdata->write_stations_to_ptv(f.string());
_metdata->write_stations_to_shp((output_folder_path / std::format("stations_{}.shp",_comm_world.rank())).string());
boost::filesystem::create_directories(output_folder_path / "forcing");

auto f = output_folder_path / "forcing" / std::format("stations_{}.", _comm_world.rank());
_metdata->write_stations_to_ptv(f.string() + "vtp");
_metdata->write_stations_to_shp(f.string() + "shp");

SPDLOG_DEBUG("Finished reading stations. Took {} s", c.toc<s>());

Expand Down Expand Up @@ -1507,9 +1509,6 @@ void core::init(int argc, char **argv)

// Now the forcing and mesh are loaded, assign each face the station lists
populate_face_station_lists();
// TODO: double check this but we now prune the station list on load to the mesh extent which is MPI aware
// so we should be fine to fully remove this
// populate_distributed_station_lists();

//load the parameters now that the station list has been pruned and we have a partitioned mesh
if( ispart)
Expand Down Expand Up @@ -2180,6 +2179,14 @@ void core::run()
// We can do this _once_ without incrementing the internal iterators
_metdata->next();

// even though we have already done this once in core::init, if the calling next() above resulted in a load
// of a new nc on the first time step, e.g., we had to load 2 netcdf to get to the first timestep
// we need to re build the face-station mapping as loading a new netcdf will invalidate all our stations
// TODO: this should probably be moved into metdata, and modules need to know about this to rebuild their
// interp structs
if(_metdata->is_multipart_nc() && _metdata->nc_just_loaded())
populate_face_station_lists();

SPDLOG_DEBUG("Starting model run");

c.tic();
Expand Down
3 changes: 2 additions & 1 deletion src/metdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ void metdata::load_from_netcdf(const std::string& path, const triangulation::bou
_file_end_time = _nc->get_end();

// we need to compute this from the globally known start / end times
_n_timesteps = (_end_time - _start_time).total_seconds() / _nc->get_dt().total_seconds();
// +1 to be inclusive of the start time
_n_timesteps = (_end_time - _start_time).total_seconds() / _nc->get_dt().total_seconds() +1 ;
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions src/modules/interp_met/t_monthly_lapse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ void t_monthly_lapse::init(mesh& domain)
for (size_t i = 0; i < domain->size_faces(); i++)
{

auto face = domain->face(i);
auto& d = face->make_module_data<data>(ID);
d.interp.init(global_param->interp_algorithm,face->stations().size() );
auto face = domain->face(i);
auto& d = face->make_module_data<data>(ID);
d.interp.init(global_param->interp_algorithm, face->stations().size() );

}

Expand Down

0 comments on commit 053feb8

Please sign in to comment.