Fortran intrinsic timing routines, which is better? cpu_time or system_clock

These two intrinsics report different types of time. system_clock reports “wall time” or elapsed time. cpu_time reports time used by the CPU. On a multi-tasking machine these could be very different, e.g., if your process shared the CPU equally with three other processes and therefore received 25% of the CPU and used 10 cpu seconds, … Read more

Arrays of pointers

Yeah, pointer arrays are funny in Fortran. The problem is that this: TYPE(domain),DIMENSION(:),POINTER :: dom does not define an array of pointers, as you might think, but a pointer to an array. There’s a number of cool things you can do with these things in Fortran – pointing to slices of large arrays, even with … Read more

Function in fortran, passing array in, receiving array out

With RESULT(FluxArray), fluxArray is the name of the result variable. As such, your attempt to declare the characteristics in the result clause are mis-placed. Instead, the result variable should be specified within the function body: function Flux(W1,W2) result(fluxArray) double precision, dimension(3), intent(in)::W1, W2 double precision, dimension(3) :: fluxArray ! Note, no intent for result. end … Read more