--- pumprechv8.f.0	2011-07-08 10:30:10.000000000 -0600
+++ pumprechv9.f.0	2015-04-15 11:30:32.000000000 -0600
@@ -1,4 +1,4 @@
-c	Program pumprechv8.for
+c	Program pumprechv9.for
 c	Author: Steve Larson, SSPA
 
 c	Purpose: Processes Kansas wateruse data to produce groundwater
@@ -6,6 +6,10 @@
 c	Version: This version is the same as pumprechv4.for except
 c	for the removal of the bi-linear interpolation.
 c
+c     Version 9 (spp, 4/15/2015): modified to write two additional fields to diagnostic output file authacresYYYY.out.
+c       Added fields are acres(jloc,iloc), to show cumulative gw acres in cell corresponding to authorized tract, and
+c       node number [node = 326*(iloc - 1) + jloc for row iloc and column jloc].
+c
 c     Version 8 (spp, 7/8/2011): modified to calculate pd-pu distances between the centroid of pds
 c       within a group(miles) and its corresponding place of use for each tract, given by variable distpdpu_mi;
 c       and a nominal range of distance for pds within the group, given by
@@ -43,8 +47,17 @@
 c
 c     Compiled and linked with Lahey 95 v5.6 as follows:
 c       lf95 pumprechv5.for -chk -lst
+! source code notes
+
+! Compiling with Gnu Fortran:
+! Prior to compiling, linking or running:
+!   set path=%path%;C:\MinGW\bin\
+! To compile:
+!   Switches: -c: Compile without linking; -o link without compiling; -ffree-line-length-none (free format source code, no line length limit), -Wall (Warnings all)
+!   gfortran  -c -Wall -Wextra -fcheck=bounds -Fbacktrace pumprechv9.for
+!   gfortran -static -o pumprechv9 pumprechv9.o
 c
-      program pumprechv7
+      program pumprechv9
 
       dimension pump(400,400),gwret(400,400),acres(400,400),
      + dx(400),dy(400),sx(401),sy(401),ibound(400,400),pumpmi(400,400),
@@ -84,8 +97,8 @@
 c
       ier0=0
       if (IARGC().ne.2) then
-        write(*,*) 'usage: pumprechv7 [year] [almena factor]'
-        write(*,*) 'ex. for 2010: pumprechv7 2010 0.7187758'
+        write(*,*) 'usage: pumprechv9 [year] [almena factor]'
+        write(*,*) 'ex. for 2010: pumprechv9 2010 0.7187758'
         STOP
       end if
 c
@@ -95,7 +108,7 @@
       call GETARG(2,chalmena_factor) !arg 2: almena factor (text version, declared as character*10)
       write(*,*) 'run for year '//year//
      |           ', almena factor='//chalmena_factor
-      read(trim(chalmena_factor),'(G32.0)') almenafactor
+      read(chalmena_factor,'(G32.0)') almenafactor      !replace trim(chalmena_factor) with chalmena_factor
       write(*,*) ' real version: ',almenafactor
 ccc      STOP
 
@@ -163,6 +176,8 @@
 
       sumgwret=0.
       sumacres=0.
+      acresmax=0.
+      acresmin=0.
 c     total auth acres for each grp
       write(*,*) '..reading authorized acres by group'
       open(20,file='authacres'//year//'.txt')
@@ -353,7 +368,7 @@
      |  ' grp',' twnshp',' range',' sect',' tract', ' authacres',
      |  ' fct', ' xloc',' yloc',' row',' col',' fct=authacres/authtot',
      |  ' ibound(jloc,iloc)',' npd(grp)',' xpd(grp)',' ypd(grp)',
-     |  ' distpdpu_mi',' pdrange_mi'
+     |  ' distpdpu_mi',' pdrange_mi',' acres(jloc,iloc)',' node'
 c        1         2         3         4         5         6         7 2
       ygtop=yg0+ny*gdy
       do
@@ -374,6 +389,7 @@
          yoff=ygtop-yloc
          jloc=xoff/gdx+1.0
          iloc=yoff/gdy+1.0
+         node=326*(iloc-1)+jloc
          fct=authacres/authtot(grp)
 c        1         2         3         4         5         6         7 2
          if (jloc.gt.0.and.jloc.le.nx.and.iloc.gt.0.and.iloc.le.ny)then
@@ -381,9 +397,6 @@
          else
            ibnd=-99
          endif
-         write(30,*,iostat=eof) grp,twnshp,range,sect,tract,authacres,
-     |     fct,xloc,yloc,iloc,jloc,fct,ibnd,npd(grp),xpd(grp),ypd(grp),
-     |     distpdpu,pdrange(grp)
 c         write(14,*) n,nout,county,ibound(jloc,iloc),xoff,yoff,jloc,iloc
          if(jloc.lt.1.or.jloc.gt.nx) then
             nout=nout+1
@@ -408,6 +421,10 @@
             gwret(jloc,iloc)=gwret(jloc,iloc)+fct*gwretloc(grp)
             acres(jloc,iloc)=acres(jloc,iloc)+fct*acresloc(grp)
 
+         write(30,*,iostat=eof) grp,twnshp,range,sect,tract,authacres,
+     |     fct,xloc,yloc,iloc,jloc,fct,ibnd,npd(grp),xpd(grp),ypd(grp),
+     |     distpdpu,pdrange(grp),acres(jloc,iloc),node
+
       end do
       close(20)
       close(30)
