netxsimdg
Loading...
Searching...
No Matches
ParaGridIO.hpp
Go to the documentation of this file.
1
8#ifndef PARAGRIDIO_HPP
9#define PARAGRIDIO_HPP
10
12
13#include <map>
14#include <ncFile.h>
15#include <string>
16
17namespace Nextsim {
18
25public:
27 : IParaGridIO(grid)
28 {
29 if (dimCompMap.size() == 0)
30 makeDimCompMap();
31 }
32 virtual ~ParaGridIO();
33
38 ModelState getModelState(const std::string& filePath) override;
39
49 void dumpModelState(
50 const ModelState& state, const ModelMetadata& meta, const std::string& filePath) override;
51
59 ModelState readForcingTime(const std::set<std::string>& forcings, const TimePoint& time,
60 const std::string& filePath) override
61 {
62 return readForcingTimeStatic(forcings, time, filePath);
63 }
64
73 const ModelState& state, const ModelMetadata& meta, const std::string& filePath) override;
74
81 static void close(const std::string& filePath);
82
83 static ModelState readForcingTimeStatic(
84 const std::set<std::string>& forcings, const TimePoint& time, const std::string& filePath);
85
86private:
87 ParaGridIO() = delete;
88 ParaGridIO(const ParaGridIO& other) = delete;
89 ParaGridIO& operator=(const ParaGridIO& other) = delete;
90
91 static const std::map<std::string, ModelArray::Type> dimensionKeys;
92
93 static const std::map<ModelArray::Dimension, bool> isDG;
94 static std::map<ModelArray::Dimension, ModelArray::Type> dimCompMap;
95
96 // Ensures that static variables are created in the correct order.
97 static void makeDimCompMap();
98
99 // Closes all still-open NetCDF files
100 static void closeAllFiles();
101
102 // Existing or open files are a property of the computer outside the individual
103 // class instance, so they are static.
104 static std::map<std::string, netCDF::NcFile> openFiles;
105 static std::map<std::string, size_t> timeIndexByFile;
106};
107
108} /* namespace Nextsim */
109
110#endif /* PARAGRIDIO_HPP */
void writeDiagnosticTime(const ModelState &state, const ModelMetadata &meta, const std::string &filePath) override
Writes diagnostic data to a file.
void dumpModelState(const ModelState &state, const ModelMetadata &meta, const std::string &filePath) override
Writes the ModelState to a given file location from the provided model data and metadata.
ModelState readForcingTime(const std::set< std::string > &forcings, const TimePoint &time, const std::string &filePath) override
Reads forcings from a ParameticGrid flavoured file.
ModelState getModelState(const std::string &filePath) override
static void close(const std::string &filePath)
A class to hold the grid data for parameterised rectangular grids.