From f480b8910ff4e08da57ab176c6b6ce20e871882a Mon Sep 17 00:00:00 2001
From: zhang <zhang@9a6e40ed-f3a0-4838-9b4a-bf418f78e88d>
Date: Thu, 22 Dec 2011 13:08:03 +0000
Subject: [PATCH] Add feature to stop the code when the kid index is less than
 1 in GetElemPos( )

---
 tracy/tracy/src/t2elem.cc | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/tracy/tracy/src/t2elem.cc b/tracy/tracy/src/t2elem.cc
index a6ec5c6..a28630b 100644
--- a/tracy/tracy/src/t2elem.cc
+++ b/tracy/tracy/src/t2elem.cc
@@ -2893,11 +2893,26 @@ int GetnKid(const int Fnum1) {
  none
 
  Comments:
+ example:
+  long FORLIM = GetnKid(ElemIndex("CH")); // get number of CH
+  // search element position for Family CH
+  for(k=1;k<FORLIM;k++){
+  fprintf(stdout, "elem %d is at position %ld \n", k, Elem_GetPos(ElemIndex("CH"), k));
+  }
+
+  
+  21/12/2011  Jianfeng Zhang@ soleil
+  Add warning message: when call Elem_GetPos(), the kid index knum1 start from 1 !!!!!
 
  ****************************************************************************/
 long Elem_GetPos(const int Fnum1, const int Knum1) {
     long int loc;
-
+    
+    if(Knum1 < 1){
+    cout << "Elem_GetPos:  kid index of the family starts from 1 !!!" << endl;
+    cout << "Element: " << ElemFam[Fnum1 - 1].ElemF.PName << "with Fnum:  " <<Fnum1<<"  Knum: "<<Knum1<<endl;
+    exit_(1); 
+    }
     if (ElemFam[Fnum1 - 1].nKid != 0)
         loc = ElemFam[Fnum1 - 1].KidList[Knum1 - 1];
     else {
-- 
GitLab