///////////////////////////////////////////////////////////////////////////////////////
/// \file config.h
/// \brief Configuration header file, accessible throughout the model code.
///
/// This header file contains preprocessor definitions accessible throughout the
/// model code. Each implementation file (.cpp file) in LPJ-GUESS should include
/// this header before anything else. Definitions should be placed here if they
/// are of interest when configuring how to build LPJ-GUESS, for instance
/// definitions for enabling/disabling a module, or changing a behaviour which
/// for some reason isn't configurable from the instruction file.
///
/// This file may also contain non-model related code for working around platform
/// specific issues, such as non-standard conforming compilers.
///
/// \author Joe Siltberg
/// $Date: 2018-12-21 08:30:58 +0100 (Fri, 21 Dec 2018) $
///
///////////////////////////////////////////////////////////////////////////////////////

#ifndef LPJ_GUESS_CONFIG_H
#define LPJ_GUESS_CONFIG_H

// Compiler specific checks, for instance for disabling specific warnings

// All versions of Microsoft's compiler
#ifdef _MSC_VER

// 'this' : used in base member initializer list
#pragma warning (disable: 4355)
// long name
#pragma warning (disable: 4786)

#endif

// min and max functions for MS Visual C++ 6.0
#if defined(_MSC_VER) && _MSC_VER == 1200
namespace std {
template <class T> inline T max(const T& a, const T& b) {
    return (a > b) ? a : b;
}

template <class T> inline T min(const T& a, const T& b) {
    return (a < b) ? a : b;
}
}
#else
// modern compilers define min and max in <algorithm>
#include <algorithm>
#endif

// ecev3 - so the model knows it's a coupled run, and when the CMIP6 forcing data (LULC & N dep.) starts
const bool ECEARTH = true;
const int CMIP6STARTYEAR = 1850;
const int CMIP6ENDYEAR = 2100;
// Whether to print monthly LAI and annual vegetation type and fraction to file in eceframework.cpp
const bool printOutputToFile = true; 
// Whether to spinup using IFS output or ERA20C output in eceframework.cpp
const bool ERA20CSPINUP = true;
const bool ECEARTHWITHCRUNCEP = false;
const bool PLUS200PPM = false; // CRESCENDO S3a experiment. Plus 200 ppm from year 1996
const bool PLUS5SOILT = false; // CRESCENDO S3b experiment. Plus 5K soil temp from year 1996
const bool PLUS50KGN = false; // CRESCENDO S3c experiment. Plus 50kg N/ha/year from year 1996
const int PLUSYEAR = 1996;

using std::min;
using std::max;

// platform independent function for changing working directory
// we'll call our new function change_directory
#ifdef _MSC_VER
// The Microsoft way
#include <direct.h>
#define change_directory _chdir
#else
// The POSIX way
#include <unistd.h>
#define change_directory chdir
#endif

#endif // LPJ_GUESS_CONFIG_H
