#Mac上PETSc安装问题
##安装流程
-
Download and install MPICH.
-
Download and unzip/untar the PETSc package to /usr/local/petsc/ (or wherever you want to put PETSc). Unzip/untar the download from /usr/local/petsc/ as follows:
sudo gunzip -c petsc.tar.gz | sudo tar -xof -
-
Set the PETSC_DIR and PETSC_ARCH environmental variables. This can be done by adding the following lines to
~/.bash_profile
set environmental variables for PETSc
export PETSC_DIR=/usr/local/petsc/petsc-x.xx.x/
export PETSC_ARCH=arch-darwin-c-opt
Don’t forget to
source ~/.bash_profile
after making the change. -
From within the PETSc directory, run the configure script with flags to use gcc, g++, f77, and the BLAS and LAPACK libraries included in Apple’s vecLib:
sudo python ./config/configure.py --with-blas-lapack-lib="-framework accelerate" --with-mpi-dir=/usr/local/opt/mpich
-
Build with the debug C++/gfortran target and run the test script:
sudo make BOPT=g_c++sudo make BOPT=g_c++ test
-
Build and test with whatever other targets you want, e.g. the optimized C++/gfortran target
BOPT=O_c++
, the debug C/gfortran targetBOPT=g
, or the optimized C/gfortran targetBOPT=O
.
注意事项
blas和lapack库包含在OS X的Accelerate Framework中,所以无需另外安装blas和lapack库。
##pyhyp安装
这样安装貌似pyhyp用不了,没有petscvec.h90
文件,只有petscvec.h
文件。重新按照pyhyp的方法安装试试。
sudo ./configure --with-shared-libraries --download-superlu_dist=yes --download-parmetis=yes --download-metis=yes --with-fortran-interfaces=1 --with-debuggig=no --with-scalar-type=real --with-cxx-dialect=C++11 --PETSC_ARCH=real-opt
Mac上最简单的安装方法是直接brew install petsc
。
PETSc v3.8以后,不再需要在fortran文件中include任何.h90文件了,
For each Fortran function (and main) use the following
subroutine mysubroutine(.....)
#include <petsc/finclude/petscxxx.h>
use petscxxx
implicit none
make之前,需要在config.mk中设置CGNS_VERSION_FLAG
,默认没有给值,会导致编译又问题,提示找不到cgnslib_h.f
。解决办法为设置flag的值:CGNS_VERSION_FLAG=-DUSECGNSMODULE
。
Instead of PETSC_NULL_OBJECT
you must pass PETSC_NULL_XXX
(for example PETSC_NULL_VEC
) using the specific object type XXX that the function call is expecting.
Installing PETSc 2.2.1 on Mac OS X 10.3
Compile Fortran source with Accelerate Framework (LAPACK and BLAS)