/[lmdze]/trunk/Sources/bibio/tanh_cautious.f
ViewVC logotype

Contents of /trunk/Sources/bibio/tanh_cautious.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 144 - (show annotations)
Wed Jun 10 16:46:46 2015 UTC (8 years, 11 months ago) by guez
File size: 766 byte(s)
In procedure fxhyp, the convoluted computation of tanh(fa/fb) occurred
three times. Extracted it into a function. Also, the computation of
xmoy and fxm was repeated. So stored the values in arrays instead.

In procedure fxhyp, in the computation of fhyp, there were tests
xtild(i) == 0. and xtild(i) == pi_d. No use to do these tests at each
iteration. We now they are true for i == nmax and i == 2 * nmax,
respectively, and we know they are false for other values of
"i". Similarly, in the computations of ffdx and xxpr, there were the
tests xmoy == 0. and xmoy == pi_d, these could not be true.

Moved files from bibio to dyn3d, following LMDZ.

1 module tanh_cautious_m
2
3 implicit none
4
5 contains
6
7 elemental double precision function tanh_cautious(fa, fb)
8
9 ! Compute tanh(fa / fb) with caution.
10
11 double precision, intent(in):: fa, fb
12
13 !-------------------------------------------------------------
14
15 IF (200d0 * fb < - fa) THEN
16 tanh_cautious = - 1d0
17 ELSE IF (200d0 * fb < fa) THEN
18 tanh_cautious = 1d0
19 ELSE
20 IF (ABS(fa) < 1d-13 .AND. ABS(fb) < 1d-13) THEN
21 IF (200d0 * fb + fa < 1d-10) THEN
22 tanh_cautious = - 1d0
23 ELSE IF (200d0 * fb - fa < 1d-10) THEN
24 tanh_cautious = 1d0
25 END IF
26 ELSE
27 tanh_cautious = TANH(fa / fb)
28 END IF
29 END IF
30
31 end function tanh_cautious
32
33 end module tanh_cautious_m

  ViewVC Help
Powered by ViewVC 1.1.21