Skip to main content
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.

Filter by
Sorted by
Tagged with
1 vote
0 answers
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 - \...
SHR's user avatar
  • 11
4 votes
2 answers
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-...
user36313's user avatar
  • 143
2 votes
0 answers
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 ...
Touko Puro's user avatar
1 vote
1 answer
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 ...
David's user avatar
  • 11
1 vote
0 answers
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 ...
Xray25's user avatar
  • 21
2 votes
0 answers
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 ...
mp_def's user avatar
  • 21
1 vote
1 answer
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 ...
Marco Leonardi's user avatar
2 votes
1 answer
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 ...
Avii's user avatar
  • 121
1 vote
1 answer
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 ...
Fib's user avatar
  • 11
2 votes
1 answer
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 ...
H. Zhou's user avatar
  • 123
7 votes
1 answer
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 ...
Robert Bassett's user avatar
0 votes
2 answers
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 ...
SHdotCom's user avatar
8 votes
1 answer
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 ...
Robert Bassett's user avatar
0 votes
2 answers
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: ...
duality's user avatar
6 votes
1 answer
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 (...
tmph's user avatar
  • 337
1 vote
2 answers
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 ...
tmph's user avatar
  • 337
0 votes
0 answers
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....
Vítězslav Štembera's user avatar
0 votes
0 answers
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.
Daniel Bedard's user avatar
0 votes
0 answers
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. ...
Dark Knight45's user avatar
2 votes
1 answer
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 ...
user31765's user avatar
  • 101
2 votes
1 answer
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 ...
maxbear123's user avatar
3 votes
1 answer
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 ...
nougako's user avatar
  • 185
2 votes
1 answer
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." ...
yemino's user avatar
  • 515
1 vote
0 answers
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 ...
ALIN's user avatar
  • 11
1 vote
1 answer
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 ...
ipcamit's user avatar
  • 135
2 votes
3 answers
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 ...
Debasish Das's user avatar
0 votes
1 answer
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 ...
Elham Q's user avatar
  • 11
0 votes
0 answers
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 ...
Pruthvi Mehta's user avatar
4 votes
2 answers
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: ...
Not a chance's user avatar
-1 votes
1 answer
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(...
Pruthvi Mehta's user avatar
0 votes
1 answer
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 ...
Riri's user avatar
  • 43
0 votes
3 answers
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 ...
John Snow's user avatar
  • 139
1 vote
3 answers
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 ...
user157588's user avatar
2 votes
0 answers
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 ...
sequence's user avatar
  • 226
2 votes
1 answer
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 ...
V.J.'s user avatar
  • 21
2 votes
1 answer
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 ...
Mr Puh's user avatar
  • 123
1 vote
1 answer
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 ...
jecht300's user avatar
1 vote
2 answers
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 ...
user1887919's user avatar
1 vote
1 answer
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: ...
Insight's user avatar
  • 11
0 votes
1 answer
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 ...
Mr.Weathers's user avatar
2 votes
1 answer
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 ...
user30200's user avatar
2 votes
1 answer
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}...
John Snow's user avatar
  • 139
0 votes
1 answer
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 ...
Schneider's user avatar
1 vote
1 answer
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 ...
PCat27's user avatar
  • 11
4 votes
2 answers
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 ...
user32882's user avatar
  • 251
4 votes
1 answer
237 views

Compute bilinear form with LAPACK

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 ...
brubeck's user avatar
  • 63
2 votes
0 answers
75 views

Parallel compact schemes using the Parallal Diagonal Dominant (PDD) algorithm

I would like to use the PDD algorithm developed by Sun to solve tridiagonal matrices in parallel for the following compact finite difference scheme: $ \begin{align} \dfrac{1}{4}f^{'}_{i-1} + f^{'}_i +...
user26633's user avatar
5 votes
2 answers
295 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 ...
Simon Woodward's user avatar
1 vote
2 answers
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 ...
Varazda's user avatar
  • 133
1 vote
0 answers
114 views

Dealing with non-physical negative ODE solutions using ODEPACK

Hi and thank you all again. I am solving the reaction-diffusion-advection equation as follows $ \partial_{t} n\left(t,z\right) = -\partial_{z}\left(\Phi\left(t,z\right)\right) + p\left(t,z\right) -n\...
Juan Luis Gómez González's user avatar