What does `CHARACTER*(*)` mean?

I came across character*(*) in: https://github.com/Reference-LAPACK/lapack/blob/122506cd8b6ce050a200920c3d4c0b153b150fd8/SRC/xerbla.f#L79, what does it mean exactly?

I am familiar with the star notation, where for example in gfortran the declaration real*8 means real(kind=8), although in the former the 8 means the number of bytes, while in the latter it is a compiler specific kind designator (in gfortran they happen to both be 8 for double precision).

My understanding is that character*10 means character(len=10).

What does character*(*) mean?

From experimenting with gfortran it seems character*(*) means the same as character(len=*), which is the same as character(*), in other words, the extra star * in character*(*) is superfluous. Is that the case?

From further experimenting, character(*, kind=c_char) is allowed, but character*(*, kind=c_char) is not, which leads me to believe that character*(*) is a workaround for character** (which does not parse), in other words, it’s the length of the character, size * bytes. It is just a coincidence that the more modern approach is to use character(len=*, kind=c_char) and that it looks similar.

This is a weird part of Fortran syntax that dates to F77. You can say either:


Even more weird, you can do this:


and the (*) will take precedence. See in 18-007r1.

The CHARACTER* form is deprecated.


Yes, character*( * ) is an archaic form that means the same as character( * ).

1 Like

Thank you @kargl, @sblionel and @billlong. Everything is clear now.