Advertisements
Most climate science code is in Fortran. Here is a useful C++ code snippet in case they ever want to switch over.
float record_temperature = yearly_temperatures[2005];
float 2010_temperature = yearly_temperatures[2010];
while (2010_temperature < record_temperature)
{
for (int month = 0; month < 12; month++)
{
float monthly_temperature = monthly_temperatures[2010][month];
float random_noise = ( float( (rand() % 5 ) / 10 ) - 0.15 );
monthly_temperature += random_noise;
monthly_temperatures[2010][month] = monthly_temperature;
2010_temperature += (random_noise / 12);
}
}
yearly_temperatures[2010] = 2010_temperature;
record_temperature = 2010_temperature;
Advertisements