Strange behaviour when using type(*) and character(*) in GFortran

Do you mean that it is against the standard to pass an unallocated variable as an actual argument to a dummy argument that is neither allocatable nor optional? I think I understand what you mean, but it worked in GFortran. Maybe it’s undefined behaviour?

Since many people have asked why would you need such a function, here’s what I do:
I’ve written a program that stores all arguments of a subroutine in a netCDF file. Since some arguments are deeply nested derived types, I automated the process by parsing the source code and generating function calls to my netCDF library. For each Fortran data type within the derived types, I generate the necessary variable definition (including its dimensions) and storage of each variable. (In some cases, there are over 100 individual variables). Sometimes, a derived type is passed to a subroutine where some members are not allocated because they aren’t used in the subroutine. My plan is to skip all unallocated variables, because the parser that generates the function calls has no way of knowing whether an allocatable variable is allocated or not.