Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

Hull and Outfitting

CHARACTER Handling

  • Last UpdatedNov 07, 2025
  • 1 minute read

The handling of character variables is the most significant difference between FORTRAN 66 and FORTRAN 77.

Whenever character arguments are passed into a DARs routine, the routine will ignore any trailing blanks. Character arguments returned by a routine are padded with blanks to the end of the character string. A returned character argument will never be undefined. A blank string ' ' will be returned as a 'minimum' ('blank' as distinct from 'null').

Programmers should be aware that an assignment such as the following will result in a character string 'ABC ';; that is, 'ABC' followed by seven blanks. This is true even if CD3XYZ previously contained more than three non-blank characters.

CHARACTER*10   CD3XYZ

.

.

CD3XYZ =   'ABC'

Whilst the string 'ABC ' is interpreted the same as 'ABC', the string ' ABC' will not be.

If the programmer wishes to know the significant length of a returned string (for example, the significant length of 'ABC ' is 3), they may use the general utility function D3ULEN.

for example,

EXTERNAL D3xxxx, D3ULEN

INTEGER D3ULEN, NC

CHARACTER*10 CD3XYZ

CALL D3xxxx(.........,CD3XYZ,.....)

PRINT *, CD3XYZ(1:D3ULEN(CD3XYZ)), ' returned'

or

NC = D3ULEN(CD3XYZ)

PRINT *, CD3XYZ(1:NC), ' returned'

would print

ABC returned

rather than

ABC returned

This could be embellished by constructions such as:

IF (D3ULEN(CD3XYZ).EQ.0) THEN

PRINT *, 'blank string returned'

ELSE

.....

ENDIF

TitleResults for “How to create a CRG?”Also Available in