[Dart-dev] [6930] DART/trunk/random_seq: update random number tests - remove obsolete tests,
nancy at ucar.edu
nancy at ucar.edu
Fri Apr 25 08:28:29 MDT 2014
Revision: 6930
Author: nancy
Date: 2014-04-25 08:28:25 -0600 (Fri, 25 Apr 2014)
Log Message:
-----------
update random number tests - remove obsolete tests,
rename some to be more clear, update the namelist values.
add a quickbuild to build all the tests
Modified Paths:
--------------
DART/trunk/random_seq/test/input.nml
DART/trunk/random_seq/test_reseed.f90
Added Paths:
-----------
DART/trunk/random_seq/test/mkmf_test_gaussian
DART/trunk/random_seq/test/path_names_test_gaussian
DART/trunk/random_seq/test/quickbuild.csh
DART/trunk/random_seq/test_gaussian.f90
Removed Paths:
-------------
DART/trunk/random_seq/test/mkmf_test_random_gsl
DART/trunk/random_seq/test/path_names_test_gsl_dart
DART/trunk/random_seq/test/path_names_test_gsl_native
DART/trunk/random_seq/test/path_names_test_random_gsl
-------------- next part --------------
Modified: DART/trunk/random_seq/test/input.nml
===================================================================
--- DART/trunk/random_seq/test/input.nml 2014-04-25 14:23:41 UTC (rev 6929)
+++ DART/trunk/random_seq/test/input.nml 2014-04-25 14:28:25 UTC (rev 6930)
@@ -5,16 +5,26 @@
/
&test_diff_nml
- mean = 0.0d0,
- sd1 = 1.0d0,
- sd2 = 1.0d0,
- iseed = 123
+ mean = 5.0,
+ sd1 = 1.0,
+ sd2 = 2.0,
+ iseed = 123
/
&test_reseed_nml
nsamples = 1000
- calendar_name = 'NO_CALENDAR'
- start_day = 0
- start_sec = 0
+ calendar_name = 'GREGORIAN'
+ start_day = 146770
+ start_sec = 10
/
+# possible reseed tests:
+# calendar_name = 'GREGORIAN'
+# start_day = 146770
+# start_sec = 10
+# or
+# calendar_name = 'NO_CALENDAR'
+# start_day = 0
+# start_sec = 0
+
+
Copied: DART/trunk/random_seq/test/mkmf_test_gaussian (from rev 6925, DART/trunk/random_seq/test/mkmf_test_random_gsl)
===================================================================
--- DART/trunk/random_seq/test/mkmf_test_gaussian (rev 0)
+++ DART/trunk/random_seq/test/mkmf_test_gaussian 2014-04-25 14:28:25 UTC (rev 6930)
@@ -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_gaussian -t ../../mkmf/mkmf.template \
+ -a "../../" path_names_test_gaussian
+
+exit $status
+
+# <next few lines under version control, do not edit>
+# $URL$
+# $Revision$
+# $Date$
+
Deleted: DART/trunk/random_seq/test/mkmf_test_random_gsl
===================================================================
--- DART/trunk/random_seq/test/mkmf_test_random_gsl 2014-04-25 14:23:41 UTC (rev 6929)
+++ DART/trunk/random_seq/test/mkmf_test_random_gsl 2014-04-25 14:28:25 UTC (rev 6930)
@@ -1,18 +0,0 @@
-#!/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_random_gsl -t ../../mkmf/mkmf.template \
- -a "../../" path_names_test_random_gsl
-
-exit $status
-
-# <next few lines under version control, do not edit>
-# $URL$
-# $Revision$
-# $Date$
-
Copied: DART/trunk/random_seq/test/path_names_test_gaussian (from rev 6925, DART/trunk/random_seq/test/path_names_test_random_gsl)
===================================================================
--- DART/trunk/random_seq/test/path_names_test_gaussian (rev 0)
+++ DART/trunk/random_seq/test/path_names_test_gaussian 2014-04-25 14:28:25 UTC (rev 6930)
@@ -0,0 +1,6 @@
+common/types_mod.f90
+mpi_utilities/null_mpi_utilities_mod.f90
+random_seq/random_seq_mod.f90
+random_seq/test_gaussian.f90
+time_manager/time_manager_mod.f90
+utilities/utilities_mod.f90
Deleted: DART/trunk/random_seq/test/path_names_test_gsl_dart
===================================================================
--- DART/trunk/random_seq/test/path_names_test_gsl_dart 2014-04-25 14:23:41 UTC (rev 6929)
+++ DART/trunk/random_seq/test/path_names_test_gsl_dart 2014-04-25 14:28:25 UTC (rev 6930)
@@ -1,6 +0,0 @@
-random_seq/test_gsl_dart.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
Deleted: DART/trunk/random_seq/test/path_names_test_gsl_native
===================================================================
--- DART/trunk/random_seq/test/path_names_test_gsl_native 2014-04-25 14:23:41 UTC (rev 6929)
+++ DART/trunk/random_seq/test/path_names_test_gsl_native 2014-04-25 14:28:25 UTC (rev 6930)
@@ -1 +0,0 @@
-random_seq/test_gsl_native.c
Deleted: DART/trunk/random_seq/test/path_names_test_random_gsl
===================================================================
--- DART/trunk/random_seq/test/path_names_test_random_gsl 2014-04-25 14:23:41 UTC (rev 6929)
+++ DART/trunk/random_seq/test/path_names_test_random_gsl 2014-04-25 14:28:25 UTC (rev 6930)
@@ -1,6 +0,0 @@
-random_seq/test_random_gsl.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/quickbuild.csh
===================================================================
--- DART/trunk/random_seq/test/quickbuild.csh (rev 0)
+++ DART/trunk/random_seq/test/quickbuild.csh 2014-04-25 14:28:25 UTC (rev 6930)
@@ -0,0 +1,44 @@
+#!/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$
+#
+# Script to manage the compilation of all tests in this directory.
+
+#----------------------------------------------------------------------
+
+\rm -f *.o *.mod
+
+set TEST = "random_seq"
+
+#----------------------------------------------------------------------
+# Build all targets
+#----------------------------------------------------------------------
+
+@ n = 0
+foreach TARGET ( mkmf_* )
+
+ set PROG = `echo $TARGET | sed -e 's#mkmf_##'`
+
+ @ n = $n + 1
+ echo
+ echo "---------------------------------------------------"
+ echo "${TEST} build number ${n} is ${PROG}"
+ \rm -f ${PROG}
+ csh $TARGET || exit $n
+ make || exit $n
+
+end
+
+\rm -f *.o *.mod input.nml*_default
+
+exit 0
+
+# <next few lines under version control, do not edit>
+# $URL$
+# $Revision$
+# $Date$
+
Property changes on: DART/trunk/random_seq/test/quickbuild.csh
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author HeadURL Id
Added: svn:eol-style
+ native
Copied: DART/trunk/random_seq/test_gaussian.f90 (from rev 6929, DART/trunk/random_seq/test_random_gsl.f90)
===================================================================
--- DART/trunk/random_seq/test_gaussian.f90 (rev 0)
+++ DART/trunk/random_seq/test_gaussian.f90 2014-04-25 14:28:25 UTC (rev 6930)
@@ -0,0 +1,85 @@
+! 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_gaussian
+
+! test the gaussian distribution random number generator routine
+! with different means, standard deviations, and iterations.
+
+use types_mod, only : r8
+use utilities_mod, only : register_module, &
+ initialize_utilities, finalize_utilities
+use random_seq_mod, only : random_seq_type, init_random_seq, random_gaussian
+
+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
+integer :: i, j, n
+real(r8) :: r1, sqdist, mean_sqdist
+real(r8) :: mean, sd
+
+type t_inputs
+ real(r8) :: m
+ real(r8) :: stddev
+ integer :: nreps
+end type
+
+
+! to add more tests or change the parameters, specify a test count
+! and update the sets of (mean, stddev, repeatcount) here:
+
+integer, parameter :: ntests = 10
+type(t_inputs) :: t(ntests) = (/ &
+ t_inputs(0.0_r8, 1.0_r8, 1000), &
+ t_inputs(0.0_r8, 1.0_r8, 1000000), &
+ t_inputs(0.0_r8, 1.0_r8, 100000000), &
+ t_inputs(1.0_r8, 5.0_r8, 100000000), &
+ t_inputs(1.0_r8, 5.0_r8, 10000), &
+ t_inputs(6.0_r8, 1.0_r8, 100000000), &
+ t_inputs(6.0_r8, 8.0_r8, 10000), &
+ t_inputs(6.0_r8, 8.0_r8, 1000000), &
+ t_inputs(6.0_r8, 8.0_r8, 100000000), &
+ t_inputs(0.0_r8, 8.0_r8, 100000000) /)
+
+
+call initialize_utilities('test_random')
+call register_module(source,revision,revdate)
+
+do j=1, ntests
+
+ call init_random_seq(r, 5)
+
+ mean = t(j)%m
+ sd = t(j)%stddev
+ n = t(j)%nreps
+
+ mean_sqdist = 0.0_r8
+
+ do i = 1, n
+ r1 = random_gaussian(r, mean, sd)
+ sqdist = (mean-r1)**2
+ mean_sqdist = mean_sqdist + sqdist
+ end do
+ write(*, *) 'input mean, sd, n = ', mean, sd, n
+ write(*, *) 'resulting var is ', sqrt(mean_sqdist / n)
+
+enddo
+
+call finalize_utilities()
+
+end program test_gaussian
+
+! <next few lines under version control, do not edit>
+! $URL$
+! $Id$
+! $Revision$
+! $Date$
Modified: DART/trunk/random_seq/test_reseed.f90
===================================================================
--- DART/trunk/random_seq/test_reseed.f90 2014-04-25 14:23:41 UTC (rev 6929)
+++ DART/trunk/random_seq/test_reseed.f90 2014-04-25 14:28:25 UTC (rev 6930)
@@ -4,6 +4,24 @@
!
! $Id$
+! a test of reseeding the random sequence generator, to see
+! if different seeds generate overlapping sequences of values.
+! one use case in the regular dart code is when running
+! perfect_model_obs and generating random draws of gaussian
+! error values. if the program is restarted each time between
+! separate model advances, if the same seed is used each time
+! then the errors will be the same. the code now reseeds the
+! random number generator with a value based on the state data
+! timestamp. this seed seems to generate random values for
+! observation errors which are not repeating.
+!
+! this program was also helpful in finding a bug in the
+! time_manager code with one compiler. it was generating
+! long repeating sequences of values which lead to the
+! discovery that the seconds were being rounded off to 0
+! when setting a time type and different times would result
+! in the same initial seed.
+
program test_reseed
use types_mod, only : r8
More information about the Dart-dev
mailing list