Skip to content

Commit c3d322c

Browse files
authored
rename Gimmick to JSONResource and fake_spec_file to spec_file_pypartmc (#347)
1 parent b6e7d5b commit c3d322c

16 files changed

+85
-85
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ add_definitions("-DSUNDIALS_INT64_T=1")
4949
### sources ########################################################################################
5050

5151
set(PyPartMC_sources
52-
pypartmc.cpp gimmicks.cpp fake_spec_file.cpp sys.cpp
52+
pypartmc.cpp json_resource.cpp spec_file_pypartmc.cpp sys.cpp
5353
run_part.F90 run_part_opt.F90 util.F90 aero_data.F90 aero_state.F90 env_state.F90 gas_data.F90
5454
gas_state.F90 scenario.F90 condense.F90 aero_particle.F90 bin_grid.F90
5555
camp_core.F90 photolysis.F90 aero_mode.F90 aero_dist.F90 bin_grid.cpp condense.cpp run_part.cpp
@@ -179,7 +179,7 @@ set(partmclib_SOURCES condense_solver.c aero_state.F90 integer_varray.F90 intege
179179
photolysis.F90
180180
)
181181
add_prefix(gitmodules/partmc/src/ partmclib_SOURCES)
182-
list(APPEND partmclib_SOURCES src/fake_spec_file.F90 src/sys.F90)
182+
list(APPEND partmclib_SOURCES src/spec_file_pypartmc.F90 src/sys.F90)
183183

184184
set(klu_SOURCES
185185
KLU/Source/klu_analyze.c

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ PyPartMC is used within the [test workflow of the PySDM project](https://github.
232232
- PartMC and selected parts of SUNDIALS are statically linked (and compiled in during `pip install` or `python -m build`)
233233
- C (SUNDIALS, netCDF), C++ (pybind11, ...) and Fortran (PartMC, CAMP, netCDF-fortran) dependencies are linked through [git submodules](https://github.com/open-atmos/PyPartMC/blob/main/.gitmodules)
234234
- MOSAIC dependency is optionally linked through setting the environmental variable `MOSAIC_HOME`
235-
- a [drop-in replacement of the PartMC spec file routines](https://github.com/open-atmos/PyPartMC/blob/main/src/fake_spec_file.F90) is used for i/o from/to JSON
235+
- a [drop-in replacement of the PartMC spec file routines](https://github.com/open-atmos/PyPartMC/blob/main/src/spec_file_pypartmc.F90) is used for i/o from/to JSON
236236

237237
## Implementation architecture
238238

@@ -255,10 +255,10 @@ flowchart TD
255255
PyPartMC --> ppmc_cpp["PyPartMC-C++"]
256256
ppmc_cpp --> pybind11_json
257257
pybind11_json ---> nlohmann::JSON
258-
fake_spec_file_cpp --> nlohmann::JSON
258+
spec_file_pypartmc_cpp --> nlohmann::JSON
259259
end
260260
subgraph C ["C"]
261-
fake_spec_file_c --> fake_spec_file_cpp["SpecFile-C++"]
261+
spec_file_pypartmc_c --> spec_file_pypartmc_cpp["SpecFile-C++"]
262262
ppmc_cpp --> ppmc_c["PyPartMC-C"]
263263
netCDF-C
264264
SUNDIALS
@@ -273,8 +273,8 @@ flowchart TD
273273
PartMC --> SUNDIALS
274274
PartMC ---> camp_f
275275
camp_f["CAMP"] --> camp_c
276-
PartMC ----> fake_spec_file_f[SpecFile-F]
277-
fake_spec_file_f --> fake_spec_file_c["SpecFile-C"]
276+
PartMC ----> spec_file_pypartmc_f[SpecFile-F]
277+
spec_file_pypartmc_f --> spec_file_pypartmc_c["SpecFile-C"]
278278
end
279279
280280
style PartMC fill:#7ae7ff,stroke-width:2px,color:#2B2B2B

src/aero_data.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#pragma once
88

99
#include "pmc_resource.hpp"
10-
#include "gimmicks.hpp"
10+
#include "json_resource.hpp"
1111
#include "pybind11/stl.h"
1212
#include "aero_data_parameters.hpp"
1313

@@ -41,10 +41,10 @@ struct AeroData {
4141
AeroData(const nlohmann::json &json) :
4242
ptr(f_aero_data_ctor, f_aero_data_dtor)
4343
{
44-
if (!InputGimmick::unique_keys(json))
44+
if (!InputJSONResource::unique_keys(json))
4545
throw std::runtime_error("Species names must be unique");
4646

47-
GimmickGuard<InputGimmick> guard(json);
47+
JSONResourceGuard<InputJSONResource> guard(json);
4848
f_aero_data_from_json(this->ptr.f_arg());
4949
}
5050

src/aero_dist.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ struct AeroDist {
4949
ptr(f_aero_dist_ctor, f_aero_dist_dtor),
5050
aero_data(aero_data)
5151
{
52-
if (!InputGimmick::unique_keys(json))
52+
if (!InputJSONResource::unique_keys(json))
5353
throw std::runtime_error("Mode names must be unique");
5454
for (const auto &mode : json)
5555
AeroMode::check_mode_json(mode.begin().value());
5656

57-
GimmickGuard<InputGimmick> guard(json, "", "mode_name", 1);
57+
JSONResourceGuard<InputJSONResource> guard(json, "", "mode_name", 1);
5858
f_aero_dist_from_json(ptr.f_arg_non_const(), aero_data->ptr.f_arg_non_const());
5959
}
6060

src/aero_mode.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ struct AeroMode {
131131
if (json.size() != 1 || !json.is_object() || !json.begin().value().is_object())
132132
throw std::runtime_error("Single-element dict expected with mode name as key and mode params dict as value");
133133
check_mode_json(json.begin().value());
134-
GimmickGuard<InputGimmick> guard(json, "", "mode_name");
134+
JSONResourceGuard<InputJSONResource> guard(json, "", "mode_name");
135135
f_aero_mode_from_json(ptr.f_arg_non_const(), aero_data.ptr.f_arg_non_const());
136136
}
137137

@@ -143,7 +143,7 @@ struct AeroMode {
143143

144144
if (!mass_frac.is_array()) // TODO #320: check if all are single-element dicts
145145
throw std::runtime_error("mass_frac value must be a list of single-element dicts");
146-
if (!InputGimmick::unique_keys(mass_frac))
146+
if (!InputJSONResource::unique_keys(mass_frac))
147147
throw std::runtime_error("mass_frac keys must be unique");
148148
}
149149

src/camp_core.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#pragma once
88

9-
#include "gimmicks.hpp"
9+
#include "json_resource.hpp"
1010
#include "pmc_resource.hpp"
1111

1212
extern "C" void f_camp_core_ctor(void *ptr) noexcept;

src/env_state.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#pragma once
88

9-
#include "gimmicks.hpp"
9+
#include "json_resource.hpp"
1010
#include "pmc_resource.hpp"
1111

1212
extern "C" void f_env_state_ctor(void *ptr) noexcept;
@@ -30,7 +30,7 @@ struct EnvState {
3030
EnvState(const nlohmann::json &json) :
3131
ptr(f_env_state_ctor, f_env_state_dtor)
3232
{
33-
GimmickGuard<InputGimmick> guard(json);
33+
JSONResourceGuard<InputJSONResource> guard(json);
3434
f_env_state_from_json(this->ptr.f_arg());
3535
}
3636

src/gas_data.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#pragma once
88

9-
#include "gimmicks.hpp" // TODO #119: rename to something like json_resource.hpp?
9+
#include "json_resource.hpp"
1010
#include "pmc_resource.hpp"
1111
#include "gas_data_parameters.hpp"
1212
#include "pybind11/stl.h"
@@ -37,7 +37,7 @@ struct GasData {
3737
nlohmann::json::array()
3838
}}));
3939

40-
GimmickGuard<InputGimmick> guard(json_array);
40+
JSONResourceGuard<InputJSONResource> guard(json_array);
4141
f_gas_data_from_json(this->ptr.f_arg());
4242
}
4343

src/gas_state.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <string>
99
#include "pybind11_json/pybind11_json.hpp"
1010
#include "nlohmann/json.hpp"
11-
#include "gimmicks.hpp"
11+
#include "json_resource.hpp"
1212
#include "pmc_resource.hpp"
1313
#include "gas_data.hpp"
1414

@@ -59,10 +59,10 @@ struct GasState {
5959
}
6060

6161
static auto __str__(const GasState &self) {
62-
GimmickGuard<OutputGimmick> guard;
62+
JSONResourceGuard<OutputJSONResource> guard;
6363

6464
f_gas_state_to_json(self.ptr.f_arg());
65-
auto str = gimmick_ptr()->str();
65+
auto str = json_resource_ptr()->str();
6666

6767
return str;
6868
}
@@ -120,7 +120,7 @@ struct GasState {
120120
if (json.size() == 0)
121121
throw std::runtime_error("Non-empty sequence of mixing ratios expected");
122122

123-
GimmickGuard<InputGimmick> guard(json);
123+
JSONResourceGuard<InputJSONResource> guard(json);
124124
f_gas_state_from_json(
125125
self.ptr.f_arg(),
126126
self.gas_data->ptr.f_arg()

src/gimmicks.cpp renamed to src/json_resource.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Authors: https://github.com/open-atmos/PyPartMC/graphs/contributors #
55
##################################################################################################*/
66

7-
#include "gimmicks.hpp"
7+
#include "json_resource.hpp"
88

99
template <class X>
1010
X& singleton()
@@ -13,7 +13,7 @@ X& singleton()
1313
return x;
1414
}
1515

16-
std::unique_ptr<Gimmick> &gimmick_ptr() {
17-
return singleton<std::unique_ptr<Gimmick>>();
16+
std::unique_ptr<JSONResource> &json_resource_ptr() {
17+
return singleton<std::unique_ptr<JSONResource>>();
1818
}
1919

0 commit comments

Comments
 (0)