!------------------------------------------------------------------------------
!        IST/MARETEC, Water Modelling Group, Mohid modelling system
!------------------------------------------------------------------------------
!
! TITLE         : Mohid Model
! PROJECT       : Mohid Base 1
! MODULE        : Global Data
! URL           : http://www.mohid.com
! AFFILIATION   : IST/MARETEC, Marine Modelling Group
! DATE          : May 2003
! REVISION      : Frank Braunschweig - v4.0
! DESCRIPTION   : Module which store global parameter
!
!------------------------------------------------------------------------------
Module ModuleGlobalData

    implicit none

    public

    !Subroutines---------------------------------------------------------------
    public  ::  CheckPropertyName
    public  ::  GetPropertyName
    public  ::  GetPropertyIDNumber
    private ::      ConstructPropList
    private ::          AddPropList
    public  ::  Check_Particulate_Property
    public  ::  TranslateTypeZUV
    
    public  ::  UnitsManager
    public  ::  SetError
    public  ::  WriteErrorMessage
    public  ::  LogKeyWord
    public  ::  StartupMohid
    public  ::  ShutdownMohid

    public  ::  GetUsersNumber
    
    !Modules management-----------------------------------------------------------------
    public  ::  RegisterNewInstance
    public  ::  AssociateInstance
    public  ::  DeassociateInstance
    public  ::  Read_Lock
    public  ::  Read_Unlock
    public  ::  VerifyReadLock

    !Parameter-----------------------------------------------------------------
    integer, parameter  :: MaxModules           =  67
    integer, parameter  :: MaxInstances         = 500

    integer, parameter  :: StringLength         = 128
    integer, parameter  :: PathLength           = 256


    !Search in Block, file, etc...
    integer, parameter :: FromFile_             = 1
    integer, parameter :: FromBlock_            = 2
    integer, parameter :: FromBlockInBlock_     = 3


    integer, parameter :: FromFile              = 1
    integer, parameter :: FromBlock             = 2
    integer, parameter :: FromBlockInBlock      = 3

    !Matrix Types (Centered in Z, U or V)
    integer, parameter :: TypeZ_                = 1
    integer, parameter :: TypeU_                = 2
    integer, parameter :: TypeV_                = 3


#ifdef _SHORT_LINE_LENGTH
    integer, parameter  :: line_length          = 64
#else
#ifdef  _LONG_LINE_LENGTH
    integer, parameter  :: line_length          = 1024
#else
    integer, parameter  :: line_length          = 256
#endif
#endif
                                                
    real   , parameter  :: FillValueReal        = -9.9e15
    integer, parameter  :: FillValueInt         = -9999999
                                                
    real,    parameter  :: AllmostZeroFraction  = 1.e-5
    real,    parameter  :: AllmostZero          = 1.e-15

    integer,            parameter :: null_int   = -999999
    real,               parameter :: null_real  = -9.9E15
    character(LEN = 5), parameter :: null_str   = '*****'

    !Time
    real,               parameter :: CyclicTime = -9999

   
    !character
    character(LEN = 1), parameter :: space      = char(32)   !" "
    character(LEN = 1), parameter :: dot        = char(46)   !"."
    character(LEN = 1), parameter :: delimiter  = char(58)   !":"
    character(LEN = 1), parameter :: semicolumn = char(59)   !";"
    character(LEN = 1), parameter :: tab        = char(9)    !" "

    logical, parameter :: OFF    = .FALSE.
    logical, parameter :: ON     = .TRUE.
    logical, parameter :: IDLE   = .FALSE.
    logical, parameter :: ACTIVE = .TRUE.

    !Errors
    integer, parameter :: UNKNOWN_               =-99
    integer, parameter :: SUCCESS_               = 0
    integer, parameter :: OFF_ERR_               = 1 
    integer, parameter :: ON_ERR_                = 2
    integer, parameter :: FILE_NOT_FOUND_ERR_    = 3 
    integer, parameter :: SIZE_ERR_              = 4
    integer, parameter :: BLOCK_END_ERR_         = 5
    integer, parameter :: KEYWORD_NOT_FOUND_ERR_ = 6
    integer, parameter :: READ_LOCK_ERR_         = 7
    integer, parameter :: IDLE_ERR_              = 9
    integer, parameter :: BLOCK_LOCK_ERR_        = 10
    integer, parameter :: BLOCK_UNLOCK_ERR_      = 11
    integer, parameter :: NBUSERS_ERR_           = 12
    integer, parameter :: CLIENT_NB_ERR_         = 13
    integer, parameter :: UNIT_ERR_              = 14
    integer, parameter :: INPUT_ERR_             = 15
    integer, parameter :: NO_ID_ERR_             = 16
    integer, parameter :: ID_ERR_                = 17
    integer, parameter :: NOT_FOUND_ERR_         = 18
    integer, parameter :: TIME_ERR_              = 19
    integer, parameter :: NOT_ASSOCIATE_         = 20
    integer, parameter :: FILE_EXISTS_ERR_       = 21


    !Water Properties 
    integer, parameter :: Density_                          =  0        
    integer, parameter :: Temperature_                      =  1        
    integer, parameter :: Salinity_                         =  2 
    integer, parameter :: Phytoplankton_                    =  3 
    integer, parameter :: Zooplankton_                      =  4 
    integer, parameter :: DOPRefractory_                    =  6
    integer, parameter :: DOPNon_Refractory_                =  7
    integer, parameter :: DONRefractory_                    =  8 
    integer, parameter :: DONNon_Refractory_                =  9  
    integer, parameter :: Inorganic_Phosphorus_             = 10

!____used @ modulelife______________________________________________
    integer, parameter :: POC_                              = 11   
    integer, parameter :: POP_                              = 12   
    integer, parameter :: PON_                              = 13   
    integer, parameter :: DOC_                              = 14   
    integer, parameter :: DOP_                              = 15   
    integer, parameter :: DON_                              = 16   
    integer, parameter :: Ammonia_                          = 20 
    integer, parameter :: Nitrate_                          = 21         
    integer, parameter :: Silicate_                         = 22 
    integer, parameter :: BioSilica_                        = 23
    integer, parameter :: CarbonDioxide_                    = 24
    integer, parameter :: Oxygen_                           = 25 
    integer, parameter :: DissolO2PercentSat_               = 26


    integer, parameter :: Nitrite_                          = 51
    integer, parameter :: BOD_                              = 52
    integer, parameter :: Cohesive_Sediment_                = 53
    integer, parameter :: Oil_                              = 54
    integer, parameter :: Ciliate_                          = 55
    integer, parameter :: Bacteria_                         = 56
    integer, parameter :: ParticulateArsenic_               = 57
    integer, parameter :: DissolvedArsenic_                 = 58
    integer, parameter :: Larvae_                           = 59
    integer, parameter :: Age_                              = 60
    integer, parameter :: Fecal_Coliforms_                  = 61
    integer, parameter :: Fish_                             = 62
    integer, parameter :: FishFood_                         = 63
    integer, parameter :: MacroAlgae_                       = 64
    integer, parameter :: MicroPhytoBenthos_                = 65
    integer, parameter :: AdsorbedAmmonia_                  = 66
    integer, parameter :: RefreactaryOrganicN_              = 67
    integer, parameter :: Ngas_                             = 68
    integer, parameter :: HeterotrophicN_                   = 69
    integer, parameter :: AnaerobicN_                       = 70
    integer, parameter :: AutotrophicN_                     = 71
    integer, parameter :: AnaerobicC_                       = 72
    integer, parameter :: AutotrophicC_                     = 73
    integer, parameter :: HeterotrophicC_                   = 74
    integer, parameter :: LabileOrganicC_                   = 75
    integer, parameter :: RefreactaryOrganicC_              = 76
    integer, parameter :: GenericProperty_                  = 77
    integer, parameter :: T90_                              = 78

    !Production parameters  
    integer, parameter :: GrossProd_                        = 80
    integer, parameter :: NutrientLim_                      = 81
    integer, parameter :: LightLim_                         = 82
    integer, parameter :: TemperatureLim_                   = 83
    integer, parameter :: SalinityLim_                      = 84
    integer, parameter :: NetProd_                          = 85
    integer, parameter :: DiaGrossProd_                     = 800 
    integer, parameter :: DiaNutrientLim_                   = 801 
    integer, parameter :: DiaLightLim_                      = 802 
    integer, parameter :: DiaTemperatureLim_                = 803 
    integer, parameter :: Diatoms_                          = 804 
    integer, parameter :: NLim_                             = 805
    integer, parameter :: PLim_                             = 806
    integer, parameter :: DiaNLim_                          = 807
    integer, parameter :: DiaPLim_                          = 808
    integer, parameter :: DiaSiLim_                         = 809



    !Hydrodynamic Properties
    integer, parameter :: WaterLevel_                       = 86
    integer, parameter :: VelocityU_                        = 87
    integer, parameter :: VelocityV_                        = 88
    integer, parameter :: WaterFluxX_                       = 89
    integer, parameter :: WaterFluxY_                       = 90
    integer, parameter :: WaterDepth_                       = 900
    integer, parameter :: Volume_                           = 901
    integer, parameter :: PercentageMaxVolume_              = 902
    integer, parameter :: VelocityModulus_                  = 903
    integer, parameter :: Courant_                          = 904
    integer, parameter :: FlowModulus_                      = 905
    integer, parameter :: ShearStress_                      = 906
    
    !Assimilation Properties        guillaume nogueira
    integer, parameter :: AltimLevelAnalyzed_               = 4000
    integer, parameter :: AltimTemperatureAnalyzed_         = 4001
    integer, parameter :: AltimSalinityAnalyzed_            = 4002
    integer, parameter :: AltimLevelToAssimilate_           = 4003
    integer, parameter :: VarianceFieldToAssimilate_        = 4004
                                                            
    !Explicit forces                                        
    integer, parameter :: CoriolisX_                        = 91
    integer, parameter :: BaroclinicForceX_                 = 92
    integer, parameter :: HorizontalTransportX_             = 93
                                                            
    integer, parameter :: CoriolisY_                        = 94
    integer, parameter :: BaroclinicForceY_                 = 95
    integer, parameter :: HorizontalTransportY_             = 96

    !MRV. Barotropic velocities for using in Flather condition
    integer, parameter :: BarotropicVelocityU_              = 97
    integer, parameter :: BarotropicVelocityV_              = 98

    !Hydrodynamic Properties
    integer, parameter :: VelocityW_                        = 99

    integer, parameter :: ShearVelocity_                    = 100

    integer, parameter :: ParticulateContaminant_           = 101
    integer, parameter :: DissolvedContaminant_             = 102

    integer, parameter :: Sediment                          = 103

    !Soil DissolvedSodium Adsorption Ratio parameters
    integer, parameter :: DissolvedSodium_                  = 104
    integer, parameter :: DissolvedCalcium_                 = 105
    integer, parameter :: ParticulateSodium_                = 106
    integer, parameter :: ParticulateCalcium_               = 107

    !Hydrodynamic Properties
    integer, parameter :: Vorticity_                        = 108
    integer, parameter :: BaroclinicKE_                     = 109
    integer, parameter :: PerturbationPE_                   = 110
    integer, parameter :: KineticEnergy_                    = 111

    integer, parameter :: BaroclinicVelocityU_              = 113
    integer, parameter :: BaroclinicVelocityV_              = 114
    
    integer, parameter :: ObstacleDragCoef_                 = 200

    !Geometry properties
    integer, parameter :: VerticalZ_                        = 300
     

    !Interface AirWater Properties
    integer, parameter :: LatentHeat_                       = 500
    integer, parameter :: SensibleHeat_                     = 501     
    integer, parameter :: Evaporation_                      = 502
    integer, parameter :: NetLongWaveRadiation_             = 503
    integer, parameter :: OxygenFlux_                       = 504
    integer, parameter :: WindShearVelocity_                = 505
    integer, parameter :: SurfaceRadiation_                 = 506
    integer, parameter :: WindStressX_                      = 507
    integer, parameter :: WindStressY_                      = 508
    integer, parameter :: SurfaceWaterFlux_                 = 509
    integer, parameter :: NonSolarFlux_                     = 510
    integer, parameter :: TurbulentKineticEnergy_           = 511
    integer, parameter :: CarbonDioxideFlux_                = 512
    integer, parameter :: Albedo_                           = 513
    integer, parameter :: UpwardLongWaveRadiation_          = 514
    integer, parameter :: DownwardLongWaveRadiation_        = 515
    integer, parameter :: ShortWaveSolarRadiation_          = 516
    integer, parameter :: LongWaveSolarRadiation_           = 517
    integer, parameter :: ShortWaveSolarRadiationExtin_     = 518
    integer, parameter :: LongWaveSolarRadiationExtin_      = 519



    !AtmosProperties
    integer, parameter :: WindVelocityX_                    = 600
    integer, parameter :: WindVelocityY_                    = 601
    integer, parameter :: SolarRadiation_                   = 602
    integer, parameter :: Precipitation_                    = 603
    integer, parameter :: AtmosphericPressure_              = 604
    integer, parameter :: AirTemperature_                   = 605
    integer, parameter :: RelativeHumidity_                 = 606
    integer, parameter :: WindModulos_                      = 607
    integer, parameter :: WindAngle_                        = 608
    integer, parameter :: CloudCover_                       = 609
    integer, parameter :: Irrigation_                       = 610
    integer, parameter :: SunHours_                         = 611
    integer, parameter :: ATMTransmitivity_                 = 612

    !Vegetation Properties
    integer, parameter :: LeafAreaIndex_                    = 700
    integer, parameter :: SpecificLeafStorage_              = 701
    integer, parameter :: EVTPCropCoefficient_              = 702
    integer, parameter :: RootDepth_                        = 703
    integer, parameter :: RootFeddesParameterH1_            = 704
    integer, parameter :: RootFeddesParameterH2_            = 705
    integer, parameter :: RootFeddesParameterH3_            = 706
    integer, parameter :: RootFeddesParameterH4_            = 707


