Share Your Experience: Take the 2024 Developer Survey

# Questions tagged [fortran]

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

181 questions
Filter by
Sorted by
Tagged with
1 vote
60 views

### Calculating Lyapunov exponent for 3D system

I am trying to calculate the Lyapunov spectrum of a Lorenz model, \begin{align} \begin{split} \frac{dx}{dt} =& \sigma(y - x), \\ \frac{dy}{dt} =& x(\rho - z) - y, \\ \frac{dz}{dt} =& xy - \...
• 11
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-...
• 143
77 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 ...
• 131
1 vote
220 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 ...
• 11
1 vote
81 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 ...
• 21
62 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 ...
• 21
1 vote
210 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 ...
97 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 ...
• 121
1 vote
83 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 ...
• 11
195 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 ...
• 123
3k 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 ...
2k 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 ...
• 11
723 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 ...
309 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: ...
779 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 (...
• 337
1 vote
299 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 ...
• 337
91 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....
149 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.
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. ...
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 ...
• 101
128 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 ...
• 123
238 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 ...
• 185
992 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." ...
• 515
1 vote
249 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 ...
• 11
1 vote
160 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 ...
• 135
582 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 ...
247 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 ...
• 11
109 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 ...
444 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: ...
• 117
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(...
215 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 ...
• 43
652 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 ...
• 139
1 vote
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 ...
• 129
93 views

### Processing time steps in chunks with Fortran [closed]

My PDE simulation program written in Fortran has to make about 2 million variable time steps. But with each time step it slows down more and more, so that if it initially makes 1000 time steps per ...
• 226
658 views

### Testing a block tridiagonal system of equations

In 1D problems, tridiagonal systems of equations are obtained when we use finite-difference or finite-volumes in a structured mesh. A wide solver is the TDMA algorithm here. In two-dimensional ...
• 21
1k views

### What is good practice for protecting parent scope variables in Fortran?

So I just picked up a project that is written in fortran90. I am used to coding in python and C. What is really troubling for me is the use of subroutines in fortran90. In fortran people use ...
• 123
1 vote
781 views

### How to use LAPACK function (DGELSY) in Fortran

I am trying to use Least Squares Minimization to solve a the matrix problem: b = A*x for x. The system is overdetermined, and A is a dense matrix. In the LAPACK library, I believe the routine DGELSY ...
• 13
1 vote
375 views

### Second derivative using Fornberg finite difference method

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 ...
• 233
1 vote
504 views

### Gaussian Elimination Using Fortran [closed]

I developed the code below for performing gaussian elimination in order to evaluate the determinant of a matrix: ...
• 11
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 ...
• 101
3k views

### LAPACK equivalent on c++ , which is the best one? [duplicate]

I am following a course of computational material physics. The professor uses fortran to code and uses lapack to solve eigenvalue problems. So far I just know c++. There is an equivalent library that ...
2k views

### A robust algorithm to sort a non-convex polygon vertices

Let v_{0},...,v_{N-1} be N points in a Cartesian xy plane defining the vertices of closed polygon (i.e. v_{N} = v_{0}). Let P_{0}...
• 139
164 views

### Compute outward normal and surface area for 8 noded brick element in FEA

I have a cube which is divided into 8 small cubes by bisecting each edge, I am trying to find out the surface area of each of the faces and the corresponding outward normals for them. This operation ...
1 vote
698 views

### How write a integration loop in fortran, leapfrog scheme to solvind PDE (advection)?

I want to resolve numerically this equation using of difference finite method with Leapfrog Scheme $$\frac{\partial{u}}{\partial t}+ v \frac{\partial{u}}{\partial x}= 0$$ I'm trying to write a code ...
• 11
130 views

### Analytical testing/quality control for scientific software in professional setting

I am charged with maintaining a buildserver on Teamcity which is meant to test our in house FE software. Currently our test suite consists of a list of benchmarks which run every time a commit is made ...
• 251
I need to compute a bilinear form for a set of left and right vectors $$w_k = \sum_{i,j} V_{ik}^*A_{ij}U_{jk},$$ where $A_{ij}\in\mathbb{R}$ and $U_{jk}, V_{ik} \in \mathbb{C}$ (Assume that all the ...