Ignore:
Timestamp:
Jul 8, 2020 9:56:29 AM (4 years ago)
Author:
raasch
Message:

files re-formatted to follow the PALM coding standard

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/random_function_mod.f90

    r4360 r4592  
    11!> @file random_function_mod.f90
    2 !------------------------------------------------------------------------------!
     2!--------------------------------------------------------------------------------------------------!
    33! This file is part of the PALM model system.
    44!
    5 ! PALM is free software: you can redistribute it and/or modify it under the
    6 ! terms of the GNU General Public License as published by the Free Software
    7 ! Foundation, either version 3 of the License, or (at your option) any later
    8 ! version.
     5! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General
     6! Public License as published by the Free Software Foundation, either version 3 of the License, or
     7! (at your option) any later version.
    98!
    10 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
    11 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
    12 ! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     9! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
     10! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
     11! Public License for more details.
    1312!
    14 ! You should have received a copy of the GNU General Public License along with
    15 ! PALM. If not, see <http://www.gnu.org/licenses/>.
     13! You should have received a copy of the GNU General Public License along with PALM. If not, see
     14! <http://www.gnu.org/licenses/>.
    1615!
    1716! Copyright 1997-2020 Leibniz Universitaet Hannover
    18 !------------------------------------------------------------------------------!
     17!--------------------------------------------------------------------------------------------------!
     18!
    1919!
    2020! Current revisions:
    2121! -----------------
    22 ! 
    23 ! 
     22!
     23!
    2424! Former revisions:
    2525! -----------------
    2626! $Id$
     27! File re-formatted to follow the PALM coding standard
     28!
     29! 4360 2020-01-07 11:25:50Z suehring
    2730! Corrected "Former revisions" section
    28 ! 
     31!
    2932! 4144 2019-08-06 09:11:47Z raasch
    30 ! relational operators .EQ., .NE., etc. replaced by ==, /=, etc.
    31 ! 
     33! Relational operators .EQ., .NE., etc. replaced by ==, /=, etc.
     34!
    3235! 3802 2019-03-17 13:33:42Z raasch
    33 ! type conversion added to avoid compiler warning about constant integer
    34 ! division truncation
    35 !
     36! Type conversion added to avoid compiler warning about constant integer division truncation
     37!
    3638! 3655 2019-01-07 16:51:22Z knoop
    3739! Corrected "Former revisions" section
     
    4143!
    4244!
     45!--------------------------------------------------------------------------------------------------!
    4346! Description:
    4447! ------------
    45 !> Random number generator, produces numbers equally distributed in interval [0,1]
    46 !> This routine is taken from the "numerical recipes"
    47 !------------------------------------------------------------------------------!
     48!> Random number generator, produces numbers equally distributed in interval [0,1].
     49!> This routine is taken from the "numerical recipes".
     50!--------------------------------------------------------------------------------------------------!
    4851 MODULE random_function_mod
    49  
     52
    5053
    5154    USE kinds
     
    7073 CONTAINS
    7174
    72 !------------------------------------------------------------------------------!
     75!--------------------------------------------------------------------------------------------------!
    7376! Description:
    7477! ------------
    7578!> @todo Missing subroutine description.
    76 !------------------------------------------------------------------------------!
    77     SUBROUTINE random_function_ini
     79!--------------------------------------------------------------------------------------------------!
     80 SUBROUTINE random_function_ini
    7881
    79        IMPLICIT NONE
     82    IMPLICIT NONE
    8083
    81        random_iv = 0
    82        random_iy = 0
     84    random_iv = 0
     85    random_iy = 0
    8386
    84     END SUBROUTINE random_function_ini
     87 END SUBROUTINE random_function_ini
    8588
    86     FUNCTION random_function( idum )
     89!--------------------------------------------------------------------------------------------------!
     90! Description:
     91! ------------
     92!> @todo Missing function description.
     93!--------------------------------------------------------------------------------------------------!
     94 FUNCTION random_function( idum )
    8795
    8896
    89        IMPLICIT NONE
     97    IMPLICIT NONE
    9098
    91        INTEGER(iwp) ::  ia               !<
    92        INTEGER(iwp) ::  idum             !<
    93        INTEGER(iwp) ::  im               !<
    94        INTEGER(iwp) ::  iq               !<
    95        INTEGER(iwp) ::  ir               !<
    96        INTEGER(iwp) ::  ndiv             !<
    97        INTEGER(iwp) ::  ntab             !<
     99    INTEGER(iwp) ::  ia               !<
     100    INTEGER(iwp) ::  idum             !<
     101    INTEGER(iwp) ::  im               !<
     102    INTEGER(iwp) ::  iq               !<
     103    INTEGER(iwp) ::  ir               !<
     104    INTEGER(iwp) ::  ndiv             !<
     105    INTEGER(iwp) ::  ntab             !<
    98106
    99        INTEGER(iwp) ::  j                !<
    100        INTEGER(iwp) ::  k                !<
     107    INTEGER(iwp) ::  j                !<
     108    INTEGER(iwp) ::  k                !<
    101109
    102        REAL(wp)     ::  am               !<
    103        REAL(wp)     ::  eps              !<
    104        REAL(wp)     ::  random_function  !<
    105        REAL(wp)     ::  rnmx             !<
     110    REAL(wp)     ::  am               !<
     111    REAL(wp)     ::  eps              !<
     112    REAL(wp)     ::  random_function  !<
     113    REAL(wp)     ::  rnmx             !<
    106114
    107        PARAMETER ( ia=16807, im=2147483647, am=1.0_wp/im, iq=127773, ir=2836, &
    108                    ntab=32, ndiv=1+INT(REAL(im-1)/ntab), eps=1.2e-7_wp, rnmx=1.0_wp-eps )
     115    PARAMETER ( ia = 16807, im = 2147483647, am = 1.0_wp / im, iq = 127773, ir = 2836, ntab = 32, &
     116                ndiv = 1 + INT( REAL( im - 1 ) / ntab ), eps = 1.2e-7_wp, rnmx = 1.0_wp - eps )
    109117
    110        IF ( idum <= 0  .OR.  random_iy == 0 )  THEN
    111           idum = max (-idum,1)
    112           DO  j = ntab+8,1,-1
    113              k    = idum / iq
    114              idum = ia * ( idum - k * iq ) - ir * k
    115              IF ( idum < 0 )  idum = idum + im
    116              IF ( j <= ntab )  random_iv(j) = idum
    117           ENDDO
    118           random_iy = random_iv(1)
    119        ENDIF
     118    IF ( idum <= 0  .OR.  random_iy == 0 )  THEN
     119       idum = MAX( -idum, 1 )
     120       DO  j = ntab + 8, 1, -1
     121          k    = idum / iq
     122          idum = ia * ( idum - k * iq ) - ir * k
     123          IF ( idum < 0 )  idum = idum + im
     124          IF ( j <= ntab )  random_iv(j) = idum
     125       ENDDO
     126       random_iy = random_iv(1)
     127    ENDIF
    120128
    121        k    = idum / iq
    122        idum = ia * ( idum - k * iq ) - ir * k
    123        IF ( idum < 0 )  idum = idum + im
    124        j            = 1 + random_iy / ndiv
    125        random_iy    = random_iv(j)
    126        random_iv(j) = idum
    127        random_function  = MIN( am * random_iy , rnmx )
     129    k    = idum / iq
     130    idum = ia * ( idum - k * iq ) - ir * k
     131    IF ( idum < 0 )  idum = idum + im
     132    j            = 1 + random_iy / ndiv
     133    random_iy    = random_iv(j)
     134    random_iv(j) = idum
     135    random_function  = MIN( am * random_iy , rnmx )
    128136
    129     END FUNCTION random_function
     137 END FUNCTION random_function
    130138
    131139 END MODULE random_function_mod
Note: See TracChangeset for help on using the changeset viewer.