!____used @ moduleCEQUALW2______________________________________________
    integer, parameter :: RPOM_                             = 2001
    integer, parameter :: LPOM_                             = 2002
    integer, parameter :: LDOM_                             = 2003
    integer, parameter :: RDOM_                             = 2004
    integer, parameter :: PSilica_                          = 2005
    integer, parameter :: DSilica_                          = 2006
    integer, parameter :: ICarbon_                          = 2007
    integer, parameter :: pH_                               = 2008
    integer, parameter :: HCO3_                             = 2009
    integer, parameter :: CO3_                              = 2010      
    integer, parameter :: Algae_1_                          = 2011
    integer, parameter :: Algae_2_                          = 2012
    integer, parameter :: Algae_3_                          = 2013
    integer, parameter :: Algae_4_                          = 2014
    integer, parameter :: Algae_5_                          = 2015
    integer, parameter :: Epiphyton_1_                      = 2016
    integer, parameter :: Epiphyton_2_                      = 2017
    integer, parameter :: Epiphyton_3_                      = 2018
    integer, parameter :: Epiphyton_4_                      = 2019
    integer, parameter :: Epiphyton_5_                      = 2020
    integer, parameter :: Alkalinity_                       = 2040
    integer, parameter :: Detritus_                         = 2041

    ! Rates for output -------------------------------------------

    !Algal Growth Limitations                     
    integer, parameter :: ANLim_                           = 2101
    integer, parameter :: APLim_                           = 2102
    integer, parameter :: ASLim_                           = 2103
    integer, parameter :: ALightLim_                       = 2104
    integer, parameter :: AOverallLim_                     = 2106
                                                
    
    
    !Epiphyte Growth Limitations                         
    integer, parameter :: ENLim_                           = 2107
    integer, parameter :: EPLim_                           = 2108
    integer, parameter :: ESLim_                           = 2109
    integer, parameter :: ELightLim_                       = 2110
    integer, parameter :: EOverallLim_                     = 2112
                                            
    
    !Decay Rates                                
    integer, parameter ::  NH4D_                           = 2113
    integer, parameter ::  NO3D_                           = 2114
    integer, parameter ::  LDOMD_                          = 2115
    integer, parameter ::  RDOMD_                          = 2116
    integer, parameter ::  LPOMD_                          = 2117
    integer, parameter ::  RPOMD_                          = 2118
    integer, parameter ::  LRDOMD_                         = 2119
    integer, parameter ::  LRPOMD_                         = 2120
    integer, parameter ::  CBODD_                          = 2121
    
    !phosphorus
    integer, parameter ::  PO4ER_                          = 2122
    integer, parameter ::  PO4EG_                          = 2123
    integer, parameter ::  PO4AR_                          = 2124
    integer, parameter ::  PO4AG_                          = 2125
    integer, parameter ::  PO4OM_                          = 2126
    integer, parameter ::  PO4BOD_                         = 2127
            
    ! ammonia
    
    integer, parameter ::  NH4ER_                          = 2128 
    integer, parameter ::  NH4EG_                          = 2129
    integer, parameter ::  NH4AR_                          = 2130
    integer, parameter ::  NH4AG_                          = 2131
    integer, parameter ::  NH4OM_                          = 2132
    integer, parameter ::  NH4BOD_                         = 2133
    
    !nitrate
    integer, parameter ::  NO3AG_                          = 2134
    integer, parameter ::  NO3EG_                          = 2135

    !dissolved silica
    integer, parameter ::  DSIAG_                          = 2136
    integer, parameter ::  DSIEG_                          = 2137
    integer, parameter ::  DSID_                           = 2138

    !particulated silica
    integer, parameter ::  PSIAM_                          = 2139
    integer, parameter ::  PSID_                           = 2140 

    !LabDom
    integer, parameter ::  LDOMAP_                         = 2141
    integer, parameter ::  LDOMEP_                         = 2142


    !labPom
    integer, parameter ::  LPOMAP_                         = 2143


    !oxygen
    integer, parameter ::  DOAP_                           = 2144
    integer, parameter ::  DOEP_                           = 2145
    integer, parameter ::  DOAR_                           = 2146
    integer, parameter ::  DOER_                           = 2147
    integer, parameter ::  DOOM_                           = 2148
    integer, parameter ::  DONIT_                          = 2149
    
    !inorganic Carbon
    integer, parameter ::  ICarbonAP_                      = 2150
    integer, parameter ::  ICarbonEP_                      = 2151
    integer, parameter ::  ICarbonBOD_                     = 2152

    !sand transport
    integer, parameter ::  Diameter_                       = 3001
    integer, parameter ::  Percentage_                     = 3002
    integer, parameter ::  D35_                            = 3003
    integer, parameter ::  D50_                            = 3004
    integer, parameter ::  D90_                            = 3005
    integer, parameter ::  BedRock_                        = 3006
    integer, parameter ::  SandTauCritic_                  = 3007
    integer, parameter ::  Sand_                           = 3008

    integer, parameter ::  TransportCapacity_              = 3101 
    integer, parameter ::  TransportCapacityX_             = 3102 
    integer, parameter ::  TransportCapacityY_             = 3103 
    integer, parameter ::  BottomEvolution_                = 3104 
    integer, parameter ::  Newbathymetry_                  = 3105 

    !wave dynamics
    integer, parameter ::  WaveStressX_                    = 3401
    integer, parameter ::  WaveStressY_                    = 3402
    integer, parameter ::  OrbitalVelocityX_               = 3403
    integer, parameter ::  OrbitalVelocityY_               = 3404
    !!Monocromatic:
    integer, parameter ::  WaveAmplitude_                  = 3501
    integer, parameter ::  WavePeriod_                     = 3502
    integer, parameter ::  WaveDirection_                  = 3503
    !!Statistical wave parametres (WW3,SWAN)
    integer, parameter ::  SignificantWaveHeight_          = 3504
    integer, parameter ::  MeanWaveLength_                 = 3505
    integer, parameter ::  MeanWavePeriod_                 = 3506
    integer, parameter ::  MeanWaveDirection_              = 3507
    integer, parameter ::  MeanDirectionalSpread_          = 3508
    integer, parameter ::  PeakFrequency_                  = 3509
    integer, parameter ::  PeakDirection_                  = 3510
    integer, parameter ::  WindSeaPeakFrequency_           = 3511
    integer, parameter ::  WindSeaPeakDirection_           = 3512

!____________________________________________________________________________________
!________________________________________________________exclusive use @ modulelife__

    integer, parameter :: Diatom_C_                         = 5001
    integer, parameter :: Diatom_N_                         = 5002
    integer, parameter :: Diatom_P_                         = 5003
    integer, parameter :: Diatom_Si_                        = 5004
    integer, parameter :: Diatom_Chl_                       = 5005
    integer, parameter :: Mix_Flagellate_C_                 = 5006
    integer, parameter :: Mix_Flagellate_N_                 = 5007
    integer, parameter :: Mix_Flagellate_P_                 = 5008
    integer, parameter :: Mix_Flagellate_Chl_               = 5009
    integer, parameter :: Picoalgae_C_                      = 5010
    integer, parameter :: Picoalgae_N_                      = 5011
    integer, parameter :: Picoalgae_P_                      = 5012
    integer, parameter :: Picoalgae_Chl_                    = 5013
    integer, parameter :: Flagellate_C_                     = 5014
    integer, parameter :: Flagellate_N_                     = 5015
    integer, parameter :: Flagellate_P_                     = 5016
    integer, parameter :: Flagellate_Chl_                   = 5017
    integer, parameter :: Microzooplankton_C_               = 5018
    integer, parameter :: Microzooplankton_N_               = 5019
    integer, parameter :: Microzooplankton_P_               = 5020
    integer, parameter :: Het_Nanoflagellate_C_             = 5021
    integer, parameter :: Het_Nanoflagellate_N_             = 5022
    integer, parameter :: Het_Nanoflagellate_P_             = 5023
    integer, parameter :: Mesozooplankton_C_                = 5024
    integer, parameter :: Mesozooplankton_N_                = 5025
    integer, parameter :: Mesozooplankton_P_                = 5026
    integer, parameter :: Het_Bacteria_C_                   = 5027
    integer, parameter :: Het_Bacteria_N_                   = 5028
    integer, parameter :: Het_Bacteria_P_                   = 5029
    integer, parameter :: DOCsl_                            = 5030  
    integer, parameter :: DOPsl_                            = 5031 
    integer, parameter :: DONsl_                            = 5032


    integer, parameter :: ConsolidationFlux_                = 9000
    integer, parameter :: Porosity_                         = 9001

!_______________________________________________________________________________________________

      
    !Name of Waterproperties
    character(StringLength), private, parameter :: Char_Density              = 'density'
    character(StringLength), private, parameter :: Char_Temperature          = 'temperature'
    character(StringLength), private, parameter :: Char_Salinity             = 'salinity'
    character(StringLength), private, parameter :: Char_Phytoplankton        = 'phytoplankton'
    character(StringLength), private, parameter :: Char_Zooplankton          = 'zooplankton'
    character(StringLength), private, parameter :: Char_DOPRefractory        = 'dissolved refractory organic phosphorus'
    character(StringLength), private, parameter :: Char_DOPNon_Refractory    = 'dissolved non-refractory organic phosphorus'
    character(StringLength), private, parameter :: Char_DONRefractory        = 'dissolved refractory organic nitrogen'
    character(StringLength), private, parameter :: Char_DONNon_Refractory    = 'dissolved non-refractory organic nitrogen'
    character(StringLength), private, parameter :: Char_Inorganic_Phosphorus = 'inorganic phosphorus'


! Marky Mark 
!_______used @ modulelife__________________________________________________________________________________________________

    character(StringLength), private, parameter :: Char_POC                  = 'particulate organic carbon'
    character(StringLength), private, parameter :: Char_POP                  = 'particulate organic phosphorus'    
    character(StringLength), private, parameter :: Char_PON                  = 'particulate organic nitrogen'
    character(StringLength), private, parameter :: Char_DOC                  = 'labile dissolved organic carbon'
    character(StringLength), private, parameter :: Char_DOP                  = 'labile dissolved organic phosphorus'    
    character(StringLength), private, parameter :: Char_DON                  = 'labile dissolved organic nitrogen'
    character(StringLength), private, parameter :: Char_DOCsl                = 'semi-labile dissolved organic carbon'
    character(StringLength), private, parameter :: Char_DOPsl                = 'semi-labile dissolved organic phosphorus'    
    character(StringLength), private, parameter :: Char_DONsl                = 'semi-labile dissolved organic nitrogen'
    character(StringLength), private, parameter :: Char_Ammonia              = 'ammonia'
    character(StringLength), private, parameter :: Char_Nitrate              = 'nitrate'
    character(StringLength), private, parameter :: Char_Silicate             = 'silicate acid'
    character(StringLength), private, parameter :: Char_BioSilica            = 'biogenic silica'
    character(StringLength), private, parameter :: Char_CarbonDioxide        = 'carbon dioxide'
    character(StringLength), private, parameter :: Char_Oxygen               = 'oxygen'
    character(StringLength), private, parameter :: Char_DissolO2PercentSat   = 'dissolved oxygen percent saturation'

    character(StringLength), private, parameter :: Char_Diatom_C             = 'diatoms carbon'
    character(StringLength), private, parameter :: Char_Diatom_N             = 'diatoms nitrogen'
    character(StringLength), private, parameter :: Char_Diatom_P             = 'diatoms phosphorus'
    character(StringLength), private, parameter :: Char_Diatom_Si            = 'diatoms silica'
    character(StringLength), private, parameter :: Char_Diatom_Chl           = 'diatoms chlorophyll'

    character(StringLength), private, parameter :: Char_Mix_Flagellate_C     = 'autotrophic flagellates carbon'
    character(StringLength), private, parameter :: Char_Mix_Flagellate_N     = 'autotrophic flagellates nitrogen'
    character(StringLength), private, parameter :: Char_Mix_Flagellate_P     = 'autotrophic flagellates phosphorus'
    character(StringLength), private, parameter :: Char_Mix_Flagellate_Chl   = 'autotrophic flagellates chlorophyll'

    character(StringLength), private, parameter :: Char_Picoalgae_C          = 'picoalgae carbon'
    character(StringLength), private, parameter :: Char_Picoalgae_N          = 'picoalgae nitrogen'
    character(StringLength), private, parameter :: Char_Picoalgae_P          = 'picoalgae phosphorus'
    character(StringLength), private, parameter :: Char_Picoalgae_Chl        = 'picoalgae chlorophyll'

    character(StringLength), private, parameter :: Char_Flagellate_C         = 'flagellates carbon'
    character(StringLength), private, parameter :: Char_Flagellate_N         = 'flagellates nitrogen'
    character(StringLength), private, parameter :: Char_Flagellate_P         = 'flagellates phosphorus'
    character(StringLength), private, parameter :: Char_Flagellate_Chl       = 'flagellates chlorophyll'

    character(StringLength), private, parameter :: Char_Microzooplankton_C   = 'microzooplankton carbon'
    character(StringLength), private, parameter :: Char_Microzooplankton_N   = 'microzooplankton nitrogen'
    character(StringLength), private, parameter :: Char_Microzooplankton_P   = 'microzooplankton phosphorus'

    character(StringLength), private, parameter :: Char_Het_Nanoflagellate_C = 'heterotrophic nanoflagellate carbon'
    character(StringLength), private, parameter :: Char_Het_Nanoflagellate_N = 'heterotrophic nanoflagellate nitrogen'
    character(StringLength), private, parameter :: Char_Het_Nanoflagellate_P = 'heterotrophic nanoflagellate phosphorus'

    character(StringLength), private, parameter :: Char_Mesozooplankton_C    = 'mesozooplankton carbon'
    character(StringLength), private, parameter :: Char_Mesozooplankton_N    = 'mesozooplankton nitrogen'
    character(StringLength), private, parameter :: Char_Mesozooplankton_P    = 'mesozooplankton phosphorus'

    character(StringLength), private, parameter :: Char_Het_Bacteria_C       = 'heterotrophic bacteria carbon'
    character(StringLength), private, parameter :: Char_Het_Bacteria_N       = 'heterotrophic bacteria nitrogen'
    character(StringLength), private, parameter :: Char_Het_Bacteria_P       = 'heterotrophic bacteria phosphorus'
