Question about old-style declarations

We have been trying to get rid of old-style constructs, declarations and non-standard features in our code, using compiler options. I was surprised to see that neither Intel Fortran oneAPI or gfortran flag the declaration for variable string2 in this little program. They both flag the declaration of string1.

program chkchar
    implicit none

    character*20 :: string1
    character    :: string2*20

    string1 = '1 '
    string2 = '2 '

    write(*,*) string1, string2

end program chkchar

Is there a reason this is not flagged, for instance, this form is not marked as obsolescent?

That is correct, the * char-length in an entity-decl (R803 of J3/24-007) is not obsolescent. The * char-length in a length-selector (R722 ibid.) is obsolescent.

Thanks for the explanation. I find that a trifle amazing, but there it is :slight_smile:

The non-obsolescent feature enables statement like Character :: a, b*10, c*(N+M), x*(:), z*(*) which would take many statements to write otherwise.

2 Likes