PROGRAM splitdiam c Splits Diamond file into monomers CHARACTER*132 line, line1, line2, line3, filnam LOGICAL flag(11:22)/12*.FALSE./ INTEGER n(11:22)/12*0/, nres(11:22)/12*0/, mres(11:22) WRITE (6, 1000) 'Enter input file name:' READ (5, 1000) filnam OPEN (unit=10, form='FORMATTED', status='OLD', readonly, 1 file=filnam) ll = length(filnam)+2 filnam(ll-1:ll-1) = '.' READ (10, 1000) line1 1000 FORMAT (a) len1 = length(line1) READ (10, 1000) line2 len2 = length(line2) READ (10, 1000) line3 len2 = length(line3) DO WHILE (.TRUE.) READ (10, 1000, end=9) line len = length(line) ifile = ICHAR(line(72:72))-54 IF (ifile .LE. 16) THEN IF (.NOT. flag(ifile)) THEN filnam(ll:ll) = line(72:72) OPEN (unit=ifile, form='FORMATTED', status='UNKNOWN', 1 carriagecontrol='LIST', file=filnam) flag(ifile) = .TRUE. WRITE (ifile, 1000) line1(1:len1) WRITE (ifile, 1000) line2(1:len2) WRITE (ifile, 1000) line3(1:len3) endIF n(ifile) = n(ifile)+1 READ (line(46:50), 1001) mn IF (mn .NE. mres(ifile)) THEN nres(ifile) = nres(ifile)+1 mres(ifile) = mn endIF WRITE (line(51:55), 1001) n(ifile) WRITE (line(46:50), 1001) nres(ifile) 1001 FORMAT (i5) WRITE (ifile, 1000) line(1:len) endIF endDO 9 CLOSE (unit=10) DO i = 11,22 IF (flag(ifile)) CLOSE (unit=ifile) endDO end INTEGER FUNCTION length(line) CHARACTER*132 line DO i = 132,1,-1 IF (line(i:i) .NE. ' ') goto 9 endDO 9 length = i return end