1 | #include "xios.hpp" |
---|
2 | |
---|
3 | #include "icdate.hpp" |
---|
4 | #include "exception.hpp" |
---|
5 | #include "timer.hpp" |
---|
6 | #include "context.hpp" |
---|
7 | #include "context_client.hpp" |
---|
8 | #include "workflow_graph.hpp" |
---|
9 | #include "graphviz.hpp" |
---|
10 | |
---|
11 | |
---|
12 | extern "C" |
---|
13 | { |
---|
14 | void cxios_update_calendar(int step) |
---|
15 | TRY |
---|
16 | { |
---|
17 | CTimer::get("XIOS").resume(); |
---|
18 | xios::CContext* context = CContext::getCurrent(); |
---|
19 | if (!context->hasServer && !context->client->isAttachedModeEnabled()) |
---|
20 | context->checkBuffersAndListen(); |
---|
21 | context->updateCalendar(step); |
---|
22 | context->sendUpdateCalendar(step); |
---|
23 | CTimer::get("XIOS").suspend(); |
---|
24 | |
---|
25 | // int my_rank; |
---|
26 | // MPI_Comm_rank(CXios::globalComm, &my_rank); |
---|
27 | // if(my_rank==0) |
---|
28 | // { |
---|
29 | // // CGraphviz::showStaticWorkflowGraph(); |
---|
30 | // CGraphviz::buildStaticWorkflowGraph(); |
---|
31 | // StdString commande_string="dot -Tpdf graph.dot -o graph"+to_string(step-1)+".pdf"; |
---|
32 | // const char* command=commande_string.c_str(); |
---|
33 | // system(command); |
---|
34 | // } |
---|
35 | |
---|
36 | |
---|
37 | } |
---|
38 | CATCH_DUMP_STACK |
---|
39 | |
---|
40 | void cxios_get_current_date(cxios_date* current_date_c) |
---|
41 | TRY |
---|
42 | { |
---|
43 | CTimer::get("XIOS").resume(); |
---|
44 | const xios::CContext* context = CContext::getCurrent(); |
---|
45 | const std::shared_ptr<xios::CCalendar> cal = context->getCalendar(); |
---|
46 | if (!cal) |
---|
47 | ERROR("void cxios_get_current_date(cxios_date* current_date_c)", |
---|
48 | << "Impossible to get the current date: no calendar was defined."); |
---|
49 | const CDate& currentDate = cal->getCurrentDate(); |
---|
50 | current_date_c->year = currentDate.getYear(); |
---|
51 | current_date_c->month = currentDate.getMonth(); |
---|
52 | current_date_c->day = currentDate.getDay(); |
---|
53 | current_date_c->hour = currentDate.getHour(); |
---|
54 | current_date_c->minute = currentDate.getMinute(); |
---|
55 | current_date_c->second = currentDate.getSecond(); |
---|
56 | CTimer::get("XIOS").suspend(); |
---|
57 | } |
---|
58 | CATCH_DUMP_STACK |
---|
59 | |
---|
60 | int cxios_get_year_length_in_seconds(int year) |
---|
61 | TRY |
---|
62 | { |
---|
63 | CTimer::get("XIOS").resume(); |
---|
64 | const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar(); |
---|
65 | if (!cal) |
---|
66 | ERROR("int cxios_get_year_length_in_seconds(int year)", |
---|
67 | << "Impossible to get the year length: no calendar was defined."); |
---|
68 | int length = cal->getYearTotalLength(CDate(*cal, year, 01, 01)); |
---|
69 | CTimer::get("XIOS").suspend(); |
---|
70 | |
---|
71 | return length; |
---|
72 | } |
---|
73 | CATCH_DUMP_STACK |
---|
74 | |
---|
75 | int cxios_get_day_length_in_seconds() |
---|
76 | TRY |
---|
77 | { |
---|
78 | CTimer::get("XIOS").resume(); |
---|
79 | const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar(); |
---|
80 | if (!cal) |
---|
81 | ERROR("int cxios_get_day_length_in_seconds()", |
---|
82 | << "Impossible to get the day length: no calendar was defined."); |
---|
83 | int length = cal->getDayLengthInSeconds(); |
---|
84 | CTimer::get("XIOS").suspend(); |
---|
85 | |
---|
86 | return length; |
---|
87 | } |
---|
88 | CATCH_DUMP_STACK |
---|
89 | } |
---|