Changeset 282


Ignore:
Timestamp:
09/12/07 17:43:11 (17 years ago)
Author:
smasson
Message:

use of double precision to avoid rounding errors

Location:
trunk/SRC/Interpolation
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/SRC/Interpolation/compute_fromirr_bilinear_weigaddr.pro

    r271 r282  
    216216                                    , newcoord[0, 2], newcoord[1, 2] $ 
    217217                                    , newcoord[0, 1], newcoord[1, 1] $ 
    218                                     , newcoord[0, 4], newcoord[1, 4]) 
     218                                    , newcoord[0, 4], newcoord[1, 4], /double) 
    219219        ENDIF ELSE BEGIN 
    220220          xy = quadrilateral2square(xcell[0, ind], ycell[0, ind] $ 
    221221                                    , xcell[1, ind], ycell[1, ind] $ 
    222222                                    , xcell[2, ind], ycell[2, ind] $ 
    223                                     , xcell[3, ind], ycell[3, ind], xx, yy) 
     223                                    , xcell[3, ind], ycell[3, ind], xx, yy, /double) 
    224224        ENDELSE 
    225225; take care of rounding errors... 
    226         zero = where(abs(xy) LT 1e-4) 
    227         IF zero[0] NE -1 THEN xy[zero] = 0 
    228         one = where(abs(1-xy) LT 1e-4) 
    229         IF one[0] NE -1 THEN xy[one] = 1 
     226        zero = where(abs(xy) LT 1e-6) 
     227        IF zero[0] NE -1 THEN xy[zero] = 0.d 
     228        one = where(abs(1.d - xy) LT 1e-6) 
     229        IF one[0] NE -1 THEN xy[one] = 1.d 
    230230; some checks... 
    231231        tmpmsk = omsk[celladdr[*, ind]] 
     
    249249          END 
    250250        ENDCASE 
    251  
    252  
    253  
    254251      ENDIF ELSE foraddr[n] = -1 
    255252    ENDIF ELSE foraddr[n] = -1 
     
    289286; mask the weight to suppress the corner located on land 
    290287  newaweig = newaweig*((omsk)[newaaddr]) 
    291   totalweig = total(newaweig, 1) 
    292288; for cell with some land corner, 
    293 ; we have to redistribute the weight on the reaining water corners 
     289; we have to redistribute the weight on the remaining water corners 
    294290; weights normalization 
    295   totalweig = total(newaweig, 1) 
    296   IF min(totalweig, max = ma) EQ 0 then stop 
    297   IF ma GT 1 then stop 
    298   newaweig = newaweig/(replicate(1., 4)#totalweig) 
    299   totalweig = total(newaweig, 1) 
    300  
     291  totalweig = total(newaweig, 1, /double) 
     292  IF abs(min(totalweig, max = ma)) LT 1.e-6 then stop 
     293  IF abs(1.d - ma) GT 1.e-6 then stop 
     294  newaweig = newaweig/(replicate(1.d, 4)#totalweig) 
    301295; weights 
    302296  weig = dblarr(4, jpia*jpja) 
  • trunk/SRC/Interpolation/compute_fromreg_bilinear_weigaddr.pro

    r238 r282  
    217217  ENDIF 
    218218; check totalweight = 1 
    219   totalweig = abs(1-total(weig, 1)) 
     219  totalweig = abs(1.d - total(weig, 1, /double)) 
    220220  IF (where(temporary(totalweig) GE 1.e-5))[0] NE -1 THEN stop 
    221221; 
  • trunk/SRC/Interpolation/compute_fromreg_imoms3_weigaddr.pro

    r262 r282  
    284284  weig[15, short] = wx3 * wy3 
    285285; 
    286   mi = min(total(weig[*, short], 1), max = ma) 
     286  mi = min(total(weig[*, short], 1, /double), max = ma) 
    287287  IF abs(mi-1) GE 1.e-6 THEN stop 
    288288  IF abs(ma-1) GE 1.e-6 THEN stop 
     
    385385    weig[7, short] = wx3 * wy2 
    386386; 
    387     mi = min(total(weig[*, short], 1), max = ma) 
     387    mi = min(total(weig[*, short], 1, /double), max = ma) 
    388388    IF abs(mi-1) GE 1.e-6 THEN stop 
    389389    IF abs(ma-1) GE 1.e-6 THEN stop 
     
    451451    weig[3, short] = wx3 
    452452; 
    453     mi = min(total(weig[*, short], 1), max = ma) 
     453    mi = min(total(weig[*, short], 1, /double), max = ma) 
    454454    IF abs(mi-1) GE 1.e-6 THEN stop 
    455455    IF abs(ma-1) GE 1.e-6 THEN stop 
     
    517517    weig[3, short] = wx3 
    518518; 
    519     mi = min(total(weig[*, short], 1), max = ma) 
     519    mi = min(total(weig[*, short], 1, /double), max = ma) 
    520520    IF abs(mi-1) GE 1.e-6 THEN stop 
    521521    IF abs(ma-1) GE 1.e-6 THEN stop 
  • trunk/SRC/Interpolation/quadrilateral2square.pro

    r242 r282  
    3838; Can be scalar or array. 
    3939; 
    40 ; @keyword PERF 
     40; @keyword PERF {type=salar 0 or 1}{default=0} 
     41; activate to print the elapsed time spent within quadrilateral2square 
     42; 
     43; @keyword DOUBLE {type=salar 0 or 1}{default=0} 
     44; activate to perform double precision computation 
    4145; 
    4246; @returns 
     
    7579;- 
    7680; 
    77 FUNCTION quadrilateral2square, x0in, y0in, x1in, y1in, x2in, y2in, x3in, y3in, xxin, yyin, PERF = perf 
     81FUNCTION quadrilateral2square, x0in, y0in, x1in, y1in, x2in, y2in, x3in, y3in, xxin, yyin, PERF = perf, DOUBLE = double 
    7882; 
    7983  compile_opt idl2, strictarrsubs 
     
    111115; get the matrix A 
    112116; 
    113   a = square2quadrilateral(x0in, y0in, x1in, y1in, x2in, y2in, x3in, y3in) 
     117  a = square2quadrilateral(x0in, y0in, x1in, y1in, x2in, y2in, x3in, y3in, DOUBLE = double) 
    114118; 
    115119; compute the adjoint matrix 
  • trunk/SRC/Interpolation/square2quadrilateral.pro

    r242 r282  
    2929; 
    3030; @param xxin {in}{optional} 
     31; first coordinates of the point(s) for which we want to do the mapping. 
    3132; @param yyin {in}{optional} 
    32 ; the coordinates of the point(s) for which we want to do the mapping. 
     33; second coordinates of the point(s) for which we want to do the mapping. 
     34; 
     35; @keyword DOUBLE {type=salar 0 or 1}{default=0} 
     36; activate to perform double precision computation 
    3337; 
    3438; @returns 
     
    6771;- 
    6872; 
    69 FUNCTION square2quadrilateral, x0in, y0in, x1in, y1in, x2in, y2in, x3in, y3in, xxin, yyin 
     73FUNCTION square2quadrilateral, x0in, y0in, x1in, y1in, x2in, y2in, x3in, y3in, xxin, yyin, DOUBLE = double 
    7074; 
    7175; Warning, wrong definition of (x2,y2) and (x3,y3) at the bottom of 
Note: See TracChangeset for help on using the changeset viewer.