gfortran

Array inside type array as function argument

心已入冬 提交于 2019-12-11 07:48:06
问题 I have the following program at hand program foo type bar real, dimension(2) :: vector end type type(bar), dimension(3) :: bararray call doSomething(bararray%vector) end program subroutine doSomething(v) real, dimension(3,2), intent(inout) :: v ... end subroutine Now this gives me a compilation error. Error: Two or more part references with nonzero rank must not be specified at (1) If I change the call to call doSomething((/bararray%vector(1), bararray%vector(2)/)) everything works out nicely

Trouble using function name as argument in Fortran

妖精的绣舞 提交于 2019-12-11 06:59:41
问题 I wanted to make it easier to change a certain function which will be used by a subroutine in a fortran project. However I can not get it to work. I have seen quite a few examples which use the external , however I am not sure if I have to use it, since I put all my function and subroutines in modules. Here is a simplified example of the problem I am dealing with: I have the program in a separate file: program test use Parameters use circArrayConstructer use velocity use RungeKutta4 implicit

gdb/gfortran broken after 7.2/4.7

戏子无情 提交于 2019-12-11 06:22:44
问题 I have three machine, two run Linux and one run OS X Yosemite with different version of gfortran and gdb . gdb on my old box work well with allocated arrays, however, newer version of gdb (after 7.2) and gfortran (after 4.7) do not seem to be able to examine the allocatable variables. My question is: is this an expected behavior or is there a patch to keep gfortran , gdb work like the older version? This is a small version of code I tested: integer :: x(2,3) integer, allocatable :: y(:,:)

Floating point output format with leading zeros

非 Y 不嫁゛ 提交于 2019-12-11 06:19:08
问题 For example, if I make these definitions: Real, parameter :: No_01 = 2.34 Real, parameter :: No_02 = 34.56 and I want to write these variables with F format in this way: Character(*), parameter :: FMT_01 = '(2x,F4.2)' Character(*), parameter :: FMT_02 = '(2x,F5.2)' The result of writing to screen would be: Write(*, FMT_01 ) NO_01 => 2.34 Write(*, FMT_02 ) NO_02 => 34.56 Is there any kind of F format which can be used for geting this result of writing instead: Result is: !Correct result !Not

How do I declare the precision of a number to be an adjustable parameter?

你离开我真会死。 提交于 2019-12-11 06:06:09
问题 In 2013 there was a question on converting a big working code from double to quadruple precision: "Converting a working code from double-precision to quadruple-precision: How to read quadruple-precision numbers in FORTRAN from an input file", and the consensus was to declare variables using an adjustable parameter "WP" that specifies the "working precision", instead of having a separate version of the program with variables declared using D+01, and another version using Q+01. This way we can

Using a derived type pointer and a polymorphic target in Fortran

▼魔方 西西 提交于 2019-12-11 05:24:31
问题 The Fortran function listed below compiles and executes as expected using ifort 11.1. However GFortran 4.6 returns the compiler error: THIS_NML => THIS Error: Different types in pointer assignment at (1); attempted assignment of CLASS(UNIT) to TYPE(UNIT). Fortran code: FUNCTION PROCESS_COMMAND(THIS, CMD, DATA) RESULT(RET) CLASS(UNIT), INTENT(INOUT), TARGET :: THIS CHARACTER(LEN = *), INTENT(IN) :: CMD CHARACTER(LEN = *), INTENT(IN) :: DATA CHARACTER(LEN = 200) :: STRING INTEGER :: IOS TYPE

Can't install deSolve pacakge in R, Library not loaded: libgcc_s.1.dylib

痞子三分冷 提交于 2019-12-11 04:59:47
问题 I am using MacOSX sierra, I installed fortrun using brew: brew install gcc brew update && brew reinstall r brew link --overwrite r Now I need to install deSolve but I can't: > install.packages("deSolve") Installing package into '/usr/local/lib/R/site-library' (as 'lib' is unspecified) trying URL 'https://cran.rstudio.com/src/contrib/deSolve_1.21.tar.gz' Content type 'application/x-gzip' length 2172444 bytes (2.1 MB) ================================================== downloaded 2.1 MB dyld:

How to read numeric data from a string in FORTRAN

断了今生、忘了曾经 提交于 2019-12-11 04:52:54
问题 I have a character string array in FORTRAN as ' results: CI- Energies --- th= 89 ph=120'. How do I extract the characters '120' from the string and store into a real variable? The string is written in the file 'input.DAT'. I have written the FORTRAN code as: implicit real*8(a-h,o-z) character(39) line open(1,file='input.DAT',status='old') read(1,'(A)') line,phi write(*,'(A)') line write(*,*)phi end Upon execution it shows: At line 5 of file string.f (unit = 1, file = 'input.dat') Fortran

How to stop a subroutine and raise a flag?

半世苍凉 提交于 2019-12-11 04:19:55
问题 I am writing a program in Fortran 95 (to be compiled with with gfortran) containing a subroutine that performs a certain computation. As suggested in "Fortran 95/2003 for Scientists & Engineers" by S. J. Chapman, I am trying to stop the subroutine when an error is encountered and "throw" [1] an error flag that is "catch"ed [1] by the calling program, that will take all the necessary actions. Ideally, I am going for something like: ! Pseudo-code PROGRAM my_prog integer :: error_flag CALL my

division by zero doesn't work with ieee_arithmetic in gfortran 5.4

旧时模样 提交于 2019-12-11 03:55:22
问题 I'm using ieee_arithmetic with Fortran on a Linux machine that runs gfortran version 5.4.0. I'm getting an error of division by zero when trying to initialize values for Inf and NaN . There doesn't seem to be an issue with ieee_arithmetic because elsewhere in the file I can successfully call ieee_is_finite() with no issues. I thought that ieee_arithmetic allowed division by zero to be used for these specific cases, but I must be missing something. Below is a sample of code: module rcrlib_gnu