      SUBROUTINE GETCOD                                                 GETC0001
C-----------------------------------------------------------------------GETC0002
C                                                                       GETC0003
C  SUBROUTINE GETCOD  -  Read in the name of the .lan file              GETC0004
C                                                                       GETC0005
C----------------------------------------------------------------------+GETC0006
                                                                        GETC0007
      INCLUDE 'bplot.inc'                                               GETC0008
                                                                        GETC0009
WINNT - needed for system call to getarg                                GETC0010
      integer(2)  n1,status                                             GETC0011
WINNT - end                                                             GETC0012
                                                                        GETC0013
CHECK v.3.2-->                                                          GETC0014
C      INTEGER       LINE                                               GETC0015
WINNT - not needed                                                      GETC0016
C      CHARACTER*1   LOWERA                                             GETC0017
C      CHARACTER*26  UPPER                                              GETC0018
C      INTEGER       LINE, N                                            GETC0019
WINNT - end                                                             GETC0020
      INTEGER       LINE                                                GETC0021
CHECK v.3.2<--                                                          GETC0022
      LOGICAL       IERROR                                              GETC0023
                                                                        GETC0024
WINNT - not needed                                                      GETC0025
CHECK v.3.2-->                                                          GETC0026
C      DATA  LOWERA / 'a' /                                             GETC0027
C      DATA  UPPER  / 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' /                    GETC0028
CHECK v.3.2<--                                                          GETC0029
WINNT - end                                                             GETC0030
                                                                        GETC0031
C---- Initialise variables                                              GETC0032
      LINE = 0                                                          GETC0033
                                                                        GETC0034
WINNT - accept file name from command line if provided else ask for it  GETC0035
                                                                        GETC0036
C---- Accept name of original .pdb file holding the structure           GETC0037
c      PRINT*, 'Enter filename containing coordinates of structure'     GETC0038
c      READ(*,110,ERR=900) PDBFIL                                       GETC0039
c 110  FORMAT(A)                                                        GETC0040
      write(*,*) 'BPLOT - Windows NT version B.Rupp 1996'               GETC0041
      n1 = 1                                                            GETC0042
      CALL GETARG(n1, pdbfil, status)                                   GETC0043
      if (status.lt.1) then                                             GETC0044
         PRINT*, 'Enter filename containing coordinates of structure '  GETC0045
CHECK v.3.2-->                                                          GETC0046
         PRINT*, '  (for file containing ensemble of NMR structures en',GETC0047
     &    'ter @filename;'                                              GETC0048
         PRINT*, '   for set of separate PDB files to be processed, en',GETC0049
     &    'ter %filelist,'                                              GETC0050
         PRINT*, '   where filelist contains a list of PDB files to be',GETC0051
     &    ' cleaned up)'                                                GETC0052
CHECK v.3.2<--                                                          GETC0053
         READ(*,10) PDBFIL                                              GETC0054
10       FORMAT(A)                                                      GETC0055
      else                                                              GETC0056
         write(*,*) 'File name parsed from command line : ',pdbfil      GETC0057
      end if                                                            GETC0058
c --- get second parameter from command line                            GETC0059
      n1 = 2                                                            GETC0060
      CALL GETARG(n1, chain, status)                                    GETC0061
c --- if missing, get the chain id                                      GETC0062
      if (status.lt.1) then                                             GETC0063
C---- Accept chain-ID                                                   GETC0064
         PRINT*, 'Enter chain-ID letter, or leave blank for all '       GETC0065
         READ(*,'(a)',ERR=906) CHAIN                                    GETC0066
      end if                                                            GETC0067
WINNT - make chain upper case using UPSTRG                              GETC0068
      call upstrg (chain,1)                                             GETC0069
c --- if it's a number it must be the resolution so use blank for all   GETC0070
WINNT - new function ISNUM returns true if char is a number             GETC0071
      if (isnum(chain)) then                                            GETC0072
         chain=' '                                                      GETC0073
         write(*,*)'All chains included '                               GETC0074
      else                                                              GETC0075
         write(*,*)'Chain processed : ',chain                           GETC0076
      end if                                                            GETC0077
                                                                        GETC0078
C---- Accept chain-ID                                                   GETC0079
c      PRINT*, 'Enter required chain-ID, or leave blank for all'        GETC0080
c      READ(*,110,ERR=906) CHAIN                                        GETC0081
c                                                                       GETC0082
CHECK v.3.2-->                                                          GETC0083
C---- Convert chain ID to upper-case if necessary                       GETC0084
c      N = ICHAR(CHAIN) - ICHAR(LOWERA) + 1                             GETC0085
c      IF (N.GE.1 .AND. N.LE.26) CHAIN = UPPER(N:N)                     GETC0086
CHECK v.3.2<--                                                          GETC0087
                                                                        GETC0088
WINNT - end                                                             GETC0089
                                                                        GETC0090
C---- Peel off directory path and extension                             GETC0091
      CALL GETNAM(PDBFIL,ISTART,IEND,IERROR)                            GETC0092
      IF (IERROR) GO TO 990                                             GETC0093
                                                                        GETC0094
C---- Form names of other files that will be required in default directoGETC0095
      ILEN = IEND - ISTART + 1                                          GETC0096
      BRCODE = PDBFIL(ISTART:IEND)                                      GETC0097
      FILLAN = PDBFIL(ISTART:IEND) // '.lan'                            GETC0098
      FILPLN = PDBFIL(ISTART:IEND) // '.pln'                            GETC0099
      FILPS = BRCODE                                                    GETC0100
CHECK v.3.2-->                                                          GETC0101
      FILSUM = PDBFIL(ISTART:IEND) // '.sum'                            GETC0102
CHECK v.3.2<--                                                          GETC0103
CHECK v.3.3.2-->                                                        GETC0104
      FILHTM = PDBFIL(ISTART:IEND) // '.html'                           GETC0105
CHECK v.3.3.2<--                                                        GETC0106
      PSLEN = IEND - ISTART + 1                                         GETC0107
      BLEN = PSLEN                                                      GETC0108
      IF (CHAIN.NE.' ') THEN                                            GETC0109
          BRCODE = BRCODE(1:BLEN) // ' - Chain ' // CHAIN               GETC0110
          BLEN = BLEN + 10                                              GETC0111
          IF (BLEN.GT.78) BLEN = 78                                     GETC0112
      ENDIF                                                             GETC0113
                                                                        GETC0114
      GO TO 999                                                         GETC0115
                                                                        GETC0116
C---- Fatal errors                                                      GETC0117
 900  CONTINUE                                                          GETC0118
      PRINT*, '*** ERROR. Data error in entered filename'               GETC0119
      GO TO 990                                                         GETC0120
                                                                        GETC0121
 906  CONTINUE                                                          GETC0122
      PRINT*, '*** ERROR. Data error in entered chain-ID'               GETC0123
      GO TO 990                                                         GETC0124
                                                                        GETC0125
990   CONTINUE                                                          GETC0126
      IFAIL = .TRUE.                                                    GETC0127
                                                                        GETC0128
999   CONTINUE                                                          GETC0129
      RETURN                                                            GETC0130
      END                                                               GETC0131
