fortran77

Dynamic memory allocation in fortran77

匆匆过客 提交于 2019-12-08 05:34:09
问题 I am writing a Fortran77 program which uses a 3-dimensional array. I am declaring the array as follows Array_E(0:500,0:1000,0:100). When I execute the program it crashes instantly saying that it is "killed". When I ran strace, what I got was, execve("./yee", ["./yee"], [/* 65 vars */] +++ killed by SIGKILL +++ I suspect the problem is that the g77 compiler is not able to allocate memory for the array. In fact there are nine such arrays. In such a case is there a way to dynamically allocate

How to pass single dimension array from fortran to c [duplicate]

ぐ巨炮叔叔 提交于 2019-12-08 00:51:24
问题 This question already has answers here : Unable to pass array from FORTRAN to C (2 answers) Closed 5 years ago . I am passing a single dimension array to function from Fortran program to a C. The function get called but the values it gets are garbage. Here is my code File: abc.f program test real*4 :: a(4) data a / 1,2,3,4 / call test_func(a) end program testFile: File: abc.c int test_func(double a[]) { int i; for(i=0;i<4;i++) { printf("%f\n",a[i]); } return 0; } But if i pass integer instead

How to use Fortran statement labels well?

一个人想着一个人 提交于 2019-12-07 02:54:56
问题 I'm working on a model written in Fortran 95, which I am completely new to. The concept of statement labels seems strange, and I've so far only found the explanation that the labels can be arbitrarily decided by the author, usually incrementing by 10's. Are there any practical uses of these labels, other than picking out more easily where a statement is ending? AND a generally accepted standard on how to label. 回答1: The only way I can think of statement labels being useful in modern Fortran

Reading a string with spaces in Fortran

雨燕双飞 提交于 2019-12-06 19:19:21
问题 Using read(asterisk, asterisk) in Fortran doesn't seem to work if the string to be read from the user contains spaces. Consider the following code: character(Len = 1000) :: input = ' ' read(*,*) input If the user enters the string "Hello, my name is John Doe", only "Hello," will be stored in input; everything after the space is disregarded. My assumption is that the compiler assumes that "Hello," is the first argument, and that "my" is the second, so to capture the other words, we'd have to

Where can I get the files to install f2c on redhat linux?

夙愿已清 提交于 2019-12-06 15:51:57
问题 I am looking for an rpm or simple install instructions for getting f2c to work on my redhat linux os. I am new to linux and it is difficult finding something like this on google. (The goal is to use f2c to convert a simple fortran77 file to c, then compile) Does anybody have any suggestions? 回答1: Getting the source with rsync (recommended): $ rsync -avz netlib.org::netlib/f2c/src f2c Getting the sources via FTP: $ mkdir -p f2c/src $ cd f2c/src $ ftp ftp.netlib.org ftp> cd f2c ftp> prompt ftp>

Dynamic memory allocation in fortran77

二次信任 提交于 2019-12-06 15:21:29
I am writing a Fortran77 program which uses a 3-dimensional array. I am declaring the array as follows Array_E(0:500,0:1000,0:100). When I execute the program it crashes instantly saying that it is "killed". When I ran strace, what I got was, execve("./yee", ["./yee"], [/* 65 vars */] +++ killed by SIGKILL +++ I suspect the problem is that the g77 compiler is not able to allocate memory for the array. In fact there are nine such arrays. In such a case is there a way to dynamically allocate memory on the stack in f77? If this is not the reason for the crash, kindly let me know if you have any

Identify version of Fortran of this code for the LF compiler

南楼画角 提交于 2019-12-06 09:25:03
I'm new to Fortran. I was given a file that is supposed to be in Fortran 90, but written to be compiled with the Lahey Fujitsu compiler (the sparse documentation states that it should be compiled with lf95 filename.f -out compiled_name @imsllf95.cmd ). However, some lines are commented with c , which as I understand was the way to comment in Fortran 77. Also, matrices are declared like REAL*8, DIMENSION(23,8) :: xxx19 , which again I think is from Fortran 77. For the most part, I can compile the file with gfortran or ifort except for a section that requires the computation of a matrix inverse.

Fortran 77 common blocks in multithreading C++ application

这一生的挚爱 提交于 2019-12-06 07:50:13
I develop one C++ program which calls a Fortran 77 routine. The main C++ program may run multithreaded. However, it happens that the Fortran 77 routine hides several common blocks which are modified on each call depending on its arguments. I am afraid that all common blocks may be shared between multiple threads and that concurrent accesses to these blocks will probably mess everything. First question : Am I right? Would common blocks be shared between multiple threads? Second question : Is there a simple way to avoid it? Rewriting the Fortran routines seems unaffordable, I am rather looking

FORTRAN WRITE()

[亡魂溺海] 提交于 2019-12-05 08:29:15
Before I begin, I must preface by stating that I am a novice when it comes to FORTRAN. I am maintaining a legacy piece of code from 1978. It's purpose is to read in some data values from a file, process the values, and then output the processed values to another text file. Given the following FORTRAN code: INTEGER NM,STUBS,I,J,K PARAMETER (NM=67,STUBS=43) INTEGER*4 MDS(STUBS,NM) CALL OPEN$A(A$RDWR,'/home/test/data.txt', MAXPATHLEN,1) CALL OPEN$A(A$WRIT,'out',11,2) DO 90 I=1,2 READ(1,82) STUB !-- data processing --! WRITE(2,80) STUB,(MDS(I,J),J=1,24) 90 CONTINUE 80 FORMAT(/1X,A24,25I5) 82

Opening Binary Files in Fortran: Status, Form, Access

ぃ、小莉子 提交于 2019-12-05 05:17:34
I have been working with Fortran for years, but the file I/O is still hazy to me. My understanding of status , form , access , recl is limited, because I only needed certain use-cases in grad school. I know that Fortran binary files have extra information at the top of the file that describe the size of the file. But that has never been an issue for me before because I have only had to deal with Fortran files in Fortran code, where the extra information is necessary, but invisible. But how do I open a flat, binary file in Fortran? In the past, I might open a Fortran binary using Fortran by