src/util.f90 File Reference

The pmc_util module. More...

Namespaces

namespace  pmc_util
 

Common utility subroutines.


Functions

subroutine pmc_util::assert_msg (code, condition_ok, error_msg)
 Errors unless condition_ok is true.
subroutine pmc_util::assert (code, condition_ok)
 Errors unless condition_ok is true.
subroutine pmc_util::die (code)
 Error immediately.
subroutine pmc_util::die_msg (code, error_msg)
 Error immediately.
integer pmc_util::get_unit ()
 Returns an available unit number. This should be freed by free_unit().
subroutine pmc_util::free_unit (unit)
 Frees a unit number returned by get_unit().
subroutine pmc_util::open_output (basename, suffix, out_unit)
 Allocate a new unit and open it with a filename given by basename + suffix.
subroutine pmc_util::pmc_srand (seed)
 Initializes the random number generator to the state defined by the given seed. If the seed is 0 then a seed is auto-generated from the current time.
real *8 pmc_util::pmc_rand ()
 Returns a random number between 0 and 1. Call this function rather than rand() or random_number() directly, as some compilers have trouble with one or the other.
integer pmc_util::pmc_rand_int (n)
 Returns a random integer between 1 and n.
integer pmc_util::prob_round (val)
 Round val to floor(val) or ceil(val) with probability proportional to the relative distance from val. That is, Prob(prob_round(val) == floor(val)) = ceil(val) - val.
real *8 pmc_util::vol2rad (v)
 Convert volume (m^3) to radius (m).
real *8 pmc_util::vol2diam (v)
 Convert volume (m^3) to diameter (m).
real *8 pmc_util::rad2vol (r)
 Convert radius (m) to volume (m^3).
real *8 pmc_util::diam2vol (d)
 Convert diameter (m) to volume (m^3).
logical pmc_util::almost_equal (d1, d2)
 Tests whether two real numbers are almost equal using only a relative tolerance.
logical pmc_util::almost_equal_abs (d1, d2, abs_tol)
 Tests whether two real numbers are almost equal using an absolute and relative tolerance.
subroutine pmc_util::check_event (time, timestep, interval, last_time, do_event)
 Computes whether an event is scheduled to take place.
subroutine pmc_util::open_existing (unit, filename)
 Opens a file for reading that must already exist, checking for errors.
subroutine pmc_util::linspace (min_x, max_x, n, x)
 Makes a linearly spaced array of length n from min to max.
subroutine pmc_util::logspace (min_x, max_x, n, x)
 Makes a logarithmically spaced array of length n from min to max.
integer pmc_util::linspace_find (min_x, max_x, n, x)
 Find the position of a real number in a 1D linear array.
integer pmc_util::logspace_find (min_x, max_x, n, x)
 Find the position of a real number in a 1D logarithmic array.
integer pmc_util::find_1d (n, x_vals, x)
 Find the position of a real number in an arbitrary 1D array.
real *8 pmc_util::interp_1d (x_vals, y_vals, x)
 1D linear interpolation.
integer pmc_util::string_to_integer (string)
 Convert a string to an integer.
real *8 pmc_util::string_to_real (string)
 Convert a string to a real.
logical pmc_util::string_to_logical (string)
 Convert a string to a logical.
integer pmc_util::sample_cts_pdf (n, pdf)
 Sample the given continuous probability density function.
integer pmc_util::sample_disc_pdf (n, pdf)
 Sample the given discrete probability density function.
subroutine pmc_util::sample_vec_cts_to_disc (n, vec_cts, n_samp, vec_disc)
 Convert a continuous vector into a discrete vector.
subroutine pmc_util::vec_cts_to_disc (n, vec_cts, n_samp, vec_disc)
 Convert a continuous vector into a discrete vector.
subroutine pmc_util::average_integer (int_vec, int_avg)
 Computes the average of an array of integer numbers.
subroutine pmc_util::average_real (real_vec, real_avg)
 Computes the average of an array of real numbers.
subroutine pmc_util::get_basename (filename, basename)
 Strip the extension to find the basename.
subroutine pmc_util::iso8601_date_and_time (date_time)
 Current date and time in ISO 8601 format.

Variables

integer, parameter pmc_util::max_units = 200
 Maximum number of IO units usable simultaneously.
integer, parameter pmc_util::unit_offset = 10
 Minimum unit number to allocate.
logical, dimension(max_units), save pmc_util::unit_used = .false.
 Table of unit numbers storing allocation status.

Detailed Description

The pmc_util module.


Generated on 29 Mar 2010 for PartMC by  doxygen 1.6.1