      SUBROUTINE GETCOD                                                 GETC0001
                                                                        GETC0002
      INCLUDE 'anglen.inc'                                              GETC0003
                                                                        GETC0004
WINNT - needed for call to getarg                                       GETC0005
      integer(2)  n1,status                                             GETC0006
WINNT - end                                                             GETC0007
                                                                        GETC0008
CHECK v.2.0-->                                                          GETC0009
C      INTEGER       I                                                  GETC0010
CHECK v.2.0<--                                                          GETC0011
CHECK v.2.0-->                                                          GETC0012
      INTEGER       IEND, ILEN, ISTART                                  GETC0013
      LOGICAL       IERROR                                              GETC0014
CHECK v.2.0<--                                                          GETC0015
                                                                        GETC0016
C---- Initialise variables                                              GETC0017
                                                                        GETC0018
CHECK v.2.0-->                                                          GETC0019
C---- Accept 4-letter Brookhaven code                                   GETC0020
C      PRINT*, 'Enter 4-letter Brookhaven code of protein'              GETC0021
C      READ(*,10) BRCODE                                                GETC0022
C 10   FORMAT(A4)                                                       GETC0023
                                                                        GETC0024
C---- Check that the code doesn't contain any blanks                    GETC0025
C      DO 100, I = 1, 4                                                 GETC0026
C          IF (BRCODE(I:I).EQ.' ') GO TO 900                            GETC0027
C 100  CONTINUE                                                         GETC0028
C      FILNEW = 'p' // BRCODE // '.new'                                 GETC0029
C      FILLAN = 'p' // BRCODE // '.lan'                                 GETC0030
CHECK v.2.0<--                                                          GETC0031
                                                                        GETC0032
CHECK v.2.0-->                                                          GETC0033
C---- Accept name of original .pdb file holding the structure           GETC0034
c      PRINT*, 'Enter filename containing coordinates of structure'     GETC0035
c      READ(*,10) PDBFIL                                                GETC0036
c10    FORMAT(A)                                                        GETC0037
c                                                                       GETC0038
WINNT - accept file name from command line if provided else ask for it  GETC0039
      n1 = 1                                                            GETC0040
      CALL GETARG(n1, pdbfil, status)                                   GETC0041
      if (status.lt.1) then                                             GETC0042
         PRINT*, 'Enter filename containing coordinates of structure '  GETC0043
CHECK v.3.2-->                                                          GETC0044
         PRINT*, '  (for file containing ensemble of NMR structures en',GETC0045
     &    'ter @filename;'                                              GETC0046
         PRINT*, '   for set of separate PDB files to be processed, en',GETC0047
     &    'ter %filelist,'                                              GETC0048
         PRINT*, '   where filelist contains a list of PDB files to be',GETC0049
     &    ' cleaned up)'                                                GETC0050
CHECK v.3.2<--                                                          GETC0051
         READ(*,10) PDBFIL                                              GETC0052
10       FORMAT(A)                                                      GETC0053
      else                                                              GETC0054
         write(*,*) 'File name parsed from command line : ',pdbfil      GETC0055
      end if                                                            GETC0056
WINNT - end                                                             GETC0057
                                                                        GETC0058
C---- Peel off directory path and extension                             GETC0059
      CALL GETNAM(PDBFIL,ISTART,IEND,IERROR)                            GETC0060
      IF (IERROR) GO TO 990                                             GETC0061
                                                                        GETC0062
C---- Form names of other files that will be required in default dir    GETC0063
      ILEN = IEND - ISTART + 1                                          GETC0064
      FILNEW = PDBFIL(ISTART:IEND) // '.new'                            GETC0065
      FILLAN = PDBFIL(ISTART:IEND) // '.lan'                            GETC0066
CHECK v.2.2-->                                                          GETC0067
      FILPLN = PDBFIL(ISTART:IEND) // '.pln'                            GETC0068
CHECK v.2.2<--                                                          GETC0069
CHECK v.2.0<--                                                          GETC0070
                                                                        GETC0071
      GO TO 999                                                         GETC0072
                                                                        GETC0073
C---- Fatal errors                                                      GETC0074
990   CONTINUE                                                          GETC0075
      IFAIL = .TRUE.                                                    GETC0076
                                                                        GETC0077
999   CONTINUE                                                          GETC0078
      RETURN                                                            GETC0079
      END                                                               GETC0080
