From d99ad594f731511413f5bad96f0c0dfe0c2c08aa Mon Sep 17 00:00:00 2001
From: Pedro Costa
Date: Mon, 13 Dec 2021 07:02:02 +0000
Subject: Better extraction of the Fortran compiler from the MPI wrapper (#634)
- changed command to one supported by more (all?) MPI libraries
---
src/fpm_compiler.f90 | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
(limited to 'src')
diff --git a/src/fpm_compiler.f90 b/src/fpm_compiler.f90
index c0c5b73..bccff74 100644
--- a/src/fpm_compiler.f90
+++ b/src/fpm_compiler.f90
@@ -40,7 +40,7 @@ use fpm_environment, only: &
OS_UNKNOWN
use fpm_filesystem, only: join_path, basename, get_temp_filename, delete_file, unix_path, &
& getline
-use fpm_strings, only: string_cat, string_t
+use fpm_strings, only: split, string_cat, string_t
implicit none
public :: compiler_t, new_compiler, archiver_t, new_archiver
public :: debug
@@ -467,7 +467,7 @@ function get_compiler_id(compiler) result(id)
character(len=*), intent(in) :: compiler
integer(kind=compiler_enum) :: id
- character(len=:), allocatable :: command, output
+ character(len=:), allocatable :: full_command, full_command_parts(:), command, output
integer :: stat, io
! Check whether we are dealing with an MPI compiler wrapper first
@@ -475,14 +475,18 @@ function get_compiler_id(compiler) result(id)
& .or. check_compiler(compiler, "mpif90") &
& .or. check_compiler(compiler, "mpif77")) then
output = get_temp_filename()
- call run(compiler//" -showme:command > "//output//" 2>&1", &
+ call run(compiler//" -show > "//output//" 2>&1", &
& echo=.false., exitstat=stat)
if (stat == 0) then
open(file=output, newunit=io, iostat=stat)
- if (stat == 0) call getline(io, command, stat)
+ if (stat == 0) call getline(io, full_command, stat)
close(io, iostat=stat)
! If we get a command from the wrapper, we will try to identify it
+ call split(full_command, full_command_parts, delimiters=' ')
+ if(size(full_command_parts) > 0)then
+ command = trim(full_command_parts(1))
+ endif
if (allocated(command)) then
id = get_id(command)
if (id /= id_unknown) return
--
cgit v1.2.3