1
subroutine recoor(overflow, cell, alat, xa, isa, xmass, na)
3
c *******************************************************************
4
c Reads atomic coordinates and format in which they are given, to be
5
c transformed into Bohr cartesian for internal handling.
6
c It also shifts them all according to AtomicCoordinatesOrigin.
8
c Written by E. Artacho, December 1997, on the original piece of the
9
c redata subroutine written by P. Ordejon in December 1996.
10
c ********* INPUT ***************************************************
11
c logical overflow : true if some dimension is too small
12
c integer na : number of atoms
13
c double precision cell(3,3): Lattice (supercell) vectors
14
c double precision alat : Lattice constant (in Bohr)
15
c ********* OUTPUT **************************************************
16
c double precision xa(3,na) : atomic coordinates in Bohr cartesian
17
c integer isa(na) : atomic species of different atoms
18
c integer xmass(na) : atomic masses of different atoms
19
c *******************************************************************
25
double precision xa(3,na), cell(3,3), alat, xmass(na)
27
c Internal variables and arrays
29
character acf*22, acf_defect*22
31
integer iscale, ia, i, ix, iunit
32
double precision origin(3), xac(3)
36
c enable FDF input/output
38
include 'fdf/fdfdefs.h'
42
C format of atomic coordinates
44
acf_defect = 'NotScaledCartesianBohr'
45
acf = fdf_string('AtomicCoordinatesFormat',acf_defect)
46
if (leqi(acf,'NotScaledCartesianBohr')) then
49
. 'recoor: Atomic-coordinates input format = ',
50
. 'Cartesian coordinates'
54
else if (leqi(acf,'NotScaledCartesianAng')) then
57
. 'recoor: Atomic-coordinates input format = ',
58
. 'Cartesian coordinates'
62
else if (leqi(acf,'ScaledCartesian')) then
63
if (alat.eq.0.d0) then
64
write(6,"(/,2a)") 'recoor: ERROR: Explicit lattice ',
65
. 'constant is needed for ScaledCartesian format'
66
stop 'recoor: ERROR: Explicit lattice constant needed'
70
. 'recoor: Atomic-coordinates input format = ',
71
. 'Cartesian coordinates'
74
. '(in units of alat)'
75
else if (leqi(acf,'ScaledByLatticeVectors') .or.
76
. leqi(acf,'Fractional') ) then
77
if (alat.eq.0.d0) then
78
write(6,"(/,2a)") 'recoor: ERROR: Explicit lattice ',
79
. 'constant is needed for Fractional format'
80
stop 'recoor: ERROR: Explicit lattice constant needed'
84
. 'recoor: Atomic-coordinates input format = ',
85
. 'Ref. to lattice vectors'
87
write(6,"(/,'recoor: ',72(1h*))")
88
write(6,"('recoor: INPUT ERROR')")
89
write(6,'(a)') 'recoor: '
90
write(6,'(2a)') 'recoor: You must use one of the following',
91
. ' coordinate scaling options:'
92
write(6,'(a)') 'recoor: - NotScaledCartesianBohr '
93
write(6,'(a)') 'recoor: - NotScaledCartesianAng '
94
write(6,'(a)') 'recoor: - ScaledCartesian '
95
write(6,'(2a)') 'recoor: - ScaledByLatticeVectors ',
97
write(6,"('recoor: ',72(1h*))")
98
stop 'recoor: ERROR: Wrong atomic-coordinate input format'
102
c read atomic coordinates and species
104
if (.not. overflow) then
106
if ( fdf_block('AtomicCoordinatesAndAtomicSpecies',iunit) )
109
read(iunit,*) (xa(i,ia), i=1,3), isa(ia), xmass(ia)
112
write(6,"(/,'recoor: ',72(1h*))")
113
write(6,"('recoor: INPUT ERROR')")
115
. 'recoor: You must specify the atomic coordinates'
116
write(6,"('recoor: ',72(1h*))")
117
stop 'recoor: ERROR: Atomic coordinates missing'
120
if ( fdf_block('AtomicCoordinatesOrigin',iunit) ) then
121
read(iunit,*) (origin(i),i=1,3)
124
xa(i,ia) = xa(i,ia) + origin(i)
130
c Scale atomic coordinates
131
c Coord. option = 0 => Do nothing
132
c Coord. option = 1 => Multiply by 1./0.529177 (Ang --> Bohr)
133
c Coord. option = 2 => Multiply by lattice constant
134
c Coord. option = 3 => Multiply by lattice vectors
136
if (iscale .eq. 1) then
139
xa(ix,ia) = 1.d0 / 0.529177d0 * xa(ix,ia)
142
elseif (iscale .eq. 2) then
145
xa(ix,ia) = alat * xa(ix,ia)
148
elseif (iscale .eq. 3) then
154
xa(ix,ia) = cell(ix,1) * xac(1) +
155
. cell(ix,2) * xac(2) +
156
. cell(ix,3) * xac(3)
161
write(6,'(a)') 'recoor: Atomic coordinates (Bohr) and species'
163
write(6,"('recoor: ',i4,2x,3f10.5,i3)")
164
. ia,(xa(ix,ia),ix=1,3),isa(ia)