From 51ec04486562e1a47586dd304681cf37950c1f5b Mon Sep 17 00:00:00 2001
From: Kyle Klenk <kyle.c.klenk@gmail.com>
Date: Thu, 18 Aug 2022 19:07:57 +0000
Subject: [PATCH] removed definedGlobal data from cppwrap_job.f90

---
 .../job_actor_subroutine_wrappers.hpp          |  2 ++
 build/source/actors/job_actor/cppwrap_job.f90  | 18 +++++++++---------
 build/source/actors/job_actor/job_actor.cpp    |  4 ++++
 build/source/driver/summaActors_globalData.f90 | 12 +++++++++---
 utils/laugh_tests/celia1990/output/runinfo.txt |  2 +-
 .../laugh_tests/colbeck1976/output/runinfo.txt |  2 +-
 .../laugh_tests/miller1998/output/runinfo.txt  |  2 +-
 .../mizoguchi1990/output/runinfo.txt           |  2 +-
 utils/laugh_tests/run_all_summa_actors.sh      |  7 ++++++-
 .../vanderborght2005/output/runinfo.txt        |  2 +-
 10 files changed, 35 insertions(+), 18 deletions(-)

diff --git a/build/includes/job_actor/job_actor_subroutine_wrappers.hpp b/build/includes/job_actor/job_actor_subroutine_wrappers.hpp
index 794d937..6eb6834 100644
--- a/build/includes/job_actor/job_actor_subroutine_wrappers.hpp
+++ b/build/includes/job_actor/job_actor_subroutine_wrappers.hpp
@@ -6,6 +6,8 @@ extern "C" {
 
     void setTimesDirsAndFiles(char const* file_manager, int* err);
 
+    void defineGlobalData(int* start_gru_index, int* err);
+
     void cleanUpJobActor(int* err);
     
 }
