Questions tagged [fortran]
Fortran is a general purpose programming language widely used by the scientific computing community.
182 questions
4
votes
1
answer
394
views
Non-uniform Gaussian spaced vector
I am working on a Fortran code that uses a uniformly spaced grid in two directions (x,y). Which works fine, but when I need to study a certain problem with good resolution, I need to increase the ...
1
vote
0
answers
81
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 - \...
4
votes
2
answers
2k
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-...
2
votes
0
answers
91
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
1
answer
267
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
0
answers
100
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 ...
2
votes
0
answers
70
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 ...
1
vote
1
answer
225
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 ...
2
votes
1
answer
103
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
1
answer
94
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 ...
2
votes
1
answer
227
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 ...
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 ...
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 ...
8
votes
1
answer
834
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 ...
0
votes
2
answers
439
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:
...
6
votes
1
answer
865
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
2
answers
331
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 ...
0
votes
0
answers
106
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....
0
votes
0
answers
151
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.
0
votes
0
answers
24
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.
...
2
votes
1
answer
122
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 ...
2
votes
1
answer
135
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 ...
3
votes
1
answer
274
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 ...
2
votes
1
answer
1k
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."
...
1
vote
0
answers
277
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 ...
1
vote
1
answer
166
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 ...
2
votes
3
answers
639
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 ...
0
votes
1
answer
256
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 ...
0
votes
0
answers
116
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 ...
4
votes
2
answers
523
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:
...
-1
votes
1
answer
48
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(...
0
votes
1
answer
244
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 ...
0
votes
3
answers
694
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 ...
2
votes
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 ...
2
votes
0
answers
97
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 ...
2
votes
1
answer
691
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 ...
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 ...
1
vote
1
answer
841
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 ...
1
vote
2
answers
394
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 ...
1
vote
1
answer
528
views
Gaussian Elimination Using Fortran [closed]
I developed the code below for performing gaussian elimination in order to evaluate the determinant of a matrix:
...
0
votes
1
answer
128
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 ...
2
votes
1
answer
4k
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 ...
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}...
0
votes
1
answer
182
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
1
answer
721
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 ...
4
votes
2
answers
132
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 ...
4
votes
1
answer
254
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 ...
2
votes
0
answers
76
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 +...
5
votes
2
answers
297
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 ...
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 ...