Run-Time Function: Returns the total number of command-line arguments, including the command.
Module: USE DFLIB
Syntax
Results:
The result is of type INTEGER(4).
The result is the number of command-line arguments,
including the command. For example, NARGS returns 4 for the command-line
invocation of PROG1 -g -c -a
.
Compatibility
CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB
Example
USE DFLIB
INTEGER(2) result
result = RUNQQ('myprog', '-c -r')
END
! MYPROG.F90 responds to command switches -r, -c,
! and/or -d
USE DFLIB
INTEGER(4) count, num
INTEGER(2) i, status
CHARACTER(80) buf
REAL r1 / 0.0 /
COMPLEX c1 / (0.0,0.0) /
REAL(8) d1 / 0.0 /
num = 5
count = NARGS( )
DO i = 1, count-1
CALL GETARG(i, buf, status)
IF (buf(2:status) .EQ.'r') THEN
r1 = REAL(num)
WRITE (*,*) 'r1 = ',r1
ELSE IF (buf(2:status) .EQ.'c') THEN
c1 = CMPLX(num)
WRITE (*,*) 'c1 = ', c1
ELSE IF (buf(2:status) .EQ.'d') THEN
d1 = DBLE(num)
WRITE (*,*) 'd1 = ', d1
ELSE
WRITE(*,*) 'Invalid command switch'
EXIT
END IF
END DO
END