random_n Function

public function random_n(k)

Arguments

Type IntentOptional AttributesName
integer :: k

Return Value real(kind=dp)


Calls

proc~~random_n~~CallsGraph proc~random_n random_n float float proc~random_n->float

Called by

proc~~random_n~~CalledByGraph proc~random_n random_n proc~hydrotope_allocate hydrotope_allocate proc~hydrotope_allocate->proc~random_n proc~gamma_distribution gamma_distribution proc~gamma_distribution->proc~random_n proc~soil_initialise soil_initialise proc~soil_initialise->proc~random_n proc~initialise initialise proc~initialise->proc~soil_initialise proc~hydrotope_initialise hydrotope_initialise proc~initialise->proc~hydrotope_initialise proc~hydrotope_initialise->proc~hydrotope_allocate proc~soil_curve_number_alpha soil_curve_number_alpha proc~soil_curve_number_alpha->proc~gamma_distribution proc~runsubbasin runsubbasin proc~runsubbasin->proc~soil_curve_number_alpha program~swim swim program~swim->proc~initialise proc~time_process_years time_process_years program~swim->proc~time_process_years proc~time_process_day time_process_day proc~time_process_day->proc~runsubbasin proc~time_process_month time_process_month proc~time_process_month->proc~time_process_day proc~time_process_years->proc~time_process_month

Contents

Source Code


Source Code

  function random_n(k)
    !**** PURPOSE: THIS FUNCTION PROVIDES RANDOM NUMBERS RANGING FROM 0. TO 1.
    !**** CALLED IN: GAMMAD, INIT, READSUB
    !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    !     PARAMETERS & VARIABLES
    !
    !      >>>>> STATIC
    !      i = local par
    !      >>>>>
    !calc randn
    !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    integer i, k
    real(dp) random_n

    dimension k(4)
    k(4) = 3 * k(4) + k(2)
    k(3) = 3 * k(3) + k(1)
    k(2) = 3 * k(2)
    k(1) = 3 * k(1)
    i = k(1) / 1000
    k(1) = k(1) - i * 1000
    k(2) = k(2) + i
    i = k(2) / 100
    k(2) = k(2) - 100 * i
    k(3) = k(3) + i
    i = k(3) / 1000
    k(3) = k(3) - i * 1000
    k(4) = k(4) + i
    i = k(4) / 100
    k(4) = k(4) - 100 * i
    random_n = (((float(k(1)) * .001 + float(k(2))) * .01 + float(k(3))) * .001 + &
        float(k(4))) * .01
    return
  end function random_n