[Dart-dev] DART/branches Revision: 12998
dart at ucar.edu
dart at ucar.edu
Mon Mar 4 11:04:16 MST 2019
nancy at ucar.edu
2019-03-04 11:04:16 -0700 (Mon, 04 Mar 2019)
378
use a single precision integer in the time tendency
routine. with intel 18.0.1 and the default optimization
(-O) the second iteration of this loop is executed twice
if the index is a long int. since we're accumulating in
the loop, this results in wrong answers. other versions
of the compiler fix this bug, but just to be safe we can
easily use a single precision int here.
Modified: DART/branches/recam/models/lorenz_96/model_mod.f90
===================================================================
--- DART/branches/recam/models/lorenz_96/model_mod.f90 2019-03-04 17:59:00 UTC (rev 12997)
+++ DART/branches/recam/models/lorenz_96/model_mod.f90 2019-03-04 18:04:16 UTC (rev 12998)
@@ -135,15 +135,18 @@
real(r8), intent(in) :: x(:)
real(r8), intent(out) :: dt(:)
-integer :: j, jp1, jm1, jm2
+integer :: j, jp1, jm1, jm2, ms
-do j = 1, model_size
+! avoid compiler bugs with long integers
+! being used as loop indices.
+ms = model_size
+do j = 1, ms
jp1 = j + 1
- if(jp1 > model_size) jp1 = 1
+ if(jp1 > ms) jp1 = 1
jm2 = j - 2
- if(jm2 < 1) jm2 = model_size + jm2
+ if(jm2 < 1) jm2 = ms + jm2
jm1 = j - 1
- if(jm1 < 1) jm1 = model_size
+ if(jm1 < 1) jm1 = ms
dt(j) = (x(jp1) - x(jm2)) * x(jm1) - x(j) + forcing
end do
More information about the Dart-dev
mailing list