function [ DOUT ] = KODERR( MIRREQ )
%KODERR coefficients - error model part
%
%      SUBROUTINE KODERR(MIRREQ,DOUT)
%-------------------------------------------------------------------------------
% coefficients - error model part
%-------------------------------------------------------------------------------

%      REAL DOUT(5,3,81)
%      INTEGER MIRREQ(81),I,J,K
%      REAL DERRTE(5,3,81)
  persistent DERRTE NI NJ NK;
  if isempty(DERRTE)
    NI = 5;
    NJ = 3;
    NK = 81;
    dat = cell(NI,NJ-1);
    %     350km equinox
    dat{1,1} = [ 2.1178E+00, 1.3114E-07, 2.6148E-01, ...
                -2.8483E-07,-8.3770E-02,-2.3135E-08, ...
                 5.7835E-02,-9.9532E-08,-2.0735E-02, ...
                -1.9633E-01, 4.4717E-08, 5.0244E-02, ...
                -9.1274E-09, 4.8611E-02, 2.5790E-08, ...
                 1.2098E-02,-3.3205E-08, 6.4414E-02, ...
                 2.4963E-08, 2.6340E-03,-3.3202E-08, ...
                 1.0058E-02, 1.0816E-09,-1.3928E-02, ...
                 1.4163E-08,-1.5039E-01, 1.0533E-08, ...
                -4.5060E-03, 8.3297E-09, 2.4488E-03, ...
                -3.7760E-09,-1.8094E-03, 9.6798E-02, ...
                -1.8772E-09, 1.0867E-02,-1.9474E-09, ...
                -6.8032E-03, 3.3603E-09, 7.8251E-03, ...
                 1.6945E-01,-1.1341E-08,-2.0581E-02, ...
                -1.9111E-09,-5.8315E-03,-5.3837E-11, ...
                -3.5216E-02,-3.3668E-09, 1.1079E-03, ...
                 8.5225E-09, 4.8433E-03,-2.6840E-09, ...
                 9.9141E-02,-1.0567E-08, 1.8306E-03, ...
                 1.9576E-10, 1.5468E-03, 1.6529E-01, ...
                -8.3743E-09,-1.0179E-02,-1.0826E-09, ...
                -1.4207E-03,-4.8573E-02, 1.1394E-08, ...
                 1.4470E-02, 2.6626E-10, 9.4379E-02, ...
                -1.8262E-08,-2.0741E-03, 1.3797E-09, ...
                 5.9985E-03, 1.8945E-10, 3.4170E-04, ...
                 6.8581E-02, 5.7838E-09, 6.9529E-03, ...
                 1.5896E-02,-5.0075E-09, 2.8420E-02, ...
                -4.8417E-09, 2.9191E-02, 4.8866E-02];
    %     350km June solstice
    dat{1,2} = [ 2.1020E+00, 6.4074E-02, 8.8979E-02, ...
                -1.6295E-01,-6.8680E-02,-4.9903E-02, ...
                 2.7634E-02, 5.3483E-02,-3.6534E-02, ...
                -2.3004E-01, 5.3630E-02, 9.0376E-02, ...
                 2.6442E-02, 3.7594E-02, 1.7345E-02, ...
                -4.3779E-02,-4.7004E-03, 9.0849E-02, ...
                 2.6102E-02,-3.2626E-02,-1.1288E-03, ...
                 2.4115E-02,-1.8059E-03,-3.9570E-03, ...
                 5.6676E-03,-6.3478E-02, 1.5132E-02, ...
                 3.1012E-02,-1.7904E-04,-1.7065E-04, ...
                -6.6273E-03, 5.2600E-03,-1.5202E-01, ...
                 2.2061E-02, 1.0633E-02,-2.8630E-03, ...
                -9.6908E-03,-1.3059E-03, 2.4577E-03, ...
                 9.1133E-02, 1.0057E-02, 7.1922E-04, ...
                 2.9878E-03, 7.7424E-04,-4.4353E-03, ...
                -7.6271E-03, 1.4035E-02,-1.3870E-02, ...
                 1.6514E-03, 1.3885E-03, 7.7953E-04, ...
                 1.1731E-01, 2.3511E-02,-8.2554E-04, ...
                -2.4741E-03, 1.5413E-04, 3.3407E-02, ...
                -5.2112E-04,-6.3114E-03, 5.3990E-03, ...
                -9.1618E-04, 1.1605E-02, 1.2671E-03, ...
                -2.1350E-03, 2.6276E-03, 8.2348E-02, ...
                -2.2401E-06,-1.4076E-03, 1.6459E-03, ...
                -4.3340E-02, 1.4798E-02, 4.6935E-03, ...
                 3.0577E-02, 6.6725E-03, 9.0547E-03, ...
                -1.5337E-02,-4.3676E-03,-6.5343E-02, ...
                 1.1111E-02, 2.3191E-03,-3.1603E-02];
    %     550km equinox
    dat{2,1} = [ 2.0812E+00, 2.4308E-07, 5.6584E-01, ...
                 1.9086E-08,-7.6095E-02,-5.1032E-07, ...
                -1.7049E-01,-1.0472E-08, 6.7164E-02, ...
                -2.2595E-01, 4.2122E-09, 6.1906E-03, ...
                 3.9518E-08, 4.5763E-02,-2.2074E-08, ...
                -1.1397E-02,-1.0607E-08, 1.6385E-01, ...
                 4.4170E-08,-2.2410E-02,-1.5556E-08, ...
                 1.2078E-02,-2.9345E-08,-2.3789E-03, ...
                 5.0526E-08,-2.4343E-01, 1.6201E-08, ...
                 1.9976E-02,-2.2397E-11, 4.6519E-03, ...
                -1.1324E-09,-2.2603E-03,-1.2091E-01, ...
                 6.5523E-09, 2.3472E-02, 1.2557E-10, ...
                 3.5617E-03, 2.1655E-09,-1.3878E-03, ...
                -2.4845E-02,-3.1878E-09,-1.3496E-02, ...
                 3.2648E-09,-8.7088E-04,-3.2223E-09, ...
                -8.9965E-02, 1.6719E-09, 5.9083E-03, ...
                 7.0153E-10, 6.3045E-06,-1.7459E-09, ...
                 1.1872E-01, 3.4154E-09, 8.3146E-03, ...
                 7.3305E-11,-1.5977E-04, 2.3161E-02, ...
                 1.6234E-09,-9.7428E-03,-3.1068E-10, ...
                 1.1073E-03, 6.8273E-02, 7.3145E-09, ...
                 4.3073E-03, 1.3123E-10, 1.7105E-02, ...
                 1.9378E-09,-1.6849E-03, 3.9189E-10, ...
                 1.4436E-02,-7.5937E-10, 5.5921E-04, ...
                 3.0434E-02,-5.3588E-10, 1.7285E-03, ...
                -4.6172E-02, 1.0424E-09,-3.3645E-02, ...
                 4.5595E-10,-1.0524E-02,-6.6919E-02];
    %     550km June solstice
    dat{2,2} = [ 2.0903E+00, 4.9465E-02, 4.1834E-01, ...
                -3.0721E-02,-1.0157E-01,-1.5666E-01, ...
                -7.6741E-02, 1.2230E-01, 3.1210E-02, ...
                -1.5269E-01, 4.5530E-02,-2.1376E-03, ...
                -1.8327E-02, 2.3483E-02, 3.1872E-02, ...
                -2.3882E-02,-1.4407E-02, 4.4489E-02, ...
                 1.4618E-02,-2.3584E-04,-6.5495E-03, ...
                 1.6602E-02,-7.5274E-03,-1.3698E-02, ...
                -8.2527E-03,-2.1590E-01, 2.5813E-02, ...
                 5.0590E-02, 2.1022E-03, 1.0141E-02, ...
                -5.1961E-03, 5.4961E-03, 9.7779E-03, ...
                 1.5319E-02,-1.0422E-02,-9.1045E-03, ...
                -8.1248E-03,-5.5846E-03, 1.2857E-03, ...
                -3.1836E-02,-4.4886E-03,-1.8187E-02, ...
                -1.0253E-03,-4.4267E-04,-1.6932E-03, ...
                -8.0883E-02, 2.2869E-02, 3.6385E-03, ...
                 6.0430E-03, 1.8587E-03,-1.5704E-03, ...
                 5.2741E-02, 2.3327E-03,-8.1670E-03, ...
                 2.3873E-03,-4.6541E-04,-5.5659E-02, ...
                 1.0942E-02,-1.0447E-02,-4.5905E-04, ...
                 2.9831E-04, 9.2199E-02,-8.8334E-03, ...
                 4.9657E-03,-1.2876E-03, 1.5785E-02, ...
                -1.1838E-02,-2.4461E-04, 8.0350E-04, ...
                 8.4769E-03, 7.2212E-03, 1.2089E-03, ...
                 4.0519E-02,-8.4599E-03, 1.1588E-03, ...
                -3.3485E-02, 5.8463E-03,-2.8652E-03, ...
                 8.8555E-03,-2.6834E-02,-5.0552E-02];
    %     850km equinox
    dat{3,1} = [ 2.1741E+00,-3.0713E-07, 7.0198E-02, ...
                 4.9868E-07,-1.4427E-01, 2.8235E-08, ...
                 2.9561E-02,-8.1150E-07, 1.8500E-03, ...
                 8.5103E-02, 3.3995E-09, 3.7822E-02, ...
                 4.4995E-08, 3.8160E-02, 6.1687E-09, ...
                -7.6820E-03,-3.5958E-08, 5.4672E-02, ...
                 1.5964E-10, 1.6325E-02,-2.9809E-08, ...
                -2.8099E-03, 2.0887E-08,-1.6249E-03, ...
                 6.0045E-09,-4.3312E-02, 1.2503E-08, ...
                 3.9802E-02, 1.6466E-08, 1.4980E-02, ...
                -7.7490E-09, 4.3219E-03, 1.0214E-01, ...
                -1.6204E-08, 8.0035E-03, 3.9310E-09, ...
                -2.1047E-04,-2.0211E-10, 2.3744E-03, ...
                -1.0833E-01,-2.6971E-09,-1.8076E-02, ...
                 3.9598E-09, 8.3868E-05,-1.0948E-10, ...
                 7.6547E-02, 1.1306E-09,-1.5295E-02, ...
                -8.6391E-10,-9.3252E-04,-9.1719E-12, ...
                 6.3563E-02,-1.2694E-08,-6.3280E-03, ...
                 5.2632E-10,-7.9613E-04,-1.1528E-02, ...
                 1.0676E-08, 1.0950E-02,-5.2360E-09, ...
                -1.0426E-03,-8.4653E-03, 2.7643E-09, ...
                -1.0339E-03, 1.0439E-09, 8.2576E-02, ...
                -1.0238E-08,-5.2244E-03,-2.8944E-10, ...
                 1.7164E-02,-3.7405E-09, 1.3255E-03, ...
                -1.6994E-02, 4.5616E-09, 1.3458E-03, ...
                 2.5439E-02,-5.2198E-09, 3.0276E-02, ...
                -3.3313E-09,-5.7659E-02, 2.8990E-02];
    %     850km June solstice
    dat{3,2} = [ 2.1685E+00,-9.1071E-02,-1.2046E-01, ...
                -2.0084E-01,-7.3145E-02,-1.2735E-01, ...
                -5.5899E-02, 5.2264E-02, 2.3232E-02, ...
                 2.8355E-02,-3.9715E-02, 6.7638E-02, ...
                 2.3396E-02,-8.2230E-03, 1.1384E-02, ...
                -1.6781E-02,-1.7576E-03,-8.0253E-02, ...
                -3.9270E-02,-1.0264E-02,-1.7191E-03, ...
                -4.4668E-03,-1.2252E-04,-7.9374E-03, ...
                 2.3770E-03, 5.3901E-02,-1.9019E-03, ...
                 3.2748E-02, 8.1218E-03, 3.1385E-03, ...
                 6.5387E-03, 1.9147E-03, 9.6127E-02, ...
                -2.7965E-02,-7.7649E-03, 3.7879E-03, ...
                -4.0496E-03, 6.9544E-03,-5.2783E-04, ...
                -1.5082E-01, 1.2699E-02,-1.2565E-03, ...
                 6.7728E-03, 3.6761E-03,-1.7899E-03, ...
                -6.4801E-02,-1.7940E-02,-1.3257E-02, ...
                 5.2332E-03,-6.6084E-03,-2.9180E-03, ...
                 3.0122E-02, 2.1713E-02,-8.3407E-03, ...
                 1.1084E-03, 9.2082E-04,-8.5997E-02, ...
                -1.4387E-02, 9.3689E-03, 6.2303E-04, ...
                 3.5905E-04, 1.7038E-02,-6.3187E-03, ...
                 3.6498E-03, 5.2909E-04,-7.0981E-03, ...
                 5.5184E-03, 6.6041E-04, 3.3276E-04, ...
                 6.9458E-02,-4.9348E-03, 6.0775E-03, ...
                -5.0934E-02,-4.4936E-03, 1.3723E-03, ...
                -8.1570E-03, 1.3748E-02, 7.0236E-03, ...
                 7.9914E-04,-4.6833E-02,-1.6385E-02];
    %     1400km equinox
    dat{4,1} = [ 2.1822E+00, 3.3549E-08, 1.2164E-01, ...
                 2.4764E-07,-8.7502E-02,-4.0691E-07, ...
                 2.3355E-03,-2.8158E-07,-1.3242E-03, ...
                 1.4782E-02, 1.5416E-08, 8.8183E-02, ...
                 2.7046E-08,-2.2398E-02,-4.4919E-09, ...
                -7.8416E-03,-1.7223E-08,-1.3115E-02, ...
                 2.6125E-08, 5.3183E-02,-2.9019E-08, ...
                -3.7068E-04, 5.4685E-10, 1.7274E-03, ...
                 1.8592E-08,-6.2685E-02,-5.3055E-09, ...
                 3.1005E-02, 1.7579E-09, 2.4121E-03, ...
                 4.4444E-11, 4.1500E-03,-2.4028E-01, ...
                -2.3704E-08, 8.7659E-03, 4.2252E-09, ...
                 4.8969E-03, 4.0202E-10, 1.9055E-03, ...
                -1.6350E-01, 3.2289E-09, 1.4824E-03, ...
                -3.6081E-09, 1.3517E-03, 2.4239E-09, ...
                -1.6658E-01, 1.0138E-09, 1.3305E-02, ...
                 4.1669E-09, 1.8869E-03,-2.0831E-09, ...
                 2.0076E-02,-1.0135E-08, 2.2258E-03, ...
                -1.2563E-09,-1.3067E-03,-1.8645E-01, ...
                 2.1705E-09,-7.8197E-03,-9.9205E-10, ...
                 9.4107E-04, 1.7436E-01,-2.0898E-09, ...
                 7.8659E-03, 2.7303E-10, 7.1875E-02, ...
                -2.0799E-09,-3.6387E-03, 2.5309E-09, ...
                -9.2385E-02, 1.1905E-09, 2.6655E-03, ...
                -2.4122E-02, 6.0810E-10, 5.8355E-03, ...
                -5.1302E-02,-7.9405E-09,-7.6189E-02, ...
                -6.7824E-10,-3.1716E-02,-4.1055E-02];
    %     1400km June solstice
    dat{4,2} = [ 2.1442E+00,-1.3864E-01, 1.7112E-01, ...
                -2.1389E-01,-1.8186E-02,-1.0237E-01, ...
                 5.9302E-02, 6.0929E-02, 2.4732E-02, ...
                 7.8690E-02,-2.1925E-02, 1.2199E-01, ...
                -2.8987E-02,-5.3213E-02,-4.8915E-03, ...
                 4.6986E-03,-1.1799E-02,-2.4101E-02, ...
                -2.2908E-02, 2.3052E-02,-8.2149E-03, ...
                 3.1831E-03,-7.8876E-04, 9.0815E-03, ...
                 2.5709E-03,-1.9943E-01, 1.6644E-02, ...
                 3.6662E-02, 8.7738E-03,-2.2514E-03, ...
                -3.0569E-04, 3.6344E-04, 5.6322E-02, ...
                 1.1496E-02, 1.8602E-02,-1.9180E-03, ...
                 6.0620E-03,-6.3761E-04, 3.2952E-03, ...
                -1.4087E-01, 8.0978E-03, 4.2363E-03, ...
                 5.9284E-03, 9.9418E-04, 1.9006E-03, ...
                -9.8914E-02, 8.8500E-03, 2.2600E-03, ...
                 4.5221E-05,-1.4855E-04, 6.4891E-04, ...
                 3.2002E-02,-1.8770E-02, 2.5766E-04, ...
                 6.8798E-04, 7.8152E-04,-5.2227E-02, ...
                 1.3226E-03,-1.6813E-03, 4.7524E-05, ...
                -3.5793E-04, 6.7469E-02,-1.0750E-02, ...
                -2.0372E-03, 2.9722E-04, 4.0765E-02, ...
                -1.4128E-02,-6.7906E-03, 6.6127E-04, ...
                 2.0483E-02, 2.7251E-03,-3.2169E-04, ...
                 7.7473E-02,-6.8423E-03,-1.5793E-03, ...
                -2.6085E-02, 8.8083E-03, 4.2452E-02, ...
                 8.2699E-04, 2.1088E-02, 1.7894E-02];
    %     2000km equinox
    dat{5,1} = [ 2.4436E+00,-4.3843E-07, 1.5425E-01, ...
                -5.5662E-08, 4.0385E-03, 8.1161E-07, ...
                 5.3553E-02,-6.9405E-07,-1.8544E-02, ...
                 1.7362E-01, 4.5975E-08,-6.9333E-03, ...
                 6.9511E-10,-1.9003E-02, 2.0966E-08, ...
                -2.9413E-04,-4.3705E-08, 1.4120E-02, ...
                -4.4319E-08, 2.6738E-02,-1.3382E-09, ...
                -7.7713E-03,-2.1625E-08, 6.7646E-03, ...
                 2.9648E-08,-4.9498E-03,-6.9172E-09, ...
                 1.8036E-02, 8.0627E-09, 1.6950E-03, ...
                -8.2902E-11, 2.3367E-04, 1.2521E-02, ...
                -2.9426E-08,-1.0396E-02, 8.0042E-10, ...
                 3.0297E-03, 2.7689E-10,-9.5301E-04, ...
                -2.3612E-02,-7.9111E-10,-7.6654E-03, ...
                 2.9311E-10,-2.8914E-04, 8.3715E-11, ...
                -7.8202E-02, 6.6501E-09, 3.8289E-03, ...
                 4.0403E-09, 1.6187E-03,-5.7231E-10, ...
                 6.4240E-02,-3.3474E-09,-1.3766E-03, ...
                -5.7988E-10, 6.2600E-04, 3.8725E-03, ...
                 1.5940E-08,-5.3759E-03,-2.1427E-09, ...
                -8.9545E-04, 3.5896E-02,-4.3521E-09, ...
                 2.9789E-03, 1.0916E-09, 7.4931E-02, ...
                -4.2211E-09,-8.2421E-03, 1.4316E-09, ...
                -2.6314E-02,-4.4286E-10,-3.5706E-03, ...
                 6.3435E-02,-2.5381E-09,-2.2050E-03, ...
                -6.6893E-02, 1.6210E-09, 4.0881E-02, ...
                -5.1892E-09, 9.0158E-03, 2.3495E-02];
    %     2000km June solstice
    dat{5,2} = [ 2.4223E+00,-1.6581E-01, 2.0883E-01, ...
                -8.0645E-02,-3.9722E-02, 1.5954E-02, ...
                 3.0088E-02,-9.6053E-03, 7.4229E-03, ...
                 1.4053E-01, 7.9878E-03, 4.2976E-02, ...
                -2.6882E-02,-1.1069E-02,-5.6813E-03, ...
                 3.1338E-03,-7.3863E-03,-9.6881E-03, ...
                -4.0146E-02, 1.3978E-02,-1.6224E-02, ...
                 9.3162E-03,-1.0888E-02,-1.4472E-02, ...
                -5.4611E-03,-5.0694E-02, 5.5719E-02, ...
                 6.4098E-03, 2.0679E-03,-3.4277E-03, ...
                 2.9826E-03, 2.2637E-03, 4.8907E-02, ...
                 8.6854E-03, 6.6625E-03, 3.3814E-03, ...
                 7.7458E-04, 2.9699E-03,-6.9636E-04, ...
                -9.5779E-03, 1.6612E-03, 1.3018E-02, ...
                -5.0237E-03,-1.6025E-03, 1.3429E-03, ...
                 2.9054E-02, 7.2855E-03,-1.3993E-02, ...
                -5.2888E-03,-2.7511E-05, 2.6011E-04, ...
                 1.5534E-02,-1.6128E-02, 6.3239E-03, ...
                -3.7710E-03, 7.4519E-04,-5.6335E-02, ...
                 1.4123E-02, 7.2038E-03,-8.2835E-04, ...
                -3.9963E-04, 2.0466E-02, 1.4346E-02, ...
                -3.4267E-03, 5.6522E-04,-6.6495E-02, ...
                -6.4634E-04, 4.2662E-04, 1.3420E-03, ...
                 2.0465E-02, 6.0863E-04, 4.9604E-04, ...
                -2.2755E-02,-7.0387E-03, 1.3109E-03, ...
                 3.6849E-02, 2.2601E-03, 2.2893E-02, ...
                -1.1385E-02, 4.4417E-02,-6.5754E-03];
    DERRTE = zeros(NI,NJ,NK);
    for I=1:NI
      for J=1:NJ-1
        for K=1:NK
          DERRTE(I,J,K) = dat{I,J}(K);
        end
      end
    end
  end
  DOUT = DERRTE;
  for K=1:NK
    for I=1:NI
      DOUT(I,NJ,K)=DERRTE(I,NJ-1,K)*MIRREQ(K);
    end
  end

end

