- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello I've been having some problems with how a counter is being added up.... This counter is used as an index in a couple of arrays, and because its been behaving strangely I've had a lot of problems.
To better illustrate this I wrote a simple program that adds the counter as in my subroutine, and it has been appended at the end.
This program returns the following output:
The second run output is the correct one because the value of q must be 24 at the end. What I don't understand is why the first cycle (without the WRITE statement) acts so strangely so as to return such an erroneous value for q. Any suggestions or ideas?
The program has been compiled like this:
My computer has Linux CentOS 4.2 installed, and is a Dell Inspiron 8100 laptop. With PIII processor (1 GHz), and 512MB of RAM.
I should notice that when compiled with gfortran (http://gcc.gnu.org/fortran/) I got the correct solutions in both cycles.
So is this maybe a bug????
Any input will be very much appreciated!
thanks,
Rodrigo.
To better illustrate this I wrote a simple program that adds the counter as in my subroutine, and it has been appended at the end.
This program returns the following output:
Output first run: 32 24
q 8
q 9
q 14
q 15
Output second run: 24 24
The second run output is the correct one because the value of q must be 24 at the end. What I don't understand is why the first cycle (without the WRITE statement) acts so strangely so as to return such an erroneous value for q. Any suggestions or ideas?
The program has been compiled like this:
$ ifort nonesense.f90
My computer has Linux CentOS 4.2 installed, and is a Dell Inspiron 8100 laptop. With PIII processor (1 GHz), and 512MB of RAM.
I should notice that when compiled with gfortran (http://gcc.gnu.org/fortran/) I got the correct solutions in both cycles.
So is this maybe a bug????
Any input will be very much appreciated!
thanks,
Rodrigo.
PROGRAM nonsense
IMPLICIT NONE
INTEGER, PARAMETER :: nt = 4, nc = 3, nq = nt*(nc + 3)
INTEGER :: i, q, k
q = 1
DO i = 1, nc-1
q = q + 1
END DO
q = q + 1
q = q + 1
q = q + 1
q = q + 1
DO k = 2, nt-1
DO i = 1, nc-1
q = q + 1
END DO
q = q + 1
q = q + 1
q = q + 1
q = q + 1
END DO
DO i = 1, nc
q = q + 1
END DO
q = q + 1
q = q + 1
WRITE (*,*) 'Output first run:',q, nq
q = 1
DO i = 1, nc-1
q = q + 1
END DO
q = q + 1
q = q + 1
q = q + 1
q = q + 1
DO k = 2, nt-1
DO i = 1, nc-1
q = q + 1
WRITE(6,*) 'q',q
END DO
q = q + 1
q = q + 1
q = q + 1
q = q + 1
END DO
DO i = 1, nc
q = q + 1
END DO
q = q + 1
q = q + 1
WRITE (*,*) 'Output second run:',q, nq
END PROGRAM nonsense
Message Edited by soyrush@gmail.com on 02-16-2006 04:06 PM
Message Edited by soyrush@gmail.com on 02-16-2006 04:18 PM
Link Copied
0 Replies

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page