[270] | 1 | /* ************************************************************************** * |
---|
| 2 | * Copyright © IPSL/LSCE, XMLIOServer, Avril 2010 - Octobre 2011 * |
---|
| 3 | * ************************************************************************** */ |
---|
| 4 | |
---|
| 5 | #include <boost/multi_array.hpp> |
---|
| 6 | #include <boost/shared_ptr.hpp> |
---|
| 7 | |
---|
| 8 | #include "xmlioserver.hpp" |
---|
| 9 | |
---|
| 10 | #include "attribute_template_impl.hpp" |
---|
| 11 | #include "object_template_impl.hpp" |
---|
| 12 | #include "group_template_impl.hpp" |
---|
| 13 | |
---|
| 14 | #include "calendar_type.hpp" |
---|
| 15 | |
---|
| 16 | #include "icutil.hpp" |
---|
| 17 | |
---|
| 18 | extern "C" |
---|
| 19 | { |
---|
| 20 | // /////////////////////////////// Définitions ////////////////////////////// // |
---|
| 21 | |
---|
| 22 | void xios_set_timestep(double ts_year, double ts_month, double ts_day, |
---|
| 23 | double ts_hour, double ts_minute, double ts_second) |
---|
| 24 | { |
---|
| 25 | try |
---|
| 26 | { |
---|
| 27 | date::CDuration dur = {ts_year, ts_month, ts_day, ts_hour, ts_minute, ts_second}; |
---|
| 28 | boost::shared_ptr<xmlioserver::tree::CContext> context = |
---|
| 29 | xmlioserver::CObjectFactory::GetObject<xmlioserver::tree::CContext> |
---|
| 30 | (CObjectFactory::GetCurrentContextId()); |
---|
| 31 | boost::shared_ptr<xmlioserver::data::CDataTreatment> dtreat = context->getDataTreatment(); |
---|
[276] | 32 | if (dtreat.get() != 0) |
---|
| 33 | { |
---|
| 34 | dtreat->set_timestep(dur); |
---|
| 35 | } |
---|
| 36 | else |
---|
| 37 | { |
---|
| 38 | context->solveCalendar(); |
---|
| 39 | context->timestep.setValue(dur.toString()); |
---|
| 40 | context->getCalendar()->setTimeStep(dur); |
---|
| 41 | } |
---|
[270] | 42 | } |
---|
| 43 | catch (xmlioserver::CException & exc) |
---|
| 44 | { |
---|
| 45 | std::cerr << exc.getMessage() << std::endl; |
---|
| 46 | exit (EXIT_FAILURE); |
---|
| 47 | } |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | void xios_update_calendar(int step) |
---|
| 51 | { |
---|
| 52 | try |
---|
| 53 | { |
---|
| 54 | boost::shared_ptr<xmlioserver::tree::CContext> context = |
---|
| 55 | xmlioserver::CObjectFactory::GetObject<xmlioserver::tree::CContext> |
---|
| 56 | (CObjectFactory::GetCurrentContextId()); |
---|
| 57 | boost::shared_ptr<xmlioserver::data::CDataTreatment> dtreat = context->getDataTreatment(); |
---|
| 58 | dtreat->update_calendar(step); |
---|
| 59 | } |
---|
| 60 | catch (xmlioserver::CException & exc) |
---|
| 61 | { |
---|
| 62 | std::cerr << exc.getMessage() << std::endl; |
---|
| 63 | exit (EXIT_FAILURE); |
---|
| 64 | } |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | } // extern "C" |
---|