@@ -55,12 +55,17 @@ ModelState ParaGridIO::getModelState(const std::string& filePath, ModelMetadata&
55
55
state.merge (ModelState { { { fieldId, field } }, {} });
56
56
}
57
57
// Assume that all fields in the supplied ModelState are necessary, and so read them from file.
58
+ std::set<std::string> restartFieldIds = xiosHandler.configGetInputRestartFieldNames ();
58
59
for (auto & entry : state.data ) {
59
60
const std::string fieldId = entry.first ;
60
61
if (!xiosHandler.getFieldReadAccess (fieldId)) {
61
62
throw std::runtime_error (" ParaGridIO::getModelState: field " + fieldId
62
63
+ " is not configured for reading, but is being read from file." );
63
64
};
65
+ if (restartFieldIds.count (fieldId) == 0 ) {
66
+ throw std::runtime_error (
67
+ " ParaGridIO::getModelState: field " + fieldId + " is not configured as a restart." );
68
+ }
64
69
xiosHandler.read (fieldId, entry.second );
65
70
}
66
71
return state;
@@ -86,10 +91,14 @@ ModelState ParaGridIO::readForcingTimeStatic(
86
91
const bool readAccess = true ;
87
92
std::set<std::string> forcingFieldIds = xiosHandler.configGetForcingFieldNames ();
88
93
for (const std::string& fieldId : forcings) {
89
- if (forcingFieldIds. count (fieldId) == 0 || !xiosHandler.getFieldReadAccess (fieldId)) {
94
+ if (!xiosHandler.getFieldReadAccess (fieldId)) {
90
95
throw std::runtime_error (" ParaGridIO::readForcingTimeStatic: forcing " + fieldId
91
96
+ " is not configured for reading, but is being read from file." );
92
97
}
98
+ if (forcingFieldIds.count (fieldId) == 0 ) {
99
+ throw std::runtime_error (" ParaGridIO::readForcingTimeStatic: field " + fieldId
100
+ + " is not configured as a forcing." );
101
+ }
93
102
// ASSUME all forcings are HFields: finite volume fields on the same
94
103
// grid as ice thickness
95
104
HField field (ModelArray::Type::H);
@@ -112,15 +121,18 @@ void ParaGridIO::dumpModelState(
112
121
{
113
122
Xios& xiosHandler = Xios::getInstance ();
114
123
115
- // Assume that all fields in the supplied ModelState are necessary, and so write them to
116
- // file.
117
- // TODO: Check they are indeed restarts
124
+ // Assume that all fields in the supplied ModelState are necessary, and so write them to file.
125
+ std::set<std::string> restartFieldIds = xiosHandler.configGetOutputRestartFieldNames ();
118
126
for (auto entry : state.data ) {
119
127
const std::string fieldId = entry.first ;
120
128
if (xiosHandler.getFieldReadAccess (fieldId)) {
121
129
throw std::runtime_error (" ParaGridIO::dumpModelState: field " + fieldId
122
130
+ " is not configured for writing, but is being written to file." );
123
131
};
132
+ if (restartFieldIds.count (fieldId) == 0 ) {
133
+ throw std::runtime_error (" ParaGridIO::dumpModelState: field " + fieldId
134
+ + " is not configured as a restart." );
135
+ }
124
136
xiosHandler.write (fieldId, entry.second );
125
137
}
126
138
}
@@ -130,19 +142,20 @@ void ParaGridIO::writeDiagnosticTime(
130
142
{
131
143
Xios& xiosHandler = Xios::getInstance ();
132
144
133
- // Assume that all fields in the supplied ModelState are necessary, and so write them to
134
- // file.
135
- // TODO: Check they are indeed diagnostics
145
+ // Assume that all fields in the supplied ModelState are necessary, and so write them to file.
146
+ std::set<std::string> diagnosticFieldIds = xiosHandler.configGetDiagnosticFieldNames ();
136
147
for (auto entry : state.data ) {
137
148
const std::string fieldId = entry.first ;
138
149
if (xiosHandler.getFieldReadAccess (fieldId)) {
139
150
throw std::runtime_error (" ParaGridIO::writeDiagnosticTime: field " + fieldId
140
151
+ " is not configured for writing, but is being written to file." );
141
152
};
153
+ if (diagnosticFieldIds.count (fieldId) == 0 ) {
154
+ throw std::runtime_error (" ParaGridIO::writeDiagnosticTime: field " + fieldId
155
+ + " is not configured as a diagnostic." );
156
+ }
142
157
xiosHandler.write (fieldId, entry.second );
143
158
}
144
- // TODO: Create a special timeless set of dimensions for the landmask - use 'once' operation
145
- // TODO: Put the time axis variable
146
159
}
147
160
148
161
} /* namespace Nextsim */
0 commit comments