aboutsummaryrefslogtreecommitdiff
path: root/src/GetHyperslab.c
blob: f0ec33c509daaf972bb6111e9d7fbc318a458d1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
 /*@@
   @file      GetHyperslab.c
   @date      Sun 2 Dec 2001
   @author    Thomas Radke
   @desc
              Routines to extract hyperslabs from CCTK array variables
   @enddesc
   @version   $Id$
 @@*/


#include <stdlib.h>
#include <string.h>

#include "cctk.h"
#include "cctk_Parameters.h"

#include "CactusPUGH/PUGH/src/include/pugh.h"
#include "PUGHSlab.h"
#include "PUGHSlabi.h"

static const char *rcsid = "$Header$";

CCTK_FILEVERSION(CactusPUGH_PUGHSlab_GetHyperslab_c)

/********************************************************************
 ********************    Macro Definitions   ************************
 ********************************************************************/
/* define this if you want debugging output */
/* #define DEBUG 1 */

/* define some defaults for optional parameters */
#define DEFAULT_PROCESSOR  0
#define DEFAULT_TIMELEVEL  0

/********************************************************************
 ********************    Internal Routines   ************************
 ********************************************************************/
static int GetLocalHyperslab (const cGH *GH,
                              const hslab_mapping_t *mapping,
                              int vindex,
                              int timelevel,
                              int hdatatype,
                              void *hdata);
static int GetDiagonalFromFrom3D (const cGH *GH,
                                  const hslab_mapping_t *mapping,
                                  int vindex,
                                  int timelevel,
                                  int hdatatype,
                                  t_hslabConversionFn conversion_fn,
                                  void *hdata);
#ifdef CCTK_MPI
static void SortIntoUnchunkedHyperslab (const hslab_mapping_t *mapping,
                                        int nprocs, int hdata_size,
                                        const void *chunked_hdata,
                                        void *unchunked_hdata);
#endif


CCTK_INT PUGHSlab_Get (const cGH *GH,
                       CCTK_INT   mapping_handle,
                       CCTK_INT   proc,
                       CCTK_INT   vindex,
                       CCTK_INT   timelevel,
                       CCTK_INT   hdatatype,
                       void      *hdata)
{
  CCTK_INT retval;

  retval = PUGHSlab_GetList (GH, mapping_handle, 1, &proc, &vindex, &timelevel,
                             hdatatype >= 0 ? &hdatatype : NULL, &hdata, NULL);

  return (retval == 1 ? 0 : -1);
}


