Skip to content

Instantly share code, notes, and snippets.

@appleparan
Last active July 5, 2018 08:12
Show Gist options
  • Save appleparan/494cd0ffcc21a492a547d74ef8098c08 to your computer and use it in GitHub Desktop.
Save appleparan/494cd0ffcc21a492a547d74ef8098c08 to your computer and use it in GitHub Desktop.
Instruction: how to compile PETSc and install it
  • $ means shell prompt
  1. Install gcc

    1. go to ~/src
    $ cd ~/src
    
    1. install gcc (for cmake, takes few HOURS)
    $ mkdir gcc_src
    $ cd gcc_src
    $ curl -L -O http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-7.3.0/gcc-7.3.0.tar.gz
    $ tar zxvf gcc-7.3.0
    $ mkdir objdir 
    $ cd gcc-7.3.0
    $ contrib/download_prerequisites
    $ cd ../objdir
    $ ../gcc-7.3.0/configure --prefix=$HOME/usr/local/gcc --disable-multilib
    $ make && make install
    

    update PATH and LD_LIBRARY_PATH to ~/.bashrc, but don't modify original export just append additional paths

    export LD_LIBRARY_PATH=$HOME/usr/lib:$HOME/usr/local/gcc/lib64:$HOME/usr/local/gcc/lib:$LD_LIBRARY_PATH
    export PATH=$HOME/usr/bin:$HOME/usr/local/gcc/bin:$PATH
    

    then restart remote shell or use source command

    source ~/.bashrc
    

    Check gcc is properly installed

    gcc --version
    
  2. Install cURL

    $ cd ~/src
    $ curl -L -O https://curl.haxx.se/download/curl-7.60.0.tar.gz
    $ tar zxvf curl-7.60.0.tar.gz
    $ cd curl-7.60.0
    $ ./configure --prefix=$HOME/usr 
    $ make && make install
    

    update PATH and LD_LIBRARY_PATH to ~/.bashrc, but don't modify original export just append additional paths

    export LD_LIBRARY_PATH=$HOME/usr/lib:$HOME/usr/local/gcc/lib64:$HOME/usr/local/gcc/lib:$LD_LIBRARY_PATH
    export PATH=$HOME/usr/bin:$HOME/usr/local/gcc/bin:$PATH
    

    then restart remote shell or use source command

    source ~/.bashrc
    
  3. Install CMAKE

    $ curl -L -O https://cmake.org/files/v3.10/cmake-3.10.3.tar.gz
    $ tar zxvf cmake-3.10.3.tar.gz
    $ cd cmake-3.10.3
    $ ./bootstrap --prefix=$HOME/usr/local/cmake
    $ make && make install
    

    update PATH and LD_LIBRARY_PATH to ~/.bashrc, but don't modify original export just append additional paths

    export LD_LIBRARY_PATH=$HOME/usr/local/cmake/lib:$LD_LIBRARY_PATH
    export PATH=$HOME/usr/local/cmake/bin:$PATH
    

    then restart remote shell or use source command

    source ~/.bashrc
    
  4. Install PETSc (펫씨)

    1. Download PETSc (펫씨)
    cd ~/src
    curl -L -O http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.9.0.tar.gz
    
    1. unzip
    tar zxvf petsc-3.9.0.tar.gz
    
    1. configure
    cd petsc-3.9.0
    ./configure --prefix=$HOME/usr/local/PETSc --download-fblaslapack --with-mpi-dir=/engrid/enhpc/mpich-3.2.1 --download-mumps --download-scalapack --download-parmetis --download-metis --download-ptscotch --download-trilinos, --download-hypre --download-superlu_dist
    
     1. If you want to install with GPU Support (CUDA)
     ```
     ./configure --prefix=/opt/PETSc --download-fblaslapack --download-mumps --download-scalapack --download-parmetis --download-metis --download-ptscotch --download-trilinos, --download-hypre --download-superlu_dist --with-cuda=1 --with-cusp=1 --with-cusp-dir=/opt/cusp
     ```
    
    1. make
    make all test
    
    1. install
    make install
    
    1. update Makefile using installed path
    $HOME/usr/local/PETSc
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment