next up previous contents index
Next: Procedures as Arguments Up: Arrays as Arguments Previous: Array Sections

Character Arrays

    When a dummy argument is a character array the passed-length mechanism can be used in the same way as for a character variable. Every element of the dummy array has the length that was passed in from the actual argument.

For example, a subroutine designed to sort an array of character strings into ascending order might start with specification statements like these:

 
       SUBROUTINE SORT(NELS, NAMES) 
       INTEGER NELS 
       CHARACTER NAMES(NELS)*(*)
Alternatively the actual argument can be a character variable or substring. In such cases it usually makes more sense not to use the passed-length mechanism. For example an actual argument declared:
CHARACTER*80 LINE
could be passed to a subroutine which declared it as an array of four 20-character elements:
 
       SUBROUTINE SPLIT(LINE) 
       CHARACTER LINE(4)*20

Although this is valid Fortran, it is not a very satisfactory programming technique to use a procedure call to alter the shape of an item so radically.



Helen Rowlands
8/27/1998