[ Pobierz całość w formacie PDF ]

FORTRAN 77 Library Routines 347
7
" Subsequent calls: elapsed time since the last call to dtime
" Single processor: time used by the CPU
" Multiple Processor: the sum of times for all the CPUs, which is not useful
data; use etime instead.
Note  Do not call dtime from within a parallelized loop.
The function is:
e = dtime( tarray )
tarray real(2) Output e= -1.0: Error: tarray values are undefined
e`" -1.0: User time in tarray(1) if no error
System time in tarray(2) if no error
Return real Output e= -1.0: Error
value e`" -1.0: The sum of tarray(1) and tarray(2)
Example: dtime(), single processor:
real e, dtime, t(2)
print *, 'elapsed:', e, ', user:', t(1), ', sys:', t(2)
do i = 1, 10000
k=k+1
end do
e = dtime( t )
print *, 'elapsed:', e, ', user:', t(1), ', sys:', t(2)
end
demo% f77 -silent tdtime.f
demo% a.out
elapsed: 0., user: 0., sys: 0.
elapsed: 0.180000, user: 6.00000E-02, sys: 0.120000
demo%
etime: Elapsed Time Since Start of Execution
For etime, the elapsed time is:
" Single Processor CPU time for the calling process
" Multiple Processor wallclock time while processing your program
348 FORTRAN 77 Reference Manual
7
Here is how FORTRAN 77 decides single processor or multiple processor:
For a FORTRAN 77 MP program that uses an MP option ultimately, linked
with libF77_mt, if the environment variable PARALLEL is:
" Undefined, the current run is single processor.
" Defined and in the range 1, 2, 3, & , the current run is multiple processor.
" Defined, but some value other than 1, 2, 3, & , the results are unpredictable.
The function is:
e = etime( tarray )
tarray real(2) Output e= -1.0: Error: tarray values are undefined
e`" -1.0: Single Processor: User time in tarray(1)
System time in tarray(2)
Multiple Processor: Wall clock time in tarray(1)
0.0 in tarray(2)
Return value real Output e= -1.0: Error
e`" -1.0: The sum of tarray(1) and tarray(2)
Example: etime(), single processor:
real e, etime, t(2)
do i = 1, 10000
k=k+1
end do
e = etime( t )
print *, 'elapsed:', e, ', user:', t(1),  , sys:', t(2)
end
demo% f77 -silent tetime.f
demo% a.out
elapsed: 0.190000, user: 6.00000E-02, sys: 0.130000
demo%
See also times(2), f77(1), and the FORTRAN 77 User s Guide.
FORTRAN 77 Library Routines 349
7
7.9 exit: Terminate a Process and Set the Status
The subroutine is:
call exit( status )
status INTEGER Input
Example: exit():
integer status
status = 7
call exit( status )
end
exit flushes and closes all the files in the process, and notifies the parent
process if it is executing a wait.
The low-order 8 bits of status are available to the parent process. These 8 bits
are shifted left 8 bits, and all other bits are zero. (Therefore, status should be in
the range of 256 - 65280). This call will never return.
The C function exit can cause cleanup actions before the final 'sys exit'.
If you call exit without an argument, you will get a warning message, and a
zero will be automatically provided as an argument. See also: exit(2),
fork(2), fork(3f), wait(2), wait(3f).
7.10 f77_floatingpoint: FORTRAN 77 IEEE Definitions
The file f77_floatingpoint.h defines constants and types used to
implement standard floating-point according to ANSI/IEEE Std 754-1985.
Include the file in a source program as follows:
#include
350 FORTRAN 77 Reference Manual
7
The file f77_floatingpoint.h defines constants and types used to
implement standard floating-point according to ANSI/IEEE Std 754-1985. Use
these constants and types to write more easily understood.F source files that
will undergo automatic preprocessing prior to FORTRAN 77 compilation.
IEEE Rounding Mode
fp_direction_type The type of the IEEE rounding direction mode. The order
of enumeration varies according to hardware.
SIGFPE Handling
sigfpe_code_type The type of a SIGFPE code.
sigfpe_handler_type The type of a user-definable SIGFPE exception
handler called to handle a particular SIGFPE code.
SIGFPE_DEFAULT A macro indicating default SIGFPE exception
handling: IEEE exceptions to continue with a
default result and to abort for other SIGFPE codes.
SIGFPE_IGNORE A macro indicating an alternate SIGFPE exception
handling, namely to ignore and continue execution.
SIGFPE_ABORT A macro indicating an alternate SIGFPE exception
handling, namely to abort with a core dump.
FORTRAN 77 Library Routines 351
7
IEEE Exception Handling
N_IEEE_EXCEPTION The number of distinct IEEE floating-point exceptions.
fp_exception_type The type of theN_IEEE_EXCEPTION exceptions. Each
exception is given a bit number.
fp_exception_field_type The type intended to hold at least
N_IEEE_EXCEPTION bits corresponding to the IEEE
exceptions numbered byfp_exception_type. Thus,
fp_inexact corresponds to the least significant bit
and fp_invalid to the fifth least significant bit.
Some operations can set more than one exception.
IEEE Classification
fp_class_type A list of the classes of IEEE floating-point values and symbols.
Refer to the Numerical Computation Guide. See also ieee_environment(3M)
and f77_ieee_environment(3F).
352 FORTRAN 77 Reference Manual
7
7.11 f77_ieee_environment: IEEE Arithmetic
Here is a summary:
ieee_flags ieeer = ieee_flags( action,mode,in,out )
ieee_handler ieeer = ieee_handler(action,exception,hdl )
sigfpe ieeer = sigfpe( code, hdl )
action character Input
code sigfpe_code_type Input
mode character Input
in character Input
exception character Input
hdl sigfpe_handler_type Input
out character Output
Return value INTEGER Output
These subprograms provide modes and status required to fully exploit
ANSI/IEEE Std 754-1985 arithmetic in a FORTRAN 77 program. They
correspond closely to the functions ieee_flags(3M), ieee_handler(3M),
and sigfpe(3).
If you use sigfpe, you must do your own setting of the corresponding trap-
enable-mask bits in the floating-point status register. The details are in the
SPARC architecture manual. The libm function ieee_handler sets these
trap-enable-mask bits for you. [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • zboralski.keep.pl