gfortran

Different syntaxes to declare arrays: with and without the dimension statement [duplicate]

亡梦爱人 提交于 2020-01-04 10:05:11
问题 This question already has answers here : Array declaration in Fortran (2 answers) Closed last year . I'm using gfortran version 7.2.0. I'm quite new to Fortran. I know there are different versions of Fortran. In the code below, I'm declaring arrays (or actually tensors) using different syntaxes program arrays implicit none integer :: m(3, 4) integer, dimension(3, 4) :: n print *, "m = ", m print *, "n = ", n end program arrays In one case, I'm using the dimension statement, in the other I am

Loop vectorization gives different answer

回眸只為那壹抹淺笑 提交于 2020-01-04 09:38:10
问题 I am building some unit tests and find that my code gives a slightly different result when vectorized. In my example case below, an array a is summed in one dimension and added to an initial value x . Most elements of a are too small to change x . The code is: module datamod use ISO_FORTRAN_ENV, only : dp => REAL64 implicit none ! -- Array dimensions are large enough for gfortran to vectorize integer, parameter :: N = 6 integer, parameter :: M = 10 real(dp) :: x(N), a(N,M) contains subroutine

Fortran 4.7.2/4.8.1 error: There is no specific subroutine for the generic 'vode' at (1)

瘦欲@ 提交于 2020-01-04 07:53:07
问题 I try to compile the fortran program which my advisor gave me. It doesn't want to compile when I'm doing this with gfortran 4.7.2 on Mac OS X 10.8.4 and with gfortran 4.8.1 on Arch Linux x64. I've built the minimal working example which replays the error. Unfortunately, it's quite big anyway, so I've put it on the github: https://github.com/kabanovdmitry/vode-test I can compile this code under Ubuntu 12.04 with gfortran 4.6.3. I've checked press releases for GCC 4.7 and found nothing that

Can Fortran PURE functions use global parameters?

ⅰ亾dé卋堺 提交于 2020-01-03 16:58:39
问题 It seems to me the what is called a pure function in Fortran is not considered pure enough for those who use functional programming. So here is my question. Suppose I have the following code: MODULE basics IMPLICIT NONE INTEGER, PARAMETER :: dp = kind(1.0d0) REAL(dp), PARAMETER :: PI=3.1415926535897932_dp REAL(dp), PARAMETER :: earthEquatorialRadius=6378.137_dp END MODULE basics MODULE myFunctions USE basics IMPLICIT NONE PURE REAL(dp) FUNCTION sphericalArc(angleInRadians) REAL(dp),INTENT(IN)

How to implement Structures of Arrays instead of Arrays of Structures in Fortran?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-02 19:11:08
问题 I'm writing my code on CFD topic with Fortran. After discussing with some friends from computer science, they told me that one could speed up the computation time if one implements Structures of Arrays (SoA) instead of Arrays of Structures (AoS) on his/her code. There are many examples I've seen about this topic's implementation, but most of them are in C or C++. (e.g. https://software.intel.com/en-us/articles/how-to-manipulate-data-structure-to-optimize-memory-use-on-32-bit-intel

Stringify macro with GNU gfortran

≡放荡痞女 提交于 2020-01-02 06:32:07
问题 How can I stringify a preprocessor macro with GNU gfortran? I would like to pass a macro definition to GNU gfortran which will then be used as a string in the code. Effectively I would like to do this: program test implicit none character (len=:), allocatable :: astring astring = MYMACRO write (*, *) astring end program test and then build with: gfortran -DMYMACRO=hello test.F90 I tried creating various macro, for example: #define STRINGIFY_(x) #x #define STRINGIFY(x) STRINGIFY_(x) ...

How to compile in gfortran in case Sensitive mode?

删除回忆录丶 提交于 2020-01-02 01:59:48
问题 Is it possible to compile a fortran 90/95 code in gfortran with Case Sensitive ? I searched the manuals, but couldn't find any flag or option I can give to gfortran to make it case sensitive. I want to have variables in upper case and lower case to be different. So, is it possible? 回答1: There is no such flag or option. Of course, gfortran being free software, you're welcome to download the source code and create your own version with that particular feature. In reality, I'd recommend to just

Fortran 90 - “Segmentation fault - invalid memory reference” with scalable 3D array

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-02 01:17:07
问题 I have compiled a fortran 90 program with gfortran which builds a scalable 3D array in a way I want. Upon running, I get the following error: Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: #0 0x10542ee42 #1 0x10542f60e #2 0x7fff8d7895a9 #3 0x10542575e #4 0x105425975 #5 0x105425d0e Segmentation fault: 11 I believe this is a memory issue with the large 3D array, as it works if I decrease the dimensions, but is there anyway to get around

How to use loadlibrary and getprocaddress from gfortran?

你离开我真会死。 提交于 2020-01-01 20:27:25
问题 I'm trying to learn how to call a function in a fortran dll from a fortran executable on windows. I'm working with gfortran 4.7 and photran in eclipse. My test dll has a single function in hello.f90: hello.f90 subroutine hello implicit none print *, "Hello World!" end subroutine hello with the following makefile: all: gfortran -Wall -c hello.f90 gfortran -shared -o hello.dll hello.o Dependency Walker confirms that the function "hello_" is exported. Now I'm trying to build a program that calls

Translate F2PY compile steps into setup.py

ⅰ亾dé卋堺 提交于 2020-01-01 10:49:12
问题 I've inherited a Fortran 77 code which implements several subroutines which are run through a program block which requires a significant amount of user-input via an interactive command prompt every time the program is run. Since I'd like to automate running the code, I moved all the subroutines into a module and wrote a wrapper code through F2PY. Everything works fine after a 2-step compilation: gfortran -c my_module.f90 -o my_module.o -ffixed-form f2py -c my_module.o -m my_wrapper my_wrapper