fortran77

Reading REAL's from file in FORTRAN 77 - odd results

五迷三道 提交于 2019-12-11 08:17:21
问题 I'm currently messing around in FORTRAN 77 and I've ran into a problem that I can't seem to figure out. I'm trying to read from a file that looks similar to below: 000120 Description(s) here 18 7 10.15 000176 Description(s) here 65 20 56.95 ... The last column in each row is a monetary amount (never greater than 100). I am trying to read the file by using code similar to below integer pid, qty, min_qty real price character*40 descrip open(unit=2, file='inventory.dat', status='old') read(2,

FORTRAN block data seems to not be working

南笙酒味 提交于 2019-12-11 06:36:34
问题 I am working on some legacy code that relies heavily on common blocks which are initialized with BLOCK DATA similar to the code below. BLOCK DATA filename PARAMETER (size=100) CHARACTER*8 somearray(size) COMMON /block1/ somearray DATA(somearray(i), i=100)/ *'string1', 'string2', ... , 'string100'/ END At some point in the program a subroutine uses this common block as shown in the code below. SUBROUTINE SUB(array) IMPLICIT DOUBLE PRECISION (A-H,O-Z) CHARACTER*8 array(*), somearray(100) COMMON

Rounding of double precision to single precision: Forcing an upper bound

泪湿孤枕 提交于 2019-12-11 04:22:29
问题 I'm using a Mersenne Twister implementation which provides me numbers with double precision. http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/FORTRAN/fortran.html (implementation in Fortran 77 by Tsuyoshi Tada, I'm using genrand_real2) However, my application needs, in order to avoid warnings while multiplying numbers with different precisions, a single precision random number. So, I wrote a small function to convert between the two data types: function genrand_real() real genrand

What is the intent of this Fortran 77 code?

白昼怎懂夜的黑 提交于 2019-12-11 04:20:47
问题 I'm trying to Pythonize a FORTRAN77 code. There's a block of code that I just can't seem to grasp the intent of. ZM is just a scalar between 0 and 1. Z is a 1D array of numbers between 0 and 1 with NJ elements. J, J1, and J1M are type INTEGER. PDFZ is another 1D array with NJ elements. I'm having trouble mapping out the flow of execution. DO 18 J=2,NJ IF(ZM.GT.Z(J)) GOTO 18 J1=J J1M=J-1 GOTO 20 18 CONTINUE 20 CONTINUE DO 22 J=1,NJ PDFZ(J)=0.D0 22 CONTINUE PDFZ(J1)=(ZM-Z(J1M))/(Z(J1)-Z(J1M))

Whats wrong with the following FORTRAN 77 code?

流过昼夜 提交于 2019-12-11 01:08:47
问题 I am a total FORTRAN 77 newbie, and I don't understand why the first code shows an error while the second one compiles when I expect them to do the same. First code (which doesn't compile and gives a error citing an unexpected data declaration statement at z): program FOO integer x, y x = 1 y = 2 integer z z = 3 end This code which looks 100% similar in functionality to the first one compiles without errors program FOO integer x, y, z x = 1 y = 2 z = 3 end I also tried disabling implicit

Syntax for openmp long directive list fortran77

随声附和 提交于 2019-12-10 22:58:34
问题 PROBLEM : Long list of directives openmp fortran77 c$omp parallel default(shared) private(i,k,i1,i2,i3,i4,i5, $ i6,x0,y0,z0,vnx0,vny0,vnz0,qs0) c$omp do Task to be performed c$omp end do c$omp end parallel I'm trying to compile the above program using ifort and it works fine. I have checked with the serial version and I get the same result ifort -openmp -parallel -o ./solve But when I try to compile using gfortran it doesn't work. gfortran -fopenmp I get the following error quinckedrop.f:2341

Upper bound of random number generator

自古美人都是妖i 提交于 2019-12-10 21:34:11
问题 This is actually a follow up question of a previous one: Rounding of double precision to single precision: Forcing an upper bound After what I thought was the solution of my problems with the answer of previous question, I tried running my program again and found that I had the same problem. The Mersenne Twister implementation I'm using generates a signed 32 bits random integer. The guy who implemented the RNG made this function to generate a random double precision float in the range [0,1):

“d” label in the first column, Fortran 77

余生颓废 提交于 2019-12-10 17:13:44
问题 I am modifying a code from a model written in Fortran 77, but I have come across an odd thing to me. In some files, there is a label "d" in the first column of a line, like the example below: d real*8 co2rootfix,co2rootloss,co2shootfix d character komma*1 d open(unit=87,file='crop_CO2.csv',status='unknown') d write(87,*) 'date,co2rootfix,co2rootloss,co2shootfix' d open(unit=88,file='crop_dm.csv',status='unknown') d write(88,*) 'date,wrtpot,wrt,wstpot,wst,rdpot,rd,laipot,lai, d &gwrt,gwst,drrt

Fortran 77 common blocks in multithreading C++ application

廉价感情. 提交于 2019-12-10 10:34: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

Opening Binary Files in Fortran: Status, Form, Access

我只是一个虾纸丫 提交于 2019-12-10 04:04:19
问题 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