Neko  0.8.1
A portable framework for high-order spectral element flow simulations
speclib.f90
Go to the documentation of this file.
1 ! Copyright (c) 2008-2020, UCHICAGO ARGONNE, LLC.
2 !
3 ! The UChicago Argonne, LLC as Operator of Argonne National
4 ! Laboratory holds copyright in the Software. The copyright holder
5 ! reserves all rights except those expressly granted to licensees,
6 ! and U.S. Government license rights.
7 !
8 ! Redistribution and use in source and binary forms, with or without
9 ! modification, are permitted provided that the following conditions
10 ! are met:
11 !
12 ! 1. Redistributions of source code must retain the above copyright
13 ! notice, this list of conditions and the disclaimer below.
14 !
15 ! 2. Redistributions in binary form must reproduce the above copyright
16 ! notice, this list of conditions and the disclaimer (as noted below)
17 ! in the documentation and/or other materials provided with the
18 ! distribution.
19 !
20 ! 3. Neither the name of ANL nor the names of its contributors
21 ! may be used to endorse or promote products derived from this software
22 ! without specific prior written permission.
23 !
24 ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 ! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27 ! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
28 ! UCHICAGO ARGONNE, LLC, THE U.S. DEPARTMENT OF
29 ! ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
31 ! TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 !
37 ! Additional BSD Notice
38 ! ---------------------
39 ! 1. This notice is required to be provided under our contract with
40 ! the U.S. Department of Energy (DOE). This work was produced at
41 ! Argonne National Laboratory under Contract
42 ! No. DE-AC02-06CH11357 with the DOE.
43 !
44 ! 2. Neither the United States Government nor UCHICAGO ARGONNE,
45 ! LLC nor any of their employees, makes any warranty,
46 ! express or implied, or assumes any liability or responsibility for the
47 ! accuracy, completeness, or usefulness of any information, apparatus,
48 ! product, or process disclosed, or represents that its use would not
49 ! infringe privately-owned rights.
50 !
51 ! 3. Also, reference herein to any specific commercial products, process,
52 ! or services by trade name, trademark, manufacturer or otherwise does
53 ! not necessarily constitute or imply its endorsement, recommendation,
54 ! or favoring by the United States Government or UCHICAGO ARGONNE LLC.
55 ! The views and opinions of authors expressed
56 ! herein do not necessarily state or reflect those of the United States
57 ! Government or UCHICAGO ARGONNE, LLC, and shall
58 ! not be used for advertising or product endorsement purposes.
59 !
60 !==============================================================================
61 !
75 !
76 !------------------------------------------------------------------------------
77 !
78 ! ABBRIVIATIONS:
79 !
80 ! M - Set of mesh points
81 ! Z - Set of collocation/quadrature points
82 ! W - Set of quadrature weights
83 ! H - Lagrangian interpolant
84 ! D - Derivative operator
85 ! I - Interpolation operator
86 ! GL - Gauss Legendre
87 ! GLL - Gauss-Lobatto Legendre
88 ! GJ - Gauss Jacobi
89 ! GLJ - Gauss-Lobatto Jacobi
90 !
91 !
92 ! MAIN ROUTINES:
93 !
94 ! Points and weights:
95 !
96 ! ZWGL Compute Gauss Legendre points and weights
97 ! ZWGLL Compute Gauss-Lobatto Legendre points and weights
98 ! ZWGJ Compute Gauss Jacobi points and weights (general)
99 ! ZWGLJ Compute Gauss-Lobatto Jacobi points and weights (general)
100 !
101 ! Lagrangian interpolants:
102 !
103 ! HGL Compute Gauss Legendre Lagrangian interpolant
104 ! HGLL Compute Gauss-Lobatto Legendre Lagrangian interpolant
105 ! HGJ Compute Gauss Jacobi Lagrangian interpolant (general)
106 ! HGLJ Compute Gauss-Lobatto Jacobi Lagrangian interpolant (general)
107 !
108 ! Derivative operators:
109 !
110 ! DGLL Compute Gauss-Lobatto Legendre derivative matrix
111 ! DGLLGL Compute derivative matrix for a staggered mesh (GLL->GL)
112 ! DGJ Compute Gauss Jacobi derivative matrix (general)
113 ! DGLJ Compute Gauss-Lobatto Jacobi derivative matrix (general)
114 ! DGLJGJ Compute derivative matrix for a staggered mesh (GLJ->GJ) (general)
115 !
116 ! Interpolation operators:
117 !
118 ! IGLM Compute interpolation operator GL -> M
119 ! IGLLM Compute interpolation operator GLL -> M
120 ! IGJM Compute interpolation operator GJ -> M (general)
121 ! IGLJM Compute interpolation operator GLJ -> M (general)
122 !
123 ! Other:
124 !
125 ! PNLEG Compute Legendre polynomial of degree N
126 ! PNDLEG Compute derivative of Legendre polynomial of degree N
127 !
128 ! Comments:
129 !
130 ! Note that many of the above routines exist in both single and
131 ! double precision. If the name of the single precision routine is
132 ! SUB, the double precision version is called SUBD. In most cases
133 ! all the "low-level" arithmetic is done in double precision, even
134 ! for the single precsion versions.
135 !
136 ! Useful references:
137 !
138 ! [1] Gabor Szego: Orthogonal Polynomials, American Mathematical Society,
139 ! Providence, Rhode Island, 1939.
140 ! [2] Abramowitz & Stegun: Handbook of Mathematical Functions,
141 ! Dover, New York, 1972.
142 ! [3] Canuto, Hussaini, Quarteroni & Zang: Spectral Methods in Fluid
143 ! Dynamics, Springer-Verlag, 1988.
144 !
145 !
146 !==============================================================================
147 module speclib
148  use num_types, only : rp
149  use utils, only: neko_error
150 
151 
152 contains
159  SUBROUTINE zwgl (Z,W,NP)
160  REAL(KIND=rp) z(1),w(1), alpha, beta
161  alpha = 0.
162  beta = 0.
163  CALL zwgj (z,w,np,alpha,beta)
164  RETURN
165  end subroutine zwgl
166 
167  SUBROUTINE zwgll (Z,W,NP)
168 !--------------------------------------------------------------------
169 !
170 ! Generate NP Gauss-Lobatto Legendre points (Z) and weights (W)
171 ! associated with Jacobi polynomial P(N)(alpha=0,beta=0).
172 ! The polynomial degree N=NP-1.
173 ! Z and W are in single precision, but all the arithmetic
174 ! operations are done in double precision.
175 !
176 !--------------------------------------------------------------------
177  REAL(KIND=rp) z(1),w(1), alpha, beta
178  alpha = 0.
179  beta = 0.
180  CALL zwglj (z,w,np,alpha,beta)
181  RETURN
182  end subroutine zwgll
183 
184  SUBROUTINE zwgj (Z,W,NP,ALPHA,BETA)
185 !--------------------------------------------------------------------
186 !
187 ! Generate NP GAUSS JACOBI points (Z) and weights (W)
188 ! associated with Jacobi polynomial P(N)(alpha>-1,beta>-1).
189 ! The polynomial degree N=NP-1.
190 ! Single precision version.
191 !
192 !--------------------------------------------------------------------
193  parameter(nmax=84)
194  parameter(nzd = nmax)
195  REAL(KIND=rp) zd(nzd),wd(nzd),alphad,betad
196  REAL(KIND=rp) z(1),w(1),alpha,beta
197 
198  npmax = nzd
199  IF (np.GT.npmax) THEN
200  WRITE (6,*) 'Too large polynomial degree in ZWGJ'
201  WRITE (6,*) 'Maximum polynomial degree is',nmax
202  WRITE (6,*) 'Here NP=',np
203  call neko_error
204  ENDIF
205  alphad = alpha
206  betad = beta
207  CALL zwgjd (zd,wd,np,alphad,betad)
208  DO 100 i=1,np
209  z(i) = zd(i)
210  w(i) = wd(i)
211 100 CONTINUE
212  RETURN
213  end subroutine zwgj
214 
215  SUBROUTINE zwgjd (Z,W,NP,ALPHA,BETA)
216 !--------------------------------------------------------------------
217 !
218 ! Generate NP GAUSS JACOBI points (Z) and weights (W)
219 ! associated with Jacobi polynomial P(N)(alpha>-1,beta>-1).
220 ! The polynomial degree N=NP-1.
221 ! Double precision version.
222 !
223 !--------------------------------------------------------------------
224  IMPLICIT REAL(KIND=RP) (a-h,o-z)
225  REAL(KIND=rp) z(1),w(1),alpha,beta
226 
227  n = np-1
228  dn = ((n))
229  one = 1.
230  two = 2.
231  apb = alpha+beta
232 
233  IF (np.LE.0) THEN
234  WRITE (6,*) 'ZWGJD: Minimum number of Gauss points is 1',np
235  call neko_error
236  ENDIF
237  IF ((alpha.LE.-one).OR.(beta.LE.-one)) THEN
238  WRITE (6,*) 'ZWGJD: Alpha and Beta must be greater than -1'
239  call neko_error
240  ENDIF
241 
242  IF (np.EQ.1) THEN
243  z(1) = (beta-alpha)/(apb+two)
244  w(1) = gammaf(alpha+one)*gammaf(beta+one)/gammaf(apb+two) &
245  * two**(apb+one)
246  RETURN
247  ENDIF
248 
249  CALL jacg (z,np,alpha,beta)
250 
251  np1 = n+1
252  np2 = n+2
253  dnp1 = ((np1))
254  dnp2 = ((np2))
255  fac1 = dnp1+alpha+beta+one
256  fac2 = fac1+dnp1
257  fac3 = fac2+one
258  fnorm = pnormj(np1,alpha,beta)
259  rcoef = (fnorm*fac2*fac3)/(two*fac1*dnp2)
260  DO 100 i=1,np
261  CALL jacobf (p,pd,pm1,pdm1,pm2,pdm2,np2,alpha,beta,z(i))
262  w(i) = -rcoef/(p*pdm1)
263 100 CONTINUE
264  RETURN
265  end subroutine zwgjd
266 
267  SUBROUTINE zwglj (Z,W,NP,ALPHA,BETA)
268 !--------------------------------------------------------------------
269 !
270 ! Generate NP GAUSS LOBATTO JACOBI points (Z) and weights (W)
271 ! associated with Jacobi polynomial P(N)(alpha>-1,beta>-1).
272 ! The polynomial degree N=NP-1.
273 ! Single precision version.
274 !
275 !--------------------------------------------------------------------
276  parameter(nmax=84)
277  parameter(nzd = nmax)
278  REAL(KIND=rp) zd(nzd),wd(nzd),alphad,betad
279  REAL(KIND=rp) z(1),w(1),alpha,beta
280 
281  npmax = nzd
282  IF (np.GT.npmax) THEN
283  WRITE (6,*) 'Too large polynomial degree in ZWGLJ'
284  WRITE (6,*) 'Maximum polynomial degree is',nmax
285  WRITE (6,*) 'Here NP=',np
286  call neko_error
287  ENDIF
288  alphad = alpha
289  betad = beta
290  CALL zwgljd (zd,wd,np,alphad,betad)
291  DO 100 i=1,np
292  z(i) = zd(i)
293  w(i) = wd(i)
294 100 CONTINUE
295  RETURN
296  end subroutine zwglj
297 
298  SUBROUTINE zwgljd (Z,W,NP,ALPHA,BETA)
299 !--------------------------------------------------------------------
300 !
301 ! Generate NP GAUSS LOBATTO JACOBI points (Z) and weights (W)
302 ! associated with Jacobi polynomial P(N)(alpha>-1,beta>-1).
303 ! The polynomial degree N=NP-1.
304 ! Double precision version.
305 !
306 !--------------------------------------------------------------------
307  IMPLICIT REAL(KIND=RP) (a-h,o-z)
308  REAL(KIND=rp) z(np),w(np),alpha,beta
309 
310  n = np-1
311  nm1 = n-1
312  one = 1.
313  two = 2.
314 
315  IF (np.LE.1) THEN
316  WRITE (6,*) 'ZWGLJD: Minimum number of Gauss-Lobatto points is 2'
317  WRITE (6,*) 'ZWGLJD: alpha,beta:',alpha,beta,np
318  call neko_error
319  ENDIF
320  IF ((alpha.LE.-one).OR.(beta.LE.-one)) THEN
321  WRITE (6,*) 'ZWGLJD: Alpha and Beta must be greater than -1'
322  call neko_error
323  ENDIF
324 
325  IF (nm1.GT.0) THEN
326  alpg = alpha+one
327  betg = beta+one
328  CALL zwgjd (z(2),w(2),nm1,alpg,betg)
329  ENDIF
330  z(1) = -one
331  z(np) = one
332  DO 100 i=2,np-1
333  w(i) = w(i)/(one-z(i)**2)
334 100 CONTINUE
335  CALL jacobf (p,pd,pm1,pdm1,pm2,pdm2,n,alpha,beta,z(1))
336  w(1) = endw1(n,alpha,beta)/(two*pd)
337  CALL jacobf (p,pd,pm1,pdm1,pm2,pdm2,n,alpha,beta,z(np))
338  w(np) = endw2(n,alpha,beta)/(two*pd)
339 
340 ! RETURN
341  end subroutine zwgljd
342 
343  REAL(kind=rp) FUNCTION endw1 (N,ALPHA,BETA)
344  IMPLICIT REAL(KIND=RP) (a-h,o-z)
345  REAL(kind=rp) alpha,beta
346  zero = 0.
347  one = 1.
348  two = 2.
349  three = 3.
350  four = 4.
351  apb = alpha+beta
352  IF (n.EQ.0) THEN
353  endw1 = zero
354  RETURN
355  ENDIF
356  f1 = gammaf(alpha+two)*gammaf(beta+one)/gammaf(apb+three)
357  f1 = f1*(apb+two)*two**(apb+two)/two
358  IF (n.EQ.1) THEN
359  endw1 = f1
360  RETURN
361  ENDIF
362  fint1 = gammaf(alpha+two)*gammaf(beta+one)/gammaf(apb+three)
363  fint1 = fint1*two**(apb+two)
364  fint2 = gammaf(alpha+two)*gammaf(beta+two)/gammaf(apb+four)
365  fint2 = fint2*two**(apb+three)
366  f2 = (-two*(beta+two)*fint1 + (apb+four)*fint2) &
367  * (apb+three)/four
368  IF (n.EQ.2) THEN
369  endw1 = f2
370  RETURN
371  ENDIF
372  DO 100 i=3,n
373  di = ((i-1))
374  abn = alpha+beta+di
375  abnn = abn+di
376  a1 = -(two*(di+alpha)*(di+beta))/(abn*abnn*(abnn+one))
377  a2 = (two*(alpha-beta))/(abnn*(abnn+two))
378  a3 = (two*(abn+one))/((abnn+two)*(abnn+one))
379  f3 = -(a2*f2+a1*f1)/a3
380  f1 = f2
381  f2 = f3
382 100 CONTINUE
383  endw1 = f3
384  RETURN
385  end function endw1
386 
387  REAL(kind=rp) FUNCTION endw2 (N,ALPHA,BETA)
388  IMPLICIT REAL(KIND=RP) (a-h,o-z)
389  REAL(kind=rp) alpha,beta
390  zero = 0.
391  one = 1.
392  two = 2.
393  three = 3.
394  four = 4.
395  apb = alpha+beta
396  IF (n.EQ.0) THEN
397  endw2 = zero
398  RETURN
399  ENDIF
400  f1 = gammaf(alpha+one)*gammaf(beta+two)/gammaf(apb+three)
401  f1 = f1*(apb+two)*two**(apb+two)/two
402  IF (n.EQ.1) THEN
403  endw2 = f1
404  RETURN
405  ENDIF
406  fint1 = gammaf(alpha+one)*gammaf(beta+two)/gammaf(apb+three)
407  fint1 = fint1*two**(apb+two)
408  fint2 = gammaf(alpha+two)*gammaf(beta+two)/gammaf(apb+four)
409  fint2 = fint2*two**(apb+three)
410  f2 = (two*(alpha+two)*fint1 - (apb+four)*fint2) &
411  * (apb+three)/four
412  IF (n.EQ.2) THEN
413  endw2 = f2
414  RETURN
415  ENDIF
416  DO 100 i=3,n
417  di = ((i-1))
418  abn = alpha+beta+di
419  abnn = abn+di
420  a1 = -(two*(di+alpha)*(di+beta))/(abn*abnn*(abnn+one))
421  a2 = (two*(alpha-beta))/(abnn*(abnn+two))
422  a3 = (two*(abn+one))/((abnn+two)*(abnn+one))
423  f3 = -(a2*f2+a1*f1)/a3
424  f1 = f2
425  f2 = f3
426 100 CONTINUE
427  endw2 = f3
428  RETURN
429  end function endw2
430 
431  REAL(kind=rp) FUNCTION gammaf (X)
432  IMPLICIT REAL(KIND=RP) (a-h,o-z)
433  REAL(kind=rp) x
434  zero = 0.0
435  half = 0.5
436  one = 1.0
437  two = 2.0
438  four = 4.0
439  pi = four*atan(one)
440  gammaf = one
441  IF (x.EQ.-half) gammaf = -two*sqrt(pi)
442  IF (x.EQ. half) gammaf = sqrt(pi)
443  IF (x.EQ. one ) gammaf = one
444  IF (x.EQ. two ) gammaf = one
445  IF (x.EQ. 1.5 ) gammaf = sqrt(pi)/2.
446  IF (x.EQ. 2.5) gammaf = 1.5*sqrt(pi)/2.
447  IF (x.EQ. 3.5) gammaf = 0.5*(2.5*(1.5*sqrt(pi)))
448  IF (x.EQ. 3. ) gammaf = 2.
449  IF (x.EQ. 4. ) gammaf = 6.
450  IF (x.EQ. 5. ) gammaf = 24.
451  IF (x.EQ. 6. ) gammaf = 120.
452  RETURN
453  end function gammaf
454 
455  REAL(kind=rp) FUNCTION pnormj (N,ALPHA,BETA)
456  IMPLICIT REAL(KIND=RP) (a-h,o-z)
457  REAL(kind=rp) alpha,beta
458  one = 1.
459  two = 2.
460  dn = ((n))
461  const = alpha+beta+one
462  IF (n.LE.1) THEN
463  prod = gammaf(dn+alpha)*gammaf(dn+beta)
464  prod = prod/(gammaf(dn)*gammaf(dn+alpha+beta))
465  pnormj = prod * two**const/(two*dn+const)
466  RETURN
467  ENDIF
468  prod = gammaf(alpha+one)*gammaf(beta+one)
469  prod = prod/(two*(one+const)*gammaf(const+one))
470  prod = prod*(one+alpha)*(two+alpha)
471  prod = prod*(one+beta)*(two+beta)
472  DO 100 i=3,n
473  dindx = ((i))
474  frac = (dindx+alpha)*(dindx+beta)/(dindx*(dindx+alpha+beta))
475  prod = prod*frac
476 100 CONTINUE
477  pnormj = prod * two**const/(two*dn+const)
478  RETURN
479  end function pnormj
480 
481  SUBROUTINE jacg (XJAC,NP,ALPHA,BETA)
482 !--------------------------------------------------------------------
483 !
484 ! Compute NP Gauss points XJAC, which are the zeros of the
485 ! Jacobi polynomial J(NP) with parameters ALPHA and BETA.
486 ! ALPHA and BETA determines the specific type of Gauss points.
487 ! Examples:
488 ! ALPHA = BETA = 0.0 -> Legendre points
489 ! ALPHA = BETA = -0.5 -> Chebyshev points
490 !
491 !--------------------------------------------------------------------
492  IMPLICIT REAL(KIND=RP) (a-h,o-z)
493  REAL(KIND=rp) xjac(1)
494  DATA kstop /10/
495  DATA eps/1.0e-12_rp/
496  n = np-1
497  one = 1.
498  dth = 4.*atan(one)/(2.*((n))+2.)
499  DO 40 j=1,np
500  IF (j.EQ.1) THEN
501  x = cos((2.*(((j))-1.)+1.)*dth)
502  ELSE
503  x1 = cos((2.*(((j))-1.)+1.)*dth)
504  x2 = xlast
505  x = (x1+x2)/2.
506  ENDIF
507  DO 30 k=1,kstop
508  CALL jacobf (p,pd,pm1,pdm1,pm2,pdm2,np,alpha,beta,x)
509  recsum = 0.
510  jm = j-1
511  DO 29 i=1,jm
512  recsum = recsum+1./(x-xjac(np-i+1))
513 29 CONTINUE
514  delx = -p/(pd-recsum*p)
515  x = x+delx
516  IF (abs(delx) .LT. eps) GOTO 31
517 30 CONTINUE
518 31 CONTINUE
519  xjac(np-j+1) = x
520  xlast = x
521 40 CONTINUE
522  DO 200 i=1,np
523  xmin = 2.
524  DO 100 j=i,np
525  IF (xjac(j).LT.xmin) THEN
526  xmin = xjac(j)
527  jmin = j
528  ENDIF
529 100 CONTINUE
530  IF (jmin.NE.i) THEN
531  swap = xjac(i)
532  xjac(i) = xjac(jmin)
533  xjac(jmin) = swap
534  ENDIF
535 200 CONTINUE
536  RETURN
537  end subroutine jacg
538 
539  SUBROUTINE jacobf (POLY,PDER,POLYM1,PDERM1,POLYM2,PDERM2,N,ALP,BET,X)
540 !--------------------------------------------------------------------
541 !
542 ! Computes the Jacobi polynomial (POLY) and its derivative (PDER)
543 ! of degree N at X.
544 !
545 !--------------------------------------------------------------------
546  IMPLICIT REAL(KIND=RP) (a-h,o-z)
547  apb = alp+bet
548  poly = 1.
549  pder = 0.
550  IF (n .EQ. 0) RETURN
551  polyl = poly
552  pderl = pder
553  poly = (alp-bet+(apb+2.)*x)/2.
554  pder = (apb+2.)/2.
555  IF (n .EQ. 1) RETURN
556  DO 20 k=2,n
557  dk = ((k))
558  a1 = 2.*dk*(dk+apb)*(2.*dk+apb-2.)
559  a2 = (2.*dk+apb-1.)*(alp**2-bet**2)
560  b3 = (2.*dk+apb-2.)
561  a3 = b3*(b3+1.)*(b3+2.)
562  a4 = 2.*(dk+alp-1.)*(dk+bet-1.)*(2.*dk+apb)
563  polyn = ((a2+a3*x)*poly-a4*polyl)/a1
564  pdern = ((a2+a3*x)*pder-a4*pderl+a3*poly)/a1
565  psave = polyl
566  pdsave = pderl
567  polyl = poly
568  poly = polyn
569  pderl = pder
570  pder = pdern
571 20 CONTINUE
572  polym1 = polyl
573  pderm1 = pderl
574  polym2 = psave
575  pderm2 = pdsave
576  RETURN
577  end subroutine jacobf
578 
579  REAL(kind=rp) FUNCTION hgj (II,Z,ZGJ,NP,ALPHA,BETA)
580 !---------------------------------------------------------------------
581 !
582 ! Compute the value of the Lagrangian interpolant HGJ through
583 ! the NP Gauss Jacobi points ZGJ at the point Z.
584 ! Single precision version.
585 !
586 !---------------------------------------------------------------------
587  parameter(nmax=84)
588  parameter(nzd = nmax)
589  REAL(kind=rp) zd,zgjd(nzd),alphad,betad
590  REAL(kind=rp) z,zgj(1),alpha,beta
591  npmax = nzd
592  IF (np.GT.npmax) THEN
593  WRITE (6,*) 'Too large polynomial degree in HGJ'
594  WRITE (6,*) 'Maximum polynomial degree is',nmax
595  WRITE (6,*) 'Here NP=',np
596  call neko_error
597  ENDIF
598  zd = z
599  DO 100 i=1,np
600  zgjd(i) = zgj(i)
601 100 CONTINUE
602  alphad = alpha
603  betad = beta
604  hgj = hgjd(ii,zd,zgjd,np,alphad,betad)
605  RETURN
606  end function hgj
607 
608  REAL(kind=rp) FUNCTION hgjd (II,Z,ZGJ,NP,ALPHA,BETA)
609 !---------------------------------------------------------------------
610 !
611 ! Compute the value of the Lagrangian interpolant HGJD through
612 ! the NZ Gauss-Lobatto Jacobi points ZGJ at the point Z.
613 ! Double precision version.
614 !
615 !---------------------------------------------------------------------
616  IMPLICIT REAL(KIND=RP) (a-h,o-z)
617  REAL(kind=rp) z,zgj(1),alpha,beta
618  eps = 1.e-5
619  one = 1.
620  zi = zgj(ii)
621  dz = z-zi
622  IF (abs(dz).LT.eps) THEN
623  hgjd = one
624  RETURN
625  ENDIF
626  CALL jacobf (pzi,pdzi,pm1,pdm1,pm2,pdm2,np,alpha,beta,zi)
627  CALL jacobf (pz,pdz,pm1,pdm1,pm2,pdm2,np,alpha,beta,z)
628  hgjd = pz/(pdzi*(z-zi))
629  RETURN
630  end function hgjd
631 
632  REAL(kind=rp) FUNCTION hglj (II,Z,ZGLJ,NP,ALPHA,BETA)
633 !---------------------------------------------------------------------
634 !
635 ! Compute the value of the Lagrangian interpolant HGLJ through
636 ! the NZ Gauss-Lobatto Jacobi points ZGLJ at the point Z.
637 ! Single precision version.
638 !
639 !---------------------------------------------------------------------
640  parameter(nmax=84)
641  parameter(nzd = nmax)
642  REAL(kind=rp) zd,zgljd(nzd),alphad,betad
643  REAL(kind=rp) z,zglj(1),alpha,beta
644  npmax = nzd
645  IF (np.GT.npmax) THEN
646  WRITE (6,*) 'Too large polynomial degree in HGLJ'
647  WRITE (6,*) 'Maximum polynomial degree is',nmax
648  WRITE (6,*) 'Here NP=',np
649  call neko_error
650  ENDIF
651  zd = z
652  DO 100 i=1,np
653  zgljd(i) = zglj(i)
654 100 CONTINUE
655  alphad = alpha
656  betad = beta
657  hglj = hgljd(ii,zd,zgljd,np,alphad,betad)
658  RETURN
659  end function hglj
660 
661  REAL(kind=rp) FUNCTION hgljd (I,Z,ZGLJ,NP,ALPHA,BETA)
662 !---------------------------------------------------------------------
663 !
664 ! Compute the value of the Lagrangian interpolant HGLJD through
665 ! the NZ Gauss-Lobatto Jacobi points ZJACL at the point Z.
666 ! Double precision version.
667 !
668 !---------------------------------------------------------------------
669  IMPLICIT REAL(KIND=RP) (a-h,o-z)
670  REAL(kind=rp) z,zglj(1),alpha,beta
671  eps = 1.e-5
672  one = 1.
673  zi = zglj(i)
674  dz = z-zi
675  IF (abs(dz).LT.eps) THEN
676  hgljd = one
677  RETURN
678  ENDIF
679  n = np-1
680  dn = ((n))
681  eigval = -dn*(dn+alpha+beta+one)
682  CALL jacobf (pi,pdi,pm1,pdm1,pm2,pdm2,n,alpha,beta,zi)
683  const = eigval*pi+alpha*(one+zi)*pdi-beta*(one-zi)*pdi
684  CALL jacobf (p,pd,pm1,pdm1,pm2,pdm2,n,alpha,beta,z)
685  hgljd = (one-z**2)*pd/(const*(z-zi))
686  RETURN
687  end function hgljd
688 
689  SUBROUTINE dgj (D,DT,Z,NZ,NZD,ALPHA,BETA)
690 !-----------------------------------------------------------------
691 !
692 ! Compute the derivative matrix D and its transpose DT
693 ! associated with the Nth order Lagrangian interpolants
694 ! through the NZ Gauss Jacobi points Z.
695 ! Note: D and DT are square matrices.
696 ! Single precision version.
697 !
698 !-----------------------------------------------------------------
699  parameter(nmax=84)
700  parameter(nzdd = nmax)
701  REAL(KIND=rp) dd(nzdd,nzdd),dtd(nzdd,nzdd),zd(nzdd),alphad,betad
702  REAL(KIND=rp) d(nzd,nzd),dt(nzd,nzd),z(1),alpha,beta
703 
704  IF (nz.LE.0) THEN
705  WRITE (6,*) 'DGJ: Minimum number of Gauss points is 1'
706  call neko_error
707  ENDIF
708  IF (nz .GT. nmax) THEN
709  WRITE (6,*) 'Too large polynomial degree in DGJ'
710  WRITE (6,*) 'Maximum polynomial degree is',nmax
711  WRITE (6,*) 'Here Nz=',nz
712  call neko_error
713  ENDIF
714  IF ((alpha.LE.-1.).OR.(beta.LE.-1.)) THEN
715  WRITE (6,*) 'DGJ: Alpha and Beta must be greater than -1'
716  call neko_error
717  ENDIF
718  alphad = alpha
719  betad = beta
720  DO 100 i=1,nz
721  zd(i) = z(i)
722 100 CONTINUE
723  CALL dgjd (dd,dtd,zd,nz,nzdd,alphad,betad)
724  DO i=1,nz
725  DO j=1,nz
726  d(i,j) = dd(i,j)
727  dt(i,j) = dtd(i,j)
728  END DO
729  END DO
730  RETURN
731  end subroutine dgj
732 
733  SUBROUTINE dgjd (D,DT,Z,NZ,NZD,ALPHA,BETA)
734 !-----------------------------------------------------------------
735 !
736 ! Compute the derivative matrix D and its transpose DT
737 ! associated with the Nth order Lagrangian interpolants
738 ! through the NZ Gauss Jacobi points Z.
739 ! Note: D and DT are square matrices.
740 ! Double precision version.
741 !
742 !-----------------------------------------------------------------
743  IMPLICIT REAL(KIND=RP) (a-h,o-z)
744  REAL(KIND=rp) d(nzd,nzd),dt(nzd,nzd),z(1),alpha,beta
745  n = nz-1
746  dn = ((n))
747  one = 1.
748  two = 2.
749 
750  IF (nz.LE.1) THEN
751  WRITE (6,*) 'DGJD: Minimum number of Gauss-Lobatto points is 2'
752  call neko_error
753  ENDIF
754  IF ((alpha.LE.-one).OR.(beta.LE.-one)) THEN
755  WRITE (6,*) 'DGJD: Alpha and Beta must be greater than -1'
756  call neko_error
757  ENDIF
758 
759  DO i=1,nz
760  DO j=1,nz
761  CALL jacobf (pi,pdi,pm1,pdm1,pm2,pdm2,nz,alpha,beta,z(i))
762  CALL jacobf (pj,pdj,pm1,pdm1,pm2,pdm2,nz,alpha,beta,z(j))
763  IF (i.NE.j) d(i,j) = pdi/(pdj*(z(i)-z(j)))
764  IF (i.EQ.j) d(i,j) = ((alpha+beta+two)*z(i)+alpha-beta)/ &
765  (two*(one-z(i)**2))
766  dt(j,i) = d(i,j)
767  END DO
768  END DO
769  RETURN
770  end subroutine dgjd
771 
772  SUBROUTINE dglj (D,DT,Z,NZ,NZD,ALPHA,BETA)
773 !-----------------------------------------------------------------
774 !
775 ! Compute the derivative matrix D and its transpose DT
776 ! associated with the Nth order Lagrangian interpolants
777 ! through the NZ Gauss-Lobatto Jacobi points Z.
778 ! Note: D and DT are square matrices.
779 ! Single precision version.
780 !
781 !-----------------------------------------------------------------
782  parameter(nmax=84)
783  parameter(nzdd = nmax)
784  REAL(KIND=rp) dd(nzdd,nzdd),dtd(nzdd,nzdd),zd(nzdd),alphad,betad
785  REAL(KIND=rp) d(nzd,nzd),dt(nzd,nzd),z(1),alpha,beta
786 
787  IF (nz.LE.1) THEN
788  WRITE (6,*) 'DGLJ: Minimum number of Gauss-Lobatto points is 2'
789  call neko_error
790  ENDIF
791  IF (nz .GT. nmax) THEN
792  WRITE (6,*) 'Too large polynomial degree in DGLJ'
793  WRITE (6,*) 'Maximum polynomial degree is',nmax
794  WRITE (6,*) 'Here NZ=',nz
795  call neko_error
796  ENDIF
797  IF ((alpha.LE.-1.).OR.(beta.LE.-1.)) THEN
798  WRITE (6,*) 'DGLJ: Alpha and Beta must be greater than -1'
799  call neko_error
800  ENDIF
801  alphad = alpha
802  betad = beta
803  DO 100 i=1,nz
804  zd(i) = z(i)
805 100 CONTINUE
806  CALL dgljd (dd,dtd,zd,nz,nzdd,alphad,betad)
807  DO i=1,nz
808  DO j=1,nz
809  d(i,j) = dd(i,j)
810  dt(i,j) = dtd(i,j)
811  END DO
812  END DO
813  RETURN
814  end subroutine dglj
815 
816  SUBROUTINE dgljd (D,DT,Z,NZ,NZD,ALPHA,BETA)
817 !-----------------------------------------------------------------
818 !
819 ! Compute the derivative matrix D and its transpose DT
820 ! associated with the Nth order Lagrangian interpolants
821 ! through the NZ Gauss-Lobatto Jacobi points Z.
822 ! Note: D and DT are square matrices.
823 ! Double precision version.
824 !
825 !-----------------------------------------------------------------
826  IMPLICIT REAL(KIND=RP) (a-h,o-z)
827  REAL(KIND=rp) d(nzd,nzd),dt(nzd,nzd),z(1),alpha,beta
828  n = nz-1
829  dn = ((n))
830  one = 1.
831  two = 2.
832  eigval = -dn*(dn+alpha+beta+one)
833 
834  IF (nz.LE.1) THEN
835  WRITE (6,*) 'DGLJD: Minimum number of Gauss-Lobatto points is 2'
836  call neko_error
837  ENDIF
838  IF ((alpha.LE.-one).OR.(beta.LE.-one)) THEN
839  WRITE (6,*) 'DGLJD: Alpha and Beta must be greater than -1'
840  call neko_error
841  ENDIF
842 
843  DO i=1,nz
844  DO j=1,nz
845  CALL jacobf (pi,pdi,pm1,pdm1,pm2,pdm2,n,alpha,beta,z(i))
846  CALL jacobf (pj,pdj,pm1,pdm1,pm2,pdm2,n,alpha,beta,z(j))
847  ci = eigval*pi-(beta*(one-z(i))-alpha*(one+z(i)))*pdi
848  cj = eigval*pj-(beta*(one-z(j))-alpha*(one+z(j)))*pdj
849  IF (i.NE.j) d(i,j) = ci/(cj*(z(i)-z(j)))
850  IF ((i.EQ.j).AND.(i.NE.1).AND.(i.NE.nz)) &
851  d(i,j) = (alpha*(one+z(i))-beta*(one-z(i)))/ &
852  (two*(one-z(i)**2))
853  IF ((i.EQ.j).AND.(i.EQ.1)) &
854  d(i,j) = (eigval+alpha)/(two*(beta+two))
855  IF ((i.EQ.j).AND.(i.EQ.nz)) &
856  d(i,j) = -(eigval+beta)/(two*(alpha+two))
857  dt(j,i) = d(i,j)
858  END DO
859  END DO
860  RETURN
861  end subroutine dgljd
862 
863  SUBROUTINE dgll (D,DT,Z,NZ,NZD)
864 !-----------------------------------------------------------------
865 !
866 ! Compute the derivative matrix D and its transpose DT
867 ! associated with the Nth order Lagrangian interpolants
868 ! through the NZ Gauss-Lobatto Legendre points Z.
869 ! Note: D and DT are square matrices.
870 !
871 !-----------------------------------------------------------------
872  IMPLICIT REAL(KIND=RP) (a-h,o-z)
873  parameter(nmax=84)
874  REAL(KIND=rp) d(nzd,nzd),dt(nzd,nzd),z(1)
875  n = nz-1
876  IF (nz .GT. nmax) THEN
877  WRITE (6,*) 'Subroutine DGLL'
878  WRITE (6,*) 'Maximum polynomial degree =',nmax
879  WRITE (6,*) 'Polynomial degree =',nz
880  ENDIF
881  IF (nz .EQ. 1) THEN
882  d(1,1) = 0.
883  RETURN
884  ENDIF
885  fn = (n)
886  d0 = fn*(fn+1.)/4.
887  DO i=1,nz
888  DO j=1,nz
889  d(i,j) = 0.
890  IF (i.NE.j) d(i,j) = pnleg(z(i),n)/ &
891  (pnleg(z(j),n)*(z(i)-z(j)))
892  IF ((i.EQ.j).AND.(i.EQ.1)) d(i,j) = -d0
893  IF ((i.EQ.j).AND.(i.EQ.nz)) d(i,j) = d0
894  dt(j,i) = d(i,j)
895  END DO
896  END DO
897  RETURN
898  end subroutine dgll
899 
900  REAL(kind=rp) FUNCTION hgll (I,Z,ZGLL,NZ)
901 !---------------------------------------------------------------------
902 !
903 ! Compute the value of the Lagrangian interpolant L through
904 ! the NZ Gauss-Lobatto Legendre points ZGLL at the point Z.
905 !
906 !---------------------------------------------------------------------
907  IMPLICIT REAL(KIND=RP) (a-h,o-z)
908  REAL(kind=rp) zgll(1), eps, dz, z
909  eps = 1.e-5
910  dz = z - zgll(i)
911  IF (abs(dz) .LT. eps) THEN
912  hgll = 1.
913  RETURN
914  ENDIF
915  n = nz - 1
916  alfan = (n)*((n)+1.)
917  hgll = - (1.-z*z)*pndleg(z,n)/ &
918  (alfan*pnleg(zgll(i),n)*(z-zgll(i)))
919  RETURN
920  end function hgll
921 
922  REAL(kind=rp) FUNCTION hgl (I,Z,ZGL,NZ)
923 !---------------------------------------------------------------------
924 !
925 ! Compute the value of the Lagrangian interpolant HGL through
926 ! the NZ Gauss Legendre points ZGL at the point Z.
927 !
928 !---------------------------------------------------------------------
929  REAL(kind=rp) zgl(1), z, eps, dz
930  eps = 1.e-5
931  dz = z - zgl(i)
932  IF (abs(dz) .LT. eps) THEN
933  hgl = 1.
934  RETURN
935  ENDIF
936  n = nz-1
937  hgl = pnleg(z,nz)/(pndleg(zgl(i),nz)*(z-zgl(i)))
938  RETURN
939  end function hgl
940 
941  REAL(kind=rp) FUNCTION pnleg (Z,N)
942 !---------------------------------------------------------------------
943 !
944 ! Compute the value of the Nth order Legendre polynomial at Z.
945 ! (Simpler than JACOBF)
946 ! Based on the recursion formula for the Legendre polynomials.
947 !
948 !---------------------------------------------------------------------
949 !
950 ! This next statement is to overcome the underflow bug in the i860.
951 ! It can be removed at a later date. 11 Aug 1990 pff.
952 !
953  IMPLICIT REAL(KIND=RP) (a-h,o-z)
954  REAL(kind=rp) z, p1, p2, p3
955  IF(abs(z) .LT. 1.0e-25) z = 0.0
956 
957 
958  p1 = 1.
959  IF (n.EQ.0) THEN
960  pnleg = p1
961  RETURN
962  ENDIF
963  p2 = z
964  p3 = p2
965  DO 10 k = 1, n-1
966  fk = (k)
967  p3 = ((2.*fk+1.)*z*p2 - fk*p1)/(fk+1.)
968  p1 = p2
969  p2 = p3
970 10 CONTINUE
971  pnleg = p3
972  if (n.eq.0) pnleg = 1.
973  RETURN
974  end function pnleg
975 
976  REAL(kind=rp) FUNCTION pndleg (Z,N)
977 !----------------------------------------------------------------------
978 !
979 ! Compute the derivative of the Nth order Legendre polynomial at Z.
980 ! (Simpler than JACOBF)
981 ! Based on the recursion formula for the Legendre polynomials.
982 !
983 !----------------------------------------------------------------------
984  IMPLICIT REAL(KIND=RP) (a-h,o-z)
985  REAL(kind=rp) p1, p2, p1d, p2d, p3d, z
986  p1 = 1.
987  p2 = z
988  p1d = 0.
989  p2d = 1.
990  p3d = 1.
991  DO 10 k = 1, n-1
992  fk = (k)
993  p3 = ((2.*fk+1.)*z*p2 - fk*p1)/(fk+1.)
994  p3d = ((2.*fk+1.)*p2 + (2.*fk+1.)*z*p2d - fk*p1d)/(fk+1.)
995  p1 = p2
996  p2 = p3
997  p1d = p2d
998  p2d = p3d
999 10 CONTINUE
1000  pndleg = p3d
1001  IF (n.eq.0) pndleg = 0.
1002  RETURN
1003  end function pndleg
1004 
1005  SUBROUTINE dgllgl (D,DT,ZM1,ZM2,IM12,NZM1,NZM2,ND1,ND2)
1006 !-----------------------------------------------------------------------
1007 !
1008 ! Compute the (one-dimensional) derivative matrix D and its
1009 ! transpose DT associated with taking the derivative of a variable
1010 ! expanded on a Gauss-Lobatto Legendre mesh (M1), and evaluate its
1011 ! derivative on a Guass Legendre mesh (M2).
1012 ! Need the one-dimensional interpolation operator IM12
1013 ! (see subroutine IGLLGL).
1014 ! Note: D and DT are rectangular matrices.
1015 !
1016 !-----------------------------------------------------------------------
1017  REAL(KIND=rp) d(nd2,nd1), dt(nd1,nd2), zm1(nd1), zm2(nd2), im12(nd2,nd1)
1018  REAL(KIND=rp) eps, zp, zq
1019  IF (nzm1.EQ.1) THEN
1020  d(1,1) = 0.
1021  dt(1,1) = 0.
1022  RETURN
1023  ENDIF
1024  eps = 1.e-6
1025  nm1 = nzm1-1
1026  DO ip = 1, nzm2
1027  DO jq = 1, nzm1
1028  zp = zm2(ip)
1029  zq = zm1(jq)
1030  IF ((abs(zp) .LT. eps).AND.(abs(zq) .LT. eps)) THEN
1031  d(ip,jq) = 0.
1032  ELSE
1033  d(ip,jq) = (pnleg(zp,nm1)/pnleg(zq,nm1) &
1034  -im12(ip,jq))/(zp-zq)
1035  ENDIF
1036  dt(jq,ip) = d(ip,jq)
1037  END DO
1038  END DO
1039  RETURN
1040  end subroutine dgllgl
1041 
1042  SUBROUTINE dgljgj (D,DT,ZGL,ZG,IGLG,NPGL,NPG,ND1,ND2,ALPHA,BETA)
1043 !-----------------------------------------------------------------------
1044 !
1045 ! Compute the (one-dimensional) derivative matrix D and its
1046 ! transpose DT associated with taking the derivative of a variable
1047 ! expanded on a Gauss-Lobatto Jacobi mesh (M1), and evaluate its
1048 ! derivative on a Guass Jacobi mesh (M2).
1049 ! Need the one-dimensional interpolation operator IM12
1050 ! (see subroutine IGLJGJ).
1051 ! Note: D and DT are rectangular matrices.
1052 ! Single precision version.
1053 !
1054 !-----------------------------------------------------------------------
1055  REAL(KIND=rp) d(nd2,nd1), dt(nd1,nd2), zgl(nd1), zg(nd2), iglg(nd2,nd1)
1056  parameter(nmax=84)
1057  parameter(ndd = nmax)
1058  REAL(KIND=rp) dd(ndd,ndd), dtd(ndd,ndd)
1059  REAL(KIND=rp) zgd(ndd), zgld(ndd), iglgd(ndd,ndd)
1060  REAL(KIND=rp) alphad, betad
1061 
1062  IF (npgl.LE.1) THEN
1063  WRITE(6,*) 'DGLJGJ: Minimum number of Gauss-Lobatto points is 2'
1064  call neko_error
1065  ENDIF
1066  IF (npgl.GT.nmax) THEN
1067  WRITE(6,*) 'Polynomial degree too high in DGLJGJ'
1068  WRITE(6,*) 'Maximum polynomial degree is',nmax
1069  WRITE(6,*) 'Here NPGL=',npgl
1070  call neko_error
1071  ENDIF
1072  IF ((alpha.LE.-1.).OR.(beta.LE.-1.)) THEN
1073  WRITE(6,*) 'DGLJGJ: Alpha and Beta must be greater than -1'
1074  call neko_error
1075  ENDIF
1076 
1077  alphad = alpha
1078  betad = beta
1079  DO i=1,npg
1080  zgd(i) = zg(i)
1081  DO j=1,npgl
1082  iglgd(i,j) = iglg(i,j)
1083  END DO
1084  END DO
1085  DO 200 i=1,npgl
1086  zgld(i) = zgl(i)
1087 200 CONTINUE
1088  CALL dgljgjd (dd,dtd,zgld,zgd,iglgd,npgl,npg,ndd,ndd,alphad,betad)
1089  DO i=1,npg
1090  DO j=1,npgl
1091  d(i,j) = dd(i,j)
1092  dt(j,i) = dtd(j,i)
1093  END DO
1094  END DO
1095  RETURN
1096  end subroutine dgljgj
1097 
1098  SUBROUTINE dgljgjd (D,DT,ZGL,ZG,IGLG,NPGL,NPG,ND1,ND2,ALPHA,BETA)
1099 !-----------------------------------------------------------------------
1100 !
1101 ! Compute the (one-dimensional) derivative matrix D and its
1102 ! transpose DT associated with taking the derivative of a variable
1103 ! expanded on a Gauss-Lobatto Jacobi mesh (M1), and evaluate its
1104 ! derivative on a Guass Jacobi mesh (M2).
1105 ! Need the one-dimensional interpolation operator IM12
1106 ! (see subroutine IGLJGJ).
1107 ! Note: D and DT are rectangular matrices.
1108 ! Double precision version.
1109 !
1110 !-----------------------------------------------------------------------
1111  IMPLICIT REAL(KIND=RP) (a-h,o-z)
1112  REAL(KIND=rp) d(nd2,nd1), dt(nd1,nd2), zgl(nd1), zg(nd2)
1113  REAL(KIND=rp) iglg(nd2,nd1), alpha, beta
1114 
1115  IF (npgl.LE.1) THEN
1116  WRITE(6,*) 'DGLJGJD: Minimum number of Gauss-Lobatto points is 2'
1117  call neko_error
1118  ENDIF
1119  IF ((alpha.LE.-1.).OR.(beta.LE.-1.)) THEN
1120  WRITE(6,*) 'DGLJGJD: Alpha and Beta must be greater than -1'
1121  call neko_error
1122  ENDIF
1123 
1124  eps = 1.e-6
1125  one = 1.
1126  two = 2.
1127  ngl = npgl-1
1128  dn = ((ngl))
1129  eigval = -dn*(dn+alpha+beta+one)
1130 
1131  DO i=1,npg
1132  DO j=1,npgl
1133  dz = abs(zg(i)-zgl(j))
1134  IF (dz.LT.eps) THEN
1135  d(i,j) = (alpha*(one+zg(i))-beta*(one-zg(i)))/ &
1136  (two*(one-zg(i)**2))
1137  ELSE
1138  CALL jacobf (pi,pdi,pm1,pdm1,pm2,pdm2,ngl,alpha,beta,zg(i))
1139  CALL jacobf (pj,pdj,pm1,pdm1,pm2,pdm2,ngl,alpha,beta,zgl(j))
1140  faci = alpha*(one+zg(i))-beta*(one-zg(i))
1141  facj = alpha*(one+zgl(j))-beta*(one-zgl(j))
1142  const = eigval*pj+facj*pdj
1143  d(i,j) = ((eigval*pi+faci*pdi)*(zg(i)-zgl(j)) &
1144  -(one-zg(i)**2)*pdi)/(const*(zg(i)-zgl(j))**2)
1145  ENDIF
1146  dt(j,i) = d(i,j)
1147  END DO
1148  END DO
1149  RETURN
1150  end subroutine dgljgjd
1151 
1152  SUBROUTINE iglm (I12,IT12,Z1,Z2,NZ1,NZ2,ND1,ND2)
1153 !----------------------------------------------------------------------
1154 !
1155 ! Compute the one-dimensional interpolation operator (matrix) I12
1156 ! ands its transpose IT12 for interpolating a variable from a
1157 ! Gauss Legendre mesh (1) to a another mesh M (2).
1158 ! Z1 : NZ1 Gauss Legendre points.
1159 ! Z2 : NZ2 points on mesh M.
1160 !
1161 !--------------------------------------------------------------------
1162  REAL(KIND=rp) i12(nd2,nd1),it12(nd1,nd2),z1(nd1),z2(nd2), zi
1163  IF (nz1 .EQ. 1) THEN
1164  i12(1,1) = 1.
1165  it12(1,1) = 1.
1166  RETURN
1167  ENDIF
1168  DO i=1,nz2
1169  zi = z2(i)
1170  DO j=1,nz1
1171  i12(i,j) = hgl(j,zi,z1,nz1)
1172  it12(j,i) = i12(i,j)
1173  END DO
1174  END DO
1175  RETURN
1176  end subroutine iglm
1177 
1178  SUBROUTINE igllm (I12,IT12,Z1,Z2,NZ1,NZ2,ND1,ND2)
1179 !----------------------------------------------------------------------
1180 !
1181 ! Compute the one-dimensional interpolation operator (matrix) I12
1182 ! ands its transpose IT12 for interpolating a variable from a
1183 ! Gauss-Lobatto Legendre mesh (1) to a another mesh M (2).
1184 ! Z1 : NZ1 Gauss-Lobatto Legendre points.
1185 ! Z2 : NZ2 points on mesh M.
1186 !
1187 !--------------------------------------------------------------------
1188  REAL(KIND=rp) i12(nd2,nd1),it12(nd1,nd2),z1(nd1),z2(nd2),zi
1189  IF (nz1 .EQ. 1) THEN
1190  i12(1,1) = 1.
1191  it12(1,1) = 1.
1192  RETURN
1193  ENDIF
1194  DO i=1,nz2
1195  zi = z2(i)
1196  DO j=1,nz1
1197  i12(i,j) = hgll(j,zi,z1,nz1)
1198  it12(j,i) = i12(i,j)
1199  END DO
1200  END DO
1201  RETURN
1202  end subroutine igllm
1203 
1204  SUBROUTINE igjm (I12,IT12,Z1,Z2,NZ1,NZ2,ND1,ND2,ALPHA,BETA)
1205 !----------------------------------------------------------------------
1206 !
1207 ! Compute the one-dimensional interpolation operator (matrix) I12
1208 ! ands its transpose IT12 for interpolating a variable from a
1209 ! Gauss Jacobi mesh (1) to a another mesh M (2).
1210 ! Z1 : NZ1 Gauss Jacobi points.
1211 ! Z2 : NZ2 points on mesh M.
1212 ! Single precision version.
1213 !
1214 !--------------------------------------------------------------------
1215  REAL(KIND=rp) i12(nd2,nd1),it12(nd1,nd2),z1(nd1),z2(nd2),zi,alpha,beta
1216  IF (nz1 .EQ. 1) THEN
1217  i12(1,1) = 1.
1218  it12(1,1) = 1.
1219  RETURN
1220  ENDIF
1221  DO i=1,nz2
1222  zi = z2(i)
1223  DO j=1,nz1
1224  i12(i,j) = hgj(j,zi,z1,nz1,alpha,beta)
1225  it12(j,i) = i12(i,j)
1226  END DO
1227  END DO
1228  RETURN
1229  end subroutine igjm
1230 
1231  SUBROUTINE igljm (I12,IT12,Z1,Z2,NZ1,NZ2,ND1,ND2,ALPHA,BETA)
1232 !----------------------------------------------------------------------
1233 !
1234 ! Compute the one-dimensional interpolation operator (matrix) I12
1235 ! ands its transpose IT12 for interpolating a variable from a
1236 ! Gauss-Lobatto Jacobi mesh (1) to a another mesh M (2).
1237 ! Z1 : NZ1 Gauss-Lobatto Jacobi points.
1238 ! Z2 : NZ2 points on mesh M.
1239 ! Single precision version.
1240 !
1241 !--------------------------------------------------------------------
1242  REAL(KIND=rp) i12(nd2,nd1),it12(nd1,nd2),z1(nd1),z2(nd2),zi,alpha,beta
1243  IF (nz1 .EQ. 1) THEN
1244  i12(1,1) = 1.
1245  it12(1,1) = 1.
1246  RETURN
1247  ENDIF
1248  DO i=1,nz2
1249  zi = z2(i)
1250  DO j=1,nz1
1251  i12(i,j) = hglj(j,zi,z1,nz1,alpha,beta)
1252  it12(j,i) = i12(i,j)
1253  END DO
1254  END DO
1255  RETURN
1256  end subroutine igljm
1257 end module speclib
integer, parameter, public rp
Global precision used in computations.
Definition: num_types.f90:12
LIBRARY ROUTINES FOR SPECTRAL METHODS.
Definition: speclib.f90:147
real(kind=rp) function pnormj(N, ALPHA, BETA)
Definition: speclib.f90:456
subroutine zwgll(Z, W, NP)
Definition: speclib.f90:168
real(kind=rp) function pnleg(Z, N)
Definition: speclib.f90:942
real(kind=rp) function hgj(II, Z, ZGJ, NP, ALPHA, BETA)
Definition: speclib.f90:580
subroutine dgljgj(D, DT, ZGL, ZG, IGLG, NPGL, NPG, ND1, ND2, ALPHA, BETA)
Definition: speclib.f90:1043
subroutine zwgj(Z, W, NP, ALPHA, BETA)
Definition: speclib.f90:185
subroutine dgj(D, DT, Z, NZ, NZD, ALPHA, BETA)
Definition: speclib.f90:690
subroutine jacg(XJAC, NP, ALPHA, BETA)
Definition: speclib.f90:482
subroutine zwgjd(Z, W, NP, ALPHA, BETA)
Definition: speclib.f90:216
subroutine dgll(D, DT, Z, NZ, NZD)
Definition: speclib.f90:864
real(kind=rp) function hglj(II, Z, ZGLJ, NP, ALPHA, BETA)
Definition: speclib.f90:633
subroutine zwglj(Z, W, NP, ALPHA, BETA)
Definition: speclib.f90:268
subroutine dglj(D, DT, Z, NZ, NZD, ALPHA, BETA)
Definition: speclib.f90:773
real(kind=rp) function pndleg(Z, N)
Definition: speclib.f90:977
subroutine igjm(I12, IT12, Z1, Z2, NZ1, NZ2, ND1, ND2, ALPHA, BETA)
Definition: speclib.f90:1205
real(kind=rp) function hgl(I, Z, ZGL, NZ)
Definition: speclib.f90:923
real(kind=rp) function gammaf(X)
Definition: speclib.f90:432
subroutine dgljgjd(D, DT, ZGL, ZG, IGLG, NPGL, NPG, ND1, ND2, ALPHA, BETA)
Definition: speclib.f90:1099
subroutine igljm(I12, IT12, Z1, Z2, NZ1, NZ2, ND1, ND2, ALPHA, BETA)
Definition: speclib.f90:1232
real(kind=rp) function hgjd(II, Z, ZGJ, NP, ALPHA, BETA)
Definition: speclib.f90:609
subroutine iglm(I12, IT12, Z1, Z2, NZ1, NZ2, ND1, ND2)
Definition: speclib.f90:1153
subroutine zwgl(Z, W, NP)
Generate NP Gauss Legendre points Z and weights W associated with Jacobi polynomial ....
Definition: speclib.f90:160
real(kind=rp) function hgljd(I, Z, ZGLJ, NP, ALPHA, BETA)
Definition: speclib.f90:662
real(kind=rp) function endw1(N, ALPHA, BETA)
Definition: speclib.f90:344
subroutine dgljd(D, DT, Z, NZ, NZD, ALPHA, BETA)
Definition: speclib.f90:817
real(kind=rp) function hgll(I, Z, ZGLL, NZ)
Definition: speclib.f90:901
real(kind=rp) function endw2(N, ALPHA, BETA)
Definition: speclib.f90:388
subroutine zwgljd(Z, W, NP, ALPHA, BETA)
Definition: speclib.f90:299
subroutine dgjd(D, DT, Z, NZ, NZD, ALPHA, BETA)
Definition: speclib.f90:734
subroutine jacobf(POLY, PDER, POLYM1, PDERM1, POLYM2, PDERM2, N, ALP, BET, X)
Definition: speclib.f90:540
subroutine dgllgl(D, DT, ZM1, ZM2, IM12, NZM1, NZM2, ND1, ND2)
Definition: speclib.f90:1006
subroutine igllm(I12, IT12, Z1, Z2, NZ1, NZ2, ND1, ND2)
Definition: speclib.f90:1179
Utilities.
Definition: utils.f90:35