Ignore:
Timestamp:
Jun 19, 2020 11:56:30 AM (4 years ago)
Author:
eckhard
Message:

Handle COSMO soil data with and without additional surface temperature

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/UTIL/inifor/src/inifor_util.f90

    r4523 r4568  
    2626! -----------------
    2727! $Id$
     28! Added function for checking floating point equality
     29!
     30!
     31! 4523 2020-05-07 15:58:16Z eckhard
    2832! respect integer working precision (iwp) specified in inifor_defs.f90
    2933!
     
    462466 END SUBROUTINE
    463467
     468
     469!------------------------------------------------------------------------------!
     470! Description:
     471! ------------
     472!> Check for exact or near equality of two floating point numbers. Inspired by
     473!> https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
     474!------------------------------------------------------------------------------!
     475 LOGICAL FUNCTION nearly_equal(a, b, max_rel_diff)
     476
     477    REAL(wp), INTENT(IN) ::  a, b, max_rel_diff
     478    REAL(wp)             ::  diff, mag
     479 
     480    diff = ABS( a - b )
     481    mag = MAX( ABS(a), ABS(b) )
     482    nearly_equal = ( diff .LE. mag * max_rel_diff )
     483
     484 END FUNCTION nearly_equal
     485
    464486 END MODULE inifor_util
Note: See TracChangeset for help on using the changeset viewer.