diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Write.c | 16 |
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); } |