Questions tagged [fortran]

Fortran is a general-purpose, procedural, imperative programming language that is especially suited for numeric computation and scientific computing.

Filter by
Sorted by
Tagged with
12
votes
2answers
623 views

Extracting a set of numbers from a file

I do most of my programming in C/C++ and Perl, but I currently learning Fortran. I began by coding up a simple program, something that took me < 5 minutes in Perl (see this thread from BioStar). ...
12
votes
3answers
402 views

FizzBuzz vs. FortRan

In keeping with using FizzBuzz as an introduction to a language, I present FizzBuzz with a Fortran95 twist: For multiples of 3, print Fort, and for 5's multiples ...
8
votes
3answers
947 views

1D shock tube problem written in Fortran

I have written a simple Euler solver for the 1D shock tube problem. Eventually, I plan to extend this code to solve the full 3D compressible Navier-Stokes equations. Therefore, I want to start with ...
7
votes
2answers
3k views

Calculator in FORTRAN

This is my first step into Fortran. The program aims to provide a simple way of calculating numbers. Just looking for improvements in general. ...
5
votes
2answers
158 views

Efficient communication across multiple processors for finite elements

I am implementing finite element code using MPI. Obviously, when using MPI I will have to include communication between different nodes so that all processors have all relevant information. As this is ...
5
votes
1answer
1k views

Computing exponential function by Taylor Series without overflow

The original question is to write a Fortran program to compute the sum of the first 20 terms in the exponential equation (for x=1,2,3,4,5): $$\sum_{n=0}^\infty \frac{x^n}{n!} = 1 + \frac{x^1}{1!} + \...
4
votes
2answers
229 views

Increase performance of a spate of 2x2 matrix multiplication

I would like to improve the performance of the piece of code below (in Fortran). It gives good results but the profiling tells me that it is where it spends most of its running time. Basically, it ...
4
votes
1answer
481 views

High performance exponential of a skew Hermitian matrix in Fortran 95

I'm new to Fortran, and this is pretty much my first escapade. Below is a function that I wrote which relies on calls to LAPACK. The function is sat in a module with some other functions and works ...
4
votes
1answer
877 views

Gees - GPL Euler equation solver

As a little helper I recently had to write a code that solves the 1-D Euler equations. As it serves my purpose well I though others could make use of it as well. The homepage of the code can be found ...
4
votes
1answer
2k views

Implementing the Barabási–Albert model

I am writing a code for Barabási–Albert(BA) model with specific node and edges. The algorithm is almost like [1] as follows: ...
4
votes
1answer
659 views

Linear shooting method to solve a B.V.P

I have wrote a code to approximate the solution of a boundary value problem: x'' = p(t)x'(t)+q(t)x(t)+r(t) x(b) = beta in [a,b] by using Runge-Kutta method ...
4
votes
0answers
37 views

Lightweight lock using OMP atomic

I am working on a Monte Carlo simulation using OpenMP multithreading. To avoid race conditions when multiple threads work on the same resolution element, I have implemented the following ...
3
votes
1answer
202 views

Reimplementing numpy.genfromtxt in Fortran for Python

I've found that the function genfromtxt from numpy in Python is very slow. Therefore I decided to wrap a subroutine with f2py to read my data. The data is a matrix....
3
votes
1answer
83 views

Reverse quick sort in Fortran

I have written a quick sort routine to inplace sort an array in descending order: ...
3
votes
1answer
45 views

Fortran 90 / openmp heat transfer simulation optimization

I'm a newbie playing around with Fortran 90 and openmp and wrote the code below (a simple 2D heat transfer simulation) for testing purposes. So far I don't see any speedup by using openmp / parallel ...
3
votes
0answers
84 views

Passing file identifiers to all subroutines of fortran code

The Fortran program 'MAIN' below calls 3 subroutines. It opens a file if it is not present, (overwrites if it is already present). writes something on the file using the file identifier integer and ...
2
votes
2answers
446 views

Monte Carlo Pi with R + Fortran + MPI

I created a R package to calculate Pi with a Monte Carlo simulation. My goal is to optimize the parallel function SnowPi as much as possible. This is the ...
2
votes
1answer
64 views

Improving performance of a subroutine that checks for a vacancy in a lattice

I use the following subroutine to check whether a small subsection of a 3D Int array is all equal to zero. If any value in the particular subsection is non-zero, I exit and return ...
2
votes
0answers
71 views

Reversing a file in Fortran

This is my first foray into (modern) Fortran in order to learn a bit more about the language, and I'm attempting the following problem: taking the path of an arbitrarily-sized text or binary file ...
1
vote
2answers
117 views

Smearing estimate with Fortran

I wrote this Fortran module and I need its subroutines to run as fast as possible. My hope is to get some advice to optimize this code, and after having the serial version running as fast as it can ...
1
vote
2answers
150 views

Checking whether two lists contain the same elements

I have two lists of numbers: $$\{i_1, i_2, i_3,i_4\}$$ and $$\{j_1,j_2,j_3,j_4\}$$ The problem I want to solve is: Inside a loop, if the following two conditions are satisfied, then it will do ...
1
vote
0answers
71 views

Array initialization inside function to be called repeatedly

I have written a Fortran95 function that will be called many times in a loop. A much reduced version of it, called myFunction, is below. Examples of its use is ...