Difference between revisions of "FJORD TIDAL CASE"

From WikiROMS
Jump to navigationJump to search
Line 281: Line 281:


===Modify ana_fsobc.h===
===Modify ana_fsobc.h===
You will have to edit the file <span class="red">ana_fsobc.h</span> (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 <span class="green">ADD the green</span> code.
You will have to edit the file <span class="red">ana_fsobc.h</span> (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 <span class="green">ADD the green code</span>.
  #elif defined TEST_CHAN
  #elif defined TEST_CHAN
       IF (WESTERN_EDGE) THEN
       IF (WESTERN_EDGE) THEN

Revision as of 22:51, 16 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 14, 2008

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.

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, SNCTOOLS and the ROMS Matlab tool-kit. 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. 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. Here I will use EASYGRID.

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, SNCTOOLS and a few scripts (like spheric_dist.m and smth_bath.m) from the ROMS Matlab tool-kit



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 decimal degrees. For more information about bathymetry for ROMS, click 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 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 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 coarse-resolution using read_srtm30plus.m


Get coastline

In EASYGRID, the coastline is only used for plotting and 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 decimal degrees).


An easy way to get coastline data is at NOAA's Coastline Extractor. Remember to select Matlab as format option (not default). Again, SEAGRID's wikiROMS page has excellent tools and descriptions on how to use the Coastline Extractor...


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.


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. Below is a copy of EASYGRID's user settings / instructions. 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.

%*******************************************************************************************************************************
% USER SETTINGS ****************************************************************************************************************
%*******************************************************************************************************************************
%
% Switches -------------------------
     save_grid = 1;   % Save GRID in a NetCDF file ( yes = 1; no = 0 )
     save_init = 1;   % Create (and save) INITIAL CONDITIONS (from grid) ( yes = 1; no = 0 )
 screen_output = 1;   % Displays (on the screen) many parameters that need to be copy-pasted in the ocean.in file ( yes = 1; no = 0 )
     plot_grid = 1;   % Plot grid ( yes = 1; no = 0 )
   smooth_grid = 1;   % 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 --------
     lat =  44.8125;        % Latitude  (degrees) of the bottom-left corner of the grid.
     lon = -62.8855;        % Longitude (degrees) of the bottom-left corner of the grid. 
%
       X = 9100;            % Width of domain (meters)
       Y = 2550;            % Length of domain (meters)
rotangle = -43;             % Angle (degrees) to rotate the grid conterclock-wise
   resol = 30;              % Cell width and height (i.e. Resolution)in meters. Grid cells are forced to be (almost) square.
       N = 10;              % 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.
%    
      hh = nan;             % Analytical Depth (meters) used to create a uniform-depth grid. If using a bathymetry file, leave hh = nan;
    minh = 4;               % Arbitrary depth offset in meters (see above). minh should be a little more than the maximum expected tidal variation.
   Bathy = 'Test_bathy.mat';% 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
       if smooth_grid == 1;
           order = 2;       % Order of Shapiro filter (2,4,8)... default: 2
            rlim = 0.35;    % Maximum r-factor allowed (0.35)... default: 0.35
           npass = 50;      % Maximum number of passes.......... default: 50
       end
%---------------------------------
%                      
%
% Coastline ----------------------
   Coast = load('Test_coast.mat'); % 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 ------------------------------
% -------------------------------------------------------------------------
Grid_filename = 'Fjord';      % 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
Descrip_grd   = 'Test grid';               %Description for grid .nc file
Descrip_ini   = 'Test initial conditions'; %Description for initial conditions .nc file
Author        = 'John Smith';
Computer      = 'My Computer';
%
% -------------------------------------------------------------------------
% INITIAL CONDITIONS ------------------------------------------------------
% -------------------------------------------------------------------------
if save_init == 1; % See "Switches section" (above) to turn this ON or OFF
    % Initial conditions will be constant throught the grid domain
    %--------------------------------------------------------------------------
    NH4          = 0.1;     % Ammonium concentration (millimole_NH4 meter-3)
    NO3          = 10;      % Nitrate concentration (millimole_N03 meter-3)
    chlorophyll1 = 0.3;     % Chlorophyll concentration in small phytoplankyon (milligrams_chlorophyll meter-3)
    chlorophyll2 = 0.3;     % Chlorophyll concentration in large phytoplankyon (milligrams_chlorophyll meter-3)
    detritus1    = 0.03;    % Small detritus concentration (millimole_nitrogen meter-3)
    detritus2    = 0.03;    % Large detritus concentration (millimole_nitrogen meter-3)
    detritusC1   = 1;       % Small detritus carbon concentration (millimole_carbon meter-3)
    detritusC2   = 0.2;     % Large detritus carbon concentration (millimole_carbon meter-3)
    phyto1       = 0.02;    % Small phytoplankton concentration (millimole_nitrogen meter-3)
    phyto2       = 0.02;    % Large phytoplankton concentration (millimole_nitrogen meter-3)
    phytoC1      = 0.2;     % Small phytoplankton carbon concentration (millimole_carbon meter-3)
    phytoC2      = 0.1;     % Small phytoplankton carbon concentration (millimole_carbon meter-3)
    salt         = 30;      % Salinity (PSU)
    temp         = 9;       % Potential temperature (Celsius)
    u            = 0;       % u-momentum component (meter second-1)
    ubar         = 0;       % Vertically integrated u-momentum component (meter second-1)
    v            = 0;       % v-momentum component (meter second-1)
    vbar         = 0;       % Vertically integrated v-momentum component (meter second-1)
    zeta         = 0;       % Free-surface (meters)
    zooplankton  = 0.01;    % Zooplankton concentration "millimole_nitrogen meter-3"
    zooplanktonC = 0.5;     % Zooplankton carbon concentration "millimole_carbon meter-3"
    %--------------------------------------------------------------------------
end
%
%
% 
%*******************************************************************************************************************************
% END OF USER SETTINGS *********************************************************************************************************
%*******************************************************************************************************************************



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 lat lon X Y and rotangle. This is done in a 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.

% Switches -------------------------
     save_grid = 0;   % Save GRID in a NetCDF file ( yes = 1; no = 0 )
     save_init = 0;   % Create (and save) INITIAL CONDITIONS (from grid) ( yes = 1; no = 0 )
 screen_output = 0;   % Displays (on the screen) many parameters that need to be copy-pasted in the ocean.in file ( yes = 1; no = 0 )
     plot_grid = 1;   % Plot grid ( yes = 1; no = 0 )
   smooth_grid = 0;   % Smooth bathymetry ( yes = 1; no = 0 ) using H. Arango's smth_bath.m , which applies a Shapiro filter to the bathymetry



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 smooth_grid variable in the %Switches section. 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 %Bathymetry somoothing section of the USER SETTINGS until obtaining the desired smoothness.

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 useful for some simple cases and to do "quick-tests".


If you need to add another initial-condition variable, add in the USER SETTINGS:

% -------------------------------------------------------------------------
% INITIAL CONDITIONS ------------------------------------------------------
% ------------------------------------------------------------------------- 
new_variable = 0; % Variable description (units)


and ADD to the end of the easygrid.m file (substitute the parts in red)

%--------------------------------------------------------------------------
       dims                    = { 'time'; 's_rho'; 'eta_rho'; 'xi_rho'};
       nc{ 'newvar'}           = ncdouble(dims);
       nc{ 'newvar'}(:,:,:)    = ones(N,Mp,Lp).* 'new_variable';
       nc{ 'newvar'}.time      = 'ocean_time' ;



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 USER SETTING 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
|  ----------------------------------------------------------------------------------------------

WarningMake 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.



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 editmask.m 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.

Masking Criteria:

  • Fill in (i.e. mask) 1-cell bays
  • Fill in disconnected lakes
  • Tiny islands apparently don't cause troubles.



Simple Tidal Forcing

There are a few ways to setup 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

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

Text

#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