19 #include <sys/types.h> 47 void write_log(
int NUM,
double t,
const double* y_host, FILE* pFile)
49 fwrite(&t,
sizeof(
double), 1, pFile);
51 for (
int j = 0; j < NUM; j++)
54 buffer[0] = y_host[j];
55 for (
int i = 1; i <
NSP; ++i)
57 buffer[i] = y_host[NUM * i + j];
60 #if NN == NSP + 1 //pyjac 64 fwrite(buffer,
sizeof(
double),
NN, pFile);
87 int main (
int argc,
char *argv[])
92 feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
106 omp_set_num_threads (max_threads);
109 num_threads = max_threads;
111 if (sscanf(argv[1],
"%i", &num_threads) !=1 || (num_threads <= 0) || (num_threads > max_threads)) {
112 printf(
"Error: Number of threads not in correct range\n");
113 printf(
"Provide number between 1 and %i\n", max_threads);
116 omp_set_num_threads (num_threads);
120 int problemsize = NUM;
121 if (sscanf(argv[2],
"%i", &problemsize) !=1 || (problemsize <= 0))
123 printf(
"Error: Problem size not in correct range\n");
124 printf(
"Provide number greater than 0\n");
133 #pragma omp parallel reduction(+:num_threads) 139 printf (
"# ODEs: %d\n", NUM);
140 printf (
"# threads: %d\n", num_threads);
149 const char* filename =
"shuffled_data.bin";
150 #elif !defined(SAME_IC) 151 const char* filename =
"ign_data.bin";
165 bool ign_flag =
false;
168 double T0 = y_host[0];
175 int len = strlen(f_name);
176 char out_name[len + 13];
178 if (stat(
"./log/", &info) != 0)
180 printf(
"Expecting 'log' subdirectory in current working directory. Please run" 181 " mkdir log (or the equivalent) and run again.\n");
184 sprintf(out_name,
"log/%s-log.bin", f_name);
185 pFile = fopen(out_name,
"wb");
206 intDriver(NUM, t, t_next, var_host, y_host);
211 printf(
"%.15le\t%.15le\n", t, y_host[0]);
215 if ((y_host[0] < 0.0) || (y_host[0] > 10000.0))
217 printf(
"Error, out of bounds.\n");
218 printf(
"Time: %e, ind %d val %e\n", t, 0, y_host[0]);
223 #if !defined(LOG_END_ONLY) 230 if ((y_host[0] >= (T0 + 400.0)) && !(ign_flag)) {
249 printf (
"Time: %.15e sec\n", runtime);
250 runtime = runtime / ((double)(numSteps));
251 printf (
"Time per step: %e (s)\t%.15e (s/thread)\n", runtime, runtime / NUM);
253 printf (
"Ig. Delay (s): %e\n", t_ign);
255 printf(
"TFinal: %e\n", y_host[0]);
void intDriver(const int NUM, const double t, const double t_end, const double *pr_global, double *y_global)
Integration driver for the CPU integrators.
Timer interface for Linux.
void write_log(int NUM, double t, const double *y_host, FILE *pFile)
Writes state vectors to file.
int main(int argc, char *argv[])
void apply_reverse_mask(double *y_host)
Not needed for van der Pol.
void cleanup_solver(int num_threads)
Cleans up the created solvers.
definition of the generic initial condition reader
void initialize_solver(int num_threads)
Initializes the solver.
void set_same_initial_conditions(int NUM, double **y_host, double **var_host)
Set same ICs for all problems.
Contains skeleton of all methods that need to be defined on a per solver basis.
void solver_log()
Executes solver specific logging tasks.
void init_solver_log()
Initializes solver specific items for logging.
const char * solver_name()
Returns a descriptive solver name.
void read_initial_conditions(const char *filename, int NUM, double **y_host, double **variable_host)
Reads initial conditions for IVPs from binary file.