Changeset 9826


Ignore:
Timestamp:
09/16/11 16:35:08 (14 years ago)
Author:
Mathieu Morlighem
Message:

Added support for petsc 3.2

Location:
issm/trunk
Files:
1 added
17 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/configs/astrid/configure.sh

    r8252 r9826  
    1212 --with-petsc-dir=$ISSM_TIER/externalpackages/petsc/install \
    1313 --with-petsc-version=3 \
     14 --with-tao-dir=$ISSM_TIER/externalpackages/tao/install \
    1415 --with-mpi-include=$ISSM_TIER/externalpackages/mpich2/install/include  \
    1516 --with-mpi-lib="-L$ISSM_TIER/externalpackages/mpich2/install/lib/ -lmpich " \
  • issm/trunk/m4/issm_options.m4

    r9812 r9826  
    342342        AC_ARG_WITH([petsc-version],
    343343                          AS_HELP_STRING([--with-petsc-version = VERSION],
    344                                                          [petsc version -- 2 or 3]),
     344                                                         [petsc version -- 3.1 or 3.2]),
    345345                          [PETSC_VERSION=$withval],[PETSC_VERSION=""])
     346
     347        dnl [morlighe@astrid m4]$ echo 3.2 | sed -e 's/3\..*//'
     348        dnl [morlighe@astrid m4]$ echo 3.2 | sed -e 's/3\.//'
    346349
    347350        if test "$PARALLEL_VALUE" = "yes" ; then
     
    349352                        AC_MSG_ERROR([missing --with-petsc-version argument for parallel compilation!])
    350353                fi
    351                 if test "$PETSC_VERSION" = "2" ; then
    352                 AC_DEFINE([_PETSC_VERSION_],[2],[ Petsc version number])
    353                 fi
    354 
     354                if test "$PETSC_VERSION" = "2.3" ; then
     355                        AC_DEFINE([_PETSC_MAJOR_],[2],[ Petsc version major])
     356                        AC_DEFINE([_PETSC_MINOR_],[3],[ Petsc version minor])
     357                fi
    355358                if test "$PETSC_VERSION" = "3" ; then
    356                 AC_DEFINE([_PETSC_VERSION_],[3],[ Petsc version number])
     359                        AC_DEFINE([_PETSC_MAJOR_],[3],[ Petsc version major])
     360                        AC_DEFINE([_PETSC_MINOR_],[1],[ Petsc version minor])
     361                fi
     362                if test "$PETSC_VERSION" = "3.1" ; then
     363                        AC_DEFINE([_PETSC_MAJOR_],[3],[ Petsc version major])
     364                        AC_DEFINE([_PETSC_MINOR_],[1],[ Petsc version minor])
     365                fi
     366                if test "$PETSC_VERSION" = "3.2" ; then
     367                        AC_DEFINE([_PETSC_MAJOR_],[3],[ Petsc version major])
     368                        AC_DEFINE([_PETSC_MINOR_],[2],[ Petsc version minor])
    357369                fi
    358370        fi
  • issm/trunk/src/c/modules/Solverx/DofTypesToIndexSet.cpp

    r9320 r9826  
    6464               
    6565                /*Create indices sets: */
     66                #if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
    6667                ISCreateGeneral(PETSC_COMM_WORLD,pressure_num,pressure_indices,&isp);
    6768                ISCreateGeneral(PETSC_COMM_WORLD,velocity_num,velocity_indices,&isv);
     69                #else
     70                ISCreateGeneral(PETSC_COMM_WORLD,pressure_num,pressure_indices,PETSC_COPY_VALUES,&isp);
     71                ISCreateGeneral(PETSC_COMM_WORLD,velocity_num,velocity_indices,PETSC_COPY_VALUES,&isv);
     72                #endif
     73        }
    6874
    69         }
    7075        /*Free ressources:*/
    7176        xfree((void**)&pressure_indices);
    7277        xfree((void**)&velocity_indices);
    73 
    7478
    7579        /*Assign output pointers:*/
  • issm/trunk/src/c/modules/Solverx/Solverx.cpp

    r9761 r9826  
    2727        PC         pc               = NULL;
    2828        int        iteration_number;
    29         PetscTruth flag;
    3029        int        solver_type;
    3130        bool       fromlocalsize    = true;
     31        #if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
     32        PetscTruth flag,flg;
     33        #else
     34        PetscBool flag,flg;
     35        #endif
     36
    3237        /*stokes: */
    3338        IS         isv=NULL;
    3439        IS         isp=NULL;
    3540
    36         #if _PETSC_VERSION_ == 3
     41        #if _PETSC_MAJOR_ >= 3
    3742        char ksp_type[50];
    38         PetscTruth flg;
    3943        #endif
    4044
     
    4246        /*Display message*/
    4347        _printf_(VerboseModule(),"   Solving\n");
     48        #if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
    4449        if(VerboseSolver())PetscOptionsPrint(stdout);
     50        #else
     51        PetscViewer *v=NULL;
     52        PetscViewerCreate(PETSC_COMM_SELF,v);
     53        if(VerboseSolver())PetscOptionsView(*v);
     54        #endif
    4555
    4656        /*First, check that f-set is not NULL, ie model is fully constrained: {{{*/
     
    5363        /*Initial guess logic here: {{{1*/
    5464        /*Now, check that we are not getting an initial guess to the solver, if we are running a direct solver: */
    55         #if _PETSC_VERSION_ == 3
     65        #if _PETSC_MAJOR_ >= 3
    5666        PetscOptionsGetString(PETSC_NULL,"-ksp_type",ksp_type,49,&flg);
    5767        if (strcmp(ksp_type,"preonly")==0)uf0=NULL;
     
    7383         We need to convert them if we are going to run the solvers successfully: */
    7484        #ifdef _SERIAL_
    75         #if _PETSC_VERSION_ == 2
     85        #if _PETSC_MAJOR_ == 2
    7686        if (solver_type==MUMPSPACKAGE_LU){
    7787                /*Convert Kff to MATTAIJMUMPS: */
  • issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp

    r9761 r9826  
    6868                MatAssemblyBegin(Kff,MAT_FINAL_ASSEMBLY);
    6969                MatAssemblyEnd(Kff,MAT_FINAL_ASSEMBLY);
    70                 #if _PETSC_VERSION_ == 2
     70                #if _PETSC_MAJOR_ == 2
    7171                MatCompress(Kff);
    7272                #endif
     
    7474                MatAssemblyBegin(Kfs,MAT_FINAL_ASSEMBLY);
    7575                MatAssemblyEnd(Kfs,MAT_FINAL_ASSEMBLY);
    76                 #if _PETSC_VERSION_ == 2
     76                #if _PETSC_MAJOR_ == 2
    7777                MatCompress(Kfs);
    7878                #endif
     
    117117                MatAssemblyBegin(Kff,MAT_FINAL_ASSEMBLY);
    118118                MatAssemblyEnd(Kff,MAT_FINAL_ASSEMBLY);
    119                 #if _PETSC_VERSION_ == 2
     119                #if _PETSC_MAJOR_ == 2
    120120                MatCompress(Kff);
    121121                #endif
     
    123123                MatAssemblyBegin(Kfs,MAT_FINAL_ASSEMBLY);
    124124                MatAssemblyEnd(Kfs,MAT_FINAL_ASSEMBLY);
    125                 #if _PETSC_VERSION_ == 2
     125                #if _PETSC_MAJOR_ == 2
    126126                MatCompress(Kfs);
    127127                #endif
  • issm/trunk/src/c/shared/Numerics/PetscOptionsFromAnalysis.cpp

    r9561 r9826  
    6666         *capability is not covered by Petsc!: */
    6767
    68         #if _PETSC_VERSION_ == 2
     68        #if _PETSC_MAJOR_ == 2
    6969        PetscOptionsDestroy();
    7070        PetscOptionsCreate();
  • issm/trunk/src/c/toolkits/petsc/patches/ISFree.cpp

    r9320 r9826  
    1717void ISFree(IS* pis){
    1818
     19        #if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
    1920        if(*pis)ISDestroy(*pis);
    2021        *pis=NULL;
     22        #else
     23        if(*pis)ISDestroy(pis);
     24        *pis=NULL;
     25        #endif
    2126
    2227}
  • issm/trunk/src/c/toolkits/petsc/patches/KSPFree.cpp

    r9320 r9826  
    1717void KSPFree(KSP* pksp){
    1818
     19        #if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
    1920        if(*pksp)KSPDestroy(*pksp);
    2021        *pksp=NULL;
     22        #else
     23        if(*pksp)KSPDestroy(pksp);
     24        *pksp=NULL;
     25        #endif
    2126
    2227}
  • issm/trunk/src/c/toolkits/petsc/patches/MatFree.cpp

    r9320 r9826  
    1717void MatFree(Mat* pmat){
    1818
     19        #if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
    1920        if(*pmat)MatDestroy(*pmat);
    2021        *pmat=NULL;
     22        #else
     23        if(*pmat)MatDestroy(pmat);
     24        *pmat=NULL;
     25        #endif
    2126
    2227}
  • issm/trunk/src/c/toolkits/petsc/patches/MatInvert.cpp

    r6412 r9826  
    6565        MatFree(&identity);
    6666        VecFree(&diagonal);
     67        #if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
    6768        KSPDestroy(ksp);
     69        #else
     70        KSPDestroy(&ksp);
     71        #endif
    6872
    6973        /*Assign output pointers:*/
  • issm/trunk/src/c/toolkits/petsc/patches/MatMultPatch.cpp

    r9320 r9826  
    3434                VecRelocalize(&X_rel,X,n);
    3535                MatMult(A,X_rel,AX); ;
    36                 VecDestroy(X_rel);;
     36                #if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
     37                VecDestroy(X_rel);
     38                #else
     39                VecDestroy(&X_rel);
     40                #endif
    3741        }
    3842}
  • issm/trunk/src/c/toolkits/petsc/patches/MatPartition.cpp

    r9320 r9826  
    7979               
    8080                /*Now each node has a node_rows vectors holding which rows they should extract from matrixA. Create an Index Set from node_rows.*/
     81                #if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
    8182                ISCreateGeneral(MPI_COMM_WORLD,count,node_rows,&row_index);
     83                #else
     84                ISCreateGeneral(MPI_COMM_WORLD,count,node_rows,PETSC_COPY_VALUES,&row_index);
     85                #endif
    8286               
    8387                /*Same deal for columns*/
     
    8690                        *(node_cols+i)=(int)*(col_partition_vector+i)-1;
    8791                }
     92                #if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
    8893                ISCreateGeneral(MPI_COMM_WORLD,col_partition_vector_size,node_cols,&col_index);
     94                #else
     95                ISCreateGeneral(MPI_COMM_WORLD,col_partition_vector_size,node_cols,PETSC_COPY_VALUES,&col_index);
     96                #endif
    8997
    9098                /*Call MatGetSubMatrix*/
    9199                csize=PetscDetermineLocalSize(col_partition_vector_size);
    92100                if(col_partition_vector_size==row_partition_vector_size){
    93                         #if _PETSC_VERSION_ == 3
     101                        #if _PETSC_MAJOR_ >= 3
    94102                        MatGetSubMatrix(matrixA,row_index,col_index,MAT_INITIAL_MATRIX,&outmatrix);
    95103                        #else
     
    98106                }
    99107                else{
    100                         #if _PETSC_VERSION_ == 3
     108                        #if _PETSC_MAJOR_ >= 3
    101109                        MatGetSubMatrix(matrixA,row_index,col_index,MAT_INITIAL_MATRIX,&outmatrix);
    102110                        #else
  • issm/trunk/src/c/toolkits/petsc/patches/NewMat.cpp

    r9320 r9826  
    7878        int    nnz;
    7979
    80         #if _PETSC_VERSION_ == 3
     80        #if _PETSC_MAJOR_ >= 3
    8181        const MatType type;
    8282        #else
     
    9999        MatGetType(outmatrix,&type);
    100100       
    101         #if _PETSC_VERSION_ == 2
     101        #if _PETSC_MAJOR_ == 2
    102102        if((strcmp(type,"mpiaij")==0) || (strcmp(type,"aijmumps")==0)){
    103103                MatMPIAIJSetPreallocation(outmatrix,d_nz,NULL,o_nz,NULL);
  • issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsDetermineSolverType.cpp

    r9320 r9826  
    2222
    2323        char option[100];
     24   #if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
    2425        PetscTruth flag;
     26        #else
     27        PetscBool flag;
     28        #endif
    2529
    2630        /*output: */
  • issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp

    r9320 r9826  
    2323
    2424        /*The list of options is going to be pairs of the type "-option option_value"*/
    25         #if _PETSC_VERSION_ == 2
     25        #if _PETSC_MAJOR_ == 2
    2626                PetscToken *token=NULL ;
    2727        #else
  • issm/trunk/src/c/toolkits/petsc/patches/VecFree.cpp

    r9320 r9826  
    1717void VecFree(Vec* pvec){
    1818
     19        #if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
    1920        if(*pvec)VecDestroy(*pvec);
     21        #else
     22        if(*pvec)VecDestroy(pvec);
     23        #endif
    2024        *pvec=NULL;
    2125
  • issm/trunk/src/mex/Solver/Solver.cpp

    r8910 r9826  
    1616        int         analysis_type;
    1717        char        option[100];
     18        #if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
    1819        PetscTruth  flag;
     20        #else
     21        PetscBool flag;
     22        #endif
    1923       
    2024        /*Matlab solver: */
Note: See TracChangeset for help on using the changeset viewer.