LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-08-2014, 08:46 PM   #1
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Rep: Reputation: Disabled
Debugging a GFortran program.


Hi there. My environment is Win7==>Oracle VB=>>Ubuntu==>GFortran.

I just converted apparently a FORTRAN77 program to GFortran and it finally compiled. The program is huge: over 6,000 lines. After the compilation I ran the exec file (./a.out) and nothing happened. I mean there is no output. So, I would like to have an option to do step by step debugging, like in Microsoft Visual Studio for instance.

I found gdb package but it required debugging symbols. I ran it with the -g option that generates them but again nothing really happens.

I am wondering what options do exist out there for debugging?

Thanks, A.

Last edited by AlexBB; 11-08-2014 at 08:55 PM.
 
Old 11-08-2014, 10:24 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,260

Rep: Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948
Anything written in Fortran 77 will compile without issue in gfortran. Fortran 77 is Fortran 77, the language is operating system and compiler-independent. What, exactly, did you do to "convert" it? And what did you convert it TO?

When you run it, does it return, or does it get stuck running? If it returns, what's the exit status (echo $?)?

Last edited by suicidaleggroll; 11-08-2014 at 10:28 PM.
 
Old 11-09-2014, 10:34 AM   #3
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Original Poster
Rep: Reputation: Disabled
In my OP I made it clear that I was not sure it was FORTRAN77. I am not that knowledgeable. I now know for a fact that there are quite a few FORTRAN dialects, some of them proprietary it seems. This is exactly what I did. From that first attempt to compile it, when the compiler gave me allotted 25 errors, it became clear that the compiler did not like the letter C in the first column for continuation. It takes "!" instead and, of course, as we know, not necessarily in the first column position because I stored the source code in a file with .f08 extension. Then there were many problems with FORMAT statements. I had to replace single quote with double quote mark and especially duals like /'...'/ had to be replaces with this: "...". All statements of continuation which were digits or asterisks in the 6th column had to be removed and instead an ampersand & had to be placed at the end of the previous line. This is pretty much the extend of it. It could have been even an earlier version of FORTRAN, like FORTRAN 66?
 
Old 11-09-2014, 10:39 AM   #4
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Original Poster
Rep: Reputation: Disabled
Yes, it is definitely a FORTRAN 66. I just found a statement in the source code to READ two values from a data card!
 
Old 11-09-2014, 10:43 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,133

Rep: Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273
You can write a small test program to check how debugging works. (You need to compile your code with -g and run/execute with gdb). You can also try to set breakpoints.
But again: What do you mean by nothing happened?
When you run it, does it return, or does it get stuck running? If it returns, what's the exit status (echo $?)?
You can also try strace to check if the program is running (for example in an endless loop).
 
Old 11-09-2014, 11:00 AM   #6
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Original Poster
Rep: Reputation: Disabled
Thanks, I am working on it actually. What I meant by "nothing happened" was that I had practically no feedback. First time (yesterday) it stuck on a READ statement from stdin. It was also unexpected that the stdin is called LIN in this program. OK, I actually compiled it with -g option yesterday and now ran it with gdb run <filename> so it gave me a symbol table. I don't know if you have any experience with Visual Studio and the debugging over there. I expect something like this: to be able to trace execution step by step. This huge program is actually working now but it leaves me no option to understand what is going on inside.

Now it does return with a statement:

Code:
Reading symbols from /home/alex/LEGENDRE/a.out...done.
(gdb) run
Starting program: /home/alex/LEGENDRE/a.out 
 ** TEST SINGLE PRECISION LEGENDRE FUNCTION ROUTINES IN FCNPAK ** 
 ***** TEST 1 (SINGLE PRECISION) PASSED *****
 ***** TEST 2 (SINGLE PRECISION) PASSED *****
 ***** TEST 3 (SINGLE PRECISION) PASSED *****
 ***** TEST 4 (SINGLE PRECISION) PASSED *****
 ***** TEST 5 (SINGLE PRECISION) FAILED *****
0 TESTS COMPLETED, NUMBER OF TESTS FAILED =  1
 ** TEST DOUBLE PRECISION LEGENDRE FUNCTION ROUTINES IN FCNPAK ** 
 ***** TEST 1 (DOUBLE PRECISION) PASSED *****
 ***** TEST 2 (DOUBLE PRECISION) PASSED *****
 ***** TEST 3 (DOUBLE PRECISION) PASSED *****
 ***** TEST 4 (DOUBLE PRECISION) PASSED *****
 ***** TEST 5 (DOUBLE PRECISION) FAILED *****
0 TESTS COMPLETED, NUMBER OF TESTS FAILED =  1
 ***** WARNING -- AT LEAST ONE TEST FOR SUBLIBRARY FCNPAKHAS FAILED ***** 
[Inferior 1 (process 18136) exited normally]
(gdb)
 
Old 11-09-2014, 11:05 AM   #7
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Original Poster
Rep: Reputation: Disabled
OK I tried ctrace. This is what I got:

Code:
(gdb) strace legendre_fun2.f08
Function "legendre_fun2.f08" not defined.
Make static tracepoint pending on future shared library load? (y or [n])
What shall I say: Yes or No?

Then why does it say that the file is not defined? It is defined for sure.
 
Old 11-09-2014, 11:19 AM   #8
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Original Poster
Rep: Reputation: Disabled
OK, it seems I found what I needed.
 
Old 11-09-2014, 11:35 AM   #9
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,133

Rep: Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273
you can use ddd as GUI frontend for gdb.
 
Old 11-09-2014, 12:12 PM   #10
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Original Poster
Rep: Reputation: Disabled
Could you explain what it means? It is interesting but I am not sure I understand it. Thanks.
 
Old 11-09-2014, 02:01 PM   #11
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,133

Rep: Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273
ddd is a tool, you need to install it. That is a graphical environment to debug. https://www.gnu.org/software/ddd/
 
1 members found this post helpful.
Old 11-09-2014, 02:29 PM   #12
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Original Poster
Rep: Reputation: Disabled
Wow! It is cool! Thank you much. A.
 
Old 11-09-2014, 05:00 PM   #13
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,133

Rep: Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273
glad to help you. If you really want to say thanks just press YES
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to terminate a gfortran program? AlexBB Linux - Newbie 6 05-06-2014 07:27 AM
C program - RTLD - Help with Debugging nikunjbadjatya Programming 1 03-23-2011 11:22 PM
Running a gFortran job and debugging options Albert P. Linnell Linux - Newbie 1 03-03-2009 11:46 PM
Debugging an exexutable C program akm3 Programming 6 12-18-2008 11:45 AM
Debugging Multithreaded Program villie Programming 2 08-17-2004 12:24 PM


All times are GMT -5. The time now is 10:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration