source: trunk/tradit_spectral_model/PROJECTS/BETA_PLANE/POMME/s1_bar_func.f @ 2

Last change on this file since 2 was 2, checked in by xlvlod, 17 years ago

initial import from /home2/xlvlod/IDRIS/SVN_BASE_TRUNK

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