Compiling SciFortran on WSL

SciFortran is a “library of fortran modules and routines for scientific calculations (in a way just like scipy for python)”. Trying to install it under Windows Subsystem for Linux 2 Ubuntu with

mkdir build
cd build
cmake ..

I get

cmake ..
-- The Fortran compiler identification is GNU 9.3.0
-- Check for working Fortran compiler: /usr/bin/f95
-- Check for working Fortran compiler: /usr/bin/f95  -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /usr/bin/f95 supports Fortran 90
-- Checking whether /usr/bin/f95 supports Fortran 90 -- yes
-- OS: Linux 5.10.43.3-microsoft-standard-WSL2
-- BUILD_TYPE=RELEASE
-- Fortran Compiler id   = GNU
-- Fortran Compiler ver. = 9.3.0
-- Fortran Compiler options = -cpp -ffree-line-length-none -fPIC -w  -Wno-argument-mismatch -O3   -funroll-loops
-- Found MPI_Fortran: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_usempif08.so (found version "3.1") 
-- Found MPI: TRUE (found version "3.1")  
-- Set Fortran compiler FC to /usr/bin/mpif90, ID=GNU
-- Found Git: /usr/bin/git (found version "2.25.1") 
-- Git SHA1: 8c2a7fe1aa1d7e7a935996e36ceb7bb81f6ff4fc
-- Git branch: master
-- Git tag: 4.7.3-1-g8c2a7fe
-- Looking for Fortran sgemm
-- Looking for Fortran sgemm - not found
-- Looking for Fortran sgemm
-- Looking for Fortran sgemm - found
-- Found BLAS: /usr/lib/x86_64-linux-gnu/libopenblas.so  
-- Looking for Fortran cheev
-- Looking for Fortran cheev - found
-- BLAS/LAPACK found at: /usr/lib/x86_64-linux-gnu/libopenblas.so /usr/lib/x86_64-linux-gnu/libopenblas.so;/usr/lib/x86_64-linux-gnu/libopenblas.so
-- Finding SCALAPACK
-- Testing P-ARPACK patch: zdotc.patch
-- Patch not applied. Applying: zdotc.patch
CMake Error at src/arpack/CMakeLists.txt:215 (MESSAGE):
  Error applying patch zdotc.patch


-- Configuring incomplete, errors occurred!
See also "/mnt/c/fortran/public_domain/github/SciFortran/build/CMakeFiles/CMakeOutput.log".
See also "/mnt/c/fortran/public_domain/github/SciFortran/build/CMakeFiles/CMakeError.log".

with more details, including the authors’ suggestions, here. Can anyone compile SciFortran on WSL?

Hi, I just tried to install SciFortran on WSL2 and don’t see any problems. The only change I did is that I added the recommended environment variable FC=mpif90 before cmake ... The gfortran, cmake and open-mpi are all installed from homebrew but not apt. (Homebrew is highly recommended!)

Here is what pops out after FC=mpif90 cmake ..

-- The Fortran compiler identification is GNU 11.2.0
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /home/linuxbrew/.linuxbrew/bin/mpif90 - skipped
-- Checking whether /home/linuxbrew/.linuxbrew/bin/mpif90 supports Fortran 90
-- Checking whether /home/linuxbrew/.linuxbrew/bin/mpif90 supports Fortran 90 - yes
-- OS: Linux 5.10.16.3-microsoft-standard-WSL2
-- BUILD_TYPE=RELEASE
-- Fortran Compiler id   = GNU
-- Fortran Compiler ver. = 11.2.0
-- Fortran Compiler options = -cpp -ffree-line-length-none -fPIC -w  -fallow-argument-mismatch -O3   -funroll-loops
-- Found MPI_Fortran: /home/linuxbrew/.linuxbrew/bin/mpif90 (found version "3.1")
-- Found MPI: TRUE (found version "3.1")
-- Set Fortran compiler FC to /home/linuxbrew/.linuxbrew/bin/mpif90, ID=GNU
-- Found Git: /usr/bin/git (found version "2.25.1")
-- Git SHA1: 8c2a7fe1aa1d7e7a935996e36ceb7bb81f6ff4fc
-- Git branch: master
-- Git tag: 4.7.3-1-g8c2a7fe
-- Looking for Fortran sgemm
-- Looking for Fortran sgemm - not found
-- Looking for Fortran sgemm
-- Looking for Fortran sgemm - not found
-- Finding SCALAPACK
-- Testing P-ARPACK patch: zdotc.patch
-- Patch applied: zdotc.patch
-- Version file: /home/han/Projects/SciFortran/build/etc/modules/scifor/gnu/.version
-- Module file: scifor/gnu/4.7.3-1-g8c2a7fe
-- SF compilation lines: -L${libdir} -lscifor

-- Library version: 4.7.3-1-g8c2a7fe
-- Library will be installed in: /home/han/opt/scifor/gnu/4.7.3-1-g8c2a7fe
--
>> TO CONCLUDE INSTALLATION <<
Compile with:
$ make
Install with:
$ make install

Uninstall with:
$ make uninstall

-- Configuring done
-- Generating done
-- Build files have been written to: /home/han/Projects/SciFortran/build

SciFortran updated the CMakeLists.txt file, and I can now compile the project on WSL 2 with the instructions given.