Index: addend.f
===================================================================
--- addend.f	(revision cb47b9cbc592f256d0e066794c5ad7b9a1b99540)
+++ addend.f	(revision 38d77eb4e27a6b22e4388b28629620f02aec9598)
@@ -42,6 +42,7 @@
      &.or.grn(:3).eq.'nme'.or.grc(:3).eq.'nme') then
 
-        write(*,'(2a)') ' addend> N-Acetyl (ace) or N-Methylamide (nme)'
-     &   ,' should be put in SEQUENCE file, not added as end groups'
+        write (logString, '(2a)') 
+     &   ' addend> N-Acetyl (ace) or N-Methylamide (nme)',
+     &   ' should be put in SEQUENCE file, not added as end groups'
 
         stop
@@ -59,5 +60,5 @@
               sbrs='nh2+'
             else
-              write (*,'(2a)') ' addend> ',
+              write (logString, '(2a)') ' addend> ',
      &         ' No N-terminal Hyp possible with ECEPP/3 dataset'
               stop
@@ -87,5 +88,5 @@
         else
 
-          write(*,'(2a)') ' addend> Can add only ',
+          write (logString, '(2a)') ' addend> Can add only ',
      &     'nh2 or nh3+ to N-terminus'
           stop
@@ -98,5 +99,5 @@
       else ! ace
 
-        write(*,'(2a)') ' addend> Acetyl group',
+        write (logString, '(2a)') ' addend> Acetyl group',
      &     ' at N-terminus not modified'
       endif
@@ -128,5 +129,5 @@
         else
 
-          write(*,'(2a)') ' addend> Can add only ',
+          write (logString, '(2a)') ' addend> Can add only ',
      &     'cooh or coo- to C-terminus'
           stop
@@ -139,5 +140,5 @@
       else  ! N'-methylamide
 
-        write(*,'(2a)') ' addend> N-Methylamide',
+        write (logString, '(2a)') ' addend> N-Methylamide',
      &     ' at C-terminus not modified'
 
@@ -149,7 +150,9 @@
         cg = cg + cgat(i)
       enddo
-      if (abs(cg).gt.1.d-5) write(*,'(a,i2,a,f7.3,/)')
-     &        ' addend> Net charge of molecule #'
+      if (abs(cg).gt.1.d-5) then
+         write (logString, '(a,i2,a,f7.3)') 
+     &      ' addend> Net charge of molecule #'
      &        ,nml,': ',cg
+      endif
 
       return
@@ -204,6 +207,7 @@
         endif
       enddo
-      write (*,'(4a,i4,a,i4)') ' rplgrp> cannot find atom >',rpat,
-     &'< to be replaced in residue ',seq(nrs),nrs,' of molecule ',nml
+      write (logString, '(4a,i4,a,i4)') ' rplgrp> cannot find atom >',
+     &   rpat,
+     &   '< to be replaced in residue ',seq(nrs),nrs,' of molecule ',nml
       stop
 
@@ -234,5 +238,5 @@
             if (iowat(ibd(i)).ne.nfirp) then
               if (ibdrg.ne.0) then
-                write (*,'(2a,i3)') 
+                write (logString, '(2a,i3)') 
      &             ' rplgrp> Can handle only simple ring at 1st',
      &             ' atom of molecule #',nml
@@ -261,5 +265,5 @@
           goto 11
         else
-          write (*,'(4a,i4,a,i4)') 
+          write (logString, '(4a,i4,a,i4)') 
      &      ' rplgrp> Cannot replace BACKBONE atom ',rpat,
      &      ' of residue ',seq(nrs),nrs,' in molecule #',nml
@@ -275,5 +279,5 @@
 ! _______________________________ get data for substituent atoms
     3 if (iopfil(lunlib,reslib,'old','formatted').le.izero) then
-        write (*,'(a,/,a,i3,2a)') 
+        write (logString, '(a,/,a,i3,2a)') 
      &    ' rplgrp> ERROR opening library of residues:',
      &    ' LUN=',lunlib,' FILE=',reslib(1:iendst(reslib))
@@ -289,5 +293,5 @@
         endif
       enddo
-      write (*,'(4a)') ' rplgrp> Cannot find atom >',rpat,
+      write (logString, '(4a)') ' rplgrp> Cannot find atom >',rpat,
      &'< in substituent residue ',sbrs
       stop
@@ -372,5 +376,6 @@
         else  ! more atoms
           if ((ilaat+nsh).gt.mxat) then
-            write (*,'(a,i5)') ' rplgrp> number of atoms > ',mxat
+            write (logString, '(a,i5)') ' rplgrp> number of atoms > ',
+     &         mxat
             stop
           endif
