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:**

--------v(i,j+1,k)---------

| |

u(i,j,k) r(i,j,k) u(i+1,j,k)

| |

---------v(i,j,k)----------

Indexing in MATLAB (for post processing, analsis and plotting purposes):

**Code:**

--------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)----------

Example with (xi, eta) notation:

in ROMS:

**Code:**

......................v(80,55)...............

u(80,54).....rho(xi= 80,eta= 54).....u(81,54)

......................v(80,54)...............

in MATLAB:

**Code:**

...................v(55,81)..................

u(55,80).....rho(eta= 55,xi= 81).....u(55,81)

...................v(54,81)..................

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]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

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

Additional Notes:

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

this post.