Difference between revisions of "ROMS UNSW2008"

From WikiROMS
Jump to navigationJump to search
Line 7: Line 7:
'''A tutorial for new ROMS users will be held at the UNSW Computer Labs on Monday 30 March 2009, immediately prior to the ROMS Sydney 2009 User Workshop at the Sydney Institute of Marine Sciences, 31 March to 2 April 2009.'''
'''A tutorial for new ROMS users will be held at the UNSW Computer Labs on Monday 30 March 2009, immediately prior to the ROMS Sydney 2009 User Workshop at the Sydney Institute of Marine Sciences, 31 March to 2 April 2009.'''


{{note}}''This tutorial is intended for complete newcomers to ROMS. It assumes basic knowledge of working in a UNIX environment, and that the essential components required to compile and execute ROMS are already installed on the host computer network. This wiki page borrows heavily from David's Robertson's excellent [[ROMS_Cygwin|Installing ROMS under Cygwin]] tutorial where you will find more information about setting up the required computing environment (compilers, libraries etc.) for ROMS.''
{{note}}''<span class="blue">This tutorial is intended for complete newcomers to ROMS. It assumes basic knowledge of working in a UNIX environment, and that the essential components required to compile and execute ROMS are already installed on the host computer network. This wiki page borrows heavily from David's Robertson's excellent [[ROMS_Cygwin|Installing ROMS under Cygwin]] tutorial where you will find more information about setting up the required computing environment (compilers, libraries etc.) for ROMS.</span>''
   
   
In the course of the tutorial, we cover how to download the code, configure it for a set of applications, and run the model. Error messages that arise during the configuration process will be explained so that these can better be debugged when users return to their home institutions and try to work through this process again.  
In this tutorial, we cover how to download the code, configure it for an application, and run the model. Error messages that arise during the configuration process will be explained so that these can better be debugged when users return to their home institutions and try to work through this process again.  


This wiki entry will be updated on tutorial day as we discover the questions that arise when a set of novice users approach using ROMS for the first time.  
This wiki entry will be updated on tutorial day as we discover the questions that arise when a set of novice users approach using ROMS for the first time.  
Line 26: Line 26:
::<div class="box"><span class="forestGreen">cd ~<br />mkdir src</span></div>
::<div class="box"><span class="forestGreen">cd ~<br />mkdir src</span></div>


:*Check out the ROMS source code replacing 'bruce' with the ROMS user name you registered with.
:*Check out the ROMS source code replacing <span class="forestGreen">''bruce''</span> with the ROMS user name you registered with.
::<div class="box"><span class="forestGreen">svn checkout --username bruce <nowiki>https://www.myroms.org/svn/src/trunk src</nowiki></span></div> Note the target directory <span class="forestGreen">src</span> at the end of the command. If your code ends up in the wrong place, you may have omitted this.  
::<div class="box"><span class="forestGreen">svn checkout --username bruce <nowiki>https://www.myroms.org/svn/src/trunk src</nowiki></span></div> Note the target directory <span class="forestGreen">src</span> at the end of the command. If your code ends up in the wrong place, you may have omitted this.  


You will see many lines stream by indicating the files that are being added to your src directory. When it finishes, you can type <span class="forestGreen">ls src</span> to see the contents of the directory.  
You will see many lines stream by indicating the files that are being added to your src directory. When it finishes, you can type <span class="forestGreen">ls src</span> to see the contents of the directory.  


To see the contents of the directory where the code is downloaded for this tutorial, type this
To see the contents of the directory where the code is downloaded for this tutorial, type this:
::<div class="box"><span class="forestGreen">cd /tmp/jwilkin<br />ls src</span></div>
::<div class="box"><span class="forestGreen">cd /tmp/jwilkin<br />ls src</span></div>


Line 39: Line 39:
:*In your home directory, or in whichever directory you want to organize your ROMS projects, create a new folder named <span class="red">Projects</span> and change into it.
:*In your home directory, or in whichever directory you want to organize your ROMS projects, create a new folder named <span class="red">Projects</span> and change into it.
::<div class="box"><span class="forestGreen">cd ~<br />mkdir Projects<br />cd Projects</span></div>
::<div class="box"><span class="forestGreen">cd ~<br />mkdir Projects<br />cd Projects</span></div>
:*Create a folder named <span class="red">Upwelling</span> and change into it. 'Upwelling' is the name of the [[Test Cases|ROMS test case]] we are going to compile and run.
:*Create a folder named <span class="red">upwelling</span> and change into it. '''upwelling''' is the name of the [[Test Cases|ROMS test case]] we are going to compile and run.
::<div class="box"><span class="forestGreen">mkdir Upwelling<br />cd Upwelling</span></div>
::<div class="box"><span class="forestGreen">mkdir upwelling<br />cd upwelling</span></div>


