#1934 closed Bug (fixed)
Bug in diawri.F90:dia_wri() for kinetic energy (eken)
Reported by: | pderian | Owned by: | nemo |
---|---|---|---|
Priority: | low | Milestone: | |
Component: | OCE | Version: | v3.6 |
Severity: | Keywords: | OPA eken kinetic outputs v3.6 | |
Cc: |
Description
Context
Experienced "Segmentation fault - invalid memory reference" crashes in diawri.F90:dia_wri() (with key_iomput) when trying to output kinetic energy (field id="eken").
Analysis
Looking at dia_wri(), there is these lines 297-299:
IF ( iom_use("eken") ) THEN rke(:,:,jk) = 0._wp ! kinetic energy DO jk = 1, jpkm1 ...
It is unclear why the "rke(:,:,jk) = 0._wp" assignment involves the jk variable in this context. The value of the later is not guaranteed and out-of-bound crash could occur?
Fix
Commenting said line 298 fixes the issue.
Commit History (2)
Changeset | Author | Time | ChangeLog |
---|---|---|---|
8465 | timgraham | 2017-08-25T10:34:47+02:00 | |
8464 | timgraham | 2017-08-25T10:31:40+02:00 |
Change History (8)
comment:1 Changed 7 years ago by timgraham
comment:2 Changed 7 years ago by pderian
I see; thanks Tim for the correct fix!
comment:3 Changed 7 years ago by timgraham
- Resolution set to fixed
- Status changed from new to closed
comment:4 Changed 7 years ago by nemo
- Keywords outputs added; output removed
comment:5 Changed 7 years ago by nemo
- Keywords energy removed
comment:6 Changed 7 years ago by nemo
- Keywords release-3.6* added
comment:7 Changed 7 years ago by nemo
- Keywords release-3.6* removed
comment:8 Changed 3 years ago by nemo
- Keywords OPA v3.6 added
Note: See
TracTickets for help on using
tickets.
Coincidentally we were looking at this bit of code earlier this morning for another reason. The error you have seen is a bug but the suggested fix is not correct. Line 298 should be replaced with
so that the bottom grid point is set to zero (this is because the loop at line 299 only goes to jpkm1. If this is not done then with some compilers invalid values will occur in the bottom grid cell and will cause an error in XIOS later and these errors are really hard to find.
The reason we were looking at the code is that the units suggest that there is a bug. I'll open another ticket for this though.