Hello Guys,
I'm having a few unusual problems and wondered if someone could please advise. I'm running a code that performs a number of calculations. When the code begins certain values are initialised and, after a prescribed number of loops, the values are changed. A simplified version of my code would be
IMPLICIT NONE
INTEGER :: I, flow
REAL(dp) :: z1, z2 !I've used double precision here
flow=4
z1=0._dp
z2=0._dp
DO I=1,10
IF ( (flow==4) .and. ( I>20 ) ) THEN
z1=0.1_dp
z2=0.1_dp
ENDIF
perform_calculations
ENDDO
The loop goes up to 10 here and so I would imagine that the IF statement would be bypassed entirely as although the first condition is true (flow==4) the second is never true. The problem I'm having, however, is that the output of the code changes depending on whether the IF statement is present or not. The results of the 'perform_calculations' section depend upon what I put inside the IF statement - even though it should not be accessed.
I know this sounds strange: If I use different values of z within the IF statement then the output of 'perform_calculations' should not change - as the IF statement is never true. The output does change however and I'm really confused!
My solution, for this simple case, should be an array of zeros. The numbers are exactly zero - there is no numerical error here due to the nature of the eqns I'm solving. If I use one value of z then I get 0e00 as my output (which is correct for the case I'm dealing with). If I change the values of z in the IF block, however, then I get an array of numbers *e-18.
Could someone please help me understand why this is happening? I cannot understand why the contents of the IF statement should cause this change of output.
many thanks, B