-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathprintout_base.f90
372 lines (336 loc) · 10.5 KB
/
printout_base.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
!
! Copyright (C) 2002-2011 Quantum ESPRESSO group
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
! This module contains subroutines to print computed quantities to
! standard output and ASCII file
MODULE printout_base
IMPLICIT NONE
SAVE
CHARACTER(LEN=256) :: fort_unit(30:44)
! ... fort_unit = fortran units for saving physical quantity
CHARACTER(LEN=256) :: pprefix
! ... prefix combined with the output path
CONTAINS
SUBROUTINE printout_base_init( outdir, prefix )
USE io_global, ONLY: ionode, ionode_id
USE mp_global, ONLY: intra_image_comm
! KNK_nimage
! USE mp_global, ONLY: my_image_id
USE mp, ONLY: mp_bcast
INTEGER :: iunit, ierr
CHARACTER(LEN=*), INTENT(IN) :: outdir
CHARACTER(LEN=*), INTENT(IN) :: prefix
! KNK_nimage
! CHARACTER(LEN=6), EXTERNAL :: int_to_char
IF( prefix /= ' ' ) THEN
pprefix = TRIM( prefix )
ELSE
pprefix = 'fpmd'
END IF
! KNK_nimage
! if (my_image_id > 0) pprefix = TRIM(pprefix) // '_' // TRIM(int_to_char( my_image_id ))
!
IF( outdir /= ' ' ) THEN
pprefix = TRIM( outdir ) // '/' // TRIM( pprefix )
END IF
ierr = 0
IF( ionode ) THEN
fort_unit(30) = trim(pprefix)//'.con'
fort_unit(31) = trim(pprefix)//'.eig'
fort_unit(32) = trim(pprefix)//'.pol'
fort_unit(33) = trim(pprefix)//'.evp'
fort_unit(34) = trim(pprefix)//'.vel'
fort_unit(35) = trim(pprefix)//'.pos'
fort_unit(36) = trim(pprefix)//'.cel'
fort_unit(37) = trim(pprefix)//'.for'
fort_unit(38) = trim(pprefix)//'.str'
fort_unit(39) = trim(pprefix)//'.nos'
fort_unit(40) = trim(pprefix)//'.the'
fort_unit(41) = trim(pprefix)//'.spr' ! wannier spread
fort_unit(42) = trim(pprefix)//'.wfc' ! wannier function
fort_unit(43) = trim(pprefix)//'.hrs' ! hirshfeld volumes
fort_unit(44) = trim(pprefix)//'.ncg' ! number of cgsteps
DO iunit = LBOUND( fort_unit, 1 ), UBOUND( fort_unit, 1 )
OPEN(UNIT=iunit, FILE=fort_unit(iunit), &
STATUS='unknown', POSITION='append', IOSTAT = ierr )
CLOSE( iunit )
END DO
END IF
CALL mp_bcast(ierr, ionode_id, intra_image_comm)
IF( ierr /= 0 ) THEN
CALL errore(' printout_base_init ', &
' error in opening unit, check outdir = '//TRIM(outdir),iunit)
END IF
RETURN
END SUBROUTINE printout_base_init
SUBROUTINE printout_base_open( suffix )
CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: suffix
INTEGER :: iunit
LOGICAL :: ok=.true.
! ... Open units 30, 31, ... 44 for simulation output
IF( PRESENT( suffix ) ) THEN
IF( LEN( suffix ) /= 3 ) &
CALL errore(" printout_base_open ", " wrong suffix ", 1 )
ok = .false.
END IF
DO iunit = LBOUND( fort_unit, 1 ), UBOUND( fort_unit, 1 )
IF( PRESENT( suffix ) ) THEN
IF( index( fort_unit(iunit), suffix, back=.TRUE. ) == &
( len_trim( fort_unit(iunit) ) - 2 ) ) THEN
OPEN( UNIT=iunit, FILE=fort_unit(iunit), STATUS='unknown', POSITION='append')
ok = .true.
END IF
ELSE
OPEN( UNIT=iunit, FILE=fort_unit(iunit), STATUS='unknown', POSITION='append')
END IF
END DO
IF( PRESENT( suffix ) ) THEN
IF( .NOT. ok ) &
CALL errore(" printout_base_open ", " file with suffix "//suffix//" not found ", 1 )
END IF
RETURN
END SUBROUTINE printout_base_open
FUNCTION printout_base_unit( suffix )
! return the unit corresponding to a given suffix
CHARACTER(LEN=*), INTENT(IN) :: suffix
INTEGER :: printout_base_unit
INTEGER :: iunit
LOGICAL :: ok
IF( LEN( suffix ) /= 3 ) &
CALL errore(" printout_base_unit ", " wrong suffix ", 1 )
ok = .false.
DO iunit = LBOUND( fort_unit, 1 ), UBOUND( fort_unit, 1 )
IF( index( fort_unit(iunit), suffix, back=.TRUE. ) == ( len_trim( fort_unit(iunit) ) - 2 ) ) THEN
printout_base_unit = iunit
ok = .true.
END IF
END DO
IF( .NOT. ok ) &
CALL errore(" printout_base_unit ", " file with suffix "//suffix//" not found ", 1 )
RETURN
END FUNCTION printout_base_unit
FUNCTION printout_base_name( suffix )
! return the full name of a print out file with a given suffix
CHARACTER(LEN=*), INTENT(IN) :: suffix
CHARACTER(LEN=256) :: printout_base_name
INTEGER :: iunit
LOGICAL :: ok
IF( LEN( suffix ) /= 3 ) &
CALL errore(" printout_base_name ", " wrong suffix ", 1 )
ok = .false.
DO iunit = LBOUND( fort_unit, 1 ), UBOUND( fort_unit, 1 )
IF( index( fort_unit(iunit), suffix, back=.TRUE. ) == ( len_trim( fort_unit(iunit) ) - 2 ) ) THEN
printout_base_name = fort_unit(iunit)
ok = .true.
END IF
END DO
IF( .NOT. ok ) &
CALL errore(" printout_base_name ", " file with suffix "//suffix//" not found ", 1 )
RETURN
END FUNCTION printout_base_name
SUBROUTINE printout_base_close( suffix )
CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: suffix
INTEGER :: iunit
LOGICAL :: topen
LOGICAL :: ok
! ... Close and flush unit 30, ... 44
IF( PRESENT( suffix ) ) THEN
IF( LEN( suffix ) /= 3 ) &
CALL errore(" printout_base_close ", " wrong suffix ", 1 )
ok = .false.
END IF
DO iunit = LBOUND( fort_unit, 1 ), UBOUND( fort_unit, 1 )
IF( PRESENT( suffix ) ) THEN
IF( index( fort_unit(iunit), suffix, back=.TRUE. ) == ( len_trim( fort_unit(iunit) ) - 2 ) ) THEN
INQUIRE( UNIT=iunit, OPENED=topen )
IF( topen ) CLOSE(iunit)
ok = .true.
END IF
ELSE
INQUIRE( UNIT=iunit, OPENED=topen )
IF (topen) CLOSE(iunit)
END IF
END DO
IF( PRESENT( suffix ) ) THEN
IF( .NOT. ok ) &
CALL errore(" printout_base_close ", " file with suffix "//suffix//" not found ", 1 )
END IF
RETURN
END SUBROUTINE printout_base_close
SUBROUTINE printout_pos( iunit, tau, nat, what, nfi, tps, label, fact, sort, head )
!
USE kinds
!
INTEGER, INTENT(IN) :: iunit, nat
REAL(DP), INTENT(IN) :: tau( :, : )
CHARACTER(LEN=3), INTENT(IN), OPTIONAL :: what
INTEGER, INTENT(IN), OPTIONAL :: nfi
REAL(DP), INTENT(IN), OPTIONAL :: tps
CHARACTER(LEN=3), INTENT(IN), OPTIONAL :: label( : )
REAL(DP), INTENT(IN), OPTIONAL :: fact
INTEGER, INTENT(IN), OPTIONAL :: sort( : )
CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: head
!
INTEGER :: ia, k
REAL(DP) :: f
!
IF( PRESENT( fact ) ) THEN
f = fact
ELSE
f = 1.0_DP
END IF
!
IF( PRESENT( head ) ) THEN
WRITE( iunit, 10 ) head
END IF
!
IF( PRESENT( what ) ) THEN
IF ( what == 'xyz' ) WRITE( iunit, *) nat
END IF
!
IF( PRESENT( nfi ) .AND. PRESENT( tps ) ) THEN
WRITE( iunit, 30 ) nfi, tps
ELSE IF( PRESENT( what ) ) THEN
IF( what == 'pos' ) THEN
WRITE( iunit, 40 )
ELSE IF( what == 'vel' ) THEN
WRITE( iunit, 50 )
ELSE IF( what == 'for' ) THEN
WRITE( iunit, 60 )
END IF
END IF
!
IF( PRESENT( label ) ) THEN
IF( PRESENT( sort ) ) THEN
DO ia = 1, nat
WRITE( iunit, 255 ) label( sort(ia) ), ( f * tau(k, sort(ia) ),k = 1,3)
END DO
ELSE
DO ia = 1, nat
WRITE( iunit, 255 ) label(ia), ( f * tau(k,ia),k = 1,3)
END DO
END IF
ELSE
DO ia = 1, nat
WRITE( iunit, 252 ) (tau(k,ia),k = 1,3)
END DO
END IF
10 FORMAT(3X,A)
30 FORMAT(I7,1X,F11.8)
40 FORMAT(3X,'ATOMIC_POSITIONS')
50 FORMAT(3X,'ATOMIC_VELOCITIES')
60 FORMAT(3X,'Forces acting on atoms (au):')
255 FORMAT(3X,A3,3E25.14)
252 FORMAT(3E25.14)
RETURN
END SUBROUTINE printout_pos
SUBROUTINE printout_cell( iunit, h, nfi, tps )
!
USE kinds
!
INTEGER, INTENT(IN) :: iunit
REAL(DP), INTENT(IN) :: h(3,3)
INTEGER, INTENT(IN), OPTIONAL :: nfi
REAL(DP), INTENT(IN), OPTIONAL :: tps
!
INTEGER :: i, j
!
IF( PRESENT( nfi ) .AND. PRESENT( tps ) ) THEN
WRITE( iunit, 30 ) nfi, tps
ELSE
WRITE( iunit, 40 )
END IF
!
DO i = 1, 3
WRITE( iunit, 100 ) (h(i,j),j=1,3)
END DO
!
30 FORMAT(I7,1X,F11.8)
40 FORMAT(3X,'CELL_PARAMETERS')
100 FORMAT(3F14.8)
RETURN
END SUBROUTINE printout_cell
SUBROUTINE printout_stress( iunit, str, nfi, tps )
!
USE kinds
!
INTEGER, INTENT(IN) :: iunit
REAL(DP), INTENT(IN) :: str(3,3)
INTEGER, INTENT(IN), OPTIONAL :: nfi
REAL(DP), INTENT(IN), OPTIONAL :: tps
!
INTEGER :: i, j
!
IF( PRESENT( nfi ) .AND. PRESENT( tps ) ) THEN
WRITE( iunit, 30 ) nfi, tps
ELSE
WRITE( iunit, 40 )
END IF
!
DO i = 1, 3
WRITE( iunit, 100 ) (str(i,j),j=1,3)
END DO
!
30 FORMAT(I7,1X,F11.8)
40 FORMAT(3X,'Total stress (GPa)')
100 FORMAT(3(F18.8,1X))
RETURN
END SUBROUTINE printout_stress
SUBROUTINE printout_vefftsvdw( iunit, veff, nat, nfi, tps )
!
USE kinds
!
INTEGER, INTENT(IN) :: iunit, nat
REAL(DP), INTENT(IN) :: veff(nat)
INTEGER, INTENT(IN), OPTIONAL :: nfi
REAL(DP), INTENT(IN), OPTIONAL :: tps
!
INTEGER :: i, j
!
IF( PRESENT( nfi ) .AND. PRESENT( tps ) ) THEN
WRITE( iunit, 30 ) nfi, tps
ELSE
WRITE( iunit, 40 )
END IF
!
DO i = 1, nat
WRITE( iunit, 100 ) veff(i)
END DO
!
30 FORMAT(I7,1X,F11.8)
40 FORMAT(3X,'Veff tsvdw')
100 FORMAT(F20.10)
RETURN
END SUBROUTINE printout_vefftsvdw
SUBROUTINE printout_wfc( iunit, wfc_temp, nband, nfi, tps, iss )
!
USE kinds
!
INTEGER, INTENT(IN) :: iunit, nband
REAL(DP), INTENT(IN) :: wfc_temp(3,nband)
INTEGER, INTENT(IN) :: nfi
REAL(DP), INTENT(IN) :: tps
INTEGER, INTENT(IN), OPTIONAL :: iss
!
INTEGER :: i, j
!
IF( PRESENT( iss ) ) THEN
WRITE( iunit, 40 ) nfi, tps, iss
ELSE
WRITE( iunit, 30 ) nfi, tps
END IF
!
DO i = 1, nband
WRITE( iunit, 100 ) (wfc_temp(j,i),j=1,3)
END DO
!
30 FORMAT(I7,1X,F11.8)
40 FORMAT(I7,1X,F11.8,1X,"spin=",I5)
100 FORMAT(3E25.14)
RETURN
END SUBROUTINE printout_wfc
END MODULE printout_base