next up previous
Next: Building with netCDF support Up: Manual installation Previous: Modifications in the source

Compiling and linking SWAN source code

After the necessary modifications are made as described in the previous section, the source code is ready for compilation. All source code is written in Fortran 90 so you must have a Fortran 90 compiler in order to compile SWAN. The source code cannot be compiled with a Fortran 77 compiler. If you intended to use MPI for parallel runs, you must use the command mpif90 instead of the original compiler command or using the Integrated Development Environment e.g., for Visual Fortran (see Installation and User's Guide for MPICH2).

The SWAN source code complies with the ANSI Fortran 90 standard, except for a few cases, where the limit of 19 continuation lines is violated. We are currently not aware of any compiler that cannot deal with this violation of the ANSI standard.

When compiling SWAN you should check that the compiler allocates the same amount of memory for all INTEGERS, REAL and LOGICALS. Usually, for these variables 4 bytes are allocated, on supercomputers (vector or parallel), however, this sometimes is 8 bytes. When a compiler allocates 8 bytes for a REAL and 4 bytes for an INTEGER, for example, SWAN will not run correctly.

Furthermore, SWAN can generate binary MATLAB files on request, which are unformatted. Some compilers, e.g. Compaq Visual Fortran and Intel Fortran version 9.x (or higher), measured record length in 4-byte or longword units and as a consequence, these unformatted files cannot be loaded in MATLAB. Hence, in such as case a compiler option is needed to request 1-byte units, e.g. for Compaq Visual Fortran this is /assume:byterecl and for Intel Fortran version 9.x (or higher) this is -assume byterecl.

The modules (in files swmod1.ftn, swmod2.ftn, m_constants.ftn90, m_fileio.ftn90, serv_xnl4v5.ftn90, mod_xnl4v5.ftn90, SwanGriddata.ftn90, SwanGridobjects.ftn90 and SwanCompdata.ftn90) must be compiled first. Several subroutines use these modules. These subroutines need the compiled versions of the modules before they can be compiled. Linking should be done without any options nor using shared libraries (e.g. math or NAG). It is recommended to rename the executable to swan.exe after linking.

Referring to the previous example, compilation and linking may be done as follows:

mpif90 swmod1.f swmod2.f m_constants.f90 m_fileio.f90 serv_xnl4v5.f90
       mod_xnl4v5.f90 SwanGriddata.f90 SwanGridobjects.f90 SwanCompdata.f90
       ocp*.f swan*.f Swan*.f90 -o swan.exe

next up previous
Next: Building with netCDF support Up: Manual installation Previous: Modifications in the source
The SWAN team 2017-10-26