source: LMDZ4/trunk/libf/bibio/pchdf.F @ 5428

Last change on this file since 5428 was 1425, checked in by lguez, 14 years ago

Replaced Numerical Recipes procedures for spline interpolation (not in
the public domain) by procedures from the Pchip package in the Slatec
library. This only affects the program "ce0l", not the program
"gcm". Tested on Brodie SX8 with "-debug" and "-prod", "-parallel
none" and "-parallel mpi". "start.nc" and "limit.nc" are
changed. "startphy.nc" is not changed. The relative change is of order
1e-7 or less. The revision makes the program faster (tested on Brodie
with "-prod -d 144x142x39", CPU time is 38 s, instead of 54
s). Procedures from Slatec are untouched, except for
"i1mach.F". Created procedures "pchfe_95" and "pchsp_95" which are
wrappers for "pchfe" and "pchsp" from Slatec. "pchfe_95" and
"pchsp_95" have a safer and simpler interface.

Replaced "make" by "sxgmake" in "arch-SX8_BRODIE.fcm". Added files for
compilation by FCM with "g95".

In "arch-linux-32bit.fcm", replaced "pgf90" by "pgf95". There was no
difference between "dev" and "debug" so added "-O1" to "dev". Added
debugging options. Removed "-Wl,-Bstatic
-L/usr/lib/gcc-lib/i386-linux/2.95.2", which usually produces an error
at link-time.

Bash is now ubiquitous while KornShell? is not so use Bash instead of
KornShell? in FCM.

Replaced some statements "write(6,*)" by "write(lunout,*)". Replaced
"stop" by "stop 1" in the case where "abort_gcm" is called with "ierr
/= 0". Removed "stop" statements at the end of procedures
"limit_netcdf" and main program "ce0l" (why not let the program end
normally?).

Made some arrays automatic instead of allocatable in "start_inter_3d".

Zeroed "wake_pe", "fm_therm", "entr_therm" and "detr_therm" in
"dyn3dpar/etat0_netcdf.F90". The parallel and sequential results of
"ce0l" are thus identical.

File size: 3.1 KB
Line 
1*DECK PCHDF
2      REAL FUNCTION PCHDF (K, X, S, IERR)
3C***BEGIN PROLOGUE  PCHDF
4C***SUBSIDIARY
5C***PURPOSE  Computes divided differences for PCHCE and PCHSP
6C***LIBRARY   SLATEC (PCHIP)
7C***TYPE      SINGLE PRECISION (PCHDF-S, DPCHDF-D)
8C***AUTHOR  Fritsch, F. N., (LLNL)
9C***DESCRIPTION
10C
11C          PCHDF:   PCHIP Finite Difference Formula
12C
13C     Uses a divided difference formulation to compute a K-point approx-
14C     imation to the derivative at X(K) based on the data in X and S.
15C
16C     Called by  PCHCE  and  PCHSP  to compute 3- and 4-point boundary
17C     derivative approximations.
18C
19C ----------------------------------------------------------------------
20C
21C     On input:
22C        K      is the order of the desired derivative approximation.
23C               K must be at least 3 (error return if not).
24C        X      contains the K values of the independent variable.
25C               X need not be ordered, but the values **MUST** be
26C               distinct.  (Not checked here.)
27C        S      contains the associated slope values:
28C                  S(I) = (F(I+1)-F(I))/(X(I+1)-X(I)), I=1(1)K-1.
29C               (Note that S need only be of length K-1.)
30C
31C     On return:
32C        S      will be destroyed.
33C        IERR   will be set to -1 if K.LT.2 .
34C        PCHDF  will be set to the desired derivative approximation if
35C               IERR=0 or to zero if IERR=-1.
36C
37C ----------------------------------------------------------------------
38C
39C***SEE ALSO  PCHCE, PCHSP
40C***REFERENCES  Carl de Boor, A Practical Guide to Splines, Springer-
41C                 Verlag, New York, 1978, pp. 10-16.
42C***ROUTINES CALLED  XERMSG
43C***REVISION HISTORY  (YYMMDD)
44C   820503  DATE WRITTEN
45C   820805  Converted to SLATEC library version.
46C   870813  Minor cosmetic changes.
47C   890411  Added SAVE statements (Vers. 3.2).
48C   890411  REVISION DATE from Version 3.2
49C   891214  Prologue converted to Version 4.0 format.  (BAB)
50C   900315  CALLs to XERROR changed to CALLs to XERMSG.  (THJ)
51C   900328  Added TYPE section.  (WRB)
52C   910408  Updated AUTHOR and DATE WRITTEN sections in prologue.  (WRB)
53C   920429  Revised format and order of references.  (WRB,FNF)
54C   930503  Improved purpose.  (FNF)
55C***END PROLOGUE  PCHDF
56C
57C**End
58C
59C  DECLARE ARGUMENTS.
60C
61      INTEGER  K, IERR
62      REAL  X(K), S(K)
63C
64C  DECLARE LOCAL VARIABLES.
65C
66      INTEGER  I, J
67      REAL  VALUE, ZERO
68      SAVE ZERO
69      DATA  ZERO /0./
70C
71C  CHECK FOR LEGAL VALUE OF K.
72C
73C***FIRST EXECUTABLE STATEMENT  PCHDF
74      IF (K .LT. 3)  GO TO 5001
75C
76C  COMPUTE COEFFICIENTS OF INTERPOLATING POLYNOMIAL.
77C
78      DO 10  J = 2, K-1
79         DO 9  I = 1, K-J
80            S(I) = (S(I+1)-S(I))/(X(I+J)-X(I))
81    9    CONTINUE
82   10 CONTINUE
83C
84C  EVALUATE DERIVATIVE AT X(K).
85C
86      VALUE = S(1)
87      DO 20  I = 2, K-1
88         VALUE = S(I) + VALUE*(X(K)-X(I))
89   20 CONTINUE
90C
91C  NORMAL RETURN.
92C
93      IERR = 0
94      PCHDF = VALUE
95      RETURN
96C
97C  ERROR RETURN.
98C
99 5001 CONTINUE
100C     K.LT.3 RETURN.
101      IERR = -1
102      CALL XERMSG ('SLATEC', 'PCHDF', 'K LESS THAN THREE', IERR, 1)
103      PCHDF = ZERO
104      RETURN
105C------------- LAST LINE OF PCHDF FOLLOWS ------------------------------
106      END
Note: See TracBrowser for help on using the repository browser.