root / src / cmshft.f90 @ 3
Historique | Voir | Annoter | Télécharger (1,6 ko)
| 1 | 1 | pfleura2 | subroutine cmshft(natom,rx,ry,rz,rmass,cmx,cmy,cmz,ishift) |
|---|---|---|---|
| 2 | 1 | pfleura2 | !c |
| 3 | 1 | pfleura2 | !c shifts all x, y, and z coordinates passed in rx,ry,rz to keep |
| 4 | 1 | pfleura2 | !c the center of mass at the origin if ishift is not zero. otherwise |
| 5 | 1 | pfleura2 | !c cmx, cmy, and cmz return the center of mass coordinates and no |
| 6 | 1 | pfleura2 | !c shift is performed. coordinate and mass units arbitrary. |
| 7 | 1 | pfleura2 | !c |
| 8 | 1 | pfleura2 | |
| 9 | 1 | pfleura2 | use VarTypes |
| 10 | 1 | pfleura2 | use Io_module |
| 11 | 1 | pfleura2 | |
| 12 | 1 | pfleura2 | IMPLICIT NONE |
| 13 | 1 | pfleura2 | |
| 14 | 1 | pfleura2 | |
| 15 | 1 | pfleura2 | ! Number of atoms |
| 16 | 1 | pfleura2 | INTEGER(KINT), INTENT(IN) :: NAtom |
| 17 | 1 | pfleura2 | ! Coordinates and masses |
| 18 | 1 | pfleura2 | REAL(KREAL), DIMENSION(NAtom) :: rx,ry,rz,rmass |
| 19 | 1 | pfleura2 | ! Center of mass coordinates |
| 20 | 1 | pfleura2 | real(KREAL) :: cmx,cmy,cmz |
| 21 | 1 | pfleura2 | ! Flag if user wants to shift center of mass to origin |
| 22 | 1 | pfleura2 | INTEGER(KINT) :: IShift |
| 23 | 1 | pfleura2 | |
| 24 | 1 | pfleura2 | REAL(KREAL), parameter :: zero=0.d0,one=1.d0 |
| 25 | 2 | pfleura2 | INTEGER(KINT) :: j |
| 26 | 1 | pfleura2 | REAL(KREAL) :: TmassI, tmass |
| 27 | 1 | pfleura2 | |
| 28 | 1 | pfleura2 | if(natom.le.0) then |
| 29 | 1 | pfleura2 | if(IOOUT.gt.0) write(IOOUT,'(/2a/)') & |
| 30 | 1 | pfleura2 | ' *** error, illegal array dimension in cmshft,', & |
| 31 | 1 | pfleura2 | ' return without action ***' |
| 32 | 1 | pfleura2 | return |
| 33 | 1 | pfleura2 | end if |
| 34 | 1 | pfleura2 | !c |
| 35 | 1 | pfleura2 | !c calculate center of mass coordinates |
| 36 | 1 | pfleura2 | !c |
| 37 | 1 | pfleura2 | tmass=rmass(1) |
| 38 | 1 | pfleura2 | do j=2,natom |
| 39 | 1 | pfleura2 | tmass=tmass+rmass(j) |
| 40 | 1 | pfleura2 | END DO |
| 41 | 1 | pfleura2 | !c |
| 42 | 1 | pfleura2 | !c DO i=1,natom |
| 43 | 1 | pfleura2 | !c write(IOOUT,'(4F15.3)') rmass(i),rx(i),ry(i),rz(i) |
| 44 | 1 | pfleura2 | !c END DO |
| 45 | 1 | pfleura2 | |
| 46 | 1 | pfleura2 | cmx=zero |
| 47 | 1 | pfleura2 | cmy=zero |
| 48 | 1 | pfleura2 | cmz=zero |
| 49 | 1 | pfleura2 | do j=1,natom |
| 50 | 1 | pfleura2 | cmx=rmass(j)*rx(j)+cmx |
| 51 | 1 | pfleura2 | cmy=rmass(j)*ry(j)+cmy |
| 52 | 1 | pfleura2 | cmz=rmass(j)*rz(j)+cmz |
| 53 | 1 | pfleura2 | END DO |
| 54 | 1 | pfleura2 | |
| 55 | 1 | pfleura2 | tmassi=one/tmass |
| 56 | 1 | pfleura2 | cmx=cmx*tmassi |
| 57 | 1 | pfleura2 | cmy=cmy*tmassi |
| 58 | 1 | pfleura2 | cmz=cmz*tmassi |
| 59 | 1 | pfleura2 | !c |
| 60 | 1 | pfleura2 | !c optional shift of all cartesian coordinates |
| 61 | 1 | pfleura2 | !c |
| 62 | 1 | pfleura2 | if(ishift.ne.0) then |
| 63 | 1 | pfleura2 | do j=1,natom |
| 64 | 1 | pfleura2 | rx(j)=rx(j)-cmx |
| 65 | 1 | pfleura2 | ry(j)=ry(j)-cmy |
| 66 | 1 | pfleura2 | rz(j)=rz(j)-cmz |
| 67 | 1 | pfleura2 | END DO |
| 68 | 1 | pfleura2 | end if |
| 69 | 1 | pfleura2 | |
| 70 | 1 | pfleura2 | return |
| 71 | 1 | pfleura2 | end subroutine cmshft |