Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29253 Discussions

Problem with variable that change their values without apparent reason

Matteo
Novice
14,231 Views
I would propose a part of my code:INTEGER :: n,a,b
REAL*8 :: c
LOGICAL, ALLOCATABLE, DIMENSION(:,:) :: pop, new_pop
LOGICAL, ALLOCATABLE, DIMENSION(:,:,:;:) :: position
!
OPEN(10, FILE = 'printout.txt')
n = 150
ALLOCATE(pop(1:n,1:n))
ALLOCATE(new_pop(1:n,1:n))
ALLOCATE (position(1:n,1:n,1:n,1:n))
pop(:,:) = .FALSE.
position(:,:,:,:) = .FALSE.
! some assignation to pop matrix
! position should trace the assignation, but it is not important for this example
pop(2,5) = .TRUE.
pop(75,1) = .TRUE. !...ans so on
DO a=1,n
DO b=1,n
IF (a.gt.100.and.b.lt.50) THEN
CYCLE
ELSE
CALL random_number(c)
IF (x.gt.0.5d0) THEN
new_pop(a,b) = .TRUE.
ELSE
new_pop(a,b) = pop(a,b)
END IF
END IF
END DO
END DO
! I would write that
DO a=1,n
WRITE(10,1000) pop(a,:)
END DO

It is old fashion, but it should work.
Inside the two DO cycle "pop" is never on the left side of the assignment.
Anyway, when I try to write, "pop(128,1)" doesn't report the correct value. In fact, it should have the initial value .FALSE., but in debug I found .TRUE.

I fear it can be linked to the memory.
In fact, I use a 32bit compiler on Windows 7 (Intel Fortan 10.x) and I fear Fortran can make some mess with the memory management (these are the only variables and the arraies are very large).
I should set better my compiler?

Regards,
Matteo
 
Labels (2)
0 Kudos
42 Replies
JohnNichols
Valued Contributor III
821 Views

I was interested in the steps you all followed - it was fascinating to watch. 

IN 1996 I set Strand6 running on the mainframe at the Uni at 8 pm, it grabbed the CPU and locked out everything until the operator arrived the next morning.  I was told by the Dean I was banned from the system forthwith.  I ran it on a 386 and it took 2 weeks for one run.  These days it would take a few minutes - the computer did nothing for two weeks but sit there -- the IT people were upset I said it will return relax. By the 10th day I was worried. 

The IT people banned that program. 

It is just fun and iteration. 

I once spent 7 days working on one line of LISP in an AutoLISP program - try teaching yourself LISP using the command manual for AUTOLISP before the internet.  I was jumping up and down when I got it to work, my friend said calm down it is only LISP. 

 

0 Kudos
Reply