Index: XIOS/trunk/src/buffer_client.cpp
===================================================================
--- XIOS/trunk/src/buffer_client.cpp	(revision 511)
+++ XIOS/trunk/src/buffer_client.cpp	(revision 512)
@@ -46,5 +46,4 @@
     if (size>bufferSize) ERROR("CClientBuffer::hasSpace(int size)",
                                <<"request size is too big for buffer, increase buffer client size"<<endl
-                               <<"Current buffer_size : "<<CXios::bufferSize<<endl
                                <<"buffer_size must be > "<<size*2<<endl)
 
Index: XIOS/trunk/src/buffer_client.hpp
===================================================================
--- XIOS/trunk/src/buffer_client.hpp	(revision 511)
+++ XIOS/trunk/src/buffer_client.hpp	(revision 512)
@@ -16,5 +16,5 @@
     public:
 
-    CClientBuffer(MPI_Comm intercomm,int serverRank, StdSize bfSize = CXios::bufferSize) ;
+    CClientBuffer(MPI_Comm intercomm,int serverRank, StdSize bfSize = 0) ;
     ~CClientBuffer() ;
     bool isBufferFree(int size) ;
Index: XIOS/trunk/src/buffer_server.hpp
===================================================================
--- XIOS/trunk/src/buffer_server.hpp	(revision 511)
+++ XIOS/trunk/src/buffer_server.hpp	(revision 512)
@@ -15,5 +15,5 @@
     public:
 
-    CServerBuffer(StdSize bufSize = CXios::bufferSize) ;
+    CServerBuffer(StdSize bufSize) ;
     ~CServerBuffer() ;
     char* buffer ;
Index: XIOS/trunk/src/context_client.cpp
===================================================================
--- XIOS/trunk/src/context_client.cpp	(revision 511)
+++ XIOS/trunk/src/context_client.cpp	(revision 512)
@@ -15,6 +15,10 @@
 namespace xios
 {
-
-
+    /*!
+    \param [in] parent Pointer to context on client side
+    \param [in] intraComm_ communicator of group client
+    \param [in] interComm_ communicator of group server
+    \cxtSer [in] cxtSer Pointer to context of server side. (It is only used on case of attached mode)
+    */
     CContextClient::CContextClient(CContext* parent,MPI_Comm intraComm_, MPI_Comm interComm_, CContext* cxtSer)
      : mapBufferSize_(), parentServer(cxtSer)
@@ -35,5 +39,8 @@
     }
 
-
+    /*!
+    In case of attached mode, the current context must be reset to context for client
+    \param [in] event Event sent to server
+    */
     void CContextClient::sendEvent(CEventClient& event)
     {
@@ -72,4 +79,8 @@
     }
 
+    /*!
+    Special function to setup size of buffer not only on client side but also on server side
+    corresponding to the connection
+    */
     void CContextClient::sendBufferSizeEvent()
     {
@@ -81,5 +92,5 @@
               <<"No information about server buffer, that should not happen...");
 
-      for (; itMap != iteMap; ++iteMap)
+      for (; itMap != iteMap; ++itMap)
       {
         if (buffers.end() == buffers.find(itMap->first))
@@ -97,4 +108,9 @@
     }
 
+    /*!
+    If client is also server (attached mode), after sending event, it should process right away
+    the incoming event.
+    \param [in] ranks list rank of server connected this client
+    */
     void CContextClient::waitEvent(list<int>& ranks)
     {
@@ -122,7 +138,12 @@
        parentServer->server->eventLoop() ;
       }
-
     }
 
+    /*!
+    Setup buffer for each connection to server and verify their state to put content into them
+    \param [in] serverList list of rank of connected server
+    \param [in] sizeList size of message corresponding to each connection
+    \return List of buffer input which event can be placed
+    */
     list<CBufferOut*> CContextClient::getBuffers(list<int>& serverList, list<int>& sizeList)
     {
@@ -166,10 +187,17 @@
    }
 
+   /*!
+   Make a new buffer for a certain connection to server with specific rank
+   \param [in] rank rank of connected server
+   */
    void CContextClient::newBuffer(int rank)
    {
-//     buffers[rank]=new CClientBuffer(interComm,rank);
       buffers[rank]=new CClientBuffer(interComm,rank, mapBufferSize_[rank]) ;
    }
 
+   /*!
+   Verify state of buffers. Buffer is under pending state if there is no message on it
+   \return state of buffers, pending(true), ready(false)
+   */
    bool CContextClient::checkBuffers(void)
    {
@@ -180,4 +208,5 @@
    }
 
+   //! Release all buffers
    void CContextClient::releaseBuffers(void)
    {
@@ -186,4 +215,9 @@
    }
 
+   /*!
+   Verify state of buffers corresponding to a connection
+   \param [in] ranks list rank of server to which client connects to
+   \return state of buffers, pending(true), ready(false)
+   */
    bool CContextClient::checkBuffers(list<int>& ranks)
    {
@@ -194,4 +228,8 @@
    }
 
