Skip to content

Commit d99ad59

Browse files
authored
Better extraction of the Fortran compiler from the MPI wrapper (#634)
- changed command to one supported by more (all?) MPI libraries
1 parent cc8a920 commit d99ad59

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/fpm_compiler.f90

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module fpm_compiler
4040
OS_UNKNOWN
4141
use fpm_filesystem, only: join_path, basename, get_temp_filename, delete_file, unix_path, &
4242
& getline
43-
use fpm_strings, only: string_cat, string_t
43+
use fpm_strings, only: split, string_cat, string_t
4444
implicit none
4545
public :: compiler_t, new_compiler, archiver_t, new_archiver
4646
public :: debug
@@ -467,22 +467,26 @@ function get_compiler_id(compiler) result(id)
467467
character(len=*), intent(in) :: compiler
468468
integer(kind=compiler_enum) :: id
469469

470-
character(len=:), allocatable :: command, output
470+
character(len=:), allocatable :: full_command, full_command_parts(:), command, output
471471
integer :: stat, io
472472

473473
! Check whether we are dealing with an MPI compiler wrapper first
474474
if (check_compiler(compiler, "mpifort") &
475475
& .or. check_compiler(compiler, "mpif90") &
476476
& .or. check_compiler(compiler, "mpif77")) then
477477
output = get_temp_filename()
478-
call run(compiler//" -showme:command > "//output//" 2>&1", &
478+
call run(compiler//" -show > "//output//" 2>&1", &
479479
& echo=.false., exitstat=stat)
480480
if (stat == 0) then
481481
open(file=output, newunit=io, iostat=stat)
482-
if (stat == 0) call getline(io, command, stat)
482+
if (stat == 0) call getline(io, full_command, stat)
483483
close(io, iostat=stat)
484484

485485
! If we get a command from the wrapper, we will try to identify it
486+
call split(full_command, full_command_parts, delimiters=' ')
487+
if(size(full_command_parts) > 0)then
488+
command = trim(full_command_parts(1))
489+
endif
486490
if (allocated(command)) then
487491
id = get_id(command)
488492
if (id /= id_unknown) return

0 commit comments

Comments
 (0)