
50 Cray T3E User’s Guide
As an example, consider a simple code that computes and prints a root
of a polynomial using IMSL routines ZREAL and WRRRN. The code is
written so that it can be run on both T3E and Caper (DEC AlphaServer at
CSC), on which the preprocessor replaces the single precision IMSL calls
with the corresponding double precision versions by defining macros.
Moreover, the variable info is printed if INFO is defined.
#ifdef __alpha
#define zreal dzreal
#define wrrrn dwrrrn
#endif
PROGRAM root
IMPLICIT NONE
INTEGER, PARAMETER:: prec=SELECTED_REAL_KIND(12,100)
REAL (prec):: eabs=1.0e-5, erel=1.0e-5, eps=1.0e-5, &
eta=1.0e-2, xi=1.0, x
INTEGER:: nr=1, imax=100, info, one=1, zero=0
CHARACTER(9):: title=’A root is’
REAL (prec), EXTERNAL:: fun
CALL zreal(fun,eabs,erel,eps,eta,nr,imax,xi,x,info)
CALL wrrrn(title,one,nr,x,one,zero)
#ifdef INFO
PRINT *, info
#endif
END PROGRAM root
FUNCTION fun(x) RESULT(value)
IMPLICIT NONE
INTEGER, PARAMETER:: prec=SELECTED_REAL_KIND(12,100)
REAL (prec):: x, value
value=x**2-2
END FUNCTION fun
To compile and link on T3E use
t3e% f90 -eZ -F root.f90 -p$MODULES_F90 $LINK_F90 -DINFO
Here the preprocessor was invoked with -eZ, -F enables macro expan-
sion, and -DINFO defines INFO. On Caper the preprocessor is activated
with -cpp:
caper% f90 $FFLAGS -cpp root.f90 $LINK_FNL -DINFO
In both cases the output is
A root is
1.414
4
Kommentare zu diesen Handbüchern