Opened 2 months ago

Closed 7 weeks ago

#2340 closed Bug (fixed)

Segmentation fault in river runoffs

Reported by: tkarna Owned by: systeam
Priority: low Milestone:
Component: SBC Version: release-4.0
Severity: critical Keywords: rivers, segfault,
Cc:

Description

Context

River runoffs can cause a segmentation fault.

Analysis

The river runoff routine (in file src/OCE/SBC/sbcrnf.F90) searches for the number of vertical levels over which the river runoff will be distributed. The corresponding do loop (see lines 343 and 400) has a poor ending condition: if mbkt(ji,jj)=1 the loop will never finish. This causes a segmentation fault in the gdept_0 array.

jk = 2
DO WHILE ( jk /= mbkt(ji,jj) .AND. gdept_0(ji,jj,jk) < h_rnf(ji,jj) ) ;  jk = jk + 1
END DO

Fix

The fix is to use a more generic < end condition in both loops (it's also better programming style):

jk = 2
DO WHILE ( jk < mbkt(ji,jj) .AND. gdept_0(ji,jj,jk) < h_rnf(ji,jj) ) ;  jk = jk + 1
END DO

Commit History (1)

ChangesetAuthorTimeChangeLog
12168smasson2019-12-11T10:16:47+01:00

trunk: minor bugfix in sbcrfn, see #2340

Change History (4)

comment:1 Changed 7 weeks ago by smasson

In 12168:

trunk: minor bugfix in sbcrfn, see #2340

comment:2 Changed 7 weeks ago by clem

Ok, this has been corrected in the trunk at r12168
However, if you get a seg fault it would probably mean that you try to apply runoff on land.

comment:3 Changed 7 weeks ago by tkarna

Great, thanks! Yes, this case corresponds to a setup where one accidentally applies runoff on land. It's good that it does not cause segmentation fault anymore. Maybe Nemo could raise an error or a warning in such a case?

comment:4 Changed 7 weeks ago by smasson

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.