It is not required to know the total size of a FITS data array or table before beginning to write the data to the FITS file. In the case of the primary array or an image extension, one should initially create the array with the size of the highest dimension (largest NAXISn keyword) set to a dummy value, such as 1. Then after all the data have been written and the true dimensions are known, then the NAXISn value should be updated using the ffmkyj routine before moving to another extension or closing the FITS file.
A similar procedure may be used in the case of FITS tables, where the number of rows in the table (the NAXIS2 value) may initially be set to 1 and then updated with the correct value before closing the table. Alternatively, one may use the ffirow routine to insert additional rows into a table if the original value turns out to be too small. This latter method must be used if any of the columns contain variable length arrays.