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

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

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


Revision 1.2 - (show annotations) (download)
Tue Nov 3 15:28:03 1998 UTC (25 years, 6 months ago) by cnh
Branch: MAIN
CVS Tags: checkpoint17, checkpoint19, checkpoint18, checkpoint20, checkpoint21, checkpoint22
Changes since 1.1: +24 -7 lines
Partial changes to incoporate atmospheric configuration
Minor TAMC compliance changes
Included one-layer verification experiment exp0

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

  ViewVC Help
Powered by ViewVC 1.1.22