Personal tools

Difference between revisions of "*NIX platforms"

From MohidWiki

Jump to: navigation, search
(Building MohidWater)
 
(Building MohidWater)
 
(33 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
This is a tutorial on how to install MOHID in linux and derived other platforms. To complement this tutorial, you can also check out some [[Codeplex#Video%20tutorials|video tutorials]] in the [[Codeplex]] article.
 +
 
== Installing ==
 
== Installing ==
  
 
=== Prerequisites ===
 
=== Prerequisites ===
 +
# gcc, g++ and make-tools for linux
 +
# Subversion
 +
# Intel Fortran 9 or greater
  
''NOTE'': this article was written assuming the fortran compiler is ''Intel''. If this is not the case then change where there is written "ifort" with the fortran compiler in use (ex: pgf90, g90, etc...).
+
''NOTE'': this article was written assuming the fortran compiler is ''Intel''. If this is not the case then change where there is written "ifort" with the fortran compiler in use (ex: openf95, pgf90, g90, etc...). In particular, the MOHID code is found to build well with the [[open64]] fortran.
  
 
==== HDF5 libraries ====
 
==== HDF5 libraries ====
To compile Mohid it is mandatory to have the HDF5 [http://hdf.ncsa.uiuc.edu/HDF5/] libraries compiled. In HDF5's web page it is possible to obtain both binary distribuitions and the source code. Most of the times it is necessary to build from source which  takse the following steps:
+
To compile Mohid it is mandatory to have the HDF5 [http://hdf.ncsa.uiuc.edu/HDF5/] libraries compiled.  
# download the source code, e. g. hdf5-1.6.5.tar.gz;
+
 
# <code> > tar -zxvf hdf5-1.6.5.tar.gz</code>
+
===== Extract from Codeplex =====
# <code> > cd hdf5-1.6.5</code>
+
HDF5 libraries are available at Codeplex.
# <code> > F9X=ifort ./configure --enable-fortran (--prefix=$HDF5ROOTDIR --enable-parallel)</code>
+
 
# <code> > make</code>
+
===== Compile from source =====
# <code> > make check</code>
+
In HDF5's web page it is possible to obtain both binary distribuitions and the source code. Most of the times it is necessary to build from source; so download the source code, e. g. hdf5-1.6.5.tar.gz;
# <code> > make install</code>
+
> tar -zxvf hdf5-1.6.5.tar.gz</code>
Libraries may be found in ./hdf5/lib/ and, typically, in /opt/hdf5/hdf5/lib. Detailed information may be found in file ./release_docs/INSTALL .
+
> cd hdf5-1.6.5</code>
 +
> F9X=ifort ./configure --enable-fortran (--prefix=$HDF5ROOTDIR --enable-parallel)</code>
 +
> make</code>
 +
> make check</code>
 +
> make install</code>
 +
Detailed information may be found in file ./release_docs/INSTALL.
  
 
==== Zlib libraries ====
 
==== Zlib libraries ====
To use the HDF5 libraries it is mandatory to have installed the zlib libraries. So install the zlib package for your linux distro. Also, keep a record of where the libz.a library is installed (it might come in handy later on).#
+
To use the HDF5 libraries it is mandatory to have installed the zlib libraries. So install the zlib package for your linux distro. Also, keep a record of where the libz.a library is installed (it might come in handy later on).
 +
 
 +
===== Extract from Codeplex =====
 +
Zlib libraries are available at Codeplex.
  
 
==== Netcdf libraries ====
 
==== Netcdf libraries ====
 
The netcdf libraries are optional since they are not required to run [[MohidWater]]. However they are useful for other modules of the Mohid Suite such as [[ConvertToHDF5]]. You can get them from the [http://www.unidata.ucar.edu/software/netcdf/ official site]. Here's the [[netcdf|report]] on how to build them for windows.
 
The netcdf libraries are optional since they are not required to run [[MohidWater]]. However they are useful for other modules of the Mohid Suite such as [[ConvertToHDF5]]. You can get them from the [http://www.unidata.ucar.edu/software/netcdf/ official site]. Here's the [[netcdf|report]] on how to build them for windows.
  
==== Makefiles ====
+
=== Checking out the MOHID code ===
Make sure you always have the latest version of the Makefiles from the [[SourceSafe]]. Or,
+
Use [[subversion]] to checkout the latest version of the code stored at [[codeplex]].
get a [http://www.mohid.com/hydrogroup/archive.xml test version] of the makefiles from the [http://www.mohid.com/hydrogroup/index.xml hydrogroup page].
+
> mkdir [mohidpath]
 +
> svn co https://mohid.svn.codeplex.com/svn [mohidpath]
  
==== [[sos|Soscmd]] (optional) ====
+
Or update to the latest version of the code
The Source-Off site is a program that allows you to obtain the latest version of the code. This is for advanced users only. If you already have a mohid distro with the source code, then don't bother with this.
+
  > svn update
 
 
To obtain the [[sos|soscmd]] client go to [http://www.sourcegear.com/sos/downloads.html this] page.
 
 
 
To obtain the latest Mohid version
 
#configure the file <code> > makefiles/nix.sos</code>
 
##Give it the server name usually <code>SERVER=sos.mohid.com</code>
 
##Type in your sourcesafe username and password in <code>USER</code> and in <code>PASS</code>
 
##Type in you home directory where the ''.iky'' and ''.key'' files are enclosed. That's it for the configuration!
 
  #--------Users: fill these lines with your sourcesafe data-------------
 
SERVER  :=
 
USER    :=
 
PASS    :=
 
SOSHOME :=
 
PROJECT := $(basename $(TARGET))
 
GET    := soscmd -command GetFile \
 
          -server $(SERVER):8890 \
 
          -name $(USER) -password $(PASS) \
 
          -database "W:\SourceSafe\Mohid_v4\srcsafe.ini" \
 
            -project $(PROJECT) \
 
            -soshome $(SOSHOME) \
 
            -file
 
S      := sos
 
#--------End of sourcesafe data-------------
 
 
 
# type <code> > make nix.sos</code>
 
  
 
=== Building MohidWater ===
 
=== Building MohidWater ===
To compile MohidWater using the makefiles from the main path, first make sure the source file ending is capitalized (F90, not f90). Afterwards, execute the compilation steps:
+
Make sure that you have Intel Fortran installed (any version later than 9.x should do). Follow instructions in the README file that is in the Codeplex distribution, under the Linux folder (you are required to create the Editme.mk file from a template and edit your hdf5 and Zlib libraries paths).
# <code> > for i in `find . | grep .f90 | grep -v 'GOTMvar'`; do  mv $i `echo $i | sed -e 's/f90/F90/'`;done</code>
 
# <code> > source /opt/intel/fc/9.0/bin/ifortvars.sh</code>
 
# <code> > make nix</code>
 
  
The first line is required because linux is sensitive to capitalization whereas windows wasn't. The second line is required in order to properly configure intel fortran 9.0 to work. It may be unnecessary in future versions of intel fortran.
+
To build the Linux makefile solution, just type
 +
> make Nix
  
 
To clean the distribution, type:
 
To clean the distribution, type:
# <code> > make nix.clean</code>
+
> make Nix.clean
 
 
== Developping [[makefile]]s ==
 
  
To develop new makefiles for future or current modules, edit the [[makefile]] in the [[Module Shell]] from the [[Mohid]] [[SourceSafe]]. Please bear in mind that it must work under
+
Make sure you also check our [[codeplex|videos]].
in windows, as well as under linux.
 
  
=== Using [[sos|SourceOffSite]] in the [[makefile]] ===
+
== Running Mohid projects in linux ==
  
An interesting feature of the makefiles would be that they automatically access the [[SourceSafe]]
+
===General guidelines that change from windows===
repository. To do so one can use the [[sos|soscmd]] command line client. An example can be found on the [[*NIX platforms|Sample makefile]].
+
# There are no graphical interfaces available. No GUI, no PostProcessor and no GIS.
 +
# Linux is case-sensitive. This is very important.
 +
# Linux reads paths to files and folders using the slash '/' instead of the backslash '\'.
  
To use it type:
+
Required files for mohidwater to run (preserve letters capitalization!). You must copy (and edit) the files manually:
# <code> > make nix.sos</code>
+
exe/nomfich.dat
 +
exe/tree.dat
  
 
== TroubleShooting ==
 
== TroubleShooting ==
Line 100: Line 87:
 
A: Probably you need to specify  to link against the libz.a library. Identify the exactly
 
A: Probably you need to specify  to link against the libz.a library. Identify the exactly
 
the location of libz.a (ex: in my system it can be found at /opt/zlib/lib/libz.a)
 
the location of libz.a (ex: in my system it can be found at /opt/zlib/lib/libz.a)
then add the following line in MohidWater makefile:
+
then add edit accordingly the ''Solutions/Linux/Editme.mk'' file.
 
 
LIBS_NIX = \
 
          $(BASE2LIB) \
 
          $(BASE1LIB) \
 
          $(LIB_HDF5_NIX)/libhdf5_fortran.a \
 
          $(LIB_HDF5_NIX)/libhdf5.a \
 
          $(LIB_HDF5_NIX)/libhdf5_hl.a \
 
          $(LIB_NETCDF_NIX)/libnetcdf.a \
 
          /opt/zlib/lib/libz.a
 
  
 
==See also==
 
==See also==
 
*[[Makefile]]
 
*[[Makefile]]
 
*[[Mohid Makefile]]
 
*[[Mohid Makefile]]
 +
*[[ifort]]
 +
*[[open64]]
  
 
[[Category:Technology]]
 
[[Category:Technology]]
 
[[Category:Linux]]
 
[[Category:Linux]]
 
[[Category:Makefile]]
 
[[Category:Makefile]]

Latest revision as of 19:15, 8 September 2014

This is a tutorial on how to install MOHID in linux and derived other platforms. To complement this tutorial, you can also check out some video tutorials in the Codeplex article.

Installing

Prerequisites

  1. gcc, g++ and make-tools for linux
  2. Subversion
  3. Intel Fortran 9 or greater

NOTE: this article was written assuming the fortran compiler is Intel. If this is not the case then change where there is written "ifort" with the fortran compiler in use (ex: openf95, pgf90, g90, etc...). In particular, the MOHID code is found to build well with the open64 fortran.

HDF5 libraries

To compile Mohid it is mandatory to have the HDF5 [1] libraries compiled.

Extract from Codeplex

HDF5 libraries are available at Codeplex.

Compile from source

In HDF5's web page it is possible to obtain both binary distribuitions and the source code. Most of the times it is necessary to build from source; so download the source code, e. g. hdf5-1.6.5.tar.gz;

> tar -zxvf hdf5-1.6.5.tar.gz</code>
> cd hdf5-1.6.5</code>
> F9X=ifort ./configure --enable-fortran (--prefix=$HDF5ROOTDIR --enable-parallel)</code>
> make</code>
> make check</code>
> make install</code>

Detailed information may be found in file ./release_docs/INSTALL.

Zlib libraries

To use the HDF5 libraries it is mandatory to have installed the zlib libraries. So install the zlib package for your linux distro. Also, keep a record of where the libz.a library is installed (it might come in handy later on).

Extract from Codeplex

Zlib libraries are available at Codeplex.

Netcdf libraries

The netcdf libraries are optional since they are not required to run MohidWater. However they are useful for other modules of the Mohid Suite such as ConvertToHDF5. You can get them from the official site. Here's the report on how to build them for windows.

Checking out the MOHID code

Use subversion to checkout the latest version of the code stored at codeplex.

> mkdir [mohidpath]
> svn co https://mohid.svn.codeplex.com/svn [mohidpath]

Or update to the latest version of the code

> svn update

Building MohidWater

Make sure that you have Intel Fortran installed (any version later than 9.x should do). Follow instructions in the README file that is in the Codeplex distribution, under the Linux folder (you are required to create the Editme.mk file from a template and edit your hdf5 and Zlib libraries paths).

To build the Linux makefile solution, just type

> make Nix

To clean the distribution, type:

> make Nix.clean

Make sure you also check our videos.

Running Mohid projects in linux

General guidelines that change from windows

  1. There are no graphical interfaces available. No GUI, no PostProcessor and no GIS.
  2. Linux is case-sensitive. This is very important.
  3. Linux reads paths to files and folders using the slash '/' instead of the backslash '\'.

Required files for mohidwater to run (preserve letters capitalization!). You must copy (and edit) the files manually:

exe/nomfich.dat
exe/tree.dat

TroubleShooting

Q: the makefile keeps giving me errors :(

A:Here's a list of what could be causing these errors:

  1. Open the makefiles and check that fields are properly filled.
  2. Make sure that mod and bin directories exist in the module's folder. Otherwise simply make them with the mkdir command.
  3. Make sure that "ifort" is a valid command. If it isn't then you probably didn't loaded its environment variables. Type "source /opt/intel/fc/9.0/bin/ifortvars.sh" for that.
  4. Make sure that the intel fortran compiler was properly installed.

Q: the makefile complains when compiling ModuleGOTM.f90

A: Probably you have to rename

GOTMVariables_in.f90 ---> GOTMvariables_in.f90
GOTMVariables_out.f90 ---> GOTMvariables_out.f90.

This error shows up in linux because it's case-sensitive whereas windows isn't. Also, make sure that the extension is written in lower case.

Q: By the time i'm linking the final MohidWater binary I get some error about unreferenced functions "compress2" and others in HDF5 files...

A: Probably you need to specify to link against the libz.a library. Identify the exactly the location of libz.a (ex: in my system it can be found at /opt/zlib/lib/libz.a) then add edit accordingly the Solutions/Linux/Editme.mk file.

See also