diff --git a/src/ProgramDeclarations.cs b/src/ProgramDeclarations.cs
index d564578..44082e3 100644
--- a/src/ProgramDeclarations.cs
+++ b/src/ProgramDeclarations.cs
@@ -1194,6 +1194,10 @@ partial class Program
///
public static Int32 IOUT;
///
+ ///Fixed random seed value
+ ///
+ public static Int32 FIXEDRND;
+ ///
///Total simulation time
///
public static double DTI;
diff --git a/src/Read_Ini_Files.cs b/src/Read_Ini_Files.cs
index 0172d42..0c1e258 100644
--- a/src/Read_Ini_Files.cs
+++ b/src/Read_Ini_Files.cs
@@ -513,6 +513,10 @@ private static void Read_IIN_Dat()
text[1] = text[1].Trim();
text[1] = text[1].Replace(".", decsep);
IOUT = Convert.ToInt32(text[1]);
+ text = myreader.ReadLine().Split(new char[] { '!', ':' });
+ text[1] = text[1].Trim();
+ text[1] = text[1].Replace(".", decsep);
+ FIXEDRND = Convert.ToInt32(text[1]);
}
}
}
diff --git a/src/TEMPINT.cs b/src/TEMPINT.cs
index b03f34a..5a6827f 100644
--- a/src/TEMPINT.cs
+++ b/src/TEMPINT.cs
@@ -18,6 +18,20 @@ namespace GRAMM_2001
{
partial class Program
{
+ ///
+ /// Seed value used in GRAMM deterministic mode.
+ /// The value of 160991 was chosen because the seed produces a first NextDouble() that is
+ /// approximately halfway within the 10-degree sector width for the first weather situation.
+ /// For example, if the sector ranges from 260 to 270 degrees, this seed value will produce 265.
+ /// For weather situations after that, the NextDouble() will operate as expected, with each weather
+ /// situation producing a different wind direction between 260 and 270 degrees in this example.
+ /// But the direction will be the same between model runs.
+ /// When not running GRAMM in deterministic mode, you could get a different value each time
+ /// the program is run for the same weather situation, such as 262, 267, 260, 270, etc.
+ ///
+ private const int FixedSeedValue = 160991;
+ private static readonly Random FixedRnd = new(FixedSeedValue);
+
///
/// This routine computes the initial wind- and temperature fields based on either
/// the file meteopgt.all representing a single point measurement and stability class or
@@ -29,7 +43,7 @@ partial class Program
public static void Temp_INIT(int NI, int NJ, int NK)
{
//local variables declaration block
- Random rnd = new Random();
+ Random rnd;
string VARI;
string VAIR;
string ZEILE;
@@ -275,6 +289,15 @@ public static void Temp_INIT(int NI, int NJ, int NK)
}
//RANDOM wind direction within 10° Sector width to avoid finger like structures with point sources
+ if (Program.FIXEDRND == 1)
+ {
+ rnd = FixedRnd;
+ }
+ else
+ {
+ rnd = new Random();
+ }
+
if (TIMESERIES == 0)
{
WINDDIR = WINDDIR - SECTORWIDTH / 20 + SECTORWIDTH / 10 * rnd.NextDouble();