Difference between revisions of "Tidal Forcing"

From WikiROMS
Jump to navigationJump to search
m (Text replacement - "ocean.in" to "roms.in")   (change visibility)
(6 intermediate revisions by 2 users not shown)
Line 4: Line 4:
Once the appropriate [[Options|CPP options]] have been set (e.g. [[Options#SSH_TIDES|SSH_TIDES]], [[Options#UV_TIDES|UV_TIDES]], [[Options#RAMP_TIDES|RAMP_TIDES]]), a netcdf file of tidal constituents must be generated.   
Once the appropriate [[Options|CPP options]] have been set (e.g. [[Options#SSH_TIDES|SSH_TIDES]], [[Options#UV_TIDES|UV_TIDES]], [[Options#RAMP_TIDES|RAMP_TIDES]]), a netcdf file of tidal constituents must be generated.   


#'''Download the desired tidal constituent database and associated software'''. There are many tidal constituent databases available for download and the choice of databases depends on the desired constituents and location of the ROMS grid. Two possibilities which have broad geographic range and generally the dominant constituents are the [http://volkov.oce.orst.edu/tides/otps.html OSU Tidal Data Prediction Software](OTPS) and the [http://www.unc.edu/ims/ccats/tides/tides.htm ADCIRC tidal database]. Remember to download the associated software with each data base as there ire typically routines which facilitate the extraction and interpolation of the database to the ROMS grid.
#'''Download the desired tidal constituent database and associated software'''. There are many tidal constituent databases available for download and the choice of databases depends on the desired constituents and location of the ROMS grid. Two possibilities which have broad geographic range and generally the dominant constituents are the [http://volkov.oce.orst.edu/tides/otps.html OSU Tidal Data Prediction Software](OTPS) and the [https://adcirc.org/products/adcirc-tidal-databases/ ADCIRC tidal database]. Remember to download the associated software with each data base as there are typically routines which facilitate the extraction and interpolation of the database to the ROMS grid.
#'''Interpolate the tidal constituent database to the desired ROMS grid'''. See the above comment. While it is  possible to write code (e.g. MATLAB, FORTRAN) to perform this task, it is typically easier to use the provided packages.  
#'''Interpolate the tidal constituent database to the desired ROMS grid'''. See the above comment. While it is  possible to write code (e.g. MATLAB, FORTRAN) to perform this task, it is typically easier to use the provided packages.  
#'''Verify all open boundary grid cells contain valid data'''. During the interpolation process, depending on the land mask for the ROMS grid and the tidal database grid, it is possible to have grid cells near land points which the ROMS grid may define as water, but the tidal grid defines as land. Should this occur a 180 degree phase shift along the open boundary near land points is possible. As ROMS is tidally forced on the open boundary, this could be problematic.  
#'''Verify all open boundary grid cells contain valid data'''. During the interpolation process, depending on the land mask for the ROMS grid and the tidal database grid, it is possible to have grid cells near land points which the ROMS grid may define as water, but the tidal grid defines as land. Should this occur, a 180 degree phase shift along the open boundary near land points is possible. As ROMS is tidally forced on the open boundary, this could be problematic.  
#'''The phase of the [[Variables#u|u]]/[[Variables#v|v]]/[[Variables#zeta|zeta]] components of the tidal constituents should be shifted to the appropriate reference time(t=to)'''.It is typical for tidal constituent databases to be stored with the phase shifted by the equilibrium tidal argument. Consequently the reference time for the tide is not the desired time, as set in [[ocean.in]] using the variable  [[Variables#tide_start|TIDE_START]]. In addition, nodal corrections need to be made due to long period tides. The equilibrium argument and nodal corrections can  be calculated using the tidal database software or Rich Pawlowicz's [http://www.eos.ubc.ca/~rich/#T_Tide T_TIDE] MATLAB package. Also, see below for more thoughts on the 18.6 year business.
#'''The phase of the [[Variables#u|u]]/[[Variables#v|v]]/[[Variables#zeta|zeta]] components of the tidal constituents should be shifted to the appropriate reference time(t=t<sub>o</sub>)'''. It is typical for tidal constituent databases to be stored with the phase shifted by the equilibrium tidal argument. Consequently the reference time for the tide is not the desired time, as set in [[roms.in]] using the variable  [[Variables#tide_start|TIDE_START]]. In addition, nodal corrections need to be made due to long period tides. The equilibrium argument and nodal corrections can  be calculated using the tidal database software or Rich Pawlowicz's [http://www.eos.ubc.ca/~rich/#T_Tide T_TIDE] MATLAB package. Also, see below for more thoughts on the 18.6 year business.
#'''Convert the amplitude/phase information to tidal ellipse parameters, if necessary'''. ROMS requires tidal information to be stored as ellipse parameters for use. One tidal ellipse package is [http://woodshole.er.usgs.gov/operations/sea-mat/tidal_ellipse-html/index.html ap2ep.m] from Zhigang Xu.MATLAB tidal ellipse code is available.
#'''Convert the amplitude/phase information to tidal ellipse parameters, if necessary'''. ROMS requires tidal information to be stored as ellipse parameters for use. One tidal ellipse package is [https://github.com/dcherian/tools/blob/master/ROMS/arango/tidal_ellipse/ap2ep.m ap2ep.m] from Zhigang Xu. MATLAB tidal ellipse code is available.
#'''Export tidal ellipse parameters to a ROMS netcdf forcing file'''.
#'''Export tidal ellipse parameters to a ROMS netcdf forcing file'''.


Two examples of this process are described below.  
Two examples of this process are described below.  


{{warning}} Newer Matlab versions are incompatible with older versions of t_tide and will cause errors. In particular, the "finite" function has been replaced with "isfinite" Rich Pawlowicz has provided an updated version of t_tide on his website http://www.eos.ubc.ca/~rich/#T_Tide. I have also provided a link here [http://marine.rutgers.edu/~hunter/roms/tides/t_tide/t_tide_v1.3beta.zip]
{{warning}} Newer Matlab versions are incompatible with older versions of t_tide and will cause errors. In particular, the "finite" function has been replaced with "isfinite" Rich Pawlowicz has provided an updated version of t_tide on his website http://www.eos.ubc.ca/~rich/#T_Tide. I have also provided a link [http://marine.rutgers.edu/~hunter/roms/tides/t_tide/t_tide_v1.3beta.zip here]


==OSU Tidal Prediction Software Example (Matlab)==
==OSU Tidal Prediction Software Example (Matlab)==
Line 20: Line 20:
{{note}} The fortran based OTPS tidal constituent extraction routines have been replaced by a MATLAB based version.  
{{note}} The fortran based OTPS tidal constituent extraction routines have been replaced by a MATLAB based version.  


The processing in this example was carried out in MATLAB using routines found in http://myroms.org/hunter/roms_tides/ and http://myroms.org/hunter/roms_tides/update/otps It requires [http://www.eos.ubc.ca/~rich/#T_Tide T_TIDE] and the Earth and Space Research [ftp://ftp.esr.org/pub/datasets/tmd/tmd_toolbox.zip TMD TOOLBOX].  
The processing in this example was carried out in MATLAB using routines found in http://myroms.org/hunter/roms_tides/ and http://myroms.org/hunter/roms_tides/update/otps. It requires [http://www.eos.ubc.ca/~rich/#T_Tide T_TIDE] and the Earth and Space Research [ftp://ftp.esr.org/pub/datasets/tmd/tmd_toolbox.zip TMD TOOLBOX].  


#Download the [http://www.coas.oregonstate.edu/research/po/research/tide/region.html OSU  tidal processing software](OTPS.tar.Z) to the the working directory e.g. OTPS/. Extract the OTPS routines.  
#Download the [ftp://ftp.esr.org/pub/datasets/tmd/tmd_toolbox.zip ESR Tidal Model Driver](OTPS.tar.Z) to the the working directory e.g. OTPS/. Extract the TMD routines.  
#* cd OTPS/
#* cd OTPS/
#* uncompress OTPS.tar.Z
#* uncompress tmd_toolbox.zip
#* tar xvf OTPS.tar
#* add tmd_toolbox directory to the matlab path.
#Download the appropriate regional or global model database with respect to the ROMS domain. e.g. For a model of the East coast of the United states, download  EC.tar.Z. Uncompressing and extracting this file should great a subdirectory called DATA/
#Download the appropriate regional or global model database with respect to the ROMS domain. e.g. For a model of the East coast of the United states, download  EC.tar.Z. Uncompressing and extracting this file should great a subdirectory called DATA/
#* uncompress EC.tar.Z
#* uncompress EC.tar.Z
#* tar xvf EC.tar
#* tar xvf EC.tar
#Compile extract_HC.f into the executable extract_HC. There is a makefile included in the OTPS.tar.Z archive. It requires an f90 compiler.
#Now the tidal constituents are ready to be extracted and saved to a ROMS forcing file. An example (using MATLAB) of how to do this is given in [http://myroms.org/hunter/roms_tides/update/otps otps2frc_wrapper.m]. In the following example, t is the reference date for the tide (i.e. [[Variables#tide_start|TIDE_START]]), tpred is the nodal corrections reference time (usually the midpoint of range of the prediction time), and gfile is the ROMS grid file. Also included are and output file and the path the OTIS database.  
#* make extract_HC
#Now the tidal constituents are ready to be extracted and saved to a ROMS forcing file. An example (using MATLAB) of how to do this is given in [http://marine.rutgers.edu/~hunter/roms/tides/otps/ otps2frc_v3.m]. In the following example, t is the reference date for the tide (i.e. [[Variables#tide_start|TIDE_START]]), tpred is the nodal corrections reference time (usually the midpoint of range of the prediction time), and gfile is the ROMS grid file. Also included are and output file and the path the OTIS database.  
#*>> t=datenum(2005,1,1);
#*>> t=datenum(2005,1,1);
#*>> tpred=datenum(2006,1,1);
#*>> tpred=datenum(2006,1,1);
#*>> gfile='/home/hunter/roms/in/roms_latte_grid_3c.nc';
#*>> gfile='/home/hunter/roms/in/roms_latte_grid_3c.nc';
#*>> otps2frc_v3(gfile,t,tpred,'test_EC.nc','DATA/Model_EC')  
#*>> domain='LATTE';
#*>> otps2frc_5(gfile,t,tpred,'test_EC.nc','DATA/Model_EC',domain)  




{{note}} otps2frc_v3 calls extract_HC and generates several intermediate files. It also generates the file setup.inp as input to extract_HC. The format of setup.inp is:
<div class="box" style="margin-left:27px;">
DATA/Model_NA      ! 1. tidal model control file
../ll.dat          ! 2. latitude/longitude/time file
z                  ! 3. z/U/V/u/v
o1,k1,n2,m2,s2      ! 4. tidal constituents to include
AP                  ! 5. AP/RI
oce                ! 6. oce/geo
0                  ! 7. 1/0 correct for minor constituents
../nena_8g_z.out    ! 8. output file (ASCII)
</div>
Details of the format are found in the OTPS.tar.Z README file.


{{note}} It is also hard-coded into otps2frc_v3 to only look for the constituents m2,s2,k1,o1. If you want more constituents(and they exist in the regional or global database of your choice) you will have to edit otps2frc_v3.m.
{{note}} Depending on the versions of the Matlab scripts used, the user may have problems creating a ROMS forcing file. Depending on the version of the file t_vuf.m (called by otps2frc_v5.m) in the Matlab path, the two lines of otps2frc_v5.m that call t_vuf.m may need to be modified. If the version t_vuf.m in the Matlab path requires 4 inputs, instead of the three given by otps2frc_v5.m, then either 'full' or 'nodal' needs to be added as the first input variable.
 
{{note}} Depending on the versions of the Matlab scripts used the user may have problems creating a ROMS forcing file. Depending on the version of the file t_vuf.m (called by otps2frc_v3.m) in the Matlab path, the two lines of otps2frc_v3.m that call t_vuf.m may need to be modified. If the version t_vuf.m in the Matlab path requires 4 inputs, instead of the three given by otps2frc_v3.m, then either 'full' or 'nodal' needs to be added as the first input variable.
 
{{warning}} If you attempt to extract constituents that don't exist in the database, extract_HC MAY fill in data for those constituents, usually by filling in with data from a constituent that exists. So verify the constituent is part of the database.


==ADCIRC Tidal Database Example (Matlab)==
==ADCIRC Tidal Database Example (Matlab)==
The processing in this example was carried out in MATLAB using routines found in http://marine.rutgers.edu/~hunter/roms/tides/adcirc/. It has been tested on a SUN and requires [http://www.eos.ubc.ca/~rich/#T_Tide T_TIDE].  
The processing in this example was carried out in MATLAB using routines found in http://myroms.org/hunter/roms_tides/. It requires [http://www.eos.ubc.ca/~rich/#T_Tide T_TIDE].  


#Download the desired [http://www.unc.edu/ims/ccats/tides/tides.htm ADCIRC tidal database]. e.g. Download ec2001_v2e.zip. Unzip this file into the working directory.  
#Download the desired [https://adcirc.org/products/adcirc-tidal-databases/ ADCIRC tidal database]. e.g. Download ec2001_v2e.zip. Unzip this file into the working directory.  
#* unzip ec_95d.zip
#* unzip ec2001_v2e.zip
#Compile tides_ec2001.f into the executable tides_ec2001.out. *
#Compile tides_ec2001.f into the executable adcirc_extract
#* f77 -g -o tides_ec2001.out tides_ec2001.f
#* f77 -g -o adcirc_extract  tides_ec2001.f
#Now the tidal constituents are ready to be extracted and saved to a ROMS forcing file. An example (using MATLAB) of how to do this is given in [http://marine.rutgers.edu/~hunter/roms/tides/adcirc/ adcirc2frc_v2.m]. In the following example, t is the reference date for the tide (i.e. [[Variables#tide_start|TIDE_START]]),tp is a prediction time(usually the same as the reference data) used to calculate nodal corrections and gfile is the ROMS grid file. Also included are an output filename and a processing flag. The processing flag determines whether tides_ec2001.out is executed. It needs to b e run only once. As it can take a very long time, once the output file tides.out is generated, change this from  1 to 0.  
#Now the tidal constituents are ready to be extracted and saved to a ROMS forcing file. An example (using MATLAB) of how to do this is given in [http://myroms.org/hunter/roms_tides/update/adcirc/ adcirc2frc_wrapper.m]. In the following example, t is the reference date for the tide (i.e. [[Variables#tide_start|TIDE_START]]), tp is a prediction time(usually the same as the reference data) used to calculate nodal corrections and gfile is the ROMS grid file. Also included are an output filename and a processing flag. The processing flag determines whether adcirc_extract is executed. It needs to be run only once. As it can take a very long time, once the output file tides.out is generated, change this from  1 to 0.  
#*>> t=datenum(2005,1,1);
#*>> t=datenum(2005,1,1);
#*>> tp=datenum(2006,1,1);
#*>> tp=datenum(2006,1,1);
#*>> gfile='/home/hunter/roms/in/roms_latte_grid_3c.nc';
#*>> gfile='/home/hunter/roms/in/roms_latte_grid_3c.nc';
#*>> adcirc2frc_v2(gfile,t,tp,'test_adcirc.nc',1)
#*>> domain='LATTE';
#*>> adcirc2frc_v5(gfile,t,tp,'test_adcirc.nc',1,domain)
 
 
 
 
{{note}} * - The file tides_ec2001.f is written to compile using SUN f77. It will not work with g77 as downloaded from the ADCIRC website. There is a logical unit of 105 which is out of range for g77. It must be edited to change these to a number <99.


{{note}} * - The file tides_ec2001.f is written to compile using SUN f77. It will not work with g77 as downloaded from the ADCIRC website. There is a logical unit of of 105 which is out of range for g77. It must be edited to change thes lo a number <99. An example of and edited file is available in http://marine.rutgers.edu/~hunter/roms/tides/adcirc/tides_ec2001.f.
{{note}} This version of adcirc2frc_v5.m includes all tidal constituents from the ADCIRC database. Any undesired constituents must be removed after the tidal file is generated.


{{note}} This version of adcirc2frc_v2.m includes all tidal constituents from the ADCIRC database. Any undesired constituents must be removed after the tidal file is generated.
{{note}} The files adcirc2frc_v6.m, adcirc2frc_wrapper_v6.m, and read_adcirc_tdb.m have been added to http://myroms.org/hunter/roms_tides/update/adcirc/. This set of files allows the use to extract constituents from the ADCIRC database without the use of fortran.


==Comments on the 18.6 year tides==
==Comments on the 18.6 year tides==

Revision as of 15:13, 17 July 2019

Description of Tidal Forcing in ROMS

Tidal Forcing Files in ROMS

Once the appropriate CPP options have been set (e.g. SSH_TIDES, UV_TIDES, RAMP_TIDES), a netcdf file of tidal constituents must be generated.

  1. Download the desired tidal constituent database and associated software. There are many tidal constituent databases available for download and the choice of databases depends on the desired constituents and location of the ROMS grid. Two possibilities which have broad geographic range and generally the dominant constituents are the OSU Tidal Data Prediction Software(OTPS) and the ADCIRC tidal database. Remember to download the associated software with each data base as there are typically routines which facilitate the extraction and interpolation of the database to the ROMS grid.
  2. Interpolate the tidal constituent database to the desired ROMS grid. See the above comment. While it is possible to write code (e.g. MATLAB, FORTRAN) to perform this task, it is typically easier to use the provided packages.
  3. Verify all open boundary grid cells contain valid data. During the interpolation process, depending on the land mask for the ROMS grid and the tidal database grid, it is possible to have grid cells near land points which the ROMS grid may define as water, but the tidal grid defines as land. Should this occur, a 180 degree phase shift along the open boundary near land points is possible. As ROMS is tidally forced on the open boundary, this could be problematic.
  4. The phase of the u/v/zeta components of the tidal constituents should be shifted to the appropriate reference time(t=to). It is typical for tidal constituent databases to be stored with the phase shifted by the equilibrium tidal argument. Consequently the reference time for the tide is not the desired time, as set in roms.in using the variable TIDE_START. In addition, nodal corrections need to be made due to long period tides. The equilibrium argument and nodal corrections can be calculated using the tidal database software or Rich Pawlowicz's T_TIDE MATLAB package. Also, see below for more thoughts on the 18.6 year business.
  5. Convert the amplitude/phase information to tidal ellipse parameters, if necessary. ROMS requires tidal information to be stored as ellipse parameters for use. One tidal ellipse package is ap2ep.m from Zhigang Xu. MATLAB tidal ellipse code is available.
  6. Export tidal ellipse parameters to a ROMS netcdf forcing file.

Two examples of this process are described below.

Warning Newer Matlab versions are incompatible with older versions of t_tide and will cause errors. In particular, the "finite" function has been replaced with "isfinite" Rich Pawlowicz has provided an updated version of t_tide on his website http://www.eos.ubc.ca/~rich/#T_Tide. I have also provided a link here

OSU Tidal Prediction Software Example (Matlab)

Note The fortran based OTPS tidal constituent extraction routines have been replaced by a MATLAB based version.

The processing in this example was carried out in MATLAB using routines found in http://myroms.org/hunter/roms_tides/ and http://myroms.org/hunter/roms_tides/update/otps. It requires T_TIDE and the Earth and Space Research TMD TOOLBOX.

  1. Download the ESR Tidal Model Driver(OTPS.tar.Z) to the the working directory e.g. OTPS/. Extract the TMD routines.
    • cd OTPS/
    • uncompress tmd_toolbox.zip
    • add tmd_toolbox directory to the matlab path.
  2. Download the appropriate regional or global model database with respect to the ROMS domain. e.g. For a model of the East coast of the United states, download EC.tar.Z. Uncompressing and extracting this file should great a subdirectory called DATA/
    • uncompress EC.tar.Z
    • tar xvf EC.tar
  3. Now the tidal constituents are ready to be extracted and saved to a ROMS forcing file. An example (using MATLAB) of how to do this is given in otps2frc_wrapper.m. In the following example, t is the reference date for the tide (i.e. TIDE_START), tpred is the nodal corrections reference time (usually the midpoint of range of the prediction time), and gfile is the ROMS grid file. Also included are and output file and the path the OTIS database.
    • >> t=datenum(2005,1,1);
    • >> tpred=datenum(2006,1,1);
    • >> gfile='/home/hunter/roms/in/roms_latte_grid_3c.nc';
    • >> domain='LATTE';
    • >> otps2frc_5(gfile,t,tpred,'test_EC.nc','DATA/Model_EC',domain)


Note Depending on the versions of the Matlab scripts used, the user may have problems creating a ROMS forcing file. Depending on the version of the file t_vuf.m (called by otps2frc_v5.m) in the Matlab path, the two lines of otps2frc_v5.m that call t_vuf.m may need to be modified. If the version t_vuf.m in the Matlab path requires 4 inputs, instead of the three given by otps2frc_v5.m, then either 'full' or 'nodal' needs to be added as the first input variable.

ADCIRC Tidal Database Example (Matlab)

The processing in this example was carried out in MATLAB using routines found in http://myroms.org/hunter/roms_tides/. It requires T_TIDE.

  1. Download the desired ADCIRC tidal database. e.g. Download ec2001_v2e.zip. Unzip this file into the working directory.
    • unzip ec2001_v2e.zip
  2. Compile tides_ec2001.f into the executable adcirc_extract
    • f77 -g -o adcirc_extract tides_ec2001.f
  3. Now the tidal constituents are ready to be extracted and saved to a ROMS forcing file. An example (using MATLAB) of how to do this is given in adcirc2frc_wrapper.m. In the following example, t is the reference date for the tide (i.e. TIDE_START), tp is a prediction time(usually the same as the reference data) used to calculate nodal corrections and gfile is the ROMS grid file. Also included are an output filename and a processing flag. The processing flag determines whether adcirc_extract is executed. It needs to be run only once. As it can take a very long time, once the output file tides.out is generated, change this from 1 to 0.
    • >> t=datenum(2005,1,1);
    • >> tp=datenum(2006,1,1);
    • >> gfile='/home/hunter/roms/in/roms_latte_grid_3c.nc';
    • >> domain='LATTE';
    • >> adcirc2frc_v5(gfile,t,tp,'test_adcirc.nc',1,domain)



Note * - The file tides_ec2001.f is written to compile using SUN f77. It will not work with g77 as downloaded from the ADCIRC website. There is a logical unit of 105 which is out of range for g77. It must be edited to change these to a number <99.

Note This version of adcirc2frc_v5.m includes all tidal constituents from the ADCIRC database. Any undesired constituents must be removed after the tidal file is generated.

Note The files adcirc2frc_v6.m, adcirc2frc_wrapper_v6.m, and read_adcirc_tdb.m have been added to http://myroms.org/hunter/roms_tides/update/adcirc/. This set of files allows the use to extract constituents from the ADCIRC database without the use of fortran.

Comments on the 18.6 year tides

The "18 year" tide is not a separate tidal constituent, but is rather a modulation of the amplitude (and a phase shift) of the other tides. The amplitude of the modulation for three constituents is shown here:

18yrs small.jpg

  • Because we run multi-decadal simulations, we have chosen not to include the "nodal corrections" in the external forcing file but to modify ROMS to compute them for the time at hand. The alternative would be to swap out the tidal forcing file every few years.
  • These long-period modulations cause us to be dubious of the ROMS detiding algorithm since it is learning on the fly but not forgetting what it was learning nine years before.
  • I have been asked by several people how I create the tides files. My scripts (without tidal potentials) are File:Tides ncl.tar.gz.