Skip to content

Commit 053feb8

Browse files
committed
Put the forcing shp/vtu into a separate directory. Ensure face-station relationship is built if we seek a nc on load. Ensure we compute the correct number of timesteps across a multipart nc
1 parent dd1e045 commit 053feb8

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

src/core.cpp

+13-6
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,11 @@ void core::config_forcing(pt::ptree &value)
645645
}
646646

647647

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

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

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

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

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

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

21852192
c.tic();

src/metdata.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ void metdata::load_from_netcdf(const std::string& path, const triangulation::bou
212212
_file_end_time = _nc->get_end();
213213

214214
// we need to compute this from the globally known start / end times
215-
_n_timesteps = (_end_time - _start_time).total_seconds() / _nc->get_dt().total_seconds();
215+
// +1 to be inclusive of the start time
216+
_n_timesteps = (_end_time - _start_time).total_seconds() / _nc->get_dt().total_seconds() +1 ;
216217
}
217218
else
218219
{

src/modules/interp_met/t_monthly_lapse.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ void t_monthly_lapse::init(mesh& domain)
4646
for (size_t i = 0; i < domain->size_faces(); i++)
4747
{
4848

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

5353
}
5454

0 commit comments

Comments
 (0)