CCTK_INT PUGHSlab_GetList (const cGH *GH,
                           CCTK_INT mapping_handle,
                           CCTK_INT num_arrays,
                           const CCTK_INT *procs        /* num_arrays */,
                           const CCTK_INT *vindices     /* num_arrays */,
                           const CCTK_INT *timelevels   /* num_arrays */,
                           const CCTK_INT *hdatatypes   /* num_arrays */,
                           void *const *hdata           /* num_arrays */,
                           CCTK_INT *retvals            /* num_arrays */)
{
  int i, timelevel, hdatatype, hdata_size, retval;
  CCTK_INT result, *result_ptr;
  hslab_mapping_t *mapping;
  void *local_hdata;
#ifdef CCTK_MPI
  int myproc, nprocs, proc;
  MPI_Comm comm;
  void *chunked_hdata;
  MPI_Datatype mpi_vtype;
#endif


  retval = 0;
  if (num_arrays <= 0)
  {
    return (0);
  }

  mapping = PUGHSlabi_GetMapping (mapping_handle);
  if (mapping)
  {
    /* check mapping consistency */
    /*** FIXME ***/
    /* all vindices[] must match the given mapping */

    /* check if there's any data to extract */
    if (mapping->totals_global <= 0)
    {
      retval = num_arrays;
    }
  }
  else
  {
    retval = -1;
  }

  /* immediately return in case of errors or if there's nothing to do */
  if (retval)
  {
    /* set the retvals[] according to the return value */
    if (retvals)
    {
      for (i = 0; i < num_arrays; i++)
      {
        retvals[i] = retval > 0 ? 0 : retval;
      }
    }

    return (retval);
  }

#ifdef CCTK_MPI
  myproc = CCTK_MyProc (GH);
  nprocs = CCTK_nProcs (GH);
  comm = PUGH_pGH (GH)->PUGH_COMM_WORLD;
#else
  /* suppress compiler warnings about unused parameters */
  (void) (procs + 0);
#endif

  /* now loop over all hyperslabs */
  /*** FIXME: should optimize this loop away ***/
  for (i = 0; i < num_arrays; i++)
  {
    timelevel = timelevels ? timelevels[i] : DEFAULT_TIMELEVEL;
    hdatatype = hdatatypes ? hdatatypes[i] : CCTK_VarTypeI (vindices[i]);
    hdata_size = CCTK_VarTypeSize (hdatatype);
    result_ptr = retvals ? &retvals[i] : &result;

    if (mapping->totals <= 0)
    {
      local_hdata = NULL;
      *result_ptr = 0;
    }
    else
    {
      /* allocate temporary array to keep the local hyperslab data */
      local_hdata = mapping->is_global_hyperslab ?
                    malloc (mapping->totals * hdata_size) : hdata[i];

      /* get the processor-local hyperslab */
      *result_ptr = GetLocalHyperslab (GH, mapping, vindices[i], timelevel,
                                       hdatatype, local_hdata);
    }

    if (*result_ptr == 0)
    {
      retval++;
    }

    if (! mapping->is_global_hyperslab)
    {
      continue;
    }

#ifdef CCTK_MPI
    proc = procs ? procs[i] : DEFAULT_PROCESSOR;
    if (proc < 0 || proc == myproc)
    {
      /* allocate temporary array to receive the chunks from all processors */
      /* for the case of hdim == 1, the sorting is done by MPI */
      chunked_hdata = mapping->hdim > 1 ?
                      malloc (mapping->totals_global * hdata_size) : hdata[i];
    }
    else
    {
      chunked_hdata = NULL;
    }

    /* detect the MPI datatype to use */
    mpi_vtype = PUGH_MPIDataType (PUGH_pGH (GH), hdatatype);

    /* collect the hyperslab chunks from all processors */
    if (proc < 0)
    {
      CACTUS_MPI_ERROR (MPI_Allgatherv (local_hdata, mapping->totals, mpi_vtype,
                                        chunked_hdata, mapping->recvcnts,
                                        mapping->displs, mpi_vtype, comm));
    }
    else
    {
      CACTUS_MPI_ERROR (MPI_Gatherv (local_hdata, mapping->totals, mpi_vtype,
                                     chunked_hdata, mapping->recvcnts,
                                     mapping->displs, mpi_vtype, proc, comm));
    }

    /* free processor-local chunk */
    if (local_hdata)
    {
      free (local_hdata);
    }

    /* Now we got the global hyperslab data in a chunked array.
       The user wants it unchunked, so let's sort it... */
    if (mapping->hdim > 1 && (proc < 0 || proc == myproc))
    {
      SortIntoUnchunkedHyperslab (mapping, nprocs, hdata_size, chunked_hdata,
                                  hdata[i]);
      free (chunked_hdata);
    }
#endif
  }

  return (retval);
}

/********************************************************************
 ********************    Internal Routines   ************************
 ********************************************************************/