!___________________________________________________________________________________________________________________


    character(StringLength), private, parameter :: Char_Nitrite              = 'nitrite'
    character(StringLength), private, parameter :: Char_BOD                  = 'biochemical oxygen demand'
    character(StringLength), private, parameter :: Char_Cohesive_Sediment    = 'cohesive sediment'
    character(StringLength), private, parameter :: Char_Fecal_Coliforms      = 'fecal coliforms'
    character(StringLength), private, parameter :: Char_T90                  = 'T90'

    character(StringLength), private, parameter :: Char_Oil                  = 'oil'
    character(StringLength), private, parameter :: Char_Ciliate              = 'ciliate'
    character(StringLength), private, parameter :: Char_Bacteria             = 'bacteria'
    character(StringLength), private, parameter :: Char_ParticulateArsenic   = 'particulate arsenic'
    character(StringLength), private, parameter :: Char_DissolvedArsenic     = 'dissolved arsenic'
    character(StringLength), private, parameter :: Char_Larvae               = 'larvae'
    character(StringLength), private, parameter :: Char_Age                  = 'age'
    character(StringLength), private, parameter :: Char_Fish                 = 'fish'
    character(StringLength), private, parameter :: Char_FishFood             = 'fish food'
    character(StringLength), private, parameter :: Char_MacroAlgae           = 'macroalgae'
    character(StringLength), private, parameter :: Char_MicroPhytoBenthos    = 'microphytobenthos' !Rosa
    character(StringLength), private, parameter :: Char_GenericProperty      = 'generic property'

    character(StringLength), private, parameter :: Char_GrossProd            = 'grossprod'
    character(StringLength), private, parameter :: Char_NutrientLim          = 'nutrientlim'
    character(StringLength), private, parameter :: Char_NLim                 = 'nitrogenlim'
    character(StringLength), private, parameter :: Char_PLim                 = 'phosphoruslim'
    character(StringLength), private, parameter :: Char_LightLim             = 'lightlim'
    character(StringLength), private, parameter :: Char_TemperatureLim       = 'temperaturelim'
    character(StringLength), private, parameter :: Char_SalinityLim          = 'salinitylim' 
    character(StringLength), private, parameter :: Char_NetProd              = 'netprod'

    character(StringLength), private, parameter :: Char_DiaGrossProd         = 'diagrossprod'      
    character(StringLength), private, parameter :: Char_DiaNutrientLim       = 'dianutrientlim'    
    character(StringLength), private, parameter :: Char_DiaLightLim          = 'dialightlim'       
    character(StringLength), private, parameter :: Char_DiaTemperatureLim    = 'diatemperaturelim' 
    character(StringLength), private, parameter :: Char_Diatoms              = 'diatoms'           
    character(StringLength), private, parameter :: Char_DiaNLim              = 'dianitrogenlim'
    character(StringLength), private, parameter :: Char_DiaPLim              = 'diaphosphoruslim'
    character(StringLength), private, parameter :: Char_DiaSiLim             = 'diasilicalim'

    character(StringLength), private, parameter :: Char_AdsorbedAmmonia      = 'particulated ammonia'
    character(StringLength), private, parameter :: Char_RefreactaryOrganicN  = 'particulated refractory organic nitrogen'
    character(StringLength), private, parameter :: Char_Ngas                 = 'nitrogen gas'

    character(StringLength), private, parameter :: Char_HeterotrophicC       = 'heterotrophic microorganism carbon'
    character(StringLength), private, parameter :: Char_HeterotrophicN       = 'heterotrophic microorganism nitrogen'
    character(StringLength), private, parameter :: Char_AnaerobicC           = 'anaerobic microorganism carbon'
    character(StringLength), private, parameter :: Char_AnaerobicN           = 'anaerobic microorganism nitrogen'
    character(StringLength), private, parameter :: Char_AutotrophicC         = 'autotrophic microorganism carbon'
    character(StringLength), private, parameter :: Char_AutotrophicN         = 'autotrophic microorganism nitrogen'

    character(StringLength), private, parameter :: Char_LabileOrganicC       = 'particulate labile organic carbon'
    character(StringLength), private, parameter :: Char_RefreactaryOrganicC  = 'particulated refractory organic carbon'

    character(StringLength), private, parameter :: Char_WaterLevel_          = 'water level'
    character(StringLength), private, parameter :: Char_VelocityModulus_     = 'velocity modulus'   
    character(StringLength), private, parameter :: Char_FlowModulus_         = 'flow modulus'   
    character(StringLength), private, parameter :: Char_VelocityU_           = 'velocity U'
    character(StringLength), private, parameter :: Char_VelocityV_           = 'velocity V'
    character(StringLength), private, parameter :: Char_VelocityW_           = 'velocity W'
    character(StringLength), private, parameter :: Char_ShearStress_         = 'shear stress'

    ! guillaume nogueira
    character(StringLength), private, parameter :: Char_AltimLevelAnalyzed_         = 'water level analyzed for altimetry'
    character(StringLength), private, parameter :: Char_AltimTemperatureAnalyzed_   = 'temperature analyzed for altimetry'
    character(StringLength), private, parameter :: Char_AltimSalinityAnalyzed_      = 'salinity analyzed for altimetry'
    character(StringLength), private, parameter :: Char_AltimLevelToAssimilate_     = 'water level for altimetry assimilation'
    character(StringLength), private, parameter :: Char_VarianceFieldToAssimilate_  = 'variance field for assimilation'

    character(StringLength), private, parameter :: Char_WaterFluxX_          = 'water flux X'
    character(StringLength), private, parameter :: Char_WaterFluxY_          = 'water flux Y'
    character(StringLength), private, parameter :: Char_CoriolisX_           = 'coriolis X'
    character(StringLength), private, parameter :: Char_BaroclinicForceX_    = 'baroclinic force X'
    character(StringLength), private, parameter :: Char_HorizontalTransportX_= 'horizontal transport X'
    character(StringLength), private, parameter :: Char_CoriolisY_           = 'coriolis Y'
    character(StringLength), private, parameter :: Char_BaroclinicForceY_    = 'baroclinic force Y'
    character(StringLength), private, parameter :: Char_HorizontalTransportY_= 'horizontal transport Y'
    character(StringLength), private, parameter :: Char_BarotropicVelocityU_ = 'barotropic velocity U'
    character(StringLength), private, parameter :: Char_BarotropicVelocityV_ = 'barotropic velocity V'
    character(StringLength), private, parameter :: Char_BaroclinicVelocityU_ = 'baroclinic velocity U'
    character(StringLength), private, parameter :: Char_BaroclinicVelocityV_ = 'baroclinic velocity V'

    character(StringLength), private, parameter :: Char_ObstacleDragCoef     = 'obstacle drag coefficient'

    character(StringLength), private, parameter :: Char_VerticalZ            = 'vertical z'

    character(StringLength), private, parameter :: Char_ShearVelocity        = 'shear velocity'

    character(StringLength), private, parameter :: Char_Vorticity            = 'vorticity'
    character(StringLength), private, parameter :: Char_BaroclinicKE         = 'baroclinic KE'
    character(StringLength), private, parameter :: Char_PerturbationPE       = 'Perturbation Potential Energy'
    character(StringLength), private, parameter :: Char_KineticEnergy        = 'Kinetic Energy'

    character(StringLength), private, parameter :: Char_ParticulateContaminant='particulate contaminant'
    character(StringLength), private, parameter :: Char_DissolvedContaminant = 'dissolved contaminant'

    character(StringLength), private, parameter :: Char_Sediment             = 'sediment'

    character(StringLength), private, parameter :: Char_DissolvedSodium      = 'dissolved sodium'
    character(StringLength), private, parameter :: Char_DissolvedCalcium     = 'dissolved calcium'

    character(StringLength), private, parameter :: Char_ParticulateSodium    = 'particulate sodium'
    character(StringLength), private, parameter :: Char_ParticulateCalcium   = 'particulate calcium'

!_______used @ moduleCEQUALW2__________________________________________________________________________________________________

    character(StringLength), private, parameter :: Char_RPOM                = 'refractory particulate organic matter'
    character(StringLength), private, parameter :: Char_LPOM                = 'labile particulate organic matter'
    character(StringLength), private, parameter :: Char_LDOM                = 'labile dissolved organic matter'
    character(StringLength), private, parameter :: Char_RDOM                = 'refractory dissolved organic matter'
    character(StringLength), private, parameter :: Char_PSilica             = 'particulate silica'
    character(StringLength), private, parameter :: Char_DSilica             = 'dissolved silica'
    character(StringLength), private, parameter :: Char_ICarbon             = 'inorganic carbon'
    character(StringLength), private, parameter :: Char_pH                  = 'pH'
    character(StringLength), private, parameter :: Char_HCO3                = 'bicarbonate'
    character(StringLength), private, parameter :: Char_CO3                 = 'carbonate'
    character(StringLength), private, parameter :: Char_Algae_1             = 'algae_1'
    character(StringLength), private, parameter :: Char_Algae_2             = 'algae_2'
    character(StringLength), private, parameter :: Char_Algae_3             = 'algae_3'
    character(StringLength), private, parameter :: Char_Algae_4             = 'algae_4'
    character(StringLength), private, parameter :: Char_Algae_5             = 'algae_5'
    character(StringLength), private, parameter :: Char_Epiphyton_1         = 'epiphyton_1'
    character(StringLength), private, parameter :: Char_Epiphyton_2         = 'epiphyton_2'
    character(StringLength), private, parameter :: Char_Epiphyton_3         = 'epiphyton_3'
    character(StringLength), private, parameter :: Char_Epiphyton_4         = 'epiphyton_4'
    character(StringLength), private, parameter :: Char_Epiphyton_5         = 'epiphyton_5'
    character(StringLength), private, parameter :: Char_Alkalinity          = 'alkalinity'
    character(StringLength), private, parameter :: Char_Detritus            = 'detritus'

    ! Rates for output ---------------------------------------------------------------------------------------------------

             
    !Algal Growth Limitations  
                                    
    character(StringLength), private, parameter :: Char_ANLim               = 'ANLIM'
    character(StringLength), private, parameter :: Char_APLim               = 'APLIM'
    character(StringLength), private, parameter :: Char_ASLim               = 'ASLIM'
    character(StringLength), private, parameter :: Char_ALightLim           = 'ALIGHTLIM'
    character(StringLength), private, parameter :: Char_AOverallLim         = 'AOVERALLLIM'

    !Epiphyte Growth Limitations                         
    character(StringLength), private, parameter :: Char_ENLim               = 'ENLIM'
    character(StringLength), private, parameter :: Char_EPLim               = 'EPLIM'
    character(StringLength), private, parameter :: Char_ESLim               = 'ESLIM'
    character(StringLength), private, parameter :: Char_ELightLim           = 'ELIGHTLIM'
    character(StringLength), private, parameter :: Char_EOverallLim         = 'EOVERALLLIM'
                                                
       
    !Decay Rates                                
    character(StringLength), private, parameter :: Char_NH4D                = 'NH4D'
    character(StringLength), private, parameter :: Char_NO3D                = 'NO3D'
    character(StringLength), private, parameter :: Char_LDOMD               = 'LDOMD'
    character(StringLength), private, parameter :: Char_RDOMD               = 'RDOMD'
    character(StringLength), private, parameter :: Char_LPOMD               = 'LPOMD'
    character(StringLength), private, parameter :: Char_RPOMD               = 'RPOMD'
    character(StringLength), private, parameter :: Char_LRDOMD              = 'LRDOMD'
    character(StringLength), private, parameter :: Char_LRPOMD              = 'LRPOMD'
    character(StringLength), private, parameter :: Char_CBODD               = 'CBODD'
                                                                            
    !phosphorus                                                             
    character(StringLength), private, parameter :: Char_PO4ER               = 'PO4ER'
    character(StringLength), private, parameter :: Char_PO4EG               = 'PO4EG'
    character(StringLength), private, parameter :: Char_PO4AR               = 'PO4AR'
    character(StringLength), private, parameter :: Char_PO4AG               = 'PO4AG'
    character(StringLength), private, parameter :: Char_PO4OM               = 'PO4OM'
    character(StringLength), private, parameter :: Char_PO4BOD              = 'PO4BOD'
        
    !ammonia
    character(StringLength), private, parameter :: Char_NH4ER               = 'NH4ER'
    character(StringLength), private, parameter :: Char_NH4EG               = 'NH4EG'
    character(StringLength), private, parameter :: Char_NH4AR               = 'NH4AR'
    character(StringLength), private, parameter :: Char_NH4AG               = 'NH4AG'
    character(StringLength), private, parameter :: Char_NH4OM               = 'NH4OM'
    character(StringLength), private, parameter :: Char_NH4BOD              = 'NH4BOD'
                                                                            
    !nitrate                                                                
    character(StringLength), private, parameter :: Char_NO3AG               = 'NO3AG'
    character(StringLength), private, parameter :: Char_NO3EG               = 'NO3EG'
                                                                            
    !dissolved silica                                                       
    character(StringLength), private, parameter :: Char_DSIAG               = 'DSIAG'
    character(StringLength), private, parameter :: Char_DSIEG               = 'DSIEG'
    character(StringLength), private, parameter :: Char_DSID                = 'DSID '
                                                                            
    !particulated silica                                                    
    character(StringLength), private, parameter :: Char_PSIAM               = 'PSIAM'
    character(StringLength), private, parameter :: Char_PSID                = 'PSID '

    !LabDom
    character(StringLength), private, parameter :: Char_LDOMAP              = 'LDOMAP'
    character(StringLength), private, parameter :: Char_LDOMEP              = 'LDOMEP'
                                                                            
                                                                            
    !labPom                                                                 
    character(StringLength), private, parameter :: Char_LPOMAP              = 'LPOMAP'
                                                                            
    !oxygen                                                                 
    character(StringLength), private, parameter :: Char_DOAP                = 'DOAP'
    character(StringLength), private, parameter :: Char_DOEP                = 'DOEP'
    character(StringLength), private, parameter :: Char_DOAR                = 'DOAR'
    character(StringLength), private, parameter :: Char_DOER                = 'DOER'
    character(StringLength), private, parameter :: Char_DOOM                = 'DOOM'
    character(StringLength), private, parameter :: Char_DONIT               = 'DONIT'

    !inorganic Carbon
    character(StringLength), private, parameter :: Char_ICarbonAP           = 'ICARBONAP'
    character(StringLength), private, parameter :: Char_ICarbonEP           = 'ICARBONEP'
    character(StringLength), private, parameter :: Char_ICarbonBOD          = 'ICARBONBOD'
