GoldSim Modeling & Native DLL

Step-by-Step GoldSim Setup Guide

Overview & Prerequisites

This tutorial walks through connecting the native 64-bit CligenWeather.dll engine to a GoldSim model using GoldSim's External (DLL) element and Time Series Definition outputs.

Before starting:

  1. Open your project in the Climate Simulator and generate your station's CLIGEN Parameters.
  2. Open the GoldSim DLL tab and download CligenWeather.dll into the same folder as your GoldSim .gsm model file (or download the complete bundle from the GitHub Release).
  3. Working Example Included: You can also download CLIGEN_SLC.gsm (GoldSim model) and CLIGEN_SLC.gsp (GoldSim Player file) directly from the GoldSim DLL tab or GitHub Release. This ready-to-run example uses weather data from Salt Lake City International Airport to demonstrate the exact 14-input / 3-Time-Series-Definition setup below.
  4. Create an Array Label Set in GoldSim named Months (Jan through Dec, 12 items).

Step 1: Create the 9 Monthly Vector Data Elements

To keep the GoldSim model clean and eliminate Lookup Table interpolation overhead, the DLL accepts your 12 monthly climate parameters as 9 Vector Data elements (Vector[Months], 12 items each) and fits a periodic seasonal cubic spline internally.

Create 9 Data elements defined as 1-D Arrays (Vectors) indexed by Months and paste the corresponding column values from the CLIGEN Parameters tab:

Element Name Type Units (Metric / US) Description
PWW Vector[Months] - Wet-day probability given previous day was wet (12 items)
PWD Vector[Months] - Wet-day probability given previous day was dry (12 items)
Mean_P Vector[Months] mm or in Mean daily precipitation depth on wet days (12 items)
SD_P Vector[Months] mm or in Standard deviation of wet-day precipitation depth (12 items)
Skew_P Vector[Months] - Skewness coefficient of wet-day precipitation depth (12 items)
Mean_Tmax Vector[Months] C or F Mean daily maximum air temperature (12 items)
SD_Tmax Vector[Months] Cdeg or Fdeg Standard deviation of daily maximum temperature (Difference unit)
Mean_Tmin Vector[Months] C or F Mean daily minimum air temperature (12 items)
SD_Tmin Vector[Months] Cdeg or Fdeg Standard deviation of daily minimum temperature (Difference unit)

Tip: GoldSim distinguishes between absolute temperatures (C, F) and temperature differences/standard deviations (Cdeg, Fdeg). Use Cdeg or Fdeg for SD_Tmax and SD_Tmin.


Step 2: Configure the External Element (CLIGEN_DLL)

Insert an External element (Insert > Function Elements > External), name it CLIGEN_DLL, and configure the Definition tab:

  • DLL Path (file name): CligenWeather.dll
  • Function Name (case-sensitive): CligenWeather
  • Run in separate process: Since GoldSim is a 32-bit application, check the box for running in separate process.

GoldSim External Element Interface Configuration

Next, switch to the Interface tab and add the 14 Input Arguments (113 double values total = 5 scalars + 9 monthly 12-item vectors) in this exact order:

# Input ID Type & Units GoldSim Link / Value
1 Start_Time Scalar (datetime) Link to GoldSim run property ~StartTime
2 Sim_Dur Scalar (day) Link to GoldSim run property ~SimDuration
3 Time_Step Scalar (day) Link to GoldSim run property ~TimestepLength (e.g., 1 day)
4 Realization Scalar (-) Link to GoldSim run property ~Realization
5 Units_Flag Scalar (-) 0 = Metric (mm, C), 1 = US Customary (in, F)
6 PWW Vector[Months] (-) Link to PWW Data element (12 items)
7 PWD Vector[Months] (-) Link to PWD Data element (12 items)
8 Mean_P Vector[Months] (mm or in) Link to Mean_P Data element (12 items)
9 SD_P Vector[Months] (mm or in) Link to SD_P Data element (12 items)
10 Skew_P Vector[Months] (-) Link to Skew_P Data element (12 items)
11 Mean_Tmax Vector[Months] (C or F) Link to Mean_Tmax Data element (12 items)
12 SD_Tmax Vector[Months] (Cdeg or Fdeg) Link to SD_Tmax Data element (12 items)
13 Mean_Tmin Vector[Months] (C or F) Link to Mean_Tmin Data element (12 items)
14 SD_Tmin Vector[Months] (Cdeg or Fdeg) Link to SD_Tmin Data element (12 items)

Still on the Interface tab, add the 3 Output Arguments as Time Series Definitions in this exact order:

# Output ID Type & Units Description
1 Precip_Rate Time Series Definition (mm/d or in/d, instantaneous values) Stochastic daily precipitation rate time series
2 Tmax Time Series Definition (C or F, instantaneous values) Stochastic daily maximum air temperature time series
3 Tmin Time Series Definition (C or F, instantaneous values) Stochastic daily minimum air temperature time series

Step 3: Link Downstream Time Series Elements & Run

Create three Time Series elements in GoldSim (Precip_DLL, Tmax_DLL, Tmin_DLL):

  1. Set Data Source to Linked to external Time Series Definition.
  2. Link each Time Series element to the corresponding output from CLIGEN_DLL:
  3. Precip_DLL → CLIGEN_DLL.Precip_Rate
  4. Tmax_DLL → CLIGEN_DLL.Tmax
  5. Tmin_DLL → CLIGEN_DLL.Tmin

Connect a Time History Result element to Precip_DLL, Tmax_DLL, and Tmin_DLL and run your Monte Carlo simulation. At ETime = 0 of each realization, CligenWeather.dll seeds its 64-bit Mersenne Twister (mt19937_64) from Realization and populates the complete daily weather time series for the entire simulation duration.