Sponsored Content
Full Discussion: Fortran compile problem
Operating Systems Linux Fortran compile problem Post 302637753 by drl on Wednesday 9th of May 2012 09:17:35 AM
Old 05-09-2012
Hi.

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

The error message that I get is:
Code:
open(unit=02,status='old',form='formatted',file='STNS',read only)
                                                      1
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:
Code:
#!/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

FILE=${1-one.f90}

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

pl " Results:"
gfortran $FILE
./a.out

exit 0

producing:
Code:
% ./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)
open(unit=02,status='old',form='formatted',file='STNS',action='read')
rewind (02)
! call input2
close(02)

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

end

-----
 Results:
  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: Amazon.com: 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
 

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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/cmndline.cc' object='contrib/cmndline.lo' libtool=yes \ DEPDIR=.deps depmode=none... (1 Reply)
Discussion started by: jbo
1 Replies

4. 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

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. 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

7. 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

8. 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

9. 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
MPI_Status_f2c(3OpenMPI)												  MPI_Status_f2c(3OpenMPI)

NAME
MPI_Status_f2c, MPI_Status_c2f - Translates a C status into a Fortran status, or vice versa. SYNTAX
C Syntax #include <mpi.h> int MPI_Status_f2c(MPI_Fint *f_status, MPI_Status *c_status) int MPI_Status_c2f(MPI_Status *c_status, MPI_Fint *f_status) DESCRIPTION
These two procedures are provided in C to convert from a Fortran status (which is an array of integers) to a C status (which is a struc- ture), and vice versa. The conversion occurs on all the information in status, including that which is hidden. That is, no status informa- tion is lost in the conversion. When using MPI_Status_f2c, if f_status is a valid Fortran status, but not the Fortran value of MPI_STATUS_IGNORE or MPI_STATUSES_IGNORE, then MPI_Status_f2c returns in c_status a valid C status with the same content. If f_status is the Fortran value of MPI_STATUS_IGNORE or MPI_STATUSES_IGNORE, or if f_status is not a valid Fortran status, then the call is erroneous. When using MPI_Status_c2f, the opposite conversion is applied. If c_status is MPI_STATUS_IGNORE or MPI_STATUSES_IGNORE, or if c_status is not a valid C status, then the call is erroneous. The C status has the same source, tag and error code values as the Fortran status, and returns the same answers when queried for count, elements, and cancellation. The conversion function may be called with a Fortran status argument that has an undefined error field, in which case the value of the error field in the C status argument is undefined. Open MPI 1.2 September 2006 MPI_Status_f2c(3OpenMPI)
All times are GMT -4. The time now is 01:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy