netxsimdg
Loading...
Searching...
No Matches
IDiagnosticOutput.hpp
Go to the documentation of this file.
1
8#ifndef IDIAGNOSTICOUTPUT_HPP
9#define IDIAGNOSTICOUTPUT_HPP
10
14
15#include <string>
16
17namespace Nextsim {
19public:
21 : protectedArrayNames(generateProtectedNames())
22 , sharedArrayNames(generateSharedNames())
23 , protectedExternalNames(generateProtectedExternal())
24 , sharedExternalNames(generateSharedExternal())
25 {
26 }
27 virtual ~IDiagnosticOutput() = default;
28
34 virtual void setFilenamePrefix(const std::string& filePrefix) = 0;
35
42 virtual void outputState(const ModelMetadata& meta) = 0;
43
44 // Define some of the ModelComponent class functions
45 // No data to be set
46 void setData(const ModelState::DataMap& state) { }
47protected:
48 const std::map<std::string, ProtectedArray> protectedArrayNames;
49 const std::map<std::string, SharedArray> sharedArrayNames;
50 const std::map<std::string, std::string> protectedExternalNames;
51 const std::map<std::string, std::string> sharedExternalNames;
52private:
53 /*
54 * Using a pair of .ipp files to allow definitions of the externally visible
55 * names of the fields to defined outside of an actual source file, even if the
56 * definition file has a slightly odd format.
57 */
58 static inline std::map<std::string, std::string> generateProtectedExternal()
59 {
60 return {
62 };
63 }
64 static inline std::map<std::string, std::string> generateSharedExternal()
65 {
66 return {
68 };
69 }
70
71 // clang-format off
72 // Using a macro protects against typos
73 #define SHAREDEL(NAME) { #NAME, SharedArray::NAME }
74 // Mapping from canonical SharedArray name to the SharedArray enum value
75 static inline std::map<std::string, ModelComponent::SharedArray> generateSharedNames()
76 {
77 return {
78 SHAREDEL(H_ICE), // Updated ice thickness, ice average, m
79 SHAREDEL(C_ICE), // Updated ice concentration
80 SHAREDEL(H_SNOW), // Updated snow depth, ice average, m
81 SHAREDEL(T_ICE), // Updated ice temperatures, ˚C
82 SHAREDEL(Q_IA), // Ice to atmosphere heat flux W m⁻²
83 SHAREDEL(Q_IC), // Ice conduction heat flux W m⁻²
84 SHAREDEL(Q_IO), // Ice to ocean heat flux W m⁻²
85 SHAREDEL(Q_OW), // Open water heat flux W m⁻²
86 SHAREDEL(DQIA_DT), // Derivative of Qᵢₐ w.r.t. ice surface temperature W m⁻² K⁻¹
87 SHAREDEL(HSNOW_MELT), // Thickness of snow that melted, m
88 SHAREDEL(SUBLIM), // Upward sublimation rate kg m⁻² s⁻¹
89 SHAREDEL(DELTA_HICE), // Change in sea ice thickness, m
90 SHAREDEL(DELTA_CICE), // Change in sea ice concentration
91 SHAREDEL(NEW_ICE), // Volume of new ice formed [m]
92 };
93 }
94 #undef SHAREDEL
95
96 // Using a macro protects against typos
97 #define PROTEL(NAME) { #NAME, ProtectedArray::NAME }
98 // Mapping from canonical ProtectedArray name to the ProtectedArray enum value
99 static inline std::map<std::string, ModelComponent::ProtectedArray> generateProtectedNames()
100 {
101 return {
102 PROTEL(H_ICE), // Ice thickness, cell average, m
103 PROTEL(C_ICE), // Ice concentration
104 PROTEL(H_SNOW), // Snow depth, cell average, m
105 PROTEL(T_ICE), // Ice temperature, ˚C
106 PROTEL(T_AIR), // Air temperature, ˚C
107 PROTEL(DEW_2M), // Dew point at 2 m, ˚C
108 PROTEL(P_AIR), // sea level air pressure, Pa
109 PROTEL(MIXRAT), // water vapour mass mixing ratio
110 PROTEL(SW_IN), // incoming shortwave flux, W m⁻²
111 PROTEL(LW_IN), // incoming longwave flux, W m⁻²
112 PROTEL(MLD), // mixed layer depth, m
113 PROTEL(SNOW), // snow fall, kg m⁻² s⁻¹
114 PROTEL(SSS), // sea surface salinity, PSU
115 PROTEL(SST), // sea surface temperature ˚C
116 PROTEL(EXT_SSS), // exterior sea surface salinity, PSU
117 PROTEL(EXT_SST), // exterior sea surface temperature ˚C
118 PROTEL(EVAP_MINUS_PRECIP), // E-P atmospheric freshwater flux, kg s⁻¹ m⁻²
119 PROTEL(ML_BULK_CP), // Mixed layer bulk heat capacity J K⁻¹ m⁻²
120 PROTEL(TF), // Ocean freezing temperature, ˚C
121 PROTEL(WIND_SPEED), // Wind speed, m s⁻¹
122 PROTEL(HTRUE_ICE), // Ice thickness, ice average, m
123 PROTEL(HTRUE_SNOW), // Snow thickness, ice average, m
124 PROTEL(OCEAN_U), // x(east)-ward ocean current, m s⁻¹
125 PROTEL(OCEAN_V), // y(north)-ward ocean current, m s⁻¹
126 PROTEL(SLAB_SSS), // slab ocean surface salinity, PSU
127 PROTEL(SLAB_SST), // slab ocean surface temperature ˚C
128 PROTEL(SLAB_QDW), // Slab ocean temperature nudging heat flux, W m⁻²
129 PROTEL(SLAB_FDW), // Slab ocean salinity nudging water flux, kg s⁻¹ m⁻²
130 };
131 }
132 #undef PROTEL
133 // clang-format on
134
135};
136}
137#endif /* IDIAGNOSTICOUTPUT_HPP */
virtual void setFilenamePrefix(const std::string &filePrefix)=0
Sets the output file name.
void setData(const ModelState::DataMap &state)
Set the initial data of the component from the passed ModelState.
virtual void outputState(const ModelMetadata &meta)=0
Outputs the passed ModelState.