I noticed recently that intel fortran, about version 15.0.X, has started warning about the length of interoperable character components:
warning #8753: A CHARACTER component of an interoperable derived type must have length 1. [LIBRARY]
character(kind=c_char,len=32) :: library = "some name"
The Standard does require that interoperable character variables have len=1, or in other words, a declaration like this: (I wish this worked.)
(1) character(kind=c_char, len=1) :: library(32) = "some name" ! Cannot actually initialize a character array like this.
Up to now, I've been skirting the question, because scalar character variables with len>1 "just work", at least for the compilers I'm mostly interested in using. So the perennial question that I haven't been able to answer is:
How do I assign a sensible default to a character array declared as in (1) above?
To be clear, the statement at (1) will compile, and will dutifully set library to 32 repetitions of the character 's'. Not sensible. Or I *could* do it like this:
(2) character(kind=c_char, len=1) :: library(32) = [ 's','o','m','e','','n','a','m','e' ]!(In reality, trailing blanks are necessary.)
Also not sensible. I have tried defining a pure function that converts a scalar string to an array, but the compiler seems to disagree about the legality of such a specification expression. Am I forgetting something obvious here? Default values are really kind of important. Thank you for any comments or guidance on this matter.