SWIG-Fortran is used to generate the C++-Fortran bindings.
Clone swig-fortran from
>> cd
>> git clone https://github.com/swig-fortran/swig.git swig-fortran
>> cd swig-fortran
To avoid dependency issues involving the Niagara environment not containing the modules bison, we need to revert to an older version v4.0.4 of SWIG by running the command (see below for the alternative of using newer versions of SWIG)
>> git checkout 5177f08
OPTION 1: (Recommended if using stack NiaEnv/2019b)
Load the module 'autotools' (to get autoconf) and the PCRE2 module (alternatively, add it to your bashrc and source it) and then setup the configure script
>> module load autotools pcre2
OPTION 2: (Recommended if using stack NiaEnv/2022a)
Since Niagara does not have PCRE2 as a loadable module, you must install it manually via
>> module load autotools
>> wget https://github.com/PhilipHazel/pcre2/releases/download/pcre2-10.44/pcre2-10.44.tar.gz
>> tar -xzf pcre2-10.44.tar.gz
>> cd pcre2-10.44
>> ./configure CC=mpicc CXX=mpicxx FC=mpifc --prefix=${HOME}/swig-fortran/build
>> make -j4 # note could increase 4 to desired number of cores
>> make install
>> cd ../
Note that we are choosing to install PCRE2 in the same directory as SWIG. Alternatively, you could choose a different directory location in --prefix . Hwoever, you would then need to correspondingly modify the below export statements so that the libraries and header files can be found.
You can now continue the SWIG installation by running (in the swig-fortran directory)
>> ./autogen.sh
>> ./configure --prefix=${HOME}/swig-fortran/build
>> make
>> make install
Once again, if you wish to use a different install directory (for example simply ${HOME}/swig-fortran, then modify the above --prefix flag. Finally, add the build directory (i.e. whatever path you specified to the prefix flag) to your PATH in your .bashrc using the following line,
>> export PATH=${HOME}/swig-fortran/build/bin:$PATH
If you manually installed PCRE2 for the 2022 environment, you also need to add the following to link to your PCRE2 libraries and header files. Note that the first line can be omitted if you chose the same install directory for both swig and PCRE2, as was suggested above.
>> export PATH=${HOME}/swig-fortran/build/bin:$PATH
>> export LD_LIBRARY_PATH=${HOME}/swig-fortran/build/lib:$LD_LIBRARY_PATH
>> export CPATH=${HOME}/swig-fortran/build/include:$CPATH
OPTIONAL: If you want to use newer versions of SWIG, you will also need to download bison, which can be installed using the instructions here. We choose not to use newer versions of SWIG, however, because the above is simpler and leads to nearly identical wrappers.