diff --git a/src/core.cpp b/src/core.cpp index cd260acf..60b3478a 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -2425,7 +2425,7 @@ void core::run() else { // loading a new netcdf will invalidate all our stations, so we need to rebuild the list of stations - if(_metdata->is_multipart_nc()) + if(_metdata->is_multipart_nc() && _metdata->nc_just_loaded()) populate_face_station_lists(); } diff --git a/src/metdata.cpp b/src/metdata.cpp index 37612b63..9a379dbe 100644 --- a/src/metdata.cpp +++ b/src/metdata.cpp @@ -31,6 +31,7 @@ metdata::metdata(std::string mesh_proj4) _mesh_proj4 = mesh_proj4; is_first_timestep = true; _is_multipart_nc = false; + _just_loaded_nc = false; OGRSpatialReference srs; srs.importFromProj4(_mesh_proj4.c_str()); @@ -96,6 +97,7 @@ void metdata::load_from_netcdf(const std::string& path, const triangulation::bou SPDLOG_DEBUG("Found NetCDF file {}", path); _use_netcdf = true; + _just_loaded_nc = true; _nc = std::make_unique(); // only do this once, don't repeat if we have them cached @@ -690,9 +692,18 @@ bool metdata::next_ascii() return true; } + +bool metdata::nc_just_loaded() +{ + return _just_loaded_nc; +} + bool metdata::next_nc() { + // assume we won't have to load a netcdf + _just_loaded_nc = false; + //_current_ts is already ++ from the next() call if(!_is_multipart_nc && (_current_ts > _end_time)) { diff --git a/src/metdata.hpp b/src/metdata.hpp index ecbe7ad5..c4baeb35 100644 --- a/src/metdata.hpp +++ b/src/metdata.hpp @@ -166,6 +166,14 @@ class metdata std::string start_time_str(); std::string end_time_str(); + /** + * Returns true if a netcdf was just loaded. + * Calling next() without having to load a multipart will cause this to begin to return false + **/ + bool nc_just_loaded(); + + /// + /// @return bool is_multipart_nc(); /** @@ -265,6 +273,7 @@ class metdata // Mapped w/ stations ID -> metdata std::map> _ascii_stations; + // ----------------------------------- // This is a different approach than how stations used to work @@ -282,6 +291,7 @@ class metdata size_t _n_timesteps; bool _is_multipart_nc; + bool _just_loaded_nc; // if a nc file was just loaded // These two are the start and end time of the simulation. If we have loaded from a single file // these will be equal to file_*. However, if we are loading from a multi-part file then the file_*