Difference between Fortran’s “abstract” and “normal” interfaces

The “normal” interfaces — known by the standard as specific interface blocks (as you use in the title of the question) — are just normal interface blocks for some procedure. Therefore: interface subroutine foo_sub end subroutine end interface means that there exists an actual (external) subroutine named foo_sub and it conforms to the specified interface. … Read more

Difference between local allocatable and automatic arrays

For the sake of clarity, I’ll briefly mention terminology. The two arrays are both local variables and arrays of rank 1. alloc_array is an allocatable array; automatic_array is an explicit-shape automatic object. Being local variables their scope is that of the procedure. Automatic arrays and unsaved allocatable arrays come to an end when execution of … Read more

Having parameter (constant) variable with NaN value in Fortran

To add to Vladimir F’s answer I’ll mention that gfortran 5.0 (but not earlier) supports the IEEE intrinsic modules. Instead of real x x=0 x=0/x one can use use, intrinsic :: iso_fortran_env use, intrinsic :: ieee_arithmetic integer(int32) i real(real32) x x = ieee_value(x, ieee_quiet_nan) i = transfer(x,i) This gives you a little flexibility over which … Read more

Fortran polymorphism in pointers

When you have polymorphism like this there are two things to consider about an object: its dynamic type and its declared type. The parameters component of test_mask (base_mask) is declared as class(base_pars),pointer :: parameters Such a component therefore has declared type base_pars. Come the pointer assignment mask_test%parameters=>par_test mask_test%parameters has dynamic type the same as par_test: … Read more