Canoe
Comprehensive Atmosphere N' Ocean Engine
read_thermo_property.cpp
Go to the documentation of this file.
1 // C/C++
2 #include <cstring>
3 #include <string>
4 
5 // athena
6 #include <athena/parameter_input.hpp>
7 
8 // application
9 #include <application/exceptions.hpp>
10 
11 // canoe
12 #include <configure.hpp>
13 
14 void read_thermo_property(Real var[], char const name[], int len, Real v0,
15  ParameterInput* pin) {
16  char buf[80], cstr[1024], *p;
17 
18  var[0] = v0;
19  for (int n = 1; n <= NVAPOR; ++n) {
20  snprintf(buf, sizeof(buf), "%s%d", name, n);
21  std::string str = pin->GetString("thermodynamics", buf);
22  std::snprintf(cstr, sizeof(cstr), "%s", str.c_str());
23  p = std::strtok(cstr, " ,");
24  int m = 0;
25  while ((p != NULL) && (m++ < len)) {
26  var[n + (m - 1) * NVAPOR] = std::stod(p);
27  p = std::strtok(NULL, " ,");
28  }
29  if (m != len) {
30  throw ValueError("read_thermo_property", name, len, m);
31  }
32  }
33 }
void read_thermo_property(Real var[], char const name[], int len, Real v0, ParameterInput *pin)