program chargedna character*80 ts,fn LOGICAL*4 notemptyline c write(6,*)' Changes charges in Gaussian inputs in INP.LST' open(2,file='INP.LST',status='old',err=999) ill=0 1 read(2,2000,end=99,err=99)fn 2000 format(a80) write(6,2000)fn open(3,file=fn,status='old',err=999) ill=ill+1 iel=0 2 read(3,2000,end=98,err=98)ts if(.not.notemptyline(ts))iel=iel+1 if(iel.eq.2)then read(3,*)ich ,im nch=0 3 read(3,2000,end=98,err=98)ts l=len(ts) do 4 i=1,l 4 if(ts(i:i).ne.' ')goto 5 5 if(ts(i:i).eq.'p'.or.ts(i:i).eq.'P')nch=nch-1 goto 3 endif goto 2 98 close(3) write(6,*)'Old charge: ',ich,', new charge: ',nch open(3,file=fn,status='old',err=999) do 7 io=len(fn),1,-1 7 if(fn(io:io).ne.' ')goto 8 8 open(4,file=fn(1:io)//'.N') iel=0 6 read(3,2000,end=97,err=97)ts write(4,2000)ts if(.not.notemptyline(ts))iel=iel+1 if(iel.eq.2)then iel=iel+1 read(3,*) write(4,4000)nch ,1 4000 format(2I4) endif goto 6 97 close(3,status='delete') close(4) call rename(fn(1:io)//'.N',fn(1:io)) goto 1 99 close(2) write(6,*)ill,' files rewritten' stop 999 write(6,*)' File not found' stop end function notemptyline(ts) IMPLICIT REAL*8 (A-H,O-Z) IMPLICIT INTEGER*4 (I-N) LOGICAL*4 notemptyline CHARACTER*(*) ts c l=len(ts) notemptyline=.false. do 1 i=1,l 1 if(ts(i:i).ne.' ')notemptyline=.true. return end