gfortran

GFortran I/O error 5002 while reading a direct access file

为君一笑 提交于 2019-12-11 13:08:23
问题 I have a little Problem reading a file in Fortran. As you can see I am lopping over a file reading certain records with a specific length. What happens is, when it comes to a certain record I'm getting an IOSTAT Error 5002. Now my question is what does this error mean: is it end of file or there is no record left or something else? Can I ignore it? I am using MinGW GFortran 4.8.0. Here's the code: PROGRAM test_read INTEGER*4 HCM_error DOUBLE PRECISION N_Record(22) CHARACTER*8 C_Record(22)

Fortran 77 debugger to check array bounds

◇◆丶佛笑我妖孽 提交于 2019-12-11 12:48:46
问题 I am still green to debugging F77 and am having some problems with array bounds. I recently modified a lengthy code to have new array sizes. Everything 'seemed' okay until I noticed methods to alter one array, altered another. Somewhere in this code, I assume, an assignment is out of bounds and writing to the other arrays. Is there a debugger/tool in the linux environment that will 'catch' the out of bounds exception? I am currently using gfortran 回答1: There is a flag for gfortran to insert

Allocatable arrays in fortran 77 and gfortran

帅比萌擦擦* 提交于 2019-12-11 12:27:24
问题 I'm trying to compile some old fortran77 programs with gfortran and getting error with allocatable arrays. If I define arrays in f90-style, like: REAL*8,allocatable::somearray(:) everything is fine, but in those old programs arrays defined as: REAL*8 somearray[ALLOCATABLE](:) which cause gfortran error output: REAL*8,allocatable::somearray[ALLOCATABLE](:) 1 Fatal Error: Coarrays disabled at (1), use -fcoarray= to enable I really wish to avoid rewriting whole programs to f90 style, so, could

Write C function that returns int to Fortran

亡梦爱人 提交于 2019-12-11 12:15:01
问题 Ultimately I am trying to write an IPC calculator making use of Fortran to calculate and C to pass the data between the two Fortran programs. When I am done it will hopefully look like: Fortran program to pass input -> Client written in C -> Server written in C -> Fortran program to calculate input and pass ans back The C client/server part is done, but at the moment I am stuck trying to write a program that takes input in a Fortran program, passes it to a C program that calculates the answer

Compiling with clang and gfortran

☆樱花仙子☆ 提交于 2019-12-11 12:07:16
问题 I'm trying to compile a project I recently started working on, and was asked to compile the code in clang instead of gcc. There is a CMake file for the project, and I tried to cmake the project using cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ../src However an error is thrown, which I believe is because clang doesn't have a Fortran compiler and part of the project has Fortran code. Is there a way to make it use gfortran (previously used when gcc is used) when compiling the

How to pass subroutine names as arguments in Fortran classes

☆樱花仙子☆ 提交于 2019-12-11 11:53:46
问题 In How to pass subroutine names as arguments in Fortran? we learned how to pass subroutine names as arguments in Fortran. How can we do this inside a class structure? The ensuing code produces the following compilation error using GNU Fortran (GCC) 5.1.0: gfortran -Wall -Wextra -Wconversion -Og -pedantic -fcheck=bounds -fmax-errors=5 class_pass.f08 myClass.f08:44:30: class ( test ), target :: me 1 Error: Derived type ‘test’ at (1) is being used before it is defined myClass.f08:9:21: procedure

Undefined reference to Fortran function in C++

試著忘記壹切 提交于 2019-12-11 11:34:23
问题 I can't seem to figure out why this isn't working. /* main.cpp */ #include <stdio.h> extern "C" { int __stdcall inhalf(int *); } int main() { int toHalf = 2; int halved = inhalf(&toHalf); printf("Half of 2 is %d", halved); return 0; } Ok, that looks good. $ g++ -c main.cpp No errors. ! functions.f90 function inhalf(i) result(j) integer, intent(in) :: i integer :: j j = i/2 end function inhalf I'm pretty sure that's right. $ gfortran -c functions.f90 So far so good... $ gcc -o testo main.o

Export COMMON block from DLL with gfortran

旧巷老猫 提交于 2019-12-11 11:34:13
问题 I am having trouble correctly accessing a variable in a Fortran DLL from a Fortran EXE when the variable is part of a COMMON block. I have a trivial code simple.f90 which I compile into a DLL using MSYS64/MinGW-w64 gfortran 9.2 as x86_64-w64-mingw32-gfortran simple.f90 -o simple.dll -shared ! simple.f90 module m implicit none integer :: a, b !common /numbers/ a, b end module subroutine init_vals use m implicit none a = 1 b = 2 end subroutine This library is used from a even simpler program

Fortran compiler broken

☆樱花仙子☆ 提交于 2019-12-11 11:24:25
问题 I recently updated my operating system from OS X 10.8 to OS X 10.9. Most of the applications still worked after the update, but one of the applications that did not work was g95 (my fortran compiler I use for class). I thought I was compiling faulty code until I tried compiling it on another machine. It seems as though the linker ld is missing a library that was not carried over in the update. The full error is produced on every compile time (as long as there are no syntax errors) ld: library

How can I use dlmopen in Fortran?

蓝咒 提交于 2019-12-11 09:09:22
问题 I want to load the same .so file twice as separate instances. Based on the example, I have created the app with two dlopen commands. However, I was facing some issues and I understood that dlmopen should be used if I am using multiple instances of a same .so . However, I don't know how to pass the arguments. Can someone help me how to do this in GFortran? My code is as below, program example use :: iso_c_binding implicit none integer(c_int), parameter :: rtld_lazy=1 ! value extracte from the