For Programmers: Free Programming Magazines  


Home > Archive > Fortran > April 2007 > unexplainable behaviour - f90 - looking for some tools to help diagnose









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author unexplainable behaviour - f90 - looking for some tools to help diagnose
oyaron

2007-04-17, 7:05 pm

Hi Everyone.

Sorry for the very general subject but that's exactly my problem now -
not being able to pin point on anything specific.
I have a very large piece of code in f90 that includes many
subroutines and some modules - basically a numerical scheme to solve a
set of ODEs, etc...

During my last set of updates, something was probably ruined and I'm
now in a situation in which the behaviour of the run can change
completely (including getting stuck) even when adding a very simple
debug printing (WRITE statement) or certain simple assignments or
simple DO loops - even statements that have nothing to do with the
surrounding code (meaning nothing that should affect the run).

My latest updates did include use of new arrays, a change of arguments
between subroutines etc...

My questions are:

1. Did anyone encounter such frustrating situations, and if so, are
there any suggestions.
2. Which tools can I use to try starting diagnose the situation? would
using a debugger help? maybe running a source check, e.g. like ftnchek
- but that's only for f77 (is there anything good for f90?)

Thanks in advance, Ofer.

Beliavsky

2007-04-17, 7:05 pm

On Apr 17, 9:52 am, oyaron <oya...@gmail.com> wrote:
> Hi Everyone.
>
> Sorry for the very general subject but that's exactly my problem now -
> not being able to pin point on anything specific.
> I have a very large piece of code in f90 that includes many
> subroutines and some modules - basically a numerical scheme to solve a
> set of ODEs, etc...
>
> During my last set of updates, something was probably ruined and I'm
> now in a situation in which the behaviour of the run can change
> completely (including getting stuck) even when adding a very simple
> debug printing (WRITE statement) or certain simple assignments or
> simple DO loops - even statements that have nothing to do with the
> surrounding code (meaning nothing that should affect the run).
>
> My latest updates did include use of new arrays, a change of arguments
> between subroutines etc...
>
> My questions are:
>
> 1. Did anyone encounter such frustrating situations, and if so, are
> there any suggestions.


Yes, all of us, I feel safe in saying. There is probably a bug in the
code, such as accessing an out-of-bounds array element. You did not
say what compiler, compiler options, and operating system you are
using. You should turn on all warnings and debugging options of your
compiler -- some are listed for several compilers at
http://www.polyhedron.com/pb05/linux/diagnose.html .

You should use a source control system so that going back to earlier
versions is easy. In this case I don't practice what I preach, but I
do create a zip file daily of all Fortran source files and their input
parameter files. It's better than nothing.

oyaron

2007-04-17, 7:05 pm

On Apr 17, 5:02 pm, Beliavsky <beliav...@aol.com> wrote:
> On Apr 17, 9:52 am, oyaron <oya...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> Yes, all of us, I feel safe in saying. There is probably a bug in the
> code, such as accessing an out-of-bounds array element. You did not
> say what compiler, compiler options, and operating system you are
> using. You should turn on all warnings and debugging options of your
> compiler -- some are listed for several compilers athttp://www.polyhedron.com/pb05/linux/diagnose.html.
>
> You should use a source control system so that going back to earlier
> versions is easy. In this case I don't practice what I preach, but I
> do create a zip file daily of all Fortran source files and their input
> parameter files. It's better than nothing.


Thanks for the prompt reply...
I'm using ifort compiler on linux system, optimization switched off (-
O0).
Can you suggest specifically which warning etc.. switches should be
turned on (with ifort)?

e p chandler

2007-04-17, 7:05 pm

On Apr 17, 9:52 am, oyaron <oya...@gmail.com> wrote:
> Hi Everyone.
>
> Sorry for the very general subject but that's exactly my problem now -
> not being able to pin point on anything specific.
> I have a very large piece of code in f90 that includes many
> subroutines and some modules - basically a numerical scheme to solve a
> set of ODEs, etc...
>
> During my last set of updates, something was probably ruined and I'm
> now in a situation in which the behaviour of the run can change
> completely (including getting stuck) even when adding a very simple
> debug printing (WRITE statement) or certain simple assignments or
> simple DO loops - even statements that have nothing to do with the
> surrounding code (meaning nothing that should affect the run).
>
> My latest updates did include use of new arrays, a change of arguments
> between subroutines etc...
>
> My questions are:
>
> 1. Did anyone encounter such frustrating situations, and if so, are
> there any suggestions.


These are common symptoms of array access out of bounds or an argument
mismatch.
You are trashing memory somewhere.

> 2. Which tools can I use to try starting diagnose the situation? would
> using a debugger help? maybe running a source check, e.g. like ftnchek
> - but that's only for f77 (is there anything good for f90?)


1. Turn on your compiler's debugging options, in particular bounds
checking. For g95 this is -fbounds-check.

2. Compile with Silverfrost (FTN95). It has many good debugging
options.

3. Are you taking advantage of the features of Fortran 90? Read up on
using modules. This is one way to get an automatic interface check on
subroutine arguments.

4. Divide and conquer. Go back to your last working program and change
one thing at a time. Compile and run, etc.

>Thanks in advance, Ofer.


HTH

-- Elliot


Beliavsky

2007-04-18, 8:04 am

On Apr 18, 7:11 am, Catherine Rees Lay <catherine.n...@polyhedron.com>
wrote:

<snip>

> If it's compatible with your code (it's Windows rather than Linux), the
> Silverfrost compiler is truly excellent at catching these sorts of problems.


Yes, but it is a strict Fortran 95 compiler, not supporting the
Technical Report extending the functionality of allocatable arrays.
Other Fortran 95 compilers being actively maintained do implement the
TR. The Silverfrost compiler is becoming less relevant to many Fortran
programmers, even those who use Windows.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com