#2340 closed Bug (fixed)
Segmentation fault in river runoffs
Reported by: | tkarna | Owned by: | systeam |
---|---|---|---|
Priority: | low | Milestone: | |
Component: | SBC | Version: | v4.0 |
Severity: | critical | Keywords: | rivers segfault v4.0 |
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)
Changeset | Author | Time | ChangeLog |
---|---|---|---|
12168 | smasson | 2019-12-11T10:16:47+01:00 | trunk: minor bugfix in sbcrfn, see #2340 |
Change History (5)
comment:1 Changed 5 years ago by smasson
comment:2 Changed 5 years 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 5 years 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 5 years ago by smasson
- Resolution set to fixed
- Status changed from new to closed
comment:5 Changed 3 years ago by nemo
- Keywords v4.0 added; removed
In 12168: