Numerical Recipes in Fortran 77 - The Art of Scientific Computing

Peter Kitson

ISBN : 052143064X

Order a printed copy of this book from Amazon.


Cover Design - Numerical Recipes in Fortran 77 - The Art of Scientific Computing
 

For your free electronic copy of this book please verify the numbers below. 

(We need to do this to make sure you're a person and not a malicious script)

Numbers

 




Sample Chapter From Numerical Recipes in Fortran 77 - The Art of Scientific Computing
     Copyright © William H. Press, Brian P. Flannery, Saul A. Teukolsky, William T. Vetterling



Chapter 1. Preliminaries

1.0 Introduction

This book, like its predecessor edition, is supposed to teach you methods of
numerical computing that are practical, efficient, and (insofar as possible) elegant.
We presume throughout this book that you, the reader, have particular tasks that you
want to get done. We view our job as educating you on how to proceed. Occasionally
we may try to reroute you briefly onto a particularly beautiful side road; but by and
large, we will guide you along main highways that lead to practical destinations.

Throughout this book, you will find us fearlessly editorializing, telling you
what you should and shouldn’t do. This prescriptive tone results from a conscious
decision on our part, and we hope that you will not find it irritating. We do not
claim that our advice is infallible! Rather, we are reacting against a tendency, in
the textbook literature of computation, to discuss every possible method that has
ever been invented, without ever offering a practical judgment on relative merit. We
do, therefore, offer you our practical judgments whenever we can. As you gain
experience, you will form your own opinion of how reliable our advice is.

We presume that you are able to read computer programs in FORTRAN, that
being the language of this version of Numerical Recipes (Second Edition). The
book Numerical Recipes in C (Second Edition) is separately available, if you prefer
to program in that language. Earlier editions of Numerical Recipes in Pascal and
Numerical Recipes Routines and Examples in BASIC are also available; while not
containing the additional material of the Second Edition versions in C and FORTRAN,
these versions are perfectly serviceable if Pascal or BASIC is your language of
choice.

When we include programs in the text, they look like this:

SUBROUTINE flmoon(n,nph,jd,frac)
INTEGER jd,n,nph
REAL frac,RAD
PARAMETER (RAD=3.14159265/180.)

Our programs begin with an introductory comment summarizing their purpose and explaining
their calling sequence. This routine calculates the phases of the moon. Given an integer
n and a code nph for the phase desired (nph = 0 for new moon, 1 for first quarter, 2 for
full, 3 for last quarter), the routine returns the Julian Day Number jd, and the fractional
part of a day frac to be added to it, of the nth such phase since January, 1900. Greenwich
Mean Time is assumed.

INTEGER i
REAL am,as,c,t,t2,xtra
c=n+nph/4. 
t=c/1236.85
t2=t**2
as=359.2242+29.105356*c
am=306.0253+385.816918*c+0.010730*t2 !
jd=2415020+28*n+7*nph
xtra=0.75933+1.53058868*c+(1.178e-4-1.55e-7*t)*t2
if(nph.eq.0.or.nph.eq.2)then
xtra=xtra+(0.1734-3.93e-4*t)*sin(RAD*as)-0.4068*sin(RAD*am)
else if(nph.eq.1.or.nph.eq.3)then
xtra=xtra+(0.1721-4.e-4*t)*sin(RAD*as)-0.6280*sin(RAD*am)
else
pause ’nph is unknown in flmoon’ 
endif
if(xtra.ge.0.)then
i=int(xtra)
else
i=int(xtra-1.)
endif
jd=jd+i
frac=xtra-i
return
END