Difference between revisions of "Special Subroutines"

From LIBISIS
Jump to navigation Jump to search
Line 36: Line 36:
  
 
===IXFalloc===
 
===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===
 
===IXFrealloc===
 
===IXFallocdims===
 
===IXFallocdims===

Revision as of 13:31, 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

IXFallocdims

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