:*Copy the <span class="red">build.bash</span> file distributed with ROMS to your <span class="red">Projects/Upwelling</span> directory.
:*Copy the <span class="red">build.bash</span> file distributed with ROMS to your <span class="red">Projects/upwelling</span> directory.
::<div class="box"><span class="forestGreen">cp /tmp/jwilkin/src/ROMS/Bin/build.bash .</span></div>
::<div class="box"><span class="forestGreen">cp /tmp/jwilkin/src/ROMS/Bin/build.bash .</span></div>


Next we need to configure a few options inside <span class="red">build.bash</span> so that it finds the directories where the source code and your Project are located.  
Next we need to configure a few options inside <span class="red">build.bash</span> so that it finds the directories where the source code and your Project are located.  


:*Open the <span class="red">build.bash</span> script you just copied into your <span class="red">Upwelling</span> directory using your preferred text editor, e.g. vi.
:*Open the <span class="red">build.bash</span> script you just copied into your <span class="red">upwelling</span> directory using your preferred text editor, e.g. vi.
::<div class="box"><span class="forestGreen">vi build.bash</div>
::<div class="box"><span class="forestGreen">vi build.bash</div>


:*Scroll down until you find <span class="orange">MY_PROJECT_DIR</span> and set it as follows.  
:*Scroll down until you find <span class="orange">MY_PROJECT_DIR</span> and set it as follows.  
::<div class="box"> <span class="blue">export</span> <span class="red">MY_PROJECT_DIR</span>=${<span class="red">HOME</span>}/Projects/Upwelling</div> This obviously assumes you put <span class="red">Projects/Upwelling</span> under your home directory.  
::<div class="box"> <span class="blue">export</span> <span class="red">MY_PROJECT_DIR</span>=${<span class="red">HOME</span>}/Projects/upwelling</div> This obviously assumes you put <span class="red">Projects/upwelling</span> under your home directory.  


If you frequently move your ROMS project between hosts where you have a different directory structure, e.g. a temporary scratch space, you can use the <span class="orange">MY_ROOT_DIR</span> variable to minimize the changes you make to <span class="red">build.bash</span>.
If you frequently move your ROMS project between hosts where you have a different directory structure, e.g. a temporary scratch space, you can use the <span class="orange">MY_ROOT_DIR</span> variable to minimize the changes you make to <span class="red">build.bash</span>.


:*For example:  
:*For example:  
::<div class="box"><span class="blue">export</span> <span class="red">MY_ROOT_DIR</span>=/usr/scratch/bruce<br /><span class="blue">export</span> <span class="red">MY_PROJECT_DIR</span>=${<span class="red">MY_ROOT_DIR</span>}/Projects/Upwelling</div>
::<div class="box"><span class="blue">export</span> <span class="red">MY_ROOT_DIR</span>=/usr/scratch/bruce<br /><span class="blue">export</span> <span class="red">MY_PROJECT_DIR</span>=${<span class="red">MY_ROOT_DIR</span>}/Projects/upwelling</div>


Next we tell <span class="red">build.bash</span> where to find the ROMS source code downloaded from the svn repository (which you can keep up to date the <span class="forestGreen">svn update</span> command - see more on this at LINK ). Note that most of the source code changes you make to customize ROMS will be made in your Projects space, and need not be made to the downloaded code directly. We will discuss exceptions to this during the tutorial, and how source code modifications interact with svn.
Next we tell <span class="red">build.bash</span> where to find the ROMS source code downloaded from the svn repository (which you can keep up to date the <span class="forestGreen">svn update</span> command - see more on this at LINK ). Note that most of the source code changes you make to customize ROMS will be made in your Projects space, and need not be made to the downloaded code directly. We will discuss exceptions to this during the tutorial, and how source code modifications interact with svn.
Line 64: Line 64:
::<div class="box"><span class="blue">export</span> <span class="red">MY_ROMS_SRC</span>=${<span class="red">MY_ROOT_DIR</span>}/src</div> assuming this is the relative path in which you keep your source code on the various machines you work on.  
::<div class="box"><span class="blue">export</span> <span class="red">MY_ROMS_SRC</span>=${<span class="red">MY_ROOT_DIR</span>}/src</div> assuming this is the relative path in which you keep your source code on the various machines you work on.  


