From e7aab0dd23b4de8ad7fbf13d2b1f51135ced8337 Mon Sep 17 00:00:00 2001
From: KyleKlenk <kyle.c.klenk@gmail.com>
Date: Mon, 24 Oct 2022 19:51:04 +0000
Subject: [PATCH] removed calls to unused files

---
 build/makefile_sundials                       |   4 +-
 .../file_access_actor/cppwrap_fileAccess.f90  | 144 -----------
 .../deallocateOutputStruc.f90                 |  22 --
 .../file_access_actor/file_access_actor.cpp   |  60 +----
 .../file_access_actor/initOutputStruc.f90     | 176 +++----------
 build/source/actors/hru_actor/cppwrap_hru.f90 | 237 ------------------
 build/source/actors/hru_actor/hru_actor.cpp   |   2 +-
 build/source/actors/hru_actor/hru_actor.f90   |   1 -
 build/source/dshare/data_types.f90            |  18 --
 build/source/netcdf/writeOutput.f90           | 180 +------------
 10 files changed, 32 insertions(+), 812 deletions(-)

diff --git a/build/makefile_sundials b/build/makefile_sundials
index 842265e..e86f1e4 100644
--- a/build/makefile_sundials
+++ b/build/makefile_sundials
@@ -244,7 +244,6 @@ MODRUN = $(patsubst %, $(ENGINE_DIR)/%, $(SUMMA_MODRUN))
 SUMMA_NETCDF = \
 		netcdf_util.f90 \
 		def_output.f90 \
-		outputStrucWrite.f90 \
 		writeOutput.f90	\
 		read_icondActors.f90
 NETCDF = $(patsubst %, $(NETCDF_DIR)/%, $(SUMMA_NETCDF))
@@ -265,8 +264,7 @@ SUMMA_DRIVER= \
 		summaActors_restart.f90 \
 		summaActors_forcing.f90 \
 		SummaActors_modelRun.f90 \
-		summaActors_alarms.f90 \
-		summaActors_wOutputStruc.f90
+		summaActors_alarms.f90
 		
 		
 DRIVER = $(patsubst %, $(DRIVER_DIR)/%, $(SUMMA_DRIVER))
diff --git a/build/source/actors/file_access_actor/cppwrap_fileAccess.f90 b/build/source/actors/file_access_actor/cppwrap_fileAccess.f90
index 8c664cd..f09e37e 100644
--- a/build/source/actors/file_access_actor/cppwrap_fileAccess.f90
+++ b/build/source/actors/file_access_actor/cppwrap_fileAccess.f90
@@ -15,8 +15,6 @@ module cppwrap_fileAccess
   public::Init_OutputStruct
   public::initFailedHRUTracker
   public::FileAccessActor_ReadForcing
-  ! public::Create_Output_File
-  public::FileAccessActor_WriteOutput
   
   contains
 
