Make GetNumElements callable from init().
authorOrion Lawlor <olawlor@acm.org>
Mon, 11 Feb 2002 23:52:26 +0000 (23:52 +0000)
committerOrion Lawlor <olawlor@acm.org>
Mon, 11 Feb 2002 23:52:26 +0000 (23:52 +0000)
src/libs/ck-libs/tcharm/tcharm.C

index 15df0b479bf7be909a5b4f728cc9e197e6777774..9657823b3af14d06526d1ab908dbbbde386f7e0e 100644 (file)
@@ -18,6 +18,7 @@ Orion Sky Lawlor, olawlor@acm.org, 11/19/2001
 CtvDeclare(TCharm *,_curTCharm);
 CpvDeclare(inState,_stateTCharm);
 
 CtvDeclare(TCharm *,_curTCharm);
 CpvDeclare(inState,_stateTCharm);
 
+static int lastNumChunks=0;
 /*readonly*/ int tcharm_nomig=0, tcharm_nothreads=0;
 
 void TCharm::nodeInit(void)
 /*readonly*/ int tcharm_nomig=0, tcharm_nothreads=0;
 
 void TCharm::nodeInit(void)
@@ -524,6 +525,7 @@ CDECL int TCharmGetNumChunks(void)
        char **argv=TCharmArgv();
        CmiGetArgInt(argv,"-vp",&nChunks);
        CmiGetArgInt(argv,"+vp",&nChunks);
        char **argv=TCharmArgv();
        CmiGetArgInt(argv,"-vp",&nChunks);
        CmiGetArgInt(argv,"+vp",&nChunks);
+       lastNumChunks=nChunks;
        return nChunks;
 }
 FDECL int FTN_NAME(TCHARM_GET_NUM_CHUNKS,tcharm_get_num_chunks)(void)
        return nChunks;
 }
 FDECL int FTN_NAME(TCHARM_GET_NUM_CHUNKS,tcharm_get_num_chunks)(void)
@@ -538,7 +540,12 @@ Callable from worker thread
 CDECL int TCharmElement(void)
 { return TCharm::get()->getElement();}
 CDECL int TCharmNumElements(void)
 CDECL int TCharmElement(void)
 { return TCharm::get()->getElement();}
 CDECL int TCharmNumElements(void)
-{ return TCharm::get()->getNumElements();}
+{ 
+       if (TCharm::getState()==inDriver)
+               return TCharm::get()->getNumElements();
+       else
+               return lastNumChunks;
+}
 
 FDECL int FTN_NAME(TCHARM_ELEMENT,tcharm_element)(void) 
 { return TCharmElement();}
 
 FDECL int FTN_NAME(TCHARM_ELEMENT,tcharm_element)(void) 
 { return TCharmElement();}