source: trunk/SRC/Grid/romsdepth.pro @ 504

Last change on this file since 504 was 501, checked in by smasson, 8 years ago

set of bugfixes...

  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1;+
2;
3; @file_comments
4; compute depth of ROMS outputs according to ROMS parameters
5; stored in the common variable (cm_4mesh) romszinfos
6;
7; @categories
8; Grid
9;
10; @returns
11; the depth of the points (or -1 if error)
12;
13; @uses
14; <pro>cm_4mesh</pro>
15; <pro>cm_4data</pro>
16;
17; @restrictions
18; common variable (<pro>cm_4mesh</pro>) romszinfos must be correctly defined
19;
20; @history
21; Sept 2006 Sebastien Masson (smasson\@lodyc.jussieu.fr)
22;
23; @version
24; $Id$
25;
26;-
27FUNCTION romsdepth, new_s_coord = new_s_coord
28;
29  compile_opt idl2, strictarrsubs
30;
31@cm_4mesh
32@cm_4data
33;
34  theta_s = romszinfos.theta_s
35  IF theta_s EQ -1 THEN return, -1
36  theta_b = romszinfos.theta_b
37  IF theta_b EQ -1 THEN return, -1
38  hc      = romszinfos.hc
39  IF hc EQ -1 THEN return, -1
40  hroms = romszinfos.h
41  IF hroms[0] EQ -1 THEN return, -1
42  zeta = romszinfos.zeta
43  IF zeta[0] EQ -1 THEN return, -1
44  type = vargrid
45;
46  grille, -1, -1, -1, -1, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz
47  hroms = hroms[firstx:lastx, firsty:lasty]
48  nt = n_elements(zeta[firstx:lastx, firsty:lasty, *])/nx/ny
49;
50  IF type EQ 'W' THEN BEGIN
51    sc = (findgen(jpk)-jpk)/jpk
52;  sc = (dindgen(jpk+1)-jpk)/jpk
53;  jpk = jpk+1
54  ENDIF ELSE BEGIN
55    sc = (findgen(jpk)-jpk-0.5+1)/jpk
56  ENDELSE
57;
58  IF keyword_set(new_s_coord) THEN BEGIN
59
60    IF theta_s GT 0. THEN BEGIN
61      csrf = ( 1. - cosh(theta_s*sc) ) / ( cosh(theta_s) - 1. )
62    ENDIF ELSE BEGIN
63      csrf = - sc*sc
64    ENDELSE
65    if theta_b GT 0. THEN BEGIN
66      cs = ( exp(theta_b*csrf) - 1. ) / ( 1. - exp(-theta_b) ) 
67    ENDIF ELSE BEGIN
68      cs = csrf
69    ENDELSE
70   
71    hh = (hroms[*]#replicate(1., jpk))
72    z0 = hh * ( replicate(1., nx*ny)#(hc*sc)[*] + hh * replicate(1., nx*ny)#cs[*] ) / ( hc + hh )
73   
74   
75  ENDIF ELSE BEGIN
76   
77    cff1 = 1./sinh(theta_s)
78    cff2 = 0.5/tanh(0.5*theta_s)
79
80    cs = (1.-theta_b)*cff1*sinh(theta_s*sc)+theta_b*(cff2*tanh(theta_s*(sc+0.5))-0.5)
81    cff = hc*(sc-cs)
82    cff1 = cs
83
84    z0 = replicate(1., nx*ny)#cff[*] + (replicate(1., nx*ny)#cff1[*]) * (hroms[*]#replicate(1., jpk))
85
86  ENDELSE
87
88;
89  hinv = 1./hroms
90  hinv = hinv[*]#replicate(1., jpk)
91; put a z dimension to zeta
92  zeta = transpose((temporary(zeta))[firstx:lastx, firsty:lasty, *])
93  zeta = reform((temporary(zeta))[*]#replicate(1., jpk), nt, ny, nx, jpk, /overwrite)
94  zeta = transpose(temporary(zeta), [2, 1, 3, 0])
95
96  z = (z0[*]#replicate(1., nt)) + temporary(zeta) * ((1.+z0*hinv)[*]#replicate(1., nt))
97  z = reform(z, nx, ny, jpk, nt, /overwrite)
98  z = -1*reverse(temporary(z), 3)
99
100  return, z
101end
Note: See TracBrowser for help on using the repository browser.