gfortran

How to find out which compiler was used: g77 or gfortran

Hi, I'm compiling library for a private project, which depends on a number of libraries. Specifically one of the dependencies is compiled with Fortran. On some instances, I've seen the dependency compiled with g77, on others I've seen it compiled with gfortran. My project then is ./configure'd to link with either -lg2c or -lgfortran, bu...

gfortran: how to control output directory for .mod files

Is there is a way to put .mod files, generated by gfortran (GCC), into a separate output directory? I know how to place object files or other output with the -o flag as in: gfortran -c test.f03 -o /path/to/output/dir/test.o But the .mod files (which are generated by the above call) are not affected by the -o flag and placed in the curr...

What's the easiest way to read .dbf file from gfortran

Hi! I'm using gfortran, I need to write a function that reads records from a .dbf file associated with an ESRI Shapefile. The file I should be able to read is available from internet http://diss.rm.ingv.it/diss/DISS_3.0.4.shp.zip The opinion of the file command about the format of the file is: $ file GGSources_polyline.dbf GGSources_p...

BLAS subroutines dgemm, dgemv and ddot doesn't work with scalars?

Hi, I have a Fortran subroutine which uses BLAS' subroutines dgemm, dgemv and ddot, which calculate matrix * matrix, matrix * vector and vector * vector. I have m * m matrices and m * 1 vectors. In some cases m=1. It seems that those subroutines doesn't work well in those cases. They doesn't give errors, but there seems to be some numer...

Compilation error while porting from gfortran to ifort

I'm trying to port a program from gfortran to ifort (Intel Fortran Compiler 11). I'm stuck with two files that only compile with gfortran: gfortran -x f77 -c daedrid.ff gfortran -x f77-cpp-input -c daedris.ff when I try to run intel fortran compiler with these files, I get: ifort -fpp -c daedrid.ff ifort: warning #10147: no action pe...

Mixed language statically linking with gfortran and gcc

Hi, I have some code written in C and Fortran that I want to compile into a statically-linked executable. If I compile the code dynamically (using the -fno-underscoring option for gfortran), it all works fine. However, I want to link it into a .so file, statically linking most of the needed libraries, and then link dynamically to libkrb5...

Writing and calling pure subroutines in Fortran 90 using gfortran

When writing and calling pure subroutines in Fortran 90 using gfortran, how do I find out why the compiler emits this error? Error: Subroutine call to XXXX at (1) is not PURE I'll try to pose my question as specifically as I can while at the same time being general enough to be useful to others, so I'll avoid pasting in my actual code...

How do I flush output to file after each write with a gfortran Fortran 90 program?

I am running a loop in a Fortran 90 program that outputs numerical values to an output file for each iteration of the loop. The problem is that the output is not saved to the file but every so many steps. How do I get it to flush each step? Example code: open(unit=1,file='output') do i = 1, 1000 write(1,*) i end do close(unit=1) ...

Fortran pointer functions: why does this code's behavior depend on the order of function calls?

Context The toy Fortran code posted below calls two pointer functions. That is, both functions return a pointer. In fact, they're both array pointers. They both attempt to do the same thing, which is to return an integer array pointer referencing an integer array having three elements, 1, 2, and 3. The first function uses the pointe...

How to make a fortran executable that runs on Mac OS X 10.5 and 10.6

I'd like to compile a fortran code with gfortran so that it will work on both Mac OS X 10.5 and 10.6. Is there a way to do this? I tried compiling on 10.6 and get this message when I run the executable on 10.5: dyld: unknown required load command 0x80000022 Trace/BPT trap ...

Xcode with fortran

Hi. I'm trying to compile some fortran files in Xcode, using a makefile made by me. The problem is that Xcode can't find gfortran compiler. I have it, because if I go to console and try to compile from there it works well. Do you know how to add fortran compiler to Xcode. Thanks in advance ...

Associated pointers in derived type? gFortran vs. Intel

Hello, I would like to check if a pointer inside a derived type has already been defined or not. I wrote the following simple code to show you my problem: program test implicit none type y real(8), pointer :: x(:) end type y type(y), pointer :: w(:) allocate(w(2)) allocate(w(1)%x(2)) write(*,*) associated(w(1)%x), associated(w(...

Fortran bus error on mac

The following Fortran code is giving me a bus error on my Mac but no errors when I run it on my Linux machine: PROGRAM TINY WRITE(UNIT=*, FMT=*) 'Hello, world!' END My understanding is that a bus error occurs when the program attempts to access impossible memory but I do not understand where such an attempt has been made in this...

gfortran, DLL, underscore

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 '_f...

how I can find out, which compiler I have used

I have installed NetCDF "binary-netcdf-4.0.1_gfortran_gfortran_c++.tar ". But I am not sure about the gfortran compiler I have used. How can I find the compiler I have used? ...

Porting sun studio compatible fortran 77 to gcc: format specifier in READ, FORMAT

I have some old fortran 77 I'm trying to port to gcc on Windows. I'm using gfortran 4.4. The statement uses READ(FOO, '(F)' , ERR=BAR) BAZ and gcc is complaining about F. From what I've seen it looks like F needs a size associated with it. There are also FORMAT statements which use a similar construct. What is the proper way to port t...

Pre-processing !DEC$ directives in gfortran

I've got a large Fortran codebase that originally targeted Intel's compiler. I'm now gearing up to compile with gfortran. Unfortunately, the code is littered with Intel-style pre-processing directives like: !DEC$ IF DEFINED (MYDIRECTIVE) REAL, DIMENSION(:,:,:), ALLOCATABLE :: my_real_var !DEC$ ENDIF From what I can tell via googlin...

How to debug command line file with symbolic data

I have a compiled .exe file (compiled with gfortran and -g option) that crashes. I can attach the WinDBG program to it using the WinDBG -I command. Funny enough it generates a stack overflow: (38f0.2830): Stack overflow - code c00000fd (!!! second chance !!!) However, the output says that there is no debugging information in my progr...

Attempting my first fortran 95 program, to solve quadratic eqn. Getting weird errors.

So, I'm attempting my first program in Fortran, trying to solve quadratic eqn. I have double and triple checked my code and don't see anything wrong. I keep getting "Invalid character in name at (1)" and "Unclassifiable statement at (1)" at various locations. Any help would be greatly appreciated... ! This program solves quadratic equat...

GFortran real format error on OpenSolaris 2009.06

Hi, I get on trouble using gfortran on OpenSolaris 2009.06 64bit. I compile mine (gcc-4.4.1) or use the one provided by OpenSolaris package system (gcc-4.3.2). But I'm in trouble using this simple code (extract from the more complexe one I targeted) : PROGRAM TESTPRGM REAL test; test=-1.14739E+002; writ...