/[MITgcm]/MITgcm/pkg/openad/ad_s_different_multiple.F
ViewVC logotype

Contents of /MITgcm/pkg/openad/ad_s_different_multiple.F

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


Revision 1.1 - (show annotations) (download)
Tue Aug 20 17:41:49 2013 UTC (10 years, 10 months ago) by jahn
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint64o, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64n
move files in verification/OpenAD/code_oad_all to new package openad

1 #include "CPP_EEOPTIONS.h"
2 CBOP
3 C !ROUTINE: DIFFERENT_MULTIPLE
4
5 C !INTERFACE:
6 subroutine oad_s_DIFFERENT_MULTIPLE( freq, val1, step, isit )
7 IMPLICIT NONE
8
9 C !DESCRIPTION:
10 C *==========================================================*
11 C | LOGICAL FUNCTION DIFFERENT\_MULTIPLE
12 C | o Checks if a multiple of freq exist
13 C | around val1 +/- step/2
14 C *==========================================================*
15 C | This routine is used for diagnostic and other periodic
16 C | operations. It is very sensitive to arithmetic precision.
17 C | For IEEE conforming arithmetic it works well but for
18 C | cases where short cut arithmetic is used it may not work
19 C | as expected. To overcome this issue compile this routine
20 C | separately with no optimisation.
21 C *==========================================================*
22
23 C !INPUT PARAMETERS:
24 C == Routine arguments ==
25 C freq :: Frequency by which time is divided.
26 C val1 :: time that is checked
27 C step :: length of time interval (around val1) that is checked
28 _RL freq, val1, step
29 logical isit
30
31 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
32
33 C !LOCAL VARIABLES:
34 C == Local variables ==
35 C v1, v2, v3, v4 :: Temp. for holding time
36 C d1, d2, d3 :: Temp. for hold difference
37 _RL v1, v2, v3, v4, d1, d2, d3
38 CEOP
39
40 C o Do easy cases first.
41 isit = .FALSE.
42
43 IF ( freq .NE. 0. ) THEN
44 IF ( ABS(step) .GT. freq ) THEN
45 isit = .TRUE.
46 ELSE
47
48 C o This case is more complex because of round-off error
49 v1 = val1
50 v2 = val1 - step
51 v3 = val1 + step
52
53 C Test v1 to see if its a "closest multiple"
54 v4 = NINT(v1/freq)*freq
55 d1 = v1-v4
56 d2 = v2-v4
57 d3 = v3-v4
58 IF ( ABS(d1) .LT. ABS(d2) .AND. ABS(d1) .LE. ABS(d3) )
59 & isit = .TRUE.
60
61 ENDIF
62 ENDIF
63
64 RETURN
65 END

  ViewVC Help
Powered by ViewVC 1.1.22