# Questions tagged [fortran]

Fortran is a general purpose programming language widely used by the scientific computing community.

180 questions
Filter by
Sorted by
Tagged with
1k views

### Small quadratic programming problem - a simple Fortran code needed

I need to find a distance from a point in 3D space to a parallelepiped (a crystal lattice cell). The problem boils down to a quadratic programming task: Let $L$ be a matrix of lattice vectors (row-...
1 vote
202 views

### Differential equation for radioactive cooling in fortran

Today I'm trying to evaluate this differential equation for internal energy in a gas in Fortran: $$\frac{du}{dt} = - \frac{n_H^2}{\rho}\frac{\Lambda}{n_H^2}$$ Where nH is the density of hydrogen in ...
148 views

### Windows Fortran compiler for legacy Finite Element (1980) code?

The version of Fortran used comes from Montreal Ecole Polytechnique in 1980. I need a compiler for Fortran for Windows 7 or Windows 8.
75 views

### OpenMP Fortran array operations in target regions

I am asking this here for the possibility that someone here is familiar with OpenMP offloading. Is there some other way to parallelise Fortran array operations outside of unrolling the loops of the ...
1 vote
207 views

### How to get the inverse FFt in this Fortran code?

I find this fft algorithm on the link The code looks simple and easy to implement. But it does not have inverse fast Fourier transformation. A brief search on the internet shows that to get the ...
1 vote
80 views

### Fortran - Lid-Driven Cavity Boundary Conditions Error when using SIMPLE method

I am studying Numerical Methods for incompressible flows. part of the tasks is to model the lid driven cavity problem in 2D using the SIMPLE method. I have been provided with Fortran code that is ...
61 views

### Losing memory on each call to scalapack solve function

I am solving a large system of equations using scalapack. Some systems that should run with no problem failed, apparently due to lack of memory in an mpi call. After investigating with ...
8k views

### What is the difference between MATLAB and FORTRAN?

In our university some Ph.D students for computational methods prefer FORTRAN over MATLAB. I can't understand why? What is the difference between them when are used in computational methods like ...
54k views

### Python vs FORTRAN

Which one is better: FORTRAN or Python? And I guess that in both cases you need Gnuplot, am I right? I'm working on a Windows machine at the moment. I'd like to use it to get numerical solutions for ...
92 views

### Interpolation of 1D solution from an original grid to a new grid

I have a solution of a 1D wave on a grid (tangent hyperbolic variation) and now I want to interpolate the obtained solution to a new grid with the same number of points as the previous grid but the ...
1 vote
77 views

### FORTRAN coding question [closed]

I am contacting research and I came across an algorithm in FORTRAN, with which I am not familiar. For the code above I have two questions: What does "DO 1 (...)" mean? I see that there is ...
190 views

### Accuracy loss in single-precision Euclidean norm computation

I do hydrodynamics simulations with Fortran and recently I met with this issue: I have a single-precision array b of length ...
540 views

1k views

### How do I write dimensionally agnostic code?

I often find myself writing very similar code for one, two, and three dimensional versions of a given operation/algorithm. Maintaining all of these versions can become tedious. Simple code ...
241 views

### Solving sparse linear equations with an iterative, out-of-core algorithm

Is there an iterative sparse parallel linear equation solver with out-of-core capabilities? I need to solve a very large system of equations. I have implemented direct sparse parallel solvers in-core ...
2k views

### Eigen C++ Library Over 4x Slower than Fortran

I am experimenting with ways to call compiled programs from Python. My primary interest is iterative optimization methods, so I'm testing an implementation of Newton's method to solve a logistic ...
1 vote
2k views

### Using OpenMP in Fortran for common array operations

In Fortran, given arrays A(1000000) and B(1000000), and to compute the sum you simply write: C = A + B However, when I want to implement OpenMP, I have to write ...
2k views

### Solving coupled ODEs using Runge-Kutta method

I want to solve the following sets of $n$ coupled equations. Initial values of $x_{n}(t)$ and $p_{n}(t)$ are specified. The problem is, I have an 1D lattice where every particle is bound with ...
1k views

### Are C++ and FORTRAN low or high -level programming languages?

In this post, they mentioned that C++ and FORTRAN are low–level programming languages. However, In other references, they consderd these language as a high-level programming languages. Which one is ...
676 views

### Why Is This Python Code Faster Than Fortran Wrapper with F2PY?

I am writing a proof-of-concept implementation of Newton's method for minimizing the negative log-likelihood term in a logistic regression model. I'm comparing the performance of a native python ...
2k views

### How to Run MPI-3.0 in shared memory mode like OpenMP

I am parallelizing code to numerically solve a 5 Dimensional population balance model. Currently I have a very good MPICH2 parallelized code in FORTRAN but as we increase parameter values the arrays ...
269 views

### Fortran: Can a procedure, contained in a module, call another procedure contained in the same module? [closed]

For instance, consider a module with the following general structure: ...
716 views

### Causes for different results for different number of nodes in MPI

I am trying to develop what might be called legacy Fortran code from my group. Upon testing, I found that the program (which takes about a day to run on 20 processes) works when run on a single node (...
1 vote
286 views

### Affecting parts of an array outside MPI process efficiently

This was originally asked on Stackoverflow but instead of migrating it was suggested I repost here and delete that one. I've tried to clarify based on comments there. I'm new to MPI, but I am trying ...
564 views

### How to begin writing scientific codes in C++ in Trilinos or PETSC style?

My background: I have taken some courses on numerical analysis during my PhD and read a few books on the topic as well. I mostly work on low Reynolds number fluid mechanics and use boundary element ...
49k views

### C++ vs Fortran for HPC

In my computational science PhD program, we are working almost exclusively in C++ and Fortran. It seems like some professors prefer one over the other. I am wondering which one is 'better' or if one ...
90 views

### Sparse linear solver in fortran working with REAL16

I need some (direct) sparse linear solver for fortran, which works with REAL16 data type. Any suggestions? Both Pardiso and MUMPS support only REAL8. (identical question: https://math.stackexchange....
23 views

### How to convert this code to scan random datas instead of binned datas?

I am new to Fortran and I am trying to write a code using random data instead of binned data in x, y, z as shown in my sample code. ...
21k views

### How much better are Fortran compilers really?

This question is an extension of two discussions that came up recently in the replies to "C++ vs Fortran for HPC". And it is a bit more of a challenge than a question... One of the most often-heard ...
635 views

### Parallel output in ASCII-format with MPI

After some parallel computations, I need to write the results in a file and for plotting reasons, I want them in ASCII format. Because of performance issues, I want to avoid to ...
1 vote
155 views

### How to debug segmentation faults in large problems?

I am sorry if this question seems like off topic or opinion based, but I was not sure how to go about it. I am currently working on a 100k x 100k positive definite linear system and trying to solve it ...
118 views

### Best practice for ADTs in computational science with Fortran

I have been writing a software package in Fortran for solution of the Vlasov-Poisson system in 2D2V. I want this software to be useful beyond its current application (e.g. systems with different ...
2k views

### Are there open-source scientific libraries which use modern Fortran with OOP?

I've spent the last couple of months on coding a Fortran program for solving a particular PDE system (describes fluid flow/combustion). I tryed to use latest-standard Fortran and the new OOP ...
1 vote
2k views

### implementation of a simple SPH example

I am currently learning the Smoothed Particle Hydrodynamics method that I need to use later in my thesis. I have studied the mathematics behind the method and I want to code a simple example to show ...
126 views

### Trouble Making 3rd-Order Sympletic Integrator for Planitary N-Body Problem (A Hamiltonian System)

I am doing a solar-system simulation. I am using Ruth's 3rd order sympletic integrator to avoid the problem of Energy Drift (which I had with RK4), but the the planets quickly leave orbit, and energy ...
225 views

### Shall I use global, heap allocated array or local, stack allocated one if references to its elements are made too many times?

I actually have this data locality as a possible problem for why my fortran program runs somewhat slow. In one part of this program, I have nested loops and throughout these loops, a given section of ...
950 views

### ifort: everithing ok, but with gfortran: segmentation fault [closed]

In the following code, if I compile using ifort runs ok, but if I run it with gfortran appears the error: "Program received signal SIGSEGV: Segmentation fault - invalid memory reference." ...
120 views

### Access PETSc data in totalview?

Is it possible to view the data stored in the various PETSc data types from within totalview? Ordinarily, PETSc types are integers which act as pointers to the actual data (obviously my understanding ...
1 vote
242 views

### Fortune algorithm for voronoi diagram

Although there are many algorithms to construct Voronoi diagram, some of them are faster than others. Based on my knowledge Fortune algorithm is fastest for construct Voronoi diagram either in two ...
293 views

### Recommended language/environment for large scale semi-continuous biological models

We have a fairly large (maybe 1000 equations) differential-algebraic equation model written in ACSLX, an obsolete modelling environment similar to Modelica. The model represents the evolution of a ...
9k views

### F2Py with allocatable and assumed shape arrays

I would like to use f2py with modern Fortran. In particular I'm trying to get the following basic example to work. This is the smallest useful example I could ...
245 views

### Two RK4 method in one program

I want to solve this integral using RK4 by coding in Fortran: $$R=∫1/a(t) dt → dR/dt=1/a(t) =f(t)$$ Initial point: t=0 (or a=0.001) and R=0 And I have to get a(t) by solving another ...
106 views

### Create random number generator from a top hat distribution

How would I use a random number generator to give random numbers from a top hat distribution in Fortran? I've seen lots of information about how to make a Gaussian random number generator, but not one ...
425 views

### More stable method of back substitution?

I've been tinkering a little in Fortran (2008) and wrote the following to solve $Rx=b$ for $R\in\mathbb{R}^{n\times n}$ upper-triangular, $x,b\in\mathbb{R}^n$. My code looks like this: ...
46 views

### Why does this line of code give a flat distribution?

I'm struggling to understand a line of FORTRAN code and was hoping someone on here would be able to help me out. These lines of code are meant to generate a flat distribution - I understand that GRNDM(...
207 views

### Library to solve dense linear system with GMRES

I have a fortran 90 code and I want to solve a dense linear system with GMRES. I would prefer the restarted GMRES with preconditioning. Is there some library that you know of that I could use? Now I ...
21k views

### Intel Fortran Compiler: tips on optimization at compilation

I will start with my personal experience in our lab. Back in the ifort 9 and 10 days, we used to be quite aggressive with the optimizations, compiling with -O3 and processor specific flags (-xW -xSSE4....
I have some discrete data, non-equispaced in $x$, $y=f(x)$. I want to use a numerical finite difference method to calculate the second derivatives of $y$, at some point. I am using the Fornberg ...