fortran

Fortran: integer*4 vs integer(4) vs integer(kind=4)

Hi, I'm trying to learn Fortran and I'm seeing a lot of different definitions being passed around and I'm wondering if they're trying to accomplish the same thing. What is the difference between the following? integer*4 integer(4) integer(kind=4) Thanks ...

Fortran: Binary Subtraction (is there a binary type?)

I have a homework question regarding operator precedence in Fortran. In order to understand the question I need to know how to use binary numbers in Fortran. Can someone give me an example of how to use binary numbers in fortran? (Specifically with subtraction). ...

Long ints in Fortran

I'm trying to work with large numbers (~10^14), and I need to be able to store them and iterate over loops of that length. ie. n=SOME_BIG_NUMBER do i=n,1,-1 I've tried the usual star notation, kind=8 etc. but nothing seemed to work. Then I checked the huge(i) functions, and the code: program inttest print *,huge(1) print *,huge...

Error: Two Main Programs in Fortran

I'm trying to write a program with a function which returns a matrix with a random number on the diagonal, 1s on the sub-diagonals and 0s everywhere else. So, I wrote this function: real function am1d do i=1,L do j=1,L if (i.eq.j) then am1d(i,j)=rand()*w-w/2. elseif ((i-j.eq.1) .or...

Fortran return statement

Hello, I'm trying to get some code compiled under gfortran that compiles fine under g77. The problem seems to be from a return statement: ffuncs.f:934.13: RETURN E 1 Error: Alternate RETURN statement at (1) requires a SCALAR-INTEGER return specifier In the code anything E was specified as real*8: IMPLICIT REAL*8 ( A - H...

Does over-using function calls affect performance? Specifically in Fortran

I habitually write code with lots of functions, I find it makes it clearer. But now I'm writing some code in Fortran which needs to be very efficient, and I'm wondering whether over-using functions will slow it down, or whether the compiler will work out what's going on and optimise? I know in Java/Python etc each function is an object,...

Read a line containing (large) N reals to an array in Fortran

I've read() down past a header of an input file, and read the value of L on the way. Now I come to a line of L^2 consecutive reals, which I need to input to the elements of an allocatable array A(L,L). Trying character *100 :: buffer read (1,10) buffer 10 format(a(L*10)) results in Error: Syntax error in ...

Howto resolve compiler specific runtime initialization functions for a library from the main application

What is the best practice when doing a mixed language library where the library language requires a runtime initialization? I have a problem where I'd like to create a certain library in Fortran which is to used from C++. I'd want to preserve platform independence and compiler independence if possible. Now, the two compilers I have play...

Calling a Fortran subroutine from Java

I have a huge subroutine written in Fortran that I need to use in a Java program. How can I call it? I am using ubuntu 10.04. ...

Linking after using f2c

I used f2c to translate a huge Fortran subroutine into C. The header says the following: /* fourier.f -- translated by f2c (version 20090411). You must link the resulting object file with libf2c: on Microsoft Windows system, link with libf2c.lib; on Linux or Unix systems, link with .../path/to/libf2c.a -lm or, if you inst...

What is the equivalent type in C for REAL(KIND=real_normal) in Fortran?

I have a problem with passing of an array from Fortran to a c function: In the fortran the array is defined as REAL(KIND=real_normal) , DIMENSION(:), ALLOCATABLE :: array call cFunc(array) If define the cFunc as void cFunc(double *data){...} Than the data contains only "garbage" values. Where is the problem in this case? (with in...

How to install Fortran compiler (gcc42-fortran)

I'm trying to install R and came across this error during installation: http://projects.uabgrid.uab.edu/r-group/wiki/install-R, which is why i need to install the fortran compiler. Every .rpm i have downloaded of the gcc42.fortran has given me this error: libgfortran2 >= 4.2.1_20070724-50.18 is needed by package gcc42-fortran-4.2...

Are Fortran control characters (carriage control) still implemented in compilers?

In the book Fortran 95/2003 for Scientists and Engineers, there is much talk given to the importance of recognizing that the first column in a format statement is reserved for control characters. I've also seen control characters referred to as carriage control on the internet. To avoid confusion, by control characters, I refer to the c...

converter software for fortran 77 to fortran 90

i have coding for fortran 77 but i want to converted to fortran 90..where can i donwload the converter software?? ...

Prevent a user from closing an application that is opened through a C# program

I have a old command line based program (its fortran if that matters) that is opened from a C# application when a user clicks a button. If the command line program is shut down while it is running data becomes corrupted. Is there any way to prevent people shutting it down while it is running? Like make the [x] not be available or some...

Does Fortran have inherent limitations on numerical accuracy compared to other languages?

While working on a simple programming exercise, I produced a while loop (DO loop in Fortran) that was meant to exit when a real variable had reached a precise value. I noticed that due to the precision being used, the equality was never met and the loop became infinite. This is, of course, not unheard of and one is advised that, rather ...

Creating RAW image file in Fortran

Is it possible to create a raw image in Fortran? I was thinking BMP but not really sure what extension would be best. Basically, I want to be able to have an array or a text file that contains the color values for each pixel, so a 3 pixel wide red image would just be FF0000FF0000FF0000 or something similar to that ...

Dynamic linking unable to resolve main symbols

I'm trying to dynamically link a module into my program. If I normally compile and link this module then the symbols in it are normally accessible to the C++ via declaring the function prototypes as extern "C". The module itself is a group of fortran functions, that call C++ functions that I have written. When attempting to dynamically ...

Fortran assignment on declaration and SAVE attribute gotcha.

In fortran 95, if you assign a variable at declaration integer :: var = 0 it is equivalent to integer, save :: var = 0 and the variable is therefore preserved after routine execution (is equivalent to static in C speak) and does not get reinitialized when called again. What is the rationale/technical issue behind such (IMHO dangero...

Fortran compilation in all computers?

Heys, I've been following stackoverflow for a time, but for the first time I have a question that I haven't found the answer to here =) I've got a quick and a tiny question. I have a fortran program, which I can compile using f77, f95 or ifort, doesn't matter. It compiles properly on all the three operating systems that I have (one of ...