source: trunk/SpectralModelF90/PROJECTS/BETA_PLANE/POMME/s2_bar_func.f @ 6

Last change on this file since 6 was 6, checked in by xlvlod, 18 years ago

import initial from SVN_BASE_TRUNK

File size: 3.5 KB
Line 
1      subroutine s2_bar_func(xprime,yprime,zprime,s2_bar,
2     *                        s2_bar_x,s2_bar_y,s2_bar_z,g2s2b,
3     *                        Lz,s2_scale)
4c
5c     *****input arguments xprime,yprime,zprime are DIMENSIONLESS as are all returned values
6c     (xprime,yprime,zprime):     d'less spatial position
7c     Lz:                         vertical size of computational domain [m]
8c     s2_scale:                   characteristic range of s2 values, used to scale s2
9c                                 units are dimensional, e.g. psu for s2-->Salinity
10     
11c     *****output variables, these need to be specified in this routine
12c             s2_bar, s2_bar_x, s2_bar_y, s2_bar_z, g2s2b
13c             scalar concentration, and spatial gradients, g2s2b=grad2(s2_bar)   [dimensional units]
14
15      implicit none
16      real xprime,yprime,zprime
17      real Lz,s2_scale
18      real s2_bar,s2_bar_x,s2_bar_y,s2_bar_z,g2s2b
19
20c     local variables: you may need some intermediate variables,
21c                      these need to be explicitly declared here
22      real x,y,z,ans,ansp,ansm,delta_z,delta_x
23
24
25c     it may be convenient to know the dimensional spatial location (x,y,z) in [m], so we compute it
26      x = xprime*Lz       ! use dimensional value to evaluate formulae
27      y = yprime*Lz       ! use dimensional value to evaluate formulae
28      z = zprime*Lz       ! use dimensional value to evaluate formulae
29
30
31c****    USER CUSTOMIZED CODE SEGMENT STARTS  HERE ************************
32c            scalars='TS' --> s2 = T' and s2 = S'
33
34      delta_z = Lz/10000.    ! [m] (offset for estimating derivs)
35      delta_x = 100.   ! ""
36     
37      ! stay underwater
38      if(z >= Lz-delta_z) z=Lz-delta_z
39     
40      call interp2d(x,z,'S',ans)
41      call interp2d(x,z+delta_z,'S',ansp)
42      call interp2d(x,z-delta_z,'S',ansm)
43     
44      s2_bar = ans ! [psu]
45      s2_bar_z = (ansp-ansm)/(2.*delta_z)        ! [psu/m]
46      g2s2b = (ansp -2.*ans + ansm)/(delta_z**2) ! [psu/m2]
47     
48     
49      call interp2d(x+delta_x,z,'S',ansp)
50      call interp2d(x-delta_x,z,'S',ansm)
51     
52      s2_bar_x = (ansp-ansm)/(2.*delta_x)        ! [psu/m]
53         
54         
55      s2_bar_y = 0.0                             ! [psu/m]
56     
57
58c****    USER DEFINED CODE SEGMENT ENDS HERE ********************************
59
60
61
62
63c     
64c***  LEAVE THIS SECTION AS IS, SCALING MUST BE CONSISTENT********************
65c***  WITH THE REST OF THE ALGORITHM  ****************************************
66      s2_bar=s2_bar/(s2_scale)
67      s2_bar_x = s2_bar_x/(s2_scale/Lz)
68      s2_bar_y = s2_bar_y/(s2_scale/Lz)
69      s2_bar_z = s2_bar_z/(s2_scale/Lz)
70      g2s2b = g2s2b/(s2_scale/Lz**2)
71c*****************************************************************************
72c*****************************************************************************
73
74c      print*,'s2_bar interpoled ...'
75      return
76      end
77
78
79
80c It may seem odd to have the inputs in dimensionless form
81c when it is usually convenient for the user to define the
82c ambient quantities in dimensional form. Also, we have a
83c **do not touch** section of code that converts the user
84c specified dimenaional quantities back to dimensionless form.
85c I chose to do it this way because this function gets called
86c from so many places in the code, it would be a pain and
87c a potential source of typos to do the scalings just before
88c and just after each call. This is not the case with 
89c user_defined_ics and user_defined_forcing. These routines
90c get called in one location only and so it makes sense to
91c make the scaling "invisible" to the user.
Note: See TracBrowser for help on using the repository browser.