libode
Easy to compile, fast ODE integrators as C++ classes
Loading...
Searching...
No Matches
ode_io.h
Go to the documentation of this file.
1#ifndef ODE_IO_H_
2#define ODE_IO_H_
3
5
6#include <cstdio>
7#include <cstdlib>
8#include <string>
9#include <iostream>
10#include <sstream>
11
12namespace ode {
13
15
18void ode_check_write (const char *fn);
19
21
26template<class T>
27void ode_write (char const *fn, T *a, unsigned long n) {
28 //check that the file can be written
30 //open the file
31 FILE *ofile = fopen(fn, "wb");
32 //write values
33 fwrite(a, sizeof(T), n, ofile);
34 //close the file
35 fclose(ofile);
36}
37
39
42void ode_print_exit (const char *msg);
43
45std::string ode_int_to_string (long i);
46
47} // namespace ode
48
49#endif
void ode_check_write(const char *fn)
check if a file can be written (opened in write mode)
Definition ode_io.cc:7
void ode_print_exit(const char *msg)
print a message and exit with failure
Definition ode_io.cc:17
void ode_write(char const *fn, T *a, unsigned long n)
write an array to a binary file
Definition ode_io.h:27
std::string ode_int_to_string(long i)
converts an integer into a string
Definition ode_io.cc:25