Index: redvar.f
===================================================================
--- redvar.f	(revision 87ddcf7a314d90070d607f0ec7ac0a700b843abc)
+++ redvar.f	(revision e40e335d8909b50cd784019735fcdb0c28ee19bb)
@@ -1,119 +1,111 @@
-!**************************************************************
-!
-! This file contains the subroutines: redvar
-!
-! Copyright 2003-2005  Frank Eisenmenger, U.H.E. Hansmann,
-!                      Shura Hayryan, Chin-Ku 
-! Copyright 2007       Frank Eisenmenger, U.H.E. Hansmann,
-!                      Jan H. Meinke, Sandipan Mohanty
-!
-! **************************************************************
+c**************************************************************
+c
+c This file contains the subroutines: redvar
+c
+c Copyright 2003-2005  Frank Eisenmenger, U.H.E. Hansmann,
+c                      Shura Hayryan, Chin-Ku 
+c Copyright 2007       Frank Eisenmenger, U.H.E. Hansmann,
+c                      Jan H. Meinke, Sandipan Mohanty
+c
+c **************************************************************
 
 
       subroutine redvar
 
-! ...................................................................
-!
-! PURPOSE: Read global parameters for molecules from lines
-!
-!          +--------------------------------------------------+
-!          |@ molecule no. : six floats separated by commas   |
-!          +--------------------------------------------------+
-!
-!          NB: 1) if omit field with molecule no. assume: nml=1
-!              2) last 3 float are angles in deg.
-!
-!          Read and interpret file to SET and FIX internal variables
-!          by commands:
-!
-!          +-----------------------------------------+
-!          |  molecule : residue : variable : value  |
-!          +-----------------------------------------+
-!
-!        * Lines containing '&' assign FIXED variable(s), they will
-!          not be varied during subsequent minimization etc.
-!
-!        * Empty LINES or lines containing '#' are ignored
-!        * Several commands on same line must be separated by ';'
-!        * Empty COMMANDS, i.e. ' : : ' are ignored
-!        * All spaces are not significant and are therefore ignored
-!
-!        * A command consists of up to 4 (maxfld) fields, separated
-!          by ':'
-!
-!        - last field     : value for VARIABLE (REAL)
-!                           ! should never be empty
-!        - 1st before last: name(s) (CHAR) or index(ices) of VARIABLE(S)
-!        - 2nd before last: name(s) or index(ices) of RESIDUE(S)
-!        - 3rd before last: name or number(ices) of MOLECULE(S)
-!
-!        * molecules, residues, variables can be identified, either by,
-!          INDICES (zones 'n1-n2' possible) or NAMES
-!
-!        * several identifiers in a field can be separated by ','
-!
-!        * INDICES: for residues  - refer to numbering within molecule
-!                 : for variables - refer to numbering within residue
-!        * ZONES:   '-n2' indicates '1-n2'
-!                   'n1-' indicates 'n1-(all)'
-!        * NAMES or their ends can be indicated by wild-card '*'
-!                are case-sensitive
-!
-!        Example:  phi:-65; psi:-45  >set all phi=-65, all psi=-45
-!                  om*: 180 &  >set all omg, omt ... to 180 & fix them
-!                  5 : x* : -60  >set all xi-angles of residue 5 to 60
-!
-! CALLS: setvar,extstr,iendst,ibegst,iopfil,iredin,iredrl
-! ......................................................................
+c ...................................................................
+c
+c PURPOSE: Read global parameters for molecules from lines
+c
+c          +--------------------------------------------------+
+c          |@ molecule no. : six floats separated by commas   |
+c          +--------------------------------------------------+
+c
+c          NB: 1) if omit field with molecule no. assume: nml=1
+c              2) last 3 float are angles in deg.
+c
+c          Read and interpret file to SET and FIX internal variables
+c          by commands:
+c
+c          +-----------------------------------------+
+c          |  molecule : residue : variable : value  |
+c          +-----------------------------------------+
+c
+c        * Lines containing '&' assign FIXED variable(s), they will
+c          not be varied during subsequent minimization etc.
+c
+c        * Empty LINES or lines containing '#' are ignored
+c        * Several commands on same line must be separated by ';'
+c        * Empty COMMANDS, i.e. ' : : ' are ignored
+c        * All spaces are not significant and are therefore ignored
+c
+c        * A command consists of up to 4 (maxfld) fields, separated
+c          by ':'
+c
+c        - last field     : value for VARIABLE (REAL)
+c                           ! should never be empty
+c        - 1st before last: name(s) (CHAR) or index(ices) of VARIABLE(S)
+c        - 2nd before last: name(s) or index(ices) of RESIDUE(S)
+c        - 3rd before last: name or number(ices) of MOLECULE(S)
+c
+c        * molecules, residues, variables can be identified, either by,
+c          INDICES (zones 'n1-n2' possible) or NAMES
+c
+c        * several identifiers in a field can be separated by ','
+c
+c        * INDICES: for residues  - refer to numbering within molecule
+c                 : for variables - refer to numbering within residue
+c        * ZONES:   '-n2' indicates '1-n2'
+c                   'n1-' indicates 'n1-(all)'
+c        * NAMES or their ends can be indicated by wild-card '*'
+c                are case-sensitive
+c
+c        Example:  phi:-65; psi:-45  >set all phi=-65, all psi=-45
+c                  om*: 180 &  >set all omg, omt ... to 180 & fix them
+c                  5 : x* : -60  >set all xi-angles of residue 5 to 60
+c
+c CALLS: setvar,extstr,iendst,ibegst,iopfil,iredin,iredrl
+c ......................................................................
 
 
       include 'INCL.H'
 
