gfortran

I/O in pure Fortran procedures

萝らか妹 提交于 2019-12-23 08:50:43
问题 I'm trying to incorporate error checking within a pure procedure I am writing. I would like something like: pure real function func1(output_unit,a) implicit none integer :: a, output_unit if (a < 0) then write(output_unit,*) 'Error in function func1: argument must be a nonnegative integer. It is ', a else func1 = a/3 endif return end function func1 However, pure functions are not allowed to have IO statements to external files, so I tried passing a unit number to the function, e.g. output

dyld: Library not loaded: @rpath/libgfortran.3.dylib

跟風遠走 提交于 2019-12-23 05:35:16
问题 I am trying to learn Fortran programming language, as a test I wrote a simple program like this: !Fortran Program program first print *, "Hello World" end program first Then I threw this code file in to mac terminal and run gfortran first.f95 which then gave me an output of a.out as expected. However, when I try to run the output in terminal by navigating into the output directory and typing ./a.out . It gave me this error output: dyld: Library not loaded: @rpath/libgfortran.3.dylib

conda gfortran on osx failed link issue

空扰寡人 提交于 2019-12-23 05:09:21
问题 This issue is apparently well known and widely referenced. I'm running a python code using a conda installed environment on OSX. I'm getting ImportError: dlopen(/Users/me/anaconda/lib/python2.7/site-packages/numpy/core/multiarray.so, 2): Library not loaded: @rpath/libgfortran.3.dylib This happens regardless of whether I install gcc in the environment. All the suggested work arounds I found aren't applicable to my case. It's been hours of googling. Can someone please provide relevant

Linking FORTRAN and C++ objects files

為{幸葍}努か 提交于 2019-12-23 04:14:07
问题 I am going to call a C++ function from FORTRAN, for which I am using ISO_C_Binding module. After compaction of the FORTRAN main file and C++ function with commands gfortran -c mlp8.f90 g++ -c mean_cpp.cc Which will create the objects files but in the linking phase as suggested by some members I am going to use the commands g++ mlp8.o mean_cpp.o -o main –lgfortran I.e. using C++ compiler with linking to FORTRAN libraries but it gives error like /Cygnus/cygwin-b20/H-i586-cygwin32/i586-win32/bin

OpenMP Crashing with Large Arrays

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 02:29:39
问题 I'm using Fortran and OpenMP, but I keep encountering an issue when I try to parallelize loops using OpenMP when there are large arrays. For example, the following code: PROGRAM main IMPLICIT NONE INTEGER, PARAMETER :: NUMLOOPS = 300000 REAL(8) :: TESTMAT(NUMLOOPS) INTEGER :: i,j !$OMP PARALLEL SHARED(TESTMAT) !$OMP DO DO i=1,NUMLOOPS TESTMAT(i) = i END DO !$OMP END DO !$OMP END PARALLEL write(*,*) SUM(TESTMAT)/(NUMLOOPS) END PROGRAM main compiled using this Makefile: .SUFFIXES: .f90 F90 =

Force explicit variable declaration with gfortran

风格不统一 提交于 2019-12-22 18:22:10
问题 I am linking some fortran code (f90) from matlab using mex and I am having matlab freeze occasionally. In the past, I had freezing happening due to mismatch between data types (say integer*4 vs integer*8). The code I am linking has many implicitly defined variables, so I am wondering if there is a hidden data type conflict that only occurs occasionally. To rule out data type mismatch as the cause of the freeze, I would like to have the compiler requiring all variables to be explicitly

installing gfortran in cygwin: gfortran: cyglto_plugin.dll not found

狂风中的少年 提交于 2019-12-22 14:47:31
问题 I'm trying to get the gfortran compiler with cygwin. When attempting to compile a hello world program, I get the following error: gfortran: fatal error: -fuse-linker-plugin, but cyglto_plugin.dll not found compilation terminated. To install the compiler, I used the cygwin setup and selected gcc-fortran: GNU compiler collection libgfortran3: GCC fortran runtime library I also mistakenly selected the toolchains for mingw, even though I don't have the mingw compiler (as far as I'm aware). g++,

Prevent FORTRAN from closing when a character is inputed instead of a number

二次信任 提交于 2019-12-22 10:53:42
问题 I have a read statement that expects a number, very simple example code: program test integer var read(*,*) var end The thing is that I usually input a string of characters (ie: yes ) on account of being distracted. How can I prevent my code from halting entirely and instead display an error message of the type You've entered an incorrect value. Try again ? I'm thinking something like: program test integer var 10 read(*,*) var if (var.not.a.number) then write(*,*)'You've entered an incorrect

Type bound procedure overloading in Fortran 2003

佐手、 提交于 2019-12-22 08:38:30
问题 I've been programming in Java for a few years; however, I'm now taking a course which uses Fortran as example code (77 standard). Although I've always viewed Fortran as an ancient language, I decided to try out the latest implementation of the 2003 standard using the gfortran compiler to see its merits for myself. So far, I've been surprised with the modern features, but I have run into one issue which is demonstrated by the example below. module mod1 type type1 real :: x real :: y contains

Unable to link to libgfortran.a [duplicate]

感情迁移 提交于 2019-12-22 08:35:08
问题 This question already has answers here : Why does the order in which libraries are linked sometimes cause errors in GCC? (9 answers) Closed 5 years ago . I have gfortran installed on my system and the file libgfortran.a can be found at /usr/lib/gcc/x86_64-linux-gnu/4.6/ . Using nm I made sure that the function _gfortran_compare_string is defined in there: $ nm /usr/lib/gcc/x86_64-linux-gnu/4.6/libgfortran.a | grep _gfortran_compare_string Returns 0000000000000000 T _gfortran_compare_string