From 943ddd5ae77c1a1a86ab3ed47f76b7d95d79cba9 Mon Sep 17 00:00:00 2001
From: "Brown, Jesse" <brownjm@ornl.gov>
Date: Mon, 7 Feb 2022 20:36:34 +0000
Subject: [PATCH] Apply review comments

---
 sammy/src/dat/mdat6.f                           |  1 +
 sammy/src/fgm/FreeGasDopplerBroadening_M.f90    |  2 +-
 sammy/src/fgm/mfgm0.f90                         |  2 +-
 sammy/src/fgm/mfgm1.f90                         |  8 ++++----
 sammy/src/fgm/mfgm3.f90                         |  4 ++--
 sammy/src/ort/mort.f                            |  2 +-
 sammy/src/sam/sammy_api_m.f90                   | 10 +++++-----
 sammy/src/squ/msqu0.f                           |  4 ++--
 sammy/src/the/DopplerAndResolutionBroadener.cpp |  2 +-
 sammy/src/the/DopplerAndResolutionBroadener.h   | 17 +++++++++++++++--
 10 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/sammy/src/dat/mdat6.f b/sammy/src/dat/mdat6.f
index 274da6c14..817ec73bf 100644
--- a/sammy/src/dat/mdat6.f
+++ b/sammy/src/dat/mdat6.f
@@ -1,4 +1,5 @@
 C
+C TODO: These subroutines should be moved to the IO library
 C
 C --------------------------------------------------------------
 C
diff --git a/sammy/src/fgm/FreeGasDopplerBroadening_M.f90 b/sammy/src/fgm/FreeGasDopplerBroadening_M.f90
index 0def92007..f1fa9e85a 100644
--- a/sammy/src/fgm/FreeGasDopplerBroadening_M.f90
+++ b/sammy/src/fgm/FreeGasDopplerBroadening_M.f90
@@ -55,7 +55,7 @@ subroutine  FreeGasDopplerBroadening_addSelfData(this, self, copyData, ipos)
 
     call this%getData(data)
 
-    ! Note this is before the switch, which happens in call to braoden
+    ! Note this is before the switch, which happens in call to broaden
     DO Iso=1,this%dataSelf%getNumberIsotopes()
        do jdat = 1, this%getNumEnergyUnbroadened()
           DO Ii=0,this%numPar
diff --git a/sammy/src/fgm/mfgm0.f90 b/sammy/src/fgm/mfgm0.f90
index a14781166..a6e589d15 100644
--- a/sammy/src/fgm/mfgm0.f90
+++ b/sammy/src/fgm/mfgm0.f90
@@ -18,7 +18,7 @@
       use AllocateFunctions_m
       use rsl7_m
       use mxct27_m
-      use mfgn1_m
+      use mfgm1_m
       use SammyLptPrinting_m
       use FreeGasDopplerBroadening_M
       use EndfData_common_m, only : expData
diff --git a/sammy/src/fgm/mfgm1.f90 b/sammy/src/fgm/mfgm1.f90
index b0f2513d2..07a961af5 100644
--- a/sammy/src/fgm/mfgm1.f90
+++ b/sammy/src/fgm/mfgm1.f90
@@ -1,4 +1,4 @@
-module mfgn1_m
+module mfgm1_m
 contains
 !
 !
@@ -145,7 +145,7 @@ contains
 !
             IF (Em.LT.Emins) THEN
 !                            These points are the very low-energy limit,
-!                                  of very little interest, ergo "stetd"
+!                                  of very little interest, ergo copy as is
                IF (broadener%getEnergyUnbroadened(iposVel+1).GE.Emin) THEN
                   Now = Now + 1
                   call broadener%transferUnbroadenedAll(iposVel, iso, Kvtemp, IflmscKsitmp)
@@ -156,7 +156,7 @@ contains
                END IF
             ELSE IF (Em.GT.Emaxs) THEN
 !                            These points are the very high-energy limit,
-!                                  of very little interest, ergo "stetd"
+!                                  of very little interest, ergo copy as is
                ee = 0.0
                if (iposVel.gt.1) ee = broadener%getEnergyUnbroadened(iposVel-1)
                IF (ee.LE.Emax) THEN
@@ -269,4 +269,4 @@ contains
       RETURN
 !
       END
-end module mfgn1_m
+end module mfgm1_m
diff --git a/sammy/src/fgm/mfgm3.f90 b/sammy/src/fgm/mfgm3.f90
index f2d357104..eadfa8142 100644
--- a/sammy/src/fgm/mfgm3.f90
+++ b/sammy/src/fgm/mfgm3.f90
@@ -1,4 +1,4 @@
-module mfgm3_M
+module mfgm3_m
   implicit none
   contains
 !
@@ -90,4 +90,4 @@ module mfgm3_M
 !
       RETURN
       END SUBROUTINE Stetd
-end module mfgm3_M
+end module mfgm3_m
diff --git a/sammy/src/ort/mort.f b/sammy/src/ort/mort.f
index bfa8b78e4..1c2112cef 100644
--- a/sammy/src/ort/mort.f
+++ b/sammy/src/ort/mort.f
@@ -148,7 +148,7 @@ C
          end if
       end if
       call broadener%setUnbroadenedGrid(2, ii)
-      call broadener%setBroadenedGrid(1, ii) ! always finish on  experinental grid
+      call broadener%setBroadenedGrid(1, ii) ! always finish on  experimental grid
       
       CALL Orresb (broadener, A_Iweigh, A_Iwts, Dist)
       CALL Showwe (A_It , A_Iwts, Dt, Ipnts)