-!     functions
-      integer iopfil, iendst, iredin, iredrl, ibegst
-! maxfld: max. # of fields in one command
-! maxide: max. # of identifiers in a field
-! maxcmd: max. # of commands to be interpreted
-! ilrg:   a large integer
-
-      integer maxfld, maxide, maxcmd, ilrg, ifdend, icb, i, ib, ibz
-      integer ife, ifb, ide, id, ice, ie, ieh, ieh1, iez, ihz, ifx, ifld
-      integer ile, ii, ihy, ilb, iml, it, in ,io, inum, kbz, iv, ity, jb
-      integer j, k, l, kez, kk, kv, lez, lbz,ll, ll1, ll2, n, nfi, ncmd
-      integer nfld, nide, nml, ntlvr
-      double precision vlvrx, rn, vr, val
+c maxfld: max. # of fields in one command
+c maxide: max. # of identifiers in a field
+c maxcmd: max. # of commands to be interpreted
+c ilrg:   a large integer
+
       parameter (maxfld=4,
-     &           maxide=30,
-     &           maxcmd=5000,
-     &           ilrg=1000000)
+     #           maxide=30,
+     #           maxcmd=5000,
+     #           ilrg=1000000)
 
       character spcm,spfd,spcc,sphy,cmt,wdc,sfix,blnk, sglp,
-     &          line*132,lincmd*132,linfld(maxfld)*132,linide*132,
-     &          linh*132,strg(6)*17
+     #          line*132,lincmd*132,linfld(maxfld)*132,linide*132,
+     #          linh*132,strg(6)*17
       dimension ifdend(maxfld),vlvrx(mxvr),rn(6)
       logical fix,did,exa,forml(mxml),forrs(mxrs),forvr(mxvr),
-     &        stvr(mxvr)
+     #        stvr(mxvr)
       data spcm/';'/,spfd/':'/,spcc/','/,sphy/'-'/,cmt/'#'/,wdc/'*'/,
-     &     sfix/'&'/,blnk/' '/, sglp/'@'/
-
-
-! ___________________________________ Checks
+     #     sfix/'&'/,blnk/' '/, sglp/'@'/
+
+
+c ___________________________________ Checks
       ntlvr=ivrml1(ntlml)+nvrml(ntlml)-1
       if (ntlvr.eq.0) then
-        write(logString,*)'redvar> No variables defined in molecule(s)'
+        write (*,*) ' redvar> No variables defined in molecule(s)'
         return
       endif
-! ___________________________________ Initialize
+c ___________________________________ Initialize
 
       io=iopfil(lunvar,varfil,'old','formatted')
       if (io.eq.0) then
-        write (logString, '(a,/,a,i3,2a)') 
-     &    ' redvar> ERROR opening file to set variables:',
-     &    ' LUN=',lunvar,' FILE=',varfil(1:iendst(varfil))
+        write (*,'(a,/,a,i3,2a)') 
+     #    ' redvar> ERROR opening file to set variables:',
+     #    ' LUN=',lunvar,' FILE=',varfil(1:iendst(varfil))
         stop
       elseif (io.eq.-1) then
         return
       endif
-! ___________________________________ Initialization
+c ___________________________________ Initialization
       do i=1,ntlml
         forml(i)=.true.
@@ -136,5 +128,5 @@
           vr=blat(iatvr(i))
         else
