ROMS vs MATLAB indices explained (for rivers and others)

Discussions, suggestions and corrections to ROMS/TOMS documentation currently under developement.

Moderators: arango, robertson

Post Reply
Message
Author
nacholibre
Posts: 81
Joined: Thu Dec 07, 2006 3:14 pm
Location: USGS
Contact:

ROMS vs MATLAB indices explained (for rivers and others)

#1 Unread post by nacholibre »

I have been thinking about posting on this topic for a while. ROMS horizontal discretization is very well defined in Numerical Solution Technique and placement of rivers in Description of River Input. However, I don't think the notation in MATLAB has been documented. I think this had also been a part of the confusion in defining rivers / point sources locations in the past. I hope this helps prevent some confusion in the future.
Zafer

With (i, j) notation:
Indexing in ROMS (if working on ROMS code or defining inputs in analytical modules or NetCDF files):

Code: Select all

           --------v(i,j+1,k)---------
           |                         |
        u(i,j,k)    r(i,j,k)     u(i+1,j,k)
           |                         |
           ---------v(i,j,k)----------
[/size]
Indexing in MATLAB (for post processing, analsis and plotting purposes):

Code: Select all

           --------v(j+1,i+1,k)---------
           |                           |
       u(j+1,i,k)  r(j+1,i+1,k)     u(j+1,i+1,k)
           |                           |
           ---------v(j,i+1,k)----------
[/size]
Example with (xi, eta) notation:
in ROMS:

Code: Select all

......................v(80,55)...............
u(80,54).....rho(xi= 80,eta= 54).....u(81,54)
......................v(80,54)...............
[/size]
in MATLAB:

Code: Select all

...................v(55,81)..................
u(55,80).....rho(eta= 55,xi= 81).....u(55,81)
...................v(54,81)..................
[/size]

Explanation:
1. Array indices start from 1 in MATLAB.
2. Array indices start from 0 in Fortran (ROMS).
3. Array dimensions are flipped between MATLAB (eta, xi) and ROMS (xi, eta) notations.
4. rho point indices in MATLAB are one more of what they are in ROMS. i.e.

Code: Select all

ROMS(xi, eta) -> MATLAB(eta+1, xi+1)
5. For u and v points this is slightly difference since these arrays have one member short in one of their dimensions. ROMS solves hydrodynamic equations over the interior points (i=1:Lm and j=1:Nm) for a full grid size of (i=0:L, j=0:M). i.e. Lm=L-1, Mm=M-1 and full range rho(0:L, 0:M), whereas, u(1:Lm, 0:M), v(0:L,1:M). See [url=https://www.myroms.org/wiki/index.php/Numerical_Solution_Technique]here[/url] for more details.
e.g.
Lm=158 means 1:158 interior points in ROMS which corresponds to 0:159 full range points in ROMS and 1:160 full range points in MATLAB. 

[b]Additional Notes:
[/b]1. Assume that the cell with rho(xi= 80,eta= 54) in the above example is a wet cell neighboring a land masked cell with rho(xi= 79,eta= 54) on the east of it. If defining a river / point source coming in from the east the location will be as river_Xposition=80, river_Eposition=54 in ROMS river input file. 
2. You can test your river / point source indices by running map_rivers.m code, which can be found on [url=https://www.myroms.org/forum/viewtopic.php?f=14&t=2200]this post.[/url]

Post Reply