sfilippone/psblas3

Support CMake build

Closed this issue · 3 comments

The NRC-funded work on Morfeus includes a requirement to build NEMO on Windows and Linux. We plan accomplish this in two steps:

  1. Write CMake scripts to build NEMO and its dependencies, including PSBLAS and MLD2P4, on Linux.
  2. Import the CMake scripts into Microsoft Visual Studio for building on Windows.

Because NEMO depends on PSBLAS and MLD2P4, I will fork this repository and the MLD2P4 repository and add CMake files. I will then submit a pull request for your review.

Is this the correct repository to fork for PSBLAS? I assume I don't need to fork the psblas3-ext repository for now.

@sfilippone To start, I'm using CMake 3.9.1 and GCC 7.2.0 to build the PSBLAS 3.5.0 base library. Have you built PSBLAS 3.5.0 with GCC 7? I haven't looked at the PSBLAS source code yet, but it appears gfortran is rejecting non-standard code. Could you please investigate the error message below? In case it helps, GCC 7.2.0 is installed inside the current Sourcery Institute virtual machine, which is where I'm building.

$ git checkout https://github.com/sourceryinstitute/psblas3
$ cd psblas
$ git checkout add-cmake-scripts
$ mkdir build
$ cd build
$ cmake ..
-- Build from git repository detected
-- Found Git: /usr/bin/git (found version "2.14.1") 
-- The C compiler identification is GNU 7.2.0
-- The Fortran compiler identification is GNU 7.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working Fortran compiler: /usr/bin/gfortran
-- Check for working Fortran compiler: /usr/bin/gfortran  -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /usr/bin/gfortran supports Fortran 90
-- Checking whether /usr/bin/gfortran supports Fortran 90 -- yes
-- Building PSBLAS version: v3.5.0-27-g7b8e929b
-- Performing Test Check_Simple_Coarray_Fortran_Source_Compiles
-- Performing Test Check_Simple_Coarray_Fortran_Source_Compiles - Success
-- Found MPI_C: /opt/mpich/3.2/gnu/7.2.0/lib/libmpi.so (found version "3.1") 
-- Found MPI_Fortran: /opt/mpich/3.2/gnu/7.2.0/lib/libmpifort.so (found version "3.1") 
-- Found MPI: TRUE (found version "3.1")  
-- MPI runtime and compile time environments appear to be consistent
-- Performing Test MPI_C_COMPILES
-- Performing Test MPI_C_COMPILES - Success
-- Performing Test MPI_Fortran_MODULE_COMPILES
-- Performing Test MPI_Fortran_MODULE_COMPILES - Success
-- Performing Test MPI_Fortran_INCLUDE_COMPILES
-- Performing Test MPI_Fortran_INCLUDE_COMPILES - Success
-- Configuring done
CMake Error: INSTALL(EXPORT) given unknown export "PSBLASTargets"
-- Generating done
-- Build files have been written to: /home/rouson/Desktop/Builds/psblas3/build
rouson@sourcery-VirtualBox:~/Desktop/Builds/psblas3/build$ make
Scanning dependencies of target base
[  0%] Building Fortran object CMakeFiles/base.dir/base/modules/psb_const_mod.F90.o
[  1%] Building Fortran object CMakeFiles/base.dir/base/modules/psb_error_mod.F90.o
[  1%] Building Fortran object CMakeFiles/base.dir/base/modules/psb_realloc_mod.F90.o
[  2%] Building Fortran object CMakeFiles/base.dir/base/modules/aux/psi_c_serial_mod.f90.o
[  2%] Building Fortran object CMakeFiles/base.dir/base/modules/aux/psi_d_serial_mod.f90.o
[  2%] Building Fortran object CMakeFiles/base.dir/base/modules/aux/psi_i_serial_mod.f90.o
[  2%] Building Fortran object CMakeFiles/base.dir/base/modules/aux/psi_s_serial_mod.f90.o
[  3%] Building Fortran object CMakeFiles/base.dir/base/modules/aux/psi_z_serial_mod.f90.o
[  3%] Building Fortran object CMakeFiles/base.dir/base/modules/aux/psi_serial_mod.f90.o
[  3%] Building Fortran object CMakeFiles/base.dir/base/modules/serial/psb_base_mat_mod.f90.o
[  3%] Building Fortran object CMakeFiles/base.dir/base/modules/serial/psb_i_base_vect_mod.f90.o
[  3%] Building Fortran object CMakeFiles/base.dir/base/modules/aux/psb_string_mod.f90.o
[  3%] Building Fortran object CMakeFiles/base.dir/base/modules/serial/psb_c_base_vect_mod.f90.o
[  3%] Building Fortran object CMakeFiles/base.dir/base/modules/serial/psb_c_base_mat_mod.f90.o
[  3%] Building Fortran object CMakeFiles/base.dir/base/modules/serial/psb_c_csc_mat_mod.f90.o
[  4%] Building Fortran object CMakeFiles/base.dir/base/modules/serial/psb_c_csr_mat_mod.f90.o
[  5%] Building Fortran object CMakeFiles/base.dir/base/modules/serial/psb_i_vect_mod.F90.o
/home/rouson/Desktop/Builds/psblas3/base/modules/serial/psb_i_vect_mod.F90:213:6:

       mld = psb_i_get_base_vect_default()
      1
