Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiq committed Jul 12, 2024
1 parent 82c781d commit 3be895d
Show file tree
Hide file tree
Showing 36 changed files with 4,875 additions and 4,903 deletions.
158 changes: 79 additions & 79 deletions src/cenmass.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,102 +2,102 @@
! Written by Leandro Martínez, 2009-2011.
! Copyright (c) 2009-2018, Leandro Martínez, Jose Mario Martinez,
! Ernesto G. Birgin.
!
!
! Subroutine cenmass
!
! Computes the center of mass of free molecules and
! for fixed molecules, if required.
! for fixed molecules, if required.
!
subroutine cenmass()

use sizes
use compute_data, only : ntype, coor, idfirst, natoms
use input, only : keyword, amass, nlines, linestrut
use sizes
use compute_data, only : ntype, coor, idfirst, natoms
use input, only : keyword, amass, nlines, linestrut

implicit none
integer :: k, iline
integer :: itype, iatom, idatom
double precision, allocatable :: cm(:,:), totm(:)
logical, allocatable :: domass(:)

! Allocate local vectors

implicit none
integer :: k, iline
integer :: itype, iatom, idatom
double precision, allocatable :: cm(:,:), totm(:)
logical, allocatable :: domass(:)
allocate(cm(ntype,3),totm(ntype),domass(ntype))

! Allocate local vectors
! Setting the molecules for which the center of mass is computed

allocate(cm(ntype,3),totm(ntype),domass(ntype))
do itype = 1, ntype
domass(itype) = .true.
end do

! Setting the molecules for which the center of mass is computed
do iline = 1, nlines
if(keyword(iline,1).eq.'fixed') then
do itype = 1, ntype
if(iline.gt.linestrut(itype,1).and. &
iline.lt.linestrut(itype,2)) then
domass(itype) = .false.
end if
end do
end if
end do

do itype = 1, ntype
domass(itype) = .true.
end do
do iline = 1, nlines
if(keyword(iline,1).eq.'centerofmass'.or. &
keyword(iline,1).eq.'center') then
do itype = 1, ntype
if(iline.gt.linestrut(itype,1).and. &
iline.lt.linestrut(itype,2)) then
domass(itype) = .true.
end if
end do
end if
end do

do iline = 1, nlines
if(keyword(iline,1).eq.'fixed') then
do itype = 1, ntype
if(iline.gt.linestrut(itype,1).and. &
iline.lt.linestrut(itype,2)) then
domass(itype) = .false.
end if
! Computing the center of mass

do itype = 1, ntype
do k = 1, 3
cm(itype, k) = 0.d0
end do
end if
end do

do iline = 1, nlines
if(keyword(iline,1).eq.'centerofmass'.or. &
keyword(iline,1).eq.'center') then
do itype = 1, ntype
if(iline.gt.linestrut(itype,1).and. &
iline.lt.linestrut(itype,2)) then
domass(itype) = .true.
end if
end do

do itype = 1, ntype
totm(itype) = 0.d0
idatom = idfirst(itype) - 1
do iatom = 1, natoms(itype)
idatom = idatom + 1
totm(itype) = totm(itype) + amass(idatom)
end do
end if
end do

! Computing the center of mass

do itype = 1, ntype
do k = 1, 3
cm(itype, k) = 0.d0
end do
end do

do itype = 1, ntype
totm(itype) = 0.d0
idatom = idfirst(itype) - 1
do iatom = 1, natoms(itype)
idatom = idatom + 1
totm(itype) = totm(itype) + amass(idatom)
end do
end do

do itype = 1, ntype
idatom = idfirst(itype) - 1
do iatom = 1, natoms(itype)
idatom = idatom + 1
do k = 1, 3
cm(itype, k) = cm(itype, k) + coor(idatom, k)*amass(idatom)
end do
end do
do k = 1, 3
cm(itype, k) = cm(itype, k) / totm(itype)
end do
end do

! Putting molecules in their center of mass

do itype = 1, ntype
if(domass(itype)) then
end do

