14
votes
Accepted
How to compare runtimes of two algorithms in a reproducible way
To make more robust comparisons (on linux), you can :
1) On Intel CPUs the turbo overclocks your CPU. This is controlled by the temperature of the CPU, so it can behave differently from one run to ...
11
votes
Accepted
What is the difference between MATLAB and FORTRAN?
When one uses a low–level programming language, e.g. C++ or FORTRAN, one essentially controls lots of things: how parameters are passed, how data structures are aligned in memory, what is the most ...
10
votes
Accepted
Accuracy loss in single-precision Euclidean norm computation
The squares are harmless (as long as they don't overflow/underflow), because the relative perturbation they introduce is of the order of the machine precision $u\approx 10^{-8}$. Your troubles here ...
9
votes
Accepted
Linear interpolation in Fortran
There is no built-in Fortran functionality to do linear interpolation. You could either use a library or write your own routine. I haven't tried compiling or testing and my fortran may be a bit rusty, ...
9
votes
Accepted
Loop optimization with f2py, Cython and Numba
I think that the problem is linked to the way in which f2py generates the fortran interface: the argument to fortranrun.f2py should be stored as a F_CONTIGUOUS ...
9
votes
Recommended language/environment for large scale semi-continuous biological models
You should consider giving Julia a try. Let me explain what's going on in the design space right now that would be of interest to you. Full disclosure I am the lead developer of JuliaDiffEq.
...
8
votes
What is the difference between MATLAB and FORTRAN?
In general, you will be much more productive writing software in a higher-level
language (e.g MATLAB) that has features useful in describing problems in your particular
domain (e.g. matrices in ...
8
votes
Why there are people that still prefer fortran 77 over new versions?
I think it's generally true that there are no advantages of Fortran 77 over either newer versions of Fortran or in fact any number of other programming languages that are widely used in scientific ...
7
votes
Why Is This Python Code Faster Than Fortran Wrapper with F2PY?
Shoutout to Kyle Mandli and Endulum who each contributed to this answer in the comments.
First, I took Endulum's suggestion and removed the redundant reshapes. ...
6
votes
Fortran code for Ewald summation
Notice that the summation in $U^{(r)}$ is incorrect. You want to sum over all the copies of the atoms in the lattice of periodic boxes, not just those whose indices satisfy $i > j$. In the ...
6
votes
Accepted
computing turbulent energy spectrum from isotropic turbulence flow field in a box
One issue causing the jagged spectra at high wavenumbers is under sampling there. For example consider the 2D analogue of your binning procedure:
You don't want to sample from the red zones as they ...
6
votes
How do I program periodic boundary conditions?
Typically, you would add "guard cells", that is (for u) u(-1) and u(n+1) with your notation. Before each integration step:
u(n+1) = u(0)
u(-1) = u(n)
and ...
5
votes
Fortran code for Ewald summation
The National Institute of Standards and Technology (NIST) proposes different inputs and outputs to test your implementation. Have a look there:
https://www.nist.gov/mml/csd/chemical-informatics-...
5
votes
Finite element library in fortran
I would recommend writing your own code using PETSc. The most complex part of a parallel FE code is parallel assembly and solve and PETSc takes care of both. The latest version of PETSc also has ...
5
votes
Accepted
Finite element mesh software
I'd say Gmsh. I used it for a few finite element projects, and it was mostly easy to work with. The mesh output formats are very parseable, and there's at least one third-party parser (MeshPy) that ...
5
votes
Efficently invert tiny matrix in Fortran
Here are the routines we use in QMC=Chem for small matrices. QMC=Chem is under GPL license, so if your code is also under GPL, you can use them.
EDIT: To get the inverse, you need to multiply the ...
5
votes
How do I write dimensionally agnostic code?
The clear answers if you want to keep Fortran speed are to use a language which has proper code generation like Julia or C++. C++ templates have already been mentioned, so I'll mention Julia's tools ...
5
votes
Accepted
derivative of an array
Purely in terms of terminology, it's probably better to talk about taking discrete partial derivatives of variable fields stored in an array, rather than differentiating an array itself.
Regarding ...
5
votes
Accepted
implementation of a simple SPH example
The SPH implementation of the function in your question reads as:
$f(x,y)=\frac{1}{2}\big(\frac{\partial x}{\partial x}+\frac{\partial y}{\partial y}\big)=\frac{1}{2}\nabla\cdot\textbf{r}\approx\frac{...
5
votes
Accepted
What is good practice for protecting parent scope variables in Fortran?
There are several tools to make a codebase more structured. In your example, the subroutine within big() is called without arguments, but changes something in the outer scope, as you said. To prevent ...
5
votes
More stable method of back substitution?
Back-substitution is backward stable, and this implies that its error is of the same order as the error induced by truncation of the input data to machine precision, (machine precision)x(condition ...
5
votes
Accepted
ifort: everithing ok, but with gfortran: segmentation fault
The variable c isn't initialized anywhere in the program, so the value that it will have at runtime can be anything.
Here I've entered a slight modification of the ...
5
votes
Accepted
Shall I use global, heap allocated array or local, stack allocated one if references to its elements are made too many times?
TL,DR: Leave it on the heap, but switch your loop order.
For starters, the program stack has fairly limited space.
If you're making arrays that large, I'd be very surprised if it fit on the stack.
...
5
votes
Causes for different results for different number of nodes in MPI
There is no way for anyone to tell you where the issue comes from without access to the actual code. But here are common reasons why the output (legitimately) differs for different numbers of ...
5
votes
Eigen C++ Library Over 4x Slower than Fortran
Despite my initial conviction that I was including all relevant compiler flags, in fact I wasn't. I forgot the -fopenmp flag on the C++ compiler, which enables ...
4
votes
Which package should I use to wrap Modern Fortran Code with Python?
f90wrap is build on top of f2py and automatically generates the Python wrappers for the underlying Fortran code base, including access to derived types. A set of simple examples show how it works.
4
votes
Accepted
Meshing options to generate number of the sides of and element (tetgen-triangle)
I have implemented a method that works pretty well for reconstructing edge information in surfacic meshes (or facet information in volumetric meshes), but I am working in C++. I'll try to explain that ...
4
votes
Accepted
What do C, C++ and Java have that Fortran 2003 don't?
One thing that C++ includes that Fortran doesn't have is extensive support for generic programming and compile-time code ...
4
votes
What is the difference between MATLAB and FORTRAN?
There are already very good answers, and I want to add only two aspects:
Vendor Lock:
If you choose Matlab or similar Packages (Mathematica etc.), you chain yourself to that vendor. Many ...
4
votes
Why there are people that still prefer fortran 77 over new versions?
In general the features that are being removed from the language are either pointless or dangerous, so I'd definitely recommend you may sure you write new code to compile under a later standard, even ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
fortran × 179performance × 15
parallel-computing × 14
mpi × 14
numerics × 12
lapack × 12
python × 11
c++ × 11
fluid-dynamics × 10
c × 9
finite-element × 8
matrix × 8
linear-algebra × 7
pde × 7
finite-difference × 7
computational-physics × 7
hpc × 7
algorithms × 6
linear-solver × 5
sparse-matrix × 5
simulation × 5
random-number-generation × 5
compiling × 5
ode × 4
computational-geometry × 4