\ No newline at end of file
diff --git a/build/source/actors/job_actor/cppwrap_job.f90 b/build/source/actors/job_actor/cppwrap_job.f90
index 32cd7b2..2706261 100644
--- a/build/source/actors/job_actor/cppwrap_job.f90
+++ b/build/source/actors/job_actor/cppwrap_job.f90
@@ -53,7 +53,7 @@ subroutine initGlobals(file_manager, totalGRUs, totalHRUs, numGRUs, numHRUs, sta
   integer(i4b)                              :: fileHRU              ! [used for filenames] number of HRUs in the input file
   character(len=256)                        :: summaFileManagerFile ! path/name of file defining directories and files
 
-  call c_f_string(file_manager, file_manager_path, 256)
+  ! call c_f_string(file_manager, file_manager_path, 256)
 
   ! Conver the fileManager path to format needed for summa_SetTimesDirsAndFIles
   ! summaFileManagerFile = trim(file_manager_path)
@@ -67,15 +67,15 @@ subroutine initGlobals(file_manager, totalGRUs, totalHRUs, numGRUs, numHRUs, sta
   ! endif
 
   ! define global data (parameters, metadata)
-  call summa_defineGlobalData(err, cmessage)
-  ! if(err/=0)then; message=trim(message)//trim(cmessage); return; endif
-  if(err/=0)then
-    message=trim(message)//trim(cmessage)
-    print*, cmessage
-    return
-  endif
+  ! call summa_defineGlobalData(err, cmessage)
+  ! ! if(err/=0)then; message=trim(message)//trim(cmessage); return; endif
+  ! if(err/=0)then
+  !   message=trim(message)//trim(cmessage)
+  !   print*, cmessage
+  !   return
+  ! endif
   ! Set the index of the start GRU
-  startGRU = startGRUIndex
+  ! startGRU = startGRUIndex
 
   ! *****************************************************************************
   ! *** read the number of GRUs and HRUs
diff --git a/build/source/actors/job_actor/job_actor.cpp b/build/source/actors/job_actor/job_actor.cpp
index cff2b4d..fb73fed 100644
--- a/build/source/actors/job_actor/job_actor.cpp
+++ b/build/source/actors/job_actor/job_actor.cpp
@@ -61,6 +61,10 @@ behavior job_actor(stateful_actor<job_state>* self, int startGRU, int numGRU,
     if (err != 0) {
         aout(self) << "ERROR: Job_Actor - setTimesDirsAndFiles\n";
     }
+    defineGlobalData(&self->state.startGRU, &err);
+    if (err != 0) {
+        aout(self) << "ERROR: Job_Actor - defineGlobalData\n";
+    }
     initJob(self);
 
     // Spawn the file_access_actor. This will return the number of forcing files we are working with
diff --git a/build/source/driver/summaActors_globalData.f90 b/build/source/driver/summaActors_globalData.f90
index 69e2f7f..509cb9a 100755
--- a/build/source/driver/summaActors_globalData.f90
+++ b/build/source/driver/summaActors_globalData.f90
@@ -20,6 +20,7 @@
 
 module summa_globalData
 ! used to declare and allocate global summa data structures
+USE, intrinsic :: iso_c_binding
 
 ! access missing values
 USE globalData,only:integerMissing   ! missing integer
@@ -56,13 +57,14 @@ USE globalData,only:fluxChild_map                           ! index of the child
 USE globalData,only:indxChild_map                           ! index of the child data structure: stats indx
 USE globalData,only:bvarChild_map                           ! index of the child data structure: stats bvar
 
+USE globalData,only:startGRU
 ! safety: set private unless specified otherwise
 implicit none
 private
 public::summa_defineGlobalData
 contains
 
-subroutine summa_defineGlobalData(err, message)
+subroutine summa_defineGlobalData(start_gru_index, err) bind(C, name="defineGlobalData")
   ! ---------------------------------------------------------------------------------------
   ! * desired modules
   ! ---------------------------------------------------------------------------------------
@@ -87,9 +89,10 @@ subroutine summa_defineGlobalData(err, message)
   ! ---------------------------------------------------------------------------------------
   implicit none
   ! dummy variables
-  integer(i4b),intent(out)              :: err                ! error code
-  character(*),intent(out)              :: message            ! error message
+  integer(c_int),intent(in)             :: start_gru_index    ! Index of the starting GRU (-g option from user)
+  integer(c_int),intent(out)            :: err                ! error code
   ! local variables
+  character(len=256)                    :: message            ! error message
   character(LEN=256)                    :: cmessage           ! error message of downwind routine
   logical(lgt), dimension(maxvarFlux)   :: flux_mask          ! mask defining desired flux variables
   logical(lgt), dimension(maxvarForc)   :: statForc_mask      ! mask defining forc stats
@@ -159,6 +162,9 @@ subroutine summa_defineGlobalData(err, message)
   statIndx_meta(:)%vartype = iLookVarType%outstat
   statBvar_meta(:)%vartype = iLookVarType%outstat
 
+  ! Set the startGRU
+  startGRU = start_gru_index
+
 end subroutine summa_defineGlobalData
 
 end module summa_globalData
diff --git a/utils/laugh_tests/celia1990/output/runinfo.txt b/utils/laugh_tests/celia1990/output/runinfo.txt
index 89f0cb1..40049d3 100644
--- a/utils/laugh_tests/celia1990/output/runinfo.txt
+++ b/utils/laugh_tests/celia1990/output/runinfo.txt
@@ -1 +1 @@
- Run start time on system:  ccyy=2022 - mm=08 - dd=18 - hh=18 - mi=17 - ss=46.186
+ Run start time on system:  ccyy=2022 - mm=08 - dd=18 - hh=19 - mi=06 - ss=04.983
diff --git a/utils/laugh_tests/colbeck1976/output/runinfo.txt b/utils/laugh_tests/colbeck1976/output/runinfo.txt
index 075f6d6..bc8446c 100644
--- a/utils/laugh_tests/colbeck1976/output/runinfo.txt
+++ b/utils/laugh_tests/colbeck1976/output/runinfo.txt
@@ -1 +1 @@
- Run start time on system:  ccyy=2022 - mm=08 - dd=18 - hh=18 - mi=17 - ss=52.696
+ Run start time on system:  ccyy=2022 - mm=08 - dd=18 - hh=19 - mi=06 - ss=14.868
diff --git a/utils/laugh_tests/miller1998/output/runinfo.txt b/utils/laugh_tests/miller1998/output/runinfo.txt
index d098867..5d7a135 100644
--- a/utils/laugh_tests/miller1998/output/runinfo.txt
+++ b/utils/laugh_tests/miller1998/output/runinfo.txt
@@ -1 +1 @@
- Run start time on system:  ccyy=2022 - mm=08 - dd=18 - hh=18 - mi=18 - ss=01.637
+ Run start time on system:  ccyy=2022 - mm=08 - dd=18 - hh=19 - mi=06 - ss=27.048
diff --git a/utils/laugh_tests/mizoguchi1990/output/runinfo.txt b/utils/laugh_tests/mizoguchi1990/output/runinfo.txt
index f6212ae..c21daeb 100644
--- a/utils/laugh_tests/mizoguchi1990/output/runinfo.txt
+++ b/utils/laugh_tests/mizoguchi1990/output/runinfo.txt
@@ -1 +1 @@
- Run start time on system:  ccyy=2022 - mm=08 - dd=18 - hh=18 - mi=18 - ss=11.308
+ Run start time on system:  ccyy=2022 - mm=08 - dd=18 - hh=19 - mi=06 - ss=39.863
diff --git a/utils/laugh_tests/run_all_summa_actors.sh b/utils/laugh_tests/run_all_summa_actors.sh
index 92e1a8e..6f6719c 100755
--- a/utils/laugh_tests/run_all_summa_actors.sh
+++ b/utils/laugh_tests/run_all_summa_actors.sh
@@ -5,27 +5,32 @@ cd celia1990
 ./run_test_summa_actors.sh
 python3 verify_celia.py
 cd ..
+sleep 3
 
 echo "Starting Colbeck"
 cd colbeck1976
 ./run_test_summa_actors.sh
 python3 verify_colbeck.py
 cd ..
+sleep 3
 
 echo "Starting Miller"
 cd miller1998
 ./run_test_summa_actors.sh
 python3 verify_miller.py
 cd ..
+sleep 3
 
 echo "Starting Mizoguchi"
 cd mizoguchi1990
 ./run_test_summa_actors.sh
 python3 verify_mizoguchi.py
 cd ..
+sleep 3
 
 echo "Starting Vanderborght"
 cd vanderborght2005
 ./run_test_summa_actors.sh
 python3 verify_vanderborght.py
-cd ..
\ No newline at end of file
+cd ..
+sleep 3
diff --git a/utils/laugh_tests/vanderborght2005/output/runinfo.txt b/utils/laugh_tests/vanderborght2005/output/runinfo.txt
index 9010eb2..819f684 100644
--- a/utils/laugh_tests/vanderborght2005/output/runinfo.txt
+++ b/utils/laugh_tests/vanderborght2005/output/runinfo.txt
@@ -1 +1 @@
- Run start time on system:  ccyy=2022 - mm=08 - dd=18 - hh=18 - mi=18 - ss=43.832
+ Run start time on system:  ccyy=2022 - mm=08 - dd=18 - hh=19 - mi=07 - ss=14.172
-- 
GitLab