+   /*!
+   Set buffer size for each connection
+   \param [in] mapSize mapping rank of connected server to size of allocated buffer
+   */
    void CContextClient::setBufferSize(const std::map<int, StdSize>& mapSize)
    {
@@ -200,4 +238,8 @@
    }
 
+   /*!
+   Get leading server in the group of connected server
+   \return rank of leading server
+   */
    int CContextClient::getServerLeader(void)
    {
@@ -217,4 +259,8 @@
    }
 
+   /*!
+   Check if client connects to leading server
+   \return connected(true), not connected (false)
+   */
    bool CContextClient::isServerLeader(void)
    {
@@ -236,7 +282,9 @@
    }
 
+   /*!
+   Finalize context client and do some reports
+   */
    void CContextClient::finalize(void)
    {
-
      map<int,CClientBuffer*>::iterator itBuff ;
      bool stop=true ;
@@ -259,5 +307,4 @@
      }
      CTimer::get("Blocking time").suspend();
-//     report(0)<< " Memory report : Context <"<<context->getId()<<"> : client side : total memory used for buffer "<<buffers.size()*CXios::bufferSize<<" bytes"<<endl ;
 
      std::map<int, StdSize>::const_iterator itbMap = mapBufferSize_.begin(),
@@ -267,5 +314,5 @@
      {
        report(10)<< " Memory report : Context <"<<context->getId()<<"> : client side : memory used for buffer of each connection to server" << endl
-                 << "  +)To server with rank " << itMap->first << " : " << itMap->second << " bytes " << endl;
+                 << "  +) To server with rank " << itMap->first << " : " << itMap->second << " bytes " << endl;
        totalBuf += itMap->second;
      }
Index: XIOS/trunk/src/context_client.hpp
===================================================================
--- XIOS/trunk/src/context_client.hpp	(revision 511)
+++ XIOS/trunk/src/context_client.hpp	(revision 512)
@@ -12,51 +12,71 @@
   class CContext ;
 
+  /*!
+  \class CContextClient
+  A context can be both on client and on server side. In order to differenciate the role of
+  context on each side, e.x client sending events, server receiving and processing events, there is a need of
+  concrete "context" classes for both sides.
+  CContextClient processes and sends events from client to server where CContextServer receives these events
+  and processes them.
+  */
   class CContextClient
   {
+    public:
+    // Contructor
+    CContextClient(CContext* parent,MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer = 0) ;
 
-    public:
-    CContextClient(CContext* parent,MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer = 0) ;
-//    void registerEvent(CEventClient& event) ;
+    // Send event to server
+    void sendEvent(CEventClient& event) ;
+    void waitEvent(list<int>& ranks) ;
 
-//    list<CBufferOut*> newEvent(CEventClient& event,list<int>& sizes) ;
-    void sendEvent(CEventClient& event) ;
-
+    // Functions relates to set/get buffers
     list<CBufferOut*> getBuffers(list<int>& serverlist, list<int>& sizeList) ;
     void newBuffer(int rank) ;
-    size_t timeLine ;
-    int clientRank ;
-    int clientSize ;
-    int serverSize ;
-//    set<int> connectedServer ;
-    MPI_Comm interComm ;
-    MPI_Comm intraComm ;
-    map<int,CClientBuffer*> buffers ;
     bool checkBuffers(list<int>& ranks) ;
     bool checkBuffers(void);
     void releaseBuffers(void);
-    void closeContext(void) ;
+
     bool isServerLeader(void) ;
     int getServerLeader(void) ;
+
+    // Close and finalize context client
+    void closeContext(void) ;
     void finalize(void) ;
-    void waitEvent(list<int>& ranks) ;
 
     void setBufferSize(const std::map<int, StdSize>& mapSize);
     void sendBufferSizeEvent();
 
-    CContext* context ;
+    public:
+      CContext* context ; //!< Context for client
+
+      size_t timeLine ; //!< Timeline of each event
+
+      int clientRank ; //!< Rank of current client
+
+      int clientSize ; //!< Size of client group
+
+      int serverSize ; //!< Size of server group
+
+      MPI_Comm interComm ; //!< Communicator of server group
+
+      MPI_Comm intraComm ; //!< Communicator of client group
+
+      map<int,CClientBuffer*> buffers ; //!< Buffers for connection to servers
 
     private:
-    std::map<int, StdSize> mapBufferSize_;
-    CContext* parentServer;
+      //! Mapping of server and buffer size for each connection to server
+      std::map<int, StdSize> mapBufferSize_;
+
+      //! Context for server (Only used in attached mode)
+      CContext* parentServer;
+
+    public: // Some function should be removed in the future
+      //    void registerEvent(CEventClient& event) ;
+//    list<CBufferOut*> newEvent(CEventClient& event,list<int>& sizes) ;
 //    bool locked ;
+//    set<int> connectedServer ;
 
   } ;
-
-
-
-
 }
 
-
-
-#endif
+#endif // __CONTEXT_CLIENT_HPP__
Index: XIOS/trunk/src/cxios.cpp
===================================================================
--- XIOS/trunk/src/cxios.cpp	(revision 511)
+++ XIOS/trunk/src/cxios.cpp	(revision 512)
@@ -23,12 +23,11 @@
   bool CXios::usingOasis ;
   bool CXios::usingServer = false;