!________________________________________________________________________________________________________________________   
    
    !Zero dimensional modules
    character(StringLength), parameter          :: WaterQualityModel        = 'WaterQuality'
    character(StringLength), parameter          :: SedimentQualityModel     = 'SedimentQualityModel'
    character(StringLength), parameter          :: LifeModel                = 'LifeModel'
    character(StringLength), parameter          :: CEQUALW2Model            = 'CEQUALW2'
    character(StringLength), parameter          :: BenthicCEQUALW2Model     = 'BenthicCEQUALW2'
    character(StringLength), parameter          :: BenthosModel             = 'Benthos'
    character(StringLength), parameter          :: TempqsimModel            = 'Tempqsim'


    !Water air interface
    character(StringLength), private, parameter :: Char_LatentHeat               = 'latent heat'
    character(StringLength), private, parameter :: Char_SensibleHeat             = 'sensible heat'
    character(StringLength), private, parameter :: Char_Evaporation              = 'evaporation'
    character(StringLength), private, parameter :: Char_NetLongWaveRadiation     = 'net long wave radiation'
    character(StringLength), private, parameter :: Char_UpwardLongWaveRadiation  = 'upward long wave radiation'
    character(StringLength), private, parameter :: Char_DownwardLongWaveRadiation= 'downward long wave radiation'

    character(StringLength), private, parameter :: Char_ShortWaveSolarRadiation  = 'short wave solar radiation'
    character(StringLength), private, parameter :: Char_LongWaveSolarRadiation   = 'long wave solar radiation'

    character(StringLength), private, parameter :: Char_ShortWaveSolarRadiaExtin = 'short wave solar radiation extinction'
    character(StringLength), private, parameter :: Char_LongWaveSolarRadiaExtin  = 'long wave solar radiation extinction'


    character(StringLength), private, parameter :: Char_OxygenFlux               = 'oxygen flux'
    character(StringLength), private, parameter :: Char_WindShearVelocity        = 'wind shear velocity'
    character(StringLength), private, parameter :: Char_SurfaceRadiation         = 'surface radiation'
    character(StringLength), private, parameter :: Char_WindStressX              = 'wind stress X'
    character(StringLength), private, parameter :: Char_WindStressY              = 'wind stress Y'
    character(StringLength), private, parameter :: Char_SurfaceWaterFlux         = 'surface water flux'
    character(StringLength), private, parameter :: Char_NonSolarFlux             = 'non solar flux'
    character(StringLength), private, parameter :: Char_TurbulentKineticEnergy   = 'turbulent kinetic energy'
    character(StringLength), private, parameter :: Char_CarbonDioxideFlux        = 'carbon dioxide flux'
    character(StringLength), private, parameter :: Char_Albedo                   = 'albedo'

    !Atmosphere
    character(StringLength), private, parameter :: Char_WindVelocityX            = 'wind velocity X'
    character(StringLength), private, parameter :: Char_WindVelocityY            = 'wind velocity Y'
    character(StringLength), private, parameter :: Char_SolarRadiation           = 'solar radiation'
    character(StringLength), private, parameter :: Char_Precipitation            = 'precipitation'
    character(StringLength), private, parameter :: Char_AtmosphericPressure      = 'atmospheric pressure'
    character(StringLength), private, parameter :: Char_AirTemperature           = 'air temperature'
    character(StringLength), private, parameter :: Char_RelativeHumidity         = 'relative humidity'
    character(StringLength), private, parameter :: Char_WindModulos              = 'wind modulos'
    character(StringLength), private, parameter :: Char_WindAngle                = 'wind angle'
    character(StringLength), private, parameter :: Char_CloudCover               = 'cloud cover'
    character(StringLength), private, parameter :: Char_Irrigation               = 'irrigation'
    character(StringLength), private, parameter :: Char_SunHours                 = 'sunshine hours'
    character(StringLength), private, parameter :: Char_ATMTransmitivity         = 'atmospheric transmitivity' 

    !Sand Transport
    character(StringLength), private, parameter :: Char_Diameter                 = 'sand diameter'
    character(StringLength), private, parameter :: Char_Percentage               = 'sand percentage'
    character(StringLength), private, parameter :: Char_D35                      = 'D35'
    character(StringLength), private, parameter :: Char_D50                      = 'D50'
    character(StringLength), private, parameter :: Char_D90                      = 'D90'
    character(StringLength), private, parameter :: Char_BedRock                  = 'bed rock'
    character(StringLength), private, parameter :: Char_SandTauCritic            = 'sand tau critic'
    character(StringLength), private, parameter :: Char_TransportCapacity        = "transport capacity"
    character(StringLength), private, parameter :: Char_TransportCapacityX       = "transport capacity X"
    character(StringLength), private, parameter :: Char_TransportCapacityY       = "transport capacity Y"
    character(StringLength), private, parameter :: Char_BottomEvolution          = "bottom evolution"
    character(StringLength), private, parameter :: Char_Newbathymetry            = "new bathymetry"
    character(StringLength), private, parameter :: Char_Sand                     = "sand"

    !wave dynamics
    character(StringLength), private, parameter :: Char_WaveStressX              = 'wave stress X'
    character(StringLength), private, parameter :: Char_WaveStressY              = 'wave stress Y'   
    character(StringLength), private, parameter :: Char_OrbitalVelocityX         = 'orbital velocity X'
    character(StringLength), private, parameter :: Char_OrbitalVelocityY         = 'orbital velocity Y'
    !!Monocromatic:
    character(StringLength), private, parameter :: Char_WaveAmplitude            = 'wave amplitude'
    character(StringLength), private, parameter :: Char_WavePeriod               = 'wave period'
    character(StringLength), private, parameter :: Char_WaveDirection            = 'wave direction'
    !!Statistical wave parametres (WW3,SWAN)
    character(StringLength), private, parameter :: Char_SignificantWaveHeight    = 'significant wave height'
    character(StringLength), private, parameter :: Char_MeanWaveLength           = 'mean wave length'
    character(StringLength), private, parameter :: Char_MeanWavePeriod           = 'mean wave period'
    character(StringLength), private, parameter :: Char_MeanWaveDirection        = 'mean wave direction'
    character(StringLength), private, parameter :: Char_MeanDirectionalSpread    = 'mean directional spread'
    character(StringLength), private, parameter :: Char_PeakFrequency            = 'peak frequency'
    character(StringLength), private, parameter :: Char_PeakDirection            = 'peak direction'
    character(StringLength), private, parameter :: Char_WindSeaPeakFrequency     = 'wind sea peak frequency'
    character(StringLength), private, parameter :: Char_WindSeaPeakDirection     = 'wind sea peak direction'

    !Consolidation
    character(StringLength), private, parameter :: Char_ConsolidationFlux        = 'consolidation flux'
    character(StringLength), private, parameter :: Char_Porosity                 = 'porosity'

    !Vegetation
    character(StringLength), private, parameter :: Char_LeafAreaIndex            = 'leaf area index'
    character(StringLength), private, parameter :: Char_SpecificLeafStorage      = 'specific leaf storage'
    character(StringLength), private, parameter :: Char_EVTPCropCoefficient      = 'evtp crop coefficient'
    character(StringLength), private, parameter :: Char_RootDepth                = 'root depth'
    character(StringLength), private, parameter :: Char_RootFeddesParameterH1    = 'feddes h1'
    character(StringLength), private, parameter :: Char_RootFeddesParameterH2    = 'feddes h2'
    character(StringLength), private, parameter :: Char_RootFeddesParameterH3    = 'feddes h3'
    character(StringLength), private, parameter :: Char_RootFeddesParameterH4    = 'feddes h4'
    


    !Mapping
    integer, parameter :: Compute         = 1
    integer, parameter :: Covered         = 1
    integer, parameter :: Not_Covered     = 0
    integer, parameter :: Boundary        = 1
    integer, parameter :: Not_Boundary    = 0
    integer, parameter :: Exterior        = 1
    integer, parameter :: WaterPoint      = 1
    integer, parameter :: OpenPoint       = 1
    integer, parameter :: Imposed         = 1

    integer, parameter :: UndefinedPoint   = -999
    integer, parameter :: NoBasinPoint     = 0
    integer, parameter :: BasinPoint       = 1
    integer, parameter :: NoLakePoint      = 0
    integer, parameter :: LakePoint        = 1

    !Open Files
    integer, parameter :: CLOSE_FILE    = 0
    integer, parameter :: OPEN_FILE     = 1

    !Physic constants
    real(8), parameter  :: EarthMass_               = 5.9742e24
    real(8), parameter  :: GravitationalConstant_   = 6.67259e-11
    real(8), parameter  :: mu_                      = 3.9863387178e14 !is the product of the two latter constants
    real(8), parameter  :: EqRadius_                = 6378135.d0 !m
    real(8), parameter  :: MeanRadius_              = 6371000.d0 ! m

    real,    parameter  :: Gravity            = 9.81
    real,    parameter  :: Const_VonKarman    = 0.4
    real,    parameter  :: Air_Density        = 1.2
    real,    parameter  :: WaterDynamicVisc   = 1e-3
    real,    parameter  :: WaterCinematicVisc = 1e-6
    real,    parameter  :: SigmaDensityReference = 1e3

    !PV = nRT - thermodynamic (n - number of moles)
    real,    parameter  :: R                  = 8.3144  

    !Avogadro    
    real,    parameter  :: Mole               = 6.02e23    

    !Default specific heat
    real,    parameter  :: SpecificHeatDefault = 4200.  ![joules/kg/Kelvin]

    !Angles
    real(8), parameter  :: Pi = 3.1415926535897932384626433832795

    !Zero Degrees
    real, parameter     :: AbsoluteZero = 273.15

    !Error Magnitudes
    integer, parameter :: FATAL_       = 1
    integer, parameter :: WARNING_     = 2

    !Error Types
    integer, parameter :: INTERNAL_    = 1
    integer, parameter :: OUT_OF_MEM_  = 2
    integer, parameter :: KEYWORD_     = 3

    ! Vertical communication between nested models 
    integer, parameter :: FatherSonDifDim    = 0
    integer, parameter :: FatherSonEqualDim  = 1
    integer, parameter :: Father2DSon3D      = 2
    integer, parameter :: Father3DSon2D      = 3

    !Methodologies use to compute sedimentation velocity of fine sediments
    integer, parameter :: WSConstant = 1, SPMFunction = 2

    !Advection 1D parameters
    integer, parameter :: UpwindOrder1 = 1, UpwindOrder2 = 2, UpwindOrder3 = 3, P2_TVD = 4, CentralDif = 5, LeapFrog = 6
    integer, parameter :: MinMod = 1, VanLeer = 2, Muscl = 3, Superbee = 4, PDM = 5
    real,    parameter :: MinValue = 1.e-16

    !Transport Parameters
    integer, parameter :: velocityX = 1, velocityY = 2, velocityZ = 3, massProperty = 4
    integer, parameter :: NearestNeighbour = 1, centered = 2 !other interpolation methods here 

    !Filter grid data 
    integer, parameter :: NoFilter = 0, ModifyLax = 1


    !Transport options
    real,    parameter                          :: ExplicitScheme           = 0.
    real,    parameter                          :: ImplicitScheme           = 1.


    !Density compute methods
    integer, parameter                          :: LeendertseState_         = 1
    integer, parameter                          :: UNESCOState_             = 2
    integer, parameter                          :: Linear_                  = 3
    integer, parameter                          :: Mel96State_              = 4
    integer, parameter                          :: JMD95State_              = 5
    integer, parameter                          :: ConstantDensity_         = 6
    integer, parameter                          :: WangState_               = 7

    !Methods to compute baroclinic force 
    integer, parameter                          :: DensityUniform           = 1
    integer, parameter                          :: DensityLinear            = 2
    integer, parameter                          :: Leibniz                  = 3
    integer, parameter                          :: Leibniz2                 = 4

    !Datums 
    integer, parameter                          :: CLARKE_1866_DATUM        = 1
    integer, parameter                          :: GRS_80_DATUM             = 2
    integer, parameter                          :: WGS_84_DATUM             = 3
       

    !Methods to compute oxygen and carbon dioxide fluxes
    integer, parameter                          :: Broecker_et_al_1978      = 1
    integer, parameter                          :: Gelda_et_al_1996         = 2
    integer, parameter                          :: Banks_Herrera_1977       = 3
    integer, parameter                          :: Wanninkhof_et_al_1991    = 4
    integer, parameter                          :: Chen_Kanwisher_1963      = 5
    integer, parameter                          :: Cole_Buchak_1993         = 6
    integer, parameter                          :: Banks_1975               = 7
    integer, parameter                          :: Smith_1978               = 8
    integer, parameter                          :: Liss_1973                = 9
    integer, parameter                          :: Downing_Truesdale_1955   = 10
    integer, parameter                          :: Kanwisher_1963           = 11
    integer, parameter                          :: Yu_et_al_1977            = 12
    integer, parameter                          :: Weiler_1974              = 13

    !Vegetation Root Profiles
    integer, parameter                          :: RootLinear_              = 1
    integer, parameter                          :: RootTriangular_          = 2


    !Module IDs
    integer, parameter ::  mGLOBALDATA_             =  1        
    integer, parameter ::  mTIME_                   =  2 
    integer, parameter ::  mENTERDATA_              =  3 
    integer, parameter ::  mFUNCTIONS_              =  4 
    integer, parameter ::  mLUD_                    =  5 
    integer, parameter ::  mWATERQUALITY_           =  6
    integer, parameter ::  mGRIDDATA_               =  7 
    integer, parameter ::  mHDF5_                   =  8            
    integer, parameter ::  mHORIZONTALGRID_         =  9
    integer, parameter ::  mHORIZONTALMAP_          = 10 
    integer, parameter ::  mGEOMETRY_               = 11 
    integer, parameter ::  mSTOPWATCH_              = 12 
    integer, parameter ::  mADVECTIONDIFFUSION_     = 13 
    integer, parameter ::  mMAP_                    = 14 
    integer, parameter ::  mTIMESERIE_              = 15 
    integer, parameter ::  mSOIL_                   = 16
    integer, parameter ::  mBOXDIF_                 = 17
    integer, parameter ::  mASSIMILATION_           = 18
    integer, parameter ::  mSTATISTIC_              = 19
    integer, parameter ::  mDISCHARGES_             = 20
    integer, parameter ::  mATMOSPHERE_             = 21
    integer, parameter ::  mHYDROINTEGRATION_       = 22
    integer, parameter ::  mHYDRODYNAMICFILE_       = 23
    integer, parameter ::  mTOGA_                   = 24
    integer, parameter ::  mGAUGE_                  = 25
    integer, parameter ::  mTRIANGULATION_          = 26
    integer, parameter ::  mGOTM_                   = 27
    integer, parameter ::  mTURBGOTM_               = 28
    integer, parameter ::  mTURBULENCE_             = 29
    integer, parameter ::  mOPENBOUNDARY_           = 30
    integer, parameter ::  mHYDRODYNAMIC_           = 31
    integer, parameter ::  mFREEVERTICALMOVEMENT_   = 32
    integer, parameter ::  mSEDIMENTQUALITY_        = 33
    integer, parameter ::  mINTERFACE_              = 34
    integer, parameter ::  mWATERPROPERTIES_        = 35
    integer, parameter ::  mOIL_                    = 36
    integer, parameter ::  mJET_                    = 37
    integer, parameter ::  mLAGRANGIAN_             = 38
    integer, parameter ::  mMODEL_                  = 39
    integer, parameter ::  mCONSOLIDATION_          = 40
    integer, parameter ::  mSEDIMENTPROPERTIES_     = 41
    integer, parameter ::  mLIFE_                   = 42
    integer, parameter ::  mCEQUALW2_               = 43
    integer, parameter ::  mBASINGEOMETRY_          = 44
    integer, parameter ::  mRUNOFF_                 = 45
    integer, parameter ::  mDRAINAGENETWORK_        = 46
    integer, parameter ::  mINTERFACEWATERAIR_      = 47
    integer, parameter ::  mINTERFACESEDIMENTWATER_ = 48
    integer, parameter ::  mLIGHTEXTINCTION_        = 49
    integer, parameter ::  mRIVERHYDRODYNAMIC_      = 50
    integer, parameter ::  mFILLMATRIX_             = 51
    integer, parameter ::  mWAVES_                  = 52
    integer, parameter ::  mBASIN_                  = 53
    integer, parameter ::  mINFILTRATION_           = 54
    integer, parameter ::  mSOILPROPERTIES_         = 55
    integer, parameter ::  mSOILPLANTAIR_           = 56
    integer, parameter ::  mSOILMACROPORES_         = 57
    integer, parameter ::  mSAND_                   = 58
    integer, parameter ::  mMACROPOREPROPERTIES_    = 59
    integer, parameter ::  mPOROUSMEDIA_            = 60
    integer, parameter ::  mSWAT_                   = 61
    integer, parameter ::  mPROFILE_                = 62
    integer, parameter ::  mBENTHOS_                = 63
    integer, parameter ::  mCLIMATOLOGY_            = 64
    integer, parameter ::  mFIREINDEX_              = 65
    integer, parameter ::  mINTERPOLATION_          = 66
    integer, parameter ::  mVEGETATION_             = 67

    type T_Size1D
        integer                 :: ILB            = null_int
        integer                 :: IUB            = null_int
    end type T_Size1D

    type T_Size2D
        integer                 :: ILB            = null_int
        integer                 :: IUB            = null_int
        integer                 :: JLB            = null_int
        integer                 :: JUB            = null_int
    end type T_Size2D

    type T_Size3D
        integer                 :: ILB            = null_int
        integer                 :: IUB            = null_int
        integer                 :: JLB            = null_int
        integer                 :: JUB            = null_int
        integer                 :: KLB            = null_int
        integer                 :: KUB            = null_int
    end type T_Size3D

    type T_PropertyID
        character(StringLength) :: Name              = null_str
        character(StringLength) :: Units             = null_str
        character(StringLength) :: Description       = null_str
        integer                 :: IDNumber          = null_int    
        integer                 :: ObjFillMatrix     = 0
        logical                 :: SolutionFromFile  = OFF
    end type T_PropertyID

    type T_Instance
        integer                 :: ID         = 0
        integer                 :: Users      = 0
        integer                 :: Readers    = 0
        logical                 :: Read_Lock  = IDLE
    end type T_Instance

    type T_Module
        integer                 :: ID
        character(StringLength) :: Name
    end type T_Module

    type (T_Module), dimension(MaxModules), parameter  :: MohidModules =  (/             &
          T_Module(mGLOBALDATA_             , "GlobalData"),        T_Module(mTIME_                   , "Time"),                  &
          T_Module(mENTERDATA_              , "EnterData"),         T_Module(mFUNCTIONS_              , "Functions"),             &
          T_Module(mLUD_                    , "LUD"),               T_Module(mWATERQUALITY_           , "WaterQuality"),          &
          T_Module(mGRIDDATA_               , "GridData"),          T_Module(mHDF5_                   , "HDF5"),                  &
          T_Module(mHORIZONTALGRID_         , "HorizontalGrid"),    T_Module(mHORIZONTALMAP_          , "HorizontalMap"),         &
          T_Module(mGEOMETRY_               , "Geometry"),          T_Module(mSTOPWATCH_              , "StopWatch"),             &
          T_Module(mADVECTIONDIFFUSION_     , "AdvectionDiffusion"),T_Module(mMAP_                    , "Map"),                   &
          T_Module(mTIMESERIE_              , "TimeSerie"),         T_Module(mSOIL_                   , "Soil"),                  &
          T_Module(mBOXDIF_                 , "BoxDif"),            T_Module(mASSIMILATION_           , "Assimilation"),          &
          T_Module(mSTATISTIC_              , "Statistic"),         T_Module(mDISCHARGES_             , "Discharges"),            &
          T_Module(mATMOSPHERE_             , "Atmosphere"),        T_Module(mHYDROINTEGRATION_       , "HydroIntegration"),      &
          T_Module(mHYDRODYNAMICFILE_       , "HydrodynamicFile"),  T_Module(mTOGA_                   , "Toga"),                  &
          T_Module(mGAUGE_                  , "Gauge"),             T_Module(mTRIANGULATION_          , "Triangulation"),         &
          T_Module(mGOTM_                   , "GOTM"),              T_Module(mTURBGOTM_               , "TurbGOTM"),              &
          T_Module(mTURBULENCE_             , "Turbulence"),        T_Module(mOPENBOUNDARY_           , "OpenBoundary"),          &
          T_Module(mHYDRODYNAMIC_           , "Hydrodynamic"),      T_Module(mFREEVERTICALMOVEMENT_   , "FreeVerticalMovement"),  &
          T_Module(mSEDIMENTQUALITY_        , "SedimentQuality"),   T_Module(mINTERFACE_              , "Interface"),             &
          T_Module(mWATERPROPERTIES_        , "WaterProperties"),   T_Module(mOIL_                    , "Oil"),                   &
          T_Module(mJET_                    , "Jet"),               T_Module(mLAGRANGIAN_             , "Lagrangian"),            &
          T_Module(mMODEL_                  , "Model"),             T_Module(mCONSOLIDATION_          , "Consolidation"),         &
          T_Module(mSEDIMENTPROPERTIES_     , "SedimentProperties"),T_Module(mLIFE_                   , "Life"),                  &
          T_Module(mCEQUALW2_               , "CEQUALW2"),          T_Module(mBASINGEOMETRY_          , "BasinGeometry"),         &
          T_Module(mRUNOFF_                 , "RunOff"),            T_Module(mDRAINAGENETWORK_        , "DrainageNetwork"),       &
          T_Module(mINTERFACEWATERAIR_      , "InterfaceWaterAir"), T_Module(mINTERFACESEDIMENTWATER_ , "InterfaceWaterSediment"),&
          T_Module(mLIGHTEXTINCTION_        , "LightExtinction"),   T_Module(mRIVERHYDRODYNAMIC_      , "RiverHydrodynamic"),     &
          T_Module(mFILLMATRIX_             , "FillMatrix"),        T_Module(mWAVES_                  , "Waves"),                 &
          T_Module(mBASIN_                  , "Basin"),             T_Module(mSOILPROPERTIES_         , "SoilProperties"),        &
          T_Module(mINFILTRATION_           , "Infiltration"),      T_Module(mSOILPLANTAIR_           , "SoilPlantAir"),          &
          T_Module(mSOILMACROPORES_         , "SoilMacropores"),    T_Module(mSAND_                   , "Sand"),                  &
          T_Module(mMACROPOREPROPERTIES_    , "MacroporeProperties"),T_Module(mPOROUSMEDIA_           , "PorousMedia"),           &
          T_Module(mSWAT_                   , "ModuleSwat"),        T_Module(mPROFILE_                , "Profile"),               &
          T_Module(mBENTHOS_                , "Benthos"),           T_Module(mCLIMATOLOGY_            , "Climatology"),           &
          T_Module(mFIREINDEX_              , "FireIndex"),         T_Module(mINTERPOLATION_          , "Interpolation"),         &
          T_Module(mVEGETATION_             , "Vegetation")/)

    !Variables
    logical, dimension(MaxModules)                          :: RegisteredModules = .false.
    character(LEN=StringLength)                             :: FilesName = 'nomfich.dat'
    logical                                                 :: MonitorPerformance
    logical                                                 :: MonitorDT
    integer                                                 :: UnitDT
    character(LEN=StringLength), dimension(:), pointer      :: PropNameList
    integer,                     dimension(:), pointer      :: PropNumberList
    integer                                                 :: PropertiesNumber
    integer, private                                        :: ErrorFileID
    integer, private                                        :: UsedKeyFileID
    
    type (T_Instance), dimension (MaxModules, MaxInstances), save :: ObjCollector
    private :: ObjCollector

    contains 

    !--------------------------------------------------------------------------

    logical function ModuleIsRegistered (iModule)
    
        !Arguments-------------------------------------------------------------
        integer                                     :: iModule
    
        ModuleIsRegistered = RegisteredModules(iModule)
        
    end function ModuleIsRegistered
    
    !--------------------------------------------------------------------------
    
    subroutine RegisterModule (iModule)
    
        !Arguments-------------------------------------------------------------
        integer                                     :: iModule

        RegisteredModules(iModule) = .true.

