LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Where is the error in a Gfortran file? (https://www.linuxquestions.org/questions/linux-newbie-8/where-is-the-error-in-a-gfortran-file-4175522569/)

AlexBB 10-18-2014 03:30 PM

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:

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)
end

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:

Code:

fortran_1.f08:6.16:

  read (unit=1,900) val
                1
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?

AlexBB 10-18-2014 04:00 PM

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.

ndc85430 10-19-2014 03:06 AM

Yes you do - your first line. You use '!' to denote comments in Fortran, not '#'.

AlexBB 10-19-2014 11:42 AM

Wow, it worked! It may be the most valuable suggestion I have received here for some time. Appreciate it. Thanks.


All times are GMT -5. The time now is 03:14 PM.