/*@@
  @routine    GetLocalHyperslab
  @date       Fri May 12 2000
  @author     Thomas Radke
  @desc
              Extract a hyperslab from the processor-local chunk
              of a domain-decomposed Cactus array variable.

              This routine delivers the local hyperslab data
              to be collected into a global hyperslab by PUGHlab_GetHyperslab().
              IO methods can call this routine as well to collect the
              local hyperslab data and output it in parallel.
  @enddesc

  @calls      PUGHSlab_GetDatatypeConversionFn

  @var        GH
  @vdesc      Pointer to CCTK grid hierarchy
  @vtype      const cGH *
  @vio        in
  @endvar
  @var        mapping
  @vdesc      pointer to the mapping structure for this hyperslab request
  @vtype      const hslab_mapping_t *
  @vio        in
  @endvar
  @var        vindex
  @vdesc      index of variable to get a hyperslab from
  @vtype      int
  @vio        in
  @endvar
  @var        timelevel
  @vdesc      timelvl of variable to get a hyperslab from
  @vtype      int
  @vio        in
  @endvar
  @var        hdatatype
  @vdesc      CCTK datatype of the requested hyperslab
  @vtype      int
  @vio        in
  @endvar
  @var        hdata
  @vdesc      reference to the user-supplied hyperslab data buffer
  @vtype      void *
  @vio        out
  @endvar
@@*/
static int GetLocalHyperslab (const cGH *GH,
                              const hslab_mapping_t *mapping,
                              int vindex,
                              int timelevel,
                              int hdatatype,
                              void *hdata)
{
  int *point;                    /* looper over hyperslab dimensions */
  int *startpoint,               /* hyperslab's local start and endpoint */
      *endpoint;                 /* within the variable's grid dimensions */
  int *downsample;               /* the downsample[] vector extended to vdim */
  int *points_per_dim;           /* points per subvolume */
  int i;                         /* general looper */
  int vdim;                      /* looper over all source dimensions */
  int vdata_size,                /* size of one data point in bytes for */
      hdata_size;                /* source and hyperslab data */
  int dim0_points;               /* number of hyperslab points in dim 0 */
  int dim0_hsize;                /* byte size of hyperslab points in dim 0 */
  const char *typed_vdata;             /* byte pointers into source and */
  char *typed_hdata;             /* hyperslab data arrays */
  const void *vdata;
  int retval;                    /* the return value (0 for success) */
  cGroup vinfo;                  /* variable's group info */
  pGH *pughGH;                   /* pointer to the current pGH */
  pGA *GA;                       /* the variable's GA structure from PUGH */
  const char *errormsg;          /* error message string */
  t_hslabConversionFn conversion_fn;


  vdata = NULL;

  /* do some plausibility checks */
  errormsg = NULL;
  if (! GH || ! mapping || (mapping->totals > 0 && ! hdata))
  {
    errormsg = "NULL pointer(s) passed for GH/mapping/hdata arguments";
  }
  else if (CCTK_GroupData (CCTK_GroupIndexFromVarI (vindex), &vinfo) < 0)
  {
    errormsg = "Invalid variable index given";
  }
  else if (timelevel < 0 || timelevel >= vinfo.numtimelevels)
  {
    errormsg = "Invalid timelevel given";
  }
  else if (vinfo.grouptype != mapping->vinfo.grouptype ||
           vinfo.disttype  != mapping->vinfo.disttype ||
           vinfo.dim       != mapping->vinfo.dim ||
           vinfo.stagtype  != mapping->vinfo.stagtype)
  {
    errormsg = "Group data for template variable in mapping and given variable "
               "don't match";
  }
  else
  {
    vdata = CCTK_VarDataPtrI (GH, timelevel, vindex);
    if (vdata == NULL)
    {
      errormsg = "Variable has no storage allocated";
    }
  }

  /* immediately return in case of errors */
  if (errormsg)
  {
    CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
                "GetLocalHyperslab: %s", errormsg);
    return (-1);
  }

  /* if datatype conversion was requested
     get the appropriate predefined datatype conversion routine
     in case the user didn't supply one by her own */
  conversion_fn = mapping->conversion_fn;
  if (vinfo.vartype != hdatatype)
  {
    if (conversion_fn == NULL)
    {
      conversion_fn = PUGHSlabi_GetDatatypeConversionFn (vinfo.vartype,
                                                         hdatatype);
      if (! conversion_fn)
      {
        CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
                    "No predefined PUGHSlab routine available to convert "
                    "'%s' into '%s'", CCTK_VarTypeName (vinfo.vartype),
                    CCTK_VarTypeName (hdatatype));
        return (-1);
      }
    }
  }
  else if (conversion_fn)
  {
    CCTK_WARN (8, "Datatype conversion routine supplied but no datatype "
                  "conversion requested. Ignoring conversion routine...");
    conversion_fn = NULL;
  }

  /* diagonals from 3D variables are treated special */
  if (mapping->is_diagonal_in_3D)
  {
    retval = GetDiagonalFromFrom3D (GH, mapping, vindex, timelevel, hdatatype,
                                    conversion_fn, hdata);
    return (retval);
  }

  /* allocate the temporary arrays */
  point          = malloc (5 * vinfo.dim * sizeof (int));
  startpoint     = point + 1*vinfo.dim;
  endpoint       = point + 2*vinfo.dim;
  downsample     = point + 3*vinfo.dim;
  points_per_dim = point + 4*vinfo.dim;

  memcpy (startpoint, mapping->local_startpoint, vinfo.dim * sizeof (int));
  memcpy (endpoint, mapping->local_endpoint, vinfo.dim * sizeof (int));
  memcpy (downsample, mapping->downsample, vinfo.dim * sizeof (int));

  /* get the pGH pointer and the variable's GA structure */
  pughGH = PUGH_pGH (GH);
  GA     = (pGA *) pughGH->variables[vindex][timelevel];

  /* nested loop over vinfo.dim dimensions */
  /* NOTE: the following code assumes startpoint[vdim] < endpoint[vdim] */
  if (mapping->is_full_hyperslab && conversion_fn == NULL)
  {
    memcpy (hdata, vdata, mapping->totals * CCTK_VarTypeSize (vinfo.vartype));
  }
  else
  {
    /* get the byte size of a single data point
       in the variable and hyperslab data array */
    vdata_size = CCTK_VarTypeSize (vinfo.vartype);
    hdata_size = CCTK_VarTypeSize (hdatatype);

    typed_hdata = (char *) hdata;

    /* compute the points_per_dim[] vector */
    /* NOTE: this could be computed at startup and kept in a GH extension
             once we have one for thorn PUGHSlab */
    points_per_dim[0] = 1;
    for (vdim = 1; vdim < vinfo.dim; vdim++)
    {
      points_per_dim[vdim] = points_per_dim[vdim-1] *
                             GA->extras->lnsize[vdim-1];
    }

    /* get the number of hyperslab points in lowest dimension
       and their size in bytes */
    dim0_points = (endpoint[0] - startpoint[0]) / downsample[0];
    if ((endpoint[0] - startpoint[0]) % downsample[0])
    {
      dim0_points++;
    }
    dim0_hsize = dim0_points * hdata_size;

    /* transform the ranges into byte ranges */
    for (i = 0; i < vinfo.dim; i++)
    {
      startpoint[i] *= vdata_size;
      endpoint[i]   *= vdata_size;
      downsample[i] *= vdata_size;
    }

    /* initialize the index vector to the local startpoint */
    memcpy (point, startpoint, vinfo.dim * sizeof (point[0]));

    /* do the nested loops starting with the innermost */
    vdim = 1;
    while (1)
    {
      /* check for end of current loop */
      if (vinfo.dim > 1 && point[vdim] >= endpoint[vdim])
      {
        /* increment outermost loopers */
        for (vdim++; vdim < vinfo.dim; vdim++)
        {
          point[vdim] += downsample[vdim];
          if (point[vdim] < endpoint[vdim])
          {
            break;
          }
        }

        /* done if beyond outermost loop */
        if (vdim >= vinfo.dim)
        {
          break;
        }

        /* reset innermost loopers */
        for (vdim--; vdim > 0; vdim--)
        {
          point[vdim] = startpoint[vdim];
        }
        vdim = 1;
      }

      /* get the byte pointer into the source array */
      typed_vdata = (const char *) vdata + point[0];
      for (i = 1; i < vinfo.dim; i++)
      {
        typed_vdata += point[i] * points_per_dim[i];
      }

      /* copy the data in lowest dimension: if possible copy all data points
         in a row otherwise do it one by one */
      if (downsample[0] == vdata_size)
      {
        if (conversion_fn)
        {
          if (conversion_fn (dim0_points, 1, 1, vinfo.vartype, hdatatype,
                             typed_vdata, typed_hdata) != dim0_points)
          {
            CCTK_WARN (1, "datatype conversion routine failed");
          }
        }
        else
        {
          memcpy (typed_hdata, typed_vdata, dim0_hsize);
        }
      }
      else
      {
        if (conversion_fn)
        {
          if (conversion_fn (dim0_points,  mapping->downsample[0], 1,
                             vinfo.vartype, hdatatype, typed_vdata,
                             typed_hdata) != dim0_points)
          {
            CCTK_WARN (1, "datatype conversion routine failed");
          }
          typed_vdata += downsample[0] * dim0_points;
        }
        else
        {
          for (i = 0; i < dim0_hsize; i += hdata_size)
          {
            memcpy (typed_hdata + i, typed_vdata, vdata_size);
            typed_vdata += downsample[0];
          }
        }
      }
      typed_hdata += dim0_hsize;

      if (vinfo.dim > 1)
      {
        /* increment current looper */
        point[vdim] += downsample[vdim];
      }
      else
      {
        /* exit loop if hyperslab dim is only 1D */
        break;
      }

    } /* end of nested loops over all dimensions */
  } /* end of branch extracting the hyperslab data */

  /* free allocated temporary memory */
  free (point);

  return (0);
}


