[Dart-dev] [9962] DART/trunk/models/cam/model_mod.f90: Fix exits from loops where the loop index may be used after the end of the loop .

nancy at ucar.edu nancy at ucar.edu
Mon Mar 14 12:56:53 MDT 2016


Revision: 9962
Author:   raeder
Date:     2016-03-14 12:56:52 -0600 (Mon, 14 Mar 2016)
Log Message:
-----------
Fix exits from loops where the loop index may be used after the end of the loop.

Modified Paths:
--------------
    DART/trunk/models/cam/model_mod.f90

-------------- next part --------------
Modified: DART/trunk/models/cam/model_mod.f90
===================================================================
--- DART/trunk/models/cam/model_mod.f90	2016-03-14 17:53:04 UTC (rev 9961)
+++ DART/trunk/models/cam/model_mod.f90	2016-03-14 18:56:52 UTC (rev 9962)
@@ -5195,7 +5195,8 @@
 !    highest_obs_level = highest_obs_level + 1
 ! enddo
 High: do highest_obs_level=1,num_levs
-   if (p_col(highest_obs_level) > highest_obs_pressure_Pa) exit High
+   if (p_col(highest_obs_level) > highest_obs_pressure_Pa .or. &
+       highest_obs_level == num_levs) exit High
 enddo High
 
 ! Test to be sure user hasn't set level so low that contributions from
@@ -5771,7 +5772,7 @@
 !      bot_lev = bot_lev + 1
 !   end do
    Bottom: do bot_lev = 2,num_levs
-      if (old_array(3) > model_h(bot_lev)) exit Bottom
+      if (old_array(3) > model_h(bot_lev) .or. bot_lev == num_levs) exit Bottom
    end do Bottom
    top_lev = bot_lev - 1
 


More information about the Dart-dev mailing list