| 1 |
C Copyright(C) 1999-2020 National Technology & Engineering Solutions |
| 2 |
C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 3 |
C NTESS, the U.S. Government retains certain rights in this software. |
| 4 |
C |
| 5 |
C See packages/seacas/LICENSE for details |
| 6 |
SUBROUTINE GETINP( KIN,KOUT,PROMPT,LINE,IOSTAT ) |
| 7 |
CHARACTER*(*) PROMPT,LINE |
| 8 |
CHARACTER*132 PREFIX |
| 9 |
DATA KOUNT /0/ |
| 10 |
|
| 11 |
************************************************************************ |
| 12 |
|
| 13 |
C FREFLD INPUT SYSTEM - ANSI FORTRAN - UTILITY ROUTINE |
| 14 |
|
| 15 |
C DESCRIPTION: |
| 16 |
C This routine is performs all I/O for the SUPES Free Field Input |
| 17 |
C system. Its operation depends on the input and output units |
| 18 |
C specified by the caller as follows. |
| 19 |
|
| 20 |
C KIN KOUT Source Echo |
| 21 |
C ------------------------------------------------------------------ |
| 22 |
C 0 0 Standard Input Standard Output |
| 23 |
C 0 M Standard Input Standard Output and File (M) |
| 24 |
C N M File (N) File (N) |
| 25 |
C N 0 File (N) none |
| 26 |
|
| 27 |
C If the prompt string is 'AUTO' this routine will generate a prompt |
| 28 |
C of the form ' n: ', where "n" is the current input line number. |
| 29 |
C Only lines read under the AUTO feature are counted. |
| 30 |
|
| 31 |
C This routine does not restrict the length of the input string, but |
| 32 |
C no more than 132 characters, including the prompt, will be echoed. |
| 33 |
|
| 34 |
C FORMAL PARAMETERS: |
| 35 |
C KIN INTEGER Unit from which to read input. |
| 36 |
C KOUT INTEGER Unit to which to echo input. |
| 37 |
C PROMPT CHARACTER Prompt string. |
| 38 |
C LINE CHARACTER Input record. |
| 39 |
C IOSTAT INTEGER ANSI FORTRAN I/O status. |
| 40 |
|
| 41 |
C ROUTINES CALLED: |
| 42 |
C STRIPB Strip leading/trailing blanks from a string. |
| 43 |
C EXREAD Prompt, read, and echo and input record. |
| 44 |
|
| 45 |
************************************************************************ |
| 46 |
|
| 47 |
C Generate a prompt if autoincrement mode is requested; in any case |
| 48 |
C PREFIX(1:LPRE) will contain the prompt - |
| 49 |
IF( PROMPT .EQ. 'AUTO' ) THEN |
| 50 |
KOUNT = KOUNT + 1 |
| 51 |
C Wrap-around counter, if it exceeds 4 digits - |
| 52 |
IF ( KOUNT .EQ. 10000 ) KOUNT = 0 |
| 53 |
WRITE( PREFIX,1000 ) KOUNT |
| 54 |
LPRE = 6 |
| 55 |
ELSE |
| 56 |
PREFIX = PROMPT |
| 57 |
LPRE = LEN( PROMPT ) |
| 58 |
END IF |
| 59 |
|
| 60 |
C Read the input line - |
| 61 |
IF ( KIN .EQ. 0 ) THEN |
| 62 |
CALL EXREAD( PREFIX(1:LPRE),LINE,IOSTAT ) |
| 63 |
ELSE |
| 64 |
READ( KIN,2000,IOSTAT=IOSTAT ) LINE |
| 65 |
END IF |
| 66 |
|
| 67 |
C Return if I/O error or EOF detected - |
| 68 |
IF ( IOSTAT .NE. 0 ) RETURN |
| 69 |
|
| 70 |
C Find the last non-blank character - |
| 71 |
CALL STRIPB( LINE,ILEFT,IRIGHT ) |
| 72 |
|
| 73 |
C Truncate the string for echo, if necessary - |
| 74 |
IRIGHT = MIN( IRIGHT,132-LPRE ) |
| 75 |
|
| 76 |
C Echo the input line, if requested - |
| 77 |
IF ( KOUT .GT. 0 ) THEN |
| 78 |
IF ( IRIGHT .EQ. 0 ) THEN |
| 79 |
WRITE( KOUT,3000 ) PREFIX(1:LPRE) |
| 80 |
ELSE |
| 81 |
WRITE( KOUT,3000 ) PREFIX(1:LPRE),LINE(1:IRIGHT) |
| 82 |
END IF |
| 83 |
END IF |
| 84 |
|
| 85 |
1000 FORMAT( I4,': ' ) |
| 86 |
2000 FORMAT( A ) |
| 87 |
3000 FORMAT( 1X,A,A ) |
| 88 |
|
| 89 |
END |