[cig-commits] commit:

Mercurial hg at geodynamics.org
Mon Nov 24 11:59:37 PST 2008


changeset:   162:352c2356a55a
user:        JohnMansour <john.mansour at maths.monash.edu.au>
date:        Fri Sep 19 16:29:00 2008 +1000
files:       Swarm/src/SwarmDump.c
description:
mod to avoid checkpointing nfs issues on tango:

materialswarm checkpoints are written to temporary file, then moved to required filename.


diff -r 9899cccf3498 -r 352c2356a55a Swarm/src/SwarmDump.c
--- a/Swarm/src/SwarmDump.c	Mon Sep 15 06:49:04 2008 +0000
+++ b/Swarm/src/SwarmDump.c	Fri Sep 19 16:29:00 2008 +1000
@@ -240,6 +240,7 @@ void _SwarmDump_Execute( void* swarmDump
 	Particle_Index    particleLocalCount;
 	SizeT             particleSize;
 	Name              filename;
+	Name              filenameTemp;
 	Index             swarm_I;
 	Swarm*            swarm;
 	Stream*           info = Journal_Register( Info_Type, self->type );
@@ -287,12 +288,21 @@ void _SwarmDump_Execute( void* swarmDump
 		SwarmDump_DumpToHDF5( self, swarm, filename );
 #else
       Stg_asprintf( &filename, "%s.dat", filename );
-      Stream_RedirectFile( stream, filename );
+      /* write checkpoint file to a temporary file to avoid nfs issues */
+      Stg_asprintf( &filenameTemp, "%s.temp", filename );
+      Stream_RedirectFile( stream, filenameTemp );
 		MPIStream_WriteAllProcessors( stream, swarm->particles, particleSize, (SizeT) particleLocalCount, swarm->comm );
 		Stream_CloseFile( stream );
 #endif
+		/* remove old checkpoint file, if any exists... then move temp file to appropriate filename */
+		if(swarm->myRank == 0){
+		      remove( filename );
+		      rename( filenameTemp , filename );
+		}
 
 		Memory_Free( filename );
+		Memory_Free( filenameTemp );		
+
 	}
 	Stream_UnIndent( info );
 	Journal_DPrintf( info, "Proc %d: finished Swarm binary checkpoint.\n", self->swarmList[0]->myRank );



More information about the CIG-COMMITS mailing list