Many thanks for your prompt help, MakisH & fsimonis!
Sorry that perhaps I was misleading. In CMakeError.log, it still shows “/usr/bin/ld: cannot find -lpthreads”. Besides, the Ubuntu version is 19 (not 18)
I tried to re-install libboost, cmake, Petsc and preCICE. The compilation steps are shown below.
==================================================
sudo apt-get install libboost-all-dev
**Reading package lists... Done**
**Building dependency tree **
**Reading state information... Done**
**libboost-all-dev is already the newest version (1.67.0.1).**
**sh: 0: getcwd() failed: No such file or directory**
**0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.**
**sh: 0: getcwd() failed: No such file or directory**
==================================================
sudo apt-get -y install cmake
**Reading package lists... Done**
**Building dependency tree **
**Reading state information... Done**
**cmake is already the newest version (3.13.4-1).**
**sh: 0: getcwd() failed: No such file or directory**
**0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.**
**sh: 0: getcwd() failed: No such file or directory**
which cmake
**sh: 0: getcwd() failed: No such file or directory**
**/usr/bin/cmake**
cd /usr/bin
cmake --version
**cmake version 3.13.4**
**CMake suite maintained and supported by Kitware (kitware.com/cmake).**
===================================================================
Petsc is installed using the commands below.
sudo ./configure --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich
sudo make all test
Last several lines at the end of the compilation log info printed on the screen.
**CLINKER arch-linux2-c-debug/lib/libpetsc.so.3.12.1**
**make[2]: Leaving directory '/scratch/hd/sw/petsc-3.12.1'**
**make[1]: Leaving directory '/scratch/hd/sw/petsc-3.12.1'**
**Now to check if the libraries are working do:**
**make PETSC_DIR=/scratch/hd/sw/petsc-3.12.1 PETSC_ARCH=arch-linux2-c-debug check**
**=========================================**
**Running test examples to verify correct installation**
****Using PETSC_DIR=/scratch/hd/sw/petsc-3.12.1 and PETSC_ARCH=arch-linux2-c-debug****
**C/C++ example src/snes/examples/tutorials/ex19 run successfully with 1 MPI process**
**C/C++ example src/snes/examples/tutorials/ex19 run successfully with 2 MPI processes**
**Fortran example src/snes/examples/tutorials/ex5f run successfully with 1 MPI process**
**Completed test examples**
===================================================================
In the file ~/.bashrc, add the following lines.
export PETSC_DIR=/scratch/hd/sw/petsc-3.12.1
export PETSC_ARCH=arch-linux2-c-debug
source ~/.bashrc
====================================================================
rm precice-1.6.1 -rf
tar -xzvf v1.6.1.tar.gz
cd precice-1.6.1
mkdir build && cd build
sudo cmake -DCMAKE_CXX_COMPILER=mpicxx -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
See the compilation error printed on the screen at the bottom.
======================================================================
CMakeError.log and CMakeOutput.log are saved in the links below.
https://drive.google.com/open?id=1ZALOuPIQNyz0IZGJ0BVm9mGaPky8R1L9
======================================================================
The same error message is shown when either of the two below methods is used.
sudo CXX=mpicxx cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
sudo cmake -DCMAKE_CXX_COMPILER=mpicxx -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
**-- The CXX compiler identification is GNU 8.3.0**
**-- Check for working CXX compiler: /usr/local/bin/mpicxx**
**-- Check for working CXX compiler: /usr/local/bin/mpicxx -- works**
**-- Detecting CXX compiler ABI info**
**-- Detecting CXX compiler ABI info - done**
**-- Detecting CXX compile features**
**-- Detecting CXX compile features - done**
**-- --------------------**
**-- == CONFIGURATION**
**-- Library version to build: 1.6.1**
**-- Build configuration: RelWithDebInfo**
**-- Build shared libraries: ON**
**-- Target system: Linux-5.0.0-32-generic**
**-- Host system: Linux-5.0.0-32-generic**
**-- Library architecture: x86_64-linux-gnu**
**-- CXX compiler: /usr/local/bin/mpicxx**
**-- CXX compiler flags: <empty>**
**-- CXX linker: /usr/bin/ld**
**-- Install prefix: /usr/local**
**-- Source directory: /scratch/hd/sw/precice-1.6.1**
**-- Binary directory: /scratch/hd/sw/precice-1.6.1/build**
**-- --------------------**
**-- Build with MPI: ON**
**-- Build with PETSC: ON**
**-- Build with PYTHON: ON**
**-- Configure package generation: ON**
**-- Install tests/testfiles: ON**
**-- Additional CTest MPI Flags: <empty>**
**-- --------------------**
**-- Looking for C++ include pthread.h**
**-- Looking for C++ include pthread.h - found**
**-- Looking for pthread_create**
**-- Looking for pthread_create - not found**
**-- Looking for pthread_create in pthreads**
**-- Looking for pthread_create in pthreads - not found**
**-- Looking for pthread_create in pthread**
**-- Looking for pthread_create in pthread - found**
**-- Found Threads: TRUE **
**-- Boost version: 1.67.0**
**-- Found the following Boost libraries:**
**-- filesystem**
**-- log**
**-- log_setup**
**-- program_options**
**-- system**
**-- thread**
**-- unit_test_framework**
**-- date_time**
**-- regex**
**-- chrono**
**-- atomic**
**-- Found Eigen3: /usr/include/eigen3 (Required is at least version "3.2") **
**-- Validating Eigen**
**-- Validating Eigen - success**
**-- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.4") **
**-- Validating LibXML2**
**-- Validating LibXML2 - success**
**-- Validating JSON**
**-- Validating JSON - success**
**-- Validating Prettyprint**
**-- Validating Prettyprint - success**
**-- Found MPI_CXX: /usr/local/bin/mpicxx (found version "3.1") **
**-- Found MPI: TRUE (found version "3.1") **
**CMake Error at /usr/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):**
**PETSc could not be found. Be sure to set PETSC_DIR and PETSC_ARCH.**
**(missing: PETSC_INCLUDES PETSC_LIBRARIES PETSC_EXECUTABLE_RUNS) (Required**
**is at least version "3.6")**
**Call Stack (most recent call first):**
**/usr/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)**
**cmake/modules/FindPETSc.cmake:345 (find_package_handle_standard_args)**
**CMakeLists.txt:148 (find_package)**
**-- Configuring incomplete, errors occurred!**