Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://xmm.vilspa.esa.es/sas/8.0.0/doc/ssclib/node61.html
Дата изменения: Wed Jul 2 03:52:40 2008 Дата индексирования: Fri Sep 5 18:38:32 2008 Кодировка: Поисковые слова: п п п п п п п п п п п п п п п п п п п п п п п п п п |
It is often useful to be able to read an array of any data type into a fortran array of a single data type. The following interface covers just about every combination I could think of.
interface readArrayData subroutine readArrayDataName1dReal32(imageSetName, vector) character(*), intent(in) :: imageSetName real(single), pointer :: vector(:) end subroutine readArrayDataName1dReal32 subroutine readArrayDataName2dReal32(imageSetName, image) character(*), intent(in) :: imageSetName real(single), pointer :: image(:,:) end subroutine readArrayDataName2dReal32 subroutine readArrayDataName3dReal32(imageSetName, cube) character(*), intent(in) :: imageSetName real(single), pointer :: cube(:,:,:) end subroutine readArrayDataName3dReal32 subroutine readArrayDataName1dReal64(imageSetName, vector) character(*), intent(in) :: imageSetName real(double), pointer :: vector(:) end subroutine readArrayDataName1dReal64 subroutine readArrayDataName2dReal64(imageSetName, image) character(*), intent(in) :: imageSetName real(double), pointer :: image(:,:) end subroutine readArrayDataName2dReal64 subroutine readArrayDataName3dReal64(imageSetName, cube) character(*), intent(in) :: imageSetName real(double), pointer :: cube(:,:,:) end subroutine readArrayDataName3dReal64 subroutine readArrayDataName2dBool(imageSetName, image) character(*), intent(in) :: imageSetName logical(bool), pointer :: image(:,:) end subroutine readArrayDataName2dBool subroutine readArrayDataName2dInt16(imageSetName, image) character(*), intent(in) :: imageSetName integer(int16), pointer :: image(:,:) end subroutine readArrayDataName2dInt16 subroutine readArrayDataName2dInt32(imageSetName, image) character(*), intent(in) :: imageSetName integer(int32), pointer :: image(:,:) end subroutine readArrayDataName2dInt32 subroutine readArrayDataArray1dReal32(inArray, vector) type(ArrayT), intent(in) :: inArray real(single), pointer :: vector(:) end subroutine readArrayDataArray1dReal32 subroutine readArrayDataArray2dReal32(inArray, image) type(ArrayT), intent(in) :: inArray real(single), pointer :: image(:,:) end subroutine readArrayDataArray2dReal32 subroutine readArrayDataArray3dReal32(inArray, cube) type(ArrayT), intent(in) :: inArray real(single), pointer :: cube(:,:,:) end subroutine readArrayDataArray3dReal32 subroutine readArrayDataArray1dReal64(inArray, vector) type(ArrayT), intent(in) :: inArray real(double), pointer :: vector(:) end subroutine readArrayDataArray1dReal64 subroutine readArrayDataArray2dReal64(inArray, image) type(ArrayT), intent(in) :: inArray real(double), dimension(:,:), pointer :: image end subroutine readArrayDataArray2dReal64 subroutine readArrayDataArray3dReal64(inArray, cube) type(ArrayT), intent(in) :: inArray real(double), dimension(:,:,:), pointer :: cube end subroutine readArrayDataArray3dReal64 subroutine readArrayDataArray2dBool(inArray, image) type(ArrayT), intent(in) :: inArray logical(bool), dimension(:,:), pointer :: image end subroutine readArrayDataArray2dBool subroutine readArrayDataArray2dInt16(inArray, image) type(ArrayT), intent(in) :: inArray integer(int16), dimension(:,:), pointer :: image end subroutine readArrayDataArray2dInt16 subroutine readArrayDataArray2dInt32(inArray, image) type(ArrayT), intent(in) :: inArray integer(int32), dimension(:,:), pointer :: image end subroutine readArrayDataArray2dInt32 end interface
Boolean values are converted to real or integer 0s and 1s; real or integer are converted to boolean TRUE if > 0, FALSE otherwise.
Where the dimensions of the dataset array don't match those of the to-be-returned pointer array, it is eventually intended to convert these as follows:
Dims: | Out 1 | Out2 | Out 3 |
In 1 | simple | ->image(1,:) | ->cube(1,1,:) |
In 2 | take 1st row | simple | -> cube(1,:,:) |
In 3 | take 1st row, 1st plane | take 1st plane | simple |
In >3 | not supported | not supported | not supported |
First rows or planes are always aligned with the biggest dimension(s).
However most of the inter-dimensional functionality is not yet in place.
Note that the returned pointer is not associated with any pointer allocated by a dal call such as, for example:
arrayDataReal32 => real32Array2Data(inArray)
Where readArrayData is called with the name of image dataset, the dataset is released within the subroutine, and all such dataset pointers are at that time deallocated; if readArrayData is called instead with the pointer inArray specified, the dataset and its array remain open, all dataset pointers which were allocated within the subroutine also remain allocated, but deallocate in the normal way at the time the calling routine releases the dataset (or its array). In either case, the returned pointer argument `vector', `image', or `cube' REMAINS ALLOCATED and therefore should be expressely deallocated in the calling routine via the fortran `deallocate' statement.
XMM-Newton SOC/SSC -- 2008-07-01