Hot answers tagged

27 votes

Which version of Fortran should I learn?

It's a bit of a popular misnomer that there is a "version" of Fortran to know. With rare exception, the latest Fortran standards (and compilers) retain excellent backwards compatibility with older ...
user avatar
  • 2,213
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 ...
user avatar
12 votes
Accepted

Fortran 90/95: Deallocating variables

Fortran's allocatable variables are automatically deallocated when the variable goes out of scope (see http://www.fortran90.org/src/best-practices.html#allocatable-arrays). This means that it is not ...
user avatar
10 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 ...
user avatar
  • 861
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 ...
user avatar
9 votes

Use of Java or Scala in HPC?

Java has been around for almost 20 years now as a major programming language, but it hasn't caught on in scientific computing so far. I think that's a good indicator for what's going to happen in the ...
user avatar
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, ...
user avatar
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 ...
user avatar
  • 3,789
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. ...
user avatar
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 ...
user avatar
  • 5,744
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 ...
user avatar
7 votes
Accepted

How do Fotran77 and Fortran90/95 differ in performance via present-day compilers with array manipulation?

There is almost no good reason to write your own dense matrix manipulation routines until you have compared to fast libraries (MKL, FLAME, MAGMA, etc). Writing these libraries is challenging work that ...
user avatar
  • 10.8k
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. ...
user avatar
6 votes

Lua and Fortran (or Python) I/O

This is probably not the answer you are looking for, but I wanted to state it anyway: Your choice of programming languages introduces two difficulties you will encounter as your program grows. First,...
user avatar
6 votes

Use of Java or Scala in HPC?

It seems unlikely to me. The Java MPI APIs haven't been worked on in years (so you're wrong about #4), and the JVM's floating-point performance is notoriously poor. Java may out perform C/C++ or ...
user avatar
  • 10.8k
6 votes

Use of Java or Scala in HPC?

I would argue that Java will in fact REDUCE productivity when compared with modern c++, or even with modern Fortran for the purpose of scientific computing. Writing ...
user avatar
  • 2,473
6 votes
Accepted

precision loss in non-trigonometric, periodic functions using FFTW and NaNs after marching forward in time (Fortran)

There are three issues that are likely to cause such problems in pseudospectral methods: Gibbs oscillations Aliasing Time step too large In any case you likely develop oscillations in the solution ...
user avatar
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 ...
user avatar
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 ...
user avatar
  • 1,859
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 ...
user avatar
5 votes
Accepted

Using OpenMP in Fortran for common array operations

For the record, you might try putting an OpenMP worksharing region around your array operation syntax: !$omp workshare C=A+B Don't forget to build with OpenMP ...
user avatar
  • 10.8k
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 ...
user avatar
5 votes
Accepted

literature on scientific computing

Honestly, the best ideas have already been said. I'll try to synthesize my thoughts anyway. First, the best way to write a program is whatever way gives you the results you need, for the least ...
user avatar
  • 126
5 votes
Accepted

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

For a sparse parallel solver, it's your own responsibility to provide a matrix vector product and a suitable preconditioner. The data for the vector itself should fit into main memory in any case. If ...
user avatar
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 ...
user avatar
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 ...
user avatar
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-...
user avatar
  • 207
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 ...
user avatar
  • 1,779
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 ...
user avatar
  • 2,199
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{...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible