% makes arrays for use in CASA

% in getSoilParams
clay    = zeros(numberOfGridCells,1);
silt    = zeros(numberOfGridCells,1);
sand    = zeros(numberOfGridCells,1);
   
litcn   = zeros(numberOfGridCells,1);
lignin  = zeros(numberOfGridCells,1);
lrage   = zeros(numberOfGridCells,1);
woodage = zeros(numberOfGridCells,1);

% in doPET
PET = zeros(numberOfGridCells,1);
AHI = zeros(numberOfGridCells,1);

coef = [1.040   -4.00E-3    6.46E-6     -8.04E-7;
        0.944   -2.00E-3    2.71E-6     -4.32E-7;
        1.040   -4.49E-4    4.04E-6     -4.99E-8;
        1.010    2.00E-3    4.86E-6      2.97E-7;
        1.040    4.00E-3    2.89E-6      7.50E-7;
        1.010    4.00E-3    1.76E-6      9.28E-7;
        1.040    4.00E-3    6.46E-6      8.04E-7;
        1.040    3.00E-3    7.87E-6      3.85E-7;
        1.010    3.87E-4    5.32E-6      1.02E-7;
        1.040   -2.00E-3    7.20E-6     -2.95E-7;
        1.010   -4.00E-3    3.88E-6     -6.87E-7;
        1.040   -5.00E-3    3.61E-6     -9.49E-7];    

% in doSoilMoisture
last_pack       = zeros(numberOfGridCells,1);       % begin snow pack set at unity
pack            = zeros(numberOfGridCells,1);
bgmoist         = 0.5*ones(numberOfGridCells,12);
NPPmoist        = 0.5*ones(numberOfGridCells,12);
EET             = zeros(numberOfGridCells,1);
NPPmoist_temp   = zeros(numberOfGridCells,1);
bgmoist_temp    = zeros(numberOfGridCells,1);    
bgmoistpret     = zeros(numberOfGridCells,1);
NPPmoistpret    = zeros(numberOfGridCells,1);    
soilm           = zeros(numberOfGridCells,1);

% in doFPARandLAI
% constants used to determine the simple ratio for each grid cell from
% code written by Sietse Los in January 1993
SRMAX1  = 4.2448;
SRMAX2  = 4.5970;
SRMAX3  = 4.5970;
SRMAX4  = 4.5970;
SRMAX5  = 4.5970;
SRMAX6  = 4.2448;
SRMAX7  = 3.8387;
SRMAX8  = 4.5970;
SRMAX9  = 3.8387;
SRMAX10 = 3.8387;
SRMAX11 = 3.8387;
SRMAX12 = 3.8387;
SRMIN   = 1.0000;   % for unvegetated lands

% maximum and minimum possible FPAR
FPARMAX = 0.9500;
FPARMIN = 0.0000;   % this has CHANGED from original code, original FPARMIN was 0.0010

% maximum possible LAI for each biome
LAIMAX1 = 7.0000; 
LAIMAX2 = 7.0000;
LAIMAX3 = 7.5000;
LAIMAX4 = 8.0000;
LAIMAX5 = 8.0000;
LAIMAX6 = 5.0000;
LAIMAX7 = 5.0000;
LAIMAX8 = 5.0000;
LAIMAX9 = 5.0000;
LAIMAX10= 5.0000;
LAIMAX11= 5.0000;
LAIMAX12= 6.0000;

srmax    = zeros(numberOfGridCells,1);
LAImax   = zeros(numberOfGridCells,1);
LAI_temp = zeros(numberOfGridCells,1);

FPAR     = zeros(numberOfGridCells,12);
LAI      = zeros(numberOfGridCells,12);    
    
% in doOptimumTemperature
topt        = zeros(numberOfGridCells,1);
maxlai      = zeros(numberOfGridCells,1);
lais        = zeros(numberOfGridCells,13);

% in doLeafRootShedding
LTCON       = zeros(numberOfGridCells,1);
LTVAR       = zeros(numberOfGridCells,1);

% in getFireParams
CCratio_previous = zeros(numberOfGridCells,1);

% in doTreeCarbon & doHerbCarbon
woodPoolNames = {'abovewoodpool';'belowwoodpool';'leafpool';'frootpool';'cwdpool';'surfstrpool';'surfmetpool'; ...
                 'surfmicpool';'soilstrpool';'soilmetpool';'soilmicpool';'slowpool';'armoredpool'};
herbPoolNames = {'hleafpool';'hfrootpool';'hsurfstrpool';'hsurfmetpool';'hsurfmicpool';'hsoilstrpool'; ...
                 'hsoilmetpool';'hsoilmicpool';'hslowpool';'harmoredpool'};
[x,y]=size(woodPoolNames);numberOfWoodPools=x;[x,y]=size(herbPoolNames);numberOfHerbPools=x;

if numberOfAgeClasses == 1
    for pool = 1:numberOfWoodPools
    	eval([woodPoolNames{pool},' = zeros(numberOfGridCells,numberOfAgeClasses);'])
	end
	for pool = 1:numberOfHerbPools
	    eval([herbPoolNames{pool},' = zeros(numberOfGridCells,numberOfAgeClasses);'])
	end
    fuelshortage = zeros(numberOfGridCells,numberOfAgeClasses);
else
    for pool = 1:numberOfWoodPools
    	eval([woodPoolNames{pool},'s = zeros(numberOfGridCells,numberOfAgeClasses);'])
	end
	for pool = 1:numberOfHerbPools
	    eval([herbPoolNames{pool},'s = zeros(numberOfGridCells,numberOfAgeClasses);'])
	end
end
