Re: Does print statement will effect the behavior of program?
- From: dpb <none@xxxxxxx>
- Date: Wed, 24 Oct 2007 11:26:46 -0500
Fortran Learner wrote:
....
The problem is, when I try to run that old program, if the lines
start with * are commented, the program will stopped with the
information "forrtl: severe (174): SIGSEGV, segmentation fault
occurred".
But If I drop the * (uncomment the related lines), it will worked. I
am wondering what happened here. And I also found that the program
will stop unless print all the realted varibables.
Here is the related code.
DO 14 I = NCORE+1,NORB
* print *, I, NREF
* print *, IOPTR(I)
* print *, JWLIST(I,IOPTR(I))
IOREF(I,NREF) = JWLIST(I,IOPTR(I))
* print *, "Here no problem"
14 CONTINUE
Some related variables are defined and initialized like this, also the
preset value in the iteration:
NCORE : undefined, but initiaized : NCORE = 0, Present value is:
9
NORB: : undefined, but initiaized : NORB = 0. Present value is:
12
IOPTR(I) : defined in a common block, but NEVER used before the
ieration. ...
This has all the characteristics of out of bounds array access combined
with the possibility of uninitialized variables in either the loop
indices or arrays.
Changing symptoms with the inclusion/exclusion of print statements (or
any other executable code for that matter, it's just so commonly seen w/
i/o owing to the tendency to add debugging statements) is probably one
of the most faq's ever.
I'd suggest compiling with all possible debugging options on,
particularly array bounds checking.
Also, if the code doesn't use implicit none that would be a good start
as well to eliminate all compilation errors arising from its inclusion.
Many codes relied on the nonstandard behavior of some compilers to
initialize variables to zero -- this may also be a case here. While not
a recommendation as to a solution (all variables should definitely be
initialized explicitly), for debugging you might try whatever is the
option for that with the particular compiler you're using.
--
.
- Follow-Ups:
- Re: Does print statement will effect the behavior of program?
- From: Fortran Learner
- Re: Does print statement will effect the behavior of program?
- References:
- Does print statement will effect the behavior of program?
- From: Fortran Learner
- Does print statement will effect the behavior of program?
- Prev by Date: Does print statement will effect the behavior of program?
- Next by Date: Re: Does print statement will effect the behavior of program?
- Previous by thread: Does print statement will effect the behavior of program?
- Next by thread: Re: Does print statement will effect the behavior of program?
- Index(es):
Relevant Pages
|