static int GetDiagonalFromFrom3D (const cGH *GH,
                                  const hslab_mapping_t *mapping,
                                  int vindex,
                                  int timelevel,
                                  int hdatatype,
                                  t_hslabConversionFn conversion_fn,
                                  void *hdata)
{
  int i, j, k, myproc, linear_idx;
  int vdatatype, hdata_size, vdata_size;
  const char *vdata;
  const pGExtras *extras;


  /* get the variable's GA structure */
  extras = ((const pGA *) PUGH_pGH (GH)->variables[vindex][timelevel])->extras;

  vdatatype = CCTK_VarTypeI (vindex);
  hdata_size = CCTK_VarTypeSize (hdatatype);
  vdata_size = CCTK_VarTypeSize (vdatatype);
  vdata = CCTK_VarDataPtrI (GH, timelevel, vindex);

  myproc = CCTK_MyProc (GH);

  i = mapping->global_startpoint[0] - extras->lb[myproc][0];
  j = mapping->global_startpoint[1] - extras->lb[myproc][1];
  k = mapping->global_startpoint[2] - extras->lb[myproc][2];
  while (i < extras->ownership[0][1][0] &&
         j < extras->ownership[0][1][1] &&
         k < extras->ownership[0][1][2])
  {
    if (i >= extras->ownership[0][0][0] &&
        j >= extras->ownership[0][0][1] &&
        k >= extras->ownership[0][0][2])
    {
      linear_idx = i + j*extras->hyper_volume[1] + k*extras->hyper_volume[2];
      if (conversion_fn)
      {
        if (conversion_fn (1, 1, 1, vdatatype, hdatatype,
                           vdata + linear_idx*vdata_size, hdata) != 1)
        {
          CCTK_WARN (1, "datatype conversion routine failed");
        }
      }
      else
      {
        memcpy (hdata, vdata + linear_idx*vdata_size, hdata_size);
      }
      hdata = (char *) hdata + hdata_size;
    }
    i += mapping->downsample[0];
    j += mapping->downsample[1];
    k += mapping->downsample[2];
  }

  return (0);
}


