@sdeverywhere/cli 0.7.10 → 0.7.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +11 -11
- package/src/c/model.c +38 -2
- package/src/c/sde.h +3 -1
- package/LICENSE +0 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdeverywhere/cli",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.11",
|
|
4
4
|
"description": "Contains the `sde` command line interface for the SDEverywhere tool suite.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -10,9 +10,16 @@
|
|
|
10
10
|
"bin": {
|
|
11
11
|
"sde": "src/main.js"
|
|
12
12
|
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"lint": "eslint . --max-warnings 0",
|
|
15
|
+
"prettier:check": "prettier --check .",
|
|
16
|
+
"prettier:fix": "prettier --write .",
|
|
17
|
+
"precommit": "../../scripts/precommit",
|
|
18
|
+
"ci:build": "run-s lint prettier:check"
|
|
19
|
+
},
|
|
13
20
|
"dependencies": {
|
|
14
|
-
"@sdeverywhere/build": "^0.3.
|
|
15
|
-
"@sdeverywhere/compile": "^0.7.
|
|
21
|
+
"@sdeverywhere/build": "^0.3.2",
|
|
22
|
+
"@sdeverywhere/compile": "^0.7.7",
|
|
16
23
|
"bufx": "^1.0.5",
|
|
17
24
|
"byline": "^5.0.0",
|
|
18
25
|
"ramda": "^0.27.0",
|
|
@@ -29,12 +36,5 @@
|
|
|
29
36
|
},
|
|
30
37
|
"bugs": {
|
|
31
38
|
"url": "https://github.com/climateinteractive/SDEverywhere/issues"
|
|
32
|
-
},
|
|
33
|
-
"scripts": {
|
|
34
|
-
"lint": "eslint . --max-warnings 0",
|
|
35
|
-
"prettier:check": "prettier --check .",
|
|
36
|
-
"prettier:fix": "prettier --write .",
|
|
37
|
-
"precommit": "../../scripts/precommit",
|
|
38
|
-
"ci:build": "run-s lint prettier:check"
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
}
|
package/src/c/model.c
CHANGED
|
@@ -8,6 +8,14 @@
|
|
|
8
8
|
struct timespec startTime, finishTime;
|
|
9
9
|
#endif
|
|
10
10
|
|
|
11
|
+
// For each output variable specified in the indices buffer, there
|
|
12
|
+
// are 4 index values:
|
|
13
|
+
// varIndex
|
|
14
|
+
// subIndex0
|
|
15
|
+
// subIndex1
|
|
16
|
+
// subIndex2
|
|
17
|
+
#define INDICES_PER_OUTPUT 4
|
|
18
|
+
|
|
11
19
|
// The special _time variable is not included in .mdl files.
|
|
12
20
|
double _time;
|
|
13
21
|
|
|
@@ -17,6 +25,7 @@ size_t outputIndex = 0;
|
|
|
17
25
|
|
|
18
26
|
// Output data buffer used by `runModelWithBuffers`
|
|
19
27
|
double* outputBuffer = NULL;
|
|
28
|
+
int32_t* outputIndexBuffer = NULL;
|
|
20
29
|
size_t outputVarIndex = 0;
|
|
21
30
|
size_t numSavePoints = 0;
|
|
22
31
|
size_t savePointIndex = 0;
|
|
@@ -66,6 +75,13 @@ double getSaveper() {
|
|
|
66
75
|
return _saveper;
|
|
67
76
|
}
|
|
68
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Return the constant `maxOutputIndices` value.
|
|
80
|
+
*/
|
|
81
|
+
int getMaxOutputIndices() {
|
|
82
|
+
return maxOutputIndices;
|
|
83
|
+
}
|
|
84
|
+
|
|
69
85
|
char* run_model(const char* inputs) {
|
|
70
86
|
// run_model does everything necessary to run the model with the given inputs.
|
|
71
87
|
// It may be called multiple times. Call finish() after all runs are complete.
|
|
@@ -102,13 +118,15 @@ char* run_model(const char* inputs) {
|
|
|
102
118
|
* (where tN is the last time in the range), the second variable outputs will begin,
|
|
103
119
|
* and so on.
|
|
104
120
|
*/
|
|
105
|
-
void runModelWithBuffers(double* inputs, double* outputs) {
|
|
121
|
+
void runModelWithBuffers(double* inputs, double* outputs, int32_t* outputIndices) {
|
|
106
122
|
outputBuffer = outputs;
|
|
123
|
+
outputIndexBuffer = outputIndices;
|
|
107
124
|
initConstants();
|
|
108
125
|
setInputsFromBuffer(inputs);
|
|
109
126
|
initLevels();
|
|
110
127
|
run();
|
|
111
128
|
outputBuffer = NULL;
|
|
129
|
+
outputIndexBuffer = NULL;
|
|
112
130
|
}
|
|
113
131
|
|
|
114
132
|
void run() {
|
|
@@ -137,7 +155,25 @@ void run() {
|
|
|
137
155
|
numSavePoints = (size_t)(round((_final_time - _initial_time) / _saveper)) + 1;
|
|
138
156
|
}
|
|
139
157
|
outputVarIndex = 0;
|
|
140
|
-
|
|
158
|
+
if (outputIndexBuffer != NULL) {
|
|
159
|
+
// Store the outputs as specified in the current output index buffer
|
|
160
|
+
for (size_t i = 0; i < maxOutputIndices; i++) {
|
|
161
|
+
size_t indexBufferOffset = i * INDICES_PER_OUTPUT;
|
|
162
|
+
size_t varIndex = (size_t)outputIndexBuffer[indexBufferOffset];
|
|
163
|
+
if (varIndex > 0) {
|
|
164
|
+
size_t subIndex0 = (size_t)outputIndexBuffer[indexBufferOffset + 1];
|
|
165
|
+
size_t subIndex1 = (size_t)outputIndexBuffer[indexBufferOffset + 2];
|
|
166
|
+
size_t subIndex2 = (size_t)outputIndexBuffer[indexBufferOffset + 3];
|
|
167
|
+
storeOutput(varIndex, subIndex0, subIndex1, subIndex2);
|
|
168
|
+
} else {
|
|
169
|
+
// Stop when we reach the first zero index
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
// Store the normal outputs
|
|
175
|
+
storeOutputData();
|
|
176
|
+
}
|
|
141
177
|
savePointIndex++;
|
|
142
178
|
}
|
|
143
179
|
if (step == lastStep) break;
|
package/src/c/sde.h
CHANGED
|
@@ -42,6 +42,7 @@ EXTERN double _epsilon;
|
|
|
42
42
|
|
|
43
43
|
// Internal variables
|
|
44
44
|
EXTERN const int numOutputs;
|
|
45
|
+
EXTERN const int maxOutputIndices;
|
|
45
46
|
|
|
46
47
|
// Standard simulation control parameters
|
|
47
48
|
EXTERN double _time;
|
|
@@ -55,7 +56,7 @@ double getInitialTime(void);
|
|
|
55
56
|
double getFinalTime(void);
|
|
56
57
|
double getSaveper(void);
|
|
57
58
|
char* run_model(const char* inputs);
|
|
58
|
-
void runModelWithBuffers(double* inputs, double* outputs);
|
|
59
|
+
void runModelWithBuffers(double* inputs, double* outputs, int32_t* outputIndices);
|
|
59
60
|
void run(void);
|
|
60
61
|
void startOutput(void);
|
|
61
62
|
void outputVar(double value);
|
|
@@ -69,6 +70,7 @@ void setInputsFromBuffer(double *inputData);
|
|
|
69
70
|
void evalAux(void);
|
|
70
71
|
void evalLevels(void);
|
|
71
72
|
void storeOutputData(void);
|
|
73
|
+
void storeOutput(size_t varIndex, size_t subIndex0, size_t subIndex1, size_t subIndex2);
|
|
72
74
|
const char* getHeader(void);
|
|
73
75
|
|
|
74
76
|
#ifdef __cplusplus
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2016-2022 Todd Fincannon and Climate Interactive / New Venture Fund
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|