@@ -28,9 +28,9 @@ find_or_install()
2828 done
2929
3030 if [[ " $package " == " $executable " ]]; then
31- echo -e " $this_script : Checking whether $executable is in the PATH..."
31+ printf " $this_script : Checking whether $executable is in the PATH..."
3232 else
33- echo -e " $this_script : Checking whether $package executable $executable is in the PATH..."
33+ printf " $this_script : Checking whether $package executable $executable is in the PATH..."
3434 fi
3535 if type " $executable " > /dev/null; then
3636 printf " yes.\n"
@@ -43,8 +43,7 @@ find_or_install()
4343
4444 package_install_path=$( ./build.sh -P " $package " )
4545
46- echo -e " $this_script : Checking whether $executable is in the directory in which $this_script \n"
47- printf " installs it by default and whether the user has executable permission for it..."
46+ printf " Checking whether $executable is in the prerequisites/instalations directory.."
4847 if [[ -x " $package_install_path /bin/$executable " ]]; then
4948 printf " yes.\n"
5049 script_installed_package=true
@@ -111,8 +110,30 @@ find_or_install()
111110 # Every branch that discovers an acceptable pre-existing installation must set the
112111 # MPIFC, MPICC, and MPICXX environment variables. Every branch must also manage the
113112 # dependency stack.
113+
114+ if [[ ! -z " ${arg_f} " ]]; then
115+
116+ # -f or --with-fortran argument specifies a compiler, which we use if mpif90
117+ # invokes the specified compiler. Otherwise, we halt and print an error message.
118+
119+ mpif90_wraps=$( mpif90 --version)
120+ compiler=$( ${arg_f} --version)
121+ if [[ " ${mpif90_wraps} " != " ${compiler} " ]]; then
122+ emergency " The specified compiler ${arg_f} differs from the compiler that mpif90 invokes."
123+ else
124+ info " mpif90 invokes the specified compiler ${arg_f} "
125+ fi
126+ export MPIFC=mpif90
127+ export MPICC=mpicc
128+ export MPICXX=mpicxx
129+
130+ # Halt the recursion
131+ stack_push dependency_pkg " none"
132+ stack_push dependency_exe " none"
133+ stack_push dependency_path " none"
134+
135+ elif [[ " $script_installed_package " == true ]]; then
114136
115- if [[ " $script_installed_package " == true ]]; then
116137 echo -e " $this_script : Using the $package installed by $this_script \n"
117138 export MPIFC=$package_install_path /bin/mpif90
118139 export MPICC=$package_install_path /bin/mpicc
@@ -123,9 +144,10 @@ find_or_install()
123144 stack_push dependency_path " none"
124145
125146 elif [[ " $package_in_path " == " true" ]]; then
147+
126148 echo -e " $this_script : Checking whether $executable in PATH wraps gfortran... "
127- mpif90__version_header =$( mpif90 --version | head -1)
128- first_three_characters=$( echo " $mpif90__version_header " | cut -c1-3)
149+ mpif90_version_header =$( mpif90 --version | head -1)
150+ first_three_characters=$( echo " $mpif90_version_header " | cut -c1-3)
129151 if [[ " $first_three_characters " != " GNU" ]]; then
130152 printf " no.\n"
131153 # Trigger 'find_or_install gcc' and subsequent build of $package
@@ -142,11 +164,8 @@ find_or_install()
142164 is_true=$( ./print_true)
143165 rm acceptable_compiler print_true
144166
145- [ " $acceptable " == " $is_true " ] && printf " yes.\n"
146- [ ! -z " ${arg_f} " ] && printf " no.\n Default compiler installation overridden by --with-fortran/-f=${arg_f} \n"
147-
148- if [[ " $acceptable " == " $is_true " || ! -z " ${arg_f} " ]]; then
149- echo -e " $this_script : Using the $executable found in the PATH.\n"
167+ if [[ " $acceptable " == " $is_true " ]]; then
168+ printf " yes.\n $this_script : Using the $executable found in the PATH.\n"
150169 export MPIFC=mpif90
151170 export MPICC=mpicc
152171 export MPICXX=mpicxx
@@ -173,7 +192,7 @@ find_or_install()
173192
174193 elif [[ $package == " gcc" ]]; then
175194
176- # We arrive when the 'elif [[ $package == "gcc " ]]' block pushes "gcc" onto the
195+ # We arrive here when the 'elif [[ $package == "mpich " ]]' block pushes "gcc" onto the
177196 # the dependency_pkg stack, resulting in the recursive call 'find_or_install gcc'
178197
179198 # Every branch that discovers an acceptable pre-existing installation must set the
0 commit comments