module defvar type atomtype integer index real*8 x,y,z,charge end type type content real*8 x,y,z,value end type integer n1,n2,n3,ncenter real*8 orgx,orgy,orgz,v1x,v1y,v1z,v2x,v2y,v2z,v3x,v3y,v3z type(content),allocatable :: cubmat(:,:,:) type(atomtype),allocatable :: a(:) end module program cubelite use defvar implicit real*8 (a-h,o-z) character inpfile*200,outfile*200 write(*,*) "cubelite: Read, manipulate and write cube file" write(*,*) "Programmed by Sobereva 2012-Feb-8" write(*,*) write(*,*) "Input the cube filename to be loaded" read(*,"(a)") inpfile call readcube(inpfile) ! cubmat%value=cubmat%value**2 ! where (cubmat%x>0) cubmat%value=1000D0 ! b2a=0.529177249D0 ! open(10,file="output.txt",status="replace") ! write(*,*) "Input Z (in angstrom) to define a XY plane" ! read(*,*) posZ ! posZ=posZ/b2a ! rmindist=abs(cubmat(1,1,1)%z-posZ) ! k=1 ! do icycz=2,n3 ! disttmp=abs(cubmat(1,1,icycz)%z-posZ) ! if (disttmp 1) then allocate(mo_serial(nmo)) allocate(temp_readdata(n3*nmo)) read(10,*) mo_serial write(*,"('There are ',i5,' MOs in this grid file, the serial number are: ')") nmo do i=1,nmo write(*,"('Number ',i5,' : MO= ',i5)") i,mo_serial(i) end do write(*,*) "Which MO you want to load? Input the serial number" read(*,*) mo_select else read(10,*) !Only one MO, pass the MO serial line end if end if write(*,*) write(*,*) "Loading cube file, please wait..." do i=1,n1 do j=1,n2 if (nmo==0.or.nmo==1) then read(10,*) cubmat(i,j,:)%value else !Load the specified MO from vast of MOs read(10,*) temp_readdata cubmat(i,j,:)%value=temp_readdata(mo_select:size(temp_readdata):nmo) end if end do end do do i=1,n1 do j=1,n2 do k=1,n3 cubmat(i,j,k)%x=orgx+(i-1)*v1x+(j-1)*v2x+(k-1)*v3x cubmat(i,j,k)%y=orgy+(i-1)*v1y+(j-1)*v2y+(k-1)*v3y cubmat(i,j,k)%z=orgz+(i-1)*v1z+(j-1)*v2z+(k-1)*v3z end do end do end do write(*,*) "Loading completed!" close(10) end subroutine subroutine outcube(cubname) use defvar implicit real*8 (a-h,o-z) character cubname*200 open(10,file=cubname,access="sequential",status="replace") write(10,"(' Generated by cubelite')") write(10,"(' Totally ',i12,' grid points')") n1*n2*n3 write(10,"(i5,3f12.6)") ncenter,orgx,orgy,orgz write(10,"(i5,3f12.6)") n1,v1x,v1y,v1z write(10,"(i5,3f12.6)") n2,v2x,v2y,v2z write(10,"(i5,3f12.6)") n3,v3x,v3y,v3z do i=1,ncenter write(10,"(i5,4f12.6)") a(i)%index,a(i)%charge,a(i)%x,a(i)%y,a(i)%z end do write(*,*) "Outputting cube file..." do i=1,n1 do j=1,n2 do k=1,n3 write(10,"(1PE13.5)",advance="no") cubmat(i,j,k)%value if (mod(k,6)==0.or.k==n3) write(10,*) end do end do end do close(10) write(*,*) "Outputting finished" end subroutine
Baidu
map