/[MITgcm]/MITgcm/eesupp/src/different_multiple.F
ViewVC logotype

Annotation of /MITgcm/eesupp/src/different_multiple.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (hide annotations) (download)
Sun Feb 4 14:38:42 2001 UTC (23 years, 3 months ago) by cnh
Branch: MAIN
CVS Tags: checkpoint40pre3, checkpoint40pre1, checkpoint40pre7, checkpoint40pre6, checkpoint40pre9, checkpoint40pre8, checkpoint38, checkpoint40pre2, checkpoint40pre4, pre38tag1, c37_adj, pre38-close, checkpoint39, checkpoint37, checkpoint36, checkpoint35, checkpoint40pre5, checkpoint40
Branch point for: pre38
Changes since 1.3: +2 -1 lines
Made sure each .F and .h file had
the CVS keywords Header and Name at its start.
Most had header but very few currently have Name, so
lots of changes!

1 cnh 1.4 C $Header: /u/gcmpack/models/MITgcmUV/eesupp/src/different_multiple.F,v 1.3 1999/05/24 14:57:55 adcroft Exp $
2     C $Name: $
3 cnh 1.1 #include "CPP_EEOPTIONS.h"
4    
5     CStartofinterface
6     LOGICAL FUNCTION DIFFERENT_MULTIPLE( freq, val1, val2 )
7     C /==========================================================\
8     C | LOGICAL FUNCTION DIFFERENT_MULTIPLE |
9     C | o Checks two numbers multiple of a third number. |
10     C |==========================================================|
11     C | This routine is used for diagnostic and other periodic |
12     C | operations. It is very sensitive to arithmetic precision.|
13     C | For IEEE conforming arithmetic is works well but for |
14     C | cases where short cut arithmetic is used it may not work|
15     C | as expected. To overcome this issue compile this routine |
16     C | separately with no optimisation. |
17     C \==========================================================/
18     IMPLICIT NONE
19     C Returns TRUE if val1 and val2 are different multiples of freq.
20 cnh 1.2 _RL freq, val1, val2
21 cnh 1.1 CEndofinterface
22 cnh 1.2 _RL f, v1, v2, v3, v4, d1, d2, d3, step
23    
24     C o Do easy cases first.
25 cnh 1.1 DIFFERENT_MULTIPLE = .FALSE.
26 adcroft 1.3
27     IF ( freq .NE. 0. ) THEN
28     IF ( ABS(val1-val2) .GT. freq ) THEN
29     DIFFERENT_MULTIPLE = .TRUE.
30     ELSE
31    
32     C o This case is more complex because of round-off error
33     f = freq
34     v1 = val1
35     v2 = val2
36     step = v1-v2
37    
38     C Test v1 to see if its a "closest multiple"
39     v3 = v1 + step
40     v4 = NINT(v1/f)*f
41     d1 = v1-v4
42     d2 = v2-v4
43     d3 = v3-v4
44     IF ( ABS(d1) .LE. ABS(d2) .AND. ABS(d1) .LE. ABS(d3) )
45     & DIFFERENT_MULTIPLE = .TRUE.
46    
47     ENDIF ! |val1-val2| > freq
48     ENDIF ! freq != 0
49 cnh 1.1
50 cnh 1.2 END

  ViewVC Help
Powered by ViewVC 1.1.22