aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@eff87b29-5268-4891-90a3-a07138403961>2002-04-25 16:20:53 +0000
committertradke <tradke@eff87b29-5268-4891-90a3-a07138403961>2002-04-25 16:20:53 +0000
commit7163b5eb8615197e29c96ad6b85a2f2af86a4c54 (patch)
tree573b52f288f193bf6663101fbd282f6afcec98ea
parent01bc2eb4b52e6b1de3c50822d38b86d5656b2cc0 (diff)
Some optimization: use Hyperslab_Get() instead of Hyperslab_GetList().
git-svn-id: http://svn.cactuscode.org/arrangements/CactusIO/IOJpeg/trunk@65 eff87b29-5268-4891-90a3-a07138403961
-rw-r--r--src/Write.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/Write.c b/src/Write.c
index 606a6c2..4c6ffb1 100644
--- a/src/Write.c
+++ b/src/Write.c
@@ -175,7 +175,7 @@ int IOJpeg_Write (const cGH *GH, CCTK_INT vindex, const char *alias)
fullname);
continue;
}
- total_hsize = hsize[0] * hsize[1];
+ total_hsize = hsize[0] * hsize[1] * CCTK_VarTypeSize (gdata.vartype);
if (total_hsize <= 0)
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
@@ -185,16 +185,12 @@ int IOJpeg_Write (const cGH *GH, CCTK_INT vindex, const char *alias)
continue;
}
- if (myproc == 0)
- {
- /* allocate hyperslab buffer */
- hdata = malloc (total_hsize * CCTK_VarTypeSize (gdata.vartype));
- }
+ /* allocate hyperslab buffer */
+ hdata = myproc == 0 ? malloc (total_hsize) : NULL;
/* get the hyperslab */
- i = Hyperslab_GetList (GH, mapping, 1, NULL, &vindex, NULL, &htype, &hdata,
- NULL);
- if (i != 1)
+ i = Hyperslab_Get (GH, mapping, 0, vindex, 0, htype, hdata);
+ if (i)
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
"Failed to extract hyperslab for variable '%s'", fullname);
@@ -206,7 +202,7 @@ int IOJpeg_Write (const cGH *GH, CCTK_INT vindex, const char *alias)
/* and dump the data to file */
if (myproc == 0)
{
- if (i == 1)
+ if (i == 0)
{
WriteData (GH, vindex, alias, gdata.dim, dir, min, max, hsize, hdata);
}