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

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

changing array dimensions in fortran

See the RESHAPE intrinsic, e.g. http://gcc.gnu.org/onlinedocs/gfortran/RESHAPE.html Alternatively, if you want to avoid the copy (in some cases an optimizing compiler might be able to do a reshape without copying, e.g. if the RHS array is not used afterwards, but I wouldn’t count on it), as of Fortran 2003 you can assign pointers to targets of … Read more

What is an undefined reference/unresolved external symbol error and how do I fix it in Fortran?

A link-time error like these messages can be for many of the same reasons as for more general uses of the linker, rather than just having compiled a Fortran program. Some of these are covered in the linked question about C++ linking and in another answer here: failing to specify the library, or providing them … Read more

tech