[172] | 1 | ;------------------------------------------------------------ |
---|
| 2 | ;------------------------------------------------------------ |
---|
| 3 | ;------------------------------------------------------------ |
---|
| 4 | ;+ |
---|
| 5 | ; |
---|
| 6 | ; @file_comments read NetCDF grid file created by ROMS |
---|
| 7 | ; |
---|
[226] | 8 | ; @categories |
---|
[172] | 9 | ; Grid |
---|
| 10 | ; |
---|
| 11 | ; @examples |
---|
| 12 | ; IDL> ncdf_meshroms [,' filename'] |
---|
| 13 | ; |
---|
| 14 | ; @param filename {in}{optional}{default='roms_grd.nc'}{type=scalar string} |
---|
| 15 | ; Name of the meshmask file to read. If this name does not contain any "/" |
---|
| 16 | ; and if iodirectory keyword is not specify, then the common variable |
---|
| 17 | ; iodir will be use to define the mesh file path. |
---|
| 18 | ; |
---|
| 19 | ; @keyword GLAMBOUNDARY {default=those defined in the file}{type=2 elements vector} |
---|
| 20 | ; Longitude boundaries that should be used to visualize the data. |
---|
| 21 | ; lon2 > lon1 |
---|
| 22 | ; lon2 - lon1 le 360 |
---|
| 23 | ; By default, the common (cm_4mesh) variable key_shift will be automatically |
---|
| 24 | ; defined according to GLAMBOUNDARY. |
---|
| 25 | ; |
---|
| 26 | ; @keyword ONEARTH {default=1}{type=scalar: 0 or 1} |
---|
| 27 | ; Force the manual definition of data localization on the earth or not |
---|
| 28 | ; 0) if the data are not on the earth |
---|
| 29 | ; 1) if the data are on earth (in that case we can for example use |
---|
| 30 | ; the labels 'longitude', 'latitude' in plots). |
---|
| 31 | ; The resulting value will be stored in the common (cm_4mesh) variable key_onearth |
---|
| 32 | ; ONEARTH = 0 forces PERIODIC = 0, SHIFT = 0 and is cancelling GLAMBOUNDARY |
---|
| 33 | ; |
---|
| 34 | ; @keyword GETDIMENSIONS {default=0}{type=scalar: 0 or 1} |
---|
| 35 | ; Activate this keywords if you only want to know the dimension |
---|
| 36 | ; of the domain stored in the mesh file. This dimensions will be |
---|
| 37 | ; defined in jpiglo, jpjglo, jpkglo (cm_4mesh common variables) |
---|
| 38 | ; |
---|
| 39 | ; @keyword PERIODIC {default=computed by using the first line of glamt}{type=scalar: 0 or 1} |
---|
| 40 | ; Force the manual definition of the grid zonal periodicity. |
---|
| 41 | ; The resulting value will be stored in the common (cm_4mesh) variable key_periodic |
---|
| 42 | ; PERIODIC = 0 forces SHIFT = 0 |
---|
| 43 | ; |
---|
| 44 | ; @keyword NRHO {default=1}{type=scalar} |
---|
| 45 | ; Specify the number of rho level that contain the data we want to explore. |
---|
[226] | 46 | ; This is mainly useful when using xxx to get access to the deeper levers and vertical sections. |
---|
[172] | 47 | ; |
---|
| 48 | ; @keyword SHIFT {default=computed according to glamboundary}{type=scalar} |
---|
[226] | 49 | ; Force the manual definition of the zonal shift that must be apply to the data. |
---|
[172] | 50 | ; The resulting value will be stored in the common (cm_4mesh) variable key_shift |
---|
| 51 | ; Note that if key_periodic=0 then in any case key_shift = 0. |
---|
| 52 | ; |
---|
| 53 | ; @keyword STRCALLING {type=scalar string} |
---|
| 54 | ; the calling command used to call computegrid (this is used by xxx.pro) |
---|
| 55 | ; |
---|
| 56 | ; @keyword STRIDE {default=[1, 1, 1]}{type=3 elements vector} |
---|
| 57 | ; Specify the stride in x, y and z direction. The resulting |
---|
| 58 | ; value will be stored in the common (cm_4mesh) variable key_stride |
---|
| 59 | ; |
---|
| 60 | ; @keyword _EXTRA used to pass isafile keywords |
---|
| 61 | ; |
---|
| 62 | ; @uses cm_4mesh cm_4data cm_4cal |
---|
| 63 | ; |
---|
| 64 | ; @restrictions |
---|
| 65 | ; |
---|
| 66 | ; ixminmesh,ixmaxmesh,iyminmesh,iymaxmesh,izminmesh,izmaxmesh must |
---|
| 67 | ; be defined before calling ncdf_meshread. if some of those value |
---|
| 68 | ; are equal to -1 they will be automatically defined |
---|
| 69 | ; |
---|
| 70 | ; In the original ROMS grid, if F grid has (jpi,jpj) points then T |
---|
| 71 | ; grid will have (jpi+1,jpj+1) points, U grid will have (jpi,jpj+1) |
---|
| 72 | ; points and V grid will have (jpi+1,jpj) points. |
---|
| 73 | ; By default C-grid used in this package needs the same number of |
---|
| 74 | ; points for T,U,V and F grid, with a T point at the bottom left |
---|
| 75 | ; corner of the grid. We therefore ignore the last column of T and |
---|
| 76 | ; V points and the last line of T and U points. |
---|
| 77 | ; |
---|
| 78 | ; Scale factors are compuited using the distance between the points |
---|
[226] | 79 | ; (which is not the exact definition for irregular grid). |
---|
[172] | 80 | ; |
---|
[226] | 81 | ; @history |
---|
| 82 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) September 2006 |
---|
[172] | 83 | ; |
---|
[226] | 84 | ; @version |
---|
| 85 | ; $Id$ |
---|
[172] | 86 | ; |
---|
| 87 | ;- |
---|
| 88 | ;------------------------------------------------------------ |
---|
| 89 | ;------------------------------------------------------------ |
---|
| 90 | ;------------------------------------------------------------ |
---|
| 91 | PRO ncdf_meshroms, filename, NRHO = nrho, GLAMBOUNDARY = glamboundary $ |
---|
| 92 | , ONEARTH = onearth, GETDIMENSIONS = getdimensions $ |
---|
| 93 | , PERIODIC = periodic, SHIFT = shift, STRIDE = stride $ |
---|
| 94 | , STRCALLING = strcalling, _EXTRA = ex |
---|
| 95 | ; |
---|
| 96 | ;--------------------------------------------------------- |
---|
| 97 | ; |
---|
| 98 | compile_opt idl2, strictarrsubs |
---|
| 99 | ; |
---|
| 100 | @cm_4mesh |
---|
| 101 | @cm_4data |
---|
| 102 | @cm_4cal |
---|
| 103 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
| 104 | @updatenew |
---|
| 105 | @updatekwd |
---|
| 106 | ENDIF |
---|
| 107 | ;--------------------------------------------------------- |
---|
| 108 | ; |
---|
| 109 | tempsun = systime(1) ; for key_performance |
---|
| 110 | ;------------------------------------------------------- |
---|
| 111 | ; find meshfile name and open it! |
---|
| 112 | ;------------------------------------------------------- |
---|
| 113 | ; def of filename by default |
---|
| 114 | IF n_params() EQ 0 then filename = 'roms_grd.nc' |
---|
| 115 | meshname = isafile(file = filename, iodirectory = iodir, _EXTRA = ex) |
---|
| 116 | meshname = meshname[0] |
---|
| 117 | ; |
---|
| 118 | noticebase = xnotice('Reading file !C '+meshname+'!C ...') |
---|
| 119 | ; if the meshmask is on tape archive ... get it back |
---|
| 120 | IF !version.OS_FAMILY EQ 'unix' THEN spawn, '\file '+meshname+' > /dev/null' |
---|
| 121 | cdfid = ncdf_open(meshname) |
---|
| 122 | contient = ncdf_inquire(cdfid) |
---|
| 123 | ;------------------------------------------------------------ |
---|
| 124 | ; dimensions |
---|
| 125 | ;------------------------------------------------------------ |
---|
| 126 | ncdf_diminq, cdfid, 'xi_rho', name, jpiglo |
---|
| 127 | ncdf_diminq, cdfid, 'eta_rho', name, jpjglo |
---|
| 128 | IF n_elements(nrho) NE 0 THEN jpkglo = long(nrho[0]) $ |
---|
| 129 | ELSE jpkglo = 1L |
---|
| 130 | ; |
---|
| 131 | if keyword_set(getdimensions) then begin |
---|
| 132 | widget_control, noticebase, bad_id = nothing, /destroy |
---|
| 133 | ncdf_close, cdfid |
---|
| 134 | return |
---|
| 135 | endif |
---|
| 136 | ;------------------------------------------------------- |
---|
| 137 | ; check that all i[xyz]min[ax]mesh are well defined |
---|
| 138 | ;------------------------------------------------------- |
---|
| 139 | if n_elements(ixminmesh) EQ 0 THEN ixminmesh = 0 |
---|
| 140 | if n_elements(ixmaxmesh) EQ 0 then ixmaxmesh = jpiglo-1 |
---|
| 141 | if ixminmesh EQ -1 THEN ixminmesh = 0 |
---|
| 142 | IF ixmaxmesh EQ -1 then ixmaxmesh = jpiglo-1 |
---|
| 143 | if n_elements(iyminmesh) EQ 0 THEN iyminmesh = 0 |
---|
| 144 | IF n_elements(iymaxmesh) EQ 0 then iymaxmesh = jpjglo-1 |
---|
| 145 | if iyminmesh EQ -1 THEN iyminmesh = 0 |
---|
| 146 | IF iymaxmesh EQ -1 then iymaxmesh = jpjglo-1 |
---|
| 147 | if n_elements(izminmesh) EQ 0 THEN izminmesh = 0 |
---|
| 148 | IF n_elements(izmaxmesh) EQ 0 then izmaxmesh = jpkglo-1 |
---|
| 149 | if izminmesh EQ -1 THEN izminmesh = 0 |
---|
| 150 | IF izmaxmesh EQ -1 then izmaxmesh = jpkglo-1 |
---|
| 151 | ; definition of jpi,jpj,jpj |
---|
| 152 | jpi = long(ixmaxmesh-ixminmesh+1) |
---|
| 153 | jpj = long(iymaxmesh-iyminmesh+1) |
---|
| 154 | jpk = long(izmaxmesh-izminmesh+1) |
---|
| 155 | ;------------------------------------------------------- |
---|
| 156 | ; check onearth and its consequences |
---|
| 157 | ;------------------------------------------------------- |
---|
| 158 | IF n_elements(onearth) EQ 0 THEN key_onearth = 1 $ |
---|
| 159 | ELSE key_onearth = keyword_set(onearth) |
---|
| 160 | IF NOT key_onearth THEN BEGIN |
---|
| 161 | periodic = 0 |
---|
| 162 | shift = 0 |
---|
| 163 | ENDIF |
---|
| 164 | ;------------------------------------------------------- |
---|
| 165 | ; automatic definition of key_periodic |
---|
| 166 | ;------------------------------------------------------- |
---|
| 167 | IF n_elements(periodic) EQ 0 THEN BEGIN |
---|
| 168 | IF jpi GT 1 THEN BEGIN |
---|
| 169 | ncdf_varget, cdfid, 'lon_rho', xaxis $ |
---|
| 170 | , offset = [ixminmesh, iyminmesh], count = [jpi, 1] |
---|
| 171 | xaxis = (xaxis+720) MOD 360 |
---|
| 172 | xaxis = xaxis[sort(xaxis)] |
---|
| 173 | key_periodic = (xaxis[jpi-1]+2*(xaxis[jpi-1]-xaxis[jpi-2])) $ |
---|
| 174 | GE (xaxis[0]+360) |
---|
| 175 | ENDIF ELSE key_periodic = 0 |
---|
| 176 | ENDIF ELSE key_periodic = keyword_set(periodic) |
---|
| 177 | ;------------------------------------------------------- |
---|
| 178 | ; automatic definition of key_shift |
---|
| 179 | ;------------------------------------------------------- |
---|
| 180 | IF n_elements(shift) EQ 0 THEN BEGIN |
---|
| 181 | key_shift = long(testvar(var = key_shift)) |
---|
| 182 | ; key_shift will be defined according to the first line of glamt. |
---|
| 183 | if keyword_set(glamboundary) AND jpi GT 1 AND key_periodic EQ 1 $ |
---|
| 184 | THEN BEGIN |
---|
| 185 | ncdf_varget, cdfid, 'lon_rho', xaxis $ |
---|
| 186 | , offset = [ixminmesh, iyminmesh], count = [jpi, 1] |
---|
| 187 | ; xaxis between glamboundary[0] and glamboundary[1] |
---|
| 188 | xaxis = xaxis MOD 360 |
---|
| 189 | smaller = where(xaxis LT glamboundary[0]) |
---|
| 190 | if smaller[0] NE -1 then xaxis[smaller] = xaxis[smaller]+360 |
---|
| 191 | bigger = where(xaxis GE glamboundary[1]) |
---|
| 192 | if bigger[0] NE -1 then xaxis[bigger] = xaxis[bigger]-360 |
---|
| 193 | ; |
---|
| 194 | key_shift = (where(xaxis EQ min(xaxis)))[0] |
---|
| 195 | IF key_shift NE 0 THEN BEGIN |
---|
| 196 | key_shift = jpi-key_shift |
---|
| 197 | xaxis = shift(xaxis, key_shift) |
---|
| 198 | ENDIF |
---|
| 199 | ; |
---|
| 200 | IF array_equal(sort(xaxis), lindgen(jpi)) NE 1 THEN BEGIN |
---|
[226] | 201 | print, 'the x axis (1st line of glamt) is not sorted in the increasing order after the automatic definition of key_shift' |
---|
[172] | 202 | print, 'please use the keyword shift (and periodic) to suppress the automatic definition of key_shift (and key_periodic) and define by hand a more suitable value...' |
---|
| 203 | widget_control, noticebase, bad_id = nothing, /destroy |
---|
| 204 | return |
---|
| 205 | ENDIF |
---|
| 206 | ; |
---|
| 207 | ENDIF ELSE key_shift = 0 |
---|
| 208 | ENDIF ELSE key_shift = long(shift)*(key_periodic EQ 1) |
---|
| 209 | ;------------------------------------------------------- |
---|
| 210 | ; check key_stride and related things |
---|
| 211 | ;------------------------------------------------------- |
---|
| 212 | if n_elements(stride) eq 3 then key_stride = stride |
---|
| 213 | if n_elements(key_stride) LE 2 then key_stride = [1, 1, 1] |
---|
| 214 | key_stride = 1l > long(key_stride) |
---|
| 215 | IF total(key_stride) NE 3 THEN BEGIN |
---|
| 216 | IF key_shift NE 0 THEN BEGIN |
---|
| 217 | ; for explanation, see header of read_ncdf_varget.pro |
---|
| 218 | jpiright = key_shift |
---|
| 219 | jpileft = jpi - key_shift - ( (key_stride[0]-1)-((key_shift-1) MOD key_stride[0]) ) |
---|
| 220 | jpi = ((jpiright-1)/key_stride[0]+1) + ((jpileft-1)/key_stride[0]+1) |
---|
| 221 | ENDIF ELSE jpi = (jpi-1)/key_stride[0]+1 |
---|
| 222 | jpj = (jpj-1)/key_stride[1]+1 |
---|
| 223 | jpk = (jpk-1)/key_stride[2]+1 |
---|
| 224 | ENDIF |
---|
| 225 | ;------------------------------------------------------- |
---|
| 226 | ; for the variables related to the partial steps |
---|
| 227 | ;------------------------------------------------------- |
---|
| 228 | key_partialstep = 0 |
---|
| 229 | hdept = -1 |
---|
| 230 | hdepw = -1 |
---|
| 231 | ;------------------------------------------------------- |
---|
| 232 | ; default definitions to be able to use read_ncdf_varget |
---|
| 233 | ;------------------------------------------------------- |
---|
| 234 | ; default definitions to be able to use read_ncdf_varget |
---|
| 235 | ixmindtasauve = testvar(var = ixmindta) |
---|
| 236 | iymindtasauve = testvar(var = iymindta) |
---|
| 237 | izmindtasauve = testvar(var = izmindta) |
---|
| 238 | ; |
---|
| 239 | ixmindta = 0l |
---|
| 240 | iymindta = 0l |
---|
| 241 | izmindta = 0l |
---|
| 242 | ; |
---|
| 243 | jpt = 1 |
---|
| 244 | time = 1 |
---|
| 245 | firsttps = 0 |
---|
| 246 | ; |
---|
| 247 | firstx = 0 |
---|
| 248 | lastx = jpi-1 |
---|
| 249 | firsty = 0 |
---|
| 250 | lasty = jpj-1 |
---|
| 251 | firstz = 0 |
---|
| 252 | lastz = jpk-1 |
---|
| 253 | nx = jpi |
---|
| 254 | ny = jpj |
---|
| 255 | nz = 1 |
---|
| 256 | izminmeshsauve = izminmesh |
---|
| 257 | izminmesh = 0 |
---|
[212] | 258 | ; |
---|
| 259 | key_yreverse = 0 |
---|
| 260 | key_zreverse = 1 |
---|
[216] | 261 | key_gridtype = 'c' |
---|
[172] | 262 | ;------------------------------------------------------- |
---|
| 263 | ; 2d arrays: |
---|
| 264 | ;------------------------------------------------------- |
---|
| 265 | ; list the 2d variables that must be read |
---|
| 266 | namebase = ['lon_', 'lat_', 'mask_', 'x_', 'y_'] |
---|
| 267 | namebase2 = ['glam', 'gphi', 'mask' , 'd1', 'd2'] |
---|
| 268 | ; |
---|
| 269 | ; read all grid T variables |
---|
| 270 | ; |
---|
| 271 | for i = 0, n_elements(namebase)-1 do begin |
---|
| 272 | varcontient = ncdf_varinq(cdfid, namebase[i]+'rho') |
---|
| 273 | name = varcontient.name |
---|
| 274 | @read_ncdf_varget |
---|
| 275 | command = namebase2[i]+'t = float(temporary(res))' |
---|
| 276 | nothing = execute(command) |
---|
| 277 | ENDFOR |
---|
| 278 | d1t = 1.e3*(shift(d1t, -1, 0) - d1t) |
---|
| 279 | d2t = 1.e3*(shift(d2t, 0, -1) - d2t) |
---|
| 280 | for i = 0, n_elements(namebase2)-1 do begin |
---|
| 281 | command = namebase2[i]+'t = '+namebase2[i]+'t[0:jpi-2, 0:jpj-2]' |
---|
| 282 | nothing = execute(command) |
---|
| 283 | ENDFOR |
---|
| 284 | tmask = byte(temporary(maskt)) |
---|
| 285 | IF jpk GT 1 THEN tmask = reform(tmask[*]#replicate(1b, jpk), jpi-1, jpj-1, jpk, /overwrite) |
---|
| 286 | e1u = temporary(d1t) |
---|
| 287 | e2v = temporary(d2t) |
---|
| 288 | ; h: Final bathymetry at RHO-points |
---|
| 289 | varcontient = ncdf_varinq(cdfid, 'h') |
---|
| 290 | name = varcontient.name |
---|
| 291 | @read_ncdf_varget |
---|
| 292 | hroms = float(temporary(res)) |
---|
| 293 | hroms = hroms[0:jpi-2, 0:jpj-2] |
---|
| 294 | ; |
---|
| 295 | ; read all grid U variables |
---|
| 296 | ; |
---|
| 297 | jpiglo = jpiglo - 1 |
---|
| 298 | jpi = jpi - 1 |
---|
| 299 | ixmaxmesh = ixmaxmesh - 1 |
---|
| 300 | firstx = 0 |
---|
| 301 | lastx = jpi-1 |
---|
| 302 | nx = jpi |
---|
| 303 | ; |
---|
| 304 | for i = 0, n_elements(namebase)-1 do begin |
---|
| 305 | varcontient = ncdf_varinq(cdfid, namebase[i]+'u') |
---|
| 306 | name = varcontient.name |
---|
| 307 | @read_ncdf_varget |
---|
| 308 | command = namebase2[i]+'u = float(temporary(res))' |
---|
| 309 | nothing = execute(command) |
---|
| 310 | ENDFOR |
---|
| 311 | tmpsave = 2. * 1.e3 * d1u[0, 0:jpj-2] |
---|
| 312 | d1u = 1.e3*(shift(d1u, -1, 0) - d1u) |
---|
| 313 | d2u = 1.e3*(shift(d2u, 0, -1) - d2u) |
---|
| 314 | for i = 0, n_elements(namebase2)-1 do begin |
---|
| 315 | command = namebase2[i]+'u = '+namebase2[i]+'u[*, 0:jpj-2]' |
---|
| 316 | nothing = execute(command) |
---|
| 317 | ENDFOR |
---|
| 318 | umaskred = byte((temporary(masku))[jpi-1, *]) |
---|
| 319 | IF jpk GT 1 THEN umaskred = reform(umaskred[*]#replicate(1b, jpk), 1, jpj-1, jpk, /overwrite) |
---|
| 320 | e1t = temporary(d1u) |
---|
| 321 | e1t = shift(temporary(e1t), 1, 0) |
---|
| 322 | e1t[0, *] = temporary(tmpsave) |
---|
| 323 | e2f = temporary(d2u) |
---|
| 324 | ; |
---|
| 325 | ; read all grid V variables |
---|
| 326 | ; |
---|
| 327 | jpiglo = jpiglo + 1 |
---|
| 328 | jpi = jpi + 1 |
---|
| 329 | ixmaxmesh = ixmaxmesh + 1 |
---|
| 330 | firstx = 0 |
---|
| 331 | lastx = jpi-1 |
---|
| 332 | nx = jpi |
---|
| 333 | jpjglo = jpjglo - 1 |
---|
| 334 | jpj = jpj - 1 |
---|
| 335 | iymaxmesh = iymaxmesh - 1 |
---|
| 336 | firsty = 0 |
---|
| 337 | lasty = jpj-1 |
---|
| 338 | ny = jpj |
---|
| 339 | ; |
---|
| 340 | for i = 0, n_elements(namebase)-1 do begin |
---|
| 341 | varcontient = ncdf_varinq(cdfid, namebase[i]+'v') |
---|
| 342 | name = varcontient.name |
---|
| 343 | @read_ncdf_varget |
---|
| 344 | command = namebase2[i]+'v = float(temporary(res))' |
---|
| 345 | nothing = execute(command) |
---|
| 346 | ENDFOR |
---|
| 347 | d1v = 1.e3*(shift(d1v, -1, 0) - d1v) |
---|
| 348 | tmpsave = 2. * 1.e3 * d2v[0:jpi-2, 0] |
---|
| 349 | d2v = 1.e3*(shift(d2v, 0, -1) - d2v) |
---|
| 350 | for i = 0, n_elements(namebase2)-1 do begin |
---|
| 351 | command = namebase2[i]+'v = '+namebase2[i]+'v[0:jpi-2, *]' |
---|
| 352 | nothing = execute(command) |
---|
| 353 | ENDFOR |
---|
| 354 | vmaskred = byte((temporary(maskv))[*, jpj-1]) |
---|
| 355 | IF jpk GT 1 THEN vmaskred = reform(vmaskred[*]#replicate(1b, jpk), jpi-1, 1, jpk, /overwrite) |
---|
| 356 | e1f = temporary(d1v) |
---|
| 357 | e2t = temporary(d2v) |
---|
| 358 | e2t = shift(temporary(e2t), 0, 1) |
---|
| 359 | e2t[*, 0] = temporary(tmpsave) |
---|
| 360 | ; |
---|
| 361 | ; read all grid F variables |
---|
| 362 | ; |
---|
| 363 | jpiglo = jpiglo - 1 |
---|
| 364 | jpi = jpi - 1 |
---|
| 365 | ixmaxmesh = ixmaxmesh - 1 |
---|
| 366 | firstx = 0 |
---|
| 367 | lastx = jpi-1 |
---|
| 368 | nx = jpi |
---|
| 369 | ; |
---|
| 370 | for i = 0, n_elements(namebase)-1 do begin |
---|
| 371 | varcontient = ncdf_varinq(cdfid, namebase[i]+'psi') |
---|
| 372 | name = varcontient.name |
---|
| 373 | @read_ncdf_varget |
---|
| 374 | command = namebase2[i]+'f = float(temporary(res))' |
---|
| 375 | nothing = execute(command) |
---|
| 376 | ENDFOR |
---|
| 377 | tmpsave1 = 2. * 1.e3 * d1f[0, *] |
---|
| 378 | d1f = 1.e3*(shift(d1f, -1, 0) - d1f) |
---|
| 379 | tmpsave2 = 2. * 1.e3 * d2f[*, 0] |
---|
| 380 | d2f = 1.e3*(shift(d2f, 0, -1) - d2f) |
---|
| 381 | fmaskredy = byte(maskf[jpi-1, *]) |
---|
| 382 | IF jpk GT 1 THEN fmaskredy = reform(fmaskredy[*]#replicate(1b, jpk), 1, jpj, jpk, /overwrite) |
---|
| 383 | fmaskredx = byte((temporary(maskf))[*, jpj-1]) |
---|
| 384 | IF jpk GT 1 THEN fmaskredx = reform(fmaskredx[*]#replicate(1b, jpk), jpi, 1, jpk, /overwrite) |
---|
| 385 | e1v = temporary(d1f) |
---|
| 386 | e1v = shift(temporary(e1v), 1, 0) |
---|
| 387 | e1v[0, *] = temporary(tmpsave1) |
---|
| 388 | e2u = temporary(d2f) |
---|
| 389 | e2u = shift(temporary(e2u), 0, 1) |
---|
| 390 | e2u[*, 0] = temporary(tmpsave2) |
---|
| 391 | ;------------------------------------------------------- |
---|
| 392 | ; in the case of key_stride ne [1, 1, 1] redefine f points |
---|
| 393 | ; coordinates: they must be in the middle of 3 T points |
---|
| 394 | ;------------------------------------------------------- |
---|
| 395 | if key_stride[0] NE 1 OR key_stride[1] NE 1 then BEGIN |
---|
| 396 | ; we must recompute glamf and gphif... |
---|
| 397 | IF jpi GT 1 THEN BEGIN |
---|
| 398 | if (keyword_set(key_onearth) AND keyword_set(xnotsorted)) $ |
---|
| 399 | OR (keyword_set(key_periodic) AND key_irregular) then BEGIN |
---|
| 400 | stepxf = (glamt + 720) MOD 360 |
---|
| 401 | stepxf = shift(stepxf, -1, -1) - stepxf |
---|
| 402 | stepxf = [ [[stepxf]], [[stepxf + 360]], [[stepxf - 360]] ] |
---|
| 403 | stepxf = min(abs(stepxf), dimension = 3) |
---|
| 404 | IF NOT keyword_set(key_periodic) THEN $ |
---|
| 405 | stepxf[jpi-1, *] = stepxf[jpi-2, *] |
---|
| 406 | ENDIF ELSE BEGIN |
---|
| 407 | stepxf = shift(glamt, -1, -1) - glamt |
---|
| 408 | IF keyword_set(key_periodic) THEN $ |
---|
| 409 | stepxf[jpi-1, *] = 360 + stepxf[jpi-1, *] $ |
---|
| 410 | ELSE stepxf[jpi-1, *] = stepxf[jpi-2, *] |
---|
| 411 | ENDELSE |
---|
| 412 | IF jpj GT 1 THEN BEGIN |
---|
| 413 | stepxf[*, jpj-1] = stepxf[*, jpj-2] |
---|
| 414 | stepxf[jpi-1, jpj-1] = stepxf[jpi-2, jpj-2] |
---|
| 415 | ENDIF |
---|
| 416 | glamf = glamt + 0.5 * stepxf |
---|
| 417 | ENDIF ELSE glamf = glamt + 0.5 |
---|
| 418 | IF jpj GT 1 THEN BEGIN |
---|
| 419 | ; we must compute stepyf: y distance between T(i,j) T(i+1,j+1) |
---|
| 420 | stepyf = shift(gphit, -1, -1) - gphit |
---|
| 421 | stepyf[*, jpj-1] = stepyf[*, jpj-2] |
---|
| 422 | IF jpi GT 1 THEN BEGIN |
---|
| 423 | if NOT keyword_set(key_periodic) THEN $ |
---|
| 424 | stepyf[jpi-1, *] = stepyf[jpi-2, *] |
---|
| 425 | stepyf[jpi-1, jpj-1] = stepyf[jpi-2, jpj-2] |
---|
| 426 | ENDIF |
---|
| 427 | gphif = gphit + 0.5 * stepyf |
---|
| 428 | ENDIF ELSE gphif = gphit + 0.5 |
---|
| 429 | ENDIF |
---|
| 430 | ;------------------------------------------------------- |
---|
| 431 | ; 1d arrays |
---|
| 432 | ;------------------------------------------------------- |
---|
[173] | 433 | gdept = findgen(jpk) |
---|
| 434 | gdepw = findgen(jpk) |
---|
| 435 | e3t = replicate(1., jpk) |
---|
| 436 | e3w = replicate(1., jpk) |
---|
[172] | 437 | ;------------------------------------------------------- |
---|
| 438 | ncdf_close, cdfid |
---|
| 439 | ;------------------------------------------------------- |
---|
| 440 | ; Apply Glamboudary |
---|
| 441 | ;------------------------------------------------------- |
---|
| 442 | if keyword_set(glamboundary) AND key_onearth then BEGIN |
---|
| 443 | if glamboundary[0] NE glamboundary[1] then BEGIN |
---|
| 444 | glamt = temporary(glamt) MOD 360 |
---|
| 445 | smaller = where(glamt LT glamboundary[0]) |
---|
| 446 | if smaller[0] NE -1 then glamt[smaller] = glamt[smaller]+360 |
---|
| 447 | bigger = where(glamt GE glamboundary[1]) |
---|
| 448 | if bigger[0] NE -1 then glamt[bigger] = glamt[bigger]-360 |
---|
| 449 | glamu = temporary(glamu) MOD 360 |
---|
| 450 | smaller = where(glamu LT glamboundary[0]) |
---|
| 451 | if smaller[0] NE -1 then glamu[smaller] = glamu[smaller]+360 |
---|
| 452 | bigger = where(glamu GE glamboundary[1]) |
---|
| 453 | if bigger[0] NE -1 then glamu[bigger] = glamu[bigger]-360 |
---|
| 454 | glamv = temporary(glamv) MOD 360 |
---|
| 455 | smaller = where(glamv LT glamboundary[0]) |
---|
| 456 | if smaller[0] NE -1 then glamv[smaller] = glamv[smaller]+360 |
---|
| 457 | bigger = where(glamv GE glamboundary[1]) |
---|
| 458 | if bigger[0] NE -1 then glamv[bigger] = glamv[bigger]-360 |
---|
| 459 | glamf = temporary(glamf) MOD 360 |
---|
| 460 | smaller = where(glamf LT glamboundary[0]) |
---|
| 461 | if smaller[0] NE -1 then glamf[smaller] = glamf[smaller]+360 |
---|
| 462 | bigger = where(glamf GE glamboundary[1]) |
---|
| 463 | if bigger[0] NE -1 then glamf[bigger] = glamf[bigger]-360 |
---|
| 464 | toosmall = where(glamu EQ glamboundary[0]) |
---|
| 465 | IF toosmall[0] NE -1 THEN glamu[toosmall] = glamu[toosmall] + 360 |
---|
| 466 | toosmall = where(glamf EQ glamboundary[0]) |
---|
| 467 | IF toosmall[0] NE -1 THEN glamf[toosmall] = glamf[toosmall] + 360 |
---|
| 468 | endif |
---|
| 469 | endif |
---|
| 470 | ;------------------------------------------------------- |
---|
| 471 | ; make sure we do have 2d arrays when jpj eq 1 |
---|
| 472 | ;------------------------------------------------------- |
---|
| 473 | IF jpj EQ 1 THEN BEGIN |
---|
| 474 | glamt = reform(glamt, jpi, jpj, /over) |
---|
| 475 | gphit = reform(gphit, jpi, jpj, /over) |
---|
| 476 | e1t = reform(e1t, jpi, jpj, /over) |
---|
| 477 | e2t = reform(e2t, jpi, jpj, /over) |
---|
| 478 | glamu = reform(glamu, jpi, jpj, /over) |
---|
| 479 | gphiu = reform(gphiu, jpi, jpj, /over) |
---|
| 480 | e1u = reform(e1u, jpi, jpj, /over) |
---|
| 481 | e2u = reform(e2u, jpi, jpj, /over) |
---|
| 482 | glamv = reform(glamv, jpi, jpj, /over) |
---|
| 483 | gphiv = reform(gphiv, jpi, jpj, /over) |
---|
| 484 | e1v = reform(e1v, jpi, jpj, /over) |
---|
| 485 | e2v = reform(e2v, jpi, jpj, /over) |
---|
| 486 | glamf = reform(glamf, jpi, jpj, /over) |
---|
| 487 | gphif = reform(gphif, jpi, jpj, /over) |
---|
| 488 | e1f = reform(e1f, jpi, jpj, /over) |
---|
| 489 | e2f = reform(e2f, jpi, jpj, /over) |
---|
| 490 | ENDIF |
---|
| 491 | ;------------------------------------------------------- |
---|
| 492 | ixmindta = ixmindtasauve |
---|
| 493 | iymindta = iymindtasauve |
---|
| 494 | izmindta = izmindtasauve |
---|
| 495 | ;------------------------------------------------------- |
---|
| 496 | widget_control, noticebase, bad_id = nothing, /destroy |
---|
| 497 | ; |
---|
| 498 | ;==================================================== |
---|
| 499 | ; grid parameters used by xxx |
---|
| 500 | ;==================================================== |
---|
| 501 | ; |
---|
| 502 | IF NOT keyword_set(strcalling) THEN BEGIN |
---|
| 503 | IF n_elements(ccmeshparameters) EQ 0 THEN strcalling = 'ncdf_meshroms' $ |
---|
| 504 | ELSE strcalling = ccmeshparameters.filename |
---|
| 505 | ENDIF |
---|
| 506 | IF n_elements(glamt) GE 2 THEN BEGIN |
---|
| 507 | glaminfo = moment(glamt) |
---|
| 508 | IF finite(glaminfo[2]) EQ 0 THEN glaminfo = glaminfo[0:1] |
---|
| 509 | gphiinfo = moment(gphit) |
---|
| 510 | IF finite(gphiinfo[2]) EQ 0 THEN gphiinfo = gphiinfo[0:1] |
---|
| 511 | ENDIF ELSE BEGIN |
---|
| 512 | glaminfo = glamt |
---|
| 513 | gphiinfo = gphit |
---|
| 514 | ENDELSE |
---|
| 515 | romszinfos = {h:hroms, zeta:replicate(0., jpi, jpj), theta_s:-1, theta_b:-1, hc:-1} |
---|
| 516 | ccmeshparameters = {filename:strcalling $ |
---|
| 517 | , glaminfo:float(string(glaminfo, format = '(E11.4)')) $ |
---|
| 518 | , gphiinfo:float(string(gphiinfo, format = '(E11.4)')) $ |
---|
| 519 | , jpiglo:jpiglo, jpjglo:jpjglo, jpkglo:jpkglo $ |
---|
| 520 | , jpi:jpi, jpj:jpj, jpk:jpk $ |
---|
| 521 | , ixminmesh:ixminmesh, ixmaxmesh:ixmaxmesh $ |
---|
| 522 | , iyminmesh:iyminmesh, iymaxmesh:iymaxmesh $ |
---|
| 523 | , izminmesh:izminmesh, izmaxmesh:izmaxmesh $ |
---|
| 524 | , key_shift:key_shift, key_periodic:key_periodic $ |
---|
| 525 | , key_stride:key_stride, key_gridtype:key_gridtype $ |
---|
| 526 | , key_yreverse:key_yreverse, key_zreverse:key_zreverse $ |
---|
| 527 | , key_partialstep:key_partialstep, key_onearth:key_onearth} |
---|
| 528 | ; |
---|
| 529 | if keyword_set(key_performance) THEN $ |
---|
| 530 | print, 'time ncdf_meshread', systime(1)-tempsun |
---|
| 531 | |
---|
| 532 | ;------------------------------------------------------- |
---|
| 533 | @updateold |
---|
| 534 | ;------------------------------------------------------- |
---|
| 535 | return |
---|
| 536 | end |
---|