LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: Neil Storer (Neil.Storer_at_[hidden])
Date: 2005-03-10 13:37:37


Ravi,

You came to the static array solution yourself prior to my previous
e-mail. That e-mail explains why the dynamic one you were using doesn't
work.

To get a dynamic allocation solution you could do the following:

Dynamically allocate a single dimension array (let's call it "contig")of
ln*br*thk ints.

        int *contig;
        contig = new int[ln*br*thk];

Then instead of saying:

        for(j=0;j<br;j++)
        A[i][j] = new int[ln];

say:
        int *ptr;
        ptr = contig;
        for(j=0;j<br;j++)
        {
           A[i][j] = ptr;
           ptr+= ln;
        }

This will ensure that the integers values in A are contiguous.

Good luck.

Neil

By the way, forget my stuff about little-endian. LAM-MPI sorts it out. It would be a problem though if you wanted to write the array to a binary file, but that's another matter.

-- 
+-----------------+---------------------------------+------------------+
| Neil Storer     |    Head: Systems S/W Section    | Operations Dept. |
+-----------------+---------------------------------+------------------+
| ECMWF,          | email: neil.storer_at_[hidden]    |    //=\\  //=\\  |
| Shinfield Park, | Tel:   (+44 118) 9499353        |   //   \\//   \\ |
| Reading,        |        (+44 118) 9499000 x 2353 | ECMWF            |
| Berkshire,      | Fax:   (+44 118) 9869450        | ECMWF            |
| RG2 9AX,        |                                 |   \\   //\\   // |
| UK              | URL:   http://www.ecmwf.int/    |    \\=//  \\=//  |
+--+--------------+---------------------------------+----------------+-+
   | ECMWF is the European Centre for Medium-Range Weather Forecasts |
   +-----------------------------------------------------------------+