GETNUM() and GETINT8()

Fortran version:

    INTEGER FUNCTION GETNUM( LO , HI , DEFAULT , PROMPT )
    INTEGER FUNCTION GETNUM1( DEFAULT , PROMPT )
        INTEGER      , INTENT(IN   ) :: LO      ! Minimum allowed return value
        INTEGER      , INTENT(IN   ) :: HI      ! Maximum allowed return value
        INTEGER      , INTENT(IN   ) :: DEFAULT ! Default return value
        CHARACTER*(*), INTENT(IN   ) :: PROMPT  ! Prompt for user
    INTEGER(8) FUNCTION GETINT8( LO , HI , DEFAULT , PROMPT )
    INTEGER(8) FUNCTION GETINT81( DEFAULT , PROMPT )
        INTEGER(8)   , INTENT(IN   ) :: LO      ! Minimum allowed return value
        INTEGER(8)   , INTENT(IN   ) :: HI      ! Maximum allowed return value
        INTEGER(8)   , INTENT(IN   ) :: DEFAULT ! Default return value
        CHARACTER*(*), INTENT(IN   ) :: PROMPT  ! Prompt for user

NO C version:

Summary:

Display the PROMPT to standard output, get the user's response as an INTEGER and for GETNUM(), check that it is within range [LO,HI]. Return DEFAULT if the user hits <RET>. Re-prompts on error for up to 5 attempts; exits in case of more than 5 entry errors. If environment variable PROMPTFLAG is set to "N", returns DEFAULT without prompting the user. Logs the value returned, for tracking and validation purposes.

The default is displayed in square brackets at the end of the prompt [LIKE THIS]. For Fortran-90 declarations and interface checking:

    USE M3UTILIO
    
GETNUM1 is for I/O API-3.2 and later, only.

See also GETVAL(), GETDATE(), GETMENU(), GETREAL(), GETDBLE(), GETSTR(), and GETYN().

Preconditions:

none

Fortran Usage:

GETVAL() is the Fortran-90-generic (I/O API-3.2 or later only) that calls these or various other similar routines, as determined by the argument-list.

(See sample programs LATLON or PRESZ for additional usage examples.)

    ...
    USE M3UTILIO    !! else:  INTEGER, EXTERNAL :: GETNUM, GETNUM1
    ...
    INTEGER     L, M, N
    REAL        X
    ...
    L = GETNUM( 1, 10, 7, 'Give me a (INTEGER) number between 1 and 10' )
    M = GETNUM( 99, 'Give me a (INTEGER) number' )
    Z = GETVAL( 12.3, 'Give me a  (REAL) number' )  !!  only if USE M3UTILIO
    N = GETVAL( 22, 'Give me a (INTEGER) number' )  !!  ditto
    ...

C Usage:

Don't, unless you're already comfortable with mixed-language programming.


Previous: GETMENU

Next: GETREAL

Up: Utility Routines

To: Models-3/EDSS I/O API: The Help Pages