Closed gnikit closed 3 years ago
That's right: fortran does not guarantee short-circuit logic
Maybe something like:
if (int_dump_period>0) then
zero_modulus = mod(timestep, int_dump_period) == 0
else
zero_modulus = True
end if
if (zero_modulus) then
...
TBH I find the logic in that part of the code a little hard to follow
Closed via #301
In line 91 https://github.com/FluidityProject/fluidity/blob/2ad88a413ca999d4bd37b50e8ddb2588866335c1/femtools/Write_State.F90#L91
A comparison for
int_dump_period == 0
is done followed by amod(,int_dump_period)
,mod()
however is incapable of handling divisions by zero (it should throw and arithmetic exception if divided by zero). The actual problem arises due to the fact that the Fortran standard does not evaluate logic statements in any particular direction and does not have short-circuit evaluation either.taken from this discussion at the Intel Forum
So it is up to the compiler and its optimiser to chose how such clauses are evaluated. I think GCC strictly follows the standard in newer versions (at least with debugging symbols) so it will probably segfault in Ubuntu 20.04