/[lmdze]/trunk/misc/tanh_cautious.f90
ViewVC logotype

Annotation of /trunk/misc/tanh_cautious.f90

Parent Directory Parent Directory | Revision Log Revision Log


Revision 328 - (hide annotations)
Thu Jun 13 14:40:06 2019 UTC (5 years ago) by guez
File size: 766 byte(s)
Change all `.f` suffixes to `.f90`. (The opposite was done in revision
82.)  Because of change of philosopy in GNUmakefile: we already had a
rewritten rule for `.f`, so it does not make the makefile longer to
replace it by a rule for `.f90`. And it spares us options of
makedepf90 and of the compiler. Also we prepare the way for a simpler
`CMakeLists.txt`.

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