[cig-commits] [commit] devel: Fix off-by-one in regular layer count. (253b728)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Wed Apr 30 16:39:47 PDT 2014


Repository : ssh://geoshell/specfem3d_globe

On branch  : devel
Link       : https://github.com/geodynamics/specfem3d_globe/compare/811ae11b80604736d2845c4e5a062755069fc9a6...fedf291c8257de6ffc3151362afcb814578beb7e

>---------------------------------------------------------------

commit 253b72884443f2c4684e939aea70ae2e6eea6258
Author: Elliott Sales de Andrade <esalesde at physics.utoronto.ca>
Date:   Sun Aug 18 18:47:50 2013 -0400

    Fix off-by-one in regular layer count.


>---------------------------------------------------------------

253b72884443f2c4684e939aea70ae2e6eea6258
 src/specfem3D/locate_regular_points.f90 | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/specfem3D/locate_regular_points.f90 b/src/specfem3D/locate_regular_points.f90
index 69d3eb3..de7fc82 100644
--- a/src/specfem3D/locate_regular_points.f90
+++ b/src/specfem3D/locate_regular_points.f90
@@ -47,24 +47,28 @@
   type (kl_reg_grid_variables), intent(inout) :: GRID
 
   integer :: myrank,ios,nlayer,i,nlat,nlon,npts_this_layer
+  real :: r
 
   ! improvements to make: read-in by master and broadcast to all slaves
   open(10,file=PATHNAME_KL_REG,iostat=ios,status='old',action='read')
 
   read(10,*) GRID%dlat, GRID%dlon
 
-  nlayer = 1
-  do while (nlayer <= NM_KL_REG_LAYER)
-    read(10,*,iostat=ios) GRID%rlayer(nlayer), GRID%ndoubling(nlayer)
+  nlayer = 0
+  do
+    read(10,*,iostat=ios) r, i
     if (ios/=0) exit
+
+    if (nlayer >= NM_KL_REG_LAYER) then
+      call exit_MPI(myrank, 'Increase NM_KL_REG_LAYER limit')
+    endif
+
     nlayer = nlayer + 1
+    GRID%rlayer(nlayer) = r
+    GRID%ndoubling(nlayer) = i
   enddo
   close(10)
 
-  if (nlayer > NM_KL_REG_LAYER) then
-    call exit_MPI(myrank, 'Increase NM_KL_REG_LAYER limit')
-  endif
-
   GRID%nlayer = nlayer
 
   GRID%npts_total = 0



More information about the CIG-COMMITS mailing list