who can help me to run the program in G95

135 views
Skip to first unread message

lihong...@gmail.com

unread,
Jun 23, 2014, 8:25:10 AM6/23/14
to gg...@googlegroups.com
Dear G95 group members
I need your help. I run the program in gfortran (I can not install G95 into my mac computer because of system problems). The program can be compiled in gfortran, but when I run the program, there will show the error information as follows :


Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:

#0  0x105372e42

#1  0x10537360e

#2  0x10590e5a9

#3  0x1053650db

#4  0x10536203f

#5  0x10536acf0

#6  0x10536b268

Segmentation fault: 11

Therefore, I need you to help me to run this program in many kinds of fortran compiler, and which one maybe can tell me what is the wrong in my codes. I offer the codes and data in the file.

When the program show the information as "please input the file name of input file within 80 bytes", you just need to copy the data into the screen because I do not write the output until now. If there are any wrong information,please send the email to me (xumi...@aliyun.com) or send to this forum. Thanks

Best Wishes
Xu

data.docx
the program.docx

Robert Funnell

unread,
Jun 23, 2014, 11:39:24 AM6/23/14
to lihong...@gmail.com, gg...@googlegroups.com
On Mon, 23 Jun 2014, lihong...@gmail.com wrote:

> Dear G95 group members
> I need your help. I run the program in gfortran (I can not install G95 into
> my mac computer because of system problems). The program can be compiled in
> gfortran, but when I run the program, there will show the error information
> as follows :
>
>
> Program received signal SIGSEGV: Segmentation fault - invalid memory
> reference.
>
> Backtrace for this error:
>
> #0 0x105372e42
> ...

Doesn't gfortran have options that will cause it to output more
detailed error messages, including file names and line numbers of the
calling routines?

lihong...@gmail.com

unread,
Jun 24, 2014, 1:32:30 AM6/24/14
to gg...@googlegroups.com, lihong...@gmail.com
I am new to gfortran. Do you know which option in gfortran? Thanks
Xu

2014年6月24日火曜日 0時39分24秒 UTC+9 Robert:

lihong...@gmail.com

unread,
Jun 24, 2014, 5:00:25 AM6/24/14
to gg...@googlegroups.com, lihong...@gmail.com
I had found the option to check the warning. Thanks
Xu

2014年6月24日火曜日 14時32分30秒 UTC+9 lihong...@gmail.com:

jfh

unread,
Jun 26, 2014, 6:02:16 PM6/26/14
to gg...@googlegroups.com

I don't have the spare time to check someone else's 138 KB file but I do have 3 constructive suggestions.

1. There are various causes of segmentation faults but common ones are calling a subroutine or function with actual arguments that don't match the dummy arguments, and using an element of an array that's outside the declared bounds. Compile with all the checks your compiler offers. With gfortran and g95 and a program called myprogram.f90 I would use

gfortran  -Wall -Wextra -fbounds-check -Wintrinsic-shadow -fcheck=all -Wconversion -Wcharacter-truncation -Wsurprising -pedantic myprogram.f90

or

g95 -fbounds-check -Wall -Wextra -freal=nan -finteger=-1234567890 myprogram.f90

If using g95 note that -freal and -finteger only give scalar variables unlikely values to start with, not array elements, but they will help rescue you if your program assumes all variables = 0 until given other values. You won't make that mistake yourself (I hope) but you may have collected a program written by someone else whose computer did that automatically.

2. Make a copy of your program and remove parts of it, testing whether you still get the error. With luck you will finish up with a very short program that still has the error, which makes it much easier to diagnose. Do not change your original program, as you may need it to check your copy against it or start again if you have guessed wrong about the cause of the error.

3. If you get an error message saying Internal compiler error then you have found a bug in the compiler, whether your program has a bug or not. Recently I got one of these from gfortran 4.8 in a complicated program; I was about to start step 2 and report the bug when I had located it but first I downloaded gfortran 4.9 and found that the compiler bug had been fixed.

ep...@juno.com

unread,
Jul 25, 2014, 11:48:30 AM7/25/14
to gg...@googlegroups.com
On Thursday, June 26, 2014 6:02:16 PM UTC-4, jfh wrote:
On Tuesday, June 24, 2014 12:25:10 AM UTC+12, lihong...@gmail.com wrote:
I run the program in gfortran (I can not install G95 into my mac computer because of system problems). The program can be compiled in gfortran, but when I run the program, there will show the error information as follows :

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

I don't have the spare time to check someone else's 138 KB file but I do have 3 constructive suggestions.

There are various causes of segmentation faults but common ones are calling a subroutine or function with actual arguments that don't match the dummy arguments, and using an element of an array that's outside the declared bounds.

One big problem with this program as that most arrays are declared as ALLOCATABLE inside subroutines even though they are not allocated or deallocated there. Subroutine MOTION calls subroutine HYDRO_DRAG. Many arguments to HYDRO_DRAG are not referenced in the calling routine and also are NOT in the argument list from the main program. They are declared as allocatable, hence they are *local* but they are not allocated there. Passing them to the inner routine leads to wild references and out of bounds errors with crazy bounds.

g95 does not help with warnings turned on. Error messages are "variable X is set but never allocated".
.
Reply all
Reply to author
Forward
0 new messages