Prism 6.0 provides support for debugging Fortran 90 programs. This chapter describes the degree of support for Fortran 90 provided by Prism commands.
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
With significant limitations, you can use Prism to debug Fortran 90 programs containing the features described in this section.
Prism views user-defined operators as functions. If a new operator . my_op. appears in a Fortran 90 program, then Prism cannot deal with the operator . my_op. as an operator, but it can deal with the function my_op, viewed as a generic function. You cannot use operators named * (or +, or any other keyword operator.), but you can stop in functions that are used to define such operators. For example:
interface operator(.add_op.) integer function int_add(i, j) integer*4, intent(in) :: i, j end function int_add real function real_add(x, y) real, intent(in) :: x, y end function real_add end interface
In this example, Prism does not support debugging the user defined function .add_op.
(prism) print 1 .add_op. 2
However, Prism supports the function add_op:
(prism) print add_op(1,2)
A list pops up, allowing you to choose which add_op to apply.
The following commands can take internal procedure names as arguments:
stop in
whatis
If there are several procedures with the same name, a list pops up from which to select the desired procedure.
Prism supports the same intrinsics in Fortran 90 that it supports in Fortran 77. See " Using Fortran Intrinsic Functions in Expressions".
You cannot use Prism to debug Fortran 90 programs containing the features described in this section.
Prism does not support constructors for derived types.
type point3 integer x,y,z;end type point3 type(point3) :: var,var2;
Prism does support assignment to derived types, however. For example:
(prism) assign var = var2
Although Fortran 90 allows the use of constructors, Prism does not support them. The following example is not supported:
(prism) assign var = point3(1,2,3)
If the generic function is defined in the current module, such as:
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
then only references to the fadd are supported, but references to specific functions that define fadd are not. For example:
(prism) whatis intadd prism: "intadd" is not defined in the scope `f90_user_op_generic.exe`f90_user_op_generic.f90`main`
The error checking involved by the semantics of the => operator is not fully supported. If your program causes an illegal pointer assignment, Prism might not issue any error, and the behavior of the program will be undefined.
Prism does not print the result of an array-valued function.