Victor

Thanks so much for your response. I am having some troubles with it though.

I have posted my efforts on to a web site to avoid copying large amounts of

code into the message - it's not very long but I thought it would be

cleaner.

http://www.tompagenet.co.uk/fits.php
there are links on the right to my original code (as hinted at in my first

post) and the code that I created after your suggestions. The new code fails

to run, almost certainly because of the:

fits_write_img(fptr, TDOUBLE, fpixel, nelements, array[0][0], &status)line

in the code. This calls an external procedure (one of the CFITSIO

procedures -

http://heasarc.gsfc.nasa.gov/docs/so...io/fitsio.html
for those who are interested).The trouble is that this appears to expect an

array of the form array[0][0] (which is two dimensional, but then it knows

it is three dimensional and works out the third dimension by using the

nelements argument which explains the total number of elements and thus if

you know two dimensions it can calculate the third.Should it be of

importance, these are the argements both procedures take:* wldepth - the

size of the dynamic array dimension (the other two are of static size

griddef)* inarray[][griddef][griddef] - the inputed array (basically the

data to write out by the procedure seen above)* line - a number that simply

alters the filename (irrelevant)* type - ditto (irrelevant)Thanks for any

help with this, it is very much appreciated!Thanks, Tom

"Victor Bazarov" <(E-Mail Removed)> wrote in message

news:YPcYb.46506$_44.44246@attbi_s52...

> "Tom Page" <(E-Mail Removed)> wrote...

>> Hello all

>>

>> I have a question that may or may not be simple - I need my three

>> dimensional array to be of the form:

>>

>> array[jj][kk][ii]

>>

>> where jj and kk range from 0 to some constant fixed at the very

>> beginnning

>> of the program (currently 20) but [ii] goes from 0 to some boundary that

>> depends on calculations performed within the program. I know it is

> possible

>> to do this:

>>

>> double (*somearray)[fixed][fixed]= new double[variable

>> expression][fixed][fixed]

>>

>> but can I have the last subscript as variable? - this is not just a

> question

>> of hypothetics, but a need to have the data in this format as an external

>> procedure expects the data with the first and second dimensions to be one

>> type of data (which has a fixed size) and the third dimension to have a

>> variable size.

>

> There are several ways to skin your cat. You can have a two-dimensional

> array of vector<double>. You can have an array of pointers each of which

> is dynamically allocated, almost like you did below (I snipped it, but you

> know what I am talking about), you just need to do

>

> double *tda[fixed1][fixed2], **ptda = &tda[0][0];

> for (int i = 0; i < fixed1 * fixed2; ++i)

> ptda[i] = new double[variable];

>

> thus allocating 'variable' doubles for each of tda elements. Now access

> them using

>

> tda[jj][kk][ii]

>

>> [...]

>

> Also take a look at the FAQ, see "Dynamic multidimensional arrays".

>

> Victor

>

>