******************************************************************************* program cellvec ******************************************************************************* c c This program allows the user to create input car files with c expanded or compressed coordinates along one unit cell vector c c To compile non-graphics programs use : c f77 $(OPT) cellvec.f -o cellvec c real rx(300), ry(300), rz(300) real ucell ,cx,cy,cz character*80 record(300) character*80 rec character*80 aform character*80 bform character*40 fname character*40 gname character*20 right character*20 r1 character*5 left character*5 l1 integer i,ia,id,ih integer natom integer ndisp ,nfrag integer j,itime integer ifrag(20) c c print *,'Enter car file name: ' read(5,'(a40)') fname c print *,'Input the number of atoms:' read(5,*) natom c c open(unit=7,file=fname,form='formatted', $ status='old',err=990) c aform = "(a5,3(2x,f13.9),a29)" bform = "(a5,3(f10.5),a29)" c read(7,'(a80)',end=997,err=995) record(1) read(7,'(a80)',end=997,err=995) record(2) read(7,'(a80)',end=997,err=995) record(3) read(7,'(a80)',end=997,err=995) record(4) read(7,'(a80)',end=997,err=995) record(5) write(6,'(a80)') record(5) read (record(5),bform,err=996) l1,cx,cy,cz,r1 print *,'The unit cell and all coordinates along one direction' print *,'will be multiplied by a factor.' print *,'Input the factor to multiply the unit cell vector:' read(5,*) ucell cz=cz*ucell c do 200 i=1,natom read(7,'(a80)',end=997,err=995) record(i+5) write(6,'(a80)') record(i+5) read (record(i+5),aform,err=996) left,rx(i), $ ry(i),rz(i),right rz(i)=rz(i)*ucell 200 continue c close(7) c c print *,'Enter car file name: ' read(5,'(a40)') gname open(unit=7,file=gname,form='formatted', $ status='new',err=990) ierror=0 junit=7 do 50 j=1,4 write(junit,'(a80)') record(j) 50 continue rec=record(5) write (junit,10) rec(1:5),cx,cy,cz,rec(36:80) do 100 j = 1,natom rec=record(j+5) write (junit,20) rec(1:8),rx(j),ry(j),rz(j),rec(51:80) 100 continue do 150 j = 1,2 write(junit,'(a3)') 'end' 150 continue close(7) c 10 format(a5,3(f10.5),a45) 20 format(a8,f12.9,3x,f12.9,3x,f12.9,a30) c c goto 999 990 continue print *,'Error in input file' goto 999 995 continue print *,'Error in format' print *, record goto 999 996 continue print *,'Error parsing format' print *, record print *,left, rx(i), ry(i), rz(i),right goto 999 997 continue print *,'End of file detected' 999 continue c end c *************************************************************************** Subroutine int2char(i,tempchar1,tempchar2) *************************************************************************** ! To convert the integer data to character data Implicit None Integer i Character*1 tempchar1 Character*2 tempchar2 Character*4 record if(i.lt.10) then Write (record,'(i1)') i Read (record,'(a1)') tempchar1 else Write (record,'(i2)') i Read (record,'(a2)') tempchar2 endif Return End