diff options
author | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2001-03-21 11:32:30 +0000 |
---|---|---|
committer | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2001-03-21 11:32:30 +0000 |
commit | 63d13b19a212a35b7e5895afa236d3a53a6596d2 (patch) | |
tree | 56637bbd2db11f4dd769a62b4fe604d45e4c4304 /src/Write2D.c | |
parent | 33890a8ce893e033b3acb849460e60c42b9cdf15 (diff) |
Added string attributes 'parameter file' and 'creation date' to the output
files. These should help identifying your datafiles later on.
Also fixed couple of gcc compiler warnings.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOFlexIO/trunk@178 ebee0441-1374-4afa-a3b5-247f3ba15b9a
Diffstat (limited to 'src/Write2D.c')
-rw-r--r-- | src/Write2D.c | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/src/Write2D.c b/src/Write2D.c index 78c6fc4..01b4b6f 100644 --- a/src/Write2D.c +++ b/src/Write2D.c @@ -50,7 +50,7 @@ CCTK_FILEVERSION(CactusPUGHIO_IOFlexIO_Write2D_c) @vio in @vcomment @endvar - @var index + @var vindex @vdesc index of variable to output @vtype int @vio in @@ -64,7 +64,7 @@ CCTK_FILEVERSION(CactusPUGHIO_IOFlexIO_Write2D_c) @endvar @@*/ -void IOFlexIO_Write2D (cGH *GH, int index, const char *alias) +void IOFlexIO_Write2D (cGH *GH, int vindex, const char *alias) { DECLARE_CCTK_PARAMETERS int dir; /* looper for directions */ @@ -83,13 +83,13 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias) IEEEfile_2D = NULL; /* get the variable group indormation */ - groupindex = CCTK_GroupIndexFromVarI (index); + groupindex = CCTK_GroupIndexFromVarI (vindex); CCTK_GroupData (groupindex, &groupinfo); /* check if variable has storage assigned */ if (! CCTK_QueryGroupStorageI (GH, groupindex)) { - char *fullname = CCTK_FullName (index); + char *fullname = CCTK_FullName (vindex); CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, @@ -153,6 +153,8 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias) /* Open/Create files */ for (dir = 0; dir < 3; dir++) { + int len; + char buffer[128]; const char *extensions[3] = {"yz", "xz", "xy"}; @@ -178,6 +180,22 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias) fname); return; } + + /* add the parameter filename and the creation date + as file identification attributes */ + buffer[0] = 0; + CCTK_ParameterFilename (sizeof (buffer), buffer); + CACTUS_IEEEIO_ERROR (IOwriteAttribute (IEEEfile_2D[dir], + "parameter file", FLEXIO_CHAR, + strlen (buffer) + 1, buffer)); + buffer[0] = 0; + Util_CurrentDate (sizeof (buffer), buffer); + len = strlen (buffer) + 1; + buffer[len-1] = ' '; + Util_CurrentTime (sizeof (buffer) - len, buffer + len); + CACTUS_IEEEIO_ERROR (IOwriteAttribute (IEEEfile_2D[dir], + "creation date", FLEXIO_CHAR, + strlen (buffer) + 1, buffer)); } /* store file desriptors in database */ @@ -194,7 +212,7 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias) if (verbose) { CCTK_VInfo (CCTK_THORNSTRING, "Resuming 2D output files for variable " - "'%s'", CCTK_VarName (index)); + "'%s'", CCTK_VarName (vindex)); } for (dir = 0; dir < 3; dir++) @@ -205,7 +223,7 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias) } /* get the timelevel for the variable to output */ - timelevel = CCTK_NumTimeLevelsFromVarI (index) - 1; + timelevel = CCTK_NumTimeLevelsFromVarI (vindex) - 1; if (timelevel > 0) { timelevel--; @@ -252,10 +270,10 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias) directions[dir] = 1; /* get the variable slice */ - if (Hyperslab_GetHyperslab (GH, 0, index, timelevel, 2, origin, directions, + if (Hyperslab_GetHyperslab (GH, 0, vindex, timelevel, 2, origin, directions, lengths, downsamples, &data, data_hsizes) < 0) { - char *fullname = CCTK_FullName (index); + char *fullname = CCTK_FullName (vindex); CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, @@ -267,7 +285,7 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias) /* processor 0 write the hyperslab data */ if (myproc == 0) { - CCTK_REAL origin[2], delta[2]; + CCTK_REAL origin_attr[2], delta_attr[2]; /* the data itself */ @@ -276,16 +294,16 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias) free (data); /* Time and space attributes */ - origin[0] = coord_origin3D[dir_i]; - origin[1] = coord_origin3D[dir_j]; - delta[0] = GH->cctk_delta_space[dir_i]; - delta[1] = GH->cctk_delta_space[dir_j]; + origin_attr[0] = coord_origin3D[dir_i]; + origin_attr[1] = coord_origin3D[dir_j]; + delta_attr[0] = GH->cctk_delta_space[dir_i]; + delta_attr[1] = GH->cctk_delta_space[dir_j]; CACTUS_IEEEIO_ERROR (IOwriteAttribute (IEEEfile_2D[dir], "time", FLEXIO_REAL, 1, &GH->cctk_time)); CACTUS_IEEEIO_ERROR (IOwriteAttribute (IEEEfile_2D[dir], "origin", - FLEXIO_REAL, 2, origin)); + FLEXIO_REAL, 2, origin_attr)); CACTUS_IEEEIO_ERROR (IOwriteAttribute (IEEEfile_2D[dir], "delta", - FLEXIO_REAL, 2, delta)); + FLEXIO_REAL, 2, delta_attr)); /* and also the coordinate ranges */ CACTUS_IEEEIO_ERROR (IOwriteAttribute (IEEEfile_2D[dir], "min_ext", @@ -302,7 +320,7 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias) if (verbose) { CCTK_VInfo (CCTK_THORNSTRING, "Pausing 2D output files for variable '%s'", - CCTK_VarName (index)); + CCTK_VarName (vindex)); } for (dir = 0; dir < 3; dir++) |