00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _CropSoil_h
00020 #define _CropSoil_h
00021
00022
00023 #include "BasicData.h"
00024
00025
00026 typedef struct
00027 { double dc;
00028 double bd;
00029 double rf;
00030 double ef;
00031 double so;
00032 } gnrlP;
00033
00034
00035 typedef struct
00036 { double mf_n;
00037 double mf_p;
00038 double mf_k;
00039 double ph_f;
00040 double li_f;
00041 } mferP;
00042
00043
00044
00045 typedef struct
00046 { double of_n;
00047 double of_p;
00048 double of_k;
00049 double of_c;
00050 } oferP;
00051
00052
00053
00054 typedef struct
00055 { double yp;
00056 double m1;
00057 double m2;
00058 double n1;
00059 double n2;
00060 double p1;
00061 double p2;
00062 double k1;
00063 double k2;
00064 double c1;
00065 double c2;
00066 double c3;
00067 double a1;
00068 double a2;
00069 double fg;
00070 double fs;
00071 } yildF;
00072
00073
00074 typedef struct
00075 { double s1;
00076 double h1;
00077 double gn;
00078 double gp;
00079 double gk;
00080 double sn;
00081 double sp;
00082 double sk;
00083 double sc;
00084 double me;
00085 } cropP;
00086
00087
00088 typedef struct
00089 { double e1;
00090 double e2;
00091 } erosP;
00092
00093
00094
00095
00096 typedef struct
00097 { double yld;
00098 double ysm;
00099 } caYld;
00100
00101
00102 class inCrA
00103 {
00104 public:
00105
00106
00107 int crpID;
00108 double inLab;
00109 double* inFer;
00110
00111 inCrA(int numF);
00112 virtual ~inCrA();
00113 };
00114
00115
00116
00117
00118 class soilC
00119 { public:
00120
00121 double N;
00122 double P;
00123 double K;
00124 double A;
00125 double C;
00126 double sl;
00127 double se;
00128
00129 virtual ~soilC()
00130 {
00131 }
00132
00133 };
00134
00135
00136 class sProc
00137 {
00138 public:
00139
00140 double SON1;
00141 double RTN1;
00142 double PCO1;
00143 double CER1;
00144 double KIC1;
00145 double NER1;
00146 double RTS1;
00147 double KGC1;
00148 double YST1;
00149 double SOC1;
00150 double APH1;
00151
00152 double* FER1;
00153
00154 sProc(int numF)
00155 { if((FER1 = new double[numF]) == NULL)
00156 { printf("Error: Not enough memory for 'sProc'\n");
00157 exitfun();
00158 }
00159 }
00160
00161 virtual ~sProc()
00162 { delete [] FER1;
00163 }
00164 };
00165
00166
00167 typedef struct
00168 { double STN1;
00169 double STN2;
00170 double STN3;
00171 double RES1;
00172 double RES2;
00173 double RES3;
00174 double MAN1;
00175 double MAN2;
00176 double MAN3;
00177 } lUseH;
00178
00179
00180
00181
00182 class crpMixNRU
00183 {
00184 public:
00185
00186
00187 int nCr;
00188 int* crA;
00189 int* cID;
00190 int* cLP;
00191 int* yLP;
00192 double* aHa;
00193 double* LAB;
00194 double* YLD;
00195 double* YSM;
00196 double** FER;
00197
00198
00199 int nru;
00200 int soilID;
00201 double tSize;
00202 double tStvL;
00203 double avgSl;
00204 double avgSe;
00205
00206 double STN;
00207 double RES;
00208 double MAN;
00209
00210 sProc* soilP;
00211 lUseH landU;
00212
00213
00214 crpMixNRU(int n, int numF)
00215 { nCr = n;
00216
00217 if((crA = new int[nCr]) == NULL)
00218 { printf( "Error: Not enough memory for 'crpMix'\n");
00219 exitfun();
00220 }
00221
00222 if((cID = new int[nCr]) == NULL)
00223 { printf( "Error: Not enough memory for 'crpMix'\n");
00224 exitfun();
00225 }
00226
00227 if((cLP = new int[nCr]) == NULL)
00228 { printf( "Error: Not enough memory for 'crpMix'\n");
00229 exitfun();
00230 }
00231
00232 if((yLP = new int[nCr]) == NULL)
00233 { printf( "Error: Not enough memory for 'crpMix'\n");
00234 exitfun();
00235 }
00236
00237 if((aHa = new double[nCr]) == NULL)
00238 { printf( "Error: Not enough memory for 'crpMix'\n");
00239 exitfun();
00240 }
00241
00242 if((LAB = new double[nCr]) == NULL)
00243 { printf( "Error: Not enough memory for 'crpMix'\n");
00244 exitfun();
00245 }
00246
00247 if((YLD = new double[nCr]) == NULL)
00248 { printf( "Error: Not enough memory for 'crpMix'\n");
00249 exitfun();
00250 }
00251
00252 if((YSM = new double[nCr]) == NULL)
00253 { printf( "Error: Not enough memory for 'crpMix'\n");
00254 exitfun();
00255 }
00256
00257 if((FER = new double*[nCr]) == NULL)
00258 { printf( "Error: Not enough memory for 'crpMix'\n");
00259 exitfun();
00260 }
00261
00262 for (int i = 0; i < nCr; i++)
00263 { if((FER[i] = new double[numF]) == NULL)
00264 { printf( "Error: Not enough memory for 'crpMix'\n");
00265 exitfun();
00266 }
00267 }
00268 }
00269
00270 virtual ~crpMixNRU()
00271 { delete [] crA;
00272 delete [] cID;
00273 delete [] cLP;
00274 delete [] yLP;
00275 delete [] aHa;
00276 delete [] LAB;
00277 delete [] YLD;
00278 delete [] YSM;
00279
00280 for (int i = 0; i < nCr; i++)
00281 { delete [] FER[i];
00282 }
00283 delete [] FER;
00284 }
00285 };
00286
00287
00288
00289 class CropSoil
00290 { protected:
00291 FILE* datStrm;
00292 int numTypes;
00293
00294 int numCrops;
00295 int numCropA;
00296 int numNRUnt;
00297 int numMiFer;
00298 int numOrFer;
00299 int numSeasn;
00300
00301 gnrlP* gnrlPars;
00302 mferP* mferPars;
00303 oferP* oferPars;
00304 yildF* yldFuncs;
00305 cropP* cropPars;
00306 erosP* erosPars;
00307
00308 sProc** initPro;
00309 lUseH* initLuh;
00310
00311 caYld** yldExp;
00312 inCrA*** craInp;
00313
00314 public:
00315 CropSoil(void)
00316 { numTypes = -1;
00317
00318 numCrops = -1;
00319 numCropA = -1;
00320 numNRUnt = -1;
00321 numMiFer = -1;
00322 numOrFer = -1;
00323 numSeasn = -1;
00324
00325 gnrlPars = NULL;
00326 mferPars = NULL;
00327 oferPars = NULL;
00328 yldFuncs = NULL;
00329 cropPars = NULL;
00330 erosPars = NULL;
00331
00332 initPro = NULL;
00333
00334 yldExp = NULL;
00335 craInp = NULL;
00336 }
00337
00338 virtual ~CropSoil()
00339 { deallocateMem();
00340 }
00341
00342 virtual void readInputFromFile(char*);
00343 virtual void writeInputIntoFile(char*);
00344
00345 virtual int getNumCrops();
00346 virtual int getNumCropA();
00347 virtual int getNumNRUnt();
00348 virtual int getNumMiFer();
00349 virtual int getNumOrFer();
00350 virtual int getNumSeasn();
00351
00352 virtual gnrlP& getGnrlPars(int typ);
00353 virtual double getLimeInFert(int fer);
00354 virtual sProc* getInitSoilPr(int typ);
00355 virtual lUseH& getInitLdUseH(int typ);
00356 virtual caYld getInitYldExp(int act, int typ);
00357 virtual int getCrpID(int cra, int typ);
00358 virtual double getInLab(int cra, int typ);
00359 virtual double getInFer(int cra, int typ, int fer);
00360 virtual int getZeroLabAct(int typ);
00361
00362 virtual void makeYldOfCropMix(int aID, int sID, int kID, int fID,
00363 crpMixNRU*& cmNRU, sProc*& sPrNRU, soilC*& sConNRU);
00364 virtual void writeRowInfoStrm(int aID, int sID, int kID, int fID, int nru,
00365 int cID, int typ, int crA);
00366 virtual void writeEquatInStrm(double rslt);
00367 virtual void writeNewLineStrm();
00368
00369 virtual void printToScreen(void);
00370 virtual void deallocateMem(void);
00371 };
00372
00373
00374
00375 #endif