Menu
I. Introduction
The MOM4 ocean model is usually exectued in parallel on supercomputers. However, not every researcher has access to super-compters nor commercial compiler suites. In addition to this, not every researcher requires the full power of a supercomputer to conduct their research.
This document describes the process of how to successfully build and run MOM4 with gfortran on Mac OSX.
Aug 06, 2019 The 5.0 version of GFortran is provided as a free download on our website. This free program is a product of [email protected]. This download was checked by our built-in antivirus and was rated as malware free. The program belongs to Development Tools. I followed the instructions given here How to uninstall gfortran compiler on MAC OSX 10.7 But when I try to install gfortran again, it tells me a version of gfortran already exists. Macos uninstall gfortran. Share improve this question. Asked Jul 5 '17 at 16:07. 167 9 9 bronze badges. This will download and unpack a new version of gfortran, putting it into a new directory: /gfortran. It will also put a Makevars file into your /.R directory so that R knows where to look when it wants gfortran. To test it, install pomp from source by running the following in an R session. Remove download gfortran. Port over the configuration checks to use the backup and remove function. Implement a new gfortran download and installation technique. Upgrade installer accepted macos versions. Add changelog details. Remove dangling installer. Update splash screen of installer for readme.
Gfortran for macOS. The goal of this repository is to host GNU Fortran packages for macOS. These are simple installers, that will install the GCC compilers (including gfortran) in /usr/local/gfortran. Follow this link to download! Step 5: Now the compilers are installed, and if you’re running Mac OS 10.11, you should be able to test the.
II. What You'll Need
- NetCDF 4.1.1 (later versions of 3.X should work)
- OpenMPI (latest version)
- gcc/gfortran (version 4.4 or later)
III. GCC and GFORTRAN 4.4
If you already have gfortran 4.4 or later you can skip this step.
OSX does not come with gfortran unless you download the XCode development tools (and even then it's a horribly out of date version).
The easiest way to get gcc an gfortran is through MacPorts. The last time I checked though the gfortran version was not 4.4 or greater. This is crucial as gfortran versions less than 4.4 contain a bug when reading in unformatted binary files.
Building gcc/gfortran 4.4 isn't hard, but it does take a while to build. Detailed build instructions can be found on the GCC website.
IV. NetCDF
If you already have a recent version of NetCDF that supports NetCDF 3 and has FORTRAN bindings then you can skip this step.
I had to build NetCDF 4.1.1 since versions available via Mac Ports did not contain FORTRAN bindings. However, when building version 4.1.1 special care is needed.
First, due to a problem with HDF5 you should NOT build with NetCDF4 features enabled. Doing so will result in undefined HDF5 symbols which will prevent correct linking. The supposed workaround (building HDF5 with -g to keep the symbols) does not appear to work.
Apple safari download mac os x. Second, an older bug in NetCDF on the Mac has seemed to resurface. Following the normal instructions will build NetCDF, however no symbols (or at least not the correct ones) will be present in the built libraries.
The way I built NetCDF to correctly have everything that was necesssary was to use the following configure command:
./configure --enable-fortran --enable-shared --enable-static CC=gcc --disable-cxx FC=gfortran CFLAGS='-g -DpgiFortran' CPPFLAGS='-g -DpgiFortran' FCFLAGS='-g -fno-f2c'
The key here is to use the -DpgiFortran flag. This will create NetCDF libraries with all the correct symbols. I also specified the C compiler (CC=) and the fortran compiler(FC=) since on my system I have multiple versions of each installed. I performed a make check install to install the libraries into /usr/local/other, though you can install them elsewhere. You will just need to tell MOM4 where to find NetCDF if you place it in a different directory.
IV.Open MPI
I used the latest verion of open MPI (mpich2) via Mac Ports. No building necessary. You will need to set it up correctly on your machine however.
First, you will need to ensure that ssh is running on your machine. Even when just connectiong to localhost, MPI needs to be able to make sh connections. To do this go to System Preferences->Sharing and enable remote login. This will turn on the ssh daemon on your machine.
At this point you'd be able to run a single process of the model. The MPI library is smart enough to realize that it doesn't need communications or a daemon if there is only one process. However, if you are on a multi-core machine and you want to use more than one core some additional setup is required.
You will ned to create a host file. Create a file named mpd.hosts in your home directory and put either localhost or 127.0.0.1 on the first line of the file. This file represents the list of hosts that MPI can communicate with, so in our case it's just the local machine.
After creating the host file, you can execute mpdboot specifying the host file and the number of 'nodes'. For example, if you're on a dual core machine, you'd specify something like this:
mpdboot --totalnum=1 --ncpus=2
Run this from your home directory or you will need to specify th hosts file via th -f option. This only needs to be done once. After the MPI daemon is running, you will be able to run parallel instances.
V. Compiling MOM4
The version of MOM4 used for this is the public release of MOM4p1 released December 2009.
MOM4 has a few implementation bugs that prevent it from compiling/running 100% serially, so unfortunately you do need to compile with MPI enabled. You can compile WITHOUT it being enabled, however only some of the 'example' experiments will run without throwing an error. That being said, it's possible to run with just a single processor with MPI.
Modifications were required in order for this to work with gfortran.
First, there isn't a gfortran template so it needs to be created. Copy the environs.g95 and mkmf.template.g95 files and rename them to environs.gfort and mkmf.template.gfort.
The environs.gfort file should have a number of commented out lines. At the bottom of the file, you should have the following:
setenv NC_BLKSZ 64K
setenv MPICH_MAX_SHORT_MSG_SIZE 8000
setenv NC_BLKSZ 1M
setenv MPICH_MAX_SHORT_MSG_SIZE 8000
setenv NC_BLKSZ 1M
Next, open the mkmf.template.gfort file and use the following:
FFLAGS = -cpp -fcray-pointer -g -fdefault-real-8 -O2 -ffree-line-length-none -fno-range-check
CPPFLAGS = -I/usr/include -I/usr/local/include -I/usr/local/mpich/include
FC = gfortran
LD = gfortran
LDFLAGS = -lnetcdff -lnetcdf -L/usr/local/mpich/lib -lmpich -lfmpich -lmpichcxx
CFLAGS = -D__IFC
CPPFLAGS = -I/usr/include -I/usr/local/include -I/usr/local/mpich/include
FC = gfortran
LD = gfortran
LDFLAGS = -lnetcdff -lnetcdf -L/usr/local/mpich/lib -lmpich -lfmpich -lmpichcxx
CFLAGS = -D__IFC
You may need to change some of these values to reflect the directories on your system.
Open the mom4_solo_compile script in the exp directory and set MPI to 1. If you try to run the mom4_solo_compile script at this point, you may get compilation errors.
How To Download Gfortran On Mac Os
It turns out that compilers like PGI and gforrtran are more strict about operator overloading than Intel. For example, if you overload the operator .NE. andd you use /= in your code, the Intel compiler will not complain. However, gfortran will complain. In order to fix this problem, the operator overload must be consistent. In other words, if you overload /= then you MUST use /= . Using .NE. will result in a compilation failure.
The changes necessary are straightforward based on the compiler errors. Once that is taken care of, there is another modification that may be required.
Canon easy photoprint ex mac download. As I mentioned before, MOM4 has some issues with serial builds. I added a hack in the ocean_drifters.f90 file so that 'serial' builds would compile. Replace line 209 with the following:
#ifdef _SERIAL
!HACK: Something appears to be broken with serial builds. This hack allows
!the model to compile.
call drifters_set_pe_neighbors(drfts, domain=0, ermesg=ermesg)
#else
call drifters_set_pe_neighbors(drfts, domain=Domain%domain2d, ermesg=ermesg)
#endif
!HACK: Something appears to be broken with serial builds. This hack allows
!the model to compile.
call drifters_set_pe_neighbors(drfts, domain=0, ermesg=ermesg)
#else
call drifters_set_pe_neighbors(drfts, domain=Domain%domain2d, ermesg=ermesg)
#endif
At this point you should now be able to compile and link without issue.
V. Running MOM4
There are several scripts for running MOM4, however I stuck with running the 'solo' version (mom4_solo_run script). The easiest way to test that the model is working is to download the 'examples'. If you execute the model run script without an example/specification then you will get an information message instructing you on where to get them and how to install them. I've extracted this for easy reference:
Please make sure that the variable 'name' in this script is set to one of box1, box_channel1, bowl1, dome1, gyre1, iom1, mk3p51 or torus1 .
Then download and extract here the tar ball corresponding to this experiment from GFDL anonymous ftp site!
cd whatever_your_work_dir_is
wget ftp.gfdl.noaa.gov:/perm/MOM4/mom4p1_pubrel_dec2009/exp/$name.input.tar.gz (where $name is one of the specified names above)
tar zxvf $name.input.tar.gz
Then download and extract here the tar ball corresponding to this experiment from GFDL anonymous ftp site!
cd whatever_your_work_dir_is
wget ftp.gfdl.noaa.gov:/perm/MOM4/mom4p1_pubrel_dec2009/exp/$name.input.tar.gz (where $name is one of the specified names above)
tar zxvf $name.input.tar.gz
After get one or more of the examples, open the mom4_solo_run script and set the name to which one you want to run and set the npes tothe number of processors you want to use. For example, you may want to run box1 with 2 processors.
Now depening on how you have your shell environment set up you may or may not need to tweak the runscript a little. For example, when I tried to execute the run script, the path to the executable wasn't being prepended to the executable so I would receive file not found errors. Make any necessary adjustments though you may not need to.
At this point you should be able to run the model succesfully. You may need to adjust the length of the run in order to get results depening on the scenario you're running.
VI. Conclusions
At this point the process is a little tedious to get MOM4 running on the Mac. A number of these steps can be eliminated or simplified if the model changes can be added to the repository. Also, a binary distribution of gcc/gfortran would eliminate the need to build the compiler. That being said, the process (aside from the build times) shouldn't take too long. If I can build a version statically, then the whole thing coul be distributed as a zip file but I haven't been successful in that area yet.
These steps have only been tested with the 'solo' model. Coupled versions hypothetically should not need any further modifications but I haven't tested this yet.
How To Download Gfortran On Mac Version
The results so far have been validated visually byinspecting the output files with grads and Panoply http://www.giss.nasa.gov/tools/panoply/. Further testing over longer periods of time will be conducted in the near future.