-          write(logString,*) 'redvar>  unknown variable type: ',it,' !'
+          write(*,*) 'redvar>  unknown variable type: ',it,' !'
           stop
         endif
@@ -146,8 +138,8 @@
     1 read (lunvar,'(a)',end=2) line
       ile=iendst(line)
-! _________________________________ ! ignore empty and commentary lines
+c _________________________________ ! ignore empty and commentary lines
       if (ile.gt.0.and.index(line(1:ile),cmt).le.0) then
 
-! _________________________________________ Global variables
+c _________________________________________ Global variables
         ilb = index(line(1:ile),sglp)+1
         if (ilb.ge.2) then
@@ -158,9 +150,8 @@
 
             if (iredin(lincmd,nml).le.0.or.
-     &          nml.le.0.or.nml.gt.ntlml) then
-              write (logString, *) 
-     &                 'redvar> ','Incorrect molecule number >',
-     &                    lincmd(1:l),'<  Must be in range [1,',
-     &                    ntlml,'] !'
+     #          nml.le.0.or.nml.gt.ntlml) then
+              write (*,*) 'redvar> ','Incorrect molecule number >',
+     #                    lincmd(1:l),'<  Must be in range [1,',
+     #                    ntlml,'] !'
               close(lunvar)
               stop
@@ -188,9 +179,9 @@
           if (iredrl(linh,rn(6)).le.0) goto 105
 
-! ---------------------------------------- check global angles
+c ---------------------------------------- check global angles
           if (  abs(rn(4)).gt.(1.8d2+1d-6)
-     &     .or. abs(rn(5)).gt.(9d1+1d-6) 
-     &     .or. abs(rn(6)).gt.(1.8d2+1d-6)
-     &    ) goto 106
+     #     .or. abs(rn(5)).gt.(9d1+1d-6) 
+     #     .or. abs(rn(6)).gt.(1.8d2+1d-6)
+     #    ) goto 106
            
           do i = 1,3
@@ -230,5 +221,5 @@
             endif
 
-! _________________________________________ Extract Command Fields
+c _________________________________________ Extract Command Fields
             nfld=0
             icb=1
@@ -244,5 +235,5 @@
 
             enddo
-! _______________________________ Interpret Command Fields (except last)
+c _______________________________ Interpret Command Fields (except last)
             do i=1,nfld-1
               ii=i
@@ -264,5 +255,5 @@
                 enddo
               endif
-! __________________________________ Identifiers in field
+c __________________________________ Identifiers in field
               nide=0
               ifb=1
@@ -308,8 +299,8 @@
                       if (ifld.eq.3) then        !  Mol.
 
-! ################### impossible # (inum) of molecule
+c ################### impossible # (inum) of molecule
 
                         if (inum.le.0.or.inum.gt.ntlml) then
-                          write (logString, *) ' # 1: ',inum
+                          write (*,*) ' # 1: ',inum
                           goto 104
                         endif
@@ -322,8 +313,8 @@
                             k=inum+nfi-1
 
-! ################### impossible # of residue (inum) in molecule
+c ################### impossible # of residue (inum) in molecule
 
                             if (k.lt.nfi.or.k.gt.irsml2(j)) then
-                              write (logString, *) ' # 2: ',inum
+                              write (*,*) ' # 2: ',inum
                               goto 104
                             endif 
@@ -340,9 +331,9 @@
                                 l=inum+nfi-1
 
-! ################### impossible # of variable (inum) in residue
+c ################### impossible # of variable (inum) in residue
 
                                 if (l.lt.nfi.or.
-     &                              l.gt.nfi+nvrrs(k)-1) then
-                                  write (logString, *) ' # 3: ',inum
+     #                              l.gt.nfi+nvrrs(k)-1) then
+                                  write (*,*) ' # 3: ',inum
                                   goto 104
                                 endif
@@ -373,7 +364,7 @@
                             linh(1:ieh1)=nmml(j)(ib:ieh)
                             if (((exa.and.ieh1.eq.id).or.
-     &                         (.not.exa.and.ieh1.ge.id)).and.
-     &                         linh(1:id).eq.linide(1:id))
-     &                         forml(j)=.true.
+     #                         (.not.exa.and.ieh1.ge.id)).and.
+     #                         linh(1:id).eq.linide(1:id))
+     #                         forml(j)=.true.
                           endif
                         enddo        
