Index: XMLIO_V2/dev/common/src/xmlio/attribute_map.cpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/attribute_map.cpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/attribute_map.cpp	(revision 278)
@@ -96,4 +96,5 @@
                                                    it != attributes.end();
                                                    it ++)
+         {
             if ((*it).first.compare(StdString("id")) != 0 &&
                 (*it).first.compare(StdString("src"))!= 0)
@@ -102,4 +103,5 @@
                CAttributeMap::operator[]((*it).first)->fromString((*it).second);
             }
+         }
       }
       
Index: XMLIO_V2/dev/common/src/xmlio/client.cpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/client.cpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/client.cpp	(revision 278)
@@ -16,5 +16,5 @@
    CClient::~CClient(void)
    { 
-      this->finalize();
+      //this->finalize();
    } 
    
@@ -27,5 +27,5 @@
    boost::shared_ptr<CClient> CClient::CreateClient(MPIComm comm_client_server)
    {
-      if (CClient::Client.get() != NULL)
+      if (CClient::Client.get() == NULL)
          CClient::Client = boost::shared_ptr<CClient>(new CClient(comm_client_server));
       return (CClient::GetClient());
Index: XMLIO_V2/dev/common/src/xmlio/client.hpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/client.hpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/client.hpp	(revision 278)
@@ -24,5 +24,5 @@
          ~CClient(void);  
          
-      protected : 
+      public : 
       
          /// Accesseur ///
Index: XMLIO_V2/dev/common/src/xmlio/config/context_attribute.conf
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/config/context_attribute.conf	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/config/context_attribute.conf	(revision 278)
@@ -1,5 +1,5 @@
 DECLARE_ATTRIBUTE(StdString, calendar_type)
 DECLARE_ATTRIBUTE(StdString, start_date)
-
+DECLARE_ATTRIBUTE(StdString, timestep)
 DECLARE_ATTRIBUTE(StdString, output_dir)
 
Index: XMLIO_V2/dev/common/src/xmlio/data_treatment.cpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/data_treatment.cpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/data_treatment.cpp	(revision 278)
@@ -50,4 +50,5 @@
          // Mise Ã  jour cÃŽtÃ© client
          this->currentContext->getCalendar()->setTimeStep(duration);
+         this->currentContext->timestep.setValue(duration.toString());
          std::cout << "timestep :" << duration << std::endl;
          if (CXIOSManager::GetStatus() == CXIOSManager::LOC_CLIENT)
@@ -79,5 +80,7 @@
             {
                if (field->updateDataServer(currDate, data))
+               {
                   file->getDataOutput()->writeFieldData(field);
+               }
                return;
             }
Index: XMLIO_V2/dev/common/src/xmlio/data_treatment.hpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/data_treatment.hpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/data_treatment.hpp	(revision 278)
@@ -47,5 +47,5 @@
 
             /// CrÃ©ation des sorties ///
-            template <class T> void createDataOutput(void);
+            template <class T> void createDataOutput(comm::MPIComm comm_server = CXIOSManager::Comm_Server);
 
             /// Destructeur ///
@@ -72,5 +72,5 @@
 
       template <class T>
-         void CDataTreatment::createDataOutput(void)
+         void CDataTreatment::createDataOutput(comm::MPIComm comm_server )
       {
          std::vector<boost::shared_ptr<CFile> >::const_iterator
@@ -79,4 +79,5 @@
          for (; it != end; it++)
          {
+            CXIOSManager::Comm_Server = comm_server;
             boost::shared_ptr<CFile> file = *it;
             StdString filename = (!file->name.isEmpty())
@@ -89,7 +90,7 @@
             if (!file->name_suffix.isEmpty())
                 oss << file->name_suffix.getValue();
-            if (comm::CMPIManager::GetCommSize() > 1)
-	        oss << "_node" << comm::CMPIManager::GetCommRank();
-	    oss << ".nc";
+            if (comm::CMPIManager::GetCommSize(comm_server) > 1)
+	             oss << "." << comm::CMPIManager::GetCommRank(comm_server);
+	         oss << ".nc";
             boost::shared_ptr<io::CDataOutput> dout(new T(oss.str(), false));
             file->initializeDataOutput(dout);
Index: XMLIO_V2/dev/common/src/xmlio/exception.cpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/exception.cpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/exception.cpp	(revision 278)
@@ -23,5 +23,13 @@
 
    CException::~CException(void)
-   { if (desc_rethrow) throw (*this); }
+   { 
+      if (desc_rethrow)
+#ifdef __XIOS_NOABORT
+        throw (*this); 
+#else
+      std::cerr << this->getMessage() << std::endl;
+      abort();
+#endif
+   }
 
    //---------------------------------------------------------------
Index: XMLIO_V2/dev/common/src/xmlio/fortran/icdata.cpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/fortran/icdata.cpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/fortran/icdata.cpp	(revision 278)
@@ -39,5 +39,4 @@
          CTreeManager::PrintTreeToFile(oss.str());
          oss.str("");
-
          boost::shared_ptr<CDataTreatment> dt(new CDataTreatment (context));
          context->setDataTreatment(dt);
@@ -67,8 +66,10 @@
                CMPIManager::Wait(request);  // Pas encore en mode RPC
             }
+            CXIOSManager::RunClient(false, CMPIManager::GetCommWorld());
+            CClient::CreateClient(comm_client_server);
          }
          else
          {
-            dt->createDataOutput<CNc4DataOutput>();
+            dt->createDataOutput<CNc4DataOutput>(CMPIManager::GetCommWorld());
          }
       }
