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
Display thePROMPT
to standard output, get the user's response as anINTEGER
and forGETNUM()
, check that it is within range[LO,HI]
. ReturnDEFAULT
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", returnsDEFAULT
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 M3UTILIOGETNUM1
is for I/O API-3.2 and later, only.See also GETVAL(), GETDATE(), GETMENU(), GETREAL(), GETDBLE(), GETSTR(), and GETYN().
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 ...
Don't, unless you're already comfortable with mixed-language programming.
To: Models-3/EDSS I/O API: The Help Pages