fortran

Discrepancy between the values computed by Fortran and C++

I would have dared say that the numeric values computed by Fortran and C++ would be way more similar. However, from what I am experiencing, it turns out that the calculated numbers start to diverge after too few decimal digits. I have come across this problem during the process of porting some legacy code from the former language to the ...

Writing fortran robust and "modern" code

In some scientific environments, you often cannot go without FORTRAN as most of the developers only know that idiom, and there is lot of legacy code and related experience. And frankly, there are not many other cross-platform options for high performance programming ( C++ would do the task, but the syntax, zero-starting arrays, and point...

Creating Python C module from Fortran sources on Ubuntu 10.04 LTS

In a project I work on we use a Python C module compiled from Fortran with f2py. I've had no issues building it on Windows 7 32bit (using mingw32) and on the servers it's built on 32bit Linux. But I've recently installed Ubuntu 10.04 LTS 64bit on my laptop that I use for development, and when I build it I get a lot of warnings (even thou...

matlab precision determinant problem

I have the following program format compact; format short g; clear; clc; L = 140; J = 77; Jm = 10540; G = 0.8*10^8; d = L/3; for i=1:500000 omegan=1.+0.0001*i; a(1,1) = ((omegan^2)*(Jm/(G*J))*d^2)-2; a(1,2) = 2; a(1,3) = 0; a(1,4) = 0; a(2,1) = 1; a(2,2) = ((omegan^2)*(Jm/(G*J))*d^2)-2; a(2,3) = 1; a(2,4) = 0; a(3,1) = 0; a(3,2...

How to compile Python scripts for use in FORTRAN?

Hello, Although I found many answers and discussions about this question, I am unable to find a solution particular to my situation. Here it is: I have a main program written in FORTRAN. I have been given a set of python scripts that are very useful. My goal is to access these python scripts from my main FORTRAN program. Currently, I s...

Reading input files in FORTRAN

Purpose: Create a program that takes two separate files, opens and reads them, assigns their contents to arrays, do some math with those arrays, create a new array with product numbers, print to a new file. Simple enough right? My input files have comment characters at the beginning. One trouble is, they are '#' which are comment ch...

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

Passing a Fortran int array to C++ by calling C++ function in Fortran

I am trying to call a C++ function in a Fortran subroutine. This C++ function is supposed to update an integer array. Here is a non-working code I wrote. What is the issue? ! Fortran function that calls a C++ function. subroutine my_function() integer(4) ar(*) integer(4) get_filled_ar ! Need correct syntax here. ...

An error which does not present itself with a debugger attached.

I am using Intel's FORTRAN compiler to compile a numerical library. The test case provided errors out within libc.so.6. When I attach Intel's debugger (IDB) the application runs through successfully. How do I debug a bug where the debugger prevents the bug? Note that the same bug arose with gfortran. I am working within OpenSUSE 11....

accing a fortran 'module' in a 'function defined in some other file

I am using Fortran 90. I have defined a Fortran module in fileA.f as: module getArr double precision a(100) end module getArr The same fileA.f contains a subroutine that uses this module: subroutine my_sub use getArr implicit none a(1) = 10.5 end subroutine In fileB.f, I have a Fortran function. I am trying to access ...

OpenMP in Fortran

I very rarely use fortran, however I have been tasked with taking legacy code rewriting it to run in parallel. I'm using gfortran for my compiler choice. I found some excellent resources at https://computing.llnl.gov/tutorials/openMP/ as well as a few others. My problem is this, before I add any OpenMP directives, if I simply compile...

fatal error F1002

Hi , I have a Fortran 77 program code , I am using fortran power station 4.0 on XP . I wrote this program because I am studying Master's degree in Mechanics , It is a very long Finite element method code. The code is the following : 1 -Main Program STARTS with : PARAMETER (HLENGTH=600.0,VLENGTH=600.0,NHELE=6,NVELE=6,NTYPE=1) PARA...

Fortran intent(inout) v's no intent

Good practice dictates that subroutine arguments in Fortran should each have a specified intent (i.e. intent(in), intent(out) or intent(inout) as described this question): subroutine bar (a, b) real, intent(in) :: a real, intent(inout) :: b b = b + a ... However, not specifying an intent is valid Fortran: subroutine b...

fortran SAVE statement

I've read it's entry in the language reference (Intel's), but I cannot quite grasp what it does. Could someone in layman's terms explain it to me, what it means when it is included in a module ? ...

pass fortran 77 function to C/C++

hello. Is it possible to pass fortran 77 function as a callback function pointer to C/C++? if so, how? information I found on the web relates to fortran 90 and above, but my legacy code base is in 77. many thanks ...

FORTRAN: Invalid form for an assignment

I can't get this code to compile uding either the g77 minGW compiler or the g95 compiler. Does anyone know why? I get these errors with the g77: diff5z10.for: In subroutine `diffract': diff5z10.for:579: Tropo100 = 20.34 - .077 * Dist ^ Invalid form for assignment statement at (^) diff5z10.for:581: IF (Freq...

parse content away from structure in a binary file

Using C#, I need to read a packed binary file created using FORTRAN. The file is stored in an "Unformatted Sequential" format as described here (about half-way down the page in the "Unformatted Sequential Files" section): http://www.tacc.utexas.edu/services/userguides/intel8/fc/f_ug1/pggfmsp.htm As you can see from the URL, the file i...

AccessViolationException was unhandled, calling fortran dll from vb net

I have a subroutine that was written in fortran that I need to call from VB.NET where all of my other functions are written. I did not write the fortran, and hardly know fortran. I am getting the below exception on my dll function call and don't know how to fix it. I wonder if it is due to incongruent variable lengths? I have the sou...

Using MATLAB's plotting features as an interactive part of a Fortran program

Although many of you will have a decent idea of what I'm aiming at, just from reading the title -- allow me a simple introduction still. I have a Fortran program - it consists of a program, some internal subroutines, 7 modules with its own procedures, and ... uhmm, that's it. Without going into much detail, for I don't think it's neces...

How to say "Hello World" in Fortran

I want to create a program that says "Hello World" in Fortran programming language. How should I go about this task? ...