From: Benjamin on
On 1 Jun., 17:56, mecej4 <mecej4.nyets...(a)operamail.com> wrote:
> Benjamin wrote:
>
> > After compiling the whole codes without no errors, I'm getting into
> > the trouble of  "segmentation fault" when I try to run the executable
> > file.
> > It's a little bit annoying....
> > Although I've known it's generated by several factors:
> > # An array index is outside the declared range.
> > # The name of an array index is misspelled.
> > # The calling routine has a REAL argument, which the called routine
> > has as INTEGER.
> > # An array index is miscalculated.
> > # The calling routine has fewer arguments than required.
> > # A pointer is used before it has been defined.
> > ....I can't find the fatal factor(s).
>
> > But is there any software or package to check this progress?
> > My OS is openSUSE 11.0, the compiler is SCons.
>
> 1. Compile with the checking options of your compiler set ON
> (e.g., -C -traceback ... check your compiler options list see what to use)
>
> AND/OR
>
> 2. Compile with -g, and use tools such as GDB and VALGRIND.
>
> Once you establish that the seg-fault is traceable to your code, you may see
> it as a good thing, if the alternative is to propagate erroneous results
> throughout your program with no notification to you.
>
> Compiling without errors merely establishes that those errors that are
> detectable by static analysis of the code have been removed. By no means
> does it follow that there are no more errors left in the code.
>
> -- mecej4

Thanks a lot.
I've complied the program with SCons...
now I'm trying to debug the program with gdb..
From: steve on
On Jun 1, 8:01 am, Benjamin <benjami...(a)googlemail.com> wrote:
> On 1 Jun., 16:59, steve <kar...(a)comcast.net> wrote:
>
>
>
> > On Jun 1, 7:53 am, Benjamin <benjami...(a)googlemail.com> wrote:
>
> > > After compiling the whole codes without no errors, I'm getting into
> > > the trouble of  "segmentation fault" when I try to run the executable
> > > file.
> > > It's a little bit annoying....
> > > Although I've known it's generated by several factors:
> > > # An array index is outside the declared range.
> > > # The name of an array index is misspelled.
> > > # The calling routine has a REAL argument, which the called routine
> > > has as INTEGER.
> > > # An array index is miscalculated.
> > > # The calling routine has fewer arguments than required.
> > > # A pointer is used before it has been defined.
> > > ....I can't find the fatal factor(s).
>
> > > But is there any software or package to check this progress?
> > > My OS is openSUSE 11.0, the compiler is SCons.
>
> > Scons appears to be some sort of integrated build environment.
> > What is the actual Fortran compiler installed on your system?
>
> > --
> > steve
>
> Oh, sry, gFortran is the actual comiler

With gfortran try the compiler options '-fbounds-check -Wall -Wextra -
g'.
The -Wall and -Wextra option will most likely produce a large amount
that (IMHO) should be fixed. -fbounds-check should help catch array
index issues.

--
steve
From: dpb on
Benjamin wrote:
....

> Thanks a lot.
> I've complied the program with SCons...
> now I'm trying to debug the program with gdb..

As others have noted, use all available error trapping and traceback
options first.

One could also disable optimization until the problem(s) is/are resolved
as well as it may make determination of just where something went sought
somewhat easier.

Rarely would there be no clues or breadcrumbs to follow after such has
been done...

--
From: Louis Krupp on
On 6/1/2010 8:53 AM, Benjamin wrote:
>
> After compiling the whole codes without no errors, I'm getting into
> the trouble of "segmentation fault" when I try to run the executable
> file.
> It's a little bit annoying....
> Although I've known it's generated by several factors:

<snip>
> # The name of an array index is misspelled.

Use "implicit none" if you're not doing so already. You'll have to
declare all of your variables, and unless you declare two variables with
very similar names, the compiler is likely to catch misspellings.

> # The calling routine has a REAL argument, which the called routine
> has as INTEGER.
<snip>
> # The calling routine has fewer arguments than required.
<snip>

Use modules. The compiler will convert arguments as necessary (someone
want to verify this?) or flag argument list mismatches.

Louis
From: Ron Shepard on
In article <5KWdnQAwhvwt9ZjRnZ2dnUVZ_g6dnZ2d(a)indra.net>,
Louis Krupp <lkrupp_nospam(a)indra.com.invalid> wrote:

>
> Use modules. The compiler will convert arguments as necessary

No, nothing is converted.

> (someone
> want to verify this?)

You must be thinking of some other language. Other languages do
sometimes do silent conversions to match arguments.

> or flag argument list mismatches.

This part *IS* right, and that's one of the reasons why modules are so
useful.

$.02 -Ron Shepard