fortran90

What flags do you set for your GFORTRAN debugger/compiler to catch faulty code?

情到浓时终转凉″ 提交于 2019-11-27 05:04:20
问题 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 errors would lead to many people suffering e.g. the dark side. What kind of flags do you set when you compile your program for Fortran for debugging purposes? What kind of flags do you set for the production system? What do you do before you deploy? The production version uses ifort as a compiler,

Wrong result when using a global variable in Fortran

痞子三分冷 提交于 2019-11-27 04:57:25
问题 I'm learning the basics of Fortran. I created a simple subroutine initializing a matrix: program test integer, parameter :: n = 1024 real :: a(n, n) call init(a) write (*, *) a(1, 1) end program subroutine init(a) real :: a(n, n) a(:, :) = 3.0 end subroutine Then the output is 0.0 instead of expected 3.0 . Apart from that, valgrind says that: ==7006== Conditional jump or move depends on uninitialised value(s) ==7006== at 0x400754: init_ (in /home/marcin/proj/mimuw/fortran/test) ==7006== by

What does “real*8” mean?

丶灬走出姿态 提交于 2019-11-27 04:36:21
The manual of a program written in Fortran 90 says, "All real variables and parameters are specified in 64-bit precision (i.e. real*8 )." According to Wikipedia , single precision corresponds to 32-bit precision, whereas double precision corresponds to 64-bit precision, so apparently the program uses double precision. But what does real*8 mean? I thought that the 8 meant that 8 digits follow the decimal point. However, Wikipedia seems to say that single precision typically provides 6-9 digits whereas double precision typically provides 15-17 digits. Does this mean that the statement "64-bit

Where to put `implicit none` in Fortran

纵然是瞬间 提交于 2019-11-27 04:22:45
Do I need to put implicit none inside every function and subroutine? Or is it enough to put it at the beginning of the module containing these functions and subroutines? Or is it enough to put it at the beginning of the program that is using these modules? From observation of other's working code, implicit none is included in all these places. I am not sure if this is done redundantly because removing implicit none from subroutines still compiled and produced the same output. By the way, I am using gfortran fortran 90 . The implicit statement (including implicit none ) applies to a scoping

What are the ways to pass a set of variable values through the subroutine to a function without common block?

不问归期 提交于 2019-11-27 04:07:36
问题 I do not want to use common blocks in my program. My main program calls a subroutine which calls a function. The function needs variables from the subroutine. What are the ways to pass the set of information from the subroutine to the function? program ... call CONDAT(i,j) end program SUBROUTINE CONDAT(i,j) common /contact/ iab11,iab22,xx2,yy2,zz2 common /ellip/ b1,c1,f1,g1,h1,d1,b2,c2,f2,g2,h2,p2,q2,r2,d2 call function f(x) RETURN END function f(x) common /contact/ iab11,iab22,xx2,yy2,zz2

Fortran SAVE statement

扶醉桌前 提交于 2019-11-27 03:49:54
I've read about the save statement in the (Intel's) language reference document, but I cannot quite grasp what it does. Could someone explain to me in simple language what it means when the save statement is included in a module ? In principal when a module goes out-of-scope, the variables of that module become undefined -- unless they are declared with the SAVE attribute, or a SAVE statement is used. "Undefined" means that you are not allowed to rely on the variable having the previous value if you again use the module -- it might have the previous value when you re-access the module, or it

Can not install gfortran via homebrew

巧了我就是萌 提交于 2019-11-27 03:10:34
问题 I got this message when i tried to install gfortran. ~$ brew install gfortran Error: No available formula for gfortran GNU Fortran is now provided as part of GCC, and can be installed with: brew install gcc My question is how to install gfortran with homebrew or port? or If now GNU Fortran is a part of GCC How can i compile fortran code using gcc? I'm not sure may be i've misunderstood something i remember that the last time i still can use gfortran to compile my code but now it doesn't work.

f2py: Specifying real precision in fortran when interfacing with python?

懵懂的女人 提交于 2019-11-27 01:58:50
问题 I am playing around with f2py. I'm a bit confused about numpy intrinsic types vs. fortran 90 types. It seems like I can only use single precision reals in fortran 90, when interacting with python. Let me illustrate with an example: Say I have this fortran 90 module, test.f90, to be compiled with f2py and imported in python: module test implicit none integer, parameter :: sp = selected_real_kind(6,37) ! single precision integer, parameter :: dp = selected_real_kind(15,307) ! double precision

How can gfortran tell if I am compiling f90 or f95 code?

我与影子孤独终老i 提交于 2019-11-27 01:29:25
问题 I understand gfortran can compile f90 or f95? How does it know which one it is compiling? Also can it compile f77 code? Does ubuntu already have a fortran compiler or do I need to download gfortran? 回答1: gfortran can guess certain things from the file extension; if the file has an extension of .f, .f90, f95, .f03, or .f08 it will assume fixed (.f) or free format with the appropriate standards. But you can force it to compile (say) fortran2003 code with the option -std=f2003. Eg, from the

Is There a Better Double-Precision Assignment in Fortran 90?

只愿长相守 提交于 2019-11-26 23:16:10
In Fortran 90 (using gfortran on Mac OS X) if I assign a value to a double-precision variable without explicitly tacking on a kind, the precision doesn't "take." What I mean is, if I run the following program: program sample_dp implicit none integer, parameter :: sp = kind(1.0) integer, parameter :: dp = kind(1.0d0) real(sp) :: a = 0. real(dp) :: b = 0., c = 0., d = 0.0_dp, e = 0_dp ! assign values a = 0.12345678901234567890 b = 0.12345678901234567890 c = DBLE(0.12345678901234567890) d = 0.12345678901234567890_dp write(*,101) a, b, c, d 101 format(1x, 'Single precision: ', T27, F17.15, / & 1x,