diff --git a/sammy/src/sam/sammy_api_m.f90 b/sammy/src/sam/sammy_api_m.f90
index 14f17365a..5cdaf7b42 100755
--- a/sammy/src/sam/sammy_api_m.f90
+++ b/sammy/src/sam/sammy_api_m.f90
@@ -32,7 +32,7 @@ module sammy_api_m
 
     integer::K_Stop
     CHARACTER(len=6)::Where_To_Next
-    logical::readData, everHadMoreData
+    logical::readData, fullReadIsNeeded
 contains
     !
     !  after sammy_init
@@ -65,7 +65,7 @@ contains
     !
     ! TODO: Separate making the auxillary grid from data reading and make it a separate function
     ! TODO: Separate conversion to/from U parameters from reading (some already is), and call directly from API
-    ! TODO: Make writing new data a separate function from samfin_0 and call from API
+    ! TODO: Make writing new input and parameter file a separate function from samfin_0 and call from API
     subroutine sammy_init_api(infile,sizeData) BIND(C,name="sammy_init_api")
         character(kind = C_CHAR), dimension(*), intent(in) :: infile
         character(len=:), allocatable :: filename
@@ -156,7 +156,7 @@ contains
             end if
         end if
         readData = .false.
-        everHadMoreData = .false.
+        fullReadIsNeeded = .false.
 
         ! now all input is read at least once
 
@@ -253,7 +253,7 @@ contains
             Where_To_Next = 'samthe'
         else if (moreData) then
             Where_To_Next = 'samdat'
-            everHadMoreData = .true.
+            fullReadIsNeeded = .true.
         end if
 
     end subroutine perform_fit
@@ -274,7 +274,7 @@ contains
        logical::fullRead
 
        fullRead = .not.readData
-       if (everHadMoreData) fullRead = .true.
+       if (fullReadIsNeeded) fullRead = .true.
        if (fullRead) then
            call Samdat_0(.false.)
        else
diff --git a/sammy/src/squ/msqu0.f b/sammy/src/squ/msqu0.f
index f0ba226fe..cd2410bfa 100644
--- a/sammy/src/squ/msqu0.f
+++ b/sammy/src/squ/msqu0.f
@@ -35,8 +35,8 @@ C
             Ii    = 2*Nvpall + Nvpall**2
             I     = Idimen (Ii, 1, 'Ii, 1')
             I     = Idimen (I, -1, 'I, -1')
-            I     = Idimen (0,  0, '0,  0')   ! estimated
-            I     = Idimen (0, 0, '0, 0')     ! really used
+            I     = Idimen (0,  0, '0,  0')   ! print estimated memory usage
+            I     = Idimen (0, 0, '0, 0')     ! print memory usage that is really used
          END IF
       END IF
 C
diff --git a/sammy/src/the/DopplerAndResolutionBroadener.cpp b/sammy/src/the/DopplerAndResolutionBroadener.cpp
index f12efc56e..11f136592 100644
--- a/sammy/src/the/DopplerAndResolutionBroadener.cpp
+++ b/sammy/src/the/DopplerAndResolutionBroadener.cpp
@@ -34,7 +34,7 @@ void DopplerAndResolutionBroadener::setUnbroadenedGrid(int index, int pos) {
 
 void DopplerAndResolutionBroadener::setBroadenedGrid(int index, int pos){
     if( index < 0) throw std::runtime_error("index for grid is out of range of available energy grids");
-    // we usually expect a experimental grid and an auxillary grid
+    // we usually expect an experimental grid and an auxillary grid
     // However, sometimes the experimental and auxillary grid is the same
     // So if the calling program wants the auxillary grid it can always ask
     // for the grid at index 1, if that doesn't exist, the experimental
diff --git a/sammy/src/the/DopplerAndResolutionBroadener.h b/sammy/src/the/DopplerAndResolutionBroadener.h
index b582ab45d..d48ab7b4c 100644
--- a/sammy/src/the/DopplerAndResolutionBroadener.h
+++ b/sammy/src/the/DopplerAndResolutionBroadener.h
@@ -82,7 +82,6 @@ public:
      *
      * @param index the index for the original grid  in GridDataList
      * @param pos  the position of the energy in the original grid
-     * @param off the offset from which to start the energy
      */
     void setUnbroadenedGrid(int index, int pos=0);
 
@@ -93,7 +92,6 @@ public:
      *
      * @param index the index for the original grid  in GridDataList
      * @param pos  the position of the energy in the original grid
-     * @param off the offset from which to start the energy
      */
     void setBroadenedGrid(int index, int pos=0);
 
@@ -157,6 +155,11 @@ public:
      */
     void insertEnergyBroadened(int pos);
 
+    /**
+     * Get the object where cross section and derivatives are kept
+     *
+     * @return the object where cross section and derivatives are kept
+     */
     DerivativeHandler & getData() { return handler; }
 
     /**
@@ -181,6 +184,16 @@ public:
     int getEmInUnbroadened(double em, int istart) const;
 
 
+    /**
+     * Get the number of points between elow and ehigh.
+     * This is used to determine how far to extend the integral if
+     * broadening.
+     *
+     * The value can be retrieved via getIntegralSpan
+     *
+     * @param elow the lower energy for the integral
+     * @param ehigh  the upper energy for the integral
+     */
     void calcIntegralSpan(double elow, double ehigh);
 private:
     int numIso; // number of isotopes (if 1 - always use shared value)
-- 
GitLab