gfortran

gfortran for dummies: What does mcmodel=medium do exactly?

孤人 提交于 2019-12-17 06:39:07
问题 I have some code that is giving me relocation errors when compiling, below is an example which illustrates the problem: program main common/baz/a,b,c real a,b,c b = 0.0 call foo() print*, b end subroutine foo() common/baz/a,b,c real a,b,c integer, parameter :: nx = 450 integer, parameter :: ny = 144 integer, parameter :: nz = 144 integer, parameter :: nf = 23*3 real :: bar(nf,nx*ny*nz) !real, allocatable,dimension(:,:) :: bar !allocate(bar(nf,nx*ny*nz)) bar = 1.0 b = bar(12,32*138*42) return

Use Fortran subroutine in R? Error: Return type mismatch

删除回忆录丶 提交于 2019-12-16 18:03:34
问题 I'm trying to learn how to use fortran code inside R. I was able to follow this tutorial. Now, I'm trying to use that as a base plus this fortran program to calculate pi. I create a file Fpi.f90 with this code: subroutine pi(avepi, DARTS, ROUNDS) double precision, intent(out) :: avepi integer, intent(in) :: DARTS, ROUNDS integer :: MASTER, rank, i, n integer, allocatable :: seed(:) double precision :: pi_est, homepi, pirecv, pisum ! we set it to zero in the sequential run rank = 0 !

gfortran linking flag for openmp

限于喜欢 提交于 2019-12-14 03:53:38
问题 I'm trying to link multiple .o files using gfortran . I've compiled the files like so (in a makefile): gfortran -c -fopenmp file1.f gfortran -c -fopenmp file2.f Now I'd like to link the files with an option for OpenMP. I know with the Intel compiler the linking flag is -liomp5 , so to link the files with the Intel compiler one would call: ifort -o a.out file1.o file2.o -liomp5 This is obviously not the correct flag for the GNU compiler. What is the correct OpenMP linking flag for gfortran ?

Segfault when allocating large array in Fortran

我是研究僧i 提交于 2019-12-14 03:13:54
问题 I have a very simple example of a strange segfault I am having and it is as follows: program big_array_segfault integer :: nX = 13000 integer :: nY = 100000 real(kind = 8), allocatable :: bigarr(:,:) allocate(bigarr(nX, nY)) end program big_array_segfault Note that I have 20 GB of RAM to work with and this does not even begin to approach that. Everything I have seen online suggests that this may be a problem with Stack space vs Heap space but I don't know how to control the memory in that way

Python module with Fortran: LNK1112 `module machine type 'X86' conflicts with target machine type 'x64'`

雨燕双飞 提交于 2019-12-14 02:26:03
问题 So lately I've been learning an absolute stack about how programming and compiling and stuff works, but this is a little out of my depth. Currently, I'm trying to install pyigrf12 so that I have some way of using the IGRF in Python (where I do most of my work). My first issue was, because this model was developed in Fortran, finding a suitable compiler. I used MinGW to install both g77 and gfortran among other things. Each compiler gives me different errors. When setup.py defaulted to using

Implicit conversion integer <--> logical in Fortran if statement

半世苍凉 提交于 2019-12-14 02:09:20
问题 I have some legacy Fortran code which I was asked to analyze and translate to a modern language. I don't know which compiler was used in the past to compile the code, so for now, I'm trying to compile it with gfortran. The code contains a statement like this was causes gfortran to complain: program test implicit none integer*4 :: var var=.true. if(var) then write(*,*) "Hi" endif end program test Compiling this with gfortran gives the following error: test.f:6:9: if(var) then 1 Error: IF

How to implement factorial function into code?

笑着哭i 提交于 2019-12-14 02:05:49
问题 So I am using the taylor series to calculate sin(0.75) in fortran 90 up until a certain point, so I need to run it in a do while loop (until my condition is met). This means I will need to use a factorial, here's my code: program taylor implicit none real :: x = 0.75 real :: y integer :: i = 3 do while (abs(y - sin(0.75)) > 10.00**(-7)) i = i + 2 y = x - ((x**i)/fact(i)) print *, y end do end program taylor Where i've written fact(i) is where i'll need the factorial. Unfortunately, Fortran

Reading an image into an array?

▼魔方 西西 提交于 2019-12-13 20:11:41
问题 I'm attempting to write a program that utilizes the sobel filter to detect edges in images. So first off, I've written down some of the requirements in some basic code, such as the x and y direction filters as arrays and also an attempt to read in a pgm image: program edges implicit none integer, dimension(:,:), allocatable :: inp, outim, GX, GY integer, parameter :: dp = selected_real_kind(15,300) integer :: ky, kx, x, y, out_unit = 10, M, N, sx, sy, i, j real(kind=dp) :: G M = 5 N = 5

Shared library linked with static library: relocation error

梦想的初衷 提交于 2019-12-13 17:08:35
问题 I would like to create a shared library with gfortran, linking it with the static version of libgfortran for portability reasons. Unfortunately, I don't manage to link the different objects appropriately. I have already found some posts addressing a similar issue, but I could not figure out how to fix the problem. My source files are all compiled with the -fPIC flag. When I try to link the objects with the flags -shared and -static-libgfortran , I get the following error message: gfortran

Serial program runs slower with multiple instances or in parallel

天大地大妈咪最大 提交于 2019-12-13 16:22:56
问题 I have a fortran code that I am using to calculate some quantities related to the work that I do. The code itself involves several nested loops, and requires very little disk I/O. Whenever the code is modified, I run it against a suite of several input files (just to make sure it's working properly). To make a long story short, the most recent update has increased the run time of the program by about a factor of four, and running each input file serially with one CPU takes about 45 minutes (a