SIDL r-arrays are passed to and from methods as normal FORTRAN 90 arrays. You do not need to include the index variables because the values are determined from the FORTRAN 90 array extents in each dimension.
The client-side interface for the solve example introduced in Section 5.4 behaves as if it is a FORTRAN 77 function with the following overloaded interface:
private :: solve_1s, solve_2s interface solve module procedure solve_1s, solve_2s end interface recursive subroutine solve_1s(self, A, x, exception) implicit none ! in num.Linsol self type(num_Linsol_t) , intent(in) :: self ! in array<double,2,column-major> A type(sidl_double_2d) , intent(in) :: A ! inout array<double,column-major> x type(sidl_double_1d) , intent(inout) :: x ! out sidl.BaseInterface exception type(sidl_BaseInterface_t) , intent(out) :: exception end subroutine solve_1s recursive subroutine solve_2s(self, A, x, exception) implicit none ! in num.Linsol self type(num_Linsol_t) , intent(in) :: self ! in rarray<double,2> A(m,n) real (kind=sidl_double) , intent(in), dimension(:, :) :: A ! inout rarray<double> x(n) real (kind=sidl_double) , intent(inout), dimension(:) :: x ! out sidl.BaseInterface exception type(sidl_BaseInterface_t) , intent(out) :: exception ! in int m integer (kind=sidl_int) :: m ! in int n integer (kind=sidl_int) :: n end subroutine solve_2s
You can use either normal FORTRAN 90 arrays or normal SIDL arrays when calling a FORTRAN 90 method, but you cannot use a mixture.
The server-side interface for solve is similar. Note, the lower index each dimension of every incoming array is always zero.
recursive subroutine num_Linsol_solve_mi(self, A, x, m, n, exception) use sidl use sidl_BaseInterface use sidl_RuntimeException use num_Linsol use sidl_double_array use num_Linsol_impl ! DO-NOT-DELETE splicer.begin(num.Linsol.solve.use) ! Insert-Code-Here {num.Linsol.solve.use} (use statements) ! DO-NOT-DELETE splicer.end(num.Linsol.solve.use) implicit none type(num_Linsol_t) :: self ! in integer (kind=sidl_int) :: m ! in integer (kind=sidl_int) :: n ! in type(sidl_BaseInterface_t) :: exception ! out real (kind=sidl_double), dimension(0:m-1, 0:n-1) :: A ! in real (kind=sidl_double), dimension(0:n-1) :: x ! inout ! DO-NOT-DELETE splicer.begin(num.Linsol.solve) ! Insert-Code-Here {num.Linsol.solve} (solve method) ! DO-NOT-DELETE splicer.end(num.Linsol.solve) end subroutine num_Linsol_solve_mi
For normal SIDL arrays, 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, 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.
use sidl type sidl_double_2d sequence integer (kind=sidl_arrayptr) :: d_array real (kind=sidl_double), pointer, & dimension(:,:) :: d_data end type sidl_double_2d type sidl_double_3d sequence integer (kind=sidl_arrayptr) :: d_array real (kind=sidl_double), 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, or create2dCol, to create a new array. These SIDL routines initialize d_data to refer to the data allocated in d_array. Note, create1d, create2dRow, and create2dCol create arrays whose lower index is 0 not 1. To create arrays with a lower index of 1, use createCol or createRow.
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. When an array is sliced, the resulting array might not even have one densely packed dimension.
In F90, generic arrays are represented as the derived type sidl__array. Note there are two underscores in sidl__array. The derived type is defined in the sidl_array_type module, and the generic array subroutines are defined in the sidl_array_array module which declared: addRef, deleteRef, dimen, type, isColumnOrder, isRowOrder, is_null, no_null, set_null, lower, upper, length, stride, and smartCopy. The F90 binding includes a cast subroutine to can from a generic array to an array of a particular type and dimension and vice versa.