Changeset 121 for trunk/SRC/Grid/ncdf_meshread.pro
- Timestamp:
- 06/29/06 16:59:33 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Grid/ncdf_meshread.pro
r118 r121 10 10 ; @examples 11 11 ; IDL> ncdf_meshread [,' filename'] 12 ; 13 ; @param filename {in}{optional} the name of the meshmask file to read. Default is 14 ; meshmask.nc. if this name does not contain any / and if 12 ; 13 ; @param filename {in}{optional}{default=meshmask.nc} 14 ; the name of the meshmask file to read. 15 ; if this name does not contain any "/" and if 15 16 ; iodirectory keyword is not specify, then the common variable 16 17 ; iodir will be use to define the mesh file path. 17 18 ; 18 ; @keyword GLAMBOUNDARY a 2 elements vector, {lon1,lon2], the longitute19 ; @keyword GLAMBOUNDARY a 2 elements vector, [lon1,lon2], the longitude 19 20 ; boundaries that should be used to visualize the data. 20 21 ; lon2 > lon1 … … 37 38 ; computed by using the first line of glamt. 38 39 ; 39 ; @keyword SHIFT 40 ; de bault, key_shift is automaticaly computed according to the40 ; @keyword SHIFT to force the manual definition of key_shift. By 41 ; default, key_shift is automaticaly computed according to the 41 42 ; glamboundary (when defined) by using the first line of glamt. if 42 ; key_periodic=0 then in any case key_shift = 0. 43 ; key_periodic=0 then in any case key_shift = 0. 43 44 ; 44 45 ; @keyword STRCALLING a string containing the calling command used to call 45 46 ; computegrid (this is used by xxx.pro) 46 47 ; 47 ; @keyword STRIDE a 3 elements vector to specify the stride in x, y, z48 ; direction. Default definition is key_stride. The resulting value49 ; will be stored in the common (cm_4mesh) variable key_stride50 ; 48 ; @keyword STRIDE {default=key_stride} 49 ; a 3 elements vector to specify the stride in x, y, z direction. 50 ; The resulting value will be stored in the common (cm_4mesh) variable 51 ; key_stride 51 52 ; 52 53 ; @keyword _EXTRA used to pass your keywords to the created function. 53 54 ; 54 ;55 55 ; @uses cm_4mesh cm_4data cm_4cal 56 56 ; 57 ; @restrictions define and/or use common variables from 57 ; @restrictions define and/or use common variables from 58 58 ; cm_4mesh, cm_4data, cm_4cal 59 59 ; … … 62 62 ; ixminmesh,ixmaxmesh,iyminmesh,iymaxmesh,izminmesh,izmaxmesh must 63 63 ; be defined febore calling ncdf_meshread. if some of those value 64 ; are equal to -1 they will be automatically defined 64 ; are equal to -1 they will be automatically defined 65 65 ; 66 66 ; @history Sebastien Masson (smasson\@lodyc.jussieu.fr) … … 70 70 ; of key_shift, ...) 71 71 ; Oct. 2004, Sebastien Masson: add PERIODIC and SHIFT 72 ; Aug. 2005, Sebastien Masson: some cleaning + english 72 ; Aug. 2005, Sebastien Masson: some cleaning + english 73 73 ; 74 74 ; @version $Id$ … … 100 100 print, ' The keyword CHECKDAT has been suppressed (it could create bugs).' 101 101 print, ' Remove it from the call of ncdf_meshread' 102 print, ' Please use smallmeshmask.pro or micromeshmask.pro to create a' 102 print, ' Please use smallmeshmask.pro or micromeshmask.pro to create a' 103 103 print, ' meshmask that has manageable size' 104 104 return … … 107 107 ; find meshfile name and open it! 108 108 ;------------------------------------------------------- 109 ; def de filename par defaut109 ; def of filename by default 110 110 IF n_params() EQ 0 then filename = 'meshmask.nc' 111 111 meshname = isafile(file = filename, iodirectory = iodir, _EXTRA = ex) … … 123 123 ncdf_diminq, cdfid, 'y', name, jpjglo 124 124 listdims = strlowcase(ncdf_listdims(cdfid)) 125 IF (where(listdims EQ 'z'))[0] NE -1 THEN ncdf_diminq, cdfid, 'z', name, jpkglo ELSE BEGIN 125 IF (where(listdims EQ 'z'))[0] NE -1 THEN ncdf_diminq, cdfid, 'z', name, jpkglo ELSE BEGIN 126 126 dimid = (where(strmid(listdims, 0, 5) EQ 'depth'))[0] 127 IF dimid NE -1 THEN ncdf_diminq, cdfid, dimid, name, jpkglo ELSE BEGIN 127 IF dimid NE -1 THEN ncdf_diminq, cdfid, dimid, name, jpkglo ELSE BEGIN 128 128 dummy = report('We could not find the vertical dimension..., its name must be z or start with depth') 129 129 stop 130 ENDELSE 131 ENDELSE 130 ENDELSE 131 ENDELSE 132 132 ; 133 133 if keyword_set(getdimensions) then begin … … 159 159 ;------------------------------------------------------- 160 160 IF n_elements(onearth) EQ 0 THEN key_onearth = 1 $ 161 ELSE key_onearth = keyword_set(onearth) 161 ELSE key_onearth = keyword_set(onearth) 162 162 IF NOT key_onearth THEN BEGIN 163 163 periodic = 0 … … 207 207 bigger = where(xaxis GE glamboundary[1]) 208 208 if bigger[0] NE -1 then xaxis[bigger] = xaxis[bigger]-360 209 ; 209 ; 210 210 key_shift = (where(xaxis EQ min(xaxis)))[0] 211 IF key_shift NE 0 THEN BEGIN 211 IF key_shift NE 0 THEN BEGIN 212 212 key_shift = jpi-key_shift 213 213 xaxis = shift(xaxis, key_shift) … … 219 219 widget_control, noticebase, bad_id = nothing, /destroy 220 220 return 221 ENDIF 221 ENDIF 222 222 ; 223 223 ENDIF ELSE key_shift = 0 … … 286 286 ; for compatibility with old versions of meshmask/partial steps 287 287 IF (where(allvarname EQ 'e3tp'))[0] NE -1 THEN $ 288 namevar = [namevar, 'e3tp', 'e3wp'] ELSE BEGIN 288 namevar = [namevar, 'e3tp', 'e3wp'] ELSE BEGIN 289 289 e3t_ps = -1 290 290 e3w_ps = -1 291 291 ENDELSE 292 292 IF (where(allvarname EQ 'e3t_ps'))[0] NE -1 $ 293 THEN namevar = [namevar, 'e3t_ps', 'e3w_ps' ]ELSE BEGIN 293 THEN namevar = [namevar, 'e3t_ps', 'e3w_ps' ]ELSE BEGIN 294 294 e3t_ps = -1 295 295 e3w_ps = -1 296 296 ENDELSE 297 297 IF (where(allvarname EQ 'e3u_ps'))[0] NE -1 $ 298 THEN namevar = [namevar, 'e3u_ps', 'e3v_ps'] ELSE BEGIN 298 THEN namevar = [namevar, 'e3u_ps', 'e3v_ps'] ELSE BEGIN 299 299 e3u_ps = -1 300 300 e3v_ps = -1 … … 307 307 name = varcontient.name 308 308 @read_ncdf_varget 309 command e= namevar[i]+'=float(res)'310 rien = execute(commande)309 command = namevar[i]+'=float(res)' 310 nothing = execute(command) 311 311 ENDFOR 312 312 ; for compatibility with old versions of meshmask/partial steps … … 314 314 IF n_elements(e3tp) NE 0 THEN e3t_ps = temporary(e3tp) 315 315 IF n_elements(e3wp) NE 0 THEN e3w_ps = temporary(e3wp) 316 ; in the kase of key_stride ne [1, 1, 1] redefine f points316 ; in the case of key_stride ne [1, 1, 1] redefine f points 317 317 ; coordinates: they must be in the middle of 3 T points 318 318 if key_stride[0] NE 1 OR key_stride[1] NE 1 then BEGIN 319 319 ; we must recompute glamf and gphif... 320 IF jpi GT 1 THEN BEGIN 320 IF jpi GT 1 THEN BEGIN 321 321 if (keyword_set(key_onearth) AND keyword_set(xnotsorted)) $ 322 322 OR (keyword_set(key_periodic) AND key_irregular) then BEGIN … … 333 333 ELSE stepxf[jpi-1, *] = stepxf[jpi-2, *] 334 334 ENDELSE 335 IF jpj GT 1 THEN BEGIN 335 IF jpj GT 1 THEN BEGIN 336 336 stepxf[*, jpj-1] = stepxf[*, jpj-2] 337 337 stepxf[jpi-1, jpj-1] = stepxf[jpi-2, jpj-2] … … 339 339 glamf = glamt + 0.5 * stepxf 340 340 ENDIF ELSE glamf = glamt + 0.5 341 IF jpj GT 1 THEN BEGIN 341 IF jpj GT 1 THEN BEGIN 342 342 ; we must compute stepyf: y distance between T(i,j) T(i+1,j+1) 343 343 stepyf = shift(gphit, -1, -1) - gphit … … 347 347 stepyf[jpi-1, *] = stepyf[jpi-2, *] 348 348 stepyf[jpi-1, jpj-1] = stepyf[jpi-2, jpj-2] 349 ENDIF 349 ENDIF 350 350 gphif = gphit + 0.5 * stepyf 351 351 ENDIF ELSE gphif = gphit + 0.5 … … 370 370 ; the mask is stored as the bit values of the byte array (along the y 371 371 ; dimension, see micromeshmask.pro)... 372 ; we must modify several parameters... 372 ; we must modify several parameters... 373 373 iyminmesh = 0L 374 374 firsty = yyy1/8 … … 386 386 zzz = transpose(temporary(zzz)) 387 387 zzz = zzz[*, yyy1 MOD 8: 8*ny - 8 + yyy2 MOD 8] 388 IF key_stridetrue[1] NE 1 THEN BEGIN 388 IF key_stridetrue[1] NE 1 THEN BEGIN 389 389 ; IF float(strmid(!version.release,0,3)) LT 5.6 THEN BEGIN 390 390 nnny = (size(zzz))[2] … … 478 478 CASE n_elements(varcontient.dim) OF 479 479 4:BEGIN 480 command e= 'ncdf_varget,cdfid,namevar[i],'+namevar[i] $480 command = 'ncdf_varget,cdfid,namevar[i],'+namevar[i] $ 481 481 +',offset = [0,0,izminmesh,0], count = [1,1,jpk,1]' 482 if key_stride[2] NE 1 then command e = commande+', stride=[1,1,key_stride[2],1]'483 END 482 if key_stride[2] NE 1 then command = command+', stride=[1,1,key_stride[2],1]' 483 END 484 484 2:BEGIN 485 command e= 'ncdf_varget,cdfid,namevar[i],'+namevar[i] $485 command = 'ncdf_varget,cdfid,namevar[i],'+namevar[i] $ 486 486 +',offset = [izminmesh,0], count = [jpk,1]' 487 if key_stride[2] NE 1 then command e = commande+', stride=key_stride[2]'488 END 487 if key_stride[2] NE 1 then command = command+', stride=key_stride[2]' 488 END 489 489 1:BEGIN 490 command e= 'ncdf_varget,cdfid,namevar[i],'+namevar[i] $490 command = 'ncdf_varget,cdfid,namevar[i],'+namevar[i] $ 491 491 +',offset = [izminmesh], count = [jpk]' 492 if key_stride[2] NE 1 then command e = commande+', stride=key_stride[2]'492 if key_stride[2] NE 1 then command = command+', stride=key_stride[2]' 493 493 END 494 494 ENDCASE 495 rien = execute(commande)496 command e= namevar[i]+'=float('+namevar[i]+')'497 rien = execute(commande)498 command e= 'if size('+namevar[i]+', /n_dimension) gt 0 then '+namevar[i]+' = reform('+namevar[i]+', /over)'499 rien = execute(commande)495 nothing = execute(command) 496 command = namevar[i]+'=float('+namevar[i]+')' 497 nothing = execute(command) 498 command = 'if size('+namevar[i]+', /n_dimension) gt 0 then '+namevar[i]+' = reform('+namevar[i]+', /over)' 499 nothing = execute(command) 500 500 ENDFOR 501 501 ;------------------------------------------------------- … … 535 535 ; make sure we do have 2d arrays when jpj eq 1 536 536 ;------------------------------------------------------- 537 IF jpj EQ 1 THEN BEGIN 537 IF jpj EQ 1 THEN BEGIN 538 538 glamt = reform(glamt, jpi, jpj, /over) 539 539 gphit = reform(gphit, jpi, jpj, /over) … … 557 557 e3t_ps = reform(e3t_ps, jpi, jpj, /over) 558 558 e3w_ps = reform(e3w_ps, jpi, jpj, /over) 559 ENDIF 559 ENDIF 560 560 ENDIF 561 561 ;------------------------------------------------------- … … 574 574 ;==================================================== 575 575 ; 576 IF NOT keyword_set(strcalling) THEN BEGIN 576 IF NOT keyword_set(strcalling) THEN BEGIN 577 577 IF n_elements(ccmeshparameters) EQ 0 THEN strcalling = 'ncdf_meshread' $ 578 578 ELSE strcalling = ccmeshparameters.filename 579 ENDIF 579 ENDIF 580 580 IF n_elements(glamt) GE 2 THEN BEGIN 581 581 glaminfo = moment(glamt) … … 583 583 gphiinfo = moment(gphit) 584 584 IF finite(gphiinfo[2]) EQ 0 THEN gphiinfo = gphiinfo[0:1] 585 ENDIF ELSE BEGIN 585 ENDIF ELSE BEGIN 586 586 glaminfo = glamt 587 587 gphiinfo = gphit 588 ENDELSE 588 ENDELSE 589 589 ccmeshparameters = {filename:strcalling $ 590 590 , glaminfo:float(string(glaminfo, format = '(E11.4)')) $ … … 601 601 ; 602 602 if keyword_set(key_performance) THEN $ 603 print, 'time ncdf_meshread', systime(1)-tempsun 603 print, 'time ncdf_meshread', systime(1)-tempsun 604 604 605 605 ;-------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.