First I want to say the answer is not about something like optional or present.
I want to define a function that looks like write(*,*) .... As we see, the number of input variants can be arbitrary. If we use the optional keyword, we need to define all the possible inputs. Assume that we have 1000 (possible) inputs, what can we do?    
You can't do anything with simple subroutine or Fortran arguments. It is simply not possible. You can only use arguments that are defined in the function.
You will have to either place everything into an array, if the types of all inputs are the same, or you will have to create some more complicated derived types - maybe a polymorphic linked list or similar.
Note that what you ask for does exist in some languages (C variadic functions, for example), but it does not exist in Fortran.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With