source: trunk/LMDZ.COMMON/libf/misc/pchsp_95_m.F90 @ 3525

Last change on this file since 3525 was 979, checked in by emillour, 11 years ago

Common dynamics:
Updates in the dynamics (seq and ) to keep up with updates
in LMDZ5 (up to LMDZ5 trunk, rev 1760):

  • General stuff (essentially to keep up with Earth model):
  • Updated makelmdz_fcm and makelmdz (more control on dimension.h, added option -mem, although it is not usefull for now)
  • Updated build_gcm with more control over fcm
  • Updated create_make_gcm (enable looking for code in subdirectories)
  • bibio:
  • updates (just renaming the files actually...) new_unit.F90 => new_unit_m.F90, pchsp_95.F90 => pchsp_95_m.F90 and pchfe_95.F90 => pchfe_95_m.F90
  • filtrez:
  • mod_fft.F90: use more baseline CPP directives for preprocessor compatibility
  • mod_filtre_fft_loc.F90: added this new file
  • filtreg_mod.f90: added calls to init_..._loc
  • filtreg.F: fixed calls to DGEMM into SGEMM (preprocessing does the switch)
  • dyn3d:
  • removed obsolete files: etat0_netcdf.F90 limit_netcdf.F90

pres2lev.F90

  • added new file : pres2lev_mod.F90 (module containing "old" pres2lev)
  • gcm.F: changed args to call to inidissip (added arg "vert_prof_dissip")
  • inidissip.F90: added arg "vert_prof_dissip" and the "earth model" discterizations (flagged with "planet_type=="earth")
  • comdissnew.h: added 'vert_prof_dissip' to the common block
  • guide_mod.F90: added the "use pres2lev_mod"
  • conf_gcm.F: cosmetics, and evaluation of vert_prof_dissip, (and also of dissip_* factors, for Earth model)
  • comconst.h : added dissip_factz,dissip_zref variables (for Earth mode dissip)
  • dyn3dpar:
  • removed obsolete files: etat0_netcdf.F90 limit_netcdf.F90

pres2lev.F90 mod_const_para.F90

  • added new files: pres2lev_mod.F90 (module containing "old" pres2lev)

mod_const_mpi

  • abort_gcm : better control of abort in parallel mode
  • gcm.F: changed args to call to inidissip (added arg "vert_prof_dissip")
  • inidissip.F90: added arg "vert_prof_dissip" and the "earth model" discterizations (flagged with "planet_type=="earth")
  • comdissnew.h: added 'vert_prof_dissip' to the common block
  • filtreg_p.F : bug correction (array bounds)
  • guide_p_mod.F90 : added the "use pres2lev_mod"
  • conf_gcm.F : cosmetics (and evaluation of vert_prof_dissip , and

also of dissip_* factors, for Earth model)
plus check if "adjust" is indeed not used in OpenMP

  • comconst.h : add dissip_factz,dissip_zref variables (for Earth mode dissip)

EM

File size: 4.2 KB
Line 
1module pchsp_95_m
2
3  implicit none
4
5contains
6
7  function pchsp_95(x, f, ibeg, iend, vc_beg, vc_end)
8
9    ! PURPOSE: Set derivatives needed to determine the Hermite
10    ! representation of the cubic spline interpolant to given data,
11    ! with specified boundary conditions.
12
13    ! Part of the "pchip" package.
14
15    ! CATEGORY: E1A
16
17    ! KEYWORDS: cubic hermite interpolation, piecewise cubic
18    ! interpolation, spline interpolation
19
20    ! DESCRIPTION: "pchsp" stands for "Piecewise Cubic Hermite Spline"
21    ! Computes the Hermite representation of the cubic spline
22    ! interpolant to the data given in X and F satisfying the boundary
23    ! conditions specified by Ibeg, iend, vc_beg and VC_end.
24
25    ! The resulting piecewise cubic Hermite function may be evaluated
26    ! by "pchfe" or "pchfd".
27
28    ! NOTE: This is a modified version of C. de Boor's cubic spline
29    ! routine "cubspl".
30
31    ! REFERENCE: Carl de Boor, A Practical Guide to Splines, Springer,
32    ! 2001, pages 43-47
33
34    use assert_eq_m, only: assert_eq
35
36    real, intent(in):: x(:)
37    ! independent variable values
38    ! The elements of X must be strictly increasing:
39    !                X(I-1) < X(I),  I = 2...N.
40    !           (Error return if not.)
41    ! (error if size(x) < 2)
42
43    real, intent(in):: f(:)
44    !     dependent variable values to be interpolated
45    !  F(I) is value corresponding to X(I).
46
47    INTEGER, intent(in):: ibeg
48    !     desired boundary condition at beginning of data
49
50    !        IBEG = 0  to set pchsp_95(1) so that the third derivative is con-
51    !              tinuous at X(2).  This is the "not a knot" condition
52    !              provided by de Boor's cubic spline routine CUBSPL.
53    !              This is the default boundary condition.
54    !        IBEG = 1  if first derivative at X(1) is given in VC_BEG.
55    !        IBEG = 2  if second derivative at X(1) is given in VC_BEG.
56    !        IBEG = 3  to use the 3-point difference formula for pchsp_95(1).
57    !              (Reverts to the default boundary condition if size(x) < 3 .)
58    !        IBEG = 4  to use the 4-point difference formula for pchsp_95(1).
59    !              (Reverts to the default boundary condition if size(x) < 4 .)
60
61    !          NOTES:
62    !           1. An error return is taken if IBEG is out of range.
63    !           2. For the "natural" boundary condition, use IBEG=2 and
64    !              VC_BEG=0.
65
66    INTEGER, intent(in):: iend
67    !           IC(2) = IEND, desired condition at end of data.
68    !  IEND may take on the same values as IBEG, but applied to
69    !  derivative at X(N). In case IEND = 1 or 2, The value is given in VC_END.
70
71    !          NOTES:
72    !           1. An error return is taken if IEND is out of range.
73    !           2. For the "natural" boundary condition, use IEND=2 and
74    !              VC_END=0.
75
76    REAL, intent(in), optional:: vc_beg
77    ! desired boundary value, as indicated above.
78    !           VC_BEG need be set only if IBEG = 1 or 2 .
79
80    REAL, intent(in), optional:: vc_end
81    ! desired boundary value, as indicated above.
82    !           VC_END need be set only if Iend = 1 or 2 .
83
84    real pchsp_95(size(x))
85    ! derivative values at the data points
86    !           These values will determine the cubic spline interpolant
87    !           with the requested boundary conditions.
88    !           The value corresponding to X(I) is stored in
89    !                PCHSP_95(I),  I=1...N.
90
91    ! LOCAL VARIABLES:
92    real wk(2, size(x)) ! real array of working storage
93    INTEGER n ! number of data points
94    integer ierr, ic(2)
95    real vc(2)
96
97    !-------------------------------------------------------------------
98
99    n = assert_eq(size(x), size(f), "pchsp_95 n")
100    if ((ibeg == 1 .or. ibeg == 2) .and. .not. present(vc_beg)) then
101       print *, "vc_beg required for IBEG = 1 or 2"
102       stop 1
103    end if
104    if ((iend == 1 .or. iend == 2) .and. .not. present(vc_end)) then
105       print *, "vc_end required for IEND = 1 or 2"
106       stop 1
107    end if
108    ic = (/ibeg, iend/)
109    if (present(vc_beg)) vc(1) = vc_beg
110    if (present(vc_end)) vc(2) = vc_end
111    call PCHSP(IC, VC, N, X, F, pchsp_95, 1, WK, size(WK), IERR)
112    if (ierr /= 0) stop 1
113
114  END function pchsp_95
115
116end module pchsp_95_m
Note: See TracBrowser for help on using the repository browser.