source: XMLIO_V2/dev/dev_rv/src4/xmlio/main_server.cpp @ 249

Last change on this file since 249 was 249, checked in by hozdoba, 13 years ago

Ajout d'une partie d'Interface fortran pour la version 4
Ajout des sorties netcdf4 pour la version 4

File size: 2.7 KB
Line 
1/* ************************************************************************** *
2 *      Copyright © IPSL/LSCE, XMLIOServer, Avril 2010 - Octobre 2011         *
3 * ************************************************************************** */
4/**
5 * \file    main_server.cpp
6 * \brief   Programme principal du projet.
7 * \author  Hervé Ozdoba
8 * \version 0.4
9 * \date    1er Juin 2011
10 *
11 * Ce fichier contient le point d'entrée du programme permettant
12 * de lancer le serveur d'Entrée/Sortie parallÚle.
13 */
14
15// XMLIOServer headers
16#include "xmlioserver_spl.hpp"
17
18#include "mpi_interface.hpp"
19#include "onetcdf4.hpp"
20#include "onetcdf4_impl.hpp"
21
22namespace xios = xmlioserver;
23//~ using namespace xios::data;
24using namespace xios::io;
25//~ using namespace xios::tree;
26//~ using namespace xios::xml;
27using namespace xios::comm;
28//~ using namespace xios::func;
29
30// Point d'entrée du programme serveur principal.
31int main (int argc, char ** argv, char ** XIOS_UNUSED (env))
32{
33   try
34   {
35      CMPIManager::Initialise(&argc, &argv);
36      {
37         MPI_Comm cworld = CMPIManager::GetCommWorld();
38         int rank = CMPIManager::GetCommRank();
39         int size = CMPIManager::GetCommSize();
40         
41         CONetCDF4 output("wk/data/herve.nc", false, &cworld);
42         
43         CONetCDF4::CNetCDF4Path path;
44         path.push_back("ozdoba");
45         
46         output.addGroup("ozdoba");
47         output.setCurrentPath(path);
48         output.addDimension("time");
49         output.addDimension("x", 10);
50         output.addDimension("y", 10);
51         
52         std::vector<std::string> dims;
53         dims.push_back("time");
54         dims.push_back("x");
55         dims.push_back("y");
56         
57         std::string toto("toto");
58         output.addVariable(toto, NC_INT, dims);
59
60         output.writeAttribute("att1", "llo");
61         
62         std::vector<int> vvv;
63         vvv.push_back(1);
64         output.writeAttribute("att1", vvv, &toto);
65         vvv.push_back(5);
66         output.writeAttribute("att5", vvv, &toto);
67         
68         boost::multi_array<int, 2> data(boost::extents[2][10]);
69         boost::multi_array<int, 2>::iterator it = data.begin(), end = data.end();
70         
71         for (std::size_t i = 0; i < data.num_elements(); i++) data.data()[i] = rank;
72
73         std::vector<std::size_t> _start;
74         std::vector<std::size_t> _count;
75         _start.push_back(10*rank/size);
76         _count.push_back(2);
77         _start.push_back(0);
78         _count.push_back(10);
79         
80         output.writeData( data, toto, 0, false, &_start, &_count);
81      }
82
83      CMPIManager::Finalize();
84   }
85   catch (xios::CException & _exception)
86   {
87      std::cerr << _exception.getMessage() << std::endl;
88      CMPIManager::Finalize();
89      return (-1);
90   }
91   return (0);
92}
93
94
Note: See TracBrowser for help on using the repository browser.