#ifndef _GUI_
        !Feedback
        write(unit=ErrorFileID, fmt=*)"Registered Module  : ", trim(MohidModules(iModule)%Name)
#endif
        
    end subroutine RegisterModule
    
    !--------------------------------------------------------------------------

    integer function RegisterNewInstance (iModule)

        !Arguments-------------------------------------------------------------
        integer                                     :: iModule

        !Local-----------------------------------------------------------------
        integer                                     :: iInstance

        !Search first empty ID
        iInstance = 1
        do while (ObjCollector(iModule, iInstance)%Users /= 0)
            iInstance = iInstance + 1
        enddo

        !Set users to 1
        ObjCollector(iModule, iInstance)%Users = 1

#ifndef _GUI_
        !Feedback
        write(unit=ErrorFileID, fmt=*)"Registered Instance: ", trim(MohidModules(iModule)%Name)
        write(unit=ErrorFileID, fmt=*)"Instance ID        : ", iInstance
#endif

        !Returns ID
        RegisterNewInstance = iInstance

    end function RegisterNewInstance

    !--------------------------------------------------------------------------

    integer function AssociateInstance   (iModule, iInstance)

        !Arguments-------------------------------------------------------------
        integer                                     :: iModule
        integer                                     :: iInstance

        !Local-----------------------------------------------------------------

        !Checks for error
        if (iInstance == 0) then
            write(*,*)'iInstance cannot be zero'
            stop 'AssociateInstance - ModuleGlobalData - ERR01'
        endif
    
        !Increase number by one
        ObjCollector(iModule, iInstance)%Users = ObjCollector(iModule, iInstance)%Users + 1

        !Returns ID
        AssociateInstance = iInstance

    end function AssociateInstance

    !--------------------------------------------------------------------------

    integer function DeassociateInstance (iModule, iInstance)

        !Arguments-------------------------------------------------------------
        integer                                     :: iModule
        integer                                     :: iInstance

        !Local-----------------------------------------------------------------

        !Decrease number by one
        ObjCollector(iModule, iInstance)%Users = ObjCollector(iModule, iInstance)%Users - 1

        !Checks for error
        if (ObjCollector(iModule, iInstance)%Users < 0) then
            write(*,*)'Users cannot be negative'
            stop 'DeassociateInstance - ModuleGlobalData - ERR01'
        endif

        !Returns Number of users
        DeassociateInstance = ObjCollector(iModule, iInstance)%Users

    end function DeassociateInstance

    !--------------------------------------------------------------------------

    subroutine Read_Lock(iModule, iInstance) 

        !Arguments-------------------------------------------------------------
        integer                                     :: iModule
        integer                                     :: iInstance

        !----------------------------------------------------------------------

        ObjCollector(iModule, iInstance)%Read_Lock = ACTIVE
        ObjCollector(iModule, iInstance)%readers   = ObjCollector(iModule, iInstance)%readers + 1

        !----------------------------------------------------------------------

    end subroutine Read_Lock

    !--------------------------------------------------------------------------

    subroutine Read_Unlock(iModule, iInstance, RoutineName) 

        !Arguments-------------------------------------------------------------
        integer                                     :: iModule
        integer                                     :: iInstance
        character(len=*)                            :: RoutineName

        !----------------------------------------------------------------------
              
        !Cannot Read_unlock if Instance is not Read_lock
        if (.not. ObjCollector(iModule, iInstance)%Read_Lock) then
            write(*, *) 'Number of Readers error.'
            write(*, *) 'Routine Name    : ', trim(RoutineName)
            write(*, *) 'Module  Name    : ', trim(MohidModules(iModule)%Name)
            write(*, *) 'Instance  ID    : ', iInstance
            stop        'Read_Unlock - ModuleGlobalData - ERR01'
        end if
            
        !Decreases number of readers
        ObjCollector(iModule, iInstance)%readers = ObjCollector(iModule, iInstance)%readers - 1

        !If number of reades equal to zero set Read_lock to IDLE
        if (ObjCollector(iModule, iInstance)%readers == 0) ObjCollector(iModule, iInstance)%Read_Lock = IDLE

        !if Number of readers is negative, somethink is wrong
        if (ObjCollector(iModule, iInstance)%readers < 0) then
            write(*, *) 'Negative number of readers'
            write(*, *) 'Routine Name    : ', trim(RoutineName)
            write(*, *) 'Module  Name    : ', trim(MohidModules(iModule)%Name)
            write(*, *) 'Instance  ID    : ', iInstance
            stop        'Read_Unlock - ModuleGlobalData - ERR02'
        end if

        !----------------------------------------------------------------------

    end subroutine Read_Unlock

    !--------------------------------------------------------------------------

    integer function VerifyReadLock (iModule, iInstance) 

        !Arguments-------------------------------------------------------------
        integer                                     :: iModule
        integer                                     :: iInstance

        if  (ObjCollector(iModule, iInstance)%Read_Lock) then 
            VerifyReadLock = READ_LOCK_ERR_
        else 
            VerifyReadLock = IDLE_ERR_
        end if

    end function VerifyReadLock

    !--------------------------------------------------------------------------

    logical function CheckPropertyName (PropertyName, Number)

        !Arguments-------------------------------------------------------------
        character(len=*), intent (IN)               :: PropertyName
        integer,          intent (OUT), optional    :: Number

        !Local-----------------------------------------------------------------
        integer :: i

        !----------------------------------------------------------------------

        CheckPropertyName = .false.

        call ConstructPropList

        do i=1, PropertiesNumber

            if (PropertyName == PropNameList(i)) then

                if (present(Number)) Number = PropNumberList(i)
                CheckPropertyName = .TRUE.

            endif

        enddo

        !----------------------------------------------------------------------

    end function  CheckPropertyName

    !--------------------------------------------------------------------------

    character (len=StringLength) function GetPropertyName (Number)

        !Arguments-------------------------------------------------------------
        integer,          intent (IN )              :: Number

        !Local-----------------------------------------------------------------
        integer :: i

        !----------------------------------------------------------------------

        call ConstructPropList

        do i=1, PropertiesNumber

            if (Number == PropNumberList(i)) then

                GetPropertyName = PropNameList(i)

            endif

        enddo

        !----------------------------------------------------------------------

    end function GetPropertyName

    !--------------------------------------------------------------------------

    integer function GetPropertyIDNumber (PropertyName)

        !Arguments-------------------------------------------------------------
        character(len=*), intent (IN )              :: PropertyName

        !Local-----------------------------------------------------------------
        integer :: i

        !----------------------------------------------------------------------
        
        GetPropertyIDNumber = UNKNOWN_

        call ConstructPropList

        do i=1, PropertiesNumber

            if (trim(PropertyName) == trim(PropNameList(i))) then

                GetPropertyIDNumber = PropNumberList(i)

            endif

        enddo

        if(GetPropertyIDNumber == UNKNOWN_)then
            write(*,*)'Unknown property'
            stop 'GetPropertyIDNumber - ModuleGlobalData - ERR01'
        end if

        !----------------------------------------------------------------------

    end function GetPropertyIDNumber

    !--------------------------------------------------------------------------

    subroutine ConstructPropList

        !Local-----------------------------------------------------------------
        integer       :: ListNumber, i, j

        !Begin-----------------------------------------------------------------
        logical, save :: FirstList = .true.


        
        if (FirstList) then

            FirstList = .false.

            call AddPropList (Temperature_,             Char_Temperature,               ListNumber)
            call AddPropList (Salinity_,                Char_Salinity,                  ListNumber)   
            call AddPropList (Density_,                 Char_Density,                   ListNumber)   
            call AddPropList (Phytoplankton_,           Char_Phytoplankton,             ListNumber)
            call AddPropList (Zooplankton_,             Char_Zooplankton,               ListNumber)
            call AddPropList (DOPRefractory_,           Char_DOPRefractory,             ListNumber)
            call AddPropList (DOPNon_Refractory_,       Char_DOPNon_Refractory,         ListNumber)
            call AddPropList (DONRefractory_,           Char_DONRefractory,             ListNumber)
            call AddPropList (DONNon_Refractory_,       Char_DONNon_Refractory,         ListNumber)
            call AddPropList (Inorganic_Phosphorus_,    Char_Inorganic_Phosphorus,      ListNumber)         
            
            call AddPropList (POC_,                     Char_POC,                       ListNumber)                             
            call AddPropList (POP_,                     Char_POP,                       ListNumber)                      
            call AddPropList (PON_,                     Char_PON,                       ListNumber)                      
            call AddPropList (DOC_,                     Char_DOC,                       ListNumber)                      
            call AddPropList (DOP_,                     Char_DOP,                       ListNumber)                      
            call AddPropList (DON_,                     Char_DON,                       ListNumber)                      
            call AddPropList (DOCsl_,                   Char_DOCsl,                     ListNumber)                    
            call AddPropList (DOPsl_,                   Char_DOPsl,                     ListNumber)                    
            call AddPropList (DONsl_,                   Char_DONsl,                     ListNumber)                    
            call AddPropList (Ammonia_,                 Char_Ammonia,                   ListNumber)                  
            call AddPropList (Nitrate_,                 Char_Nitrate,                   ListNumber)                  
            call AddPropList (Silicate_,                Char_Silicate,                  ListNumber)                 
            call AddPropList (BioSilica_,               Char_BioSilica,                 ListNumber)               
            call AddPropList (CarbonDioxide_,           Char_CarbonDioxide,             ListNumber)                      
            call AddPropList (Oxygen_,                  Char_Oxygen,                    ListNumber) 
            call AddPropList (DissolO2PercentSat_,      Char_DissolO2PercentSat,        ListNumber)  
            call AddPropList (Diatom_C_,                Char_Diatom_C,                  ListNumber)     
            call AddPropList (Diatom_N_,                Char_Diatom_N,                  ListNumber)                 
            call AddPropList (Diatom_P_,                Char_Diatom_P,                  ListNumber)                 
            call AddPropList (Diatom_Si_,               Char_Diatom_Si,                 ListNumber)               
            call AddPropList (Diatom_Chl_,              Char_Diatom_Chl,                ListNumber)               
            call AddPropList (Mix_Flagellate_C_,        Char_Mix_Flagellate_C,          ListNumber)               
            call AddPropList (Mix_Flagellate_N_,        Char_Mix_Flagellate_N,          ListNumber)    
            call AddPropList (Mix_Flagellate_P_,        Char_Mix_Flagellate_P,          ListNumber)         
            call AddPropList (Mix_Flagellate_Chl_,      Char_Mix_Flagellate_Chl,        ListNumber)         
            call AddPropList (Picoalgae_C_,             Char_Picoalgae_C,               ListNumber)          
            call AddPropList (Picoalgae_N_,             Char_Picoalgae_N,               ListNumber)          
            call AddPropList (Picoalgae_P_,             Char_Picoalgae_P,               ListNumber)     
            call AddPropList (Picoalgae_Chl_,           Char_Picoalgae_Chl,             ListNumber)      
            call AddPropList (Flagellate_C_,            Char_Flagellate_C,              ListNumber)              
            call AddPropList (Flagellate_N_,            Char_Flagellate_N,              ListNumber)              
            call AddPropList (Flagellate_P_,            Char_Flagellate_P,              ListNumber)              
            call AddPropList (Flagellate_Chl_,          Char_Flagellate_Chl,            ListNumber)              
            call AddPropList (Microzooplankton_C_,      Char_Microzooplankton_C,        ListNumber)     
            call AddPropList (Microzooplankton_N_,      Char_Microzooplankton_N,        ListNumber)             
            call AddPropList (Microzooplankton_P_,      Char_Microzooplankton_P,        ListNumber)             
            call AddPropList (Het_Nanoflagellate_C_,    Char_Het_Nanoflagellate_C,      ListNumber)         
            call AddPropList (Het_Nanoflagellate_N_,    Char_Het_Nanoflagellate_N,      ListNumber) 
            call AddPropList (Het_Nanoflagellate_P_,    Char_Het_Nanoflagellate_P,      ListNumber)  
            call AddPropList (Mesozooplankton_C_,       Char_Mesozooplankton_C,         ListNumber)    
            call AddPropList (Mesozooplankton_N_,       Char_Mesozooplankton_N,         ListNumber)                
            call AddPropList (Mesozooplankton_P_,       Char_Mesozooplankton_P,         ListNumber)               
            call AddPropList (Het_Bacteria_C_,          Char_Het_Bacteria_C,            ListNumber)                 
            call AddPropList (Het_Bacteria_N_,          Char_Het_Bacteria_N,            ListNumber)                 
            call AddPropList (Het_Bacteria_P_,          Char_Het_Bacteria_P,            ListNumber)                          
         
            call AddPropList (Nitrite_,                 Char_Nitrite,                   ListNumber)
            call AddPropList (BOD_,                     Char_BOD,                       ListNumber)
            call AddPropList (Cohesive_Sediment_,       Char_Cohesive_Sediment,         ListNumber)
            call AddPropList (Fecal_Coliforms_,         Char_Fecal_Coliforms,           ListNumber)
            call AddPropList (T90_,                     Char_T90,                       ListNumber)
            call AddPropList (Oil_,                     Char_Oil,                       ListNumber)
            call AddPropList (Ciliate_,                 Char_Ciliate,                   ListNumber)
            call AddPropList (Bacteria_,                Char_Bacteria,                  ListNumber)
            call AddPropList (ParticulateArsenic_,      Char_ParticulateArsenic,        ListNumber)
            call AddPropList (DissolvedArsenic_,        Char_DissolvedArsenic,          ListNumber)
            call AddPropList (Larvae_,                  Char_Larvae,                    ListNumber)
            call AddPropList (Age_,                     Char_Age,                       ListNumber)
            call AddPropList (Fish_,                    Char_Fish,                      ListNumber)
            call AddPropList (FishFood_,                Char_FishFood,                  ListNumber)
            call AddPropList (MacroAlgae_,              Char_MacroAlgae,                ListNumber)
            call AddPropList (MicroPhytoBenthos_,       Char_MicroPhytoBenthos,         ListNumber)

            call AddPropList (AdsorbedAmmonia_,         Char_AdsorbedAmmonia,           ListNumber)
            call AddPropList (RefreactaryOrganicN_,     Char_RefreactaryOrganicN,       ListNumber)
            call AddPropList (Ngas_,                    Char_Ngas,                      ListNumber)
            call AddPropList (HeterotrophicN_,          Char_HeterotrophicN,            ListNumber)
            call AddPropList (AnaerobicN_,              Char_AnaerobicN,                ListNumber)
            call AddPropList (AutotrophicN_,            Char_AutotrophicN,              ListNumber)
            call AddPropList (AnaerobicC_,              Char_AnaerobicC,                ListNumber)
            call AddPropList (AutotrophicC_,            Char_AutotrophicC,              ListNumber)
            call AddPropList (HeterotrophicC_,          Char_HeterotrophicC,            ListNumber)
            call AddPropList (LabileOrganicC_,          Char_LabileOrganicC,            ListNumber)
            call AddPropList (RefreactaryOrganicC_,     Char_RefreactaryOrganicC,       ListNumber)           
            
            call AddPropList (GenericProperty_,         Char_GenericProperty,           ListNumber)
            call AddPropList (GrossProd_,               Char_GrossProd,                 ListNumber)
            call AddPropList (NetProd_,                 Char_NetProd,                   ListNumber)
            call AddPropList (NutrientLim_,             Char_NutrientLim,               ListNumber)
            call AddPropList (NLim_,                    Char_NLim,                      ListNumber)
            call AddPropList (PLim_,                    Char_PLim,                      ListNumber)
            call AddPropList (LightLim_ ,               Char_LightLim ,                 ListNumber)
            call AddPropList (TemperatureLim_,          Char_TemperatureLim,            ListNumber)
            call AddPropList (SalinityLim_,             Char_SalinityLim,               ListNumber)
            call AddPropList (DiaGrossProd_,            Char_DiaGrossProd,              ListNumber)
            call AddPropList (DiaNutrientLim_,          Char_DiaNutrientLim,            ListNumber)
            call AddPropList (DiaNLim_,                 Char_DiaNLim,                   ListNumber)
            call AddPropList (DiaPLim_,                 Char_DiaPLim,                   ListNumber)
            call AddPropList (DiaSiLim_,                Char_DiaSiLim,                  ListNumber)
            call AddPropList (DiaLightLim_ ,            Char_DiaLightLim ,              ListNumber)
            call AddPropList (DiaTemperatureLim_,       Char_DiaTemperatureLim,         ListNumber)
            call AddPropList (Diatoms_,                 Char_Diatoms,                   ListNumber)
            call AddPropList (WaterLevel_,              Char_WaterLevel_,               ListNumber)
            call AddPropList (VelocityModulus_,         Char_VelocityModulus_,          ListNumber)
            call AddPropList (FlowModulus_,             Char_FlowModulus_,              ListNumber)
            call AddPropList (VelocityU_,               Char_VelocityU_,                ListNumber)
            call AddPropList (VelocityV_,               Char_VelocityV_,                ListNumber)
            call AddPropList (VelocityW_,               Char_VelocityW_,                ListNumber)
            call AddPropList (WaterFluxX_,              Char_WaterFluxX_,               ListNumber)
            call AddPropList (WaterFluxY_,              Char_WaterFluxY_,               ListNumber)
            call AddPropList (CoriolisX_,               Char_CoriolisX_,                ListNumber)
            call AddPropList (BaroclinicForceX_,        Char_BaroclinicForceX_,         ListNumber)
            call AddPropList (HorizontalTransportX_,    Char_HorizontalTransportX_,     ListNumber)
            call AddPropList (CoriolisY_,               Char_CoriolisY_,                ListNumber)
            call AddPropList (BaroclinicForceY_  ,      Char_BaroclinicForceY_  ,       ListNumber)
            call AddPropList (HorizontalTransportY_,    Char_HorizontalTransportY_,     ListNumber)
            call AddPropList (BarotropicVelocityU_ ,    Char_BarotropicVelocityU_ ,     ListNumber)
            call AddPropList (BarotropicVelocityV_ ,    Char_BarotropicVelocityV_ ,     ListNumber)

            ! guillaume nogueira
            call AddPropList (AltimLevelAnalyzed_,         Char_AltimLevelAnalyzed_,          ListNumber)
            call AddPropList (AltimTemperatureAnalyzed_,   Char_AltimTemperatureAnalyzed_,    ListNumber)
            call AddPropList (AltimSalinityAnalyzed_,      Char_AltimSalinityAnalyzed_,       ListNumber)
            call AddPropList (AltimLevelToAssimilate_ ,    Char_AltimLevelToAssimilate_ ,     ListNumber)
            call AddPropList (VarianceFieldToAssimilate_ , Char_VarianceFieldToAssimilate_ ,  ListNumber)
            
            call AddPropList (BaroclinicVelocityU_ ,    Char_BaroclinicVelocityU_ ,     ListNumber)
            call AddPropList (BaroclinicVelocityV_ ,    Char_BaroclinicVelocityV_ ,     ListNumber)
            call AddPropList (ObstacleDragCoef_ ,       Char_ObstacleDragCoef ,         ListNumber)

            call AddPropList (Vorticity_ ,              Char_Vorticity ,                ListNumber)
            call AddPropList (BaroclinicKE_ ,           Char_BaroclinicKE ,             ListNumber)
            call AddPropList (PerturbationPE_ ,         Char_PerturbationPE ,           ListNumber)
            call AddPropList (KineticEnergy_ ,          Char_KineticEnergy ,            ListNumber)

            call AddPropList (ShearVelocity_,           Char_ShearVelocity,             ListNumber)

            call AddPropList (VerticalZ_,               Char_VerticalZ,                 ListNumber)

            call AddPropList (ParticulateContaminant_,  Char_ParticulateContaminant,    ListNumber)
            call AddPropList (DissolvedContaminant_,    Char_DissolvedContaminant,      ListNumber)

            call AddPropList (Sediment,                 Char_Sediment,                  ListNumber)

            call AddPropList (DissolvedSodium_ ,        Char_DissolvedSodium ,          ListNumber)
            call AddPropList (DissolvedCalcium_,        Char_DissolvedCalcium,          ListNumber)
                                                        
            call AddPropList (ParticulateSodium_ ,      Char_ParticulateSodium ,        ListNumber)
            call AddPropList (ParticulateCalcium_,      Char_ParticulateCalcium,        ListNumber)

            call AddPropList (LatentHeat_,              Char_LatentHeat,                ListNumber)
            call AddPropList (SensibleHeat_,            Char_SensibleHeat,              ListNumber)
            call AddPropList (Evaporation_  ,           Char_Evaporation  ,             ListNumber)
            call AddPropList (NetLongWaveRadiation_,    Char_NetLongWaveRadiation,      ListNumber)
            call AddPropList (UpwardLongWaveRadiation_, Char_UpwardLongWaveRadiation,   ListNumber)
            call AddPropList (DownwardLongWaveRadiation_,Char_DownwardLongWaveRadiation,ListNumber)

            call AddPropList (ShortWaveSolarRadiation_, Char_ShortWaveSolarRadiation,   ListNumber)
            call AddPropList (LongWaveSolarRadiation_,  Char_LongWaveSolarRadiation,    ListNumber)

            call AddPropList (ShortWaveSolarRadiationExtin_, Char_ShortWaveSolarRadiaExtin,   ListNumber)
            call AddPropList (LongWaveSolarRadiationExtin_ , Char_LongWaveSolarRadiaExtin,    ListNumber)
            
            call AddPropList (OxygenFlux_ ,             Char_OxygenFlux ,               ListNumber)
            call AddPropList (WindShearVelocity_ ,      Char_WindShearVelocity ,        ListNumber)
            call AddPropList (SurfaceRadiation_ ,       Char_SurfaceRadiation ,         ListNumber)
            call AddPropList (WindStressX_,             Char_WindStressX,               ListNumber)
            call AddPropList (WindStressY_,             Char_WindStressY,               ListNumber)
            call AddPropList (SurfaceWaterFlux_ ,       Char_SurfaceWaterFlux ,         ListNumber)
            call AddPropList (NonSolarFlux_ ,           Char_NonSolarFlux ,             ListNumber)
            call AddPropList (TurbulentKineticEnergy_,  Char_TurbulentKineticEnergy,    ListNumber)
            call AddPropList (CarbonDioxideFlux_ ,      Char_CarbonDioxideFlux,         ListNumber)
            call AddPropList (Albedo_ ,                 Char_Albedo,                    ListNumber)


            call AddPropList (WindVelocityX_,           Char_WindVelocityX       ,      ListNumber)
            call AddPropList (WindVelocityY_,           Char_WindVelocityY       ,      ListNumber)
            call AddPropList (SolarRadiation_,          Char_SolarRadiation      ,      ListNumber)
            call AddPropList (Precipitation_,           Char_Precipitation       ,      ListNumber)
            call AddPropList (AtmosphericPressure_,     Char_AtmosphericPressure ,      ListNumber)
            call AddPropList (AirTemperature_,          Char_AirTemperature      ,      ListNumber)
            call AddPropList (RelativeHumidity_,        Char_RelativeHumidity    ,      ListNumber)
            call AddPropList (WindModulos_,             Char_WindModulos         ,      ListNumber)
            call AddPropList (WindAngle_,               Char_WindAngle           ,      ListNumber)
            call AddPropList (CloudCover_,              Char_CloudCover          ,      ListNumber)
            call AddPropList (Irrigation_,              Char_Irrigation          ,      ListNumber)
            call AddPropList (SunHours_ ,               Char_SunHours            ,      ListNumber)
            call AddPropList (ATMTransmitivity_ ,       Char_ATMTransmitivity    ,      ListNumber)
           
            call AddPropList (RPOM_ ,                   Char_RPOM                ,      ListNumber)
            call AddPropList (LPOM_ ,                   Char_LPOM                ,      ListNumber)
            call AddPropList (LDOM_ ,                   Char_LDOM                ,      ListNumber)
            call AddPropList (RDOM_ ,                   Char_RDOM                ,      ListNumber)
            call AddPropList (PSilica_ ,                Char_PSilica             ,      ListNumber)
            call AddPropList (DSilica_ ,                Char_DSilica             ,      ListNumber)
            call AddPropList (ICarbon_ ,                Char_ICarbon             ,      ListNumber)
            call AddPropList (pH_ ,                     Char_pH                  ,      ListNumber)
            call AddPropList (HCO3_ ,                   Char_HCO3                ,      ListNumber)
            call AddPropList (CO3_ ,                    Char_CO3                 ,      ListNumber)
            call AddPropList (Algae_1_ ,                Char_Algae_1             ,      ListNumber)
            call AddPropList (Algae_2_ ,                Char_Algae_2             ,      ListNumber)
            call AddPropList (Algae_3_ ,                Char_Algae_3             ,      ListNumber)
            call AddPropList (Algae_4_ ,                Char_Algae_4             ,      ListNumber)
            call AddPropList (Algae_5_ ,                Char_Algae_5             ,      ListNumber)
            call AddPropList (Epiphyton_1_ ,            Char_Epiphyton_1         ,      ListNumber)
            call AddPropList (Epiphyton_2_ ,            Char_Epiphyton_2         ,      ListNumber)
            call AddPropList (Epiphyton_3_ ,            Char_Epiphyton_3         ,      ListNumber)
            call AddPropList (Epiphyton_4_ ,            Char_Epiphyton_4         ,      ListNumber)
            call AddPropList (Epiphyton_5_ ,            Char_Epiphyton_5         ,      ListNumber)
            call AddPropList (Alkalinity_ ,             Char_Alkalinity          ,      ListNumber)
            call AddPropList (Detritus_ ,               Char_Detritus            ,      ListNumber)
 
            call AddPropList (ANLim_,                   Char_ANLim,                      ListNumber)       
            call AddPropList (APLim_,                   Char_APLim,                      ListNumber)       
            call AddPropList (ASLim_,                   Char_ASLim,                      ListNumber)       
            call AddPropList (ALightLim_,               Char_ALightLim,                  ListNumber)   
            call AddPropList (AOverallLim_,             Char_AOverallLim,                ListNumber) 
            call AddPropList (ENLim_,                   Char_ENLim,                      ListNumber)               
            call AddPropList (EPLim_,                   Char_EPLim,                      ListNumber)   
            call AddPropList (ESLim_,                   Char_ESLim,                      ListNumber)      
            call AddPropList (ELightLim_,               Char_ELightLim,                  ListNumber)              
            call AddPropList (EOverallLim_,             Char_EOverallLim,                ListNumber)       
            call AddPropList (NH4D_,                    Char_NH4D,                       ListNumber) 
            call AddPropList (NO3D_,                    Char_NO3D,                       ListNumber) 
            call AddPropList (LDOMD_,                   Char_LDOMD,                      ListNumber) 
            call AddPropList (RDOMD_,                   Char_RDOMD,                      ListNumber) 
            call AddPropList (LPOMD_,                   Char_LPOMD,                      ListNumber)            
            call AddPropList (RPOMD_,                   Char_RPOMD,                      ListNumber) 
            call AddPropList (LRDOMD_,                  Char_LRDOMD,                     ListNumber)           
            call AddPropList (LRPOMD_,                  Char_LRPOMD,                     ListNumber)        
            call AddPropList (CBODD_,                   Char_CBODD,                      ListNumber)         
            call AddPropList (PO4ER_,                   Char_PO4ER,                      ListNumber)     
            call AddPropList (PO4EG_,                   Char_PO4EG,                      ListNumber)     
            call AddPropList (PO4AR_,                   Char_PO4AR,                      ListNumber)     
            call AddPropList (PO4AG_,                   Char_PO4AG,                      ListNumber)     
            call AddPropList (PO4OM_,                   Char_PO4OM,                      ListNumber)     
            call AddPropList (PO4BOD_,                  Char_PO4BOD,                     ListNumber)    
            call AddPropList (NH4ER_,                   Char_NH4ER,                      ListNumber)  
            call AddPropList (NH4EG_,                   Char_NH4EG,                      ListNumber)  
            call AddPropList (NH4AR_,                   Char_NH4AR,                      ListNumber)  
            call AddPropList (NH4AG_,                   Char_NH4AG,                      ListNumber)    
            call AddPropList (NH4OM_,                   Char_NH4OM,                      ListNumber)    
            call AddPropList (NH4BOD_,                  Char_NH4BOD,                     ListNumber)   
            call AddPropList (NO3AG_,                   Char_NO3AG,                      ListNumber)   
            call AddPropList (NO3EG_,                   Char_NO3EG,                      ListNumber)   
            call AddPropList (DSIAG_,                   Char_DSIAG,                      ListNumber) 
            call AddPropList (DSIEG_,                   Char_DSIEG,                      ListNumber) 
            call AddPropList (DSID_,                    Char_DSID,                       ListNumber)  
            call AddPropList (PSIAM_,                   Char_PSIAM,                      ListNumber)     
            call AddPropList (PSID_,                    Char_PSID,                       ListNumber)      
            call AddPropList (LDOMAP_,                  Char_LDOMAP,                     ListNumber)    
            call AddPropList (LDOMEP_,                  Char_LDOMEP,                     ListNumber)    
            call AddPropList (LPOMAP_,                  Char_LPOMAP,                     ListNumber)    
            call AddPropList (DOAP_,                    Char_DOAP,                       ListNumber)      
            call AddPropList (DOEP_,                    Char_DOEP,                       ListNumber)      
            call AddPropList (DOAR_,                    Char_DOAR,                       ListNumber)      
            call AddPropList (DOER_,                    Char_DOER,                       ListNumber)      
            call AddPropList (DOOM_,                    Char_DOOM,                       ListNumber)       
            call AddPropList (DONIT_,                   Char_DONIT,                      ListNumber)      
            call AddPropList (ICarbonAP_,               Char_ICarbonAP,                  ListNumber) 
            call AddPropList (ICarbonEP_,               Char_ICarbonEP,                  ListNumber) 
            call AddPropList (ICarbonBOD_,              Char_ICarbonBOD,                 ListNumber)

            call AddPropList (Diameter_,                Char_Diameter,                   ListNumber)
            call AddPropList (Percentage_,              Char_Percentage,                 ListNumber)
            call AddPropList (D35_,                     Char_D35,                        ListNumber)
            call AddPropList (D50_,                     Char_D50,                        ListNumber)
            call AddPropList (D90_,                     Char_D90,                        ListNumber)
            call AddPropList (BedRock_,                 Char_BedRock,                    ListNumber)
            call AddPropList (SandTauCritic_,           Char_SandTauCritic,              ListNumber)
            call AddPropList (Sand_,                    Char_Sand,                       ListNumber)

            call AddPropList (TransportCapacity_,       Char_TransportCapacity,          ListNumber)
            call AddPropList (TransportCapacityX_,      Char_TransportCapacityX,         ListNumber)
            call AddPropList (TransportCapacityY_,      Char_TransportCapacityY,         ListNumber)
            call AddPropList (BottomEvolution_,         Char_BottomEvolution  ,          ListNumber)
            call AddPropList (Newbathymetry_,           Char_Newbathymetry    ,          ListNumber)

            !wave dynamics
            call AddPropList (WaveStressX_,             Char_WaveStressX,                ListNumber)
            call AddPropList (WaveStressY_,             Char_WaveStressY,                ListNumber)
            call AddPropList (OrbitalVelocityX_,        Char_OrbitalVelocityX,           ListNumber)
            call AddPropList (OrbitalVelocityY_,        Char_OrbitalVelocityY,           ListNumber)

            !!Monocromatic:
            call AddPropList (WaveAmplitude_,           Char_WaveAmplitude,              ListNumber)
            call AddPropList (WavePeriod_,              Char_WavePeriod,                 ListNumber)
            call AddPropList (WaveDirection_,           Char_WaveDirection,              ListNumber)
            !!Statistical wave parametres (WW3,SWAN)
            call AddPropList (SignificantWaveHeight_,   Char_SignificantWaveHeight,      ListNumber)
            call AddPropList (MeanWaveLength_,          Char_MeanWaveLength,             ListNumber)
            call AddPropList (MeanWavePeriod_,          Char_MeanWavePeriod,             ListNumber)
            call AddPropList (MeanWaveDirection_,       Char_MeanWaveDirection,          ListNumber)
            call AddPropList (MeanDirectionalSpread_,   Char_MeanDirectionalSpread,      ListNumber)
            call AddPropList (PeakFrequency_,           Char_PeakFrequency,              ListNumber)
            call AddPropList (PeakDirection_,           Char_PeakDirection,              ListNumber)
            call AddPropList (WindSeaPeakFrequency_,    Char_WindSeaPeakFrequency,       ListNumber)
            call AddPropList (WindSeaPeakDirection_,    Char_WindSeaPeakDirection,       ListNumber)

            call AddPropList (ConsolidationFlux_,       Char_ConsolidationFlux,          ListNumber)
            call AddPropList (Porosity_,                Char_Porosity,                   ListNumber)
            
            call AddPropList (ShearStress_,             Char_ShearStress_,               ListNumber)

            call AddPropList (LeafAreaIndex_,           Char_LeafAreaIndex,             ListNumber)
            call AddPropList (SpecificLeafStorage_,     Char_SpecificLeafStorage,       ListNumber)
            call AddPropList (EVTPCropCoefficient_,     Char_EVTPCropCoefficient,       ListNumber)
            call AddPropList (RootDepth_,               Char_RootDepth,                 ListNumber)
            call AddPropList (RootFeddesParameterH1_,   Char_RootFeddesParameterH1,     ListNumber)
            call AddPropList (RootFeddesParameterH2_,   Char_RootFeddesParameterH2,     ListNumber)
            call AddPropList (RootFeddesParameterH3_,   Char_RootFeddesParameterH3,     ListNumber)
            call AddPropList (RootFeddesParameterH4_,   Char_RootFeddesParameterH4,     ListNumber)


            !Place to add new properties to the names list
        
            !Ends building the property name list
            call AddPropList(FillValueInt, 'No name', ListNumber, EndList = .true.)


            PropertiesNumber = ListNumber

            do i = 1, PropertiesNumber
            do j = 1, PropertiesNumber

                if (i/=j .and. (PropNameList  (i) == PropNameList  (j) .or.           &
                                PropNumberList(i) == PropNumberList(j)))              &
                                stop 'ConstructPropList - GlobalData, ERR01'
            enddo
            enddo
            
        endif    



    end subroutine ConstructPropList
    
    !--------------------------------------------------------------------------

    subroutine AddPropList(PropNumber, PropName, ListNumber, EndList)

        !Arguments-------------------------------------------------------------
        integer,          intent (IN)               :: PropNumber
        character(len=*), intent (IN)               :: PropName
        integer,          intent (INOUT)            :: ListNumber
        logical,          intent (IN),    optional  :: EndList

        !Begin-----------------------------------------------------------------
        logical                                                      :: EndList_
        character(len=StringLength), allocatable, dimension(:), save :: AuxChar
        integer,                     allocatable, dimension(:), save :: AuxInt
        logical                                               , save :: FirstProp = .true.
        
        !----------------------------------------------------------------------


        if (present(EndList)) then 

            EndList_ = EndList

        else

            EndList_ = .false.

        endif

       if (.not. EndList_) then

            if (FirstProp) then

                FirstProp = .false.

                allocate (PropNumberList(1))                
                allocate (PropNameList  (1))
                allocate (AuxInt        (1))
                allocate (AuxChar       (1))

                ListNumber = 1
    
            else     

                deallocate   (PropNameList)
                deallocate   (PropNumberList)

                allocate     (PropNameList  (ListNumber + 1))      
                allocate     (PropNumberList(ListNumber + 1))      

                 
                PropNameList  (1 : ListNumber) = AuxChar(1 : ListNumber)
                PropNumberList(1 : ListNumber) = AuxInt (1 : ListNumber)
 
                deallocate   (AuxInt, AuxChar)
                allocate     (AuxChar(ListNumber + 1), AuxInt(ListNumber + 1))       

                ListNumber = ListNumber + 1

            endif     

            PropNameList  (ListNumber) = PropName
            PropNumberList(ListNumber) = PropNumber

            AuxChar      (:)          = PropNameList  (:)
            AuxInt       (:)          = PropNumberList(:)


        else       

            deallocate (AuxChar, AuxInt)

        endif      


    end subroutine AddPropList


    !----------------------------------------------------------------------


    logical function Check_Particulate_Property(Property)

        !Arguments-------------------------------------------------------------
        integer, intent (IN) :: Property

        !----------------------------------------------------------------------

