/* ReSCAL - Global definitions
 *
 * Copyright (C) 2011-2012
 *
 * Author: Olivier Rozier <rozier@ipgp.fr>
 *
 * This file is part of ReSCAL.
 *
 * ReSCAL is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */



// version number and date
#define VER_NUM "1.3.1"
#define VER_DAT "2012-10"

// numeric format
#define NUM_MODE "en_US.UTF-8"  //english
//#define NUM_MODE "fr_FR.UTF-8"  //french

// ======================================================
// programs
enum PROGS {PROG_RESCAL, PROG_TOOL};

// ======================================================

// choice of a model

#define MODELE_DUN    //Dune morphodynamics
//#define MODELE_AVA    //Avalanches
//#define MODELE_CMB    //Core-mantle boundary
//#define MODELE_ICB    //Innercore-core boundary
//#define MODELE_RIV    //River (soil and water, no air)
//#define MODELE_CHE    //"Chenal et air" (obsolete)
//#define MODELE_CRI    //Cristallization (of calcite)
//#define MODELE_DIF    //Diffusion
//#define MODELE_LIFE   //Stochastic game of life (2D)

// ======================================================

// common options
#define GUI		//graphical interface
#define CYCLAGE_HOR     //horizontal cycling (incompatible with TRANSITION_BORD)
#define INFO_CEL        //log the number of cells
#define INFO_DBL        //log the number of active doublets
#define INFO_TRANS      //log the number of effective transitions
#define DUMP_SIGNATURE  //footprints for the comparison of two simulations (identical simulations => identical footprints)
//#define LOG_FILE        //ReSCAL logs redirected into a file
#define USE_LIBPNG        //use of libpng
//#define USE_GD          //use of libgd (alternative to USE_LIBPNG, but obsolete)
//#define ROTATE_LIGHT    //automatic rotation of the light source in ROT_CYCLE mode
#define REORIENT_AUTO   //automatic reorientation when saving (images of) the cellular space
#define CSP_MUTEX       //mutual exclusion on the cellular space (no transition while saving data)
//#define GTK_OLD_SYNTAX  //compile with old version of GTK+2.x

// ===================== CMB MODEL =====================
#ifdef MODELE_CMB

// nom du modele
#define MOD_NAME "CMB"

// list des etats
#define PLUS  0 //solide
#define ZERO  1 //liquide sature en elements legers
#define MOINS 2 //liquide non-sature
#define BORD  3 //bord
#define DUM   4 //inerte
#define PIERRE 7 //granit
#define TUNNEL 9 //tunnel vers une terre parallele

// noms des etats
#define ETATS { "PLUS", "ZERO", "MOINS", "BORD", "DUM", "", "", "GRANIT", "", "TUNNEL" }

// options specifiques du modele
//#define TRANSITION_BORD
#define DUMP_RUGOSI
#endif

// ===================== DUNES MODEL =====================
#ifdef MODELE_DUN

// name of the model
#define MOD_NAME "DUN"

// cell states
#define GR    0 //stable sand
#define GRJ   1 //instable sand
#define GRV   2 //not used
#define EAUC  3 //air (or water)
#define EAUT  4 //not used
#define BORD  5 //boundary
#define DUM   6 //neutral
#define IN    7 //input of sand
#define OUT   8 //output of sand
#define TUNNEL 9 //tunnel to another cellular space (with PARALLEL option)

// names of cell states
#define ETATS { "GR", "GRJ", "", "EAUC", "", "BORD", "DUM", "IN", "OUT", "TUNNEL" }

// specific options of the model
#define ALTI GR //compute elevation map for cells of type GR
#define AVALANCHES
//#define ROTATIONS
//#ifndef CYCLAGE_HOR
//#define TRANSITION_BORD //boundary transitions (obsolete)
//#endif
#define LIENS_TRANSITIONS //correlations of transitions
#define LGCA //lattice gas
#define CGV //compute shear stress (with LGCA option)
#define WIND_DATA //option for importing wind data from a file (with ROTATIONS option)
#define TIME_SCALE //option for computing the time scale (using additional physical parameters)
#define CELL_TIME GR //save time for each cell of type GR
//#define CELL_COLOR //use colored cells
//#define NORM2D //CGV with 2d normals
//#define TRACE_TRANS
//#define TRACE3D_CEL
//#define TRACE_PAR_COL //save the courses of colored cells (one cell per color)
//#define DUMP_SIGMA //calcul sigma sur l'altitude (avec le peigne)
//#define DUMP_AUTOCORREL //calcul de l'auto-correlation sur l'altitude (avec le peigne)
//#define APPEL_MCC //external matlab application
#endif

// ===================== MODELE AVA =====================
#ifdef MODELE_AVA

// nom du modele
#define MOD_NAME "AVA"

// list des etats
#define GR    0 //grain stable
#define AIR   1 //air
#define BORD  2 //bord
#define DUM   3 //inerte
#define IN    4 //source de grains
#define OUT   5 //sortie de grains
#define TUNNEL 9 //tunnel vers une terre parallele

#define TERRE    GR

// noms des etats
#define ETATS { "GR", "AIR", "BORD", "DUM", "IN", "OUT", "", "", "", "TUNNEL" }

// options specifiques du modele
#define ALTI GR //calcul de la hauteur des piles de cellules GR
#define AVALANCHES  //avalanches
//#define ROTATIONS //table tournante
//#define TRANSITION_BORD
//#define CELL_TIME GR //datation des cellules GR
#define CELL_COLOR //cellules colorees
//#define NORM2D //pour l'affichage
//#define TRACE_TRANS
#endif

// ===================== MODELE ICB =====================
#ifdef MODELE_ICB

