fortran

How to break out of a nested parallel (OpenMP) Fortran loop idiomatically?

Here's sequential code: do i = 1, n do j = i+1, n if ("some_condition(i,j)") then result = "here's result" return end if end do end do Is there a cleaner way to execute iterations of the outer loop concurrently other than: !$OMP PARALLEL private(i,j) !$OMP DO do i = 1, n !$OMP FLUS...

Are Fortran, Cobol, Basic and Forth high level programming languages?

Are Fortran, Cobol, Basic and Forth high level programming languages? And if not, what where the first high level programming languages? What where the first object-oriented languages? ...

Good FORTRAN books/tutorials for beginners?

This may be a duplicate of http://stackoverflow.com/questions/31672/learning-fortran-in-the-modern-era, but that thread went on discussing legacy code concerns. Anyway, few months ago in a bookstore sale I picked up book called FORTRAN 66 for PDP-11. I found it interesting and decided it would be nice to learn FORTRAN. So I'm looking fo...

Fortran severe (40) Error... Help?!

I can compile but when I run I get this error "forrtl: severe (40): recursive I/O operation, unit -1, file unknown" if I set n = 29 or more... Can anyone help with where I might have gone wrong? Thanks. PROGRAM SOLUTION IMPLICIT NONE ! Variable Declaration INTEGER :: i REAL :: dt DOUBLE PRECISION :: st(0:9) DOUBLE PRECISION :: s...

Fortran ASSOCIATE syntax to allow indexed access?

Is there a nice way to write a Fortran ASSOCIATE statement to turn this FORALL (i = 2:n-2) v(:,i) = v(:,i) + MATMUL(A, & c(2)*u(:,i-2) + c(1)*u(:,i-1) + c(0)*u(:,i) + c(1)*u(:,i+1) + c(2)*u(:,i+2)) END FORALL into something like the following ASSOCIATE ( U => ..., V => ...) FORALL (i = 2:n-2) V(i) = V(i) ...

Common block usage in Fortran

I'm new to Fortran and just doing some simple things for work. And as a new programmer in general, not sure exactly how this works, so excuse me if my explanation or notation is not the best. At the top of the .F file there are common declarations. The person explaining it to me said think of it like a struct in C, and that they are gl...

How to implement Horner's scheme for multivariate polynomials?

Background I need to solve polynomials in multiple variables using Horner's scheme in Fortran90/95. The main reason for doing this is the increased efficiency and accuracy that occurs when using Horner's scheme to evaluate polynomials. I currently have an implementation of Horner's scheme for univariate/single variable polynomials. How...

segfault with -fopenmp for a trivial program

I am refreshing openmp a bit, and got into this weird situation. Shaved off the bunch, I created this minimal trivial case that shows the issue program ex2 implicit none integer, parameter :: n=10000000 integer :: i real :: x(n) do i=1,n x(i) = 0.0d0 enddo end program with no flags specified, gfortran...

For Fortran 90+ is there any utility as good as astyle?

Can anyone recommend a nice Fortran code beautifier? f90pp/f90ppr works but is a bit dodgy and lacks the formatting options of C/C++ beautifiers like astyle. ...

fortran to matlab

Hello, I have a following fortran program: program test implicit none real :: a, b, c read*,a read*,b c=a*b if(c<0)then print*,"OK" else print*,"NOT OK" endif end I want to use this program with MATLAB with S-function, but I don't know any ways. Can you help me ? can you help me? ...

Fortran 90 Presence Of Optional Arguments

I do not understand the behavior of the present() intrinsic function with pgf90 7.2. I wrote a 20 line sample program to test this, but the results still make no sense to me. Observe: subroutine testopt(one,two,three,four,five) implicit none integer, intent(in) :: one,two integer, intent(out) :: three integer, intent(in), o...

What is being done in here ? (Used math recognition)

I know this isn't exactly programming related per se, but programmers are the most probable of all people who will recognize this maybe. I have the following (X and Y are arrays, both with 3 elements), and I cannot recognize (although it reminds me of a few things, but none quite!) what is being done here. Does it ring any bells for any...

Call C/C++ code form a fortran program in visual studio? (How to compile mixed C and fortran code in visual studio)

Hi every one, i am looking for a way, how i can integrate a c++ code with fortran code (i want simply call some C/C++ functions in the fortran code). I have found some proposals for gcc or console compilers, but i have not any idea how to translate this approach to solve integrationproblem within the visual studio. At the time I am thi...

Returning character string of unknown length in fortran

Apologies for the rather simple question, I just can't seem to find ANY good fortran docs. I'm trying to write a function that reads from a unit, trims the output and appends the null terminator, something like: character(*) function readCString() character*512 str read(1, *) str readCString = TRIM(str)//char(0) return end func...

OPEN and WRITE to files in FORTRAN DLL

I am writing in fortran and compiling using the g95 compiler. I need to have a log file output to a DLL i am writing, that is currently linking and running with the master program, but producing incorrect results. I don't know much about FORTRAN, but i did get the following code to produce output in an EXE i compiled: OPEN(UNIT=3, F...

Should I learn Fortran or C++ to extend R?

I work with machine learning with fairly large datasets (they still fit in memory) and I have written some calculations in R which I find to be too slow. Thus I would like to replace the "critical parts" of the program with compiled code that I would call from R. An example problem that I have in hand is implementing the forward-backward...

Reading REAL's from file in FORTRAN 77 - odd results..

Hey Everyone! I'm currently messing around in FORTRAN 77 and I've ran into a problem that I can't seem to figure out. I'm trying to read from a file that looks similar to below: 000120 Description(s) here 18 7 10.15 000176 Description(s) here 65 20 56.95 ... The last column in each row is a monetary...

ifort linker undefined reference

I'm compiling a large HPC system written in Fortran using the Intel compiler (ifort). There are about several hundred individual modules and they all compile fine, but the linker throws up this error: phys_grid.o(.text+0x91b2): In function `phys_grid_mp_assign_chunks_': : undefined reference to `_mm_idivrem_epi32' The _mm_idivrem_epi3...

How can I visualize Fortran (90 or later) source code, e.g. using Graphviz?

I've been thrown into a large Fortran project with a large number of source files. I need to contribute to this project and it would seem prudent that I first understand the source. As a first step, I'd like to visualize the interdependences between the various source files, i.e. which source files need which modules. As far as I can t...

OpenMP & MPI explanation

A few minutes ago I stumbled upon some text, which reminded me of something that has been wondering my mind for a while, but I had nowhere to ask. So, in hope this may be the place, where people have hands on experience with both, I was wondering if someone could explain what is the difference between OpenMP and MPI ? I've read the Wik...