@@ -466,5 +471,5 @@
           nb=nb+1
           if (nb.gt.mxbd) then
-            write (*,'(6a,/,2a,3(i4,a))')
+            write (logString, '(6a,/,2a,3(i4,a))')
      &      ' rplgrp> Cannot add atoms following ',rpat,
      &      ' from group ',sbrs,' to atom ',rpat,
@@ -593,5 +598,6 @@
         else
           if ((ilavr+jsh).gt.mxvr) then
-            write (*,'(a,i5)') ' rplgrp> number of variables > ',mxvr
+            write (logString, '(a,i5)') 
+     &         ' rplgrp> number of variables > ',mxvr
             stop
           endif
@@ -628,10 +634,10 @@
       return
 ! __________________________________________ Errors
-   10 write (*,'(3a,/,2a,i4,a,i4,/,2a)') 
+   10 write (logString, '(3a,/,2a,i4,a,i4,/,2a)') 
      &   ' rplgrp> Cannot replace atom(s) following ',rpat,
      &   ' from INSIDE a ring','    in residue: ',seq(nrs),nrs,
      &   ' in molecule #',nml,' or in substitute: ',sbrs
       stop
-   11 write (*,'(4a,i4,a,i4,/,a)') 
+   11 write (logString, '(4a,i4,a,i4,/,a)') 
      &   ' rplgrp> Cannot replace atom(s) following ',rpat,
      &   ' of residue ',seq(nrs),nrs,' in molecule #',nml,
@@ -686,5 +692,6 @@
           endif
         else
-          write (*,*) ' redchg> dont know which end goup is present'
+          write(logString,*)
+     &                  ' redchg> dont know which end goup is present'
           stop
         endif
@@ -698,5 +705,5 @@
 
         if (iopfil(lunchg,chgfil,'old','formatted').le.izero) then
-          write (*,'(a,/,a,i3,2a)') 
+          write (logString, '(a,/,a,i3,2a)') 
      &      ' redchg> ERROR opening library of charges:',
      &      ' LUN=',lunchg,' FILE=',chgfil(1:iendst(chgfil))
@@ -722,5 +729,6 @@
                 endif
               enddo
-              write (*,'(6a)') ' redchg> Cannot find atom: ',atnm,
+              write (logString, '(6a)') ' redchg> Cannot find atom: ',
+     &                        atnm,
      &                        ' for entry: ',cgty,' in library: ',
      &                        chgfil(1:iendst(chgfil))
@@ -729,5 +737,5 @@
             return
           else
-            write (*,'(4a)')
+            write (logString, '(4a)')
      &       ' redchg> must increase MXATH to read data for entry: ',
      &        cgty,' in library: ',chgfil(1:iendst(chgfil))
@@ -737,5 +745,5 @@
         endif
         goto 1
-    3   write (*,'(4a)')
+    3   write (logString, '(4a)')
      &   ' redchg> Cannot find entry: ',cgty,' in library: ',
      &      chgfil(1:iendst(chgfil))
@@ -746,5 +754,5 @@
 
         if (iopfil(lunlib,reslib,'old','formatted').le.izero) then
-          write (*,'(a,/,a,i3,2a)') 
+          write (logString, '(a,/,a,i3,2a)') 
      &      ' redchg> ERROR opening library of residues:',
      &      ' LUN=',lunlib,' FILE=',reslib(1:iendst(reslib))
@@ -769,5 +777,6 @@
                 endif
               enddo
-              write (*,'(6a)') ' redchg> Cannot find atom: ',atnm,
+              write (logString, '(6a)') ' redchg> Cannot find atom: ',
+     &                        atnm,
      &                        ' for entry: ',cgty,' in library: ',
      &                        reslib(1:iendst(reslib))
@@ -776,5 +785,5 @@
             return
           else
-            write (*,'(4a)')
+            write (logString, '(4a)')
      &       ' redchg> must increase MXATH to read data for entry: ',
      &        cgty,' in library: ',reslib(1:iendst(reslib))
@@ -784,5 +793,5 @@
         endif
         goto 4
-    6   write (*,'(4a)')
+    6   write (logString, '(4a)')
      &   ' redchg> Cannot find entry: ',cgty,' in library: ',
      &      reslib(1:iendst(reslib))
@@ -792,5 +801,5 @@
       endif
 
-   10 write (*,'(4a)')
+   10 write (logString, '(4a)')
      &    ' redchg> Do not have charges for N/C-terminal residue ',
      &    res,' modified with group :',sbrs
