(git:27c966b)
Loading...
Searching...
No Matches
atom_upf.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Routines that process Quantum Espresso UPF files.
10!> \par History
11!> * 07.2018 CP2K-SIRIUS interface [Juerg Hutter]
12!> * 02.2016 created [Juerg Hutter]
13! **************************************************************************************************
21 USE ieee_arithmetic, ONLY: ieee_is_finite
22 USE kinds, ONLY: default_string_length,&
23 dp
25 ptable
26 USE upf_types, ONLY: atom_upfpot_type,&
30#include "../base/base_uses.f90"
31
32 IMPLICIT NONE
33
34 PRIVATE
36
37 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'atom_upf'
38
39! **************************************************************************************************
40
41CONTAINS
42
43! **************************************************************************************************
44!> \brief ...
45!> \param pot ...
46!> \param upf_filename ...
47!> \param read_header ...
48!> \param read_augmentation Import scalar USPP augmentation and optional full partial waves explicitly.
49!> This reader option does not enable USPP in a calculation method.
50! **************************************************************************************************
51 SUBROUTINE atom_read_upf(pot, upf_filename, read_header, read_augmentation)
52
53 TYPE(atom_upfpot_type) :: pot
54 CHARACTER(len=*), INTENT(IN) :: upf_filename
55 LOGICAL, INTENT(IN), OPTIONAL :: read_header, read_augmentation
56
57 CHARACTER(LEN=2) :: symbol
58 INTEGER :: l, ncore, nel
59 LOGICAL :: readall, readaug
60
61 IF (PRESENT(read_header)) THEN
62 readall = .NOT. read_header
63 ELSE
64 readall = .true.
65 END IF
66 readaug = .false.
67 IF (PRESENT(read_augmentation)) readaug = read_augmentation
68
69 ! filename
70 pot%filename = adjustl(trim(upf_filename))
71
72 ! Ignore json potentials as SIRIUS will parse those on its own.
73 l = len_trim(pot%filename)
74 IF (l >= 5) THEN
75 IF (pot%filename(l - 4:l) == '.json') THEN
76 pot%zion = 0.0_dp
77 RETURN
78 END IF
79 END IF
80
81 CALL atom_read_upf_v2(pot, upf_filename, readall, readaug)
82
83 ! set up econf
84 IF (sum(pot%econf) == 0) THEN
85 symbol = adjustl(trim(pot%symbol))
86 CALL get_ptable_info(symbol, number=ncore)
87 pot%econf(0:3) = ptable(ncore)%e_conv(0:3)
88 nel = nint(ncore - pot%zion)
89 SELECT CASE (nel)
90 CASE DEFAULT
91 cpabort("Unknown Core State")
92 CASE (0)
93 ! no core electron
94 CASE (2)
95 pot%econf(0:3) = pot%econf(0:3) - ptable(2)%e_conv(0:3)
96 CASE (10)
97 pot%econf(0:3) = pot%econf(0:3) - ptable(10)%e_conv(0:3)
98 CASE (18)
99 pot%econf(0:3) = pot%econf(0:3) - ptable(18)%e_conv(0:3)
100 CASE (28)
101 pot%econf(0:3) = pot%econf(0:3) - ptable(18)%e_conv(0:3)
102 pot%econf(2) = pot%econf(2) - 10
103 CASE (36)
104 pot%econf(0:3) = pot%econf(0:3) - ptable(36)%e_conv(0:3)
105 CASE (46)
106 pot%econf(0:3) = pot%econf(0:3) - ptable(36)%e_conv(0:3)
107 pot%econf(2) = pot%econf(2) - 10
108 CASE (54)
109 pot%econf(0:3) = pot%econf(0:3) - ptable(54)%e_conv(0:3)
110 CASE (60)
111 pot%econf(0:3) = pot%econf(0:3) - ptable(36)%e_conv(0:3)
112 pot%econf(2) = pot%econf(2) - 10
113 pot%econf(3) = pot%econf(3) - 14
114 CASE (62)
115 ! [Kr] 4d10 4f14 5s2 core, with 5p semicore in the valence (e.g. Pt).
116 pot%econf(0:3) = pot%econf(0:3) - [10, 18, 20, 14]
117 CASE (68)
118 pot%econf(0:3) = pot%econf(0:3) - ptable(54)%e_conv(0:3)
119 pot%econf(3) = pot%econf(3) - 14
120 CASE (78)
121 pot%econf(0:3) = pot%econf(0:3) - ptable(54)%e_conv(0:3)
122 pot%econf(2) = pot%econf(2) - 10
123 pot%econf(3) = pot%econf(3) - 14
124 END SELECT
125 !
126 cpassert(all(pot%econf >= 0))
127 END IF
128
129 ! name
130 IF (pot%pname == "") THEN
131 pot%pname = adjustl(trim(pot%symbol))
132 END IF
133
134 END SUBROUTINE atom_read_upf
135
136! **************************************************************************************************
137!> \brief ...
138!> \param pot ...
139!> \param upf_filename ...
140!> \param readall ...
141!> \param readaug Read scalar USPP augmentation arrays.
142! **************************************************************************************************
143 SUBROUTINE atom_read_upf_v2(pot, upf_filename, readall, readaug)
144
145 TYPE(atom_upfpot_type) :: pot
146 CHARACTER(len=*), INTENT(IN) :: upf_filename
147 LOGICAL, INTENT(IN) :: readall, readaug
148
149 CHARACTER(LEN=default_string_length) :: nametag
150 INTEGER :: ib, ntag
151 LOGICAL :: at_end
152 TYPE(cp_parser_type) :: parser
153
154 ntag = 0
155 CALL parser_create(parser, upf_filename, apply_preprocessing=.false.)
156 DO
157 at_end = .false.
158 CALL parser_get_next_line(parser, 1, at_end)
159 IF (at_end) EXIT
160 CALL parser_get_object(parser, nametag, lower_to_upper=.true.)
161 IF (nametag(1:1) /= "<") cycle
162 IF (ntag == 0) THEN
163 ! we are looking for UPF tag
164 IF (nametag(2:4) == "UPF") THEN
165 CALL parser_get_object(parser, nametag, lower_to_upper=.true.)
166 ! read UPF file version
167 CALL parser_get_object(parser, nametag, lower_to_upper=.true.)
168 pot%version = trim(nametag)
169 cpassert(nametag(1:5) == "2.0.1")
170 CALL parser_get_object(parser, nametag, lower_to_upper=.true.)
171 cpassert(nametag(1:1) == ">")
172 ntag = 1
173 END IF
174 ELSE IF (ntag == 1) THEN
175 ! we are looking for 1st level tags
176 IF (nametag(2:8) == "PP_INFO") THEN
177 cpassert(nametag(9:9) == ">")
178 CALL upf_info_section(parser, pot)
179 ELSE IF (nametag(2:10) == "PP_HEADER") THEN
180 IF (.NOT. (nametag(11:11) == ">")) THEN
181 CALL upf_header_option(parser, pot)
182 END IF
183 IF (readaug .AND. pot%is_ultrasoft .AND. .NOT. pot%is_paw .AND. pot%has_wfc) THEN
184 cpassert(.NOT. ALLOCATED(pot%partial_waves))
185 ALLOCATE (pot%partial_waves)
186 END IF
187 ELSE IF (nametag(2:8) == "PP_MESH") THEN
188 IF (.NOT. (nametag(9:9) == ">")) THEN
189 CALL upf_mesh_option(parser, pot)
190 END IF
191 CALL upf_mesh_section(parser, pot)
192 ELSE IF (nametag(2:8) == "PP_NLCC") THEN
193 IF (nametag(9:9) == ">") THEN
194 CALL upf_nlcc_section(parser, pot, .false.)
195 ELSE
196 CALL upf_nlcc_section(parser, pot, .true.)
197 END IF
198 ELSE IF (nametag(2:9) == "PP_LOCAL") THEN
199 IF (nametag(10:10) == ">") THEN
200 CALL upf_local_section(parser, pot, .false.)
201 ELSE
202 CALL upf_local_section(parser, pot, .true.)
203 END IF
204 ELSE IF (nametag(2:12) == "PP_NONLOCAL") THEN
205 cpassert(nametag(13:13) == ">")
206 CALL upf_nonlocal_section(parser, pot, readaug)
207 ELSE IF (nametag(2:13) == "PP_SEMILOCAL") THEN
208 CALL upf_semilocal_section(parser, pot)
209 ELSE IF (nametag(2:9) == "PP_PSWFC") THEN
210 ! skip section for now
211 ELSE IF (nametag(2:12) == "PP_FULL_WFC") THEN
212 IF (ALLOCATED(pot%partial_waves)) THEN
213 CALL upf_full_wfc_section(parser, pot%partial_waves, nametag, pot%mesh_size, pot%number_of_proj)
214 END IF
215 ELSE IF (nametag(2:11) == "PP_RHOATOM") THEN
216 ! skip section for now
217 ELSE IF (nametag(2:7) == "PP_PAW") THEN
218 ! skip section for now
219 ELSE IF (nametag(2:6) == "/UPF>") THEN
220 EXIT
221 END IF
222 END IF
223 END DO
224 CALL parser_release(parser)
225
226 cpassert(ntag > 0)
227
228 ! rescale projectors
229 IF (ALLOCATED(pot%beta)) THEN
230 cpassert(ALLOCATED(pot%r) .AND. ALLOCATED(pot%rab))
231 DO ib = 1, pot%number_of_proj
232 IF (pot%r(1) == 0.0_dp) THEN
233 pot%beta(2:, ib) = pot%beta(2:, ib)/pot%r(2:)
234 ELSE
235 pot%beta(:, ib) = pot%beta(:, ib)/pot%r(:)
236 END IF
237 END DO
238 END IF
239
240 ! test for not supported options
241 IF (readall) THEN
242 IF (pot%is_ultrasoft .AND. .NOT. readaug) THEN
243 cpabort("UPF ultrasoft pseudopotential not implemented")
244 END IF
245 IF (pot%is_paw) THEN
246 cpabort("UPF PAW potential not implemented")
247 END IF
248 END IF
249 IF (readaug .AND. pot%is_ultrasoft .AND. .NOT. pot%is_paw) THEN
250 cpassert(ALLOCATED(pot%qij) .AND. ALLOCATED(pot%qijl))
251 END IF
252
253 IF (ALLOCATED(pot%partial_waves)) THEN
254 cpassert(ALLOCATED(pot%partial_waves%ae_wfc))
255 cpassert(ALLOCATED(pot%partial_waves%ps_wfc))
256 cpassert(all(pot%partial_waves%angular_momenta == pot%lbeta))
257 END IF
258
259 END SUBROUTINE atom_read_upf_v2
260
261! **************************************************************************************************
262!> \brief ...
263!> \param parser ...
264!> \param pot ...
265! **************************************************************************************************
266 SUBROUTINE upf_info_section(parser, pot)
267 TYPE(cp_parser_type), INTENT(INOUT) :: parser
268 TYPE(atom_upfpot_type) :: pot
269
270 CHARACTER(LEN=default_string_length) :: line, string
271 INTEGER :: icount, iline
272 LOGICAL :: at_end
273
274 icount = 0
275 DO
276 CALL parser_get_next_line(parser, 1, at_end)
277 cpassert(.NOT. at_end)
278 iline = parser%buffer%present_line_number
279 line = trim(parser%buffer%input_lines(iline))
280 CALL parser_get_object(parser, string)
281 IF (string(1:10) == "</PP_INFO>") EXIT
282 icount = icount + 1
283 IF (icount > pot%maxinfo) cycle
284 pot%info(icount) = line
285 END DO
286 pot%maxinfo = icount
287
288 END SUBROUTINE upf_info_section
289
290! **************************************************************************************************
291!> \brief ...
292!> \param parser ...
293!> \param pot ...
294! **************************************************************************************************
295 SUBROUTINE upf_header_option(parser, pot)
296 TYPE(cp_parser_type), INTENT(INOUT) :: parser
297 TYPE(atom_upfpot_type) :: pot
298
299 CHARACTER(LEN=default_string_length) :: string
300 LOGICAL :: at_end
301
302 DO
303 IF (parser_test_next_token(parser) == "EOL") THEN
304 CALL parser_get_next_line(parser, 1, at_end)
305 cpassert(.NOT. at_end)
306 END IF
307 CALL parser_get_object(parser, string, lower_to_upper=.true.)
308 IF (string == "/>") EXIT
309 SELECT CASE (string)
310 CASE ("GENERATED")
311 CALL parser_get_object(parser, pot%generated, allow_empty=.true.)
312 CASE ("AUTHOR")
313 CALL parser_get_object(parser, pot%author, allow_empty=.true.)
314 CASE ("DATE")
315 CALL parser_get_object(parser, pot%date, allow_empty=.true.)
316 CASE ("COMMENT")
317 CALL parser_get_object(parser, pot%comment, allow_empty=.true.)
318 CASE ("ELEMENT")
319 CALL parser_get_object(parser, pot%symbol)
320 cpassert(2 <= len(pot%symbol))
321 CASE ("PSEUDO_TYPE")
322 CALL parser_get_object(parser, pot%pseudo_type)
323 CASE ("RELATIVISTIC")
324 CALL parser_get_object(parser, pot%relativistic)
325 CASE ("IS_ULTRASOFT")
326 CALL parser_get_object(parser, pot%is_ultrasoft)
327 CASE ("IS_PAW")
328 CALL parser_get_object(parser, pot%is_paw)
329 CASE ("IS_COULOMB")
330 CALL parser_get_object(parser, pot%is_coulomb)
331 CASE ("HAS_SO")
332 CALL parser_get_object(parser, pot%has_so)
333 CASE ("HAS_WFC")
334 CALL parser_get_object(parser, pot%has_wfc)
335 CASE ("HAS_GIPAW")
336 CALL parser_get_object(parser, pot%has_gipaw)
337 CASE ("PAW_AS_GIPAW")
338 CALL parser_get_object(parser, pot%paw_as_gipaw)
339 CASE ("CORE_CORRECTION")
340 CALL parser_get_object(parser, pot%core_correction)
341 CASE ("FUNCTIONAL")
342 CALL parser_get_object(parser, pot%functional)
343 CASE ("Z_VALENCE")
344 CALL parser_get_object(parser, pot%zion)
345 CASE ("TOTAL_PSENERGY")
346 CALL parser_get_object(parser, pot%total_psenergy)
347 CASE ("WFC_CUTOFF")
348 CALL parser_get_object(parser, pot%wfc_cutoff)
349 CASE ("RHO_CUTOFF")
350 CALL parser_get_object(parser, pot%rho_cutoff)
351 CASE ("L_MAX")
352 CALL parser_get_object(parser, pot%l_max)
353 CASE ("L_MAX_RHO")
354 CALL parser_get_object(parser, pot%l_max_rho)
355 CASE ("L_LOCAL")
356 CALL parser_get_object(parser, pot%l_local)
357 CASE ("MESH_SIZE")
358 CALL parser_get_object(parser, pot%mesh_size)
359 CASE ("NUMBER_OF_WFC")
360 CALL parser_get_object(parser, pot%number_of_wfc)
361 CASE ("NUMBER_OF_PROJ")
362 CALL parser_get_object(parser, pot%number_of_proj)
363 CASE DEFAULT
364 cpwarn(string)
365 CALL cp_abort(__location__, "Error while parsing UPF header: "// &
366 "Adjust format of delimiters ... only double quotes are admissible.")
367 END SELECT
368 END DO
369
370 END SUBROUTINE upf_header_option
371
372! **************************************************************************************************
373!> \brief ...
374!> \param parser ...
375!> \param pot ...
376! **************************************************************************************************
377 SUBROUTINE upf_mesh_option(parser, pot)
378 TYPE(cp_parser_type), INTENT(INOUT) :: parser
379 TYPE(atom_upfpot_type) :: pot
380
381 CHARACTER(LEN=default_string_length) :: string
382 INTEGER :: jj
383 LOGICAL :: at_end
384
385 DO
386 IF (parser_test_next_token(parser) == "EOL") THEN
387 CALL parser_get_next_line(parser, 1, at_end)
388 cpassert(.NOT. at_end)
389 END IF
390 CALL parser_get_object(parser, string, lower_to_upper=.true.)
391 IF (string == ">") EXIT
392 SELECT CASE (string)
393 CASE ("DX")
394 CALL parser_get_object(parser, pot%dx)
395 CASE ("XMIN")
396 CALL parser_get_object(parser, pot%xmin)
397 CASE ("RMAX")
398 CALL parser_get_object(parser, pot%rmax)
399 CASE ("MESH")
400 CALL parser_get_object(parser, jj)
401 cpassert(pot%mesh_size == jj)
402 CASE ("ZMESH")
403 CALL parser_get_object(parser, pot%zmesh)
404 CASE DEFAULT
405 cpabort("Unknown UPF PP_MESH option <"//trim(string)//"> found")
406 END SELECT
407
408 END DO
409
410 END SUBROUTINE upf_mesh_option
411
412! **************************************************************************************************
413!> \brief ...
414!> \param parser ...
415!> \param pot ...
416! **************************************************************************************************
417 SUBROUTINE upf_mesh_section(parser, pot)
418 TYPE(cp_parser_type), INTENT(INOUT) :: parser
419 TYPE(atom_upfpot_type) :: pot
420
421 CHARACTER(LEN=default_string_length) :: line, string, string2
422 INTEGER :: icount, m, mc, ms
423 LOGICAL :: at_end
424
425 DO
426 CALL parser_get_next_line(parser, 1, at_end)
427 cpassert(.NOT. at_end)
428 CALL parser_get_object(parser, string, lower_to_upper=.true.)
429 SELECT CASE (string)
430 CASE ("<PP_R", "<PP_R>")
431 m = pot%mesh_size
432 ms = pot%mesh_size
433 mc = 1
434 IF (string /= "<PP_R>") THEN
435 ! options
436 DO
437 IF (parser_test_next_token(parser) == "EOL") THEN
438 CALL parser_get_next_line(parser, 1, at_end)
439 cpassert(.NOT. at_end)
440 END IF
441 CALL parser_get_object(parser, string2, lower_to_upper=.true.)
442 IF (string2 == ">") EXIT
443 SELECT CASE (string2)
444 CASE ("TYPE")
445 CALL parser_get_object(parser, line, lower_to_upper=.true.)
446 cpassert(line == "REAL")
447 CASE ("SIZE")
448 CALL parser_get_object(parser, ms)
449 cpassert(ms <= m)
450 CASE ("COLUMNS")
451 CALL parser_get_object(parser, mc)
452 CASE DEFAULT
453 cpabort("Unknown UPF PP_R option <"//trim(string2)//"> found")
454 END SELECT
455 END DO
456 END IF
457 ALLOCATE (pot%r(m))
458 pot%r = 0.0_dp
459 icount = 1
460 DO WHILE (icount <= ms)
461 IF (parser_test_next_token(parser) == "EOL") THEN
462 CALL parser_get_next_line(parser, 1, at_end)
463 cpassert(.NOT. at_end)
464 ELSE
465 CALL parser_get_object(parser, pot%r(icount))
466 icount = icount + 1
467 END IF
468 END DO
469 CASE ("<PP_RAB", "<PP_RAB>")
470 m = pot%mesh_size
471 ms = pot%mesh_size
472 mc = 1
473 IF (string /= "<PP_RAB>") THEN
474 ! options
475 DO
476 IF (parser_test_next_token(parser) == "EOL") THEN
477 CALL parser_get_next_line(parser, 1, at_end)
478 cpassert(.NOT. at_end)
479 END IF
480 CALL parser_get_object(parser, string2, lower_to_upper=.true.)
481 IF (string2 == ">") EXIT
482 SELECT CASE (string2)
483 CASE ("TYPE")
484 CALL parser_get_object(parser, line, lower_to_upper=.true.)
485 cpassert(line == "REAL")
486 CASE ("SIZE")
487 CALL parser_get_object(parser, ms)
488 cpassert(ms <= m)
489 CASE ("COLUMNS")
490 CALL parser_get_object(parser, mc)
491 CASE DEFAULT
492 cpabort("Unknown UPF PP_RAB option <"//trim(string2)//"> found")
493 END SELECT
494 END DO
495 END IF
496 ALLOCATE (pot%rab(m))
497 pot%rab = 0.0_dp
498 icount = 1
499 DO WHILE (icount <= ms)
500 IF (parser_test_next_token(parser) == "EOL") THEN
501 CALL parser_get_next_line(parser, 1, at_end)
502 cpassert(.NOT. at_end)
503 ELSE
504 CALL parser_get_object(parser, pot%rab(icount))
505 icount = icount + 1
506 END IF
507 END DO
508 CASE ("</PP_MESH>")
509 EXIT
510 CASE DEFAULT
511 !
512 END SELECT
513 END DO
514
515 END SUBROUTINE upf_mesh_section
516
517! **************************************************************************************************
518!> \brief ...
519!> \param parser ...
520!> \param pot ...
521!> \param options ...
522! **************************************************************************************************
523 SUBROUTINE upf_nlcc_section(parser, pot, options)
524 TYPE(cp_parser_type), INTENT(INOUT) :: parser
525 TYPE(atom_upfpot_type) :: pot
526 LOGICAL, INTENT(IN) :: options
527
528 CHARACTER(LEN=default_string_length) :: line, string
529 INTEGER :: icount, m, mc, ms
530 LOGICAL :: at_end
531
532 m = pot%mesh_size
533 ms = m
534 mc = 1
535 IF (options) THEN
536 DO
537 IF (parser_test_next_token(parser) == "EOL") THEN
538 CALL parser_get_next_line(parser, 1, at_end)
539 cpassert(.NOT. at_end)
540 END IF
541 CALL parser_get_object(parser, string, lower_to_upper=.true.)
542 IF (string == ">") EXIT
543 SELECT CASE (string)
544 CASE ("TYPE")
545 CALL parser_get_object(parser, line, lower_to_upper=.true.)
546 cpassert(line == "REAL")
547 CASE ("SIZE")
548 CALL parser_get_object(parser, ms)
549 cpassert(ms <= m)
550 CASE ("COLUMNS")
551 CALL parser_get_object(parser, mc)
552 CASE DEFAULT
553 cpabort("Unknown UPF PP_NLCC option <"//trim(string)//"> found")
554 END SELECT
555 END DO
556 END IF
557
558 ALLOCATE (pot%rho_nlcc(m))
559 pot%rho_nlcc = 0.0_dp
560 icount = 1
561 DO WHILE (icount <= ms)
562 IF (parser_test_next_token(parser) == "EOL") THEN
563 CALL parser_get_next_line(parser, 1, at_end)
564 cpassert(.NOT. at_end)
565 ELSE
566 CALL parser_get_object(parser, pot%rho_nlcc(icount))
567 icount = icount + 1
568 END IF
569 END DO
570
571 CALL parser_get_next_line(parser, 1, at_end)
572 cpassert(.NOT. at_end)
573 CALL parser_get_object(parser, string, lower_to_upper=.true.)
574 cpassert(string == "</PP_NLCC>")
575
576 END SUBROUTINE upf_nlcc_section
577
578! **************************************************************************************************
579!> \brief ...
580!> \param parser ...
581!> \param pot ...
582!> \param options ...
583! **************************************************************************************************
584 SUBROUTINE upf_local_section(parser, pot, options)
585 TYPE(cp_parser_type), INTENT(INOUT) :: parser
586 TYPE(atom_upfpot_type) :: pot
587 LOGICAL, INTENT(IN) :: options
588
589 CHARACTER(LEN=default_string_length) :: line, string
590 INTEGER :: icount, m, mc, ms
591 LOGICAL :: at_end
592
593 m = pot%mesh_size
594 ms = m
595 mc = 1
596 IF (options) THEN
597 DO
598 IF (parser_test_next_token(parser) == "EOL") THEN
599 CALL parser_get_next_line(parser, 1, at_end)
600 cpassert(.NOT. at_end)
601 END IF
602 CALL parser_get_object(parser, string, lower_to_upper=.true.)
603 IF (string == ">") EXIT
604 SELECT CASE (string)
605 CASE ("TYPE")
606 CALL parser_get_object(parser, line, lower_to_upper=.true.)
607 cpassert(line == "REAL")
608 CASE ("SIZE")
609 CALL parser_get_object(parser, ms)
610 cpassert(ms <= m)
611 CASE ("COLUMNS")
612 CALL parser_get_object(parser, mc)
613 CASE DEFAULT
614 cpabort("Unknown UPF PP_LOCAL option <"//trim(string)//"> found")
615 END SELECT
616 END DO
617 END IF
618
619 ALLOCATE (pot%vlocal(m))
620 pot%vlocal = 0.0_dp
621 icount = 1
622 DO WHILE (icount <= ms)
623 IF (parser_test_next_token(parser) == "EOL") THEN
624 CALL parser_get_next_line(parser, 1, at_end)
625 cpassert(.NOT. at_end)
626 ELSE
627 CALL parser_get_object(parser, pot%vlocal(icount))
628 icount = icount + 1
629 END IF
630 END DO
631
632 ! Ry -> Hartree
633 pot%vlocal = 0.5_dp*pot%vlocal
634
635 CALL parser_get_next_line(parser, 1, at_end)
636 cpassert(.NOT. at_end)
637 CALL parser_get_object(parser, string, lower_to_upper=.true.)
638 cpassert(string == "</PP_LOCAL>")
639
640 END SUBROUTINE upf_local_section
641
642! **************************************************************************************************
643!> \brief ...
644!> \param parser ...
645!> \param pot ...
646!> \param readaug Import angular-resolved USPP augmentation data.
647! **************************************************************************************************
648 SUBROUTINE upf_nonlocal_section(parser, pot, readaug)
649 TYPE(cp_parser_type), INTENT(INOUT) :: parser
650 TYPE(atom_upfpot_type) :: pot
651 LOGICAL, INTENT(IN) :: readaug
652
653 CHARACTER(LEN=default_string_length) :: line, string
654 INTEGER :: i1, i2, ibeta, icount, la, m, mc, ms, &
655 nbeta
656 LOGICAL :: at_end
657
658 m = pot%mesh_size
659 nbeta = pot%number_of_proj
660 ALLOCATE (pot%dion(nbeta, nbeta), pot%beta(m, nbeta), pot%lbeta(nbeta))
661 pot%dion = 0.0_dp
662 pot%beta = 0.0_dp
663 pot%lbeta = -1
664
665 ibeta = 0
666 DO
667 CALL parser_get_next_line(parser, 1, at_end)
668 cpassert(.NOT. at_end)
669 CALL parser_get_object(parser, string, lower_to_upper=.true.)
670 IF (string(1:8) == "<PP_BETA") THEN
671 ms = m
672 ibeta = ibeta + 1
673 i1 = ibeta
674 la = 0
675 cpassert(ibeta <= nbeta)
676 DO
677 IF (parser_test_next_token(parser) == "EOL") THEN
678 CALL parser_get_next_line(parser, 1, at_end)
679 cpassert(.NOT. at_end)
680 END IF
681 CALL parser_get_object(parser, string, lower_to_upper=.true.)
682 IF (string == ">") EXIT
683 SELECT CASE (string)
684 CASE ("TYPE")
685 CALL parser_get_object(parser, line, lower_to_upper=.true.)
686 cpassert(line == "REAL")
687 CASE ("SIZE")
688 CALL parser_get_object(parser, ms)
689 cpassert(ms <= m)
690 CASE ("COLUMNS")
691 CALL parser_get_object(parser, mc)
692 CASE ("INDEX")
693 CALL parser_get_object(parser, i1)
694 cpassert(i1 <= nbeta)
695 CASE ("ANGULAR_MOMENTUM")
696 CALL parser_get_object(parser, la)
697 CASE ("LABEL")
698 CALL parser_get_object(parser, line, allow_empty=.true.)
699 ! not used currently
700 CASE ("CUTOFF_RADIUS_INDEX")
701 CALL parser_get_object(parser, line)
702 ! not used currently
703 CASE ("CUTOFF_RADIUS")
704 CALL parser_get_object(parser, line)
705 ! not used currently
706 CASE ("ULTRASOFT_CUTOFF_RADIUS")
707 CALL parser_get_object(parser, line)
708 ! not used currently
709 CASE DEFAULT
710 cpabort("Unknown UPF PP_BETA option <"//trim(string)//"> found")
711 END SELECT
712 END DO
713 pot%lbeta(i1) = la
714 icount = 1
715 DO WHILE (icount <= ms)
716 IF (parser_test_next_token(parser) == "EOL") THEN
717 CALL parser_get_next_line(parser, 1, at_end)
718 cpassert(.NOT. at_end)
719 ELSE
720 CALL parser_get_object(parser, pot%beta(icount, i1))
721 icount = icount + 1
722 END IF
723 END DO
724 ELSE IF (string(1:7) == "<PP_DIJ") THEN
725 ms = nbeta*nbeta
726 IF (string /= "<PP_DIJ>") THEN
727 DO
728 IF (parser_test_next_token(parser) == "EOL") THEN
729 CALL parser_get_next_line(parser, 1, at_end)
730 cpassert(.NOT. at_end)
731 END IF
732 CALL parser_get_object(parser, string, lower_to_upper=.true.)
733 IF (string == ">") EXIT
734 SELECT CASE (string)
735 CASE ("TYPE")
736 CALL parser_get_object(parser, line, lower_to_upper=.true.)
737 cpassert(line == "REAL")
738 CASE ("SIZE")
739 CALL parser_get_object(parser, ms)
740 cpassert(ms == nbeta*nbeta)
741 CASE ("COLUMNS")
742 CALL parser_get_object(parser, mc)
743 CASE DEFAULT
744 cpabort("Unknown UPF PP_DIJ option <"//trim(string)//"> found")
745 END SELECT
746 END DO
747 END IF
748 icount = 1
749 DO WHILE (icount <= ms)
750 IF (parser_test_next_token(parser) == "EOL") THEN
751 CALL parser_get_next_line(parser, 1, at_end)
752 cpassert(.NOT. at_end)
753 ELSE
754 i1 = (icount - 1)/nbeta + 1
755 i2 = mod(icount - 1, nbeta) + 1
756 CALL parser_get_object(parser, pot%dion(i1, i2))
757 icount = icount + 1
758 END IF
759 END DO
760 ELSE IF (string(1:16) == "<PP_AUGMENTATION") THEN
761 IF (readaug .AND. .NOT. pot%is_paw) CALL upf_augmentation_section(parser, pot)
762 ELSE IF (string(1:14) == "</PP_NONLOCAL>") THEN
763 EXIT
764 END IF
765 END DO
766
767 ! Convert the complete beta*D*beta operator from Ry to Hartree without
768 ! changing the tabulated projector amplitude. This also preserves the
769 ! projector convention needed by augmentation charges and PAW duality.
770 ! Some NC converters put energy units into beta and inverse energy into D;
771 ! preserving their numerical beta still gives the correct operator here.
772 ! The radial prefactor in PP_BETA is removed after reading the whole file.
773 pot%dion = 0.5_dp*pot%dion
774
775 END SUBROUTINE upf_nonlocal_section
776
777! **************************************************************************************************
778!> \brief Read angular-momentum-resolved USPP augmentation in its tabulated convention.
779!> PP_Q is retained independently of the radial quadrature of PP_QIJL. Those
780!> quantities need not agree exactly in a finite-precision dataset. No energy
781!> conversion or projector normalization is applied to either augmentation array.
782!> \param parser UPF token stream, positioned after the PP_AUGMENTATION tag name.
783!> \param pot UPF data with the mesh and all beta angular momenta already read.
784! **************************************************************************************************
785 SUBROUTINE upf_augmentation_section(parser, pot)
786 TYPE(cp_parser_type), INTENT(INOUT) :: parser
787 TYPE(atom_upfpot_type), INTENT(INOUT) :: pot
788
789 CHARACTER(LEN=default_string_length) :: string, tag, value
790 INTEGER :: i, j, k, l, lmax, m, nb, nc, nqf, nqlc, &
791 pair, size_data, tag_i, tag_j, tag_l
792 LOGICAL :: at_end, is_null, q_with_l, read_q, &
793 self_closing
794 LOGICAL, ALLOCATABLE :: present_channel(:, :)
795
796 cpassert(.NOT. ALLOCATED(pot%qij) .AND. .NOT. ALLOCATED(pot%qijl))
797 cpassert(all(pot%lbeta >= 0))
798 nb = pot%number_of_proj
799 m = pot%mesh_size
800 lmax = 2*maxval(pot%lbeta)
801 q_with_l = .false.
802 nqf = -1
803 nqlc = lmax + 1
804 DO
805 IF (parser_test_next_token(parser) == "EOL") THEN
806 CALL parser_get_next_line(parser, 1, at_end)
807 cpassert(.NOT. at_end)
808 END IF
809 CALL parser_get_object(parser, string, lower_to_upper=.true.)
810 IF (string == ">") EXIT
811 SELECT CASE (string)
812 CASE ("Q_WITH_L")
813 CALL parser_get_object(parser, q_with_l)
814 CASE ("NQF")
815 CALL parser_get_object(parser, nqf)
816 CASE ("NQLC")
817 CALL parser_get_object(parser, nqlc)
818 CASE DEFAULT
819 cpabort("Unknown UPF PP_AUGMENTATION option <"//trim(string)//"> found")
820 END SELECT
821 END DO
822 IF (.NOT. q_with_l .OR. nqf /= 0) THEN
823 cpabort("Native USPP import requires angular-resolved PP_QIJL with nqf=0")
824 END IF
825 IF (nqlc == 0) nqlc = lmax + 1
826 cpassert(nqlc >= lmax + 1)
827 nc = nb*(nb + 1)/2
828 ALLOCATE (pot%qij(nb, nb), pot%qijl(m, nc, 0:lmax), present_channel(nc, 0:lmax))
829 pot%qij = 0.0_dp
830 pot%qijl = 0.0_dp
831 present_channel = .false.
832 read_q = .false.
833 DO
834 CALL parser_get_next_line(parser, 1, at_end)
835 cpassert(.NOT. at_end)
836 CALL parser_get_object(parser, tag, lower_to_upper=.true.)
837 IF (tag == "</PP_AUGMENTATION>") EXIT
838 IF (tag(1:2) == "</") cycle
839 cpassert(tag(1:8) == "<PP_QIJL" .OR. tag == "<PP_Q" .OR. tag == "<PP_Q>")
840 i = -1
841 j = -1
842 l = -1
843 pair = -1
844 size_data = m
845 IF (tag == "<PP_Q" .OR. tag == "<PP_Q>") size_data = nb*nb
846 is_null = .false.
847 self_closing = .false.
848 IF (tag /= "<PP_Q>") THEN
849 DO
850 IF (parser_test_next_token(parser) == "EOL") THEN
851 CALL parser_get_next_line(parser, 1, at_end)
852 cpassert(.NOT. at_end)
853 END IF
854 CALL parser_get_object(parser, string, lower_to_upper=.true.)
855 IF (string == ">") EXIT
856 IF (string == "/>") THEN
857 self_closing = .true.
858 EXIT
859 END IF
860 SELECT CASE (string)
861 CASE ("TYPE")
862 CALL parser_get_object(parser, value, lower_to_upper=.true.)
863 cpassert(value == "REAL")
864 CASE ("SIZE")
865 CALL parser_get_object(parser, size_data)
866 CASE ("COLUMNS")
867 CALL parser_get_object(parser, value)
868 CASE ("FIRST_INDEX")
869 CALL parser_get_object(parser, i)
870 CASE ("SECOND_INDEX")
871 CALL parser_get_object(parser, j)
872 CASE ("COMPOSITE_INDEX")
873 CALL parser_get_object(parser, pair)
874 CASE ("ANGULAR_MOMENTUM")
875 CALL parser_get_object(parser, l)
876 CASE ("IS_NULL")
877 CALL parser_get_object(parser, is_null)
878 CASE DEFAULT
879 cpabort("Unknown UPF augmentation array option <"//trim(string)//"> found")
880 END SELECT
881 END DO
882 END IF
883 IF (tag(1:8) == "<PP_QIJL") THEN
884 cpassert(i >= 1 .AND. i <= j .AND. j <= nb)
885 cpassert(pair == j*(j - 1)/2 + i)
886 cpassert(l >= abs(pot%lbeta(i) - pot%lbeta(j)))
887 cpassert(l <= pot%lbeta(i) + pot%lbeta(j))
888 cpassert(modulo(pot%lbeta(i) + pot%lbeta(j) - l, 2) == 0)
889 ! Cross-check the tag suffix as well as the explicit attributes.
890 string = tag(10:)
891 DO k = 1, len_trim(string)
892 IF (string(k:k) == ".") string(k:k) = " "
893 END DO
894 READ (string, *) tag_i, tag_j, tag_l
895 cpassert(tag_i == i .AND. tag_j == j .AND. tag_l == l)
896 cpassert(.NOT. present_channel(pair, l))
897 present_channel(pair, l) = .true.
898 IF (is_null) THEN
899 cpassert(self_closing .AND. size_data == 0)
900 cycle
901 END IF
902 cpassert(.NOT. self_closing .AND. size_data == m)
903 DO k = 1, m
904 DO WHILE (parser_test_next_token(parser) == "EOL")
905 CALL parser_get_next_line(parser, 1, at_end)
906 cpassert(.NOT. at_end)
907 END DO
908 CALL parser_get_object(parser, pot%qijl(k, pair, l))
909 END DO
910 ELSE
911 cpassert(.NOT. read_q .AND. .NOT. self_closing .AND. .NOT. is_null)
912 cpassert(size_data == nb*nb)
913 DO j = 1, nb
914 DO i = 1, nb
915 DO WHILE (parser_test_next_token(parser) == "EOL")
916 CALL parser_get_next_line(parser, 1, at_end)
917 cpassert(.NOT. at_end)
918 END DO
919 CALL parser_get_object(parser, pot%qij(i, j))
920 END DO
921 END DO
922 read_q = .true.
923 END IF
924 END DO
925 cpassert(read_q)
926 DO j = 1, nb
927 DO i = 1, j
928 pair = j*(j - 1)/2 + i
929 DO l = abs(pot%lbeta(i) - pot%lbeta(j)), pot%lbeta(i) + pot%lbeta(j), 2
930 cpassert(present_channel(pair, l))
931 END DO
932 END DO
933 END DO
934 END SUBROUTINE upf_augmentation_section
935
936! **************************************************************************************************
937!> \brief ...
938!> \param parser ...
939!> \param pot ...
940! **************************************************************************************************
941 SUBROUTINE upf_semilocal_section(parser, pot)
942 TYPE(cp_parser_type), INTENT(INOUT) :: parser
943 TYPE(atom_upfpot_type) :: pot
944
945 CHARACTER(LEN=default_string_length) :: line, string
946 INTEGER :: i1, ib, icount, la, lmax, m, mc, ms
947 LOGICAL :: at_end
948
949 m = pot%mesh_size
950 lmax = pot%l_max
951 ALLOCATE (pot%vsemi(m, lmax + 1))
952 pot%vsemi = 0.0_dp
953
954 ib = 0
955 DO
956 CALL parser_get_next_line(parser, 1, at_end)
957 cpassert(.NOT. at_end)
958 CALL parser_get_object(parser, string, lower_to_upper=.true.)
959 IF (string(1:7) == "<PP_VNL") THEN
960 ms = m
961 ib = ib + 1
962 i1 = ib
963 la = 0
964 cpassert(ib <= lmax + 1)
965 DO
966 IF (parser_test_next_token(parser) == "EOL") THEN
967 CALL parser_get_next_line(parser, 1, at_end)
968 cpassert(.NOT. at_end)
969 END IF
970 CALL parser_get_object(parser, string, lower_to_upper=.true.)
971 IF (string == ">") EXIT
972 SELECT CASE (string)
973 CASE ("TYPE")
974 CALL parser_get_object(parser, line, lower_to_upper=.true.)
975 cpassert(line == "REAL")
976 CASE ("SIZE")
977 CALL parser_get_object(parser, ms)
978 cpassert(ms <= m)
979 CASE ("COLUMNS")
980 CALL parser_get_object(parser, mc)
981 CASE ("L")
982 CALL parser_get_object(parser, la)
983 CASE DEFAULT
984 cpabort("Unknown UPF PP_VNL option <"//trim(string)//"> found")
985 END SELECT
986 END DO
987 i1 = la + 1
988 icount = 1
989 DO WHILE (icount <= ms)
990 IF (parser_test_next_token(parser) == "EOL") THEN
991 CALL parser_get_next_line(parser, 1, at_end)
992 cpassert(.NOT. at_end)
993 ELSE
994 CALL parser_get_object(parser, pot%vsemi(icount, i1))
995 icount = icount + 1
996 END IF
997 END DO
998 ELSE IF (string(1:15) == "</PP_SEMILOCAL>") THEN
999 EXIT
1000 ELSE
1001 !
1002 END IF
1003 END DO
1004 ! Ry -> Hartree
1005 pot%vsemi = 0.5_dp*pot%vsemi
1006
1007 END SUBROUTINE upf_semilocal_section
1008
1009! **************************************************************************************************
1010!> \brief Skip complete XML comment lines before original full-wave data.
1011!> \param parser ...
1012!> \param at_end ...
1013! **************************************************************************************************
1014 SUBROUTINE upf_next_line(parser, at_end)
1015 TYPE(cp_parser_type), INTENT(INOUT) :: parser
1016 LOGICAL, INTENT(OUT) :: at_end
1017
1018 CHARACTER(LEN=:), ALLOCATABLE :: line
1019 LOGICAL :: in_comment
1020
1021 in_comment = .false.
1022 DO
1023 CALL parser_get_next_line(parser, 1, at_end)
1024 IF (at_end) THEN
1025 cpassert(.NOT. in_comment)
1026 RETURN
1027 END IF
1028 line = adjustl(parser%buffer%input_lines(parser%buffer%present_line_number))
1029 IF (.NOT. in_comment .AND. index(line, '<!--') /= 1) RETURN
1030 in_comment = index(line, '-->') == 0
1031 END DO
1032 END SUBROUTINE upf_next_line
1033
1034! **************************************************************************************************
1035!> \brief Read an original full-wave array without normalization or unit conversion.
1036!> \param parser ...
1037!> \param tag ...
1038!> \param values ...
1039!> \param index_value ...
1040!> \param angular_momentum ...
1041! **************************************************************************************************
1042 SUBROUTINE upf_real_array(parser, tag, values, index_value, angular_momentum)
1043 TYPE(cp_parser_type), INTENT(INOUT) :: parser
1044 CHARACTER(LEN=*), INTENT(IN) :: tag
1045 REAL(dp), INTENT(OUT) :: values(:)
1046 INTEGER, INTENT(OUT), OPTIONAL :: index_value, angular_momentum
1047
1048 CHARACTER(LEN=default_string_length) :: name, string, value
1049 INTEGER :: i, last, n
1050 LOGICAL :: at_end
1051
1052 n = SIZE(values)
1053 last = len_trim(tag)
1054 IF (PRESENT(index_value)) index_value = -1
1055 IF (PRESENT(angular_momentum)) angular_momentum = -1
1056 IF (tag(last:last) == ">") THEN
1057 name = tag(2:last - 1)
1058 ELSE
1059 name = tag(2:last)
1060 DO
1061 IF (parser_test_next_token(parser) == "EOL") THEN
1062 CALL upf_next_line(parser, at_end)
1063 cpassert(.NOT. at_end)
1064 END IF
1065 CALL parser_get_object(parser, string, lower_to_upper=.true.)
1066 IF (string == ">") EXIT
1067 SELECT CASE (string)
1068 CASE ("TYPE")
1069 CALL parser_get_object(parser, value, lower_to_upper=.true.)
1070 cpassert(value == "REAL")
1071 CASE ("SIZE")
1072 CALL parser_get_object(parser, n)
1073 cpassert(n == SIZE(values))
1074 CASE ("COLUMNS")
1075 CALL parser_get_object(parser, value)
1076 CASE ("INDEX")
1077 cpassert(PRESENT(index_value))
1078 CALL parser_get_object(parser, index_value)
1079 CASE ("L")
1080 cpassert(PRESENT(angular_momentum))
1081 CALL parser_get_object(parser, angular_momentum)
1082 CASE ("LABEL")
1083 CALL parser_get_object(parser, value, allow_empty=.true.)
1084 CASE DEFAULT
1085 cpabort("Unknown UPF "//trim(name)//" option <"//trim(string)//"> found")
1086 END SELECT
1087 END DO
1088 END IF
1089 DO i = 1, n
1090 DO WHILE (parser_test_next_token(parser) == "EOL")
1091 CALL upf_next_line(parser, at_end)
1092 cpassert(.NOT. at_end)
1093 END DO
1094 CALL parser_get_object(parser, values(i))
1095 END DO
1096 cpassert(all(ieee_is_finite(values)))
1097 CALL upf_next_line(parser, at_end)
1098 cpassert(.NOT. at_end)
1099 CALL parser_get_object(parser, string, lower_to_upper=.true.)
1100 cpassert(string == "</"//trim(name)//">")
1101 END SUBROUTINE upf_real_array
1102
1103! **************************************************************************************************
1104!> \brief Import projector-indexed AE and PS partial waves, retaining r*phi(r).
1105!> \param parser ...
1106!> \param waves ...
1107!> \param opening_tag ...
1108!> \param mesh_size ...
1109!> \param number_of_proj ...
1110! **************************************************************************************************
1111 SUBROUTINE upf_full_wfc_section(parser, waves, opening_tag, mesh_size, number_of_proj)
1112 TYPE(cp_parser_type), INTENT(INOUT) :: parser
1113
1114 CLASS(upf_partial_waves_type), INTENT(INOUT) :: waves
1115 CHARACTER(LEN=*), INTENT(IN) :: opening_tag
1116 INTEGER, INTENT(IN) :: mesh_size, number_of_proj
1117
1118 CHARACTER(LEN=default_string_length) :: string, suffix, tag
1119 INTEGER :: i, index_value, ios, l, last, m, n, nb, &
1120 wave_type
1121 LOGICAL :: at_end
1122 LOGICAL, ALLOCATABLE :: found(:, :)
1123 REAL(dp), ALLOCATABLE :: values(:)
1124
1125 nb = number_of_proj
1126 m = mesh_size
1127 cpassert(nb > 0 .AND. m > 0)
1128 cpassert(.NOT. ALLOCATED(waves%ae_wfc) .AND. .NOT. ALLOCATED(waves%ps_wfc))
1129 cpassert(.NOT. ALLOCATED(waves%angular_momenta))
1130 IF (opening_tag /= "<PP_FULL_WFC>") THEN
1131 DO
1132 IF (parser_test_next_token(parser) == "EOL") THEN
1133 CALL upf_next_line(parser, at_end)
1134 cpassert(.NOT. at_end)
1135 END IF
1136 CALL parser_get_object(parser, string, lower_to_upper=.true.)
1137 IF (string == ">") EXIT
1138 cpassert(string == "NUMBER_OF_WFC")
1139 CALL parser_get_object(parser, n)
1140 cpassert(n == nb)
1141 END DO
1142 END IF
1143 ALLOCATE (waves%ae_wfc(m, nb), waves%ps_wfc(m, nb), waves%angular_momenta(nb))
1144 ALLOCATE (found(nb, 2), values(m))
1145 found = .false.
1146 waves%angular_momenta = -1
1147 DO
1148 CALL upf_next_line(parser, at_end)
1149 cpassert(.NOT. at_end)
1150 CALL parser_get_object(parser, tag, lower_to_upper=.true.)
1151 IF (tag == "</PP_FULL_WFC>") EXIT
1152 SELECT CASE (tag(1:10))
1153 CASE ("<PP_AEWFC.")
1154 wave_type = 1
1155 CASE ("<PP_PSWFC.")
1156 wave_type = 2
1157 CASE DEFAULT
1158 cpabort("Unknown UPF full partial-wave tag "//trim(tag))
1159 END SELECT
1160 last = len_trim(tag)
1161 IF (tag(last:last) == ">") last = last - 1
1162 suffix = tag(11:last)
1163 READ (suffix, *, iostat=ios) i
1164 cpassert(ios == 0)
1165 cpassert(i >= 1 .AND. i <= nb)
1166 cpassert(.NOT. found(i, wave_type))
1167 CALL upf_real_array(parser, tag, values, index_value, l)
1168 IF (index_value /= -1) THEN
1169 cpassert(index_value == i)
1170 END IF
1171 cpassert(l >= 0)
1172 IF (waves%angular_momenta(i) >= 0) THEN
1173 cpassert(l == waves%angular_momenta(i))
1174 END IF
1175 waves%angular_momenta(i) = l
1176 IF (wave_type == 1) THEN
1177 waves%ae_wfc(:, i) = values
1178 ELSE
1179 waves%ps_wfc(:, i) = values
1180 END IF
1181 found(i, wave_type) = .true.
1182 END DO
1183 cpassert(all(found))
1184 END SUBROUTINE upf_full_wfc_section
1185
1186! **************************************************************************************************
1187!> \brief ...
1188!> \param upfpot ...
1189! **************************************************************************************************
1190 PURE SUBROUTINE atom_release_upf(upfpot)
1191
1192 TYPE(atom_upfpot_type), INTENT(INOUT) :: upfpot
1193
1194 ! Intrinsic assignment releases all allocatable components, including NLCC,
1195 ! and clears metadata before this temporary is reused for another KIND.
1196 CALL upf_release(upfpot)
1197
1198 END SUBROUTINE atom_release_upf
1199! **************************************************************************************************
1200
1201END MODULE atom_upf
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
Routines that process Quantum Espresso UPF files.
Definition atom_upf.F:14
pure subroutine, public atom_release_upf(upfpot)
...
Definition atom_upf.F:1191
subroutine, public atom_read_upf(pot, upf_filename, read_header, read_augmentation)
...
Definition atom_upf.F:52
Utility routines to read data from files. Kept as close as possible to the old parser because.
subroutine, public parser_get_next_line(parser, nline, at_end)
Read the next input line and broadcast the input information. Skip (nline-1) lines and skip also all ...
character(len=3) function, public parser_test_next_token(parser, string_length)
Test next input object.
Utility routines to read data from files. Kept as close as possible to the old parser because.
subroutine, public parser_release(parser)
releases the parser
subroutine, public parser_create(parser, file_name, unit_nr, para_env, end_section_label, separator_chars, comment_char, continuation_char, quote_char, section_char, parse_white_lines, initial_variables, apply_preprocessing)
Start a parser run. Initial variables allow to @SET stuff before opening the file.
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
Periodic Table related data definitions.
type(atom), dimension(0:nelem), public ptable
subroutine, public get_ptable_info(symbol, number, amass, ielement, covalent_radius, metallic_radius, vdw_radius, found)
Pass information about the kind given the element symbol.
Owned UPF dataset and radial conventions shared by ATOM and Quickstep. Dataset availability does not ...
Definition upf_types.F:12
real(dp) function, dimension(size(pot%r)), public upf_radial_weights(pot)
Composite Simpson weights for dr on the supplied UPF mesh index.
Definition upf_types.F:100
pure subroutine, public upf_release(pot)
Release every owned field and reset metadata before reusing a dataset.
Definition upf_types.F:152