!+ ! Function in4getn (prompt, ivec, n_vec) result (istat) ! ! Prompt for and get an array of integers ! Retry if ill formed. ! Return input value if entered. ! If "@" is the last non-blank character of prompt, "" will be substituted ! in plase of the "@" where "nnnn, ..." are the default (input) values. ! ! Input: ! prompt -- Character(*): Prompt string. ! ivec(*) -- Integer: Input array values will be used as the default. ! ! Output: ! ivec(*) -- Integer: Return values. ! istat -- Integer: Status. 1 = OK. -1 = 'QUIT' typed. !- function in4getn(prompt, ivec, n_vec) result (istat) use str_find_mod implicit none integer ivec(*), i, n, ix, ic, ios, istat, n_vec real(rp) val character(*) prompt character(100) line, prompt2, word ! Change from "$" format to allow input on same line as prompt ! Doesn't work correctly on VMS - revert to "$" via conditional ! compile feb 2010 sbp prompt2 = prompt n = len_trim(prompt2) if (prompt2(n:n) == '@') then prompt2(n:) = ' use default ios = -1 if (is_integer(word)) then read (word, *, iostat = ios) ivec(i) elseif (is_real(word)) then read (word, *, iostat = ios) val if (ios == 0) ivec(i) = nint(val) endif if (ios /= 0) then print *, ' BAD INPUT! Retry or type "QUIT"' goto 1 endif enddo if (line /= '') then print *, ' EXTRA CHARACTERS FOUND! Retry or type "QUIT"' goto 1 endif end function