do itype = 1, ntype
idatom = idfirst(itype) - 1
do iatom = 1, natoms(itype)
idatom = idatom + 1
do k = 1, 3
coor(idatom, k) = coor(idatom, k) - cm(itype, k)
end do
idatom = idatom + 1
do k = 1, 3
cm(itype, k) = cm(itype, k) + coor(idatom, k)*amass(idatom)
end do
end do
do k = 1, 3
cm(itype, k) = cm(itype, k) / totm(itype)
end do
end if
end do
end do

! Putting molecules in their center of mass

do itype = 1, ntype
if(domass(itype)) then
idatom = idfirst(itype) - 1
do iatom = 1, natoms(itype)
idatom = idatom + 1
do k = 1, 3
coor(idatom, k) = coor(idatom, k) - cm(itype, k)
end do
end do
end if
end do

deallocate(cm,totm,domass)
deallocate(cm,totm,domass)

return
return
end subroutine cenmass
194 changes: 97 additions & 97 deletions src/checkpoint.f90
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
!
!
! Written by Leandro Martínez, 2009-2011.
! Copyright (c) 2009-2018, Leandro Martínez, Jose Mario Martinez,
! Ernesto G. Birgin.
!
!

!
! Subroutine that writes the last point obtained when
Expand All @@ -11,106 +11,106 @@

subroutine checkpoint(n,x)

use sizes
use compute_data
use input
use usegencan
use ahestetic
use sizes
use compute_data
use input
use usegencan
use ahestetic

implicit none
integer :: i
integer :: n
double precision :: x(n)
double precision :: fx
logical :: movebadprint
character(len=strl) :: xyzout_forced
implicit none
integer :: i
integer :: n
double precision :: x(n)
double precision :: fx
logical :: movebadprint
character(len=strl) :: xyzout_forced

! All molecules are important
! All molecules are important

do i = 1, ntfix
comptype(i) = .true.
comptype(i) = .true.
end do

! Call the subroutine that computes de function value

call computef(n,x,fx)

write(*,dash3_line)
write(*,"(&
&' Packmol was not able to find a solution to your',/,&
&' packing problem with the desired distance tolerance.',/,/,&
&' First of all, be sure if the molecules fit in the',/,&
&' regions specified and if the constraints were set',/,&
&' correctly. ',/,/,&
&' Secondly, try simply running it again with a different ',/,&
&' seed for the random number generator of the initial ',/,&
&' point. This is done by adding the keyword seed to the',/,&
&' input file, as in: ',/,/,&
&' seed 192911 ',/,/,&
&' The best configuration found has a function value of',/,&
&' f = ', e14.7,/,/,&
&' IMPORTANT: ',/,&
&' If the number of molecules and the restraints are',/,&
&' correct, it is still very likely that the current point',/,&
&' fits your needs if your purpose is to run a MD',/,&
&' simulation.',/,&
&' Therefore, we recommend to minimize the energy of the',/,&
&' solution found, equilibrate it and run with it as well.',/&
&)") fx
write(*,dash3_line)

call output(n,x,xyzout)

write(*,*) ' The solution with the best function value was '
write(*,*) ' written to the output file: ', trim(adjustl(xyzout))
if ( crd ) write(*,*) ' ... and to CRD file: ', trim(adjustl(crdfile))
write(*,dash1_line)
write(*,*) ' Forcing the solution to fit the constraints...'

! CALL GENCAN

init1 = .true.
do i = 1, nloop
iprint1 = 0
iprint2 = 0
call pgencan(n,x,fx)
movebadprint = .false.
call movebad(n,x,fx,movebadprint)
end do
init1 = .false.

write(*,*)
write(*,dash1_line)
xyzout_forced = trim(adjustl(xyzout))//'_FORCED'
call output(n,x,xyzout_forced)

