Changeset 18479


Ignore:
Timestamp:
09/02/14 16:35:51 (11 years ago)
Author:
abuzzi
Message:

CHG: final version parallelized code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/contrib/gravity/vfsa_mpi.cpp

    r18473 r18479  
    147147
    148148        /* Seed the random number generator {{{*/
    149         srand (time(NULL));               /*}}}*/
     149                srand (time(NULL));            /*}}}*/
    150150        /* Define the variables {{{*/
    151151
     
    444444        int    M,N;
    445445        double chisq;
    446 
    447446        /*Get system size*/
    448447        A->GetSize(&M,&N);
     
    533532
    534533        double *glocal=new double[n]();
    535         double *gcalc=new double[n]();
    536534
    537535        for(int c=my_rank;c<n;c+=num_procs){
     
    567565                                        si*=-1;
    568566                                        for(int j=0;j<2;j++){
    569                                                 si*=-1;
     567                                                sj*=-1;
    570568                                                s=si*sj;
    571569                                                for(int k=0;k<l;k++){
     
    588586        }
    589587
    590         MPI_Allreduce(glocal,gcalc,n,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
    591         if(!my_rank){for(int c=0;c<n;c++){
    592                 g->SetValue(c,0,gcalc[c]);
    593         }
    594         }
     588        MPI_Allreduce(glocal,g->GetPointer(),n,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
    595589
    596590        delete xp;
     
    603597        delete U2;
    604598        delete []glocal;
    605         delete []gcalc;
    606599}/*}}}*/
    607600void vec2gridsimple(Matrix *V,Matrix *V1,int nx, int ny){/*{{{*/
Note: See TracChangeset for help on using the changeset viewer.