cd1 :   if ((Property == POC_                   ) .OR.  (Property == PON_                   ) .OR.          &
            (Property == POP_                   ) .OR.  (Property == ParticulateArsenic_    ) .OR.          &
            (Property == AdsorbedAmmonia_       ) .OR.  (Property == AnaerobicC_            ) .OR.          &
            (Property == AnaerobicN_            ) .OR.  (Property == AutotrophicC_          ) .OR.          &
            (Property == AutotrophicN_          ) .OR.  (Property == HeterotrophicC_        ) .OR.          &
            (Property == HeterotrophicN_        ) .OR.  (Property == LabileOrganicC_        ) .OR.          &
            (Property == RefreactaryOrganicC_   ) .OR.  (Property == RefreactaryOrganicN_   ) .OR.          &            
            (Property == Cohesive_Sediment_     ) .OR.  (Property == ParticulateContaminant_) .OR.          &  
            (Property == ParticulateSodium_     ) .OR.  (Property == ParticulateCalcium_    ) .OR.          &  
            (Property == Detritus_              ) .OR.  (Property == Phytoplankton_         ) .OR.          &  
            (Property == Diatom_C_              ) .OR.  (Property == Diatom_N_              ) .OR.          &  
            (Property == Diatom_P_              ) .OR.  (Property == Diatom_Si_             ) .OR.          &
            (Property == Diatom_Chl_            ) .OR.  (Property == Mix_Flagellate_C_      ) .OR.          &
            (Property == Mix_Flagellate_N_      ) .OR.  (Property == Mix_Flagellate_P_      ) .OR.          &
            (Property == Mix_Flagellate_Chl_    ) .OR.  (Property == Picoalgae_C_           ) .OR.          &
            (Property == Picoalgae_N_           ) .OR.  (Property == Picoalgae_P_           ) .OR.          &
            (Property == Picoalgae_Chl_         ) .OR.  (Property == Flagellate_C_          ) .OR.          &
            (Property == Flagellate_N_          ) .OR.  (Property == Flagellate_P_          ) .OR.          &
            (Property == Flagellate_Chl_        ) .OR.  (Property == Algae_1_               ) .OR.          &  
            (Property == Algae_2_               ) .OR.  (Property == Algae_3_               ) .OR.          &  
            (Property == Algae_4_               ) .OR.  (Property == Algae_5_               ) .OR.          &
            (Property == Epiphyton_1_           ) .OR.  (Property == Epiphyton_2_           ) .OR.          &
            (Property == Epiphyton_3_           ) .OR.  (Property == Epiphyton_4_           ) .OR.          &  
            (Property == Epiphyton_5_           ) .OR.  (Property == PSilica_               ) .OR.          &  
            (Property == LPOM_                  ) .OR.  (Property == RPOM_                  ) .OR.          &  
            (Property == BioSilica_             ) .OR.  (Property == Diatoms_               ) .OR.          &
            (Property == Larvae_                )) then

            Check_Particulate_Property = .TRUE.
        
        else

            Check_Particulate_Property = .FALSE.

        end if cd1

    end function Check_Particulate_Property

        
    !--------------------------------------------------------------------------


    integer function TranslateTypeZUV(Char_TypeZUV)

        !Arguments-------------------------------------------------------------
        character(len=*), intent(in)            :: Char_TypeZUV
        
        !----------------------------------------------------------------------

        select case(Char_TypeZUV)

            case("Z", "z")

                TranslateTypeZUV = TypeZ_

            case("U", "u")

                TranslateTypeZUV = TypeU_

            case("V", "v")

                TranslateTypeZUV = TypeV_

            case default

                write(*,*)'Invalid type ZUV'
                stop      'TranslateTypeZUV - ModuleGlobalData - ERR01'

        end select

    end function TranslateTypeZUV


    !--------------------------------------------------------------------------

    !--------------------------------------------------------------------------
    !  UnitsManager - Routine to index unit files numbers  
    !--------------------------------------------------------------------------
    !   Variables:                                         
    !   OPENCLOSE     - Activate unit (1) or deactivate (0)
    !   UNIT          - Number to the opened unit or to the unit to close   

    subroutine UnitsManager(UNIT, OPENCLOSE, STAT)

        !Arguments-------------------------------------------------------------
        integer,           intent(INOUT)    :: UNIT
        integer,           intent(IN   )    :: OPENCLOSE
        integer, optional, intent(OUT  )    :: STAT

        !External--------------------------------------------------------------
        logical                             :: opened
        integer                             :: STAT_CALL

        !Local-----------------------------------------------------------------
        integer                             :: STAT_

        !----------------------------------------------------------------------

        STAT_ = UNKNOWN_

