source: XIOS/trunk/src/interface/c/icfield.cpp @ 1119

Last change on this file since 1119 was 1119, checked in by rlacroix, 7 years ago

Add the ability to check if an output field is active at the current timestep.

The "xios_field_is_active" function can now take an optional logical argument that can be used to enable this new behavior.

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
  • Property svn:eol-style set to native
File size: 3.7 KB
Line 
1/* ************************************************************************** *
2 *      Copyright © IPSL/LSCE, xios, Avril 2010 - Octobre 2011         *
3 * ************************************************************************** */
4
5#include <boost/multi_array.hpp>
6#include <boost/shared_ptr.hpp>
7
8#include "xios.hpp"
9
10#include "attribute_template.hpp"
11#include "object_template.hpp"
12#include "group_template.hpp"
13
14#include "icutil.hpp"
15#include "timer.hpp"
16#include "field.hpp"
17
18extern "C"
19{
20// /////////////////////////////// Définitions ////////////////////////////// //
21
22   // ----------------------- Redéfinition de types ----------------------------
23   
24   typedef xios::CField      * XFieldPtr;
25   typedef xios::CFieldGroup * XFieldGroupPtr;
26   
27   typedef xios::CDomain     * XDomainPtr;
28   typedef xios::CAxis       * XAxisPtr;
29   typedef xios::CScalar     * XScalarPtr;
30
31// --------------------------------------------------------------------------   
32// ------------------------ Création des handle -----------------------------
33// --------------------------------------------------------------------------   
34   
35   void cxios_field_handle_create (XFieldPtr * _ret, const char * _id, int _id_len)
36   {
37      std::string id; 
38      if (!cstr2string(_id, _id_len, id)) return;
39      CTimer::get("XIOS").resume() ;
40      *_ret = CField::get(id);
41      CTimer::get("XIOS").suspend() ;
42   }
43   
44   void cxios_fieldgroup_handle_create (XFieldGroupPtr * _ret, const char * _id, int _id_len)
45   {
46      std::string id; 
47      if (!cstr2string(_id, _id_len, id)) return;
48      CTimer::get("XIOS").resume() ;
49      *_ret = CFieldGroup::get(id);
50      CTimer::get("XIOS").suspend() ;
51   }
52
53
54   // -------------------- Vérification des identifiants -----------------------
55
56   void cxios_field_valid_id (bool * _ret, const char * _id, int _id_len)
57   {
58      std::string id;
59      if (!cstr2string(_id, _id_len, id)) return;
60      CTimer::get("XIOS").resume() ;
61      *_ret = CField::has(id);
62      CTimer::get("XIOS").suspend() ;
63   }
64
65   void cxios_fieldgroup_valid_id (bool * _ret, const char * _id, int _id_len)
66   {
67      std::string id;
68      if (!cstr2string(_id, _id_len, id)) return;
69      CTimer::get("XIOS").resume() ;
70      *_ret = CFieldGroup::has(id);
71      CTimer::get("XIOS").suspend() ;
72   }
73
74// -----------------------------------------------------------------------------------------------------   
75// ------------------------- Other functions
76// -----------------------------------------------------------------------------------------------------   
77
78  void cxios_field_is_active (XFieldPtr field_hdl, bool at_current_timestep, bool* ret)
79  {
80    CTimer::get("XIOS").resume() ;
81    *ret = field_hdl->isActive(at_current_timestep);
82    CTimer::get("XIOS").suspend() ;
83  }
84
85// -----------------------------------------------------------------------------------------------------
86// ------------------------- Retrieving information of grid associated to field
87// -----------------------------------------------------------------------------------------------------
88  void cxios_field_get_domain_handle(XDomainPtr * domain_hdl_ret, XFieldPtr field_hdl, int domainIndex)
89  {
90     CTimer::get("XIOS").resume() ;
91     *domain_hdl_ret = field_hdl->grid->getDomain(domainIndex);
92     CTimer::get("XIOS").suspend();
93  }
94
95  void cxios_field_get_axis_handle(XAxisPtr * axis_hdl_ret, XFieldPtr field_hdl, int axisIndex)
96  {
97     CTimer::get("XIOS").resume() ;
98     *axis_hdl_ret = field_hdl->grid->getAxis(axisIndex);
99     CTimer::get("XIOS").suspend();
100  }
101
102  void cxios_field_get_scalar_handle(XScalarPtr * scalar_hdl_ret, XFieldPtr field_hdl, int scalarIndex)
103  {
104     CTimer::get("XIOS").resume() ;
105     *scalar_hdl_ret = field_hdl->grid->getScalar(scalarIndex);
106     CTimer::get("XIOS").suspend();
107  }
108} // extern "C"
Note: See TracBrowser for help on using the repository browser.