With few limitations, you can use Prism to debug Fortran 90 programs containing the features described in this section.
With the exception of constructors, Prism supports derived types in Fortran 90. For example, given these declarations:
type point3 integer x,y,z; end type point3 type(point3) :: var,var2;
you can use Prism commands with these Fortran 90 variables:
(prism) print var (prism) whatis var (prism) whatis point3 (prism) assign var=var2 (prism) print var%x (prism) assign var%x = 70
Prism fully supports generic functions in Fortran 90. For example, given the generic function fadd, declared as follows:
interface fadd integer function intadd(i, j) integer*4, intent(in) :: i, j end function intadd real function realadd(x, y) real, intent(in) :: x, y end function realadd end interface
you can use Prism commands with these Fortran 90 generic functions:
(prism) p fadd(1,2) (prism) whatis fadd (prism) stop in fadd
In each case, Prism asks you which instance of fadd your command refers to: For example:
(prism) whatis fadd More than one identifier `fadd'. Select one of the following names: 0) Cancel 1) `f90_user_op_generic.exe`f90_user_op_generic.f90`fadd ! real*4 realadd 2) `f90_user_op_generic.exe`f90_user_op_generic.f90`fadd ! integer*4 intadd > 1 real*4 function fadd (x, y) (dummy argument) real*4 x (dummy argument) real*4 y
In addition to the standard assignment operator (=), Prism supports the new Fortran 90 pointer assignment operator =>. For example:
program pnode type node integer x,y type(node), pointer :: next end type node type(node), target :: n1,n2,n3 type(node), pointer :: pn1, pn2 ... pn1 => n1 pn2 => n2 i = 0 end
The following examples assume that a breakpoint has been set at the last statement, i = 0, and show how Prism supports Fortran 90 pointers:
print pn1 - Prints the value pointed to by pn1, in this case n1.
print pn1%x - Prints the value of the member x in the object pointed to by pn1 (in this case n1%x).
assign pn1%x = 3 - Assigns n1%x = 3.
assign pn1=n3 - Assigns n3 to the value pointed to by pn1 (this has the same effect as assign n1=n3).
assign pn1=>n3 - Makes pn1 point to n3.
assign pn1=>pn2 - Makes pn1 point to the same object as pn2.
If pn1 does not point to any value, an attempt to access it will result in an error message:
(prism) p pn1 Fortran variable is not allocated/associated.
You can find the state of a pointer using the whatis command. Assume pn1 has not been associated:
(prism) whatis pn1 node pn1 ! unallocated f90 pointer
Assume pn1 has been associated with a value:
(prism) whatis pn1 node pn1 ! f90 pointer
Prism supports pointers to arrays in the same way that it supports simple pointers. The Fortran 90 language constraints apply. For example, Fortran 90 allows pointer assignment between pointers to arrays. Assignment to arrays having different ranks is not allowed.
For example, given these declarations:
real, dimension(10), target :: r_arr1 real, dimension(20), target :: r_arr2 real, dimension(:), pointer :: p_arr1,p_arr2
you can use Prism commands with these Fortran 90 pointers to arrays:
(prism) print p_arr1 (prism) whatis p_arr2 (prism) assign p_arr1 => r_arr1 (prism) assign p_arr1(1:2) = 7
Prism does not handle Fortran 90 pointers to array sections correctly. For example,
array_ptr => some_array(1:10:3)
Prism will print some elements of the array, although it will not print the correct elements or the correct number of elements.
Prism supports allocatable arrays in the same way that it supports pointers to arrays. Fortran 90 support includes the Prism commands print and whatis. Prism also supports slicing and striding Fortran 90 allocatable arrays. For example, to print a section of allocatable array alloc_array:
(prism) print alloc_array(1:30:2)
Fortran 90 language constraints apply. For example, Fortran 90 allows allocating or deallocating memory for an allocatable array but does not allow making an allocatable array point to another object. Therefore, Prism does not recognize pointer assignment, =>, to allocatable arrays.
Prism supports Fortran 90 operations on arrays or array sections, and assignment to continuous sections of arrays.
(prism) assign a=b+c (prism) assign a(3:7)=b(2:10:2)+c(8:8)
Prism supports Fortran 90 masked print statements:
(prism) where (arr>0) print arr
The Prism whatis command shows variable attributes. These attributes include allocated and associated attributes for pointers, or the (function variable) attribute displayed for a RESULT variable in Fortran 90. For example, given this declaration:
function inc(i) result(j) integer i; integer k; integer j; k = i+1 j = k end function inc
the whatis command displays the function variable attribute of j:
(prism) whatis j (function variable) integer*4 j