cd1 :   if      (OPENCLOSE .EQ. OPEN_FILE ) then

            Unit   = 8
            Opened = .true.
do1 :       do while (Opened)
                Unit = Unit + 1
                inquire(UNIT = Unit, OPENED = Opened)
            end do do1

            STAT_ = SUCCESS_

        else if (OPENCLOSE .EQ. CLOSE_FILE) then cd1

            inquire(UNIT = Unit, OPENED = opened)

if8 :       if (opened) then
                close(UNIT, IOSTAT = STAT_CALL)

if9 :           if (STAT_CALL .NE. SUCCESS_) then
                    write(*,*)  
                    write(*,*) "Error closing file unit ", Unit
                    write(*,*) "UnitsManager - ModuleGlobalData - WRN01"

                    STAT_ = UNIT_ERR_
                else
          
                    STAT_ = SUCCESS_

                end if if9
            else
                write(*,*)  
                write(*,*) "Error closing file unit ", Unit
                write(*,*) "The unit is already closed."
                write(*,*) "UnitsManager - ModuleGlobalData - WRN02"

                STAT_ = UNIT_ERR_
            end if if8

        else
            write(*,*) 
            write(*,*) "OPENCLOSE must be 0 or 1."
            write(*,*) "OPENCLOSE is ", OPENCLOSE
            stop       "UnitsManager - ModuleGlobalData - ERR01"

        end if cd1


        if (present(STAT)) STAT = STAT_

        !----------------------------------------------------------------------

    end subroutine UnitsManager

    !--------------------------------------------------------------------------

    subroutine SetError(ErrorMagnitude, ErrorType, SmallMessage, Screen)

        !Arguments-------------------------------------------------------------

        integer,            intent(IN) :: ErrorMagnitude
        integer,            intent(IN) :: ErrorType

        logical, optional,  intent(IN) :: Screen

        character(LEN = *), intent(IN) :: SmallMessage
                                                                                   
        !Local-----------------------------------------------------------------
                     
        character(10) :: StrErrorMagnitude = "          "
        character(10) :: StrErrorType      = "          "

        logical :: Screen_
                     
        !----------------------------------------------------------------------

