Ignore:
Timestamp:
07/02/09 10:38:54 (15 years ago)
Author:
smasson
Message:

wrong bugfix in previous changeset:398

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SRC/Grid/computegrid.pro

    r371 r399  
    353353;==================================================== 
    354354; 
    355   jpiglo = long(nx) 
    356   jpjglo = long(ny) 
    357   jpkglo = long(nz) 
    358   IF keyword_set(romsh) THEN BEGIN 
    359     jpiglo = jpiglo - 1 
    360     jpjglo = jpjglo - 1 
    361     fullcgrid = 1 
    362   ENDIF 
     355  IF keyword_set(romsh) THEN fullcgrid = 1 
     356  CASE 1 OF 
     357    keyword_set(fbase2tbase):key_gridtype = 'c_f' 
     358    keyword_set(ubase2tbase):key_gridtype = 'c_u' 
     359    keyword_set(vbase2tbase):key_gridtype = 'c_v' 
     360    else:key_gridtype = 'c' 
     361  ENDCASE 
     362  IF strlen(key_gridtype) EQ 3 THEN fullcgrid = 1 
     363; 
     364  IF n_elements(xminmesh) NE 0 AND n_elements(xmaxmesh) NE 0 THEN BEGIN 
     365    IF nx EQ jpi AND xminmesh EQ ixminmesh AND xmaxmesh EQ ixmaxmesh THEN xalreadycut = 1 
     366  ENDIF 
     367  IF keyword_set(xalreadycut) THEN BEGIN 
     368    xmin = 0  
     369    xmax = jpi - 1  
     370    nxx = jpi 
     371  ENDIF ELSE BEGIN 
     372    jpiglo = long(nx) 
     373    IF keyword_set(romsh) THEN jpiglo = jpiglo - 1     
     374    IF n_elements(xminmesh) NE 0 THEN ixminmesh = long(xminmesh[0]) ELSE ixminmesh  = 0l 
     375    IF n_elements(xmaxmesh) NE 0 THEN ixmaxmesh = long(xmaxmesh[0]) ELSE ixmaxmesh  = jpiglo-1 
     376    IF ixmaxmesh LT 0 THEN ixmaxmesh = jpiglo -1 + ixmaxmesh 
     377    ixmaxmesh = 0 > ixmaxmesh < (jpiglo-1) 
     378    ixminmesh = 0 > ixminmesh < ixmaxmesh 
     379    jpi = ixmaxmesh-ixminmesh+1 
     380    xmin = ixminmesh  
     381    xmax = ixmaxmesh 
     382    nxx = jpiglo 
     383  ENDELSE 
     384 
     385  IF n_elements(yminmesh) NE 0 AND n_elements(ymaxmesh) NE 0 THEN BEGIN 
     386    IF ny EQ jpj AND yminmesh EQ iyminmesh AND ymaxmesh EQ iymaxmesh THEN yalreadycut = 1 
     387  ENDIF 
     388  IF keyword_set(yalreadycut) THEN BEGIN 
     389    ymin = 0  
     390    ymax = jpj - 1  
     391    nyy = jpj 
     392  ENDIF ELSE BEGIN  
     393    jpjglo = long(ny) 
     394    IF keyword_set(romsh) THEN jpjglo = jpjglo - 1 
     395    IF n_elements(yminmesh) NE 0 THEN iyminmesh = long(yminmesh[0]) ELSE iyminmesh  = 0l 
     396    IF n_elements(ymaxmesh) NE 0 THEN iymaxmesh = long(ymaxmesh[0]) ELSE iymaxmesh  = jpjglo-1 
     397    IF key_gridtype EQ 'c_v' OR key_gridtype EQ 'c_f' THEN iymaxmesh = iymaxmesh-1 
     398    IF iymaxmesh LT 0 THEN iymaxmesh = jpjglo -1 + iymaxmesh 
     399    iymaxmesh = 0 > iymaxmesh < (jpjglo-1) 
     400    iyminmesh = 0 > iyminmesh < iymaxmesh 
     401    jpj = iymaxmesh-iyminmesh+1 
     402    ymin = iyminmesh  
     403    ymax = iymaxmesh 
     404    nyy = jpjglo 
     405  ENDELSE 
     406 
     407  IF n_elements(zminmesh) NE 0 AND n_elements(zmaxmesh) NE 0 THEN BEGIN 
     408    IF nz EQ jpk AND zminmesh EQ izminmesh AND zmaxmesh EQ izmaxmesh THEN zalreadycut = 1 
     409  ENDIF 
     410  IF keyword_set(zalreadycut) THEN BEGIN 
     411    zmin = 0  
     412    zmax = jpk - 1  
     413    nzz = jpk 
     414  ENDIF ELSE BEGIN  
     415   jpkglo = long(nz) 
     416    IF n_elements(zminmesh) NE 0 THEN izminmesh = long(zminmesh[0]) ELSE izminmesh  = 0l 
     417    IF n_elements(zmaxmesh) NE 0 THEN izmaxmesh = long(zmaxmesh[0]) ELSE izmaxmesh  = jpkglo-1 
     418    IF izmaxmesh LT 0 THEN izmaxmesh = jpkglo -1 + izmaxmesh 
     419    izmaxmesh = 0 > izmaxmesh < (jpkglo-1) 
     420    izminmesh = 0 > izminmesh < izmaxmesh 
     421    jpk = izmaxmesh-izminmesh+1 
     422    zmin = izminmesh  
     423    zmax = izmaxmesh 
     424    nzz = jpkglo 
     425  ENDELSE 
    363426; 
    364427; impact of plain keyword: 
     
    372435  ENDIF 
    373436; 
    374   IF n_elements(xminmesh) NE 0 THEN ixminmesh = long(xminmesh[0]) ELSE ixminmesh  = 0l 
    375   IF n_elements(xmaxmesh) NE 0 THEN ixmaxmesh = long(xmaxmesh[0]) ELSE ixmaxmesh  = jpiglo-1 
    376   IF n_elements(yminmesh) NE 0 THEN iyminmesh = long(yminmesh[0]) ELSE iyminmesh  = 0l 
    377   IF n_elements(ymaxmesh) NE 0 THEN iymaxmesh = long(ymaxmesh[0]) ELSE iymaxmesh  = jpjglo-1 
    378   IF n_elements(zminmesh) NE 0 THEN izminmesh = long(zminmesh[0]) ELSE izminmesh  = 0l 
    379   IF n_elements(zmaxmesh) NE 0 THEN izmaxmesh = long(zmaxmesh[0]) ELSE izmaxmesh  = jpkglo-1 
    380 ; 
    381   CASE 1 OF 
    382     keyword_set(fbase2tbase):key_gridtype = 'c_f' 
    383     keyword_set(ubase2tbase):key_gridtype = 'c_u' 
    384     keyword_set(vbase2tbase):key_gridtype = 'c_v' 
    385     else:key_gridtype = 'c' 
    386   ENDCASE 
    387   IF key_gridtype EQ 'c_v' OR key_gridtype EQ 'c_f' THEN BEGIN 
    388     iymaxmesh = iymaxmesh-1 
    389   ENDIF 
    390   IF strlen(key_gridtype) EQ 3 THEN fullcgrid = 1 
    391 ; 
    392   IF ixmaxmesh LT 0 THEN ixmaxmesh = jpiglo -1 + ixmaxmesh 
    393   IF iymaxmesh LT 0 THEN iymaxmesh = jpjglo -1 + iymaxmesh 
    394   IF izmaxmesh LT 0 THEN izmaxmesh = jpkglo -1 + izmaxmesh 
    395437; avoid basics errors... 
    396   ixmaxmesh = 0 > ixmaxmesh < (jpiglo-1) 
    397   ixminmesh = 0 > ixminmesh < ixmaxmesh 
    398   iymaxmesh = 0 > iymaxmesh < (jpjglo-1) 
    399   iyminmesh = 0 > iyminmesh < iymaxmesh 
    400   izmaxmesh = 0 > izmaxmesh < (jpkglo-1) 
    401   izminmesh = 0 > izminmesh < izmaxmesh 
    402 ; 
    403   jpi = ixmaxmesh-ixminmesh+1 
    404   jpj = iymaxmesh-iyminmesh+1 
    405   jpk = izmaxmesh-izminmesh+1 
    406438; 
    407439  jpidta = jpiglo 
     
    468500; force glamt to have 2 dimensions 
    469501; 
    470   CASE size(reform(glamt), /n_dimensions) OF 
    471     0:glamt = replicate(glamt, jpi, jpj) 
    472     1:glamt = glamt[ixminmesh:ixmaxmesh]#replicate(1, jpj) 
    473     2:glamt = glamt[ixminmesh:ixmaxmesh, iyminmesh:iymaxmesh] 
     502  IF n_elements(glamt) EQ nxx*nyy THEN glamt = reform(glamt, nxx, nyy, /over) $ 
     503  ELSE glamt = reform(glamt, nxx, /over) 
     504  CASE size(glamt, /n_dimensions) OF 
     505    1:BEGIN  
     506      IF n_elements(glamt) EQ 1 THEN glamt = replicate(glamt[0], jpi, jpj) $ 
     507      ELSE glamt = glamt[xmin:xmax]#replicate(1, jpj) 
     508    END 
     509    2:glamt = glamt[xmin:xmax, ymin:ymax] 
    474510  ENDCASE 
    475511; keep 2d array even with degenerated dimension 
     
    498534; force gphit to have 2 dimensions 
    499535; 
    500   CASE size(reform(gphit), /n_dimensions) OF 
    501     0:gphit = replicate(gphit, jpi, jpj) 
    502     1:gphit = replicate(1, jpi)#gphit[iyminmesh:iymaxmesh] 
    503     2:gphit = gphit[ixminmesh:ixmaxmesh, iyminmesh:iymaxmesh] 
     536  IF n_elements(gphit) EQ nxx*nyy THEN gphit = reform(gphit, nxx, nyy, /over) $ 
     537  ELSE gphit = reform(gphit, nyy, /over) 
     538  CASE size(gphit, /n_dimensions) OF 
     539    1:BEGIN  
     540      IF n_elements(gphit) EQ 1 THEN gphit = replicate(gphit[0], jpi, jpj) $ 
     541      ELSE gphit = replicate(1, jpi)#gphit[ymin:ymax] 
     542    END 
     543    2:gphit = gphit[xmin:xmax, ymin:ymax] 
    504544  ENDCASE 
    505545; keep 2d array even with degenerated dimension 
     
    9901030      END 
    9911031      ELSE:BEGIN 
    992         gdept = zaxis[izminmesh:izmaxmesh] 
     1032        gdept = zaxis[zmin:zmax] 
    9931033        IF n_elements(zreverse) EQ 0 THEN BEGIN 
    9941034          IF jpk GT 1 THEN BEGIN 
     
    10281068; 
    10291069  if tmask[0] NE -1 then BEGIN 
     1070    tmask = byte(temporary(tmask)) 
    10301071    IF keyword_set(romsh) THEN tmask = tmask[0:jpiglo-1, 0:jpjglo-1] 
    1031     IF n_elements(mask) EQ jpiglo*jpjglo AND jpkglo GT 1 THEN BEGIN 
    1032       tmask = tmask[*]#replicate(1, jpkglo) 
    1033       tmask = reform(tmask, jpiglo, jpjglo, jpkglo, /overwrite) 
     1072    IF n_elements(mask) EQ nxx*nyy AND nzz GT 1 THEN BEGIN 
     1073      tmask = tmask[*]#replicate(1b, nzz) 
     1074      tmask = reform(tmask, nxx, nyy, nzz, /overwrite) 
    10341075    ENDIF 
    1035     IF jpiglo EQ 1 OR jpjglo EQ 1 THEN tmask = reform(tmask, jpiglo, jpjglo, jpkglo, /overwrite) 
    1036     tmask = byte(tmask[ixminmesh:ixmaxmesh, iyminmesh:iymaxmesh, izminmesh:izmaxmesh]) 
    1037     tmask = reform(tmask, jpi, jpj, jpk, /over) 
     1076    IF nxx EQ 1 OR nyy EQ 1 OR nzz EQ 1 THEN tmask = reform(tmask, nxx, nyy, nzz, /overwrite) 
     1077    tmask = tmask[xmin:xmax, ymin:ymax, zmin:zmax] 
     1078    IF jpi EQ 1 OR jpj EQ 1 OR jpk EQ 1 THEN tmask = reform(tmask, jpi, jpj, jpk, /over) 
    10381079    if key_shift NE 0 then tmask = shift(tmask, key_shift, 0, 0) 
    10391080; because tmask = reverse(tmask, 2) is not working if the 3rd 
     
    12421283  ENDELSE 
    12431284  IF keyword_set(romsh) THEN $ 
    1244      romszinfos = {h:romsh[ixminmesh:ixmaxmesh, iyminmesh:iymaxmesh], zeta:replicate(0., jpi, jpj), theta_s:-1, theta_b:-1, hc:-1} $ 
     1285     romszinfos = {h:romsh[xmin:xmax, ymin:ymax], zeta:replicate(0., jpi, jpj), theta_s:-1, theta_b:-1, hc:-1} $ 
    12451286  ELSE romszinfos = {h:-1, zeta:-1, theta_s:-1, theta_b:-1, hc:-1} 
    12461287 
Note: See TracChangeset for help on using the changeset viewer.