fopen=>CmiFopen.
authorGengbin Zheng <gzheng@illinois.edu>
Wed, 20 Oct 2010 07:13:58 +0000 (02:13 -0500)
committerGengbin Zheng <gzheng@illinois.edu>
Wed, 20 Oct 2010 07:13:58 +0000 (02:13 -0500)
src/ck-core/ckcheckpoint.C

index c1342cc3ee4cf8fc031cac2238e5287ecc086567..2728c9fb75ad4d7a798e918f87299097925ebfec 100644 (file)
@@ -110,17 +110,17 @@ void CkCheckpointMgr::Checkpoint(const char *dirname, CkCallback& cb){
 #ifndef CMK_CHARE_USE_PTR
        // save groups into Chares.dat
        sprintf(fileName,"%s/Chares_%d.dat",dirname,CkMyPe());
-       FILE* fChares = fopen(fileName,"wb");
+       FILE* fChares = CmiFopen(fileName,"wb");
        if(!fChares) CkAbort("Failed to create checkpoint file for chares!");
        PUP::toDisk pChares(fChares);
        CkPupChareData(pChares);
-       fclose(fChares);
+       CmiFclose(fChares);
 #endif
 
        // save groups into Groups.dat
        // content of the file: numGroups, GroupInfo[numGroups], _groupTable(PUP'ed), groups(PUP'ed)
        sprintf(fileName,"%s/Groups_%d.dat",dirname,CkMyPe());
-       FILE* fGroups = fopen(fileName,"wb");
+       FILE* fGroups = CmiFopen(fileName,"wb");
        if(!fGroups) CkAbort("Failed to create checkpoint file for group table!");
        PUP::toDisk pGroups(fGroups);
 #if (defined(_FAULT_MLOG_) || defined(_FAULT_CAUSAL_))
@@ -128,13 +128,13 @@ void CkCheckpointMgr::Checkpoint(const char *dirname, CkCallback& cb){
 #else
     CkPupGroupData(pGroups);
 #endif
-       fclose(fGroups);
+       CmiFclose(fGroups);
 
        // save nodegroups into NodeGroups.dat
        // content of the file: numNodeGroups, GroupInfo[numNodeGroups], _nodeGroupTable(PUP'ed), nodegroups(PUP'ed)
        if (CkMyRank() == 0) {
          sprintf(fileName,"%s/NodeGroups_%d.dat",dirname,CkMyNode());
-         FILE* fNodeGroups = fopen(fileName,"wb");
+         FILE* fNodeGroups = CmiFopen(fileName,"wb");
          if(!fNodeGroups) 
            CkAbort("Failed to create checkpoint file for nodegroup table!");
          PUP::toDisk pNodeGroups(fNodeGroups);
@@ -143,16 +143,16 @@ void CkCheckpointMgr::Checkpoint(const char *dirname, CkCallback& cb){
 #else
       CkPupNodeGroupData(pNodeGroups);
 #endif
-         fclose(fNodeGroups);
+         CmiFclose(fNodeGroups);
        }
 
        //DEBCHK("[%d]CkCheckpointMgr::Checkpoint called dirname={%s}\n",CkMyPe(),dirname);
        sprintf(fileName,"%s/arr_%d.dat",dirname, CkMyPe());
-       FILE *datFile=fopen(fileName,"wb");
+       FILE *datFile=CmiFopen(fileName,"wb");
        if (datFile==NULL) CkAbort("Could not create data file");
        PUP::toDisk  p(datFile);
        CkPupArrayElementsData(p);
-       fclose(datFile);
+       CmiFclose(datFile);
 
 #if CMK_HAS_SYNC && ! CMK_DISABLE_SYNC
        system("sync");
@@ -596,23 +596,23 @@ static void checkpointOne(const char* dirname, CkCallback& cb){
        
        // save readonlys, and callback BTW
        sprintf(filename,"%s/RO.dat",dirname);
-       FILE* fRO = fopen(filename,"wb");
+       FILE* fRO = CmiFopen(filename,"wb");
        if(!fRO) CkAbort("Failed to create checkpoint file for readonly data!");
        PUP::toDisk pRO(fRO);
        int _numPes = CkNumPes();
        pRO|_numPes;
        CkPupROData(pRO);
        pRO|cb;
-       fclose(fRO);
+       CmiFclose(fRO);
 
        // save mainchares into MainChares.dat
        {
                sprintf(filename,"%s/MainChares.dat",dirname);
-               FILE* fMain = fopen(filename,"wb");
+               FILE* fMain = CmiFopen(filename,"wb");
                if(!fMain) CkAbort("Failed to open checkpoint file for mainchare data!");
                PUP::toDisk pMain(fMain);
                CkPupMainChareData(pMain, NULL);
-               fclose(fMain);
+               CmiFclose(fMain);
        }
 }
 
@@ -670,14 +670,14 @@ void CkRestartMain(const char* dirname, CkArgMsg *args){
 
        // restore readonlys
        sprintf(filename,"%s/RO.dat",dirname);
-       FILE* fRO = fopen(filename,"rb");
+       FILE* fRO = CmiFopen(filename,"rb");
        if(!fRO) CkAbort("Failed to open checkpoint file for readonly data!");
        int _numPes = -1;
        PUP::fromDisk pRO(fRO);
        pRO|_numPes;
        CkPupROData(pRO);
        pRO|cb;
-       fclose(fRO);
+       CmiFclose(fRO);
        DEBCHK("[%d]CkRestartMain: readonlys restored\n",CkMyPe());
         _oldNumPes = _numPes;
 
@@ -685,11 +685,11 @@ void CkRestartMain(const char* dirname, CkArgMsg *args){
 
        // restore mainchares
        sprintf(filename,"%s/MainChares.dat",dirname);
-       FILE* fMain = fopen(filename,"rb");
+       FILE* fMain = CmiFopen(filename,"rb");
        if(fMain && CkMyPe()==0){ // only main chares have been checkpointed, we restart on PE0
                PUP::fromDisk pMain(fMain);
                CkPupMainChareData(pMain, args);
-               fclose(fMain);
+               CmiFclose(fMain);
                DEBCHK("[%d]CkRestartMain: mainchares restored\n",CkMyPe());
                //bdcastRO(); // moved to CkPupMainChareData()
        }
@@ -698,11 +698,11 @@ void CkRestartMain(const char* dirname, CkArgMsg *args){
        // restore chares only when number of pes is the same 
        if(CkNumPes() == _numPes) {
                sprintf(filename,"%s/Chares_%d.dat",dirname,CkMyPe());
-               FILE* fChares = fopen(filename,"rb");
+               FILE* fChares = CmiFopen(filename,"rb");
                if(!fChares) CkAbort("Failed to open checkpoint file for chares!");
                PUP::fromDisk pChares(fChares);
                CkPupChareData(pChares);
-               fclose(fChares);
+               CmiFclose(fChares);
                _chareRestored = 1;
        }
 #endif
@@ -714,7 +714,7 @@ void CkRestartMain(const char* dirname, CkArgMsg *args){
                sprintf(filename,"%s/Groups_0.dat",dirname);
        else
                sprintf(filename,"%s/Groups_%d.dat",dirname,CkMyPe());
-       FILE* fGroups = fopen(filename,"rb");
+       FILE* fGroups = CmiFopen(filename,"rb");
        if(!fGroups) CkAbort("Failed to open checkpoint file for group table!");
        PUP::fromDisk pGroups(fGroups);
 #if (defined(_FAULT_MLOG_) || defined(_FAULT_CAUSAL_))
@@ -722,7 +722,7 @@ void CkRestartMain(const char* dirname, CkArgMsg *args){
 #else
     CkPupGroupData(pGroups);
 #endif
-       fclose(fGroups);
+       CmiFclose(fGroups);
 
        // restore nodegroups
        // content of the file: numNodeGroups, GroupInfo[numNodeGroups], _nodeGroupTable(PUP'ed), nodegroups(PUP'ed)
@@ -731,7 +731,7 @@ void CkRestartMain(const char* dirname, CkArgMsg *args){
                        sprintf(filename,"%s/NodeGroups_0.dat",dirname);
                else
                        sprintf(filename,"%s/NodeGroups_%d.dat",dirname,CkMyNode());
-               FILE* fNodeGroups = fopen(filename,"rb");
+               FILE* fNodeGroups = CmiFopen(filename,"rb");
                if(!fNodeGroups) CkAbort("Failed to open checkpoint file for nodegroup table!");
                PUP::fromDisk pNodeGroups(fNodeGroups);
 #if (defined(_FAULT_MLOG_) || defined(_FAULT_CAUSAL_))
@@ -739,7 +739,7 @@ void CkRestartMain(const char* dirname, CkArgMsg *args){
 #else
         CkPupNodeGroupData(pNodeGroups);
 #endif
-               fclose(fNodeGroups);
+               CmiFclose(fNodeGroups);
        }
 
        // for each location, restore arrays
@@ -749,11 +749,11 @@ void CkRestartMain(const char* dirname, CkArgMsg *args){
           for (i=0; i<_numPes;i++) {
             if (i%CkNumPes() == CkMyPe()) {
              sprintf(filename,"%s/arr_%d.dat",dirname, i);
-             FILE *datFile=fopen(filename,"rb");
+             FILE *datFile=CmiFopen(filename,"rb");
              if (datFile==NULL) CkAbort("Could not read data file");
              PUP::fromDisk  p(datFile);
              CkPupArrayElementsData(p);
-             fclose(datFile);
+             CmiFclose(datFile);
             }
          }