Statistics
| Revision:

root / src / Write_vasp.f90 @ 5

History | View | Annotate | Download (2.5 kB)

1
SUBROUTINE Write_vasp(poscar)
2

    
3
  Use Path_module, only : Nat, NGeomF,XyzGeomF,intCoordF,Coord,FrozAtoms,IndZmat,LatR,Ncoord, Vmd
4
  Use Io_module
5

    
6
  IMPLICIT NONE
7

    
8
  CHARACTER(SCHARS), INTENT(IN) :: poscar
9

    
10
  INTEGER(KINT) :: IGeom, Idx
11
  REAL(KREAL), ALLOCATABLE :: GeomTmpC(:), GeomTmp(:)
12
  CHARACTER(SCHARS) :: Line,Line2
13

    
14
  ! For VMD printing
15
  CHARACTER(SCHARS), PARAMETER :: FirstWord="mol "
16
  CHARACTER(LCHARS), PARAMETER :: LastWords=" type POSCAR first 0 last -1 step 1 filebonds 1 autobonds 1 waitfor all"
17

    
18
  CHARACTER(LCHARS) :: TITLE
19
  LOGICAL :: Debug
20

    
21
  INTERFACE
22
     function valid(string) result (isValid)
23
       CHARACTER(*), intent(in) :: string
24
       logical                  :: isValid
25
     END function VALID
26
  END INTERFACE
27

    
28
  debug=valid('write_vasp')
29
  if (debug) WRITE(*,*) '================ Entering Write_VASP ===================='
30

    
31
  ALLOCATE(GeomTmpC(3*Nat), GeomTmp(NCoord))
32

    
33
  Line2="00"
34
  DO IGeom=1,NGeomF
35
     WRITE(Line,'(I5)') IGeom-1
36
     Idx=2-Len_TRIM(ADJUSTL(Line))
37
     OPEN(IOTMP,File=TRIM(POSCAR) // "_" // Line2(1:Idx) // AdjustL(TRIM(Line)))
38
     ! we convert the coordinates into Cartesian coordinates
39
     SELECT CASE (Coord)
40
     CASE ('CART','HYBRID')
41
        GeomTmpC=Reshape(reshape(XyzGeomF(IGeom,:,:),(/Nat,3/),ORDER=(/2,1/)),(/3*Nat/))
42
     CASE ('ZMAT')
43
        GeomTmp=IntCoordF(IGeom,:)
44
        ! we have to generate the cartesian coordinates from the internal coordinates
45
        CAll Int2Cart(nat,indzmat,geomtmp,GeomTmpC)
46
     CASE ('MIXED')
47
        GeomTmp=IntCoordF(IGeom,:)
48
        CAll Mixed2Cart(nat,indzmat,geomtmp,GeomTmpC)
49
     END SELECT
50

    
51
     if (debug) WRITE(*,*) "Converting geom ",IGeom," into file ",Trim(POSCAR) // "_" // Line2(1:Idx) // AdjustL(TRIM(Line))
52

    
53
     WRITE(Title,'(A,I2,"/",I2)') Trim(Vasp_Title) // " - Geom ",IGeom-1,NGeomF-1
54

    
55
     Call PrintGeomVasp(Title,geomTmpC,Latr,FrozAtoms,IoTmp)
56

    
57
     CLOSE(IOTMP)
58
  END DO
59

    
60
  if (Vmd) THEN
61
     WRITE(IOOUT,*) "## Insert the following list into the Test_NEB_example.vmd file for an easy VMD use"
62

    
63
     Line2="00"
64
     WRITE(IOOUT,'(A)') TRIM(FirstWord) // " new " // TRIM(POSCAR) // "_00" // TRIM(LastWords)
65
     DO IGeom=2,NGeomF
66
        WRITE(Line,'(I5)') IGeom-1
67
        Idx=2-Len_TRIM(ADJUSTL(Line))
68
        WRITE(IOOUT,'(A)') TRIM(FirstWord) // " addfile " // TRIM(POSCAR) //  &
69
             "_" // Line2(1:Idx) // TRIM(ADJUSTL(Line)) // TRIM(LastWords)
70
     END DO
71
     WRITE(IOOUT,*) "## End of List"
72
  END IF
73

    
74
  if (debug) WRITE(*,*) '================  Write_VASP OVER ===================='
75
  DeALLOCATE(GeomTmpC, GeomTmp)
76

    
77
END SUBROUTINE Write_vasp