From 1ca00e8078ce8a53f7ce70ee943de3d7706f44d9 Mon Sep 17 00:00:00 2001
From: Robin Betz <robin@robinbetz.com>
Date: Thu, 10 Jul 2025 15:51:38 -0700
Subject: [PATCH] Initialize maxmove variable for all file types.

maxmove sets the number of molecules that may be moved to a better
position and defaults to all molecules in the structure section. However
this was only being parsed for the pdb file format, resulting in 0
molecules being moved in movebad in heuristics.F90 and failure to
converge for inputs of non-pdb file formats.

This PR sets the default value regardless of file type and parses it out
of the structure section.
---
 src/getinp.f90 | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/getinp.f90 b/src/getinp.f90
index 6a0761b..8f0c44d 100644
--- a/src/getinp.f90
+++ b/src/getinp.f90
@@ -773,8 +773,13 @@ subroutine getinp()
       end if
    end do
 
-   ! Assigning the input lines that correspond to each structure
 
+   ! Default to all non-fixed molecules may be moved.
+   do itype = 1, ntype
+     maxmove(itype) = nmols(itype)
+   end do
+
+   ! Assigning the input lines that correspond to each structure
    itype = 0
    iline = 0
    do while(iline < nlines)
@@ -785,6 +790,9 @@ subroutine getinp()
          iline = iline + 1
          do while(keyword(iline,1).ne.'end'.or.&
             keyword(iline,2).ne.'structure')
+            if(keyword(iline,1).eq.'maxmove') then
+               read(keyword(iline,2),*) maxmove(itype)
+            end if
             if(keyword(iline,1) == 'structure'.or.&
                iline == nlines) then
                write(*,*) ' ERROR: Structure specification not ending with "end structure"'
@@ -806,16 +814,12 @@ subroutine getinp()
          changechains(itype) = .false.
          chain(itype) = "#"
          segid(itype) = ""
-         maxmove(itype) = nmols(itype)
          do iline = 1, nlines
             if(iline.gt.linestrut(itype,1).and.&
                iline.lt.linestrut(itype,2)) then
                if(keyword(iline,1).eq.'changechains') then
                   changechains(itype) = .true.
                end if
-               if(keyword(iline,1).eq.'maxmove') then
-                  read(keyword(iline,2),*) maxmove(itype)
-               end if
                if(keyword(iline,1).eq.'resnumbers') then
                   read(keyword(iline,2),*) resnumbers(itype)
                end if
