 ## #2290 closed Bug (fixed)

Reported by: reporter: Owned by: owner: The author of the ticket. Person in charge for handling jchanut systeam low DYN release-4.0 minor

### Description

#### Analysis

There are a couple of bugs in dynzdf.F90 with ln_zad_Aimp=.true.
1) In building the tridiagonal matrix one uses the implicit vertical velocity at W-point:

```zWui = 0.5_wp * ( wi(ji,jj,jk  ) + wi(ji+1,jj,jk  ) )
zWus = 0.5_wp * ( wi(ji,jj,jk+1) + wi(ji+1,jj,jk+1) )
```

which is multiplied later when filling the matrix by

```zdt = r2dt * 0.5
```

```zwi(ji,jj,jk) = zzwi + zdt * MIN( zWui, 0._wp )
zws(ji,jj,jk) = zzws - zdt * MAX( zWus, 0._wp )
zwd(ji,jj,jk) = 1._wp - zzwi - zzws + zdt * ( MAX( zWui, 0._wp ) - MIN( zWus, 0._wp ) )
```

It means that vertical velocities are multiplied by 0.5 twice instead of once.

2) Off diagonal terms should be divided by e3u, including implicit advection terms which is not the case.

#### Fix

U velocity case:

```ze3ua =  ( 1._wp - r_vvl ) * e3u_n(ji,jj,jk) + r_vvl * e3u_a(ji,jj,jk)
...
zWui = ( wi(ji,jj,jk  ) + wi(ji+1,jj,jk  ) ) / ze3ua
zWus = ( wi(ji,jj,jk+1) + wi(ji+1,jj,jk+1) ) / ze3ua
zwi(ji,jj,jk) = zzwi + zdt * MIN( zWui, 0._wp )
zws(ji,jj,jk) = zzws - zdt * MAX( zWus, 0._wp )
zwd(ji,jj,jk) = 1._wp - zzwi - zzws + zdt * ( MAX( zWui, 0._wp ) - MIN( zWus, 0._wp ) )
```

### Commit History (2)

ChangesetTimeChangeLog
11282jchanut2019-07-17T15:57:17+02:00

11281jchanut2019-07-17T15:51:21+02:00

In 11281: