In 2020, Fortran 2018 features are still not completely supported by
compilers. Therefore, the Fortran code of this project keeps some pre-F2018
features. They can be removed later (say, in 2025) if compilers implement
Fortran 2018 better at that time.

The pre-F2018 features include the following.

1. (Must update) Since F2018, ERROR STOP statement can appear in a pure subprogram. Therefore,
ERRSTOP can be implemented as pure subroutines. Consequently, all functions can be pure!
ERROR STOP is available since F2008.
Note that the MATLAB version of ERRSTOP uses the mexErrMsgIdAndTxt subroutine of MathWorks and hence
cannot be declared pure. Thus the "pure" attribute has to be removed when refactoring the code the
mexification, after calling interform.m.

1. (May update) We do not take advantage of the "automatic allocation upon intrinsic assignment"
feature for ALLOCATABLE variables (NOT POINTERS). This is available since F2003.

For example,

real, allocatable :: x(:)

call safealloc(x, n)
x = y  ! y is an array of size n

can be replaced by

real, allocatable :: x(:)

x = y ! Automatic allocation upon intrinsic assignment

HOW TO FIND: search for 'safealloc' and 'fmxAlloc'

N.B.: Not all allocation can be removed!
1. Automatic allocation does not happen for POINTERs.
2. Another example:

real, allocatable :: x(:)
integer :: n

allocate(x(n))
do i = 1, n
    x(i) = real(i)
end do

However, the above example can be simplified to the following without ALLOCATE using implicit loop:

real, allocatable :: x(:)
x = [(real(i), i = 1, n)]

3. (May update) Related to 2: explicit deallocation v.s. automatic deallocation (maybe we should
stick to the former). In F2003, automatic deallocation happens to allocatable objects when they go
out of scope. However, we prefer to deallocate them explicitly and immediately after they finish
their mission. In addition, as of 20220331, automatic deallocate may not be well implemented in some
compilers, (even) including gfortran. See
https://fortran-lang.discourse.group/t/best-practice-deallocating-allocatable-arrays-explicitly-vs-implicitly