Make sure that <span class="orange">MY_CPP_FLAGS</span> is '''not''' set. Sometimes this is set in the distributed buiuld.bash exmaple. Comment out options with the # symbol like so:
Make sure that <span class="orange">MY_CPP_FLAGS</span> is '''not''' set. Sometimes this is set in the distributed build.bash exmaple. Comment out options with the # symbol like so:
::<div class="box"><span class="blue">#export MY_CPP_FLAGS="-DNPZD_POWELL"</span> </div>
::<div class="box"><span class="blue">#export MY_CPP_FLAGS="-DAVERAGES"</span> </div>


:*Save and close the <span class="red">build.bash</span> file.
The UNSW Computer Lab machines are single core, so we need to tell <span class="red">build.bash</span> not to assume MPI parallel compilation.  


:*Comment out the options for <span class="orange">USE_MPI</span> and <span class="orange">USE_MPIF90</span>
::<div class="box"><span class="blue">#export USE_MPI=on <br>#export USE_MPIF90=on</span> </div>
:*If you were compiling in parallel you would leave the default entries in <span class="red">build.bash</span>. We also leave the compiler option as the default because this says use the <span class="forestGreen">ifort</span> (Intel FORTRAN) compiler which is what we want on the UNSW machines.
::<div class="box"><span class="blue">export</span>            <span class="red">USE_MPI</span>=<br /><span class="blue">export</span>        <span class="red">USE_MPIF90</span>=<br /><span class="blue">export</span>              <span class="red">FORT</span>=ifort</div>
:*We leave the compiler option as the default because this says use the <span class="forestGreen">ifort</span> (Intel FORTRAN) compiler which is what we want on the UNSW machines.
::<div class="box">
<span class="blue">export</span>              <span class="red">FORT</span>=ifort</div>
Save and close the <span class="red">build.bash</span> file.
 


We will return later to the configuration of paths to the compiler and libraries.


:*We are compiling in serial using the <span class="red">g95</span> compiler so make your <span class="red">build.bash</span> match the following:
::<div class="box"><span class="blue">export</span>            <span class="red">USE_MPI</span>=<br /><span class="blue">export</span>        <span class="red">USE_MPIF90</span>=<br /><span class="blue">export</span>              <span class="red">FORT</span>=g95</div>


:*You will need to add the following two lines anywhere '''above''' the line that reads <span class="blue">cd</span> ${<span class="red">MY_ROMS_SRC</span>}
:*You will need to add the following two lines anywhere '''above''' the line that reads <span class="blue">cd</span> ${<span class="red">MY_ROMS_SRC</span>}
Line 82: Line 96:
We need two more files in Projects/upwelling to configure and run ROMS. We copy the versions downloaded with svn because these are files you will work with locally when you experiment with changes to the test case example configuration.  
We need two more files in Projects/upwelling to configure and run ROMS. We copy the versions downloaded with svn because these are files you will work with locally when you experiment with changes to the test case example configuration.  


:*Copy files <span class="red">ocean_upwelling.in</span> and <span class="red">upwelling.h</span> into the <span class="red">Projects/Upwelling</span> directory you just created.
:*Copy files <span class="red">ocean_upwelling.in</span> and <span class="red">upwelling.h</span> into the <span class="red">Projects/upwelling</span> directory you just created.


::<div class="box"><span class="forestGreen">cd ~/Projects/upwelling<br />cp /tmp/jwilkin/src/ROMS/External/ocean_upwelling.in . <br>cp /tmp/jwilkin/src/ROMS/Include/upwelling.h .</span></div>
::<div class="box"><span class="forestGreen">cd ~/Projects/upwelling<br />cp /tmp/jwilkin/src/ROMS/External/ocean_upwelling.in . <br>cp /tmp/jwilkin/src/ROMS/Include/upwelling.h .</span></div>
Line 112: Line 126:
Getting past the first few errors with compilation is often tricky. Carefully read any error messages you get for clues on what might be wrong with your configuration
Getting past the first few errors with compilation is often tricky. Carefully read any error messages you get for clues on what might be wrong with your configuration


