If you want the version of gfortran to match the versions of gcc, g, etc. Installed on your machine, download the appropriate version of gfortran from here. The R developers and SciPy developers recommend this method. The easiest way to get gcc an gfortran is through MacPorts. MacPorts is a package management system that simplifies the installation of software on the Mac. To install go to www.macports.org and download the appropriate MacPorts for your system. As such it fully supports compilation into fat files like gfortran -arch i386 -arch ppc -arch x8664 -arch ppc64 t.f -o t on both Intel Macs and PowerPC Macs (32- and 64-bit). Dependent libraries are fat as well, avoiding problems known from other Fortran builds (such as those from HPC).
Also, fink install gfortran did not work, but this may be the one to use: fink install gfortran-shlibs virtual library This installs gcc47-shlibs-4.7.0-100. Not sure what gfortran version it is, but I presume that gfortran is just a part of GCC and probably has the same version number???
I. Introduction
The MOM4 ocean model is usually exectued in parallel on supercomputers. However, not every researcher has access to super-computers 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.
II. What You'll Need
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. MacPorts is a package management system that simplifies the installation of software on the Mac. To install go to www.macports.org and download the appropriate MacPorts for your system.
By default MacPorts gets installed on /opt/local Make sure that, after installation your PATH (and MANPATH) variables are modified to find the newly installed executable called 'port' (see also http://guide.macports.org/). Afterwards do the following:
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 at gcc.gnu.org.
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.
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. MPICH2
I used the latest version of mpich2 via Mac Ports. To install
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 ssh 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 (you may need to open a new terminal window). 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.
First 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.
Then create a file called .mpd.conf in your home directory (~/.mpd.conf) with the contents:
and make it 600 permissions (chmod 600 ~/.mpd.conf).
When done, you must 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 the mpd.hosts file via the -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. Celtx 2.9.1 download mac. 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
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
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.
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.
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
At this point you should now be able to compile and link without issue.
V. Running MOM4
Ameritron 10 meter mods pdf free. 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
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. How to download mac video. 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.
How To Download Gfortran On Mac Os
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
How To Download Gfortran On Mac File
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.
Gfortran Mac Os
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 Computer
The results so far have been validated visually byinspecting the output files with grads and Panoply http://www.giss.nasa.gov/tools/panoply/. Enregistrer en pdf document word: software free download. Further testing over longer periods of time will be conducted in the near future.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2020
Categories |