#ifdef CCTK_MPI
static void SortIntoUnchunkedHyperslab (const hslab_mapping_t *mapping,
                                        int nprocs, int hdata_size,
                                        const void *chunked_hdata,
                                        void *unchunked_hdata)
{
  int i, j, proc, linear_hoffset;
  int *point, *points_per_hdim;
  char *copy_to;
  const char *copy_from;
  const CCTK_INT *hsize_chunk, *hoffset_chunk;


  /* allocate temporary vectors */
  point = malloc (2 * mapping->hdim * sizeof (int));
  points_per_hdim = point + mapping->hdim;

  points_per_hdim[0] = 1;
  for (i = 1; i < mapping->hdim; i++)
  {
    points_per_hdim[i] = points_per_hdim[i-1] * mapping->global_hsize[i-1];
  }

  /* use char pointers for easy incrementing when copying */
  copy_from = (const char *) chunked_hdata;
  copy_to   = (char *) unchunked_hdata;

  /* now copy the chunks from each processor into the global hyperslab */
  for (proc = 0; proc < nprocs; proc++)
  {
    /* get the pointers to processor i's chunk offset and size */
    hoffset_chunk = mapping->chunk + proc * (2*mapping->hdim+1);
    hsize_chunk = hoffset_chunk + mapping->hdim;

    /* skip processors which didn't contribute any data */
    if (hsize_chunk[mapping->hdim] <= 0)
    {
      continue;
    }

    /* set startpoint to zero */
    memset (point, 0, mapping->hdim * sizeof (int));

    i = 1;
    while (1)
    {
      /* check for end of current loop */
      if (point[i] >= hsize_chunk[i])
      {
        /* increment outermost loopers */
        for (i++; i < mapping->hdim; i++)
        {
          if (++point[i] < hsize_chunk[i])
          {
            break;
          }
        }

        /* done if beyond outermost loop */
        if (i >= mapping->hdim)
        {
          break;
        }

        /* reset innermost loopers */
        for (i--; i > 0; i--)
        {
          point[i] = 0;
        }
        i = 1;
      }

      /* get the linear offset */
      linear_hoffset = hoffset_chunk[0];
      for (j = 1; j < mapping->hdim; j++)
      {
        linear_hoffset += (hoffset_chunk[j] + point[j]) * points_per_hdim[j];
      }
      /* copy the line */
      memcpy (copy_to + linear_hoffset * hdata_size, copy_from,
              hsize_chunk[0] * hdata_size);
      copy_from += hsize_chunk[0] * hdata_size;

      /* increment current looper */
      point[i]++;

    } /* end of nested loops over all dimensions */
  } /* end of loop over all processors */

  /* free allocated temporary vectors */
  free (point);
}
#endif