Changeset 1328 for XIOS


Ignore:
Timestamp:
11/15/17 12:14:34 (6 years ago)
Author:
yushan
Message:

dev_omp

Location:
XIOS/dev/branch_openmp
Files:
179 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_openmp/bld.cfg

    r1287 r1328  
    3838#bld::target test_new_features.exe  
    3939#bld::target test_unstruct_complete.exe  
    40 bld::target test_omp.exe  
    41 bld::target test_complete_omp.exe  
    42 bld::target test_remap_omp.exe  
    43 bld::target test_unstruct_omp.exe 
     40#bld::target test_omp.exe  
     41#bld::target test_complete_omp.exe  
     42bld::target test_remap.exe  
     43bld::target test_remap_ref.exe  
     44#bld::target test_unstruct_omp.exe 
    4445#bld::target test_netcdf_omp.exe 
    45 #bld::target test_client.exe  
    46 #bld::target test_complete.exe 
     46bld::target test_client.exe  
     47bld::target test_complete.exe 
    4748#bld::target test_remap.exe 
    4849#bld::target test_unstruct.exe 
  • XIOS/dev/branch_openmp/extern/remap/src/clipper.cpp

    r1205 r1328  
    42744274{ 
    42754275  //The equation of a line in general form (Ax + By + C = 0) 
    4276   //given 2 points (x,y) & (x,y) is ... 
    4277   //(y - y)x + (x - x)y + (y - y)x - (x - x)y = 0 
    4278   //A = (y - y); B = (x - x); C = (y - y)x - (x - x)y 
    4279   //perpendicular distance of point (x,y) = (Ax + By + C)/Sqrt(A + B) 
     4276  //given 2 points (x¹,y¹) & (x²,y²) is ... 
     4277  //(y¹ - y²)x + (x² - x¹)y + (y² - y¹)x¹ - (x² - x¹)y¹ = 0 
     4278  //A = (y¹ - y²); B = (x² - x¹); C = (y² - y¹)x¹ - (x² - x¹)y¹ 
     4279  //perpendicular distance of point (x³,y³) = (Ax³ + By³ + C)/Sqrt(A² + B²) 
    42804280  //see http://en.wikipedia.org/wiki/Perpendicular_distance 
    42814281  double A = double(ln1.Y - ln2.Y); 
  • XIOS/dev/branch_openmp/extern/remap/src/cputime.cpp

    r694 r1328  
    11#include "mpi.hpp" 
     2using namespace ep_lib; 
    23 
    34namespace sphereRemap { 
  • XIOS/dev/branch_openmp/extern/remap/src/elt.hpp

    r1172 r1328  
    5353struct Elt : Polyg 
    5454{ 
    55   Elt() {} 
    56   Elt(const double *bounds_lon, const double *bounds_lat, int max_num_vert) 
    57   { 
    58     int k = 0; 
    59     vertex[k++] = xyz(bounds_lon[0], bounds_lat[0]); 
    60     for (int i = 1; i < max_num_vert; i++) 
    61     { 
    62       vertex[k] = xyz(bounds_lon[i], bounds_lat[i]); 
    63       /* netCDF convention: if first vertex repeats element is finished (at least three vertices == triagle) */ 
    64       if (k >= 3 && squaredist(vertex[k], vertex[0]) < EPS*EPS)  
    65         break; 
    66       /* eliminate zero edges: move to next vertex only if it is different */ 
    67       if (squaredist(vertex[k], vertex[k-1]) > EPS*EPS) 
    68         k++; 
    69       //else cout << "Removed edge " << k << " due to zero length (coinciding endpoints)." << endl ; 
    70     } 
    71     n = k; 
    72     x = barycentre(vertex, n); 
    73   } 
     55        Elt() {} 
     56        Elt(const double *bounds_lon, const double *bounds_lat, int max_num_vert) 
     57        { 
     58                int k = 0; 
     59                vertex[k++] = xyz(bounds_lon[0], bounds_lat[0]); 
     60                for (int i = 1; i < max_num_vert; i++) 
     61                { 
     62                        vertex[k] = xyz(bounds_lon[i], bounds_lat[i]); 
     63                        /* netCDF convention: if first vertex repeats element is finished (at least three vertices == triagle) */ 
     64                        if (k >= 3 && squaredist(vertex[k], vertex[0]) < EPS*EPS)  
     65                                break; 
     66                        /* eliminate zero edges: move to next vertex only if it is different */ 
     67                        if (squaredist(vertex[k], vertex[k-1]) > EPS*EPS) 
     68                                k++; 
     69                        else 
     70                                /* cout << "Removed edge " << k << " due to zero length (coinciding endpoints)." << endl */ ; 
     71                } 
     72                n = k; 
     73                x = barycentre(vertex, n); 
     74        } 
    7475 
    7576        Elt& operator=(const Elt& rhs) 
     
    9596        } 
    9697 
    97   void delete_intersections() 
    98   { 
    99     for (list<Polyg*>::iterator it = this->is.begin(); it != this->is.end(); it++) 
    100     { 
    101       Polyg* poly = *it; 
    102       delete poly; 
    103     } 
    104   } 
     98        void delete_intersections() 
     99        { 
     100                for (list<Polyg*>::iterator it = this->is.begin(); it != this->is.end(); it++) 
     101                { 
     102                        Polyg* poly = *it; 
     103                        delete poly; 
     104                } 
     105        } 
    105106 
    106107  void insert_vertex(int i, const Coord& v) 
  • XIOS/dev/branch_openmp/extern/remap/src/gridRemap.cpp

    r1155 r1328  
    1111 
    1212CRemapGrid srcGrid; 
    13 #pragma omp threadprivate(srcGrid) 
    14  
    1513CRemapGrid tgtGrid; 
    16 #pragma omp threadprivate(tgtGrid) 
    1714 
    1815} 
  • XIOS/dev/branch_openmp/extern/remap/src/gridRemap.hpp

    r1220 r1328  
    1414Coord readPole(std::istream&); 
    1515 
    16  
     16extern CRemapGrid srcGrid; 
     17extern CRemapGrid tgtGrid; 
    1718 
    1819} 
  • XIOS/dev/branch_openmp/extern/remap/src/intersect.cpp

    r1220 r1328  
    1515namespace sphereRemap { 
    1616 
    17 extern CRemapGrid srcGrid; 
    18 #pragma omp threadprivate(srcGrid) 
    19  
    20 extern CRemapGrid tgtGrid; 
    21 #pragma omp threadprivate(tgtGrid) 
    22  
    2317using namespace std; 
    2418 
     
    2721int neighbour_idx(const Elt& a, const Elt& b) 
    2822{ 
    29   for (int i = 0; i < a.n; i++) 
    30   { 
    31     for (int j = 0; j < b.n; j++) 
    32     { 
    33       assert(squaredist(a.vertex[ i       ], b.vertex[ j       ]) > EPS*EPS || 
    34              squaredist(a.vertex[(i+1)%a.n], b.vertex[(j+1)%b.n]) > EPS*EPS); 
    35       if (   squaredist(a.vertex[ i       ], b.vertex[ j           ]) < 1e-13*1e-13 && 
    36              squaredist(a.vertex[(i+1)%a.n], b.vertex[(j+b.n-1)%b.n]) < 1e-13*1e-13) 
    37       { 
    38         return i; 
    39       } 
    40     } 
    41   } 
    42   return NOT_FOUND; 
     23        for (int i = 0; i < a.n; i++) 
     24        { 
     25                for (int j = 0; j < b.n; j++) 
     26                { 
     27                        assert(squaredist(a.vertex[ i       ], b.vertex[ j       ]) > EPS*EPS || 
     28                               squaredist(a.vertex[(i+1)%a.n], b.vertex[(j+1)%b.n]) > EPS*EPS); 
     29                        if (   squaredist(a.vertex[ i       ], b.vertex[ j           ]) < 1e-13*1e-13 && 
     30                               squaredist(a.vertex[(i+1)%a.n], b.vertex[(j+b.n-1)%b.n]) < 1e-13*1e-13) 
     31                        { 
     32                                return i; 
     33                        } 
     34                } 
     35        } 
     36        return NOT_FOUND; 
    4337} 
    4438 
     
    211205bool isNeighbour(Elt& a, const Elt& b) 
    212206{ 
    213   // return neighbour_idx(a, b) != NOT_FOUND; 
     207        // return neighbour_idx(a, b) != NOT_FOUND; 
    214208  return insertNeighbour(a,b,false) ; 
    215209} 
     
    219213void intersect(Elt *a, Elt *b) 
    220214{ 
    221   int na = a->n; /* vertices of a */ 
    222   int nb = b->n; /* vertices of b */ 
    223   Coord *c   = new Coord[na+nb]; 
    224   Coord *c2  = new Coord[na+nb]; 
    225   Coord *xc  = new Coord[na+nb]; 
    226   Coord *xc2 = new Coord[na+nb]; 
    227   Coord gc, gc2; 
    228   double *d = new double[na+nb]; 
    229   double *d2 = new double[na+nb]; 
    230   double are, are2; 
    231   Ipt ipt[NMAX*NMAX]; 
    232   Ipt ipt2[NMAX*NMAX]; 
    233   ptsec(a, b, ipt); 
    234   /* make ipt2 transpose of ipt */ 
    235   for (int ii = 0; ii < na; ii++) 
    236     for (int jj = 0; jj < nb; jj++) 
    237       ipt2[jj*na+ii] = ipt[ii*nb+jj]; 
    238   list<Sgm> iscot; 
    239   recense(a, b, ipt, iscot, 0); 
    240   recense(b, a, ipt2, iscot, 1); 
    241  
    242   int nseg = iscot.size(); 
    243   int nc = 0; 
    244   int nc2 = 0; 
    245   while (iscot.size() && nc < 2) 
    246     nc = assemble(iscot, c, d, xc); 
    247   while (iscot.size() && nc2 < 2) 
    248     nc2 = assemble(iscot, c2, d2, xc2); 
    249 //  assert(nseg == nc + nc2 || nseg == 1); // unused segment 
     215        int na = a->n; /* vertices of a */ 
     216        int nb = b->n; /* vertices of b */ 
     217        Coord *c   = new Coord[na+nb]; 
     218        Coord *c2  = new Coord[na+nb]; 
     219        Coord *xc  = new Coord[na+nb]; 
     220        Coord *xc2 = new Coord[na+nb]; 
     221        Coord gc, gc2; 
     222        double *d = new double[na+nb]; 
     223        double *d2 = new double[na+nb]; 
     224        double are, are2; 
     225        Ipt ipt[NMAX*NMAX]; 
     226        Ipt ipt2[NMAX*NMAX]; 
     227        ptsec(a, b, ipt); 
     228        /* make ipt2 transpose of ipt */ 
     229        for (int ii = 0; ii < na; ii++) 
     230                for (int jj = 0; jj < nb; jj++) 
     231                        ipt2[jj*na+ii] = ipt[ii*nb+jj]; 
     232        list<Sgm> iscot; 
     233        recense(a, b, ipt, iscot, 0); 
     234        recense(b, a, ipt2, iscot, 1); 
     235 
     236        int nseg = iscot.size(); 
     237        int nc = 0; 
     238        int nc2 = 0; 
     239        while (iscot.size() && nc < 2) 
     240                nc = assemble(iscot, c, d, xc); 
     241        while (iscot.size() && nc2 < 2) 
     242                nc2 = assemble(iscot, c2, d2, xc2); 
     243//      assert(nseg == nc + nc2 || nseg == 1); // unused segment 
    250244 
    251245        if (!(nseg == nc + nc2 || nseg == 1)) 
     
    266260 
    267261//    intersect_ym(a,b) ; 
    268   if (nc == 1) nc = 0; 
    269   if (nc2 == 1) nc2 = 0; 
    270   gc = barycentre(xc, nc); 
    271   gc2 = barycentre(xc2, nc2); 
    272   orient(nc, xc, c, d, gc); 
    273  
    274   Coord pole = srcGrid.pole; 
    275   if (pole == ORIGIN) pole = tgtGrid.pole; 
    276   const double MINBASE = 1e-11; 
    277   if (nc == 2) /* nc is the number of vertices of super mesh element */ 
    278   { 
    279     double base = arcdist(xc[0], xc[1]); 
     262        if (nc == 1) nc = 0; 
     263        if (nc2 == 1) nc2 = 0; 
     264        gc = barycentre(xc, nc); 
     265        gc2 = barycentre(xc2, nc2); 
     266        orient(nc, xc, c, d, gc); 
     267 
     268        Coord pole = srcGrid.pole; 
     269        if (pole == ORIGIN) pole = tgtGrid.pole; 
     270        const double MINBASE = 1e-11; 
     271        if (nc == 2) /* nc is the number of vertices of super mesh element */ 
     272        { 
     273                double base = arcdist(xc[0], xc[1]); 
    280274cerr << "DID ARRIVE " << base << xc[0] << xc[1] << endl; 
    281     gc = midpoint(gc, midpointSC(xc[0], xc[1])); 
    282     /* intersection area `are` must be zero here unless we have one great and one small circle */ 
    283     are = alun(base, fabs(scalarprod(xc[0], pole))); 
    284   } 
    285   else 
    286   { 
    287     are = airbar(nc, xc, c, d, pole, gc); 
    288   } 
    289   if (nc2 == 2) 
    290   { 
    291     double base = arcdist(xc2[0], xc2[1]); 
     275                gc = midpoint(gc, midpointSC(xc[0], xc[1])); 
     276                /* intersection area `are` must be zero here unless we have one great and one small circle */ 
     277                are = alun(base, fabs(scalarprod(xc[0], pole))); 
     278        } 
     279        else 
     280        { 
     281                are = airbar(nc, xc, c, d, pole, gc); 
     282        } 
     283        if (nc2 == 2) 
     284        { 
     285                double base = arcdist(xc2[0], xc2[1]); 
    292286cerr << "DID ARRIVE " << base << xc2[0] << xc2[1] << endl; 
    293     assert(base > MINBASE); 
    294     gc2 = midpoint(gc2, midpointSC(xc2[0], xc2[1])); 
    295     are2 = alun(base, fabs(scalarprod(xc2[0], pole))); // 0 
    296   } 
    297   else 
    298   { 
    299     are2 = airbar(nc2, xc2, c2, d2, pole, gc2); 
    300   } 
     287                assert(base > MINBASE); 
     288                gc2 = midpoint(gc2, midpointSC(xc2[0], xc2[1])); 
     289                are2 = alun(base, fabs(scalarprod(xc2[0], pole))); // 0 
     290        } 
     291        else 
     292        { 
     293                are2 = airbar(nc2, xc2, c2, d2, pole, gc2); 
     294        } 
    301295 
    302296//  double ym_area=intersect_ym(a,b) ; 
    303297 
    304298  if (nc > 1) 
    305   { 
    306     /* create one super mesh polygon that src and dest point to */ 
    307     Polyg *is = new Polyg; 
    308     is->x = gc; 
    309     is->area = are; 
    310     is->id = b->id; 
    311     is->src_id = b->src_id; 
    312     is->n = nc; 
    313     (a->is).push_back(is); 
    314     (b->is).push_back(is); 
     299        { 
     300                /* create one super mesh polygon that src and dest point to */ 
     301                Polyg *is = new Polyg; 
     302                is->x = gc; 
     303                is->area = are; 
     304                is->id = b->id; 
     305                is->src_id = b->src_id; 
     306                is->n = nc; 
     307                (a->is).push_back(is); 
     308                (b->is).push_back(is); 
    315309/* 
    316     if (  2*fabs(are-ym_area)/(are+ym_area) > 1.1 && ym_area>1e-8) 
     310          if (  2*fabs(are-ym_area)/(are+ym_area) > 1.1 && ym_area>1e-8) 
    317311    { 
    318312      cout<<"Big area difference : "<<are<<"  "<<ym_area<<endl ; 
     
    320314    } 
    321315*/ 
    322 //    cout<<"intersection : "<<are<<" "<< ym_area<<"  diff : "<<fabs(are-ym_area)<<"  ratio : "<<fabs(are-ym_area)/(0.5*(are+ym_area))<<endl ; 
    323   } 
    324   if (nc2 > 1) 
    325   { 
    326     Polyg *is = new Polyg; 
    327     is->x = gc2; 
    328     is->area = are2; 
    329     is->id = b->id; /* intersection holds id of corresponding source element (see Elt class definition for details about id) */ 
    330     is->src_id = b->src_id; 
    331     is->n = nc2; 
    332     (a->is).push_back(is); 
    333     (b->is).push_back(is); 
     316//              cout<<"intersection : "<<are<<" "<< ym_area<<"  diff : "<<fabs(are-ym_area)<<"  ratio : "<<fabs(are-ym_area)/(0.5*(are+ym_area))<<endl ; 
     317        } 
     318        if (nc2 > 1) 
     319        { 
     320                Polyg *is = new Polyg; 
     321                is->x = gc2; 
     322                is->area = are2; 
     323                is->id = b->id; /* intersection holds id of corresponding source element (see Elt class definition for details about id) */ 
     324                is->src_id = b->src_id; 
     325                is->n = nc2; 
     326                (a->is).push_back(is); 
     327                (b->is).push_back(is); 
    334328/* 
    335     if (  2*fabs(are-ym_area)/(are+ym_area) > 1.1 && ym_area>1e-8 ) 
     329    if (        2*fabs(are-ym_area)/(are+ym_area) > 1.1 && ym_area>1e-8 ) 
    336330    { 
    337331      cout<<"Big area difference : "<<are<<"  "<<ym_area<<endl ; 
     
    339333    } 
    340334*/ 
    341 //    cout<<"intersection : "<<are2<<" "<< ym_area<<"  diff : "<<fabs(are-ym_area)<<"  ratio : "<<fabs(are-ym_area)/(0.5*(are+ym_area))<<endl ; 
    342   } 
     335//              cout<<"intersection : "<<are2<<" "<< ym_area<<"  diff : "<<fabs(are-ym_area)<<"  ratio : "<<fabs(are-ym_area)/(0.5*(are+ym_area))<<endl ; 
     336        } 
    343337/* 
    344338  if (nc<=1 && nc2<=1) 
     
    350344  } 
    351345*/ 
    352   delete [] c; 
    353   delete [] c2; 
    354   delete [] xc; 
    355   delete [] xc2; 
    356   delete [] d; 
    357   delete [] d2; 
    358 } 
    359  
    360 } 
     346        delete [] c; 
     347        delete [] c2; 
     348        delete [] xc; 
     349        delete [] xc2; 
     350        delete [] d; 
     351        delete [] d2; 
     352} 
     353 
     354} 
  • XIOS/dev/branch_openmp/extern/remap/src/intersection_ym.cpp

    r1220 r1328  
    1313 
    1414namespace sphereRemap { 
    15  
    16 extern CRemapGrid srcGrid; 
    17 #pragma omp threadprivate(srcGrid) 
    18  
    19 extern CRemapGrid tgtGrid; 
    20 #pragma omp threadprivate(tgtGrid) 
    21  
    2215 
    2316using namespace std; 
  • XIOS/dev/branch_openmp/extern/remap/src/libmapper.cpp

    r1205 r1328  
    1414#include "mapper.hpp" 
    1515#include "cputime.hpp" // cputime 
    16 #include <stdio.h> 
     16 
     17using namespace ep_lib; 
    1718 
    1819using namespace sphereRemap ; 
     
    2122   and deallocated during the second step (computing the weights) */ 
    2223Mapper *mapper; 
    23 #pragma omp threadprivate(mapper) 
     24 
    2425 
    2526/** xxx_bounds_yyy is of length n_vert_per_cell_xxx*n_cell_xxx 
     
    3334                     int order, int* n_weights) 
    3435{ 
    35   assert(src_bounds_lon); 
    36   assert(src_bounds_lat); 
    37   assert(n_vert_per_cell_src >= 3); 
    38   assert(n_cell_src >= 4); 
    39   assert(dst_bounds_lon); 
    40   assert(dst_bounds_lat); 
    41   assert(n_vert_per_cell_dst >= 3); 
    42   assert(n_cell_dst >= 4); 
    43   assert(1 <= order && order <= 2); 
     36        assert(src_bounds_lon); 
     37        assert(src_bounds_lat); 
     38        assert(n_vert_per_cell_src >= 3); 
     39        assert(n_cell_src >= 4); 
     40        assert(dst_bounds_lon); 
     41        assert(dst_bounds_lat); 
     42        assert(n_vert_per_cell_dst >= 3); 
     43        assert(n_cell_dst >= 4); 
     44        assert(1 <= order && order <= 2); 
    4445 
    4546  mapper = new Mapper(MPI_COMM_WORLD); 
     
    8081        double tic = cputime(); 
    8182        mapper = new Mapper(MPI_COMM_WORLD); 
    82         mapper->setVerbosity(PROGRESS) ; 
     83  mapper->setVerbosity(PROGRESS) ; 
    8384        mapper->buildSSTree(src_msh, dst_msh); 
    8485        double tac = cputime(); 
     
    149150        char **argv = NULL; 
    150151        MPI_Init(&argc, &argv);*/ 
    151         //MPI_Init(NULL, NULL); 
    152         int provided; 
    153         MPI_Init_thread(NULL, NULL, 3, &provided); 
    154         assert(provided >= 3); 
     152        MPI_Init(NULL, NULL); 
    155153} 
    156154 
  • XIOS/dev/branch_openmp/extern/remap/src/mapper.cpp

    r1220 r1328  
    1212 
    1313#include "mapper.hpp" 
     14using namespace ep_lib; 
    1415 
    1516namespace sphereRemap { 
    16  
    17 extern CRemapGrid srcGrid; 
    18 #pragma omp threadprivate(srcGrid) 
    19  
    20 extern CRemapGrid tgtGrid; 
    21 #pragma omp threadprivate(tgtGrid) 
    22  
    2317 
    2418/* A subdivition of an array into N sub-arays 
     
    7266void Mapper::setTargetMesh(const double* boundsLon, const double* boundsLat, int nVertex, int nbCells, const double* pole, const long int* globalId) 
    7367{ 
    74     tgtGrid.pole = Coord(pole[0], pole[1], pole[2]); 
    75  
    76     int mpiRank, mpiSize; 
    77     MPI_Comm_rank(communicator, &mpiRank); 
    78     MPI_Comm_size(communicator, &mpiSize); 
    79  
    80     targetElements.reserve(nbCells); 
    81     targetMesh.reserve(nbCells); 
    82  
    83     targetGlobalId.resize(nbCells) ; 
    84     if (globalId==NULL) 
    85     { 
    86         long int offset ; 
    87         long int nb=nbCells ; 
    88         MPI_Scan(&nb,&offset,1,MPI_LONG,MPI_SUM,communicator) ; 
    89         offset=offset-nb ; 
    90         for(int i=0;i<nbCells;i++) targetGlobalId[i]=offset+i ; 
    91     } 
    92     else targetGlobalId.assign(globalId,globalId+nbCells); 
    93  
    94     for (int i = 0; i < nbCells; i++) 
    95     { 
    96         int offs = i*nVertex; 
    97         Elt elt(boundsLon + offs, boundsLat + offs, nVertex); 
    98         targetElements.push_back(elt); 
    99         targetMesh.push_back(Node(elt.x, cptRadius(elt), &sourceElements.back())); 
    100         cptEltGeom(targetElements[i], Coord(pole[0], pole[1], pole[2])); 
    101     } 
     68  tgtGrid.pole = Coord(pole[0], pole[1], pole[2]); 
     69 
     70  int mpiRank, mpiSize; 
     71  MPI_Comm_rank(communicator, &mpiRank); 
     72  MPI_Comm_size(communicator, &mpiSize); 
     73 
     74  targetElements.reserve(nbCells); 
     75  targetMesh.reserve(nbCells); 
     76 
     77  targetGlobalId.resize(nbCells) ; 
     78  if (globalId==NULL) 
     79  { 
     80    long int offset ; 
     81    long int nb=nbCells ; 
     82    MPI_Scan(&nb,&offset,1,MPI_LONG,MPI_SUM,communicator) ; 
     83    offset=offset-nb ; 
     84    for(int i=0;i<nbCells;i++) targetGlobalId[i]=offset+i ; 
     85  } 
     86  else targetGlobalId.assign(globalId,globalId+nbCells); 
     87 
     88  for (int i = 0; i < nbCells; i++) 
     89  { 
     90    int offs = i*nVertex; 
     91    Elt elt(boundsLon + offs, boundsLat + offs, nVertex); 
     92    targetElements.push_back(elt); 
     93    targetMesh.push_back(Node(elt.x, cptRadius(elt), &sourceElements.back())); 
     94    cptEltGeom(targetElements[i], Coord(pole[0], pole[1], pole[2])); 
     95  } 
    10296 
    10397 
     
    106100void Mapper::setSourceValue(const double* val) 
    107101{ 
    108     int size=sourceElements.size() ; 
    109     for(int i=0;i<size;++i) sourceElements[i].val=val[i] ; 
     102  int size=sourceElements.size() ; 
     103  for(int i=0;i<size;++i) sourceElements[i].val=val[i] ; 
    110104} 
    111105 
    112106void Mapper::getTargetValue(double* val) 
    113107{ 
    114     int size=targetElements.size() ; 
    115     for(int i=0;i<size;++i) val[i]=targetElements[i].val ; 
     108  int size=targetElements.size() ; 
     109  for(int i=0;i<size;++i) val[i]=targetElements[i].val ; 
    116110} 
    117111 
    118112vector<double> Mapper::computeWeights(int interpOrder, bool renormalize, bool quantity) 
    119113{ 
    120     vector<double> timings; 
    121     int mpiSize, mpiRank; 
    122     MPI_Comm_size(communicator, &mpiSize); 
    123     MPI_Comm_rank(communicator, &mpiRank); 
    124  
    125     this->buildSSTree(sourceMesh, targetMesh); 
    126  
    127     if (mpiRank == 0 && verbose) cout << "Computing intersections ..." << endl; 
    128     double tic = cputime(); 
    129     computeIntersection(&targetElements[0], targetElements.size()); 
    130     timings.push_back(cputime() - tic); 
    131  
    132     tic = cputime(); 
    133     if (interpOrder == 2) { 
    134         if (mpiRank == 0 && verbose) cout << "Computing grads ..." << endl; 
    135         buildMeshTopology(); 
    136         computeGrads(); 
    137     } 
    138     timings.push_back(cputime() - tic); 
    139  
    140     /* Prepare computation of weights */ 
    141     /* compute number of intersections which for the first order case 
    142        corresponds to the number of edges in the remap matrix */ 
    143     int nIntersections = 0; 
    144     for (int j = 0; j < targetElements.size(); j++) 
    145     { 
    146         Elt &elt = targetElements[j]; 
    147         for (list<Polyg*>::iterator it = elt.is.begin(); it != elt.is.end(); it++) 
    148             nIntersections++; 
    149     } 
    150     /* overallocate for NMAX neighbours for each elements */ 
    151     remapMatrix = new double[nIntersections*NMAX]; 
    152     srcAddress = new int[nIntersections*NMAX]; 
    153     srcRank = new int[nIntersections*NMAX]; 
    154     dstAddress = new int[nIntersections*NMAX]; 
    155     sourceWeightId =new long[nIntersections*NMAX]; 
    156     targetWeightId =new long[nIntersections*NMAX]; 
    157  
    158  
    159     if (mpiRank == 0 && verbose) cout << "Remapping..." << endl; 
    160     tic = cputime(); 
    161     nWeights = remap(&targetElements[0], targetElements.size(), interpOrder, renormalize, quantity); 
    162     timings.push_back(cputime() - tic); 
    163  
    164     for (int i = 0; i < targetElements.size(); i++) targetElements[i].delete_intersections(); 
    165  
    166     return timings; 
     114  vector<double> timings; 
     115  int mpiSize, mpiRank; 
     116  MPI_Comm_size(communicator, &mpiSize); 
     117  MPI_Comm_rank(communicator, &mpiRank); 
     118 
     119 
     120  this->buildSSTree(sourceMesh, targetMesh); 
     121 
     122  if (mpiRank == 0 && verbose) cout << "Computing intersections ..." << endl; 
     123  double tic = cputime(); 
     124  computeIntersection(&targetElements[0], targetElements.size()); 
     125  timings.push_back(cputime() - tic); 
     126 
     127        tic = cputime(); 
     128        if (interpOrder == 2) { 
     129                if (mpiRank == 0 && verbose) cout << "Computing grads ..." << endl; 
     130                buildMeshTopology(); 
     131                computeGrads(); 
     132        } 
     133        timings.push_back(cputime() - tic); 
     134 
     135        /* Prepare computation of weights */ 
     136        /* compute number of intersections which for the first order case 
     137           corresponds to the number of edges in the remap matrix */ 
     138        int nIntersections = 0; 
     139        for (int j = 0; j < targetElements.size(); j++) 
     140        { 
     141                Elt &elt = targetElements[j]; 
     142                for (list<Polyg*>::iterator it = elt.is.begin(); it != elt.is.end(); it++) 
     143                        nIntersections++; 
     144        } 
     145        /* overallocate for NMAX neighbours for each elements */ 
     146        remapMatrix = new double[nIntersections*NMAX]; 
     147        srcAddress = new int[nIntersections*NMAX]; 
     148        srcRank = new int[nIntersections*NMAX]; 
     149        dstAddress = new int[nIntersections*NMAX]; 
     150  sourceWeightId =new long[nIntersections*NMAX]; 
     151  targetWeightId =new long[nIntersections*NMAX]; 
     152 
     153 
     154        if (mpiRank == 0 && verbose) cout << "Remapping..." << endl; 
     155        tic = cputime(); 
     156        nWeights = remap(&targetElements[0], targetElements.size(), interpOrder, renormalize, quantity); 
     157        timings.push_back(cputime() - tic); 
     158 
     159  for (int i = 0; i < targetElements.size(); i++) targetElements[i].delete_intersections(); 
     160 
     161        return timings; 
    167162} 
    168163 
    169164/** 
    170   @param elements are cells of the target grid that are distributed over CPUs 
    171   indepentently of the distribution of the SS-tree. 
    172   @param nbElements is the size of the elements array. 
    173   @param order is the order of interpolaton (must be 1 or 2). 
    174   */ 
     165   @param elements are cells of the target grid that are distributed over CPUs 
     166          indepentently of the distribution of the SS-tree. 
     167   @param nbElements is the size of the elements array. 
     168   @param order is the order of interpolaton (must be 1 or 2). 
     169*/ 
    175170int Mapper::remap(Elt *elements, int nbElements, int order, bool renormalize, bool quantity) 
    176171{ 
    177     int mpiSize, mpiRank; 
    178     MPI_Comm_size(communicator, &mpiSize); 
    179     MPI_Comm_rank(communicator, &mpiRank); 
    180  
    181     /* create list of intersections (super mesh elements) for each rank */ 
    182     multimap<int, Polyg *> *elementList = new multimap<int, Polyg *>[mpiSize]; 
    183     for (int j = 0; j < nbElements; j++) 
    184     { 
    185         Elt& e = elements[j]; 
    186         for (list<Polyg *>::iterator it = e.is.begin(); it != e.is.end(); it++) 
    187             elementList[(*it)->id.rank].insert(pair<int, Polyg *>((*it)->id.ind, *it)); 
    188     } 
    189  
    190     int *nbSendElement = new int[mpiSize]; 
    191     int **sendElement = new int*[mpiSize]; /* indices of elements required from other rank */ 
    192     double **recvValue = new double*[mpiSize]; 
    193     double **recvArea = new double*[mpiSize]; 
    194     Coord **recvGrad = new Coord*[mpiSize]; 
    195     GloId **recvNeighIds = new GloId*[mpiSize]; /* ids of the of the source neighbours which also contribute through gradient */ 
    196     for (int rank = 0; rank < mpiSize; rank++) 
    197     { 
    198         /* get size for allocation */ 
    199         int last = -1; /* compares unequal to any index */ 
    200         int index = -1; /* increased to starting index 0 in first iteration */ 
    201         for (multimap<int, Polyg *>::iterator it = elementList[rank].begin(); it != elementList[rank].end(); ++it) 
    202         { 
    203             if (last != it->first) 
    204                 index++; 
    205             (it->second)->id.ind = index; 
    206             last = it->first; 
    207         } 
    208         nbSendElement[rank] = index + 1; 
    209  
    210         /* if size is non-zero allocate and collect indices of elements on other ranks that we intersect */ 
    211         if (nbSendElement[rank] > 0) 
    212         { 
    213             sendElement[rank] = new int[nbSendElement[rank]]; 
    214             recvValue[rank]   = new double[nbSendElement[rank]]; 
    215             recvArea[rank]    = new double[nbSendElement[rank]]; 
    216             if (order == 2) 
    217             { 
    218                 recvNeighIds[rank] = new GloId[nbSendElement[rank]*(NMAX+1)]; 
    219                 recvGrad[rank]    = new Coord[nbSendElement[rank]*(NMAX+1)]; 
    220             } 
    221             else 
    222                 recvNeighIds[rank] = new GloId[nbSendElement[rank]]; 
    223  
    224             last = -1; 
    225             index = -1; 
    226             for (multimap<int, Polyg *>::iterator it = elementList[rank].begin(); it != elementList[rank].end(); ++it) 
    227             { 
    228                 if (last != it->first) 
    229                     index++; 
    230                 sendElement[rank][index] = it->first; 
    231                 last = it->first; 
    232             } 
    233         } 
    234     } 
    235  
    236     /* communicate sizes of source elements to be sent (index lists and later values and gradients) */ 
    237     int *nbRecvElement = new int[mpiSize]; 
    238     MPI_Alltoall(nbSendElement, 1, MPI_INT, nbRecvElement, 1, MPI_INT, communicator); 
    239  
    240     /* communicate indices of source elements on other ranks whoes value and gradient we need (since intersection) */ 
    241     int nbSendRequest = 0; 
    242     int nbRecvRequest = 0; 
    243     int **recvElement = new int*[mpiSize]; 
    244     double **sendValue = new double*[mpiSize]; 
    245     double **sendArea = new double*[mpiSize]; 
    246     Coord **sendGrad = new Coord*[mpiSize]; 
    247     GloId **sendNeighIds = new GloId*[mpiSize]; 
    248     MPI_Request *sendRequest = new MPI_Request[4*mpiSize]; 
    249     MPI_Request *recvRequest = new MPI_Request[4*mpiSize]; 
    250     for (int rank = 0; rank < mpiSize; rank++) 
    251     { 
    252         if (nbSendElement[rank] > 0) 
    253         { 
    254             MPI_Issend(sendElement[rank], nbSendElement[rank], MPI_INT, rank, 0, communicator, &sendRequest[nbSendRequest]); 
    255             nbSendRequest++; 
    256         } 
    257  
    258         if (nbRecvElement[rank] > 0) 
    259         { 
    260             recvElement[rank] = new int[nbRecvElement[rank]]; 
    261             sendValue[rank]   = new double[nbRecvElement[rank]]; 
    262             sendArea[rank]   = new double[nbRecvElement[rank]]; 
    263             if (order == 2) 
    264             { 
    265                 sendNeighIds[rank] = new GloId[nbRecvElement[rank]*(NMAX+1)]; 
    266                 sendGrad[rank]    = new Coord[nbRecvElement[rank]*(NMAX+1)]; 
    267             } 
    268             else 
    269             { 
    270                 sendNeighIds[rank] = new GloId[nbRecvElement[rank]]; 
    271             } 
    272             MPI_Irecv(recvElement[rank], nbRecvElement[rank], MPI_INT, rank, 0, communicator, &recvRequest[nbRecvRequest]); 
    273             nbRecvRequest++; 
    274         } 
    275     } 
    276  
    277     MPI_Status *status = new MPI_Status[4*mpiSize]; 
    278  
    279     MPI_Waitall(nbSendRequest, sendRequest, status); 
    280     MPI_Waitall(nbRecvRequest, recvRequest, status); 
    281  
    282     /* for all indices that have been received from requesting ranks: pack values and gradients, then send */ 
    283     nbSendRequest = 0; 
    284     nbRecvRequest = 0; 
    285     for (int rank = 0; rank < mpiSize; rank++) 
    286     { 
    287         if (nbRecvElement[rank] > 0) 
    288         { 
    289             int jj = 0; // jj == j if no weight writing 
    290             for (int j = 0; j < nbRecvElement[rank]; j++) 
    291             { 
    292                 sendValue[rank][j] = sstree.localElements[recvElement[rank][j]].val; 
    293                 sendArea[rank][j] = sstree.localElements[recvElement[rank][j]].area; 
    294                 if (order == 2) 
    295                 { 
    296                     sendGrad[rank][jj] = sstree.localElements[recvElement[rank][j]].grad; 
    297                     sendNeighIds[rank][jj] = sstree.localElements[recvElement[rank][j]].src_id; 
    298                     jj++; 
    299                     for (int i = 0; i < NMAX; i++) 
    300                     { 
    301                         sendGrad[rank][jj] = sstree.localElements[recvElement[rank][j]].gradNeigh[i]; 
    302                         sendNeighIds[rank][jj] = sstree.localElements[recvElement[rank][j]].neighId[i]; 
    303                         jj++; 
    304                     } 
    305                 } 
    306                 else 
    307                     sendNeighIds[rank][j] = sstree.localElements[recvElement[rank][j]].src_id; 
    308             } 
    309             MPI_Issend(sendValue[rank], nbRecvElement[rank], MPI_DOUBLE, rank, 0, communicator, &sendRequest[nbSendRequest]); 
    310             nbSendRequest++; 
    311             MPI_Issend(sendArea[rank], nbRecvElement[rank], MPI_DOUBLE, rank, 1, communicator, &sendRequest[nbSendRequest]); 
    312             nbSendRequest++; 
    313             if (order == 2) 
    314             { 
    315                 MPI_Issend(sendGrad[rank], 3*nbRecvElement[rank]*(NMAX+1), 
    316                         MPI_DOUBLE, rank, 2, communicator, &sendRequest[nbSendRequest]); 
    317                 nbSendRequest++; 
    318                 MPI_Issend(sendNeighIds[rank], 4*nbRecvElement[rank]*(NMAX+1), MPI_INT, rank, 3, communicator, &sendRequest[nbSendRequest]); 
    319                 //ym  --> attention taille GloId 
    320                 nbSendRequest++; 
    321             } 
    322             else 
    323             { 
    324                 MPI_Issend(sendNeighIds[rank], 4*nbRecvElement[rank], MPI_INT, rank, 4, communicator, &sendRequest[nbSendRequest]); 
    325                 //ym  --> attention taille GloId 
    326                 nbSendRequest++;                 
    327             } 
    328         } 
    329         if (nbSendElement[rank] > 0) 
    330         { 
    331             MPI_Irecv(recvValue[rank],  nbSendElement[rank], MPI_DOUBLE, rank, 0, communicator, &recvRequest[nbRecvRequest]); 
    332             nbRecvRequest++; 
    333             MPI_Irecv(recvArea[rank],  nbSendElement[rank], MPI_DOUBLE, rank, 1, communicator, &recvRequest[nbRecvRequest]); 
    334             nbRecvRequest++; 
    335             if (order == 2) 
    336             { 
    337                 MPI_Irecv(recvGrad[rank], 3*nbSendElement[rank]*(NMAX+1), 
    338                         MPI_DOUBLE, rank, 2, communicator, &recvRequest[nbRecvRequest]); 
    339                 nbRecvRequest++; 
    340                 MPI_Irecv(recvNeighIds[rank], 4*nbSendElement[rank]*(NMAX+1), MPI_INT, rank, 3, communicator, &recvRequest[nbRecvRequest]); 
    341                 //ym  --> attention taille GloId 
    342                 nbRecvRequest++; 
    343             } 
    344             else 
    345             { 
    346                 MPI_Irecv(recvNeighIds[rank], 4*nbSendElement[rank], MPI_INT, rank, 4, communicator, &recvRequest[nbRecvRequest]); 
    347                 //ym  --> attention taille GloId 
    348                 nbRecvRequest++; 
    349             } 
    350         } 
    351     } 
    352      
    353     MPI_Waitall(nbRecvRequest, recvRequest, status); 
    354     MPI_Waitall(nbSendRequest, sendRequest, status);  
    355      
    356      
    357  
    358     /* now that all values and gradients are available use them to computed interpolated values on target 
    359        and also to compute weights */ 
    360     int i = 0; 
    361     for (int j = 0; j < nbElements; j++) 
    362     { 
    363         Elt& e = elements[j]; 
    364  
    365         /* since for the 2nd order case source grid elements can contribute to a destination grid element over several "paths" 
    366            (step1: gradient is computed using neighbours on same grid, step2: intersection uses several elements on other grid) 
    367            accumulate them so that there is only one final weight between two elements */ 
    368         map<GloId,double> wgt_map; 
    369  
    370         /* for destination element `e` loop over all intersetions/the corresponding source elements */ 
    371         for (list<Polyg *>::iterator it = e.is.begin(); it != e.is.end(); it++) 
    372         { 
    373             /* it is the intersection element, so it->x and it->area are barycentre and area of intersection element (super mesh) 
    374                but it->id is id of the source element that it intersects */ 
    375             int n1 = (*it)->id.ind; 
    376             int rank = (*it)->id.rank; 
    377             double fk = recvValue[rank][n1]; 
    378             double srcArea = recvArea[rank][n1]; 
    379             double w = (*it)->area; 
    380             if (quantity) w/=srcArea ; 
    381  
    382             /* first order: src value times weight (weight = supermesh area), later divide by target area */ 
    383             int kk = (order == 2) ? n1 * (NMAX + 1) : n1; 
    384             GloId neighID = recvNeighIds[rank][kk]; 
    385             wgt_map[neighID] += w; 
    386  
    387             if (order == 2) 
    388             { 
    389                 for (int k = 0; k < NMAX+1; k++) 
    390                 { 
    391                     int kk = n1 * (NMAX + 1) + k; 
    392                     GloId neighID = recvNeighIds[rank][kk]; 
    393                     if (neighID.ind != -1)  wgt_map[neighID] += w * scalarprod(recvGrad[rank][kk], (*it)->x); 
    394                 } 
    395  
    396             } 
    397         } 
    398  
    399         double renorm=0; 
    400         if (renormalize)  
    401             for (map<GloId,double>::iterator it = wgt_map.begin(); it != wgt_map.end(); it++) renorm+=it->second / e.area; 
    402         else renorm=1. ; 
    403  
    404         for (map<GloId,double>::iterator it = wgt_map.begin(); it != wgt_map.end(); it++) 
    405         { 
    406             if (quantity)  this->remapMatrix[i] = (it->second ) / renorm; 
    407             else this->remapMatrix[i] = (it->second / e.area) / renorm; 
    408             this->srcAddress[i] = it->first.ind; 
    409             this->srcRank[i] = it->first.rank; 
    410             this->dstAddress[i] = j; 
    411             this->sourceWeightId[i]= it->first.globalId ; 
    412             this->targetWeightId[i]= targetGlobalId[j] ; 
    413             i++; 
    414         } 
    415     } 
    416      
    417     /* free all memory allocated in this function */ 
    418     for (int rank = 0; rank < mpiSize; rank++) 
    419     { 
    420         if (nbSendElement[rank] > 0) 
    421         { 
    422             delete[] sendElement[rank]; 
    423             delete[] recvValue[rank]; 
    424             delete[] recvArea[rank]; 
    425             if (order == 2) 
    426             { 
    427                 delete[] recvGrad[rank]; 
    428             } 
    429             delete[] recvNeighIds[rank]; 
    430         } 
    431         if (nbRecvElement[rank] > 0) 
    432         { 
    433             delete[] recvElement[rank]; 
    434             delete[] sendValue[rank]; 
    435             delete[] sendArea[rank]; 
    436             if (order == 2) 
    437                 delete[] sendGrad[rank]; 
    438             delete[] sendNeighIds[rank]; 
    439         } 
    440     } 
    441     delete[] status; 
    442     delete[] sendRequest; 
    443     delete[] recvRequest; 
    444     delete[] elementList; 
    445     delete[] nbSendElement; 
    446     delete[] nbRecvElement; 
    447     delete[] sendElement; 
    448     delete[] recvElement; 
    449     delete[] sendValue; 
    450     delete[] recvValue; 
    451     delete[] sendGrad; 
    452     delete[] recvGrad; 
    453     delete[] sendNeighIds; 
    454     delete[] recvNeighIds; 
    455      
    456     return i; 
     172        int mpiSize, mpiRank; 
     173        MPI_Comm_size(communicator, &mpiSize); 
     174        MPI_Comm_rank(communicator, &mpiRank); 
     175 
     176        /* create list of intersections (super mesh elements) for each rank */ 
     177        multimap<int, Polyg *> *elementList = new multimap<int, Polyg *>[mpiSize]; 
     178        for (int j = 0; j < nbElements; j++) 
     179        { 
     180                Elt& e = elements[j]; 
     181                for (list<Polyg *>::iterator it = e.is.begin(); it != e.is.end(); it++) 
     182                        elementList[(*it)->id.rank].insert(pair<int, Polyg *>((*it)->id.ind, *it)); 
     183        } 
     184 
     185        int *nbSendElement = new int[mpiSize]; 
     186        int **sendElement = new int*[mpiSize]; /* indices of elements required from other rank */ 
     187        double **recvValue = new double*[mpiSize]; 
     188        double **recvArea = new double*[mpiSize]; 
     189        Coord **recvGrad = new Coord*[mpiSize]; 
     190        GloId **recvNeighIds = new GloId*[mpiSize]; /* ids of the of the source neighbours which also contribute through gradient */ 
     191        for (int rank = 0; rank < mpiSize; rank++) 
     192        { 
     193                /* get size for allocation */ 
     194                int last = -1; /* compares unequal to any index */ 
     195                int index = -1; /* increased to starting index 0 in first iteration */ 
     196                for (multimap<int, Polyg *>::iterator it = elementList[rank].begin(); it != elementList[rank].end(); ++it) 
     197                { 
     198                        if (last != it->first) 
     199                                index++; 
     200                        (it->second)->id.ind = index; 
     201                        last = it->first; 
     202                } 
     203                nbSendElement[rank] = index + 1; 
     204 
     205                /* if size is non-zero allocate and collect indices of elements on other ranks that we intersect */ 
     206                if (nbSendElement[rank] > 0) 
     207                { 
     208                        sendElement[rank] = new int[nbSendElement[rank]]; 
     209                        recvValue[rank]   = new double[nbSendElement[rank]]; 
     210                        recvArea[rank]    = new double[nbSendElement[rank]]; 
     211                        if (order == 2) 
     212                        { 
     213                                recvNeighIds[rank] = new GloId[nbSendElement[rank]*(NMAX+1)]; 
     214                                recvGrad[rank]    = new Coord[nbSendElement[rank]*(NMAX+1)]; 
     215                        } 
     216                        else 
     217                                recvNeighIds[rank] = new GloId[nbSendElement[rank]]; 
     218 
     219                        last = -1; 
     220                        index = -1; 
     221                        for (multimap<int, Polyg *>::iterator it = elementList[rank].begin(); it != elementList[rank].end(); ++it) 
     222                        { 
     223                                if (last != it->first) 
     224                                        index++; 
     225                                sendElement[rank][index] = it->first; 
     226                                last = it->first; 
     227                        } 
     228                } 
     229        } 
     230 
     231        /* communicate sizes of source elements to be sent (index lists and later values and gradients) */ 
     232        int *nbRecvElement = new int[mpiSize]; 
     233        MPI_Alltoall(nbSendElement, 1, MPI_INT, nbRecvElement, 1, MPI_INT, communicator); 
     234 
     235        /* communicate indices of source elements on other ranks whoes value and gradient we need (since intersection) */ 
     236        int nbSendRequest = 0; 
     237        int nbRecvRequest = 0; 
     238        int **recvElement = new int*[mpiSize]; 
     239        double **sendValue = new double*[mpiSize]; 
     240        double **sendArea = new double*[mpiSize]; 
     241        Coord **sendGrad = new Coord*[mpiSize]; 
     242        GloId **sendNeighIds = new GloId*[mpiSize]; 
     243        MPI_Request *sendRequest = new MPI_Request[4*mpiSize]; 
     244        MPI_Request *recvRequest = new MPI_Request[4*mpiSize]; 
     245        for (int rank = 0; rank < mpiSize; rank++) 
     246        { 
     247                if (nbSendElement[rank] > 0) 
     248                { 
     249                        MPI_Issend(sendElement[rank], nbSendElement[rank], MPI_INT, rank, 0, communicator, &sendRequest[nbSendRequest]); 
     250                        nbSendRequest++; 
     251                } 
     252 
     253                if (nbRecvElement[rank] > 0) 
     254                { 
     255                        recvElement[rank] = new int[nbRecvElement[rank]]; 
     256                        sendValue[rank]   = new double[nbRecvElement[rank]]; 
     257                        sendArea[rank]   = new double[nbRecvElement[rank]]; 
     258                        if (order == 2) 
     259                        { 
     260                                sendNeighIds[rank] = new GloId[nbRecvElement[rank]*(NMAX+1)]; 
     261                                sendGrad[rank]    = new Coord[nbRecvElement[rank]*(NMAX+1)]; 
     262                        } 
     263                        else 
     264                        { 
     265                                sendNeighIds[rank] = new GloId[nbRecvElement[rank]]; 
     266                        } 
     267                        MPI_Irecv(recvElement[rank], nbRecvElement[rank], MPI_INT, rank, 0, communicator, &recvRequest[nbRecvRequest]); 
     268                        nbRecvRequest++; 
     269                } 
     270        } 
     271 
     272  MPI_Status *status = new MPI_Status[4*mpiSize]; 
     273 
     274  MPI_Waitall(nbSendRequest, sendRequest, status); 
     275  MPI_Waitall(nbRecvRequest, recvRequest, status); 
     276 
     277        /* for all indices that have been received from requesting ranks: pack values and gradients, then send */ 
     278        nbSendRequest = 0; 
     279        nbRecvRequest = 0; 
     280        for (int rank = 0; rank < mpiSize; rank++) 
     281        { 
     282                if (nbRecvElement[rank] > 0) 
     283                { 
     284                        int jj = 0; // jj == j if no weight writing 
     285                        for (int j = 0; j < nbRecvElement[rank]; j++) 
     286                        { 
     287                                sendValue[rank][j] = sstree.localElements[recvElement[rank][j]].val; 
     288                                sendArea[rank][j] = sstree.localElements[recvElement[rank][j]].area; 
     289                                if (order == 2) 
     290                                { 
     291                                        sendGrad[rank][jj] = sstree.localElements[recvElement[rank][j]].grad; 
     292                                        sendNeighIds[rank][jj] = sstree.localElements[recvElement[rank][j]].src_id; 
     293                                        jj++; 
     294                                        for (int i = 0; i < NMAX; i++) 
     295                                        { 
     296                                                sendGrad[rank][jj] = sstree.localElements[recvElement[rank][j]].gradNeigh[i]; 
     297            sendNeighIds[rank][jj] = sstree.localElements[recvElement[rank][j]].neighId[i]; 
     298                                                jj++; 
     299                                        } 
     300                                } 
     301                                else 
     302                                        sendNeighIds[rank][j] = sstree.localElements[recvElement[rank][j]].src_id; 
     303                        } 
     304                        MPI_Issend(sendValue[rank],  nbRecvElement[rank], MPI_DOUBLE, rank, 0, communicator, &sendRequest[nbSendRequest]); 
     305                        nbSendRequest++; 
     306                        MPI_Issend(sendArea[rank],  nbRecvElement[rank], MPI_DOUBLE, rank, 0, communicator, &sendRequest[nbSendRequest]); 
     307                        nbSendRequest++; 
     308                        if (order == 2) 
     309                        { 
     310                                MPI_Issend(sendGrad[rank], 3*nbRecvElement[rank]*(NMAX+1), 
     311                                                                MPI_DOUBLE, rank, 0, communicator, &sendRequest[nbSendRequest]); 
     312                                nbSendRequest++; 
     313                                MPI_Issend(sendNeighIds[rank], 4*nbRecvElement[rank]*(NMAX+1), MPI_INT, rank, 0, communicator, &sendRequest[nbSendRequest]); 
     314//ym  --> attention taille GloId 
     315                                nbSendRequest++; 
     316                        } 
     317                        else 
     318                        { 
     319                                MPI_Issend(sendNeighIds[rank], 4*nbRecvElement[rank], MPI_INT, rank, 0, communicator, &sendRequest[nbSendRequest]); 
     320//ym  --> attention taille GloId 
     321                                nbSendRequest++; 
     322                        } 
     323                } 
     324                if (nbSendElement[rank] > 0) 
     325                { 
     326                        MPI_Irecv(recvValue[rank],  nbSendElement[rank], MPI_DOUBLE, rank, 0, communicator, &recvRequest[nbRecvRequest]); 
     327                        nbRecvRequest++; 
     328                        MPI_Irecv(recvArea[rank],  nbSendElement[rank], MPI_DOUBLE, rank, 0, communicator, &recvRequest[nbRecvRequest]); 
     329                        nbRecvRequest++; 
     330                        if (order == 2) 
     331                        { 
     332                                MPI_Irecv(recvGrad[rank], 3*nbSendElement[rank]*(NMAX+1), 
     333                                                MPI_DOUBLE, rank, 0, communicator, &recvRequest[nbRecvRequest]); 
     334                                nbRecvRequest++; 
     335                                MPI_Irecv(recvNeighIds[rank], 4*nbSendElement[rank]*(NMAX+1), MPI_INT, rank, 0, communicator, &recvRequest[nbRecvRequest]); 
     336//ym  --> attention taille GloId 
     337                                nbRecvRequest++; 
     338                        } 
     339                        else 
     340                        { 
     341                                MPI_Irecv(recvNeighIds[rank], 4*nbSendElement[rank], MPI_INT, rank, 0, communicator, &recvRequest[nbRecvRequest]); 
     342//ym  --> attention taille GloId 
     343                                nbRecvRequest++; 
     344                        } 
     345                } 
     346        } 
     347         
     348        MPI_Waitall(nbSendRequest, sendRequest, status); 
     349        MPI_Waitall(nbRecvRequest, recvRequest, status); 
     350         
     351 
     352        /* now that all values and gradients are available use them to computed interpolated values on target 
     353           and also to compute weights */ 
     354        int i = 0; 
     355        for (int j = 0; j < nbElements; j++) 
     356        { 
     357                Elt& e = elements[j]; 
     358 
     359                /* since for the 2nd order case source grid elements can contribute to a destination grid element over several "paths" 
     360                   (step1: gradient is computed using neighbours on same grid, step2: intersection uses several elements on other grid) 
     361                   accumulate them so that there is only one final weight between two elements */ 
     362                map<GloId,double> wgt_map; 
     363 
     364                /* for destination element `e` loop over all intersetions/the corresponding source elements */ 
     365                for (list<Polyg *>::iterator it = e.is.begin(); it != e.is.end(); it++) 
     366                { 
     367                        /* it is the intersection element, so it->x and it->area are barycentre and area of intersection element (super mesh) 
     368                        but it->id is id of the source element that it intersects */ 
     369                        int n1 = (*it)->id.ind; 
     370                        int rank = (*it)->id.rank; 
     371                        double fk = recvValue[rank][n1]; 
     372                        double srcArea = recvArea[rank][n1]; 
     373                        double w = (*it)->area; 
     374      if (quantity) w/=srcArea ; 
     375 
     376                        /* first order: src value times weight (weight = supermesh area), later divide by target area */ 
     377                        int kk = (order == 2) ? n1 * (NMAX + 1) : n1; 
     378                        GloId neighID = recvNeighIds[rank][kk]; 
     379                        wgt_map[neighID] += w; 
     380 
     381                        if (order == 2) 
     382                        { 
     383                                for (int k = 0; k < NMAX+1; k++) 
     384                                { 
     385                                        int kk = n1 * (NMAX + 1) + k; 
     386                                        GloId neighID = recvNeighIds[rank][kk]; 
     387                                        if (neighID.ind != -1)  wgt_map[neighID] += w * scalarprod(recvGrad[rank][kk], (*it)->x); 
     388                                } 
     389 
     390                        } 
     391                } 
     392 
     393    double renorm=0; 
     394    if (renormalize)  
     395      for (map<GloId,double>::iterator it = wgt_map.begin(); it != wgt_map.end(); it++) renorm+=it->second / e.area; 
     396    else renorm=1. ; 
     397 
     398    for (map<GloId,double>::iterator it = wgt_map.begin(); it != wgt_map.end(); it++) 
     399                { 
     400      if (quantity)  this->remapMatrix[i] = (it->second ) / renorm; 
     401                        else this->remapMatrix[i] = (it->second / e.area) / renorm; 
     402                        this->srcAddress[i] = it->first.ind; 
     403                        this->srcRank[i] = it->first.rank; 
     404                        this->dstAddress[i] = j; 
     405      this->sourceWeightId[i]= it->first.globalId ; 
     406      this->targetWeightId[i]= targetGlobalId[j] ; 
     407                        i++; 
     408                } 
     409        } 
     410 
     411        /* free all memory allocated in this function */ 
     412        for (int rank = 0; rank < mpiSize; rank++) 
     413        { 
     414                if (nbSendElement[rank] > 0) 
     415                { 
     416                        delete[] sendElement[rank]; 
     417                        delete[] recvValue[rank]; 
     418                        delete[] recvArea[rank]; 
     419                        if (order == 2) 
     420                        { 
     421                                delete[] recvGrad[rank]; 
     422                        } 
     423                        delete[] recvNeighIds[rank]; 
     424                } 
     425                if (nbRecvElement[rank] > 0) 
     426                { 
     427                        delete[] recvElement[rank]; 
     428                        delete[] sendValue[rank]; 
     429                        delete[] sendArea[rank]; 
     430                        if (order == 2) 
     431                                delete[] sendGrad[rank]; 
     432                        delete[] sendNeighIds[rank]; 
     433                } 
     434        } 
     435        delete[] status; 
     436        delete[] sendRequest; 
     437        delete[] recvRequest; 
     438        delete[] elementList; 
     439        delete[] nbSendElement; 
     440        delete[] nbRecvElement; 
     441        delete[] sendElement; 
     442        delete[] recvElement; 
     443        delete[] sendValue; 
     444        delete[] recvValue; 
     445        delete[] sendGrad; 
     446        delete[] recvGrad; 
     447        delete[] sendNeighIds; 
     448        delete[] recvNeighIds; 
     449        return i; 
    457450} 
    458451 
    459452void Mapper::computeGrads() 
    460453{ 
    461     /* array of pointers to collect local elements and elements received from other cpu */ 
    462     vector<Elt*> globalElements(sstree.nbLocalElements + nbNeighbourElements); 
    463     int index = 0; 
    464     for (int i = 0; i < sstree.nbLocalElements; i++, index++) 
    465         globalElements[index] = &(sstree.localElements[i]); 
    466     for (int i = 0; i < nbNeighbourElements; i++, index++) 
    467         globalElements[index] = &neighbourElements[i]; 
    468  
    469     update_baryc(sstree.localElements, sstree.nbLocalElements); 
    470     computeGradients(&globalElements[0], sstree.nbLocalElements); 
     454        /* array of pointers to collect local elements and elements received from other cpu */ 
     455        vector<Elt*> globalElements(sstree.nbLocalElements + nbNeighbourElements); 
     456        int index = 0; 
     457        for (int i = 0; i < sstree.nbLocalElements; i++, index++) 
     458                globalElements[index] = &(sstree.localElements[i]); 
     459        for (int i = 0; i < nbNeighbourElements; i++, index++) 
     460                globalElements[index] = &neighbourElements[i]; 
     461 
     462        update_baryc(sstree.localElements, sstree.nbLocalElements); 
     463        computeGradients(&globalElements[0], sstree.nbLocalElements); 
    471464} 
    472465 
    473466/** for each element of the source grid, finds all the neighbouring elements that share an edge 
    474   (filling array neighbourElements). This is used later to compute gradients */ 
     467    (filling array neighbourElements). This is used later to compute gradients */ 
    475468void Mapper::buildMeshTopology() 
    476469{ 
    477     int mpiSize, mpiRank; 
    478     MPI_Comm_size(communicator, &mpiSize); 
    479     MPI_Comm_rank(communicator, &mpiRank); 
    480  
    481     vector<Node> *routingList = new vector<Node>[mpiSize]; 
    482     vector<vector<int> > routes(sstree.localTree.leafs.size()); 
    483  
    484     sstree.routeIntersections(routes, sstree.localTree.leafs); 
    485  
    486     for (int i = 0; i < routes.size(); ++i) 
    487         for (int k = 0; k < routes[i].size(); ++k) 
    488             routingList[routes[i][k]].push_back(sstree.localTree.leafs[i]); 
    489     routingList[mpiRank].clear(); 
    490  
    491  
    492     CMPIRouting mpiRoute(communicator); 
    493     mpiRoute.init(routes); 
    494     int nRecv = mpiRoute.getTotalSourceElement(); 
    495  
    496     int *nbSendNode = new int[mpiSize]; 
    497     int *nbRecvNode = new int[mpiSize]; 
    498     int *sendMessageSize = new int[mpiSize]; 
    499     int *recvMessageSize = new int[mpiSize]; 
    500  
    501     for (int rank = 0; rank < mpiSize; rank++) 
    502     { 
    503         nbSendNode[rank] = routingList[rank].size(); 
    504         sendMessageSize[rank] = 0; 
    505         for (size_t j = 0; j < routingList[rank].size(); j++) 
    506         { 
    507             Elt *elt = (Elt *) (routingList[rank][j].data); 
    508             sendMessageSize[rank] += packedPolygonSize(*elt); 
    509         } 
    510     } 
    511  
    512     MPI_Alltoall(nbSendNode, 1, MPI_INT, nbRecvNode, 1, MPI_INT, communicator); 
    513     MPI_Alltoall(sendMessageSize, 1, MPI_INT, recvMessageSize, 1, MPI_INT, communicator); 
    514  
    515     char **sendBuffer = new char*[mpiSize]; 
    516     char **recvBuffer = new char*[mpiSize]; 
    517     int *pos = new int[mpiSize]; 
    518  
    519     for (int rank = 0; rank < mpiSize; rank++) 
    520     { 
    521         if (nbSendNode[rank] > 0) sendBuffer[rank] = new char[sendMessageSize[rank]]; 
    522         if (nbRecvNode[rank] > 0) recvBuffer[rank] = new char[recvMessageSize[rank]]; 
    523     } 
    524  
    525     for (int rank = 0; rank < mpiSize; rank++) 
    526     { 
    527         pos[rank] = 0; 
    528         for (size_t j = 0; j < routingList[rank].size(); j++) 
    529         { 
    530             Elt *elt = (Elt *) (routingList[rank][j].data); 
    531             packPolygon(*elt, sendBuffer[rank], pos[rank]); 
    532         } 
    533     } 
    534     delete [] routingList; 
    535  
    536  
    537     int nbSendRequest = 0; 
    538     int nbRecvRequest = 0; 
    539     MPI_Request *sendRequest = new MPI_Request[mpiSize]; 
    540     MPI_Request *recvRequest = new MPI_Request[mpiSize]; 
    541     MPI_Status  *status      = new MPI_Status[mpiSize]; 
    542  
    543     for (int rank = 0; rank < mpiSize; rank++) 
    544     { 
    545         if (nbSendNode[rank] > 0) 
    546         { 
    547             MPI_Issend(sendBuffer[rank], sendMessageSize[rank], MPI_CHAR, rank, 0, communicator, &sendRequest[nbSendRequest]); 
    548             nbSendRequest++; 
    549         } 
    550         if (nbRecvNode[rank] > 0) 
    551         { 
    552             MPI_Irecv(recvBuffer[rank], recvMessageSize[rank], MPI_CHAR, rank, 0, communicator, &recvRequest[nbRecvRequest]); 
    553             nbRecvRequest++; 
    554         } 
    555     } 
    556      
    557     MPI_Waitall(nbRecvRequest, recvRequest, status); 
    558     MPI_Waitall(nbSendRequest, sendRequest, status); 
    559  
    560     for (int rank = 0; rank < mpiSize; rank++) 
    561         if (nbSendNode[rank] > 0) delete [] sendBuffer[rank]; 
    562     delete [] sendBuffer; 
    563  
    564     char **sendBuffer2 = new char*[mpiSize]; 
    565     char **recvBuffer2 = new char*[mpiSize]; 
    566  
    567     for (int rank = 0; rank < mpiSize; rank++) 
    568     { 
    569         nbSendNode[rank] = 0; 
    570         sendMessageSize[rank] = 0; 
    571  
    572         if (nbRecvNode[rank] > 0) 
    573         { 
    574             set<NodePtr> neighbourList; 
    575             pos[rank] = 0; 
    576             for (int j = 0; j < nbRecvNode[rank]; j++) 
    577             { 
    578                 Elt elt; 
    579                 unpackPolygon(elt, recvBuffer[rank], pos[rank]); 
    580                 Node node(elt.x, cptRadius(elt), &elt); 
    581                 findNeighbour(sstree.localTree.root, &node, neighbourList); 
    582             } 
    583             nbSendNode[rank] = neighbourList.size(); 
    584             for (set<NodePtr>::iterator it = neighbourList.begin(); it != neighbourList.end(); it++) 
    585             { 
    586                 Elt *elt = (Elt *) ((*it)->data); 
    587                 sendMessageSize[rank] += packedPolygonSize(*elt); 
    588             } 
    589  
    590             sendBuffer2[rank] = new char[sendMessageSize[rank]]; 
    591             pos[rank] = 0; 
    592  
    593             for (set<NodePtr>::iterator it = neighbourList.begin(); it != neighbourList.end(); it++) 
    594             { 
    595                 Elt *elt = (Elt *) ((*it)->data); 
    596                 packPolygon(*elt, sendBuffer2[rank], pos[rank]); 
    597             } 
    598         } 
    599     } 
    600     for (int rank = 0; rank < mpiSize; rank++) 
    601         if (nbRecvNode[rank] > 0) delete [] recvBuffer[rank]; 
    602     delete [] recvBuffer; 
    603  
    604  
    605     MPI_Barrier(communicator); 
    606     MPI_Alltoall(nbSendNode, 1, MPI_INT, nbRecvNode, 1, MPI_INT, communicator); 
    607     MPI_Alltoall(sendMessageSize, 1, MPI_INT, recvMessageSize, 1, MPI_INT, communicator); 
    608  
    609     for (int rank = 0; rank < mpiSize; rank++) 
    610         if (nbRecvNode[rank] > 0) recvBuffer2[rank] = new char[recvMessageSize[rank]]; 
    611  
    612     nbSendRequest = 0; 
    613     nbRecvRequest = 0; 
    614  
    615     for (int rank = 0; rank < mpiSize; rank++) 
    616     { 
    617         if (nbSendNode[rank] > 0) 
    618         { 
    619             MPI_Issend(sendBuffer2[rank], sendMessageSize[rank], MPI_CHAR, rank, 0, communicator, &sendRequest[nbSendRequest]); 
    620             nbSendRequest++; 
    621         } 
    622         if (nbRecvNode[rank] > 0) 
    623         { 
    624             MPI_Irecv(recvBuffer2[rank], recvMessageSize[rank], MPI_CHAR, rank, 0, communicator, &recvRequest[nbRecvRequest]); 
    625             nbRecvRequest++; 
    626         } 
    627     } 
    628  
    629     MPI_Waitall(nbRecvRequest, recvRequest, status); 
    630     MPI_Waitall(nbSendRequest, sendRequest, status); 
    631  
    632     int nbNeighbourNodes = 0; 
    633     for (int rank = 0; rank < mpiSize; rank++) 
    634         nbNeighbourNodes += nbRecvNode[rank]; 
    635  
    636     neighbourElements = new Elt[nbNeighbourNodes]; 
    637     nbNeighbourElements = nbNeighbourNodes; 
    638  
    639     int index = 0; 
    640     for (int rank = 0; rank < mpiSize; rank++) 
    641     { 
    642         pos[rank] = 0; 
    643         for (int j = 0; j < nbRecvNode[rank]; j++) 
    644         { 
    645             unpackPolygon(neighbourElements[index], recvBuffer2[rank], pos[rank]); 
    646             neighbourElements[index].id.ind = sstree.localTree.leafs.size() + index; 
    647             index++; 
    648         } 
    649     } 
    650     for (int rank = 0; rank < mpiSize; rank++) 
    651     { 
    652         if (nbRecvNode[rank] > 0) delete [] recvBuffer2[rank]; 
    653         if (nbSendNode[rank] > 0) delete [] sendBuffer2[rank]; 
    654     } 
    655     delete [] recvBuffer2; 
    656     delete [] sendBuffer2; 
    657     delete [] sendMessageSize; 
    658     delete [] recvMessageSize; 
    659     delete [] nbSendNode; 
    660     delete [] nbRecvNode; 
    661     delete [] sendRequest; 
    662     delete [] recvRequest; 
    663     delete [] status; 
    664     delete [] pos; 
    665  
    666     /* re-compute on received elements to avoid having to send this information */ 
    667     neighbourNodes.resize(nbNeighbourNodes); 
    668     setCirclesAndLinks(neighbourElements, neighbourNodes); 
    669     cptAllEltsGeom(neighbourElements, nbNeighbourNodes, srcGrid.pole); 
    670  
    671     /* the local SS tree must include nodes from other cpus if they are potential 
    672        intersector of a local node */ 
    673     sstree.localTree.insertNodes(neighbourNodes); 
    674  
    675     /* for every local element, 
    676        use the SS-tree to find all elements (including neighbourElements) 
    677        who are potential neighbours because their circles intersect, 
    678        then check all canditates for common edges to build up connectivity information 
    679        */ 
    680     for (int j = 0; j < sstree.localTree.leafs.size(); j++) 
    681     { 
    682         Node& node = sstree.localTree.leafs[j]; 
    683  
    684         /* find all leafs whoes circles that intersect node's circle and save into node->intersectors */ 
    685         node.search(sstree.localTree.root); 
    686  
    687         Elt *elt = (Elt *)(node.data); 
    688  
    689         for (int i = 0; i < elt->n; i++) elt->neighbour[i] = NOT_FOUND; 
    690  
    691         /* for element `elt` loop through all nodes in the SS-tree 
    692            whoes circles intersect with the circle around `elt` (the SS intersectors) 
    693            and check if they are neighbours in the sense that the two elements share an edge. 
    694            If they do, save this information for elt */ 
    695         for (list<NodePtr>::iterator it = (node.intersectors).begin(); it != (node.intersectors).end(); ++it) 
    696         { 
    697             Elt *elt2 = (Elt *)((*it)->data); 
    698             set_neighbour(*elt, *elt2); 
    699         } 
    700  
    701     } 
     470        int mpiSize, mpiRank; 
     471        MPI_Comm_size(communicator, &mpiSize); 
     472        MPI_Comm_rank(communicator, &mpiRank); 
     473 
     474        vector<Node> *routingList = new vector<Node>[mpiSize]; 
     475        vector<vector<int> > routes(sstree.localTree.leafs.size()); 
     476 
     477        sstree.routeIntersections(routes, sstree.localTree.leafs); 
     478 
     479        for (int i = 0; i < routes.size(); ++i) 
     480                for (int k = 0; k < routes[i].size(); ++k) 
     481                        routingList[routes[i][k]].push_back(sstree.localTree.leafs[i]); 
     482        routingList[mpiRank].clear(); 
     483 
     484 
     485        CMPIRouting mpiRoute(communicator); 
     486        mpiRoute.init(routes); 
     487        int nRecv = mpiRoute.getTotalSourceElement(); 
     488 
     489        int *nbSendNode = new int[mpiSize]; 
     490        int *nbRecvNode = new int[mpiSize]; 
     491        int *sendMessageSize = new int[mpiSize]; 
     492        int *recvMessageSize = new int[mpiSize]; 
     493 
     494        for (int rank = 0; rank < mpiSize; rank++) 
     495        { 
     496                nbSendNode[rank] = routingList[rank].size(); 
     497                sendMessageSize[rank] = 0; 
     498                for (size_t j = 0; j < routingList[rank].size(); j++) 
     499                { 
     500                        Elt *elt = (Elt *) (routingList[rank][j].data); 
     501                        sendMessageSize[rank] += packedPolygonSize(*elt); 
     502                } 
     503        } 
     504 
     505        MPI_Alltoall(nbSendNode, 1, MPI_INT, nbRecvNode, 1, MPI_INT, communicator); 
     506        MPI_Alltoall(sendMessageSize, 1, MPI_INT, recvMessageSize, 1, MPI_INT, communicator); 
     507 
     508        char **sendBuffer = new char*[mpiSize]; 
     509        char **recvBuffer = new char*[mpiSize]; 
     510        int *pos = new int[mpiSize]; 
     511 
     512        for (int rank = 0; rank < mpiSize; rank++) 
     513        { 
     514                if (nbSendNode[rank] > 0) sendBuffer[rank] = new char[sendMessageSize[rank]]; 
     515                if (nbRecvNode[rank] > 0) recvBuffer[rank] = new char[recvMessageSize[rank]]; 
     516        } 
     517 
     518        for (int rank = 0; rank < mpiSize; rank++) 
     519        { 
     520                pos[rank] = 0; 
     521                for (size_t j = 0; j < routingList[rank].size(); j++) 
     522                { 
     523                        Elt *elt = (Elt *) (routingList[rank][j].data); 
     524                        packPolygon(*elt, sendBuffer[rank], pos[rank]); 
     525                } 
     526        } 
     527        delete [] routingList; 
     528 
     529 
     530        int nbSendRequest = 0; 
     531        int nbRecvRequest = 0; 
     532        MPI_Request *sendRequest = new MPI_Request[mpiSize]; 
     533        MPI_Request *recvRequest = new MPI_Request[mpiSize]; 
     534        MPI_Status  *status      = new MPI_Status[mpiSize]; 
     535 
     536        for (int rank = 0; rank < mpiSize; rank++) 
     537        { 
     538                if (nbSendNode[rank] > 0) 
     539                { 
     540                        MPI_Issend(sendBuffer[rank], sendMessageSize[rank], MPI_CHAR, rank, 0, communicator, &sendRequest[nbSendRequest]); 
     541                        nbSendRequest++; 
     542                } 
     543                if (nbRecvNode[rank] > 0) 
     544                { 
     545                        MPI_Irecv(recvBuffer[rank], recvMessageSize[rank], MPI_CHAR, rank, 0, communicator, &recvRequest[nbRecvRequest]); 
     546                        nbRecvRequest++; 
     547                } 
     548        } 
     549 
     550  MPI_Waitall(nbRecvRequest, recvRequest, status); 
     551  MPI_Waitall(nbSendRequest, sendRequest, status); 
     552 
     553        for (int rank = 0; rank < mpiSize; rank++) 
     554                if (nbSendNode[rank] > 0) delete [] sendBuffer[rank]; 
     555        delete [] sendBuffer; 
     556 
     557        char **sendBuffer2 = new char*[mpiSize]; 
     558        char **recvBuffer2 = new char*[mpiSize]; 
     559 
     560        for (int rank = 0; rank < mpiSize; rank++) 
     561        { 
     562                nbSendNode[rank] = 0; 
     563                sendMessageSize[rank] = 0; 
     564 
     565                if (nbRecvNode[rank] > 0) 
     566                { 
     567                        set<NodePtr> neighbourList; 
     568                        pos[rank] = 0; 
     569                        for (int j = 0; j < nbRecvNode[rank]; j++) 
     570                        { 
     571                                Elt elt; 
     572                                unpackPolygon(elt, recvBuffer[rank], pos[rank]); 
     573                                Node node(elt.x, cptRadius(elt), &elt); 
     574                                findNeighbour(sstree.localTree.root, &node, neighbourList); 
     575                        } 
     576                        nbSendNode[rank] = neighbourList.size(); 
     577                        for (set<NodePtr>::iterator it = neighbourList.begin(); it != neighbourList.end(); it++) 
     578                        { 
     579                                Elt *elt = (Elt *) ((*it)->data); 
     580                                sendMessageSize[rank] += packedPolygonSize(*elt); 
     581                        } 
     582 
     583                        sendBuffer2[rank] = new char[sendMessageSize[rank]]; 
     584                        pos[rank] = 0; 
     585 
     586                        for (set<NodePtr>::iterator it = neighbourList.begin(); it != neighbourList.end(); it++) 
     587                        { 
     588                                Elt *elt = (Elt *) ((*it)->data); 
     589                                packPolygon(*elt, sendBuffer2[rank], pos[rank]); 
     590                        } 
     591                } 
     592        } 
     593        for (int rank = 0; rank < mpiSize; rank++) 
     594                if (nbRecvNode[rank] > 0) delete [] recvBuffer[rank]; 
     595        delete [] recvBuffer; 
     596 
     597 
     598        MPI_Barrier(communicator); 
     599        MPI_Alltoall(nbSendNode, 1, MPI_INT, nbRecvNode, 1, MPI_INT, communicator); 
     600        MPI_Alltoall(sendMessageSize, 1, MPI_INT, recvMessageSize, 1, MPI_INT, communicator); 
     601 
     602        for (int rank = 0; rank < mpiSize; rank++) 
     603                if (nbRecvNode[rank] > 0) recvBuffer2[rank] = new char[recvMessageSize[rank]]; 
     604 
     605        nbSendRequest = 0; 
     606        nbRecvRequest = 0; 
     607 
     608        for (int rank = 0; rank < mpiSize; rank++) 
     609        { 
     610                if (nbSendNode[rank] > 0) 
     611                { 
     612                        MPI_Issend(sendBuffer2[rank], sendMessageSize[rank], MPI_CHAR, rank, 0, communicator, &sendRequest[nbSendRequest]); 
     613                        nbSendRequest++; 
     614                } 
     615                if (nbRecvNode[rank] > 0) 
     616                { 
     617                        MPI_Irecv(recvBuffer2[rank], recvMessageSize[rank], MPI_CHAR, rank, 0, communicator, &recvRequest[nbRecvRequest]); 
     618                        nbRecvRequest++; 
     619                } 
     620        } 
     621 
     622        MPI_Waitall(nbRecvRequest, recvRequest, status); 
     623        MPI_Waitall(nbSendRequest, sendRequest, status); 
     624 
     625        int nbNeighbourNodes = 0; 
     626        for (int rank = 0; rank < mpiSize; rank++) 
     627                nbNeighbourNodes += nbRecvNode[rank]; 
     628 
     629        neighbourElements = new Elt[nbNeighbourNodes]; 
     630        nbNeighbourElements = nbNeighbourNodes; 
     631 
     632        int index = 0; 
     633        for (int rank = 0; rank < mpiSize; rank++) 
     634        { 
     635                pos[rank] = 0; 
     636                for (int j = 0; j < nbRecvNode[rank]; j++) 
     637                { 
     638                        unpackPolygon(neighbourElements[index], recvBuffer2[rank], pos[rank]); 
     639                        neighbourElements[index].id.ind = sstree.localTree.leafs.size() + index; 
     640                        index++; 
     641                } 
     642        } 
     643        for (int rank = 0; rank < mpiSize; rank++) 
     644        { 
     645                if (nbRecvNode[rank] > 0) delete [] recvBuffer2[rank]; 
     646                if (nbSendNode[rank] > 0) delete [] sendBuffer2[rank]; 
     647        } 
     648        delete [] recvBuffer2; 
     649        delete [] sendBuffer2; 
     650        delete [] sendMessageSize; 
     651        delete [] recvMessageSize; 
     652        delete [] nbSendNode; 
     653        delete [] nbRecvNode; 
     654        delete [] sendRequest; 
     655        delete [] recvRequest; 
     656        delete [] status; 
     657        delete [] pos; 
     658 
     659        /* re-compute on received elements to avoid having to send this information */ 
     660        neighbourNodes.resize(nbNeighbourNodes); 
     661        setCirclesAndLinks(neighbourElements, neighbourNodes); 
     662        cptAllEltsGeom(neighbourElements, nbNeighbourNodes, srcGrid.pole); 
     663 
     664        /* the local SS tree must include nodes from other cpus if they are potential 
     665           intersector of a local node */ 
     666        sstree.localTree.insertNodes(neighbourNodes); 
     667 
     668        /* for every local element, 
     669           use the SS-tree to find all elements (including neighbourElements) 
     670           who are potential neighbours because their circles intersect, 
     671           then check all canditates for common edges to build up connectivity information 
     672        */ 
     673        for (int j = 0; j < sstree.localTree.leafs.size(); j++) 
     674        { 
     675                Node& node = sstree.localTree.leafs[j]; 
     676 
     677                /* find all leafs whoes circles that intersect node's circle and save into node->intersectors */ 
     678                node.search(sstree.localTree.root); 
     679 
     680                Elt *elt = (Elt *)(node.data); 
     681 
     682                for (int i = 0; i < elt->n; i++) elt->neighbour[i] = NOT_FOUND; 
     683 
     684                /* for element `elt` loop through all nodes in the SS-tree 
     685                   whoes circles intersect with the circle around `elt` (the SS intersectors) 
     686                   and check if they are neighbours in the sense that the two elements share an edge. 
     687                   If they do, save this information for elt */ 
     688                for (list<NodePtr>::iterator it = (node.intersectors).begin(); it != (node.intersectors).end(); ++it) 
     689                { 
     690                        Elt *elt2 = (Elt *)((*it)->data); 
     691                        set_neighbour(*elt, *elt2); 
     692                } 
     693 
     694        } 
    702695} 
    703696 
     
    705698void Mapper::computeIntersection(Elt *elements, int nbElements) 
    706699{ 
    707     int mpiSize, mpiRank; 
    708     MPI_Comm_size(communicator, &mpiSize); 
    709     MPI_Comm_rank(communicator, &mpiRank); 
    710  
    711     MPI_Barrier(communicator); 
    712  
    713     vector<Node> *routingList = new vector<Node>[mpiSize]; 
    714  
    715     vector<Node> routeNodes;  routeNodes.reserve(nbElements); 
    716     for (int j = 0; j < nbElements; j++) 
    717     { 
    718         elements[j].id.ind = j; 
    719         elements[j].id.rank = mpiRank; 
    720         routeNodes.push_back(Node(elements[j].x, cptRadius(elements[j]), &elements[j])); 
    721     } 
    722  
    723     vector<vector<int> > routes(routeNodes.size()); 
    724     sstree.routeIntersections(routes, routeNodes); 
    725     for (int i = 0; i < routes.size(); ++i) 
    726         for (int k = 0; k < routes[i].size(); ++k) 
    727             routingList[routes[i][k]].push_back(routeNodes[i]); 
    728  
    729     if (verbose >= 2) 
    730     { 
    731         cout << " --> rank  " << mpiRank << " nbElements " << nbElements << " : "; 
    732         for (int rank = 0; rank < mpiSize; rank++) 
    733             cout << routingList[rank].size() << "   "; 
    734         cout << endl; 
    735     } 
    736     MPI_Barrier(communicator); 
    737  
    738     int *nbSendNode = new int[mpiSize]; 
    739     int *nbRecvNode = new int[mpiSize]; 
    740     int *sentMessageSize = new int[mpiSize]; 
    741     int *recvMessageSize = new int[mpiSize]; 
    742  
    743     for (int rank = 0; rank < mpiSize; rank++) 
    744     { 
    745         nbSendNode[rank] = routingList[rank].size(); 
    746         sentMessageSize[rank] = 0; 
    747         for (size_t j = 0; j < routingList[rank].size(); j++) 
    748         { 
    749             Elt *elt = (Elt *) (routingList[rank][j].data); 
    750             sentMessageSize[rank] += packedPolygonSize(*elt); 
    751         } 
    752     } 
    753  
    754     MPI_Alltoall(nbSendNode, 1, MPI_INT, nbRecvNode, 1, MPI_INT, communicator); 
    755     MPI_Alltoall(sentMessageSize, 1, MPI_INT, recvMessageSize, 1, MPI_INT, communicator); 
    756  
    757     int total = 0; 
    758  
    759     for (int rank = 0; rank < mpiSize; rank++) 
    760     { 
    761         total = total + nbRecvNode[rank]; 
    762     } 
    763  
    764     if (verbose >= 2) cout << "---> rank " << mpiRank << " : compute intersection : total received nodes  " << total << endl; 
    765     char **sendBuffer = new char*[mpiSize]; 
    766     char **recvBuffer = new char*[mpiSize]; 
    767     int *pos = new int[mpiSize]; 
    768  
    769     for (int rank = 0; rank < mpiSize; rank++) 
    770     { 
    771         if (nbSendNode[rank] > 0) sendBuffer[rank] = new char[sentMessageSize[rank]]; 
    772         if (nbRecvNode[rank] > 0) recvBuffer[rank] = new char[recvMessageSize[rank]]; 
    773     } 
    774  
    775     for (int rank = 0; rank < mpiSize; rank++) 
    776     { 
    777         pos[rank] = 0; 
    778         for (size_t j = 0; j < routingList[rank].size(); j++) 
    779         { 
    780             Elt* elt = (Elt *) (routingList[rank][j].data); 
    781             packPolygon(*elt, sendBuffer[rank], pos[rank]); 
    782         } 
    783     } 
    784     delete [] routingList; 
    785  
    786     int nbSendRequest = 0; 
    787     int nbRecvRequest = 0; 
    788     MPI_Request *sendRequest = new MPI_Request[mpiSize]; 
    789     MPI_Request *recvRequest = new MPI_Request[mpiSize]; 
    790     MPI_Status   *status = new MPI_Status[mpiSize]; 
    791  
    792     for (int rank = 0; rank < mpiSize; rank++) 
    793     { 
    794         if (nbSendNode[rank] > 0) 
    795         { 
    796             MPI_Issend(sendBuffer[rank], sentMessageSize[rank], MPI_CHAR, rank, 0, communicator, &sendRequest[nbSendRequest]); 
    797             nbSendRequest++; 
    798         } 
    799         if (nbRecvNode[rank] > 0) 
    800         { 
    801             MPI_Irecv(recvBuffer[rank], recvMessageSize[rank], MPI_CHAR, rank, 0, communicator, &recvRequest[nbRecvRequest]); 
    802             nbRecvRequest++; 
    803         } 
    804     } 
    805  
    806     MPI_Waitall(nbRecvRequest, recvRequest, status); 
    807     MPI_Waitall(nbSendRequest, sendRequest, status); 
    808  
    809     char **sendBuffer2 = new char*[mpiSize]; 
    810     char **recvBuffer2 = new char*[mpiSize]; 
    811  
    812     double tic = cputime(); 
    813     for (int rank = 0; rank < mpiSize; rank++) 
    814     { 
    815         sentMessageSize[rank] = 0; 
    816  
    817         if (nbRecvNode[rank] > 0) 
    818         { 
    819             Elt *recvElt = new Elt[nbRecvNode[rank]]; 
    820             pos[rank] = 0; 
    821             for (int j = 0; j < nbRecvNode[rank]; j++) 
    822             { 
    823                 unpackPolygon(recvElt[j], recvBuffer[rank], pos[rank]); 
    824                 cptEltGeom(recvElt[j], tgtGrid.pole); 
    825                 Node recvNode(recvElt[j].x, cptRadius(recvElt[j]), &recvElt[j]); 
    826                 recvNode.search(sstree.localTree.root); 
    827                 /* for a node holding an element of the target, loop throught candidates for intersecting source */ 
    828                 for (list<NodePtr>::iterator it = (recvNode.intersectors).begin(); it != (recvNode.intersectors).end(); ++it) 
    829                 { 
    830                     Elt *elt2 = (Elt *) ((*it)->data); 
    831                     /* recvElt is target, elt2 is source */ 
    832                     intersect(&recvElt[j], elt2); 
    833                     //intersect_ym(&recvElt[j], elt2); 
    834                 } 
    835                 if (recvElt[j].is.size() > 0) sentMessageSize[rank] += packIntersectionSize(recvElt[j]); 
    836  
    837                 // here recvNode goes out of scope 
    838             } 
    839  
    840             if (sentMessageSize[rank] > 0) 
    841             { 
    842                 sentMessageSize[rank] += sizeof(int); 
    843                 sendBuffer2[rank] = new char[sentMessageSize[rank]]; 
    844                 *((int *) sendBuffer2[rank]) = 0; 
    845                 pos[rank] = sizeof(int); 
    846                 for (int j = 0; j < nbRecvNode[rank]; j++) 
    847                 { 
    848                     packIntersection(recvElt[j], sendBuffer2[rank], pos[rank]); 
    849                     //FIXME should be deleted: recvElt[j].delete_intersections(); // intersection areas have been packed to buffer and won't be used any more 
    850                 } 
    851             } 
    852             delete [] recvElt; 
    853         } 
    854     } 
    855     delete [] pos; 
    856  
    857     for (int rank = 0; rank < mpiSize; rank++) 
    858     { 
    859         if (nbSendNode[rank] > 0) delete [] sendBuffer[rank]; 
    860         if (nbRecvNode[rank] > 0) delete [] recvBuffer[rank]; 
    861         nbSendNode[rank] = 0; 
    862     } 
    863  
    864     if (verbose >= 2) cout << "Rank " << mpiRank << "  Compute (internal) intersection " << cputime() - tic << " s" << endl; 
    865     MPI_Alltoall(sentMessageSize, 1, MPI_INT, recvMessageSize, 1, MPI_INT, communicator); 
    866  
    867     for (int rank = 0; rank < mpiSize; rank++) 
    868         if (recvMessageSize[rank] > 0) 
    869             recvBuffer2[rank] = new char[recvMessageSize[rank]]; 
    870  
    871     nbSendRequest = 0; 
    872     nbRecvRequest = 0; 
    873  
    874     for (int rank = 0; rank < mpiSize; rank++) 
    875     { 
    876         if (sentMessageSize[rank] > 0) 
    877         { 
    878             MPI_Issend(sendBuffer2[rank], sentMessageSize[rank], MPI_CHAR, rank, 0, communicator, &sendRequest[nbSendRequest]); 
    879             nbSendRequest++; 
    880         } 
    881         if (recvMessageSize[rank] > 0) 
    882         { 
    883             MPI_Irecv(recvBuffer2[rank], recvMessageSize[rank], MPI_CHAR, rank, 0, communicator, &recvRequest[nbRecvRequest]); 
    884             nbRecvRequest++; 
    885         } 
    886     } 
    887      
    888     MPI_Waitall(nbRecvRequest, recvRequest, status); 
    889     MPI_Waitall(nbSendRequest, sendRequest, status); 
    890  
    891     delete [] sendRequest; 
    892     delete [] recvRequest; 
    893     delete [] status; 
    894     for (int rank = 0; rank < mpiSize; rank++) 
    895     { 
    896         if (nbRecvNode[rank] > 0) 
    897         { 
    898             if (sentMessageSize[rank] > 0) 
    899                 delete [] sendBuffer2[rank]; 
    900         } 
    901  
    902         if (recvMessageSize[rank] > 0) 
    903         { 
    904             unpackIntersection(elements, recvBuffer2[rank]); 
    905             delete [] recvBuffer2[rank]; 
    906         } 
    907     } 
    908     delete [] sendBuffer2; 
    909     delete [] recvBuffer2; 
    910     delete [] sendBuffer; 
    911     delete [] recvBuffer; 
    912  
    913     delete [] nbSendNode; 
    914     delete [] nbRecvNode; 
    915     delete [] sentMessageSize; 
    916     delete [] recvMessageSize; 
     700        int mpiSize, mpiRank; 
     701        MPI_Comm_size(communicator, &mpiSize); 
     702        MPI_Comm_rank(communicator, &mpiRank); 
     703 
     704        MPI_Barrier(communicator); 
     705 
     706        vector<Node> *routingList = new vector<Node>[mpiSize]; 
     707 
     708        vector<Node> routeNodes;  routeNodes.reserve(nbElements); 
     709        for (int j = 0; j < nbElements; j++) 
     710        { 
     711                elements[j].id.ind = j; 
     712                elements[j].id.rank = mpiRank; 
     713                routeNodes.push_back(Node(elements[j].x, cptRadius(elements[j]), &elements[j])); 
     714        } 
     715 
     716        vector<vector<int> > routes(routeNodes.size()); 
     717        sstree.routeIntersections(routes, routeNodes); 
     718        for (int i = 0; i < routes.size(); ++i) 
     719                for (int k = 0; k < routes[i].size(); ++k) 
     720                        routingList[routes[i][k]].push_back(routeNodes[i]); 
     721 
     722        if (verbose >= 2) 
     723        { 
     724                cout << " --> rank  " << mpiRank << " nbElements " << nbElements << " : "; 
     725                for (int rank = 0; rank < mpiSize; rank++) 
     726                        cout << routingList[rank].size() << "   "; 
     727                cout << endl; 
     728        } 
     729        MPI_Barrier(communicator); 
     730 
     731        int *nbSendNode = new int[mpiSize]; 
     732        int *nbRecvNode = new int[mpiSize]; 
     733        int *sentMessageSize = new int[mpiSize]; 
     734        int *recvMessageSize = new int[mpiSize]; 
     735 
     736        for (int rank = 0; rank < mpiSize; rank++) 
     737        { 
     738                nbSendNode[rank] = routingList[rank].size(); 
     739                sentMessageSize[rank] = 0; 
     740                for (size_t j = 0; j < routingList[rank].size(); j++) 
     741                { 
     742                        Elt *elt = (Elt *) (routingList[rank][j].data); 
     743                        sentMessageSize[rank] += packedPolygonSize(*elt); 
     744                } 
     745        } 
     746 
     747        MPI_Alltoall(nbSendNode, 1, MPI_INT, nbRecvNode, 1, MPI_INT, communicator); 
     748        MPI_Alltoall(sentMessageSize, 1, MPI_INT, recvMessageSize, 1, MPI_INT, communicator); 
     749 
     750        int total = 0; 
     751 
     752        for (int rank = 0; rank < mpiSize; rank++) 
     753        { 
     754                total = total + nbRecvNode[rank]; 
     755        } 
     756 
     757        if (verbose >= 2) cout << "---> rank " << mpiRank << " : compute intersection : total received nodes  " << total << endl; 
     758        char **sendBuffer = new char*[mpiSize]; 
     759        char **recvBuffer = new char*[mpiSize]; 
     760        int *pos = new int[mpiSize]; 
     761 
     762        for (int rank = 0; rank < mpiSize; rank++) 
     763        { 
     764                if (nbSendNode[rank] > 0) sendBuffer[rank] = new char[sentMessageSize[rank]]; 
     765                if (nbRecvNode[rank] > 0) recvBuffer[rank] = new char[recvMessageSize[rank]]; 
     766        } 
     767 
     768        for (int rank = 0; rank < mpiSize; rank++) 
     769        { 
     770                pos[rank] = 0; 
     771                for (size_t j = 0; j < routingList[rank].size(); j++) 
     772                { 
     773                        Elt* elt = (Elt *) (routingList[rank][j].data); 
     774                        packPolygon(*elt, sendBuffer[rank], pos[rank]); 
     775                } 
     776        } 
     777        delete [] routingList; 
     778 
     779        int nbSendRequest = 0; 
     780        int nbRecvRequest = 0; 
     781        MPI_Request *sendRequest = new MPI_Request[mpiSize]; 
     782        MPI_Request *recvRequest = new MPI_Request[mpiSize]; 
     783        MPI_Status   *status = new MPI_Status[mpiSize]; 
     784 
     785        for (int rank = 0; rank < mpiSize; rank++) 
     786        { 
     787                if (nbSendNode[rank] > 0) 
     788                { 
     789                        MPI_Issend(sendBuffer[rank], sentMessageSize[rank], MPI_CHAR, rank, 0, communicator, &sendRequest[nbSendRequest]); 
     790                        nbSendRequest++; 
     791                } 
     792                if (nbRecvNode[rank] > 0) 
     793                { 
     794                        MPI_Irecv(recvBuffer[rank], recvMessageSize[rank], MPI_CHAR, rank, 0, communicator, &recvRequest[nbRecvRequest]); 
     795                        nbRecvRequest++; 
     796                } 
     797        } 
     798 
     799        MPI_Waitall(nbRecvRequest, recvRequest, status); 
     800        MPI_Waitall(nbSendRequest, sendRequest, status); 
     801 
     802        char **sendBuffer2 = new char*[mpiSize]; 
     803        char **recvBuffer2 = new char*[mpiSize]; 
     804 
     805        double tic = cputime(); 
     806        for (int rank = 0; rank < mpiSize; rank++) 
     807        { 
     808                sentMessageSize[rank] = 0; 
     809 
     810                if (nbRecvNode[rank] > 0) 
     811                { 
     812                        Elt *recvElt = new Elt[nbRecvNode[rank]]; 
     813                        pos[rank] = 0; 
     814                        for (int j = 0; j < nbRecvNode[rank]; j++) 
     815                        { 
     816                                unpackPolygon(recvElt[j], recvBuffer[rank], pos[rank]); 
     817                                cptEltGeom(recvElt[j], tgtGrid.pole); 
     818                                Node recvNode(recvElt[j].x, cptRadius(recvElt[j]), &recvElt[j]); 
     819                                recvNode.search(sstree.localTree.root); 
     820                                /* for a node holding an element of the target, loop throught candidates for intersecting source */ 
     821                                for (list<NodePtr>::iterator it = (recvNode.intersectors).begin(); it != (recvNode.intersectors).end(); ++it) 
     822                                { 
     823                                        Elt *elt2 = (Elt *) ((*it)->data); 
     824                                        /* recvElt is target, elt2 is source */ 
     825//                                      intersect(&recvElt[j], elt2); 
     826                                        intersect_ym(&recvElt[j], elt2); 
     827                                } 
     828                                if (recvElt[j].is.size() > 0) sentMessageSize[rank] += packIntersectionSize(recvElt[j]); 
     829 
     830                                // here recvNode goes out of scope 
     831                        } 
     832 
     833                        if (sentMessageSize[rank] > 0) 
     834                        { 
     835                                sentMessageSize[rank] += sizeof(int); 
     836                                sendBuffer2[rank] = new char[sentMessageSize[rank]]; 
     837                                *((int *) sendBuffer2[rank]) = 0; 
     838                                pos[rank] = sizeof(int); 
     839                                for (int j = 0; j < nbRecvNode[rank]; j++) 
     840                                { 
     841                                        packIntersection(recvElt[j], sendBuffer2[rank], pos[rank]); 
     842                                        //FIXME should be deleted: recvElt[j].delete_intersections(); // intersection areas have been packed to buffer and won't be used any more 
     843                                } 
     844                        } 
     845                        delete [] recvElt; 
     846                } 
     847        } 
     848        delete [] pos; 
     849 
     850        for (int rank = 0; rank < mpiSize; rank++) 
     851        { 
     852                if (nbSendNode[rank] > 0) delete [] sendBuffer[rank]; 
     853                if (nbRecvNode[rank] > 0) delete [] recvBuffer[rank]; 
     854                nbSendNode[rank] = 0; 
     855        } 
     856 
     857        if (verbose >= 2) cout << "Rank " << mpiRank << "  Compute (internal) intersection " << cputime() - tic << " s" << endl; 
     858        MPI_Alltoall(sentMessageSize, 1, MPI_INT, recvMessageSize, 1, MPI_INT, communicator); 
     859 
     860        for (int rank = 0; rank < mpiSize; rank++) 
     861                if (recvMessageSize[rank] > 0) 
     862                        recvBuffer2[rank] = new char[recvMessageSize[rank]]; 
     863 
     864        nbSendRequest = 0; 
     865        nbRecvRequest = 0; 
     866 
     867        for (int rank = 0; rank < mpiSize; rank++) 
     868        { 
     869                if (sentMessageSize[rank] > 0) 
     870                { 
     871                        MPI_Issend(sendBuffer2[rank], sentMessageSize[rank], MPI_CHAR, rank, 0, communicator, &sendRequest[nbSendRequest]); 
     872                        nbSendRequest++; 
     873                } 
     874                if (recvMessageSize[rank] > 0) 
     875                { 
     876                        MPI_Irecv(recvBuffer2[rank], recvMessageSize[rank], MPI_CHAR, rank, 0, communicator, &recvRequest[nbRecvRequest]); 
     877                        nbRecvRequest++; 
     878                } 
     879        } 
     880 
     881  MPI_Waitall(nbRecvRequest, recvRequest, status); 
     882  MPI_Waitall(nbSendRequest, sendRequest, status); 
     883 
     884        delete [] sendRequest; 
     885        delete [] recvRequest; 
     886        delete [] status; 
     887        for (int rank = 0; rank < mpiSize; rank++) 
     888        { 
     889                if (nbRecvNode[rank] > 0) 
     890                { 
     891                        if (sentMessageSize[rank] > 0) 
     892                                delete [] sendBuffer2[rank]; 
     893                } 
     894 
     895                if (recvMessageSize[rank] > 0) 
     896                { 
     897                        unpackIntersection(elements, recvBuffer2[rank]); 
     898                        delete [] recvBuffer2[rank]; 
     899                } 
     900        } 
     901        delete [] sendBuffer2; 
     902        delete [] recvBuffer2; 
     903        delete [] sendBuffer; 
     904        delete [] recvBuffer; 
     905 
     906        delete [] nbSendNode; 
     907        delete [] nbRecvNode; 
     908        delete [] sentMessageSize; 
     909        delete [] recvMessageSize; 
    917910} 
    918911 
    919912Mapper::~Mapper() 
    920913{ 
    921     delete [] remapMatrix; 
    922     delete [] srcAddress; 
    923     delete [] srcRank; 
    924     delete [] dstAddress; 
    925     if (neighbourElements) delete [] neighbourElements; 
    926 } 
    927  
    928 } 
     914        delete [] remapMatrix; 
     915        delete [] srcAddress; 
     916        delete [] srcRank; 
     917        delete [] dstAddress; 
     918        if (neighbourElements) delete [] neighbourElements; 
     919} 
     920 
     921} 
  • XIOS/dev/branch_openmp/extern/remap/src/mapper.hpp

    r1134 r1328  
    33#include "parallel_tree.hpp" 
    44#include "mpi.hpp" 
    5  
    6 #ifdef _usingEP 
    7 #include "ep_declaration.hpp" 
    8 #endif 
    95 
    106namespace sphereRemap { 
     
    2218{ 
    2319public: 
    24        Mapper(ep_lib::MPI_Comm comm=MPI_COMM_WORLD) : communicator(comm), verbose(SILENT), neighbourElements(NULL), sstree(comm) {} 
     20       Mapper(ep_lib::MPI_Comm comm) : communicator(comm), verbose(SILENT), neighbourElements(NULL), sstree(comm) {} 
    2521       ~Mapper(); 
    2622       void setVerbosity(verbosity v) {verbose=v ;} 
  • XIOS/dev/branch_openmp/extern/remap/src/mpi_cascade.cpp

    r688 r1328  
    11#include "mpi_cascade.hpp" 
    22#include <iostream> 
     3using namespace ep_lib; 
    34 
    45namespace sphereRemap { 
  • XIOS/dev/branch_openmp/extern/remap/src/mpi_cascade.hpp

    r694 r1328  
    1212{ 
    1313public: 
    14         CCascadeLevel(MPI_Comm comm) : comm(comm) 
    15         { 
    16                 MPI_Comm_size(comm, &size); 
    17                 MPI_Comm_rank(comm, &rank); 
    18         } 
    19         int colour() const { return rank % group_size; }; 
    20         int key() const { return p_colour() + rank/(p_grp_size*group_size)*p_grp_size; } 
     14  CCascadeLevel(ep_lib::MPI_Comm comm) : comm(comm) 
     15  { 
     16    ep_lib::MPI_Comm_size(comm, &size); 
     17    ep_lib::MPI_Comm_rank(comm, &rank); 
     18  } 
     19  int colour() const { return rank % group_size; }; 
     20  int key() const { return p_colour() + rank/(p_grp_size*group_size)*p_grp_size; } 
    2121 
    22         // perpendicular group 
    23         int p_colour() const { return (rank%group_size + rank/group_size) % p_grp_size; } 
    24         int p_key() const { return colour() + rank/(p_grp_size*group_size)*group_size; } 
     22  // perpendicular group 
     23  int p_colour() const { return (rank%group_size + rank/group_size) % p_grp_size; } 
     24  int p_key() const { return colour() + rank/(p_grp_size*group_size)*group_size; } 
    2525 
    26         MPI_Comm comm, pg_comm; 
    27         int rank; 
    28         int size; 
    29         int group_size; // group_size and p_grp_size are interchanged?? FIXME 
    30         int p_grp_size; 
     26  ep_lib::MPI_Comm comm, pg_comm; 
     27  int rank; 
     28  int size; 
     29  int group_size; // group_size and p_grp_size are interchanged?? FIXME 
     30  int p_grp_size; 
    3131}; 
    3232 
     
    3434{ 
    3535public: 
    36         //  
    37         CMPICascade(int nodes_per_level, MPI_Comm comm); 
     36  CMPICascade(int nodes_per_level, ep_lib::MPI_Comm comm); 
    3837 
    39         int num_levels; 
    40         std::vector<CCascadeLevel> level; 
     38  int num_levels; 
     39  std::vector<CCascadeLevel> level; 
    4140}; 
    4241 
  • XIOS/dev/branch_openmp/extern/remap/src/mpi_routing.cpp

    r1289 r1328  
    55#include "timerRemap.hpp" 
    66#include <iostream> 
    7 #ifdef _usingEP 
    8 #include "ep_declaration.hpp" 
    9 #endif 
     7using namespace ep_lib; 
    108 
    119namespace sphereRemap { 
     
    125123        CTimer::get("CMPIRouting::init(reduce_scatter)").print(); 
    126124 
    127         MPI_Info info_null; 
    128  
    129         // MPI_Alloc_mem(nbTarget *sizeof(int), info_null, &targetRank); 
    130         // MPI_Alloc_mem(nbSource *sizeof(int), info_null, &sourceRank); 
    131125        MPI_Alloc_mem(nbTarget *sizeof(int), MPI_INFO_NULL, &targetRank); 
    132126        MPI_Alloc_mem(nbSource *sizeof(int), MPI_INFO_NULL, &sourceRank); 
     
    158152        { 
    159153                #ifdef _usingEP 
    160                 MPI_Irecv(&sourceRank[i], 1, MPI_INT, -1, 0, communicator, &request[indexRequest]); 
     154                MPI_Irecv(&sourceRank[i], 1, MPI_INT, -2, 0, communicator, &request[indexRequest]); 
    161155                #else 
    162156                MPI_Irecv(&sourceRank[i], 1, MPI_INT, MPI_ANY_SOURCE, 0, communicator, &request[indexRequest]); 
     
    182176        { 
    183177                #ifdef _usingEP 
    184                 MPI_Irecv(&sourceRank[i], 1, MPI_INT, -1, 0, communicator, &request[indexRequest]); 
     178                MPI_Irecv(&sourceRank[i], 1, MPI_INT, -2, 0, communicator, &request[indexRequest]); 
    185179                #else 
    186180                MPI_Irecv(&sourceRank[i], 1, MPI_INT, MPI_ANY_SOURCE, 0, communicator, &request[indexRequest]); 
  • XIOS/dev/branch_openmp/extern/remap/src/mpi_routing.hpp

    r694 r1328  
    1111{ 
    1212 
    13         MPI_Comm communicator; 
     13        ep_lib::MPI_Comm communicator; 
    1414        int mpiRank; 
    1515        int mpiSize; 
     
    2929 
    3030public: 
    31         CMPIRouting(MPI_Comm comm); 
     31        CMPIRouting(ep_lib::MPI_Comm comm); 
    3232        ~CMPIRouting(); 
    3333        template<typename T> void init(const std::vector<T>& route, CMPICascade *cascade = NULL); 
     
    4444template <typename T> 
    4545void alltoalls_known(const std::vector<std::vector<T> >& send, std::vector<std::vector<T> >& recv, 
    46                      const std::vector<int>& ranks, MPI_Comm communicator); 
     46                     const std::vector<int>& ranks, ep_lib::MPI_Comm communicator); 
    4747 
    4848template <typename T> 
    4949void alltoalls_unknown(const std::vector<std::vector<T> >& send, std::vector<std::vector<T> >& recv, 
    50                        const std::vector<int>& ranks, MPI_Comm communicator); 
     50                       const std::vector<int>& ranks, ep_lib::MPI_Comm communicator); 
    5151} 
    5252#endif 
  • XIOS/dev/branch_openmp/extern/remap/src/node.cpp

    r1205 r1328  
    254254NodePtr insert(NodePtr thIs, NodePtr node) 
    255255{ 
    256   int la = thIs->level; // node to be inserted 
    257   int lb = node->level; // node where insertation 
    258   assert(la < lb); // node to be inserted must have lower level then parent 
    259   //if (thIs->parent) assert(find_in_tree1(thIs) == true); 
    260   NodePtr q = NULL; 
    261   NodePtr chd = NULL; 
    262   node->move(thIs); 
    263   if (la == lb - 1) 
    264   { 
     256        int la = thIs->level; // node to be inserted 
     257        int lb = node->level; // node where insertation 
     258        assert(la < lb); // node to be inserted must have lower level then parent 
     259        //if (thIs->parent) assert(find_in_tree1(thIs) == true); 
     260        NodePtr q = NULL; 
     261        NodePtr chd = NULL; 
     262        node->move(thIs); 
     263        if (la == lb - 1) 
     264        { 
    265265    node->child.push_back(thIs); 
    266     thIs->parent = node; 
    267     if (node->child.size() > MAX_NODE_SZ &&  node->tree->canSplit() ) // with us as additional child `node` is now too large :( 
    268     return (node->reinserted || node->parent == NULL) ? split(node) : reinsert(node); 
    269   } 
    270   else // la < lb - 1 
    271   { 
    272     chd = thIs->closest(node->child); 
    273     q = insert(thIs, chd); 
    274   } 
    275   if ((node->updateCount + 1) % UPDATE_EVERY == 0) 
    276     node->update(); 
    277   else 
    278   { 
    279     if (q) node->remove(q); 
    280     node->inflate(chd); 
    281   } 
     266                thIs->parent = node; 
     267                if (node->child.size() > MAX_NODE_SZ &&  node->tree->canSplit() ) // with us as additional child `node` is now too large :( 
     268                        return (node->reinserted || node->parent == NULL) ? split(node) : reinsert(node); 
     269        } 
     270        else // la < lb - 1 
     271        { 
     272                chd = thIs->closest(node->child); 
     273                q = insert(thIs, chd); 
     274        } 
     275        if ((node->updateCount + 1) % UPDATE_EVERY == 0) 
     276                node->update(); 
     277        else 
     278        { 
     279                if (q) node->remove(q); 
     280                node->inflate(chd); 
     281        } 
    282282 
    283283  return q; 
  • XIOS/dev/branch_openmp/extern/remap/src/node.hpp

    r1153 r1328  
    1515struct Circle 
    1616{ 
    17   Coord centre; 
    18   double radius; 
     17        Coord centre; 
     18        double radius; 
    1919}; 
    2020 
     
    116116struct Node 
    117117{ 
    118   int level; /* FIXME leafs are 0 and root is max level? */ 
    119   int leafCount; /* number of leafs that are descendants of this node (the elements in it's cycle) */ 
    120   Coord centre; 
    121   double radius; 
    122   NodePtr parent, ref; 
    123   std::vector<NodePtr> child; 
    124   std::list<NodePtr> intersectors; 
    125   bool reinserted; 
    126   int updateCount;  // double var; 
    127   CBasicTree* tree; 
    128   void *data; 
    129   int route; 
     118        int level; /* FIXME leafs are 0 and root is max level? */ 
     119        int leafCount; /* number of leafs that are descendants of this node (the elements in it's cycle) */ 
     120        Coord centre; 
     121        double radius; 
     122        NodePtr parent, ref; 
     123        std::vector<NodePtr> child; 
     124        std::list<NodePtr> intersectors; 
     125        bool reinserted; 
     126        int updateCount;  // double var; 
     127        CBasicTree* tree; 
     128        void *data; 
     129        int route; 
    130130  bool toDelete ; 
    131131 
    132   Node() : level(0), leafCount(1), centre(ORIGIN), radius(0), reinserted(false), updateCount(0), toDelete(false) {} 
    133   Node(const Coord& centre, double radius, void *data) 
    134     : level(0), leafCount(1), centre(centre), radius(radius), reinserted(false), updateCount(0), data(data), toDelete(false) {} 
     132        Node() : level(0), leafCount(1), centre(ORIGIN), radius(0), reinserted(false), updateCount(0), toDelete(false) {} 
     133        Node(const Coord& centre, double radius, void *data) 
     134                : level(0), leafCount(1), centre(centre), radius(radius), reinserted(false), updateCount(0), data(data), toDelete(false) {} 
    135135 
    136136//#ifdef DEBUG 
     
    178178//#endif 
    179179 
    180   void move(const NodePtr node); 
    181   void remove(const NodePtr node); 
    182   void inflate(const NodePtr node); 
    183   void update(); 
     180        void move(const NodePtr node); 
     181        void remove(const NodePtr node); 
     182        void inflate(const NodePtr node); 
     183        void update(); 
    184184  void output(std::ostream& flux, int level, int color) ; 
    185   NodePtr closest(std::vector<NodePtr>& list, int n = CLOSEST); 
    186   NodePtr farthest(std::vector<NodePtr>& list); 
    187   void findClosest(int level, NodePtr src, double& minDist, NodePtr &closest); 
    188  
    189   void search(NodePtr node); 
    190   bool centreInside(Node &node); 
    191   bool intersects(NodePtr node); 
    192   bool isInside(Node &node); 
    193   int incluCheck(); 
     185        NodePtr closest(std::vector<NodePtr>& list, int n = CLOSEST); 
     186        NodePtr farthest(std::vector<NodePtr>& list); 
     187        void findClosest(int level, NodePtr src, double& minDist, NodePtr &closest); 
     188 
     189        void search(NodePtr node); 
     190        bool centreInside(Node &node); 
     191        bool intersects(NodePtr node); 
     192        bool isInside(Node &node); 
     193        int incluCheck(); 
    194194  void checkParent(void) ; 
    195   void printChildren(); 
    196   void assignRoute(std::vector<int>::iterator& rank, int level); 
    197   void assignCircleAndPropagateUp(Coord *centres, double *radia, int level); 
    198   void printLevel(int level); 
    199   void routeNode(NodePtr node, int level); 
    200   void routingIntersecting(std::vector<Node>* routingList, NodePtr node); 
    201   void routeIntersection(std::vector<int>& routes, NodePtr node); 
     195        void printChildren(); 
     196        void assignRoute(std::vector<int>::iterator& rank, int level); 
     197        void assignCircleAndPropagateUp(Coord *centres, double *radia, int level); 
     198        void printLevel(int level); 
     199        void routeNode(NodePtr node, int level); 
     200        void routingIntersecting(std::vector<Node>* routingList, NodePtr node); 
     201        void routeIntersection(std::vector<int>& routes, NodePtr node); 
    202202  void getNodeLevel(int level,std::list<NodePtr>& NodeList) ; 
    203203  bool removeDeletedNodes(int assignLevel) ; 
  • XIOS/dev/branch_openmp/extern/remap/src/parallel_tree.cpp

    r1295 r1328  
    1212 
    1313#include "parallel_tree.hpp" 
     14using namespace ep_lib; 
    1415 
    1516namespace sphereRemap { 
    16  
    17 extern CRemapGrid srcGrid; 
    18 #pragma omp threadprivate(srcGrid) 
    19  
    20 extern CRemapGrid tgtGrid; 
    21 #pragma omp threadprivate(tgtGrid) 
    2217 
    2318static const int assignLevel = 2; 
     
    292287{ 
    293288 
    294   int assignLevel = 2; 
    295   int nbSampleNodes = 2*ipow(MAX_NODE_SZ + 1, assignLevel); 
     289        int assignLevel = 2; 
     290        int nbSampleNodes = 2*ipow(MAX_NODE_SZ + 1, assignLevel); 
    296291 
    297292 
     
    305300  MPI_Comm_size(communicator,&commSize) ; 
    306301   
    307   // make multiple of two 
    308   nbSampleNodes /= 2; 
    309   nbSampleNodes *= 2; 
    310   //assert( nbTot > nbSampleNodes*commSize) ; 
     302        // make multiple of two 
     303        nbSampleNodes /= 2; 
     304        nbSampleNodes *= 2; 
     305//  assert( nbTot > nbSampleNodes*commSize) ; 
    311306     
    312307  int nbSampleNodes1 = nbSampleNodes * (nb1*commSize)/(1.*nbTot) ; 
     
    314309   
    315310 
    316   //assert(node.size() > nbSampleNodes); 
    317   //assert(node2.size() > nbSampleNodes); 
    318   //assert(node.size() + node2.size() > nbSampleNodes); 
    319   vector<Node> sampleNodes; sampleNodes.reserve(nbSampleNodes1+nbSampleNodes2); 
    320  
    321   vector<int> randomArray1(node.size()); 
    322   randomizeArray(randomArray1); 
    323   vector<int> randomArray2(node2.size()); 
    324   randomizeArray(randomArray2); 
    325  
    326   for (int i = 0; i <nbSampleNodes1; i++) sampleNodes.push_back(Node(node[randomArray1[i%nb1]].centre,  node[randomArray1[i%nb1]].radius, NULL)); 
    327   for (int i = 0; i <nbSampleNodes2; i++) sampleNodes.push_back(Node(node2[randomArray2[i%nb2]].centre, node2[randomArray2[i%nb2]].radius, NULL)); 
     311//      assert(node.size() > nbSampleNodes); 
     312//      assert(node2.size() > nbSampleNodes); 
     313//      assert(node.size() + node2.size() > nbSampleNodes); 
     314        vector<Node> sampleNodes; sampleNodes.reserve(nbSampleNodes1+nbSampleNodes2); 
     315 
     316        vector<int> randomArray1(node.size()); 
     317        randomizeArray(randomArray1); 
     318        vector<int> randomArray2(node2.size()); 
     319        randomizeArray(randomArray2); 
     320 
     321        for (int i = 0; i <nbSampleNodes1; i++) sampleNodes.push_back(Node(node[randomArray1[i%nb1]].centre,  node[randomArray1[i%nb1]].radius, NULL)); 
     322        for (int i = 0; i <nbSampleNodes2; i++) sampleNodes.push_back(Node(node2[randomArray2[i%nb2]].centre, node2[randomArray2[i%nb2]].radius, NULL)); 
    328323 
    329324        CTimer::get("buildParallelSampleTree").resume(); 
     
    336331        CTimer::get("parallelRouteNode").resume(); 
    337332        vector<int> route(node.size()); 
     333        cout<<"node.size = "<<node.size()<<endl; 
    338334        routeNodes(route /*out*/, node); 
    339335        CTimer::get("parallelRouteNode").suspend(); 
  • XIOS/dev/branch_openmp/extern/remap/src/parallel_tree.hpp

    r1134 r1328  
    66#include "mpi_cascade.hpp" 
    77#include "mpi.hpp" 
    8 #ifdef _usingEP 
    9 #include "ep_declaration.hpp" 
    10 #endif 
    11  
    128namespace sphereRemap { 
    139 
     
    1511{ 
    1612public: 
    17         CParallelTree(ep_lib::MPI_Comm comm); 
    18         ~CParallelTree(); 
     13  CParallelTree(ep_lib::MPI_Comm comm); 
     14  ~CParallelTree(); 
    1915 
    20         void build(vector<Node>& node, vector<Node>& node2); 
     16  void build(vector<Node>& node, vector<Node>& node2); 
    2117 
    22         void routeNodes(vector<int>& route, vector<Node>& nodes, int level = 0); 
    23         void routeIntersections(vector<vector<int> >& route, vector<Node>& nodes, int level = 0); 
     18  void routeNodes(vector<int>& route, vector<Node>& nodes, int level = 0); 
     19  void routeIntersections(vector<vector<int> >& route, vector<Node>& nodes, int level = 0); 
    2420 
    25         int nbLocalElements; 
    26         Elt* localElements; 
     21  int nbLocalElements; 
     22  Elt* localElements; 
    2723 
    28         CTree localTree; 
     24  CTree localTree; 
    2925 
    3026private: 
    31         void updateCirclesForRouting(Coord rootCentre, double rootRadius, int level = 0); 
    32         void buildSampleTreeCascade(vector<Node>& sampleNodes, int level = 0); 
    33         void buildLocalTree(const vector<Node>& node, const vector<int>& route); 
    34         void buildRouteTree(); 
     27  void updateCirclesForRouting(Coord rootCentre, double rootRadius, int level = 0); 
     28  void buildSampleTreeCascade(vector<Node>& sampleNodes, int level = 0); 
     29  void buildLocalTree(const vector<Node>& node, const vector<int>& route); 
     30  void buildRouteTree(); 
    3531 
    36         //CSampleTree sampleTree; 
    37         vector<CSampleTree> treeCascade; // first for sample tree, then for routing tree 
    38         CMPICascade cascade; 
    39         ep_lib::MPI_Comm communicator ; 
     32  //CSampleTree sampleTree; 
     33  vector<CSampleTree> treeCascade; // first for sample tree, then for routing tree 
     34  CMPICascade cascade; 
     35  ep_lib::MPI_Comm communicator ; 
    4036 
    4137}; 
  • XIOS/dev/branch_openmp/extern/remap/src/polyg.cpp

    r1289 r1328  
    77 
    88#include "polyg.hpp" 
    9 #include <stdio.h> 
    109 
    1110namespace sphereRemap { 
     
    4645Coord barycentre(const Coord *x, int n) 
    4746{ 
    48  
    4947        if (n == 0) return ORIGIN; 
    5048        Coord bc = ORIGIN; 
    5149        for (int i = 0; i < n; i++) 
    52         { 
    5350                bc = bc + x[i]; 
    54         }        
    5551        /* both distances can be equal down to roundoff when norm(bc) < mashineepsilon  
    5652           which can occur when weighted with tiny area */ 
    57    
    58          
    59   //assert(squaredist(bc, proj(bc)) <= squaredist(bc, proj(bc * (-1.0))));       
     53 
     54        assert(squaredist(bc, proj(bc)) <= squaredist(bc, proj(bc * (-1.0)))); 
     55        //if (squaredist(bc, proj(bc)) > squaredist(bc, proj(bc * (-1.0)))) return proj(bc * (-1.0)); 
    6056 
    6157        return proj(bc); 
     
    165161{ 
    166162        if (N < 3) 
    167                 return 0; /* polygons with less than three vertices have zero area */ 
     163          return 0; /* polygons with less than three vertices have zero area */ 
    168164        Coord t[3]; 
    169165        t[0] = barycentre(x, N); 
     
    177173                t[1] = x[i]; 
    178174                t[2] = x[ii]; 
    179     double sc=scalarprod(crossprod(t[1] - t[0], t[2] - t[0]), t[0]) ; 
     175                double sc=scalarprod(crossprod(t[1] - t[0], t[2] - t[0]), t[0]) ; 
    180176                assert(sc >= -1e-10); // Error: tri a l'env (wrong orientation) 
    181177                double area_gc = triarea(t[0], t[1], t[2]); 
    182                 //if(area_gc<=0) printf("area_gc = %e\n", area_gc); 
    183178                double area_sc_gc_moon = 0; 
    184179                if (d[i]) /* handle small circle case */ 
     
    188183                        char sgl = (mext > 0) ? -1 : 1; 
    189184                        area_sc_gc_moon = sgl * alun(arcdist(t[1], t[2]), fabs(scalarprod(t[1], pole))); 
    190                         //if(area_sc_gc_moon<=0) printf("area_sc_gc_moon = %e\n", area_sc_gc_moon); 
    191185                        gg_exact = gg_exact + sc_gc_moon_normalintegral(t[1], t[2], pole); 
    192186                } 
    193187                area += area_gc + area_sc_gc_moon; /* for "spherical circle segment" sum triangular part (at) and "small moon" and => account for small circle */ 
    194188                g[i] = barycentre(t, 3) * (area_gc + area_sc_gc_moon); 
    195                 //printf("g[%d] = (%e,%e,%e) * (%e+%e) = (%e,%e,%e) norm = %e\n", i, barycentre(t, 3).x, barycentre(t, 3).y, barycentre(t, 3).z, area_gc,  area_sc_gc_moon, g[i].x, g[i].y, g[i].z, norm(g[i])); 
    196189        } 
    197190        gg = barycentre(g, N); 
  • XIOS/dev/branch_openmp/extern/remap/src/timerRemap.cpp

    r1146 r1328  
    44#include <map> 
    55#include <iostream> 
     6using namespace ep_lib; 
    67 
    78namespace sphereRemap { 
     
    910using namespace std; 
    1011 
    11 map<string,CTimer*> *CTimer::allTimer = 0; 
     12//map<string,CTimer*> CTimer::allTimer; 
     13map<string,CTimer*> *CTimer::allTimer_ptr = 0; 
    1214 
    1315CTimer::CTimer(const string& name_) : name(name_) 
     
    5557CTimer& CTimer::get(const string name) 
    5658{ 
    57         if(allTimer == 0) allTimer = new map<string,CTimer*>; 
    5859        map<string,CTimer*>::iterator it; 
    59         it=(*allTimer).find(name); 
    60         if (it==(*allTimer).end()) it=(*allTimer).insert(pair<string,CTimer*>(name,new CTimer(name))).first; 
     60        if(allTimer_ptr == 0) allTimer_ptr = new map<string,CTimer*>; 
     61        //it=allTimer.find(name); 
     62        it=allTimer_ptr->find(name); 
     63        //if (it==allTimer.end()) it=allTimer.insert(pair<string,CTimer*>(name,new CTimer(name))).first; 
     64        if (it==allTimer_ptr->end()) it=allTimer_ptr->insert(pair<string,CTimer*>(name,new CTimer(name))).first; 
    6165        return *(it->second); 
    6266} 
  • XIOS/dev/branch_openmp/extern/remap/src/timerRemap.hpp

    r1146 r1328  
    2727    void print(void); 
    2828    //static map<string,CTimer*> allTimer; 
    29     static map<string,CTimer*> *allTimer; 
    30     #pragma omp threadprivate(allTimer) 
    31      
     29    static map<string,CTimer*> *allTimer_ptr; 
    3230    static double getTime(void); 
    3331    static CTimer& get(string name); 
  • XIOS/dev/branch_openmp/extern/remap/src/tree.cpp

    r1172 r1328  
    2929void CBasicTree::routeNodes(vector<int>& route, vector<Node>& nodes, int assignLevel) 
    3030{ 
    31   for (int i = 0; i < nodes.size(); i++) 
    32   { 
    33     root->routeNode(&nodes[i], assignLevel); 
    34     route[i] = nodes[i].route; 
    35   } 
     31        for (int i = 0; i < nodes.size(); i++) 
     32        { 
     33                root->routeNode(&nodes[i], assignLevel); 
     34                route[i] = nodes[i].route; 
     35        } 
    3636} 
    3737 
    3838void CBasicTree::routeIntersections(vector<vector<int> >& routes, vector<Node>& nodes) 
    3939{ 
    40   for (int i = 0; i < nodes.size(); i++) 
    41     root->routeIntersection(routes[i], &nodes[i]); 
     40        for (int i = 0; i < nodes.size(); i++) 
     41                root->routeIntersection(routes[i], &nodes[i]); 
    4242} 
    4343 
    4444void CBasicTree::build(vector<Node>& nodes) 
    4545{ 
    46   newRoot(1); 
    47   insertNodes(nodes); 
     46        newRoot(1); 
     47        insertNodes(nodes); 
    4848} 
    4949 
    5050void CBasicTree::output(ostream& flux, int level) 
    5151{ 
    52   root->output(flux,level,0) ; 
     52        root->output(flux,level,0) ; 
    5353} 
    5454void CBasicTree::slim(int nbIts) 
    5555{ 
    56   for (int i = 0; i < nbIts; i++) 
    57   { 
    58     for (int level = root->level - 1; level > 0; level--) 
    59     { 
    60       slim2(root, level); 
    61       ri = 0; 
    62       emptyPool(); 
    63     } 
    64  
    65     for (int level = 2; level < root->level; level++) 
    66     { 
    67       slim2(root, level); 
    68       ri = 0; 
    69       emptyPool(); 
    70     } 
    71   } 
     56        for (int i = 0; i < nbIts; i++) 
     57        { 
     58                for (int level = root->level - 1; level > 0; level--) 
     59                { 
     60                        slim2(root, level); 
     61                        ri = 0; 
     62                        emptyPool(); 
     63                } 
     64 
     65                for (int level = 2; level < root->level; level++) 
     66                { 
     67                        slim2(root, level); 
     68                        ri = 0; 
     69                        emptyPool(); 
     70                } 
     71        } 
    7272} 
    7373 
     
    7676void CBasicTree::insertNode(NodePtr node) 
    7777{ 
    78   node->tree = this; 
    79   increaseLevelSize(0); 
    80   push_back(node); 
    81  
    82   NodePtr q; 
    83   while (pool.size()) 
    84   { 
    85     q = pool.front(); 
    86     pool.pop_front(); 
    87     q = insert(q, root); 
    88     if (ri) 
    89     { 
    90       delete q; 
    91       ri = 0; 
    92     } 
    93   } 
     78        node->tree = this; 
     79        increaseLevelSize(0); 
     80        push_back(node); 
     81 
     82        NodePtr q; 
     83        while (pool.size()) 
     84        { 
     85                q = pool.front(); 
     86                pool.pop_front(); 
     87                q = insert(q, root); 
     88                if (ri) 
     89                { 
     90                        delete q; 
     91                        ri = 0; 
     92                } 
     93        } 
    9494} 
    9595 
    9696void CBasicTree::emptyPool(void) 
    9797{ 
    98   while (pool.size()) 
    99   { 
    100     NodePtr q = pool.front(); 
    101     pool.pop_front(); 
    102     q = insert(q, root); 
    103     if (ri) 
    104     { 
    105       delete q; 
    106       ri = 0; 
    107     } 
    108   } 
     98        while (pool.size()) 
     99        { 
     100                NodePtr q = pool.front(); 
     101                pool.pop_front(); 
     102                q = insert(q, root); 
     103                if (ri) 
     104                { 
     105                        delete q; 
     106                        ri = 0; 
     107                } 
     108        } 
    109109} 
    110110 
     
    142142        root->parent = 0; 
    143143        root->leafCount = 0; 
    144         // initialize root node on the sphere 
    145         root->centre.x=1 ;  
    146         root->centre.y=0 ;  
    147         root->centre.z=0 ;  
     144// initialize root node on the sphere 
     145  root->centre.x=1 ; root->centre.y=0 ; root->centre.z=0 ;  
    148146        root->radius = 0.; 
    149147        root->reinserted = false; 
  • XIOS/dev/branch_openmp/extern/remap/src/tree.hpp

    r1172 r1328  
    1414class CBasicTree 
    1515{ 
    16   public: 
     16public: 
    1717 
    18   NodePtr root; /* The main tree is stored as Nodes which can be reached through traversal starting here */ 
    19   NodePtr ref; // FIXME this reference, set by a node is odd, try to remove 
    20   int ri; /** this is set to one by a node in case of reinsertion */ 
    21   vector<int> levelSize; /** e.g. levelSize[0] == leafs.size() */ 
    22   vector<Node> leafs; /** leafs are stored in vector for easy access and rest of the tree nodes as separate allocations, only reachable through tree traversal */ 
     18        NodePtr root; /* The main tree is stored as Nodes which can be reached through traversal starting here */ 
     19        NodePtr ref; // FIXME this reference, set by a node is odd, try to remove 
     20        int ri; /** this is set to one by a node in case of reinsertion */ 
     21        vector<int> levelSize; /** e.g. levelSize[0] == leafs.size() */ 
     22        vector<Node> leafs; /** leafs are stored in vector for easy access and rest of the tree nodes as separate allocations, only reachable through tree traversal */ 
    2323 
    24   CBasicTree() : ri(0), levelSize(MAX_LEVEL_SIZE), root(NULL), isAssignedLevel(false), okSplit(true), isActiveOkSplit(false) {}  
    25   ~CBasicTree();  
    26   void build(vector<Node>& nodes); 
    27   void slim(int nbIts = 1); 
    28   virtual void insertNodes(vector<Node>& node) = 0; 
     24        CBasicTree() : ri(0), levelSize(MAX_LEVEL_SIZE), root(NULL), isAssignedLevel(false), okSplit(true), isActiveOkSplit(false) {}  
     25        ~CBasicTree();  
     26        void build(vector<Node>& nodes); 
     27        void slim(int nbIts = 1); 
     28        virtual void insertNodes(vector<Node>& node) = 0; 
    2929 
    30   void routeNodes(vector<int>& route, vector<Node>& nodes, int assignLevel); 
    31   void routeIntersections(vector<vector<int> >& route, vector<Node>& nodes); 
     30        void routeNodes(vector<int>& route, vector<Node>& nodes, int assignLevel); 
     31        void routeIntersections(vector<vector<int> >& route, vector<Node>& nodes); 
    3232 
    33   void push_back(NodePtr node); 
    34   void push_front(NodePtr node); 
    35   void increaseLevelSize(int level); 
    36   void decreaseLevelSize(int level); 
    37   void newRoot(int level); 
    38   void insertNode(NodePtr node); 
     33        void push_back(NodePtr node); 
     34        void push_front(NodePtr node); 
     35        void increaseLevelSize(int level); 
     36        void decreaseLevelSize(int level); 
     37        void newRoot(int level); 
     38        void insertNode(NodePtr node); 
    3939  void output(ostream& flux, int level) ; 
    4040 
    41   int keepNodes; 
     41        int keepNodes; 
    4242  bool isAssignedLevel ;  
    4343  int assignLevel; 
     
    5050 
    5151   
    52   private: 
    53   deque<NodePtr > pool; 
     52private: 
     53        deque<NodePtr > pool; 
    5454         
    5555  bool okSplit ; 
    5656  
    57   protected: 
     57protected: 
    5858  void emptyPool(); 
    59   CBasicTree(int keepNodes_, int assignLevel_) : ri(0), levelSize(MAX_LEVEL_SIZE), root(NULL), keepNodes(keepNodes_), assignLevel(assignLevel_), isAssignedLevel(true),  
    60                                                  okSplit(true), isActiveOkSplit(false) {}  
     59  CBasicTree(int keepNodes_, int assignLevel_) : ri(0), levelSize(MAX_LEVEL_SIZE), root(NULL), keepNodes(keepNodes_), assignLevel(assignLevel_), isAssignedLevel(true), okSplit(true), isActiveOkSplit(false) {}  
    6160}; 
    6261 
    6362class CTree : public CBasicTree 
    6463{ 
    65   public: 
    66   void insertNodes(vector<Node>& nodes); 
     64public: 
     65        void insertNodes(vector<Node>& nodes); 
    6766}; 
    6867 
     
    7069{ 
    7170 
    72   public: 
    73   CSampleTree(int keepNodes_, int assignLevel_) : CBasicTree(keepNodes_,assignLevel_) {} 
     71public: 
     72        CSampleTree(int keepNodes_, int assignLevel_) : CBasicTree(keepNodes_,assignLevel_) {} 
    7473  void slimAssignedLevel() ; 
    7574  void removeExtraNode(void) ; 
    76   void insertNodes(vector<Node>& nodes); 
     75        void insertNodes(vector<Node>& nodes); 
    7776}; 
    7877 
  • XIOS/dev/branch_openmp/extern/src_ep_dev/ep_fortran.cpp

    r1287 r1328  
    3131      { 
    3232        fc_comm_map.insert(std::make_pair( std::make_pair( fint, omp_get_thread_num()) , comm)); 
    33         //printf("EP_Comm_c2f : MAP %p insert: %d, %d, %p\n", &fc_comm_map, fint, omp_get_thread_num(), comm.ep_comm_ptr); 
     33        printf("EP_Comm_c2f : MAP %p insert: %d, %d, %p\n", &fc_comm_map, fint, omp_get_thread_num(), comm.ep_comm_ptr); 
    3434      } 
    3535    } 
     
    5454      MPI_Comm comm_ptr; 
    5555      comm_ptr = it->second; 
    56       //printf("EP_Comm_f2c : MAP %p find: %d, %d, %p\n", &fc_comm_map, it->first.first, it->first.second, comm_ptr.ep_comm_ptr); 
     56      printf("EP_Comm_f2c : MAP %p find: %d, %d, %p\n", &fc_comm_map, it->first.first, it->first.second, comm_ptr.ep_comm_ptr); 
    5757      return  comm_ptr; 
    5858    } 
  • XIOS/dev/branch_openmp/extern/src_ep_dev/ep_intercomm.cpp

    r1287 r1328  
    4747 
    4848      MPI_Waitall(2, request, status); 
     49 
     50      //MPI_Send(&leader_ranks[0], 3, static_cast< ::MPI_Datatype>(MPI_INT), remote_leader, tag, peer_comm); 
     51      //MPI_Recv(&leader_ranks[3], 3, static_cast< ::MPI_Datatype>(MPI_INT), remote_leader, tag, peer_comm, &status[1]); 
    4952    } 
    5053 
  • XIOS/dev/branch_openmp/extern/src_ep_dev/ep_lib.cpp

    r1295 r1328  
    1010#pragma omp threadprivate(EP_PendingRequests) 
    1111 
     12 
     13 
    1214namespace ep_lib 
    1315{  
     16  bool MPI_Comm::is_null() 
     17  { 
     18    if(!this->is_intercomm) 
     19      return this->mpi_comm == MPI_COMM_NULL.mpi_comm; 
     20    else 
     21      return this->ep_comm_ptr->intercomm->mpi_inter_comm == MPI_COMM_NULL.mpi_comm; 
     22  } 
    1423 
    1524  int tag_combine(int real_tag, int src, int dest) 
  • XIOS/dev/branch_openmp/extern/src_ep_dev/ep_send.cpp

    r1295 r1328  
    1919    if(!comm.is_ep) 
    2020      return ::MPI_Send(buf, count, to_mpi_type(datatype), dest, tag, to_mpi_comm(comm.mpi_comm)); 
    21  
    22     MPI_Request request; 
    23     MPI_Status status; 
    24     MPI_Isend(buf, count, datatype, dest, tag, comm, &request); 
    25     MPI_Wait(&request, &status); 
    26  
     21    if(comm.is_intercomm) 
     22    { 
     23      MPI_Request request; 
     24      MPI_Status status; 
     25      MPI_Isend(buf, count, datatype, dest, tag, comm, &request); 
     26      MPI_Wait(&request, &status); 
     27    } 
     28    else 
     29    { 
     30      int ep_src_loc  = comm.ep_comm_ptr->size_rank_info[1].first; 
     31      int ep_dest_loc = comm.ep_comm_ptr->comm_list->rank_map->at(dest).first; 
     32      int mpi_tag     = tag_combine(tag, ep_src_loc, ep_dest_loc); 
     33      int mpi_dest    = comm.ep_comm_ptr->comm_list->rank_map->at(dest).second; 
     34 
     35      ::MPI_Send(buf, count, to_mpi_type(datatype), mpi_dest, mpi_tag, to_mpi_comm(comm.mpi_comm)); 
     36      //printf("call mpi_send for intracomm, dest = %d, tag = %d\n", dest, tag); 
     37    } 
    2738    //check_sum_send(buf, count, datatype, dest, tag, comm); 
    2839 
  • XIOS/dev/branch_openmp/extern/src_ep_dev/ep_type.hpp

    r1295 r1328  
    344344    } 
    345345 
     346    bool is_null(); 
     347 
    346348  }; 
    347349 
  • XIOS/dev/branch_openmp/inputs/REMAP/iodef.xml

    r1220 r1328  
    5151 
    5252      <file_group id="write_files" > 
    53         <file id="output_2D" name="output_2D" enabled=".TRUE."> 
     53        <file id="output_2D" name="output_2D" output_freq="1ts" enabled=".TRUE."> 
    5454          <field field_ref="src_field_2D" name="field_src" enabled=".TRUE."/> 
    5555          <field field_ref="src_field_2D_clone" name="field_src_clone" default_value="100000" enabled=".TRUE."/> 
     
    5757          <field field_ref="dst_field_2D" name="field_dst_regular_1" enabled=".TRUE." /> 
    5858          <field field_ref="dst_field_2D_regular_pole" name="field_dst_regular_2" enabled=".TRUE."/> 
    59           <field field_ref="dst_field_2D_clone" name="field_dst_regular_3" detect_missing_value=".false." default_value="100000" enabled=".TRUE."/> 
     59          <field field_ref="dst_field_2D_clone" name="field_dst_regular_3" detect_missing_value=".false." default_value="100000" enabled=".FALSE."/> 
    6060          <field field_ref="dst_field_2D_extract" name="field_dst_regular_4" enabled=".TRUE."/> 
    6161        </file>  
  • XIOS/dev/branch_openmp/src/array_new.hpp

    r1134 r1328  
    554554        TinyVector<int,N_rank> vect; 
    555555        size_t ne; 
    556  
     556         
    557557        ret =  buffer.get(numDim); 
    558558        ret &= buffer.get(vect.data(), N_rank); 
  • XIOS/dev/branch_openmp/src/attribute_enum.hpp

    r1134 r1328  
    1414namespace xios 
    1515{ 
    16     /// ////////////////////// Déclarations ////////////////////// /// 
    17     /*! 
    18       \class CAttributeEnum 
    19       This class implements the attribute representing enumeration 
     16      /// ////////////////////// Déclarations ////////////////////// /// 
     17        /*! 
     18        \class CAttributeEnum 
     19        This class implements the attribute representing enumeration 
    2020      */ 
    21     template <class T> 
    22         class CAttributeEnum : public CAttribute, public CEnum<T> 
    23     { 
     21      template <class T> 
     22         class CAttributeEnum : public CAttribute, public CEnum<T> 
     23      { 
    2424        typedef typename T::t_enum T_enum ; 
    2525        public : 
    2626 
    27         /// Constructeurs /// 
    28         explicit CAttributeEnum(const StdString & id); 
    29         CAttributeEnum(const StdString & id, 
    30                 xios_map<StdString, CAttribute*> & umap); 
    31         CAttributeEnum(const StdString & id, const T_enum & value); 
    32         CAttributeEnum(const StdString & id, const T_enum & value, 
    33                 xios_map<StdString, CAttribute*> & umap); 
     27            /// Constructeurs /// 
     28            explicit CAttributeEnum(const StdString & id); 
     29            CAttributeEnum(const StdString & id, 
     30                               xios_map<StdString, CAttribute*> & umap); 
     31            CAttributeEnum(const StdString & id, const T_enum & value); 
     32            CAttributeEnum(const StdString & id, const T_enum & value, 
     33                               xios_map<StdString, CAttribute*> & umap); 
    3434 
    35         /// Accesseur /// 
    36         T_enum getValue(void) const; 
    37         string getStringValue(void) const; 
     35            /// Accesseur /// 
     36            T_enum getValue(void) const; 
     37            string getStringValue(void) const; 
    3838 
    3939 
    40         /// Mutateurs /// 
    41         void setValue(const T_enum & value); 
     40            /// Mutateurs /// 
     41            void setValue(const T_enum & value); 
     42             
     43            void set(const CAttribute& attr) ; 
     44            void set(const CAttributeEnum& attr) ; 
     45            void reset(void); 
     46             
     47            void setInheritedValue(const CAttributeEnum& attr ); 
     48            void setInheritedValue(const CAttribute& attr ); 
     49            T_enum getInheritedValue(void)  const; 
     50            string getInheritedStringValue(void) const; 
     51            bool hasInheritedValue(void) const;           
     52           
     53            bool isEqual(const CAttributeEnum& attr ); 
     54            bool isEqual(const CAttribute& attr ); 
    4255 
    43         void set(const CAttribute& attr) ; 
    44         void set(const CAttributeEnum& attr) ; 
    45         void reset(void); 
     56            /// Destructeur /// 
     57            virtual ~CAttributeEnum(void) { } 
    4658 
    47         void setInheritedValue(const CAttributeEnum& attr ); 
    48         void setInheritedValue(const CAttribute& attr ); 
    49         T_enum getInheritedValue(void)  const; 
    50         string getInheritedStringValue(void) const; 
    51         bool hasInheritedValue(void) const;           
     59            /// Operateur /// 
     60            CAttributeEnum& operator=(const T_enum & value); 
    5261 
    53         bool isEqual(const CAttributeEnum& attr ); 
    54         bool isEqual(const CAttribute& attr ); 
     62            /// Autre /// 
     63            virtual StdString toString(void) const { return _toString();} 
     64            virtual void fromString(const StdString & str) { if (str==resetInheritanceStr) { reset(); _canInherite=false ;}  else _fromString(str);} 
    5565 
    56         /// Destructeur /// 
    57         virtual ~CAttributeEnum(void) { } 
     66            virtual bool toBuffer  (CBufferOut& buffer) const { return _toBuffer(buffer);}  
     67            virtual bool fromBuffer(CBufferIn& buffer) { return _fromBuffer(buffer); }  
     68             
     69            virtual void generateCInterface(ostream& oss,const string& className) ; 
     70            virtual void generateFortran2003Interface(ostream& oss,const string& className) ; 
     71            virtual void generateFortranInterfaceDeclaration_(ostream& oss,const string& className) ; 
     72            virtual void generateFortranInterfaceBody_(ostream& oss,const string& className) ; 
     73            virtual void generateFortranInterfaceDeclaration(ostream& oss,const string& className) ; 
     74            virtual void generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className) ; 
     75            virtual void generateFortranInterfaceGetBody_(ostream& oss,const string& className) ; 
     76            virtual void generateFortranInterfaceGetDeclaration(ostream& oss,const string& className) ;       
    5877 
    59         /// Operateur /// 
    60         CAttributeEnum& operator=(const T_enum & value); 
    61  
    62         /// Autre /// 
    63         virtual StdString toString(void) const { return _toString();} 
    64         virtual void fromString(const StdString & str) { if (str==resetInheritanceStr) { reset(); _canInherite=false ;}  else _fromString(str);} 
    65  
    66         virtual bool toBuffer  (CBufferOut& buffer) const { return _toBuffer(buffer);}  
    67         virtual bool fromBuffer(CBufferIn& buffer) { return _fromBuffer(buffer); }  
    68  
    69         virtual void generateCInterface(ostream& oss,const string& className) ; 
    70         virtual void generateFortran2003Interface(ostream& oss,const string& className) ; 
    71         virtual void generateFortranInterfaceDeclaration_(ostream& oss,const string& className) ; 
    72         virtual void generateFortranInterfaceBody_(ostream& oss,const string& className) ; 
    73         virtual void generateFortranInterfaceDeclaration(ostream& oss,const string& className) ; 
    74         virtual void generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className) ; 
    75         virtual void generateFortranInterfaceGetBody_(ostream& oss,const string& className) ; 
    76         virtual void generateFortranInterfaceGetDeclaration(ostream& oss,const string& className) ;       
    77  
    78         private : 
    79         StdString _toString(void) const; 
    80         void _fromString(const StdString & str); 
    81         bool _toBuffer  (CBufferOut& buffer) const; 
    82         bool _fromBuffer(CBufferIn& buffer) ; 
    83         CEnum<T> inheritedValue ; 
    84     }; // class CAttributeEnum     
    85  
     78         private : 
     79          StdString _toString(void) const; 
     80          void _fromString(const StdString & str); 
     81          bool _toBuffer  (CBufferOut& buffer) const; 
     82          bool _fromBuffer(CBufferIn& buffer) ; 
     83          CEnum<T> inheritedValue ; 
     84      }; // class CAttributeEnum     
     85    
    8686} // namespace xios 
    8787 
    8888#endif // __XIOS_ATTRIBUTE_ENUM__ 
    89  
  • XIOS/dev/branch_openmp/src/attribute_enum_impl.hpp

    r1134 r1328  
    1010namespace xios 
    1111{ 
    12   /// ////////////////////// Définitions ////////////////////// /// 
     12  /// ////////////////////// Définitions ////////////////////// /// 
    1313  template <class T> 
    1414  CAttributeEnum<T>::CAttributeEnum(const StdString & id) 
     
    3030     umap.insert(umap.end(), std::make_pair(id, this)); 
    3131  } 
    32   
     32 
    3333  template <class T> 
    3434  CAttributeEnum<T>::CAttributeEnum 
     
    4040     umap.insert(umap.end(), std::make_pair(id, this)); 
    4141  } 
    42   
     42 
    4343  ///-------------------------------------------------------------- 
    4444  template <class T> 
     
    5454     return CEnum<T>::get(); 
    5555  } 
    56   
     56 
    5757  template <class T> 
    5858  string CAttributeEnum<T>::getStringValue(void) const 
    5959  { 
    60     return CEnum<T>::toString(); 
    61   } 
    62  
     60     return CEnum<T>::toString(); 
     61  } 
    6362 
    6463  template <class T> 
     
    7170  void CAttributeEnum<T>::set(const CAttribute& attr) 
    7271  { 
    73      this->set(dynamic_cast<const CAttributeEnum<T>& >(attr)); 
    74   } 
    75     
    76   template <class T> 
     72    this->set(dynamic_cast<const CAttributeEnum<T>& >(attr)); 
     73  } 
     74 
     75 template <class T> 
    7776  void CAttributeEnum<T>::set(const CAttributeEnum& attr) 
    7877  { 
    79      CEnum<T>::set(attr); 
    80   } 
    81   
     78    CEnum<T>::set(attr); 
     79  } 
     80 
    8281  template <class T> 
    8382  void CAttributeEnum<T>::setInheritedValue(const CAttribute& attr) 
    8483  { 
    85      this->setInheritedValue(dynamic_cast<const CAttributeEnum<T>& >(attr)); 
    86   } 
    87    
     84    this->setInheritedValue(dynamic_cast<const CAttributeEnum<T>& >(attr)); 
     85  } 
     86 
    8887  template <class T> 
    8988  void CAttributeEnum<T>::setInheritedValue(const CAttributeEnum& attr) 
    9089  { 
    91      if (this->isEmpty() && _canInherite && attr.hasInheritedValue()) inheritedValue.set(attr.getInheritedValue()); 
    92   } 
    93    
     90    if (this->isEmpty() && _canInherite && attr.hasInheritedValue()) inheritedValue.set(attr.getInheritedValue()); 
     91  } 
     92 
    9493  template <class T> 
    9594  typename T::t_enum CAttributeEnum<T>::getInheritedValue(void) const 
    9695  { 
    97      if (this->isEmpty()) return inheritedValue.get(); 
    98      else return getValue(); 
    99   } 
    100  
    101   template <class T> 
    102       string CAttributeEnum<T>::getInheritedStringValue(void) const 
    103       { 
    104           if (this->isEmpty()) return inheritedValue.toString(); 
    105           else return CEnum<T>::toString();; 
    106       } 
    107  
    108   template <class T> 
    109       bool CAttributeEnum<T>::hasInheritedValue(void) const 
    110       { 
    111           return !this->isEmpty() || !inheritedValue.isEmpty(); 
    112       } 
    113  
    114   template <class T> 
    115       bool CAttributeEnum<T>::isEqual(const CAttribute& attr) 
    116       { 
    117           return (this->isEqual(dynamic_cast<const CAttributeEnum<T>& >(attr))); 
    118       } 
    119  
    120   template <class T> 
    121       bool CAttributeEnum<T>::isEqual(const CAttributeEnum& attr) 
    122       { 
    123           return ((dynamic_cast<const CEnum<T>& >(*this)) == (dynamic_cast<const CEnum<T>& >(attr))); 
    124       } 
     96    if (this->isEmpty()) return inheritedValue.get(); 
     97    else return getValue(); 
     98  } 
     99 
     100  template <class T> 
     101  string CAttributeEnum<T>::getInheritedStringValue(void) const 
     102  { 
     103     if (this->isEmpty()) return inheritedValue.toString(); 
     104     else return CEnum<T>::toString();; 
     105  } 
     106 
     107  template <class T> 
     108  bool CAttributeEnum<T>::hasInheritedValue(void) const 
     109  { 
     110    return !this->isEmpty() || !inheritedValue.isEmpty(); 
     111  } 
     112 
     113  template <class T> 
     114  bool CAttributeEnum<T>::isEqual(const CAttribute& attr) 
     115  { 
     116    return (this->isEqual(dynamic_cast<const CAttributeEnum<T>& >(attr))); 
     117  } 
     118 
     119  template <class T> 
     120  bool CAttributeEnum<T>::isEqual(const CAttributeEnum& attr) 
     121  { 
     122    return ((dynamic_cast<const CEnum<T>& >(*this)) == (dynamic_cast<const CEnum<T>& >(attr))); 
     123  } 
    125124 
    126125  //--------------------------------------------------------------- 
    127126 
    128127  template <class T> 
    129       CAttributeEnum<T>& CAttributeEnum<T>::operator=(const T_enum & value) 
    130       { 
    131           this->setValue(value); 
    132           return *this; 
    133       } 
     128  CAttributeEnum<T>& CAttributeEnum<T>::operator=(const T_enum & value) 
     129  { 
     130     this->setValue(value); 
     131     return *this; 
     132  } 
    134133 
    135134  //--------------------------------------------------------------- 
    136135 
    137136  template <class T> 
    138       StdString CAttributeEnum<T>::_toString(void) const 
    139       { 
    140           StdOStringStream oss; 
    141           if (!CEnum<T>::isEmpty() && this->hasId()) 
    142               oss << this->getName() << "=\"" << CEnum<T>::toString() << "\""; 
    143           return (oss.str()); 
    144       } 
    145  
    146   template <class T> 
    147       void CAttributeEnum<T>::_fromString(const StdString & str) 
    148       { 
    149           CEnum<T>::fromString(str); 
    150       } 
    151  
    152   template <class T> 
    153       bool CAttributeEnum<T>::_toBuffer (CBufferOut& buffer) const 
    154       { 
    155           return CEnum<T>::toBuffer(buffer); 
    156       } 
    157  
    158   template <class T> 
    159       bool CAttributeEnum<T>::_fromBuffer(CBufferIn& buffer) 
    160       { 
    161           return CEnum<T>::fromBuffer(buffer); 
    162       } 
    163  
    164   template <typename T> 
    165       void CAttributeEnum<T>::generateCInterface(ostream& oss,const string& className) 
    166       { 
    167           CInterface::AttributeCInterface<CEnumBase>(oss, className, this->getName()); 
    168       } 
    169  
    170   template <typename T> 
    171       void CAttributeEnum<T>::generateFortran2003Interface(ostream& oss,const string& className) 
    172       { 
    173           CInterface::AttributeFortran2003Interface<string>(oss, className, this->getName()); 
    174       } 
    175  
    176   template <typename T> 
    177       void CAttributeEnum<T>::generateFortranInterfaceDeclaration_(ostream& oss,const string& className) 
    178       { 
    179           CInterface::AttributeFortranInterfaceDeclaration<string>(oss, className, this->getName()+"_"); 
    180       } 
    181  
    182   template <typename T> 
    183       void CAttributeEnum<T>::generateFortranInterfaceBody_(ostream& oss,const string& className) 
    184       { 
    185           CInterface::AttributeFortranInterfaceBody<string>(oss, className, this->getName()); 
    186       } 
    187  
    188   template <typename T> 
    189       void CAttributeEnum<T>::generateFortranInterfaceDeclaration(ostream& oss,const string& className) 
    190       { 
    191           CInterface::AttributeFortranInterfaceDeclaration<string>(oss, className, this->getName()); 
    192       } 
    193  
    194   template <typename T> 
    195       void CAttributeEnum<T>::generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className) 
    196       { 
    197           CInterface::AttributeFortranInterfaceGetDeclaration<string>(oss, className, this->getName()+"_"); 
    198       } 
    199  
    200   template <typename T> 
    201       void CAttributeEnum<T>::generateFortranInterfaceGetBody_(ostream& oss,const string& className) 
    202       { 
    203           CInterface::AttributeFortranInterfaceGetBody<string>(oss, className, this->getName()); 
    204       } 
    205  
    206   template <typename T> 
    207       void CAttributeEnum<T>::generateFortranInterfaceGetDeclaration(ostream& oss,const string& className) 
    208       { 
    209           CInterface::AttributeFortranInterfaceGetDeclaration<string>(oss, className, this->getName()); 
    210       } 
     137  StdString CAttributeEnum<T>::_toString(void) const 
     138  { 
     139     StdOStringStream oss; 
     140     if (!CEnum<T>::isEmpty() && this->hasId()) 
     141        oss << this->getName() << "=\"" << CEnum<T>::toString() << "\""; 
     142     return (oss.str()); 
     143  } 
     144 
     145  template <class T> 
     146  void CAttributeEnum<T>::_fromString(const StdString & str) 
     147  { 
     148    CEnum<T>::fromString(str); 
     149  } 
     150 
     151  template <class T> 
     152  bool CAttributeEnum<T>::_toBuffer (CBufferOut& buffer) const 
     153  { 
     154     return CEnum<T>::toBuffer(buffer); 
     155  } 
     156 
     157  template <class T> 
     158  bool CAttributeEnum<T>::_fromBuffer(CBufferIn& buffer) 
     159  { 
     160    return CEnum<T>::fromBuffer(buffer); 
     161  } 
     162 
     163  template <typename T> 
     164  void CAttributeEnum<T>::generateCInterface(ostream& oss,const string& className) 
     165  { 
     166    CInterface::AttributeCInterface<CEnumBase>(oss, className, this->getName()); 
     167  } 
     168 
     169  template <typename T> 
     170  void CAttributeEnum<T>::generateFortran2003Interface(ostream& oss,const string& className) 
     171  { 
     172    CInterface::AttributeFortran2003Interface<string>(oss, className, this->getName()); 
     173  } 
     174 
     175  template <typename T> 
     176  void CAttributeEnum<T>::generateFortranInterfaceDeclaration_(ostream& oss,const string& className) 
     177  { 
     178    CInterface::AttributeFortranInterfaceDeclaration<string>(oss, className, this->getName()+"_"); 
     179  } 
     180 
     181  template <typename T> 
     182  void CAttributeEnum<T>::generateFortranInterfaceBody_(ostream& oss,const string& className) 
     183  { 
     184    CInterface::AttributeFortranInterfaceBody<string>(oss, className, this->getName()); 
     185  } 
     186 
     187  template <typename T> 
     188  void CAttributeEnum<T>::generateFortranInterfaceDeclaration(ostream& oss,const string& className) 
     189  { 
     190    CInterface::AttributeFortranInterfaceDeclaration<string>(oss, className, this->getName()); 
     191  } 
     192 
     193  template <typename T> 
     194  void CAttributeEnum<T>::generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className) 
     195  { 
     196    CInterface::AttributeFortranInterfaceGetDeclaration<string>(oss, className, this->getName()+"_"); 
     197  } 
     198 
     199  template <typename T> 
     200  void CAttributeEnum<T>::generateFortranInterfaceGetBody_(ostream& oss,const string& className) 
     201  { 
     202    CInterface::AttributeFortranInterfaceGetBody<string>(oss, className, this->getName()); 
     203  } 
     204 
     205  template <typename T> 
     206  void CAttributeEnum<T>::generateFortranInterfaceGetDeclaration(ostream& oss,const string& className) 
     207  { 
     208    CInterface::AttributeFortranInterfaceGetDeclaration<string>(oss, className, this->getName()); 
     209  } 
    211210} // namespace xios 
    212211 
    213212#endif // __XIOS_ATTRIBUTE_ENUM_IMPL_HPP__ 
    214  
  • XIOS/dev/branch_openmp/src/attribute_map.hpp

    r1134 r1328  
    7676            /// Propriété statique /// 
    7777            static CAttributeMap * Current; 
    78             #pragma omp threadprivate (Current) 
    7978 
    8079      };  // class CAttributeMap 
  • XIOS/dev/branch_openmp/src/buffer_client.cpp

    r1205 r1328  
    77#include "mpi.hpp" 
    88#include "tracer.hpp" 
     9 
     10 
     11using namespace ep_lib; 
    912 
    1013namespace xios 
     
    2730    buffer[1] = new char[bufferSize]; 
    2831    retBuffer = new CBufferOut(buffer[current], bufferSize); 
    29     #pragma omp critical (_output) 
    3032    info(10) << "CClientBuffer: allocated 2 x " << bufferSize << " bytes for server " << serverRank << " with a maximum of " << maxBufferedEvents << " buffered events" << endl; 
    3133  } 
  • XIOS/dev/branch_openmp/src/buffer_client.hpp

    r1205 r1328  
    66#include "mpi.hpp" 
    77#include "cxios.hpp" 
    8 #ifdef _usingEP 
    9 #include "ep_declaration.hpp" 
    10 #endif 
    118 
    129namespace xios 
     
    1613    public: 
    1714      static size_t maxRequestSize; 
    18       #pragma omp threadprivate(maxRequestSize) 
    1915 
    20       CClientBuffer(MPI_Comm intercomm, int serverRank, StdSize bufferSize, StdSize estimatedMaxEventSize, StdSize maxBufferedEvents); 
     16      CClientBuffer(ep_lib::MPI_Comm intercomm, int serverRank, StdSize bufferSize, StdSize estimatedMaxEventSize, StdSize maxBufferedEvents); 
    2117      ~CClientBuffer(); 
    2218 
     
    4036      bool pending; 
    4137 
    42       MPI_Request request; 
     38      ep_lib::MPI_Request request; 
    4339 
    4440      CBufferOut* retBuffer; 
    45       const MPI_Comm interComm; 
     41      const ep_lib::MPI_Comm interComm; 
    4642  }; 
    4743} 
  • XIOS/dev/branch_openmp/src/buffer_server.hpp

    r1134 r1328  
    44#include "xios_spl.hpp" 
    55#include "buffer.hpp" 
    6 #include "mpi_std.hpp" 
     6#include "mpi.hpp" 
    77#include "cxios.hpp" 
    88 
  • XIOS/dev/branch_openmp/src/calendar.cpp

    r1134 r1328  
    117117      const CDate& CCalendar::update(int step) 
    118118      { 
    119         #pragma omp critical (_output) 
    120         info(80)<< "update step : " << step << " timestep " << this->timestep << std::endl; 
     119        info(20) << "update step : " << step << " timestep " << this->timestep << std::endl; 
    121120        return (this->currentDate = this->getInitDate() + step * this->timestep); 
    122121      } 
  • XIOS/dev/branch_openmp/src/client.cpp

    r1205 r1328  
    1111#include "timer.hpp" 
    1212#include "buffer_client.hpp" 
    13 #include "log.hpp" 
    14  
     13using namespace ep_lib; 
    1514 
    1615namespace xios 
    1716{ 
    18     extern int test_omp_rank; 
    19     #pragma omp threadprivate(test_omp_rank) 
    2017 
    2118    MPI_Comm CClient::intraComm ; 
    2219    MPI_Comm CClient::interComm ; 
     20    //std::list<MPI_Comm> CClient::contextInterComms; 
    2321    std::list<MPI_Comm> *CClient::contextInterComms_ptr = 0; 
    2422    int CClient::serverLeader ; 
     
    2826    StdOFStream CClient::m_errorStream; 
    2927 
    30     StdOFStream CClient::array_infoStream[16]; 
    31  
    32     void CClient::initialize(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm) 
     28    void CClient::initialize(const string& codeId,MPI_Comm& localComm,MPI_Comm& returnComm) 
    3329    { 
    3430      int initialized ; 
     
    4137      { 
    4238// localComm doesn't given 
    43  
    4439        if (localComm == MPI_COMM_NULL) 
    4540        { 
    4641          if (!is_MPI_Initialized) 
    4742          { 
    48             //MPI_Init(NULL, NULL); 
    49             int return_level; 
    50             MPI_Init_thread(NULL, NULL, 3, &return_level); 
    51             assert(return_level == 3); 
     43            MPI_Init(NULL, NULL); 
    5244          } 
    5345          CTimer::get("XIOS").resume() ; 
     
    6153          int myColor ; 
    6254          int i,c ; 
    63  
    64           MPI_Comm_size(CXios::globalComm,&size); 
     55          MPI_Comm newComm ; 
     56 
     57          MPI_Comm_size(CXios::globalComm,&size) ; 
    6558          MPI_Comm_rank(CXios::globalComm,&rank); 
    66         
    6759 
    6860          hashAll=new unsigned long[size] ; 
     
    10698            MPI_Comm_size(intraComm,&intraCommSize) ; 
    10799            MPI_Comm_rank(intraComm,&intraCommRank) ; 
    108              
    109             #pragma omp critical(_output) 
    110             { 
    111               info(10)<<"intercommCreate::client "<<test_omp_rank<< " "<< &test_omp_rank <<" intraCommSize : "<<intraCommSize 
    112                  <<" intraCommRank :"<<intraCommRank<<"  serverLeader "<< serverLeader 
    113                  <<" globalComm : "<< &(CXios::globalComm) << endl ;   
    114             } 
    115  
    116              
    117             //test_sendrecv(CXios::globalComm); 
     100            info(50)<<"intercommCreate::client "<<rank<<" intraCommSize : "<<intraCommSize 
     101                 <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< serverLeader<<endl ; 
    118102            MPI_Intercomm_create(intraComm,0,CXios::globalComm,serverLeader,0,&interComm) ; 
    119  
    120103          } 
    121104          else 
     
    140123      } 
    141124      // using OASIS 
    142       else 
     125/*      else 
    143126      { 
    144127        // localComm doesn't given 
     
    165148        else MPI_Comm_dup(intraComm,&interComm) ; 
    166149      } 
    167  
     150*/ 
    168151      MPI_Comm_dup(intraComm,&returnComm) ; 
    169  
    170152    } 
    171153 
     
    174156    { 
    175157      CContext::setCurrent(id) ; 
    176       CContext* context = CContext::create(id); 
    177  
    178       int tmp_rank; 
    179       MPI_Comm_rank(contextComm,&tmp_rank) ; 
    180        
     158      CContext* context=CContext::create(id); 
    181159      StdString idServer(id); 
    182160      idServer += "_server"; 
     
    185163      { 
    186164        int size,rank,globalRank ; 
    187         //size_t message_size ; 
    188         //int leaderRank ; 
     165        size_t message_size ; 
     166        int leaderRank ; 
    189167        MPI_Comm contextInterComm ; 
    190168 
     
    197175        CMessage msg ; 
    198176        msg<<idServer<<size<<globalRank ; 
    199  
     177//        msg<<id<<size<<globalRank ; 
    200178 
    201179        int messageSize=msg.size() ; 
     
    208186 
    209187        MPI_Intercomm_create(contextComm,0,CXios::globalComm,serverLeader,10+globalRank,&contextInterComm) ; 
    210          
    211         #pragma omp critical(_output) 
    212         info(10)<<" RANK "<< tmp_rank<<" Register new Context : "<<id<<endl ; 
    213  
     188        info(10)<<"Register new Context : "<<id<<endl ; 
    214189 
    215190        MPI_Comm inter ; 
     
    217192        MPI_Barrier(inter) ; 
    218193 
    219          
    220194        context->initClient(contextComm,contextInterComm) ; 
    221195 
    222          
     196        //contextInterComms.push_back(contextInterComm); 
    223197        if(contextInterComms_ptr == NULL) contextInterComms_ptr = new std::list<MPI_Comm>; 
    224198        contextInterComms_ptr->push_back(contextInterComm); 
    225          
    226199        MPI_Comm_free(&inter); 
    227200      } 
     
    240213        // Finally, we should return current context to context client 
    241214        CContext::setCurrent(id); 
    242          
     215 
     216        //contextInterComms.push_back(contextInterComm); 
    243217        if(contextInterComms_ptr == NULL) contextInterComms_ptr = new std::list<MPI_Comm>; 
    244218        contextInterComms_ptr->push_back(contextInterComm); 
    245  
    246219      } 
    247220    } 
     
    253226 
    254227      MPI_Comm_rank(intraComm,&rank) ; 
    255  
     228  
    256229      if (!CXios::isServer) 
    257230      { 
     
    263236      } 
    264237 
    265       for (std::list<MPI_Comm>::iterator it = contextInterComms_ptr->begin(); it != contextInterComms_ptr->end(); ++it) 
     238      //for (std::list<MPI_Comm>::iterator it = contextInterComms.begin(); it != contextInterComms.end(); it++) 
     239      for (std::list<MPI_Comm>::iterator it = contextInterComms_ptr->begin(); it != contextInterComms_ptr->end(); it++) 
    266240        MPI_Comm_free(&(*it)); 
    267        
    268241      MPI_Comm_free(&interComm); 
    269242      MPI_Comm_free(&intraComm); 
     
    274247      if (!is_MPI_Initialized) 
    275248      { 
    276         if (CXios::usingOasis) oasis_finalize(); 
    277         else MPI_Finalize(); 
     249        //if (CXios::usingOasis) oasis_finalize(); 
     250        //else 
     251        MPI_Finalize() ; 
    278252      } 
    279253       
    280       #pragma omp critical (_output) 
    281       info(20) << "Client "<<rank<<" : Client side context is finalized "<< endl ; 
    282  
    283    /*#pragma omp critical (_output) 
    284    { 
     254      info(20) << "Client side context is finalized"<<endl ; 
    285255      report(0) <<" Performance report : Whole time from XIOS init and finalize: "<< CTimer::get("XIOS init/finalize").getCumulatedTime()<<" s"<<endl ; 
    286256      report(0) <<" Performance report : total time spent for XIOS : "<< CTimer::get("XIOS").getCumulatedTime()<<" s"<<endl ; 
     
    292262      report(0)<< " Memory report : increasing it by a factor will increase performance, depending of the volume of data wrote in file at each time step of the file"<<endl ; 
    293263      report(100)<<CTimer::getAllCumulatedTime()<<endl ; 
    294    }*/ 
    295     
    296264   } 
    297265 
     
    322290 
    323291      fileNameClient << fileName << "_" << std::setfill('0') << std::setw(numDigit) << getRank() << ext; 
    324        
    325292      fb->open(fileNameClient.str().c_str(), std::ios::out); 
    326293      if (!fb->is_open()) 
    327294        ERROR("void CClient::openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb)", 
    328             << std::endl << "Can not open <" << fileNameClient << "> file to write the client log(s)."); 
     295              << std::endl << "Can not open <" << fileNameClient << "> file to write the client log(s)."); 
    329296    } 
    330297 
     
    337304    void CClient::openInfoStream(const StdString& fileName) 
    338305    { 
    339       //std::filebuf* fb = m_infoStream.rdbuf(); 
    340  
    341       info_FB[omp_get_thread_num()] = array_infoStream[omp_get_thread_num()].rdbuf(); 
    342            
    343       openStream(fileName, ".out", info_FB[omp_get_thread_num()]); 
    344  
    345       info.write2File(info_FB[omp_get_thread_num()]); 
    346       report.write2File(info_FB[omp_get_thread_num()]); 
    347        
     306      std::filebuf* fb = m_infoStream.rdbuf(); 
     307      openStream(fileName, ".out", fb); 
     308 
     309      info.write2File(fb); 
     310      report.write2File(fb); 
    348311    } 
    349312 
  • XIOS/dev/branch_openmp/src/client.hpp

    r1164 r1328  
    1010    { 
    1111      public: 
    12         static void initialize(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm); 
     12        static void initialize(const string& codeId, ep_lib::MPI_Comm& localComm, ep_lib::MPI_Comm& returnComm); 
    1313        static void finalize(void); 
    1414        static void registerContext(const string& id, ep_lib::MPI_Comm contextComm); 
    1515 
    16         static MPI_Comm intraComm; 
    17         #pragma omp threadprivate(intraComm) 
    18  
    19         static MPI_Comm interComm; 
    20         #pragma omp threadprivate(interComm) 
    21  
     16        static ep_lib::MPI_Comm intraComm; 
     17        static ep_lib::MPI_Comm interComm; 
    2218        //static std::list<MPI_Comm> contextInterComms; 
    23          
    24         static std::list<MPI_Comm> * contextInterComms_ptr; 
    25         #pragma omp threadprivate(contextInterComms_ptr) 
    26  
     19        static std::list<ep_lib::MPI_Comm> *contextInterComms_ptr; 
    2720        static int serverLeader; 
    28         #pragma omp threadprivate(serverLeader) 
    29  
    3021        static bool is_MPI_Initialized ; 
    31         #pragma omp threadprivate(is_MPI_Initialized) 
    3222 
    3323        //! Get rank of the current process 
     
    5040      protected: 
    5141        static int rank; 
    52         #pragma omp threadprivate(rank) 
    53  
    5442        static StdOFStream m_infoStream; 
    55         #pragma omp threadprivate(m_infoStream)  
    56  
    5743        static StdOFStream m_errorStream; 
    58         #pragma omp threadprivate(m_errorStream) 
    59  
    60         static StdOFStream array_infoStream[16]; 
    6144 
    6245        static void openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb); 
  • XIOS/dev/branch_openmp/src/client_client_dht_template.hpp

    r1134 r1328  
    1313#include "xios_spl.hpp" 
    1414#include "array_new.hpp" 
    15 #include "mpi_std.hpp" 
     15#include "mpi.hpp" 
    1616#include "policy.hpp" 
    1717#include <boost/unordered_map.hpp> 
     
    8787                           const ep_lib::MPI_Comm& clientIntraComm, 
    8888                           std::vector<ep_lib::MPI_Request>& requestSendInfo); 
     89    void sendInfoToClients(int clientDestRank, unsigned char* info, int infoSize, 
     90                           const ep_lib::MPI_Comm& clientIntraComm, 
     91                           ep_lib::MPI_Request* requestSendInfo); 
    8992 
    9093    void recvInfoFromClients(int clientSrcRank, unsigned char* info, int infoSize, 
    9194                            const ep_lib::MPI_Comm& clientIntraComm, 
    9295                            std::vector<ep_lib::MPI_Request>& requestRecvInfo); 
     96    void recvInfoFromClients(int clientSrcRank, unsigned char* info, int infoSize, 
     97                             const ep_lib::MPI_Comm& clientIntraComm, 
     98                             ep_lib::MPI_Request* requestRecvInfo); 
     99                                                         
    93100 
    94101    // Send global index to clients 
     
    96103                            const ep_lib::MPI_Comm& clientIntraComm, 
    97104                            std::vector<ep_lib::MPI_Request>& requestSendIndexGlobal); 
     105    void sendIndexToClients(int clientDestRank, size_t* indices, size_t indiceSize, 
     106                            const ep_lib::MPI_Comm& clientIntraComm, 
     107                            ep_lib::MPI_Request* requestSendIndexGlobal); 
    98108 
    99109    void recvIndexFromClients(int clientSrcRank, size_t* indices, size_t indiceSize, 
    100110                             const ep_lib::MPI_Comm& clientIntraComm, 
    101111                             std::vector<ep_lib::MPI_Request>& requestRecvIndex); 
     112    void recvIndexFromClients(int clientSrcRank, size_t* indices, size_t indiceSize, 
     113                              const ep_lib::MPI_Comm& clientIntraComm, 
     114                              ep_lib::MPI_Request* requestRecvIndex); 
    102115 
    103116    void sendRecvOnReturn(const std::vector<int>& sendNbRank, std::vector<int>& sendNbElements, 
  • XIOS/dev/branch_openmp/src/client_client_dht_template_impl.hpp

    r1209 r1328  
    1010#include "utils.hpp" 
    1111#include "mpi_tag.hpp" 
    12 #ifdef _usingEP 
    13 #include "ep_declaration.hpp" 
    14 #include "ep_lib.hpp" 
    15 #endif 
    16  
    1712 
    1813namespace xios 
     
    2217  : H(clientIntraComm), index2InfoMapping_(), indexToInfoMappingLevel_(), nbClient_(0) 
    2318{ 
    24   MPI_Comm_size(clientIntraComm, &nbClient_); 
     19  ep_lib::MPI_Comm_size(clientIntraComm, &nbClient_); 
    2520  this->computeMPICommLevel(); 
    2621  int nbLvl = this->getNbLevel(); 
     
    4237  : H(clientIntraComm), index2InfoMapping_(), indexToInfoMappingLevel_(), nbClient_(0) 
    4338{ 
    44   MPI_Comm_size(clientIntraComm, &nbClient_); 
     39  ep_lib::MPI_Comm_size(clientIntraComm, &nbClient_); 
    4540  this->computeMPICommLevel(); 
    4641  int nbLvl = this->getNbLevel(); 
     
    6762  : H(clientIntraComm), index2InfoMapping_(), indexToInfoMappingLevel_(), nbClient_(0) 
    6863{ 
    69   MPI_Comm_size(clientIntraComm, &nbClient_); 
     64  ep_lib::MPI_Comm_size(clientIntraComm, &nbClient_); 
    7065  this->computeMPICommLevel(); 
    7166  int nbLvl = this->getNbLevel(); 
     
    10499{ 
    105100  int clientRank; 
    106   MPI_Comm_rank(commLevel,&clientRank); 
    107   //ep_lib::MPI_Barrier(commLevel); 
     101  ep_lib::MPI_Comm_rank(commLevel,&clientRank); 
    108102  int groupRankBegin = this->getGroupBegin()[level]; 
    109103  int nbClient = this->getNbInGroup()[level]; 
     
    175169    recvIndexBuff = new unsigned long[recvNbIndexCount]; 
    176170 
    177   int request_size = 0; 
    178  
    179   int currentIndex = 0; 
    180   int nbRecvClient = recvRankClient.size(); 
    181  
    182   int position = 0; 
    183  
    184   for (int idx = 0; idx < nbRecvClient; ++idx) 
     171int request_size = 0; 
     172  for (int idx = 0; idx < recvRankClient.size(); ++idx) 
    185173  { 
    186174    if (0 != recvNbIndexClientCount[idx]) 
    187     { 
    188       request_size++; 
    189     } 
     175      request_size ++; 
    190176  } 
    191177 
    192178  request_size += client2ClientIndex.size(); 
    193179 
    194  
    195180  std::vector<ep_lib::MPI_Request> request(request_size); 
    196  
     181   
    197182  std::vector<int>::iterator itbRecvIndex = recvRankClient.begin(), itRecvIndex, 
    198183                             iteRecvIndex = recvRankClient.end(), 
    199184                           itbRecvNbIndex = recvNbIndexClientCount.begin(), 
    200185                           itRecvNbIndex; 
    201    
    202    
     186  int currentIndex = 0; 
     187  int nbRecvClient = recvRankClient.size(); 
     188  int request_position = 0; 
     189  for (int idx = 0; idx < nbRecvClient; ++idx) 
     190  { 
     191    if (0 != recvNbIndexClientCount[idx]) 
     192      recvIndexFromClients(recvRankClient[idx], recvIndexBuff+currentIndex, recvNbIndexClientCount[idx], commLevel, &request[request_position++]); 
     193      //recvIndexFromClients(recvRankClient[idx], recvIndexBuff+currentIndex, recvNbIndexClientCount[idx], commLevel, request); 
     194    currentIndex += recvNbIndexClientCount[idx]; 
     195  } 
     196 
    203197  boost::unordered_map<int, size_t* >::iterator itbIndex = client2ClientIndex.begin(), itIndex, 
    204198                                                iteIndex = client2ClientIndex.end(); 
    205199  for (itIndex = itbIndex; itIndex != iteIndex; ++itIndex) 
    206   { 
    207     MPI_Isend(itIndex->second, sendNbIndexBuff[itIndex->first-groupRankBegin], MPI_UNSIGNED_LONG, itIndex->first, MPI_DHT_INDEX, commLevel, &request[position]); 
    208     position++; 
     200    sendIndexToClients(itIndex->first, (itIndex->second), sendNbIndexBuff[itIndex->first-groupRankBegin], commLevel, &request[request_position++]); 
    209201    //sendIndexToClients(itIndex->first, (itIndex->second), sendNbIndexBuff[itIndex->first-groupRankBegin], commLevel, request); 
    210   } 
    211      
    212   for (int idx = 0; idx < nbRecvClient; ++idx) 
    213   { 
    214     if (0 != recvNbIndexClientCount[idx]) 
    215     { 
    216       MPI_Irecv(recvIndexBuff+currentIndex, recvNbIndexClientCount[idx], MPI_UNSIGNED_LONG, 
    217             recvRankClient[idx], MPI_DHT_INDEX, commLevel, &request[position]); 
    218       position++; 
    219       //recvIndexFromClients(recvRankClient[idx], recvIndexBuff+currentIndex, recvNbIndexClientCount[idx], commLevel, request); 
    220     } 
    221     currentIndex += recvNbIndexClientCount[idx]; 
    222   } 
    223  
    224    
    225   std::vector<ep_lib::MPI_Status> status(request_size); 
    226   MPI_Waitall(request.size(), &request[0], &status[0]); 
    227  
     202 
     203  std::vector<ep_lib::MPI_Status> status(request.size()); 
     204  ep_lib::MPI_Waitall(request.size(), &request[0], &status[0]); 
    228205 
    229206  CArray<size_t,1>* tmpGlobalIndex; 
     
    238215    --level; 
    239216    computeIndexInfoMappingLevel(*tmpGlobalIndex, this->internalComm_, level); 
    240        
    241217  } 
    242218  else // Now, we are in the last level where necessary mappings are. 
     
    279255  } 
    280256 
    281   request_size = 0; 
     257int requestOnReturn_size=0; 
    282258  for (int idx = 0; idx < recvRankOnReturn.size(); ++idx) 
    283259  { 
    284260    if (0 != recvNbIndexOnReturn[idx]) 
    285261    { 
    286       request_size += 2; 
     262      requestOnReturn_size += 2; 
    287263    } 
    288264  } 
     
    292268    if (0 != sendNbIndexOnReturn[idx]) 
    293269    { 
    294       request_size += 2; 
    295     } 
    296   } 
    297  
    298   std::vector<ep_lib::MPI_Request> requestOnReturn(request_size); 
     270      requestOnReturn_size += 2; 
     271    } 
     272  } 
     273 
     274  int requestOnReturn_position=0; 
     275 
     276  std::vector<ep_lib::MPI_Request> requestOnReturn(requestOnReturn_size); 
    299277  currentIndex = 0; 
    300   position = 0; 
    301278  for (int idx = 0; idx < recvRankOnReturn.size(); ++idx) 
    302279  { 
     
    304281    { 
    305282      //recvIndexFromClients(recvRankOnReturn[idx], recvIndexBuffOnReturn+currentIndex, recvNbIndexOnReturn[idx], commLevel, requestOnReturn); 
    306       MPI_Irecv(recvIndexBuffOnReturn+currentIndex, recvNbIndexOnReturn[idx], MPI_UNSIGNED_LONG, 
    307             recvRankOnReturn[idx], MPI_DHT_INDEX, commLevel, &requestOnReturn[position]); 
    308       position++; 
    309283      //recvInfoFromClients(recvRankOnReturn[idx], 
    310284      //                    recvInfoBuffOnReturn+currentIndex*ProcessDHTElement<InfoType>::typeSize(), 
    311285      //                    recvNbIndexOnReturn[idx]*ProcessDHTElement<InfoType>::typeSize(), 
    312286      //                    commLevel, requestOnReturn); 
    313       MPI_Irecv(recvInfoBuffOnReturn+currentIndex*ProcessDHTElement<InfoType>::typeSize(),  
    314                 recvNbIndexOnReturn[idx]*ProcessDHTElement<InfoType>::typeSize(), MPI_CHAR, 
    315                 recvRankOnReturn[idx], MPI_DHT_INFO, commLevel, &requestOnReturn[position]); 
    316       position++; 
     287      recvIndexFromClients(recvRankOnReturn[idx], recvIndexBuffOnReturn+currentIndex, recvNbIndexOnReturn[idx], commLevel, &requestOnReturn[requestOnReturn_position++]); 
     288      recvInfoFromClients(recvRankOnReturn[idx], 
     289                          recvInfoBuffOnReturn+currentIndex*ProcessDHTElement<InfoType>::typeSize(), 
     290                          recvNbIndexOnReturn[idx]*ProcessDHTElement<InfoType>::typeSize(), 
     291                          commLevel, &requestOnReturn[requestOnReturn_position++]); 
    317292    } 
    318293    currentIndex += recvNbIndexOnReturn[idx]; 
     
    349324      //sendIndexToClients(rank, client2ClientIndexOnReturn[rank], 
    350325      //                   sendNbIndexOnReturn[idx], commLevel, requestOnReturn); 
    351       MPI_Isend(client2ClientIndexOnReturn[rank], sendNbIndexOnReturn[idx], MPI_UNSIGNED_LONG, 
    352             rank, MPI_DHT_INDEX, commLevel, &requestOnReturn[position]); 
    353       position++; 
    354326      //sendInfoToClients(rank, client2ClientInfoOnReturn[rank], 
    355327      //                  sendNbIndexOnReturn[idx]*ProcessDHTElement<InfoType>::typeSize(), commLevel, requestOnReturn); 
    356       MPI_Isend(client2ClientInfoOnReturn[rank], sendNbIndexOnReturn[idx]*ProcessDHTElement<InfoType>::typeSize(), MPI_CHAR, 
    357             rank, MPI_DHT_INFO, commLevel, &requestOnReturn[position]); 
    358       position++; 
     328      sendIndexToClients(rank, client2ClientIndexOnReturn[rank], 
     329                         sendNbIndexOnReturn[idx], commLevel, &requestOnReturn[requestOnReturn_position++]); 
     330      sendInfoToClients(rank, client2ClientInfoOnReturn[rank], 
     331                        sendNbIndexOnReturn[idx]*ProcessDHTElement<InfoType>::typeSize(), commLevel, &requestOnReturn[requestOnReturn_position++]); 
     332       
    359333    } 
    360334    currentIndex += recvNbIndexClientCount[idx]; 
     
    362336 
    363337  std::vector<ep_lib::MPI_Status> statusOnReturn(requestOnReturn.size()); 
    364   MPI_Waitall(requestOnReturn.size(), &requestOnReturn[0], &statusOnReturn[0]); 
     338  ep_lib::MPI_Waitall(requestOnReturn.size(), &requestOnReturn[0], &statusOnReturn[0]); 
    365339 
    366340  Index2VectorInfoTypeMap indexToInfoMapping; 
     
    432406{ 
    433407  int clientRank; 
    434   MPI_Comm_rank(commLevel,&clientRank); 
     408  ep_lib::MPI_Comm_rank(commLevel,&clientRank); 
    435409  computeSendRecvRank(level, clientRank); 
    436   //ep_lib::MPI_Barrier(commLevel); 
    437410 
    438411  int groupRankBegin = this->getGroupBegin()[level]; 
     
    481454    { 
    482455      client2ClientIndex[indexClient + groupRankBegin][sendNbIndexBuff[indexClient]] = it->first;; 
     456  //          ProcessDHTElement<InfoType>::packElement(it->second, client2ClientInfo[indexClient + groupRankBegin], sendNbInfo[indexClient]); 
    483457      ProcessDHTElement<InfoType>::packElement(infoTmp[idx], client2ClientInfo[indexClient + groupRankBegin], sendNbInfo[indexClient]); 
    484458      ++sendNbIndexBuff[indexClient]; 
     
    494468  int recvNbIndexCount = 0; 
    495469  for (int idx = 0; idx < recvNbIndexClientCount.size(); ++idx) 
    496   {  
    497470    recvNbIndexCount += recvNbIndexClientCount[idx]; 
    498   } 
    499471 
    500472  unsigned long* recvIndexBuff; 
     
    509481  // it will send a message to the correct clients. 
    510482  // Contents of the message are index and its corresponding informatioin 
    511   int request_size = 0;   
     483  int request_size = 0; 
     484   for (int idx = 0; idx < recvRankClient.size(); ++idx) 
     485   { 
     486     if (0 != recvNbIndexClientCount[idx]) 
     487     { 
     488       request_size += 2; 
     489     } 
     490   } 
     491  
     492   request_size += client2ClientIndex.size(); 
     493   request_size += client2ClientInfo.size(); 
     494  
     495   std::vector<ep_lib::MPI_Request> request(request_size); 
    512496  int currentIndex = 0; 
    513497  int nbRecvClient = recvRankClient.size(); 
    514   int current_pos = 0;  
    515  
     498  int request_position=0; 
    516499  for (int idx = 0; idx < nbRecvClient; ++idx) 
    517500  { 
    518501    if (0 != recvNbIndexClientCount[idx]) 
    519502    { 
    520       request_size += 2; 
    521     } 
    522     //currentIndex += recvNbIndexClientCount[idx]; 
    523   } 
    524  
    525   request_size += client2ClientIndex.size(); 
    526   request_size += client2ClientInfo.size(); 
    527  
    528  
    529  
    530   std::vector<ep_lib::MPI_Request> request(request_size); 
    531    
    532   //unsigned long* tmp_send_buf_long[client2ClientIndex.size()]; 
    533   //unsigned char* tmp_send_buf_char[client2ClientInfo.size()]; 
    534    
    535   int info_position = 0; 
    536   int index_position = 0; 
    537  
     503      //recvIndexFromClients(recvRankClient[idx], recvIndexBuff+currentIndex, recvNbIndexClientCount[idx], commLevel, request); 
     504      //recvInfoFromClients(recvRankClient[idx], 
     505      //                    recvInfoBuff+currentIndex*ProcessDHTElement<InfoType>::typeSize(), 
     506      //                    recvNbIndexClientCount[idx]*ProcessDHTElement<InfoType>::typeSize(), 
     507      //                    commLevel, request); 
     508        recvIndexFromClients(recvRankClient[idx], recvIndexBuff+currentIndex, recvNbIndexClientCount[idx], commLevel, &request[request_position++]); 
     509        recvInfoFromClients(recvRankClient[idx], 
     510                            recvInfoBuff+currentIndex*ProcessDHTElement<InfoType>::typeSize(), 
     511                            recvNbIndexClientCount[idx]*ProcessDHTElement<InfoType>::typeSize(), 
     512                            commLevel, &request[request_position++]); 
     513    } 
     514    currentIndex += recvNbIndexClientCount[idx]; 
     515  } 
    538516 
    539517  boost::unordered_map<int, size_t* >::iterator itbIndex = client2ClientIndex.begin(), itIndex, 
    540518                                                iteIndex = client2ClientIndex.end(); 
    541519  for (itIndex = itbIndex; itIndex != iteIndex; ++itIndex) 
    542   { 
     520    sendIndexToClients(itIndex->first, itIndex->second, sendNbIndexBuff[itIndex->first-groupRankBegin], commLevel, &request[request_position++]); 
    543521    //sendIndexToClients(itIndex->first, itIndex->second, sendNbIndexBuff[itIndex->first-groupRankBegin], commLevel, request); 
    544  
    545     //tmp_send_buf_long[index_position] = new unsigned long[sendNbIndexBuff[itIndex->first-groupRankBegin]]; 
    546     //for(int i=0; i<sendNbIndexBuff[itIndex->first-groupRankBegin]; i++) 
    547     //{ 
    548     //  tmp_send_buf_long[index_position][i] = (static_cast<unsigned long * >(itIndex->second))[i]; 
    549     //} 
    550     //MPI_Isend(tmp_send_buf_long[current_pos], sendNbIndexBuff[itIndex->first-groupRankBegin], MPI_UNSIGNED_LONG, 
    551     MPI_Isend(itIndex->second, sendNbIndexBuff[itIndex->first-groupRankBegin], MPI_UNSIGNED_LONG, 
    552               itIndex->first, MPI_DHT_INDEX, commLevel, &request[current_pos]); 
    553     current_pos++;  
    554     index_position++; 
    555  
    556   } 
    557  
    558522  boost::unordered_map<int, unsigned char*>::iterator itbInfo = client2ClientInfo.begin(), itInfo, 
    559523                                                      iteInfo = client2ClientInfo.end(); 
    560524  for (itInfo = itbInfo; itInfo != iteInfo; ++itInfo) 
    561   { 
     525    sendInfoToClients(itInfo->first, itInfo->second, sendNbInfo[itInfo->first-groupRankBegin], commLevel, &request[request_position++]); 
    562526    //sendInfoToClients(itInfo->first, itInfo->second, sendNbInfo[itInfo->first-groupRankBegin], commLevel, request); 
    563527 
    564     //tmp_send_buf_char[info_position] = new unsigned char[sendNbInfo[itInfo->first-groupRankBegin]]; 
    565     //for(int i=0; i<sendNbInfo[itInfo->first-groupRankBegin]; i++) 
    566     //{ 
    567     //  tmp_send_buf_char[info_position][i] = (static_cast<unsigned char * >(itInfo->second))[i]; 
    568     //} 
    569  
    570     MPI_Isend(itInfo->second, sendNbInfo[itInfo->first-groupRankBegin], MPI_CHAR, 
    571               itInfo->first, MPI_DHT_INFO, commLevel, &request[current_pos]); 
    572  
    573     current_pos++; 
    574     info_position++; 
    575   } 
    576    
    577   for (int idx = 0; idx < nbRecvClient; ++idx) 
    578   { 
    579     if (0 != recvNbIndexClientCount[idx]) 
    580     { 
    581       //recvIndexFromClients(recvRankClient[idx], recvIndexBuff+currentIndex, recvNbIndexClientCount[idx], commLevel, request); 
    582       MPI_Irecv(recvIndexBuff+currentIndex, recvNbIndexClientCount[idx], MPI_UNSIGNED_LONG, 
    583                 recvRankClient[idx], MPI_DHT_INDEX, commLevel, &request[current_pos]); 
    584       current_pos++; 
    585        
    586        
    587       MPI_Irecv(recvInfoBuff+currentIndex*ProcessDHTElement<InfoType>::typeSize(),  
    588                 recvNbIndexClientCount[idx]*ProcessDHTElement<InfoType>::typeSize(),  
    589                 MPI_CHAR, recvRankClient[idx], MPI_DHT_INFO, commLevel, &request[current_pos]); 
    590        
    591       current_pos++; 
    592        
    593  
    594  
    595       // recvInfoFromClients(recvRankClient[idx], 
    596       //                     recvInfoBuff+currentIndex*ProcessDHTElement<InfoType>::typeSize(), 
    597       //                     recvNbIndexClientCount[idx]*ProcessDHTElement<InfoType>::typeSize(), 
    598       //                     commLevel, request); 
    599     } 
    600     currentIndex += recvNbIndexClientCount[idx]; 
    601   } 
    602  
    603528  std::vector<ep_lib::MPI_Status> status(request.size()); 
    604    
    605   MPI_Waitall(request.size(), &request[0], &status[0]); 
    606    
    607   
    608   //for(int i=0; i<client2ClientInfo.size(); i++) 
    609   //  delete[] tmp_send_buf_char[i]; 
    610  
    611    
    612  
    613   //for(int i=0; i<client2ClientIndex.size(); i++) 
    614   //  delete[] tmp_send_buf_long[i]; 
    615  
     529  ep_lib::MPI_Waitall(request.size(), &request[0], &status[0]); 
    616530 
    617531  Index2VectorInfoTypeMap indexToInfoMapping; 
     
    654568  else 
    655569    index2InfoMapping_.swap(indexToInfoMapping); 
    656    
    657570} 
    658571 
     
    670583                                                       std::vector<ep_lib::MPI_Request>& requestSendIndex) 
    671584{ 
    672   printf("should not call this function sendIndexToClients");   
    673585  ep_lib::MPI_Request request; 
    674586  requestSendIndex.push_back(request); 
    675   MPI_Isend(indices, indiceSize, MPI_UNSIGNED_LONG, 
     587  ep_lib::MPI_Isend(indices, indiceSize, MPI_UNSIGNED_LONG, 
    676588            clientDestRank, MPI_DHT_INDEX, clientIntraComm, &(requestSendIndex.back())); 
     589} 
     590 
     591/*! 
     592  Send message containing index to clients 
     593  \param [in] clientDestRank rank of destination client 
     594  \param [in] indices index to send 
     595  \param [in] indiceSize size of index array to send 
     596  \param [in] clientIntraComm communication group of client 
     597  \param [in] requestSendIndex sending request 
     598*/ 
     599template<typename T, typename H> 
     600void CClientClientDHTTemplate<T,H>::sendIndexToClients(int clientDestRank, size_t* indices, size_t indiceSize, 
     601                                                       const ep_lib::MPI_Comm& clientIntraComm, 
     602                                                       ep_lib::MPI_Request* requestSendIndex) 
     603{ 
     604  ep_lib::MPI_Isend(indices, indiceSize, MPI_UNSIGNED_LONG, 
     605            clientDestRank, MPI_DHT_INDEX, clientIntraComm, requestSendIndex); 
    677606} 
    678607 
     
    689618                                                         std::vector<ep_lib::MPI_Request>& requestRecvIndex) 
    690619{ 
    691   printf("should not call this function recvIndexFromClients"); 
    692620  ep_lib::MPI_Request request; 
    693621  requestRecvIndex.push_back(request); 
    694   MPI_Irecv(indices, indiceSize, MPI_UNSIGNED_LONG, 
     622  ep_lib::MPI_Irecv(indices, indiceSize, MPI_UNSIGNED_LONG, 
    695623            clientSrcRank, MPI_DHT_INDEX, clientIntraComm, &(requestRecvIndex.back())); 
     624} 
     625 
     626/*! 
     627  Receive message containing index to clients 
     628  \param [in] clientDestRank rank of destination client 
     629  \param [in] indices index to send 
     630  \param [in] clientIntraComm communication group of client 
     631  \param [in] requestRecvIndex receiving request 
     632*/ 
     633template<typename T, typename H> 
     634void CClientClientDHTTemplate<T,H>::recvIndexFromClients(int clientSrcRank, size_t* indices, size_t indiceSize, 
     635                                                         const ep_lib::MPI_Comm& clientIntraComm, 
     636                                                         ep_lib::MPI_Request *requestRecvIndex) 
     637{ 
     638  ep_lib::MPI_Irecv(indices, indiceSize, MPI_UNSIGNED_LONG, 
     639            clientSrcRank, MPI_DHT_INDEX, clientIntraComm, requestRecvIndex); 
    696640} 
    697641 
     
    709653                                                      std::vector<ep_lib::MPI_Request>& requestSendInfo) 
    710654{ 
    711   printf("should not call this function sendInfoToClients"); 
    712655  ep_lib::MPI_Request request; 
    713656  requestSendInfo.push_back(request); 
    714   MPI_Isend(info, infoSize, MPI_CHAR, 
     657 
     658  ep_lib::MPI_Isend(info, infoSize, MPI_CHAR, 
    715659            clientDestRank, MPI_DHT_INFO, clientIntraComm, &(requestSendInfo.back())); 
     660} 
     661 
     662/*! 
     663  Send message containing information to clients 
     664  \param [in] clientDestRank rank of destination client 
     665  \param [in] info info array to send 
     666  \param [in] infoSize info array size to send 
     667  \param [in] clientIntraComm communication group of client 
     668  \param [in] requestSendInfo sending request 
     669*/ 
     670template<typename T, typename H> 
     671void CClientClientDHTTemplate<T,H>::sendInfoToClients(int clientDestRank, unsigned char* info, int infoSize, 
     672                                                      const ep_lib::MPI_Comm& clientIntraComm, 
     673                                                      ep_lib::MPI_Request *requestSendInfo) 
     674{ 
     675  ep_lib::MPI_Isend(info, infoSize, MPI_CHAR, 
     676            clientDestRank, MPI_DHT_INFO, clientIntraComm, requestSendInfo); 
    716677} 
    717678 
     
    729690                                                        std::vector<ep_lib::MPI_Request>& requestRecvInfo) 
    730691{ 
    731   printf("should not call this function recvInfoFromClients\n"); 
    732692  ep_lib::MPI_Request request; 
    733693  requestRecvInfo.push_back(request); 
    734694 
    735   MPI_Irecv(info, infoSize, MPI_CHAR, 
     695  ep_lib::MPI_Irecv(info, infoSize, MPI_CHAR, 
    736696            clientSrcRank, MPI_DHT_INFO, clientIntraComm, &(requestRecvInfo.back())); 
     697} 
     698 
     699/*! 
     700  Receive message containing information from other clients 
     701  \param [in] clientDestRank rank of destination client 
     702  \param [in] info info array to receive 
     703  \param [in] infoSize info array size to receive 
     704  \param [in] clientIntraComm communication group of client 
     705  \param [in] requestRecvInfo list of receiving request 
     706*/ 
     707template<typename T, typename H> 
     708void CClientClientDHTTemplate<T,H>::recvInfoFromClients(int clientSrcRank, unsigned char* info, int infoSize, 
     709                                                        const ep_lib::MPI_Comm& clientIntraComm, 
     710                                                        ep_lib::MPI_Request* requestRecvInfo) 
     711{ 
     712  ep_lib::MPI_Irecv(info, infoSize, MPI_CHAR, 
     713            clientSrcRank, MPI_DHT_INFO, clientIntraComm, requestRecvInfo); 
    737714} 
    738715 
     
    807784 
    808785  int nRequest = 0; 
    809    
     786  for (int idx = 0; idx < recvNbRank.size(); ++idx) 
     787  { 
     788    ep_lib::MPI_Irecv(&recvNbElements[0]+idx, 1, MPI_INT, 
     789              recvNbRank[idx], MPI_DHT_INDEX_1, this->internalComm_, &request[nRequest]); 
     790    ++nRequest; 
     791  } 
    810792 
    811793  for (int idx = 0; idx < sendNbRank.size(); ++idx) 
    812794  { 
    813     MPI_Isend(&sendNbElements[0]+idx, 1, MPI_INT, 
     795    ep_lib::MPI_Isend(&sendNbElements[0]+idx, 1, MPI_INT, 
    814796              sendNbRank[idx], MPI_DHT_INDEX_1, this->internalComm_, &request[nRequest]); 
    815797    ++nRequest; 
    816798  } 
    817    
    818   for (int idx = 0; idx < recvNbRank.size(); ++idx) 
    819   { 
    820     MPI_Irecv(&recvNbElements[0]+idx, 1, MPI_INT, 
    821               recvNbRank[idx], MPI_DHT_INDEX_1, this->internalComm_, &request[nRequest]); 
    822     ++nRequest; 
    823   } 
    824  
    825   MPI_Waitall(sendNbRank.size()+recvNbRank.size(), &request[0], &requestStatus[0]); 
     799 
     800  ep_lib::MPI_Waitall(sendNbRank.size()+recvNbRank.size(), &request[0], &requestStatus[0]); 
    826801} 
    827802 
     
    852827  std::vector<ep_lib::MPI_Request> request(sendBuffSize+recvBuffSize); 
    853828  std::vector<ep_lib::MPI_Status> requestStatus(sendBuffSize+recvBuffSize); 
    854   //ep_lib::MPI_Request request[sendBuffSize+recvBuffSize]; 
    855   //ep_lib::MPI_Status requestStatus[sendBuffSize+recvBuffSize]; 
    856    
    857   int my_rank; 
    858   MPI_Comm_rank(this->internalComm_, &my_rank); 
    859    
     829 
    860830  int nRequest = 0; 
    861831  for (int idx = 0; idx < recvBuffSize; ++idx) 
    862832  { 
    863     MPI_Irecv(&recvBuff[2*idx], 2, MPI_INT, 
     833    ep_lib::MPI_Irecv(&recvBuff[0]+2*idx, 2, MPI_INT, 
    864834              recvRank[idx], MPI_DHT_INDEX_0, this->internalComm_, &request[nRequest]); 
    865835    ++nRequest; 
    866836  } 
    867    
    868837 
    869838  for (int idx = 0; idx < sendBuffSize; ++idx) 
     
    873842    sendBuff[idx*2+1] = sendNbElements[offSet]; 
    874843  } 
    875    
    876    
    877844 
    878845  for (int idx = 0; idx < sendBuffSize; ++idx) 
    879846  { 
    880     MPI_Isend(&sendBuff[idx*2], 2, MPI_INT, 
     847    ep_lib::MPI_Isend(&sendBuff[idx*2], 2, MPI_INT, 
    881848              sendRank[idx], MPI_DHT_INDEX_0, this->internalComm_, &request[nRequest]); 
    882849    ++nRequest; 
    883850  } 
    884    
    885    
    886  
    887   //MPI_Barrier(this->internalComm_); 
    888  
    889   MPI_Waitall(sendBuffSize+recvBuffSize, &request[0], &requestStatus[0]); 
    890   //MPI_Waitall(sendBuffSize+recvBuffSize, request, requestStatus); 
    891  
    892    
     851 
     852  ep_lib::MPI_Waitall(sendBuffSize+recvBuffSize, &request[0], &requestStatus[0]); 
    893853  int nbRecvRank = 0, nbRecvElements = 0; 
    894854  recvNbRank.clear(); 
     
    902862    } 
    903863  } 
    904  
    905  
    906    
    907    
    908 } 
    909  
    910 } 
    911  
     864} 
     865 
     866} 
  • XIOS/dev/branch_openmp/src/client_server_mapping.cpp

    r1287 r1328  
    88 */ 
    99#include "client_server_mapping.hpp" 
     10using namespace ep_lib; 
    1011 
    1112namespace xios { 
     
    6465  MPI_Allgather(&nbConnectedServer,1,MPI_INT,recvCount,1,MPI_INT,clientIntraComm) ; 
    6566 
    66    
    67   // for(int i=0; i<nbClient; i++) 
    68   //   printf("MPI_Allgather : recvCount[%d] = %d\n", i, recvCount[i]); 
    69  
    7067  displ[0]=0 ; 
    7168  for(int n=1;n<nbClient;n++) displ[n]=displ[n-1]+recvCount[n-1] ; 
     
    7572 
    7673  MPI_Allgatherv(sendBuff,nbConnectedServer,MPI_INT,recvBuff,recvCount,displ,MPI_INT,clientIntraComm) ; 
    77  
    78   // for(int i=0; i<recvSize; i++) 
    79   //   printf("MPI_Allgatherv : recvBuff[%d] = %d\n", i, recvBuff[i]); 
    80  
    81  
    8274  for(int n=0;n<recvSize;n++) clientRes[recvBuff[n]]++ ; 
    8375 
  • XIOS/dev/branch_openmp/src/client_server_mapping.hpp

    r1134 r1328  
    1414#include "mpi.hpp" 
    1515#include <boost/unordered_map.hpp> 
    16 #ifdef _usingEP 
    17 #include "ep_declaration.hpp" 
    18 #endif 
    19  
    2016 
    2117namespace xios { 
  • XIOS/dev/branch_openmp/src/client_server_mapping_distributed.cpp

    r907 r1328  
    1515#include "context.hpp" 
    1616#include "context_client.hpp" 
     17using namespace ep_lib; 
    1718 
    1819namespace xios 
  • XIOS/dev/branch_openmp/src/context_client.cpp

    r1205 r1328  
    1111#include "timer.hpp" 
    1212#include "cxios.hpp" 
     13using namespace ep_lib; 
    1314 
    1415namespace xios 
     
    2021    \cxtSer [in] cxtSer Pointer to context of server side. (It is only used on case of attached mode) 
    2122    */ 
    22     CContextClient::CContextClient(CContext* parent, ep_lib::MPI_Comm intraComm_, ep_lib::MPI_Comm interComm_, CContext* cxtSer) 
     23    CContextClient::CContextClient(CContext* parent, MPI_Comm intraComm_, MPI_Comm interComm_, CContext* cxtSer) 
    2324     : mapBufferSize_(), parentServer(cxtSer), maxBufferedEvents(4) 
    2425    { 
     
    293294       if (ratio < minBufferSizeEventSizeRatio) minBufferSizeEventSizeRatio = ratio; 
    294295     } 
    295      #ifdef _usingMPI 
    296      MPI_Allreduce(MPI_IN_PLACE, &minBufferSizeEventSizeRatio, 1, MPI_DOUBLE, MPI_MIN, intraComm); 
    297      #elif _usingEP 
     296     //MPI_Allreduce(MPI_IN_PLACE, &minBufferSizeEventSizeRatio, 1, MPI_DOUBLE, MPI_MIN, intraComm); 
    298297     MPI_Allreduce(&minBufferSizeEventSizeRatio, &minBufferSizeEventSizeRatio, 1, MPI_DOUBLE, MPI_MIN, intraComm); 
    299      #endif 
    300       
     298 
    301299     if (minBufferSizeEventSizeRatio < 1.0) 
    302300     { 
     
    402400     for (itMap = itbMap; itMap != iteMap; ++itMap) 
    403401     { 
    404        //report(10) << " Memory report : Context <" << context->getId() << "> : client side : memory used for buffer of each connection to server" << endl 
    405        //           << "  +) To server with rank " << itMap->first << " : " << itMap->second << " bytes " << endl; 
     402       report(10) << " Memory report : Context <" << context->getId() << "> : client side : memory used for buffer of each connection to server" << endl 
     403                  << "  +) To server with rank " << itMap->first << " : " << itMap->second << " bytes " << endl; 
    406404       totalBuf += itMap->second; 
    407405     } 
    408      //report(0) << " Memory report : Context <" << context->getId() << "> : client side : total memory used for buffer " << totalBuf << " bytes" << endl; 
     406     report(0) << " Memory report : Context <" << context->getId() << "> : client side : total memory used for buffer " << totalBuf << " bytes" << endl; 
    409407 
    410408     releaseBuffers(); 
  • XIOS/dev/branch_openmp/src/context_server.cpp

    r1179 r1328  
    1010#include "file.hpp" 
    1111#include "grid.hpp" 
    12 #include "mpi_std.hpp" 
     12#include "mpi.hpp" 
    1313#include "tracer.hpp" 
    1414#include "timer.hpp" 
     
    1818#include <boost/functional/hash.hpp> 
    1919 
    20  
     20using namespace ep_lib; 
    2121 
    2222namespace xios 
    2323{ 
    2424 
    25   CContextServer::CContextServer(CContext* parent, ep_lib::MPI_Comm intraComm_, ep_lib::MPI_Comm interComm_) 
     25  CContextServer::CContextServer(CContext* parent,MPI_Comm intraComm_,MPI_Comm interComm_) 
    2626  { 
    2727    context=parent; 
     
    7272    int count; 
    7373    char * addr; 
    74     ep_lib::MPI_Status status; 
     74    MPI_Status status; 
    7575    map<int,CServerBuffer*>::iterator it; 
    76  
    77     for(rank=0;rank<commSize;rank++) 
    78     { 
     76    bool okLoop; 
     77 
     78    traceOff(); 
     79    MPI_Iprobe(-2, 20,interComm,&flag,&status); 
     80    traceOn(); 
     81 
     82    if (flag==true) 
     83    { 
     84      #ifdef _usingMPI 
     85      rank=status.MPI_SOURCE ; 
     86      #elif _usingEP 
     87      rank=status.ep_src ; 
     88      #endif 
     89      okLoop = true; 
    7990      if (pendingRequest.find(rank)==pendingRequest.end()) 
    80       { 
    81         traceOff(); 
    82         ep_lib::MPI_Iprobe(rank,20,interComm,&flag,&status); 
    83         traceOn(); 
    84         if (flag) 
     91        okLoop = !listenPendingRequest(status) ; 
     92      if (okLoop) 
     93      { 
     94        for(rank=0;rank<commSize;rank++) 
    8595        { 
    86           it=buffers.find(rank); 
    87           if (it==buffers.end()) // Receive the buffer size and allocate the buffer 
     96          if (pendingRequest.find(rank)==pendingRequest.end()) 
    8897          { 
    89             StdSize buffSize = 0; 
    90             ep_lib::MPI_Recv(&buffSize, 1, MPI_LONG, rank, 20, interComm, &status); 
    91             mapBufferSize_.insert(std::make_pair(rank, buffSize)); 
    92             it=(buffers.insert(pair<int,CServerBuffer*>(rank,new CServerBuffer(buffSize)))).first; 
    93           } 
    94           else 
    95           { 
    96              
    97             ep_lib::MPI_Get_count(&status,MPI_CHAR,&count); 
    98             if (it->second->isBufferFree(count)) 
    99             { 
    100               addr=(char*)it->second->getBuffer(count); 
    101               ep_lib::MPI_Irecv(addr,count,MPI_CHAR,rank,20,interComm,&pendingRequest[rank]); 
    102               bufferRequest[rank]=addr; 
    103             } 
     98 
     99            traceOff(); 
     100            MPI_Iprobe(rank, 20,interComm,&flag,&status); 
     101            traceOn(); 
     102            if (flag==true) listenPendingRequest(status) ; 
    104103          } 
    105104        } 
     
    108107  } 
    109108 
     109  bool CContextServer::listenPendingRequest(MPI_Status& status) 
     110  { 
     111    int count; 
     112    char * addr; 
     113    map<int,CServerBuffer*>::iterator it; 
     114    #ifdef _usingMPI 
     115    int rank=status.MPI_SOURCE ; 
     116    #elif _usingEP 
     117    int rank=status.ep_src; 
     118    #endif 
     119 
     120    it=buffers.find(rank); 
     121    if (it==buffers.end()) // Receive the buffer size and allocate the buffer 
     122    { 
     123       StdSize buffSize = 0; 
     124       MPI_Recv(&buffSize, 1, MPI_LONG, rank, 20, interComm, &status); 
     125       mapBufferSize_.insert(std::make_pair(rank, buffSize)); 
     126       it=(buffers.insert(pair<int,CServerBuffer*>(rank,new CServerBuffer(buffSize)))).first; 
     127       return true; 
     128    } 
     129    else 
     130    { 
     131      MPI_Get_count(&status,MPI_CHAR,&count); 
     132      if (it->second->isBufferFree(count)) 
     133      { 
     134         addr=(char*)it->second->getBuffer(count); 
     135         MPI_Irecv(addr,count,MPI_CHAR,rank,20,interComm,&pendingRequest[rank]); 
     136         bufferRequest[rank]=addr; 
     137         return true; 
     138      } 
     139      else 
     140        return false; 
     141    } 
     142  } 
     143 
    110144  void CContextServer::checkPendingRequest(void) 
    111145  { 
    112     map<int,ep_lib::MPI_Request>::iterator it; 
     146    map<int,MPI_Request>::iterator it; 
    113147    list<int> recvRequest; 
    114148    list<int>::iterator itRecv; 
     
    116150    int flag; 
    117151    int count; 
    118     ep_lib::MPI_Status status; 
    119  
    120     for(it=pendingRequest.begin();it!=pendingRequest.end();++it) 
     152    MPI_Status status; 
     153 
     154    for(it=pendingRequest.begin();it!=pendingRequest.end();it++) 
    121155    { 
    122156      rank=it->first; 
    123157      traceOff(); 
    124       ep_lib::MPI_Test(& it->second, &flag, &status); 
     158      MPI_Test(& it->second, &flag, &status); 
    125159      traceOn(); 
    126160      if (flag==true) 
    127161      { 
    128162        recvRequest.push_back(rank); 
    129         ep_lib::MPI_Get_count(&status,MPI_CHAR,&count); 
     163        MPI_Get_count(&status,MPI_CHAR,&count); 
    130164        processRequest(rank,bufferRequest[rank],count); 
    131165      } 
     
    220254    { 
    221255      finished=true; 
    222       #pragma omp critical (_output) 
    223256      info(20)<<"Server Side context <"<<context->getId()<<"> finalized"<<endl; 
    224257      std::map<int, StdSize>::const_iterator itbMap = mapBufferSize_.begin(), 
     
    227260      for (itMap = itbMap; itMap != iteMap; ++itMap) 
    228261      { 
    229         //report(10)<< " Memory report : Context <"<<context->getId()<<"> : server side : memory used for buffer of each connection to client" << endl 
    230         //          << "  +) With client of rank " << itMap->first << " : " << itMap->second << " bytes " << endl; 
     262        report(10)<< " Memory report : Context <"<<context->getId()<<"> : server side : memory used for buffer of each connection to client" << endl 
     263                  << "  +) With client of rank " << itMap->first << " : " << itMap->second << " bytes " << endl; 
    231264        totalBuf += itMap->second; 
    232265      } 
    233266      context->finalize(); 
    234       //report(0)<< " Memory report : Context <"<<context->getId()<<"> : server side : total memory used for buffer "<<totalBuf<<" bytes"<<endl; 
     267      report(0)<< " Memory report : Context <"<<context->getId()<<"> : server side : total memory used for buffer "<<totalBuf<<" bytes"<<endl; 
    235268    } 
    236269    else if (event.classId==CContext::GetType()) CContext::dispatchEvent(event); 
  • XIOS/dev/branch_openmp/src/context_server.hpp

    r1134 r1328  
    1717    bool eventLoop(bool enableEventsProcessing = true); 
    1818    void listen(void) ; 
     19    bool listenPendingRequest(ep_lib::MPI_Status& status); 
    1920    void checkPendingRequest(void) ; 
    2021    void processRequest(int rank, char* buff,int count) ; 
  • XIOS/dev/branch_openmp/src/cxios.cpp

    r1205 r1328  
    1111#include "memtrack.hpp" 
    1212#include "registry.hpp" 
     13using namespace ep_lib; 
    1314 
    1415namespace xios 
    1516{ 
    16  
    17   extern int test_omp_rank; 
    18   #pragma omp threadprivate(test_omp_rank) 
    19  
    20   const string CXios::rootFile="./iodef.xml" ; 
    21   const string CXios::xiosCodeId="xios.x" ; 
    22   const string CXios::clientFile="./xios_client"; 
    23   const string CXios::serverFile="./xios_server"; 
    24  
     17  string CXios::rootFile="./iodef.xml" ; 
     18  string CXios::xiosCodeId="xios.x" ; 
     19  string CXios::clientFile="./xios_client"; 
     20  string CXios::serverFile="./xios_server"; 
    2521 
    2622  bool CXios::isClient ; 
    2723  bool CXios::isServer ; 
    28  
    29  
    3024  MPI_Comm CXios::globalComm ; 
    31  
    32    
    3325  bool CXios::usingOasis ; 
    3426  bool CXios::usingServer = false; 
    35  
    36  
    3727  double CXios::bufferSizeFactor = 1.0; 
    3828  const double CXios::defaultBufferSizeFactor = 1.0; 
    3929  StdSize CXios::minBufferSize = 1024 * sizeof(double); 
    40  
    41  
    4230  bool CXios::printLogs2Files; 
    4331  bool CXios::isOptPerformance = true; 
     
    4937  { 
    5038    set_new_handler(noMemory); 
    51      
    52      
    53     #pragma omp critical 
    54     { 
    55       parseFile(rootFile);   
    56     } 
    57     #pragma omp barrier 
     39    parseFile(rootFile); 
    5840    parseXiosConfig(); 
    5941  } 
     
    8769      ERROR("CXios::parseXiosConfig()", "recv_field_timeout cannot be negative."); 
    8870 
    89   
     71    //globalComm=MPI_COMM_WORLD ; 
    9072    int num_ep; 
    9173    if(isClient)   
     
    9375      num_ep = omp_get_num_threads(); 
    9476    } 
    95      
     77         
    9678    if(isServer)  
    9779    {  
    9880      num_ep = omp_get_num_threads(); 
    9981    } 
    100      
     82         
    10183    MPI_Info info; 
    10284    #pragma omp master 
     
    10688      passage = ep_comm;   
    10789    } 
    108      
     90         
    10991    #pragma omp barrier 
    110  
    111        
     92     
     93           
    11294    CXios::globalComm = passage[omp_get_thread_num()]; 
    113  
    114     int tmp_rank; 
    115     MPI_Comm_rank(CXios::globalComm, &tmp_rank); 
    116  
    117      
    118     test_omp_rank = tmp_rank; 
    119      
    12095  } 
    12196 
     
    133108 
    134109    CClient::initialize(codeId,localComm,returnComm) ; 
    135  
    136110    if (CClient::getRank()==0) globalRegistry = new CRegistry(returnComm) ; 
    137111 
     
    142116    if (printLogs2Files) 
    143117    { 
    144       #pragma omp critical 
    145118      CClient::openInfoStream(clientFile); 
    146119      CClient::openErrorStream(clientFile); 
     
    158131     if (CClient::getRank()==0) 
    159132     { 
    160        #pragma omp critical (_output) 
    161133       info(80)<<"Write data base Registry"<<endl<<globalRegistry->toString()<<endl ; 
    162134       globalRegistry->toFile("xios_registry.bin") ; 
     
    184156  void CXios::initServer() 
    185157  { 
    186     int initialized; 
    187     MPI_Initialized(&initialized); 
    188     if (initialized) CServer::is_MPI_Initialized=true ; 
    189     else CServer::is_MPI_Initialized=false ; 
    190        
    191   
    192     if(!CServer::is_MPI_Initialized) 
    193     { 
    194       MPI_Init(NULL, NULL); 
    195     } 
    196        
    197158    set_new_handler(noMemory); 
    198159    std::set<StdString> parseList; 
     
    210171     
    211172    initServer(); 
    212      
    213      
     173 
    214174    // Initialize all aspects MPI 
    215175    CServer::initialize(); 
  • XIOS/dev/branch_openmp/src/cxios.hpp

    r1134 r1328  
    55#include "mpi.hpp" 
    66#include "registry.hpp" 
    7 #include "log.hpp" 
    87 
    98namespace xios 
     
    1514  { 
    1615    public: 
    17       static void initialize(void) ; 
    18       static void initClientSide(const string & codeId, ep_lib::MPI_Comm& localComm, ep_lib::MPI_Comm& returnComm) ; 
    19       static void initServerSide(void) ; 
    20       static void clientFinalize(void) ; 
    21       static void parseFile(const string& filename) ; 
     16     static void initialize(void) ; 
     17     static void initClientSide(const string & codeId, ep_lib::MPI_Comm& localComm, ep_lib::MPI_Comm& returnComm) ; 
     18     static void initServerSide(void) ; 
     19     static void clientFinalize(void) ; 
     20     static void parseFile(const string& filename) ; 
    2221 
    23       template <typename T> 
    24       static T getin(const string& id,const T& defaultValue) ; 
     22     template <typename T> 
     23     static T getin(const string& id,const T& defaultValue) ; 
    2524 
    26       template <typename T> 
    27       static T getin(const string& id) ; 
     25     template <typename T> 
     26     static T getin(const string& id) ; 
    2827 
    2928    public: 
    30       static const string rootFile; //!< Configuration filename 
    31       static const string xiosCodeId ; //!< Identity for XIOS 
    32       static const string clientFile; //!< Filename template for client 
    33       static const string serverFile; //!< Filename template for server 
     29     static string rootFile ; //!< Configuration filename 
     30     static string xiosCodeId ; //!< Identity for XIOS 
     31     static string clientFile; //!< Filename template for client 
     32     static string serverFile; //!< Filename template for server 
    3433 
    35       static bool isClient ; //!< Check if xios is client 
    36       static bool isServer ; //!< Check if xios is server 
    37       #pragma omp threadprivate(isClient, isServer) 
     34     static bool isClient ; //!< Check if xios is client 
     35     static bool isServer ; //!< Check if xios is server 
    3836 
    39       static MPI_Comm globalComm ; //!< Global communicator 
    40       #pragma omp threadprivate(globalComm) 
     37     static ep_lib::MPI_Comm globalComm ; //!< Global communicator 
    4138 
    42       static bool printLogs2Files; //!< Printing out logs into files 
    43       static bool usingOasis ; //!< Using Oasis 
    44       static bool usingServer ; //!< Using server (server mode) 
    45       static double bufferSizeFactor; //!< Factor used to tune the buffer size 
    46       static const double defaultBufferSizeFactor; //!< Default factor value 
    47       static StdSize minBufferSize; //!< Minimum buffer size 
    48       static bool isOptPerformance; //!< Check if buffer size is for performance (as large as possible) 
    49       #pragma omp threadprivate(printLogs2Files, usingOasis, usingServer, bufferSizeFactor, minBufferSize, isOptPerformance) 
    50        
    51       static CRegistry* globalRegistry ; //!< global registry which is wrote by the root process of the servers 
    52       static double recvFieldTimeout; 
    53       #pragma omp threadprivate(recvFieldTimeout) 
    54        
    55        
     39     static bool printLogs2Files; //!< Printing out logs into files 
     40     static bool usingOasis ; //!< Using Oasis 
     41     static bool usingServer ; //!< Using server (server mode) 
     42     static double bufferSizeFactor; //!< Factor used to tune the buffer size 
     43     static const double defaultBufferSizeFactor; //!< Default factor value 
     44     static StdSize minBufferSize; //!< Minimum buffer size 
     45     static bool isOptPerformance; //!< Check if buffer size is for performance (as large as possible) 
     46     static CRegistry* globalRegistry ; //!< global registry which is wrote by the root process of the servers 
     47     static double recvFieldTimeout; //!< Time to wait for data before issuing an error when receiving a field 
     48 
    5649    public: 
    5750     //! Setting xios to use server mode 
  • XIOS/dev/branch_openmp/src/data_output.cpp

    r1205 r1328  
    44#include "group_template.hpp" 
    55#include "context.hpp" 
    6 //mpi.hpp 
     6 
    77namespace xios 
    88{ 
  • XIOS/dev/branch_openmp/src/data_output.hpp

    r1287 r1328  
    5959            virtual void writeTimeDimension_(void)           = 0; 
    6060            virtual void writeTimeAxis_ (CField*     field, 
    61                                          const boost::shared_ptr<CCalendar> cal) = 0; 
     61                                         const shared_ptr<CCalendar> cal) = 0; 
    6262 
    6363            /// Propriétés protégées /// 
  • XIOS/dev/branch_openmp/src/dht_auto_indexing.cpp

    r1134 r1328  
    88 */ 
    99#include "dht_auto_indexing.hpp" 
     10using namespace ep_lib; 
    1011 
    1112namespace xios 
     
    2223 
    2324  CDHTAutoIndexing::CDHTAutoIndexing(const CArray<size_t,1>& hashValue, 
    24                                      const ep_lib::MPI_Comm& clientIntraComm) 
     25                                     const MPI_Comm& clientIntraComm) 
    2526    : CClientClientDHTTemplate<size_t>(clientIntraComm) 
    2627  { 
     
    5859  */ 
    5960  CDHTAutoIndexing::CDHTAutoIndexing(Index2VectorInfoTypeMap& hashInitMap, 
    60                                      const ep_lib::MPI_Comm& clientIntraComm) 
     61                                     const MPI_Comm& clientIntraComm) 
    6162    : CClientClientDHTTemplate<size_t>(clientIntraComm) 
    6263  { 
  • XIOS/dev/branch_openmp/src/dht_auto_indexing.hpp

    r1134 r1328  
    1212 
    1313#include "client_client_dht_template.hpp" 
    14 #ifdef _usingEP 
    15 #include "ep_declaration.hpp" 
    16 #endif 
    1714 
    1815namespace xios 
  • XIOS/dev/branch_openmp/src/event_scheduler.cpp

    r1134 r1328  
    22#include "xios_spl.hpp" 
    33#include "mpi.hpp" 
     4using namespace ep_lib; 
    45 
    56namespace xios 
     
    132133    while(received) 
    133134    { 
    134       #ifdef _usingEP 
    135       MPI_Iprobe(-1,1,communicator,&received, &status) ; 
    136       #else 
    137       MPI_Iprobe(MPI_ANY_SOURCE,1,communicator,&received, &status) ; 
    138       #endif 
     135      MPI_Iprobe(-2,1,communicator,&received, &status) ; 
    139136      if (received) 
    140137      { 
    141138        recvRequest=new SPendingRequest ; 
    142         #ifdef _usingEP 
    143         MPI_Irecv(recvRequest->buffer, 3, MPI_UNSIGNED_LONG, -1, 1, communicator, &(recvRequest->request)) ; 
    144         #else 
    145         MPI_Irecv(recvRequest->buffer, 3, MPI_UNSIGNED_LONG, MPI_ANY_SOURCE, 1, communicator, &(recvRequest->request)) ; 
    146         #endif 
     139        MPI_Irecv(recvRequest->buffer, 3, MPI_UNSIGNED_LONG, -2, 1, communicator, &(recvRequest->request)) ; 
    147140        pendingRecvParentRequest.push(recvRequest) ; 
    148141      } 
     
    182175    while(received) 
    183176    { 
    184       #ifdef _usingEP 
    185       MPI_Iprobe(-1,0,communicator,&received, &status) ; 
    186       #else 
    187       MPI_Iprobe(MPI_ANY_SOURCE,0,communicator,&received, &status) ; 
    188       #endif 
     177      MPI_Iprobe(-2,0,communicator,&received, &status) ; 
    189178      if (received) 
    190179      { 
    191180        recvRequest=new SPendingRequest ; 
    192         #ifdef _usingEP 
    193         MPI_Irecv(recvRequest->buffer, 3, MPI_UNSIGNED_LONG, -1, 0, communicator, &recvRequest->request) ; 
    194         #else 
    195         MPI_Irecv(recvRequest->buffer, 3, MPI_UNSIGNED_LONG, MPI_ANY_SOURCE, 0, communicator, &recvRequest->request) ; 
    196         #endif 
     181        MPI_Irecv(recvRequest->buffer, 3, MPI_UNSIGNED_LONG, -2, 0, communicator, &recvRequest->request) ; 
    197182        pendingRecvChildRequest.push_back(recvRequest) ; 
    198183      } 
  • XIOS/dev/branch_openmp/src/event_scheduler.hpp

    r1134 r1328  
    44#include "xios_spl.hpp" 
    55#include "mpi.hpp" 
    6 #ifdef _usingEP 
    7 #include "ep_declaration.hpp" 
    8 #endif 
    9  
    106 
    117namespace xios 
     
    3026        *  @param[in] comm : MPI communicator du duplicate for internal use 
    3127        */ 
    32        CEventScheduler(const MPI_Comm& comm) ; 
     28       CEventScheduler(const ep_lib::MPI_Comm& comm) ; 
    3329 
    3430 
     
    155151       { 
    156152         size_t buffer[3] ;      /*!< communication buffer : timeLine, hashId, level */ 
    157          MPI_Request request ;   /*!< pending MPI request */  
     153         ep_lib::MPI_Request request ;   /*!< pending MPI request */  
    158154       } ; 
    159155        
    160        MPI_Comm communicator ;  /*!< Internal MPI communicator */  
     156       ep_lib::MPI_Comm communicator ;  /*!< Internal MPI communicator */  
    161157       int mpiRank ;            /*!< Rank in the communicator */ 
    162158       int mpiSize ;            /*!< Size of the communicator */ 
  • XIOS/dev/branch_openmp/src/filter/file_writer_filter.cpp

    r1205 r1328  
    1717  void CFileWriterFilter::onInputReady(std::vector<CDataPacketPtr> data) 
    1818  { 
    19     CDataPacketPtr packet = data[0]; 
    20  
    2119    const bool detectMissingValue = (!field->detect_missing_value.isEmpty() 
    2220                                      && !field->default_value.isEmpty() 
    2321                                      && field->detect_missing_value == true); 
     22 
     23    CArray<double, 1> dataArray = (detectMissingValue) ? data[0]->data.copy() : data[0]->data; 
     24 
    2425    if (detectMissingValue) 
    2526    { 
    2627      const double missingValue = field->default_value; 
    27       const size_t nbData = packet->data.numElements(); 
     28      const size_t nbData = dataArray.numElements(); 
    2829      for (size_t idx = 0; idx < nbData; ++idx) 
    2930      { 
    30         if (NumTraits<double>::isnan(packet->data(idx))) 
    31           packet->data(idx) = missingValue; 
     31        if (NumTraits<double>::isnan(dataArray(idx))) 
     32          dataArray(idx) = missingValue; 
    3233      } 
    3334    } 
    3435 
    35     field->sendUpdateData(packet->data); 
     36    field->sendUpdateData(dataArray); 
    3637  } 
    3738 
  • XIOS/dev/branch_openmp/src/filter/source_filter.cpp

    r1205 r1328  
    9999  void CSourceFilter::signalEndOfStream(CDate date) 
    100100  { 
     101    date = date + offset; // this is a temporary solution, it should be part of a proper temporal filter 
     102 
    101103    CDataPacketPtr packet(new CDataPacket); 
    102104    packet->date = date; 
  • XIOS/dev/branch_openmp/src/filter/spatial_transform_filter.cpp

    r1287 r1328  
     1#include "mpi.hpp" 
    12#include "spatial_transform_filter.hpp" 
    23#include "grid_transformation.hpp" 
    34#include "context.hpp" 
    45#include "context_client.hpp" 
     6using namespace ep_lib; 
    57 
    68namespace xios 
     
    6567  } 
    6668 
     69  //std::map<CGridTransformation*, boost::shared_ptr<CSpatialTransformFilterEngine> > CSpatialTransformFilterEngine::engines; 
    6770  std::map<CGridTransformation*, boost::shared_ptr<CSpatialTransformFilterEngine> > *CSpatialTransformFilterEngine::engines_ptr = 0; 
    6871 
     
    7275      ERROR("CSpatialTransformFilterEngine& CSpatialTransformFilterEngine::get(CGridTransformation* gridTransformation)", 
    7376            "Impossible to get the requested engine, the grid transformation is invalid."); 
    74  
     77     
    7578    if(engines_ptr == NULL) engines_ptr = new std::map<CGridTransformation*, boost::shared_ptr<CSpatialTransformFilterEngine> >; 
    7679 
     80    //std::map<CGridTransformation*, boost::shared_ptr<CSpatialTransformFilterEngine> >::iterator it = engines.find(gridTransformation); 
    7781    std::map<CGridTransformation*, boost::shared_ptr<CSpatialTransformFilterEngine> >::iterator it = engines_ptr->find(gridTransformation); 
     82    //if (it == engines.end()) 
    7883    if (it == engines_ptr->end()) 
    7984    { 
    8085      boost::shared_ptr<CSpatialTransformFilterEngine> engine(new CSpatialTransformFilterEngine(gridTransformation)); 
     86      //it = engines.insert(std::make_pair(gridTransformation, engine)).first; 
    8187      it = engines_ptr->insert(std::make_pair(gridTransformation, engine)).first; 
    8288    } 
     
    122128    double defaultValue = std::numeric_limits<double>::quiet_NaN(); 
    123129    if (0 != dataDest.numElements()) ignoreMissingValue = NumTraits<double>::isnan(dataDest(0)); 
    124      
    125     const std::list<CGridTransformation::SendingIndexGridSourceMap> *listLocalIndexSend_ptr = & (gridTransformation->getLocalIndexToSendFromGridSource()); 
    126      
     130 
    127131    const std::list<CGridTransformation::SendingIndexGridSourceMap>& listLocalIndexSend = gridTransformation->getLocalIndexToSendFromGridSource(); 
    128132    const std::list<CGridTransformation::RecvIndexGridDestinationMap>& listLocalIndexToReceive = gridTransformation->getLocalIndexToReceiveOnGridDest(); 
     
    133137    CArray<double,1> dataCurrentDest(dataSrc.copy()); 
    134138 
    135     std::list<CGridTransformation::SendingIndexGridSourceMap>::const_iterator itListSend  = listLocalIndexSend_ptr->begin(), 
    136                                                                               iteListSend = listLocalIndexSend_ptr->end(); 
     139    std::list<CGridTransformation::SendingIndexGridSourceMap>::const_iterator itListSend  = listLocalIndexSend.begin(), 
     140                                                                              iteListSend = listLocalIndexSend.end(); 
    137141    std::list<CGridTransformation::RecvIndexGridDestinationMap>::const_iterator itListRecv = listLocalIndexToReceive.begin(); 
    138142    std::list<size_t>::const_iterator itNbListRecv = listNbLocalIndexToReceive.begin(); 
     
    155159          sendBuff[idxSendBuff] = new double[itSend->second.numElements()]; 
    156160      } 
    157        
    158       const CGridTransformation::RecvIndexGridDestinationMap& localIndexToReceive = *itListRecv; 
    159       CGridTransformation::RecvIndexGridDestinationMap::const_iterator itbRecv = localIndexToReceive.begin(), itRecv, 
    160                                                                        iteRecv = localIndexToReceive.end(); 
    161161 
    162162      idxSendBuff = 0; 
    163       std::vector<ep_lib::MPI_Request> sendRecvRequest(localIndexToSend.size()+localIndexToReceive.size()); 
     163      std::vector<MPI_Request> sendRecvRequest(localIndexToSend.size() + itListRecv->size()); 
    164164      int position = 0; 
    165165      for (itSend = itbSend; itSend != iteSend; ++itSend, ++idxSendBuff) 
     
    172172          sendBuff[idxSendBuff][idx] = dataCurrentSrc(localIndex_p(idx)); 
    173173        } 
    174         MPI_Isend(sendBuff[idxSendBuff], countSize, MPI_DOUBLE, destRank, 12, client->intraComm, &sendRecvRequest[position]); 
    175         position++; 
     174        MPI_Isend(sendBuff[idxSendBuff], countSize, MPI_DOUBLE, destRank, 12, client->intraComm, &sendRecvRequest[position++]); 
    176175      } 
    177176 
    178177      // Receiving data on destination fields 
    179        
     178      const CGridTransformation::RecvIndexGridDestinationMap& localIndexToReceive = *itListRecv; 
     179      CGridTransformation::RecvIndexGridDestinationMap::const_iterator itbRecv = localIndexToReceive.begin(), itRecv, 
     180                                                                       iteRecv = localIndexToReceive.end(); 
    180181      int recvBuffSize = 0; 
    181182      for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) recvBuffSize += itRecv->second.size(); //(recvBuffSize < itRecv->second.size()) 
     
    188189        int srcRank = itRecv->first; 
    189190        int countSize = itRecv->second.size(); 
    190         MPI_Irecv(recvBuff + currentBuff, countSize, MPI_DOUBLE, srcRank, 12, client->intraComm, &sendRecvRequest[position]); 
    191         position++; 
     191        MPI_Irecv(recvBuff + currentBuff, countSize, MPI_DOUBLE, srcRank, 12, client->intraComm, &sendRecvRequest[position++]); 
    192192        currentBuff += countSize; 
    193193      } 
    194       std::vector<ep_lib::MPI_Status> status(sendRecvRequest.size()); 
     194      std::vector<MPI_Status> status(sendRecvRequest.size()); 
    195195      MPI_Waitall(sendRecvRequest.size(), &sendRecvRequest[0], &status[0]); 
    196196 
     
    203203      std::vector<bool> localInitFlag(dataCurrentDest.numElements(), true); 
    204204      currentBuff = 0; 
     205      bool firstPass=true;  
    205206      for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) 
    206207      { 
     
    211212                         dataCurrentDest, 
    212213                         localInitFlag, 
    213                          ignoreMissingValue); 
     214                         ignoreMissingValue,firstPass); 
    214215 
    215216        currentBuff += countSize; 
     217        firstPass=false ; 
    216218      } 
    217219 
  • XIOS/dev/branch_openmp/src/filter/spatial_transform_filter.hpp

    r1134 r1328  
    33 
    44#include "filter.hpp" 
    5  
    65namespace xios 
    76{ 
     
    106105      //static std::map<CGridTransformation*, boost::shared_ptr<CSpatialTransformFilterEngine> > engines; 
    107106      static std::map<CGridTransformation*, boost::shared_ptr<CSpatialTransformFilterEngine> > *engines_ptr; 
    108       #pragma omp threadprivate(engines_ptr) 
    109        
    110107  }; // class CSpatialTransformFilterEngine 
    111108} // namespace xios 
  • XIOS/dev/branch_openmp/src/filter/store_filter.cpp

    r1205 r1328  
    7878  void CStoreFilter::onInputReady(std::vector<CDataPacketPtr> data) 
    7979  { 
    80     CDataPacketPtr packet = data[0]; 
     80 
     81    CDataPacketPtr packet; 
     82    if (detectMissingValues) 
     83    { 
     84      const size_t nbData = data[0]->data.numElements(); 
     85 
     86      packet = CDataPacketPtr(new CDataPacket); 
     87      packet->date = data[0]->date; 
     88      packet->timestamp = data[0]->timestamp; 
     89      packet->status = data[0]->status; 
     90      packet->data.resize(nbData); 
     91      packet->data = data[0]->data; 
     92 
     93      for (size_t idx = 0; idx < nbData; ++idx) 
     94      { 
     95        if (NumTraits<double>::isnan(packet->data(idx))) 
     96          packet->data(idx) = missingValue; 
     97      } 
     98 
     99    } 
     100 
     101    else 
     102    { 
     103      packet = data[0]; 
     104    } 
    81105 
    82106    packets.insert(std::make_pair(packet->timestamp, packet)); 
     
    85109    gc.registerObject(this, packet->timestamp); 
    86110 
    87     if (detectMissingValues) 
    88     { 
    89       const size_t nbData = packet->data.numElements(); 
    90       for (size_t idx = 0; idx < nbData; ++idx) 
    91       { 
    92         if (NumTraits<double>::isnan(packet->data(idx))) 
    93           packet->data(idx) = missingValue; 
    94       } 
    95     } 
    96111  } 
    97112 
  • XIOS/dev/branch_openmp/src/filter/temporal_filter.cpp

    r1124 r1328  
    1414    , isOnceOperation(functor->timeType() == func::CFunctor::once) 
    1515    , isInstantOperation(functor->timeType() == func::CFunctor::instant) 
    16     // If we can optimize the sampling when dealing with an instant functor we do it 
    17     , samplingFreq((isInstantOperation && samplingFreq == TimeStep && samplingOffset == NoneDu) ? opFreq : samplingFreq) 
    18     , samplingOffset((isInstantOperation && samplingFreq == TimeStep && samplingOffset == NoneDu) ? opFreq - initDate.getRelCalendar().getTimeStep() : samplingOffset) 
     16    , samplingFreq(samplingFreq) 
     17    , samplingOffset(samplingOffset) 
    1918    , opFreq(opFreq) 
    2019    , nextSamplingDate(initDate + this->samplingOffset + initDate.getRelCalendar().getTimeStep()) 
  • XIOS/dev/branch_openmp/src/group_factory.cpp

    r1134 r1328  
    44{ 
    55   /// ////////////////////// Définitions ////////////////////// /// 
    6    StdString *CGroupFactory::CurrContext_ptr = new StdString; 
     6   StdString CGroupFactory::CurrContext(""); 
    77 
    88   void CGroupFactory::SetCurrentContextId(const StdString & context) 
    9    {   
    10       if(CGroupFactory::CurrContext_ptr == NULL ) CGroupFactory::CurrContext_ptr = new StdString;  
    11       CGroupFactory::CurrContext_ptr->assign(context); 
     9   {  
     10      CGroupFactory::CurrContext = context; 
    1211   } 
    1312 
    1413   StdString & CGroupFactory::GetCurrentContextId(void) 
    1514   {  
    16       return (*CGroupFactory::CurrContext_ptr); 
     15      return (CGroupFactory::CurrContext); 
    1716   } 
    1817 
  • XIOS/dev/branch_openmp/src/group_factory.hpp

    r1134 r1328  
    6969 
    7070         /// Propriétés statiques /// 
    71          static StdString *CurrContext_ptr; 
    72          #pragma omp threadprivate(CurrContext_ptr) 
     71         static StdString CurrContext; 
    7372 
    7473   }; // class CGroupFactory 
  • XIOS/dev/branch_openmp/src/group_factory_decl.cpp

    r1287 r1328  
    55{ 
    66# define  macro(U) \ 
    7   template void CGroupFactory::AddGroup<U>(boost::shared_ptr<U> pgroup,boost::shared_ptr<U> cgroup); \ 
    8   template void CGroupFactory::AddChild<U>(boost::shared_ptr<U> group, boost::shared_ptr<U::RelChild> child); \ 
    9   template boost::shared_ptr<U>  CGroupFactory::GetGroup<U>(boost::shared_ptr<U> group, const StdString & id); \ 
    10   template boost::shared_ptr<U::RelChild> CGroupFactory::GetChild<U>(boost::shared_ptr<U> group, const StdString & id); \ 
    11   template int CGroupFactory::GetGroupNum<U>(boost::shared_ptr<U> group); \ 
    12   template int CGroupFactory::GetGroupIdNum<U>(boost::shared_ptr<U> group); \ 
    13   template int CGroupFactory::GetChildNum<U>(boost::shared_ptr<U> group); \ 
     7  template void CGroupFactory::AddGroup<U>(shared_ptr<U> pgroup,shared_ptr<U> cgroup); \ 
     8  template void CGroupFactory::AddChild<U>(shared_ptr<U> group, shared_ptr<U::RelChild> child); \ 
     9  template shared_ptr<U>  CGroupFactory::GetGroup<U>(shared_ptr<U> group, const StdString & id); \ 
     10  template shared_ptr<U::RelChild> CGroupFactory::GetChild<U>(shared_ptr<U> group, const StdString & id); \ 
     11  template int CGroupFactory::GetGroupNum<U>(shared_ptr<U> group); \ 
     12  template int CGroupFactory::GetGroupIdNum<U>(shared_ptr<U> group); \ 
     13  template int CGroupFactory::GetChildNum<U>(shared_ptr<U> group); \ 
    1414  template int CGroupFactory::GetChildIdNum<U>(boost::shared_ptr<U> group); \ 
    15   template bool CGroupFactory::HasGroup<U>(boost::shared_ptr<U> group, const StdString & id); \ 
     15  template bool CGroupFactory::HasGroup<U>(shared_ptr<U> group, const StdString & id); \ 
    1616  template bool CGroupFactory::HasChild<U>(boost::shared_ptr<U> group, const StdString & id); \ 
    17   template boost::shared_ptr<U> CGroupFactory::CreateGroup<U>(boost::shared_ptr<U> group, const StdString & id ); \ 
    18   template boost::shared_ptr<U::RelChild>  CGroupFactory::CreateChild<U>(boost::shared_ptr<U> group, const StdString & id); 
     17  template shared_ptr<U> CGroupFactory::CreateGroup<U>(shared_ptr<U> group, const StdString & id ); \ 
     18  template shared_ptr<U::RelChild>  CGroupFactory::CreateChild<U>(shared_ptr<U> group, const StdString & id); 
    1919 
    2020  macro(CFieldGroup) 
  • XIOS/dev/branch_openmp/src/indent.hpp

    r1134 r1328  
    1010    public: 
    1111    static int defaultIncSize; 
    12     #pragma omp threadprivate(defaultIncSize) 
    13      
    1412    static int index ; 
    15     #pragma omp threadprivate(index) 
    16      
    1713    int incSize ; 
    1814    int offset ; 
  • XIOS/dev/branch_openmp/src/indent_xml.cpp

    r1134 r1328  
    1515   { 
    1616      static unsigned int LineNB = 1; 
    17       #pragma omp threadprivate(LineNB) 
    18        
    1917      if (CIndent::WithLine) out << LineNB++ << ". "; 
    2018      for(unsigned int i = 0; i < CIndent::Indent; out << CIndent::Increm , i++){} 
  • XIOS/dev/branch_openmp/src/indent_xml.hpp

    r1134 r1328  
    2222         /// Propriétés  statiques /// 
    2323         static unsigned int Indent; 
    24          #pragma omp threadprivate(Indent) 
    25  
    2624         static StdString    Increm; 
    27          #pragma omp threadprivate(Increm) 
    28  
    2925         static bool         WithLine; 
    30          #pragma omp threadprivate(WithLine) 
    3126 
    3227   }; // class CIndent 
  • XIOS/dev/branch_openmp/src/interface/c/icdata.cpp

    r1205 r1328  
    11/* ************************************************************************** * 
    2  *      Copyright © IPSL/LSCE, xios, Avril 2010 - Octobre 2011         * 
     2 *      Copyright IPSL/LSCE, xios, Avril 2010 - Octobre 2011         * 
    33 * ************************************************************************** */ 
    44 
     
    99#include <iostream> 
    1010 
    11  
     11#include "mpi_std.hpp" 
    1212#include "xios.hpp" 
    1313//#include "oasis_cinterface.hpp" 
     
    2323#include "context.hpp" 
    2424#include "context_client.hpp" 
    25 #include "mpi_std.hpp" 
     25 
    2626#include "timer.hpp" 
    27 #include "array_new.hpp" 
    28  
    2927 
    3028extern "C" 
    3129{ 
    32 // /////////////////////////////// Définitions ////////////////////////////// // 
    33  
    34    // ----------------------- Redéfinition de types ---------------------------- 
     30// /////////////////////////////// Dfinitions ////////////////////////////// // 
     31 
     32   // ----------------------- Redfinition de types ---------------------------- 
    3533 
    3634   typedef enum { NETCDF4 = 0 } XFileType; 
     
    3836   typedef xios::CContext* XContextPtr; 
    3937 
    40    // -------------------- Traitement des données ------------------------------ 
     38   // -------------------- Traitement des donnes ------------------------------ 
    4139 
    4240   // This function is not exported to the public Fortran interface, 
     
    6462      int initialized; 
    6563      MPI_Initialized(&initialized); 
    66  
    67       #ifdef _usingEP 
    68       if (initialized) local_comm = ep_lib::EP_Comm_f2c(static_cast< int >(*f_local_comm)); 
    69       else local_comm = MPI_COMM_NULL; 
    70       #else 
     64      #ifdef _usingMPI 
    7165      if (initialized) local_comm=MPI_Comm_f2c(*f_local_comm); 
    72       else local_comm = MPI_COMM_NULL; 
     66      else local_comm=MPI_COMM_NULL; 
     67      #elif _usingEP 
     68      ep_lib::fc_comm_map.clear(); 
     69      if (initialized) local_comm=ep_lib::EP_Comm_f2c(static_cast<int>(*f_local_comm)); 
     70      else local_comm=MPI_COMM_NULL; 
    7371      #endif 
    7472       
    75       
     73 
    7674 
    7775      CXios::initClientSide(str, local_comm, return_comm); 
    78  
    79       #ifdef _usingEP 
    80       *f_return_comm = ep_lib::EP_Comm_c2f(return_comm); 
    81       #else 
    82       *f_return_comm = MPI_Comm_c2f(return_comm); 
     76      #ifdef _usingMPI 
     77      *f_return_comm=MPI_Comm_c2f(return_comm); 
     78      #elif _usingEP 
     79      *f_return_comm=ep_lib::EP_Comm_c2f(return_comm); 
    8380      #endif 
    84  
    8581      CTimer::get("XIOS init").suspend(); 
    8682      CTimer::get("XIOS").suspend(); 
     
    9591     CTimer::get("XIOS").resume(); 
    9692     CTimer::get("XIOS init context").resume(); 
     93     #ifdef _usingMPI 
     94     comm=MPI_Comm_f2c(*f_comm); 
     95     #elif _usingEP 
    9796     comm = ep_lib::EP_Comm_f2c(static_cast< int >(*f_comm)); 
    98  
    99      CClient::registerContext(str,comm); 
    100            
     97     #endif 
     98     CClient::registerContext(str, comm); 
    10199     CTimer::get("XIOS init context").suspend(); 
    102100     CTimer::get("XIOS").suspend(); 
     
    382380 
    383381 
    384    // ---------------------- Ecriture des données ------------------------------ 
     382   // ---------------------- Ecriture des donnes ------------------------------ 
    385383 
    386384   void cxios_write_data_k80(const char* fieldid, int fieldid_size, double* data_k8, int data_Xsize) 
     
    448446      CContext* context = CContext::getCurrent(); 
    449447      if (!context->hasServer && !context->client->isAttachedModeEnabled()) 
    450       { 
    451         context->checkBuffersAndListen(); 
    452       }   
     448        context->checkBuffersAndListen(); 
    453449 
    454450      CArray<double, 3>data(data_k8, shape(data_Xsize, data_Ysize, data_Zsize), neverDeleteData); 
     
    717713    } 
    718714 
    719    // ---------------------- Lecture des données ------------------------------ 
     715   // ---------------------- Lecture des donnes ------------------------------ 
    720716 
    721717   void cxios_read_data_k80(const char* fieldid, int fieldid_size, double* data_k8, int data_Xsize) 
  • XIOS/dev/branch_openmp/src/interface/c/oasis_cinterface.cpp

    r1134 r1328  
    11#include "oasis_cinterface.hpp" 
    22#include <string> 
    3 //#include "mpi_std.hpp" 
     3using namespace ep_lib; 
    44 
    55namespace xios 
     
    2626     
    2727    fxios_oasis_get_localcomm(&f_comm) ; 
    28     #ifdef _usingEP 
    2928    comm=EP_Comm_f2c(f_comm.mpi_fint) ; 
    30     #else 
    31     comm=MPI_Comm_f2c(f_comm) ; 
    32     #endif 
    3329  } 
    3430  
     
    3834     
    3935    fxios_oasis_get_intracomm(&f_comm,server_id.data(),server_id.size()) ; 
    40     #ifdef _usingEP 
    4136    comm_client_server=EP_Comm_f2c(f_comm.mpi_fint) ; 
    42     #else 
    43     comm_client_server=MPI_Comm_f2c(f_comm) ; 
    44     #endif 
    4537  } 
    4638  
     
    5042     
    5143    fxios_oasis_get_intercomm(&f_comm,server_id.data(),server_id.size()) ; 
    52     #ifdef _usingEP 
    5344    comm_client_server=EP_Comm_f2c(f_comm.mpi_fint) ; 
    54     #else 
    55     comm_client_server=MPI_Comm_f2c(f_comm) ; 
    56     #endif 
    5745  } 
    5846} 
  • XIOS/dev/branch_openmp/src/interface/c/oasis_cinterface.hpp

    r501 r1328  
    1010  void fxios_oasis_enddef(void) ; 
    1111  void fxios_oasis_finalize(void) ; 
    12   void fxios_oasis_get_localcomm(MPI_Fint* f_comm) ; 
    13   void fxios_oasis_get_intracomm(MPI_Fint* f_comm_client_server,const char* client_id,int str_len) ; 
    14   void fxios_oasis_get_intercomm(MPI_Fint* f_comm_client_server,const char* client_id,int str_len) ; 
     12  void fxios_oasis_get_localcomm(ep_lib::MPI_Fint* f_comm) ; 
     13  void fxios_oasis_get_intracomm(ep_lib::MPI_Fint* f_comm_client_server,const char* client_id,int str_len) ; 
     14  void fxios_oasis_get_intercomm(ep_lib::MPI_Fint* f_comm_client_server,const char* client_id,int str_len) ; 
    1515} 
    1616  
     
    2020  void oasis_enddef(void) ; 
    2121  void oasis_finalize(void) ; 
    22   void oasis_get_localcomm(MPI_Comm& comm) ; 
    23   void oasis_get_intracomm(MPI_Comm& comm_client_server,const std::string& server_id) ; 
    24   void oasis_get_intercomm(MPI_Comm& comm_client_server,const std::string& server_id) ; 
     22  void oasis_get_localcomm(ep_lib::MPI_Comm& comm) ; 
     23  void oasis_get_intracomm(ep_lib::MPI_Comm& comm_client_server,const std::string& server_id) ; 
     24  void oasis_get_intercomm(ep_lib::MPI_Comm& comm_client_server,const std::string& server_id) ; 
    2525} 
    2626#endif 
  • XIOS/dev/branch_openmp/src/io/inetcdf4.cpp

    r1287 r1328  
    44 
    55#include <boost/algorithm/string.hpp> 
    6 // mpi_std.hpp 
    7 #ifdef _usingEP 
    8 #include "ep_declaration.hpp" 
    9 #endif 
    106 
    117namespace xios 
    128{ 
    13   CINetCDF4::CINetCDF4(const StdString& filename, const MPI_Comm* comm /*= NULL*/, bool multifile /*= true*/, const StdString& timeCounterName /*= "time_counter"*/) 
     9  CINetCDF4::CINetCDF4(const StdString& filename, const ep_lib::MPI_Comm* comm /*= NULL*/, bool multifile /*= true*/, const StdString& timeCounterName /*= "time_counter"*/) 
    1410  { 
    1511    // Don't use parallel mode if there is only one process 
     
    1713    { 
    1814      int commSize = 0; 
    19       MPI_Comm_size(*comm, &commSize); 
     15      ep_lib::MPI_Comm_size(*comm, &commSize); 
    2016      if (commSize <= 1) 
    2117        comm = NULL; 
    2218    } 
    23  
    2419    mpi = comm && !multifile; 
    25     MPI_Info m_info = MPI_INFO_NULL.mpi_info; 
     20    ep_lib::MPI_Info info_null; 
    2621 
    2722    // The file format will be detected automatically by NetCDF, it is safe to always set NC_MPIIO 
    2823    // even if Parallel NetCDF ends up being used. 
    2924    if (mpi) 
    30       CNetCdfInterface::openPar(filename, NC_NOWRITE | NC_MPIIO, *comm, m_info, this->ncidp); 
     25      //CNetCdfInterface::openPar(filename, NC_NOWRITE | NC_MPIIO, *comm, info_null, this->ncidp); 
     26      CNetCdfInterface::openPar(filename, NC_NOWRITE | NC_MPIIO, static_cast<MPI_Comm>(comm->mpi_comm), info_null.mpi_info, this->ncidp); 
    3127    else 
    3228      CNetCdfInterface::open(filename, NC_NOWRITE, this->ncidp); 
  • XIOS/dev/branch_openmp/src/io/inetcdf4.hpp

    r1138 r1328  
    1414#endif  // UNLIMITED_DIM 
    1515 
    16  
    1716namespace xios 
    1817{ 
     
    2322    public: 
    2423      /// Constructors /// 
    25       CINetCDF4(const StdString& filename, const MPI_Comm* comm = NULL, bool multifile = true, 
     24      CINetCDF4(const StdString& filename, const ep_lib::MPI_Comm* comm = NULL, bool multifile = true, 
    2625                const StdString& timeCounterName = "time_counter"); 
    2726      CINetCDF4(const CINetCDF4& inetcdf4);       // Not implemented. 
  • XIOS/dev/branch_openmp/src/io/inetcdf4_decl.cpp

    r1138 r1328  
    11#include "inetcdf4_impl.hpp" 
    2 // mpi_std.hpp 
    32 
    43namespace xios 
  • XIOS/dev/branch_openmp/src/io/inetcdf4_impl.hpp

    r1138 r1328  
    44#include "inetcdf4.hpp" 
    55#include "netCdfInterface.hpp" 
    6 // mpi_std.hpp 
    76 
    87namespace xios 
  • XIOS/dev/branch_openmp/src/io/nc4_data_input.cpp

    r1176 r1328  
    88#include "scalar.hpp" 
    99 
    10 // mpi.hpp 
    11  
    1210namespace xios 
    1311{ 
    14   CNc4DataInput::CNc4DataInput(const StdString& filename, ::MPI_Comm comm_file, bool multifile, bool isCollective /*= true*/, const StdString& timeCounterName /*= "time_counter"*/) 
     12  CNc4DataInput::CNc4DataInput(const StdString& filename, ep_lib::MPI_Comm comm_file, bool multifile, bool isCollective /*= true*/, const StdString& timeCounterName /*= "time_counter"*/) 
    1513    : SuperClass() 
    1614    , SuperClassWriter(filename, &comm_file, multifile, timeCounterName) 
     
    5553    CArray<double,1> fieldData(grid->getWrittenDataSize()); 
    5654    if (!field->default_value.isEmpty()) fieldData = field->default_value; 
    57     #ifdef _usingEP 
    58     SuperClass::type = ONE_FILE; 
    59     printf("SuperClass::type = %d\n", SuperClass::type); 
    60     #endif 
     55 
    6156    switch (SuperClass::type) 
    6257    { 
     
    326321      std::vector<StdSize> nBeginBndsLatLon(3), nSizeBndsLatLon(3); 
    327322      nBeginBndsLatLon[0] = 0; nSizeBndsLatLon[0] = domain->nj_glo.getValue(); 
    328       nBeginBndsLatLon[1] = 0; nSizeBndsLatLon[1] = domain->nj_glo.getValue(); 
     323      nBeginBndsLatLon[1] = 0; nSizeBndsLatLon[1] = domain->ni_glo.getValue(); 
    329324      nBeginBndsLatLon[2] = 0; nSizeBndsLatLon[2] = nbVertex; 
    330325 
  • XIOS/dev/branch_openmp/src/io/nc4_data_input.hpp

    r1138 r1328  
    33 
    44/// XIOS headers /// 
     5#include "mpi_std.hpp" 
    56#include "xios_spl.hpp" 
    67#include "data_input.hpp" 
    78#include "inetcdf4.hpp" 
    8 // mpi_std.hpp 
    99 
    1010namespace xios 
     
    2424 
    2525    /// Constructors /// 
    26     CNc4DataInput(const StdString& filename, MPI_Comm comm_file, bool multifile, bool isCollective = true, 
     26    CNc4DataInput(const StdString& filename, ep_lib::MPI_Comm comm_file, bool multifile, bool isCollective = true, 
    2727                  const StdString& timeCounterName = "time_counter"); 
    2828    CNc4DataInput(const CNc4DataInput& dataInput);       // Not implemented. 
     
    7171  private: 
    7272    /// Private attributes /// 
    73     MPI_Comm comm_file; 
     73    ep_lib::MPI_Comm comm_file; 
    7474    const StdString filename; 
    7575    bool isCollective; 
  • XIOS/dev/branch_openmp/src/io/nc4_data_output.cpp

    r1205 r1328  
    1313#include "timer.hpp" 
    1414#include "uuid.hpp" 
    15 // mpi.hpp 
    16  
    1715namespace xios 
    1816{ 
     
    3028      CNc4DataOutput::CNc4DataOutput 
    3129         (CFile* file, const StdString & filename, bool exist, bool useClassicFormat, bool useCFConvention, 
    32           ::MPI_Comm comm_file, bool multifile, bool isCollective, const StdString& timeCounterName) 
     30          ep_lib::MPI_Comm comm_file, bool multifile, bool isCollective, const StdString& timeCounterName) 
    3331            : SuperClass() 
    3432            , SuperClassWriter(filename, exist, useClassicFormat, useCFConvention, &comm_file, multifile, timeCounterName) 
     
    465463      StdString domainName = domain->name; 
    466464      domain->assignMesh(domainName, domain->nvertex); 
    467       domain->mesh->createMeshEpsilon(static_cast< ::MPI_Comm >(server->intraComm.mpi_comm), domain->lonvalue_srv, domain->latvalue_srv, domain->bounds_lon_srv, domain->bounds_lat_srv); 
     465      domain->mesh->createMeshEpsilon(server->intraComm, domain->lonvalue_srv, domain->latvalue_srv, domain->bounds_lon_srv, domain->bounds_lat_srv); 
    468466 
    469467      StdString node_x = domainName + "_node_x"; 
  • XIOS/dev/branch_openmp/src/io/nc4_data_output.hpp

    r1138 r1328  
    44/// XIOS headers /// 
    55#include "xios_spl.hpp" 
     6#include "mpi_std.hpp" 
    67#include "onetcdf4.hpp" 
    78#include "data_output.hpp" 
    8 // mpi_std.hpp 
    99 
    1010namespace xios 
     
    2727            CNc4DataOutput 
    2828               (CFile* file, const StdString & filename, bool exist, bool useClassicFormat, 
    29                 bool useCFConvention, MPI_Comm comm_file, bool multifile,  
    30                 bool isCollective = true, const StdString& timeCounterName = "time_counter"); 
     29                bool useCFConvention, 
     30                ep_lib::MPI_Comm comm_file, bool multifile, bool isCollective = true, 
     31                const StdString& timeCounterName = "time_counter"); 
    3132 
    3233            CNc4DataOutput(const CNc4DataOutput & dataoutput);       // Not implemented. 
     
    116117 
    117118            /// Propriétés privées /// 
    118             MPI_Comm comm_file; 
     119            ep_lib::MPI_Comm comm_file; 
    119120            const StdString filename; 
    120121            std::map<Time, StdSize> timeToRecordCache; 
  • XIOS/dev/branch_openmp/src/io/netCdfInterface.cpp

    r1153 r1328  
    1010#include "netCdfInterface.hpp" 
    1111#include "netCdfException.hpp" 
    12 // mpi_std.hpp 
    1312 
    1413namespace xios 
     
    5049int CNetCdfInterface::createPar(const StdString& fileName, int cMode, MPI_Comm comm, MPI_Info info, int& ncId) 
    5150{ 
    52   int status = xios::nc_create_par(fileName.c_str(), cMode, comm, info, &ncId); 
     51  int status = xios::nc_create_par(fileName.c_str(), cMode, comm, MPI_INFO_NULL.mpi_info, &ncId); 
    5352  if (NC_NOERR != status) 
    5453  { 
     
    7574int CNetCdfInterface::open(const StdString& fileName, int oMode, int& ncId) 
    7675{ 
    77   int status = NC_NOERR; 
    78   #pragma omp critical (_netcdf) 
    79   status = nc_open(fileName.c_str(), oMode, &ncId); 
    80    
     76  int status = nc_open(fileName.c_str(), oMode, &ncId); 
    8177  if (NC_NOERR != status) 
    8278  { 
     
    106102int CNetCdfInterface::openPar(const StdString& fileName, int oMode, MPI_Comm comm, MPI_Info info, int& ncId) 
    107103{ 
    108   int status; 
    109   #pragma omp critical (_netcdf) 
    110   status = xios::nc_open_par(fileName.c_str(), oMode, comm, info, &ncId); // nc_open 
     104  //int status = xios::nc_open_par(fileName.c_str(), oMode, comm, info, &ncId); 
     105  int status = xios::nc_open_par(fileName.c_str(), oMode, comm, MPI_INFO_NULL.mpi_info, &ncId); 
    111106  if (NC_NOERR != status) 
    112107  { 
     
    131126int CNetCdfInterface::close(int ncId) 
    132127{ 
    133   int status = NC_NOERR; 
    134   #pragma omp critical (_netcdf) 
    135   //#pragma omp master 
    136   { 
    137   status = nc_close(ncId); 
     128  int status = nc_close(ncId); 
    138129  if (NC_NOERR != status) 
    139130  { 
     
    146137    throw CNetCdfException(e); 
    147138  } 
    148   } 
     139 
    149140  return status; 
    150141} 
     
    356347int CNetCdfInterface::inqDimLen(int ncid, int dimId, StdSize& dimLen) 
    357348{ 
    358   int status; 
    359   #pragma omp critical (_netcdf) 
    360   status = nc_inq_dimlen(ncid, dimId, &dimLen); 
     349  int status = nc_inq_dimlen(ncid, dimId, &dimLen); 
    361350  if (NC_NOERR != status) 
    362351  { 
  • XIOS/dev/branch_openmp/src/io/netCdfInterface.hpp

    r1134 r1328  
    1010#define __NETCDF_INTERFACE_HPP_ 
    1111 
     12#include "mpi_std.hpp" 
    1213#include "xios_spl.hpp" 
    1314 
     
    1617#endif 
    1718 
    18 #include "mpi_std.hpp" 
    1919#include "netcdf.hpp" 
    2020 
  • XIOS/dev/branch_openmp/src/io/netCdfInterface_decl.cpp

    r1138 r1328  
    99 
    1010#include "netCdfInterface_impl.hpp" 
    11 // mpi_std.hpp 
    1211 
    1312namespace xios 
  • XIOS/dev/branch_openmp/src/io/netCdfInterface_impl.hpp

    r1146 r1328  
    1313#include "netCdfInterface.hpp" 
    1414#include "netCdfException.hpp" 
    15 // mpi_std.hpp 
    1615 
    1716namespace xios 
     
    8685  int CNetCdfInterface::getVaraType(int ncid, int varId, const StdSize* start, const StdSize* count, T* data) 
    8786  { 
    88     int status; 
    89     #pragma omp critical (_netcdf) 
    90     status = ncGetVaraType(ncid, varId, start, count, data); 
     87    int status = ncGetVaraType(ncid, varId, start, count, data); 
    9188    if (NC_NOERR != status) 
    9289    { 
  • XIOS/dev/branch_openmp/src/io/netCdf_cf_constant.hpp

    r1138 r1328  
    44#include "inetcdf4.hpp" 
    55#include "netCdfInterface.hpp" 
    6  
    7 // mpi_std.hpp 
    86 
    97namespace xios 
  • XIOS/dev/branch_openmp/src/io/netcdf.hpp

    r1138 r1328  
    1818extern "C" 
    1919{ 
    20   #include <netcdf_par.h> 
     20include <netcdf_par.h> 
    2121} 
    2222#  endif 
  • XIOS/dev/branch_openmp/src/io/onetcdf4.cpp

    r1287 r1328  
    1212      /// ////////////////////// Définitions ////////////////////// /// 
    1313 
    14       CONetCDF4::CONetCDF4(const StdString& filename, bool append, bool useClassicFormat, bool useCFConvention,  
    15                            const MPI_Comm* comm, bool multifile, const StdString& timeCounterName) 
     14      CONetCDF4::CONetCDF4(const StdString& filename, bool append, bool useClassicFormat, 
     15                                                        bool useCFConvention, 
     16                           const ep_lib::MPI_Comm* comm, bool multifile, const StdString& timeCounterName) 
    1617        : path() 
    1718        , wmpi(false) 
     
    3132 
    3233      void CONetCDF4::initialize(const StdString& filename, bool append, bool useClassicFormat, bool useCFConvention,  
    33                                  const MPI_Comm* comm, bool multifile, const StdString& timeCounterName) 
     34                                 const ep_lib::MPI_Comm* comm, bool multifile, const StdString& timeCounterName) 
    3435      { 
    3536         this->useClassicFormat = useClassicFormat; 
     
    4243         { 
    4344            int commSize = 0; 
    44             MPI_Comm_size(*comm, &commSize); 
     45            ep_lib::MPI_Comm_size(*comm, &commSize); 
    4546            if (commSize <= 1) 
    4647               comm = NULL; 
    4748         } 
    4849         wmpi = comm && !multifile; 
     50         ep_lib::MPI_Info info_null; 
    4951 
    5052         if (wmpi) 
     
    5658            CTimer::get("Files : create").resume(); 
    5759            if (wmpi) 
    58                CNetCdfInterface::createPar(filename, mode, *comm, MPI_INFO_NULL.mpi_info, this->ncidp); 
     60               CNetCdfInterface::createPar(filename, mode, static_cast<MPI_Comm>(comm->mpi_comm), info_null.mpi_info, this->ncidp); 
    5961            else 
    6062               CNetCdfInterface::create(filename, mode, this->ncidp); 
     
    6870            CTimer::get("Files : open").resume(); 
    6971            if (wmpi) 
    70                CNetCdfInterface::openPar(filename, mode, *comm, MPI_INFO_NULL.mpi_info, this->ncidp); 
     72               CNetCdfInterface::openPar(filename, mode, static_cast<MPI_Comm>(comm->mpi_comm), info_null.mpi_info, this->ncidp); 
    7173            else 
    7274               CNetCdfInterface::open(filename, mode, this->ncidp); 
     
    539541                                 const std::vector<StdSize>& scount, const int* data) 
    540542      { 
    541          CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data); 
    542       } 
    543  
     543          CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data); 
     544      } 
    544545      //--------------------------------------------------------------- 
    545546 
     
    549550                                 const std::vector<StdSize>& scount, const float* data) 
    550551      { 
    551          CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data); 
     552          CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data); 
    552553      } 
    553554 
  • XIOS/dev/branch_openmp/src/io/onetcdf4.hpp

    r1205 r1328  
    44/// XIOS headers /// 
    55#include "xios_spl.hpp" 
     6#include "mpi_std.hpp" 
    67#include "exception.hpp" 
    78#include "data_output.hpp" 
    89#include "array_new.hpp" 
    9 #include "mpi_std.hpp" 
    1010#include "netcdf.hpp" 
    1111 
     
    1313   #define UNLIMITED_DIM (size_t)(-1) 
    1414#endif  //UNLIMITED_DIM 
    15  
    16 // mpi_std.hpp 
    1715 
    1816namespace xios 
     
    3028            CONetCDF4(const StdString& filename, bool append, bool useClassicFormat = false, 
    3129                          bool useCFConvention = true, 
    32                       const MPI_Comm* comm = NULL, bool multifile = true, 
     30                      const ep_lib::MPI_Comm* comm = NULL, bool multifile = true, 
    3331                      const StdString& timeCounterName = "time_counter"); 
    3432 
     
    3937            /// Initialisation /// 
    4038            void initialize(const StdString& filename, bool append, bool useClassicFormat, bool useCFConvention, 
    41                             const MPI_Comm* comm, bool multifile, const StdString& timeCounterName); 
     39                            const ep_lib::MPI_Comm* comm, bool multifile, const StdString& timeCounterName); 
    4240            void close(void); 
    4341            void sync(void); 
  • XIOS/dev/branch_openmp/src/io/onetcdf4_decl.cpp

    r1138 r1328  
    11#include "onetcdf4_impl.hpp" 
    2 // mpi_std.hpp 
    32 
    43namespace xios 
  • XIOS/dev/branch_openmp/src/io/onetcdf4_impl.hpp

    r1205 r1328  
    55#include "netCdfInterface.hpp" 
    66#include "timer.hpp" 
    7 // mpi_std.hpp 
    87 
    98namespace xios 
  • XIOS/dev/branch_openmp/src/log.cpp

    r1164 r1328  
    11#include "log.hpp" 
    2 #include <string> 
    3 #include <iostream> 
    4 #include <string> 
    52 
    63namespace xios 
    74{ 
    8  
    9   std::filebuf* info_FB[16]; 
    10  
    11  
    125  CLog info("info") ; 
    136  CLog report("report") ; 
    147  CLog error("error", cerr.rdbuf()) ; 
    15  
    16    
    17   CLog& CLog::operator()(int l) 
    18     { 
    19       if (l<=level) 
    20       { 
    21         omp_set_lock( &mutex ); 
    22         //rdbuf(strBuf_);  
    23         rdbuf(strBuf_array[omp_get_thread_num()]);  
    24         *this<<"-> "<<name<<" : " ; 
    25         omp_unset_lock( &mutex ); 
    26       } 
    27       else rdbuf(NULL) ; 
    28       return *this; 
    29     } 
    30  
    31  
    32  
    33   int test_omp_rank; 
    34   #pragma omp threadprivate(test_omp_rank) 
    35  
    36    
    37  
    388} 
  • XIOS/dev/branch_openmp/src/log.hpp

    r1164 r1328  
    55#include <iostream> 
    66#include <string> 
    7 #include <stdio.h> 
    8 #include <omp.h> 
    97 
    108namespace xios 
     
    1614    public : 
    1715    CLog(const string& name_, std::streambuf* sBuff = cout.rdbuf()) 
    18       : ostream(cout.rdbuf()), level(0), name(name_), strBuf_(sBuff)  
     16      : ostream(sBuff), level(0), name(name_), strBuf_(sBuff) {} 
     17    CLog& operator()(int l) 
    1918    { 
    20       omp_init_lock( &mutex ); 
    21       for(int i=0; i<16; i++) 
    22         strBuf_array[i] = sBuff; 
     19      if (l<=level) 
     20      { 
     21        rdbuf(strBuf_); 
     22        *this<<"-> "<<name<<" : " ; 
     23      } 
     24      else rdbuf(NULL) ; 
     25      return *this; 
    2326    } 
    24  
    25     ~CLog() 
    26     { 
    27       omp_destroy_lock( &mutex ); 
    28     } 
    29  
    30  
    31     CLog& operator()(int l); 
    3227    void setLevel(int l) {level=l; } 
    33     int  getLevel() {return level ;} 
     28    int getLevel() {return level ;} 
    3429    bool isActive(void) { if (rdbuf()==NULL) return true ; else return false ;} 
    3530    bool isActive(int l) {if (l<=level) return true ; else return false ; } 
     
    5146     * \param [in] pointer to new streambuf 
    5247    */ 
    53     void changeStreamBuff(std::streambuf* sBuff)  
    54     {  
    55       strBuf_ = sBuff;  
    56       strBuf_array[omp_get_thread_num()] = sBuff; 
    57       rdbuf(sBuff); 
    58     } 
     48    void changeStreamBuff(std::streambuf* sBuff) { strBuf_ = sBuff; rdbuf(sBuff); } 
    5949 
    6050    int level ; 
    6151    string name ; 
    6252    std::streambuf* strBuf_; 
    63     std::streambuf* strBuf_array[16]; 
    64     omp_lock_t mutex; 
    6553  }; 
    6654 
     
    6856  extern CLog report; 
    6957  extern CLog error; 
    70  
    71  
    72   extern std::filebuf* info_FB[16]; 
    73  
    74  
    7558} 
    7659#endif 
  • XIOS/dev/branch_openmp/src/memtrack.cpp

    r1205 r1328  
    4444#include <sstream> 
    4545#include <string> 
     46 
    4647#include <execinfo.h> 
    4748 
     
    7677        private:    // static member variables 
    7778            static BlockHeader *ourFirstNode; 
    78             #pragma omp threadprivate(ourFirstNode) 
    7979     
    8080        private:    // member variables 
  • XIOS/dev/branch_openmp/src/mpi.hpp

    r1134 r1328  
    1010/* skip C++ Binding for OpenMPI */ 
    1111#define OMPI_SKIP_MPICXX 
    12  
    1312#ifdef _usingEP 
    1413  #include <omp.h> 
    1514  #include "../extern/src_ep_dev/ep_lib.hpp" 
    16   using namespace ep_lib; 
     15  #include "../extern/src_ep_dev/ep_declaration.hpp" 
     16  //using namespace ep_lib; 
    1717#elif _usingMPI 
    1818  #include <mpi.h> 
  • XIOS/dev/branch_openmp/src/mpi_std.hpp

    r1134 r1328  
    1111#define OMPI_SKIP_MPICXX 
    1212 
     13#include <mpi.h> 
    1314#include "../extern/src_ep_dev/ep_lib.hpp" 
    14 #include <mpi.h> 
    15  
    16  
     15#include "../extern/src_ep_dev/ep_declaration.hpp" 
    1716 
    1817#endif 
  • XIOS/dev/branch_openmp/src/node/axis.cpp

    r1205 r1328  
    4444   { /* Ne rien faire de plus */ } 
    4545 
    46    std::map<StdString, ETranformationType> *CAxis::transformationMapList_ptr = 0; //new std::map<StdString, ETranformationType>();   
    47    //bool CAxis::dummyTransformationMapList_ = CAxis::initializeTransformationMap(CAxis::transformationMapList_ptr); 
    48  
     46   //std::map<StdString, ETranformationType> CAxis::transformationMapList_ = std::map<StdString, ETranformationType>(); 
     47   std::map<StdString, ETranformationType> *CAxis::transformationMapList_ptr = 0; 
     48   //bool CAxis::dummyTransformationMapList_ = CAxis::initializeTransformationMap(CAxis::transformationMapList_); 
     49    
    4950   bool CAxis::initializeTransformationMap(std::map<StdString, ETranformationType>& m) 
    5051   { 
     
    5556     m["extract_domain"] = TRANS_EXTRACT_DOMAIN_TO_AXIS; 
    5657   } 
    57  
    5858 
    5959   bool CAxis::initializeTransformationMap() 
     
    6666     (*CAxis::transformationMapList_ptr)["extract_domain"]   = TRANS_EXTRACT_DOMAIN_TO_AXIS; 
    6767   } 
    68  
    6968 
    7069   ///--------------------------------------------------------------- 
     
    500499        globalAxisZoom[nZoomCount] = globalZoomIndex; 
    501500        ++nZoomCount; 
    502       } 
     501      }  
    503502    } 
    504503 
     
    831830      CContextServer* server = CContext::getCurrent()->server; 
    832831      axis->numberWrittenIndexes_ = axis->indexesToWrite.size(); 
    833       ep_lib::MPI_Allreduce(&axis->numberWrittenIndexes_, &axis->totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    834       ep_lib::MPI_Scan(&axis->numberWrittenIndexes_, &axis->offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
     832      MPI_Allreduce(&axis->numberWrittenIndexes_, &axis->totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
     833      MPI_Scan(&axis->numberWrittenIndexes_, &axis->offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    835834      axis->offsetWrittenIndexes_ -= axis->numberWrittenIndexes_; 
    836835    } 
     
    978977        msg << ni << begin << end; 
    979978        msg << global_zoom_begin.getValue() << global_zoom_n.getValue(); 
    980         msg << isCompressible_; 
     979        msg << isCompressible_;         
    981980        msg << zoomIndex; 
    982981        if (zoomIndex) 
     
    11571156 
    11581157        nodeElementName = node.getElementName(); 
    1159  
     1158        //std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_.end(), it; 
    11601159        if(transformationMapList_ptr == 0) initializeTransformationMap(); 
    1161         //transformationMapList_ptr = new std::map<StdString, ETranformationType>(); 
    1162  
    1163         std::map<StdString, ETranformationType>::const_iterator ite = (*CAxis::transformationMapList_ptr).end(), it; 
    1164         it = (*CAxis::transformationMapList_ptr).find(nodeElementName); 
     1160        std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_ptr->end(), it; 
     1161        //it = transformationMapList_.find(nodeElementName); 
     1162        it = transformationMapList_ptr->find(nodeElementName); 
    11651163        if (ite != it) 
    11661164        { 
     
    11841182 
    11851183} // namespace xios 
    1186  
  • XIOS/dev/branch_openmp/src/node/axis.hpp

    r1205 r1328  
    172172       private: 
    173173         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); 
    174          //static bool initializeTransformationMap(std::map<StdString, ETranformationType>* m); 
    175174         static bool initializeTransformationMap(); 
    176  
    177175         //static std::map<StdString, ETranformationType> transformationMapList_; 
    178           
    179176         static std::map<StdString, ETranformationType> *transformationMapList_ptr; 
    180          #pragma omp threadprivate(transformationMapList_ptr) 
    181  
    182          //static bool dummyTransformationMapList_; 
    183          //#pragma omp threadprivate(dummyTransformationMapList_) 
     177         static bool dummyTransformationMapList_; 
    184178 
    185179         DECLARE_REF_FUNC(Axis,axis) 
     
    193187 
    194188#endif // __XIOS_CAxis__ 
    195  
  • XIOS/dev/branch_openmp/src/node/compute_connectivity_domain.hpp

    r1134 r1328  
    6060      static CTransformation<CDomain>* create(const StdString& id, xml::CXMLNode* node); 
    6161      static bool _dummyRegistered; 
    62       #pragma omp threadprivate(_dummyRegistered) 
    63        
    6462  }; // class CComputeConnectivityDomain 
    6563 
  • XIOS/dev/branch_openmp/src/node/context.cpp

    r1287 r1328  
     1 
    12#include "context.hpp" 
    23#include "attribute_template.hpp" 
     
    1718#include "memtrack.hpp" 
    1819 
     20using namespace ep_lib; 
     21 
    1922 
    2023namespace xios { 
    2124 
    22   //shared_ptr<CContextGroup> CContext::root; 
    23   boost::shared_ptr<CContextGroup> * CContext::root_ptr = 0; 
    24  
    25    /// ////////////////////// Dfinitions ////////////////////// /// 
     25  shared_ptr<CContextGroup> CContext::root; 
     26 
     27   /// ////////////////////// Définitions ////////////////////// /// 
    2628 
    2729   CContext::CContext(void) 
     
    5759   CContextGroup* CContext::getRoot(void) 
    5860   { 
    59       //if (root.get()==NULL) root=shared_ptr<CContextGroup>(new CContextGroup(xml::CXMLNode::GetRootName())); 
    60       //return root.get(); 
    61  
    62       //static shared_ptr<CContextGroup> *root_ptr; 
    63       if(root_ptr == 0) //root_ptr = new shared_ptr<CContextGroup>; 
    64       // if (root_ptr->get()==NULL)  
    65       root_ptr = new boost::shared_ptr<CContextGroup>(new CContextGroup(xml::CXMLNode::GetRootName())); 
    66       return root_ptr->get(); 
     61      if (root.get()==NULL) root=shared_ptr<CContextGroup>(new CContextGroup(xml::CXMLNode::GetRootName())); 
     62      return root.get(); 
    6763   } 
    6864 
     
    186182      if (!this->hasChild()) 
    187183      { 
    188          //oss << "<!-- No definition -->" << std::endl; // fait planter l'incrmentation 
     184         //oss << "<!-- No definition -->" << std::endl; // fait planter l'incrémentation 
    189185      } 
    190186      else 
     
    248244   { 
    249245     hasClient=true; 
    250      client = new CContextClient(this, intraComm, interComm, cxtServer); 
    251  
    252      int tmp_rank; 
    253      MPI_Comm_rank(intraComm, &tmp_rank); 
    254      MPI_Barrier(intraComm); 
    255       
    256  
     246     client = new CContextClient(this,intraComm, interComm, cxtServer); 
    257247     registryIn=new CRegistry(intraComm); 
    258248     registryIn->setPath(getId()) ; 
     
    271261     else 
    272262     { 
    273        MPI_Comm_dup(intraComm, &intraCommServer); 
     263       ep_lib::MPI_Comm_dup(intraComm, &intraCommServer); 
    274264       comms.push_back(intraCommServer); 
    275        MPI_Comm_dup(interComm, &interCommServer); 
     265       ep_lib::MPI_Comm_dup(interComm, &interCommServer); 
    276266       comms.push_back(interCommServer); 
    277267     } 
     
    353343     else 
    354344     { 
    355        MPI_Comm_dup(intraComm, &intraCommClient); 
     345       ep_lib::MPI_Comm_dup(intraComm, &intraCommClient); 
    356346       comms.push_back(intraCommClient); 
    357        MPI_Comm_dup(interComm, &interCommClient); 
     347       ep_lib::MPI_Comm_dup(interComm, &interCommClient); 
    358348       comms.push_back(interCommClient); 
    359349     } 
     
    395385 
    396386        for (std::list<ep_lib::MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it) 
    397           MPI_Comm_free(&(*it)); 
     387          ep_lib::MPI_Comm_free(&(*it)); 
    398388        comms.clear(); 
    399389      } 
     
    527517   } 
    528518 
    529    void CContext::checkPrefetchingOfEnabledReadModeFiles() 
     519   void CContext::doPostTimestepOperationsForEnabledReadModeFiles() 
    530520   { 
    531521     int size = enabledReadModeFiles.size(); 
    532522     for (int i = 0; i < size; ++i) 
    533523     { 
    534         enabledReadModeFiles[i]->prefetchEnabledReadModeFieldsIfNeeded(); 
     524        enabledReadModeFiles[i]->doPostTimestepOperationsForEnabledReadModeFields(); 
    535525     } 
    536526   } 
     
    563553  } 
    564554 
    565    void CContext::solveAllInheritance(bool apply) 
    566    { 
    567      // Rsolution des hritages descendants (cd des hritages de groupes) 
     555   void CContext::solveAllInheritance(bool apply) // default : apply = true 
     556   { 
     557     // Résolution des héritages descendants (càd des héritages de groupes) 
    568558     // pour chacun des contextes. 
    569559      solveDescInheritance(apply); 
    570560 
    571      // Rsolution des hritages par rfrence au niveau des fichiers. 
     561     // Résolution des héritages par référence au niveau des fichiers. 
    572562      const vector<CFile*> allFiles=CFile::getAll(); 
    573563      const vector<CGrid*> allGrids= CGrid::getAll(); 
     
    593583 
    594584      for (unsigned int i = 0; i < allFiles.size(); i++) 
    595          if (!allFiles[i]->enabled.isEmpty()) // Si l'attribut 'enabled' est dfini. 
     585         if (!allFiles[i]->enabled.isEmpty()) // Si l'attribut 'enabled' est défini. 
    596586         { 
    597             if (allFiles[i]->enabled.getValue()) // Si l'attribut 'enabled' est fix  vrai. 
     587            if (allFiles[i]->enabled.getValue()) // Si l'attribut 'enabled' est fixé à vrai. 
    598588            { 
    599589              if ((initDate + allFiles[i]->output_freq.getValue()) < (initDate + this->getCalendar()->getTimeStep())) 
     
    620610 
    621611      if (enabledFiles.size() == 0) 
    622          DEBUG(<<"Aucun fichier ne va tre sorti dans le contexte nomm \"" 
     612         DEBUG(<<"Aucun fichier ne va être sorti dans le contexte nommé \"" 
    623613               << getId() << "\" !"); 
    624614   } 
     
    836826   void CContext::postProcessing() 
    837827   { 
    838      int myRank; 
    839      MPI_Comm_rank(MPI_COMM_WORLD, &myRank); 
    840  
    841828     if (isPostProcessed) return; 
    842829 
     
    860847      prepareTimeseries(); 
    861848 
    862       //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers sortir. 
     849      //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 
    863850      this->findEnabledFiles(); 
    864851      this->findEnabledReadModeFiles(); 
     
    12181205   void CContext::updateCalendar(int step) 
    12191206   { 
    1220       #pragma omp critical (_output) 
    1221       {info(50) << "updateCalendar : before : " << calendar->getCurrentDate() << endl;} 
     1207      info(50) << "updateCalendar : before : " << calendar->getCurrentDate() << endl; 
    12221208      calendar->update(step); 
    1223       #pragma omp critical (_output) 
    1224       {info(50) << "updateCalendar : after : " << calendar->getCurrentDate() << endl;} 
     1209      info(50) << "updateCalendar : after : " << calendar->getCurrentDate() << endl; 
    12251210#ifdef XIOS_MEMTRACK_LIGHT 
    1226       #pragma omp critical (_output) 
    1227       {info(50) << " Current memory used by XIOS : "<<  MemTrack::getCurrentMemorySize()*1.0/(1024*1024)<<" Mbyte, at timestep "<<step<<" of context "<<this->getId()<<endl ;} 
     1211      info(50) << " Current memory used by XIOS : "<<  MemTrack::getCurrentMemorySize()*1.0/(1024*1024)<<" Mbyte, at timestep "<<step<<" of context "<<this->getId()<<endl ; 
    12281212#endif 
    12291213      if (hasClient) 
    12301214      { 
    1231         checkPrefetchingOfEnabledReadModeFiles(); 
     1215        doPostTimestepOperationsForEnabledReadModeFiles(); 
    12321216        garbageCollector.invalidate(calendar->getCurrentDate()); 
    12331217      } 
     
    12731257    CContext* context = CObjectFactory::CreateObject<CContext>(id).get(); 
    12741258    getRoot(); 
    1275     if (!hasctxt) CGroupFactory::AddChild(*root_ptr, context->getShared()); 
     1259    if (!hasctxt) CGroupFactory::AddChild(root, context->getShared()); 
    12761260 
    12771261#define DECLARE_NODE(Name_, name_) \ 
  • XIOS/dev/branch_openmp/src/node/context.hpp

    r1287 r1328  
    55#include "xios_spl.hpp" 
    66//#include "node_type.hpp" 
     7#include "mpi_std.hpp" 
    78#include "calendar_wrapper.hpp" 
    89 
     
    1314#include "garbage_collector.hpp" 
    1415#include "registry.hpp" 
    15 #include "mpi.hpp" 
    1616 
    1717 
     
    115115         void buildFilterGraphOfEnabledFields(); 
    116116         void startPrefetchingOfEnabledReadModeFiles(); 
    117          void checkPrefetchingOfEnabledReadModeFiles(); 
     117         void doPostTimestepOperationsForEnabledReadModeFiles(); 
    118118         void findFieldsWithReadAccess(void); 
    119119         void solveAllRefOfFieldsWithReadAccess(); 
     
    206206 
    207207         // Context root 
    208          //static shared_ptr<CContextGroup> root; 
    209  
    210          static boost::shared_ptr<CContextGroup> *root_ptr; 
    211          #pragma omp threadprivate(root_ptr) 
     208         static shared_ptr<CContextGroup> root; 
    212209 
    213210         // Determine context on client or not 
     
    222219         // Concrete contex client 
    223220         CContextClient* client; 
    224  
    225  
    226221         CRegistry* registryIn ;  //!< input registry which is read from file 
    227222         CRegistry* registryOut ; //!< output registry which will be wrote on file at the finalize 
    228           
    229223 
    230224      private: 
  • XIOS/dev/branch_openmp/src/node/domain.cpp

    r1138 r1328  
    2626namespace xios { 
    2727 
    28    /// ////////////////////// Dfinitions ////////////////////// /// 
     28   /// ////////////////////// Définitions ////////////////////// /// 
    2929 
    3030   CDomain::CDomain(void) 
     
    6666 
    6767   //std::map<StdString, ETranformationType> CDomain::transformationMapList_ = std::map<StdString, ETranformationType>(); 
     68   std::map<StdString, ETranformationType> *CDomain::transformationMapList_ptr = 0; 
    6869   //bool CDomain::_dummyTransformationMapList = CDomain::initializeTransformationMap(CDomain::transformationMapList_); 
    69  
    70    std::map<StdString, ETranformationType> *CDomain::transformationMapList_ptr = 0; 
    7170 
    7271   bool CDomain::initializeTransformationMap(std::map<StdString, ETranformationType>& m) 
     
    8887     (*CDomain::transformationMapList_ptr)["expand_domain"] = TRANS_EXPAND_DOMAIN; 
    8988   } 
    90  
    9189 
    9290   const std::set<StdString> & CDomain::getRelFiles(void) const 
     
    445443      break; 
    446444     } 
     445     completeLonLatClient() ; 
    447446 
    448447   } 
     
    636635   { 
    637636          CContext* context = CContext::getCurrent(); 
    638           CContextClient* client = context->client; 
     637      CContextClient* client = context->client; 
    639638          lon_g.resize(ni_glo) ; 
    640639          lat_g.resize(nj_glo) ; 
     
    14951494 
    14961495      if (context->hasClient) 
    1497       { // Ct client uniquement 
     1496      { // CÃŽté client uniquement 
    14981497         this->checkMask(); 
    14991498         this->checkDomainData(); 
     
    15021501      } 
    15031502      else 
    1504       { // Ct serveur uniquement 
     1503      { // CÃŽté serveur uniquement 
    15051504      } 
    15061505 
     
    15351534 
    15361535      if (context->hasClient) 
    1537       { // Ct client uniquement 
     1536      { // CÃŽté client uniquement 
    15381537         this->checkMask(); 
    15391538         this->checkDomainData(); 
     
    15431542      } 
    15441543      else 
    1545       { // Ct serveur uniquement 
     1544      { // CÃŽté serveur uniquement 
    15461545      } 
    15471546 
     
    17261725                                                                                client->intraComm); 
    17271726    clientServerMap->computeServerIndexMapping(globalIndexDomain); 
    1728      
    17291727    const CClientServerMapping::GlobalIndexMap& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer(); 
    17301728 
     
    23652363        nodeElementName = node.getElementName(); 
    23662364        if(transformationMapList_ptr == 0) initializeTransformationMap(); 
    2367         std::map<StdString, ETranformationType>::const_iterator ite = (*transformationMapList_ptr).end(), it; 
    2368         it = (*transformationMapList_ptr).find(nodeElementName); 
     2365        //std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_.end(), it; 
     2366        std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_ptr->end(), it; 
     2367        //it = transformationMapList_.find(nodeElementName); 
     2368        it = transformationMapList_ptr->find(nodeElementName); 
    23692369        if (ite != it) 
    23702370        { 
  • XIOS/dev/branch_openmp/src/node/domain.hpp

    r1134 r1328  
    218218         static bool initializeTransformationMap(); 
    219219         //static std::map<StdString, ETranformationType> transformationMapList_; 
    220   
    221220         static std::map<StdString, ETranformationType> *transformationMapList_ptr; 
    222          #pragma omp threadprivate(transformationMapList_ptr) 
    223  
    224          //static bool _dummyTransformationMapList; 
    225          //#pragma omp threadprivate(_dummyTransformationMapList) 
     221         static bool _dummyTransformationMapList; 
    226222 
    227223         DECLARE_REF_FUNC(Domain,domain) 
  • XIOS/dev/branch_openmp/src/node/expand_domain.hpp

    r1134 r1328  
    6060      static CTransformation<CDomain>* create(const StdString& id, xml::CXMLNode* node); 
    6161      static bool _dummyRegistered; 
    62       #pragma omp threadprivate(_dummyRegistered) 
    63        
    6462  }; // class CExpandDomain 
    6563 
  • XIOS/dev/branch_openmp/src/node/extract_axis_to_scalar.hpp

    r1134 r1328  
    6060      static CTransformation<CScalar>* create(const StdString& id, xml::CXMLNode* node); 
    6161      static bool _dummyRegistered; 
    62       #pragma omp threadprivate(_dummyRegistered) 
    6362  }; // class CExtractAxisToScalar 
    6463 
  • XIOS/dev/branch_openmp/src/node/extract_domain_to_axis.hpp

    r1134 r1328  
    6060      static CTransformation<CAxis>* create(const StdString& id, xml::CXMLNode* node); 
    6161      static bool _dummyRegistered; 
    62       #pragma omp threadprivate(_dummyRegistered) 
    6362  }; // class CExtractDomainToAxis 
    6463 
  • XIOS/dev/branch_openmp/src/node/field.cpp

    r1209 r1328  
    2424#include "spatial_transform_filter.hpp" 
    2525 
     26#include <stdio.h> 
     27 
    2628namespace xios{ 
    2729 
    2830   /// ////////////////////// Dfinitions ////////////////////// /// 
     31 
     32  CField* CField::my_getDirectFieldReference(void) const 
     33  {                                                                       
     34    // if (this->field_ref.isEmpty())                                      
     35    // ERROR("C" #type "* C" #type "::getDirect" #type "Reference(void)",  
     36    //       << "The " #name_ " with id = '" << getId() << "'"             
     37    //       << " has no " #name_ "_ref.");                                
     38                                                                        
     39    // if (!C##type::has(this->name_##_ref))                                 
     40    // ERROR("C" #type "* C" #type "::getDirect" #type "Reference(void)",  
     41    //       << this->name_##_ref                                          
     42    //       << " refers to an unknown " #name_ " id.");                   
     43                                                                        
     44    return CField::get(this->field_ref);                               
     45  } 
     46 
    2947 
    3048   CField::CField(void) 
     
    3856      , hasTimeInstant(false) 
    3957      , hasTimeCentered(false) 
     58      , wasDataRequestedFromServer(false) 
    4059      , wasDataAlreadyReceivedFromServer(false) 
    4160      , isEOF(false) 
     
    5271      , hasTimeInstant(false) 
    5372      , hasTimeCentered(false) 
     73      , wasDataRequestedFromServer(false) 
    5474      , wasDataAlreadyReceivedFromServer(false) 
    5575      , isEOF(false) 
     
    261281    lastDataRequestedFromServer = tsDataRequested; 
    262282 
    263     if (!isEOF) // No need to send the request if we already know we are at EOF 
     283    // No need to send the request if we are sure that we are already at EOF 
     284    if (!isEOF || context->getCalendar()->getCurrentDate() <= dateEOF) 
    264285    { 
    265286      CEventClient event(getType(), EVENT_ID_READ_DATA); 
     
    277298    else 
    278299      serverSourceFilter->signalEndOfStream(tsDataRequested); 
     300 
     301    wasDataRequestedFromServer = true; 
    279302 
    280303    return !isEOF; 
     
    293316    while (currentDate >= lastDataRequestedFromServer) 
    294317    { 
    295       #pragma omp critical (_output) 
    296       { 
    297         info(20) << "currentDate : " << currentDate << endl ; 
    298         info(20) << "lastDataRequestedFromServer : " << lastDataRequestedFromServer << endl ; 
    299         info(20) << "file->output_freq.getValue() : " << file->output_freq.getValue() << endl ; 
    300         info(20) << "lastDataRequestedFromServer + file->output_freq.getValue() : " << lastDataRequestedFromServer + file->output_freq << endl ; 
    301       } 
     318      info(20) << "currentDate : " << currentDate << endl ; 
     319      info(20) << "lastDataRequestedFromServer : " << lastDataRequestedFromServer << endl ; 
     320      info(20) << "file->output_freq.getValue() : " << file->output_freq.getValue() << endl ; 
     321      info(20) << "lastDataRequestedFromServer + file->output_freq.getValue() : " << lastDataRequestedFromServer + file->output_freq << endl ; 
     322 
    302323      dataRequested |= sendReadDataRequest(lastDataRequestedFromServer + file->output_freq); 
    303324    } 
     
    435456  { 
    436457    CContext* context = CContext::getCurrent(); 
    437     int record; 
    438458    std::map<int, CArray<double,1> > data; 
     459    const bool wasEOF = isEOF; 
    439460 
    440461    for (int i = 0; i < ranks.size(); i++) 
    441462    { 
    442463      int rank = ranks[i]; 
     464      int record; 
    443465      *buffers[i] >> record; 
    444466      isEOF = (record == int(-1)); 
     
    459481 
    460482    if (isEOF) 
     483    { 
     484      if (!wasEOF) 
     485        dateEOF = lastDataReceivedFromServer; 
     486 
    461487      serverSourceFilter->signalEndOfStream(lastDataReceivedFromServer); 
     488    } 
    462489    else 
    463490      serverSourceFilter->streamDataFromServer(lastDataReceivedFromServer, data); 
     491  } 
     492 
     493  void CField::checkForLateDataFromServer(void) 
     494  { 
     495    CContext* context = CContext::getCurrent(); 
     496    const CDate& currentDate = context->getCalendar()->getCurrentDate(); 
     497 
     498    // Check if data previously requested has been received as expected 
     499    if (wasDataRequestedFromServer && (!isEOF || currentDate <= dateEOF)) 
     500    { 
     501      CTimer timer("CField::checkForLateDataFromServer"); 
     502 
     503      bool isDataLate; 
     504      do 
     505      { 
     506        const CDate nextDataDue = wasDataAlreadyReceivedFromServer ? (lastDataReceivedFromServer + file->output_freq) : context->getCalendar()->getInitDate(); 
     507        isDataLate = nextDataDue < currentDate; 
     508 
     509        if (isDataLate) 
     510        { 
     511          timer.resume(); 
     512 
     513          context->checkBuffersAndListen(); 
     514 
     515          timer.suspend(); 
     516        } 
     517      } 
     518      while (isDataLate && timer.getCumulatedTime() < CXios::recvFieldTimeout); 
     519 
     520      if (isDataLate) 
     521        ERROR("void CField::checkForLateDataFromServer(void)", 
     522              << "Late data at timestep = " << currentDate); 
     523    } 
    464524  } 
    465525 
     
    694754     CContext* context = CContext::getCurrent(); 
    695755     solveOnlyReferenceEnabledField(doSending2Server); 
    696      int myRank; 
    697      MPI_Comm_rank(context->client->intraComm, &myRank); 
     756 
     757     //std::cout<<"Field "<<this->getId()<<" areAllReferenceSolved = "<<areAllReferenceSolved<<std::endl;  
    698758 
    699759     if (!areAllReferenceSolved) 
    700760     { 
    701761        areAllReferenceSolved = true; 
    702  
     762        //std::cout<<"Field "<<this->getId()<<" all reference solved"<<std::endl;  
    703763        if (context->hasClient) 
    704764        { 
     
    825885       // Check if the data is to be read from a file 
    826886       else if (file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read) 
    827          instantDataFilter = serverSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, 
    828                                                                                                      freq_offset.isEmpty() ? NoneDu : freq_offset, 
    829                                                                                                      true, 
     887       { 
     888         checkAttributes(); 
     889         instantDataFilter = serverSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, freq_offset, true, 
    830890                                                                                                     detectMissingValues, defaultValue)); 
     891       } 
    831892       else // The data might be passed from the model 
    832893       { 
     
    910971       { 
    911972         if (!serverSourceFilter) 
    912            serverSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, 
    913                                                                                    freq_offset.isEmpty() ? NoneDu : freq_offset, 
    914                                                                                    true, 
     973         { 
     974           checkAttributes(); 
     975           serverSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, freq_offset, true, 
    915976                                                                                   detectMissingValues, defaultValue)); 
     977         } 
    916978 
    917979         selfReferenceFilter = serverSourceFilter; 
     
    9581020               << "An operation must be defined for field \"" << getId() << "\"."); 
    9591021 
    960        if (freq_op.isEmpty()) 
    961          freq_op.setValue(TimeStep); 
    962        if (freq_offset.isEmpty()) 
    963          freq_offset.setValue(NoneDu); 
     1022       checkAttributes(); 
    9641023 
    9651024       const bool detectMissingValues = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true); 
    966         
    9671025       boost::shared_ptr<CTemporalFilter> temporalFilter(new CTemporalFilter(gc, operation, 
    9681026                                                                             CContext::getCurrent()->getCalendar()->getInitDate(), 
     
    10001058               << "An operation must be defined for field \"" << getId() << "\"."); 
    10011059 
    1002        if (freq_op.isEmpty()) freq_op.setValue(TimeStep); 
    1003        if (freq_offset.isEmpty()) freq_offset.setValue(NoneDu); 
     1060       checkAttributes(); 
    10041061 
    10051062       const bool detectMissingValues = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true); 
    1006  
    10071063       boost::shared_ptr<CTemporalFilter> temporalFilter(new CTemporalFilter(gc, operation, 
    10081064                                                                             CContext::getCurrent()->getCalendar()->getInitDate(), 
     
    14501506 
    14511507   /*! 
     1508    * Check on freq_off and freq_op attributes. 
     1509    */ 
     1510   void CField::checkAttributes(void) 
     1511   { 
     1512     bool isFieldRead = file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read; 
     1513     if (isFieldRead && operation.getValue() != "instant") 
     1514       ERROR("void CField::checkAttributes(void)", 
     1515             << "Unsupported operation for field '" << getFieldOutputName() << "'." << std::endl 
     1516             << "Currently only \"instant\" is supported for fields read from file.") 
     1517 
     1518     if (freq_op.isEmpty()) 
     1519     { 
     1520       if (operation.getValue() == "instant") 
     1521         freq_op.setValue(file->output_freq.getValue()); 
     1522       else 
     1523         freq_op.setValue(TimeStep); 
     1524     } 
     1525     if (freq_offset.isEmpty()) 
     1526       freq_offset.setValue(isFieldRead ? NoneDu : (freq_op.getValue() - TimeStep)); 
     1527   } 
     1528 
     1529   /*! 
    14521530    * Returns string arithmetic expression associated to the field. 
    14531531    * \return if content is defined return content string, otherwise, if "expr" attribute is defined, return expr string. 
  • XIOS/dev/branch_openmp/src/node/field.hpp

    r1119 r1328  
    150150        static void recvReadDataReady(CEventServer& event); 
    151151        void recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers); 
     152        void checkForLateDataFromServer(void); 
    152153        void outputField(CArray<double,3>& fieldOut); 
    153154        void outputField(CArray<double,2>& fieldOut); 
     
    176177        void sendAddAllVariables(); 
    177178 
     179        /// Vérifications /// 
     180        void checkAttributes(void); 
    178181 
    179182        const std::vector<StdString>& getRefDomainAxisIds(); 
     
    181184        const string& getExpression(void); 
    182185        bool hasExpression(void) const; 
     186 
     187        CField* my_getDirectFieldReference(void) const; 
     188 
     189 
    183190 
    184191      public: 
     
    195202         bool isEOF; 
    196203         CDate lastlast_Write_srv, last_Write_srv, last_operation_srv; 
    197          CDate lastDataRequestedFromServer, lastDataReceivedFromServer; 
    198          bool wasDataAlreadyReceivedFromServer; 
     204         CDate lastDataRequestedFromServer, lastDataReceivedFromServer, dateEOF; 
     205         bool wasDataRequestedFromServer, wasDataAlreadyReceivedFromServer; 
    199206 
    200207         map<int,boost::shared_ptr<func::CFunctor> > foperation_srv; 
  • XIOS/dev/branch_openmp/src/node/file.cpp

    r1287 r1328  
    1818#include "timer.hpp" 
    1919 
     20 
    2021namespace xios { 
    2122 
     
    2425   CFile::CFile(void) 
    2526      : CObjectTemplate<CFile>(), CFileAttributes() 
    26       , vFieldGroup(), data_out(), enabledFields(), fileComm(MPI_COMM_NULL) 
     27      , vFieldGroup(), data_out(), enabledFields() 
    2728      , allDomainEmpty(false), isOpen(false) 
    2829   { 
     
    3334   CFile::CFile(const StdString & id) 
    3435      : CObjectTemplate<CFile>(id), CFileAttributes() 
    35       , vFieldGroup(), data_out(), enabledFields(), fileComm(MPI_COMM_NULL) 
     36      , vFieldGroup(), data_out(), enabledFields() 
    3637      , allDomainEmpty(false), isOpen(false) 
    3738    { 
     
    263264      // create sub communicator for file 
    264265      int color = allDomainEmpty ? 0 : 1; 
    265       MPI_Comm_split(server->intraComm, color, server->intraCommRank, &fileComm); 
    266       if (allDomainEmpty) MPI_Comm_free(&fileComm); 
     266      ep_lib::MPI_Comm_split(server->intraComm, color, server->intraCommRank, &fileComm); 
     267      if (allDomainEmpty) ep_lib::MPI_Comm_free(&fileComm); 
    267268 
    268269      // if (time_counter.isEmpty()) time_counter.setValue(time_counter_attr::centered); 
     
    461462         { 
    462463            int commSize, commRank; 
    463             MPI_Comm_size(fileComm, &commSize); 
    464             MPI_Comm_rank(fileComm, &commRank); 
     464            ep_lib::MPI_Comm_size(fileComm, &commSize); 
     465            ep_lib::MPI_Comm_rank(fileComm, &commRank); 
    465466 
    466467            if (server->intraCommSize > 1) 
     
    482483         if (isOpen) data_out->closeFile(); 
    483484 
    484         data_out = boost::shared_ptr<CDataOutput>(new CNc4DataOutput(this, oss.str(), append, useClassicFormat, useCFConvention, 
    485                                                               static_cast< ::MPI_Comm >(fileComm.mpi_comm), multifile, isCollective, time_counter_name)); 
     485        data_out = shared_ptr<CDataOutput>(new CNc4DataOutput(this, oss.str(), append, useClassicFormat, useCFConvention, 
     486                                                              fileComm, multifile, isCollective, time_counter_name)); 
    486487        isOpen = true; 
    487488 
     
    577578      { 
    578579        int commSize, commRank; 
    579         MPI_Comm_size(fileComm, &commSize); 
    580         MPI_Comm_rank(fileComm, &commRank); 
     580        ep_lib::MPI_Comm_size(fileComm, &commSize); 
     581        ep_lib::MPI_Comm_rank(fileComm, &commRank); 
    581582 
    582583        if (server->intraCommSize > 1) 
     
    596597      bool isCollective = par_access.isEmpty() || par_access == par_access_attr::collective; 
    597598 
    598       #ifdef _usingEP 
    599       //printf("multifile was %d\n", multifile); 
    600       multifile = true; 
    601599      if (isOpen) data_out->closeFile(); 
    602       if (time_counter_name.isEmpty()) data_in = boost::shared_ptr<CDataInput>(new CNc4DataInput(oss.str(), static_cast< ::MPI_Comm >(fileComm.mpi_comm), multifile, isCollective)); 
    603       else data_in = boost::shared_ptr<CDataInput>(new CNc4DataInput(oss.str(), static_cast< ::MPI_Comm >(fileComm.mpi_comm), multifile, isCollective, time_counter_name)); 
     600      if (time_counter_name.isEmpty()) data_in = shared_ptr<CDataInput>(new CNc4DataInput(oss.str(), fileComm, multifile, isCollective)); 
     601      else data_in = shared_ptr<CDataInput>(new CNc4DataInput(oss.str(), fileComm, multifile, isCollective, time_counter_name)); 
    604602      isOpen = true; 
    605       #else 
    606       if (isOpen) data_out->closeFile(); 
    607       if (time_counter_name.isEmpty()) data_in = boost::shared_ptr<CDataInput>(new CNc4DataInput(oss.str(), static_cast< ::MPI_Comm >(fileComm.mpi_comm), multifile, isCollective)); 
    608       else data_in = boost::shared_ptr<CDataInput>(new CNc4DataInput(oss.str(), static_cast< ::MPI_Comm >(fileComm.mpi_comm), multifile, isCollective, time_counter_name)); 
    609       isOpen = true; 
    610       #endif 
    611  
    612        
    613603    } 
    614604  } 
     
    625615          this->data_in->closeFile(); 
    626616       } 
    627       if (fileComm != MPI_COMM_NULL) MPI_Comm_free(&fileComm); 
     617//      if (fileComm != MPI_COMM_NULL) MPI_Comm_free(&fileComm); 
     618      //if (fileComm.mpi_comm != ::MPI_COMM_NULL) MPI_Comm_free(&fileComm); 
    628619   } 
    629620   //---------------------------------------------------------------- 
     
    638629 
    639630     // It would probably be better to call initFile() somehow 
    640       
    641      MPI_Comm_dup(client->intraComm, &fileComm); 
     631     ep_lib::MPI_Comm_dup(client->intraComm, &fileComm); 
    642632     if (time_counter_name.isEmpty()) time_counter_name = "time_counter"; 
    643633 
    644      //#pragma omp critical (_readAttributesOfEnabledFieldsInReadMode_) 
    645      //{ 
    646      checkFile(); // calls nc_open 
     634     checkFile(); 
    647635 
    648636     for (int idx = 0; idx < enabledFields.size(); ++idx) 
     
    658646 
    659647        // Read necessary value from file 
    660         #pragma omp critical (_func) 
    661         { 
    662           //checkFile(); 
    663           this->data_in->readFieldAttributesValues(enabledFields[idx]); 
    664           //close(); 
    665         } 
    666          
     648        this->data_in->readFieldAttributesValues(enabledFields[idx]); 
     649 
    667650        // Fill attributes for base reference 
    668651        enabledFields[idx]->solveGridDomainAxisBaseRef(); 
     
    671654     // Now everything is ok, close it 
    672655     close(); 
    673      //} 
    674       
    675      //if (fileComm != MPI_COMM_NULL) MPI_Comm_free(&fileComm); 
    676       
    677656   } 
    678657 
     
    806785 
    807786   /*! 
    808      Prefetching the data for enabled fields read from file whose data is out-of-date. 
    809    */ 
    810    void CFile::prefetchEnabledReadModeFieldsIfNeeded(void) 
     787     Do all post timestep operations for enabled fields in read mode: 
     788      - Prefetch the data read from file when needed 
     789      - Check that the data excepted from server has been received 
     790   */ 
     791   void CFile::doPostTimestepOperationsForEnabledReadModeFields(void) 
    811792   { 
    812793     if (mode.isEmpty() || mode.getValue() != mode_attr::read) 
     
    815796     int size = this->enabledFields.size(); 
    816797     for (int i = 0; i < size; ++i) 
     798     { 
     799       this->enabledFields[i]->checkForLateDataFromServer(); 
    817800       this->enabledFields[i]->sendReadDataRequestIfNeeded(); 
     801     } 
    818802   } 
    819803 
     
    11211105       CField* field = this->enabledFields[i]; 
    11221106       this->sendAddField(field->getId()); 
     1107       field->checkAttributes(); 
    11231108       field->sendAllAttributesToServer(); 
    11241109       field->sendAddAllVariables(); 
  • XIOS/dev/branch_openmp/src/node/file.hpp

    r1134 r1328  
    44/// XIOS headers /// 
    55#include "xios_spl.hpp" 
     6#include "mpi_std.hpp" 
    67#include "field.hpp" 
    78#include "data_output.hpp" 
     
    1112#include "attribute_enum.hpp" 
    1213#include "attribute_enum_impl.hpp" 
    13 #include "mpi.hpp" 
    14 #ifdef _usingEP 
    15 #include "ep_declaration.hpp" 
    16 #endif 
    1714 
    1815namespace xios { 
     
    110107         void buildFilterGraphOfEnabledFields(CGarbageCollector& gc); 
    111108         void prefetchEnabledReadModeFields(); 
    112          void prefetchEnabledReadModeFieldsIfNeeded(); 
     109         void doPostTimestepOperationsForEnabledReadModeFields(); 
    113110 
    114111         // Add component into file 
  • XIOS/dev/branch_openmp/src/node/generate_rectilinear_domain.hpp

    r1134 r1328  
    6060      static CTransformation<CDomain>* create(const StdString& id, xml::CXMLNode* node); 
    6161      static bool _dummyRegistered; 
    62       #pragma omp threadprivate(_dummyRegistered) 
    6362  }; // class CGenerateRectilinearDomain 
    6463 
  • XIOS/dev/branch_openmp/src/node/grid.cpp

    r1205 r1328  
    11141114          outLocalIndexToServer(idx) = itIndex->second; 
    11151115        } 
    1116  
     1116         
    11171117        const std::list<int>& ranks = client->getRanksServerLeader(); 
    11181118        for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     
    17501750        pDom->solveRefInheritance(apply); 
    17511751        pDom->solveInheritanceTransformation(); 
     1752        //cout<<"pDom check"<<endl; 
    17521753      } 
    17531754    } 
  • XIOS/dev/branch_openmp/src/node/interpolate_axis.hpp

    r1134 r1328  
    6262      static CTransformation<CAxis>* create(const StdString& id, xml::CXMLNode* node); 
    6363      static bool _dummyRegistered; 
    64       #pragma omp threadprivate(_dummyRegistered) 
    65        
    6664  }; // class CInterpolateAxis 
    6765 
  • XIOS/dev/branch_openmp/src/node/interpolate_domain.hpp

    r1134 r1328  
    6060      static CTransformation<CDomain>* create(const StdString& id, xml::CXMLNode* node); 
    6161      static bool _dummyRegistered; 
    62       #pragma omp threadprivate(_dummyRegistered) 
    6362  }; // class CInterpolateDomain 
    6463 
  • XIOS/dev/branch_openmp/src/node/inverse_axis.hpp

    r1134 r1328  
    5959      static CTransformation<CAxis>* create(const StdString& id, xml::CXMLNode* node); 
    6060      static bool _dummyRegistered; 
    61       #pragma omp threadprivate(_dummyRegistered) 
    6261 
    6362  }; // class CInverseAxis 
  • XIOS/dev/branch_openmp/src/node/mesh.cpp

    r1134 r1328  
    66 
    77#include "mesh.hpp" 
     8using namespace ep_lib; 
    89 
    910namespace xios { 
     
    3132  } 
    3233 
    33   std::map <StdString, CMesh> CMesh::meshList = std::map <StdString, CMesh>(); 
    34   std::map <StdString, vector<int> > CMesh::domainList = std::map <StdString, vector<int> >(); 
     34  //std::map <StdString, CMesh> CMesh::meshList = std::map <StdString, CMesh>(); 
     35  //std::map <StdString, vector<int> > CMesh::domainList = std::map <StdString, vector<int> >(); 
    3536 
    3637  std::map <StdString, CMesh> *CMesh::meshList_ptr = 0; 
    3738  std::map <StdString, vector<int> > *CMesh::domainList_ptr = 0; 
    38  
    3939 
    4040///--------------------------------------------------------------- 
     
    4545 * \param [in] nvertex Number of verteces (1 for nodes, 2 for edges, 3 and up for faces). 
    4646 */ 
    47  
    48 /* bkp 
    49   CMesh* CMesh::getMesh (StdString meshName, int nvertex) 
    50   { 
    51     CMesh::domainList[meshName].push_back(nvertex); 
    52  
    53     if ( CMesh::meshList.begin() != CMesh::meshList.end() ) 
    54     { 
    55       for (std::map<StdString, CMesh>::iterator it=CMesh::meshList.begin(); it!=CMesh::meshList.end(); ++it) 
    56       { 
    57         if (it->first == meshName) 
    58           return &meshList[meshName]; 
    59         else 
    60         { 
    61           CMesh newMesh; 
    62           CMesh::meshList.insert( make_pair(meshName, newMesh) ); 
    63           return &meshList[meshName]; 
    64         } 
    65       } 
    66     } 
    67     else 
    68     { 
    69       CMesh newMesh; 
    70       CMesh::meshList.insert( make_pair(meshName, newMesh) ); 
    71       return &meshList[meshName]; 
    72     } 
    73   } 
    74 */ 
    75  
    7647  CMesh* CMesh::getMesh (StdString meshName, int nvertex) 
    7748  { 
     
    7950    if(CMesh::meshList_ptr == NULL)   CMesh::meshList_ptr   = new std::map <StdString, CMesh>(); 
    8051 
    81     (*CMesh::domainList_ptr)[meshName].push_back(nvertex); 
    82  
    83     if ( (*CMesh::meshList_ptr).begin() != (*CMesh::meshList_ptr).end() ) 
    84     { 
    85       for (std::map<StdString, CMesh>::iterator it=(*CMesh::meshList_ptr).begin(); it!=(*CMesh::meshList_ptr).end(); ++it) 
     52    //CMesh::domainList[meshName].push_back(nvertex); 
     53    CMesh::domainList_ptr->at(meshName).push_back(nvertex); 
     54 
     55    //if ( CMesh::meshList.begin() != CMesh::meshList.end() ) 
     56    if ( CMesh::meshList_ptr->begin() != CMesh::meshList_ptr->end() ) 
     57    { 
     58      //for (std::map<StdString, CMesh>::iterator it=CMesh::meshList.begin(); it!=CMesh::meshList.end(); ++it) 
     59      for (std::map<StdString, CMesh>::iterator it=CMesh::meshList_ptr->begin(); it!=CMesh::meshList_ptr->end(); ++it) 
    8660      { 
    8761        if (it->first == meshName) 
    88           return &((*CMesh::meshList_ptr)[meshName]); 
     62          //return &meshList[meshName]; 
     63          return &meshList_ptr->at(meshName); 
    8964        else 
    9065        { 
    9166          CMesh newMesh; 
    92           (*CMesh::meshList_ptr).insert( make_pair(meshName, newMesh) ); 
    93           return &((*CMesh::meshList_ptr)[meshName]); 
     67          //CMesh::meshList.insert( make_pair(meshName, newMesh) ); 
     68          CMesh::meshList_ptr->insert( make_pair(meshName, newMesh) ); 
     69          //return &meshList[meshName]; 
     70          return &meshList_ptr->at(meshName); 
    9471        } 
    9572      } 
     
    9875    { 
    9976      CMesh newMesh; 
    100       (*CMesh::meshList_ptr).insert( make_pair(meshName, newMesh) ); 
    101       return &((*CMesh::meshList_ptr)[meshName]); 
     77      //CMesh::meshList.insert( make_pair(meshName, newMesh) ); 
     78      CMesh::meshList_ptr->insert( make_pair(meshName, newMesh) ); 
     79      //return &meshList[meshName]; 
     80      return &meshList_ptr->at(meshName); 
    10281    } 
    10382  } 
     
    524503 * \param [in] bounds_lat Array of boundary latitudes. Its size depends on the element type. 
    525504 */ 
    526   void CMesh::createMeshEpsilon(const ep_lib::MPI_Comm& comm, 
     505  void CMesh::createMeshEpsilon(const MPI_Comm& comm, 
    527506                                const CArray<double, 1>& lonvalue, const CArray<double, 1>& latvalue, 
    528507                                const CArray<double, 2>& bounds_lon, const CArray<double, 2>& bounds_lat) 
     
    17241703   */ 
    17251704 
    1726   void CMesh::getGloNghbFacesNodeType(const ep_lib::MPI_Comm& comm, const CArray<int, 1>& face_idx, 
     1705  void CMesh::getGloNghbFacesNodeType(const MPI_Comm& comm, const CArray<int, 1>& face_idx, 
    17271706                               const CArray<double, 2>& bounds_lon, const CArray<double, 2>& bounds_lat, 
    17281707                               CArray<int, 2>& nghbFaces) 
     
    18801859   */ 
    18811860 
    1882   void CMesh::getGloNghbFacesEdgeType(const ep_lib::MPI_Comm& comm, const CArray<int, 1>& face_idx, 
     1861  void CMesh::getGloNghbFacesEdgeType(const MPI_Comm& comm, const CArray<int, 1>& face_idx, 
    18831862                               const CArray<double, 2>& bounds_lon, const CArray<double, 2>& bounds_lat, 
    18841863                               CArray<int, 2>& nghbFaces) 
     
    20612040   */ 
    20622041 
    2063   void CMesh::getGlobalNghbFaces(const int nghbType, const ep_lib::MPI_Comm& comm, 
     2042  void CMesh::getGlobalNghbFaces(const int nghbType, const MPI_Comm& comm, 
    20642043                                 const CArray<int, 1>& face_idx, 
    20652044                                 const CArray<double, 2>& bounds_lon, const CArray<double, 2>& bounds_lat, 
  • XIOS/dev/branch_openmp/src/node/mesh.hpp

    r1134 r1328  
    8080      int nbFaces_; 
    8181 
    82       static std::map <StdString, CMesh> meshList; 
    83       static std::map <StdString, vector<int> > domainList; 
    84  
     82      //static std::map <StdString, CMesh> meshList; 
    8583      static std::map <StdString, CMesh> *meshList_ptr; 
     84      //static std::map <StdString, vector<int> > domainList; 
    8685      static std::map <StdString, vector<int> > *domainList_ptr; 
    87       #pragma omp threadprivate(meshList_ptr, domainList_ptr) 
    88     
    8986      CClientClientDHTSizet* pNodeGlobalIndex;                    // pointer to a map <nodeHash, nodeIdxGlo> 
    9087      CClientClientDHTSizet* pEdgeGlobalIndex;                    // pointer to a map <edgeHash, edgeIdxGlo> 
  • XIOS/dev/branch_openmp/src/node/reduce_axis_to_scalar.hpp

    r1134 r1328  
    5959      static CTransformation<CScalar>* create(const StdString& id, xml::CXMLNode* node); 
    6060      static bool _dummyRegistered; 
    61       #pragma omp threadprivate(_dummyRegistered) 
    6261  }; // class CReduceAxisToScalar 
    6362 
  • XIOS/dev/branch_openmp/src/node/reduce_domain_to_axis.hpp

    r1134 r1328  
    6060      static CTransformation<CAxis>* create(const StdString& id, xml::CXMLNode* node); 
    6161      static bool _dummyRegistered; 
    62       #pragma omp threadprivate(_dummyRegistered) 
    6362  }; // class CReduceDomainToAxis 
    6463 
  • XIOS/dev/branch_openmp/src/node/reduce_domain_to_scalar.hpp

    r1134 r1328  
    6060      static CTransformation<CScalar>* create(const StdString& id, xml::CXMLNode* node); 
    6161      static bool _dummyRegistered; 
    62       #pragma omp threadprivate(_dummyRegistered) 
    6362  }; // class CReduceDomainToScalar 
    6463 
  • XIOS/dev/branch_openmp/src/node/scalar.cpp

    r1134 r1328  
    2828 
    2929   //std::map<StdString, ETranformationType> CScalar::transformationMapList_ = std::map<StdString, ETranformationType>(); 
     30   std::map<StdString, ETranformationType> *CScalar::transformationMapList_ptr = 0; 
    3031   //bool CScalar::dummyTransformationMapList_ = CScalar::initializeTransformationMap(CScalar::transformationMapList_); 
    31  
    32    std::map<StdString, ETranformationType> *CScalar::transformationMapList_ptr = 0; 
    33     
    3432   bool CScalar::initializeTransformationMap(std::map<StdString, ETranformationType>& m) 
    3533   { 
     
    175173 
    176174        nodeElementName = node.getElementName(); 
     175        //std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_.end(), it; 
    177176        if(CScalar::transformationMapList_ptr == 0) initializeTransformationMap(); 
    178         std::map<StdString, ETranformationType>::const_iterator ite = (*CScalar::transformationMapList_ptr).end(), it; 
    179         it = (*CScalar::transformationMapList_ptr).find(nodeElementName); 
     177        std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_ptr->end(), it; 
     178        //it = transformationMapList_.find(nodeElementName); 
     179        it = transformationMapList_ptr->find(nodeElementName); 
    180180        if (ite != it) 
    181181        { 
  • XIOS/dev/branch_openmp/src/node/scalar.hpp

    r1134 r1328  
    8888           static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); 
    8989           static bool initializeTransformationMap(); 
    90             
    91            //static bool dummyTransformationMapList_; 
    92  
     90           //static std::map<StdString, ETranformationType> transformationMapList_; 
    9391           static std::map<StdString, ETranformationType> *transformationMapList_ptr; 
    94            #pragma omp threadprivate(transformationMapList_ptr) 
     92           static bool dummyTransformationMapList_; 
    9593 
    9694 
  • XIOS/dev/branch_openmp/src/node/transformation.hpp

    r1138 r1328  
    3535      typedef std::map<ETranformationType, CreateTransformationCallBack> CallBackMap; 
    3636      static CallBackMap* transformationCreationCallBacks_; 
    37       //#pragma omp threadprivate(transformationCreationCallBacks_) 
    3837 
    3938      static bool registerTransformation(ETranformationType transType, CreateTransformationCallBack createFn); 
     
    6665    if (0 == transformationCreationCallBacks_) 
    6766      transformationCreationCallBacks_ = new CallBackMap(); 
     67 
    6868    return (*transformationCreationCallBacks_).insert(make_pair(transType, createFn)).second; 
    6969  } 
  • XIOS/dev/branch_openmp/src/node/zoom_axis.hpp

    r1134 r1328  
    6060      static CTransformation<CAxis>* create(const StdString& id, xml::CXMLNode* node); 
    6161      static bool _dummyRegistered; 
    62       #pragma omp threadprivate(_dummyRegistered) 
    6362  }; // class CZoomAxis 
    6463 
  • XIOS/dev/branch_openmp/src/node/zoom_domain.hpp

    r1134 r1328  
    6060      static CTransformation<CDomain>* create(const StdString& id, xml::CXMLNode* node); 
    6161      static bool _dummyRegistered; 
    62       #pragma omp threadprivate(_dummyRegistered) 
    63        
    6462  }; // class CZoomDomain 
    6563 
  • XIOS/dev/branch_openmp/src/object_factory.cpp

    r1134 r1328  
    55   /// ////////////////////// Définitions ////////////////////// /// 
    66 
    7    StdString *CObjectFactory::CurrContext_ptr = new StdString; 
     7   StdString CObjectFactory::CurrContext(""); 
    88 
    99   void CObjectFactory::SetCurrentContextId(const StdString & context) 
    10    { 
    11      if(CObjectFactory::CurrContext_ptr == NULL ) CObjectFactory::CurrContext_ptr = new StdString; 
    12      CObjectFactory::CurrContext_ptr->assign(context);  
    13    } 
     10   { CObjectFactory::CurrContext = context; } 
    1411 
    1512   StdString & CObjectFactory::GetCurrentContextId(void) 
    16    {  
    17      return (*CObjectFactory::CurrContext_ptr);  
    18    } 
     13   { return (CObjectFactory::CurrContext); } 
    1914 
    2015} // namespace xios 
  • XIOS/dev/branch_openmp/src/object_factory.hpp

    r1134 r1328  
    5959 
    6060         /// Propriétés statiques /// 
    61          static StdString *CurrContext_ptr; 
    62          #pragma omp threadprivate(CurrContext_ptr) 
     61         static StdString CurrContext; 
    6362 
    6463   }; // class CObjectFactory 
  • XIOS/dev/branch_openmp/src/object_factory_decl.cpp

    r1287 r1328  
    55{ 
    66#define macro(U) \ 
    7   template boost::shared_ptr<U> CObjectFactory::GetObject<U>(const StdString& id);  \ 
    8   template boost::shared_ptr<U> CObjectFactory::GetObject<U>(const StdString& context,const StdString& id); \ 
    9   template boost::shared_ptr<U> CObjectFactory::GetObject<U>(const U* const object); \ 
     7  template shared_ptr<U> CObjectFactory::GetObject<U>(const StdString& id);  \ 
     8  template shared_ptr<U> CObjectFactory::GetObject<U>(const StdString& context,const StdString& id); \ 
     9  template shared_ptr<U> CObjectFactory::GetObject<U>(const U* const object); \ 
    1010  template int CObjectFactory::GetObjectNum<U>(void); \ 
    1111  template int CObjectFactory::GetObjectIdNum<U>(void); \ 
    12   template const std::vector<boost::shared_ptr<U> >& CObjectFactory::GetObjectVector<U>(const StdString& context ); \ 
     12  template const std::vector<shared_ptr<U> >& CObjectFactory::GetObjectVector<U>(const StdString& context ); \ 
    1313  template bool CObjectFactory::HasObject<U>(const StdString& id); \ 
    1414  template bool CObjectFactory::HasObject<U>(const StdString& context,const StdString& id); \ 
  • XIOS/dev/branch_openmp/src/object_factory_impl.hpp

    r1134 r1328  
    66namespace xios 
    77{ 
    8    /// ////////////////////// Définitions ////////////////////// /// 
     8   /// ////////////////////// Dfinitions ////////////////////// /// 
    99   template <typename U> 
    1010       int CObjectFactory::GetObjectNum(void) 
    1111   { 
    12       if (CurrContext_ptr->size() == 0) 
     12      if (CurrContext.size() == 0) 
    1313         ERROR("CObjectFactory::GetObjectNum(void)", 
    1414               << "please define current context id !"); 
    15  
    16       if(U::AllVectObj == NULL) return 0; 
    17        
    18        
    19       return (*U::AllVectObj)[*CObjectFactory::CurrContext_ptr].size(); 
     15      //return (U::AllVectObj[CObjectFactory::CurrContext].size()); 
     16      if(U::AllVectObj_ptr == NULL) return 0; 
     17      return (*U::AllVectObj_ptr)[CObjectFactory::CurrContext].size(); 
    2018   } 
    2119 
     
    2321      int CObjectFactory::GetObjectIdNum(void) 
    2422   { 
    25       if (CurrContext_ptr->size() == 0) 
     23      if (CurrContext.size() == 0) 
    2624         ERROR("CObjectFactory::GetObjectIdNum(void)", 
    2725               << "please define current context id !"); 
    28       if(U::AllMapObj  == NULL) return 0; 
    29  
    30        
    31  
    32       return (* U::AllMapObj) [*CObjectFactory::CurrContext_ptr].size(); 
     26      //return (U::AllMapObj[CObjectFactory::CurrContext].size()); 
     27      if(U::AllMapObj_ptr == NULL) return 0; 
     28      return (*U::AllMapObj_ptr)[CObjectFactory::CurrContext].size(); 
    3329   } 
    3430 
     
    3632      bool CObjectFactory::HasObject(const StdString & id) 
    3733   { 
    38       if (CurrContext_ptr->size() == 0) 
     34      if (CurrContext.size() == 0) 
    3935         ERROR("CObjectFactory::HasObject(const StdString & id)", 
    4036               << "[ id = " << id << " ] please define current context id !"); 
    41        
    42       if(U::AllMapObj  == NULL)  return false; 
     37      //return (U::AllMapObj[CObjectFactory::CurrContext].find(id) != 
     38      //        U::AllMapObj[CObjectFactory::CurrContext].end()); 
     39      if(U::AllMapObj_ptr  == NULL)  return false; 
     40      return ((*U::AllMapObj_ptr)[CObjectFactory::CurrContext].find(id) != 
     41              (*U::AllMapObj_ptr)[CObjectFactory::CurrContext].end()); 
    4342 
    44        
    45  
    46       return ((*U::AllMapObj)[*CObjectFactory::CurrContext_ptr].find(id) != 
    47               (*U::AllMapObj)[*CObjectFactory::CurrContext_ptr].end()); 
    4843   } 
    4944 
     
    5146      bool CObjectFactory::HasObject(const StdString & context, const StdString & id) 
    5247   { 
    53       if(U::AllMapObj  == NULL) return false; 
    5448 
    55       if (U::AllMapObj->find(context) == U::AllMapObj->end()) return false ; 
     49      // if (U::AllMapObj.find(context) == U::AllMapObj.end()) return false ; 
     50      // else return (U::AllMapObj[context].find(id) !=  U::AllMapObj[context].end()); 
     51      if(U::AllMapObj_ptr  == NULL) return false; 
    5652 
    57       else 
    58       { 
    59          return ((*U::AllMapObj)[context].find(id) !=  (*U::AllMapObj)[context].end()); 
    60       }  
    61           
     53      if (U::AllMapObj_ptr->find(context) == U::AllMapObj_ptr->end()) return false ; 
     54      else return ((*U::AllMapObj_ptr)[context].find(id) !=  (*U::AllMapObj_ptr)[context].end()); 
    6255   } 
    6356 
     
    6558      boost::shared_ptr<U> CObjectFactory::GetObject(const U * const object) 
    6659   { 
    67       if(U::AllVectObj == NULL) return (boost::shared_ptr<U>()); 
    68     
    69       if (CurrContext_ptr->size() == 0) 
     60      if(U::AllVectObj_ptr == NULL) return (boost::shared_ptr<U>()); 
     61      if (CurrContext.size() == 0) 
    7062         ERROR("CObjectFactory::GetObject(const U * const object)", 
    7163               << "please define current context id !"); 
    72       std::vector<boost::shared_ptr<U> > & vect = 
    73                      (*U::AllVectObj)[*CObjectFactory::CurrContext_ptr]; 
     64      //std::vector<boost::shared_ptr<U> > & vect = U::AllVectObj[CObjectFactory::CurrContext]; 
     65      std::vector<boost::shared_ptr<U> > & vect = (*U::AllVectObj_ptr)[CObjectFactory::CurrContext]; 
    7466 
    7567      typename std::vector<boost::shared_ptr<U> >::const_iterator 
     
    9284      boost::shared_ptr<U> CObjectFactory::GetObject(const StdString & id) 
    9385   { 
    94       if(U::AllMapObj  == NULL) return (boost::shared_ptr<U>()); 
    95  
    96       if (CurrContext_ptr->size() == 0) 
     86      if(U::AllMapObj_ptr  == NULL) return (boost::shared_ptr<U>()); 
     87      if (CurrContext.size() == 0) 
    9788         ERROR("CObjectFactory::GetObject(const StdString & id)", 
    9889               << "[ id = " << id << " ] please define current context id !"); 
     
    10192               << "[ id = " << id << ", U = " << U::GetName() << " ] " 
    10293               << "object was not found."); 
    103       return (*U::AllMapObj)[*CObjectFactory::CurrContext_ptr][id]; 
     94 
     95      //cout<<"CObjectFactory::GetObject(const StdString & id)[ id = " << id << ", U = " << U::GetName() << " ] "<<endl; 
     96      if(id == "src_domain_regular_read") 
     97      { 
     98         //cout<<"match"<<endl; 
     99      } 
     100 
     101      //return (U::AllMapObj[CObjectFactory::CurrContext][id]); 
     102      return (*U::AllMapObj_ptr)[CObjectFactory::CurrContext][id]; 
    104103   } 
    105104 
     
    107106      boost::shared_ptr<U> CObjectFactory::GetObject(const StdString & context, const StdString & id) 
    108107   { 
    109       if(U::AllMapObj  == NULL) return (boost::shared_ptr<U>()); 
     108      if(U::AllMapObj_ptr  == NULL) return (boost::shared_ptr<U>()); 
    110109 
    111110      if (!CObjectFactory::HasObject<U>(context,id)) 
     
    114113               << "object was not found."); 
    115114 
    116       return (*U::AllMapObj)[context][id]; 
     115      //cout<<"CObjectFactory::GetObject(const StdString & context, const StdString & id)[ id = " << id << ", U = " << U::GetName() << " ] "<<endl; 
     116      if(id == "src_domain_regular_read") 
     117      { 
     118         //cout<<"match"<<endl; 
     119         boost::shared_ptr<U> value; 
     120      } 
     121      //return (U::AllMapObj[context][id]); 
     122      return (*U::AllMapObj_ptr)[context][id]; 
    117123   } 
    118124 
     
    120126   boost::shared_ptr<U> CObjectFactory::CreateObject(const StdString& id) 
    121127   { 
    122       if(U::AllVectObj == NULL) U::AllVectObj = new xios_map<StdString, std::vector<boost::shared_ptr<U> > >; 
    123       if(U::AllMapObj  == NULL) U::AllMapObj  = new xios_map<StdString, xios_map<StdString, boost::shared_ptr<U> > >; 
     128      if(U::AllVectObj_ptr == NULL) U::AllVectObj_ptr = new xios_map<StdString, std::vector<boost::shared_ptr<U> > >; 
     129      if(U::AllMapObj_ptr  == NULL) U::AllMapObj_ptr  = new xios_map<StdString, xios_map<StdString, boost::shared_ptr<U> > >; 
    124130 
    125        
    126       if (CurrContext_ptr->empty()) 
     131      if (CurrContext.empty()) 
    127132         ERROR("CObjectFactory::CreateObject(const StdString& id)", 
    128133               << "[ id = " << id << " ] please define current context id !"); 
     
    136141         boost::shared_ptr<U> value(new U(id.empty() ? CObjectFactory::GenUId<U>() : id)); 
    137142 
    138          (* U::AllVectObj)[*CObjectFactory::CurrContext_ptr].insert((*U::AllVectObj)[*CObjectFactory::CurrContext_ptr].end(), value); 
    139          (* U::AllMapObj) [*CObjectFactory::CurrContext_ptr].insert(std::make_pair(value->getId(), value)); 
     143         //U::AllVectObj[CObjectFactory::CurrContext].insert(U::AllVectObj[CObjectFactory::CurrContext].end(), value); 
     144         //U::AllMapObj[CObjectFactory::CurrContext].insert(std::make_pair(value->getId(), value)); 
     145 
     146         (*U::AllVectObj_ptr)[CObjectFactory::CurrContext].insert((*U::AllVectObj_ptr)[CObjectFactory::CurrContext].end(), value); 
     147         (*U::AllMapObj_ptr) [CObjectFactory::CurrContext].insert(std::make_pair(value->getId(), value)); 
     148         //cout<<"CObjectFactory::CreateObject(const StdString& id) [ id = " << id << " ]" <<endl; 
    140149 
    141150         return value; 
     
    147156         CObjectFactory::GetObjectVector(const StdString & context) 
    148157   { 
    149       if(U::AllVectObj != NULL)  
    150        
    151       return (*U::AllVectObj)[context]; 
     158      //return (U::AllVectObj[context]); 
     159      return (*U::AllVectObj_ptr)[context]; 
    152160   } 
    153161 
     
    163171   { 
    164172      StdOStringStream oss; 
    165       if(U::GenId == NULL) U::GenId = new xios_map< StdString, long int >; 
    166       oss << GetUIdBase<U>() << (*U::GenId)[*CObjectFactory::CurrContext_ptr]++; 
     173      if(U::GenId_ptr == NULL) U::GenId_ptr = new xios_map< StdString, long int >; 
     174      oss << GetUIdBase<U>() << (*U::GenId_ptr)[CObjectFactory::CurrContext]++; 
    167175      return oss.str(); 
    168176   } 
  • XIOS/dev/branch_openmp/src/object_template.hpp

    r1287 r1328  
    7777         static T* get(const string& contextId, const string& id) ; 
    7878         T* get(void) ; 
    79          boost::shared_ptr<T> getShared(void) ; 
    80          static boost::shared_ptr<T> getShared(const T* ptr) ; 
     79         shared_ptr<T> getShared(void) ; 
     80         static shared_ptr<T> getShared(const T* ptr) ; 
    8181 
    8282         static T* create(const string& id=string("")) ; 
     
    100100 
    101101         /// Propriétés statiques /// 
    102          // bkp 
    103          // static xios_map<StdString, 
    104          //        xios_map<StdString, 
    105          //        boost::shared_ptr<DerivedType> > > AllMapObj; 
    106          // static xios_map<StdString, 
    107          //        std::vector<boost::shared_ptr<DerivedType> > > AllVectObj; 
     102         static xios_map<StdString, 
     103                xios_map<StdString, 
     104                boost::shared_ptr<DerivedType> > > *AllMapObj_ptr; 
     105         static xios_map<StdString, 
     106                std::vector<boost::shared_ptr<DerivedType> > > *AllVectObj_ptr; 
    108107 
    109          // static xios_map< StdString, long int > GenId ; 
    110  
    111  
    112          static xios_map<StdString, xios_map<StdString, boost::shared_ptr<DerivedType> > > *AllMapObj; 
    113          static xios_map<StdString, std::vector<boost::shared_ptr<DerivedType> > > *AllVectObj; 
    114          static xios_map< StdString, long int > *GenId; 
    115          #pragma omp threadprivate(AllMapObj, AllVectObj, GenId) 
     108         static xios_map< StdString, long int > *GenId_ptr ; 
    116109 
    117110   }; // class CObjectTemplate 
  • XIOS/dev/branch_openmp/src/object_template_impl.hpp

    r1287 r1328  
    2424      xios_map<StdString, 
    2525      xios_map<StdString, 
    26       boost::shared_ptr<T> > > *CObjectTemplate<T>::AllMapObj = 0; 
     26      //boost::shared_ptr<T> > > CObjectTemplate<T>::AllMapObj; 
     27      boost::shared_ptr<T> > > *CObjectTemplate<T>::AllMapObj_ptr = 0; 
    2728 
    2829   template <class T> 
    2930      xios_map<StdString, 
    30       std::vector<boost::shared_ptr<T> > > *CObjectTemplate<T>::AllVectObj = 0; 
    31  
    32    template <class T> 
    33       xios_map<StdString,long int> *CObjectTemplate<T>::GenId = 0; 
     31      //std::vector<boost::shared_ptr<T> > > CObjectTemplate<T>::AllVectObj; 
     32      std::vector<boost::shared_ptr<T> > > *CObjectTemplate<T>::AllVectObj_ptr = 0; 
     33 
     34   template <class T> 
     35      //xios_map<StdString,long int> CObjectTemplate<T>::GenId; 
     36      xios_map<StdString,long int> *CObjectTemplate<T>::GenId_ptr = 0; 
    3437 
    3538   template <class T> 
     
    6669         CObjectTemplate<T>::GetAllVectobject(const StdString & contextId) 
    6770   { 
    68       return (CObjectTemplate<T>::AllVectObj->at(contextId)); 
     71      //return (CObjectTemplate<T>::AllVectObj[contextId]); 
     72    return (CObjectTemplate<T>::AllVectObj_ptr->at(contextId)); 
    6973   } 
    7074 
     
    321325 
    322326   template <typename T> 
    323    boost::shared_ptr<T> CObjectTemplate<T>::getShared(const T* ptr) 
     327   shared_ptr<T> CObjectTemplate<T>::getShared(const T* ptr) 
    324328   { 
    325329     return CObjectFactory::GetObject<T>(ptr); 
     
    327331 
    328332   template <typename T> 
    329    boost::shared_ptr<T> CObjectTemplate<T>::getShared(void) 
     333   shared_ptr<T> CObjectTemplate<T>::getShared(void) 
    330334   { 
    331335     return CObjectFactory::GetObject<T>((T*)this); 
     
    335339   const vector<T*> CObjectTemplate<T>::getAll() 
    336340   { 
    337      const vector< boost::shared_ptr<T> >& shared_vect= CObjectFactory::GetObjectVector<T>(); 
     341     const vector< shared_ptr<T> >& shared_vect= CObjectFactory::GetObjectVector<T>(); 
    338342     vector<T*> vect; 
    339343 
    340      typename vector<boost::shared_ptr<T> >::const_iterator it; 
     344     typename vector<shared_ptr<T> >::const_iterator it; 
    341345     for(it=shared_vect.begin();it!=shared_vect.end();++it) vect.push_back(it->get()); 
    342346     return vect; 
     
    346350   const vector<T*> CObjectTemplate<T>::getAll(const string & id) 
    347351   { 
    348      const vector< boost::shared_ptr<T> >& shared_vect= CObjectFactory::GetObjectVector<T>(id); 
     352     const vector< shared_ptr<T> >& shared_vect= CObjectFactory::GetObjectVector<T>(id); 
    349353     vector<T*> vect; 
    350354 
    351      typename vector<boost::shared_ptr<T> >::const_iterator it; 
     355     typename vector<shared_ptr<T> >::const_iterator it; 
    352356     for(it=shared_vect.begin();it!=shared_vect.end();++it) vect.push_back(it->get()); 
    353357     return vect; 
  • XIOS/dev/branch_openmp/src/parse_expr/lex_parser.cpp

    r1134 r1328  
    347347extern char *yytext; 
    348348#define yytext_ptr yytext 
    349  
    350349static yyconst flex_int16_t yy_nxt[][128] = 
    351350    { 
  • XIOS/dev/branch_openmp/src/parse_expr/yacc_parser.cpp

    r1134 r1328  
    8080} 
    8181 
    82   static IFilterExprNode* parsed; 
    83   static std::string globalInputText; 
    84   static std::string *globalInputText_ptr = 0; 
    85   static size_t globalReadOffset = 0; 
    86   #pragma omp threadprivate(parsed, globalInputText_ptr, globalReadOffset) 
    87    
     82  IFilterExprNode* parsed; 
     83  std::string globalInputText; 
     84  size_t globalReadOffset = 0; 
     85 
    8886  int readInputForLexer(char* buffer, size_t* numBytesRead, size_t maxBytesToRead) 
    8987  { 
    90     if(globalInputText_ptr == 0) globalInputText_ptr = new std::string; 
    9188    size_t numBytesToRead = maxBytesToRead; 
    92     size_t bytesRemaining = (*globalInputText_ptr).length()-globalReadOffset; 
     89    size_t bytesRemaining = globalInputText.length()-globalReadOffset; 
    9390    size_t i; 
    9491    if (numBytesToRead > bytesRemaining) numBytesToRead = bytesRemaining; 
    95     for (i = 0; i < numBytesToRead; i++) buffer[i] = (*globalInputText_ptr).c_str()[globalReadOffset + i]; 
     92    for (i = 0; i < numBytesToRead; i++) buffer[i] = globalInputText.c_str()[globalReadOffset + i]; 
    9693    *numBytesRead = numBytesToRead; 
    9794    globalReadOffset += numBytesToRead; 
     
    20052002  IFilterExprNode* parseExpr(const string& strExpr) 
    20062003  { 
    2007     #pragma omp critical (_parser) 
    2008     { 
    2009       if(globalInputText_ptr == 0) globalInputText_ptr = new std::string; 
    2010       (*globalInputText_ptr).assign (strExpr); 
    2011       globalReadOffset = 0; 
    2012       yyparse(); 
    2013     } 
     2004    globalInputText = strExpr; 
     2005    globalReadOffset = 0; 
     2006    yyparse(); 
    20142007    return parsed; 
    20152008  } 
     
    20172010 
    20182011 
    2019  
  • XIOS/dev/branch_openmp/src/parse_expr/yacc_parser.yacc

    r1134 r1328  
    1515} 
    1616 
    17   static IFilterExprNode* parsed; 
    18   static std::string globalInputText; 
    19   static std::string *globalInputText_ptr = 0; 
    20   static size_t globalReadOffset = 0; 
    21   #pragma omp threadprivate(parsed, globalInputText_ptr, globalReadOffset) 
    22    
     17  IFilterExprNode* parsed; 
     18  std::string globalInputText; 
     19  size_t globalReadOffset = 0; 
     20 
    2321  int readInputForLexer(char* buffer, size_t* numBytesRead, size_t maxBytesToRead) 
    2422  { 
    25     if(globalInputText_ptr == 0) globalInputText_ptr = new std::string; 
    2623    size_t numBytesToRead = maxBytesToRead; 
    27     size_t bytesRemaining = (*globalInputText_ptr).length()-globalReadOffset; 
     24    size_t bytesRemaining = globalInputText.length()-globalReadOffset; 
    2825    size_t i; 
    2926    if (numBytesToRead > bytesRemaining) numBytesToRead = bytesRemaining; 
    30     for (i = 0; i < numBytesToRead; i++) buffer[i] = (*globalInputText_ptr).c_str()[globalReadOffset + i]; 
     27    for (i = 0; i < numBytesToRead; i++) buffer[i] = globalInputText.c_str()[globalReadOffset + i]; 
    3128    *numBytesRead = numBytesToRead; 
    3229    globalReadOffset += numBytesToRead; 
     
    148145  IFilterExprNode* parseExpr(const string& strExpr) 
    149146  { 
    150     #pragma omp critical (_parser) 
    151     { 
    152       if(globalInputText_ptr == 0) globalInputText_ptr = new std::string; 
    153       (*globalInputText_ptr).assign (strExpr); 
    154       globalReadOffset = 0; 
    155       yyparse(); 
    156     } 
     147    globalInputText = strExpr; 
     148    globalReadOffset = 0; 
     149    yyparse(); 
    157150    return parsed; 
    158151  } 
  • XIOS/dev/branch_openmp/src/policy.cpp

    r855 r1328  
    1010#include "policy.hpp" 
    1111#include <cmath> 
     12using namespace ep_lib; 
    1213 
    1314namespace xios 
  • XIOS/dev/branch_openmp/src/registry.cpp

    r1134 r1328  
    11#include "registry.hpp" 
    22#include "type.hpp" 
     3#include <mpi.hpp> 
    34#include <fstream> 
    45#include <sstream> 
     6using namespace ep_lib; 
    57 
    68namespace xios 
     
    257259  void CRegistry::hierarchicalGatherRegistry(void) 
    258260  { 
    259    // hierarchicalGatherRegistry(communicator) ; 
    260     gatherRegistry(communicator) ; 
     261    hierarchicalGatherRegistry(communicator) ; 
    261262  } 
    262263 
  • XIOS/dev/branch_openmp/src/registry.hpp

    r1134 r1328  
    66#include "mpi.hpp" 
    77#include "message.hpp" 
    8 #ifdef _usingEP 
    9 #include "ep_declaration.hpp" 
    10 #endif 
    11  
    128 
    139// Those two headers can be replaced by the C++11 equivalent in the future 
     
    110106 
    111107/** use internally for recursivity */ 
    112       void gatherRegistry(const MPI_Comm& comm) ; 
     108      void gatherRegistry(const ep_lib::MPI_Comm& comm) ; 
    113109 
    114110/** use internally for recursivity */ 
    115       void hierarchicalGatherRegistry(const MPI_Comm& comm) ; 
     111      void hierarchicalGatherRegistry(const ep_lib::MPI_Comm& comm) ; 
    116112 
    117113 
  • XIOS/dev/branch_openmp/src/server.cpp

    r1205 r1328  
    99#include <boost/functional/hash.hpp> 
    1010#include <boost/algorithm/string.hpp> 
     11#include "mpi.hpp" 
    1112#include "tracer.hpp" 
    1213#include "timer.hpp" 
    1314#include "event_scheduler.hpp" 
     15using namespace ep_lib; 
    1416 
    1517namespace xios 
     
    2527    bool CServer::finished=false ; 
    2628    bool CServer::is_MPI_Initialized ; 
    27  
    28      
    2929    CEventScheduler* CServer::eventScheduler = 0; 
    3030    
    3131    void CServer::initialize(void) 
    3232    { 
     33     // int initialized ; 
     34     // MPI_Initialized(&initialized) ; 
     35     // if (initialized) is_MPI_Initialized=true ; 
     36     // else is_MPI_Initialized=false ; 
     37 
    3338      // Not using OASIS 
    3439      if (!CXios::usingOasis) 
    3540      { 
    3641 
     42       // if (!is_MPI_Initialized) 
     43       // { 
     44       //   MPI_Init(NULL, NULL); 
     45       // } 
    3746        CTimer::get("XIOS").resume() ; 
    3847 
     
    4251        unsigned long* hashAll ; 
    4352 
    44  
     53//        int rank ; 
    4554        int size ; 
    4655        int myColor ; 
     
    4958 
    5059        MPI_Comm_size(CXios::globalComm,&size) ; 
    51          
    52         //size = CXios::globalComm.ep_comm_ptr->size_rank_info[0].second; 
    53         printf("global size = %d, size= %d\n", CXios::globalComm.ep_comm_ptr->size_rank_info[0].second, size); 
    54          
    5560        MPI_Comm_rank(CXios::globalComm,&rank); 
    5661        hashAll=new unsigned long[size] ; 
     
    7378 
    7479        myColor=colors[hashServer] ; 
    75  
    76  
    7780        MPI_Comm_split(CXios::globalComm,myColor,rank,&intraComm) ; 
    7881 
    79          
    8082        int serverLeader=leaders[hashServer] ; 
    8183        int clientLeader; 
    8284 
    8385         serverLeader=leaders[hashServer] ; 
    84          for(it=leaders.begin();it!=leaders.end();++it) 
     86         for(it=leaders.begin();it!=leaders.end();it++) 
    8587         { 
    8688           if (it->first!=hashServer) 
     
    9395                     <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< clientLeader<<endl ; 
    9496 
    95             // test_sendrecv(CXios::globalComm); 
    9697             MPI_Intercomm_create(intraComm,0,CXios::globalComm,clientLeader,0,&newComm) ; 
    9798             interComm.push_back(newComm) ; 
     
    102103      } 
    103104      // using OASIS 
    104       else 
     105/*      else 
    105106      { 
     107        int rank ,size; 
    106108        int size; 
    107109        if (!is_MPI_Initialized) oasis_init(CXios::xiosCodeId); 
     
    133135              oasis_enddef() ; 
    134136      } 
    135  
     137*/ 
     138//      int rank; 
    136139      MPI_Comm_rank(intraComm,&rank) ; 
    137140      if (rank==0) isRoot=true; 
     
    147150      delete eventScheduler ; 
    148151 
    149       for (std::list<MPI_Comm>::iterator it = contextInterComms.begin(); it != contextInterComms.end(); ++it) 
     152      for (std::list<MPI_Comm>::iterator it = contextInterComms.begin(); it != contextInterComms.end(); it++) 
    150153        MPI_Comm_free(&(*it)); 
    151       for (std::list<MPI_Comm>::iterator it = interComm.begin(); it != interComm.end(); ++it) 
     154      for (std::list<MPI_Comm>::iterator it = interComm.begin(); it != interComm.end(); it++) 
    152155        MPI_Comm_free(&(*it)); 
    153  
    154156      MPI_Comm_free(&intraComm); 
    155157 
     
    157159      { 
    158160        if (CXios::usingOasis) oasis_finalize(); 
    159         //else  {MPI_Finalize() ;} 
     161        //else MPI_Finalize() ; 
    160162      } 
    161  
    162        
    163163      report(0)<<"Performance report : Time spent for XIOS : "<<CTimer::get("XIOS server").getCumulatedTime()<<endl  ; 
    164164      report(0)<<"Performance report : Time spent in processing events : "<<CTimer::get("Process events").getCumulatedTime()<<endl  ; 
     
    182182         { 
    183183           listenRootContext(); 
    184            if (!finished)  
    185            { 
    186              listenRootFinalize() ; 
    187            } 
     184           if (!finished) listenRootFinalize() ; 
    188185         } 
    189186 
    190187         contextEventLoop() ; 
    191188         if (finished && contextList.empty()) stop=true ; 
    192           
    193189         eventScheduler->checkEvent() ; 
    194190       } 
    195         
    196         
    197191       CTimer::get("XIOS server").suspend() ; 
    198192     } 
     
    204198        int flag ; 
    205199 
    206         for(it=interComm.begin();it!=interComm.end();++it) 
     200        for(it=interComm.begin();it!=interComm.end();it++) 
    207201        { 
    208202           MPI_Status status ; 
     
    214208              MPI_Recv(&msg,1,MPI_INT,0,0,*it,&status) ; 
    215209              info(20)<<" CServer : Receive client finalize"<<endl ; 
    216  
    217210              MPI_Comm_free(&(*it)); 
    218211              interComm.erase(it) ; 
     
    268261       { 
    269262         traceOff() ; 
    270          #ifdef _usingEP 
    271          MPI_Iprobe(-1,1,CXios::globalComm, &flag, &status) ; 
    272          #else 
    273          MPI_Iprobe(MPI_ANY_SOURCE,1,CXios::globalComm, &flag, &status) ; 
    274          #endif 
     263         MPI_Iprobe(-2,1,CXios::globalComm, &flag, &status) ; 
    275264         traceOn() ; 
    276           
    277265         if (flag==true) 
    278266         { 
     
    280268           rank=status.MPI_SOURCE ; 
    281269           #elif _usingEP 
    282            rank= status.ep_src ; 
     270           rank=status.ep_src; 
    283271           #endif 
    284272           MPI_Get_count(&status,MPI_CHAR,&count) ; 
     
    298286           rank=status.MPI_SOURCE ; 
    299287           #elif _usingEP 
    300            rank= status.ep_src ; 
     288           rank=status.ep_src; 
    301289           #endif 
    302290           MPI_Get_count(&status,MPI_CHAR,&count) ; 
     
    342330            MPI_Isend(buff,count,MPI_CHAR,i,2,intraComm,&requests[i-1]) ; 
    343331         } 
    344           
    345332         MPI_Waitall(size-1,requests,status) ; 
    346333         registerContext(buff,count,it->second.leaderRank) ; 
     
    422409       bool finished ; 
    423410       map<string,CContext*>::iterator it ; 
    424        for(it=contextList.begin();it!=contextList.end();++it) 
     411       for(it=contextList.begin();it!=contextList.end();it++) 
    425412       { 
    426413         finished=it->second->checkBuffersAndListen(); 
  • XIOS/dev/branch_openmp/src/server.hpp

    r1134 r1328  
    77#include "mpi.hpp" 
    88#include "event_scheduler.hpp" 
    9  
    10 #ifdef _usingEP 
    11 #include "ep_declaration.hpp" 
    12 #endif 
    139 
    1410namespace xios 
     
    2824        static void registerContext(void* buff,int count, int leaderRank=0); 
    2925 
    30         static MPI_Comm intraComm; 
    31         static list<MPI_Comm> interComm; 
    32         static std::list<MPI_Comm> contextInterComms; 
     26        static ep_lib::MPI_Comm intraComm; 
     27        static list<ep_lib::MPI_Comm> interComm; 
     28        static std::list<ep_lib::MPI_Comm> contextInterComms; 
    3329        static CEventScheduler* eventScheduler; 
    3430         
  • XIOS/dev/branch_openmp/src/test/test_client.f90

    r1134 r1328  
    3535 
    3636  CALL MPI_INIT(ierr) 
     37 
    3738  CALL init_wait 
    38  
    39   CALL MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierr) 
    40   if(rank < 2) then 
    4139 
    4240!!! XIOS Initialization (get the local communicator) 
     
    7472 
    7573  CALL xios_context_initialize("test",comm) 
    76  
    7774  CALL xios_get_handle("test",ctx_hdl) 
    7875  CALL xios_set_current_context(ctx_hdl) 
     
    128125  CALL xios_is_defined_field_attr("field_A",enabled=ok) 
    129126  PRINT *,"field_A : attribute enabled is defined ? ",ok 
    130    
    131127  CALL xios_close_context_definition() 
    132128 
    133129  PRINT*,"field field_A is active ? ",xios_field_is_active("field_A") 
    134  
    135   call MPI_Barrier(comm, ierr) 
    136  
    137130  DO ts=1,24*10 
    138131    CALL xios_update_calendar(ts) 
    139132    CALL xios_send_field("field_A",field_A) 
    140     CALL wait_us(5000) 
     133    CALL wait_us(5000) ; 
    141134  ENDDO 
    142135 
     
    148141 
    149142  CALL xios_finalize() 
    150   print *, "Client : xios_finalize " 
    151  
    152     else 
    153  
    154     CALL xios_init_server 
    155     print *, "Server : xios_finalize " 
    156    
    157     endif 
    158      
    159143 
    160144  CALL MPI_FINALIZE(ierr) 
  • XIOS/dev/branch_openmp/src/test/test_complete.f90

    r1134 r1328  
    55  IMPLICIT NONE 
    66  INCLUDE "mpif.h" 
    7   INTEGER :: rank, size 
     7  INTEGER :: rank 
    88  INTEGER :: size_loc 
    99  INTEGER :: ierr 
     
    2828  INTEGER, ALLOCATABLE :: kindex(:) 
    2929  INTEGER :: ni,ibegin,iend,nj,jbegin,jend 
    30   INTEGER :: i,j,l,ts,n, nb_pt, provided 
     30  INTEGER :: i,j,l,ts,n, nb_pt 
    3131 
    3232!!! MPI Initialization 
    3333 
    34   CALL MPI_INIT_THREAD(3, provided, ierr) 
    35     if(provided .NE. 3) then 
    36       print*, "provided thread level = ", provided 
    37       call MPI_Abort() 
    38     endif  
    39  
    40    
     34  CALL MPI_INIT(ierr) 
    4135 
    4236  CALL init_wait 
    43  
    44   CALL MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierr) 
    45   CALL MPI_COMM_SIZE(MPI_COMM_WORLD,size,ierr) 
    46   if(rank < size-1) then 
    4737 
    4838!!! XIOS Initialization (get the local communicator) 
     
    230220!#################################################################################### 
    231221 
    232     DO ts=1,24*2 
    233     !DO ts=1,24 
     222    DO ts=1,24*10 
    234223 
    235224      CALL xios_get_handle("atmosphere",ctx_hdl) 
     
    266255!!! Fin des contextes 
    267256 
    268  
    269     CALL xios_get_handle("surface",ctx_hdl)  
    270  
     257    CALL xios_context_finalize() 
     258    CALL xios_get_handle("atmosphere",ctx_hdl) 
    271259    CALL xios_set_current_context(ctx_hdl) 
    272260    CALL xios_context_finalize() 
    273261 
    274     print *, "xios_context_finalize(surface)"  
    275  
    276      CALL xios_get_handle("atmosphere",ctx_hdl) 
    277  
    278      CALL xios_set_current_context(ctx_hdl) 
    279  
    280      CALL xios_context_finalize() 
    281  
    282      print *, "xios_context_finalize(atmosphere)" 
    283  
    284      
    285  
    286 !!! Fin de XIOS 
    287  
    288      
    289  
    290     CALL xios_finalize() 
    291  
    292262    DEALLOCATE(lon, lat, field_A_atm, lonvalue) 
    293263    DEALLOCATE(kindex, field_A_srf) 
    294264 
    295      print *, "Client : xios_finalize " 
     265!!! Fin de XIOS 
    296266 
    297267    CALL MPI_COMM_FREE(comm, ierr) 
    298268 
    299   else 
    300  
    301     CALL xios_init_server 
    302     print *, "Server : xios_finalize " 
    303    
    304     endif 
    305  
     269    CALL xios_finalize() 
    306270 
    307271    CALL MPI_FINALIZE(ierr) 
  • XIOS/dev/branch_openmp/src/test/test_remap.f90

    r1141 r1328  
    4242  CALL MPI_INIT(ierr) 
    4343  CALL init_wait 
    44    
    45   CALL MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierr) 
    46   CALL MPI_COMM_SIZE(MPI_COMM_WORLD,size,ierr) 
    47   if(rank < size-2) then 
    4844 
    4945!!! XIOS Initialization (get the local communicator) 
     
    232228 
    233229  CALL xios_finalize() 
    234    
    235   print *, "Client : xios_finalize " 
    236  
    237     else 
    238  
    239     CALL xios_init_server 
    240     print *, "Server : xios_finalize " 
    241    
    242     endif 
    243230 
    244231  CALL MPI_FINALIZE(ierr) 
  • XIOS/dev/branch_openmp/src/timer.cpp

    r1205 r1328  
    66#include <sstream> 
    77#include "tracer.hpp" 
     8using namespace ep_lib; 
    89 
    910namespace xios 
    1011{ 
    11   std::map<std::string,CTimer> CTimer::allTimer; 
     12  //std::map<std::string,CTimer> CTimer::allTimer; 
    1213  std::map<std::string,CTimer> *CTimer::allTimer_ptr = 0; 
    1314   
     
    5556  CTimer& CTimer::get(const std::string name) 
    5657  { 
    57     // bkp 
    58     // std::map<std::string,CTimer>::iterator it = allTimer.find(name); 
    59     // if (it == allTimer.end()) 
    60     //   it = allTimer.insert(std::make_pair(name, CTimer(name))).first; 
    61     // return it->second; 
     58    if(allTimer_ptr == NULL) allTimer_ptr = new std::map<std::string,CTimer>; 
    6259 
    63     if(allTimer_ptr == 0) allTimer_ptr = new std::map<std::string,CTimer>; 
     60    //std::map<std::string,CTimer>::iterator it = allTimer.find(name); 
     61    std::map<std::string,CTimer>::iterator it = allTimer_ptr->find(name); 
     62    //if (it == allTimer.end()) 
     63    if (it == allTimer_ptr->end()) 
     64      it = allTimer_ptr->insert(std::make_pair(name, CTimer(name))).first; 
    6465 
    65     std::map<std::string,CTimer>::iterator it = (*allTimer_ptr).find(name); 
    66     if (it == (*allTimer_ptr).end()) 
    67       it = (*allTimer_ptr).insert(std::make_pair(name, CTimer(name))).first; 
     66      //it = allTimer.insert(std::make_pair(name, CTimer(name))).first; 
    6867    return it->second; 
    6968  } 
     
    7271  { 
    7372    std::ostringstream strOut ; 
    74     for(std::map<std::string,CTimer>::iterator it=allTimer.begin();it!=allTimer.end();++it) 
     73    if(allTimer_ptr == 0) allTimer_ptr = new std::map<std::string,CTimer>; 
     74    //for(std::map<std::string,CTimer>::iterator it=allTimer.begin();it!=allTimer.end();++it) 
     75    for(std::map<std::string,CTimer>::iterator it=allTimer_ptr->begin();it!=allTimer_ptr->end();++it) 
    7576      strOut<<"Timer : "<<it->first<<"    -->   cumulated time : "<<it->second.getCumulatedTime()<<std::endl ; 
    7677    return strOut.str() ; 
  • XIOS/dev/branch_openmp/src/timer.hpp

    r1205 r1328  
    2020      void reset(void); 
    2121      double getCumulatedTime(void); 
    22       static std::map<std::string,CTimer> allTimer; 
    23  
     22      //static std::map<std::string,CTimer> allTimer; 
    2423      static std::map<std::string,CTimer> *allTimer_ptr; 
    25       #pragma omp threadprivate(allTimer_ptr) 
    26        
    2724      static double getTime(void); 
    2825      static CTimer& get(std::string name); 
  • XIOS/dev/branch_openmp/src/transformation/Functions/average_reduction.cpp

    r1205 r1328  
    3131                                       CArray<double,1>& dataOut, 
    3232                                       std::vector<bool>& flagInitial,                      
    33                                        bool ignoreMissingValue) 
     33                                       bool ignoreMissingValue, bool firstPass) 
    3434{ 
    3535  if (resetWeight_) { weights_.resize(flagInitial.size()); weights_ = 1.0; resetWeight_ = false; }   
     
    3939    int nbLocalIndex = localIndex.size(); 
    4040    int currentlocalIndex = 0; 
    41     double currentWeight  = 0.0;     
     41    double currentWeight  = 0.0; 
     42 
     43    if (firstPass) dataOut=std::numeric_limits<double>::quiet_NaN(); 
    4244 
    4345    for (int idx = 0; idx < nbLocalIndex; ++idx) 
     
    5759          weights_(currentlocalIndex) += 1.0; 
    5860        } 
    59       } 
    60       else 
    61       { 
    62         if (flagInitial[currentlocalIndex])  
    63           dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN(); 
    6461      } 
    6562    } 
  • XIOS/dev/branch_openmp/src/transformation/Functions/average_reduction.hpp

    r1076 r1328  
    2727                     CArray<double,1>& dataOut, 
    2828                     std::vector<bool>& flagInitial,                      
    29                      bool ignoreMissingValue); 
     29                     bool ignoreMissingValue, bool firstPass); 
    3030 
    3131  virtual void updateData(CArray<double,1>& dataOut); 
  • XIOS/dev/branch_openmp/src/transformation/Functions/extract.cpp

    r1076 r1328  
    3030                                       CArray<double,1>& dataOut, 
    3131                                       std::vector<bool>& flagInitial, 
    32                                        bool ignoreMissingValue) 
     32                                       bool ignoreMissingValue, bool firstPass) 
    3333{ 
    3434  int nbLocalIndex = localIndex.size(); 
  • XIOS/dev/branch_openmp/src/transformation/Functions/extract.hpp

    r1076 r1328  
    2727                     CArray<double,1>& dataOut, 
    2828                     std::vector<bool>& flagInitial, 
    29                      bool ignoreMissingValue); 
     29                     bool ignoreMissingValue, bool firstPass); 
    3030 
    3131  virtual ~CExtractReductionAlgorithm() {} 
  • XIOS/dev/branch_openmp/src/transformation/Functions/max_reduction.cpp

    r1205 r1328  
    3131                                   CArray<double,1>& dataOut, 
    3232                                   std::vector<bool>& flagInitial, 
    33                                    bool ignoreMissingValue) 
     33                                   bool ignoreMissingValue, bool firstPass) 
    3434{  
    3535  if (ignoreMissingValue) 
    3636  { 
    3737    int nbLocalIndex = localIndex.size(); 
    38     int currentlocalIndex = 0;     
     38    int currentlocalIndex = 0; 
     39    if (firstPass) dataOut=std::numeric_limits<double>::quiet_NaN();     
    3940    for (int idx = 0; idx < nbLocalIndex; ++idx) 
    4041    { 
     
    5152          dataOut(currentlocalIndex) = std::max(*(dataInput + idx), dataOut(currentlocalIndex)); 
    5253        } 
    53       } 
    54       else 
    55       { 
    56         if (flagInitial[currentlocalIndex])  
    57           dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN(); 
    5854      } 
    5955    } 
  • XIOS/dev/branch_openmp/src/transformation/Functions/max_reduction.hpp

    r1076 r1328  
    2727                     CArray<double,1>& dataOut, 
    2828                     std::vector<bool>& flagInitial, 
    29                      bool ignoreMissingValue); 
     29                     bool ignoreMissingValue, bool firstPass); 
    3030 
    3131  virtual ~CMaxReductionAlgorithm() {} 
  • XIOS/dev/branch_openmp/src/transformation/Functions/min_reduction.cpp

    r1205 r1328  
    3131                                   CArray<double,1>& dataOut, 
    3232                                   std::vector<bool>& flagInitial, 
    33                                    bool ignoreMissingValue) 
     33                                   bool ignoreMissingValue, bool firstPass) 
    3434{ 
    3535  if (ignoreMissingValue) 
    3636  { 
    3737    int nbLocalIndex = localIndex.size(); 
    38     int currentlocalIndex = 0;     
     38    int currentlocalIndex = 0; 
     39    if (firstPass) dataOut=std::numeric_limits<double>::quiet_NaN(); 
    3940    for (int idx = 0; idx < nbLocalIndex; ++idx) 
    4041    { 
     
    5152          dataOut(currentlocalIndex) = std::min(*(dataInput + idx), dataOut(currentlocalIndex)); 
    5253        } 
    53       } 
    54       else 
    55       { 
    56         if (flagInitial[currentlocalIndex])  
    57           dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN(); 
    5854      } 
    5955    } 
  • XIOS/dev/branch_openmp/src/transformation/Functions/min_reduction.hpp

    r1076 r1328  
    2727                     CArray<double,1>& dataOut, 
    2828                     std::vector<bool>& flagInitial,                      
    29                      bool ignoreMissingValue); 
     29                     bool ignoreMissingValue, bool firstPass); 
    3030 
    3131  virtual ~CMinReductionAlgorithm() {} 
  • XIOS/dev/branch_openmp/src/transformation/Functions/reduction.cpp

    r1155 r1328  
    1010CReductionAlgorithm::CallBackMap* CReductionAlgorithm::reductionCreationCallBacks_ = 0; 
    1111//std::map<StdString,EReductionType> CReductionAlgorithm::ReductionOperations = std::map<StdString,EReductionType>(); 
    12 std::map<StdString,EReductionType> *CReductionAlgorithm::ReductionOperations_ptr = 0;  
    13 //#pragma omp threadprivate(CReductionAlgorithm::ReductionOperations_ptr) 
     12std::map<StdString,EReductionType> *CReductionAlgorithm::ReductionOperations_ptr = 0; 
    1413 
     14bool CReductionAlgorithm::initReductionOperation(std::map<StdString,EReductionType>& m) 
     15{ 
     16  // So so stupid way to intialize operation but it works ... 
     17  m["sum"] = TRANS_REDUCE_SUM; 
     18  CSumReductionAlgorithm::registerTrans(); 
     19 
     20  m["min"] = TRANS_REDUCE_MIN; 
     21  CMinReductionAlgorithm::registerTrans(); 
     22 
     23  m["max"] = TRANS_REDUCE_MAX; 
     24  CMaxReductionAlgorithm::registerTrans(); 
     25 
     26  m["extract"] = TRANS_REDUCE_EXTRACT; 
     27  CExtractReductionAlgorithm::registerTrans(); 
     28 
     29  m["average"] = TRANS_REDUCE_AVERAGE; 
     30  CAverageReductionAlgorithm::registerTrans(); 
     31} 
    1532 
    1633bool CReductionAlgorithm::initReductionOperation() 
     
    3552 
    3653//bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation(CReductionAlgorithm::ReductionOperations); 
    37 //bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation(); 
     54bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation(); 
    3855 
    3956CReductionAlgorithm* CReductionAlgorithm::createOperation(EReductionType reduceType) 
    4057{ 
    4158  int reduceTypeInt = reduceType; 
    42  
    4359  CallBackMap::const_iterator it = (*reductionCreationCallBacks_).find(reduceType); 
    4460  if ((*reductionCreationCallBacks_).end() == it) 
  • XIOS/dev/branch_openmp/src/transformation/Functions/reduction.hpp

    r1155 r1328  
    2525  //static std::map<StdString,EReductionType> ReductionOperations; 
    2626  static std::map<StdString,EReductionType> *ReductionOperations_ptr; 
    27   #pragma omp threadprivate(ReductionOperations_ptr) 
    2827 
    2928public: 
    30   CReductionAlgorithm() { } 
     29  CReductionAlgorithm() {} 
    3130 
    3231  /*! 
     
    4342    \param [in/out] dataOut Array contains local data 
    4443    \param [in/out] flagInitial vector of boolean to mark the local index already initialized. True means there is a need for initialization 
     44    \param [in] firstPass indicate if it is the first time the apply funtion is called for a same transformation, in order to make a clean initialization  
    4545  */ 
    4646  virtual void apply(const std::vector<std::pair<int,double> >& localIndex, 
     
    4848                     CArray<double,1>& dataOut, 
    4949                     std::vector<bool>& flagInitial,                      
    50                      bool ignoreMissingValue) = 0; 
     50                     bool ignoreMissingValue, bool firstPass) = 0; 
    5151  /*! 
    5252    Update local data  
     
    6262  typedef std::map<EReductionType, CreateOperationCallBack> CallBackMap; 
    6363  static CallBackMap* reductionCreationCallBacks_; 
    64   #pragma omp threadprivate(reductionCreationCallBacks_) 
    6564 
    6665  static bool registerOperation(EReductionType reduceType, CreateOperationCallBack createFn); 
     
    7170  static bool initReductionOperation(); 
    7271  static bool _dummyInit; 
    73   #pragma omp threadprivate(_dummyInit) 
    7472}; 
    7573 
  • XIOS/dev/branch_openmp/src/transformation/Functions/sum_reduction.cpp

    r1205 r1328  
    3131                                   CArray<double,1>& dataOut, 
    3232                                   std::vector<bool>& flagInitial, 
    33                                    bool ignoreMissingValue) 
     33                                   bool ignoreMissingValue, bool firstPass) 
    3434{ 
    3535  if (ignoreMissingValue) 
    3636  { 
    3737    int nbLocalIndex = localIndex.size(); 
    38     int currentlocalIndex = 0;     
     38    int currentlocalIndex = 0; 
     39 
     40    if (firstPass) dataOut=std::numeric_limits<double>::quiet_NaN(); 
    3941   
    4042    for (int idx = 0; idx < nbLocalIndex; ++idx) 
     
    5254          dataOut(currentlocalIndex) += *(dataInput + idx); 
    5355        } 
    54       } 
    55       else 
    56       { 
    57         if (flagInitial[currentlocalIndex])  
    58           dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN(); 
    5956      } 
    6057    }     
  • XIOS/dev/branch_openmp/src/transformation/Functions/sum_reduction.hpp

    r1076 r1328  
    2727                     CArray<double,1>& dataOut, 
    2828                     std::vector<bool>& flagInitial, 
    29                      bool ignoreMissingValue); 
     29                     bool ignoreMissingValue, bool firstPass); 
    3030 
    3131  virtual ~CSumReductionAlgorithm() {} 
  • XIOS/dev/branch_openmp/src/transformation/axis_algorithm_extract_domain.cpp

    r1155 r1328  
    1313#include "grid.hpp" 
    1414#include "grid_transformation_factory_impl.hpp" 
     15#include "reduction.hpp" 
    1516 
    1617namespace xios { 
     
    6162 
    6263  pos_ = algo->position; 
    63  
    64   if(CReductionAlgorithm::ReductionOperations_ptr == 0)  
    65     CReductionAlgorithm::initReductionOperation(); 
    66  
    67   reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]); 
     64  //reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 
     65  reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations_ptr->at(op)); 
    6866} 
    6967 
     
    7270                                        CArray<double,1>& dataOut, 
    7371                                        std::vector<bool>& flagInitial,                      
    74                                         bool ignoreMissingValue) 
     72                                        bool ignoreMissingValue, bool firstPass) 
    7573{ 
    76   reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue); 
     74  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 
    7775} 
    7876 
  • XIOS/dev/branch_openmp/src/transformation/axis_algorithm_extract_domain.hpp

    r1155 r1328  
    1212#include "axis_algorithm_transformation.hpp" 
    1313#include "transformation.hpp" 
    14 #include "reduction.hpp" 
    1514 
    1615namespace xios { 
     
    2625  Extract a domain to an axis 
    2726*/ 
    28 class CAxisAlgorithmExtractDomain : public CAxisAlgorithmTransformation, public CReductionAlgorithm 
     27class CAxisAlgorithmExtractDomain : public CAxisAlgorithmTransformation 
    2928{ 
    3029public: 
     
    3534                     CArray<double,1>& dataOut, 
    3635                     std::vector<bool>& flagInitial,                      
    37                      bool ignoreMissingValue); 
     36                     bool ignoreMissingValue, bool firstPass); 
    3837 
    3938  virtual ~CAxisAlgorithmExtractDomain(); 
  • XIOS/dev/branch_openmp/src/transformation/axis_algorithm_inverse.cpp

    r1134 r1328  
    1515#include "inverse_axis.hpp" 
    1616#include "client_client_dht_template.hpp" 
     17using namespace ep_lib; 
    1718 
    1819namespace xios { 
     
    173174 
    174175  // Sending global index of grid source to corresponding process as well as the corresponding mask 
    175   std::vector<ep_lib::MPI_Request> requests; 
    176   std::vector<ep_lib::MPI_Status> status; 
     176  std::vector<MPI_Request> requests; 
     177  std::vector<MPI_Status> status; 
    177178  boost::unordered_map<int, unsigned long* > recvGlobalIndexSrc; 
    178179  boost::unordered_map<int, double* > sendValueToDest; 
     
    184185    sendValueToDest[recvRank] = new double [recvSize]; 
    185186 
    186     requests.push_back(ep_lib::MPI_Request()); 
     187    requests.push_back(MPI_Request()); 
    187188    MPI_Irecv(recvGlobalIndexSrc[recvRank], recvSize, MPI_UNSIGNED_LONG, recvRank, 46, client->intraComm, &requests.back()); 
    188189  } 
     
    206207 
    207208    // Send global index source and mask 
    208     requests.push_back(ep_lib::MPI_Request()); 
     209    requests.push_back(MPI_Request()); 
    209210    MPI_Isend(sendGlobalIndexSrc[sendRank], sendSize, MPI_UNSIGNED_LONG, sendRank, 46, client->intraComm, &requests.back()); 
    210211  } 
     
    213214  MPI_Waitall(requests.size(), &requests[0], &status[0]); 
    214215 
    215   std::vector<ep_lib::MPI_Request>().swap(requests); 
    216   std::vector<ep_lib::MPI_Status>().swap(status); 
     216 
     217  std::vector<MPI_Request>().swap(requests); 
     218  std::vector<MPI_Status>().swap(status); 
    217219 
    218220  // Okie, on destination side, we will wait for information of masked index of source 
     
    222224    int recvSize = itSend->second; 
    223225 
    224     requests.push_back(ep_lib::MPI_Request()); 
     226    requests.push_back(MPI_Request()); 
    225227    MPI_Irecv(recvValueFromSrc[recvRank], recvSize, MPI_DOUBLE, recvRank, 48, client->intraComm, &requests.back()); 
    226228  } 
     
    240242    } 
    241243    // Okie, now inform the destination which source index are masked 
    242     requests.push_back(ep_lib::MPI_Request()); 
     244    requests.push_back(MPI_Request()); 
    243245    MPI_Isend(sendValueToDest[recvRank], recvSize, MPI_DOUBLE, recvRank, 48, client->intraComm, &requests.back()); 
    244246  } 
    245247  status.resize(requests.size()); 
    246248  MPI_Waitall(requests.size(), &requests[0], &status[0]); 
     249 
    247250 
    248251  size_t nGloAxisDest = axisDest_->n_glo.getValue() - 1; 
  • XIOS/dev/branch_openmp/src/transformation/axis_algorithm_inverse.hpp

    r1134 r1328  
    1212#include "axis_algorithm_transformation.hpp" 
    1313#include "transformation.hpp" 
    14 #ifdef _usingEP 
    15 #include "ep_declaration.hpp" 
    16 #endif 
    17     
     14 
    1815namespace xios { 
    1916 
  • XIOS/dev/branch_openmp/src/transformation/axis_algorithm_reduce_domain.cpp

    r1155 r1328  
    1313#include "grid.hpp" 
    1414#include "grid_transformation_factory_impl.hpp" 
     15#include "reduction.hpp" 
    1516 
    1617namespace xios { 
     
    6970 
    7071  dir_ = (CReduceDomainToAxis::direction_attr::iDir == algo->direction)  ? iDir : jDir; 
    71  
    72   if(CReductionAlgorithm::ReductionOperations_ptr == 0)  
    73     CReductionAlgorithm::initReductionOperation(); 
    74  
    75   reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]); 
     72  //reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 
     73  reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations_ptr->at(op)); 
    7674} 
    7775 
     
    8078                                       CArray<double,1>& dataOut, 
    8179                                       std::vector<bool>& flagInitial,                      
    82                                        bool ignoreMissingValue) 
     80                                       bool ignoreMissingValue, bool firstPass) 
    8381{ 
    84   reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue); 
     82  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 
    8583} 
    8684 
     
    105103  CArray<int,1>& axisDstIndex = axisDest_->index; 
    106104  int ni_glo = domainSrc_->ni_glo, nj_glo = domainSrc_->nj_glo; 
    107   if (jDir == dir_) 
     105  if (iDir == dir_) 
    108106  { 
    109107    int nbAxisIdx = axisDstIndex.numElements(); 
     
    120118    } 
    121119  } 
    122   else if (iDir == dir_) 
     120  else if (jDir == dir_) 
    123121  { 
    124122    int nbAxisIdx = axisDstIndex.numElements(); 
  • XIOS/dev/branch_openmp/src/transformation/axis_algorithm_reduce_domain.hpp

    r1155 r1328  
    1212#include "axis_algorithm_transformation.hpp" 
    1313#include "transformation.hpp" 
    14 #include "reduction.hpp" 
    1514 
    1615namespace xios { 
     
    2524  Reduce a domain to an axis 
    2625*/ 
    27 class CAxisAlgorithmReduceDomain : public CAxisAlgorithmTransformation, public CReductionAlgorithm 
     26class CAxisAlgorithmReduceDomain : public CAxisAlgorithmTransformation 
    2827{ 
    2928public: 
     
    3433                     CArray<double,1>& dataOut, 
    3534                     std::vector<bool>& flagInitial,                      
    36                      bool ignoreMissingValue); 
     35                     bool ignoreMissingValue, bool firstPass); 
    3736 
    3837  virtual void updateData(CArray<double,1>& dataOut); 
  • XIOS/dev/branch_openmp/src/transformation/axis_algorithm_zoom.cpp

    r1205 r1328  
    4444  zoomBegin_ = zoomAxis->begin.getValue(); 
    4545  zoomSize_  = zoomAxis->n.getValue(); 
    46   zoomEnd_   = zoomBegin_ + zoomSize_ - 1; 
     46  zoomEnd_   = zoomBegin_ + zoomSize_ - 1;   
    4747 
    4848  if (zoomSize_ > axisSource->n_glo.getValue()) 
  • XIOS/dev/branch_openmp/src/transformation/domain_algorithm_interpolate.cpp

    r1205 r1328  
    2020#include "interpolate_domain.hpp" 
    2121#include "grid.hpp" 
     22using namespace ep_lib; 
    2223 
    2324namespace xios { 
     
    113114  nVertexSrc = nVertexDest = constNVertex; 
    114115 
     116 
     117 
    115118  // First of all, try to retrieve the boundary values of domain source and domain destination 
    116119  int localDomainSrcSize = domainSrc_->i_index.numElements(); 
     
    281284  } 
    282285 
     286 
    283287  for (int idx = 0; idx < nDstLocal; ++idx) 
    284288  { 
     
    404408  CContext* context = CContext::getCurrent(); 
    405409  CContextClient* client=context->client; 
    406   int split_key; 
    407   ep_lib::MPI_Comm_rank(client->intraComm, &split_key); 
    408  
    409   ep_lib::MPI_Comm poleComme(MPI_COMM_NULL); 
    410   ep_lib::MPI_Comm_split(client->intraComm, interMapValuePole.empty() ? 9 : 1, split_key, &poleComme); 
    411   if (MPI_COMM_NULL != poleComme) 
     410 
     411  ep_lib::MPI_Comm poleComme; 
     412  ep_lib::MPI_Comm_split(client->intraComm, interMapValuePole.empty() ? 0 : 1, 0, &poleComme); 
     413  if (!poleComme.is_null()) 
    412414  { 
    413415    int nbClientPole; 
     
    428430    for(int n=1;n<nbClientPole;++n) displ[n]=displ[n-1]+recvCount[n-1] ; 
    429431    int recvSize=displ[nbClientPole-1]+recvCount[nbClientPole-1] ; 
    430      
    431432 
    432433    std::vector<int> sendSourceIndexBuff(nbWeight); 
     
    601602  double* sendWeightBuff = new double [sendBuffSize]; 
    602603 
    603   std::vector<ep_lib::MPI_Request> sendRequest; 
     604  std::vector<ep_lib::MPI_Request> sendRequest(3*globalIndexInterpSendToClient.size()); 
    604605 
    605606  int sendOffSet = 0, l = 0; 
     607  int position = 0; 
    606608  for (itMap = itbMap; itMap != iteMap; ++itMap) 
    607609  { 
     
    622624    } 
    623625 
    624     sendRequest.push_back(ep_lib::MPI_Request()); 
    625626    ep_lib::MPI_Isend(sendIndexDestBuff + sendOffSet, 
    626627             k, 
     
    629630             MPI_DOMAIN_INTERPOLATION_DEST_INDEX, 
    630631             client->intraComm, 
    631              &sendRequest.back()); 
    632     sendRequest.push_back(ep_lib::MPI_Request()); 
     632             &sendRequest[position++]); 
    633633    ep_lib::MPI_Isend(sendIndexSrcBuff + sendOffSet, 
    634634             k, 
     
    637637             MPI_DOMAIN_INTERPOLATION_SRC_INDEX, 
    638638             client->intraComm, 
    639              &sendRequest.back()); 
    640     sendRequest.push_back(ep_lib::MPI_Request()); 
     639             &sendRequest[position++]); 
    641640    ep_lib::MPI_Isend(sendWeightBuff + sendOffSet, 
    642641             k, 
     
    645644             MPI_DOMAIN_INTERPOLATION_WEIGHT, 
    646645             client->intraComm, 
    647              &sendRequest.back()); 
     646             &sendRequest[position++]); 
    648647    sendOffSet += k; 
    649648  } 
     
    661660             recvBuffSize, 
    662661             MPI_INT, 
    663              MPI_ANY_SOURCE, 
     662             -2, 
    664663             MPI_DOMAIN_INTERPOLATION_DEST_INDEX, 
    665664             client->intraComm, 
     
    673672    clientSrcRank = recvStatus.ep_src; 
    674673    #endif 
     674 
    675675    ep_lib::MPI_Recv((recvIndexSrcBuff + receivedSize), 
    676676             recvBuffSize, 
     
    698698 
    699699  std::vector<ep_lib::MPI_Status> requestStatus(sendRequest.size()); 
    700   ep_lib::MPI_Status stat_ignore; 
    701   ep_lib::MPI_Waitall(sendRequest.size(), &sendRequest[0], &stat_ignore); 
     700  ep_lib::MPI_Waitall(sendRequest.size(), &sendRequest[0], &requestStatus[0]); 
    702701 
    703702  delete [] sendIndexDestBuff; 
     
    712711  
    713712/*! Redefined some functions of CONetCDF4 to make use of them */ 
    714 CDomainAlgorithmInterpolate::WriteNetCdf::WriteNetCdf(const StdString& filename, const MPI_Comm comm) 
     713CDomainAlgorithmInterpolate::WriteNetCdf::WriteNetCdf(const StdString& filename, const ep_lib::MPI_Comm comm) 
    715714  : CNc4DataOutput(NULL, filename, false, false, true, comm, false, true) {} 
    716715int CDomainAlgorithmInterpolate::WriteNetCdf::addDimensionWrite(const StdString& name,  
     
    803802  std::vector<StdSize> start(1, startIndex - localNbWeight); 
    804803  std::vector<StdSize> count(1, localNbWeight); 
    805  
    806   WriteNetCdf netCdfWriter(filename, static_cast<MPI_Comm>(client->intraComm.mpi_comm)); 
     804   
     805  WriteNetCdf netCdfWriter(filename, client->intraComm);   
    807806 
    808807  // Define some dimensions 
  • XIOS/dev/branch_openmp/src/transformation/domain_algorithm_interpolate.hpp

    r1205 r1328  
    99#ifndef __XIOS_DOMAIN_ALGORITHM_INTERPOLATE_HPP__ 
    1010#define __XIOS_DOMAIN_ALGORITHM_INTERPOLATE_HPP__ 
    11  
     11#include "mpi_std.hpp" 
    1212#include "domain_algorithm_transformation.hpp" 
    1313#include "transformation.hpp" 
    1414#include "nc4_data_output.hpp" 
    15 #ifdef _usingEP 
    16 #include "ep_declaration.hpp" 
    17 #endif 
    1815 
    1916namespace xios { 
     
    5956  { 
    6057  public: 
    61     WriteNetCdf(const StdString& filename, const MPI_Comm comm); 
     58    WriteNetCdf(const StdString& filename, const ep_lib::MPI_Comm comm); 
    6259    int addDimensionWrite(const StdString& name, const StdSize size = UNLIMITED_DIM); 
    6360    int addVariableWrite(const StdString& name, nc_type type, 
  • XIOS/dev/branch_openmp/src/transformation/generic_algorithm_transformation.cpp

    r1205 r1328  
    3030                                            CArray<double,1>& dataOut, 
    3131                                            std::vector<bool>& flagInitial, 
    32                                             bool ignoreMissingValue) 
     32                                            bool ignoreMissingValue, bool firstPass  ) 
    3333{ 
    3434  int nbLocalIndex = localIndex.size();    
  • XIOS/dev/branch_openmp/src/transformation/generic_algorithm_transformation.hpp

    r1076 r1328  
    6464    \param [in/out] flagInitial vector of boolean to mark the local index already initialized. True means there is a need for initalization 
    6565    \param [in] ignoreMissingValue don't count missing value in operation if this flag is true 
     66    \param [in] firstPass indicate if it is the first time the apply funtion is called for a same transformation, in order to make a clean initialization  
    6667  */ 
    6768  virtual void apply(const std::vector<std::pair<int,double> >& localIndex, 
     
    6970                     CArray<double,1>& dataOut, 
    7071                     std::vector<bool>& flagInitial,                      
    71                      bool ignoreMissingValue); 
     72                     bool ignoreMissingValue, bool firstPass); 
    7273 
    7374  /*! 
  • XIOS/dev/branch_openmp/src/transformation/grid_transformation.cpp

    r1203 r1328  
    453453    sendRankSizeMap[itIndex->first] = sendSize; 
    454454  } 
    455   MPI_Allgather(&connectedClient,1,MPI_INT,recvCount,1,MPI_INT,client->intraComm); 
     455  ep_lib::MPI_Allgather(&connectedClient,1,MPI_INT,recvCount,1,MPI_INT,client->intraComm); 
    456456 
    457457  displ[0]=0 ; 
     
    460460  int* recvRankBuff=new int[recvSize]; 
    461461  int* recvSizeBuff=new int[recvSize]; 
    462   MPI_Allgatherv(sendRankBuff,connectedClient,MPI_INT,recvRankBuff,recvCount,displ,MPI_INT,client->intraComm); 
    463   MPI_Allgatherv(sendSizeBuff,connectedClient,MPI_INT,recvSizeBuff,recvCount,displ,MPI_INT,client->intraComm); 
     462  ep_lib::MPI_Allgatherv(sendRankBuff,connectedClient,MPI_INT,recvRankBuff,recvCount,displ,MPI_INT,client->intraComm); 
     463  ep_lib::MPI_Allgatherv(sendSizeBuff,connectedClient,MPI_INT,recvSizeBuff,recvCount,displ,MPI_INT,client->intraComm); 
    464464  for (int i = 0; i < nbClient; ++i) 
    465465  { 
     
    473473 
    474474  // Sending global index of grid source to corresponding process as well as the corresponding mask 
    475   std::vector<ep_lib::MPI_Request> requests(2*recvRankSizeMap.size()+2*globaIndexWeightFromSrcToDst.size()); 
     475  std::vector<ep_lib::MPI_Request> requests(recvRankSizeMap.size()*2 + globaIndexWeightFromSrcToDst.size()*2); 
    476476  std::vector<ep_lib::MPI_Status> status; 
    477477  boost::unordered_map<int, unsigned char* > recvMaskDst; 
    478478  boost::unordered_map<int, unsigned long* > recvGlobalIndexSrc; 
    479   int position = 0; 
     479  int requests_position = 0; 
    480480  for (std::map<int,int>::const_iterator itRecv = recvRankSizeMap.begin(); itRecv != recvRankSizeMap.end(); ++itRecv) 
    481481  { 
     
    485485    recvGlobalIndexSrc[recvRank] = new unsigned long [recvSize]; 
    486486 
    487  
    488     MPI_Irecv(recvGlobalIndexSrc[recvRank], recvSize, MPI_UNSIGNED_LONG, recvRank, 46, client->intraComm, &requests[position]); 
    489     position++; 
    490  
    491     MPI_Irecv(recvMaskDst[recvRank], recvSize, MPI_UNSIGNED_CHAR, recvRank, 47, client->intraComm, &requests[position]); 
    492     position++; 
     487    ep_lib::MPI_Irecv(recvGlobalIndexSrc[recvRank], recvSize, MPI_UNSIGNED_LONG, recvRank, 46, client->intraComm, &requests[requests_position++]); 
     488    ep_lib::MPI_Irecv(recvMaskDst[recvRank], recvSize, MPI_UNSIGNED_CHAR, recvRank, 47, client->intraComm, &requests[requests_position++]); 
    493489  } 
    494490 
     
    525521 
    526522    // Send global index source and mask 
    527  
    528     MPI_Isend(sendGlobalIndexSrc[sendRank], sendSize, MPI_UNSIGNED_LONG, sendRank, 46, client->intraComm, &requests[position]); 
    529     position++; 
    530  
    531     MPI_Isend(sendMaskDst[sendRank], sendSize, MPI_UNSIGNED_CHAR, sendRank, 47, client->intraComm, &requests[position]); 
    532     position++; 
     523    ep_lib::MPI_Isend(sendGlobalIndexSrc[sendRank], sendSize, MPI_UNSIGNED_LONG, sendRank, 46, client->intraComm, &requests[requests_position++]); 
     524    ep_lib::MPI_Isend(sendMaskDst[sendRank], sendSize, MPI_UNSIGNED_CHAR, sendRank, 47, client->intraComm, &requests[requests_position++]); 
    533525  } 
    534526 
    535527  status.resize(requests.size()); 
    536   MPI_Waitall(requests.size(), &requests[0], &status[0]); 
     528  ep_lib::MPI_Waitall(requests.size(), &requests[0], &status[0]); 
    537529 
    538530  // Okie, now use the mask to identify which index source we need to send, then also signal the destination which masked index we will return 
    539   //std::vector<ep_lib::MPI_Request>().swap(requests); 
    540   //std::vector<ep_lib::MPI_Status>().swap(status); 
    541   requests.resize(sendRankSizeMap.size()+recvRankSizeMap.size()); 
    542   position = 0; 
     531  requests.resize(sendRankSizeMap.size() + recvRankSizeMap.size()); 
     532  requests_position = 0; 
     533  std::vector<ep_lib::MPI_Status>().swap(status); 
    543534  // Okie, on destination side, we will wait for information of masked index of source 
    544535  for (std::map<int,int>::const_iterator itSend = sendRankSizeMap.begin(); itSend != sendRankSizeMap.end(); ++itSend) 
     
    547538    int recvSize = itSend->second; 
    548539 
    549     MPI_Irecv(sendMaskDst[recvRank], recvSize, MPI_UNSIGNED_CHAR, recvRank, 48, client->intraComm, &requests[position]); 
    550     position++; 
     540    ep_lib::MPI_Irecv(sendMaskDst[recvRank], recvSize, MPI_UNSIGNED_CHAR, recvRank, 48, client->intraComm, &requests[requests_position++]); 
    551541  } 
    552542 
     
    584574 
    585575    // Okie, now inform the destination which source index are masked 
    586     MPI_Isend(recvMaskDst[recvRank], recvSize, MPI_UNSIGNED_CHAR, recvRank, 48, client->intraComm, &requests[position]); 
    587     position++; 
     576    ep_lib::MPI_Isend(recvMaskDst[recvRank], recvSize, MPI_UNSIGNED_CHAR, recvRank, 48, client->intraComm, &requests[requests_position++]); 
    588577  } 
    589578  status.resize(requests.size()); 
    590   MPI_Waitall(requests.size(), &requests[0], &status[0]); 
     579  ep_lib::MPI_Waitall(requests.size(), &requests[0], &status[0]); 
    591580 
    592581  // Cool, now we can fill in local index of grid destination (counted for masked index) 
  • XIOS/dev/branch_openmp/src/transformation/grid_transformation.hpp

    r978 r1328  
    1212#include <map> 
    1313#include <vector> 
     14#include "mpi_std.hpp" 
    1415#include "generic_algorithm_transformation.hpp" 
    1516#include "transformation_enum.hpp" 
  • XIOS/dev/branch_openmp/src/transformation/grid_transformation_factory_impl.hpp

    r1134 r1328  
    5757  typedef std::map<ETranformationType, CreateTransformationCallBack> CallBackMap; 
    5858  static CallBackMap* transformationCreationCallBacks_; 
    59   #pragma omp threadprivate(transformationCreationCallBacks_) 
    60    
    6159  static bool registerTransformation(ETranformationType transType, CreateTransformationCallBack createFn); 
    6260  static bool unregisterTransformation(ETranformationType transType); 
    6361  static bool initializeTransformation_; 
    64   #pragma omp threadprivate(initializeTransformation_) 
    6562}; 
    6663 
     
    8279                                                                               std::map<int, int>& elementPositionInGridDst2DomainPosition) 
    8380{ 
    84   if (0 == transformationCreationCallBacks_) 
    85     transformationCreationCallBacks_ = new CallBackMap(); 
    8681  typename CallBackMap::const_iterator it = (*transformationCreationCallBacks_).find(transType); 
    8782  if ((*transformationCreationCallBacks_).end() == it) 
  • XIOS/dev/branch_openmp/src/transformation/grid_transformation_selector.cpp

    r1106 r1328  
    1010#include "grid.hpp" 
    1111#include "algo_types.hpp" 
     12using namespace ep_lib; 
    1213 
    1314namespace xios { 
  • XIOS/dev/branch_openmp/src/transformation/grid_transformation_selector.hpp

    r978 r1328  
    1212#include <map> 
    1313#include <vector> 
     14#include "mpi_std.hpp" 
    1415#include "generic_algorithm_transformation.hpp" 
    1516#include "transformation_enum.hpp" 
  • XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_extract_axis.cpp

    r1155 r1328  
    1414#include "grid_transformation_factory_impl.hpp" 
    1515 
    16  
     16#include "reduction.hpp" 
    1717 
    1818namespace xios { 
     
    4949  StdString op = "extract"; 
    5050  pos_ = algo->position; 
    51    
    52   if(CReductionAlgorithm::ReductionOperations_ptr == 0)  
    53     CReductionAlgorithm::initReductionOperation(); 
    54    
    55   reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]); 
     51  //reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 
     52  reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations_ptr->at(op)); 
    5653} 
    5754 
     
    6057                                         CArray<double,1>& dataOut, 
    6158                                         std::vector<bool>& flagInitial,                      
    62                                          bool ignoreMissingValue) 
     59                                         bool ignoreMissingValue, bool firstPass) 
    6360{ 
    64   reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue); 
     61  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 
    6562} 
    6663 
  • XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_extract_axis.hpp

    r1155 r1328  
    1212#include "scalar_algorithm_transformation.hpp" 
    1313#include "transformation.hpp" 
    14 #include "reduction.hpp" 
    1514 
    1615namespace xios { 
     
    2524  Extract a scalar from an axis 
    2625*/ 
    27 class CScalarAlgorithmExtractAxis : public CScalarAlgorithmTransformation, public CReductionAlgorithm 
     26class CScalarAlgorithmExtractAxis : public CScalarAlgorithmTransformation 
    2827{ 
    2928public: 
     
    3433                     CArray<double,1>& dataOut, 
    3534                     std::vector<bool>& flagInitial,                      
    36                      bool ignoreMissingValue); 
     35                     bool ignoreMissingValue, bool firstPass); 
    3736 
    3837  virtual ~CScalarAlgorithmExtractAxis(); 
  • XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_reduce_axis.cpp

    r1155 r1328  
    1313#include "grid.hpp" 
    1414#include "grid_transformation_factory_impl.hpp" 
     15#include "reduction.hpp" 
     16 
     17#include "reduction.hpp" 
    1518 
    1619namespace xios { 
    17  
    18 //extern std::map<StdString,EReductionType> *CReductionAlgorithm::ReductionOperations_ptr;  
    19 //#pragma omp threadprivate(CReductionAlgorithm::ReductionOperations_ptr) 
    20  
    2120CGenericAlgorithmTransformation* CScalarAlgorithmReduceAxis::create(CGrid* gridDst, CGrid* gridSrc, 
    2221                                                                     CTransformation<CScalar>* transformation, 
     
    7675  } 
    7776   
    78   if(CReductionAlgorithm::ReductionOperations_ptr == 0)  
    79     CReductionAlgorithm::initReductionOperation(); 
    80    
    81   if ((*CReductionAlgorithm::ReductionOperations_ptr).end() == (*CReductionAlgorithm::ReductionOperations_ptr).find(op)) 
     77  //if (CReductionAlgorithm::ReductionOperations.end() == CReductionAlgorithm::ReductionOperations.find(op)) 
     78  if (CReductionAlgorithm::ReductionOperations_ptr->end() == CReductionAlgorithm::ReductionOperations_ptr->find(op)) 
    8279    ERROR("CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)", 
    8380       << "Operation '" << op << "' not found. Please make sure to use a supported one" 
     
    8582       << "Scalar destination " << scalarDestination->getId()); 
    8683 
    87   reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]); 
     84  //reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 
     85  reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations_ptr->at(op)); 
    8886} 
    8987 
    90 void CScalarAlgorithmReduceAxis::apply(const std::vector<std::pair<int,double> >& localIndex, 
    91                                          const double* dataInput, 
    92                                          CArray<double,1>& dataOut, 
    93                                          std::vector<bool>& flagInitial, 
    94                                        bool ignoreMissingValue) 
     88void CScalarAlgorithmReduceAxis::apply(const std::vector<std::pair<int,double> >& localIndex, const double* dataInput, CArray<double,1>& dataOut, 
     89                                         std::vector<bool>& flagInitial, bool ignoreMissingValue, bool firstPass) 
    9590{ 
    96   reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue); 
     91  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 
    9792} 
    9893 
     
    115110  TransformationWeightMap& transWeight = this->transformationWeight_[0]; 
    116111 
    117   CArray<int,1>& axisSrcIndex = axisSrc_->index; 
    118   int globalIndexSize = axisSrcIndex.numElements(); 
     112  int globalIndexSize = axisSrc_-> n_glo; 
    119113 
    120114  for (int idx = 0; idx < globalIndexSize; ++idx) 
    121115  { 
    122     transMap[0].push_back(axisSrcIndex(idx)); 
     116    transMap[0].push_back(idx); 
    123117    transWeight[0].push_back(1.0); 
    124118  } 
  • XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_reduce_axis.hpp

    r1155 r1328  
    1212#include "scalar_algorithm_transformation.hpp" 
    1313#include "transformation.hpp" 
    14 #include "reduction.hpp" 
    1514 
    1615namespace xios { 
     
    2524  Reducing an axis to a scalar 
    2625*/ 
    27 class CScalarAlgorithmReduceAxis : public CScalarAlgorithmTransformation, public CReductionAlgorithm 
     26class CScalarAlgorithmReduceAxis : public CScalarAlgorithmTransformation 
    2827{ 
    2928public: 
     
    3433                     CArray<double,1>& dataOut, 
    3534                     std::vector<bool>& flagInitial, 
    36                      bool ignoreMissingValue); 
     35                     bool ignoreMissingValue, bool firstPass); 
    3736 
    3837  virtual void updateData(CArray<double,1>& dataOut); 
  • XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_reduce_domain.cpp

    r1155 r1328  
    1414#include "grid_transformation_factory_impl.hpp" 
    1515 
    16  
     16#include "reduction.hpp" 
    1717 
    1818namespace xios { 
     
    6868 
    6969  } 
     70   
     71  // if(CReductionAlgorithm::ReductionOperations_ptr == 0)  
     72  //   CReductionAlgorithm::initReductionOperation(); 
    7073 
    71   if(CReductionAlgorithm::ReductionOperations_ptr == 0)  
    72     CReductionAlgorithm::initReductionOperation(); 
    73  
    74   if ((*CReductionAlgorithm::ReductionOperations_ptr).end() == (*CReductionAlgorithm::ReductionOperations_ptr).find(op)) 
     74  //if (CReductionAlgorithm::ReductionOperations.end() == CReductionAlgorithm::ReductionOperations.find(op)) 
     75  if (CReductionAlgorithm::ReductionOperations_ptr->end() == CReductionAlgorithm::ReductionOperations_ptr->find(op)) 
    7576    ERROR("CScalarAlgorithmReduceDomain::CScalarAlgorithmReduceDomain(CDomain* domainDestination, CDomain* domainSource, CReduceDomainToScalar* algo)", 
    7677       << "Operation '" << op << "' not found. Please make sure to use a supported one" 
     
    7879       << "Scalar destination " << scalarDestination->getId()); 
    7980 
    80   reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]); 
     81  //reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 
     82  reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations_ptr->at(op)); 
    8183} 
    8284 
     
    8587                                         CArray<double,1>& dataOut, 
    8688                                         std::vector<bool>& flagInitial,                      
    87                                          bool ignoreMissingValue) 
     89                                         bool ignoreMissingValue, bool firstPass) 
    8890{ 
    89   reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue); 
     91  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 
    9092} 
    9193 
  • XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_reduce_domain.hpp

    r1155 r1328  
    1212#include "scalar_algorithm_transformation.hpp" 
    1313#include "transformation.hpp" 
    14 #include "reduction.hpp" 
    1514 
    1615namespace xios { 
     
    2524  Reducing an DOMAIN to a scalar 
    2625*/ 
    27 class CScalarAlgorithmReduceDomain : public CScalarAlgorithmTransformation, public CReductionAlgorithm 
     26class CScalarAlgorithmReduceDomain : public CScalarAlgorithmTransformation 
    2827{ 
    2928public: 
     
    3433                     CArray<double,1>& dataOut, 
    3534                     std::vector<bool>& flagInitial,                      
    36                      bool ignoreMissingValue); 
     35                     bool ignoreMissingValue, bool firstPass); 
    3736 
    3837  virtual void updateData(CArray<double,1>& dataOut); 
  • XIOS/dev/branch_openmp/src/type/type.hpp

    r1134 r1328  
    9494    const CType_ref& operator = (CType<T>& val) const ; 
    9595    const CType_ref& operator = (const CType_ref& val) const; 
    96     operator T&() const; 
     96    operator T&() const;     
    9797 
    9898    inline virtual CBaseType* clone(void) const   { return _clone(); } 
  • XIOS/dev/branch_openmp/src/xios.hpp

    r591 r1328  
    55 
    66/// XIOS headers /// 
    7 #include "nc4_data_output.hpp" 
     7#include "data_output.hpp" 
     8//#include "nc4_data_output.hpp" 
    89 
    910 
    1011using namespace xios; 
    11 using namespace xios::xml; 
    12 using namespace xios::func; 
     12//using namespace xios::xml; 
     13//using namespace xios::func; 
    1314 
    1415#endif //__XIOS__ 
  • XIOS/dev/branch_openmp/src/xios_server.f90

    r1134 r1328  
    11PROGRAM server_main 
    22  USE xios 
    3   USE mod_wait 
    43  IMPLICIT NONE 
    54  INCLUDE "mpif.h" 
    6   INTEGER :: ierr, th_level 
    7      
    8     CALL MPI_INIT(ierr) 
    9     !CALL MPI_INIT_thread(3, th_level, ierr) 
    10     CALL init_wait 
     5  INTEGER :: ierr 
     6   
    117    CALL xios_init_server 
    12      
    13     CALL MPI_FINALIZE(ierr) 
    148 
    159  END PROGRAM server_main 
Note: See TracChangeset for help on using the changeset viewer.