PageRenderTime 52ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/Modules/read_cards.f90

http://github.com/NNemec/quantum-espresso
FORTRAN Modern | 2383 lines | 1151 code | 22 blank | 1210 comment | 88 complexity | 4f227ee54974e91bb842494d1b8913e4 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. !
  2. ! Copyright (C) 2002-2009 Quantum ESPRESSO group
  3. ! This file is distributed under the terms of the
  4. ! GNU General Public License. See the file `License'
  5. ! in the root directory of the present distribution,
  6. ! or http://www.gnu.org/copyleft/gpl.txt .
  7. !
  8. !---------------------------------------------------------------------------
  9. MODULE read_cards_module
  10. !---------------------------------------------------------------------------
  11. !
  12. ! ... This module handles the reading of cards from standard input
  13. ! ... Written by Carlo Cavazzoni and modified for "path" implementation
  14. ! ... by Carlo Sbraccia
  15. !
  16. USE kinds, ONLY : DP
  17. USE io_global, ONLY : stdout
  18. USE constants, ONLY : angstrom_au
  19. USE parser, ONLY : field_count, read_line, get_field
  20. USE io_global, ONLY : ionode, ionode_id
  21. !
  22. USE input_parameters
  23. !
  24. IMPLICIT NONE
  25. !
  26. SAVE
  27. !
  28. PRIVATE
  29. !
  30. PUBLIC :: read_cards
  31. !
  32. ! ... end of module-scope declarations
  33. !
  34. ! ----------------------------------------------
  35. !
  36. CONTAINS
  37. !
  38. ! ... Read CARDS ....
  39. !
  40. ! ... subroutines
  41. !
  42. !----------------------------------------------------------------------
  43. SUBROUTINE card_default_values( )
  44. !----------------------------------------------------------------------
  45. !
  46. USE autopilot, ONLY : init_autopilot
  47. !
  48. IMPLICIT NONE
  49. !
  50. !
  51. ! ... mask that control the printing of selected Kohn-Sham occupied
  52. ! ... orbitals, default allocation
  53. !
  54. CALL allocate_input_iprnks( 0, nspin )
  55. nprnks = 0
  56. !
  57. ! ... Simulation cell from standard input
  58. !
  59. trd_ht = .false.
  60. rd_ht = 0.0_DP
  61. !
  62. ! ... dipole
  63. !
  64. tdipole_card = .false.
  65. !
  66. ! ... Constraints
  67. !
  68. nconstr_inp = 0
  69. constr_tol_inp = 1.E-6_DP
  70. !
  71. ! ... ionic mass initialization
  72. !
  73. atom_mass = 0.0_DP
  74. !
  75. ! ... dimension of the real space Ewald summation
  76. !
  77. iesr_inp = 1
  78. !
  79. ! ... k-points
  80. !
  81. k_points = 'gamma'
  82. tk_inp = .false.
  83. nkstot = 1
  84. nk1 = 0
  85. nk2 = 0
  86. nk3 = 0
  87. k1 = 0
  88. k2 = 0
  89. k3 = 0
  90. !
  91. ! ... Grids
  92. !
  93. t2dpegrid_inp = .false.
  94. !
  95. ! ... Electronic states
  96. !
  97. tf_inp = .false.
  98. !
  99. ! ... Hartree planar mean
  100. !
  101. tvhmean_inp = .false.
  102. vhnr_inp = 0
  103. vhiunit_inp = 0
  104. vhrmin_inp = 0.0_DP
  105. vhrmax_inp = 0.0_DP
  106. vhasse_inp = 'K'
  107. !
  108. ! ... ion_velocities
  109. !
  110. tavel = .false.
  111. !
  112. ! ... setnfi
  113. !
  114. newnfi_card = -1
  115. tnewnfi_card = .false.
  116. !
  117. CALL init_autopilot()
  118. !
  119. RETURN
  120. !
  121. END SUBROUTINE card_default_values
  122. !
  123. !
  124. !----------------------------------------------------------------------
  125. SUBROUTINE read_cards ( prog )
  126. !----------------------------------------------------------------------
  127. !
  128. USE autopilot, ONLY : card_autopilot
  129. !
  130. IMPLICIT NONE
  131. !
  132. CHARACTER(len=2) :: prog ! calling program ( PW, CP, WA )
  133. CHARACTER(len=256) :: input_line
  134. CHARACTER(len=80) :: card
  135. CHARACTER(len=1), EXTERNAL :: capital
  136. LOGICAL :: tend
  137. INTEGER :: i
  138. !
  139. !
  140. CALL card_default_values( )
  141. !
  142. 100 CALL read_line( input_line, end_of_file=tend )
  143. !
  144. IF( tend ) GOTO 120
  145. IF( input_line == ' ' .or. input_line(1:1) == '#' ) GOTO 100
  146. !
  147. READ (input_line, *) card
  148. !
  149. DO i = 1, len_trim( input_line )
  150. input_line( i : i ) = capital( input_line( i : i ) )
  151. ENDDO
  152. !
  153. IF ( trim(card) == 'AUTOPILOT' ) THEN
  154. !
  155. CALL card_autopilot( input_line )
  156. !
  157. ELSEIF ( trim(card) == 'ATOMIC_SPECIES' ) THEN
  158. !
  159. CALL card_atomic_species( input_line, prog )
  160. !
  161. ELSEIF ( trim(card) == 'ATOMIC_POSITIONS' ) THEN
  162. !
  163. CALL card_atomic_positions( input_line, prog )
  164. !
  165. ELSEIF ( trim(card) == 'ATOMIC_FORCES' ) THEN
  166. !
  167. CALL card_atomic_forces( input_line, prog )
  168. !
  169. ELSEIF ( trim(card) == 'SETNFI' ) THEN
  170. !
  171. CALL card_setnfi( input_line )
  172. IF ( ( prog == 'PW' .or. prog == 'CP' ) .and. ionode ) &
  173. WRITE( stdout,'(A)') 'Warning: card '//trim(input_line)//' ignored'
  174. !
  175. ELSEIF ( trim(card) == 'CONSTRAINTS' ) THEN
  176. !
  177. CALL card_constraints( input_line )
  178. !
  179. ELSEIF ( trim(card) == 'COLLECTIVE_VARS' ) THEN
  180. !
  181. CALL card_collective_vars( input_line )
  182. !
  183. ELSEIF ( trim(card) == 'VHMEAN' ) THEN
  184. !
  185. CALL card_vhmean( input_line )
  186. IF ( ( prog == 'PW' .or. prog == 'CP' ) .and. ionode ) &
  187. WRITE( stdout,'(A)') 'Warning: card '//trim(input_line)//' ignored'
  188. !
  189. ELSEIF ( trim(card) == 'DIPOLE' ) THEN
  190. !
  191. CALL card_dipole( input_line )
  192. IF ( ( prog == 'PW' .or. prog == 'CP' ) .and. ionode ) &
  193. WRITE( stdout,'(A)') 'Warning: card '//trim(input_line)//' ignored'
  194. !
  195. ELSEIF ( trim(card) == 'ESR' ) THEN
  196. !
  197. CALL card_esr( input_line )
  198. IF ( ( prog == 'PW' .or. prog == 'CP' ) .and. ionode ) &
  199. WRITE( stdout,'(A)') 'Warning: card '//trim(input_line)//' ignored'
  200. !
  201. ELSEIF ( trim(card) == 'K_POINTS' ) THEN
  202. !
  203. IF ( ( prog == 'CP' ) ) THEN
  204. IF( ionode ) &
  205. WRITE( stdout,'(A)') 'Warning: card '//trim(input_line)//' ignored'
  206. ELSE
  207. CALL card_kpoints( input_line )
  208. ENDIF
  209. !
  210. ELSEIF ( trim(card) == 'OCCUPATIONS' ) THEN
  211. !
  212. CALL card_occupations( input_line )
  213. !
  214. ELSEIF ( trim(card) == 'CELL_PARAMETERS' ) THEN
  215. !
  216. CALL card_cell_parameters( input_line )
  217. !
  218. ELSEIF ( trim(card) == 'ATOMIC_VELOCITIES' ) THEN
  219. !
  220. CALL card_ion_velocities( input_line )
  221. IF ( prog == 'CP' .and. ionode ) &
  222. WRITE( stdout,'(A)') 'Warning: card '//trim(input_line)//' ignored'
  223. !
  224. ELSEIF ( trim(card) == 'KSOUT' ) THEN
  225. !
  226. CALL card_ksout( input_line )
  227. IF ( ( prog == 'PW' ) .and. ionode ) &
  228. WRITE( stdout,'(a)') 'Warning: card '//trim(input_line)//' ignored'
  229. !
  230. ELSEIF ( trim(card) == 'CLIMBING_IMAGES' ) THEN
  231. !
  232. CALL card_climbing_images( input_line )
  233. ELSEIF ( trim(card) == 'PLOT_WANNIER' ) THEN
  234. !
  235. CALL card_plot_wannier( input_line )
  236. ELSEIF ( trim(card) == 'WANNIER_AC' .and. ( prog == 'WA' )) THEN
  237. !
  238. CALL card_wannier_ac( input_line )
  239. ELSE
  240. !
  241. IF ( ionode ) &
  242. WRITE( stdout,'(A)') 'Warning: card '//trim(input_line)//' ignored'
  243. !
  244. ENDIF
  245. !
  246. ! ... END OF LOOP ... !
  247. !
  248. GOTO 100
  249. !
  250. 120 CONTINUE
  251. !
  252. RETURN
  253. !
  254. END SUBROUTINE read_cards
  255. !
  256. ! ... Description of the allowed input CARDS
  257. !
  258. !------------------------------------------------------------------------
  259. ! BEGIN manual
  260. !----------------------------------------------------------------------
  261. !
  262. ! ATOMIC_SPECIES
  263. !
  264. ! set the atomic species been read and their pseudopotential file
  265. !
  266. ! Syntax:
  267. !
  268. ! ATOMIC_SPECIE
  269. ! label(1) mass(1) psfile(1)
  270. ! ... ... ...
  271. ! label(n) mass(n) psfile(n)
  272. !
  273. ! Example:
  274. !
  275. ! ATOMIC_SPECIES
  276. ! O 16.0 O.BLYP.UPF
  277. ! H 1.00 H.fpmd.UPF
  278. !
  279. ! Where:
  280. !
  281. ! label(i) ( character(len=4) ) label of the atomic species
  282. ! mass(i) ( real ) atomic mass
  283. ! ( in u.m.a, carbon mass is 12.0 )
  284. ! psfile(i) ( character(len=80) ) file name of the pseudopotential
  285. !
  286. !----------------------------------------------------------------------
  287. ! END manual
  288. !------------------------------------------------------------------------
  289. !
  290. SUBROUTINE card_atomic_species( input_line, prog )
  291. !
  292. IMPLICIT NONE
  293. !
  294. CHARACTER(len=256) :: input_line
  295. CHARACTER(len=2) :: prog
  296. INTEGER :: is, ip, ierr
  297. CHARACTER(len=4) :: lb_pos
  298. CHARACTER(len=256) :: psfile
  299. LOGICAL, SAVE :: tread = .false.
  300. !
  301. !
  302. IF ( tread ) THEN
  303. CALL errore( ' card_atomic_species ', ' two occurrences', 2 )
  304. ENDIF
  305. IF ( ntyp > nsx ) THEN
  306. CALL errore( ' card_atomic_species ', ' nsp out of range ', ntyp )
  307. ENDIF
  308. !
  309. DO is = 1, ntyp
  310. !
  311. CALL read_line( input_line )
  312. READ( input_line, *, iostat=ierr ) lb_pos, atom_mass(is), psfile
  313. CALL errore( ' card_atomic_species ', 'cannot read atomic specie from: '//trim(input_line), abs(ierr))
  314. atom_pfile(is) = trim( psfile )
  315. lb_pos = adjustl( lb_pos )
  316. atom_label(is) = trim( lb_pos )
  317. !
  318. ! IF ( atom_mass(is) <= 0.0_DP ) THEN
  319. ! CALL errore( ' card_atomic_species ',' invalid atom_mass ', is )
  320. ! END IF
  321. DO ip = 1, is - 1
  322. IF ( atom_label(ip) == atom_label(is) ) THEN
  323. CALL errore( ' card_atomic_species ', &
  324. & ' two occurrences of the same atomic label ', is )
  325. ENDIF
  326. ENDDO
  327. !
  328. ENDDO
  329. taspc = .true.
  330. tread = .true.
  331. !
  332. RETURN
  333. !
  334. END SUBROUTINE card_atomic_species
  335. !
  336. !
  337. !------------------------------------------------------------------------
  338. ! BEGIN manual
  339. !----------------------------------------------------------------------
  340. !
  341. ! ATOMIC_POSITIONS
  342. !
  343. ! set the atomic positions in the cell
  344. !
  345. ! Syntax:
  346. !
  347. ! ATOMIC_POSITIONS (units_option)
  348. ! label(1) tau(1,1) tau(2,1) tau(3,1) mbl(1,1) mbl(2,1) mbl(3,1)
  349. ! label(2) tau(1,2) tau(2,2) tau(3,2) mbl(1,2) mbl(2,2) mbl(3,2)
  350. ! ... ... ... ... ...
  351. ! label(n) tau(1,n) tau(2,n) tau(3,n) mbl(1,3) mbl(2,3) mbl(3,3)
  352. !
  353. ! Example:
  354. !
  355. ! ATOMIC_POSITIONS (bohr)
  356. ! O 0.0099 0.0099 0.0000 0 0 0
  357. ! H 1.8325 -0.2243 -0.0001 1 1 1
  358. ! H -0.2243 1.8325 0.0002 1 1 1
  359. !
  360. ! Where:
  361. !
  362. ! units_option == crystal position are given in scaled units
  363. ! units_option == bohr position are given in Bohr
  364. ! units_option == angstrom position are given in Angstrom
  365. ! units_option == alat position are given in units of alat
  366. !
  367. ! label(k) ( character(len=4) ) atomic type
  368. ! tau(:,k) ( real ) coordinates of the k-th atom
  369. ! mbl(:,k) ( integer ) mbl(i,k) > 0 the i-th coord. of the
  370. ! k-th atom is allowed to be moved
  371. !
  372. !----------------------------------------------------------------------
  373. ! END manual
  374. !------------------------------------------------------------------------
  375. !
  376. ! ... routine modified for NEB ( C.S. 21/10/2003 )
  377. ! ... routine modified for SMD ( Y.K. 15/04/2004 )
  378. !
  379. SUBROUTINE card_atomic_positions( input_line, prog )
  380. !
  381. USE wrappers, ONLY: feval_infix
  382. !
  383. IMPLICIT NONE
  384. !
  385. CHARACTER(len=256) :: input_line
  386. CHARACTER(len=2) :: prog
  387. CHARACTER(len=4) :: lb_pos
  388. INTEGER :: ia, k, is, nfield, idx, rep_i
  389. LOGICAL, EXTERNAL :: matches
  390. LOGICAL :: tend
  391. LOGICAL, SAVE :: tread = .false.
  392. !
  393. INTEGER :: ifield, ierr
  394. REAL(DP) :: field_value
  395. CHARACTER(len=256) :: field_str, error_msg
  396. !
  397. !
  398. IF ( tread ) THEN
  399. CALL errore( 'card_atomic_positions', 'two occurrences', 2 )
  400. ENDIF
  401. IF ( .not. taspc ) THEN
  402. CALL errore( 'card_atomic_positions', &
  403. & 'ATOMIC_SPECIES must be present before', 2 )
  404. ENDIF
  405. IF ( ntyp > nsx ) THEN
  406. CALL errore( 'card_atomic_positions', 'nsp out of range', ntyp )
  407. ENDIF
  408. IF ( nat < 1 ) THEN
  409. CALL errore( 'card_atomic_positions', 'nat out of range', nat )
  410. ENDIF
  411. !
  412. if_pos = 1
  413. !
  414. sp_pos = 0
  415. rd_pos = 0.0_DP
  416. na_inp = 0
  417. !
  418. IF ( matches( "CRYSTAL", input_line ) ) THEN
  419. atomic_positions = 'crystal'
  420. ELSEIF ( matches( "BOHR", input_line ) ) THEN
  421. atomic_positions = 'bohr'
  422. ELSEIF ( matches( "ANGSTROM", input_line ) ) THEN
  423. atomic_positions = 'angstrom'
  424. ELSEIF ( matches( "ALAT", input_line ) ) THEN
  425. atomic_positions = 'alat'
  426. ELSE
  427. IF ( trim( adjustl( input_line ) ) /= 'ATOMIC_POSITIONS' ) THEN
  428. CALL errore( 'read_cards ', &
  429. & 'unknown option for ATOMIC_POSITION: '&
  430. & // input_line, 1 )
  431. ENDIF
  432. IF ( prog == 'FP' ) atomic_positions = 'bohr'
  433. IF ( prog == 'CP' ) atomic_positions = 'bohr'
  434. IF ( prog == 'PW' ) atomic_positions = 'alat'
  435. ENDIF
  436. !
  437. IF ( full_phs_path_flag ) THEN
  438. !
  439. IF ( allocated( pos ) ) DEALLOCATE( pos )
  440. ALLOCATE( pos( 3*nat, num_of_images ) )
  441. pos(:,:) = 0.0_DP
  442. !
  443. IF ( calculation == 'smd' .and. prog == 'CP' ) THEN
  444. !
  445. CALL errore( 'read_cards', &
  446. 'smd no longer implemented in CP', 1 )
  447. !
  448. ELSE
  449. !
  450. CALL read_line( input_line, end_of_file = tend )
  451. IF ( tend ) &
  452. CALL errore( 'read_cards', &
  453. 'end of file reading atomic positions (path)', 1 )
  454. !
  455. IF ( matches( "first_image", input_line ) ) THEN
  456. !
  457. input_images = 1
  458. CALL path_read_images( input_images )
  459. !
  460. ELSE
  461. !
  462. CALL errore( 'read_cards', &
  463. 'first_image missing in ATOMIC_POSITION', 1 )
  464. !
  465. ENDIF
  466. !
  467. read_conf_loop: DO
  468. !
  469. CALL read_line( input_line, end_of_file = tend )
  470. !
  471. IF ( tend ) &
  472. CALL errore( 'read_cards', 'end of file reading ' // &
  473. & 'atomic positions (path)', input_images + 1 )
  474. !
  475. input_images = input_images + 1
  476. IF ( input_images > num_of_images ) &
  477. CALL errore( 'read_cards', &
  478. & 'too many images in ATOMIC_POSITION', 1 )
  479. !
  480. IF ( matches( "intermediate_image", input_line ) ) THEN
  481. !
  482. CALL path_read_images( input_images )
  483. !
  484. ELSE
  485. !
  486. exit read_conf_loop
  487. !
  488. ENDIF
  489. !
  490. ENDDO read_conf_loop
  491. !
  492. IF ( matches( "last_image", input_line ) ) THEN
  493. !
  494. CALL path_read_images( input_images )
  495. !
  496. ELSE
  497. !
  498. CALL errore( 'read_cards ', &
  499. 'last_image missing in ATOMIC_POSITION', 1 )
  500. !
  501. ENDIF
  502. !
  503. ENDIF
  504. !
  505. ELSE
  506. !
  507. reader_loop : DO ia = 1,nat,1
  508. !
  509. CALL read_line( input_line, end_of_file = tend )
  510. IF ( tend ) &
  511. CALL errore( 'read_cards', &
  512. 'end of file reading atomic positions', ia )
  513. !
  514. CALL field_count( nfield, input_line )
  515. !
  516. IF ( sic /= 'none' .and. nfield /= 8 ) &
  517. CALL errore( 'read_cards', &
  518. 'ATOMIC_POSITIONS with sic, 8 columns required', 1 )
  519. !
  520. IF ( nfield /= 4 .and. nfield /= 7 .and. nfield /= 8) &
  521. CALL errore( 'read_cards', 'wrong number of columns ' // &
  522. & 'in ATOMIC_POSITIONS', ia )
  523. ! read atom symbol (column 1) and coordinate
  524. CALL get_field(1, lb_pos, input_line)
  525. lb_pos = trim(lb_pos)
  526. !
  527. error_msg = 'Error while parsing atomic position card.'
  528. ! read field 2 (atom X coordinate)
  529. CALL get_field(2, field_str, input_line)
  530. rd_pos(1,ia) = feval_infix(ierr, field_str )
  531. CALL errore('card_atomic_positions', error_msg, ierr)
  532. ! read field 2 (atom Y coordinate)
  533. CALL get_field(3, field_str, input_line)
  534. rd_pos(2,ia) = feval_infix(ierr, field_str )
  535. CALL errore('card_atomic_positions', error_msg, ierr)
  536. ! read field 2 (atom Z coordinate)
  537. CALL get_field(4, field_str, input_line)
  538. rd_pos(3,ia) = feval_infix(ierr, field_str )
  539. CALL errore('card_atomic_positions', error_msg, ierr)
  540. !
  541. IF ( nfield >= 7 ) THEN
  542. ! read constrains (fields 5-7, if present)
  543. CALL get_field(5, field_str, input_line)
  544. READ(field_str, *) if_pos(1,ia)
  545. CALL get_field(6, field_str, input_line)
  546. READ(field_str, *) if_pos(2,ia)
  547. CALL get_field(7, field_str, input_line)
  548. READ(field_str, *) if_pos(3,ia)
  549. ENDIF
  550. !
  551. IF ( nfield == 8 ) THEN
  552. CALL get_field(5, field_str, input_line)
  553. READ(field_str, *) id_loc(ia)
  554. ENDIF
  555. !
  556. match_label: DO is = 1, ntyp
  557. !
  558. IF ( trim(lb_pos) == trim( atom_label(is) ) ) THEN
  559. !
  560. sp_pos(ia) = is
  561. exit match_label
  562. !
  563. ENDIF
  564. !
  565. ENDDO match_label
  566. !
  567. IF( ( sp_pos(ia) < 1 ) .or. ( sp_pos(ia) > ntyp ) ) THEN
  568. !
  569. CALL errore( 'read_cards', 'species '//trim(lb_pos)// &
  570. & ' in ATOMIC_POSITIONS is nonexistent', ia )
  571. !
  572. ENDIF
  573. !
  574. is = sp_pos(ia)
  575. !
  576. na_inp(is) = na_inp(is) + 1
  577. !
  578. ENDDO reader_loop
  579. !
  580. ENDIF
  581. !
  582. ! DO is = 1, ntyp
  583. ! IF( na_inp( is ) < 1 ) THEN
  584. ! CALL errore( 'read_cards', &
  585. ! 'no atom found in ATOMIC_POSITIONS for species '//TRIM(atom_label(is)), is )
  586. ! END IF
  587. ! END DO
  588. !
  589. tapos = .true.
  590. tread = .true.
  591. !
  592. RETURN
  593. !
  594. CONTAINS
  595. !
  596. !-------------------------------------------------------------------
  597. SUBROUTINE path_read_images( image )
  598. !-------------------------------------------------------------------
  599. !
  600. IMPLICIT NONE
  601. !
  602. INTEGER, INTENT(in) :: image
  603. !
  604. !
  605. DO ia = 1, nat
  606. !
  607. idx = 3 * ( ia - 1 )
  608. !
  609. CALL read_line( input_line, end_of_file = tend )
  610. !
  611. IF ( tend ) &
  612. CALL errore( 'read_cards', &
  613. 'end of file reading atomic positions', ia )
  614. !
  615. CALL field_count( nfield, input_line )
  616. !
  617. IF ( nfield == 4 ) THEN
  618. !
  619. READ( input_line, * ) lb_pos, pos((idx+1),image), &
  620. pos((idx+2),image), &
  621. pos((idx+3),image)
  622. !
  623. ELSEIF ( nfield == 7 ) THEN
  624. !
  625. IF ( image /= 1 ) THEN
  626. !
  627. CALL errore( 'read_cards', &
  628. & 'wrong number of columns in ' // &
  629. & 'ATOMIC_POSITIONS', sp_pos(ia) )
  630. !
  631. ENDIF
  632. !
  633. READ( input_line, * ) lb_pos, pos((idx+1),image), &
  634. pos((idx+2),image), &
  635. pos((idx+3),image), &
  636. if_pos(1,ia), &
  637. if_pos(2,ia), &
  638. if_pos(3,ia)
  639. !
  640. ELSE
  641. !
  642. CALL errore( 'read_cards', &
  643. & 'wrong number of columns in ' // &
  644. & 'ATOMIC_POSITIONS', sp_pos(ia) )
  645. !
  646. ENDIF
  647. !
  648. IF ( image == 1 ) THEN
  649. !
  650. lb_pos = adjustl( lb_pos )
  651. !
  652. match_label_path: DO is = 1, ntyp
  653. !
  654. IF ( trim( lb_pos ) == trim( atom_label(is) ) ) THEN
  655. !
  656. sp_pos(ia) = is
  657. !
  658. exit match_label_path
  659. !
  660. ENDIF
  661. !
  662. ENDDO match_label_path
  663. !
  664. IF ( ( sp_pos(ia) < 1 ) .or. ( sp_pos(ia) > ntyp ) ) THEN
  665. !
  666. CALL errore( 'read_cards', &
  667. 'wrong index in ATOMIC_POSITIONS', ia )
  668. !
  669. ENDIF
  670. !
  671. is = sp_pos(ia)
  672. !
  673. na_inp( is ) = na_inp( is ) + 1
  674. !
  675. ENDIF
  676. !
  677. ENDDO
  678. !
  679. RETURN
  680. !
  681. END SUBROUTINE path_read_images
  682. !
  683. END SUBROUTINE card_atomic_positions
  684. !
  685. !------------------------------------------------------------------------
  686. ! BEGIN manual
  687. !----------------------------------------------------------------------
  688. !
  689. ! ATOMIC_FORCES
  690. !
  691. ! read external forces (in atomic units) from standard input
  692. !
  693. ! Syntax:
  694. !
  695. ! ATOMIC_FORCES
  696. ! label Fx(1) Fy(1) Fz(1)
  697. ! .....
  698. ! label Fx(n) Fy(n) Fz(n)
  699. !
  700. ! Example:
  701. !
  702. ! ???
  703. !
  704. ! Where:
  705. !
  706. ! label (character(len=4)) atomic label
  707. ! Fx(:), Fy(:) and Fz(:) (REAL) x, y and z component of the external force
  708. ! acting on the ions whose coordinate are given
  709. ! in the same line in card ATOMIC_POSITION
  710. !
  711. !----------------------------------------------------------------------
  712. ! END manual
  713. !------------------------------------------------------------------------
  714. !
  715. SUBROUTINE card_atomic_forces( input_line, prog )
  716. !
  717. IMPLICIT NONE
  718. !
  719. CHARACTER(len=256) :: input_line
  720. CHARACTER(len=2) :: prog
  721. INTEGER :: ia, k, nfield
  722. LOGICAL, SAVE :: tread = .false.
  723. CHARACTER(len=4) :: lb
  724. !
  725. !
  726. IF( tread ) THEN
  727. CALL errore( ' card_atomic_forces ', ' two occurrences ', 2 )
  728. ENDIF
  729. !
  730. IF( .not. taspc ) THEN
  731. CALL errore( ' card_atomic_forces ', &
  732. & ' ATOMIC_SPECIES must be present before ', 2 )
  733. ENDIF
  734. !
  735. rd_for = 0.0_DP
  736. !
  737. DO ia = 1, nat
  738. !
  739. CALL read_line( input_line )
  740. CALL field_count( nfield, input_line )
  741. IF ( nfield == 4 ) THEN
  742. READ(input_line,*) lb, ( rd_for(k,ia), k = 1, 3 )
  743. ELSEIF( nfield == 3 ) THEN
  744. READ(input_line,*) ( rd_for(k,ia), k = 1, 3 )
  745. ELSE
  746. CALL errore( ' iosys ', ' wrong entries in ATOMIC_FORCES ', ia )
  747. ENDIF
  748. !
  749. ENDDO
  750. !
  751. tread = .true.
  752. !
  753. RETURN
  754. !
  755. END SUBROUTINE card_atomic_forces
  756. !
  757. !
  758. !------------------------------------------------------------------------
  759. ! BEGIN manual
  760. !----------------------------------------------------------------------
  761. !
  762. ! K_POINTS
  763. !
  764. ! use the specified set of k points
  765. !
  766. ! Syntax:
  767. !
  768. ! K_POINTS (mesh_option)
  769. ! n
  770. ! xk(1,1) xk(2,1) xk(3,1) wk(1)
  771. ! ... ... ... ...
  772. ! xk(1,n) xk(2,n) xk(3,n) wk(n)
  773. !
  774. ! Example:
  775. !
  776. ! K_POINTS
  777. ! 10
  778. ! 0.1250000 0.1250000 0.1250000 1.00
  779. ! 0.1250000 0.1250000 0.3750000 3.00
  780. ! 0.1250000 0.1250000 0.6250000 3.00
  781. ! 0.1250000 0.1250000 0.8750000 3.00
  782. ! 0.1250000 0.3750000 0.3750000 3.00
  783. ! 0.1250000 0.3750000 0.6250000 6.00
  784. ! 0.1250000 0.3750000 0.8750000 6.00
  785. ! 0.1250000 0.6250000 0.6250000 3.00
  786. ! 0.3750000 0.3750000 0.3750000 1.00
  787. ! 0.3750000 0.3750000 0.6250000 3.00
  788. !
  789. ! Where:
  790. !
  791. ! mesh_option == automatic k points mesh is generated automatically
  792. ! with Monkhorst-Pack algorithm
  793. ! mesh_option == crystal k points mesh is given in stdin in scaled
  794. ! units
  795. ! mesh_option == tpiba k points mesh is given in stdin in units
  796. ! of ( 2 PI / alat )
  797. ! mesh_option == gamma only gamma point is used ( default in
  798. ! CPMD simulation )
  799. ! mesh_option == tpiba_b as tpiba but the weights gives the
  800. ! number of points between this point
  801. ! and the next
  802. ! mesh_option == crystal_b as crystal but the weights gives the
  803. ! number of points between this point and
  804. ! the next
  805. !
  806. ! n ( integer ) number of k points
  807. ! xk(:,i) ( real ) coordinates of i-th k point
  808. ! wk(i) ( real ) weights of i-th k point
  809. !
  810. !----------------------------------------------------------------------
  811. ! END manual
  812. !------------------------------------------------------------------------
  813. !
  814. SUBROUTINE card_kpoints( input_line )
  815. !
  816. IMPLICIT NONE
  817. !
  818. CHARACTER(len=256) :: input_line
  819. INTEGER :: i, j
  820. INTEGER :: nkaux
  821. INTEGER, ALLOCATABLE :: wkaux(:)
  822. REAL(DP), ALLOCATABLE :: xkaux(:,:)
  823. REAL(DP) :: delta
  824. LOGICAL, EXTERNAL :: matches
  825. LOGICAL, SAVE :: tread = .false.
  826. LOGICAL :: tend,terr
  827. LOGICAL :: kband = .false.
  828. !
  829. !
  830. IF ( tread ) THEN
  831. CALL errore( ' card_kpoints ', ' two occurrences', 2 )
  832. ENDIF
  833. !
  834. IF ( matches( "AUTOMATIC", input_line ) ) THEN
  835. ! automatic generation of k-points
  836. k_points = 'automatic'
  837. ELSEIF ( matches( "CRYSTAL", input_line ) ) THEN
  838. ! input k-points are in crystal (reciprocal lattice) axis
  839. k_points = 'crystal'
  840. IF ( matches( "_B", input_line ) ) kband=.true.
  841. ELSEIF ( matches( "TPIBA", input_line ) ) THEN
  842. ! input k-points are in 2pi/a units
  843. k_points = 'tpiba'
  844. IF ( matches( "_B", input_line ) ) kband=.true.
  845. ELSEIF ( matches( "GAMMA", input_line ) ) THEN
  846. ! Only Gamma (k=0) is used
  847. k_points = 'gamma'
  848. ELSE
  849. ! by default, input k-points are in 2pi/a units
  850. k_points = 'tpiba'
  851. ENDIF
  852. !
  853. IF ( k_points == 'automatic' ) THEN
  854. !
  855. ! ... automatic generation of k-points
  856. !
  857. nkstot = 0
  858. CALL read_line( input_line, end_of_file = tend, error = terr )
  859. IF (tend) GOTO 10
  860. IF (terr) GOTO 20
  861. READ(input_line, *, END=10, ERR=20) nk1, nk2, nk3, k1, k2 ,k3
  862. IF ( k1 < 0 .or. k1 > 1 .or. &
  863. k2 < 0 .or. k2 > 1 .or. &
  864. k3 < 0 .or. k3 > 1 ) CALL errore &
  865. ('card_kpoints', 'invalid offsets: must be 0 or 1', 1)
  866. IF ( nk1 <= 0 .or. nk2 <= 0 .or. nk3 <= 0 ) CALL errore &
  867. ('card_kpoints', 'invalid values for nk1, nk2, nk3', 1)
  868. !
  869. ELSEIF ( ( k_points == 'tpiba' ) .or. ( k_points == 'crystal' ) ) THEN
  870. !
  871. ! ... input k-points are in 2pi/a units
  872. !
  873. CALL read_line( input_line, end_of_file = tend, error = terr )
  874. IF (tend) GOTO 10
  875. IF (terr) GOTO 20
  876. READ(input_line, *, END=10, ERR=20) nkstot
  877. IF ( nkstot > size (xk,2) ) CALL errore &
  878. ('card_kpoints', 'too many k-points',nkstot)
  879. !
  880. DO i = 1, nkstot
  881. CALL read_line( input_line, end_of_file = tend, error = terr )
  882. IF (tend) GOTO 10
  883. IF (tend) GOTO 20
  884. READ(input_line,*, END=10, ERR=20) xk(1,i), xk(2,i), xk(3,i), wk(i)
  885. ENDDO
  886. IF (kband) THEN
  887. nkaux=nkstot
  888. ALLOCATE(xkaux(3,nkstot))
  889. ALLOCATE(wkaux(nkstot))
  890. xkaux(:,1:nkstot)=xk(:,1:nkstot)
  891. wkaux(1:nkstot)=nint(wk(1:nkstot))
  892. nkstot=0
  893. DO i=1,nkaux-1
  894. delta=1.0_DP/wkaux(i)
  895. DO j=0,wkaux(i)-1
  896. nkstot=nkstot+1
  897. IF ( nkstot > size (xk,2) ) CALL errore &
  898. ('card_kpoints', 'too many k-points',nkstot)
  899. xk(:,nkstot)=xkaux(:,i)+delta*j*(xkaux(:,i+1)-xkaux(:,i))
  900. wk(nkstot)=1.0_DP
  901. ENDDO
  902. ENDDO
  903. nkstot=nkstot+1
  904. xk(:,nkstot)=xkaux(:,nkaux)
  905. wk(nkstot)=1.0_DP
  906. DEALLOCATE(xkaux)
  907. DEALLOCATE(wkaux)
  908. ENDIF
  909. !
  910. ELSEIF ( k_points == 'gamma' ) THEN
  911. !
  912. nkstot = 1
  913. xk(:,1) = 0.0_DP
  914. wk(1) = 1.0_DP
  915. !
  916. ENDIF
  917. !
  918. tread = .true.
  919. tk_inp = .true.
  920. !
  921. RETURN
  922. 10 CALL errore ('card_kpoints', ' end of file while reading ' &
  923. & // trim(k_points) // ' k points', 1)
  924. 20 CALL errore ('card_kpoints', ' error while reading ' &
  925. & // trim(k_points) // ' k points', 1)
  926. !
  927. END SUBROUTINE card_kpoints
  928. !
  929. !------------------------------------------------------------------------
  930. ! BEGIN manual
  931. !----------------------------------------------------------------------
  932. !
  933. ! SETNFI
  934. !
  935. ! Reset the step counter to the specified value
  936. !
  937. ! Syntax:
  938. !
  939. ! SETNFI
  940. ! nfi
  941. !
  942. ! Example:
  943. !
  944. ! SETNFI
  945. ! 100
  946. !
  947. ! Where:
  948. !
  949. ! nfi (integer) new value for the step counter
  950. !
  951. !----------------------------------------------------------------------
  952. ! END manual
  953. !------------------------------------------------------------------------
  954. !
  955. SUBROUTINE card_setnfi( input_line )
  956. !
  957. IMPLICIT NONE
  958. !
  959. CHARACTER(len=256) :: input_line
  960. LOGICAL, SAVE :: tread = .false.
  961. !
  962. !
  963. IF ( tread ) THEN
  964. CALL errore( ' card_setnfi ', ' two occurrences', 2 )
  965. ENDIF
  966. CALL read_line( input_line )
  967. READ(input_line,*) newnfi_card
  968. tnewnfi_card = .true.
  969. tread = .true.
  970. !
  971. RETURN
  972. !
  973. END SUBROUTINE card_setnfi
  974. !
  975. !
  976. !------------------------------------------------------------------------
  977. ! BEGIN manual
  978. !----------------------------------------------------------------------
  979. !
  980. ! 2DPROCMESH
  981. !
  982. ! Distribute the Y and Z FFT dimensions across processors,
  983. ! instead of Z dimension only ( default distribution )
  984. !
  985. ! Syntax:
  986. !
  987. ! 2DPROCMESH
  988. !
  989. ! Where:
  990. !
  991. ! no parameters
  992. !
  993. !----------------------------------------------------------------------
  994. ! END manual
  995. !------------------------------------------------------------------------
  996. !
  997. !
  998. !------------------------------------------------------------------------
  999. ! BEGIN manual
  1000. !----------------------------------------------------------------------
  1001. !
  1002. ! OCCUPATIONS
  1003. !
  1004. ! use the specified occupation numbers for electronic states.
  1005. ! Note that you should specify 10 values per line maximum!
  1006. !
  1007. ! Syntax (nspin == 1):
  1008. !
  1009. ! OCCUPATIONS
  1010. ! f(1) .... .... f(10)
  1011. ! f(11) .... f(nbnd)
  1012. !
  1013. ! Syntax (nspin == 2):
  1014. !
  1015. ! OCCUPATIONS
  1016. ! u(1) .... .... u(10)
  1017. ! u(11) .... u(nbnd)
  1018. ! d(1) .... .... d(10)
  1019. ! d(11) .... d(nbnd)
  1020. !
  1021. ! Example:
  1022. !
  1023. ! OCCUPATIONS
  1024. ! 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0
  1025. ! 2.0 2.0 2.0 2.0 2.0 1.0 1.0
  1026. !
  1027. ! Where:
  1028. !
  1029. ! f(:) (real) these are the occupation numbers
  1030. ! for LDA electronic states.
  1031. !
  1032. ! u(:) (real) these are the occupation numbers
  1033. ! for LSD spin == 1 electronic states
  1034. ! d(:) (real) these are the occupation numbers
  1035. ! for LSD spin == 2 electronic states
  1036. !
  1037. ! Note, maximum 10 values per line!
  1038. !
  1039. !----------------------------------------------------------------------
  1040. ! END manual
  1041. !------------------------------------------------------------------------
  1042. !
  1043. SUBROUTINE card_occupations( input_line )
  1044. !
  1045. USE wrappers, ONLY: feval_infix
  1046. !
  1047. IMPLICIT NONE
  1048. !
  1049. CHARACTER(len=256) :: input_line, field_str
  1050. INTEGER :: is, nx10, i, j, nspin0
  1051. INTEGER :: nfield, nbnd_read, nf, ierr
  1052. LOGICAL, SAVE :: tread = .false.
  1053. LOGICAL :: tef
  1054. !
  1055. !
  1056. IF ( tread ) THEN
  1057. CALL errore( ' card_occupations ', ' two occurrences', 2 )
  1058. ENDIF
  1059. nspin0=nspin
  1060. IF (nspin == 4) nspin0=1
  1061. !
  1062. ALLOCATE ( f_inp ( nbnd, nspin0 ) )
  1063. DO is = 1, nspin0
  1064. !
  1065. nbnd_read = 0
  1066. DO WHILE ( nbnd_read < nbnd)
  1067. CALL read_line( input_line, end_of_file=tef )
  1068. IF (tef) CALL errore('card_occupations',&
  1069. 'Missing occupations, end of file reached',1)
  1070. CALL field_count( nfield, input_line )
  1071. !
  1072. DO nf = 1,nfield
  1073. nbnd_read = nbnd_read+1
  1074. CALL get_field(nf, field_str, input_line)
  1075. !
  1076. f_inp(nbnd_read,is) = feval_infix(ierr, field_str )
  1077. CALL errore('card_occupations',&
  1078. 'Error parsing occupation: '//trim(field_str), nbnd_read*ierr)
  1079. ENDDO
  1080. ENDDO
  1081. !
  1082. ENDDO
  1083. !
  1084. tf_inp = .true.
  1085. tread = .true.
  1086. !
  1087. RETURN
  1088. !
  1089. END SUBROUTINE card_occupations
  1090. !
  1091. !
  1092. !------------------------------------------------------------------------
  1093. ! BEGIN manual
  1094. !----------------------------------------------------------------------
  1095. !
  1096. ! VHMEAN
  1097. !
  1098. ! Calculation of potential average along a given axis
  1099. !
  1100. ! Syntax:
  1101. !
  1102. ! VHMEAN
  1103. ! unit nr rmin rmax asse
  1104. !
  1105. ! Example:
  1106. !
  1107. ! ????
  1108. !
  1109. ! Where:
  1110. !
  1111. ! ????
  1112. !
  1113. !----------------------------------------------------------------------
  1114. ! END manual
  1115. !------------------------------------------------------------------------
  1116. !
  1117. SUBROUTINE card_vhmean( input_line )
  1118. !
  1119. IMPLICIT NONE
  1120. !
  1121. CHARACTER(len=256) :: input_line
  1122. LOGICAL, SAVE :: tread = .false.
  1123. !
  1124. !
  1125. IF ( tread ) THEN
  1126. CALL errore( ' card_vhmean ', ' two occurrences', 2 )
  1127. ENDIF
  1128. !
  1129. tvhmean_inp = .true.
  1130. CALL read_line( input_line )
  1131. READ(input_line,*) &
  1132. vhiunit_inp, vhnr_inp, vhrmin_inp, vhrmax_inp, vhasse_inp
  1133. tread = .true.
  1134. !
  1135. RETURN
  1136. !
  1137. END SUBROUTINE card_vhmean
  1138. !
  1139. !
  1140. !
  1141. !------------------------------------------------------------------------
  1142. ! BEGIN manual
  1143. !----------------------------------------------------------------------
  1144. !
  1145. ! DIPOLE
  1146. !
  1147. ! calculate polarizability
  1148. !
  1149. ! Syntax:
  1150. !
  1151. ! DIPOLE
  1152. !
  1153. ! Where:
  1154. !
  1155. ! no parameters
  1156. !
  1157. !----------------------------------------------------------------------
  1158. ! END manual
  1159. !------------------------------------------------------------------------
  1160. !
  1161. SUBROUTINE card_dipole( input_line )
  1162. !
  1163. IMPLICIT NONE
  1164. !
  1165. CHARACTER(len=256) :: input_line
  1166. LOGICAL, SAVE :: tread = .false.
  1167. !
  1168. !
  1169. IF ( tread ) THEN
  1170. CALL errore( ' card_dipole ', ' two occurrences', 2 )
  1171. ENDIF
  1172. !
  1173. tdipole_card = .true.
  1174. tread = .true.
  1175. !
  1176. RETURN
  1177. !
  1178. END SUBROUTINE card_dipole
  1179. !
  1180. !
  1181. !------------------------------------------------------------------------
  1182. ! BEGIN manual
  1183. !----------------------------------------------------------------------
  1184. !
  1185. ! IESR
  1186. !
  1187. ! use the specified number of neighbour cells for Ewald summations
  1188. !
  1189. ! Syntax:
  1190. !
  1191. ! ESR
  1192. ! iesr
  1193. !
  1194. ! Example:
  1195. !
  1196. ! ESR
  1197. ! 3
  1198. !
  1199. ! Where:
  1200. !
  1201. ! iesr (integer) determines the number of neighbour cells to be
  1202. ! considered:
  1203. ! iesr = 1 : nearest-neighbour cells (default)
  1204. ! iesr = 2 : next-to-nearest-neighbour cells
  1205. ! and so on
  1206. !
  1207. !----------------------------------------------------------------------
  1208. ! END manual
  1209. !------------------------------------------------------------------------
  1210. !
  1211. SUBROUTINE card_esr( input_line )
  1212. !
  1213. IMPLICIT NONE
  1214. !
  1215. CHARACTER(len=256) :: input_line
  1216. LOGICAL, SAVE :: tread = .false.
  1217. !
  1218. IF ( tread ) THEN
  1219. CALL errore( ' card_esr ', ' two occurrences', 2 )
  1220. ENDIF
  1221. CALL read_line( input_line )
  1222. READ(input_line,*) iesr_inp
  1223. !
  1224. tread = .true.
  1225. !
  1226. RETURN
  1227. !
  1228. END SUBROUTINE card_esr
  1229. !
  1230. !
  1231. !------------------------------------------------------------------------
  1232. ! BEGIN manual
  1233. !----------------------------------------------------------------------
  1234. !
  1235. ! CELL_PARAMETERS
  1236. !
  1237. ! use the specified cell dimensions
  1238. !
  1239. ! Syntax:
  1240. !
  1241. ! CELL_PARAMETERS
  1242. ! HT(1,1) HT(1,2) HT(1,3)
  1243. ! HT(2,1) HT(2,2) HT(2,3)
  1244. ! HT(3,1) HT(3,2) HT(3,3)
  1245. !
  1246. ! Example:
  1247. !
  1248. ! CELL_PARAMETERS
  1249. ! 24.50644311 0.00004215 -0.14717844
  1250. ! -0.00211522 8.12850030 1.70624903
  1251. ! 0.16447787 0.74511792 23.07395418
  1252. !
  1253. ! Where:
  1254. !
  1255. ! HT(i,j) (real) cell dimensions ( in a.u. ),
  1256. ! note the relation with lattice vectors:
  1257. ! HT(1,:) = A1, HT(2,:) = A2, HT(3,:) = A3
  1258. !
  1259. !----------------------------------------------------------------------
  1260. ! END manual
  1261. !------------------------------------------------------------------------
  1262. !
  1263. SUBROUTINE card_cell_parameters( input_line )
  1264. !
  1265. IMPLICIT NONE
  1266. !
  1267. CHARACTER(len=256) :: input_line
  1268. INTEGER :: i, j
  1269. LOGICAL, EXTERNAL :: matches
  1270. LOGICAL, SAVE :: tread = .false.
  1271. !
  1272. !
  1273. IF ( tread ) THEN
  1274. CALL errore( ' card_cell_parameters ', ' two occurrences', 2 )
  1275. ENDIF
  1276. !
  1277. IF ( matches( 'HEXAGONAL', input_line ) ) THEN
  1278. cell_symmetry = 'hexagonal'
  1279. ELSE
  1280. cell_symmetry = 'cubic'
  1281. ENDIF
  1282. !
  1283. IF ( matches( "BOHR", input_line ) ) THEN
  1284. cell_units = 'bohr'
  1285. ELSEIF ( matches( "ANGSTROM", input_line ) ) THEN
  1286. cell_units = 'angstrom'
  1287. ELSE
  1288. cell_units = 'alat'
  1289. ENDIF
  1290. !
  1291. DO i = 1, 3
  1292. CALL read_line( input_line )
  1293. READ(input_line,*) ( rd_ht( i, j ), j = 1, 3 )
  1294. ENDDO
  1295. !
  1296. trd_ht = .true.
  1297. tread = .true.
  1298. !
  1299. RETURN
  1300. !
  1301. END SUBROUTINE card_cell_parameters
  1302. !
  1303. !
  1304. !------------------------------------------------------------------------
  1305. ! BEGIN manual
  1306. !----------------------------------------------------------------------
  1307. !
  1308. ! ATOMIC_VELOCITIES
  1309. !
  1310. ! read velocities (in atomic units) from standard input
  1311. !
  1312. ! Syntax:
  1313. !
  1314. ! ATOMIC_VELOCITIES
  1315. ! label(1) Vx(1) Vy(1) Vz(1)
  1316. ! ....
  1317. ! label(n) Vx(n) Vy(n) Vz(n)
  1318. !
  1319. ! Example:
  1320. !
  1321. ! ???
  1322. !
  1323. ! Where:
  1324. !
  1325. ! label (character(len=4)) atomic label
  1326. ! Vx(:), Vy(:) and Vz(:) (REAL) x, y and z velocity components of
  1327. ! the ions
  1328. !
  1329. !----------------------------------------------------------------------
  1330. ! END manual
  1331. !------------------------------------------------------------------------
  1332. !
  1333. SUBROUTINE card_ion_velocities( input_line )
  1334. !
  1335. IMPLICIT NONE
  1336. !
  1337. CHARACTER(len=256) :: input_line
  1338. INTEGER :: ia, k, is, nfield
  1339. LOGICAL, SAVE :: tread = .false.
  1340. CHARACTER(len=4) :: lb_vel
  1341. !
  1342. !
  1343. IF( tread ) THEN
  1344. CALL errore( ' card_ion_velocities ', ' two occurrences', 2 )
  1345. ENDIF
  1346. !
  1347. IF( .not. taspc ) THEN
  1348. CALL errore( ' card_ion_velocities ', &
  1349. & ' ATOMIC_SPECIES must be present before ', 2 )
  1350. ENDIF
  1351. !
  1352. rd_vel = 0.0_DP
  1353. sp_vel = 0
  1354. !
  1355. IF ( ion_velocities == 'from_input' ) THEN
  1356. !
  1357. tavel = .true.
  1358. !
  1359. DO ia = 1, nat
  1360. !
  1361. CALL read_line( input_line )
  1362. CALL field_count( nfield, input_line )
  1363. IF ( nfield == 4 ) THEN
  1364. READ(input_line,*) lb_vel, ( rd_vel(k,ia), k = 1, 3 )
  1365. ELSE
  1366. CALL errore( ' iosys ', &
  1367. & ' wrong entries in ION_VELOCITIES ', ia )
  1368. ENDIF
  1369. !
  1370. match_label: DO is = 1, ntyp
  1371. IF ( trim( lb_vel ) == atom_label(is) ) THEN
  1372. sp_vel(ia) = is
  1373. exit match_label
  1374. ENDIF
  1375. ENDDO match_label
  1376. !
  1377. IF ( sp_vel(ia) < 1 .or. sp_vel(ia) > ntyp ) THEN
  1378. CALL errore( ' iosys ', ' wrong LABEL in ION_VELOCITIES ', ia )
  1379. ENDIF
  1380. !
  1381. ENDDO
  1382. !
  1383. ENDIF
  1384. !
  1385. tread = .true.
  1386. !
  1387. RETURN
  1388. !
  1389. END SUBROUTINE
  1390. !
  1391. !------------------------------------------------------------------------
  1392. ! BEGIN manual
  1393. !----------------------------------------------------------------------
  1394. !
  1395. ! CONSTRAINTS
  1396. !
  1397. ! Ionic Constraints
  1398. !
  1399. ! Syntax:
  1400. !
  1401. ! CONSTRAINTS
  1402. ! NCONSTR CONSTR_TOL
  1403. ! CONSTR_TYPE(.) CONSTR(1,.) CONSTR(2,.) ... { CONSTR_TARGET(.) }
  1404. !
  1405. ! Where:
  1406. !
  1407. ! NCONSTR(INTEGER) number of constraints
  1408. !
  1409. ! CONSTR_TOL tolerance for keeping the constraints
  1410. ! satisfied
  1411. !
  1412. ! CONSTR_TYPE(.) type of constrain:
  1413. ! 1: for fixed distances ( two atom indexes must
  1414. ! be specified )
  1415. ! 2: for fixed planar angles ( three atom indexes
  1416. ! must be specified )
  1417. !
  1418. ! CONSTR(1,.) CONSTR(2,.) ...
  1419. !
  1420. ! indices object of the constraint, as
  1421. ! they appear in the 'POSITION' CARD
  1422. !
  1423. ! CONSTR_TARGET target for the constrain ( in the case of
  1424. ! planar angles it is the COS of the angle ).
  1425. ! this variable is optional.
  1426. !
  1427. !----------------------------------------------------------------------
  1428. ! END manual
  1429. !------------------------------------------------------------------------
  1430. !
  1431. SUBROUTINE card_constraints( input_line )
  1432. !
  1433. IMPLICIT NONE
  1434. !
  1435. CHARACTER(len=256) :: input_line
  1436. INTEGER :: i, nfield
  1437. LOGICAL, SAVE :: tread = .false.
  1438. !
  1439. !
  1440. IF ( tread ) CALL errore( 'card_constraints', 'two occurrences', 2 )
  1441. !
  1442. CALL read_line( input_line )
  1443. !
  1444. CALL field_count( nfield, input_line )
  1445. !
  1446. IF ( nfield == 1 ) THEN
  1447. !
  1448. READ( input_line, * ) nconstr_inp
  1449. !
  1450. ELSEIF ( nfield == 2 ) THEN
  1451. !
  1452. READ( input_line, * ) nconstr_inp, constr_tol_inp
  1453. !
  1454. ELSE
  1455. !
  1456. CALL errore( 'card_constraints', 'too many fields', nfield )
  1457. !
  1458. ENDIF
  1459. WRITE(stdout,'(5x,a,i4,a,f12.6)') &
  1460. 'Reading',nconstr_inp,' constraints; tolerance:', constr_tol_inp
  1461. !
  1462. CALL allocate_input_constr()
  1463. !
  1464. DO i = 1, nconstr_inp
  1465. !
  1466. CALL read_line( input_line )
  1467. !
  1468. READ( input_line, * ) constr_type_inp(i)
  1469. !
  1470. CALL field_count( nfield, input_line )
  1471. !
  1472. IF ( nfield > nc_fields + 2 ) &
  1473. CALL errore( 'card_constraints', &
  1474. 'too many fields for this constraint', i )
  1475. !
  1476. SELECT CASE( constr_type_inp(i) )
  1477. CASE( 'type_coord', 'atom_coord' )
  1478. !
  1479. IF ( nfield == 5 ) THEN
  1480. !
  1481. READ( input_line, * ) constr_type_inp(i), &
  1482. constr_inp(1,i), &
  1483. constr_inp(2,i), &
  1484. constr_inp(3,i), &
  1485. constr_inp(4,i)
  1486. !
  1487. WRITE(stdout,'(7x,i3,a,i3,a,i2,a,2f12.6)') &
  1488. i,') '//constr_type_inp(i)(1:4),int(constr_inp(1,i)) ,' coordination wrt type:', int(constr_inp(2,i)), &
  1489. ' cutoff distance and smoothing:', constr_inp(3:4,i)
  1490. ELSEIF ( nfield == 6 ) THEN
  1491. !
  1492. READ( input_line, * ) constr_type_inp(i), &
  1493. constr_inp(1,i), &
  1494. constr_inp(2,i), &
  1495. constr_inp(3,i), &
  1496. constr_inp(4,i), &
  1497. constr_target_inp(i)
  1498. !
  1499. constr_target_set(i) = .true.
  1500. !
  1501. WRITE(stdout,'(7x,i3,a,i3,a,i2,a,2f12.6,a,f12.6)') &
  1502. i,') '//constr_type_inp(i)(1:4),int(constr_inp(1,i)) ,' coordination wrt type:', int(constr_inp(2,i)), &
  1503. ' cutoff distance and smoothing:', constr_inp(3:4,i), &
  1504. '; target:', constr_target_inp(i)
  1505. ELSE
  1506. !
  1507. CALL errore( 'card_constraints', 'type_coord, ' // &
  1508. & 'atom_coord: wrong number of fields', nfield )
  1509. !
  1510. ENDIF
  1511. !
  1512. CASE( 'distance' )
  1513. !
  1514. IF ( nfield == 3 ) THEN
  1515. !
  1516. READ( input_line, * ) constr_type_inp(i), &
  1517. constr_inp(1,i), &
  1518. constr_inp(2,i)
  1519. !
  1520. WRITE(stdout,'(7x,i3,a,2i3)') &
  1521. i,') distance between atoms: ', int(constr_inp(1:2,i))
  1522. ELSEIF ( nfield == 4 ) THEN
  1523. !
  1524. READ( input_line, * ) constr_type_inp(i), &
  1525. constr_inp(1,i), &
  1526. constr_inp(2,i), &
  1527. constr_target_inp(i)
  1528. !
  1529. constr_target_set(i) = .true.
  1530. !
  1531. WRITE(stdout,'(7x,i3,a,2i3,a,f12.6)') &
  1532. i,') distance between atoms: ', int(constr_inp(1:2,i)), '; target:', constr_target_inp(i)
  1533. ELSE
  1534. !
  1535. CALL errore( 'card_constraints', &
  1536. & 'distance: wrong number of fields', nfield )
  1537. !
  1538. ENDIF
  1539. !
  1540. CASE( 'planar_angle' )
  1541. !
  1542. IF ( nfield == 4 ) THEN
  1543. !
  1544. READ( input_line, * ) constr_type_inp(i), &
  1545. constr_inp(1,i), &
  1546. constr_inp(2,i), &
  1547. constr_inp(3,i)
  1548. !
  1549. WRITE(stdout, '(7x,i3,a,3i3)') &
  1550. i,') planar angle between atoms: ', int(constr_inp(1:3,i))
  1551. ELSEIF ( nfield == 5 ) THEN
  1552. !
  1553. READ( input_line, * ) constr_type_inp(i), &
  1554. constr_inp(1,i), &
  1555. constr_inp(2,i), &
  1556. constr_inp(3,i), &
  1557. constr_target_inp(i)
  1558. !
  1559. constr_target_set(i) = .true.
  1560. !
  1561. WRITE(stdout, '(7x,i3,a,3i3,a,f12.6)') &
  1562. i,') planar angle between atoms: ', int(constr_inp(1:3,i)), '; target:', constr_target_inp(i)
  1563. ELSE
  1564. !
  1565. CALL errore( 'card_constraints', &
  1566. & 'planar_angle: wrong number of fields', nfield )
  1567. !
  1568. ENDIF
  1569. !
  1570. CASE( 'torsional_angle' )
  1571. !
  1572. IF ( nfield == 5 ) THEN
  1573. !
  1574. READ( input_line, * ) constr_type_inp(i), &
  1575. constr_inp(1,i), &
  1576. constr_inp(2,i), &
  1577. constr_inp(3,i), &
  1578. constr_inp(4,i)
  1579. !
  1580. WRITE(stdout, '(7x,i3,a,4i3)') &
  1581. i,') torsional angle between atoms: ', int(constr_inp(1:4,i))
  1582. ELSEIF ( nfield == 6 ) THEN
  1583. !
  1584. READ( input_line, * ) constr_type_inp(i), &
  1585. constr_inp(1,i), &

Large files files are truncated, but you can click here to view the full file