write(*,*) ' The forced point was writen to the '
write(*,*) ' output file: ', trim(adjustl(xyzout_forced))
if ( crd ) write(*,*) ' ... and to CRD file: ', trim(adjustl(crdfile))
write(*,*)
write(*,*) ' If you want that the packing procedure continues'
write(*,*) ' for a longer time, add the following keyword '
write(*,*) ' to the input file: '
write(*,*)
write(*,*) ' nloop [integer] (ex: nloop 200) '
write(*,*)
write(*,*) ' The default nloop value is 50 for each molecule.'
write(*,*)

write(*,hash1_line)
write(*,*) ' ENDED WITHOUT PERFECT PACKING: '
write(*,*) ' The output file:'
write(*,*)
write(*,*) ' ', trim(adjustl(xyzout))
if ( crd ) write(*,*) ' (... and to CRD file: ', trim(adjustl(crdfile)), ')'
write(*,*)
write(*,*) ' contains the best solution found. '
write(*,*)
write(*,*) ' Very likely, if the input data was correct, '
write(*,*) ' it is a reasonable starting configuration.'
write(*,*) ' Check commentaries above for more details. '
write(*,hash1_line)
return
! Call the subroutine that computes de function value

call computef(n,x,fx)

write(*,dash3_line)
write(*,"(&
&' Packmol was not able to find a solution to your',/,&
&' packing problem with the desired distance tolerance.',/,/,&
&' First of all, be sure if the molecules fit in the',/,&
&' regions specified and if the constraints were set',/,&
&' correctly. ',/,/,&
&' Secondly, try simply running it again with a different ',/,&
&' seed for the random number generator of the initial ',/,&
&' point. This is done by adding the keyword seed to the',/,&
&' input file, as in: ',/,/,&
&' seed 192911 ',/,/,&
&' The best configuration found has a function value of',/,&
&' f = ', e14.7,/,/,&
&' IMPORTANT: ',/,&
&' If the number of molecules and the restraints are',/,&
&' correct, it is still very likely that the current point',/,&
&' fits your needs if your purpose is to run a MD',/,&
&' simulation.',/,&
&' Therefore, we recommend to minimize the energy of the',/,&
&' solution found, equilibrate it and run with it as well.',/&
&)") fx
write(*,dash3_line)

call output(n,x,xyzout)

write(*,*) ' The solution with the best function value was '
write(*,*) ' written to the output file: ', trim(adjustl(xyzout))
if ( crd ) write(*,*) ' ... and to CRD file: ', trim(adjustl(crdfile))
write(*,dash1_line)
write(*,*) ' Forcing the solution to fit the constraints...'

! CALL GENCAN

init1 = .true.
do i = 1, nloop
iprint1 = 0
iprint2 = 0
call pgencan(n,x,fx)
movebadprint = .false.
call movebad(n,x,fx,movebadprint)
end do
init1 = .false.

write(*,*)
write(*,dash1_line)
xyzout_forced = trim(adjustl(xyzout))//'_FORCED'
call output(n,x,xyzout_forced)

write(*,*) ' The forced point was writen to the '
write(*,*) ' output file: ', trim(adjustl(xyzout_forced))
if ( crd ) write(*,*) ' ... and to CRD file: ', trim(adjustl(crdfile))
write(*,*)
write(*,*) ' If you want that the packing procedure continues'
write(*,*) ' for a longer time, add the following keyword '
write(*,*) ' to the input file: '
write(*,*)
write(*,*) ' nloop [integer] (ex: nloop 200) '
write(*,*)
write(*,*) ' The default nloop value is 50 for each molecule.'
write(*,*)

write(*,hash1_line)
write(*,*) ' ENDED WITHOUT PERFECT PACKING: '
write(*,*) ' The output file:'
write(*,*)
write(*,*) ' ', trim(adjustl(xyzout))
if ( crd ) write(*,*) ' (... and to CRD file: ', trim(adjustl(crdfile)), ')'
write(*,*)
write(*,*) ' contains the best solution found. '
write(*,*)
write(*,*) ' Very likely, if the input data was correct, '
write(*,*) ' it is a reasonable starting configuration.'
write(*,*) ' Check commentaries above for more details. '
write(*,hash1_line)

return
end subroutine checkpoint

Loading

0 comments on commit 3be895d

Please sign in to comment.