Error: Nonallocatable variable must not be polymorphic in intrinsic assignment at (1) - check that there is a matching specific subroutine for '=' operator
/home/rouson/Desktop/Builds/psblas3/base/modules/serial/psb_i_vect_mod.F90:182:6:

       mld = psb_i_get_base_vect_default()
      1
Error: Nonallocatable variable must not be polymorphic in intrinsic assignment at (1) - check that there is a matching specific subroutine for '=' operator
/home/rouson/Desktop/Builds/psblas3/base/modules/serial/psb_i_vect_mod.F90:552:6:

   use psb_i_vect_mod
      1
Fatal Error: Can't open module file ‘psb_i_vect_mod.mod’ for reading at (1): No such file or directory
compilation terminated.
CMakeFiles/base.dir/build.make:7838: recipe for target 'CMakeFiles/base.dir/base/modules/serial/psb_i_vect_mod.F90.o' failed
make[3]: *** [CMakeFiles/base.dir/base/modules/serial/psb_i_vect_mod.F90.o] Error 1
CMakeFiles/base.dir/build.make:7854: recipe for target 'CMakeFiles/base.dir/base/modules/serial/psb_i_vect_mod.F90.o.provides' failed
make[2]: *** [CMakeFiles/base.dir/base/modules/serial/psb_i_vect_mod.F90.o.provides] Error 2
CMakeFiles/Makefile2:163: recipe for target 'CMakeFiles/base.dir/all' failed
make[1]: *** [CMakeFiles/base.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2

After writing the above message, I remembered that I've built successfully with the existing autotools configure/make using GCC 7.2.0 so presumably the CMake build will succeed once I pass any necessary flags. From the tail of the output of ./configure below, I see that there are several flags being passed to the Fortran and C compilers. I'll start by hardware this flags into the CMake scripts and then can work later on setting them conditionally based on system interrogation.

configure:
	PSBLAS 3.5 has been configured as follows:

   	MPIFC		      : mpifort
	MPICC                 : mpicc
	FLINK                 : 

	FDEFINES              : -DHAVE_METIS -DHAVE_LAPACK -DHAVE_MOLD -DHAVE_EXTENDS_TYPE_OF -DHAVE_SAME_TYPE_AS -DHAVE_FINAL -DHAVE_ISO_FORTRAN_ENV -DHAVE_FLUSH_STMT -DHAVE_VOLATILE -DMPI_MOD 
	CDEFINES              : -DHAVE_METIS_  -DLowerUnderscore -DPtr64Bits 
	MODEXT                : .mod
	FMFLAG                : -I
   	FCOPT                 : -g -O3  
   	CCOPT                 : -g -O3   

	BLAS                  : 

	METIS detected        : yes
	AMD detected          : 
        LIBS                  :  
	LDLIBS                : 

	LIBRARYPATH           : 
	INCLUDEPATH           : 

Because all the work on this is taking place on the Sourcery Institute fork, I'll close this issue. A pull request will be submitted when the new CMake build capability is ready.