# New URL for NEMO forge! http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
#2261 (bug when using option 31 or 32 for momentum viscosity) – NEMO

Opened 5 years ago

Closed 5 years ago

# bug when using option 31 or 32 for momentum viscosity

Reported by: Owned by: clem systeam high LDF v4.0 major v4.0

#### Analysis

There is a bug when using options 30 and 31 for momentum viscosity that makes the model crash at the first time step.
The problem is 2 fold:
1) ahmt and ahmf coefficients are not initialized to 0
2) indices start at 2 when calculating ahmf while it should start at 1 (F-points)

#### Fix

In ldfdyn.F90 =>

Initialize the coefficients during init

```         ahmt(:,:,:) = 0._wp
ahmf(:,:,:) = 0._wp
```

And replace this loop:

```              DO jj = 2, jpjm1
DO ji = fs_2, fs_jpim1
zu2pv2_ij_p1 = ub(ji  ,jj+1,jk) * ub(ji  ,jj+1,jk) + vb(ji+1,jj  ,jk) * vb(ji+1,jj  ,jk)
zu2pv2_ij    = ub(ji  ,jj  ,jk) * ub(ji  ,jj  ,jk) + vb(ji  ,jj  ,jk) * vb(ji  ,jj  ,jk)
zu2pv2_ij_m1 = ub(ji-1,jj  ,jk) * ub(ji-1,jj  ,jk) + vb(ji  ,jj-1,jk) * vb(ji  ,jj-1,jk)
zetmax = MAX( e1t(ji,jj) , e2t(ji,jj) )
zefmax = MAX( e1f(ji,jj) , e2f(ji,jj) )
ahmt(ji,jj,jk) = SQRT( (zu2pv2_ij + zu2pv2_ij_m1) * r1_288 ) * zetmax * tmask(ji,jj,jk)      ! 288= 12*12 * 2
ahmf(ji,jj,jk) = SQRT( (zu2pv2_ij + zu2pv2_ij_p1) * r1_288 ) * zefmax * fmask(ji,jj,jk)
END DO
END DO
```

by these ones:

```               DO jj = 2, jpjm1
DO ji = fs_2, fs_jpim1
zu2pv2_ij    = ub(ji  ,jj  ,jk) * ub(ji  ,jj  ,jk) + vb(ji  ,jj  ,jk) * vb(ji  ,jj  ,jk)
zu2pv2_ij_m1 = ub(ji-1,jj  ,jk) * ub(ji-1,jj  ,jk) + vb(ji  ,jj-1,jk) * vb(ji  ,jj-1,jk)
zetmax = MAX( e1t(ji,jj) , e2t(ji,jj) )
ahmt(ji,jj,jk) = SQRT( (zu2pv2_ij + zu2pv2_ij_m1) * r1_288 ) * zetmax * tmask(ji,jj,jk)      ! 288= 12*12 * 2
END DO
END DO
DO jj = 1, jpjm1
DO ji = 1, fs_jpim1
zu2pv2_ij_p1 = ub(ji  ,jj+1,jk) * ub(ji  ,jj+1,jk) + vb(ji+1,jj  ,jk) * vb(ji+1,jj  ,jk)
zu2pv2_ij    = ub(ji  ,jj  ,jk) * ub(ji  ,jj  ,jk) + vb(ji  ,jj  ,jk) * vb(ji  ,jj  ,jk)
zefmax = MAX( e1f(ji,jj) , e2f(ji,jj) )
ahmf(ji,jj,jk) = SQRT( (zu2pv2_ij + zu2pv2_ij_p1) * r1_288 ) * zefmax * fmask(ji,jj,jk)
END DO
END DO
```

### Commit History (2)

ChangesetTimeChangeLog
10784clem2019-03-20T19:36:44+01:00

solve ticket #2261

10783clem2019-03-20T19:36:26+01:00

solve ticket #2261

### comment:1 Changed 5 years ago by nicolasmartin

• Description modified (diff)

### comment:2 Changed 5 years ago by clem

In 10783:

Error: Failed to load processor `CommitTicketReference`
`No macro or processor named 'CommitTicketReference' found`

### comment:3 Changed 5 years ago by clem

In 10784:

Error: Failed to load processor `CommitTicketReference`
`No macro or processor named 'CommitTicketReference' found`

### comment:4 Changed 5 years ago by clem

• Resolution set to fixed
• Status changed from new to closed

solved at r10784