- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following module will not compile; I am probably missing something simple. Appreciate someone pointing out the error of my ways.
MODULE command_line_arguments
CONTAINS
SUBROUTINE get_arguments (num_arguments, strings,
& num_strings, error)
IMPLICIT NONE
INCLUDE 'flib.fd' ! include for GETARG and NARGS functions
!----------------------------------------------------------------------
! Calling arguments
!----------------------------------------------------------------------
INTEGER, INTENT(out) :: num_arguments ! Number of arguments returned
INTEGER, INTENT(in) :: num_strings ! Number of strings to hold
INTEGER, INTENT(out) :: error ! Error flag: 0 = no error
! -1 = system library error
! > 0 = too many arguments
CHARACTER(len=*), DIMENSION (num_strings),
& INTENT(out) :: strings
! ! Array to hold arguments
!----------------------------------------------------------------------
! Type local variables
!----------------------------------------------------------------------
INTEGER(2) :: i
INTEGER(2) status
! Get number of arguments
num_arguments = nargs()
! Check for too many argumeents
IF(num_arguments > num_strings) THEN ! too many arguments
error = num_arguments
num_arguments = num_strings
ELSE
error = 0
ENDIF
! Get arguments
DO i =0, num_arguments - 1
CALL getarg(i, strings(i + 1), status)
IF(status < 0) THEN
error = status
EXIT
ENDIF
ENDDO
END SUBROUTINE get_arguments
END MODULE command_line_arguments
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hmm - Replace the INCLUDE with USE DFLIB - but what you have should work. I'll look into this.
Steve
Steve
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page