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_Group_c2f(3)						      LAM/MPI							  MPI_Group_c2f(3)

NAME
MPI_Group_c2f - Convert a group handle from its C representation to its Fortran representation SYNOPSIS
#include <mpi.h> MPI_Fint MPI_Group_c2f(MPI_Group group) INPUT PARAMETER
group - C group handle RETURN VALUE
f_handle - Fortran group handle NOTES FOR FORTRAN
All MPI routines in Fortran (except for MPI_WTIME and MPI_WTICK ) have an additional argument ierr at the end of the argument list. ierr is an integer and has the same meaning as the return value of the routine in C. In Fortran, MPI routines are subroutines, and are invoked with the call statement. All MPI objects (e.g., MPI_Datatype , MPI_Comm ) are of type INTEGER in Fortran. ERRORS
This function does not return the normal MPI_SUCCESS integer value upon success. Instead, it returns a handle to the converted object. If an error occurs, the appropriate NULL handle will be returned. SEE ALSO
MPI_Group_c2f(3) MORE INFORMATION
For more information, please see the official MPI Forum web site, which contains the text of both the MPI-1 and MPI-2 standards. These documents contain detailed information about each MPI function (most of which is not duplicated in these man pages). http://www.mpi-forum.org/ LOCATION
handles.c LAM
/MPI 6.5.8 11/10/2002 MPI_Group_c2f(3)
All times are GMT -4. The time now is 01:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy