[Dart-dev] [6379] DART/trunk/random_seq: add a simple program to generate a large number
nancy at ucar.edu
nancy at ucar.edu
Mon Aug 5 15:21:39 MDT 2013
Revision: 6379
Author: nancy
Date: 2013-08-05 15:21:38 -0600 (Mon, 05 Aug 2013)
Log Message:
-----------
add a simple program to generate a large number
of uniform distribution values and bin them into
something that the 'bar()' function in matlab can
plot for a histogram of the distribution of values
between 0.0 and 1.0 from the random number generator.
Added Paths:
-----------
DART/trunk/random_seq/test/mkmf_test_hist
DART/trunk/random_seq/test/path_names_test_hist
DART/trunk/random_seq/test_hist.f90
-------------- next part --------------
Added: DART/trunk/random_seq/test/mkmf_test_hist
===================================================================
--- DART/trunk/random_seq/test/mkmf_test_hist (rev 0)
+++ DART/trunk/random_seq/test/mkmf_test_hist 2013-08-05 21:21:38 UTC (rev 6379)
@@ -0,0 +1,18 @@
+#!/bin/csh
+#
+# DART software - Copyright 2004 - 2013 UCAR. This open source software is
+# provided by UCAR, "as is", without charge, subject to all terms of use at
+# http://www.image.ucar.edu/DAReS/DART/DART_download
+#
+# DART $Id$
+
+../../mkmf/mkmf -p test_hist -t ../../mkmf/mkmf.template \
+ -a "../../" path_names_test_hist
+
+exit $status
+
+# <next few lines under version control, do not edit>
+# $URL$
+# $Revision$
+# $Date$
+
Property changes on: DART/trunk/random_seq/test/mkmf_test_hist
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author HeadURL Id
Added: svn:eol-style
+ native
Added: DART/trunk/random_seq/test/path_names_test_hist
===================================================================
--- DART/trunk/random_seq/test/path_names_test_hist (rev 0)
+++ DART/trunk/random_seq/test/path_names_test_hist 2013-08-05 21:21:38 UTC (rev 6379)
@@ -0,0 +1,6 @@
+random_seq/test_hist.f90
+random_seq/random_seq_mod.f90
+common/types_mod.f90
+utilities/utilities_mod.f90
+mpi_utilities/null_mpi_utilities_mod.f90
+time_manager/time_manager_mod.f90
Added: DART/trunk/random_seq/test_hist.f90
===================================================================
--- DART/trunk/random_seq/test_hist.f90 (rev 0)
+++ DART/trunk/random_seq/test_hist.f90 2013-08-05 21:21:38 UTC (rev 6379)
@@ -0,0 +1,61 @@
+! DART software - Copyright 2004 - 2013 UCAR. This open source software is
+! provided by UCAR, "as is", without charge, subject to all terms of use at
+! http://www.image.ucar.edu/DAReS/DART/DART_download
+!
+! $Id$
+
+program test_hist
+
+! generate random values and bin them into histogram bins.
+! easy enough to plot with the matlab 'bar()' function.
+
+use types_mod, only : r4, r8, digits12
+use utilities_mod, only : register_module, error_handler, E_ERR, E_MSG, &
+ initialize_utilities, finalize_utilities
+use random_seq_mod, only : random_seq_type, init_random_seq, random_uniform
+
+implicit none
+
+! version controlled file description for error handling, do not edit
+character(len=256), parameter :: source = &
+ "$URL$"
+character(len=32 ), parameter :: revision = "$Revision$"
+character(len=128), parameter :: revdate = "$Date$"
+
+type (random_seq_type) :: r
+real(r8) :: val
+integer :: i, bin
+integer, parameter :: nbins = 500
+integer :: repcount = 100000000
+integer :: bincount(nbins)
+
+call initialize_utilities('test_hist')
+call register_module(source,revision,revdate)
+
+bincount(:) = 0
+
+call init_random_seq(r, 5)
+do i=1, repcount
+ val = random_uniform(r)
+ bin = int(val*nbins)
+ !print *, i, val, bin
+ bincount(bin) = bincount(bin)+1
+enddo
+
+do i=1, nbins
+ !print *, i, bincount(i)
+ !print *, (1.0_r8/nbins)*(i-1), bincount(i)
+ print *, bincount(i)
+enddo
+
+call error_handler(E_MSG, 'test_hist', 'Finished successfully.',&
+ source,revision,revdate)
+call finalize_utilities()
+
+end program test_hist
+
+! <next few lines under version control, do not edit>
+! $URL$
+! $Id$
+! $Revision$
+! $Date$
Property changes on: DART/trunk/random_seq/test_hist.f90
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author HeadURL Id
Added: svn:eol-style
+ native
More information about the Dart-dev
mailing list