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

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

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


Revision 1.4 - (show annotations) (download)
Sat Mar 3 22:35:46 2007 UTC (17 years, 2 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64a, checkpoint64c, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f, checkpoint58w_post, checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63s, checkpoint63l, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint64, checkpoint65, checkpoint60, checkpoint61, checkpoint62, checkpoint63, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint58x_post, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, checkpoint59q, checkpoint59p, checkpoint59r, checkpoint59e, checkpoint59d, checkpoint59g, checkpoint59f, checkpoint59a, checkpoint59c, checkpoint59b, checkpoint59m, checkpoint59l, checkpoint59o, checkpoint59n, checkpoint59i, checkpoint59h, checkpoint59k, checkpoint59j, checkpoint59, checkpoint62c, checkpoint62b, checkpoint62a, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62w, checkpoint62v, checkpoint62u, checkpoint62t, checkpoint62z, checkpoint62y, checkpoint62x, checkpoint58y_post, checkpoint61f, checkpoint61g, checkpoint61d, checkpoint61e, checkpoint61b, checkpoint61c, checkpoint61a, checkpoint61n, checkpoint61o, checkpoint61l, checkpoint61m, checkpoint61j, checkpoint61k, checkpoint61h, checkpoint61i, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61q, checkpoint61z, checkpoint61x, checkpoint61y, HEAD
Changes since 1.3: +5 -2 lines
previous modification: "return FALSE when argument val1 (=time) < phase"
only applied to positive time (in case baseTime<<0); also add deltaT.

1 C $Header: /u/gcmpack/MITgcm/eesupp/src/diff_phase_multiple.F,v 1.3 2006/01/16 19:04:59 jmc Exp $
2 C $Name: $
3
4 #include "CPP_EEOPTIONS.h"
5
6 CBOP
7 C !ROUTINE: DIFF_PHASE_MULTIPLE
8
9 C !INTERFACE:
10 LOGICAL FUNCTION DIFF_PHASE_MULTIPLE( phase, freq, val1, step )
11 IMPLICIT NONE
12
13 C !DESCRIPTION:
14 C *==========================================================*
15 C | LOGICAL FUNCTION DIFF\_PHASE\_MULTIPLE
16 C | o Checks if a multiple of freq (+ phase shift) 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 phase :: shift phase time
30 C freq :: Frequency by which time is divided.
31 C val1 :: time that is checked
32 C step :: length of time interval (around val1) that is checked
33 _RL phase, freq, val1, step
34
35 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
36
37 C !LOCAL VARIABLES:
38 C == Local variables ==
39 C v1, v2, v3, v4 :: Temp. for holding time
40 C d1, d2, d3 :: Temp. for hold difference
41 _RL v1, v2, v3, v4, d1, d2, d3
42 CEOP
43
44 C o Do easy cases first.
45 DIFF_PHASE_MULTIPLE = .FALSE.
46
47 IF ( freq .NE. 0. ) THEN
48 IF ( ABS(step) .GT. ABS(freq) ) THEN
49 DIFF_PHASE_MULTIPLE = .TRUE.
50 c ELSEIF ( val1+step .GE. phase+baseTime ) THEN
51 C- should compare to phase+baseTime (above), but would need PARAMS.h ;
52 C choose to disable this condition for negative time:
53 ELSEIF ( val1+step.GE.phase .OR. val1.LT.0. ) THEN
54
55 C o This case is more complex because of round-off error
56 v1 = val1
57 v2 = val1 - step
58 v3 = val1 + step
59
60 C Test v1 to see if its a "closest multiple"
61 v4 = phase + NINT((v1-phase)/freq)*freq
62 d1 = v1-v4
63 d2 = v2-v4
64 d3 = v3-v4
65 IF ( ABS(d1) .LT. ABS(d2) .AND. ABS(d1) .LE. ABS(d3) )
66 & DIFF_PHASE_MULTIPLE = .TRUE.
67
68 ENDIF
69 ENDIF
70
71 RETURN
72 END

  ViewVC Help
Powered by ViewVC 1.1.22