:*<div class="box">Compilers/../ROMS/Include/cppdefs.h:709:22: <br>error: /student/0/a0000020/Projects/upwelling/upwelling.h: No such file or directory</div> This says the file <span class="red">upwelling.h</span> is not where Build expects it to be, which is in <span class="orange">MY_PROJECT_DIR</span>. You set this to <span class="red">~/Projects/Upwelling</span>.
:*<div class="box">Compilers/../ROMS/Include/cppdefs.h:709:22: <br>error: /student/0/a0000020/Projects/upwelling/upwelling.h: No such file or directory</div> This says the file <span class="red">upwelling.h</span> is not where Build expects it to be, which is in <span class="orange">MY_PROJECT_DIR</span>. You set this to <span class="red">~/Projects/upwelling</span>.


:*<div class="box">cp: cannot stat `/opt/intelsoft/netcdf/include/netcdf.mod': No such file or directory</div> This says the netcdf include file <span class="red">upwelling.h</span> is not where Build expects it to be.
:*<div class="box">cp: cannot stat `/opt/intelsoft/netcdf/include/netcdf.mod': No such file or directory</div> This says the netcdf include file <span class="red">upwelling.h</span> is not where Build expects it to be.

Revision as of 22:44, 12 March 2009

Installing and Running ROMS for First Time Users

A Tutorial at the UNSW Computer Labs, 30 March 2009

John Wilkin - this is work in progress

A tutorial for new ROMS users will be held at the UNSW Computer Labs on Monday 30 March 2009, immediately prior to the ROMS Sydney 2009 User Workshop at the Sydney Institute of Marine Sciences, 31 March to 2 April 2009.

NoteThis tutorial is intended for complete newcomers to ROMS. It assumes basic knowledge of working in a UNIX environment, and that the essential components required to compile and execute ROMS are already installed on the host computer network. This wiki page borrows heavily from David's Robertson's excellent Installing ROMS under Cygwin tutorial where you will find more information about setting up the required computing environment (compilers, libraries etc.) for ROMS.

In this tutorial, we cover how to download the code, configure it for an application, and run the model. Error messages that arise during the configuration process will be explained so that these can better be debugged when users return to their home institutions and try to work through this process again.

This wiki entry will be updated on tutorial day as we discover the questions that arise when a set of novice users approach using ROMS for the first time.

Download ROMS

The disk space available on the UNSW Computer Lab machines is quite limited, so for the purposes of this tutorial we have downloaded the ROMS source code to /tmp/jwilkin/src on host matht001. Instructions below will explain how to point the build.bash script that compiles ROMS to this directory.

To download the code to your own machine, these are the steps you follow:

  • You must have already registered on the ROMS portal and obtained your ROMS username/password as indicated in the Register.
  • Create a src folder where you will keep the ROMS source code. You can place this wherever you wish in your directory tree (here we assume under your home directory "~") and name it whatever you like.
cd ~
mkdir src
  • Check out the ROMS source code replacing bruce with the ROMS user name you registered with.
svn checkout --username bruce https://www.myroms.org/svn/src/trunk src
Note the target directory src at the end of the command. If your code ends up in the wrong place, you may have omitted this.

You will see many lines stream by indicating the files that are being added to your src directory. When it finishes, you can type ls src to see the contents of the directory.

To see the contents of the directory where the code is downloaded for this tutorial, type this:

cd /tmp/jwilkin
ls src

Customize the Build Script

The ROMS source code comes with a build script in the ROMS/Bin directory. Examples written with bash (build.bash) and csh (build.sh) are provided. The UNSW Computer Lab machines are configured to use bash as the default login shell, so we will work with build.bash. A full description of the build script can be found here.

  • In your home directory, or in whichever directory you want to organize your ROMS projects, create a new folder named Projects and change into it.
cd ~
mkdir Projects
cd Projects
  • Create a folder named upwelling and change into it. upwelling is the name of the ROMS test case we are going to compile and run.
mkdir upwelling
cd upwelling
  • Copy the build.bash file distributed with ROMS to your Projects/upwelling directory.
cp /tmp/jwilkin/src/ROMS/Bin/build.bash .

