Difference between revisions of "Special Subroutines"

From LIBISIS
Jump to navigation Jump to search
Line 106: Line 106:
  
 
===IXFallocdims===
 
===IXFallocdims===
 +
 +
 +
This routine will allocate space to a 2/3/4-dimensional array pointer contained in a class In the following example the class used must contain an array_pointer element in its definition of appropriate dimensionality.
 +
 +
 +
 +
'''F90 SYNTAX'''
 +
 +
 +
type IXTclass
 +
  integer(i4b),pointer::array2d_pointer(:,:)=>NULL()
 +
  integer(i4b),pointer::array3d_pointer(:,:,:)=>NULL()
 +
end type IXTclass
 +
:
 +
 +
type(IXTclass)::object
 +
 +
type(IXTstatus)::status
 +
 +
integer(i4b) :: dim_2(2),dim_3(3)
 +
allocates an n-dimensional array (n=2,3,4) depending on length of appropriately filled dimension array
 +
object%array_pointer must be of appropriate dimensionality
 +
 +
dim_2=(/ 200,100 /)
 +
dim_3=(/ 300,200,100 /)
 +
 +
! allocates a 200 by 100 element array
 +
call IXFallocdims(object%array2d_pointer,dim_2,status)
 +
call IXFallocdims(object%array2d_pointer,(/ 200,100 /),status)
 +
 +
! allocates a 300 by 200 by 100 element array
 +
call IXFallocdims(object%array3d_pointer,dim_3,status)
 +
call IXFallocdims(object%array3d_pointer,(/ 300,200,100 /),status)
 +
 
===IXFreallocdims===
 
===IXFreallocdims===
 
===IXFdealloc===
 
===IXFdealloc===

Revision as of 13:33, 2 April 2008

Memory Specific

There are three types of arrays used in the data structure and associated subroutines:


  • Array pointers
  • Allocatable arrays of objects
  • Standard FORTRAN allocatable arrays


Standard Fortran arrays are not declared as elements in the data structures but can be used temporarily in subroutines. There is a set of subroutines which can be used in these types as well as the built-in functions allocate() and deallocate().

Valid Functions

The following subroutines are valid for certain types of array of type real and integer:


array pointers and arrays of objects:

  • IXFalloc for arrays and arrays of objects
  • IXFrealloc for arrays and arrays of objects
  • IXFallocdims for arrays only
  • IXFreallocdims for arrays only
  • IXFdealloc for arrays and arrays of objects


standard FORTRAN allocatable arrays of type real and integer

  • IXFallocFortran
  • IXFreallocFortran
  • IXFallocdimsFortran
  • IXFreallocdimsFortran
  • IXFdeallocFortran


IXFalloc

This routine will allocate space to an n-dimensional array pointer (n=1-4) contained in a class, or allocate an allocatable array of objects (1 dimension only). If an array pointer is an argument it will assign matlab or fortran memory depending on which level access to the library is made from. Allocatable arrays of objects are not mirrored in matlab memory in the same way, so allocation is dealt with purely in fortran.


In the following example the class used must contain an array_pointer element in its definition. real & integer types are valid

F90 SYNTAX

 type IXTclass
 integer(i4b),pointer::array_pointer(:)=>NULL()
 integer(i4b),pointer::array2d_pointer(:,:)=>NULL()
 integer(i4b),pointer::array3d_pointer(:,:,:)=>NULL()
 integer(i4b),pointer::array4d_pointer(:,:,:,:)=>NULL()
end type IXTclass
:
type(IXTclass)::object
type(IXTclass),allocatable::object_array(:)

type(IXTstatus)::status

integer(i4b) :: n1,n2,n3,n4

n1=25

! allocates object%array_pointer to a length 25 etc...
call IXFalloc(object%array_pointer,n1,status)
call IXFalloc(object%array2d_pointer,n1,n2,status)
call IXFalloc(object%array3d_pointer,n1,n2,n3,status)
call IXFalloc(object%array4d_pointer,n1,n2,n3,n4,status)

! allocates an array of 25 objects
call IXFalloc(object_array,n1,status)

IXFrealloc

This routine will reallocate space to a 1-dimensional array pointer contained in a class, or reallocate an allocatable array of objects. If the array pointer is unallocated then IXFalloc will be called internally. If the array is already allocated, the array length will be adjusted to the new length, and the contents preserved if the preserve argument is '.true.'.


If an array pointer is an argument it will assign matlab or fortran memory depending on which level access to the library is made from. Allocatable arrays of objects are not mirrored in matlab memory in the same way, so allocation is dealt with purely in fortran.


F90 SYNTAX

type IXTclass
 integer(i4b),pointer::array_pointer(:)=>NULL()
end type IXTclass
:
type(IXTclass)::object
type(IXTclass),allocatable::object_array(:)

type(IXTstatus)::status

integer(i4b) :: size_of_array

logical::preserve

size_of_array=25 

! reallocates object%array_pointer to a length 25
call IXFrealloc(object%array_pointer,size_of_array,preserve,status)

! reallocates an array of 25 objects
call IXFrealloc(object_array,size_of_array,preserve,status)

IXFallocdims

This routine will allocate space to a 2/3/4-dimensional array pointer contained in a class In the following example the class used must contain an array_pointer element in its definition of appropriate dimensionality.


F90 SYNTAX


type IXTclass
 integer(i4b),pointer::array2d_pointer(:,:)=>NULL()
 integer(i4b),pointer::array3d_pointer(:,:,:)=>NULL()
end type IXTclass
:

type(IXTclass)::object

type(IXTstatus)::status

integer(i4b) :: dim_2(2),dim_3(3)
allocates an n-dimensional array (n=2,3,4) depending on length of appropriately filled dimension array
object%array_pointer must be of appropriate dimensionality

dim_2=(/ 200,100 /)
dim_3=(/ 300,200,100 /)

! allocates a 200 by 100 element array
call IXFallocdims(object%array2d_pointer,dim_2,status)
call IXFallocdims(object%array2d_pointer,(/ 200,100 /),status)

! allocates a 300 by 200 by 100 element array
call IXFallocdims(object%array3d_pointer,dim_3,status)
call IXFallocdims(object%array3d_pointer,(/ 300,200,100 /),status)

IXFreallocdims

IXFdealloc

IXFallocFortran

IXFreallocFortran

IXFallocdimsFortran

IXFreallocdimsFortran

IXFdeallocFortran

Validity

Valid Functions

When an object has been properly populated with real data which is self-consistent it is marked as being 'valid'. There are routines to determine an objects validity and to mark an object as valid. These operations can only be used on objects which contain an IXTbase object.

  • IXFvalid for objects and arrays of objects

Subroutines which can only be used within class methods of object

  • IXFmark_valid for objects and arrays of objects
  • IXFclear_valid for objects and arrays of objects


IXFvalid

IXFmark_valid

IXFclear_valid

other

IXFdisplay IXFpopulate_file