From 2b2335c916ca338e03e9ce5490a4f0627c356b28 Mon Sep 17 00:00:00 2001 From: Jon Wolfe Date: Thu, 16 Feb 2017 10:40:19 -0800 Subject: [PATCH] Fix uninitialized function variable and add testing on its return --- components/cice/src/source/ice_spacecurve.F90 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/cice/src/source/ice_spacecurve.F90 b/components/cice/src/source/ice_spacecurve.F90 index f1909c7d0bc..92e5585d498 100644 --- a/components/cice/src/source/ice_spacecurve.F90 +++ b/components/cice/src/source/ice_spacecurve.F90 @@ -1139,6 +1139,7 @@ function FirstFactor(fac) result(res) integer (int_kind) :: i found = .false. + res = 0 i=1 do while (i<=fac%numfact .and. (.not. found)) if(fac%used(i) == 0) then @@ -1189,8 +1190,10 @@ subroutine MatchFactor(fac1,fac2,val,found) val1 = FirstFactor(fac1) !JMD print *,'Matchfactor: found value: ',val1 - found = FindandMark(fac2,val1,.true.) - tmp = FindandMark(fac1,val1,found) + if (val1.ge.1) then + found = FindandMark(fac2,val1,.true.) + tmp = FindandMark(fac1,val1,found) + endif if (found) then val = val1 else