cd5 :   if (present(Screen)) then
            Screen_ = Screen

        else cd5

            Screen_ = ON
        end if cd5


cd1 :   if      (ErrorMagnitude == FATAL_  ) then

            StrErrorMagnitude = "FATAL"

        else if (ErrorMagnitude == WARNING_) then cd1

            StrErrorMagnitude = "WARNING"

        else

            StrErrorMagnitude = "UNKNOW"

        end if cd1
            


cd2 :   if      (ErrorType == INTERNAL_  ) then

            StrErrorType  = "INTERNAL"

        else if (ErrorType == OUT_OF_MEM_) then cd2

            StrErrorType  = "OUT_OF_MEM"

        else if (ErrorType == KEYWORD_   ) then cd2

            StrErrorType  = "KEYWORD"

        else

            StrErrorType  = "UNKNOW"

        end if cd2


        !Writes a message to the error file
        !Ricardo - dont put here any trim or adjustl or blank lines, ok?
        write(ErrorFileID, "(A)") StrErrorMagnitude//space//StrErrorType//space//trim(adjustl(SmallMessage))//dot
  
cd7 :   if (Screen_) then
            write(*,                *     ) 
            write(*,                 "(A)") trim(adjustl(StrErrorMagnitude))//semicolumn//   &
                                            space//trim(adjustl(StrErrorType))//semicolumn// &
                                            space//trim(adjustl(SmallMessage))//dot
            write(*,                *     ) 
        end if cd7

     


        !If the error message isn"t a warning, stop the execution of this process
cd3 :   if (ErrorMagnitude == FATAL_) then
            close (unit=ErrorFileID  )
            close (unit=UsedKeyFileID)
           
            stop "Program stop anormaly. See Log file."
        end if cd3

        !----------------------------------------------------------------------

    end subroutine SetError

    subroutine WriteDTLog (ModuleName, iter, DT)

        !Arguments-------------------------------------------------------------
        character(len=*)                :: ModuleName
        integer                         :: iter
        real                            :: DT

        if (MonitorDT) then
            write (UnitDT, '(A25, I10,F12.4)') ModuleName, iter, DT 
        end if

    end subroutine WriteDTLog

    !--------------------------------------------------------------------------

    subroutine StartupMohid(ModelName)

        !Arguments-------------------------------------------------------------
        character(len=*)                    :: ModelName

        !Local-----------------------------------------------------------------
        integer                             :: STAT_CALL
        integer                             :: Counter
        integer                             :: N
        character(LEN=4)                    :: Number
        integer, dimension(:), allocatable  :: Seed

        !Begin-----------------------------------------------------------------

        !Initializes Random number generator
        !The use of the "Seed" guarantees the always the same sequence of random
        !numbers is generated. This is important for debug proposes - Frank 03/05
        call RANDOM_SEED(SIZE = N)
        allocate        (Seed(N))
        Seed = 1
        call RANDOM_SEED(PUT  = Seed)

        write(*, *)"-------------------------- MOHID -------------------------"
        write(*, *)
        write(*, *)"      AUTHOR   : IST/MARETEC, Marine Modelling Group      "
        write(*, *)"      WWW      : http://www.mohid.com"
        write(*, *)                    
        write(*, *)"Constructing "//ModelName
        write(*, *)"Please Wait..."


        !Gets a unit for the Error File    
        call UnitsManager(ErrorFileID, OPEN_FILE, STAT = STAT_CALL)
        if (STAT_CALL .NE. SUCCESS_) stop 'StartupMohid - GlobalData - ERR01'
          
        Counter  = 1
do1:    do
            Number = '    '
            write(Number, fmt='(i4)')Counter

            open(UNIT   = ErrorFileID,                                    &
                 FILE   = 'Error_and_Messages_'//trim(adjustl(Number))//'.log',  &
                 STATUS = "REPLACE",                                      &
                 IOSTAT = STAT_CALL)
            if (STAT_CALL == SUCCESS_) then
                exit do1
            else
                Counter = Counter + 1
            end if
        enddo do1


        !Gets a unit for the UsedKeyWordFile
        call UnitsManager(UsedKeyFileID, OPEN_FILE, STAT = STAT_CALL)
        if (STAT_CALL .NE. SUCCESS_) stop 'StartupMohid - GlobalData - ERR02'


        Counter  = 1
do2:    do
            Number = '    '
            write(Number, fmt='(i4)')Counter

            open(UNIT   = UsedKeyFileID,                                  &
                 FILE   = 'UsedKeyWords_'//trim(adjustl(Number))//'.dat',        &
                 STATUS = "REPLACE",                                      &
                 IOSTAT = STAT_CALL)
            if (STAT_CALL == SUCCESS_) then
                exit do2
            else
                Counter = Counter + 1
            end if

        enddo do2

        !----------------------------------------------------------------------

    end subroutine StartupMohid

    !--------------------------------------------------------------------------

    subroutine ShutdownMohid (ModelName, ElapsedSeconds, TotalCPUTime,            &
                              WorkCycleElapsed, WorkCycleCPUTime)

        !Arguments-------------------------------------------------------------
        character(len=*)                :: ModelName
        real                            :: ElapsedSeconds, TotalCPUTime
        real, optional                  :: WorkCycleElapsed, WorkCycleCPUTime

        !----------------------------------------------------------------------
        integer                         :: STAT_CALL

        call UnitsManager(ErrorFileID, CLOSE_FILE, STAT = STAT_CALL)
        if (STAT_CALL .NE. SUCCESS_) stop 'ShutdownMohid - GlobalData - ERR01'

        call UnitsManager(UsedKeyFileID, CLOSE_FILE, STAT = STAT_CALL)
        if (STAT_CALL .NE. SUCCESS_) stop 'ShutdownMohid - GlobalData - ERR02'

        write(*, *)"-------------------------- MOHID -------------------------"
        write(*, *)
        write(*, *)"Program "//ModelName//" succefully terminated"
        write(*, *)                    
        write(*, *)
        write(*, 110)ElapsedSeconds
        write(*, 120)TotalCPUTime
        write(*, 130)100.*TotalCPUTime/ElapsedSeconds
        if (present(WorkCycleElapsed) .and. present(WorkCycleCPUTime)) then
            write(*, 140)WorkCycleElapsed
            write(*, 150)WorkCycleCPUTime
            if(WorkCycleElapsed/=.0) then
                write(*, 160)100.*WorkCycleCPUTime/WorkCycleElapsed
            endif
        endif
        write(*, *)
        write(*, *)"----------------------------------------------------------"
        stop

    110 format(1x, "Total Elapsed Time     : ",f14.4,/)
    120 format(1x, "Total CPU time         : ",f14.4,/)
    130 format(1x, "CPU usage (%)          : ",f14.4,/)
    140 format(1x, "Workcycle Elapsed Time : ",f14.4,/)
    150 format(1x, "Workcycle CPU time     : ",f14.4,/)
    160 format(1x, "Workcycle CPU usage (%): ",f14.4,/)

        !----------------------------------------------------------------------

    end subroutine ShutdownMohid

    integer function GetUsersNumber (iModule, iInstance)

        !Arguments-------------------------------------------------------------
        integer                                     :: iModule
        integer                                     :: iInstance

        !Local-----------------------------------------------------------------

        !Instance users number
        GetUsersNumber = ObjCollector(iModule, iInstance)%Users

    end function GetUsersNumber
    
    !--------------------------------------------------------------------------

    subroutine WriteErrorMessage(keyword, text, STAT)

        !Arguments-------------------------------------------------------------
        character(LEN = *), intent(IN )             :: keyword               
        character(LEN = *), intent(IN )             :: text
        integer, optional,  intent(OUT)             :: STAT    

        !Local-----------------------------------------------------------------
        integer                                     :: LengthText, LengthKeyword

        !----------------------------------------------------------------------
        LengthText    = LEN_TRIM(text   )
        LengthKeyword = LEN_TRIM(keyword)

#ifndef _GUI_
        write (ErrorFileID,*    )             
        write (ErrorFileID,*    )             
        write (ErrorFileID,"(A)") text
        write (ErrorFileID, 100 ) keyword
100     format("Keyword: ", A, " not found"/)
#endif    

        if (present(STAT)) STAT = SUCCESS_
        !----------------------------------------------------------------------
    
    end subroutine WriteErrorMessage

    !--------------------------------------------------------------------------

    subroutine LogKeyWord (keyword, SearchType, ClientModule, Default, CaseSensitive, Value)
    
        !Arguments-------------------------------------------------------------
        character (len=*)                           :: keyword
        integer                                     :: SearchType
        character (len=*)                           :: ClientModule
        character (len=*)                           :: Default
        logical                                     :: CaseSensitive
        character (len=*)                           :: Value

        !Local-----------------------------------------------------------------
        character (len=line_length)                 :: lkeyword
        character (len=line_length)                 :: lSearchType
        character (len=line_length)                 :: lClientModule
        character (len=line_length)                 :: lDefault
        character (len=line_length)                 :: lValue
        character (len=3          )                 :: lCaseSensitive

        lkeyword      = adjustl (keyword     )
        lClientModule = adjustl (ClientModule)
        lDefault      = adjustl (Default     )
        lValue        = adjustl (Value       )

        select case (SearchType)
        case (FromFile_)
            lSearchType = "From File"
        case (FromBlock_)
            lSearchType = "From Block"
        case (FromBlockInBlock_)
            lSearchType = "From Block In Block"
        end select

        if (CaseSensitive) then
            lCaseSensitive = 'YES'
        else
            lCaseSensitive = 'NO '
        endif

#ifndef _GUI_
        write  (unit = UsedKeyFileID, fmt = 10)lkeyword, lClientModule, lDefault, lSearchType, lValue, lCaseSensitive
   10   format (1x, a25, 1x, a25, 1x, a25, 1x, a25, 1x, a60, 1x, a3)
#endif
    end subroutine LogKeyWord 


end module ModuleGlobalData

