fortran 90 code chapters b1–b20 - pudn.comread.pudn.com/downloads174/ebook/810137/numerical...
Post on 27-Aug-2020
1 Views
Preview:
TRANSCRIPT
-
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
Fortran 90 Code Chapters B1–B20
Fortran 90 versions of all the Numerical Recipes routines appear in the followingChapters B1 through B20, numbered in correspondence with Chapters 1 through 20in Volume 1. Within each chapter, the routines appear in the same order as in Volume1, but not broken out separately by section number within Volume 1’s chapters.
There are commentaries accompanying many of the routines, generally follow-ing the printed listing of the routine to which they apply. These are of two kinds:issues related to parallelizing the algorithm in question, and issues related to theFortran 90 implementation. To distinguish between these two, rather different, kindsof discussions, we use the two icons,
f90the left icon (above) indicating a “parallel note,” and the right icon denoting a“Fortran 90 tip.” Specific code segments of the routine that are discussed in thesecommentaries are singled out by reproducing some of the code as an “index line”next to the icon, or at the beginning of subsequent paragraphs if there are severalitems that are commented on.
d=merge(FPMIN,d,abs(d)
-
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
Chapter B1. Preliminaries
SUBROUTINE flmoon(n,nph,jd,frac)USE nrtype; USE nrutil, ONLY : nrerrorIMPLICIT NONEINTEGER(I4B), INTENT(IN) :: n,nphINTEGER(I4B), INTENT(OUT) :: jdREAL(SP), INTENT(OUT) :: frac
Our programs begin with an introductory comment summarizing their purpose and explain-ing their calling sequence. This routine calculates the phases of the moon. Given an integern and a code nph for the phase desired (nph = 0 for new moon, 1 for first quarter, 2 forfull, 3 for last quarter), the routine returns the Julian Day Number jd, and the fractionalpart of a day frac to be added to it, of the nth such phase since January, 1900. GreenwichMean Time is assumed.
REAL(SP), PARAMETER :: RAD=PI/180.0_spINTEGER(I4B) :: iREAL(SP) :: am,as,c,t,t2,xtrac=n+nph/4.0_sp This is how we comment an individual line.t=c/1236.85_spt2=t**2as=359.2242_sp+29.105356_sp*c You aren’t really intended to understand this al-
gorithm, but it does work!am=306.0253_sp+385.816918_sp*c+0.010730_sp*t2jd=2415020+28*n+7*nphxtra=0.75933_sp+1.53058868_sp*c+(1.178e-4_sp-1.55e-7_sp*t)*t2select case(nph)
case(0,2)xtra=xtra+(0.1734_sp-3.93e-4_sp*t)*sin(RAD*as)-0.4068_sp*sin(RAD*am)
case(1,3)xtra=xtra+(0.1721_sp-4.0e-4_sp*t)*sin(RAD*as)-0.6280_sp*sin(RAD*am)
case defaultcall nrerror(’flmoon: nph is unknown’) This is how we will indicate error
conditions.end selecti=int(merge(xtra,xtra-1.0_sp, xtra >= 0.0))jd=jd+ifrac=xtra-iEND SUBROUTINE flmoon
f90select case(nph)...case(0,2)...end select Fortran 90 includes acase construction that executes at most one of several blocks of code,depending on the value of an integer, logical, or character expression.
Ideally, thecase construction will execute more efficiently than a long sequence ofcascadedif...else if...else if... constructions.C programmers should note thatthe Fortran 90 construction, perhaps mercifully, does not haveC’s “drop-through”feature.
merge(xtra,xtra-1.0_sp, xtra >= 0.0) The merge construction in Fortran90, while intended primarily for use with vector arguments, is also a convenient wayof generating conditional scalar expressions, that is, expressions with one value, oranother, depending on the result of a logical test.
1010
-
Chapter B1. Preliminaries 1011
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
When the arguments of amerge are vectors, parallelization by thecompiler is straightforward as an array parallel operation (see p. 964).Less obvious is how the scalar case, as above, is handled. For small-scale
parallel (SSP) machines, the natural gain is via speculative evaluation of both of thefirst two arguments simultaneously with evaluation of the test.
A good compiler should not penalize a scalar machine for use of either thescalar or vectormerge construction. The Fortran 90 standard states that “it is notnecessary for a processor to evaluate all of the operands of an expression, or toevaluate entirely each operand, if the value of the expression can be determinedotherwise.” Therefore, for each test on a scalar machine, only one or the other ofthe first two argument components need be evaluated.
� � �
FUNCTION julday(mm,id,iyyy)USE nrtype; USE nrutil, ONLY : nrerrorIMPLICIT NONEINTEGER(I4B), INTENT(IN) :: mm,id,iyyyINTEGER(I4B) :: julday
In this routine julday returns the Julian Day Number that begins at noon of the calendardate specified by month mm, day id, and year iyyy, all integer variables. Positive yearsignifies A.D.; negative, B.C. Remember that the year after 1 B.C. was 1 A.D.
INTEGER(I4B), PARAMETER :: IGREG=15+31*(10+12*1582) Gregorian Calendar adoptedOct. 15, 1582.INTEGER(I4B) :: ja,jm,jy
jy=iyyyif (jy == 0) call nrerror(’julday: there is no year zero’)if (jy < 0) jy=jy+1if (mm > 2) then Here is an example of a block IF-structure.
jm=mm+1else
jy=jy-1jm=mm+13
end ifjulday=floor(365.25_sp*jy)+floor(30.6001_sp*jm)+id+1720995if (id+31*(mm+12*iyyy) >= IGREG) then Test whether to change to Gregorian Cal-
endar.ja=floor(0.01_sp*jy)julday=julday+2-ja+floor(0.25_sp*ja)
end ifEND FUNCTION julday
� � �
PROGRAM badlukUSE nrtypeUSE nr, ONLY : flmoon,juldayIMPLICIT NONEINTEGER(I4B) :: ic,icon,idwk,ifrac,im,iyyy,jd,jday,nINTEGER(I4B) :: iybeg=1900,iyend=2000 The range of dates to be searched.REAL(SP) :: fracREAL(SP), PARAMETER :: TIMZON=-5.0_sp/24.0_spTime zone −5 is Eastern Standard Time.
write (*,’(1x,a,i5,a,i5)’) ’Full moons on Friday the 13th from’,&iybeg,’ to’,iyend
do iyyy=iybeg,iyend Loop over each year,do im=1,12 and each month.
jday=julday(im,13,iyyy) Is the 13th a Friday?idwk=mod(jday+1,7)
-
1012 Chapter B1. Preliminaries
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
if (idwk == 5) thenn=12.37_sp*(iyyy-1900+(im-0.5_sp)/12.0_sp)This value n is a first approximation to how many full moons have occurredsince 1900. We will feed it into the phase routine and adjust it up or down untilwe determine that our desired 13th was or was not a full moon. The variableicon signals the direction of adjustment.
icon=0do
call flmoon(n,2,jd,frac) Get date of full moon n.ifrac=nint(24.0_sp*(frac+TIMZON)) Convert to hours in correct time
zone.if (ifrac < 0) thenjd=jd-1 Convert from Julian Days beginning at noon
to civil days beginning at midnight.ifrac=ifrac+24end ifif (ifrac > 12) then
jd=jd+1ifrac=ifrac-12
elseifrac=ifrac+12
end ifif (jd == jday) then Did we hit our target day?
write (*,’(/1x,i2,a,i2,a,i4)’) im,’/’,13,’/’,iyyywrite (*,’(1x,a,i2,a)’) ’Full moon ’,ifrac,&
’ hrs after midnight (EST).’Don’t worry if you are unfamiliar with FORTRAN’s esoteric input/outputstatements; very few programs in this book do any input/output.
exit Part of the break-structure, case of a match.else Didn’t hit it.
ic=isign(1,jday-jd)if (ic == -icon) exit Another break, case of no match.icon=icn=n+ic
end ifend do
end ifend do
end doEND PROGRAM badluk
f90...IGREG=15+31*(10+12*1582) (in julday), ...TIMZON=-5.0_sp/24.0_sp(in badluk) These are two examples of initialization expressions for“named constants” (that is,PARAMETERs). Because the initialization
expressions will generally be evaluated at compile time, Fortran 90 puts somerestrictions on what kinds of intrinsic functions they can contain. Although theevaluation of a real expression like-5.0_sp/24.0_sp ought to give identical resultsat compile time and at execution time, all the way down to the least significantbit, in our opinion the conservative programmer shouldn’t count on strict identityat the level of floating-point roundoff error. (In the special case ofcross-compilers,such roundoff-level discrepancies between compile time and run time are almostinevitable.)
� � �
-
Chapter B1. Preliminaries 1013
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
SUBROUTINE caldat(julian,mm,id,iyyy)USE nrtypeIMPLICIT NONEINTEGER(I4B), INTENT(IN) :: julianINTEGER(I4B), INTENT(OUT) :: mm,id,iyyy
Inverse of the function julday given above. Here julian is input as a Julian Day Number,and the routine outputs mm,id, and iyyy as the month, day, and year on which the specifiedJulian Day started at noon.
INTEGER(I4B) :: ja,jalpha,jb,jc,jd,jeINTEGER(I4B), PARAMETER :: IGREG=2299161if (julian >= IGREG) then Cross-over to Gregorian Calendar produces this
correction.jalpha=int(((julian-1867216)-0.25_dp)/36524.25_dp)ja=julian+1+jalpha-int(0.25_dp*jalpha)
else if (julian < 0) then Make day number positive by adding integer num-ber of Julian centuries, then subtract themoff at the end.
ja=julian+36525*(1-julian/36525)else
ja=julianend ifjb=ja+1524jc=int(6680.0_dp+((jb-2439870)-122.1_dp)/365.25_dp)jd=365*jc+int(0.25_dp*jc)je=int((jb-jd)/30.6001_dp)id=jb-jd-int(30.6001_dp*je)mm=je-1if (mm > 12) mm=mm-12iyyy=jc-4715if (mm > 2) iyyy=iyyy-1if (iyyy
-
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).C1. Listing of Utility Modules
(nrtype and nrutil)
C1.1 Numerical Recipes Types (nrtype)
The file supplied as nrtype.f90 contains a single module named nrtype,which in turn contains definitions for a number of named constants (that is,PARAMETERs), and a couple of elementary derived data types used by the sparsematrix routines in this book. Of the named constants, by far the most important arethose that define the KIND types of virtually all the variables used in this book: I4B,I2B, and I1B for integer variables, SP and DP for real variables (and SPC and DPC forthe corresponding complex cases), and LGT for the default logical type.
MODULE nrtypeSymbolic names for kind types of 4-, 2-, and 1-byte integers:
INTEGER, PARAMETER :: I4B = SELECTED_INT_KIND(9)INTEGER, PARAMETER :: I2B = SELECTED_INT_KIND(4)INTEGER, PARAMETER :: I1B = SELECTED_INT_KIND(2)
Symbolic names for kind types of single- and double-precision reals:INTEGER, PARAMETER :: SP = KIND(1.0)INTEGER, PARAMETER :: DP = KIND(1.0D0)
Symbolic names for kind types of single- and double-precision complex:INTEGER, PARAMETER :: SPC = KIND((1.0,1.0))INTEGER, PARAMETER :: DPC = KIND((1.0D0,1.0D0))
Symbolic name for kind type of default logical:INTEGER, PARAMETER :: LGT = KIND(.true.)
Frequently used mathematical constants (with precision to spare):REAL(SP), PARAMETER :: PI=3.141592653589793238462643383279502884197_spREAL(SP), PARAMETER :: PIO2=1.57079632679489661923132169163975144209858_spREAL(SP), PARAMETER :: TWOPI=6.283185307179586476925286766559005768394_spREAL(SP), PARAMETER :: SQRT2=1.41421356237309504880168872420969807856967_spREAL(SP), PARAMETER :: EULER=0.5772156649015328606065120900824024310422_spREAL(DP), PARAMETER :: PI_D=3.141592653589793238462643383279502884197_dpREAL(DP), PARAMETER :: PIO2_D=1.57079632679489661923132169163975144209858_dpREAL(DP), PARAMETER :: TWOPI_D=6.283185307179586476925286766559005768394_dp
Derived data types for sparse matrices, single and double precision (see use in Chapter B2):TYPE sprs2_sp
INTEGER(I4B) :: n,lenREAL(SP), DIMENSION(:), POINTER :: valINTEGER(I4B), DIMENSION(:), POINTER :: irowINTEGER(I4B), DIMENSION(:), POINTER :: jcol
END TYPE sprs2_spTYPE sprs2_dp
INTEGER(I4B) :: n,lenREAL(DP), DIMENSION(:), POINTER :: val
1361
-
1362 Appendix C1. Listing of Utility Modules (nrtype and nrutil)
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
INTEGER(I4B), DIMENSION(:), POINTER :: irowINTEGER(I4B), DIMENSION(:), POINTER :: jcol
END TYPE sprs2_dpEND MODULE nrtype
About Converting to Higher Precision
You might hope that changing all the Numerical Recipes routines from singleprecision to double precision would be as simple as redefining the values of SP andDP in nrtype. Well . . . not quite.
Converting algorithms to a higher precision is not a purely mechanical taskbecause of the distinction between “roundoff error” and “truncation error.” (Pleasesee Volume 1, §1.2, if you are not familiar with these concepts.) While increasing theprecision implied by the kind values SP and DPwill indeed reduce a routine’s roundofferror, it will not reduce any truncation error that may be intrinsic to the algorithm.Sometimes, a routine contains “accuracy parameters” that can be adjusted to reducethe truncation error to the new, desired level. In other cases, however, the truncationerror cannot be so easily reduced; then, a whole new algorithm is needed. Clearlysuch new algorithms are beyond the scope of a simple mechanical “conversion.”
If, despite these cautionary words, you want to proceed with converting someroutines to a higher precision, here are some hints:
If your machine has a kind type that is distinct from, and has equal or greaterprecision than, the kind type that we use for DP, then, in nrtype, you can simplyredefine DP to this new highest precision and redefine SP to what was previouslyDP. For example, DEC machines usually have a “quadruple precision” real typeavailable, which can be used in this way. You should not need to make any furtheredits of nrtype or nrutil.
If, on the other hand, the kind type that we already use for DP is the highestprecision available, then you must leave DP defined as it is, and redefine SP in nrtypeto be this same kind type. Now, however, you will also have to edit nrutil, becausesome overloaded routines that were previously distinguishable (by the different kindtypes) will now be seen by the compiler as indistinguishable — and it will objectstrenuously. Simply delete all the “ dp” function names from the list of overloadedprocedures (i.e., from the MODULE PROCEDURE statements). Note that it is notnecessary to delete the routines from the MODULE itself. Similarly, in the interfacefile nr.f90 you must delete the “ dp” interfaces, except for the sprs... routines.(Since they have TYPE(sprs2 dp) or TYPE(sprs2 sp), they are treated as distincteven though they have functionally equivalent kind types.)
Finally, the following table gives some suggestions for changing the accuracyparameters, or constants, in some of the routines. Please note that this table is notnecessarily complete, and that higher-precision performance is not guaranteed for allthe routines, even if you make all the changes indicated. The above edits, and thesesuggestions, do, however, work in the majority of cases.
-
C1.1 Numerical Recipes Types (nrtype) 1363
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
In routine... change... to...
beschb NUSE1=5,NUSE2=5 NUSE1=7,NUSE2=8bessi IACC=40 IACC=200bessik EPS=1.0e-10 dp EPS=epsilon(x)bessj IACC=40 IACC=160bessjy EPS=1.0e-10 dp EPS=epsilon(x)broydn TOLF=1.0e-4 sp TOLF=1.0e-8 sp
TOLMIN=1.0e-6 sp TOLMIN=1.0e-12 sp
fdjac EPS=1.0e-4 sp EPS=1.0e-8 spfrprmn EPS=1.0e-10 sp EPS=1.0e-18 spgauher EPS=3.0e-13 dp EPS=1.0e-14 dpgaujac EPS=3.0e-14 dp EPS=1.0e-14 dpgaulag EPS=3.0e-13 dp EPS=1.0e-14 dpgauleg EPS=3.0e-14 dp EPS=1.0e-14 dphypgeo EPS=1.0e-6 sp EPS=1.0e-14 splinmin TOL=1.0e-4 sp TOL=1.0e-8 spnewt TOLF=1.0e-4 sp TOLF=1.0e-8 sp
TOLMIN=1.0e-6 sp TOLMIN=1.0e-12 sp
probks EPS1=0.001 sp EPS1=1.0e-6 spEPS2=1.0e-8 sp EPS2=1.0e-16 sp
qromb EPS=1.0e-6 sp EPS=1.0e-10 spqromo EPS=1.0e-6 sp EPS=1.0e-10 spqroot TINY=1.0e-6 sp TINY=1.0e-14 spqsimp EPS=1.0e-6 sp EPS=1.0e-10 spqtrap EPS=1.0e-6 sp EPS=1.0e-10 sprc ERRTOL=0.04 sp ERRTOL=0.0012 sprd ERRTOL=0.05 sp ERRTOL=0.0015 sprf ERRTOL=0.08 sp ERRTOL=0.0025 sprj ERRTOL=0.05 sp ERRTOL=0.0015 spsfroid conv=5.0e-6 sp conv=1.0e-14 spshoot EPS=1.0e-6 sp EPS=1.0e-14 spshootf EPS=1.0e-6 sp EPS=1.0e-14 spsimplx EPS=1.0e-6 sp EPS=1.0e-14 spsncndn CA=0.0003 sp CA=1.0e-8 spsor EPS=1.0e-5 dp EPS=1.0e-13 dpsphfpt DXX=1.0e-4 sp DXX=1.0e-8 spsphoot dx=1.0e-4 sp dx=1.0e-8 spsvdfit TOL=1.0e-5 sp TOL=1.0e-13 spzroots EPS=1.0e-6 sp EPS=1.0e-14 sp
-
1364 Appendix C1. Listing of Utility Modules (nrtype and nrutil)
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
C1.2 Numerical Recipes Utilities (nrutil)
The file supplied as nrutil.f90 contains a single module named nrutil,which contains specific implementations for all the Numerical Recipes utilityfunctions described in detail in Chapter 23.
The specific implementations given are something of a compromise betweendemonstrating parallel techniques (when they can be achieved in Fortran 90) andrunning efficiently on conventional, serial machines. The parameters at the beginningof the module (names beginning with NPAR ) are typically related to array lengthsbelow which the implementations revert to serial operations. On a purely serialmachine, these can be set to large values to suppress many parallel constructions.
The length and repetitiveness of the nrutil.f90 file stems in large part fromits extensive use of overloading. Indeed, the file would be even longer if weoverloaded versions for all the applicable data types that each utility could, inprinciple, instantiate. The descriptions in Chapter 23 detail both the full set ofintended data types and shapes for each routine, and also the types and shapesactually here implemented (which can also be gleaned by examining the file). Theintended result of all this overloading is, in essence, to give the utility routines thedesirable properties of many of the Fortran 90 intrinsic functions, namely, to beboth generic (apply to many data types) and elemental (apply element-by-elementto arbitrary shapes). Fortran 95’s provision of user-defined elemental functions willreduce the multiplicity of overloading in some of our routines; unfortunately thenecessity to overload for multiple data types will still be present.
Finally, it is worth reemphasizing the following point, already made in Chapter23: The purpose of the nrutil utilities is to remove from the Numerical Recipesprograms just those programming tasks and “idioms” whose efficient implementationis most hardware and compiler dependent, so as to allow for specific, efficientimplementations on different machines. One should therefore not expect the utmostin efficiency from the general purpose, one-size-fits-all, implementation listed here.
Correspondingly, we would encourage the incorporation of efficient nrutilimplementations, and/or comparable capabilities under different names, with asbroad as possible a set of overloaded data types, in libraries associated with specificcompilers or machines. In support of this goal, we have specifically put this AppendixC1, and the files nrtype.f90 and nrutil.f90, into the public domain.
MODULE nrutilTABLE OF CONTENTS OF THE NRUTIL MODULE:
routines that move data:array copy, swap, reallocate
routines returning a location as an integer valueifirstloc, imaxloc, iminloc
routines for argument checking and error handling:assert, assert eq, nrerror
routines relating to polynomials and recurrencesarth, geop, cumsum, cumprod, poly, polyterm,zroots unity
routines for ”outer” operations on vectorsouterand, outersum, outerdiff, outerprod, outerdiv
routines for scatter-with-combinescatter add, scatter max
routines for skew operations on matricesdiagadd, diagmult, get diag, put diag,
-
C1.2 Numerical Recipes Utilities (nrutil) 1365
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
unit matrix, lower triangle, upper trianglemiscellaneous routines
vabsUSE nrtype
Parameters for crossover from serial to parallel algorithms (these are used only within thisnrutil module):
IMPLICIT NONEINTEGER(I4B), PARAMETER :: NPAR_ARTH=16,NPAR2_ARTH=8 Each NPAR2 must be ≤ the
corresponding NPAR.INTEGER(I4B), PARAMETER :: NPAR_GEOP=4,NPAR2_GEOP=2INTEGER(I4B), PARAMETER :: NPAR_CUMSUM=16INTEGER(I4B), PARAMETER :: NPAR_CUMPROD=8INTEGER(I4B), PARAMETER :: NPAR_POLY=8INTEGER(I4B), PARAMETER :: NPAR_POLYTERM=8
Next, generic interfaces for routines with overloaded versions. Naming conventions for ap-pended codes in the names of overloaded routines are as follows: r=real, d=double pre-cision, i=integer, c=complex, z=double-precision complex, h=character, l=logical. Any ofr,d,i,c,z,h,l may be followed by v=vector or m=matrix (v,m suffixes are used only whenneeded to resolve ambiguities).Routines that move data:
INTERFACE array_copyMODULE PROCEDURE array_copy_r, array_copy_d, array_copy_i
END INTERFACEINTERFACE swap
MODULE PROCEDURE swap_i,swap_r,swap_rv,swap_c, &swap_cv,swap_cm,swap_z,swap_zv,swap_zm, &masked_swap_rs,masked_swap_rv,masked_swap_rm
END INTERFACEINTERFACE reallocate
MODULE PROCEDURE reallocate_rv,reallocate_rm,&reallocate_iv,reallocate_im,reallocate_hv
END INTERFACERoutines returning a location as an integer value (ifirstloc, iminloc are not currently over-loaded and so do not have a generic interface here):
INTERFACE imaxlocMODULE PROCEDURE imaxloc_r,imaxloc_i
END INTERFACERoutines for argument checking and error handling (nrerror is not currently overloaded):
INTERFACE assertMODULE PROCEDURE assert1,assert2,assert3,assert4,assert_v
END INTERFACEINTERFACE assert_eq
MODULE PROCEDURE assert_eq2,assert_eq3,assert_eq4,assert_eqnEND INTERFACE
Routines relating to polynomials and recurrences (cumprod, zroots unity are not currentlyoverloaded):
INTERFACE arthMODULE PROCEDURE arth_r, arth_d, arth_i
END INTERFACEINTERFACE geop
MODULE PROCEDURE geop_r, geop_d, geop_i, geop_c, geop_dvEND INTERFACEINTERFACE cumsum
MODULE PROCEDURE cumsum_r,cumsum_iEND INTERFACEINTERFACE poly
MODULE PROCEDURE poly_rr,poly_rrv,poly_dd,poly_ddv,&poly_rc,poly_cc,poly_msk_rrv,poly_msk_ddv
END INTERFACEINTERFACE poly_term
MODULE PROCEDURE poly_term_rr,poly_term_ccEND INTERFACE
Routines for “outer” operations on vectors (outerand, outersum, outerdiv are not currentlyoverloaded):
INTERFACE outerprod
-
1366 Appendix C1. Listing of Utility Modules (nrtype and nrutil)
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
MODULE PROCEDURE outerprod_r,outerprod_dEND INTERFACEINTERFACE outerdiff
MODULE PROCEDURE outerdiff_r,outerdiff_d,outerdiff_iEND INTERFACE
Routines for scatter-with-combine, scatter add, scatter max:INTERFACE scatter_add
MODULE PROCEDURE scatter_add_r,scatter_add_dEND INTERFACEINTERFACE scatter_max
MODULE PROCEDURE scatter_max_r,scatter_max_dEND INTERFACE
Routines for skew operations on matrices (unit matrix, lower triangle, upper triangle notcurrently overloaded):
INTERFACE diagaddMODULE PROCEDURE diagadd_rv,diagadd_r
END INTERFACEINTERFACE diagmult
MODULE PROCEDURE diagmult_rv,diagmult_rEND INTERFACEINTERFACE get_diag
MODULE PROCEDURE get_diag_rv, get_diag_dvEND INTERFACEINTERFACE put_diag
MODULE PROCEDURE put_diag_rv, put_diag_rEND INTERFACE
Other routines (vabs is not currently overloaded):CONTAINS
Routines that move data:SUBROUTINE array_copy_r(src,dest,n_copied,n_not_copied)
Copy array where size of source not known in advance.REAL(SP), DIMENSION(:), INTENT(IN) :: srcREAL(SP), DIMENSION(:), INTENT(OUT) :: destINTEGER(I4B), INTENT(OUT) :: n_copied, n_not_copiedn_copied=min(size(src),size(dest))n_not_copied=size(src)-n_copieddest(1:n_copied)=src(1:n_copied)END SUBROUTINE array_copy_r
SUBROUTINE array_copy_d(src,dest,n_copied,n_not_copied)REAL(DP), DIMENSION(:), INTENT(IN) :: srcREAL(DP), DIMENSION(:), INTENT(OUT) :: destINTEGER(I4B), INTENT(OUT) :: n_copied, n_not_copiedn_copied=min(size(src),size(dest))n_not_copied=size(src)-n_copieddest(1:n_copied)=src(1:n_copied)END SUBROUTINE array_copy_d
SUBROUTINE array_copy_i(src,dest,n_copied,n_not_copied)INTEGER(I4B), DIMENSION(:), INTENT(IN) :: srcINTEGER(I4B), DIMENSION(:), INTENT(OUT) :: destINTEGER(I4B), INTENT(OUT) :: n_copied, n_not_copiedn_copied=min(size(src),size(dest))n_not_copied=size(src)-n_copieddest(1:n_copied)=src(1:n_copied)END SUBROUTINE array_copy_i
SUBROUTINE swap_i(a,b)Swap the contents of a and b.
INTEGER(I4B), INTENT(INOUT) :: a,bINTEGER(I4B) :: dumdum=aa=bb=dumEND SUBROUTINE swap_i
-
C1.2 Numerical Recipes Utilities (nrutil) 1367
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
SUBROUTINE swap_r(a,b)REAL(SP), INTENT(INOUT) :: a,bREAL(SP) :: dumdum=aa=bb=dumEND SUBROUTINE swap_r
SUBROUTINE swap_rv(a,b)REAL(SP), DIMENSION(:), INTENT(INOUT) :: a,bREAL(SP), DIMENSION(SIZE(a)) :: dumdum=aa=bb=dumEND SUBROUTINE swap_rv
SUBROUTINE swap_c(a,b)COMPLEX(SPC), INTENT(INOUT) :: a,bCOMPLEX(SPC) :: dumdum=aa=bb=dumEND SUBROUTINE swap_c
SUBROUTINE swap_cv(a,b)COMPLEX(SPC), DIMENSION(:), INTENT(INOUT) :: a,bCOMPLEX(SPC), DIMENSION(SIZE(a)) :: dumdum=aa=bb=dumEND SUBROUTINE swap_cv
SUBROUTINE swap_cm(a,b)COMPLEX(SPC), DIMENSION(:,:), INTENT(INOUT) :: a,bCOMPLEX(SPC), DIMENSION(size(a,1),size(a,2)) :: dumdum=aa=bb=dumEND SUBROUTINE swap_cm
SUBROUTINE swap_z(a,b)COMPLEX(DPC), INTENT(INOUT) :: a,bCOMPLEX(DPC) :: dumdum=aa=bb=dumEND SUBROUTINE swap_z
SUBROUTINE swap_zv(a,b)COMPLEX(DPC), DIMENSION(:), INTENT(INOUT) :: a,bCOMPLEX(DPC), DIMENSION(SIZE(a)) :: dumdum=aa=bb=dumEND SUBROUTINE swap_zv
SUBROUTINE swap_zm(a,b)COMPLEX(DPC), DIMENSION(:,:), INTENT(INOUT) :: a,bCOMPLEX(DPC), DIMENSION(size(a,1),size(a,2)) :: dumdum=aa=bb=dumEND SUBROUTINE swap_zm
SUBROUTINE masked_swap_rs(a,b,mask)REAL(SP), INTENT(INOUT) :: a,bLOGICAL(LGT), INTENT(IN) :: maskREAL(SP) :: swp
-
1368 Appendix C1. Listing of Utility Modules (nrtype and nrutil)
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
if (mask) thenswp=aa=bb=swp
end ifEND SUBROUTINE masked_swap_rs
SUBROUTINE masked_swap_rv(a,b,mask)REAL(SP), DIMENSION(:), INTENT(INOUT) :: a,bLOGICAL(LGT), DIMENSION(:), INTENT(IN) :: maskREAL(SP), DIMENSION(size(a)) :: swpwhere (mask)
swp=aa=bb=swp
end whereEND SUBROUTINE masked_swap_rv
SUBROUTINE masked_swap_rm(a,b,mask)REAL(SP), DIMENSION(:,:), INTENT(INOUT) :: a,bLOGICAL(LGT), DIMENSION(:,:), INTENT(IN) :: maskREAL(SP), DIMENSION(size(a,1),size(a,2)) :: swpwhere (mask)
swp=aa=bb=swp
end whereEND SUBROUTINE masked_swap_rm
FUNCTION reallocate_rv(p,n)Reallocate a pointer to a new size, preserving its previous contents.
REAL(SP), DIMENSION(:), POINTER :: p, reallocate_rvINTEGER(I4B), INTENT(IN) :: nINTEGER(I4B) :: nold,ierrallocate(reallocate_rv(n),stat=ierr)if (ierr /= 0) call &
nrerror(’reallocate_rv: problem in attempt to allocate memory’)if (.not. associated(p)) RETURNnold=size(p)reallocate_rv(1:min(nold,n))=p(1:min(nold,n))deallocate(p)END FUNCTION reallocate_rv
FUNCTION reallocate_iv(p,n)INTEGER(I4B), DIMENSION(:), POINTER :: p, reallocate_ivINTEGER(I4B), INTENT(IN) :: nINTEGER(I4B) :: nold,ierrallocate(reallocate_iv(n),stat=ierr)if (ierr /= 0) call &
nrerror(’reallocate_iv: problem in attempt to allocate memory’)if (.not. associated(p)) RETURNnold=size(p)reallocate_iv(1:min(nold,n))=p(1:min(nold,n))deallocate(p)END FUNCTION reallocate_iv
FUNCTION reallocate_hv(p,n)CHARACTER(1), DIMENSION(:), POINTER :: p, reallocate_hvINTEGER(I4B), INTENT(IN) :: nINTEGER(I4B) :: nold,ierrallocate(reallocate_hv(n),stat=ierr)if (ierr /= 0) call &
nrerror(’reallocate_hv: problem in attempt to allocate memory’)if (.not. associated(p)) RETURNnold=size(p)reallocate_hv(1:min(nold,n))=p(1:min(nold,n))
-
C1.2 Numerical Recipes Utilities (nrutil) 1369
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
deallocate(p)END FUNCTION reallocate_hv
FUNCTION reallocate_rm(p,n,m)REAL(SP), DIMENSION(:,:), POINTER :: p, reallocate_rmINTEGER(I4B), INTENT(IN) :: n,mINTEGER(I4B) :: nold,mold,ierrallocate(reallocate_rm(n,m),stat=ierr)if (ierr /= 0) call &
nrerror(’reallocate_rm: problem in attempt to allocate memory’)if (.not. associated(p)) RETURNnold=size(p,1)mold=size(p,2)reallocate_rm(1:min(nold,n),1:min(mold,m))=&
p(1:min(nold,n),1:min(mold,m))deallocate(p)END FUNCTION reallocate_rm
FUNCTION reallocate_im(p,n,m)INTEGER(I4B), DIMENSION(:,:), POINTER :: p, reallocate_imINTEGER(I4B), INTENT(IN) :: n,mINTEGER(I4B) :: nold,mold,ierrallocate(reallocate_im(n,m),stat=ierr)if (ierr /= 0) call &
nrerror(’reallocate_im: problem in attempt to allocate memory’)if (.not. associated(p)) RETURNnold=size(p,1)mold=size(p,2)reallocate_im(1:min(nold,n),1:min(mold,m))=&
p(1:min(nold,n),1:min(mold,m))deallocate(p)END FUNCTION reallocate_im
Routines returning a location as an integer value:FUNCTION ifirstloc(mask)
Index of first occurrence of .true. in a logical vector.LOGICAL(LGT), DIMENSION(:), INTENT(IN) :: maskINTEGER(I4B) :: ifirstlocINTEGER(I4B), DIMENSION(1) :: locloc=maxloc(merge(1,0,mask))ifirstloc=loc(1)if (.not. mask(ifirstloc)) ifirstloc=size(mask)+1END FUNCTION ifirstloc
FUNCTION imaxloc_r(arr)Index of maxloc on an array.
REAL(SP), DIMENSION(:), INTENT(IN) :: arrINTEGER(I4B) :: imaxloc_rINTEGER(I4B), DIMENSION(1) :: imaximax=maxloc(arr(:))imaxloc_r=imax(1)END FUNCTION imaxloc_r
FUNCTION imaxloc_i(iarr)INTEGER(I4B), DIMENSION(:), INTENT(IN) :: iarrINTEGER(I4B), DIMENSION(1) :: imaxINTEGER(I4B) :: imaxloc_iimax=maxloc(iarr(:))imaxloc_i=imax(1)END FUNCTION imaxloc_i
FUNCTION iminloc(arr)Index of minloc on an array.
REAL(SP), DIMENSION(:), INTENT(IN) :: arrINTEGER(I4B), DIMENSION(1) :: iminINTEGER(I4B) :: iminlocimin=minloc(arr(:))
-
1370 Appendix C1. Listing of Utility Modules (nrtype and nrutil)
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
iminloc=imin(1)END FUNCTION iminloc
Routines for argument checking and error handling:SUBROUTINE assert1(n1,string)
Report and die if any logical is false (used for arg range checking).CHARACTER(LEN=*), INTENT(IN) :: stringLOGICAL, INTENT(IN) :: n1if (.not. n1) then
write (*,*) ’nrerror: an assertion failed with this tag:’, &string
STOP ’program terminated by assert1’end ifEND SUBROUTINE assert1
SUBROUTINE assert2(n1,n2,string)CHARACTER(LEN=*), INTENT(IN) :: stringLOGICAL, INTENT(IN) :: n1,n2if (.not. (n1 .and. n2)) then
write (*,*) ’nrerror: an assertion failed with this tag:’, &string
STOP ’program terminated by assert2’end ifEND SUBROUTINE assert2
SUBROUTINE assert3(n1,n2,n3,string)CHARACTER(LEN=*), INTENT(IN) :: stringLOGICAL, INTENT(IN) :: n1,n2,n3if (.not. (n1 .and. n2 .and. n3)) then
write (*,*) ’nrerror: an assertion failed with this tag:’, &string
STOP ’program terminated by assert3’end ifEND SUBROUTINE assert3
SUBROUTINE assert4(n1,n2,n3,n4,string)CHARACTER(LEN=*), INTENT(IN) :: stringLOGICAL, INTENT(IN) :: n1,n2,n3,n4if (.not. (n1 .and. n2 .and. n3 .and. n4)) then
write (*,*) ’nrerror: an assertion failed with this tag:’, &string
STOP ’program terminated by assert4’end ifEND SUBROUTINE assert4
SUBROUTINE assert_v(n,string)CHARACTER(LEN=*), INTENT(IN) :: stringLOGICAL, DIMENSION(:), INTENT(IN) :: nif (.not. all(n)) then
write (*,*) ’nrerror: an assertion failed with this tag:’, &string
STOP ’program terminated by assert_v’end ifEND SUBROUTINE assert_v
FUNCTION assert_eq2(n1,n2,string)Report and die if integers not all equal (used for size checking).
CHARACTER(LEN=*), INTENT(IN) :: stringINTEGER, INTENT(IN) :: n1,n2INTEGER :: assert_eq2if (n1 == n2) then
assert_eq2=n1else
write (*,*) ’nrerror: an assert_eq failed with this tag:’, &string
STOP ’program terminated by assert_eq2’end if
-
C1.2 Numerical Recipes Utilities (nrutil) 1371
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
END FUNCTION assert_eq2
FUNCTION assert_eq3(n1,n2,n3,string)CHARACTER(LEN=*), INTENT(IN) :: stringINTEGER, INTENT(IN) :: n1,n2,n3INTEGER :: assert_eq3if (n1 == n2 .and. n2 == n3) then
assert_eq3=n1else
write (*,*) ’nrerror: an assert_eq failed with this tag:’, &string
STOP ’program terminated by assert_eq3’end ifEND FUNCTION assert_eq3
FUNCTION assert_eq4(n1,n2,n3,n4,string)CHARACTER(LEN=*), INTENT(IN) :: stringINTEGER, INTENT(IN) :: n1,n2,n3,n4INTEGER :: assert_eq4if (n1 == n2 .and. n2 == n3 .and. n3 == n4) then
assert_eq4=n1else
write (*,*) ’nrerror: an assert_eq failed with this tag:’, &string
STOP ’program terminated by assert_eq4’end ifEND FUNCTION assert_eq4
FUNCTION assert_eqn(nn,string)CHARACTER(LEN=*), INTENT(IN) :: stringINTEGER, DIMENSION(:), INTENT(IN) :: nnINTEGER :: assert_eqnif (all(nn(2:) == nn(1))) then
assert_eqn=nn(1)else
write (*,*) ’nrerror: an assert_eq failed with this tag:’, &string
STOP ’program terminated by assert_eqn’end ifEND FUNCTION assert_eqn
SUBROUTINE nrerror(string)Report a message, then die.
CHARACTER(LEN=*), INTENT(IN) :: stringwrite (*,*) ’nrerror: ’,stringSTOP ’program terminated by nrerror’END SUBROUTINE nrerror
Routines relating to polynomials and recurrences:FUNCTION arth_r(first,increment,n)
Array function returning an arithmetic progression.REAL(SP), INTENT(IN) :: first,incrementINTEGER(I4B), INTENT(IN) :: nREAL(SP), DIMENSION(n) :: arth_rINTEGER(I4B) :: k,k2REAL(SP) :: tempif (n > 0) arth_r(1)=firstif (n
-
1372 Appendix C1. Listing of Utility Modules (nrtype and nrutil)
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
doif (k >= n) exitk2=k+karth_r(k+1:min(k2,n))=temp+arth_r(1:min(k,n-k))temp=temp+tempk=k2
end doend ifEND FUNCTION arth_r
FUNCTION arth_d(first,increment,n)REAL(DP), INTENT(IN) :: first,incrementINTEGER(I4B), INTENT(IN) :: nREAL(DP), DIMENSION(n) :: arth_dINTEGER(I4B) :: k,k2REAL(DP) :: tempif (n > 0) arth_d(1)=firstif (n = n) exitk2=k+karth_d(k+1:min(k2,n))=temp+arth_d(1:min(k,n-k))temp=temp+tempk=k2
end doend ifEND FUNCTION arth_d
FUNCTION arth_i(first,increment,n)INTEGER(I4B), INTENT(IN) :: first,increment,nINTEGER(I4B), DIMENSION(n) :: arth_iINTEGER(I4B) :: k,k2,tempif (n > 0) arth_i(1)=firstif (n = n) exitk2=k+karth_i(k+1:min(k2,n))=temp+arth_i(1:min(k,n-k))temp=temp+tempk=k2
end doend ifEND FUNCTION arth_i
FUNCTION geop_r(first,factor,n)Array function returning a geometric progression.
REAL(SP), INTENT(IN) :: first,factor
-
C1.2 Numerical Recipes Utilities (nrutil) 1373
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
INTEGER(I4B), INTENT(IN) :: nREAL(SP), DIMENSION(n) :: geop_rINTEGER(I4B) :: k,k2REAL(SP) :: tempif (n > 0) geop_r(1)=firstif (n = n) exitk2=k+kgeop_r(k+1:min(k2,n))=temp*geop_r(1:min(k,n-k))temp=temp*tempk=k2
end doend ifEND FUNCTION geop_r
FUNCTION geop_d(first,factor,n)REAL(DP), INTENT(IN) :: first,factorINTEGER(I4B), INTENT(IN) :: nREAL(DP), DIMENSION(n) :: geop_dINTEGER(I4B) :: k,k2REAL(DP) :: tempif (n > 0) geop_d(1)=firstif (n = n) exitk2=k+kgeop_d(k+1:min(k2,n))=temp*geop_d(1:min(k,n-k))temp=temp*tempk=k2
end doend ifEND FUNCTION geop_d
FUNCTION geop_i(first,factor,n)INTEGER(I4B), INTENT(IN) :: first,factor,nINTEGER(I4B), DIMENSION(n) :: geop_iINTEGER(I4B) :: k,k2,tempif (n > 0) geop_i(1)=firstif (n
-
1374 Appendix C1. Listing of Utility Modules (nrtype and nrutil)
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
temp=factor**NPAR2_GEOPk=NPAR2_GEOPdo
if (k >= n) exitk2=k+kgeop_i(k+1:min(k2,n))=temp*geop_i(1:min(k,n-k))temp=temp*tempk=k2
end doend ifEND FUNCTION geop_i
FUNCTION geop_c(first,factor,n)COMPLEX(SP), INTENT(IN) :: first,factorINTEGER(I4B), INTENT(IN) :: nCOMPLEX(SP), DIMENSION(n) :: geop_cINTEGER(I4B) :: k,k2COMPLEX(SP) :: tempif (n > 0) geop_c(1)=firstif (n = n) exitk2=k+kgeop_c(k+1:min(k2,n))=temp*geop_c(1:min(k,n-k))temp=temp*tempk=k2
end doend ifEND FUNCTION geop_c
FUNCTION geop_dv(first,factor,n)REAL(DP), DIMENSION(:), INTENT(IN) :: first,factorINTEGER(I4B), INTENT(IN) :: nREAL(DP), DIMENSION(size(first),n) :: geop_dvINTEGER(I4B) :: k,k2REAL(DP), DIMENSION(size(first)) :: tempif (n > 0) geop_dv(:,1)=first(:)if (n = n) exitk2=k+kgeop_dv(:,k+1:min(k2,n))=geop_dv(:,1:min(k,n-k))*&
spread(temp,2,size(geop_dv(:,1:min(k,n-k)),2))temp=temp*tempk=k2
end doend if
-
C1.2 Numerical Recipes Utilities (nrutil) 1375
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
END FUNCTION geop_dv
RECURSIVE FUNCTION cumsum_r(arr,seed) RESULT(ans)Cumulative sum on an array, with optional additive seed.
REAL(SP), DIMENSION(:), INTENT(IN) :: arrREAL(SP), OPTIONAL, INTENT(IN) :: seedREAL(SP), DIMENSION(size(arr)) :: ansINTEGER(I4B) :: n,jREAL(SP) :: sdn=size(arr)if (n == 0_i4b) RETURNsd=0.0_spif (present(seed)) sd=seedans(1)=arr(1)+sdif (n < NPAR_CUMSUM) then
do j=2,nans(j)=ans(j-1)+arr(j)
end doelse
ans(2:n:2)=cumsum_r(arr(2:n:2)+arr(1:n-1:2),sd)ans(3:n:2)=ans(2:n-1:2)+arr(3:n:2)
end ifEND FUNCTION cumsum_r
RECURSIVE FUNCTION cumsum_i(arr,seed) RESULT(ans)INTEGER(I4B), DIMENSION(:), INTENT(IN) :: arrINTEGER(I4B), OPTIONAL, INTENT(IN) :: seedINTEGER(I4B), DIMENSION(size(arr)) :: ansINTEGER(I4B) :: n,j,sdn=size(arr)if (n == 0_i4b) RETURNsd=0_i4bif (present(seed)) sd=seedans(1)=arr(1)+sdif (n < NPAR_CUMSUM) then
do j=2,nans(j)=ans(j-1)+arr(j)
end doelse
ans(2:n:2)=cumsum_i(arr(2:n:2)+arr(1:n-1:2),sd)ans(3:n:2)=ans(2:n-1:2)+arr(3:n:2)
end ifEND FUNCTION cumsum_i
RECURSIVE FUNCTION cumprod(arr,seed) RESULT(ans)Cumulative product on an array, with optional multiplicative seed.
REAL(SP), DIMENSION(:), INTENT(IN) :: arrREAL(SP), OPTIONAL, INTENT(IN) :: seedREAL(SP), DIMENSION(size(arr)) :: ansINTEGER(I4B) :: n,jREAL(SP) :: sdn=size(arr)if (n == 0_i4b) RETURNsd=1.0_spif (present(seed)) sd=seedans(1)=arr(1)*sdif (n < NPAR_CUMPROD) then
do j=2,nans(j)=ans(j-1)*arr(j)
end doelse
ans(2:n:2)=cumprod(arr(2:n:2)*arr(1:n-1:2),sd)ans(3:n:2)=ans(2:n-1:2)*arr(3:n:2)
end ifEND FUNCTION cumprod
-
1376 Appendix C1. Listing of Utility Modules (nrtype and nrutil)
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
FUNCTION poly_rr(x,coeffs)Polynomial evaluation.
REAL(SP), INTENT(IN) :: xREAL(SP), DIMENSION(:), INTENT(IN) :: coeffsREAL(SP) :: poly_rrREAL(SP) :: powREAL(SP), DIMENSION(:), ALLOCATABLE :: vecINTEGER(I4B) :: i,n,nnn=size(coeffs)if (n
-
C1.2 Numerical Recipes Utilities (nrutil) 1377
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
FUNCTION poly_rc(x,coeffs)COMPLEX(SPC), INTENT(IN) :: xREAL(SP), DIMENSION(:), INTENT(IN) :: coeffsCOMPLEX(SPC) :: poly_rcCOMPLEX(SPC) :: powCOMPLEX(SPC), DIMENSION(:), ALLOCATABLE :: vecINTEGER(I4B) :: i,n,nnn=size(coeffs)if (n
-
1378 Appendix C1. Listing of Utility Modules (nrtype and nrutil)
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
REAL(SP), DIMENSION(:), INTENT(IN) :: coeffs,xREAL(SP), DIMENSION(size(x)) :: poly_rrvINTEGER(I4B) :: i,n,mm=size(coeffs)n=size(x)if (m
-
C1.2 Numerical Recipes Utilities (nrutil) 1379
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
elseu(2:n:2)=poly_term_rr(a(2:n:2)+a(1:n-1:2)*b,b*b)u(3:n:2)=a(3:n:2)+b*u(2:n-1:2)
end ifEND FUNCTION poly_term_rr
RECURSIVE FUNCTION poly_term_cc(a,b) RESULT(u)COMPLEX(SPC), DIMENSION(:), INTENT(IN) :: aCOMPLEX(SPC), INTENT(IN) :: bCOMPLEX(SPC), DIMENSION(size(a)) :: uINTEGER(I4B) :: n,jn=size(a)if (n = nn) exitzroots_unity(k+1)=cmplx(cos(k*theta),sin(k*theta),SPC)zroots_unity(k+2:min(2*k,nn))=zroots_unity(k+1)*&
zroots_unity(2:min(k,nn-k))k=2*k
end doEND FUNCTION zroots_unity
Routines for “outer” operations on vectors. The order convention is: result(i,j) = first operand(i)(op) second operand(j).
FUNCTION outerprod_r(a,b)REAL(SP), DIMENSION(:), INTENT(IN) :: a,bREAL(SP), DIMENSION(size(a),size(b)) :: outerprod_routerprod_r = spread(a,dim=2,ncopies=size(b)) * &
spread(b,dim=1,ncopies=size(a))END FUNCTION outerprod_r
FUNCTION outerprod_d(a,b)REAL(DP), DIMENSION(:), INTENT(IN) :: a,bREAL(DP), DIMENSION(size(a),size(b)) :: outerprod_douterprod_d = spread(a,dim=2,ncopies=size(b)) * &
spread(b,dim=1,ncopies=size(a))END FUNCTION outerprod_d
FUNCTION outerdiv(a,b)REAL(SP), DIMENSION(:), INTENT(IN) :: a,bREAL(SP), DIMENSION(size(a),size(b)) :: outerdivouterdiv = spread(a,dim=2,ncopies=size(b)) / &
spread(b,dim=1,ncopies=size(a))END FUNCTION outerdiv
FUNCTION outersum(a,b)REAL(SP), DIMENSION(:), INTENT(IN) :: a,b
-
1380 Appendix C1. Listing of Utility Modules (nrtype and nrutil)
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
REAL(SP), DIMENSION(size(a),size(b)) :: outersumoutersum = spread(a,dim=2,ncopies=size(b)) + &
spread(b,dim=1,ncopies=size(a))END FUNCTION outersum
FUNCTION outerdiff_r(a,b)REAL(SP), DIMENSION(:), INTENT(IN) :: a,bREAL(SP), DIMENSION(size(a),size(b)) :: outerdiff_routerdiff_r = spread(a,dim=2,ncopies=size(b)) - &
spread(b,dim=1,ncopies=size(a))END FUNCTION outerdiff_r
FUNCTION outerdiff_d(a,b)REAL(DP), DIMENSION(:), INTENT(IN) :: a,bREAL(DP), DIMENSION(size(a),size(b)) :: outerdiff_douterdiff_d = spread(a,dim=2,ncopies=size(b)) - &
spread(b,dim=1,ncopies=size(a))END FUNCTION outerdiff_d
FUNCTION outerdiff_i(a,b)INTEGER(I4B), DIMENSION(:), INTENT(IN) :: a,bINTEGER(I4B), DIMENSION(size(a),size(b)) :: outerdiff_iouterdiff_i = spread(a,dim=2,ncopies=size(b)) - &
spread(b,dim=1,ncopies=size(a))END FUNCTION outerdiff_i
FUNCTION outerand(a,b)LOGICAL(LGT), DIMENSION(:), INTENT(IN) :: a,bLOGICAL(LGT), DIMENSION(size(a),size(b)) :: outerandouterand = spread(a,dim=2,ncopies=size(b)) .and. &
spread(b,dim=1,ncopies=size(a))END FUNCTION outerand
Routines for scatter-with-combine.SUBROUTINE scatter_add_r(dest,source,dest_index)REAL(SP), DIMENSION(:), INTENT(OUT) :: destREAL(SP), DIMENSION(:), INTENT(IN) :: sourceINTEGER(I4B), DIMENSION(:), INTENT(IN) :: dest_indexINTEGER(I4B) :: m,n,j,in=assert_eq2(size(source),size(dest_index),’scatter_add_r’)m=size(dest)do j=1,n
i=dest_index(j)if (i > 0 .and. i 0 .and. i
-
C1.2 Numerical Recipes Utilities (nrutil) 1381
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
if (i > 0 .and. i 0 .and. i
-
1382 Appendix C1. Listing of Utility Modules (nrtype and nrutil)
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
end doEND FUNCTION get_diag_rv
FUNCTION get_diag_dv(mat)REAL(DP), DIMENSION(:,:), INTENT(IN) :: matREAL(DP), DIMENSION(size(mat,1)) :: get_diag_dvINTEGER(I4B) :: jj=assert_eq2(size(mat,1),size(mat,2),’get_diag_dv’)do j=1,size(mat,1)
get_diag_dv(j)=mat(j,j)end doEND FUNCTION get_diag_dv
SUBROUTINE put_diag_rv(diagv,mat)Set the diagonal of matrix mat to the values of a vector or scalar.
REAL(SP), DIMENSION(:), INTENT(IN) :: diagvREAL(SP), DIMENSION(:,:), INTENT(INOUT) :: matINTEGER(I4B) :: j,nn=assert_eq2(size(diagv),min(size(mat,1),size(mat,2)),’put_diag_rv’)do j=1,n
mat(j,j)=diagv(j)end doEND SUBROUTINE put_diag_rv
SUBROUTINE put_diag_r(scal,mat)REAL(SP), INTENT(IN) :: scalREAL(SP), DIMENSION(:,:), INTENT(INOUT) :: matINTEGER(I4B) :: j,nn = min(size(mat,1),size(mat,2))do j=1,n
mat(j,j)=scalend doEND SUBROUTINE put_diag_r
SUBROUTINE unit_matrix(mat)Set the matrix mat to be a unit matrix (if it is square).
REAL(SP), DIMENSION(:,:), INTENT(OUT) :: matINTEGER(I4B) :: i,nn=min(size(mat,1),size(mat,2))mat(:,:)=0.0_spdo i=1,n
mat(i,i)=1.0_spend doEND SUBROUTINE unit_matrix
FUNCTION upper_triangle(j,k,extra)Return an upper triangular logical mask.
INTEGER(I4B), INTENT(IN) :: j,kINTEGER(I4B), OPTIONAL, INTENT(IN) :: extraLOGICAL(LGT), DIMENSION(j,k) :: upper_triangleINTEGER(I4B) :: nn=0if (present(extra)) n=extraupper_triangle=(outerdiff(arth_i(1,1,j),arth_i(1,1,k)) < n)END FUNCTION upper_triangle
FUNCTION lower_triangle(j,k,extra)Return a lower triangular logical mask.
INTEGER(I4B), INTENT(IN) :: j,kINTEGER(I4B), OPTIONAL, INTENT(IN) :: extraLOGICAL(LGT), DIMENSION(j,k) :: lower_triangleINTEGER(I4B) :: nn=0if (present(extra)) n=extralower_triangle=(outerdiff(arth_i(1,1,j),arth_i(1,1,k)) > -n)END FUNCTION lower_triangle
Other routines:
-
C1.2 Numerical Recipes Utilities (nrutil) 1383
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
FUNCTION vabs(v)Return the length (ordinary L2 norm) of a vector.
REAL(SP), DIMENSION(:), INTENT(IN) :: vREAL(SP) :: vabsvabs=sqrt(dot_product(v,v))END FUNCTION vabs
END MODULE nrutil
-
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).C2. Alphabetical Listing of
Explicit Interfaces
The file supplied as nr.f90 contains explicit interfaces for all the NumericalRecipes routines (except those already in the module nrutil). The interfaces arein alphabetical order, by the generic interface name, if one exists, or by the specificroutine name if there is no generic name.
The file nr.f90 is normally invoked via a USE statement within a main programor subroutine that references a Numerical Recipes routine. See §21.1 for an example.
MODULE nrINTERFACE
SUBROUTINE airy(x,ai,bi,aip,bip)USE nrtypeREAL(SP), INTENT(IN) :: xREAL(SP), INTENT(OUT) :: ai,bi,aip,bipEND SUBROUTINE airy
END INTERFACEINTERFACE
SUBROUTINE amebsa(p,y,pb,yb,ftol,func,iter,temptr)USE nrtypeINTEGER(I4B), INTENT(INOUT) :: iterREAL(SP), INTENT(INOUT) :: ybREAL(SP), INTENT(IN) :: ftol,temptrREAL(SP), DIMENSION(:), INTENT(INOUT) :: y,pbREAL(SP), DIMENSION(:,:), INTENT(INOUT) :: pINTERFACE
FUNCTION func(x)USE nrtypeREAL(SP), DIMENSION(:), INTENT(IN) :: xREAL(SP) :: funcEND FUNCTION func
END INTERFACEEND SUBROUTINE amebsa
END INTERFACEINTERFACE
SUBROUTINE amoeba(p,y,ftol,func,iter)USE nrtypeINTEGER(I4B), INTENT(OUT) :: iterREAL(SP), INTENT(IN) :: ftolREAL(SP), DIMENSION(:), INTENT(INOUT) :: yREAL(SP), DIMENSION(:,:), INTENT(INOUT) :: pINTERFACE
FUNCTION func(x)USE nrtypeREAL(SP), DIMENSION(:), INTENT(IN) :: xREAL(SP) :: funcEND FUNCTION func
END INTERFACE
1384
-
Appendix C2. Alphabetical Listing of Explicit Interfaces 1385
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
END SUBROUTINE amoebaEND INTERFACEINTERFACE
SUBROUTINE anneal(x,y,iorder)USE nrtypeINTEGER(I4B), DIMENSION(:), INTENT(INOUT) :: iorderREAL(SP), DIMENSION(:), INTENT(IN) :: x,yEND SUBROUTINE anneal
END INTERFACEINTERFACE
SUBROUTINE asolve(b,x,itrnsp)USE nrtypeREAL(DP), DIMENSION(:), INTENT(IN) :: bREAL(DP), DIMENSION(:), INTENT(OUT) :: xINTEGER(I4B), INTENT(IN) :: itrnspEND SUBROUTINE asolve
END INTERFACEINTERFACE
SUBROUTINE atimes(x,r,itrnsp)USE nrtypeREAL(DP), DIMENSION(:), INTENT(IN) :: xREAL(DP), DIMENSION(:), INTENT(OUT) :: rINTEGER(I4B), INTENT(IN) :: itrnspEND SUBROUTINE atimes
END INTERFACEINTERFACE
SUBROUTINE avevar(data,ave,var)USE nrtypeREAL(SP), DIMENSION(:), INTENT(IN) :: dataREAL(SP), INTENT(OUT) :: ave,varEND SUBROUTINE avevar
END INTERFACEINTERFACE
SUBROUTINE balanc(a)USE nrtypeREAL(SP), DIMENSION(:,:), INTENT(INOUT) :: aEND SUBROUTINE balanc
END INTERFACEINTERFACE
SUBROUTINE banbks(a,m1,m2,al,indx,b)USE nrtypeINTEGER(I4B), INTENT(IN) :: m1,m2INTEGER(I4B), DIMENSION(:), INTENT(IN) :: indxREAL(SP), DIMENSION(:,:), INTENT(IN) :: a,alREAL(SP), DIMENSION(:), INTENT(INOUT) :: bEND SUBROUTINE banbks
END INTERFACEINTERFACE
SUBROUTINE bandec(a,m1,m2,al,indx,d)USE nrtypeINTEGER(I4B), INTENT(IN) :: m1,m2INTEGER(I4B), DIMENSION(:), INTENT(OUT) :: indxREAL(SP), INTENT(OUT) :: dREAL(SP), DIMENSION(:,:), INTENT(INOUT) :: aREAL(SP), DIMENSION(:,:), INTENT(OUT) :: alEND SUBROUTINE bandec
END INTERFACEINTERFACE
SUBROUTINE banmul(a,m1,m2,x,b)USE nrtypeINTEGER(I4B), INTENT(IN) :: m1,m2REAL(SP), DIMENSION(:), INTENT(IN) :: xREAL(SP), DIMENSION(:), INTENT(OUT) :: bREAL(SP), DIMENSION(:,:), INTENT(IN) :: a
-
1386 Appendix C2. Alphabetical Listing of Explicit Interfaces
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
END SUBROUTINE banmulEND INTERFACEINTERFACE
SUBROUTINE bcucof(y,y1,y2,y12,d1,d2,c)USE nrtypeREAL(SP), INTENT(IN) :: d1,d2REAL(SP), DIMENSION(4), INTENT(IN) :: y,y1,y2,y12REAL(SP), DIMENSION(4,4), INTENT(OUT) :: cEND SUBROUTINE bcucof
END INTERFACEINTERFACE
SUBROUTINE bcuint(y,y1,y2,y12,x1l,x1u,x2l,x2u,x1,x2,ansy,&ansy1,ansy2)
USE nrtypeREAL(SP), DIMENSION(4), INTENT(IN) :: y,y1,y2,y12REAL(SP), INTENT(IN) :: x1l,x1u,x2l,x2u,x1,x2REAL(SP), INTENT(OUT) :: ansy,ansy1,ansy2END SUBROUTINE bcuint
END INTERFACEINTERFACE beschb
SUBROUTINE beschb_s(x,gam1,gam2,gampl,gammi)USE nrtypeREAL(DP), INTENT(IN) :: xREAL(DP), INTENT(OUT) :: gam1,gam2,gampl,gammiEND SUBROUTINE beschb_s
SUBROUTINE beschb_v(x,gam1,gam2,gampl,gammi)USE nrtypeREAL(DP), DIMENSION(:), INTENT(IN) :: xREAL(DP), DIMENSION(:), INTENT(OUT) :: gam1,gam2,gampl,gammiEND SUBROUTINE beschb_v
END INTERFACEINTERFACE bessi
FUNCTION bessi_s(n,x)USE nrtypeINTEGER(I4B), INTENT(IN) :: nREAL(SP), INTENT(IN) :: xREAL(SP) :: bessi_sEND FUNCTION bessi_s
FUNCTION bessi_v(n,x)USE nrtypeINTEGER(I4B), INTENT(IN) :: nREAL(SP), DIMENSION(:), INTENT(IN) :: xREAL(SP), DIMENSION(size(x)) :: bessi_vEND FUNCTION bessi_v
END INTERFACEINTERFACE bessi0
FUNCTION bessi0_s(x)USE nrtypeREAL(SP), INTENT(IN) :: xREAL(SP) :: bessi0_sEND FUNCTION bessi0_s
FUNCTION bessi0_v(x)USE nrtypeREAL(SP), DIMENSION(:), INTENT(IN) :: xREAL(SP), DIMENSION(size(x)) :: bessi0_vEND FUNCTION bessi0_v
END INTERFACEINTERFACE bessi1
FUNCTION bessi1_s(x)USE nrtypeREAL(SP), INTENT(IN) :: xREAL(SP) :: bessi1_sEND FUNCTION bessi1_s
-
Appendix C2. Alphabetical Listing of Explicit Interfaces 1387
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
FUNCTION bessi1_v(x)USE nrtypeREAL(SP), DIMENSION(:), INTENT(IN) :: xREAL(SP), DIMENSION(size(x)) :: bessi1_vEND FUNCTION bessi1_v
END INTERFACEINTERFACE
SUBROUTINE bessik(x,xnu,ri,rk,rip,rkp)USE nrtypeREAL(SP), INTENT(IN) :: x,xnuREAL(SP), INTENT(OUT) :: ri,rk,rip,rkpEND SUBROUTINE bessik
END INTERFACEINTERFACE bessj
FUNCTION bessj_s(n,x)USE nrtypeINTEGER(I4B), INTENT(IN) :: nREAL(SP), INTENT(IN) :: xREAL(SP) :: bessj_sEND FUNCTION bessj_s
FUNCTION bessj_v(n,x)USE nrtypeINTEGER(I4B), INTENT(IN) :: nREAL(SP), DIMENSION(:), INTENT(IN) :: xREAL(SP), DIMENSION(size(x)) :: bessj_vEND FUNCTION bessj_v
END INTERFACEINTERFACE bessj0
FUNCTION bessj0_s(x)USE nrtypeREAL(SP), INTENT(IN) :: xREAL(SP) :: bessj0_sEND FUNCTION bessj0_s
FUNCTION bessj0_v(x)USE nrtypeREAL(SP), DIMENSION(:), INTENT(IN) :: xREAL(SP), DIMENSION(size(x)) :: bessj0_vEND FUNCTION bessj0_v
END INTERFACEINTERFACE bessj1
FUNCTION bessj1_s(x)USE nrtypeREAL(SP), INTENT(IN) :: xREAL(SP) :: bessj1_sEND FUNCTION bessj1_s
FUNCTION bessj1_v(x)USE nrtypeREAL(SP), DIMENSION(:), INTENT(IN) :: xREAL(SP), DIMENSION(size(x)) :: bessj1_vEND FUNCTION bessj1_v
END INTERFACEINTERFACE bessjy
SUBROUTINE bessjy_s(x,xnu,rj,ry,rjp,ryp)USE nrtypeREAL(SP), INTENT(IN) :: x,xnuREAL(SP), INTENT(OUT) :: rj,ry,rjp,rypEND SUBROUTINE bessjy_s
SUBROUTINE bessjy_v(x,xnu,rj,ry,rjp,ryp)USE nrtypeREAL(SP), INTENT(IN) :: xnuREAL(SP), DIMENSION(:), INTENT(IN) :: xREAL(SP), DIMENSION(:), INTENT(OUT) :: rj,rjp,ry,ryp
-
1388 Appendix C2. Alphabetical Listing of Explicit Interfaces
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
END SUBROUTINE bessjy_vEND INTERFACEINTERFACE bessk
FUNCTION bessk_s(n,x)USE nrtypeINTEGER(I4B), INTENT(IN) :: nREAL(SP), INTENT(IN) :: xREAL(SP) :: bessk_sEND FUNCTION bessk_s
FUNCTION bessk_v(n,x)USE nrtypeINTEGER(I4B), INTENT(IN) :: nREAL(SP), DIMENSION(:), INTENT(IN) :: xREAL(SP), DIMENSION(size(x)) :: bessk_vEND FUNCTION bessk_v
END INTERFACEINTERFACE bessk0
FUNCTION bessk0_s(x)USE nrtypeREAL(SP), INTENT(IN) :: xREAL(SP) :: bessk0_sEND FUNCTION bessk0_s
FUNCTION bessk0_v(x)USE nrtypeREAL(SP), DIMENSION(:), INTENT(IN) :: xREAL(SP), DIMENSION(size(x)) :: bessk0_vEND FUNCTION bessk0_v
END INTERFACEINTERFACE bessk1
FUNCTION bessk1_s(x)USE nrtypeREAL(SP), INTENT(IN) :: xREAL(SP) :: bessk1_sEND FUNCTION bessk1_s
FUNCTION bessk1_v(x)USE nrtypeREAL(SP), DIMENSION(:), INTENT(IN) :: xREAL(SP), DIMENSION(size(x)) :: bessk1_vEND FUNCTION bessk1_v
END INTERFACEINTERFACE bessy
FUNCTION bessy_s(n,x)USE nrtypeINTEGER(I4B), INTENT(IN) :: nREAL(SP), INTENT(IN) :: xREAL(SP) :: bessy_sEND FUNCTION bessy_s
FUNCTION bessy_v(n,x)USE nrtypeINTEGER(I4B), INTENT(IN) :: nREAL(SP), DIMENSION(:), INTENT(IN) :: xREAL(SP), DIMENSION(size(x)) :: bessy_vEND FUNCTION bessy_v
END INTERFACEINTERFACE bessy0
FUNCTION bessy0_s(x)USE nrtypeREAL(SP), INTENT(IN) :: xREAL(SP) :: bessy0_sEND FUNCTION bessy0_s
FUNCTION bessy0_v(x)USE nrtype
-
Appendix C2. Alphabetical Listing of Explicit Interfaces 1389
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
REAL(SP), DIMENSION(:), INTENT(IN) :: xREAL(SP), DIMENSION(size(x)) :: bessy0_vEND FUNCTION bessy0_v
END INTERFACEINTERFACE bessy1
FUNCTION bessy1_s(x)USE nrtypeREAL(SP), INTENT(IN) :: xREAL(SP) :: bessy1_sEND FUNCTION bessy1_s
FUNCTION bessy1_v(x)USE nrtypeREAL(SP), DIMENSION(:), INTENT(IN) :: xREAL(SP), DIMENSION(size(x)) :: bessy1_vEND FUNCTION bessy1_v
END INTERFACEINTERFACE beta
FUNCTION beta_s(z,w)USE nrtypeREAL(SP), INTENT(IN) :: z,wREAL(SP) :: beta_sEND FUNCTION beta_s
FUNCTION beta_v(z,w)USE nrtypeREAL(SP), DIMENSION(:), INTENT(IN) :: z,wREAL(SP), DIMENSION(size(z)) :: beta_vEND FUNCTION beta_v
END INTERFACEINTERFACE betacf
FUNCTION betacf_s(a,b,x)USE nrtypeREAL(SP), INTENT(IN) :: a,b,xREAL(SP) :: betacf_sEND FUNCTION betacf_s
FUNCTION betacf_v(a,b,x)USE nrtypeREAL(SP), DIMENSION(:), INTENT(IN) :: a,b,xREAL(SP), DIMENSION(size(x)) :: betacf_vEND FUNCTION betacf_v
END INTERFACEINTERFACE betai
FUNCTION betai_s(a,b,x)USE nrtypeREAL(SP), INTENT(IN) :: a,b,xREAL(SP) :: betai_sEND FUNCTION betai_s
FUNCTION betai_v(a,b,x)USE nrtypeREAL(SP), DIMENSION(:), INTENT(IN) :: a,b,xREAL(SP), DIMENSION(size(a)) :: betai_vEND FUNCTION betai_v
END INTERFACEINTERFACE bico
FUNCTION bico_s(n,k)USE nrtypeINTEGER(I4B), INTENT(IN) :: n,kREAL(SP) :: bico_sEND FUNCTION bico_s
FUNCTION bico_v(n,k)USE nrtypeINTEGER(I4B), DIMENSION(:), INTENT(IN) :: n,kREAL(SP), DIMENSION(size(n)) :: bico_v
-
1390 Appendix C2. Alphabetical Listing of Explicit Interfaces
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
erica only),or send email to directcustserv@
cambridge.org (outside N
orth Am
erica).
END FUNCTION bico_vEND INTERFACEINTERFACE
FUNCTION bnldev(pp,n)USE nrtypeREAL(SP), INTENT(IN) :: ppINTEGER(I4B), INTENT(IN) :: nREAL(SP) :: bnldevEND FUNCTION bnldev
END INTERFACEINTERFACE
FUNCTION brent(ax,bx,cx,func,tol,xmin)USE nrtypeREAL(SP), INTENT(IN) :: ax,bx,cx,tolREAL(SP), INTENT(OUT) :: xminREAL(SP) :: brentINTERFACE
FUNCTION func(x)USE nrtypeREAL(SP), INTENT(IN) :: xREAL(SP) :: funcEND FUNCTION func
END INTERFACEEND FUNCTION brent
END INTERFACEINTERFACE
SUBROUTINE broydn(x,check)USE nrtypeREAL(SP), DIMENSION(:), INTENT(INOUT) :: xLOGICAL(LGT), INTENT(OUT) :: checkEND SUBROUTINE broydn
END INTERFACEINTERFACE
SUBROUTINE bsstep(y,dydx,x,htry,eps,yscal,hdid,hnext,derivs)USE nrtypeREAL(SP), DIMENSION(:), INTENT(INOUT) :: yREAL(SP), DIMENSION(:), INTENT(IN) :: dydx,yscalREAL(SP), INTENT(INOUT) :: xREAL(SP), INTENT(IN) :: htry,epsREAL(SP), INTENT(OUT) :: hdid,hnextINTERFACE
SUBROUTINE derivs(x,y,dydx)USE nrtypeREAL(SP), INTENT(IN) :: xREAL(SP), DIMENSION(:), INTENT(IN) :: yREAL(SP), DIMENSION(:), INTENT(OUT) :: dydxEND SUBROUTINE derivs
END INTERFACEEND SUBROUTINE bsstep
END INTERFACEINTERFACE
SUBROUTINE caldat(julian,mm,id,iyyy)USE nrtypeINTEGER(I4B), INTENT(IN) :: julianINTEGER(I4B), INTENT(OUT) :: mm,id,iyyyEND SUBROUTINE caldat
END INTERFACEINTERFACE
FUNCTION chder(a,b,c)USE nrtypeREAL(SP), INTENT(IN) :: a,bREAL(SP), DIMENSION(:), INTENT(IN) :: cREAL(SP), DIMENSION(size(c)) :: chderEND FUNCTION chder
-
Appendix C2. Alphabetical Listing of Explicit Interfaces 1391
Sam
ple page from N
UM
ER
ICA
L RE
CIP
ES
IN F
OR
TR
AN
90: TH
E A
rt of PA
RA
LLEL S
cientific Com
puting (ISB
N 0-521-57439-0)
Copyright (C
) 1986-1996 by Cam
bridge University P
ress.Program
s Copyright (C
) 1986-1996 by Num
erical Recipes S
oftware.
Perm
ission is granted for internet users to make one paper copy for their ow
n personal use. Further reproduction, or any copying of m
achine-readable files (including this one) to any server
computer, is strictly prohibited. T
o order Num
erical Recipes books
or CD
RO
Ms, visit w
ebsitehttp://w
ww
.nr.com or call 1-800-872-7423 (N
orth Am
e
top related