@@ -389,7 +380,7 @@
                                 linh(1:ieh1)=seq(k)(ib:ieh)
                                 if (((exa.and.ieh1.eq.id).or.
-     &                             (.not.exa.and.ieh1.ge.id))
-     &                          .and.linh(1:id).eq.linide(1:id))
-     &                            forrs(k)=.true.
+     #                             (.not.exa.and.ieh1.ge.id))
+     #                          .and.linh(1:id).eq.linide(1:id))
+     #                            forrs(k)=.true.
                               endif
                             enddo
@@ -410,7 +401,7 @@
                                     linh(1:ieh1)=nmvr(l)(ib:ieh)
                                     if (((exa.and.ieh1.eq.id)
-     &                         .or.(.not.exa.and.ieh1.ge.id))
-     &                          .and.linh(1:id).eq.linide(1:id))
-     &                              forvr(l)=.true.
+     #                         .or.(.not.exa.and.ieh1.ge.id))
+     #                          .and.linh(1:id).eq.linide(1:id))
+     #                              forvr(l)=.true.
                                   endif
                                 enddo
@@ -425,8 +416,8 @@
                   else                                       ! ___ Zone
 
-! ################### impossible zone '-' (without integer)
+c ################### impossible zone '-' (without integer)
 
                     if (ide.eq.1.and.ihy.eq.ide) then
-                      write (logString, *) ' # 4: ',ide
+                      write (*,*) ' # 4: ',ide
                       goto 104
                     endif
@@ -438,9 +429,9 @@
                       linh=linide(1:ihy-1)
 
-! ################### impossible (to read) integer before '-'
+c ################### impossible (to read) integer before '-'
 
                       if (iredin(linh,ibz).le.0.or.ibz.le.0)
-     &                  then
-                        write (logString, *) ' # 5 '
+     #                  then
+                        write (*,*) ' # 5 '
                         goto 104
                       endif
@@ -453,9 +444,9 @@
                       linh=linide(ihy+1:ide)
 
-! ################### impossible (to read) integer after '-'
+c ################### impossible (to read) integer after '-'
 
                       if (iredin(linh,iez).le.0.or.iez.le.0.or.
-     &                  iez.lt.ibz) then
-                        write (logString, *) ' # 6 '
+     #                  iez.lt.ibz) then
+                        write (*,*) ' # 6 '
                         goto 104
                       endif
@@ -511,5 +502,5 @@
             enddo  ! ... Fields (excl. value)
 
-! _____________________________________________________ Execute Command
+c _____________________________________________________ Execute Command
 
             if (iredrl(linfld(nfld),val).gt.izero) then  ! Read Value
@@ -525,13 +516,13 @@
                 endif
               enddo
-              if (.not.did) write (logString, '(3a)')
-     &          ' redvar> No variables affected by command >',
-     &          lincmd(1:ice),'<'
+              if (.not.did) write (*,'(3a)')
+     #          ' redvar> No variables affected by command >',
+     #          lincmd(1:ice),'<'
             else
 
               ll1=ibegst(linfld(nfld))
               ll2=iendst(linfld(nfld))
-              write (logString, *) 'll1,ll2, linfld(nfld): ',ll1,ll2,
-     &           '>',linfld(nfld)(ll1:ll2),'<'
+              write (*,*) 'll1,ll2, linfld(nfld): ',ll1,ll2,
+     #           '>',linfld(nfld)(ll1:ll2),'<'
 
               goto 102
@@ -544,5 +535,5 @@
 
     2 close(lunvar)
-! __________________________ Summary
+c __________________________ Summary
       iv=0
       do i=1,ntlml
@@ -560,8 +551,7 @@
              enddo
 
-             write (logString, '(3a,/,1x,5(a,2x),a)') ' redvar> ',
-     &                               nmml(i)(1:ie),
-     &                                    ' with global parameters:',
-     &                              (strg(k)(ibegst(strg(k)):),k=1,6)
+             write (*,'(3a,/,1x,5(a,2x),a)') ' redvar> ',nmml(i)(1:ie),
+     #                                    ' with global parameters:',
+     #                              (strg(k)(ibegst(strg(k)):),k=1,6)
              call setvar(i,vlvrx)
              goto 3
@@ -581,15 +571,15 @@
                 did=.true.
                 if (fxvr(iv)) then
-                  write(logString,'(3a,i4,1x,4a,f10.3,a)') ' redvar> ',
-     &                nmml(i)(1:ie),': residue ',j-jb,seq(j),
-     &                ': ',nmvr(iv),' set ',vlvrx(iv),'   Fixed'
+                  write (*,'(3a,i4,1x,4a,f10.3,a)') ' redvar> ',
+     #                nmml(i)(1:ie),': residue ',j-jb,seq(j),
+     #                ': ',nmvr(iv),' set ',vlvrx(iv),'   Fixed'
                 else
