next up previous 252
Next: CHARACTER and LOGICAL Arrays
Up: CNF and F77 Mixed Language Programming - FORTRAN and C
Previous: More on Calling FORTRAN from C


More on Arrays

For most data types arrays are handled simply, using pointers as already demonstrated. However, for arrays of some types the data in the arrays must be converted back and forth between C and FORTRAN representations. Macros and functions are provided to facilitate the conversions.

Very often, the actual size of the FORTRAN array required will not be known until runtime so space for it must be allocated dynamically in a similar way to dynamic character strings.

Macros DECLARE_type_ARRAY_DYN and F77_CREATE_type_ARRAY are defined to do this. They are designed for 1-dimensional arrays, having just the name and the number of elements as parameters, but for Unix systems, at least, will work for multi-dimensional arrays.

For most types on all current systems, the CREATE_ARRAY macros will not actually allocate space as no conversion of data is necessary, but they are provided for contingency and completeness.





next up previous 252
Next: CHARACTER and LOGICAL Arrays
Up: CNF and F77 Mixed Language Programming - FORTRAN and C
Previous: More on Calling FORTRAN from C

CNF and F77 Mixed Language Programming -- FORTRAN and C
Starlink User Note 209
P.M. Allan
A.J. Chipperfield
R.F. Warren-Smith
19 January 2000
E-mail:ussc@star.rl.ac.uk