Many thanks to John Warner for his curiosity in discovering this bug .

I haven't explored the repercussion of this bug yet but it affects viscosity and diffusion. It can break the symmetries of the stress and diffusion tensors. It can affect momentum and tracer balances.

I need to make an analysis of the entire code and check the averaging the metrics

**pm**and

**pn**horizontally with the meaning of grid spacing. Recall that

**pm**and

**pn**are the inverse grid spacing at

**RHO**-points.

**dx = 1 / pm**

**dy = 1 / pn**

This always annoyed me but we kept it like that for historical reasons.

Please, use the following

**metrics.F**for now on:

http://www.myroms.org/links/metrics.F.gz

This bug will affect also all tangent linear and adjoint applications. Fortunately, we do not need to take the adjoint of this routine. In the UCLA version of ROMS these metrics are computed in

**setup_grid1.F**.

By the way, we need to examine all the grid generation programs to see if these bug is also there.

Now, let's examine this bug by looking two continuous grid cells centered at

**RHO**-points with unusual different grid size, say 50 and 80 km:

Code: Select all

```
j ----- v(i-1)----------- v(i )-------
| | |
| | |
j-1 u(i-1) r(i-1) u(i ) r(i ) u(i+1)
| | |
| | |
j-1 ----- v(i-1)----------- v(i )-------
xr: 125 190 km
xu: 100 150 230 km
dx_r: 50 80 km (1/pm)
dx_u: 65 km (om_u)
```

**om_u**. In metrics, we had:

Code: Select all

```
om_u(i,j) = 2 / (pm(i-1,j) + pm(i,j))
= 2 / (1/50 + 1/80)
= 2 / (0.02 + 0.0125)
= 2 / 0.0325
= 61.538462
```

**65**is not equal to

**61.538462**.

Notice that if the continuous cells have the same grid spacing, it will yield the correct

**om_u**. Also notice that this error is larger as the curvilinear grid gets more distorted. The error is grid dependent and can be small on grids that are almost uniform. I wonder if this bug exits in other curvilinear models out there. It is very easy to make this mistake due to the need of inverse grid spacing in the computations.

The same goes for other terms in

**metrics.F**:

**on_u, om_v, on_v, pmon_u, pnom_u, pmon_v, pmon_p, pnom_p**

Well, I am speechless about this bug. Please replace

**metrics.F**with the new routine immediately

Good luck, H