3 Message, & ! in, optional
4 Messages, & ! in, optional
5 MaxNoCalls) ! in, optional
9 !--------------------------------------------------------------------
10 ! Purpose: General trace within a subroutine
11 !--------------------------------------------------------------------
13 character (len=*), intent(in) :: Name ! Subroutine name
14 character (len=*), optional, intent(in) :: Message ! Text to trace
15 character (len=*), optional, intent(in) :: Messages(:) ! Text to trace
16 integer, optional, intent(in) :: MaxNoCalls ! max no calls to show
18 integer :: IOStatus ! I-O return code
19 integer :: Loop ! General loop counter
21 integer :: LocalMaxNoCalls
22 character(len=25) :: Change
24 !-----------------------------------------------------------------------
25 ! Check whether trace active and depth of trace
26 !-----------------------------------------------------------------------
28 if (.NOT. TraceActive) then
32 if (TraceDepth >= trace_max_depth) then
33 ! already at maximum depth, so return
37 !-----------------------------------------------------------------------
39 !-----------------------------------------------------------------------
43 if (trace_memory) then
46 if (LastSpace < TotalSpace) then
47 write(Change,"(A9,I12)")", bigger", TotalSpace - LastSpace
48 else if (LastSpace > TotalSpace) then
49 write(Change,"(A9,I12)")", smaller", TotalSpace - LastSpace
51 if (MaxHeap(Pointer) < TotalSpace) then
52 MaxHeap(Pointer) = TotalSpace
54 LastSpace = TotalSpace
59 !-----------------------------------------------------------------------
60 ! Perform the trace if not done too many times before. only on PE 0
61 !-----------------------------------------------------------------------
65 if (present(MaxNoCalls)) then
66 LocalMaxNoCalls = MaxNoCalls
68 LocalMaxNoCalls = trace_repeat_body
71 NoCallsBody(Pointer) = NoCallsBody(Pointer)+1
73 if (NoCallsBody(Pointer) <= LocalMaxNoCalls) then
74 if (trace_memory) then
76 write (unit=trace_unit, &
77 fmt='(A, "| <a href=",A,"/",A,".html>",A,"</a>",I11,A)', &
79 pad(1:TraceDepth*TraceIndentAmount),trim(Documentation_url), &
80 trim(Name), trim(Name), TotalSpace, Change
82 write (unit=trace_unit, &
83 fmt='(A, "| ",A,I11,A)', &
85 pad(1:TraceDepth*TraceIndentAmount),trim(Name), TotalSpace, Change
89 write (unit=trace_unit, &
90 fmt='(A, "| <a href=",A,"/",A,".html>",A,"</a>")', &
92 pad(1:TraceDepth*TraceIndentAmount),trim(Documentation_url), &
93 trim(Name), trim(Name)
95 write (unit=trace_unit, &
98 pad(1:TraceDepth*TraceIndentAmount),trim(Name)
101 if (IOStatus /= 0) then
102 call da_error(__FILE__,__LINE__, &
103 (/"Cannot write to trace file for "//Name/))
106 if (present(Message)) then
107 write (unit=trace_unit, fmt='(A," ",A)', iostat=IOStatus) &
108 pad(1:TraceDepth*TraceIndentAmount),trim(Message)
109 if (IOStatus .NE. 0) then
110 call da_error(__FILE__,__LINE__, &
111 (/"Cannot write to trace file for "//Name/))
115 if (present(Messages)) then
116 do Loop = 1, size(Messages)
117 write (unit=trace_unit, fmt='(A," ",A)', iostat=IOStatus) &
118 pad(1:TraceDepth*TraceIndentAmount),trim(Messages(Loop))
119 if (IOStatus .NE. 0) then
120 call da_error(__FILE__,__LINE__, &
121 (/"Cannot write to trace file for "//Name/))
127 if (NoCallsBody(Pointer) == trace_repeat_body) then
128 write (unit=trace_unit, fmt='(A," Called enough, going quiet")', iostat=IOStatus) &
129 pad(1:TraceDepth*TraceIndentAmount)
130 if (IOStatus .NE. 0) then
131 call da_error(__FILE__,__LINE__, &
132 (/"Cannot write to trace file for "//Name/))
137 end subroutine da_trace