J3/97-258 page 1 of 1 Date: 11 Nov 1997 To: X3J3 From: Jerry Wagener Subject: More Heat on Command-line Arguments Java does command-line arguments in a nice, easy-to-use, almost-intuitive way: class CommandLine // note: "String" is the Java character-string type { public static void main (String args[]) { . . . // args[0] is the value of the first command-line argument . . . // (space delimited), args[1] the second, etc. } // args.length is the number of arguments } // args[i].length() is the length of the ith argument The Fortran analogy would be: program CommandLine (args); character(*) args(:) . . . ! args(1) is the value of the first command-line argument . . . ! (space delimited), args(2) the second, etc. . . . ! size(args) is the number of arguments end ! len(args) is the length of the longest argument In the example execution a.out Las Vegas 143 size(args) would be 3, args(1) would have the value "Las ", args(2) the value "Vegas", and args(3) the value "143 ". To accommodate command-line arguments in Fortran in this manner, the program statement is extended to optionally include a dummy argument list with one dummy argument; that argument must be declared as a rank-one assumed-length deferred-shape character array. The corresponding actual argument is supplied by the system upon execution of the program and comprises the space-delimited command-line argument character strings. The size of the actual argument is the number of such arguments supplied, and the element length of the actual argument is (at least) that of the longest such argument supplied.