Next we need to configure a few options inside build.bash so that it finds the directories where the source code and your Project are located.

  • Open the build.bash script you just copied into your upwelling directory using your preferred text editor, e.g. vi.
vi build.bash
  • Scroll down until you find MY_PROJECT_DIR and set it as follows.
export MY_PROJECT_DIR=${HOME}/Projects/upwelling
This obviously assumes you put Projects/upwelling under your home directory.

If you frequently move your ROMS project between hosts where you have a different directory structure, e.g. a temporary scratch space, you can use the MY_ROOT_DIR variable to minimize the changes you make to build.bash.

  • For example:
export MY_ROOT_DIR=/usr/scratch/bruce
export MY_PROJECT_DIR=${MY_ROOT_DIR}/Projects/upwelling

Next we tell build.bash where to find the ROMS source code downloaded from the svn repository (which you can keep up to date the svn update command - see more on this at LINK ). Note that most of the source code changes you make to customize ROMS will be made in your Projects space, and need not be made to the downloaded code directly. We will discuss exceptions to this during the tutorial, and how source code modifications interact with svn.

  • Set MY_ROMS_SRC to the location of the source code:
export MY_ROMS_SRC=/tmp/jwilkin/src
In practise, you will probably do something more like this:
export MY_ROMS_SRC=${MY_ROOT_DIR}/src
assuming this is the relative path in which you keep your source code on the various machines you work on.

Make sure that MY_CPP_FLAGS is not set. Sometimes this is set in the distributed build.bash exmaple. Comment out options with the # symbol like so:

#export MY_CPP_FLAGS="-DAVERAGES"

The UNSW Computer Lab machines are single core, so we need to tell build.bash not to assume MPI parallel compilation.

  • Comment out the options for USE_MPI and USE_MPIF90
#export USE_MPI=on
#export USE_MPIF90=on
  • If you were compiling in parallel you would leave the default entries in build.bash. We also leave the compiler option as the default because this says use the ifort (Intel FORTRAN) compiler which is what we want on the UNSW machines.
export USE_MPI=
export USE_MPIF90=
export FORT=ifort


  • We leave the compiler option as the default because this says use the ifort (Intel FORTRAN) compiler which is what we want on the UNSW machines.

export FORT=ifort


Save and close the build.bash file.




  • You will need to add the following two lines anywhere above the line that reads cd ${MY_ROMS_SRC}
export NETCDF_INCDIR=/usr/local/include
export NETCDF_LIBDIR=/usr/local/lib

Copy the input and CPPDEFS options files

We need two more files in Projects/upwelling to configure and run ROMS. We copy the versions downloaded with svn because these are files you will work with locally when you experiment with changes to the test case example configuration.

  • Copy files ocean_upwelling.in and upwelling.h into the Projects/upwelling directory you just created.
cd ~/Projects/upwelling
cp /tmp/jwilkin/src/ROMS/External/ocean_upwelling.in .
cp /tmp/jwilkin/src/ROMS/Include/upwelling.h .

View the file upwelling.h. It contains all the C-Pre-Processor (CPP) options that the compiler interprets to activate certain source code options within ROMS.

View the file ocean_upwelling.in. It contains the inputs options that ROMS reads at run time to set options that need not be fixed at compile time.

Now we are ready to compile ROMS by executing the build.bash script.


Compile ROMS

Before you run ROMS, you need to compile it to create an executable oceanS file (S for serial or single processor computer), or oceanM file (if using MPI on a parallel computer).

  • Go to your upwelling project directory:
cd ~/Projects/upwelling
  • Then type:
./build.bash
  • If lots of stuff comes on the screen then compilation is proceeding, and make take some time.
  • If the build process ends quickly with an error, then it is likely that build.bash does not point to the correct location for the upwelling.h file, the compiler, or libraries.


Compile time error messages

Getting past the first few errors with compilation is often tricky. Carefully read any error messages you get for clues on what might be wrong with your configuration

  • Compilers/../ROMS/Include/cppdefs.h:709:22:
    error: /student/0/a0000020/Projects/upwelling/upwelling.h: No such file or directory
    This says the file upwelling.h is not where Build expects it to be, which is in MY_PROJECT_DIR. You set this to ~/Projects/upwelling.
  • cp: cannot stat `/opt/intelsoft/netcdf/include/netcdf.mod': No such file or directory
    This says the netcdf include file upwelling.h is not where Build expects it to be.