Questions tagged [gfortran]

gfortran is the GNU Fortran compiler, part of GCC. It implements the Fortran 95 standard and much of the Fortran 2008 standard. This tag should be used for questions relating to the use and behaviour of gfortran specifically; questions about the Fortran language or compilers more widely should include the Fortran tag.

gfortran
Filter by
Sorted by
Tagged with
0 votes
0 answers
23 views

Gcc not linking to objects in same static library

I am using gfortran (in the form of mpif90) to link a large mpi program. It all seems to be fine except for one library libgptl.a. The link step generates a number of errors but all of the form: ...
0 votes
0 answers
72 views

How do I place my function to the 3rd column of a matrix in Fortran?

I am a newbie at Fortran so I need your help with something. I am trying to see the result of the function in column 3 but can't compile whatever I did. I am receiving an error: 48 | datatable(...
0 votes
0 answers
62 views

Issues Compiling Double Precision fortran programs on Apple M2

I'm trying to load and compile several of Mark Drela's programs (Xfoil, AVL) on my new M2 macbook pro. I've compiled these before on intelx86 but I'm running into several very curious issues on apple ...
0 votes
2 answers
630 views

gfortran 12.2.0 not working on M1 Macbook Air with MacOS Ventura 13.1-arm64

gfortran does not work on my M1 Macbook Air with MacOS Ventura 13.1-arm64 When I try to compile any program, e.g. program main print *, "Hello world." end program main I get the following ...
0 votes
0 answers
51 views

Unable to include a module in a fortran program

I am trying to compile with a fortran program that uses another module. For some reason when I try to compile it I keep getting the error: testinc.f95:5:17: 5 | type(linreg) :: lr | ...
3 votes
0 answers
79 views

Program stalls when printing from a function called in a print statement [duplicate]

The following MCVE compiles and works just fine for me on Linux with all the versions of GCC I tried. program temp implicit none print *, hello_message() contains function hello_message() ...
-1 votes
1 answer
676 views

Gfortran type mismatch error despite "-fallow-argument-mismatch" flag

Gfortran 10 added the default behavior to make type mismatches an error instead of a warning. The flag -fallow-argument-mismatch can be used to degrade the errors to warnings. However, within the same ...
4 votes
6 answers
22k views

Removing whitespace in string

I have the following code: program main character (len=15) :: abc = "te st tex t" print *, trim(abc) end program main Which outputs: te st tex t I excepted all the ...
11 votes
1 answer
2k views

Do most compilers optimize MATMUL(TRANSPOSE(A),B)?

