-
Notifications
You must be signed in to change notification settings - Fork 3
/
cmain.C
65 lines (47 loc) · 2.01 KB
/
cmain.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include <limits>
#define FORTRAN_CALL(name) name##_
#define FORTRAN_MOD_CALL(module, name) __##module##_MOD_##name
#define FORTRAN_DREF_VAR(module, name) *__##module##_MOD_##name
using Real=double;
extern "C" void loadvar ();
extern "C" void get1dvectorr (int *, int *, int *,
int *, Real **, Real **, int *);
extern "C" void string_test(const char **, int *);
extern "C" void bool_test(bool *, bool *);
extern "C" int FORTRAN_DREF_VAR(fortranvar, globalint)(...);
int main()
{
loadvar ();
std::cout << "Hello\nGlobal Int: " << FORTRAN_DREF_VAR(fortranvar, globalint) << std::endl;
std::cout << "********************* Numbers Test ******************\n";
int field_num = 1;
int component_number = 1; //getParam<int>("component_number");
int face = 2; //getParam<int>("face");
int buffer_lengths = 0;
Real * elevations = nullptr;
Real * values = nullptr;
int error_code = std::numeric_limits<int>::max();
std::cout << "Buffer Lengths: " << buffer_lengths << std::endl;
std::cout << "Elevation: " << elevations << std::endl;
std::cout << "Values: " << values << std::endl;
std::cout << "Error Code: " << error_code << '\n' << std::endl;
get1dvectorr (&field_num, &component_number, &face, &buffer_lengths, &elevations, &values, &error_code);
std::cout << "\nBuffer Lengths: " << buffer_lengths << std::endl;
std::cout << "Elevation: " << elevations << std::endl;
std::cout << "Values: " << values << std::endl;
std::cout << "Error Code: " << error_code << std::endl;
for (unsigned int i = 0; i < buffer_lengths; ++i)
std::cout << values[i] << '\t';
std::cout << std::endl;
std::cout << "********************* String Test ******************\n";
std::string foo("foobar more");
auto c_str = foo.c_str();
int c_len = foo.size() + 1;
string_test(&c_str, &c_len);
std::cout << "********************* Bool Test ******************\n";
bool true_value = true;
bool false_value = false;
bool_test(&true_value, &false_value);
return 0;
}