Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 10-18-2014, 03:30 PM   #1
Registered: Mar 2014
Posts: 444

Rep: Reputation: Disabled
Where is the error in a Gfortran file?

Hi there. My environment is: Win 7==>Oracle VB=>>Ubuntu==>Gfortran. I am trying to restore my previous FORTRAN skills starting with something elementary. This is the code:

#Attempt to read a few files in the directory and compare the values
program main
   real :: val
   900 format (F8.3)
   open (unit=1, file = "gray_disk_impr_100_256_128.dat", status = 'old')
   read (unit=1,900) val
   write (unit=6,900) val
   close (unit=1)
While compiling I get this error. It points to read and write statements (identical errors). The pointer points to the number 900 (format). It says:


   read (unit=1,900) val
Error: Syntax error in READ statement at (1)
You can see that the source code file extension is .f08. I also tried to use an asterisk instead of a numbered format statement and it gave me an error. Where is the problem?

Thanks, - Alex

P.S. Also Is there a description of all error codes for GFortran?

Last edited by AlexBB; 10-18-2014 at 03:35 PM.
Old 10-18-2014, 04:00 PM   #2
Registered: Mar 2014
Posts: 444

Original Poster
Rep: Reputation: Disabled
OK, I found the error:

The read statement should have been:

read(1,900), that's it. "unit" killed it. The same is of course true for the write statement. The last unresolved issue I have is a warning: illegal preprocessing directive. It does not say what kind. I really do not have any. Thanks.
Old 10-19-2014, 03:06 AM   #3
Registered: Apr 2014
Distribution: Slackware
Posts: 92

Rep: Reputation: Disabled
Yes you do - your first line. You use '!' to denote comments in Fortran, not '#'.
Old 10-19-2014, 11:42 AM   #4
Registered: Mar 2014
Posts: 444

Original Poster
Rep: Reputation: Disabled
Wow, it worked! It may be the most valuable suggestion I have received here for some time. Appreciate it. Thanks.


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
[SOLVED] Gfortran compilation error. Why? AlexBB Linux - Newbie 2 05-04-2014 10:33 AM
Does gfortran has issue working with the file as I/P and O/P ?? parekhharsh_j Linux - Newbie 6 06-17-2011 08:39 AM
"gfortran:error trying to execute f951 and execvp: no such file or directorry kandhakumar Linux - Software 1 06-01-2009 09:37 AM
gfortran runtime error saray Linux - Software 1 05-02-2009 10:56 AM
Gfortran compile error aukuntin Linux From Scratch 2 01-28-2007 08:08 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:29 PM.

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