SOCA
soca_ksshts_mod.F90
Go to the documentation of this file.
1 ! (C) Copyright 2017-2021 UCAR
2 !
3 ! This software is licensed under the terms of the Apache Licence Version 2.0
4 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5 
6 !> variable transform: SSH balance
8 
9 use kinds, only: kind_real
10 use soca_utils, only: soca_rho
11 use gsw_mod_toolbox, only : gsw_rho, gsw_rho_first_derivatives,gsw_sa_from_sp, gsw_pt_from_ct
12 
13 implicit none
14 private
15 public :: soca_steric_jacobian
16 
17 !> Hold the jacobians for the ssh to s/t balance transform
18 !!
19 !! should be populated by calls to soca_ksshts_mod::soca_ksshts::soca_steric_jacobian
20 !! \see soca_balance_mod::soca_balance_setup
21 type, public :: soca_ksshts
22  real(kind=kind_real), allocatable :: kssht(:,:,:) !< deta(i,j)/dT(i,j,k)
23  real(kind=kind_real), allocatable :: ksshs(:,:,:) !< deta(i,j)/dS(i,j,k)
24 end type soca_ksshts
25 
26 
27 ! ------------------------------------------------------------------------------
28 contains
29 ! ------------------------------------------------------------------------------
30 
31 
32 ! ------------------------------------------------------------------------------
33 !> Jacobian of stericnl relative to the reference state t0, s0
34 !!
35 !! \relates soca_ksshts_mod::soca_ksshts
36 !! \param s: ref. Absolute Salinity [g/kg]
37 !! \param t: Ref. Conservative Temperature [deg C]
38 !! \param p: Pressure [dbar]
39 !! \param h: Layer thickness [m]
40 !! \param lon: Longitude [DEG E]
41 !! \param lat: Latitude[DEG N]
42 !! \param jac: Jacobian
43 !! - [0] = detas/dt1, ...,detas/dtN; [m/deg C]
44 !! - [1] = detas/ds1, ...,detas/dsN; [m/(g/kg)]
45 subroutine soca_steric_jacobian (jac, t, s, p, h, lon, lat)
46  !
47  !--------------------------------------------------------------------------
48  real(kind=kind_real), intent(in) :: t, s, p, h, lon, lat
49  real(kind=kind_real), intent(out) :: jac(2)
50 
51  real(kind=kind_real) :: rho0
52  real(kind=kind_real) :: drhods, drhodt, eps=1.0e-8
53 
54  ! Insitu density
55  rho0 = soca_rho(s, t, p, lon, lat)
56  drhodt = (soca_rho(s, t+eps, p, lon, lat)-rho0)/eps
57  drhods = (soca_rho(s+eps, t, p, lon, lat)-rho0)/eps
58 
59  jac(1)=-h*drhodt/rho0
60  jac(2)=-h*drhods/rho0
61 
62 end subroutine soca_steric_jacobian
63 
64 end module soca_ksshts_mod
variable transform: SSH balance
various utility functions
Definition: soca_utils.F90:7
elemental real(kind=kind_real) function, public soca_rho(sp, pt, p, lon, lat)
calculate density from temp/salinity profile
Definition: soca_utils.F90:34
Hold the jacobians for the ssh to s/t balance transform.