Skip to content

Commit a5affba

Browse files
committed
Clang format.
1 parent 56acf1e commit a5affba

File tree

2 files changed

+58
-19
lines changed

2 files changed

+58
-19
lines changed

src/mam4xx/mam4.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
#include <mam4xx/ndrop.hpp>
3737
#include <mam4xx/nucleate_ice.hpp>
3838
#include <mam4xx/nucleation.hpp>
39+
#include <mam4xx/physical_limits.hpp>
3940
#include <mam4xx/rename.hpp>
4041
#include <mam4xx/spitfire_transport.hpp>
4142
#include <mam4xx/tropopause.hpp>
4243
#include <mam4xx/water_uptake.hpp>
4344
#include <mam4xx/wet_dep.hpp>
44-
#include <mam4xx/physical_limits.hpp>
4545

4646
namespace mam4 {
4747

src/mam4xx/physical_limits.hpp

Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,73 @@
55

66
#ifndef PHYSICAL_LIMITS_HPP
77
#define PHYSICAL_LIMITS_HPP
8-
#include <utility>
9-
#include <string>
108
#include <map>
9+
#include <string>
10+
#include <utility>
1111

1212
namespace mam4 {
1313

14+
#if 0
15+
// If a device callable version of physical_min and physical_max is needed along
16+
// with the CPU only version, somthing like this would work. Strings do not do
17+
// well on device but enums are fast.
18+
19+
enum FieldNameIndex { T_mid, qv , qc , qt , nc , nr , ni , nmr , mmr, NUMFIELD };
20+
struct min_max {const Real min; const Real max;};
21+
22+
KOKKOS_INLINE_FUNCTION constexpr min_max physical_min_max(const FieldNameIndex ind) {
23+
const min_max field_min_max[NUMFIELD] = {
24+
{100, 500}, // T_mid
25+
{1e-13, 0.2}, // qv
26+
{0, 0.1}, // qc
27+
{0, 0.1}, // qt
28+
{0, 0.1e11}, // nc
29+
{0, 0.1e10}, // nr
30+
{0, 0.1e10}, // ni
31+
{100, 0.1e13}, // nmr
32+
{100, 0.1e-5} // mmr
33+
};
34+
return field_min_max[ind];
35+
}
36+
37+
KOKKOS_INLINE_FUNCTION constexpr Real physical_min(const FieldNameIndex ind) {
38+
return physical_min_max(ind).min;
39+
}
40+
41+
KOKKOS_INLINE_FUNCTION constexpr Real physical_max(const FieldNameIndex ind) {
42+
return physical_min_max(ind).max;
43+
}
44+
1445
inline const std::pair<Real,Real>& physical_min_max(const std::string &field_name) {
1546
static const std::map<std::string, std::pair<Real,Real>>
1647
limits = {
17-
{"T_min", {100, 500} },
18-
{"qv", {1e-13, 0.2} },
19-
{"qc", {0, 0.1} },
20-
{"qt", {0, 0.1} },
21-
{"nc", {0, 0.1e11} },
22-
{"nr", {0, 0.1e10} },
23-
{"ni", {0, 0.1e10} },
24-
{"nmr", {0, 0.1e13} },
25-
{"mmr", {0, 0.1e-5} }
48+
{"T_mid", {physical_min(T_mid), physical_max(T_mid)} },
49+
{"qv", {physical_min(qv), physical_max(qv)} },
50+
{"qc", {physical_min(qc), physical_max(qc)} },
51+
{"qt", {physical_min(qt), physical_max(qt)} },
52+
{"nc", {physical_min(nc), physical_max(nc)} },
53+
{"nr", {physical_min(nr), physical_max(nr)} },
54+
{"ni", {physical_min(ni), physical_max(ni)} },
55+
{"nmr", {physical_min(nmr), physical_max(nmr)} },
56+
{"mmr", {physical_min(mmr), physical_max(mmr)} }
2657
};
2758
return limits.at(field_name);
2859
}
29-
30-
inline Real physical_min(const std::string &field_name) {
31-
return physical_min_max(field_name).first;
32-
}
33-
inline Real physical_max(const std::string &field_name) {
34-
return physical_min_max(field_name).second;
35-
}
60+
#endif
61+
inline const std::pair<Real, Real> &
62+
physical_min_max(const std::string &field_name) {
63+
static const std::map<std::string, std::pair<Real, Real>> limits = {
64+
{"T_mid", {100, 500}}, {"qv", {1e-13, 0.2}}, {"qc", {0, 0.1}},
65+
{"qt", {0, 0.1}}, {"nc", {0, 0.1e11}}, {"nr", {0, 0.1e10}},
66+
{"ni", {0, 0.1e10}}, {"nmr", {0, 0.1e13}}, {"mmr", {0, 0.1e-5}}};
67+
return limits.at(field_name);
68+
}
69+
inline Real physical_min(const std::string &field_name) {
70+
return physical_min_max(field_name).first;
71+
}
72+
inline Real physical_max(const std::string &field_name) {
73+
return physical_min_max(field_name).second;
74+
}
3675
} // namespace mam4
3776

3877
#endif

0 commit comments

Comments
 (0)