FV3 Bundle
temperature_variables_mod.f90
Go to the documentation of this file.
1 ! (C) Copyright 2018 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 transforms on temperature variables for fv3-jedi
7 !> Daniel Holdaway, NASA/JCSDA
8 
10 
14 
15 implicit none
16 private
17 
20 
21 contains
22 
23 !----------------------------------------------------------------------------
24 ! Temperature to Virtual Temperature ----------------------------------------
25 !----------------------------------------------------------------------------
26 
27 subroutine t_to_tv(geom,T,q,Tv)
28 
29  implicit none
30  type(fv3jedi_geom) , intent(in ) :: geom !Geometry for the model
31  real(kind=kind_real), intent(in ) :: t (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !Temperature (K)
32  real(kind=kind_real), intent(in ) :: q (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !Specific humidity (kg/kg)
33  real(kind=kind_real), intent(out) :: tv(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !Virtual temperature (K)
34 
35  tv = t*(1.0_kind_real + epsilon*q)
36 
37 end subroutine t_to_tv
38 
39 !----------------------------------------------------------------------------
40 
41 subroutine t_to_tv_tl(geom,T,T_tl,q,q_tl,Tv_tl)
42 
43  implicit none
44  type(fv3jedi_geom) , intent(in ) :: geom
45  real(kind=kind_real), intent(in ) :: t (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
46  real(kind=kind_real), intent(in ) :: t_tl(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
47  real(kind=kind_real), intent(in ) :: q (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
48  real(kind=kind_real), intent(in ) :: q_tl(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
49  real(kind=kind_real), intent(out) :: tv_tl(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
50 
51  tv_tl = t_tl*(1.0_kind_real + epsilon*q) + t*epsilon*q_tl
52 
53 end subroutine t_to_tv_tl
54 
55 !----------------------------------------------------------------------------
56 
57 subroutine t_to_tv_ad(geom,T,T_ad,q,q_ad,Tv_ad)
58 
59  implicit none
60  type(fv3jedi_geom) , intent(in ) :: geom
61  real(kind=kind_real), intent(in ) :: t (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
62  real(kind=kind_real), intent(inout) :: t_ad (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
63  real(kind=kind_real), intent(in ) :: q (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
64  real(kind=kind_real), intent(inout) :: q_ad (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
65  real(kind=kind_real), intent(inout) :: tv_ad(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
66 
67  t_ad = t_ad + tv_ad * (1.0_kind_real + epsilon*q)
68  q_ad = q_ad + tv_ad * epsilon*t
69  tv_ad = 0.0_kind_real
70 
71 end subroutine t_to_tv_ad
72 
73 !----------------------------------------------------------------------------
74 ! Virtual Temperature to Temperature ----------------------------------------
75 !----------------------------------------------------------------------------
76 
77 subroutine tv_to_t(geom,Tv,q,T)
78 
79  implicit none
80  type(fv3jedi_geom) , intent(in ) :: geom !Geometry for the model
81  real(kind=kind_real), intent(in ) :: tv(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !Temperature (K)
82  real(kind=kind_real), intent(in ) :: q (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !Specific humidity (kg/kg)
83  real(kind=kind_real), intent(out) :: t (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !Virtual temperature (K)
84 
85  t = tv/(1.0_kind_real + epsilon*q)
86 
87 end subroutine tv_to_t
88 
89 !----------------------------------------------------------------------------
90 
91 subroutine tv_to_t_tl(geom,Tv,Tv_tl,q,q_tl,T_tl)
92 
93  implicit none
94  type(fv3jedi_geom) , intent(in ) :: geom
95  real(kind=kind_real), intent(in ) :: tv (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
96  real(kind=kind_real), intent(in ) :: tv_tl(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
97  real(kind=kind_real), intent(in ) :: q (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
98  real(kind=kind_real), intent(in ) :: q_tl (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
99  real(kind=kind_real), intent(inout) :: t_tl (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
100 
101  t_tl = (tv_tl*(1.0_kind_real+epsilon*q)-tv*epsilon*q_tl)/(1.0_kind_real+epsilon*q)**2
102 
103 end subroutine tv_to_t_tl
104 
105 !----------------------------------------------------------------------------
106 
107 subroutine tv_to_t_ad(geom,Tv,Tv_ad,q,q_ad,T_ad)
109  implicit none
110  type(fv3jedi_geom) , intent(in ) :: geom
111  real(kind=kind_real), intent(in ) :: tv (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
112  real(kind=kind_real), intent(inout) :: tv_ad(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
113  real(kind=kind_real), intent(in ) :: q (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
114  real(kind=kind_real), intent(inout) :: q_ad (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
115  real(kind=kind_real), intent(inout) :: t_ad (geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
116 
117  real(kind=kind_real) :: temp(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
118 
119  temp = t_ad/(epsilon*q+1.0_kind_real)
120 
121  tv_ad = tv_ad + temp
122  q_ad = q_ad - tv*epsilon*temp/(epsilon*q+1.0_kind_real)
123  t_ad = 0.0_kind_real
124 
125 end subroutine tv_to_t_ad
126 
127 !----------------------------------------------------------------------------
128 
129 end module temperature_vt_mod
real(kind=kind_real), parameter, public kappa
subroutine, public tv_to_t_tl(geom, Tv, Tv_tl, q, q_tl, T_tl)
Fortran derived type to hold geometry data for the FV3JEDI model.
subroutine, public t_to_tv_tl(geom, T, T_tl, q, q_tl, Tv_tl)
Variable transforms on temperature variables for fv3-jedi Daniel Holdaway, NASA/JCSDA.
subroutine, public t_to_tv(geom, T, q, Tv)
subroutine, public tv_to_t_ad(geom, Tv, Tv_ad, q, q_ad, T_ad)
Fortran module handling geometry for the FV3 model.
real(kind=kind_real), parameter, public epsilon
subroutine, public t_to_tv_ad(geom, T, T_ad, q, q_ad, Tv_ad)
integer, parameter, public kind_real
subroutine, public tv_to_t(geom, Tv, q, T)