Index: XMLIO_V2/dev/common/src/xmlio/fortran/icdate.cpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/fortran/icdate.cpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/fortran/icdate.cpp	(revision 278)
@@ -30,5 +30,14 @@
             (CObjectFactory::GetCurrentContextId());
          boost::shared_ptr<xmlioserver::data::CDataTreatment> dtreat = context->getDataTreatment();
-         dtreat->set_timestep(dur);
+         if (dtreat.get() != 0)
+         {
+            dtreat->set_timestep(dur);     
+         }
+         else
+         {
+            context->solveCalendar();
+            context->timestep.setValue(dur.toString());
+            context->getCalendar()->setTimeStep(dur);
+         }       
       }
       catch (xmlioserver::CException & exc)
Index: XMLIO_V2/dev/common/src/xmlio/group_factory.hpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/group_factory.hpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/group_factory.hpp	(revision 278)
@@ -10,4 +10,5 @@
 #include "object_factory.hpp"
 #include "group_template.hpp"
+#include "xml_parser.hpp"
 
 namespace xmlioserver
Index: XMLIO_V2/dev/common/src/xmlio/group_parser.hpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/group_parser.hpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/group_parser.hpp	(revision 278)
@@ -13,9 +13,19 @@
 
       StdString name = node.getElementName();
+      xml::THashAttributes attributes = node.getAttributes();
       if (withAttr)
+      {
          CGroupTemplate<U, V, W>::SuperClass::parse(node);
+         if (attributes.end() != attributes.find("src"))
+         {
+            StdIFStream ifs ( attributes["src"].c_str() , StdIFStream::in );
+            if (!ifs.good())
+               ERROR("CGroupTemplate<U, V, W>::parse(xml::CXMLNode & node, bool withAttr)",
+                     << "[ filename = " << attributes["src"] << " ] Bad xml stream !");
+            xml::CXMLParser::ParseInclude(ifs, *this);
+         }
+      }
 
       // PARSING POUR GESTION DES ENFANTS
-      xml::THashAttributes attributes;
       boost::shared_ptr<V> group_ptr = (this->hasId())
          ? CObjectFactory::GetObject<V>(this->getId())
@@ -61,5 +71,5 @@
                   << "\' ne peut contenir qu'un objet de type \'" << V::GetName()
                   << "\' ou de type \'" << U::GetName()
-                  << "\' !");
+                  << "\' (reÃ§u : " << name << ") !");
 
          } while (node.goToNextElement());
Index: XMLIO_V2/dev/common/src/xmlio/main_server.cpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/main_server.cpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/main_server.cpp	(revision 278)
@@ -7,5 +7,12 @@
 #include "client.hpp"
 #include "server.hpp"
-
+extern "C"
+{
+   void xios_dtreatment_start(tree::CContext * context_hdl, int filetype, int comm_client_server, int comm_server);
+   void xios_set_timestep(double ts_year, double ts_month,  double ts_day,
+                          double ts_hour, double ts_minute, double ts_second);
+   void xios_write_data_k83(const char * fieldid, int fieldid_size, double * data_k8, int data_Xsize, int data_Ysize, int data_Zsize);
+   void xios_update_calendar(int step);
+}
 // Point d'entrÃ©e du programme principal
 
@@ -15,15 +22,8 @@
    {
       MPIComm comm_client, comm_client_server, comm_server;
-      comm::CMPIManager::Initialise(&argc, &argv); // < seulement en mode connectÃ©
-      
-      CTreeManager::ParseFile  ("test/iodef_simple_test.xml");
-      CTreeManager::PrintTreeToFile("wk/def/test.xml");
-     
-      comm::CMPIManager::Finalize();               // < seulement en mode connectÃ©
-
-      //CXIOSManager::Initialise (CXIOSManager::CLIENT_SERVER, &argc, &argv);
-      //CMPIManager::DispatchClient(true, comm_client, comm_client_server,  comm_server);
-      //CXIOSManager::RunServer("Nemo", comm_client_server, comm_server);
-      //CXIOSManager::Finalize ();
+      CXIOSManager::Initialise (CXIOSManager::CLIENT_SERVER, &argc, &argv);
+      CMPIManager::DispatchClient(true, comm_client, comm_client_server,  comm_server);
+      CXIOSManager::RunServer("Nemo", comm_client_server, comm_server);
+      CXIOSManager::Finalize ();         
    }
    catch (CException & exc)
