I define constants absent=0, read=1, global=2, local=3. All statuses are
set to
absent, then changed when read from file, calculated for global (ie
until end of program) use, or local use. For local use you take the
status from the calling routine and increment it before using it. At the
end of a routine its then a simple matter of calling tidy routine that
checks all statuses and deletes all variables with its status level or
higher. At the end of the program you call the routine with status 1 to
get read of everything.
Regarding tracing every routine has lines top and bottom
IF (UseTrace) CALL Gen_TraceEntry(RoutineName)
....
IF (UseTrace) CALL Gen_TraceEntry(RoutineName)
with at key points in the code
IF (UseTrace) CALL Gen_Trace(RoutineName,'just done blah')
The IF blocks are used to allow tracing to be switched off at run time
with
minimum impact.
The trace routines monitor memory usage using a c routine that picks up
mallinfo.uordblks, CPU time from a c routine that monitors the times
function,
and elapsed time using F90 routine SYSTEM_CLOCK. I am only interested in
total
memory, not which array its gone into.
Each call adds a few more lines to a trace file with routine names and
memory usage as a calling tree. A sample might be
> Var_Setup 12000
< Var_Setup 12000
> Var_OpenFile 12050
opening file1
| Var_OpenFile 12050
file1 opened sucessfully
< VarOpenFile 12050
> Var_ReadFile 12050
> Var_ReadFile 12050
> Var_WriteFile 12050
> Var_WriteFile 12050
< Var_Sub2 13000
> Var_OpenFile 13050
opening file1
< Var_OpenFile 13050
> Var_ReadFile 13050
> Var_ReadFile 13050
> Var_WriteFile 13050
> Var_WriteFile 13050
> Var_CloseFile 13020
< Var_CloseFile 13020
< Var_Sub2 13020, BIGGER 20
So there is a 20 byte bleed in Var_Sub2
At the end a report is produced reporting peak memory usage, and timings
per routine both exclusive and inclusive of lower level routine calls.
When run MPP the peaks, max and min across processors are also reported
which aids load balancing.
The files are HTML with hypertext links to the routines in the
documentation system.
This works under HP-UX and Cray Unicos, and has been ported sucessfully
by others to IBM SP/2
More details on tracing in an HTML document I can mail on request
John
--
John Bray, Room 337, Numerical Weather Prediction, UK Met Office
Work: [log in to unmask], http://fr0400/~frjb (internal only)
+ 44 (0) 1344 854035 (voice), + 44 (0) 1344 854026 (fax)
Home: http://www.jrbray.org.uk/
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|