Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Character Declaration

Blane_J_
New Contributor I
649 Views

In the topic "Declarations of Character Types" of the IVF users reference, it says:

The form CHARACTER*(*) is an obsolescent feature in Fortran 95.

I'm puzzled with the saying "CHARACTER*(*)". The question is elementary maybe, but does it mean the form of old FORTRAN standard " CHARACTER*(some_len_things)" or the * Length Character Syntax which is to be removed from the future standard ?

0 Kudos
8 Replies
mecej4
Honored Contributor III
649 Views

It may be best if you forget that this form ever existed. Some old forms of Fortran may look bizarre today, until one notes that when Fortran was born computer character sets were quite small and symbols often had to be used for more than one purpose. 

Since you asked, here is an example that illustrates the old notation. You want a subroutine that takes a character string as an argument and prints the length of the string. The subroutine may be called from various places with strings of various lengths.

subroutine sub(str)
character*(*) str
write(*,*)len(str)
end subroutine

Look at the second line. The first '*' separates the type from the length specification, as in INTEGER*2. The second '*' means 'take the length from the argument at run time'. The parentheses are there because without them the expression might mean 'raise the variable to the str-th power'.

0 Kudos
Steven_L_Intel1
Employee
649 Views

"CHARACTER*(*)" is the exact syntax term - the * characters are what you would type. This form is obsolete - the preferred syntax is "CHARACTER(*)" or "CHARACTER(LEN=*)". The feature of "assumed-length", where the length comes from what is passed in, is still standard.

0 Kudos
IanH
Honored Contributor II
649 Views

I thought the OP was just subtly pointing out that the ifort docs were incomplete - CHARACTER*(*) is a fairly specific example of what's obsolescent as of F95 - the docs instead should probably call out all of the "nonkeyword" forms of the type spec (but not the equivalent star business in entity decls).
 

0 Kudos
Steven_L_Intel1
Employee
649 Views

Sorry, Ian, I am missing something here. If by "nonkeyword style" you mean INTEGER*4, etc., those have never been standard. The CHARACTER* form, specifically, is obsolescent (and still is, it has not been deleted.)

0 Kudos
IanH
Honored Contributor II
649 Views

I was referring to the terminology in the ifort documentation for "Declarations for Character Types" - https://software.intel.com/en-us/node/525492. ; It currently only calls out CHARACTER*(*) as obsolescent, but it should also call out "CHARACTER*1, CHARACTER*2, CHARACTER*3, ..., CHARACTER*(a+b), CHARACTER*(a-b), ..."

 

0 Kudos
JVanB
Valued Contributor II
649 Views
In the following example, a dummy argument strh will assume the length of the associated actual argument, while the other two variables retain a length of 8:
CHARACTER *8 strg, strh(*), stri 

;)

0 Kudos
Blane_J_
New Contributor I
649 Views

Thank you for all your replies. I think the FIRST situation I assumed in the question in #1 should be the result . As lan mentioned above, I also consider a misunderstading would happen due to the ambiguous meaning of the " CHARACTER*(*) " saying. Some improvement may help I think anyway.

0 Kudos
Steven_L_Intel1
Employee
649 Views

Got it - thanks, and relayed to our writers.

0 Kudos
Reply