Skip to content

Uninitialised variables VS/VD in w3srcemd #1036

Closed
@ukmo-ccbunney

Description

@ukmo-ccbunney

Describe the bug
The VS and VD variables are not being properly initialised in w3srcemd.

Unfortunately, the compiler never complains about because it looks like they are being set with values here:

WW3/model/src/w3srcemd.F90

Lines 1446 to 1448 in 3eb8161

DO IS=IS1, NSPECH
VS(IS) = VSLN(IS) + VSIN(IS) + VSNL(IS) &
+ VSDS(IS) + VSBT(IS)

However, the loop is through IS1 to NSPECH, which are not necessarily the same as 1 and NSPEC respectively.
This means there are potentially some array elements that are unilitialised

The next time that VD is used (in the PDLIB versions of ww3_tp2.21 at least) is in the source term increment loop here:

WW3/model/src/w3srcemd.F90

Lines 1562 to 1566 in 3eb8161

DO IK = 1, NK
JAC = CLATSL/CG1(IK)
DO ITH = 1, NTH
ISP = ITH + (IK-1)*NTH
VD(ISP) = MIN(0., VD(ISP))

which is looping over the whole spectrum (IK and ITH).

To Reproduce
Compiled and run ww3_tp2.21 regtests with -finit-real=snan
This initialises all real variables to signalling NaN values (which should cause a crash).

Expected behavior
Regtest should crash (it did with GNU compiler) complainig about invalid values in VD around line 1566.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions