source: issm/oecreview/Archive/18296-19100/ISSM-18478-18479.diff

Last change on this file was 19102, checked in by Mathieu Morlighem, 10 years ago

NEW: added 18296-19100

File size: 1.6 KB
  • ../trunk-jpl/src/m/contrib/gravity/vfsa_mpi.cpp

     
    146146        MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);
    147147
    148148        /* Seed the random number generator {{{*/
    149         srand (time(NULL));               /*}}}*/
     149                srand (time(NULL));            /*}}}*/
    150150        /* Define the variables {{{*/
    151151
    152152        int    dx     = 500;   /* prism dimension in x-direction                           */
     
    443443        /*GSL Matrices and vectors: */
    444444        int    M,N;
    445445        double chisq;
    446 
    447446        /*Get system size*/
    448447        A->GetSize(&M,&N);
    449448
     
    532531        bool test=true;
    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){
    538536                glocal[c]=0;
     
    566564                                for(int i=0;i<2;i++){
    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++){
    572570                                                        R=sqrt(xp->GetValue(0,i)*xp->GetValue(0,i)+yp->GetValue(0,j)*yp->GetValue(0,j)+mesh->GetValue(a,k)*mesh->GetValue(a,k));
     
    587585                }
    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;
    597591        delete yp;
     
    602596        delete U1;
    603597        delete U2;
    604598        delete []glocal;
    605         delete []gcalc;
    606599}/*}}}*/
    607600void vec2gridsimple(Matrix *V,Matrix *V1,int nx, int ny){/*{{{*/
    608601        for(int i=0;i<ny;i++){
Note: See TracBrowser for help on using the repository browser.