Mod:Hunt Research Group/Gfortran
Appearance
GFortran
quick start
- sudo port install gcc49
- sudo port select --set gcc mp-gcc49
- gfortran -v
first install a gcc compiler using macports
- type
- port search --name gcc*
- select one to install for example
- sudo port install gcc49
- check what installs are active
- port installed 'gcc*'
- the files will be installed in /opt/local/bin
- a check will not show the new compiler
gcc -v Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 9.0.0 (clang-900.0.37) Target: x86_64-apple-darwin16.7.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
- check gfortran version does not work
- gfortran -v
- port installed '*fortran*' returns None of the specified ports are installed.
- because the MacPorts are installed in /opt and not /usr, you either need to either specify the full path, or explicitly set which compiler to use on your system.
- they will not have the standard name, in my case the fortran is gfortran-mp-4.9
- you can use MacPorts to select the default compiler
- port select --list gcc
Available versions for gcc: mp-gcc49 none (active)
- sudo port select --set gcc mp-gcc49
Selecting 'mp-gcc49' for 'gcc' succeeded. 'mp-gcc49' is now active.
- gfortran -v
Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin16/4.9.4/lto-wrapper Target: x86_64-apple-darwin16 Configured with: /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_gcc49/gcc49/work/gcc-4.9.4/configure --prefix=/opt/local --build=x86_64-apple-darwin16 --enable-languages=c,c++,objc,obj-c++,lto,fortran,java --libdir=/opt/local/lib/gcc49 --includedir=/opt/local/include/gcc49 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-4.9 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.9 --with-gxx-include-dir=/opt/local/include/gcc49/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-isl=/opt/local --disable-isl-version-check --with-cloog=/opt/local --disable-cloog-version-check --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-build-config=bootstrap-debug --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --disable-tls --with-pkgversion='MacPorts gcc49 4.9.4_2' --with-build-config=bootstrap-debug Thread model: posix gcc version 4.9.4 (MacPorts gcc49 4.9.4_2)
using fortran
- normally you will just need to "make" a package downloaded
- alternatively to compile individual files
- To compile file source.f90
- gfortran -c source.f90
- To link into runfile executable
- gfortran -o executable object1.o object2.o ...
- To combine the above
- gfortran -o executable source1.f90 source2.f90
- .f files are assumed fixed form files
- .f90 or .f95 are assumed free form files
- note: on old macs the default version of fortran is /usr/local/gfortran and /usr/local/bin/gfortran
- if required use sudo rm -r /usr/local/gfortran /usr/local/bin/gfortran