Back to home page

darwin3

 
 

    


File indexing completed on 2024-12-17 18:30:58 UTC

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
c54a51ccba Jean*0001 #include "CPP_EEOPTIONS.h"
                0002 
                0003 CBOP
cb20bb547f Jean*0004 C     !ROUTINE: DIFFERENT_MULTIPLE
c54a51ccba Jean*0005 
                0006 C     !INTERFACE:
cb20bb547f Jean*0007       LOGICAL FUNCTION DIFFERENT_MULTIPLE( freq, val1, step )
c54a51ccba Jean*0008       IMPLICIT NONE
                0009 
                0010 C     !DESCRIPTION:
                0011 C     *==========================================================*
cb20bb547f Jean*0012 C     | LOGICAL FUNCTION DIFFERENT\_MULTIPLE                       
                0013 C     | o Checks if a multiple of freq exist
c54a51ccba Jean*0014 C     |   around val1 +/- step/2
                0015 C     *==========================================================*
                0016 C     | This routine is used for diagnostic and other periodic    
                0017 C     | operations. It is very sensitive to arithmetic precision. 
                0018 C     | For IEEE conforming arithmetic it works well but for      
                0019 C     | cases where short cut arithmetic  is used it may not work 
                0020 C     | as expected. To overcome this issue compile this routine  
                0021 C     | separately with no optimisation.                          
                0022 C     *==========================================================*
                0023 
                0024 C     !INPUT PARAMETERS:
                0025 C     == Routine arguments ==
                0026 C     freq       :: Frequency by which time is divided.
                0027 C     val1       :: time that is checked 
                0028 C     step       :: length of time interval (around val1) that is checked 
cb20bb547f Jean*0029       _RL  freq, val1, step
c54a51ccba Jean*0030 
                0031 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
                0032 
                0033 C     !LOCAL VARIABLES:
                0034 C     == Local variables ==
                0035 C     v1, v2, v3, v4 :: Temp. for holding time
                0036 C     d1, d2, d3     :: Temp. for hold difference
                0037       _RL  v1, v2, v3, v4, d1, d2, d3
                0038 CEOP
                0039 
                0040 C     o Do easy cases first.
cb20bb547f Jean*0041       DIFFERENT_MULTIPLE = .FALSE.
c54a51ccba Jean*0042 
                0043       IF ( freq .NE. 0. ) THEN
                0044         IF ( ABS(step) .GT. freq ) THEN
cb20bb547f Jean*0045          DIFFERENT_MULTIPLE = .TRUE.
c54a51ccba Jean*0046         ELSE
                0047 
                0048 C         o This case is more complex because of round-off error
                0049           v1 = val1
                0050           v2 = val1 - step
                0051           v3 = val1 + step
                0052 
                0053 C         Test v1 to see if its a "closest multiple"
1e59cbb5ad Jean*0054           v4 = NINT(v1/freq)*freq
c54a51ccba Jean*0055           d1 = v1-v4
                0056           d2 = v2-v4
                0057           d3 = v3-v4
9a75538a26 Jean*0058           IF ( ABS(d1) .LT. ABS(d2) .AND. ABS(d1) .LE. ABS(d3) )
cb20bb547f Jean*0059      &        DIFFERENT_MULTIPLE = .TRUE.
c54a51ccba Jean*0060 
                0061         ENDIF
                0062       ENDIF
                0063 
                0064       RETURN
                0065       END