GFortran error: ld: library not found for -lSystem when trying to compile

On macOS Big Sur v11.1: Relevant SO post: https://apple.stackexchange.com/questions/408999/gfortran-compiler-error-on-mac-os-big-sur The fix is to add the stdlib to your $LIBRARY_PATH. For some reason or another it isn’t in your standard $PATH anymore on 11.1. export LIBRARY_PATH=”$LIBRARY_PATH:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib” (or add it to login file and restart terminal).

Fortran OpenMP program shows no speedup of CPU_TIME()

cpu_time() takes the time on the CPU, not the walltime. In parallel applications these are not the same. See here for details. Using system_clock() solves this problem: PROGRAM MAIN use omp_lib implicit none REAL*8 Times1,Times2 INTEGER I,J, iTimes1,iTimes2, rate real, allocatable, dimension(:) :: a allocate(a(1000)) CALL system_clock(count_rate=rate) DO J = 1, 1000 a(j)=j ENDDO ! … Read more

Template in Fortran?

Fortran does not have templates, but you can put the code common to the functions handling different types in an include file as a kludge to simulate templates, as shown in this code: ! file “cumul.inc” ! function cumul(xx) result(yy) ! return in yy(:) the cumulative sum of xx(:) ! type, intent(in) :: xx(:) ! … Read more

How to pass allocatable arrays to subroutines in Fortran

If a procedure has a dummy argument that is an allocatable, then an explicit interface is required in any calling scope. (There are numerous things that require an explicit interface, an allocatable dummy is but one.) You can provide that explicit interface yourself by putting an interface block for your subroutine inside the main program. … Read more

Sending 2D arrays in Fortran with MPI_Gather

The following a literal Fortran translation of this answer. I had thought this was unnecessary, but the multiple differences in array indexing and memory layout might mean that it is worth doing a Fortran version. Let me start by saying that you generally don’t really want to do this – scatter and gather huge chunks … Read more

Why should I use interfaces?

As Alexander Vogt says, interface blocks can be useful for providing generic identifiers and allowing certain compiler checks. If you’re using interface blocks to create generic identifiers you’re probably doing so within modules, so the main reason to write such blocks when modules aren’t about is for the explicit interfaces that they create in the … Read more