@@ -204,148 +202,6 @@ subroutine FileAccessActor_ReadForcing(handle_forcFileInfo, currentFile, stepsIn
 
 end subroutine FileAccessActor_ReadForcing
 
-subroutine Write_HRU_Param(&
-        handle_ncid,       &
-        indxGRU,           &
-        indxHRU,           &
-        err) bind(C, name="Write_HRU_Param")
-  
-  USE globalData,only:attr_meta,type_meta,mpar_meta,bpar_meta ! meta structures
-  USE globalData,only:gru_struc
-  USE globalData,only:outputStructure
-  USE writeOutput_module,only:writeParm                              
-
-  implicit none
-  ! dummy variables
-  type(c_ptr),   intent(in), value  :: handle_ncid ! ncid of the output file
-  integer(c_int),intent(in)         :: indxGRU     ! index of GRU in outputStructure
-  integer(c_int),intent(in)         :: indxHRU     ! index of HRU in outputStructure
-  integer(c_int),intent(inout)      :: err         ! err value for error control
-
-  ! local variables
-  type(var_i),pointer               :: ncid
-  integer(i4b)                      :: iStruct
-  character(LEN=256)                :: cmessage
-  character(LEN=256)                :: message
-
-  call c_f_pointer(handle_ncid, ncid)
-  
-  do iStruct=1,size(structInfo)
-    select case(trim(structInfo(iStruct)%structName))
-      case('attr'); call writeParm(ncid,gru_struc(indxGRU)%hruInfo(indxHRU)%hru_ix, &
-        outputStructure(1)%attrStruct(1)%gru(indxGRU)%hru(indxHRU),attr_meta,err,cmessage)
-      case('type'); call writeParm(ncid,gru_struc(indxGRU)%hruInfo(indxHRU)%hru_ix, &
-        outputStructure(1)%typeStruct(1)%gru(indxGRU)%hru(indxHRU),type_meta,err,cmessage)
-      case('mpar'); call writeParm(ncid,gru_struc(indxGRU)%hruInfo(indxHRU)%hru_ix, &
-        outputStructure(1)%mparStruct(1)%gru(indxGRU)%hru(indxHRU),mpar_meta,err,cmessage)
-    end select
-    if(err/=0)then; message=trim(message)//trim(cmessage)//'['//trim(structInfo(iStruct)%structName)//']'; return; endif
-  end do
-
-  ! write GRU parameters
-  call writeParm(ncid,indxGRU,outputStructure(1)%bparStruct(1)%gru(indxGRU),bpar_meta,err,cmessage)
-  if(err/=0)then; message=trim(message)//trim(cmessage); return; endif
-
-  ! set the outputTimestep variable so it is not reset every time we need to write to a file
-  outputTimeStep(indxGRU)%dat(:) = 1
-end subroutine
-
-subroutine FileAccessActor_WriteOutput(&
-                                handle_ncid,     & ! ncid of the output file
-                                nSteps,          & ! number of steps to write
-                                minGRU,          & ! index of GRU we are currently writing for
-                                maxGRU,          & ! index of HRU we are currently writing for
-                                err) bind(C, name="FileAccessActor_WriteOutput")
-  USE def_output_module,only:def_output                       ! module to define model output
-  USE var_lookup,only:maxVarFreq                               ! # of available output frequencies
-  USE writeOutput_module,only:writeBasin,writeTime,writeData
-  USE globalData,only:structInfo
-  USE globalData,only:outputStructure
-  USE var_lookup,only:iLookFreq                 ! named variables for the frequency structure
-  USE globalData,only:bvarChild_map             ! index of the child data structure: stats bvar
-  USE netcdf_util_module,only:nc_file_close 
-  USE netcdf_util_module,only:nc_file_open 
-
-  USE globalData,only:outputTimeStep
-  USE netcdf
-
-  implicit none
-  ! dummy variables
-  type(c_ptr),intent(in), value        :: handle_ncid       ! ncid of the output file
-  integer(c_int),intent(in)            :: nSteps            ! number of steps to write
-  integer(c_int),intent(in)            :: minGRU           ! index of GRU we are currently writing for
-  integer(c_int),intent(in)            :: maxGRU           ! index of HRU we are currently writing for
-  integer(c_int),intent(inout)         :: err               ! Error code
-  
-  ! local variables 
-  type(var_i),pointer                  :: ncid
-  character(LEN=256)                   :: message
-  character(LEN=256)                   :: cmessage
-  integer(i4b)                         :: iStruct
-  integer(i4b)                         :: numGRU
-  integer(i4b)                         :: iGRU
-  integer(i4b)                         :: iStep
-  integer(i4b)                         :: iFreq
-  integer(i4b)                         :: indxHRU=1
-  integer(i4b), dimension(maxVarFreq)  :: outputTimestepUpdate
-  integer(i4b), dimension(maxVarFreq)  :: stepCounter
-
-  call c_f_pointer(handle_ncid, ncid)
-  ! ****************************************************************************
-  ! *** write data
-  ! ****************************************************************************
-  do iGRU=minGRU, maxGRU
-    stepCounter(:) = outputTimeStep(iGRU)%dat(:) ! We want to avoid updating outputTimeStep
-    do iStep=1, nSteps
-      ! call writeBasin(ncid,iGRU,stepCounter(:),iStep,bvar_meta, &
-      !         outputStructure(1)%bvarStat(1)%gru(iGRU)%hru(indxHRU)%var, &
-      !         outputStructure(1)%bvarStruct(1)%gru(iGRU)%hru(indxHRU)%var, bvarChild_map, err, cmessage)
-      
-      ! call writeTime(ncid,outputTimeStep(iGRU)%dat(:),iStep,time_meta, &
-      !         outputStructure(1)%timeStruct(1)%gru(iGRU)%hru(indxHRU)%var,err,cmessage)
-    end do ! istep
-  end do ! iGRU
-  numGRU = maxGRU-minGRU + 1 
-  ! do iStruct=1,size(structInfo)
-  !   select case(trim(structInfo(iStruct)%structName))
-  !     case('forc')
-  !       call writeData(ncid,outputTimeStep(minGRU)%dat(:),outputTimestepUpdate,maxLayers,nSteps,&
-  !                     minGRU, maxGRU, numGRU, & 
-  !                     forc_meta,outputStructure(1)%forcStat(1),outputStructure(1)%forcStruct(1),'forc', &
-  !                     forcChild_map,outputStructure(1)%indxStruct(1),err,cmessage)
-  !     case('prog')
-  !       call writeData(ncid,outputTimeStep(minGRU)%dat(:),outputTimestepUpdate,maxLayers,nSteps,&
-  !                     minGRU, maxGRU, numGRU, &
-  !                     prog_meta,outputStructure(1)%progStat(1),outputStructure(1)%progStruct(1),'prog', &
-  !                     progChild_map,outputStructure(1)%indxStruct(1),err,cmessage)
-  !     case('diag')
-  !       call writeData(ncid,outputTimeStep(minGRU)%dat(:),outputTimestepUpdate,maxLayers,nSteps,&
-  !                     minGRU, maxGRU, numGRU, &
-  !                     diag_meta,outputStructure(1)%diagStat(1),outputStructure(1)%diagStruct(1),'diag', &
-  !                     diagChild_map,outputStructure(1)%indxStruct(1),err,cmessage)
-  !     case('flux')
-  !       call writeData(ncid,outputTimeStep(minGRU)%dat(:),outputTimestepUpdate,maxLayers,nSteps,&
-  !                     minGRU, maxGRU, numGRU, &
-  !                     flux_meta,outputStructure(1)%fluxStat(1),outputStructure(1)%fluxStruct(1),'flux', &
-  !                     fluxChild_map,outputStructure(1)%indxStruct(1),err,cmessage)
-  !     case('indx')
-  !       call writeData(ncid,outputTimeStep(minGRU)%dat(:),outputTimestepUpdate,maxLayers,nSteps,&
-  !                     minGRU, maxGRU, numGRU, &
-  !                     indx_meta,outputStructure(1)%indxStat(1),outputStructure(1)%indxStruct(1),'indx', &
-  !                     indxChild_map,outputStructure(1)%indxStruct(1),err,cmessage)
-  !   end select
-  !   if(err/=0)then; message=trim(message)//trim(cmessage)//'['//trim(structInfo(iStruct)%structName)//']'; return; endif
-  ! end do  ! (looping through structures)
-  
-  do iFreq = 1,maxvarFreq
-    outputTimeStep(minGRU)%dat(iFreq) = outputTimeStep(minGRU)%dat(iFreq) + outputTimeStepUpdate(iFreq) 
-  end do ! ifreq
-
-end subroutine
-
-
-
-
 subroutine FileAccessActor_DeallocateStructures(handle_forcFileInfo, handle_ncid) bind(C,name="FileAccessActor_DeallocateStructures")
   USE netcdf_util_module,only:nc_file_close 
   USE globalData,only:structInfo                              ! information on the data structures
diff --git a/build/source/actors/file_access_actor/deallocateOutputStruc.f90 b/build/source/actors/file_access_actor/deallocateOutputStruc.f90
index 091c8ca..f287e3f 100644
--- a/build/source/actors/file_access_actor/deallocateOutputStruc.f90
+++ b/build/source/actors/file_access_actor/deallocateOutputStruc.f90
@@ -10,26 +10,6 @@ subroutine deallocateOutputStruc(err)
   integer(i4b), intent(inout)   :: err
 
   err = 0
-  ! Time
-  call deallocateData_output(outputStructure(1)%timeStruct(1));    deallocate(outputStructure(1)%timeStruct)
-  ! Forc
-  call deallocateData_output(outputStructure(1)%forcStat(1));       deallocate(outputStructure(1)%forcStat)
-  call deallocateData_output(outputStructure(1)%forcStruct(1));     deallocate(outputStructure(1)%forcStruct)
-  ! prog
-  call deallocateData_output(outputStructure(1)%progStat(1));       deallocate(outputStructure(1)%progStat)
-  call deallocateData_output(outputStructure(1)%progStruct(1));     deallocate(outputStructure(1)%progStruct)
-  ! diag
-  call deallocateData_output(outputStructure(1)%diagStat(1));       deallocate(outputStructure(1)%diagStat)
-  call deallocateData_output(outputStructure(1)%diagStruct(1));     deallocate(outputStructure(1)%diagStruct)
-  ! flux
-  call deallocateData_output(outputStructure(1)%fluxStat(1));       deallocate(outputStructure(1)%fluxStat)
-  call deallocateData_output(outputStructure(1)%fluxStruct(1));     deallocate(outputStructure(1)%fluxStruct)
-  ! indx
-  call deallocateData_output(outputStructure(1)%indxStat(1));       deallocate(outputStructure(1)%indxStat)
-  call deallocateData_output(outputStructure(1)%indxStruct(1));     deallocate(outputStructure(1)%indxStruct)
-  ! bvar
-  call deallocateData_output(outputStructure(1)%bvarStat(1));       deallocate(outputStructure(1)%bvarStat)
-  call deallocateData_output(outputStructure(1)%bvarStruct(1));     deallocate(outputStructure(1)%bvarStruct)
   ! id
   call deallocateData_output(outputStructure(1)%idStruct(1));       deallocate(outputStructure(1)%idStruct)
   ! attr
@@ -40,8 +20,6 @@ subroutine deallocateOutputStruc(err)
   call deallocateData_output(outputStructure(1)%mparStruct(1));     deallocate(outputStructure(1)%mparStruct)
   ! bpar
   call deallocateData_output(outputStructure(1)%bparStruct(1));     deallocate(outputStructure(1)%bparStruct)
-  ! finalize stats
-  call deallocateData_output(outputStructure(1)%finalizeStats(1));  deallocate(outputStructure(1)%finalizeStats)
 
 end subroutine deallocateOutputStruc
 
diff --git a/build/source/actors/file_access_actor/file_access_actor.cpp b/build/source/actors/file_access_actor/file_access_actor.cpp
index 6456b56..ad115a0 100644
--- a/build/source/actors/file_access_actor/file_access_actor.cpp
+++ b/build/source/actors/file_access_actor/file_access_actor.cpp
@@ -250,7 +250,7 @@ behavior file_access_actor(stateful_actor<file_access_state>* self, int startGRU
           
             // Check if this list is now full
             if(self->state.output_manager->isFull(listIndex)) {
-                write(self, listIndex);
+                // write(self, listIndex);
             }
         },
 
@@ -391,64 +391,6 @@ void initalizeFileAccessActor(stateful_actor<file_access_state>* self) {
     }
 }
 
