Accessing SIDL Arrays From FORTRAN 90

The normal SIDL C function API is available from FORTRAN 90 to create, destroy, and access array elements and meta-data. The array routines are in a module. For sidl.SIDLException, the array module is named sidl_SIDLException_array, and the array module is defined in the sidl_SIDLException_array.F90.

For SIDL types dcomplex, double, fcomplex , float, int, and long, SIDL provides an array pointer to get direct access to the array elements. For the other types, you must use the functional API to access array elements.

The SIDL derived type for a SIDL array is named after the class, interface or basic type that it holds and the dimension of the array. For sidl.SIDLException, the array derived types are named sidl_SIDLException_1d, sidl_SIDLException_2d, sidl_SIDLException_3d, $\ldots$ up to sidl_SIDLException_7d. For the basic types, they are treated as sidl.dcomplex, sidl.double, sidl.fcomplex, etc. Each of these derived types has a 64 bit integer to hold an opaque pointer.

The derived type for SIDL types dcomplex, double, fcomplex , float, int, and long also has a pointer to an array of the appropriate type and dimension. For example, here is the derived type for 2d and 3d arrays of doubles.


  type sidl_double_2d
    sequence
    integer (selected_int_kind(18)) :: d_array
    real (selected_real_kind(15, 307)), pointer, &
      dimension(:,:) :: d_data
  end type sidl_double_2d

  type sidl_double_3d
    sequence
    integer (selected_int_kind(18)) :: d_array
    real (selected_real_kind(15, 307)), pointer, &
      dimension(:,:,:) :: d_data
  end type sidl_double_3d

You can access the array with the F90 array pointer d_data just like any other F90 array. However, you must not use the F90 builtins allocate or deallocate on d_data. You must use SIDL functions createCol, createRow, create1d, create2dRow, create2dCol to create a new array. These SIDL routines initialize d_data to refer to the data allocated in d_array.

You can call things like LINPACK or BLAS if you want, but you should check the stride to make sure the array is packed as needed. You can check stride(i), which indicates the distance between elements in dimension i. A value of 1 means elements are packed densely in dimension i. Negative stride values are possible, and when an array is a slice of another array, there may be no dimension with a stride of 1.



babel-0.9.4
users_guide Last Modified 2004-08-17

http://www.llnl.gov/CASC/components
components@llnl.gov