-  size_t CXios::bufferSize ;
-  double CXios::bufferServerFactorSize=2 ;
-  size_t CXios::defaultBufferSize=1024*1024*100 ; // 100Mo
-  double CXios::defaultBufferServerFactorSize=2 ;
+  double CXios::bufferServerFactorSize=1.0 ;
+  double CXios::defaultBufferServerFactorSize=1.0 ;
   bool CXios::printInfo2File;
   bool CXios::isServerSide;
   bool CXios::isOptPerformance = true;
 
+  //! Parse configuration file and create some objects from it
   void CXios::initialize()
   {
@@ -38,4 +37,8 @@
   }
 
+  /*!
+  \brief Parse xios part of configuration file (.iodef.xml)
+   Both client and server need information returned from this function
+  */
   void CXios::parseXiosConfig()
   {
@@ -43,7 +46,7 @@
     usingServer=getin<bool>("using_server",false) ;
     info.setLevel(getin<int>("info_level",0)) ;
-    report.setLevel(getin<int>("info_level",0));
+    report.setLevel(getin<int>("info_level",50));
     printInfo2File=getin<bool>("print_file",false);
-    bufferSize=getin<size_t>("buffer_size",defaultBufferSize) ;
+
     StdString bufMemory("memory");
     StdString bufPerformance("performance");
@@ -56,9 +59,14 @@
     }
 
-//    bufferServerFactorSize=getin<double>("buffer_server_factor_size",defaultBufferServerFactorSize) ;
     bufferServerFactorSize=getin<double>("buffer_factor_size",defaultBufferServerFactorSize) ;
     globalComm=MPI_COMM_WORLD ;
   }
 
+  /*!
+  Initialize client
+  \param [in] codeId identity of context
+  \param [in] localComm local communicator
+  \param [in/out] returnComm communicator corresponding to group of client with same codeId
+  */
   void CXios::initClientSide(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm)
   {
@@ -89,4 +97,5 @@
   }
 
+  //! Init server by parsing only xios part of config file
   void CXios::initServer()
   {
@@ -98,7 +107,7 @@
   }
 
+  //! Initialize server then put it into listening state
   void CXios::initServerSide(void)
   {
-//    initialize();
     initServer();
     isClient=true;
@@ -123,4 +132,5 @@
   }
 
+  //! Parse configuration file
   void CXios::parseFile(const string& filename)
   {
@@ -128,4 +138,5 @@
   }
 
+  //! Set using server
   void CXios::setUsingServer()
   {
@@ -133,4 +144,5 @@
   }
 
+  //! Unset using server
   void CXios::setNotUsingServer()
   {
Index: XIOS/trunk/src/cxios.hpp
===================================================================
--- XIOS/trunk/src/cxios.hpp	(revision 511)
+++ XIOS/trunk/src/cxios.hpp	(revision 512)
@@ -7,16 +7,11 @@
 namespace xios
 {
+  /*!
+  \class CXios
+  */
   class CXios
   {
-     public:
-
-     static string rootFile ;
-     static string xiosCodeId ;
-     static string clientFile;
-     static string serverFile;
-
+    public:
      static void initialize(void) ;
-
-
      static void initClientSide(const string & codeId, MPI_Comm& localComm, MPI_Comm& returnComm) ;
      static void initServerSide(void) ;
@@ -30,19 +25,23 @@
      static T getin(const string& id) ;
 
-     static bool isClient ;
-     static bool isServer ;
+    public:
+     static string rootFile ; //!< Configuration filename
+     static string xiosCodeId ; //!< Identity for XIOS
+     static string clientFile; //!< Filename template for client
+     static string serverFile; //!< Filename template for server
 
-     static MPI_Comm globalComm ;
+     static bool isClient ; //!< Check if xios is client
+     static bool isServer ; //!< Check if xios is server
 
-     static bool printInfo2File;
-     static bool usingOasis ;
-     static bool usingServer ;
-     static size_t bufferSize ;
-     static size_t defaultBufferSize ;
-     static double bufferServerFactorSize ;
-     static double defaultBufferServerFactorSize ;
-     static bool isOptPerformance;
+     static MPI_Comm globalComm ; //!< Global communicator
 
-     public:
+     static bool printInfo2File; //!< Printing out information into file
+     static bool usingOasis ; //!< Using Oasis
+     static bool usingServer ; //!< Using server (server mode)
+     static double bufferServerFactorSize ; //!< Factor helps tune buffer size
+     static double defaultBufferServerFactorSize ; //!< Default factor value
+     static bool isOptPerformance; //!< Check if buffer size is for performance (as large as possible)
+
+    public:
      //! Setting xios to use server mode
      static void setUsingServer();
@@ -54,22 +53,13 @@
      static bool isServerSide;
 
+     //! Initialize server (if any)
      static  void initServer();
 
-     private:
+    private:
+      //! Parse only Xios part of configuration file
       static void parseXiosConfig();
-
   } ;
-
 }
 
 //#include "cxios_impl.hpp"
-
-
-
-
-
-
-
-
-
-#endif
+#endif // __XIOS_HPP__
