You can use OpenMPI and MPICH from MacPorts for both gfortran and nagfor by setting various environment variables and/or changing the scripts. To install OpenMPI from MacPorts on OS 15.7.4 or later:
sudo -s port install openmpi-gcc15 # If this is the only MPI library to be used, make it default: port select --set mpi openmpi-gcc15To install MPICH from MacPorts on OS 15.7.4 or later:
sudo -s port install mpich-gcc15 # If this is the only MPI library to be used, make it default: port select --set mpi mpich-gcc15 # Fix the mpifort script to work for nagfor too: cd /usr/local/bin/ cp mpifort-mpich-gcc15 mpifort-mpich-gcc15.orig # set final_ldflags=" " and extra_f77_flags=" " emacs mpifort-mpich-gcc15In addition, use "setenv MPICH_FC nagfor" or "export MPICH_FC=nagfor" when using nagfor instead of the default gfortran. Alternatively, you can use the precompiled MPICH libraries configured for the nagfor compiler on OS systems. The following MPI library works for Macintosh system using ARM chips
mpich-4.1.2_nagfor_arm.tgz for OS 15.7.3 or before
mpich-5.0.0_nagfor_arm.tgz for OS 15.7.4 or newer
As root (sudo -s), open the tar file inside NAG_fortran and link it
cd /usr/local rm -rf mpich lib/NAG_Fortran/mpich tar xzf ~/Downloads/mpich*_nagfor_arm.tgz ln -s mpich lib/NAG_Fortran/mpich # this may or may not be neededThe following MPI library only works for 64-bit Macintosh system using Intel chips:
As root (sudo -s), open the tar file and link it
cd /usr/local/ tar xzf mpich-3.2.1_nagfor_fpp.tgz rm -f mpich ln -s mpich-3.2.1 mpichExit from the super user mode (Ctrl-D or exit).
In both cases include /usr/local/mpich/bin into the path in the ~/.cshrc or similar file, then
source .cshrc rehashThen type
which mpif90to see if it is found. Now you should be able to compile the code with NAG Fortran and MPICH. To avoid run time errors due to some security settings (software is not from Apple), it may be necessary to do the following:
xattr -d com.apple.quarantine /usr/local/mpi/bin/mpiexec xattr -d com.apple.quarantine /usr/local/mpi/bin/hydra_pmi_prox spctl --master-disablePossibly the last command by itself is sufficient.
For some MPI implementations it may be necessary to create a public SSH key of the machine with
ssh-keygen(hit return to all questions) and the resulting public key file should be added to the authorized keys:
cat .ssh/id_rsa.pub >> .ssh/authorized_keysEven if not needed for running MPI parallel code, the public key is useful for passwordless ssh/scp/rsync etc. access.