gfortran

Save command line output to variable in Fortran

家住魔仙堡 提交于 2020-01-01 05:51:06
问题 Is there a way to store the output of a command line utility to a variable in Fortran? I have a BASH based utility which gives me a number which needs to be used in a Fortran program. I want to call the utility through the program itself, and avoid writing the output to a file if possible. Something like this maybe? integer a write(a,*) call execute_command_line('echo 5') Or like this maybe? read(call execute_command_line('echo 5'),*) a I don't think either of these is right though. I would

gfortran doesn't work on Mac OS X 10.9

与世无争的帅哥 提交于 2020-01-01 03:36:09
问题 I updated my Mac to OS X 10.9 GM, then I found that gfortran does not work. When building any program, it shows: ld: library not found for -lcrt1.10.5.o collect2: ld return 1 Does anyone know how I might solve this? 回答1: This problem is because OS X 10.9 has removed the /Developer directory completely where the library crt1.10.5.o used to locate. The libraries have been moved to the new Xcode directory (make sure that Xcode is also updated to the latest version 5.0.1+). I found that crt1.10.5

gfortran, DLL, underscore

我们两清 提交于 2019-12-31 07:09:05
问题 I want to access some subroutines from a third party DLL. The functions use STDCALL as the calling convention. Running dumpbin /export foo.dll gives me something like: ... 7 6 00004B40 Foo@16 ... I compile my code using: gfortran test.f90 -o test.exe -Wl,foo.dll I get an error: undefined reference to '_foo_' (note the underscores). I have tried adding the -mrtd compilation flag, as well as other flags I googled, all to no avail. How can I tell fortran to not add the underscores? edit: A bit

Fortran non advancing reading of a text file

馋奶兔 提交于 2019-12-31 05:59:40
问题 I have a text file with a header of information followed by lines with just numbers, which are the data to be read. I don't know how many lines are there in the header, and it is a variable number. Here is an example: filehandle: 65536 total # scientific data sets: 1 file description: This file contains a Northern Hemisphere polar stereographic map of snow and ice coverage at 1024x1024 resolution. The map was produced using the NOAA/NESDIS Interactive MultisensorSnow and Ice Mapping System

Force CMake to use static libraries

邮差的信 提交于 2019-12-30 18:49:06
问题 [Shamelessly cross-posted from the CMake help list] I'm trying to create binaries as statically as possible. The fortran code I've got has got X11 and quadmath as dependencies, and I've come across a number of issues (maybe each of these issues should be in a different question?): My variables are currently set(CMAKE_LIBRARY_PATH /usr/X11/lib /usr/X11/include/X11 ${CMAKE_LIBRARY_PATH}) find_package(X11 REQUIRED) find_library(X11 NAMES X11.a PATHS /usr/X11/include/X11/ /usr/X11/lib) find

Gfortran: Treat pure functions as normal functions for debugging purposes?

半城伤御伤魂 提交于 2019-12-30 18:28:22
问题 I need to debug some pure functions in a fortran Program compiled with gfortran. Is there any way to ignore the pure statements so I can use write , print , etc. in these pure functions without great effort? Unfortunately it is not easly possible to just remove the pure statement. 回答1: You can use a macro and use the -cpp flag. #define pure pure subroutine s print *,"hello" end 回答2: I usually use the pre-processor for this task: #ifdef DEBUG subroutine test(...) #else pure subroutine(...)

Fortran 90 difference between compaq visual fortran and gfortran

吃可爱长大的小学妹 提交于 2019-12-30 16:27:12
问题 This may be a specific question, but I think it pertains to how memory is handled with these two compilers (Compaq visual Fortran Optimizing Compiler Version 6.5 and minGW). I am trying to get an idea of best practices with using pointers in Fortran 90 (which I must use). Here is an example code, which should work "out of the box" with one warning from a gfortran compiler: "POINTER valued function appears on RHS of assignment", and no warnings from the other compiler. module vectorField_mod

Interface mismatch - higher order functions

自古美人都是妖i 提交于 2019-12-30 13:38:33
问题 I'm trying to 'reproduce' higher order functions in fortran. module rk4 contains pure function f(t,x) result (fx) real, dimension(1), intent(in) :: x real, intent(in) :: t real, dimension(1) :: fx fx = x end function f function step(x,f,dt) result(xn) real, intent(in) :: dt real, intent(in), dimension(:) :: x real, dimension(:), allocatable :: k1,k2,k3,k4,xn real, external :: f integer :: N N = size(x) allocate(k1(N)) allocate(k2(N)) allocate(k3(N)) allocate(k4(N)) k1 = f(t,x) k2 = f(t+0.5*dt

Return an array from a function and store it in the main program

血红的双手。 提交于 2019-12-29 09:41:47
问题 Here is the Main Program: PROGRAM integration EXTERNAL funct DOUBLE PRECISION funct, a , b, sum, h INTEGER n, i REAL s PARAMETER (a = 0, b = 10, n = 200) h = (b-a)/n sum = 0.0 DO i = 1, n sum = sum+funct(i*h+a) END DO sum = h*(sum-0.5*(funct(a)+funct(b))) PRINT *,sum CONTAINS END And below is the Function funct(x) DOUBLE PRECISION FUNCTION funct(x) IMPLICIT NONE DOUBLE PRECISION x INTEGER K Do k = 1,10 funct = x ** 2 * k End Do PRINT *, 'Value of funct is', funct RETURN END I would like the

How to use gfortran for Fortran 90 with .for file extension?

杀马特。学长 韩版系。学妹 提交于 2019-12-29 09:14:13
问题 After I installed Gfortran in Ubuntu (16.04) is pointing to f95. I see in gfortran manual that -std option can be given for f95 and forward. The default -std option value I see from manual is "gnu". I am not sure of implications of internals of compiling if I use f95 for f90 code. How do I use gfortran for Fortran 90 files with .for extension? I do not want to use Fortran 95 compiler for Fortran 90 code though Fortran 95 might be able to (not sure) compile Fortran 90. 回答1: Fortran 90 is dead.