Difference between revisions of "FJORD TIDAL CASE"

From WikiROMS
Jump to navigationJump to search
Line 1: Line 1:
<div class="title">Fjord Tidal Test Case</div>
<div class="title">Fjord Tidal Test Case</div>
 
<br>
<br>
{| style="width:98%; background:yellow; margin-top:10px; border:1px solid red;" cellpadding="5" cellspacing="0"
{| style="width:98%; background:yellow; margin-top:10px; border:1px solid red;" cellpadding="5" cellspacing="0"
|-
|-
Line 6: Line 7:
|}
|}


This tutorial will go over some of the basic steps to set up a ROMS realistic application (yet, this is a very simple one). This tutorial is also a demonstration of how to use EASYGRID, a "quick-and-dirty" matlab script to make ROMS grids and initialization files.
There are a few ways to setup tidal forcing in ROMS ([[Tidal_Forcing|...learn more about tides in ROMS]]). This tutorial will explain the simplest way, which is to prescribe (<span class="red">analytically</span>) tidal variations in sea-surface height at a open boundary (this uses a FLATHER/CHAPMAN combination).  
I learned this trick from '''hetland''' in this [https://www.myroms.org/forum/viewtopic.php?p=249&sid=a059e4ffb90b2ad96b0a5463875277fe forum post] (at the bottom).  
<br>
<br>
<br>
<br>
{{warning}} '''PREREQUISITES:''' This tutorial assumes that you have (1) downloaded ROMS, (2) installed it in your computer (or cluster), (3) tested it by compiling and running one of the included test cases, and (4) installed [[MEXNC|MEXNC, SNCTOOLS and the ROMS Matlab tool-kit]]. If you haven't done all the above, check the [[Getting_Started|"Getting Started"]] and [[Tutorials|"Tutorials"]] WikiROMS sections.
{{warning}} <span class="red">RESTRICTIONS:</span> This technique is ONLY applicable in cases with one relatively narrow open boundary (say < 10 km). In this cases, the tidal height along the open boundary is essentially uniform and can be prescribed analytically.
<br>
<br>
<br>
<br>
----
{{warning}} <span class="red">PREREQUISITES:</span> This tutorial assumes that you have (1) downloaded ROMS, (2) installed it in your computer (or cluster), and (3) tested it by compiling and running one of the included test cases. If you haven't done all the above, check the [[Getting_Started|"Getting Started"]] and [[Tutorials|"Tutorials"]] WikiROMS sections.
<br>
<br>
<br>
<br>
'''Geographical Preamble:''' This application is for Ship Harbour, an estuarine fjord in Nova Scotia, Canada. [http://maps.google.ca/maps/ms?hl=en&ie=UTF8&msa=0&ll=44.774524,-62.817421&spn=0.177915,0.310707&t=h&z=12&msid=109937017048460614209.00044a9aa08be20958242 Click here] to see the location in Google. Tides are semidiurnal and tidal range is 1.4 m on average and 2 m on spring tides. For now I will only include tidal forcing, however, there is a river at the uppermost end of the estuary, which discharges freshwater at an annual average rate of 18 m<sup>3</sup> s<sup>-1</sup>. I plan to write another tutorial on how to add a river, but for now is only tides.  
 
==Geographical Preamble==
This application is for Ship Harbour, an estuarine fjord in Nova Scotia, Canada. [http://maps.google.ca/maps/ms?hl=en&ie=UTF8&msa=0&ll=44.774524,-62.817421&spn=0.177915,0.310707&t=h&z=12&msid=109937017048460614209.00044a9aa08be20958242 Click here] to see the location in Google. Tides are semidiurnal and tidal range is 1.4 m on average and 2 m on spring tides. Ship Harbour is a long embayment (~7 km) with an open (EAST) boundary of ~1 km, therefore it is an ideal candidate for the type of analytical tidal forcing taught in this tutorial. For now I will only include tidal forcing, however, there is a river at the uppermost end of the estuary, which discharges freshwater at an annual average rate of 18 m<sup>3</sup> s<sup>-1</sup>. I plan to write another tutorial on how to add a river, but for now is only tides.  
<br>
<br>
<br>
<br>
==Grid Generation==
==Grid Generation==
The first step to set up a realistic application is to set up a realistic grid. There are several [[Grid_Generation|software packages]] to generate ROMS grids; [[seagrid|SEAGRID]] and [http://www.marine.csiro.au/~sak007/ GRIDGEN] being the most popular ones. Here I will use the much-less-fancy EASYGRID, which I see it as a beginner's tool. EASYGRID is one file (easygrid.m) which makes it easier to understand the steps required to generate a simple grid (i.e. useful as a learning or teaching tool) and also reduces the required steps to get the software up and running (i.e. downloading and compiling dependencies)... hence you can play with grid-making and ROMS-running earlier in the game of ROMS-learning. 
The first step to set up a realistic application is to set up a realistic grid. There are several [[Grid_Generation|software packages]] to generate ROMS grids; [[seagrid|SEAGRID]] and [http://www.marine.csiro.au/~sak007/ GRIDGEN] being the most popular ones. I used the much-less-fancy EASYGRID, which is a bit easier to get up and running.
<br>
<br>
===Download EASYGRID===
*Download EASYGRID here (I will add link a bit later...)
*Add the location where you placed EASYGRID to Matlab's search path.
*Dependencies: EASYGRID uses [[MEXNC|MEXNC, SNCTOOLS]] and a few scripts (spheric_dist.m , smth_bath.m , pcolorjw.m) from the [[MEXNC#How to install ROMS Matlab tool-kit?|ROMS Matlab tool-kit]]. Follow links above for instruction on how to download and install these dependencies.
<br>
<br>
===Get bathymetry===
You will need a bathymetry .mat file containing 3 vectors (xbathy, ybathy and zbathy), where xbathy = Longitude, ybathy = Latitude and zbathy = depth (positive, in meters). Vectors xbathy and ybathy are in [http://en.wikipedia.org/wiki/Decimal_degrees decimal degrees]. For more information about bathymetry for ROMS, click [[Grid_Generation#Bathymetry|HERE]].
 
 
There easiest way to get bathymetry data (that I know) is to use Rich Signell's ''read_srtm30plus.m'' Matlab script. Instant bathymetry in 1 line of Matlab code! Click [[seagrid|HERE]] for instruction to get and use ''read_srtm30plus.m''.
 
 
The most difficult way to get bathymetry data (that I know) is to scan a chart and then digitize it using your mouse and a digitizing software like [http://www.ssg-surfer.com/ssg/product_info.php?products_id=133 Didger] (sorry, I am not aware of any good digitizing free software).
 
 
For this tutorial, you should download this bathymetry file (I will add link soon). I created it by merging two bathymetry files... one high-resolution digitized from a chart and another coarser-resolution using ''read_srtm30plus.m''
<br>
<br>
 
 
===Get coastline===
In EASYGRID, the coastline is only used for plotting and it therefore not indispensable. However, a later step of mask editing (using editmask.m) requires a coastline file. For both, EASYGRID and editmask.m, the coastline should be in a .mat file and should contain 2 vectors named "lat" and "lon" (both in units of [http://en.wikipedia.org/wiki/Decimal_degrees decimal degrees]).
 
 
An easy way to get coastline data is at NOAA's [http://rimmer.ngdc.noaa.gov/coast/ Coastline Extractor]. Remember to select '''Matlab''' as format option (not default). Again, [[seagrid|SEAGRID's wikiROMS page]] has excellent information on how to use the Coastline Extractor, and tools to correct and manipulate coastline data.
 
 
 
For this tutorial, you should download this coastline file (I will add link soon). I created it from the digitized chart I use to make the bathymetry file.
<br>
<br>
<br>
 
===Making your grid===
 
=====Set up USER SETTINGS=====
Before you run EASYGRID to create your ROMS grid, you need to edit EASYGRID's user settings, which is the first part of script (after the help lines). Beside each entry line there are detailed instructions. In fact, most of the "user-manual" for EASYGRID is included within itself. Therefore I will simply copy-paste below a snippet from EASYGRID's code that contains the USER SETTINGS/instructions section.
 
{{note}} '''NOTE:''' The default settings are for this Fjord test case, hence you can just run EASYGRID (after downloading the bathymetry and coastline files above) to generate the grid and initial-conditions files required for this tutorial.
 
<span style="color:green; font-size:95%; line-height:99%;">%*******************************************************************************************************************************
% USER SETTINGS ****************************************************************************************************************
%*******************************************************************************************************************************
%
% Switches -------------------------
      <font color="black">save_grid = 1;</font>  % Save GRID in a NetCDF file ( yes = 1; no = 0 )
      <font color="black">save_init = 1;</font>  % Create (and save) INITIAL CONDITIONS (from grid) ( yes = 1; no = 0 )
  <font color="black">screen_output = 1;</font>  % Displays (on the screen) many parameters that need to be copy-pasted in the ocean.in file ( yes = 1; no = 0 )
      <font color="black">plot_grid = 1;</font>  % Plot grid ( yes = 1; no = 0 )
    <font color="black">smooth_grid = 1;</font>  % Smooth bathymetry ( yes = 1; no = 0 ) using H. Arango's smth_bath.m , which applies a Shapiro filter to the bathymetry
%
% -------------------------------------------------------------------------
% GRID SETTINGS -----------------------------------------------------------
% -------------------------------------------------------------------------
%
% Geographical and Grid parameters --------
      <span class="black">lat =  44.8125;</span>        % Latitude  (degrees) of the bottom-left corner of the grid.
      <span class="black">lon = -62.8855;</span>        % Longitude (degrees) of the bottom-left corner of the grid.
%
        <span class="black">X = 9100;</span>            % Width of domain (meters)
        <span class="black">Y = 2550;</span>            % Length of domain (meters)
<span class="black">rotangle = -43;</span>            % Angle (degrees) to rotate the grid conterclock-wise
    <span class="black">resol = 30;</span>              % Cell width and height (i.e. Resolution)in meters. Grid cells are forced to be (almost) square.
        <span class="black">N = 10;</span>              % Number of vertical levels
%   
% Bathymetry -------------- % Bathymetry for ROMS is measured positive downwards (zeros are not allowed) see: https://www.myroms.org/wiki/index.php/Grid_Generation#Bathymetry
                            % To allow variations in surface elevation (eg. tides) while keeping all depths positive,
                            % an arbitrary offset (see minh below) is added to the depth vector.
%   
      <span class="black">hh = nan;</span>            % Analytical Depth (meters) used to create a uniform-depth grid. If using a bathymetry file, leave hh = nan;
    <span class="black">minh = 4;</span>              % Arbitrary depth offset in meters (see above). minh should be a little more than the maximum expected tidal variation.
    <span class="black">Bathy =</span> <span class="purple">'Test_bathy.mat'</span><span class="black">;</span>% Bathymetry file. If using the analytical depth above (i.e. hh ~= nan), then Bathy will not be used.
                            % The bathymetry file should be a .mat file containing 3 vectors (xbathy, ybathy and zbathy). where xbathy = Longitude,
                            % ybathy = Latitude and zbathy = depth (positive, in meters). xbathy and ybathy are in decimal degrees See: http://en.wikipedia.org/wiki/Decimal_degrees
        %Bathymetry smoothing routine...  See "Switches section" (above) to turn this ON or OFF
        <span class="blue">if</span> <span class="black">smooth_grid == 1;</span>
            <span class="black">order = 2;</span>      % Order of Shapiro filter (2,4,8)... default: 2
            <span class="black">rlim = 0.35;</span>    % Maximum r-factor allowed (0.35)... default: 0.35
            <span class="black">npass = 50;</span>      % Maximum number of passes.......... default: 50
        <span class="blue">end</span>
%---------------------------------
%                     
%
% Coastline ----------------------
    <span class="black">Coast = load(</span><span class="purple">'Test_coast.mat'</span><span class="black">);</span> % If there isn't a coastline file... comment-out this line: e.g. %Coast = load('test_coast.mat');
                                    % The coastline is only used for plotting. The coastline .mat file should contain 2 vectors named "lat" and "lon"
%                                   
%     
% -------------------------------------------------------------------------
% OUTPUT: File naming and NetCDF descriptors ------------------------------
% -------------------------------------------------------------------------
<span class="black">Grid_filename =</span> <span class="purple">'Fjord'</span>;      % Filename for grid and initial conditions files (don't include extension).
                              % "_grd.nc" is added to grid file and "_ini.nc" is added to initial conditions file
<span class="black">Descrip_grd  =</span> <span class="purple">'Test grid'</span>;              %Description for grid .nc file
<span class="black">Descrip_ini  =</span> <span class="purple">'Test initial conditions'</span>; %Description for initial conditions .nc file
<span class="black">Author        =</span> <span class="purple">'John Smith'</span>;
<span class="black">Computer      =</span> <span class="purple">'My Computer'</span>;
%
% -------------------------------------------------------------------------
% INITIAL CONDITIONS ------------------------------------------------------
% -------------------------------------------------------------------------
<span class="blue">if</span> <span class="black">save_init == 1;</span> % See "Switches section" (above) to turn this ON or OFF
    % Initial conditions will be constant throught the grid domain
    %--------------------------------------------------------------------------
    <span class="black">NH4          = 0.1;</span>    % Ammonium concentration (millimole_NH4 meter-3)
    <span class="black">NO3          = 10;</span>      % Nitrate concentration (millimole_N03 meter-3)
    <span class="black">chlorophyll1 = 0.3;</span>    % Chlorophyll concentration in small phytoplankyon (milligrams_chlorophyll meter-3)
    <span class="black">chlorophyll2 = 0.3;</span>    % Chlorophyll concentration in large phytoplankyon (milligrams_chlorophyll meter-3)
    <span class="black">detritus1    = 0.03;</span>    % Small detritus concentration (millimole_nitrogen meter-3)
    <span class="black">detritus2    = 0.03;</span>    % Large detritus concentration (millimole_nitrogen meter-3)
    <span class="black">detritusC1  = 1;</span>      % Small detritus carbon concentration (millimole_carbon meter-3)
    <span class="black">detritusC2  = 0.2;</span>    % Large detritus carbon concentration (millimole_carbon meter-3)
    <span class="black">phyto1      = 0.02;</span>    % Small phytoplankton concentration (millimole_nitrogen meter-3)
    <span class="black">phyto2      = 0.02;</span>    % Large phytoplankton concentration (millimole_nitrogen meter-3)
    <span class="black">phytoC1      = 0.2;</span>    % Small phytoplankton carbon concentration (millimole_carbon meter-3)
    <span class="black">phytoC2      = 0.1;</span>    % Small phytoplankton carbon concentration (millimole_carbon meter-3)
    <span class="black">salt        = 30;</span>      % Salinity (PSU)
    <span class="black">temp        = 9;</span>      % Potential temperature (Celsius)
    <span class="black">u            = 0;</span>      % u-momentum component (meter second-1)
    <span class="black">ubar        = 0;</span>      % Vertically integrated u-momentum component (meter second-1)
    <span class="black">v            = 0;</span>      % v-momentum component (meter second-1)
    <span class="black">vbar        = 0;</span>      % Vertically integrated v-momentum component (meter second-1)
    <span class="black">zeta        = 0;</span>      % Free-surface (meters)
    <span class="black">zooplankton  = 0.01;</span>    % Zooplankton concentration "millimole_nitrogen meter-3"
    <span class="black">zooplanktonC = 0.5;</span>    % Zooplankton carbon concentration "millimole_carbon meter-3"
    %--------------------------------------------------------------------------
<span class="blue">end</span>
%
%
%
%*******************************************************************************************************************************
% END OF USER SETTINGS *********************************************************************************************************
%*******************************************************************************************************************************</span>
<br>
<br>
=====Geographical/Grid parameters=====
After you got the bathymetry and coastline of your study region, now it is time to place a grid on it... In the USER SETTINGS section, you have to specify <span class="red">lat lon X Y</span> and <span class="red">rotangle</span>. This is done in an iterative manner, where first you input your best-guesses, then you plot the grid. From the plot you can adjust your geographical/grid parameters... plot... adjust... plot... and so on.
 
{{note}} '''You may want to turn off some switches (see below) to speed up the plotting process.'''
<span style="color:green; font-size:95%; line-height:99%;">% Switches -------------------------
      <font color="black">save_grid = 0;</font>  % Save GRID in a NetCDF file ( yes = 1; no = 0 )
      <font color="black">save_init = 0;</font>  % Create (and save) INITIAL CONDITIONS (from grid) ( yes = 1; no = 0 )
  <font color="black">screen_output = 0;</font>  % Displays (on the screen) many parameters that need to be copy-pasted in the ocean.in file ( yes = 1; no = 0 )
      <font color="black">plot_grid = 1;</font>  % Plot grid ( yes = 1; no = 0 )
    <font color="black">smooth_grid = 0;</font>  % Smooth bathymetry ( yes = 1; no = 0 ) using H. Arango's smth_bath.m , which applies a Shapiro filter to the bathymetry</span>
<br>
<br>
 
=====Bathymetry smoothing=====
ROMS doesn't like rough bathymetry with abrupt changes in topography. Therefore, after you got your grid where you wanted it to be, the next step is to smooth the bathymetry. Turn ON the <span class="red">smooth_grid</span> variable in the <font color="green">%Switches section</font>. Usually simply enabling smoothing (with the default settings) will do a pretty good job. But if unsatisfied, you can iteratively tweak the parameters in the <font color="green">%Bathymetry somoothing</font> section of the USER SETTINGS until obtaining the desired smoothness.
<br>
<br>
 
=====Initial Conditions=====
EASYGRID can generate a Initial-Conditions NetCDF file for ROMS. However, the process is bit crude... the user can only choose a single value for each initial-condition variable... EASYGRID makes each initial-conditions variable '''constant''' over the entire grid domain. This is only useful in some simple cases and to do "quick-tests".
To change the value of a initial-condition variable, simply go to the <font color="green">INITIAL CONDITIONS</font> section in the <font color="green">USER SETTINGS</font> and change the value of the variable of interest. As I said above, EASYGRID will "copy-paste" such value to every cell of the grid.
 
 
If you need to add another initial-condition variable... add in the <font color="green">INITIAL CONDITIONS</font> section of the <font color="green">USER SETTINGS</font>:
new_variable = 0; <span class="green">% Variable description (units)</span>
 
 
and ADD to the '''end''' of the easygrid.m file <small>(substitute the parts in red)</small>
<span class="green">%--------------------------------------------------------------------------</span>
        dims                    = { <span class="purple">'time'; 's_rho'; 'eta_rho'; 'xi_rho'</span>};
        nc{ <span class="red">'newvar'</span>}          = ncdouble(dims);
        nc{ <span class="red">'newvar'</span>}(:,:,:)    = ones(N,Mp,Lp).* <span class="red">'new_variable'</span>;
        nc{ <span class="red">'newvar'</span>}.time      = <span class="purple">'ocean_time'</span> ;
<br>
<br>
 
=====Saving .nc files=====
Once you got your grid in place and your bathymetry smoothed and your initial-conditions adjusted... it is time to save the NetCDF files for ROMS. To do this, simply turn on ALL the Switches in the <font color="green">USER SETTING</font> section and run EASYGRID. Besides the plot, this time it will also save the grid and initial conditions .nc files. EASYGRID will also output some parameters to screen:
|  COPY-PASTE the following parameters into your ocean.in file
|  ----------------------------------------------------------------------------------------------
|
|
|    Lm == 302        ! Number of I-direction INTERIOR RHO-points
|    Mm == 84        ! Number of J-direction INTERIOR RHO-points
|      N == 10          ! Number of vertical levels
|
|
|  Make sure the Baroclinic time-step (DT) in your ocean.in file is less than: 3.3882 seconds
|  ----------------------------------------------------------------------------------------------
 
{{warning}}Make sure you write this numbers (Lm, MM, N and DT) since you will need to enter them in the ocean.in file prior to running ROMS.
 
<br>
<br>
<br>
===Editing Masks===
After you created your grid.nc file, you can edit the mask (i.e. changing land-pixes to sea-pixels and vice versa) using <span class="red">editmask.m</span> which is a GUI script included in the ROMS Matlab tool-kit (inside the rmask directory).
{{warning}} The current version of editmask.m (from the ROMS toolkit) doesn't work for me. HERE (link will be added soon) is a link to a revised editmask.m version that works for me.
<br>
<br>
DOWNLOAD HERE to get the '''GRID and INITIALIZATION files required for this tutorial'''.  Alternatively, you can create your own grid and initialization files for this tutorial using the grid-generation software of your choice. You can download the bathymetry and coastline data for Ship Harbour Fjord [http://easygrid4roms.googlecode.com/files/EASYGRID_v1.rar HERE].
<br>
<br>
====Masking Criteria====
* Fill in (i.e. mask) 1-cell bays
* Fill in disconnected lakes
* Tiny islands apparently don't cause troubles.
<br>
<br>
{{note}} <span class="red">NOTE:</span> I also wrote a [[easygrid|tutorial for grid generation using EASYGRID]]. The output of that tutorial are the grid and initialization files '''used in this tutorial''' (see above). So if you want to start from scratch, you should begin with the EASYGRID tutorial.
<br>
<br>
<br>
<br>
 
==Compiling ROMS with tides==
==Simple Tidal Forcing==
Before we compile ROMS, we need to create a header (.h) file with the appropriate cpp definitions that turn ON the analytical tides. Also, we need to modify some analytical Fortran files, where we are going to specify how create the analytical tide.
There are a few ways to setup [[Tidal_Forcing|tidal forcing]] in ROMS. This tutorial will explain the simplest way, which is ONLY applicable in cases with one relatively narrow open boundary (say < 10 km). In this cases, the tidal height along the open boundary is essentially uniform and can be prescribed analytically. The fjord subject of this test case is a long embayment (~7 km) whith an open (EAST) boundary of ~1 km. Therefore this fjord is an ideal candidate for this type of analytical tidal forcing.
 
Before we compile ROMS, we need to create a header (.h) file and to modify some analytical Fortran files.




===Create header (.h) file===
===Creating header (.h) file===


Create a file named <span class="red">fjord.h</span> and copy-paste the cpp definitions below:
Create a file named <span class="red">fjord.h</span> and copy-paste the cpp definitions below:

Revision as of 17:50, 22 April 2008

Fjord Tidal Test Case



Warning This WikiROMS article is currently under HEAVY construction. This message will be erased when active construction is finished (in 1 or 2 days).
April 21, 2008

There are a few ways to setup tidal forcing in ROMS (...learn more about tides in ROMS). This tutorial will explain the simplest way, which is to prescribe (analytically) tidal variations in sea-surface height at a open boundary (this uses a FLATHER/CHAPMAN combination). I learned this trick from hetland in this forum post (at the bottom).

Warning RESTRICTIONS: This technique is ONLY applicable in cases with one relatively narrow open boundary (say < 10 km). In this cases, the tidal height along the open boundary is essentially uniform and can be prescribed analytically.

Warning PREREQUISITES: This tutorial assumes that you have (1) downloaded ROMS, (2) installed it in your computer (or cluster), and (3) tested it by compiling and running one of the included test cases. If you haven't done all the above, check the "Getting Started" and "Tutorials" WikiROMS sections.

Geographical Preamble

This application is for Ship Harbour, an estuarine fjord in Nova Scotia, Canada. Click here to see the location in Google. Tides are semidiurnal and tidal range is 1.4 m on average and 2 m on spring tides. Ship Harbour is a long embayment (~7 km) with an open (EAST) boundary of ~1 km, therefore it is an ideal candidate for the type of analytical tidal forcing taught in this tutorial. For now I will only include tidal forcing, however, there is a river at the uppermost end of the estuary, which discharges freshwater at an annual average rate of 18 m3 s-1. I plan to write another tutorial on how to add a river, but for now is only tides.

Grid Generation

The first step to set up a realistic application is to set up a realistic grid. There are several software packages to generate ROMS grids; SEAGRID and GRIDGEN being the most popular ones. I used the much-less-fancy EASYGRID, which is a bit easier to get up and running.

DOWNLOAD HERE to get the GRID and INITIALIZATION files required for this tutorial. Alternatively, you can create your own grid and initialization files for this tutorial using the grid-generation software of your choice. You can download the bathymetry and coastline data for Ship Harbour Fjord HERE.

Note NOTE: I also wrote a tutorial for grid generation using EASYGRID. The output of that tutorial are the grid and initialization files used in this tutorial (see above). So if you want to start from scratch, you should begin with the EASYGRID tutorial.

Compiling ROMS with tides

Before we compile ROMS, we need to create a header (.h) file with the appropriate cpp definitions that turn ON the analytical tides. Also, we need to modify some analytical Fortran files, where we are going to specify how create the analytical tide.


Creating header (.h) file

Create a file named fjord.h and copy-paste the cpp definitions below:

/*
**
** Options for Tidal Fjord.
**
** Application flag:   FJORD
** Input script:       ocean_fjord.in
*/
#define UV_ADV                 /* use to turn ON or OFF advection terms  */
#define UV_COR                 /* use to turn ON or OFF Coriolis term    */
#define UV_QDRAG               /* use to turn ON or OFF quadratic bottom friction */
#define DJ_GRADPS              /* use if splines density Jacobian (Shchepetkin, 2000) */
#define UV_VIS2                /* use to turn ON or OFF harmonic horizontal mixing */
#define MIX_S_UV               /* momentum mixing on s-surfaces */
#define TS_DIF2                /* use to turn ON or OFF harmonic horizontal mixing */
#define MIX_GEO_TS             /* tracer mixing on constant z surfaces */
#define TS_U3HADVECTION        /* use if 3rd-order upstream horiz. advection */
#define TS_C4VADVECTION        /* use if 4th-order centered vertical advection */
#define TS_MPDATA              /* use if recursive MPDATA 3D advection  */
#define NONLIN_EOS             /* use if using nonlinear equation of state */
#define SALINITY               /* use if having salinity */
#define SPLINES                /* use to activate parabolic splines reconstruction */
#define AVERAGES               /* use if writing out time-averaged data */
#define AVERAGES_FLUXES        /* use if writing out time-averaged fluxes */
#define AVERAGES_AKV           /* use if writing out time-averaged AKv */
#define AVERAGES_AKT           /* use if writing out time-averaged AKt */
#define SOLVE3D                /* use if solving 3D primitive equations */
#define MY25_MIXING            /* use if Mellor/Yamada Level-2.5 closure */            
# define N2S2_HORAVG           /* use if Large et al. (1994) interior closure */
# define KANTHA_CLAYSON        /* use if Kantha and Clayson stability function */
#define MASKING                /* use if analytical masking is enabled */
#define EAST_FSCHAPMAN         /*use if free-surface Chapman condition*/
#define EAST_M2FLATHER         /*use if 2D momentum Flather condition*/
#define EAST_M3RADIATION       /*use if 3D momentum radiation condition*/
#define EAST_TRADIATION        /*use if tracers radiation condition*/
#define ANA_FSOBC              /*use if analytical free-surface boundary conditions*/
#define ANA_M2OBC              /*use if analytical 2D momentum boundary conditions*/

Note The last 6 cpp definitions are the responsible for the analytical tidal forcing.
Warning If your open boundary is not EAST... change EAST_FSCHAPMAN, EAST_M2FLATHER, EAST_M3RADIATION and EAST_TRADIATION to represent your open boundary (e.g. WEST__FSCHAPMAN for a west open boundary... etc.).



Modify ana_fsobc.h

You will have to edit the file ana_fsobc.h (located in trunk/ROMS/Functionals) to tell ROMS to estimate surface height analytically when running the FJORD case. Below is a snippet of the end of the file... you have to ADD the green code.

#elif defined TEST_CHAN
     IF (WESTERN_EDGE) THEN
       cff=0.0_r8
       DO j=JstrR,JendR
         BOUNDARY(ng)%zeta_west(j)=cff
       END DO
     END IF
     IF (EASTERN_EDGE) THEN
       cff=-0.4040_r8*MIN(time(ng)/150000.0_r8,1.0_r8)
       DO j=JstrR,JendR
         BOUNDARY(ng)%zeta_east(j)=cff
       END DO
     END IF
#elif defined WEDDELL
     IF (WESTERN_EDGE) THEN
       fac=TANH((tdays(ng)-dstart)/1.0_r8)
       omega=2.0_r8*pi*time(ng)/(12.42_r8*3600.0_r8)  !  M2 Tide period
       val=0.53_r8+(0.53_r8-0.48_r8)/REAL(Iend+1,r8)
       phase=(277.0_r8+(277.0_r8-240.0_r8)/REAL(Iend+1,r8))*deg2rad
       DO j=JstrR,JendR
         BOUNDARY(ng)%zeta_west(j)=fac*val*COS(omega-phase)
       END DO
     END IF
     IF (EASTERN_EDGE) THEN
       fac=TANH((tdays(ng)-dstart)/1.0_r8)
       omega=2.0_r8*pi*time(ng)/(12.42_r8*3600.0_r8)  !  M2 Tide period
       val=0.53_r8+(0.53_r8-0.48_r8)
       phase=(277.0_r8+(277.0_r8-240.0_r8))*deg2rad
       DO j=JstrR,JendR
         BOUNDARY(ng)%zeta_east(j)=fac*val*COS(omega-phase)
       END DO
     END IF
#elif defined FJORD
     IF (WESTERN_EDGE) THEN
       fac=TANH((tdays(ng)-dstart)/1.0_r8)
       omega=2.0_r8*pi*time(ng)/(12.42_r8*3600.0_r8)  !  M2 Tide period
       val=0.53_r8+(0.53_r8-0.48_r8)/REAL(Iend+1,r8)
       phase=(277.0_r8+(277.0_r8-240.0_r8)/REAL(Iend+1,r8))*deg2rad
       DO j=JstrR,JendR
         BOUNDARY(ng)%zeta_west(j)=fac*val*COS(omega-phase)
       END DO
     END IF
     IF (EASTERN_EDGE) THEN
       fac=TANH((tdays(ng)-dstart)/1.0_r8)
       omega=2.0_r8*pi*time(ng)/(12.42_r8*3600.0_r8)  !  M2 Tide period
       val=0.53_r8+(0.53_r8-0.48_r8)
       phase=(277.0_r8+(277.0_r8-240.0_r8))*deg2rad
       DO j=JstrR,JendR
         BOUNDARY(ng)%zeta_east(j)=fac*val*COS(omega-phase)
       END DO
     END IF      
#else
     IF (EASTERN_EDGE) THEN
       DO j=JstrR,JendR
         BOUNDARY(ng)%zeta_east(j)=0.0_r8
       END DO
     END IF
     IF (WESTERN_EDGE) THEN
       DO j=JstrR,JendR
         BOUNDARY(ng)%zeta_west(j)=0.0_r8
       END DO
     END IF
     IF (SOUTHERN_EDGE) THEN
       DO i=IstrR,IendR
         BOUNDARY(ng)%zeta_south(i)=0.0_r8
       END DO
     END IF
     IF (NORTHERN_EDGE) THEN
       DO i=IstrR,IendR
         BOUNDARY(ng)%zeta_north(i)=0.0_r8
       END DO
     END IF
#endif
     RETURN
     END SUBROUTINE ana_fsobc_tile



Modify ana_m2obc.h

You will have to edit the file ana_m2obc.h (located in trunk/ROMS/Functionals) to tell ROMS to estimate currents analytically when running the FJORD case. Below is a snippet of the end of the file... you have to ADD the green code.

#elif defined WEDDELL
     IF (WESTERN_EDGE) THEN
       fac=TANH((tdays(ng)-dstart)/1.0_r8)
       omega=2.0_r8*pi*time(ng)/(12.42_r8*3600.0_r8)  !  M2 Tide period
       minor=0.0143_r8+(0.0143_r8+0.010_r8)/REAL(Iend+1,r8)
       major=0.1144_r8+(0.1144_r8-0.013_r8)/REAL(Iend+1,r8)
       phase=(318.0_r8+(318.0_r8-355.0_r8)/REAL(Iend+1,r8))*deg2rad
       angle=(125.0_r8+(125.0_r8- 25.0_r8)/REAL(Iend+1,r8))*deg2rad
       DO j=JstrR,JendR
         val=0.5_r8*(angler(Istr-1,j)+angler(Istr,j))
         BOUNDARY(ng)%ubar_west(j)=fac*(major*COS(angle-val)*          &
    &                                         COS(omega-phase)-        &
    &                                   minor*SIN(angle-val)*          &
    &                                         SIN(omega-phase))
       END DO
       DO j=Jstr,JendR
         val=0.5_r8*(angler(Istr-1,j-1)+angler(Istr-1,j))
         BOUNDARY(ng)%vbar_west(j)=fac*(major*SIN(angle-val)*          &
    &                                         COS(omega-phase)-        &
    &                                   minor*SIN(angle-val)*          &
    &                                         COS(omega-phase))
       END DO
     END IF
     IF (EASTERN_EDGE) THEN
       fac=TANH((tdays(ng)-dstart)/1.0_r8)
       omega=2.0_r8*pi*time(ng)/(12.42_r8*3600.0_r8)  !  M2 Tide period
       minor=0.0143_r8+(0.0143_r8+0.010_r8)
       major=0.1144_r8+(0.1144_r8-0.013_r8)
       phase=(318.0_r8+(318.0_r8-355.0_r8))*deg2rad
       angle=(125.0_r8+(125.0_r8- 25.0_r8))*deg2rad
       DO j=JstrR,JendR
         val=0.5_r8*(angler(Iend,j)+angler(Iend+1,j))
         BOUNDARY(ng)%ubar_east(j)=fac*(major*COS(angle-val)*          &
    &                                         COS(omega-phase)-        &
    &                                   minor*SIN(angle-val)*          &
    &                                         SIN(omega-phase))
       END DO
       DO j=Jstr,JendR
         val=0.5_r8*(angler(Iend+1,j-1)+angler(Iend+1,j))
         BOUNDARY(ng)%vbar_east(j)=fac*(major*SIN(angle-val)*          &
    &                                         COS(omega-phase)-        &
    &                                   minor*SIN(angle-val)*          &
    &                                         COS(omega-phase))
       END DO
     END IF
#elif defined FJORD
     IF (WESTERN_EDGE) THEN
       fac=TANH((tdays(ng)-dstart)/1.0_r8)
       omega=2.0_r8*pi*time(ng)/(12.42_r8*3600.0_r8)  !  M2 Tide period
       minor=0.0143_r8+(0.0143_r8+0.010_r8)/REAL(Iend+1,r8)
       major=0.1144_r8+(0.1144_r8-0.013_r8)/REAL(Iend+1,r8)
       phase=(318.0_r8+(318.0_r8-355.0_r8)/REAL(Iend+1,r8))*deg2rad
       angle=(125.0_r8+(125.0_r8- 25.0_r8)/REAL(Iend+1,r8))*deg2rad
       DO j=JstrR,JendR
         val=0.5_r8*(angler(Istr-1,j)+angler(Istr,j))
         BOUNDARY(ng)%ubar_west(j)=fac*(major*COS(angle-val)*          &
    &                                         COS(omega-phase)-        &
    &                                   minor*SIN(angle-val)*          &
    &                                         SIN(omega-phase))
       END DO
       DO j=Jstr,JendR
         val=0.5_r8*(angler(Istr-1,j-1)+angler(Istr-1,j))
         BOUNDARY(ng)%vbar_west(j)=fac*(major*SIN(angle-val)*          &
    &                                         COS(omega-phase)-        &
    &                                   minor*SIN(angle-val)*          &
    &                                         COS(omega-phase))
       END DO
     END IF
     IF (EASTERN_EDGE) THEN
       fac=TANH((tdays(ng)-dstart)/1.0_r8)
       omega=2.0_r8*pi*time(ng)/(12.42_r8*3600.0_r8)  !  M2 Tide period
       minor=0.0143_r8+(0.0143_r8+0.010_r8)
       major=0.1144_r8+(0.1144_r8-0.013_r8)
       phase=(318.0_r8+(318.0_r8-355.0_r8))*deg2rad
       angle=(125.0_r8+(125.0_r8- 25.0_r8))*deg2rad
       DO j=JstrR,JendR
         val=0.5_r8*(angler(Iend,j)+angler(Iend+1,j))
         BOUNDARY(ng)%ubar_east(j)=fac*(major*COS(angle-val)*          &
    &                                         COS(omega-phase)-        &
    &                                   minor*SIN(angle-val)*          &
    &                                         SIN(omega-phase))
       END DO
       DO j=Jstr,JendR
         val=0.5_r8*(angler(Iend+1,j-1)+angler(Iend+1,j))
         BOUNDARY(ng)%vbar_east(j)=fac*(major*SIN(angle-val)*          &
    &                                         COS(omega-phase)-        &
    &                                   minor*SIN(angle-val)*          &
    &                                         COS(omega-phase))
       END DO
     END IF      
#else
     IF (EASTERN_EDGE) THEN
       DO j=JstrR,JendR
         BOUNDARY(ng)%ubar_east(j)=0.0_r8
       END DO
       DO j=Jstr,JendR
         BOUNDARY(ng)%vbar_east(j)=0.0_r8
       END DO
     END IF
     IF (WESTERN_EDGE) THEN
       DO j=JstrR,JendR
         BOUNDARY(ng)%ubar_west(j)=0.0_r8
       END DO
       DO j=Jstr,JendR
         BOUNDARY(ng)%vbar_west(j)=0.0_r8
       END DO
     END IF
     IF (SOUTHERN_EDGE) THEN
       DO i=Istr,IendR
         BOUNDARY(ng)%ubar_south(i)=0.0_r8
       END DO
       DO i=IstrR,IendR
         BOUNDARY(ng)%vbar_south(i)=0.0_r8
       END DO
     END IF
     IF (NORTHERN_EDGE) THEN
       DO i=Istr,IendR
         BOUNDARY(ng)%ubar_north(i)=0.0_r8
       END DO
       DO i=IstrR,IendR
         BOUNDARY(ng)%vbar_north(i)=0.0_r8
       END DO
     END IF
#endif
     RETURN
     END SUBROUTINE ana_m2obc_tile

Tidal Forcing

Dummy text... No real information here yet