Ubuntu 20.04下如何编译安装Fortran的FLIBS?——接口匹配错误问题求助
I’ve run into identical intent mismatch issues with FLIBS on newer GCC versions (like the gfortran 9.x included in Ubuntu 20.04) — here’s how to resolve this and compile FLIBS correctly:
Step 1: Ensure All Dependencies Are Installed
First, make sure your system has the necessary build tools to compile Fortran code:
sudo apt update && sudo apt install gfortran make gcc
Step 2: Re-Run the Configuration Script
Navigate back to your FLIBS root directory and re-run the configure script to ensure it detects your compiler settings properly:
cd /path/to/your/flibs ./configure.sh
Step 3: Fix the Intent Mismatch in m_vstringlist.f90
The errors you’re seeing stem from stricter interface checking in modern gfortran versions. The qsort_array subroutine expects comparison functions to take arguments with INTENT(IN), but some functions in m_vstringlist.f90 lack this specification.
- Open the file
src/strings/m_vstringlist.f90in your preferred text editor:nano src/strings/m_vstringlist.f90 - Locate all 8 comparison functions listed in your error messages (e.g.,
vstrlist_compare_asciiincreasing,vstrlist_compare_asciidecreasing). Each will look similar to this:function vstrlist_compare_asciiincreasing(a,b) result(res) type(vstring) :: a, b integer :: res ! ... existing function body ... end function - Add
INTENT(IN)to both dummy arguments for each comparison function:function vstrlist_compare_asciiincreasing(a,b) result(res) type(vstring), intent(in) :: a, b integer :: res ! ... existing function body ... end function
Repeat this adjustment for all 8 comparison functions.
Step 4: Recompile FLIBS
Clean any previous build artifacts and recompile the library:
cd make make clean make
Step 5: Verify the Compiled Libraries
After a successful compile, you’ll find the required modules (cgi_protocol.mod, fcgi_protocol.mod) in the lib/linux/x86_64/gfortran/debug (or release) directory of your FLIBS installation. You can now link these modules to your Fortran script.
This fix aligns the comparison functions with the interface expected by qsort_array, which is mandatory for compatibility with newer gfortran versions.
内容的提问来源于stack exchange,提问作者John C.

