source: issm/oecreview/Archive/19101-20495/ISSM-20043-20044.diff

Last change on this file was 20498, checked in by Mathieu Morlighem, 9 years ago

CHG: done with Archive/19101-20495

File size: 2.0 KB
  • ../trunk-jpl/src/c/analyses/SealevelriseAnalysis.cpp

     
    7070                iomodel->FetchData(&degacc,SealevelriseDegaccEnum);
    7171                M=reCast<int,IssmDouble>(180./degacc+1.);
    7272                G_elastic=xNew<IssmDouble>(M);
     73               
     74                /*compute combined legendre + love number (elastic green function:*/
     75                #ifdef _HAVE_ADOLC_
     76                for(int i=0;i<M;i++){
     77                        IssmDouble alpha,x;
     78                        alpha= reCast<IssmDouble>(i)*degacc * PI / 180.0;
    7379
    74                 /*compute combined legendre + love number (elastic green function:*/
     80                        G_elastic[i]= (love_k[nl-1]-love_h[nl-1])/2.0/sin(alpha/2.0);
     81                        for (int n=0;n<nl;n++) {
     82                                IssmDouble Pn,Pn1,Pn2;
     83                                IssmDouble deltalove;
     84
     85                                deltalove = (love_k[n]-love_k[nl-1]-love_h[n]+love_h[nl-1]);
     86
     87                                if(n==0)Pn=1;
     88                                else if(n==1)Pn=cos(alpha);
     89                                else Pn= ( (2*n-1)*cos(alpha)*Pn1 - (n-1)*Pn2 ) /n;
     90                                Pn2=Pn1; Pn1=Pn;
     91
     92                                G_elastic[i] += deltalove*Pn;
     93                        }
     94                }
     95                #else
    7596                m=DetermineLocalSize(M,IssmComm::GetComm());
    7697                GetOwnershipBoundariesFromRange(&lower_row,&upper_row,m,IssmComm::GetComm());
    7798                G_elastic_local=xNew<IssmDouble>(m);
     
    113134                xDelete<int>(displs);
    114135
    115136                /*}}}*/
     137                #endif
    116138
    117                 /*Old code: {{{*/
    118                 /*for(int i=0;i<M;i++){
    119                         IssmDouble alpha,x;
    120                         alpha= reCast<IssmDouble>(i)*degacc * PI / 180.0;
    121 
    122                         G_elastic[i]= (love_k[nl-1]-love_h[nl-1])/2.0/sin(alpha/2.0);
    123                         for (int n=0;n<nl;n++) {
    124                                 IssmDouble Pn,Pn1,Pn2;
    125                                 IssmDouble deltalove;
    126 
    127                                 deltalove = (love_k[n]-love_k[nl-1]-love_h[n]+love_h[nl-1]);
    128 
    129                                 if(n==0)Pn=1;
    130                                 else if(n==1)Pn=cos(alpha);
    131                                 else Pn= ( (2*n-1)*cos(alpha)*Pn1 - (n-1)*Pn2 ) /n;
    132                                 Pn2=Pn1; Pn1=Pn;
    133 
    134                                 G_elastic[i] += deltalove*Pn;
    135                         }
    136                 }*/
    137                 /*}}}*/
    138 
    139139                /*Avoid singularity at 0: */
    140140                G_elastic[0]=G_elastic[1];
    141141                parameters->AddObject(new DoubleVecParam(SealevelriseGElasticEnum,G_elastic,M));
Note: See TracBrowser for help on using the repository browser.