[SCM] Gerris Flow Solver branch, upstream, updated. e8f73a07832050124d2b8bf6c6f35b33180e65a8
Stephane Popinet
popinet at users.sf.net
Tue Nov 24 12:24:16 UTC 2009
The following commit has been merged in the upstream branch:
commit 0c5d3d342d15218ee2c7af348f216efd359e7334
Author: Stephane Popinet <popinet at users.sf.net>
Date: Tue Jun 23 19:25:28 2009 +1000
Bug fix for file access test in parallel
darcs-hash:20090623092528-d4795-c0314a1e7fe39d6984a2aaff5bffadbc575b94db.gz
diff --git a/src/output.c b/src/output.c
index b80fe6a..acffe06 100644
--- a/src/output.c
+++ b/src/output.c
@@ -23,6 +23,7 @@
#include <sys/stat.h>
#include <sys/wait.h>
#include <errno.h>
+#include <string.h>
#include <math.h>
#include "output.h"
#include "graphic.h"
@@ -232,15 +233,15 @@ static void gfs_output_read (GtsObject ** o, GtsFile * fp)
return;
}
else {
- gchar * c, * start, * fname, * fnamebak;
- FILE * fptr;
+ GfsDomain * domain = GFS_DOMAIN (gfs_object_simulation (output));
+ gchar * c, * start;
guint len;
output->format = g_strdup (fp->token->str);
gts_file_next_token (fp);
if (!strcmp (output->format, "stderr") || !strcmp (output->format, "stdout")) {
- if (GFS_DOMAIN (gfs_object_simulation (output))->pid > 0)
+ if (domain->pid > 0)
gfs_output_mute (output);
else {
g_assert (!output->file);
@@ -299,26 +300,28 @@ static void gfs_output_read (GtsObject ** o, GtsFile * fp)
}
c++;
}
- len = GPOINTER_TO_UINT (c) - GPOINTER_TO_UINT (start);
+ len = GPOINTER_TO_UINT (c) - GPOINTER_TO_UINT (start);
if (len > 0)
output->formats = g_slist_prepend (output->formats,
format_new (start, len, NONE));
output->formats = g_slist_reverse (output->formats);
-
- fname = format_string (output->formats, -1, 0, 0.);
- fnamebak = g_strconcat (fname, "~", NULL);
- g_free (fname);
- fptr = fopen (fnamebak, "w");
- if (fptr == NULL) {
- gts_file_error (fp, "cannot open file specified by format `%s'",
- output->format);
+
+ if (output->parallel || domain->pid <= 0) {
+ gchar * fname = format_string (output->formats, domain->pid, 0, 0.);
+ gchar * fnamebak = g_strconcat (fname, "~", NULL);
+ g_free (fname);
+ FILE * fptr = fopen (fnamebak, "w");
+ if (fptr == NULL) {
+ gts_file_error (fp, "cannot open file specified by format `%s'\n %s",
+ output->format, strerror (errno));
+ g_free (fnamebak);
+ output_free (output);
+ return;
+ }
+ fclose (fptr);
+ remove (fnamebak);
g_free (fnamebak);
- output_free (output);
- return;
}
- fclose (fptr);
- remove (fnamebak);
- g_free (fnamebak);
}
}
--
Gerris Flow Solver
More information about the debian-science-commits
mailing list