46#include "./base/base_uses.f90"
50 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'topology_amber'
51 REAL(KIND=
dp),
PARAMETER,
PRIVATE :: amber_conv_factor = 20.4550_dp, &
52 amber_conv_charge = 18.2223_dp
53 INTEGER,
PARAMETER,
PRIVATE :: buffer_size = 1
59 INTERFACE rd_amber_section
60 MODULE PROCEDURE rd_amber_section_i1, rd_amber_section_c1, rd_amber_section_r1, &
61 rd_amber_section_i3, rd_amber_section_i4, rd_amber_section_i5
105 CHARACTER(len=*),
PARAMETER :: routinen =
'read_coordinate_crd'
107 CHARACTER(LEN=default_string_length) :: string
108 INTEGER :: handle, iw, j, natom
109 LOGICAL :: my_end, setup_velocities
110 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: velocity
116 NULLIFY (logger, velocity)
119 extension=
".subsysLog")
120 CALL timeset(routinen, handle)
123 IF (iw > 0)
WRITE (iw, *)
" Reading in CRD file ", trim(
topology%coord_file_name)
126 IF (iw > 0)
WRITE (iw,
'(T2,A)')
'CRD_INFO| Parsing the TITLE section'
132 IF (iw > 0)
WRITE (iw,
'(T2,A)')
'CRD_INFO| '//trim(string)
138 IF (iw > 0)
WRITE (iw,
'(T2,A,I0)')
'CRD_INFO| Number of atoms: ', natom
139 CALL reallocate(atom_info%id_molname, 1, natom)
140 CALL reallocate(atom_info%id_resname, 1, natom)
142 CALL reallocate(atom_info%id_atmname, 1, natom)
145 CALL reallocate(atom_info%atm_charge, 1, natom)
148 CALL reallocate(atom_info%id_element, 1, natom)
155 DO j = 1, natom - mod(natom, 2), 2
157 READ (parser%input_line, *) atom_info%r(1, j), atom_info%r(2, j), atom_info%r(3, j), &
158 atom_info%r(1, j + 1), atom_info%r(2, j + 1), atom_info%r(3, j + 1)
161 atom_info%id_atmname(j) =
str2id(
s2s(
"__UNDEF__"))
162 atom_info%id_molname(j) =
str2id(
s2s(
"__UNDEF__"))
163 atom_info%id_resname(j) =
str2id(
s2s(
"__UNDEF__"))
164 atom_info%id_element(j) =
str2id(
s2s(
"__UNDEF__"))
165 atom_info%resid(j) = huge(0)
166 atom_info%atm_mass(j) = huge(0.0_dp)
167 atom_info%atm_charge(j) = -huge(0.0_dp)
172 atom_info%id_atmname(j + 1) =
str2id(
s2s(
"__UNDEF__"))
173 atom_info%id_molname(j + 1) =
str2id(
s2s(
"__UNDEF__"))
174 atom_info%id_resname(j + 1) =
str2id(
s2s(
"__UNDEF__"))
175 atom_info%id_element(j + 1) =
str2id(
s2s(
"__UNDEF__"))
176 atom_info%resid(j + 1) = huge(0)
177 atom_info%atm_mass(j + 1) = huge(0.0_dp)
178 atom_info%atm_charge(j + 1) = -huge(0.0_dp)
179 atom_info%r(1, j + 1) =
cp_unit_to_cp2k(atom_info%r(1, j + 1),
"angstrom")
180 atom_info%r(2, j + 1) =
cp_unit_to_cp2k(atom_info%r(2, j + 1),
"angstrom")
181 atom_info%r(3, j + 1) =
cp_unit_to_cp2k(atom_info%r(3, j + 1),
"angstrom")
186 IF ((my_end) .AND. (j /= natom - mod(natom, 2) + 1))
THEN
188 cpabort(
"Error while reading CRD file. Unexpected end of file.")
190 ELSE IF (mod(natom, 2) /= 0)
THEN
193 READ (parser%input_line, *) atom_info%r(1, j), atom_info%r(2, j), atom_info%r(3, j)
196 atom_info%id_atmname(j) =
str2id(
s2s(
"__UNDEF__"))
197 atom_info%id_molname(j) =
str2id(
s2s(
"__UNDEF__"))
198 atom_info%id_resname(j) =
str2id(
s2s(
"__UNDEF__"))
199 atom_info%id_element(j) =
str2id(
s2s(
"__UNDEF__"))
200 atom_info%resid(j) = huge(0)
201 atom_info%atm_mass(j) = huge(0.0_dp)
202 atom_info%atm_charge(j) = -huge(0.0_dp)
211 cpwarn_if(j /= natom,
"No VELOCITY or BOX information found in CRD file.")
215 DO j = 1, natom - mod(natom, 2), 2
217 READ (parser%input_line, *) velocity(1, j), velocity(2, j), velocity(3, j), &
218 velocity(1, j + 1), velocity(2, j + 1), velocity(3, j + 1)
223 velocity(1:3, j) = velocity(1:3, j)*amber_conv_factor
225 velocity(1, j + 1) =
cp_unit_to_cp2k(velocity(1, j + 1),
"angstrom*ps^-1")
226 velocity(2, j + 1) =
cp_unit_to_cp2k(velocity(2, j + 1),
"angstrom*ps^-1")
227 velocity(3, j + 1) =
cp_unit_to_cp2k(velocity(3, j + 1),
"angstrom*ps^-1")
228 velocity(1:3, j + 1) = velocity(1:3, j + 1)*amber_conv_factor
232 setup_velocities = .true.
233 IF ((my_end) .AND. (j /= natom - mod(natom, 2) + 1))
THEN
235 CALL cp_warn(__location__, &
236 "No VELOCITY information found in CRD file. Ignoring BOX information. "// &
237 "Please provide the BOX information directly from the main CP2K input! ")
239 setup_velocities = .false.
240 ELSE IF (mod(natom, 2) /= 0)
THEN
243 READ (parser%input_line, *) velocity(1, j), velocity(2, j), velocity(3, j)
248 velocity(1:3, j) = velocity(1:3, j)*amber_conv_factor
252 IF (setup_velocities)
THEN
257 DEALLOCATE (velocity)
260 cpwarn_if(j /= natom,
"BOX information missing in CRD file.")
263 CALL cp_warn(__location__, &
264 "BOX information found in CRD file. They will be ignored. "// &
265 "Please provide the BOX information directly from the main CP2K input!")
270 "PRINT%TOPOLOGY_INFO/CRD_INFO")
271 CALL timestop(handle)
287 CHARACTER(LEN=*),
INTENT(IN) :: filename
292 CHARACTER(len=*),
PARAMETER :: routinen =
'read_connectivity_amber'
294 INTEGER :: handle, iw
300 CALL timeset(routinen, handle)
303 extension=
".subsysLog")
309 CALL rdparm_amber_8(filename, iw, para_env, do_connectivity=.true., do_forcefield=.false., &
310 atom_info=atom_info, conn_info=conn_info)
316 "PRINT%TOPOLOGY_INFO/AMBER_INFO")
317 CALL timestop(handle)
368 do_forcefield, atom_info, conn_info, amb_info, particle_set)
370 CHARACTER(LEN=*),
INTENT(IN) :: filename
371 INTEGER,
INTENT(IN) :: output_unit
373 LOGICAL,
INTENT(IN) :: do_connectivity, do_forcefield
378 POINTER :: particle_set
380 CHARACTER(len=*),
PARAMETER :: routinen =
'rdparm_amber_8'
382 CHARACTER(LEN=default_string_length) :: input_format, section
383 CHARACTER(LEN=default_string_length), &
384 ALLOCATABLE,
DIMENSION(:) :: isymbl, labres, raw_isymbl, strtmp_a
385 INTEGER :: handle, handle2, i, ifbox, ifcap, ifpert, index_now, info(31), istart, mbona, &
386 mbper, mdper, mgper, mphia, mtheta, natom, natom_prev, natyp, nbona, nbond_prev, nbonh, &
387 nbper, ndper, ngper, nhparm, nmxrs, nnb, nparm, nphb, nphi_prev, nphia, nphih, nptra, &
388 nres, nsize, ntheta, ntheta_prev, ntheth, ntypes, numang, numbnd, numextra, &
390 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: iac, ib, ibh, icb, icbh, ico, icp, icph, &
391 ict, icth, ip, iph, ipres, it, ith, &
392 iwork, jb, jbh, jp, jph, jt, jth, kp, &
393 kph, kt, kth, lp, lph
394 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: full_torsions
395 LOGICAL :: check, valid_format
396 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: asol, bsol, cn1, cn2, phase, pk, pn, &
400 CALL timeset(routinen, handle)
401 IF (output_unit > 0)
WRITE (output_unit,
'(/,A)')
" AMBER_INFO| Reading Amber Topology File: "// &
403 CALL parser_create(parser, filename, para_env=para_env, parse_white_lines=.true.)
404 valid_format = check_amber_8_std(parser, output_unit)
405 IF (valid_format)
THEN
406 DO WHILE (get_section_parmtop(parser, section, input_format))
407 SELECT CASE (trim(section))
412 CALL rd_amber_section(parser, section, info, 31)
448 IF (output_unit > 0)
THEN
449 WRITE (output_unit,
'(A,/)')
" AMBER_INFO| Information from AMBER topology file:"
450 WRITE (output_unit, 1000) &
451 natom, ntypes, nbonh, mbona, ntheth, mtheta, nphih, &
452 mphia, nhparm, nparm, nnb, nres, nbona, ntheta, &
453 nphia, numbnd, numang, nptra, natyp, nphb, ifbox, &
454 nmxrs, ifcap, numextra
458 IF (do_connectivity)
THEN
459 check =
PRESENT(atom_info) .AND.
PRESENT(conn_info)
462 IF (
ASSOCIATED(atom_info%id_molname)) natom_prev =
SIZE(atom_info%id_molname)
464 ALLOCATE (labres(nres))
465 ALLOCATE (ipres(nres))
467 IF (do_forcefield)
THEN
469 ALLOCATE (iac(natom))
470 ALLOCATE (ico(ntypes*ntypes))
471 ALLOCATE (rk(numbnd))
472 ALLOCATE (req(numbnd))
473 ALLOCATE (tk(numang))
474 ALLOCATE (teq(numang))
477 ALLOCATE (phase(nptra))
478 ALLOCATE (cn1(ntypes*(ntypes + 1)/2))
479 ALLOCATE (cn2(ntypes*(ntypes + 1)/2))
480 ALLOCATE (asol(ntypes*(ntypes + 1)/2))
481 ALLOCATE (bsol(ntypes*(ntypes + 1)/2))
484 ALLOCATE (ibh(nbonh))
485 ALLOCATE (jbh(nbonh))
486 ALLOCATE (icbh(nbonh))
489 ALLOCATE (icb(nbona))
490 ALLOCATE (ith(ntheth))
491 ALLOCATE (jth(ntheth))
492 ALLOCATE (kth(ntheth))
493 ALLOCATE (icth(ntheth))
494 ALLOCATE (it(ntheta))
495 ALLOCATE (jt(ntheta))
496 ALLOCATE (kt(ntheta))
497 ALLOCATE (ict(ntheta))
498 ALLOCATE (iph(nphih))
499 ALLOCATE (jph(nphih))
500 ALLOCATE (kph(nphih))
501 ALLOCATE (lph(nphih))
502 ALLOCATE (icph(nphih))
507 ALLOCATE (icp(nphia))
511 CASE (
"AMBER_ATOM_TYPE")
512 IF (.NOT. do_connectivity) cycle
513 CALL reallocate(atom_info%id_atmname, 1, natom_prev + natom)
514 ALLOCATE (strtmp_a(natom))
515 CALL rd_amber_section(parser, section, strtmp_a, natom)
517 atom_info%id_atmname(natom_prev + i) =
str2id(strtmp_a(i))
519 DEALLOCATE (strtmp_a)
521 IF (.NOT. do_connectivity) cycle
522 CALL reallocate(atom_info%atm_charge, 1, natom_prev + natom)
523 CALL rd_amber_section(parser, section, atom_info%atm_charge(natom_prev + 1:), natom)
525 atom_info%atm_charge(natom_prev + 1:) = atom_info%atm_charge(natom_prev + 1:)/amber_conv_charge
527 IF (.NOT. do_connectivity) cycle
528 CALL reallocate(atom_info%atm_mass, 1, natom_prev + natom)
529 CALL rd_amber_section(parser, section, atom_info%atm_mass(natom_prev + 1:), natom)
530 CASE (
"RESIDUE_LABEL")
531 IF (.NOT. do_connectivity) cycle
532 CALL reallocate(atom_info%id_resname, 1, natom_prev + natom)
533 CALL rd_amber_section(parser, section, labres, nres)
534 CASE (
"RESIDUE_POINTER")
535 IF (.NOT. do_connectivity) cycle
536 CALL reallocate(atom_info%resid, 1, natom_prev + natom)
537 CALL rd_amber_section(parser, section, ipres, nres)
538 CASE (
"ATOM_TYPE_INDEX")
539 IF (.NOT. do_forcefield) cycle
540 CALL rd_amber_section(parser, section, iac, natom)
541 CASE (
"NONBONDED_PARM_INDEX")
542 IF (.NOT. do_forcefield) cycle
543 CALL rd_amber_section(parser, section, ico, ntypes**2)
544 CASE (
"BOND_FORCE_CONSTANT")
545 IF (.NOT. do_forcefield) cycle
546 CALL rd_amber_section(parser, section, rk, numbnd)
547 CASE (
"BOND_EQUIL_VALUE")
548 IF (.NOT. do_forcefield) cycle
549 CALL rd_amber_section(parser, section, req, numbnd)
550 CASE (
"ANGLE_FORCE_CONSTANT")
551 IF (.NOT. do_forcefield) cycle
552 CALL rd_amber_section(parser, section, tk, numang)
553 CASE (
"ANGLE_EQUIL_VALUE")
554 IF (.NOT. do_forcefield) cycle
555 CALL rd_amber_section(parser, section, teq, numang)
556 CASE (
"DIHEDRAL_FORCE_CONSTANT")
557 IF (.NOT. do_forcefield) cycle
558 CALL rd_amber_section(parser, section, pk, nptra)
559 IF (nptra <= 0) cycle
561 IF (
ASSOCIATED(amb_info%raw_torsion_k))
DEALLOCATE (amb_info%raw_torsion_k)
562 ALLOCATE (amb_info%raw_torsion_k(nptra), source=pk)
563 CASE (
"DIHEDRAL_PERIODICITY")
564 IF (.NOT. do_forcefield) cycle
565 CALL rd_amber_section(parser, section, pn, nptra)
566 IF (nptra <= 0) cycle
568 IF (
ASSOCIATED(amb_info%raw_torsion_m))
DEALLOCATE (amb_info%raw_torsion_m)
569 ALLOCATE (amb_info%raw_torsion_m(nptra), source=pn)
570 CASE (
"DIHEDRAL_PHASE")
571 IF (.NOT. do_forcefield) cycle
572 CALL rd_amber_section(parser, section, phase, nptra)
573 IF (nptra <= 0) cycle
575 IF (
ASSOCIATED(amb_info%raw_torsion_phi0))
DEALLOCATE (amb_info%raw_torsion_phi0)
576 ALLOCATE (amb_info%raw_torsion_phi0(nptra), source=phase)
577 CASE (
"LENNARD_JONES_ACOEF")
578 IF (.NOT. do_forcefield) cycle
579 CALL rd_amber_section(parser, section, cn1, ntypes*(ntypes + 1)/2)
580 CASE (
"LENNARD_JONES_BCOEF")
581 IF (.NOT. do_forcefield) cycle
582 CALL rd_amber_section(parser, section, cn2, ntypes*(ntypes + 1)/2)
584 IF (.NOT. do_forcefield) cycle
585 CALL rd_amber_section(parser, section, asol, nphb)
587 IF (.NOT. do_forcefield) cycle
588 CALL rd_amber_section(parser, section, bsol, nphb)
589 CASE (
"BONDS_INC_HYDROGEN")
591 CALL rd_amber_section(parser, section, ibh, jbh, icbh, nbonh)
593 ibh(:) = ibh(:)/3 + 1
594 jbh(:) = jbh(:)/3 + 1
595 CASE (
"BONDS_WITHOUT_HYDROGEN")
597 CALL rd_amber_section(parser, section, ib, jb, icb, nbona)
601 CASE (
"ANGLES_INC_HYDROGEN")
603 CALL rd_amber_section(parser, section, ith, jth, kth, icth, ntheth)
605 ith(:) = ith(:)/3 + 1
606 jth(:) = jth(:)/3 + 1
607 kth(:) = kth(:)/3 + 1
608 CASE (
"ANGLES_WITHOUT_HYDROGEN")
610 CALL rd_amber_section(parser, section, it, jt, kt, ict, ntheta)
615 CASE (
"DIHEDRALS_INC_HYDROGEN")
617 CALL rd_amber_section(parser, section, iph, jph, kph, lph, icph, nphih)
619 iph(:) = iph(:)/3 + 1
620 jph(:) = jph(:)/3 + 1
621 kph(:) = abs(kph(:))/3 + 1
622 lph(:) = abs(lph(:))/3 + 1
623 CASE (
"DIHEDRALS_WITHOUT_HYDROGEN")
625 CALL rd_amber_section(parser, section, ip, jp, kp, lp, icp, nphia)
629 kp(:) = abs(kp(:))/3 + 1
630 lp(:) = abs(lp(:))/3 + 1
636 IF (do_forcefield .AND. (nphih + nphia > 0))
THEN
637 IF (
ASSOCIATED(amb_info%raw_torsion_id))
DEALLOCATE (amb_info%raw_torsion_id)
638 ALLOCATE (amb_info%raw_torsion_id(5, nphih + nphia))
640 amb_info%raw_torsion_id(1, i) = iph(i)
641 amb_info%raw_torsion_id(2, i) = jph(i)
642 amb_info%raw_torsion_id(3, i) = kph(i)
643 amb_info%raw_torsion_id(4, i) = lph(i)
644 amb_info%raw_torsion_id(5, i) = icph(i)
647 amb_info%raw_torsion_id(1, nphih + i) = ip(i)
648 amb_info%raw_torsion_id(2, nphih + i) = jp(i)
649 amb_info%raw_torsion_id(3, nphih + i) = kp(i)
650 amb_info%raw_torsion_id(4, nphih + i) = lp(i)
651 amb_info%raw_torsion_id(5, nphih + i) = icp(i)
657 IF (do_connectivity)
THEN
658 CALL timeset(trim(routinen)//
"_connectivity", handle2)
662 ALLOCATE (isymbl(natom))
663 ALLOCATE (iwork(natom))
665 DO i = 1,
SIZE(isymbl)
666 isymbl(i) =
id2str(atom_info%id_atmname(natom_prev + i))
670 CALL sort(isymbl, natom, iwork)
671 ALLOCATE (raw_isymbl(natom))
672 raw_isymbl(:) = isymbl
676 IF (trim(isymbl(i)) /= trim(isymbl(istart)))
THEN
677 CALL conform_atom_type_low(isymbl, iwork, i, istart, atom_info%atm_charge(natom_prev + 1:))
681 CALL conform_atom_type_low(isymbl, iwork, i, istart, atom_info%atm_charge(natom_prev + 1:))
683 CALL resolve_atom_type_collisions(isymbl, raw_isymbl)
687 atom_info%id_atmname(natom_prev + iwork(i)) =
str2id(
s2s(isymbl(i)))
694 atom_info%id_resname(natom_prev + ipres(i):natom_prev + ipres(i + 1)) =
str2id(
s2s(labres(i)))
695 atom_info%resid(natom_prev + ipres(i):natom_prev + ipres(i + 1)) = i
697 atom_info%id_resname(natom_prev + ipres(i):natom_prev + natom) =
str2id(
s2s(labres(i)))
698 atom_info%resid(natom_prev + ipres(i):natom_prev + natom) = i
703 DEALLOCATE (raw_isymbl)
712 IF (
ASSOCIATED(conn_info%bond_a)) nbond_prev =
SIZE(conn_info%bond_a)
714 CALL reallocate(conn_info%bond_a, 1, nbond_prev + nbonh + nbona)
715 CALL reallocate(conn_info%bond_b, 1, nbond_prev + nbonh + nbona)
717 index_now = nbond_prev + i
718 conn_info%bond_a(index_now) = natom_prev + ibh(i)
719 conn_info%bond_b(index_now) = natom_prev + jbh(i)
722 index_now = nbond_prev + i + nbonh
723 conn_info%bond_a(index_now) = natom_prev + ib(i)
724 conn_info%bond_b(index_now) = natom_prev + jb(i)
729 IF (
ASSOCIATED(conn_info%theta_a)) ntheta_prev =
SIZE(conn_info%theta_a)
731 CALL reallocate(conn_info%theta_a, 1, ntheta_prev + ntheth + ntheta)
732 CALL reallocate(conn_info%theta_b, 1, ntheta_prev + ntheth + ntheta)
733 CALL reallocate(conn_info%theta_c, 1, ntheta_prev + ntheth + ntheta)
735 index_now = ntheta_prev + i
736 conn_info%theta_a(index_now) = natom_prev + ith(i)
737 conn_info%theta_b(index_now) = natom_prev + jth(i)
738 conn_info%theta_c(index_now) = natom_prev + kth(i)
741 index_now = ntheta_prev + i + ntheth
742 conn_info%theta_a(index_now) = natom_prev + it(i)
743 conn_info%theta_b(index_now) = natom_prev + jt(i)
744 conn_info%theta_c(index_now) = natom_prev + kt(i)
751 IF (
ASSOCIATED(conn_info%phi_a)) nphi_prev =
SIZE(conn_info%phi_a)
753 CALL reallocate(conn_info%phi_a, 1, nphi_prev + nphih + nphia)
754 CALL reallocate(conn_info%phi_b, 1, nphi_prev + nphih + nphia)
755 CALL reallocate(conn_info%phi_c, 1, nphi_prev + nphih + nphia)
756 CALL reallocate(conn_info%phi_d, 1, nphi_prev + nphih + nphia)
758 IF (nphih + nphia /= 0)
THEN
759 ALLOCATE (full_torsions(4, nphih + nphia))
760 ALLOCATE (iwork(nphih + nphia))
763 full_torsions(1, i) = iph(i)
764 full_torsions(2, i) = jph(i)
765 full_torsions(3, i) = kph(i)
766 full_torsions(4, i) = lph(i)
769 full_torsions(1, nphih + i) = ip(i)
770 full_torsions(2, nphih + i) = jp(i)
771 full_torsions(3, nphih + i) = kp(i)
772 full_torsions(4, nphih + i) = lp(i)
774 CALL sort(full_torsions, 1, nphih + nphia, 1, 4, iwork)
776 unique_torsions = nphi_prev + 1
777 conn_info%phi_a(unique_torsions) = natom_prev + full_torsions(1, 1)
778 conn_info%phi_b(unique_torsions) = natom_prev + full_torsions(2, 1)
779 conn_info%phi_c(unique_torsions) = natom_prev + full_torsions(3, 1)
780 conn_info%phi_d(unique_torsions) = natom_prev + full_torsions(4, 1)
781 DO i = 2, nphih + nphia
782 IF ((full_torsions(1, i) /= full_torsions(1, i - 1)) .OR. &
783 (full_torsions(2, i) /= full_torsions(2, i - 1)) .OR. &
784 (full_torsions(3, i) /= full_torsions(3, i - 1)) .OR. &
785 (full_torsions(4, i) /= full_torsions(4, i - 1)))
THEN
786 unique_torsions = unique_torsions + 1
787 conn_info%phi_a(unique_torsions) = natom_prev + full_torsions(1, i)
788 conn_info%phi_b(unique_torsions) = natom_prev + full_torsions(2, i)
789 conn_info%phi_c(unique_torsions) = natom_prev + full_torsions(3, i)
790 conn_info%phi_d(unique_torsions) = natom_prev + full_torsions(4, i)
793 CALL reallocate(conn_info%phi_a, 1, unique_torsions)
794 CALL reallocate(conn_info%phi_b, 1, unique_torsions)
795 CALL reallocate(conn_info%phi_c, 1, unique_torsions)
796 CALL reallocate(conn_info%phi_d, 1, unique_torsions)
798 DEALLOCATE (full_torsions)
810 CALL reallocate(atom_info%id_molname, 1, natom_prev + natom)
811 atom_info%id_molname(natom_prev + 1:natom_prev + natom) =
str2id(
s2s(
"__UNDEF__"))
813 atom_info%id_molname(natom_prev + 1:natom_prev + natom))
814 CALL timestop(handle2)
818 IF (do_forcefield)
THEN
819 CALL timeset(trim(routinen)//
"_forcefield", handle2)
823 CALL reallocate(amb_info%bond_a, 1, buffer_size)
824 CALL reallocate(amb_info%bond_b, 1, buffer_size)
825 CALL reallocate(amb_info%bond_k, 1, buffer_size)
826 CALL reallocate(amb_info%bond_r0, 1, buffer_size)
829 CALL post_process_bonds_info(amb_info%bond_a, amb_info%bond_b, &
830 amb_info%bond_k, amb_info%bond_r0, particle_set, nsize, &
831 nbonh, ibh, jbh, icbh, rk, req)
833 CALL post_process_bonds_info(amb_info%bond_a, amb_info%bond_b, &
834 amb_info%bond_k, amb_info%bond_r0, particle_set, nsize, &
835 nbona, ib, jb, icb, rk, req)
845 CALL reallocate(amb_info%bend_a, 1, buffer_size)
846 CALL reallocate(amb_info%bend_b, 1, buffer_size)
847 CALL reallocate(amb_info%bend_c, 1, buffer_size)
848 CALL reallocate(amb_info%bend_k, 1, buffer_size)
849 CALL reallocate(amb_info%bend_theta0, 1, buffer_size)
852 CALL post_process_bends_info(amb_info%bend_a, amb_info%bend_b, &
853 amb_info%bend_c, amb_info%bend_k, amb_info%bend_theta0, &
854 particle_set, nsize, ntheth, ith, jth, kth, icth, tk, teq)
856 CALL post_process_bends_info(amb_info%bend_a, amb_info%bend_b, &
857 amb_info%bend_c, amb_info%bend_k, amb_info%bend_theta0, &
858 particle_set, nsize, ntheta, it, jt, kt, ict, tk, teq)
864 CALL reallocate(amb_info%bend_theta0, 1, nsize)
871 CALL reallocate(amb_info%torsion_a, 1, buffer_size)
872 CALL reallocate(amb_info%torsion_b, 1, buffer_size)
873 CALL reallocate(amb_info%torsion_c, 1, buffer_size)
874 CALL reallocate(amb_info%torsion_d, 1, buffer_size)
875 CALL reallocate(amb_info%torsion_k, 1, buffer_size)
876 CALL reallocate(amb_info%torsion_m, 1, buffer_size)
877 CALL reallocate(amb_info%torsion_phi0, 1, buffer_size)
880 CALL post_process_torsions_info(amb_info%torsion_a, amb_info%torsion_b, &
881 amb_info%torsion_c, amb_info%torsion_d, amb_info%torsion_k, &
882 amb_info%torsion_m, amb_info%torsion_phi0, particle_set, nsize, &
883 nphih, iph, jph, kph, lph, icph, pk, pn, phase)
885 CALL post_process_torsions_info(amb_info%torsion_a, amb_info%torsion_b, &
886 amb_info%torsion_c, amb_info%torsion_d, amb_info%torsion_k, &
887 amb_info%torsion_m, amb_info%torsion_phi0, particle_set, nsize, &
888 nphia, ip, jp, kp, lp, icp, pk, pn, phase)
896 CALL reallocate(amb_info%torsion_phi0, 1, nsize)
899 IF (nphih + nphia /= 0)
THEN
900 ALLOCATE (iwork(nphih + nphia))
901 CALL sort(amb_info%raw_torsion_id, 1, nphih + nphia, 1, 5, iwork)
908 CALL reallocate(amb_info%nonbond_a, 1, buffer_size)
909 CALL reallocate(amb_info%nonbond_eps, 1, buffer_size)
910 CALL reallocate(amb_info%nonbond_rmin2, 1, buffer_size)
913 CALL post_process_lj_info(amb_info%nonbond_a, amb_info%nonbond_eps, &
914 amb_info%nonbond_rmin2, particle_set, ntypes, nsize, iac, ico, &
919 CALL reallocate(amb_info%nonbond_eps, 1, nsize)
920 CALL reallocate(amb_info%nonbond_rmin2, 1, nsize)
936 CALL timestop(handle2)
964 CALL timestop(handle)
968 /
' NATOM = ', i7,
' NTYPES = ', i7,
' NBONH = ', i7,
' MBONA = ', i7, &
969 /
' NTHETH = ', i7,
' MTHETA = ', i7,
' NPHIH = ', i7,
' MPHIA = ', i7, &
970 /
' NHPARM = ', i7,
' NPARM = ', i7,
' NNB = ', i7,
' NRES = ', i7, &
971 /
' NBONA = ', i7,
' NTHETA = ', i7,
' NPHIA = ', i7,
' NUMBND = ', i7, &
972 /
' NUMANG = ', i7,
' NPTRA = ', i7,
' NATYP = ', i7,
' NPHB = ', i7, &
973 /
' IFBOX = ', i7,
' NMXRS = ', i7,
' IFCAP = ', i7,
' NEXTRA = ', i7,/)
985 SUBROUTINE conform_atom_type_low(isymbl, iwork, i, istart, charges)
986 CHARACTER(LEN=default_string_length),
DIMENSION(:) :: isymbl
987 INTEGER,
DIMENSION(:) :: iwork
988 INTEGER,
INTENT(IN) :: i
989 INTEGER,
INTENT(INOUT) :: istart
990 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: charges
992 CHARACTER(len=*),
PARAMETER :: routinen =
'conform_atom_type_low'
994 INTEGER :: counter, gind, handle, iend, ind, isize, &
996 INTEGER,
DIMENSION(:),
POINTER :: cindx, lindx
997 REAL(kind=
dp) :: ctmp
998 REAL(kind=
dp),
DIMENSION(:),
POINTER :: cwork
1000 CALL timeset(routinen, handle)
1002 isize = iend - istart + 1
1003 ALLOCATE (cwork(isize))
1004 ALLOCATE (lindx(isize))
1005 ALLOCATE (cindx(isize))
1009 cwork(ind) = charges(iwork(k))
1012 CALL sort(cwork, isize, cindx)
1017 IF (cwork(k) /= ctmp)
THEN
1018 counter = counter + 1
1022 IF (counter /= 1)
THEN
1027 IF (cwork(k) /= ctmp)
THEN
1030 gind = lindx(cindx(j))
1031 IF (len_trim(isymbl(gind)) + len_trim(adjustl(
cp_to_string(counter))) > &
1032 len(isymbl(gind))) cpabort(
"AMBER charge kind name exceeds string length")
1033 isymbl(gind) = trim(isymbl(gind))//adjustl(
cp_to_string(counter))
1035 counter = counter + 1
1042 gind = lindx(cindx(j))
1043 IF (len_trim(isymbl(gind)) + len_trim(adjustl(
cp_to_string(counter))) > &
1044 len(isymbl(gind))) cpabort(
"AMBER charge kind name exceeds string length")
1045 isymbl(gind) = trim(isymbl(gind))//adjustl(
cp_to_string(counter))
1051 CALL timestop(handle)
1052 END SUBROUTINE conform_atom_type_low
1060 SUBROUTINE resolve_atom_type_collisions(isymbl, raw_isymbl)
1061 CHARACTER(LEN=default_string_length), &
1062 DIMENSION(:),
INTENT(INOUT) :: isymbl
1063 CHARACTER(LEN=default_string_length), &
1064 DIMENSION(:),
INTENT(IN) :: raw_isymbl
1066 CHARACTER(len=*),
PARAMETER :: routinen =
'resolve_atom_type_collisions'
1068 CHARACTER(LEN=default_string_length) :: base_name, candidate, suffix
1069 CHARACTER(LEN=default_string_length), &
1070 ALLOCATABLE,
DIMENSION(:) :: sorted_labels
1071 INTEGER :: finish, handle,
idx, jdx, keeper, n, &
1072 nsep, p, q, raw_len, start
1073 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: order
1074 LOGICAL :: collision, seen_type
1076 CALL timeset(routinen, handle)
1079 cpassert(
SIZE(raw_isymbl) == n)
1081 ALLOCATE (sorted_labels(n))
1086 sorted_labels(:) = isymbl
1087 CALL sort(sorted_labels, n, order)
1090 DO WHILE (start <= n)
1093 DO WHILE (finish < n)
1094 IF (sorted_labels(finish + 1) /= sorted_labels(start))
EXIT
1098 IF (finish > start)
THEN
1099 keeper = order(start)
1105 DO p = start + 1, finish
1107 IF (raw_isymbl(
idx) /= raw_isymbl(keeper))
THEN
1119 DO p = start, finish
1121 IF (raw_isymbl(
idx) == sorted_labels(start))
THEN
1127 DO p = start, finish
1130 IF (keeper /= 0)
THEN
1131 IF (raw_isymbl(
idx) == raw_isymbl(keeper)) cycle
1138 IF (raw_isymbl(jdx) == raw_isymbl(
idx))
THEN
1143 IF (seen_type) cycle
1145 base_name = trim(raw_isymbl(
idx))
1146 raw_len = len_trim(base_name)
1150 IF (len_trim(sorted_labels(start)) <= raw_len)
THEN
1151 cpabort(
"Unable to disambiguate AMBER atom kind name")
1154 suffix = adjustl(sorted_labels(start) (raw_len + 1:))
1160 IF (raw_len + nsep + len_trim(suffix) > len(candidate))
THEN
1161 cpabort(
"AMBER charge kind name exceeds string length")
1164 candidate = trim(base_name)//repeat(
"_", nsep)//trim(suffix)
1166 IF (.NOT. any(isymbl == candidate))
EXIT
1171 DO q = start, finish
1173 IF (raw_isymbl(jdx) == raw_isymbl(
idx))
THEN
1174 isymbl(jdx) = candidate
1185 DEALLOCATE (sorted_labels)
1188 CALL timestop(handle)
1189 END SUBROUTINE resolve_atom_type_collisions
1200 SUBROUTINE rd_amber_section_i1(parser, section, array1, dim)
1202 CHARACTER(LEN=default_string_length),
INTENT(IN) :: section
1203 INTEGER,
DIMENSION(:) :: array1
1204 INTEGER,
INTENT(IN) :: dim
1211 DO WHILE ((i <= dim) .AND. (.NOT. my_end))
1220 IF (my_end .AND. (i <= dim))
THEN
1221 CALL cp_abort(__location__, &
1222 "End of file while reading section "//trim(section)//
" in amber topology file!")
1224 END SUBROUTINE rd_amber_section_i1
1237 SUBROUTINE rd_amber_section_i3(parser, section, array1, array2, array3, dim)
1239 CHARACTER(LEN=default_string_length),
INTENT(IN) :: section
1240 INTEGER,
DIMENSION(:) :: array1, array2, array3
1241 INTEGER,
INTENT(IN) :: dim
1248 DO WHILE ((i <= dim) .AND. (.NOT. my_end))
1270 IF (my_end .AND. (i <= dim))
THEN
1271 CALL cp_abort(__location__, &
1272 "End of file while reading section "//trim(section)//
" in amber topology file!")
1274 END SUBROUTINE rd_amber_section_i3
1288 SUBROUTINE rd_amber_section_i4(parser, section, array1, array2, array3, array4, dim)
1290 CHARACTER(LEN=default_string_length),
INTENT(IN) :: section
1291 INTEGER,
DIMENSION(:) :: array1, array2, array3, array4
1292 INTEGER,
INTENT(IN) :: dim
1299 DO WHILE ((i <= dim) .AND. (.NOT. my_end))
1327 IF (my_end .AND. (i <= dim))
THEN
1328 CALL cp_abort(__location__, &
1329 "End of file while reading section "//trim(section)//
" in amber topology file!")
1331 END SUBROUTINE rd_amber_section_i4
1346 SUBROUTINE rd_amber_section_i5(parser, section, array1, array2, array3, array4, &
1349 CHARACTER(LEN=default_string_length),
INTENT(IN) :: section
1350 INTEGER,
DIMENSION(:) :: array1, array2, array3, array4, array5
1351 INTEGER,
INTENT(IN) :: dim
1358 DO WHILE ((i <= dim) .AND. (.NOT. my_end))
1392 IF (my_end .AND. (i <= dim))
THEN
1393 CALL cp_abort(__location__, &
1394 "End of file while reading section "//trim(section)//
" in amber topology file!")
1396 END SUBROUTINE rd_amber_section_i5
1407 SUBROUTINE rd_amber_section_c1(parser, section, array1, dim)
1409 CHARACTER(LEN=default_string_length),
INTENT(IN) :: section
1410 CHARACTER(LEN=default_string_length),
DIMENSION(:) :: array1
1411 INTEGER,
INTENT(IN) :: dim
1418 DO WHILE ((i <= dim) .AND. (.NOT. my_end))
1427 IF (my_end .AND. (i <= dim))
THEN
1428 CALL cp_abort(__location__, &
1429 "End of file while reading section "//trim(section)//
" in amber topology file!")
1431 END SUBROUTINE rd_amber_section_c1
1442 SUBROUTINE rd_amber_section_r1(parser, section, array1, dim)
1444 CHARACTER(LEN=default_string_length),
INTENT(IN) :: section
1445 REAL(kind=
dp),
DIMENSION(:) :: array1
1446 INTEGER,
INTENT(IN) :: dim
1453 DO WHILE ((i <= dim) .AND. (.NOT. my_end))
1462 IF (my_end .AND. (i <= dim))
THEN
1463 CALL cp_abort(__location__, &
1464 "End of file while reading section "//trim(section)//
" in amber topology file!")
1466 END SUBROUTINE rd_amber_section_r1
1476 FUNCTION get_section_parmtop(parser, section, input_format)
RESULT(another_section)
1478 CHARACTER(LEN=default_string_length),
INTENT(OUT) :: section, input_format
1479 LOGICAL :: another_section
1481 INTEGER :: end_f, indflag, start_f
1482 LOGICAL :: found, my_end
1487 indflag = index(parser%input_line,
"%FLAG") + len_trim(
"%FLAG")
1488 DO WHILE (index(parser%input_line(indflag:indflag),
" ") /= 0)
1489 indflag = indflag + 1
1491 section = trim(parser%input_line(indflag:))
1494 IF (index(parser%input_line,
"%FORMAT") == 0 .OR. my_end)
THEN
1495 cpabort(
"Expecting %FORMAT. Not found! Abort reading of AMBER topology file!")
1498 start_f = index(parser%input_line,
"(")
1499 end_f = index(parser%input_line,
")")
1500 input_format = parser%input_line(start_f:end_f)
1501 another_section = .true.
1503 another_section = .false.
1505 END FUNCTION get_section_parmtop
1514 FUNCTION check_amber_8_std(parser, output_unit)
RESULT(found_AMBER_V8)
1516 INTEGER,
INTENT(IN) :: output_unit
1517 LOGICAL :: found_amber_v8
1520 IF (.NOT. found_amber_v8)
THEN
1521 CALL cp_abort(__location__, &
1522 "This is not an AMBER V.8 PRMTOP format file. Cannot interpret older "// &
1523 "AMBER file formats. ")
1525 IF (output_unit > 0)
WRITE (output_unit,
'(" AMBER_INFO| ",A)')
"Amber PrmTop V.8 or greater.", &
1526 trim(parser%input_line)
1528 END FUNCTION check_amber_8_std
1546 SUBROUTINE post_process_bonds_info(label_a, label_b, k, r0, particle_set, ibond, &
1547 nbond, ib, jb, icb, rk, req)
1548 CHARACTER(LEN=default_string_length), &
1549 DIMENSION(:),
POINTER :: label_a, label_b
1550 REAL(kind=
dp),
DIMENSION(:),
POINTER :: k, r0
1552 INTEGER,
INTENT(INOUT) :: ibond
1553 INTEGER,
INTENT(IN) :: nbond
1554 INTEGER,
DIMENSION(:),
INTENT(IN) :: ib, jb, icb
1555 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: rk, req
1557 CHARACTER(len=*),
PARAMETER :: routinen =
'post_process_bonds_info'
1559 CHARACTER(LEN=default_string_length) :: name_atm_a, name_atm_b
1560 CHARACTER(LEN=default_string_length), &
1561 ALLOCATABLE,
DIMENSION(:, :) :: work_label
1562 INTEGER :: handle, i
1563 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: iwork
1566 CALL timeset(routinen, handle)
1567 IF (nbond /= 0)
THEN
1568 ALLOCATE (work_label(2, nbond))
1569 ALLOCATE (iwork(nbond))
1571 name_atm_a = particle_set(ib(i))%atomic_kind%name
1572 name_atm_b = particle_set(jb(i))%atomic_kind%name
1574 work_label(1, i) = name_atm_a
1575 work_label(2, i) = name_atm_b
1577 CALL sort(work_label, 1, nbond, 1, 2, iwork)
1581 IF (ibond >
SIZE(label_a))
THEN
1582 CALL reallocate(label_a, 1, int(buffer_size + ibond*1.5_dp))
1583 CALL reallocate(label_b, 1, int(buffer_size + ibond*1.5_dp))
1584 CALL reallocate(k, 1, int(buffer_size + ibond*1.5_dp))
1585 CALL reallocate(r0, 1, int(buffer_size + ibond*1.5_dp))
1587 label_a(ibond) = work_label(1, 1)
1588 label_b(ibond) = work_label(2, 1)
1589 k(ibond) = rk(icb(iwork(1)))
1590 r0(ibond) = req(icb(iwork(1)))
1593 IF ((work_label(1, i) /= label_a(ibond)) .OR. &
1594 (work_label(2, i) /= label_b(ibond)))
THEN
1597 IF (ibond >
SIZE(label_a))
THEN
1598 CALL reallocate(label_a, 1, int(buffer_size + ibond*1.5_dp))
1599 CALL reallocate(label_b, 1, int(buffer_size + ibond*1.5_dp))
1600 CALL reallocate(k, 1, int(buffer_size + ibond*1.5_dp))
1601 CALL reallocate(r0, 1, int(buffer_size + ibond*1.5_dp))
1603 label_a(ibond) = work_label(1, i)
1604 label_b(ibond) = work_label(2, i)
1605 k(ibond) = rk(icb(iwork(i)))
1606 r0(ibond) = req(icb(iwork(i)))
1610 DEALLOCATE (work_label)
1613 CALL timestop(handle)
1614 END SUBROUTINE post_process_bonds_info
1634 SUBROUTINE post_process_bends_info(label_a, label_b, label_c, k, theta0, &
1635 particle_set, itheta, ntheta, it, jt, kt, ict, tk, teq)
1636 CHARACTER(LEN=default_string_length), &
1637 DIMENSION(:),
POINTER :: label_a, label_b, label_c
1638 REAL(kind=
dp),
DIMENSION(:),
POINTER :: k, theta0
1640 INTEGER,
INTENT(INOUT) :: itheta
1641 INTEGER,
INTENT(IN) :: ntheta
1642 INTEGER,
DIMENSION(:),
INTENT(IN) :: it, jt, kt, ict
1643 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: tk, teq
1645 CHARACTER(len=*),
PARAMETER :: routinen =
'post_process_bends_info'
1647 CHARACTER(LEN=default_string_length) :: name_atm_a, name_atm_b, name_atm_c
1648 CHARACTER(LEN=default_string_length), &
1649 ALLOCATABLE,
DIMENSION(:, :) :: work_label
1650 INTEGER :: handle, i
1651 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: iwork
1654 CALL timeset(routinen, handle)
1655 IF (ntheta /= 0)
THEN
1656 ALLOCATE (work_label(3, ntheta))
1657 ALLOCATE (iwork(ntheta))
1659 name_atm_a = particle_set(it(i))%atomic_kind%name
1660 name_atm_b = particle_set(jt(i))%atomic_kind%name
1661 name_atm_c = particle_set(kt(i))%atomic_kind%name
1664 work_label(1, i) = name_atm_a
1665 work_label(2, i) = name_atm_b
1666 work_label(3, i) = name_atm_c
1669 CALL sort(work_label, 1, ntheta, 1, 3, iwork)
1673 IF (itheta >
SIZE(label_a))
THEN
1674 CALL reallocate(label_a, 1, int(buffer_size + itheta*1.5_dp))
1675 CALL reallocate(label_b, 1, int(buffer_size + itheta*1.5_dp))
1676 CALL reallocate(label_c, 1, int(buffer_size + itheta*1.5_dp))
1677 CALL reallocate(k, 1, int(buffer_size + itheta*1.5_dp))
1678 CALL reallocate(theta0, 1, int(buffer_size + itheta*1.5_dp))
1680 label_a(itheta) = work_label(1, 1)
1681 label_b(itheta) = work_label(2, 1)
1682 label_c(itheta) = work_label(3, 1)
1683 k(itheta) = tk(ict(iwork(1)))
1684 theta0(itheta) = teq(ict(iwork(1)))
1687 IF ((work_label(1, i) /= label_a(itheta)) .OR. &
1688 (work_label(2, i) /= label_b(itheta)) .OR. &
1689 (work_label(3, i) /= label_c(itheta)))
THEN
1692 IF (itheta >
SIZE(label_a))
THEN
1693 CALL reallocate(label_a, 1, int(buffer_size + itheta*1.5_dp))
1694 CALL reallocate(label_b, 1, int(buffer_size + itheta*1.5_dp))
1695 CALL reallocate(label_c, 1, int(buffer_size + itheta*1.5_dp))
1696 CALL reallocate(k, 1, int(buffer_size + itheta*1.5_dp))
1697 CALL reallocate(theta0, 1, int(buffer_size + itheta*1.5_dp))
1699 label_a(itheta) = work_label(1, i)
1700 label_b(itheta) = work_label(2, i)
1701 label_c(itheta) = work_label(3, i)
1702 k(itheta) = tk(ict(iwork(i)))
1703 theta0(itheta) = teq(ict(iwork(i)))
1707 DEALLOCATE (work_label)
1710 CALL timestop(handle)
1711 END SUBROUTINE post_process_bends_info
1735 SUBROUTINE post_process_torsions_info(label_a, label_b, label_c, label_d, k, &
1736 m, phi0, particle_set, iphi, nphi, ip, jp, kp, lp, icp, pk, pn, phase)
1737 CHARACTER(LEN=default_string_length), &
1738 DIMENSION(:),
POINTER :: label_a, label_b, label_c, label_d
1739 REAL(kind=
dp),
DIMENSION(:),
POINTER :: k
1740 INTEGER,
DIMENSION(:),
POINTER :: m
1741 REAL(kind=
dp),
DIMENSION(:),
POINTER :: phi0
1743 INTEGER,
INTENT(INOUT) :: iphi
1744 INTEGER,
INTENT(IN) :: nphi
1745 INTEGER,
DIMENSION(:),
INTENT(IN) :: ip, jp, kp, lp, icp
1746 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: pk, pn, phase
1748 CHARACTER(len=*),
PARAMETER :: routinen =
'post_process_torsions_info'
1750 CHARACTER(LEN=default_string_length) :: name_atm_a, name_atm_b, name_atm_c, &
1752 CHARACTER(LEN=default_string_length), &
1753 ALLOCATABLE,
DIMENSION(:, :) :: work_label
1754 INTEGER :: handle, i
1755 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: iwork
1758 CALL timeset(routinen, handle)
1760 ALLOCATE (work_label(6, nphi))
1761 ALLOCATE (iwork(nphi))
1763 name_atm_a = particle_set(ip(i))%atomic_kind%name
1764 name_atm_b = particle_set(jp(i))%atomic_kind%name
1765 name_atm_c = particle_set(kp(i))%atomic_kind%name
1766 name_atm_d = particle_set(lp(i))%atomic_kind%name
1768 id3=name_atm_c, id4=name_atm_d)
1769 work_label(1, i) = name_atm_a
1770 work_label(2, i) = name_atm_b
1771 work_label(3, i) = name_atm_c
1772 work_label(4, i) = name_atm_d
1775 work_label(5, i) = trim(adjustl(
cp_to_string(phase(icp(i)))))
1776 work_label(6, i) = trim(adjustl(
cp_to_string(pn(icp(i)))))
1779 CALL sort(work_label, 1, nphi, 1, 6, iwork)
1783 IF (iphi >
SIZE(label_a))
THEN
1784 CALL reallocate(label_a, 1, int(buffer_size + iphi*1.5_dp))
1785 CALL reallocate(label_b, 1, int(buffer_size + iphi*1.5_dp))
1786 CALL reallocate(label_c, 1, int(buffer_size + iphi*1.5_dp))
1787 CALL reallocate(label_d, 1, int(buffer_size + iphi*1.5_dp))
1788 CALL reallocate(k, 1, int(buffer_size + iphi*1.5_dp))
1789 CALL reallocate(m, 1, int(buffer_size + iphi*1.5_dp))
1790 CALL reallocate(phi0, 1, int(buffer_size + iphi*1.5_dp))
1792 label_a(iphi) = work_label(1, 1)
1793 label_b(iphi) = work_label(2, 1)
1794 label_c(iphi) = work_label(3, 1)
1795 label_d(iphi) = work_label(4, 1)
1796 k(iphi) = pk(icp(iwork(1)))
1797 m(iphi) = nint(pn(icp(iwork(1))))
1798 IF (m(iphi) - pn(icp(iwork(1))) > epsilon(1.0_dp))
THEN
1799 cpabort(
"Non-integer torsions not supported")
1802 phi0(iphi) = phase(icp(iwork(1)))
1808 IF ((work_label(1, i) /= label_a(iphi)) .OR. &
1809 (work_label(2, i) /= label_b(iphi)) .OR. &
1810 (work_label(3, i) /= label_c(iphi)) .OR. &
1811 (work_label(4, i) /= label_d(iphi)) .OR. &
1812 (pn(icp(iwork(i))) /= m(iphi)) .OR. &
1813 (phase(icp(iwork(i))) /= phi0(iphi)))
THEN
1816 IF (iphi >
SIZE(label_a))
THEN
1817 CALL reallocate(label_a, 1, int(buffer_size + iphi*1.5_dp))
1818 CALL reallocate(label_b, 1, int(buffer_size + iphi*1.5_dp))
1819 CALL reallocate(label_c, 1, int(buffer_size + iphi*1.5_dp))
1820 CALL reallocate(label_d, 1, int(buffer_size + iphi*1.5_dp))
1821 CALL reallocate(k, 1, int(buffer_size + iphi*1.5_dp))
1822 CALL reallocate(m, 1, int(buffer_size + iphi*1.5_dp))
1823 CALL reallocate(phi0, 1, int(buffer_size + iphi*1.5_dp))
1825 label_a(iphi) = work_label(1, i)
1826 label_b(iphi) = work_label(2, i)
1827 label_c(iphi) = work_label(3, i)
1828 label_d(iphi) = work_label(4, i)
1829 k(iphi) = pk(icp(iwork(i)))
1830 m(iphi) = nint(pn(icp(iwork(i))))
1831 IF (m(iphi) - pn(icp(iwork(i))) > epsilon(1.0_dp))
THEN
1832 cpabort(
"Non-integer torsions not supported")
1834 phi0(iphi) = phase(icp(iwork(i)))
1838 DEALLOCATE (work_label)
1841 CALL timestop(handle)
1842 END SUBROUTINE post_process_torsions_info
1859 SUBROUTINE post_process_lj_info(atom_label, eps, sigma, particle_set, &
1860 ntypes, nsize, iac, ico, cn1, cn2, natom)
1861 CHARACTER(LEN=default_string_length), &
1862 DIMENSION(:),
POINTER :: atom_label
1863 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eps, sigma
1865 INTEGER,
INTENT(IN) :: ntypes
1866 INTEGER,
INTENT(INOUT) :: nsize
1867 INTEGER,
DIMENSION(:),
INTENT(IN) :: iac, ico
1868 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: cn1, cn2
1869 INTEGER,
INTENT(IN) :: natom
1871 CHARACTER(len=*),
PARAMETER :: routinen =
'post_process_LJ_info'
1873 CHARACTER(LEN=default_string_length) :: name_atm_a
1874 CHARACTER(LEN=default_string_length), &
1875 ALLOCATABLE,
DIMENSION(:) :: work_label
1876 INTEGER :: handle, i
1877 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: iwork
1878 LOGICAL :: check, l_dum
1879 REAL(kind=
dp) :: f12, f6, my_eps, my_sigma, sigma6
1881 CALL timeset(routinen, handle)
1882 ALLOCATE (work_label(natom))
1883 ALLOCATE (iwork(natom))
1885 name_atm_a = particle_set(i)%atomic_kind%name
1887 work_label(i) = name_atm_a
1889 CALL sort(work_label, natom, iwork)
1892 IF (nsize >
SIZE(atom_label))
THEN
1893 CALL reallocate(atom_label, 1, int(buffer_size + nsize*1.5_dp))
1894 CALL reallocate(eps, 1, int(buffer_size + nsize*1.5_dp))
1895 CALL reallocate(sigma, 1, int(buffer_size + nsize*1.5_dp))
1897 f12 = cn1(ico(ntypes*(iac(iwork(1)) - 1) + iac(iwork(1))))
1898 f6 = cn2(ico(ntypes*(iac(iwork(1)) - 1) + iac(iwork(1))))
1899 check = (f6 == 0.0_dp) .EQV. (f12 == 0.0_dp)
1903 IF (f6 /= 0.0_dp)
THEN
1904 sigma6 = (2.0_dp*f12/f6)
1905 my_sigma = sigma6**(1.0_dp/6.0_dp)
1906 my_eps = f6/(2.0_dp*sigma6)
1908 atom_label(nsize) = work_label(1)
1909 sigma(nsize) = my_sigma/2.0_dp
1913 IF (work_label(i) == atom_label(nsize))
THEN
1914 IF (iac(iwork(i)) /= iac(iwork(i - 1)))
THEN
1915 cpabort(
"AMBER kind collision: "//trim(work_label(i)))
1920 IF (nsize >
SIZE(atom_label))
THEN
1921 CALL reallocate(atom_label, 1, int(buffer_size + nsize*1.5_dp))
1922 CALL reallocate(eps, 1, int(buffer_size + nsize*1.5_dp))
1923 CALL reallocate(sigma, 1, int(buffer_size + nsize*1.5_dp))
1925 f12 = cn1(ico(ntypes*(iac(iwork(i)) - 1) + iac(iwork(i))))
1926 f6 = cn2(ico(ntypes*(iac(iwork(i)) - 1) + iac(iwork(i))))
1927 check = (f6 == 0.0_dp) .EQV. (f12 == 0.0_dp)
1931 IF (f6 /= 0.0_dp)
THEN
1932 sigma6 = (2.0_dp*f12/f6)
1933 my_sigma = sigma6**(1.0_dp/6.0_dp)
1934 my_eps = f6/(2.0_dp*sigma6)
1936 atom_label(nsize) = work_label(i)
1937 sigma(nsize) = my_sigma/2.0_dp
1942 DEALLOCATE (work_label)
1944 CALL timestop(handle)
1945 END SUBROUTINE post_process_lj_info
static GRID_HOST_DEVICE int idx(const orbital a)
Return coset index of given orbital angular momentum.
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout, file_access)
...
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.
subroutine, public parser_search_string(parser, string, ignore_case, found, line, begin_line, search_from_begin_of_file)
Search a string pattern in a file defined by its logical unit number "unit". A case sensitive search ...
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.
real(kind=dp) function, public cp_unit_to_cp2k(value, unit_str, defaults, power)
converts to the internal cp2k units to the given unit
Define all structures types related to force_fields.
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Utility routines for the memory handling.
Interface to the message passing library MPI.
Define the data structure for the particle information.
logical function, public qmmm_ff_precond_only_qm(id1, id2, id3, id4, is_link)
This function handles the atom names and modifies the "_QM_" prefix, in order to find the parameters ...
generates a unique id number for a string (str2id) that can be used two compare two strings....
character(len=default_string_length) function, public s2s(str)
converts a string in a string of default_string_length
integer function, public str2id(str)
returns a unique id for a given string, and stores the string for later retrieval using the id.
character(len=default_string_length) function, public id2str(id)
returns the string associated with a given id
Handles all functions used to read and interpret AMBER coordinates and topology files.
subroutine, public rdparm_amber_8(filename, output_unit, para_env, do_connectivity, do_forcefield, atom_info, conn_info, amb_info, particle_set)
Access information form the AMBER topology file Notes on file structure:
subroutine, public read_coordinate_crd(topology, para_env, subsys_section)
Reads the coord' version generated by the PARM or LEaP programs, as well as the restrt' version,...
subroutine, public read_connectivity_amber(filename, topology, para_env, subsys_section)
Read AMBER topology file (.top) : At this level we parse only the connectivity info the ....
Collection of subroutine needed for topology related things.
subroutine, public topology_generate_molname(conn_info, natom, natom_prev, nbond_prev, id_molname)
Generates molnames: useful when the connectivity on file does not provide them.
Control for reading in different topologies and coordinates.
All kind of helpful little routines.
type of a logger, at the moment it contains just a print level starting at which level it should be l...
stores all the informations relevant to an mpi environment