Visit Our UNIX and Linux User Community

Fortran compile problem

Thread Tools Search this Thread
Operating Systems Linux Fortran compile problem
# 1  
Old 05-09-2012
Data Fortran compile problem

Hello everyone,

I am trying to compile a code under fedora14.Kernel Linux 2.32.0. I use f77,g77 and gfortran to compile but I get the same error all ways.

         open(unit=02,status='old',form='formatted',file='STNS',read only)        ^

and open statements are like this:

      open(unit=02,status='old',form='formatted',file='STNS',read only)
      rewind (02)
      call input2

What could be the reason of this problem? I have checked and some pages say that the problem could be solved by changing the code. In my case, since the code is nearly 10000 lines long, it is impossible for me to change it and I have a little knowledge about Fortran.

What should I do to compile the code? Should I try unix or sun??? Is that be the reason?

Thank you everyone!!
# 2  
Old 05-09-2012

The "read only" part of the open will not compile on any Fortran that I know of.

The error message that I get is:
open(unit=02,status='old',form='formatted',file='STNS',read only)
Error: Syntax error in OPEN statement at (1)

Here's a script that lists, compiles, and executes an alternative that will compile, assuming that what the code really wanted was to not write on the file:
#!/usr/bin/env bash

# @(#) s1	Demonstrate open statement Fortran-90.

# Utility functions: print-as-echo, print-line-with-visual-space, debug.
# export PATH="/usr/local/bin:/usr/bin:/bin"
pe() { for _i;do printf "%s" "$_i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }
db() { ( printf " db, ";for _i;do printf "%s" "$_i";done;printf "\n" ) >&2 ; }
db() { : ; }
C=$HOME/bin/context && [ -f $C ] && $C gfortran

# Create dummy data file.

echo "Hi" > STNS


pl " Input data file $FILE:"
cat $FILE

pl " Results:"
gfortran $FILE

exit 0

% ./s1

Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian GNU/Linux 5.0.8 (lenny) 
bash GNU bash 3.2.39
gfortran GNU Fortran (Debian 4.3.2-1.1) 4.3.2

 Input data file one.f90:
program f1

! @(#) f1	Demonstrate Fortran-90.

! open(unit=02,status='old',form='formatted',file='STNS',read only)
rewind (02)
! call input2

write(*,*) ' Hello, world from one, gfortran.'


  Hello, world from one, gfortran.

If you are going to be using Fortran, I suggest you pick up a book on current Fortran. One that I have been using lately is: Modern Fortran Explained (Numerical Mathematics and Scientific Computation) (9780199601424): Michael Metcalf, John Reid, Malcolm Cohen: Books -- not cheap, but one of the best-reviewed lately.

See also usenet group comp.lang.fortran (but probably not through Google, they seem to let all the spam come through).

Best wishes ... cheers, drl

Previous Thread | Next Thread
Test Your Knowledge in Computers #400
Difficulty: Medium
The first release for HP 9000 Series 500 HP-UX for Series 500 was HP-UX 1.0 (1982).
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem trying to compile libXres

Hello. I recently tried to build libXres from the source and I am encountering issues when trying to build from two different manners. In the first I run the configure script with ./configure --prefix=/media/34GB/Arquivos-de-Programas-Linux/... (1 Reply)
Discussion started by: colt
1 Replies

2. Programming

FORTRAN:Algortihmic Problem

Hi guys I am faced with this problem that I couldn't figure out yet, if you can point me to some direction that'll be of great help. So here's what I want to do. I have let's say 10000 files which contains same number of Z coordinates in each file. I have to find the distance of those... (6 Replies)
Discussion started by: saleheen
6 Replies

3. Programming

Problem with IF ELSEIF and GOTO statements in FORTRAN

Hi I am reading a book about Fortran 90 and I write the following code, to test my understanding of the first chapter. I have a problem with the last section of the code with deals with an IF, ELSEIF, and GOTO statements. Here is my Code PROGRAM sim ! This code is used to solve two... (3 Replies)
Discussion started by: faizlo
3 Replies

4. Debian

Program compile problem (glib pkg-config)

I need to compile a program which uses glib-2.0. I installed the package libglib2.0-0 but the configure script can't find it because the libglib package doesn't provide a .pc file which pkg-config looks for. How can I resolve this? Debian 6.0 (SPARC) (3 Replies)
Discussion started by: snorkack59
3 Replies

5. Linux

Fortran compile issue

I was given this program to work with and it was supposed to be simple for someone like me who knows nothing of Fortran or Unix. It comes with a makefile, so all I have to do is use the make command, then type ./blub to execute the program. A list of data should then appear in the fort.51 file. The... (1 Reply)
Discussion started by: Arjani
1 Replies

6. Programming

GNU GDB compile problem

I have to compile gnu-gdb 6.7 on HP-UX 11.11 with /usr/local/pa64/bin/gcc 64-bit compiler, but I'm having some problems during "make": ser-tcp.c: In function `net_open': ser-tcp.c:207: warning: passing arg 5 of `getsockopt' from incompatible pointer type make: *** Error 1 make: Leaving... (8 Replies)
Discussion started by: untamed
8 Replies

7. AIX

Compile Problem on AIX5.3

Hello, I try to compile apt-rpm on a AIX box. AIX: AIX 5300-05-03 make : 3.81 CC= VAC 8 I get the follwing error: make: Entering directory `/home/root/apt-0.5.15lorg3/apt-pkg' source='contrib/' object='contrib/cmndline.lo' libtool=yes \ DEPDIR=.deps depmode=none... (1 Reply)
Discussion started by: jbo
1 Replies

8. Programming

compile problem on aix

When compiling (a simple test program): #include <stdio.h> #include <sys/context.h> int main() { printf("Hello\n"); return 0; } on AIX 5.2 with gcc 3.2.2 from the IBM site I get the following error: /usr/include/sys/context.h:169: parse error before "sigset64_t"... (4 Replies)
Discussion started by: rein
4 Replies

9. Programming

Compile problem.

I am a newbie to unix environment and i am currently using bash. May i know how to compile a new c program. (1 Reply)
Discussion started by: alkyo
1 Replies

Featured Tech Videos