/[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.8 - (show annotations) (download)
Sun May 15 02:58:40 2005 UTC (20 years, 1 month ago) by jmc
Branch: MAIN
CVS Tags: checkpoint57m_post, checkpoint57s_post, checkpoint57r_post, checkpoint57i_post, checkpoint57n_post, checkpoint57l_post, checkpoint57p_post, checkpoint57q_post, checkpoint57h_done, checkpoint57j_post, checkpoint57o_post, checkpoint57k_post
Changes since 1.7: +19 -17 lines
remove "baseTime" (no used) from arg. list of "DIFF_BASE_MULTIPLE"
and rename if "DIFFERENT_MULTIPLE"

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

  ViewVC Help
Powered by ViewVC 1.1.22