gfortran

Positive/Negative Infinity Constants in Fortran

孤街浪徒 提交于 2019-12-10 21:04:34
问题 How could I get constants (or parameter s, I suppose) that are negative and positive infinity in Fortran 2008? I tried the following code: program inf use, intrinsic :: ieee_arithmetic real(8), parameter :: inf_pos = ieee_value(0d0, ieee_positive_inf) real(8), parameter :: inf_neg = ieee_value(0d0, ieee_negative_inf) end program inf However, I get the following errors: $ gfortran inf.f08 inf.f08:4:22: real(8) :: inf_pos = ieee_value(0d0, ieee_positive_inf) 1 Error: Function ‘ieee_value’ in

Random number generator in PGI Fortran not so random

可紊 提交于 2019-12-10 20:36:05
问题 The following code just generates a simple triple of random numbers: program testrand integer, parameter :: nz = 160, nf = 160, nlt = 90 real :: tmpidx(3) integer :: idxarr(3), idx1, idx2, idx3, seed_size, ticks integer, allocatable :: seed(:) call random_seed(size=seed_size) allocate(seed(seed_size)) call system_clock(count=ticks) seed = ticks+37*(/(i-1, i=1,seed_size)/) call random_seed(put=seed) deallocate(seed) call random_number(tmpidx) idxarr = tmpidx * (/nz, nf, nlt/) idx1 = max(1

Can free-format code be included in fixed-format code?

て烟熏妆下的殇ゞ 提交于 2019-12-10 20:26:34
问题 I inherited a fixed-format file FFTRUN.f The beginning of that files looks like this: SUBROUTINE FFTRUN_2e USE, intrinsic :: ISO_C_BINDING USE FFTWmod, ONLY : FFTWplan_fwd, FFTWplan_inv, FFTWplanReady INCLUDE 'INCL_PARAM.FOR' INCLUDE 'INCL_PRATT.FOR' INCLUDE 'INCL_XYZ.FOR' INCLUDE 'FFTW3.f03' PARAMETER (NDIM=2, NDAT=IMAX*JMAX) DIMENSION NN(NDIM),DATA(NDAT) COMPLEX*16 FACTR,SCATT(IMAX,JMAX),WAVINC,DATA IF (.not.FFTWplanReady) THEN FFTWplan_fwd = fftw_plan_dft_2d(nn2,nn1,data,data, & FFTW

What should COMPILER_OPTIONS() return in Fortran?

痴心易碎 提交于 2019-12-10 20:26:21
问题 Fortran 2008 added a new procedure called COMPILER_OPTIONS() which according to GNU documentation should return a string with the options used for compiling the file. According to Fortran 2003 status wiki, almost all compilers including GNU and PGI seem to support this feature. I created a simple program COMPILER_OPTIONS.f08 shown below use iso_fortran_env print '(4a)', 'This file was compiled by using the options ', compiler_options() end Here are my results from gfortran and pgfortran

Does the Intel Fortran 95 compiler allow module arrays to be of non-constant size?

六眼飞鱼酱① 提交于 2019-12-10 20:18:45
问题 I have downloaded a Fortran 90/95 adaptive mesh refinment library (Paramesh), and now I'm trying to compile an example program that came with it. In the process I modified the Makefile to use gfortran instead of the Intel Fortran compiler. In the library code, there is a module containing this snippet: module physicaldata ! Many many lines of variable definitions here !.... Public :: nfluxvar Integer,Save :: nfluxvar ! Many many lines of variable definitions here !.... end module physicaldata

Default Status of “Unknown” in Open

断了今生、忘了曾经 提交于 2019-12-10 20:04:35
问题 I often see people using the OPEN statement without explicitly specifying a STATUS . In the Fortran 90 and 2008 standards, this is said regarding STATUS : If UNKNOWN is specified, the status is processor dependent. If this specifier is omitted, the default value is UNKNOWN. I interpret this to mean, if STATUS is omitted, anything can happen, depending what machine you're using. Yet, from doing some tests, it seems the default behavior (when STATUS is omitted), is REPLACE . But I cannot find

Does installing gfortran with homebrew and with an installer create a conflict?

给你一囗甜甜゛ 提交于 2019-12-10 19:51:29
问题 I was following an online tutorial to install some Python modules using homebrew and one step was to install gfortran with brew install gfortran . Later on, I tried using another third-party installation script to install some Python modules and after the fact I realized that part of what the script did was download and run http://r.research.att.com/tools/gcc-42-5666.3-darwin11.pkg. I don't know that much about gfortran, but looking at the brew formula for gfortran it appears that brew uses a

Random number generator (RNG/PRNG) that returns updated value of seed

本秂侑毒 提交于 2019-12-10 19:48:15
问题 I'm trying to write an RNG that also returns the value of the updated seed. The perhaps obvious reason for this is so that new random variables can be added to the program later, without changing the values of the existing RNGs. For a python/numpy version of this issue see for example: Difference between RandomState and seed in numpy Here's a example of usage with a (tentative) proposed solution: program main ! note that I am assuming size=12 for the random ! seed but this is implementation

“ld: 32-bit RIP relative reference out of range” on Mac OSX

╄→尐↘猪︶ㄣ 提交于 2019-12-10 19:26:20
问题 I am trying to compile a Fortran 90 code that basically solves a very large system of differential equations (around 5000 ODEs). In order to increase the precision of the solver, I have to increase the size of the solution arrays, and I am running into a problem. I am using a Mac computer with El Capitan, with an i7 Intel core processor and 8GB of RAM. I use the Eclipse IDE, and gfortran 5.3 compiler. Here is my error : Building target: evolution_neutrinos_interpolation Invoking: MacOS X

Equivalent to asm volatile in Gfortran?

偶尔善良 提交于 2019-12-10 19:15:07
问题 Is there an equivalent to Gcc's inline assembly in Gfortran? __asm__ __volatile__ (...) I cannot find anything in the gfortran man page, or the manual. 回答1: No, there isn't. The easiest way around it is to have a C function with the asm , and then call that C function with ISO_C_BINDING. 来源: https://stackoverflow.com/questions/30723867/equivalent-to-asm-volatile-in-gfortran