How to increase array size on-the-fly in Fortran?

Here is a Stack Overflow question with some code examples showing several ways of using Fortran allocatable arrays: How to get priorly-unkown array as the output of a function in Fortran: declaring, allocating, testing for being already being allocated, using the new move_alloc and allocation on assignment. Not shown there is explicit deallocation, since the … Read more

How to override a structure constructor in fortran

Is it currently possible to override the structure constructor in Fortran? No. Anyway even using your approach is completely not about constructor overriding. The main reason is that structure constructor # OOP constructor. There is some similarity but this is just another idea. You can not use your non-intrinsic function in initialization expression. You can … Read more

Fortran intent(inout) versus omitting intent

According to The Fortran 2003 Handbook by Adams, et al., there is one difference between an intent(inout) argument and argument without specified intent. The actual argument (i.e., in the caller) in the intent(inout) case must always be definable. If the intent is not specified, the argument must be definable if execution of the subroutine attempts … Read more

Difference between intent(out) and intent(inout)

intent(inout) and intent(out) are certainly not the same. You have noted why, although you don’t draw the correct conclusion. On entering the subroutine useless a is undefined, rather than defined. Having a variable “undefined” means that you cannot rely on a specific behaviour when you reference it. You observed that the variable a had a … Read more

STL analogue in Fortran

There are no templates in Fortran and hence no STL. You can try FLIBS for some generic libraries. It generally uses transfer() tricks to achieve generic programming. There is a preprocessor which adds some templates to Fortran and comes with some small STL, you can try that too named PyF95++. If you have access to … Read more