// nom du modele
#define MOD_NAME "ICB"

// list des etats
#define PLUS  0 //fer solide
#define ZERO  1 //liquide sature en elements legers
#define MOINS 2 //liquide non-sature
#define BORD  3 //bord
#define DUM   4 //inerte
#define TUNNEL 9 //tunnel vers une terre parallele

// noms des etats
#define ETATS { "PLUS", "ZERO", "MOINS", "BORD" , "DUM"}

// options specifiques du modele
#define DUMP_RUGOSI

#endif

// ===================== MODELE RIV =====================
#ifdef MODELE_RIV

// nom du modele
#define MOD_NAME "RIV"

// list des etats
#define TERRE  0 //terre
#define BOUE   1 //boue
#define EAU    2 //eau
#define BT     3 //boue turbulent
#define PIERRE 4 //pierre
#define BORD   5 //bord
#define DUM    6 //inerte
#define IN     7 //source
#define OUT    8 //sortie
#define TUNNEL 9 //tunnel vers une terre parallele

// noms des etats
#define ETATS { "TERRE", "BOUE", "EAU", "BT", "PIERRE", "BORD", "DUM", "IN", "OUT", "TUNNEL"}

// options specifiques du modele
#define TRANSITION_BORD
#define LIENS_TRANSITIONS
#define ALTI TERRE //calcul de la hauteur des piles de cellules TERRE
#define AVALANCHES
//#define SURRECTIONS
//#define ETAT_BT //boue qui tombe -> cones de deposition
//#define REGUL_DB //regulation des transitions de doublet en fonction de l'altitude
//#define TRACE_SRC //calcul bassin versant
//#define TRACE_AIRE  //calcul aires drainees
//#define TRACE_TRANS
//#define TRACE_PAR //calcul debit + pente
//#define APPEL_GMT
//#define LISSAGE  //couche uniforme de BOUE + cristallisation BOUE->TERRE + pas de transport vers le haut => lissage avant mode TRACE
//#define CELL_TIME TERRE //datation des cellules TERRE


#endif

// ===================== MODELE CHE =====================
#ifdef MODELE_CHE

// nom du modele
#define MOD_NAME "CHE"

// list des etats
#define TERRE 0 //terre
#define BOUE  1 //boue
#define EAU   2 //eau
#define BORD  3 //bord
#define DUM   4 //inerte
#define IN    5 //source d'eau
#define AIR   6 //air
#define PIERRE 7 //pierre
#define TUNNEL 9 //tunnel vers une terre parallele

// noms des etats
#define ETATS { "TERRE", "BOUE", "EAU", "BORD", "BIDON", "SOURCE", "AIR", "PIERRE" }

// options specifiques du modele
#define TRANSITION_BORD
//#define DIFFUSION_TERRE_EAU
#define LIENS_TRANSITIONS

#endif

// ===================== MODELE CRI =====================
#ifdef MODELE_CRI

// nom du modele
#define MOD_NAME "CRI"

// list des etats
#define PLUS  0 //solide
#define ZERO  1 //gaz
#define BORD  3 //bord
#define DUM   4 //inerte
#define IN    5 //source du gaz
#define AIR   6 //air
#define TUNNEL 9 //tunnel vers une terre parallele

// noms des etats
#define ETATS { "SOLIDE", "GAZ", "", "BORD", "DUM", "SOURCE", "AIR" }

// options specifiques du modele
#define TRANSITION_BORD

#endif

// ===================== MODELE DIF =====================
#ifdef MODELE_DIF

// nom du modele
#define MOD_NAME "DIF"

// list des etats
#define TERRE 0 //terre
#define EAU  1 //eau
#define AIR   2 //air
#define BORD  3 //bord
#define DUM   4 //inerte
#define IN    5 //source
#define BOUE  7 //boue

// noms des etats
#define ETATS { "TERRE", "EAU", "AIR", "BORD", "BIDON", "SOURCE", "", "BOUE" }

// options specifiques du modele
#define TRANSITION_BORD

#endif

// ===================== MODELE LIFE =====================
#ifdef MODELE_LIFE

// nom du modele
#define MOD_NAME "LIFE"

// list des etats
#define DEAD 0
#define ALIVE 1
#define BORD  2 //bord
#define DUM   3 //inerte

// noms des etats
#define ETATS { "DEAD", "ALIVE", "BORD", "BIDON" }

#endif

// ======================================================

// verification of compatibility between the options

#ifndef ROTATIONS
#undef REORIENT_AUTO
#endif

#ifndef CGV
#undef TIME_SCALE
#endif

#ifndef CELL_COLOR
#undef TRACE_PAR_COL
#endif

// ======================================================

// constantes communes

#define MAX_CELL  10  //max number of cell types
#define MAX_DB    100 //max number of doublets in the model
#define MAX_CHK   3   //max number of check functions for one transition

#define EST       0
#define BAS       1
#define SUD       2

#define OUEST     3
#define HAUT      4
#define NORD      5

#define VERTICAL   0
#define EST_OUEST  1
#define NORD_SUD   2
#define HORIZONTAL 3 // EST_OUEST ou NORD_SUD
#define ISOTROPE   4
#define CLASSES_DB { "VERTICAL", "EAST_WEST", "NORTH_SOUTH", "HORIZONTAL" ,"ISOTROPIC"}

#define MAX_TRANSITIONS_DB 100
#define MAX_TRANSITIONS_CEL 10
#define MAX_LIENS  100

#define MAX_TRANSITIONS MAX_TRANSITIONS_DB+MAX_TRANSITIONS_CEL

#ifdef PARALLEL
#define MAX_NODE  16
#endif

#define PI 3.14159265

#define W32 1
#define W64 2

// ======================================================

