Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [fortran]

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

0
votes
0answers
53 views

Calculate area of different geometric figures

I would like to write cleaner, reusable code in Fortran. Is the following piece of code a good way to implement generic functionality? Is the linebreaking and indentation ok? It should be Fortran90. ...
2
votes
0answers
26 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
0answers
44 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
132 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
1answer
51 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 ...
1
vote
0answers
65 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 ...
5
votes
1answer
942 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!} + \...
3
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: ...
8
votes
3answers
796 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 ...
3
votes
1answer
556 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 ...
6
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. ...
1
vote
2answers
403 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 ...
1
vote
2answers
115 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 ...
3
votes
1answer
185 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....
4
votes
2answers
208 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 ...
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 ...
12
votes
3answers
358 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 ...
4
votes
1answer
861 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 ...
3
votes
1answer
469 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 ...
12
votes
2answers
618 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). ...