Skip to content

Commit 1a948be

Browse files
committed
refactor windows search
1 parent 0fcca0e commit 1a948be

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

src/fpm_meta.f90

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -570,31 +570,26 @@ logical function msmpi_init(this,compiler,error) result(found)
570570
end if
571571

572572
! Check that the runtime is installed
573-
bindir = get_env('MSMPI_BIN')
573+
bindir = ""
574+
call get_absolute_path(get_env('MSMPI_BIN'),bindir,error)
574575

575-
! Always use DOS paths with no spaces
576-
if (len_trim(bindir)>0) then
577-
bindir = get_dos_path('C:\Program Files\Microsoft MPI\Bin\mpiexec.exe',error)
578-
endif
579-
580-
print *, 'bindir=',bindir
576+
print *, '+ bindir=',bindir
577+
print *, '+ windir=',windir
581578

582579
! In some environments, variable %MSMPI_BIN% is missing (i.e. in GitHub Action images).
583-
! Do a second attempt: search for mpiexec.exe
584-
if (len_trim(bindir)<=0 .or. .not.exists(bindir) .or. allocated(error)) then
585-
print *, '+ MSMPI_BIN path does not exist, searching mpiexec.exe....'
586-
call find_command_location('mpiexec.exe',bindir,verbose=verbose,error=error)
580+
! Do a second attempt: search for the default location
581+
if (len_trim(bindir)<=0 .or. allocated(error)) then
582+
print *, '+ MSMPI_BIN path does not exist, searching C:\Program Files\Microsoft MPI\Bin\....'
583+
call get_absolute_path('C:\Program Files\Microsoft MPI\Bin\mpiexec.exe',bindir,error)
587584
endif
588585

589-
! Do a third attempt: search for mpiexec.exe in the default location
590-
if (len_trim(bindir)<=0 .or. .not.exists(bindir) .or. allocated(error)) then
591-
print *, '+ MSMPI_BIN path does not exist, searching C:\Program Files\Microsoft MPI\Bin\mpiexec.exe....'
592-
windir = get_dos_path('C:\Program Files\Microsoft MPI\Bin\mpiexec.exe',error)
586+
! Do a third attempt: search for mpiexec.exe in PATH location
587+
if (len_trim(bindir)<=0 .or. allocated(error)) then
593588

594-
print *, 'windir=',windir
589+
call get_mpi_runner(windir,verbose,error)
595590

596591
if (.not.allocated(error)) then
597-
print *, '+ searching location of ',windir
592+
print *, '+ searching location of mpi runner, ',windir
598593
call find_command_location(windir,bindir,verbose=verbose,error=error)
599594
endif
600595

@@ -821,7 +816,7 @@ end subroutine find_command_location
821816
!> Get MPI runner in $PATH
822817
subroutine get_mpi_runner(command,verbose,error)
823818
type(string_t), intent(out) :: command
824-
logical, optional, intent(in) :: verbose
819+
logical, intent(in) :: verbose
825820
type(error_t), allocatable, intent(out) :: error
826821

827822
character(*), parameter :: try(*) = ['mpiexec','mpirun ']

0 commit comments

Comments
 (0)