      subroutine getstr (prompt, defans, string, ilen, ifail)           GETS001
c                                                                       GETS002
c     implicit complex(a-z)                                             GETS003
c     implicit none                                                     GETS004
c=======================================================================GETS005
c     General purpose routine to prompt the user to type in a character GETS006
c     string. The prompt that will be written out to the user should be GETS007
c     passed to the routine in variable PROMPT, along with a default    GETS008
c     response in      DEFANS. The variable STRING will return the user'GETS009
c     input to the calling program, and ILEN will hold its length.      GETS010
c     The flag IFAIL will have one of      the following values:        GETS011
c        IFAIL = 0 : everything OK;                                     GETS012
c        IFAIL = 1 : variable PROMPT is empty;                          GETS013
c        IFAIL = 2 : variable DEFANS is empty;                          GETS014
c        IFAIL = 3 : user's response is too long to fit in STRING;      GETS015
c        IFAIL = 4 : error occurred writing out prompt to terminal;     GETS016
c        IFAIL = 5 : error occurred reading in reply from keyboard;     GETS017
c        IFAIL = 6 : EOF detected reading in reply from keyboard.       GETS018
c=======================================================================GETS019
      character*(*) prompt, defans, string                              GETS020
      integer       ilen, ifail                                         GETS021
c                                                                       GETS022
      character     line*255                                            GETS023
      integer       lenp, lens, strlen, lend                            GETS024
c                                                                       GETS025
 1000 format (A, ' <', A, '> - ')                                       GETS026
 1010 format (A)                                                        GETS027
c                                                                       GETS028
      ilen  = 0                                                         GETS029
      ifail = 0                                                         GETS030
c                                                                       GETS031
      lenp  = strlen(prompt)                                            GETS032
      if (lenp .le. 0)  then                                            GETS033
         ifail = 1                                                      GETS034
         return                                                         GETS035
      end if                                                            GETS036
c                                                                       GETS037
      lend  = strlen(defans)                                            GETS038
      if (lend .le. 0)  then                                            GETS039
         ifail = 2                                                      GETS040
         return                                                         GETS041
      end if                                                            GETS042
c                                                                       GETS043
      lens  = len(string)                                               GETS044
c                                                                       GETS045
CHECK v.3.0.1-->                                                        GETS046
C   10 write (6, 1000, err = 904) prompt(1:lenp), defans(1:lend)        GETS047
      write (6, 1000, err = 904) prompt(1:lenp), defans(1:lend)         GETS048
CHECK v.3.0.1<--                                                        GETS049
      read  (5, 1010, err = 905, end = 906) line                        GETS050
      ilen = strlen(line)                                               GETS051
      if (ilen .eq. 0) then                                             GETS052
         line = defans(1:lend)                                          GETS053
         ilen = lend                                                    GETS054
      end if                                                            GETS055
      if (ilen .gt. lens)  then                                         GETS056
         ifail = 3                                                      GETS057
         return                                                         GETS058
      end if                                                            GETS059
      string = line(1:ilen)                                             GETS060
      ifail = 0                                                         GETS061
      return                                                            GETS062
c                                                                       GETS063
  904 ifail = 4                                                         GETS064
      return                                                            GETS065
  905 ifail = 5                                                         GETS066
      return                                                            GETS067
  906 ifail = 6                                                         GETS068
      return                                                            GETS069
c                                                                       GETS070
      end                                                               GETS071
