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

Annotation of /trunk/Sources/misc/tanh_cautious.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 145 - (hide annotations)
Tue Jun 16 15:23:29 2015 UTC (8 years, 11 months ago) by guez
File size: 766 byte(s)
Renamed bibio to misc.

In procedure fxhyp, use the fact that xf is an odd function of xtild.

In procedure invert_zoom_x, replace linear search in xf by
bisection. Also, use result from previous loop iteration as initial
guess. Variable "it" cannot be equal to 2 * nmax after search.

Unused arguments: hm of cv3_feed; ph, qnk, tv,tvp of cv3_mixing; ppsol
of lw; rconst, temp of vdif_kcay; rconst, plev, temp, ustar, l_mix of
yamada.

1 guez 144 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