Index: XMLIO_V2/dev/common/src/xmlio/manager/xios_manager.cpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/manager/xios_manager.cpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/manager/xios_manager.cpp	(revision 278)
@@ -27,4 +27,5 @@
       {
          if (CXIOSManager::Type != CLIENT)
+
          {
             // Finalisation de la biliothÃšque MPI si nÃ©cessaire
@@ -53,4 +54,7 @@
       {
          using namespace comm;
+         CXIOSManager::Comm_Client_Server = comm_client_server;
+         CXIOSManager::Comm_Server        = comm_server;
+         CXIOSManager::Status             = LOC_SERVER;
          
          // Reconstruction de l'arborescence d'objet Ã  l'aide des donnÃ©es envoyÃ©es par chacun des
@@ -67,5 +71,4 @@
          StdString main_data_tree = clientBuffer[0]->getString(0);        
          tree::CTreeManager::FromBinary(main_data_tree);
-         std::cout << "main_data_tree" << main_data_tree.size() << std::endl;
          
          // Obtention des sous-domaines clients.
@@ -156,4 +159,6 @@
          using namespace comm;
          typedef std::pair<StdString, XIOSClient> StdPairStrClient;
+         CXIOSManager::Comm_Client_Server = comm_client_server;
+         CXIOSManager::Comm_Server        = comm_client_server;
          
          CXIOSManager::ShowInformation_CS(comm_client_server);
@@ -244,5 +249,6 @@
          if (launch)
          {
-            CXIOSManager::Status  = LOC_CLIENT_SERVER;         
+            CXIOSManager::Status       = LOC_CLIENT_SERVER;    
+            CXIOSManager::Comm_Server  = comm_client;    
             (CXIOSManager::Clients.begin()->second.entry)
                (comm_client, comm_client, comm_client);
Index: XMLIO_V2/dev/common/src/xmlio/manager/xios_manager.hpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/manager/xios_manager.hpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/manager/xios_manager.hpp	(revision 278)
@@ -55,5 +55,5 @@
          static StdString  GetClientName(void);
          
-      protected :
+      public :
          
          static StdSize GetNbClient(void);
@@ -63,5 +63,5 @@
          static StdSize GetNbLocServer(const StdString & clientName = CXIOSManager::ClientName);
          
-      private :
+      public :
       
          /// Information ///
Index: XMLIO_V2/dev/common/src/xmlio/node/context.cpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/node/context.cpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/node/context.cpp	(revision 278)
@@ -8,4 +8,5 @@
 
 #include "calendar_type.hpp"
+#include "duration.hpp"
 
 #include "data_treatment.hpp"
@@ -82,10 +83,13 @@
                << "Impossible de dÃ©finir un calendrier (un attribut est manquant).");
 
-#define DECLARE_CALENDAR(MType  , mtype)                        \
-   if (calendar_type.getValue().compare(#mtype) == 0)           \
-   {                                                            \
-      this->calendar =  boost::shared_ptr<date::CCalendar>      \
-         (new date::C##MType##Calendar(start_date.getValue())); \
-      return;                                                   \
+#define DECLARE_CALENDAR(MType  , mtype)                            \
+   if (calendar_type.getValue().compare(#mtype) == 0)               \
+   {                                                                \
+      this->calendar =  boost::shared_ptr<date::CCalendar>          \
+         (new date::C##MType##Calendar(start_date.getValue()));     \
+      if (!this->timestep.isEmpty())                                \
+       this->calendar->setTimeStep                                  \
+          (date::CDuration::FromString(this->timestep.getValue())); \
+      return;                                                       \
    }
 #include "calendar_type.conf"
@@ -103,5 +107,14 @@
 
       // PARSING POUR GESTION DES ENFANTS
-      xml::THashAttributes attributes;
+      xml::THashAttributes attributes = node.getAttributes();
+
+      if (attributes.end() != attributes.find("src"))
+      {
+         StdIFStream ifs ( attributes["src"].c_str() , StdIFStream::in );
+         if (!ifs.good())
+            ERROR("CContext::parse(xml::CXMLNode & node)",
+                  << "[ filename = " << attributes["src"] << " ] Bad xml stream !");
+         xml::CXMLParser::ParseInclude(ifs, *this);
+      }
 
       if (node.getElementName().compare(CContext::GetName()))
Index: XMLIO_V2/dev/common/src/xmlio/node/domain.cpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/node/domain.cpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/node/domain.cpp	(revision 278)
@@ -20,5 +20,5 @@
       , isChecked(false), local_mask(new CArray<int, 2>(boost::extents[0][0])), relFiles()
       , ibegin_sub(), iend_sub(), jbegin_sub(), jend_sub()
-      , ibegin_zoom_sub(), jbegin_zoom_sub()
+      , ibegin_zoom_sub(), jbegin_zoom_sub(), ni_zoom_sub(), nj_zoom_sub()
       , lonvalue_sub(), latvalue_sub()
    { /* Ne rien faire de plus */ }
@@ -28,5 +28,5 @@
       , isChecked(false), local_mask(new CArray<int, 2>(boost::extents[0][0])), relFiles()
       , ibegin_sub(), iend_sub(), jbegin_sub(), jend_sub()
-      , ibegin_zoom_sub(), jbegin_zoom_sub()
+      , ibegin_zoom_sub(), jbegin_zoom_sub(),ni_zoom_sub(), nj_zoom_sub()
       , lonvalue_sub(), latvalue_sub()
    { /* Ne rien faire de plus */ }
@@ -100,4 +100,6 @@
          this->ibegin_zoom_sub.push_back(this->zoom_ibegin_loc.getValue());
          this->jbegin_zoom_sub.push_back(this->zoom_jbegin_loc.getValue());
+         this->ni_zoom_sub.push_back(this->zoom_ni_loc.getValue());
+         this->nj_zoom_sub.push_back(this->zoom_nj_loc.getValue());
       
          this->latvalue_sub.push_back(this->latvalue.getValue());
@@ -151,5 +153,4 @@
           (nj_glo.isEmpty() || nj_glo.getValue() <= 0 ))
       {
-         abort();
          ERROR("CDomain::checkAttributes(void)",
                << "[ Id = " << this->getId() << " ] "
@@ -454,6 +455,8 @@
             for (int j = 0; j < zoom_nj_client; j++)
             {
-               (*lonvalue_temp)[i + j * zoom_ni_client] = (*lonvalue_)[(i + zoom_ibegin_client -1)+(j + zoom_jbegin_client -1)*ni.getValue()];              
-               (*latvalue_temp)[i + j * zoom_ni_client] = (*latvalue_)[(i + zoom_ibegin_client -1)+(j + zoom_jbegin_client -1)*ni.getValue()];
+               (*lonvalue_temp)[i + j * zoom_ni_client] =
+               (*lonvalue_)[(i + zoom_ibegin_client -1)+(j + zoom_jbegin_client -1)*ni.getValue()];              
+               (*latvalue_temp)[i + j * zoom_ni_client] =
+               (*latvalue_)[(i + zoom_ibegin_client -1)+(j + zoom_jbegin_client -1)*ni.getValue()];
             }
          }
@@ -488,8 +491,10 @@
       ARRAY_CREATE(latvalue_temp, double, 1, [0]);
       
-      const int ibegin_serv  = ibegin.getValue(),
-                jbegin_serv  = jbegin.getValue(),
-                zoom_ni_serv = zoom_ni_loc.getValue(),
-                zoom_nj_serv = zoom_nj_loc.getValue();
+      const int ibegin_serv     = ibegin.getValue(),
+                jbegin_serv     = jbegin.getValue(),
+                zoom_ni_serv    = zoom_ni_loc.getValue(),
+                zoom_nj_serv    = zoom_nj_loc.getValue(),
+                ibegin_zoom_srv = zoom_ibegin_loc.getValue(),
+                jbegin_zoom_srv = zoom_jbegin_loc.getValue();
                       
       /*std::cout << "Rang du serveur :" << comm::CMPIManager::GetCommRank()   << std::endl
@@ -498,16 +503,9 @@
                 << "Zoom_loc begin : " << zoom_ibegin_loc << ", " << zoom_jbegin_loc <<  std::endl
                 << "Zoom_loc size : "  << zoom_ni_loc << ", " << zoom_nj_loc <<  std::endl;*/
-      
-      
-      ARRAY(double, 1) lonvalue_ = this->lonvalue.getValue(),
-                       latvalue_ = this->latvalue.getValue();
                        
       if (this->data_dim.getValue() == 2)
       {
-         StdSize dm = zoom_ni_serv * zoom_nj_serv;
-         StdSize dn = this->ni.getValue() * this->nj.getValue();
-         
-         lonvalue_->resize(boost::extents[dn]);
-         latvalue_->resize(boost::extents[dn]);
+         StdSize dm = zoom_ni_serv * zoom_nj_serv;      
+         
          lonvalue_temp->resize(boost::extents[dm]);
          latvalue_temp->resize(boost::extents[dm]);
@@ -515,16 +513,20 @@
          for (StdSize k = 0; k < lonvalue_sub.size(); k++)
          {
-            int l = 0;
             ARRAY(double, 1) lonvalue_loc = this->lonvalue_sub[k],
                              latvalue_loc = this->latvalue_sub[k];
-            const int ibegin_loc = ibegin_sub[k], iend_loc = iend_sub[k],
-                      jbegin_loc = jbegin_sub[k], jend_loc = jend_sub[k];
+            const int zoom_ibegin_cl = ibegin_zoom_sub[k], zoom_ni_cl = ni_zoom_sub[k],
+                      zoom_jbegin_cl = jbegin_zoom_sub[k], zoom_nj_cl = nj_zoom_sub[k],
+                      ni_cl = iend_sub[k] - ibegin_sub[k] + 1;
                       
-            for (int i = ibegin_loc - ibegin_serv; i < (iend_loc - ibegin_serv + 1); i++)
+            for (int i = 0; i < zoom_ni_cl; i++)
             {
-               for (int j = jbegin_loc - jbegin_serv; j < (jend_loc - jbegin_serv + 1); j++)
+               for (int j = 0; j < zoom_nj_cl; j++)
                {
-                  (*lonvalue_)[i + j * this->ni.getValue()] = (*lonvalue_loc)[l];      // erreur        
-                  (*latvalue_)[i + j * this->ni.getValue()] = (*latvalue_loc)[l++];    // erreur
+                  int ii = i /*- (ibegin_serv - 1)*/ + (zoom_ibegin_cl - 1) - (ibegin_zoom_srv - 1);
+                  int jj = j /*- (jbegin_serv - 1)*/ + (zoom_jbegin_cl - 1) - (jbegin_zoom_srv - 1);
+                  (*lonvalue_temp)[ii + jj * zoom_ni_serv] =
+                  (*lonvalue_loc)[i + j * zoom_ni_cl];
+                  (*latvalue_temp)[ii + jj * zoom_ni_serv] = 
+                  (*latvalue_loc)[i + j * zoom_ni_cl];
                }
             }
@@ -535,6 +537,4 @@
       else
       {
-         lonvalue_->resize(boost::extents[this->ni.getValue()]);
-         latvalue_->resize(boost::extents[this->nj.getValue()]);
          lonvalue_temp->resize(boost::extents[zoom_ni_serv]);
          latvalue_temp->resize(boost::extents[zoom_nj_serv]);
@@ -542,15 +542,16 @@
          for (StdSize k = 0; k < lonvalue_sub.size(); k++)
          {
-            int l = 0;
             ARRAY(double, 1) lonvalue_loc = this->lonvalue_sub[k],
                              latvalue_loc = this->latvalue_sub[k];
-            const int ibegin_loc = ibegin_sub[k], iend_loc = iend_sub[k],
-                      jbegin_loc = jbegin_sub[k], jend_loc = jend_sub[k];
+            const int zoom_ibegin_cl = ibegin_zoom_sub[k], zoom_ni_cl = ni_zoom_sub[k],
+                      zoom_jbegin_cl = jbegin_zoom_sub[k], zoom_nj_cl = nj_zoom_sub[k];
                       
-            for (int i = ibegin_loc - ibegin_serv; i < (iend_loc - ibegin_loc + 1); i++)
-               (*lonvalue_)[i] = (*lonvalue_loc)[l++];
+            for (int i = 0; i < zoom_ni_cl; i++)
+               (*lonvalue_temp)[i /*- (ibegin_serv - 1)*/ + (zoom_ibegin_cl - 1) - (ibegin_zoom_srv - 1)] =
+               (*lonvalue_loc)[i];
                
-            for (int j = jbegin_loc - jbegin_serv; j < (jend_loc - jbegin_loc + 1); j++)
-               (*latvalue_)[j] = (*latvalue_loc)[l++];
+            for (int j = 0; j < zoom_nj_cl; j++)
+               (*latvalue_temp)[j /*- (jbegin_serv - 1)*/ + (zoom_jbegin_cl - 1) - (jbegin_zoom_srv - 1)] =
+               (*latvalue_loc)[j];
          }       
          this->lonvalue.setValue(lonvalue_temp);
Index: XMLIO_V2/dev/common/src/xmlio/node/domain.hpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/node/domain.hpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/node/domain.hpp	(revision 278)
@@ -113,5 +113,5 @@
 
          std::vector<int> ibegin_sub, iend_sub, jbegin_sub, jend_sub;
-         std::vector<int> ibegin_zoom_sub, jbegin_zoom_sub;
+         std::vector<int> ibegin_zoom_sub, jbegin_zoom_sub, ni_zoom_sub, nj_zoom_sub;
          std::vector<ARRAY(double, 1)> lonvalue_sub, latvalue_sub;
 
Index: XMLIO_V2/dev/common/src/xmlio/node/field.cpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/node/field.cpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/node/field.cpp	(revision 278)
@@ -47,18 +47,27 @@
 
    bool CField::updateDataServer
-      (const date::CDate & currDate, const std::deque<ARRAY(double, 1)> storedClient)
-   {
-      if ((*last_operation + freq_operation) >= currDate)
-      {
-         ARRAY_CREATE(input, double, 1, [0]);
-         this->grid->inputFieldServer(storedClient, input);
+      (const date::CDate & currDate,
+       const std::deque<ARRAY(double, 1)> storedClient)
+   {
+      const date::CDate opeDate      = *last_operation + freq_operation;
+      const date::CDate writeDate    = *last_Write     + freq_write; 
+      
+      if (opeDate <= currDate)
+      {
+         if (this->data->num_elements() != this->grid->storeIndex[0]->num_elements())
+         {
+            this->data->resize(boost::extents[this->grid->storeIndex[0] ->num_elements()]);
+         }  
+         ARRAY_CREATE(input, double, 1, [this->data->num_elements()]);
+         this->grid->inputFieldServer(storedClient, input);          
          (*this->foperation)(input);
          *last_operation = currDate;
       }
-
-      if ((*last_Write + freq_write) >= currDate)
-      {
-         *last_Write = currDate;
-         return (true);
+      if (writeDate < (currDate + freq_operation))
+      {
+         this->foperation->final();
+         this->incrementNStep();
+         *last_Write = writeDate;
+         return (true);        
       }
       return (false);
@@ -232,4 +241,14 @@
                << "Impossible de dÃ©finir une opÃ©ration pour le champ !");
       }
+      
+      CDuration freq_offset_ = NoneDu;
+      if (!freq_offset.isEmpty())
+      {
+         freq_offset_ = CDuration::FromString(freq_offset.getValue());
+      }
+      else
+      {
+         freq_offset.setValue(NoneDu.toString());
+      }  
 
       if (CXIOSManager::GetStatus() == CXIOSManager::LOC_SERVER)
@@ -245,17 +264,10 @@
          this->foperation     =
              boost::shared_ptr<func::CFunctor>(new CInstant(this->data));
+             
+         const CDuration toffset = this->freq_operation - freq_offset_ - _context->getCalendar()->getTimeStep(); 
+         *this->last_operation   = *this->last_operation - toffset; 
       }
       else
-      {
-         CDuration freq_offset_ = NoneDu;
-         if (!freq_offset.isEmpty())
-         {
-            freq_offset_ = CDuration::FromString(freq_offset.getValue());
-         }
-         else
-         {
-            freq_offset.setValue(NoneDu.toString());
-         }   
-                  
+      {                  
          this->freq_operation = CDuration::FromString(freq_op.getValue());
          this->freq_write     = CDuration::FromString(this->file->output_freq.getValue());
@@ -264,6 +276,7 @@
          this->last_operation = boost::shared_ptr<xmlioserver::date::CDate>
                         (new date::CDate(_context->getCalendar()->getInitDate()));
+                        
          const CDuration toffset = this->freq_operation - freq_offset_ - _context->getCalendar()->getTimeStep(); 
-         *this->last_operation  = *this->last_operation - toffset;  
+         *this->last_operation   = *this->last_operation - toffset;  
          
 #define DECLARE_FUNCTOR(MType, mtype)              \
Index: XMLIO_V2/dev/common/src/xmlio/node/field.hpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/node/field.hpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/node/field.hpp	(revision 278)
@@ -170,5 +170,4 @@
       {
          //std::cout << "> " << currDate << ": Operation du champs" << this->getBaseFieldId() << std::endl;
-         
          if (this->data->num_elements() != this->grid->storeIndex[0]->num_elements())
          {
Index: XMLIO_V2/dev/common/src/xmlio/node/grid.cpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/node/grid.cpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/node/grid.cpp	(revision 278)
@@ -463,8 +463,5 @@
          ARRAY(int, 1) out_j_index_cl  =  this->out_j_index[i + 1];
          ARRAY(int, 1) out_l_index_cl  =  this->out_l_index[i + 1];
-         
-         const int ibegin_cl = ibegin[i];
-         const int jbegin_cl = jbegin[i];
-         
+                 
          int ibegin_zoom_cl = ibegin[i]; //ibegin_zoom[i];
          int jbegin_zoom_cl = jbegin[i]; //jbegin_zoom[i];
@@ -480,7 +477,7 @@
             (*storeIndex_srv)[n]  = (*storeIndex_cl)[m]; // Faux mais inutile dans le cas serveur.
             (*out_i_index_srv)[n] = (*out_i_index_cl)[m] 
-                                  /*+ (ibegin_cl - 1)*/ - (ibegin_srv - 1) + (ibegin_zoom_cl - 1) - (ibegin_zoom_srv - 1); 
+                                  /*+ (ibegin_cl - 1) - (ibegin_srv - 1)*/ + (ibegin_zoom_cl - 1) - (ibegin_zoom_srv - 1);
             (*out_j_index_srv)[n] = (*out_j_index_cl)[m]
-                                  /*+ (jbegin_cl - 1)*/ - (jbegin_srv - 1) + (jbegin_zoom_cl - 1) - (jbegin_zoom_srv - 1);
+                                  /*+ (jbegin_cl - 1) - (jbegin_srv - 1)*/ + (jbegin_zoom_cl - 1) - (jbegin_zoom_srv - 1);
             (*out_l_index_srv)[n] = (*out_l_index_cl)[m];
          }
@@ -532,11 +529,5 @@
       this->out_i_index[0] = out_i_index_srv;
       this->out_j_index[0] = out_j_index_srv;
-      this->out_l_index[0] = out_l_index_srv;
-      
-      this->storeIndex.resize(1);
-      this->out_i_index.resize(1);
-      this->out_j_index.resize(1);
-      this->out_l_index.resize(1);
-      
+      this->out_l_index[0] = out_l_index_srv;      
    }
    
@@ -552,7 +543,7 @@
                 << "Les donnÃ©es d'un client sont manquantes !") ;
       if (storedServer.get() != NULL)
-         storedServer->resize(boost::extents[this->storeIndex.size()-1]);
+         storedServer->resize(boost::extents[this->storeIndex[0]->num_elements()]);
       else 
-         ARRAY_ASSIGN(storedServer, double, 1, [this->storeIndex.size()-1]);
+         ARRAY_ASSIGN(storedServer, double, 1, [this->storeIndex[0]->num_elements()]);
          
       for (StdSize i = 0, n = 0; i < storedClient.size(); i++)
Index: XMLIO_V2/dev/common/src/xmlio/output/nc4_data_output.cpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/output/nc4_data_output.cpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/output/nc4_data_output.cpp	(revision 278)
@@ -8,4 +8,6 @@
 #include "file.hpp"
 #include "calendar.hpp"
+#include "xios_manager.hpp"
+#include "context.hpp"
 
 namespace xmlioserver
@@ -75,6 +77,10 @@
          StdString lonid     = StdString("lon_").append(domid);
          StdString latid     = StdString("lat_").append(domid);
-         StdString lonid_loc = StdString("lon_").append(domid).append("_local");
-         StdString latid_loc = StdString("lat_").append(domid).append("_local");
+         StdString lonid_loc = (comm::CMPIManager::GetCommSize(CXIOSManager::Comm_Server) > 1)
+                             ? StdString("lon_").append(domid).append("_local")
+                             : lonid;
+         StdString latid_loc = (comm::CMPIManager::GetCommSize(CXIOSManager::Comm_Server) > 1)
+                             ? StdString("lat_").append(domid).append("_local")
+                             : latid;
          StdString maskid    = StdString("mask_").append(domid).append("_local");
 
@@ -84,6 +90,9 @@
          bool isCurvilinear = (domain->lonvalue.getValue()->size() == ssize);
 
-         SuperClassWriter::addDimension(lonid, domain->ni_glo.getValue());
-         SuperClassWriter::addDimension(latid, domain->nj_glo.getValue());
+         if (comm::CMPIManager::GetCommSize(CXIOSManager::Comm_Server) > 1)
+         {
+            SuperClassWriter::addDimension(lonid, domain->zoom_ni.getValue());
+            SuperClassWriter::addDimension(latid, domain->zoom_nj.getValue());
+         }
 
          if (isCurvilinear)
@@ -104,9 +113,13 @@
                SuperClassWriter::addDimension(lonid_loc, domain->zoom_ni_loc.getValue());
                SuperClassWriter::addDimension(latid_loc, domain->zoom_nj_loc.getValue());
-               this->writeLocalAttributes(domain->zoom_ibegin_loc.getValue(),
-                                          domain->zoom_ni_loc.getValue(),
-                                          domain->zoom_jbegin_loc.getValue(),
-                                          domain->zoom_nj_loc.getValue(),
-                                          domid);
+               if (comm::CMPIManager::GetCommSize(CXIOSManager::Comm_Server) > 1)
+               {
+                  this->writeLocalAttributes(domain->zoom_ibegin_loc.getValue(),
+                                             domain->zoom_ni_loc.getValue(),
+                                             domain->zoom_jbegin_loc.getValue(),
+                                             domain->zoom_nj_loc.getValue(),
+                                             domid);
+               }
+               
                if (isCurvilinear)
                {
@@ -128,12 +141,15 @@
                dim0.push_back(lonid_loc);
 
-               SuperClassWriter::addVariable(maskid, NC_INT, dim0);
-
-               this->writeMaskAttributes(maskid,
-                  domain->data_dim.getValue()/*,
-                  domain->data_ni.getValue(),
-                  domain->data_nj.getValue(),
-                  domain->data_ibegin.getValue(),
-                  domain->data_jbegin.getValue()*/);
+               if (comm::CMPIManager::GetCommSize(CXIOSManager::Comm_Server) > 1)
+               {
+                  SuperClassWriter::addVariable(maskid, NC_INT, dim0);
+
+                  this->writeMaskAttributes(maskid,
+                     domain->data_dim.getValue()/*,
+                     domain->data_ni.getValue(),
+                     domain->data_nj.getValue(),
+                     domain->data_ibegin.getValue(),
+                     domain->data_jbegin.getValue()*/);
+               }
                   
                //SuperClassWriter::setDefaultValue(maskid, &dvm);
@@ -142,5 +158,6 @@
                SuperClassWriter::writeData(domain->latvalue.getValue(), latid, true, 0);
                SuperClassWriter::writeData(domain->lonvalue.getValue(), lonid, true, 0);
-               SuperClassWriter::writeData(mask, maskid);
+               if (comm::CMPIManager::GetCommSize(CXIOSManager::Comm_Server) > 1)
+                  SuperClassWriter::writeData(mask, maskid);
                SuperClassWriter::definition_start();
 
@@ -169,4 +186,5 @@
          switch (SuperClass::type)
          {
+            case (ONE_FILE) :
             case (MULTI_FILE) :
             {
@@ -218,6 +236,10 @@
          StdString lonid     = StdString("lon_").append(domid);
          StdString latid     = StdString("lat_").append(domid);
-         StdString lonid_loc = StdString("lon_").append(domid).append("_local");
-         StdString latid_loc = StdString("lat_").append(domid).append("_local");
+         StdString lonid_loc = (comm::CMPIManager::GetCommSize(CXIOSManager::Comm_Server) > 1)
+                             ? StdString("lon_").append(domid).append("_local")
+                             : lonid;
+         StdString latid_loc = (comm::CMPIManager::GetCommSize(CXIOSManager::Comm_Server) > 1)
+                             ? StdString("lat_").append(domid).append("_local")
+                             : latid;
          StdString fieldid   = (!field->name.isEmpty())
                              ? field->name.getValue() : field->getBaseFieldReference()->getId();
@@ -376,5 +398,15 @@
                              ? field->name.getValue() 
                              : field->getBaseFieldReference()->getId();
+         boost::shared_ptr<xmlioserver::tree::CContext> context =
+            CObjectFactory::GetObject<xmlioserver::tree::CContext>
+               (CObjectFactory::GetCurrentContextId());
+                             
+         StdOStringStream oss;
+         oss << "time_" << field->operation.getValue()
+             << "_" << field->getRelFile()->output_freq.getValue();
+             
          ARRAY(double, 1) field_data = field->getData();
+         ARRAY_CREATE(time_data, double, 1, [1]);
+         (*time_data)[0] = date::Time(*field->getLastWriteDate());
          
          if (grid->hasAxis()) // 3D
@@ -383,4 +415,5 @@
             grid->outputField(field_data, field_data3D);
             SuperClassWriter::writeData(field_data3D, fieldid, true, field->getNStep()-1);
+            SuperClassWriter::writeData(time_data, oss.str(), true, field->getNStep()-1);
             
          }
@@ -390,4 +423,5 @@
             grid->outputField(field_data,  field_data2D);
             SuperClassWriter::writeData(field_data2D, fieldid, true, field->getNStep()-1);
+            SuperClassWriter::writeData(time_data, oss.str(), true, field->getNStep()-1);
          }
       }
Index: XMLIO_V2/dev/common/src/xmlio/server.cpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/server.cpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/server.cpp	(revision 278)
@@ -33,5 +33,5 @@
    boost::shared_ptr<CServer> CServer::CreateServer(MPIComm comm_client_server)
    {
-      if (CServer::Server.get() != NULL)
+      if (CServer::Server.get() == NULL)
          CServer::Server = boost::shared_ptr<CServer>(new CServer(comm_client_server));
       return (CServer::GetServer());
@@ -140,5 +140,5 @@
    void CServer::initialize(void) // manager 0, method 0
    {
-      // Ne rien faire de plus
+      std::cout << "initialize" << std::endl;
    }
    
@@ -147,4 +147,5 @@
    void CServer::finalize(void) // manager 0, method 1
    {
+      std::cout << "finalize" << std::endl;
        comm::CMPIManager::Barrier();
    }   
Index: XMLIO_V2/dev/common/src/xmlio/xml_node.cpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/xml_node.cpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/xml_node.cpp	(revision 278)
@@ -11,4 +11,5 @@
       CXMLNode::CXMLNode(rapidxml::xml_node<char> * const root)
          : node(root)
+         , level(0)
       { /* Ne rien faire de plus */ }
 
@@ -48,5 +49,6 @@
                else if (nextElement->type() == rapidxml::node_element)
                { 
-                  node = nextElement; 
+                  node = nextElement;
+                  level++;
                   return (!retvalue); 
                }
@@ -59,7 +61,8 @@
       {
          bool retvalue = false;
-         if (!(this->getElementName().compare(CXMLNode::RootName)))
+         if (!(this->getElementName().compare(CXMLNode::RootName)) || (level == 0))
             return (retvalue);
          node = node->parent();
+         level--;
          return (!retvalue);
       }
Index: XMLIO_V2/dev/common/src/xmlio/xml_node.hpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/xml_node.hpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/xml_node.hpp	(revision 278)
@@ -46,4 +46,5 @@
 
             rapidxml::xml_node<char> * node;
+            int level;
 
             static StdString RootName;
Index: XMLIO_V2/dev/common/src/xmlio/xml_parser.cpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/xml_parser.cpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/xml_parser.cpp	(revision 278)
@@ -1,3 +1,5 @@
 #include "xml_parser.hpp"
+
+#include "context.hpp"
 
 #include "attribute_template_impl.hpp"
@@ -12,6 +14,8 @@
 
       void CXMLParser::ParseFile(const StdString & filename)
-      { StdIFStream ifs ( filename.c_str() , StdIFStream::in );
-        CXMLParser::ParseStream(ifs); }
+      {
+         StdIFStream ifs ( filename.c_str() , StdIFStream::in );
+         CXMLParser::ParseStream(ifs);
+      }
 
       void CXMLParser::ParseString(const StdString & xmlContent)
@@ -86,4 +90,5 @@
          }
       }
+
    }// namespace xml
 } // namespace xmlioserver
Index: XMLIO_V2/dev/common/src/xmlio/xml_parser.hpp
===================================================================
--- XMLIO_V2/dev/common/src/xmlio/xml_parser.hpp	(revision 275)
+++ XMLIO_V2/dev/common/src/xmlio/xml_parser.hpp	(revision 278)
@@ -4,6 +4,7 @@
 /// xmlioserver headers ///
 #include "xmlioserver_spl.hpp"
+#include "exception.hpp"
 #include "xml_node.hpp"
-#include "context.hpp"
+
 
 namespace xmlioserver
@@ -19,6 +20,29 @@
             static void ParseString(const StdString & xmlContent);
             static void ParseStream(StdIStream & stream);
+            template <class T>
+               static inline void ParseInclude(StdIStream & stream, T & object);
 
       }; //class CXMLParser
+
+      template <class T>
+         void CXMLParser::ParseInclude(StdIStream & stream, T& object)
+      {
+         StdOStringStream oss;
+         while(!stream.eof() && !stream.fail ())
+            oss.put(stream.get());
+         try
+         {
+            const StdString xmlcontent( oss.str(), 0, oss.str().size()-1 );
+            rapidxml::xml_document<char> doc;
+            doc.parse<0>(const_cast<char*>(xmlcontent.c_str()));
+            CXMLNode node(doc.first_node());
+            object.parse(node);
+         }
+         catch (rapidxml::parse_error & exc)
+         {
+            ERROR("CXMLParser::ParseStream(StdIStream & stream)",
+                  << "RapidXML error : " << exc.what() << " !");
+         }
+      }
 
    }// namespace xml