-                  write (logString, '(3a,i4,1x,4a,f10.3)') ' redvar> ',
-     &                nmml(i)(1:ie),': residue ',j-jb,seq(j),
-     &                ': ',nmvr(iv),' set ',vlvrx(iv)
+                  write (*,'(3a,i4,1x,4a,f10.3)') ' redvar> ',
+     #                nmml(i)(1:ie),': residue ',j-jb,seq(j),
+     #                ': ',nmvr(iv),' set ',vlvrx(iv)
                 endif
                 ity=ityvr(iv)
                 if (ity.eq.3.or.ity.eq.2)
-     &            vlvrx(iv)=vlvrx(iv)*cdr             ! angles
+     #            vlvrx(iv)=vlvrx(iv)*cdr             ! angles
                   
               else
@@ -599,11 +589,11 @@
           enddo
           if (did) then
-            if (in.gt.0) write (logString, '(3a,i5,a)')
-     &        ' redvar> Molecule ',nmml(i)(1:ie),': ',in,
-     &        ' variable(s) remain unchanged'
+            if (in.gt.0) write (*,'(3a,i5,a)')
+     #        ' redvar> Molecule ',nmml(i)(1:ie),': ',in,
+     #        ' variable(s) remain unchanged'
             call setvar(iml,vlvrx)
           else
-            write (logString, '(3a)') ' redvar> Molecule ',
-     &        nmml(i)(1:ie),': No internal variables changed'
+            write (*,'(3a)') ' redvar> Molecule ',
+     #        nmml(i)(1:ie),': No internal variables changed'
           endif
         endif
@@ -611,36 +601,33 @@
 
       return
-! ____________________________________________________________ Errors
-  100 write (logString, '(3a)') ' redvar> Cannot interpret command >',
-     &                 lincmd(1:ice),'<'
+c ____________________________________________________________ Errors
+  100 write (*,'(3a)') ' redvar> Cannot interpret command >',
+     #                 lincmd(1:ice),'<'
       close(lunvar)
       stop
-  101 write (logString, '(a,i5,a)') ' redvar> Command number ',ncmd,
-     &       ' reached'
+  101 write (*,'(a,i5,a)') ' redvar> Command number ',ncmd,' reached'
       close(lunvar)
       stop
-  102 write (logString, '(3a)') ' redvar> Cannot read value from >',
-     &                   lincmd(1:ice),'<'
+  102 write (*,'(3a)') ' redvar> Cannot read value from >',
+     #                   lincmd(1:ice),'<'
       close(lunvar)
       stop
-  103 write (logString, '(a,i3,3a)') ' redvar> Cannot read >',maxide,
-     &         ' identifiers from >',linfld(ii)(1:ife),'<'
+  103 write (*,'(a,i3,3a)') ' redvar> Cannot read >',maxide,
+     #         ' identifiers from >',linfld(ii)(1:ife),'<'
       close(lunvar)
       stop
-  104 write (logString, '(5a)') ' redvar> Error in identifier >',
-     &            linide(1:ide),'< of command >',lincmd(1:ice),'<'
+  104 write (*,'(5a)') ' redvar> Error in identifier >',
+     #            linide(1:ide),'< of command >',lincmd(1:ice),'<'
       close(lunvar)
       stop
-  105 write (logString, '(a,/,a,/,2a,/)') 
-     &                           ' redvar> line with global paramters:',
-     &                           line(1:ile),' must contain 6 floating',
-     &                           ' point numbers separated by commas !'
+  105 write (*,'(a,/,a,/,2a,/)') ' redvar> line with global paramters:',
+     #                           line(1:ile),' must contain 6 floating',
+     #                           ' point numbers separated by commas !'
       close(lunvar)
       stop
 
-  106 write (logString, '(a,/,a,/,2a,/)') 
-     &                           ' redvar> line with global paramters:',
-     &                           line(1:ile),' angles must be inside ',
-     &'ranges [-180,180], [-90,90], and [-180,180] Deg., respectively !'
+  106 write (*,'(a,/,a,/,2a,/)') ' redvar> line with global paramters:',
+     #                           line(1:ile),' angles must be inside ',
+     #'ranges [-180,180], [-90,90], and [-180,180] Deg., respectively !'
       close(lunvar)
       stop