-int write(stateful_actor<file_access_state>* self, int listIndex) {
-    int err = 0;
-    int minGRU = self->state.output_manager->getMinIndex(listIndex);
-    int maxGRU = self->state.output_manager->getMaxIndex(listIndex);
-    int numStepsToWrite = self->state.output_manager->getNumStepsToWrite(listIndex);
-    FileAccessActor_WriteOutput(self->state.handle_ncid,
-        &numStepsToWrite, &minGRU, 
-        &maxGRU, &err);
-        
-    // Pop The actors and send them the correct continue message
-    while(!self->state.output_manager->isEmpty(listIndex)) {
-        std::tuple<caf::actor, int> actor = self->state.output_manager->popActor(listIndex);
-        if (get<1>(actor) == 9999) {
-            
-            self->send(get<0>(actor), done_write_v);
-
-        }  else {
-            self->send(get<0>(actor), run_hru_v, 
-                self->state.forcing_file_list[get<1>(actor) - 1].getNumSteps());
-        }
-    }
-
-    return 0;
-}
-
-// int writeOutput(stateful_actor<file_access_state>* self, ) {
-
-// }
-
-// int writeOutput(stateful_actor<file_access_state>* self, int indxGRU, int indxHRU, 
-//     int numStepsToWrite, int returnMessage, caf::actor actorRef) {
-//     self->state.file_access_timing.updateStartPoint("write_duration");
-
-//     if (debug) {
-//         aout(self) << "Recieved Write Request From GRU: " << indxGRU << "\n";
-//     }
-//     int err = 0;
-//     int listIndex = self->state.output_manager->addActor(actorRef, indxGRU, returnMessage, numStepsToWrite);
-//     if (self->state.output_manager->isFull(listIndex)) {
-//         if (debug) {
-//             aout(self) << "List with Index " << listIndex << " is full and ready to write\n";
-//             aout(self) << "Minimum GRU Index = " << self->state.output_manager->getMinIndex(listIndex) << "\n";
-//             aout(self) << "Maximum GRU Index = " << self->state.output_manager->getMaxIndex(listIndex) << "\n";
-//         }
-
-//        err = write(self, listIndex);
-
-//     } else {
-//         if (debug) {
-//             aout(self) << "List with Index " << listIndex << " is not full yet waiting to write\n";
-//             aout(self) << "Size of list is " << self->state.output_manager->getSize(listIndex) << "\n";
-//         }
-//     }
-   
-//     self->state.file_access_timing.updateEndPoint("write_duration");
-//     return err;
-
-// }
 
 int readForcing(stateful_actor<file_access_state>* self, int currentFile) {
     // Check if we have already loaded this file
diff --git a/build/source/actors/file_access_actor/initOutputStruc.f90 b/build/source/actors/file_access_actor/initOutputStruc.f90
index d46015a..f109f8d 100644
--- a/build/source/actors/file_access_actor/initOutputStruc.f90
+++ b/build/source/actors/file_access_actor/initOutputStruc.f90
@@ -45,92 +45,34 @@ subroutine initalizeOutput(forcFileInfo, maxSteps, num_gru, err)
     allocate(outputStructure(1))
   end if
 
-  ! Statistics Structures
-  allocate(outputStructure(1)%forcStat(1))
-  allocate(outputStructure(1)%progStat(1))
-  allocate(outputStructure(1)%diagStat(1))
-  allocate(outputStructure(1)%fluxStat(1))
-  allocate(outputStructure(1)%indxStat(1))
-  allocate(outputStructure(1)%bvarStat(1))
-  allocate(outputStructure(1)%forcStat(1)%gru(num_gru))
-  allocate(outputStructure(1)%progStat(1)%gru(num_gru))
-  allocate(outputStructure(1)%diagStat(1)%gru(num_gru))
-  allocate(outputStructure(1)%fluxStat(1)%gru(num_gru))
-  allocate(outputStructure(1)%indxStat(1)%gru(num_gru))
-  allocate(outputStructure(1)%bvarStat(1)%gru(num_gru))
 
   ! Primary Data Structures (scalars)
-  allocate(outputStructure(1)%timeStruct(1))
-  allocate(outputStructure(1)%forcStruct(1))
   allocate(outputStructure(1)%attrStruct(1))
   allocate(outputStructure(1)%typeStruct(1))
   allocate(outputStructure(1)%idStruct(1))
-  allocate(outputStructure(1)%timeStruct(1)%gru(num_gru))
-  allocate(outputStructure(1)%forcStruct(1)%gru(num_gru))
+  allocate(outputStructure(1)%mparStruct(1))
+  allocate(outputStructure(1)%bparStruct(1))
+  allocate(outputStructure(1)%dparStruct(1))
+
   allocate(outputStructure(1)%attrStruct(1)%gru(num_gru))
   allocate(outputStructure(1)%typeStruct(1)%gru(num_gru))
   allocate(outputStructure(1)%idStruct(1)%gru(num_gru))
-  
-  ! Primary Data Structures (variable length vectors)
-  allocate(outputStructure(1)%indxStruct(1))
-  allocate(outputStructure(1)%mparStruct(1))
-  allocate(outputStructure(1)%progStruct(1))
-  allocate(outputStructure(1)%diagStruct(1))
-  allocate(outputStructure(1)%fluxStruct(1))
-  allocate(outputStructure(1)%indxStruct(1)%gru(num_gru))
   allocate(outputStructure(1)%mparStruct(1)%gru(num_gru))
-  allocate(outputStructure(1)%progStruct(1)%gru(num_gru))
-  allocate(outputStructure(1)%diagStruct(1)%gru(num_gru))
-  allocate(outputStructure(1)%fluxStruct(1)%gru(num_gru))
-
-  ! Basin-Average structures
-  allocate(outputStructure(1)%bparStruct(1))
-  allocate(outputStructure(1)%bvarStruct(1))
   allocate(outputStructure(1)%bparStruct(1)%gru(num_gru))
-  allocate(outputStructure(1)%bvarStruct(1)%gru(num_gru))
-
-  ! define the ancillary data structures
-  allocate(outputStructure(1)%dparStruct(1))
   allocate(outputStructure(1)%dparStruct(1)%gru(num_gru))
 
   ! Finalize Stats for writing
-  allocate(outputStructure(1)%finalizeStats(1))
-  allocate(outputStructure(1)%finalizeStats(1)%gru(num_gru))
-  
   
   do iGRU = 1, num_gru
     num_hru = gru_struc(iGRU)%hruCount
-    ! Statistics Structures
-    allocate(outputStructure(1)%forcStat(1)%gru(iGRU)%hru(num_hru))
-    allocate(outputStructure(1)%progStat(1)%gru(iGRU)%hru(num_hru))
-    allocate(outputStructure(1)%diagStat(1)%gru(iGRU)%hru(num_hru))
-    allocate(outputStructure(1)%fluxStat(1)%gru(iGRU)%hru(num_hru))
-    allocate(outputStructure(1)%indxStat(1)%gru(iGRU)%hru(num_hru))
-    allocate(outputStructure(1)%bvarStat(1)%gru(iGRU)%hru(num_hru))
 
     ! Primary Data Structures (scalars)
-    allocate(outputStructure(1)%timeStruct(1)%gru(iGRU)%hru(num_hru))
-    allocate(outputStructure(1)%forcStruct(1)%gru(iGRU)%hru(num_hru))
     allocate(outputStructure(1)%attrStruct(1)%gru(iGRU)%hru(num_hru))
     allocate(outputStructure(1)%typeStruct(1)%gru(iGRU)%hru(num_hru))
     allocate(outputStructure(1)%idStruct(1)%gru(iGRU)%hru(num_hru))
-  
-    ! Primary Data Structures (variable length vectors)
-    allocate(outputStructure(1)%indxStruct(1)%gru(iGRU)%hru(num_hru))
     allocate(outputStructure(1)%mparStruct(1)%gru(iGRU)%hru(num_hru))
-    allocate(outputStructure(1)%progStruct(1)%gru(iGRU)%hru(num_hru))
-    allocate(outputStructure(1)%diagStruct(1)%gru(iGRU)%hru(num_hru))
-    allocate(outputStructure(1)%fluxStruct(1)%gru(iGRU)%hru(num_hru))
-  
-    ! Basin-Average structures
-    allocate(outputStructure(1)%bvarStruct(1)%gru(iGRU)%hru(num_hru))
-
-   ! define the ancillary data structures
     allocate(outputStructure(1)%dparStruct(1)%gru(iGRU)%hru(num_hru))
 
-    ! Finalize Stats for writing
-    allocate(outputStructure(1)%finalizeStats(1)%gru(iGRU)%hru(num_hru))
-
   end do
 
   do iGRU=1,num_gru
@@ -140,92 +82,30 @@ subroutine initalizeOutput(forcFileInfo, maxSteps, num_gru, err)
       nVars = maxval(forcFileInfo%ffile_list(:)%nVars)
       nSnow = gru_struc(iGRU)%hruInfo(iHRU)%nSnow
       nSoil = gru_struc(iGRU)%hruInfo(iHRU)%nSoil
-
-      do iStruct=1,size(structInfo)
-        ! allocate space structures
-          select case(trim(structInfo(iStruct)%structName))    
-            case('time')
-              call alloc_outputStruc(time_meta,outputStructure(1)%timeStruct(1)%gru(iGRU)%hru(iHRU), &
-                        maxSteps,err=err,message=message)     ! model forcing data
-            case('forc')
-              ! Structure
-              call alloc_outputStruc(forc_meta,outputStructure(1)%forcStruct(1)%gru(iGRU)%hru(iHRU), &
-                          maxSteps,nSnow,nSoil,err,message);    ! model forcing data
-              ! Statistics
-              call alloc_outputStruc(statForc_meta(:)%var_info,outputStructure(1)%forcStat(1)%gru(iGRU)%hru(iHRU), &
-                          maxSteps,nSnow,nSoil,err,message);    ! model forcing data
-            case('attr')
-              call alloc_outputStruc(attr_meta,outputStructure(1)%attrStruct(1)%gru(iGRU)%hru(iHRU), &
-                          maxSteps,nSnow,nSoil,err,message);    ! local attributes for each HRU
-            case('type')
-              call alloc_outputStruc(type_meta,outputStructure(1)%typeStruct(1)%gru(iGRU)%hru(iHRU), &
-                            maxSteps,nSnow,nSoil,err,message);    ! classification of soil veg etc.
-            case('id'  )
-              call alloc_outputStruc(id_meta,outputStructure(1)%idStruct(1)%gru(iGRU)%hru(iHRU), &
-                            maxSteps,nSnow,nSoil,err,message);        ! local values of hru gru IDs
-            case('mpar') ! model parameters
-              call alloc_outputStruc(mpar_meta,outputStructure(1)%mparStruct(1)%gru(iGRU)%hru(iHRU), &
-                            maxSteps,nSnow,nSoil,err,message); 
-
-              call alloc_outputStruc(mpar_meta, outputStructure(1)%dparStruct(1)%gru(iGRU)%hru(iHRU), &
-                            maxSteps,err=err,message=message)
-            case('indx')
-              ! Structure
-              call alloc_outputStruc(indx_meta,outputStructure(1)%indxStruct(1)%gru(iGRU)%hru(iHRU), &
-                            maxSteps,nSnow,nSoil,err,message);    ! model variables
-              ! Statistics
-              call alloc_outputStruc(statIndx_meta(:)%var_info,outputStructure(1)%indxStat(1)%gru(iGRU)%hru(1), &
-                            maxSteps,nSnow,nSoil,err,message);    ! index vars
-            case('prog')
-              ! Structure
-              call alloc_outputStruc(prog_meta,outputStructure(1)%progStruct(1)%gru(iGRU)%hru(iHRU), &
-                            maxSteps,nSnow,nSoil,err,message);    ! model prognostic (state) variables
-              ! Statistics
-              call alloc_outputStruc(statProg_meta(:)%var_info,outputStructure(1)%progStat(1)%gru(iGRU)%hru(iHRU), &
-                            maxSteps,nSnow,nSoil,err,message);    ! model prognostic 
-            case('diag')
-              ! Structure
-              call alloc_outputStruc(diag_meta,outputStructure(1)%diagStruct(1)%gru(iGRU)%hru(iHRU), &
-                            maxSteps,nSnow,nSoil,err,message);    ! model diagnostic variables
-              ! Statistics
-              call alloc_outputStruc(statDiag_meta(:)%var_info,outputStructure(1)%diagStat(1)%gru(iGRU)%hru(iHRU), &
-                            maxSteps,nSnow,nSoil,err,message);    ! model diagnostic
-            case('flux')
-              ! Structure
-              call alloc_outputStruc(flux_meta,outputStructure(1)%fluxStruct(1)%gru(iGRU)%hru(iHRU), &
-                            maxSteps,nSnow,nSoil,err,message);    ! model fluxes
-              ! Statistics
-              call alloc_outputStruc(statFlux_meta(:)%var_info,outputStructure(1)%fluxStat(1)%gru(iGRU)%hru(iHRU), &
-                            maxSteps,nSnow,nSoil,err,message);    ! model fluxes
-            case('bpar')
-              call alloc_outputStruc(bpar_meta,outputStructure(1)%bparStruct(1)%gru(iGRU), &
-                            maxSteps,nSnow=0,nSoil=0,err=err,message=message);  ! basin-average params 
-            case('bvar')
-              ! Structure
-              call alloc_outputStruc(bvar_meta,outputStructure(1)%bvarStruct(1)%gru(iGRU)%hru(iHRU), &
-                          maxSteps,nSnow=0,nSoil=0,err=err,message=message);  ! basin-average variables
-              ! Statistics
-              call alloc_outputStruc(statBvar_meta(:)%var_info,outputStructure(1)%bvarStat(1)%gru(iGRU)%hru(iHRU), &
-                          maxSteps,nSnow=0,nSoil=0,err=err,message=message);  ! basin-average variables
-            case('deriv');  cycle
-            case('lookup'); cycle
-            case default; err=20; message='unable to find structure name: '//trim(structInfo(iStruct)%structName)
-        end select
-
-        ! check errors
-        if(err/=0)then
-          message=trim(message)//'initOutputStruc.f90 - [structure =  '//trim(structInfo(iStruct)%structName)//']'
-          print*, "message"
-          return
-        endif
-      end do  ! looping through data structures
-    
-      ! Finalize stats structure for writing to output file
-      print*, "HERE"
-      allocate(outputStructure(1)%finalizeStats(1)%gru(iGRU)%hru(iHRU)%tim(maxSteps))
-      do iStep = 1, maxSteps
-        allocate(outputStructure(1)%finalizeStats(1)%gru(iGRU)%hru(iHRU)%tim(iStep)%dat(1:maxVarFreq))
-      end do ! timeSteps
+      
+      call alloc_outputStruc(attr_meta,outputStructure(1)%attrStruct(1)%gru(iGRU)%hru(iHRU), &
+                  maxSteps,nSnow,nSoil,err,message);    ! local attributes for each HRU
+
+      call alloc_outputStruc(type_meta,outputStructure(1)%typeStruct(1)%gru(iGRU)%hru(iHRU), &
+                    maxSteps,nSnow,nSoil,err,message);    ! classification of soil veg etc.
+
+      call alloc_outputStruc(id_meta,outputStructure(1)%idStruct(1)%gru(iGRU)%hru(iHRU), &
+                    maxSteps,nSnow,nSoil,err,message);        ! local values of hru gru IDs
+
+      call alloc_outputStruc(mpar_meta,outputStructure(1)%mparStruct(1)%gru(iGRU)%hru(iHRU), &
+                    maxSteps,nSnow,nSoil,err,message); 
+
+      call alloc_outputStruc(mpar_meta, outputStructure(1)%dparStruct(1)%gru(iGRU)%hru(iHRU), &
+                    maxSteps,err=err,message=message)
+
+      call alloc_outputStruc(bpar_meta,outputStructure(1)%bparStruct(1)%gru(iGRU), &
+                    maxSteps,nSnow=0,nSoil=0,err=err,message=message);  ! basin-average params 
+      ! check errors
+      if(err/=0)then
+        message=trim(message)//'initOutputStruc.f90 - [structure =  '//trim(structInfo(iStruct)%structName)//']'
+        print*, "message"
+        return
+      endif
     end do ! Looping through GRUs
   end do
 
diff --git a/build/source/actors/hru_actor/cppwrap_hru.f90 b/build/source/actors/hru_actor/cppwrap_hru.f90
index a4a507e..718015c 100644
--- a/build/source/actors/hru_actor/cppwrap_hru.f90
+++ b/build/source/actors/hru_actor/cppwrap_hru.f90
@@ -13,7 +13,6 @@ public::Restart
 public::Forcing
 public::RunPhysics
 public::DeallocateStructures
-public::Write_Param_C
 
 contains
 
@@ -278,179 +277,6 @@ subroutine RunPhysics(&
 
 end subroutine RunPhysics
 
-! **********************************************************************************************************
-! public subroutine WriteOutput: Writes output to appropriate NetCDF output files
-! **********************************************************************************************************
-subroutine WriteOutput(&
-  indxHRU,                &
-  indxGRU,                &
-  step_index,             &
-  ! statistics structures
-  handle_forcStat,        & !  model forcing data
-  handle_progStat,        & !  model prognostic (state) variables
-  handle_diagStat,        & !  model diagnostic variables
-  handle_fluxStat,        & !  model fluxes
-  handle_indxStat,        & !  model indices
-  handle_bvarStat,        & !  basin-average variables
-  handle_timeStruct,      &
-  handle_forcStruct,      &
-  handle_attrStruct,      &
-  handle_typeStruct,      &
-  ! primary data structures (variable length vectors)
-  handle_indxStruct,      &
-  handle_mparStruct,      &
-  handle_progStruct,      &
-  handle_diagStruct,      &
-  handle_fluxStruct,      &
-  ! basin-average structures
-  handle_bparStruct,      &
-  handle_bvarStruct,      &
-  ! local HRU variables
-  handle_statCounter,     & 
-  handle_outputTimeStep,  &
-  handle_resetStats,      &
-  handle_finalizeStats,   &
-  handle_finshTime,       & ! end time for the model simulation
-  handle_oldTime,         & ! time for the previous model time step
-  outputStep,             &
-  ! run time variables
-  err) bind(C, name='WriteOutput')
-
-  use summaActors_writeOutputStruc,only:summaActors_writeToOutputStruc
-
-  implicit none
-  integer(c_int), intent(in)        :: indxHRU
-  integer(c_int), intent(in)        :: indxGRU
-  integer(c_int), intent(in)        :: step_index
-
-  ! statistics variables
-  type(c_ptr), intent(in), value    :: handle_forcStat !  model forcing data
-  type(c_ptr), intent(in), value    :: handle_progStat !  model prognostic (state) variables
-  type(c_ptr), intent(in), value    :: handle_diagStat !  model diagnostic variables
-  type(c_ptr), intent(in), value    :: handle_fluxStat !  model fluxes
-  type(c_ptr), intent(in), value    :: handle_indxStat !  model indices
-  type(c_ptr), intent(in), value    :: handle_bvarStat !  basin-average variables
-  ! primary data structures (scalars)
-  type(c_ptr), intent(in), value    :: handle_timeStruct !  model time data
-  type(c_ptr), intent(in), value    :: handle_forcStruct !  model forcing data
-  type(c_ptr), intent(in), value    :: handle_attrStruct !  local attributes for each HRU
-  type(c_ptr), intent(in), value    :: handle_typeStruct !  local classification of soil veg etc. for each HRU
-  ! primary data structures (variable length vectors)
-  type(c_ptr), intent(in), value    :: handle_indxStruct !  model indices
-  type(c_ptr), intent(in), value    :: handle_mparStruct !  model parameters
-  type(c_ptr), intent(in), value    :: handle_progStruct !  model prognostic (state) variables
-  type(c_ptr), intent(in), value    :: handle_diagStruct !  model diagnostic variables
-  type(c_ptr), intent(in), value    :: handle_fluxStruct !  model fluxes
-  ! basin-average structures
-  type(c_ptr), intent(in), value    :: handle_bparStruct !  basin-average parameters
-  type(c_ptr), intent(in), value    :: handle_bvarStruct !  basin-average variables
-  ! local HRU variables
-  type(c_ptr), intent(in), value    :: handle_statCounter
-  type(c_ptr), intent(in), value    :: handle_outputTimeStep
-  type(c_ptr), intent(in), value    :: handle_resetStats
-  type(c_ptr), intent(in), value    :: handle_finalizeStats
-  type(c_ptr), intent(in), value    :: handle_finshTime    ! end time for the model simulation
-  type(c_ptr), intent(in), value    :: handle_oldTime      ! time for the previous model time step
-  integer(c_int), intent(in)        :: outputStep
-  ! run time variables
-  integer(c_int)                    :: err
-
-  ! local variables
-  type(var_dlength),pointer         :: forcStat          !  model forcing data
-  type(var_dlength),pointer         :: progStat          !  model prognostic (state) variables
-  type(var_dlength),pointer         :: diagStat          !  model diagnostic variables
-  type(var_dlength),pointer         :: fluxStat          !  model fluxes
-  type(var_dlength),pointer         :: indxStat          !  model indices
-  type(var_dlength),pointer         :: bvarStat          !  basin-average variabl
-  ! primary data structures (scalars)
-  type(var_i),pointer               :: timeStruct        !  model time data
-  type(var_d),pointer               :: forcStruct        !  model forcing data
-  type(var_d),pointer               :: attrStruct        !  local attributes for each HRU
-  type(var_i),pointer               :: typeStruct        !  local classification of soil veg etc. for each HRU
-  ! primary data structures (variable length vectors)
-  type(var_ilength),pointer         :: indxStruct        !  model indices
-  type(var_dlength),pointer         :: mparStruct        !  model parameters
-  type(var_dlength),pointer         :: progStruct        !  model prognostic (state) variables
-  type(var_dlength),pointer         :: diagStruct        !  model diagnostic variables
-  type(var_dlength),pointer         :: fluxStruct        !  model fluxes
-  ! basin-average structures
-  type(var_d),pointer               :: bparStruct        !  basin-average parameters
-  type(var_dlength),pointer         :: bvarStruct        !  basin-average variables 
-  ! local hru data
-  type(var_i),pointer               :: statCounter
-  type(var_i),pointer               :: outputTimeStep
-  type(flagVec),pointer             :: resetStats
-  type(flagVec),pointer             :: finalizeStats
-  type(var_i),pointer               :: finshTime         ! end time for the model simulation
-  type(var_i),pointer               :: oldTime           ! time for the previous model time step
-  character(len=256)                :: message
-
-  call c_f_pointer(handle_forcStat, forcStat)
-  call c_f_pointer(handle_progStat, progStat)
-  call c_f_pointer(handle_diagStat, diagStat)
-  call c_f_pointer(handle_fluxStat, fluxStat)
-  call c_f_pointer(handle_indxStat, indxStat)
-  call c_f_pointer(handle_bvarStat, bvarStat)
-  call c_f_pointer(handle_timeStruct, timeStruct)
-  call c_f_pointer(handle_forcStruct, forcStruct)
-  call c_f_pointer(handle_attrStruct, attrStruct)
-  call c_f_pointer(handle_typeStruct, typeStruct)
-  call c_f_pointer(handle_indxStruct, indxStruct)
-  call c_f_pointer(handle_mparStruct, mparStruct)
-  call c_f_pointer(handle_progStruct, progStruct)
-  call c_f_pointer(handle_diagStruct, diagStruct)
-  call c_f_pointer(handle_fluxStruct, fluxStruct)
-  call c_f_pointer(handle_bparStruct, bparStruct)
-  call c_f_pointer(handle_bvarStruct, bvarStruct)
-  call c_f_pointer(handle_statCounter, statCounter)
-  call c_f_pointer(handle_outputTimeStep, outputTimeStep)
-  call c_f_pointer(handle_resetStats, resetStats)
-  call c_f_pointer(handle_finalizeStats, finalizeStats)
-  call c_f_pointer(handle_finshTime, finshTime);
-  call c_f_pointer(handle_oldTime, oldTime)
-
-  call summaActors_writeToOutputStruc(&
-    indxHRU,            &
-    indxGRU,            &
-    step_index,         &
-    ! statistics variables
-    forcStat,           & ! model forcing data
-    progStat,           & ! model prognostic (state) variables
-    diagStat,           & ! model diagnostic variables
-    fluxStat,           & ! model fluxes
-    indxStat,           & ! model indices
-    bvarStat,           & ! basin-average variables
-    ! primary data structures (scalars)
-    timeStruct,         & ! x%var(:)     -- model time data
-    forcStruct,         & ! x%var(:)     -- model forcing data
-    attrStruct,         & ! x%var(:)     -- local attributes for each HRU
-    typeStruct,         & ! x%var(:)     -- local classification of soil veg etc. for each HRU
-      ! primary data structures (variable length vectors)
-    indxStruct,         & ! x%var(:)%dat -- model indices
-    mparStruct,         & ! x%var(:)%dat -- model parameters
-    progStruct,         & ! x%var(:)%dat -- model prognostic (state) variables
-    diagStruct,         & ! x%var(:)%dat -- model diagnostic variables
-    fluxStruct,         & ! x%var(:)%dat -- model fluxes
-    ! basin-average structures
-    bparStruct,         & ! x%var(:)     -- basin-average parameters
-    bvarStruct,         & ! x%var(:)%dat -- basin-average variables
-    ! local HRU data
-    statCounter,        & ! x%var(:)
-    outputTimeStep,     & ! x%var(:)
-    resetStats,         & ! x%var(:)
-    finalizeStats,      & ! x%var(:)
-    finshTime,          & ! x%var(:)     -- end time for the model simulation 
-    oldTime,            & ! x%var(:)     -- time for the previous model time step
-    outputStep,         &
-    ! run time variables
-    err, message)
-
-  if(err/=0)then
-    message=trim(message)
-    print*, message
-  endif
-
-end subroutine WriteOutput
 
 subroutine DeallocateStructures(&
   handle_forcStat,      &
@@ -718,68 +544,5 @@ subroutine DeallocateData(metaStruct, dataStruct, err)
 
 end subroutine DeallocateData
 
-! **********************************************************************************************************
-! public Subroutine write_param_c: called from C to call the fortran subroutine
-! **********************************************************************************************************
-subroutine Write_Param_C(&
-      indxGRU,           &
-      indxHRU,           &
-      handle_attrStruct, &
-      handle_typeStruct, &
-      handle_mparStruct, &
-      handle_bparStruct, &
-      err) bind(C, name="Write_Param_C")
-
-  USE outputStrucWrite_module,only:writeParm ! module to write model parameters
-  USE globalData,only:attr_meta,type_meta,mpar_meta,bpar_meta ! meta structures needed for writeParam Call
-  USE globalData,only:structInfo
-  USE globalData,only:gru_struc
-  implicit none
-
-  ! Dummy Variables
-  integer(c_int), intent(in)      :: indxGRU
-  integer(c_int), intent(in)      :: indxHRU
-  type(c_ptr), intent(in), value  :: handle_attrStruct
-  type(c_ptr), intent(in), value  :: handle_typeStruct
-  type(c_ptr), intent(in), value  :: handle_mparStruct
-  type(c_ptr), intent(in), value  :: handle_bparStruct
-  integer(c_int)                  :: err
-
-  ! local variables
-  type(var_d),      pointer       :: attrStruct
-  type(var_i),      pointer       :: typeStruct
-  type(var_dlength),pointer       :: mparStruct
-  type(var_d),      pointer       :: bparStruct
-
-  integer(i4b)                    :: iStruct
-  character(len=256)              :: message
-  character(len=256)              :: cmessage
-
-  call c_f_pointer(handle_attrStruct, attrStruct)
-  call c_f_pointer(handle_typeStruct, typeStruct)
-  call c_f_pointer(handle_mparStruct, mparStruct)
-  call c_f_pointer(handle_bparStruct, bparStruct)
-
-  ! Error Control
-  err=0; message="cppwrap_Write_Param_C"
-  do iStruct=1,size(structInfo)
-    select case(trim(structInfo(iStruct)%structName))
-      case('attr'); call writeParm(indxGRU,indxHRU,gru_struc(indxGRU)%hruInfo(indxHRU)%hru_ix, &
-                                  attrStruct,attr_meta,'attr',err,cmessage)
-      case('type'); call writeParm(indxGRU,indxHRU,gru_struc(indxGRU)%hruInfo(indxHRU)%hru_ix, &
-                                  typeStruct,type_meta,'type',err,cmessage)
-      case('mpar'); call writeParm(indxGRU,indxHRU,gru_struc(indxGRU)%hruInfo(indxHRU)%hru_ix, &
-                                  mparStruct,mpar_meta,'mpar',err,cmessage)
-    end select
-    if(err/=0)then; message=trim(message)//trim(cmessage)//'['//trim(structInfo(iStruct)%structName)//']'; return; endif
-  end do  ! (looping through structures)
-
-  ! write GRU parameters
-  call writeParm(indxGRU,indxHRU,integerMissing,bparStruct,bpar_meta,'bpar',err,cmessage)
-  if(err/=0)then; message=trim(message)//trim(cmessage); return; endif 
-
-  
-
-end subroutine
 
 end module cppwrap_hru
\ No newline at end of file
diff --git a/build/source/actors/hru_actor/hru_actor.cpp b/build/source/actors/hru_actor/hru_actor.cpp
index 2a76dac..8855b47 100644
--- a/build/source/actors/hru_actor/hru_actor.cpp
+++ b/build/source/actors/hru_actor/hru_actor.cpp
@@ -106,7 +106,7 @@ behavior hru_actor(stateful_actor<hru_state>* self, int refGRU, int indxGRU,
                 // primary data structures (variable length vectors)
                 std::vector<std::vector<int>>    indx_struct_array  = get_var_ilength(self->state.handle_indxStruct);
                 std::vector<std::vector<double>> mpar_struct_array  = get_var_dlength(self->state.handle_mparStruct);
-                std::vector<std::vector<double>> prog_struct_array   = get_var_dlength(self->state.handle_progStruct);
+                std::vector<std::vector<double>> prog_struct_array  = get_var_dlength(self->state.handle_progStruct);
                 std::vector<std::vector<double>> diag_struct_array  = get_var_dlength(self->state.handle_diagStruct);
                 std::vector<std::vector<double>> flux_struct_array  = get_var_dlength(self->state.handle_fluxStruct);
                 // basin-average structures
diff --git a/build/source/actors/hru_actor/hru_actor.f90 b/build/source/actors/hru_actor/hru_actor.f90
index ecd05b9..f9a1d8d 100644
--- a/build/source/actors/hru_actor/hru_actor.f90
+++ b/build/source/actors/hru_actor/hru_actor.f90
@@ -63,7 +63,6 @@ subroutine prepareOutput(&
 
   USE globalData,only:forc_meta,attr_meta,type_meta           ! metaData structures
   USE output_stats,only:calcStats                             ! module for compiling output statistics
-  USE outputStrucWrite_module,only:writeParm                  ! module to write model parameters
   USE var_lookup,only:iLookTIME,iLookDIAG,iLookPROG,iLookINDEX, &
     iLookFreq,maxvarFreq ! named variables for time data structure
   USE globalData,only:time_meta,forc_meta,diag_meta,prog_meta,&
diff --git a/build/source/dshare/data_types.f90 b/build/source/dshare/data_types.f90
index 6ec72bf..b5f9e94 100755
--- a/build/source/dshare/data_types.f90
+++ b/build/source/dshare/data_types.f90
@@ -426,39 +426,21 @@ endtype var_time_ilength
 
 type, public :: summa_output_type
 
-  ! define the statistics structures
-  type(gru_hru_time_doubleVec),allocatable          :: forcStat(:)                   ! x%gru(:)%hru(:)%var(:)%tim(:)%dat -- model forcing data
-  type(gru_hru_time_doubleVec),allocatable          :: progStat(:)                   ! x%gru(:)%hru(:)%var(:)%tim(:)%dat -- model prognostic (state) variables
-  type(gru_hru_time_doubleVec),allocatable          :: diagStat(:)                   ! x%gru(:)%hru(:)%var(:)%tim(:)%dat -- model diagnostic variables
-  type(gru_hru_time_doubleVec),allocatable          :: fluxStat(:)                   ! x%gru(:)%hru(:)%var(:)%tim(:)%dat -- model fluxes
-  type(gru_hru_time_doubleVec),allocatable          :: indxStat(:)                   ! x%gru(:)%hru(:)%var(:)%tim(:)%dat -- model indices
-  type(gru_hru_time_doubleVec),allocatable          :: bvarStat(:)                   ! x%gru(:)%hru(:)%var(:)%tim(:)%dat -- basin-average variabl
 
   ! define the primary data structures (scalars)
-  type(gru_hru_time_int),allocatable                :: timeStruct(:)                 ! x%gru(:)%hru(:)%var(:)%tim(:)     -- model time data
-  type(gru_hru_time_double),allocatable             :: forcStruct(:)                 ! x%gru(:)%hru(:)%var(:)%tim(:)     -- model forcing data
   type(gru_hru_double),allocatable                  :: attrStruct(:)                 ! x%gru(:)%hru(:)%var(:)            -- local attributes for each HRU, DOES NOT CHANGE OVER TIMESTEPS
   type(gru_hru_int),allocatable                     :: typeStruct(:)                 ! x%gru(:)%hru(:)%var(:)%tim(:)     -- local classification of soil veg etc. for each HRU, DOES NOT CHANGE OVER TIMESTEPS
   type(gru_hru_int8),allocatable                    :: idStruct(:)                   ! x%gru(:)%hru(:)%var(:)
 
   ! define the primary data structures (variable length vectors)
-  type(gru_hru_time_intVec),allocatable             :: indxStruct(:)                 ! x%gru(:)%hru(:)%var(:)%tim(:)%dat -- model indices
   type(gru_hru_doubleVec),allocatable               :: mparStruct(:)                 ! x%gru(:)%hru(:)%var(:)%dat        -- model parameters, DOES NOT CHANGE OVER TIMESTEPS TODO: MAYBE
-  type(gru_hru_time_doubleVec),allocatable          :: progStruct(:)                 ! x%gru(:)%hru(:)%var(:)%tim(:)%dat -- model prognostic (state) variables
-  type(gru_hru_time_doubleVec),allocatable          :: diagStruct(:)                 ! x%gru(:)%hru(:)%var(:)%tim(:)%dat -- model diagnostic variables
-  type(gru_hru_time_doubleVec),allocatable          :: fluxStruct(:)                 ! x%gru(:)%hru(:)%var(:)%tim(:)%dat -- model fluxes
-
   ! define the basin-average structures
   type(gru_double),allocatable                      :: bparStruct(:)                 ! x%gru(:)%var(:)                   -- basin-average parameters, DOES NOT CHANGE OVER TIMESTEPS
-  type(gru_hru_time_doubleVec),allocatable          :: bvarStruct(:)                 ! x%gru(:)%hru(:)%var(:)%tim(:)%dat -- basin-average variables
 
   ! define the ancillary data structures
   type(gru_hru_double),allocatable                  :: dparStruct(:)                 ! x%gru(:)%hru(:)%var(:)
 
-  ! finalize stats structure
-  type(gru_hru_time_flagVec),allocatable            :: finalizeStats(:)              ! x%gru(:)%hru(:)%tim(:)%dat -- flags on when to write to file
 
-  integer(i4b)                                      :: nTimeSteps
 end type summa_output_type
 
 END MODULE data_types
diff --git a/build/source/netcdf/writeOutput.f90 b/build/source/netcdf/writeOutput.f90
index d30875f..24f843e 100644
--- a/build/source/netcdf/writeOutput.f90
+++ b/build/source/netcdf/writeOutput.f90
@@ -33,8 +33,6 @@ USE globalData,only: integerMissing, realMissing
 ! provide access to global data
 USE globalData,only:gru_struc                             ! gru->hru mapping structure
 
-USE globalData,only:outputStructure
-
 USE data_types,only:var_i
 
 ! provide access to the derived types to define the data structures
@@ -78,8 +76,7 @@ public::writeParm
 public::writeData
 public::writeBasin
 public::writeTime
-private::writeScalar
-private::writeVector
+
 ! define dimension lengths
 integer(i4b),parameter      :: maxSpectral=2              ! maximum number of spectral bands
 contains
@@ -339,181 +336,6 @@ subroutine writeData(ncid, finalize_stats, output_timestep, max_layers, index_gr
   end do ! iFreq
 end subroutine writeData
 
-
-subroutine writeScalar(ncid, outputTimestep, outputTimestepUpdate, nSteps, minGRU, maxGRU, &
-  numGRU, iFreq, iVar, meta, stat, map, err, message)
-  USE data_types,only:var_info                       ! metadata type
-
-  implicit none
-  ! declare dummy variables
-  type(var_i)   ,intent(in)         :: ncid                    ! fileid
-  integer(i4b)  ,intent(inout)      :: outputTimestep(:)       ! output time step
-  integer(i4b)  ,intent(inout)      :: outputTimestepUpdate(:) ! number of HRUs in the run domain
-  integer(i4b)  ,intent(in)         :: nSteps                  ! number of timeSteps
-  integer(i4b)  ,intent(in)         :: minGRU                  ! minGRU index to write
-  integer(i4b)  ,intent(in)         :: maxGRU                  ! maxGRU index to write - probably not needed
-  integer(i4b)  ,intent(in)         :: numGRU
-  integer(i4b)  ,intent(in)         :: iFreq                   ! output file index (year, month, day, timesteps)
-  integer(i4b)  ,intent(in)         :: iVar                    ! netcdf variable we are writing data for
-  type(var_info),intent(in)         :: meta(:)                 ! meta data
-  class(*)      ,intent(in)         :: stat                    ! stats data
-  integer(i4b)  ,intent(in)         :: map(:)                  ! map into stats child struct
-  integer(i4b)  ,intent(inout)      :: err
-  character(*)  ,intent(inout)      :: message
-
-  ! local variables
-  integer(i4b)                      :: gruCounter             ! counter for the realVecs
-  integer(i4b)                      :: iStep                  ! counter for looping over nSteps
-  integer(i4b)                      :: stepCounter            ! counter for the realVec
-  integer(i4b)                      :: iGRU
-  ! output array
-  real(rkind)                       :: realVec(numGRU, nSteps)! real vector for all HRUs in the run domain
-
-  err=0; message="writeOutput.f90-writeScalar/"
-
-  select type(stat)
-    class is (gru_hru_time_doubleVec)
-      gruCounter=0
-      do iGRU = minGRU, maxGRU
-        stepCounter = 0
-        gruCounter = gruCounter + 1
-        do iStep = 1, nSteps
-          if(.not.outputStructure(1)%finalizeStats(1)%gru(iGRU)%hru(1)%tim(iStep)%dat(iFreq)) cycle
-          stepCounter = stepCounter + 1
-          realVec(gruCounter, stepCounter) = stat%gru(iGRU)%hru(1)%var(map(iVar))%tim(iStep)%dat(iFreq)
-        end do ! iStep
-      end do ! iGRU  
-    
-      err = nf90_put_var(ncid%var(iFreq),meta(iVar)%ncVarID(iFreq),realVec(1:gruCounter, 1:stepCounter),start=(/minGRU,outputTimestep(iFreq)/),count=(/numGRU,stepCounter/))
-      if (outputTimeStepUpdate(iFreq) /= stepCounter ) then
-        print*, "ERROR Missmatch in Steps - stat doubleVec"
-        print*, "   outputTimeStepUpdate(iFreq) = ", outputTimeStepUpdate(iFreq)
-        print*, "   stepCounter = ", stepCounter
-        return
-      endif
-    class default; err=20; message=trim(message)//'stats must be scalarv and of type gru_hru_doubleVec'; return
-  end select  ! stat
-
-end subroutine
-
-subroutine writeVector(ncid, outputTimestep, maxLayers, nSteps, minGRU, maxGRU, &
-  numGRU, iFreq, iVar, meta, dat, indx, err, message)
-  USE data_types,only:var_info                       ! metadata type
-  USE var_lookup,only:iLookIndex                     ! index into index structure
-  USE var_lookup,only:iLookVarType                   ! index into type structure
-
-  implicit none
-  type(var_i)   ,intent(in)             :: ncid                    ! fileid
-  integer(i4b)  ,intent(inout)          :: outputTimestep(:)       ! output time step
-  integer(i4b)  ,intent(in)             :: maxLayers         ! maximum number of layers
-  integer(i4b)  ,intent(in)             :: nSteps                  ! number of timeSteps
-  integer(i4b)  ,intent(in)             :: minGRU                  ! minGRU index to write
-  integer(i4b)  ,intent(in)             :: maxGRU                  ! maxGRU index to write - probably not needed
-  integer(i4b)  ,intent(in)             :: numGRU
-  integer(i4b)  ,intent(in)             :: iFreq                   ! output file index (year, month, day, timesteps)
-  integer(i4b)  ,intent(in)             :: iVar                    ! netcdf variable we are writing data for
-  type(var_info),intent(in)             :: meta(:)                 ! meta data
-  class(*)      ,intent(in)             :: dat               ! timestep data
-  type(gru_hru_time_intVec) ,intent(in) :: indx         ! index data
-  integer(i4b)  ,intent(inout)          :: err
-  character(*)  ,intent(inout)          :: message
-
-  ! local variables
-  integer(i4b)                          :: gruCounter             ! counter for the realVecs
-  integer(i4b)                          :: iStep                  ! counter for looping over nSteps
-  integer(i4b)                          :: stepCounter            ! counter for the realVec
-  integer(i4b)                          :: iGRU
-  integer(i4b)                          :: nSoil
-  integer(i4b)                          :: nSnow
-  integer(i4b)                          :: nLayers
-  ! output array
-  integer(i4b)                          :: datLength         ! length of each data vector
-  integer(i4b)                          :: maxLength         ! maximum length of each data vector
-  integer(i4b)                          :: dataType          ! type of data
-  integer(i4b),parameter                :: ixInteger=1001    ! named variable for integer
-  integer(i4b),parameter                :: ixReal=1002       ! named variable for real
-  real(rkind)                           :: realArray(numGRU,maxLayers+1)  ! real array for all HRUs in the run domain
-  integer(i4b)                          :: intArray(numGRU,maxLayers+1)   ! integer array for all HRUs in the run domain
-  err=0; message="writeOutput.f90-writeVector/"
-
-  ! initialize the data vectors
-  select type (dat)
-    class is (gru_hru_time_doubleVec); realArray(:,:) = realMissing;    dataType=ixReal
-    class is (gru_hru_time_intVec);     intArray(:,:) = integerMissing; dataType=ixInteger
-    class default; err=20; message=trim(message)//'data must not be scalarv and either of type gru_hru_doubleVec or gru_hru_intVec'; return
-  end select
-
-  ! Loop over GRUs
-  
-  stepCounter = outputTimeStep(iFreq)
-  do iStep = 1, nSteps
-    gruCounter = 1
-    do iGRU = minGRU, maxGRU
-      ! get the model layers
-      nSoil   = indx%gru(iGRU)%hru(1)%var(iLookIndex%nSoil)%tim(iStep)%dat(1)
-      nSnow   = indx%gru(iGRU)%hru(1)%var(iLookIndex%nSnow)%tim(iStep)%dat(1)
-      nLayers = indx%gru(iGRU)%hru(1)%var(iLookIndex%nLayers)%tim(iStep)%dat(1)
-
-      ! get the length of each data vector
-      select case (meta(iVar)%varType)
-          case(iLookVarType%wLength); datLength = maxSpectral
-          case(iLookVarType%midToto); datLength = nLayers
-          case(iLookVarType%midSnow); datLength = nSnow
-          case(iLookVarType%midSoil); datLength = nSoil
-          case(iLookVarType%ifcToto); datLength = nLayers+1
-          case(iLookVarType%ifcSnow); datLength = nSnow+1
-          case(iLookVarType%ifcSoil); datLength = nSoil+1
-          case default; cycle
-      end select ! vartype
-
-      ! get the data vectors
-      select type (dat)
-          class is (gru_hru_time_doubleVec)
-            ! do iStep = 1, nSteps
-              if(.not.outputStructure(1)%finalizeStats(1)%gru(iGRU)%hru(1)%tim(iStep)%dat(iFreq)) cycle
-              ! stepCounter = stepCounter + 1
-              realArray(gruCounter,1:datLength) = dat%gru(iGRU)%hru(1)%var(iVar)%tim(iStep)%dat(:)
-            ! end do
-
-          class is (gru_hru_time_intVec)
-            ! do iStep = 1, nSteps
-              if(.not.outputStructure(1)%finalizeStats(1)%gru(iGRU)%hru(1)%tim(iStep)%dat(iFreq)) cycle
-              ! stepCounter = stepCounter + 1
-              intArray(gruCounter,1:datLength) = dat%gru(iGRU)%hru(1)%var(iVar)%tim(iStep)%dat(:)
-            ! end do
-          class default; err=20; message=trim(message)//'data must not be scalarv and either of type gru_hru_doubleVec or gru_hru_intVec'; return
-      end select
-
-      ! get the maximum length of each data vector
-      select case (meta(iVar)%varType)
-        case(iLookVarType%wLength); maxLength = maxSpectral
-        case(iLookVarType%midToto); maxLength = maxLayers
-        case(iLookVarType%midSnow); maxLength = maxLayers-nSoil
-        case(iLookVarType%midSoil); maxLength = nSoil
-        case(iLookVarType%ifcToto); maxLength = maxLayers+1
-        case(iLookVarType%ifcSnow); maxLength = (maxLayers-nSoil)+1
-        case(iLookVarType%ifcSoil); maxLength = nSoil+1
-        case default; cycle
-      end select ! vartype
-    end do ! iGRU
-
-   ! write the data vectors
-    select case(dataType)
-
-      case(ixReal)
-        err = nf90_put_var(ncid%var(iFreq),meta(iVar)%ncVarID(iFreq),realArray(1:numGRU,1:maxLength),start=(/minGRU,1,stepCounter/),count=(/numGRU,maxLength,1/))
-        if(err/=0)then; print*, "ERROR: with nf90_put_var in data vector (ixReal)"; return; endif
-
-      case(ixInteger)
-        err = nf90_put_var(ncid%var(iFreq),meta(iVar)%ncVarID(iFreq),intArray(1:numGRU,1:maxLength),start=(/minGRU,1,stepCounter/),count=(/numGRU,maxLength,1/))
-        if(err/=0)then; print*, "ERROR: with nf90_put_var in data vector (ixInteger)"; return; endif
-
-      case default; err=20; message=trim(message)//'data must be of type integer or real'; return
-    end select ! data type
-    stepCounter = stepCounter + 1
-  end do ! iStep
-end subroutine
-
 ! **************************************************************************************
 ! public subroutine writeBasin: write basin-average variables
 ! **************************************************************************************
-- 
GitLab