In a Fortran program, I need to compute several expressions like M · v, MT · v, MT · M, M · MT, etc ... Here, M and v are 2D and 1D arrays of small size (less than 100, ...
6 votes
2 answers
1k views

Fortran: Is there a way to conditionally use modules?

Assume I have two Fortran modules called modA and modB. Is there a way to use one or the other in a program based on a conditional statement? Does this require some type of preprocessing? For example, ...
1 vote
2 answers
679 views

gfortran: all terminall output goes to fort.6 instead of terminal

I have a program which contains some output to terminal like this: write(*,*) 'Progress...' When I run it from command line or by double click (I use windows) all terminal output goes to fort.6 file. ...
0 votes
2 answers
129 views

Fortran not writing to output file or printing to screen

I wrote this simple Fortran code with the intention of the answer being written to an output file. Instead, the output file is blank, and even when I attempt to print to the screen, it doesn't do that ...
0 votes
0 answers
40 views

Using an allocatable string coarray in Fortran

I'm writing some code using Fortran CoArrays (using caf and cafrun from OpenCoarrays) that requires having a coarray string of allocatable length. It can be exemplified by this code: program ...
0 votes
1 answer
134 views

Fortran 77 DO label also used by IF/GOTO

I have an old fortran 77 code, which I like to keep unchanged as much as possible. Since gfortran gives the loop warnings, I was thinking of changing the non-block loops to block mode. But then I ...
0 votes
0 answers
81 views

How to ensure same precision from gfortran and ifort compiler? For complex functions, to be specific [duplicate]

I am using the following code (filename cf.f90) to write values of some complex functions in output file. I am getting different outputs from gfortran and ifort compiler (I use gfortran -O3 -o cf.exe ...
46 votes
12 answers
41k views

Building R package and error "ld: cannot find -lgfortran"

I'm trying to install the package lars. Ubuntu 11.04 Natty 64-bit. From building I get: * installing *source* package âlarsâ ... ** libs gfortran -fpic -O3 -pipe -g -c delcol.f -o delcol.o gcc -...
-4 votes
1 answer
981 views

gfortran REAL not accurate to 8 decimal places [duplicate]

This question has not been previously answered. I am trying to represent a real or any number for that matter in Fortran correctly. What gfortran is doing for me is way off. For example when I declare ...
2 votes
1 answer
130 views

How does gfortran with optimization flags interpret nested implied do loops?

I have an issue with gfortran that I am trying to understand on a general level to avoid encountering it again in the future. Specifically, I am trying to understand the behavior of nested implied do ...
0 votes
0 answers
88 views

R package installation error (dbarts compiling error)

when I installed the dbarts package from the source, the compiling process reported some error information, as below. Please help me with this issue. thank you in advance > remotes::install_github(&...
47 votes
2 answers
44k views

What flags to set for GFORTRAN compiler to catch faulty code?

I think I won't find that in any textbook, because answering this takes experience. I am currently in the stage of testing/validating my code / hunting bugs to get it into production state and any ...
0 votes
1 answer
258 views

GFortran not found from make in Eclipse

I am trying to set up GFortran in Eclipse. I am using macOS. I installed GFortran and GCC. When I click "build project" in Eclipse I get this error: 10:19:28 **** Build of configuration ...
0 votes
0 answers
70 views

How to make a Makefile to run gfortran file calling Intel MKL

I am trying to solve a large sparse matrix system using the PARDISO subroutine in Intel MKL. I completed writing a code in gfortran and makefile. But when I execute the makefile, the error message ...
0 votes
1 answer
116 views

Fortran arrays seems to be accessed outside of WHERE conditions in the case of debug compilation

I'm considering a quite complex fortran code with many interconnected modules, etc .. So I'll do my best to document only a very specific part of it. The code goes fine when compiled in 'normal' ...
0 votes
1 answer
149 views

Why do I get a segmentation fault problem in this program when the matrix dimension is too large (in ifort)?

I'm making basic linear algebra computations with matrices and vectors in Fortran. I have changed compiler from gfortran to ifort and I've found that when my matrices get too large (specifically when ...
1 vote
0 answers
4k views

How to install netcdf-fortran on Ubuntu

I am using a Fortran software which needs for compilation gfortran and netcdf-fortran. As working environment I have WSL with Ubuntu 20.04.4 on Windows 10 and gfortran 9.4.0. After some search I found ...
0 votes
1 answer
134 views

"undefined reference to `dgesvx_'" although LAPACK is installed and located

I'm trying to run a fortran script that includes the function dgesvx(). I ran the script as gfortran -lblas -llapack -o cft numtype.o cfapprox.o cftest.o and the output is gfortran -lblas -llapack -o ...
0 votes
2 answers
1k views

Trying to add a Fortran compiler for Matlab

I have a file with the extension .F, which I want to compile to use with my Matlab code. To do that I`m trying to use mex tool. "mex -setup FORTRAN -v" returns. mex -setup FORTRAN -v ...
0 votes
0 answers
226 views

While running some test code in Fortran, I received an error "f951: Fatal Error: Cannot open file 'hello.f90' compilation terminated

I am new to Fortran and I am trying to execute some test code, printing hello world using the following program - program hello implicit none print *, 'Hello, World!' end program hello I ...
1 vote
0 answers
50 views

How to make fortran subroutine results reproducible on R?

I have written a Fortran subroutine: And I want to implement it on R, so I will do the compile and everything, but I have a question because my fortran subroutine which contains the random number ...
1 vote
1 answer
4k views

Installing gfortran using MSYS2

As a complete beginner, I am struggling to install gfortran using MSYS2. My end-goal is to compile multiple '.for' files and create an executable. As a first try, I am trying to create an executable ...
0 votes
0 answers
89 views

Fortran code to solve a 2D heat bar problem

Before I use MPI_Type_vector, I simply use transpose to transpose the T_l. The code can mpirun successfully. However, after I use your provided code of MPI_Type_vector, the code cannot mpirun ...
0 votes
2 answers
2k views

Cannot use HDF5 because it was created by a different version of GNU Fortran

I'm quite new to both HDF5 as well as Fortran 90. I am trying to compile a program which runs fine without HDF5. I found online that I need to use flags from the command h5fc -show, and the output is ...
16 votes
7 answers
24k views

Installing gfortran on MacBook with Apple M1 chip for use in R

I'm on a MacBook Air with an Apple M1 chip, using macOS 11.6 Big Sur. I'm on R 4.1.1. I have Xtools and gfortran for the Apple M1 installed: markwhite@marks-air ~ % which xcode-select /usr/bin/xcode-...
0 votes
0 answers
93 views

Open netcdf with gfortran in Mac environment, Undefined symbols for architecture arm64 occurs

I'm a Mac user I'm trying to create a netcdf using gfortran, but I get the following error My Mac is using an M1 chip Below is the Fortran code I made PROGRAM net2 use netcdf ...
1 vote
0 answers
62 views

gfortran error ‘variable_1’ causes a section type conflict with ‘variable_2’

I'm trying to solve the possible problem of stack size being too small for an openmp fortran program with the compiler option -mcmodel=medium and error occurs while compiling: Error: ‘profs’ causes a ...
4 votes
3 answers
17k views

"Cannot assign to named constant" (reassigning a variable)

I'm using a flag f for some error checking. Fortran (or maybe gfortran) won't let me reassign its value when I want to perform another check. integer, dimension(:,:), allocatable :: A integer :: f, n ...
0 votes
0 answers
121 views

An undefined reference to error occurs when running Fortran

I'm trying to use netCDF using Fortran, but I keep getting the following error. PROGRAM net1 use netcdf IMPLICIT NONE CHARACTER(len = 256) :: fi REAL, ALLOCATABLE :: ...
0 votes
0 answers
91 views

Linker errors with BLAS/LAPACK symbols (snrm2_, sdot_, etc) when building Fortran project with gfortran on Windows

I'm trying to build the Elmer finite element software (version 9.0) using gfortran 10.2.0 and OpenBLAS 0.3.15 libraries on Windows 10. I'm running into linker errors when creating the shared libraries,...
0 votes
0 answers
105 views

exceeds dimension bound Error reading netcdf with fortran

I am a user who uses Fortran. I try to get the average value after reading netCDF using Fortran, but I get an error PROGRAM net1 use netcdf IMPLICIT NONE CHARACTER(len = 256) ...
-1 votes
1 answer
3k views

R package 'gfortran' is not available (for R version 3.3.1)

I'm trying to install the package 'gfortran' (because the package 'deSolve' demands it to be insatlled) but get the error: install.packages("gfortran") Warning in install.packages : ...
0 votes
0 answers
44 views

Fortran77 Procedure <> called with an implicit interface [-Werror=implicit-interface] [duplicate]

In my fortran77 project, I call the subroutine BDET in the subroutine MATS. However the get the following error: Procedure <BDET> called with an implicit interface [-Werror=implicit-interface] ...
1 vote
2 answers
117 views

How to rewrite iand to conform with newer versions of gfortran

I am working with an older Fortran code and during compilation I get many different error messages, some of the of the following format: if(iand(n_jz2_max,1).eq.0) then 1 Error:...
1 vote
1 answer
139 views

Ifort gives segfault in OpenMP parallelized code when passing internal procedure as argument, but not gfortran

I have made a minimal example of my more complex Fortran code where I get segmentation fault when compiling and running with the Intel Fortran compiler ifort and not with the GNU compiler gfortran. If ...
0 votes
1 answer
540 views

cmake fortran compiler: CMAKE_FC_COMPILER or CMAKE_FORTRAN_COMPILER

I need to set a path to fortan compiler in cmake, like set(CMAKE_FC_COMPILER /bin/aarch64-none-linux-gnu-gfortran) set(CMAKE_Fortran_COMPILER /bin/aarch64-none-linux-gnu-gfortran) cmake ...
1 vote
0 answers
87 views

Different logarithm value in debug and optimized mode, with gfortran

I found today that the intrinsic log function in Fortran yields different values when the code is compiled with/without optimization. See this example: program test_log implicit none real(...
4 votes
2 answers
3k views

gfortran-9 installed, but getting "no Fortran compiler found" error (Ubuntu Server 18.04)

I've just installed gfortran-9 on Ubuntu Server 18.04 as follows: sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt update sudo apt install gfortran-9 I've been able to confirm that ...
0 votes
1 answer
253 views

Gfortran: Large Arrays do not work on M1 Mac

My Fortran code is not working on my M1 Mac (Ventura 13.5) anymore. Here is a simple example. program mwe implicit none integer, parameter :: nx=500 integer, parameter :: ny=500 ...
0 votes
1 answer
123 views

OpenMP not found using MinGW / gfortran on Windows 10

I'm using GNU Fortran 9.2.0 with all latest updates and upgrades on Windows 10. I would like to compile a code that uses OpenMP. Trying gcc -v, I see --enable-libgomp. Trying to compile the code with ...
0 votes
1 answer
93 views

how to read a csv file from fortran if the data is different for each colum

I am trying to rea csv file in fortran, but failed. I have this data in my csv file 0,2013/02/20,24.448 1,2013/02/20,24.448 2,2013/02/20,24.545 3,2013/02/20,24.448 4,2013/02/20,24.351 5,2013/02/20,24....
0 votes
0 answers
76 views

How to get eclipse to build .F files?

I have preexisting fortran source code that builds without error in visual studio with ifort (or OneAPI) that consists of multiple ".F" files and a main program. Trying to get this to build ...

1
2
3 4 5
55