Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/ProgramDeclarations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,10 @@ partial class Program
///</summary>
public static Int32 IOUT;
///<summary>
///Fixed random seed value
///</summary>
public static Int32 FIXEDRND;
///<summary>
///Total simulation time
///</summary>
public static double DTI;
Expand Down
4 changes: 4 additions & 0 deletions src/Read_Ini_Files.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
}
Expand Down
25 changes: 24 additions & 1 deletion src/TEMPINT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ namespace GRAMM_2001
{
partial class Program
{
/// <summary>
/// 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.
/// </summary>
private const int FixedSeedValue = 160991;
private static readonly Random FixedRnd = new(FixedSeedValue);

/// <summary>
/// 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
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down