LCOV - code coverage report
Current view: top level - physics/clubb/src/CLUBB_core - T_in_K_module.F90 (source / functions) Hit Total Coverage
Test: coverage.info Lines: 7 17 41.2 %
Date: 2024-12-17 17:57:11 Functions: 1 4 25.0 %

          Line data    Source code
       1             : !-------------------------------------------------------------------------
       2             : ! $Id$ 
       3             : !===============================================================================
       4             : module T_in_K_module
       5             : 
       6             :   implicit none
       7             : 
       8             :   private ! Default scope
       9             : 
      10             :   public :: thlm2T_in_K, T_in_K2thlm
      11             : 
      12             :   interface thlm2T_in_K
      13             :     module procedure thlm2T_in_K_k    ! Works over a single vertical level
      14             :     module procedure thlm2T_in_K_1D   ! Works over all vertical levels 
      15             :     module procedure thlm2T_in_K_2D   ! Works over all vertical levels and columns
      16             :   end interface thlm2T_in_K
      17             : 
      18             :   contains
      19             : 
      20             :   !-------------------------------------------------------------------------------
      21             :   ! Wrapped in interface thlm2T_in_K
      22           0 :   function thlm2T_in_K_k( thlm, exner, rcm )  & 
      23             :                   result( T_in_K )
      24             : 
      25             :   ! Description:
      26             :   !   Calculates absolute temperature from liquid water potential
      27             :   !   temperature.  (Does not include ice.)
      28             : 
      29             :   ! References: 
      30             :   !   Cotton and Anthes (1989), "Storm and Cloud Dynamics", Eqn. (2.51). 
      31             :   !-------------------------------------------------------------------------------
      32             :     use constants_clubb, only: & 
      33             :       ! Variable(s) 
      34             :         Cp,  & ! Dry air specific heat at constant p [J/kg/K]
      35             :         Lv     ! Latent heat of vaporization         [J/kg]
      36             : 
      37             :     use clubb_precision, only: &
      38             :         core_rknd ! Variable(s)
      39             : 
      40             :     implicit none
      41             : 
      42             :     ! ---------------------- Input ----------------------
      43             :     real( kind = core_rknd ), intent(in) :: & 
      44             :       thlm,   & ! Liquid potential temperature  [K]
      45             :       exner,  & ! Exner function                [-]
      46             :       rcm       ! Liquid water mixing ratio     [kg/kg]
      47             : 
      48             :     real( kind = core_rknd ) :: & 
      49             :       T_in_K ! Result temperature [K]
      50             : 
      51             :     ! ---------------------- Begin Code ----------------------
      52           0 :     T_in_K = thlm * exner + Lv * rcm / Cp
      53             : 
      54             :     return
      55             :   end function thlm2T_in_K_k
      56             : 
      57             :   !-------------------------------------------------------------------------------
      58             :   ! Wrapped in interface thlm2T_in_K
      59           0 :   function thlm2T_in_K_1D( nz, thlm, exner, rcm )  & 
      60           0 :                    result( T_in_K )
      61             : 
      62             :   ! Description:
      63             :   !   Calculates absolute temperature from liquid water potential
      64             :   !   temperature.  (Does not include ice.)
      65             : 
      66             :   ! References: 
      67             :   !   Cotton and Anthes (1989), "Storm and Cloud Dynamics", Eqn. (2.51). 
      68             :   !-------------------------------------------------------------------------------
      69             :     use constants_clubb, only: & 
      70             :       ! Variable(s) 
      71             :         Cp,  & ! Dry air specific heat at constant p [J/kg/K]
      72             :         Lv     ! Latent heat of vaporization         [J/kg]
      73             : 
      74             :     use clubb_precision, only: &
      75             :         core_rknd ! Variable(s)
      76             : 
      77             :     implicit none
      78             : 
      79             :     ! ---------------------- Input ----------------------
      80             :     integer, intent(in) :: &
      81             :       nz
      82             : 
      83             :     real( kind = core_rknd ), dimension(nz), intent(in) :: & 
      84             :       thlm,   & ! Liquid potential temperature  [K]
      85             :       exner,  & ! Exner function                [-]
      86             :       rcm       ! Liquid water mixing ratio     [kg/kg]
      87             : 
      88             :     real( kind = core_rknd ), dimension(nz) :: & 
      89             :       T_in_K ! Result temperature [K]
      90             : 
      91             :     integer :: k
      92             : 
      93             :     ! ---------------------- Begin Code ----------------------
      94           0 :     do k = 1, nz
      95           0 :       T_in_K(k) = thlm(k) * exner(k) + Lv * rcm(k) / Cp
      96             :     end do
      97             : 
      98           0 :     return
      99           0 :   end function thlm2T_in_K_1D
     100             : 
     101             :   !-------------------------------------------------------------------------------
     102             :   ! Wrapped in interface thlm2T_in_K
     103    26805168 :   function thlm2T_in_K_2D( nz, ngrdcol, thlm, exner, rcm )  & 
     104    26805168 :                    result( T_in_K )
     105             : 
     106             :   ! Description:
     107             :   !   Calculates absolute temperature from liquid water potential
     108             :   !   temperature.  (Does not include ice.)
     109             : 
     110             :   ! References: 
     111             :   !   Cotton and Anthes (1989), "Storm and Cloud Dynamics", Eqn. (2.51). 
     112             :   !-------------------------------------------------------------------------------
     113             :     use constants_clubb, only: & 
     114             :       ! Variable(s) 
     115             :         Cp,  & ! Dry air specific heat at constant p [J/kg/K]
     116             :         Lv     ! Latent heat of vaporization         [J/kg]
     117             : 
     118             :     use clubb_precision, only: &
     119             :         core_rknd ! Variable(s)
     120             : 
     121             :     implicit none
     122             : 
     123             :     ! Input 
     124             :     integer, intent(in) :: &
     125             :       nz, &
     126             :       ngrdcol
     127             : 
     128             :     real( kind = core_rknd ), dimension(ngrdcol,nz), intent(in) :: & 
     129             :       thlm,   & ! Liquid potential temperature  [K]
     130             :       exner,  & ! Exner function                [-]
     131             :       rcm       ! Liquid water mixing ratio     [kg/kg]
     132             : 
     133             :     real( kind = core_rknd ), dimension(ngrdcol,nz) :: & 
     134             :       T_in_K ! Result temperature [K]
     135             : 
     136             :     integer :: i, k
     137             : 
     138             :     ! ---- Begin Code ----
     139             : 
     140             :     !$acc data copyin( thlm, exner, rcm ) &
     141             :     !$acc     copyout( T_in_K )
     142             : 
     143             :     !$acc parallel loop gang vector collapse(2) default(present)
     144  2305244448 :     do k = 1, nz
     145 38071442448 :       do i = 1, ngrdcol
     146 38044637280 :         T_in_K(i,k) = thlm(i,k) * exner(i,k) + Lv * rcm(i,k) / Cp
     147             :       end do
     148             :     end do
     149             :     !$acc end parallel loop
     150             : 
     151             :     !$acc end data
     152             : 
     153    26805168 :     return
     154    26805168 :   end function thlm2T_in_K_2D
     155             : 
     156             : !-------------------------------------------------------------------------------
     157           0 :   elemental function T_in_K2thlm( T_in_K, exner, rcm )  & 
     158             :     result( thlm )
     159             : 
     160             : ! Description:
     161             : !   Calculates liquid water potential temperature from absolute temperature 
     162             : 
     163             : ! References: 
     164             : !   None
     165             : !-------------------------------------------------------------------------------
     166             :     use constants_clubb, only: & 
     167             :       ! Variable(s) 
     168             :         Cp,  & ! Dry air specific heat at constant p [J/kg/K]
     169             :         Lv     ! Latent heat of vaporization         [J/kg]
     170             : 
     171             :     use clubb_precision, only: &
     172             :         core_rknd ! Variable(s)
     173             : 
     174             :     implicit none
     175             : 
     176             :     ! Input 
     177             :     real( kind = core_rknd ), intent(in) :: & 
     178             :       T_in_K, &! Result temperature [K]
     179             :       exner,  & ! Exner function                [-]
     180             :       rcm       ! Liquid water mixing ratio     [kg/kg]
     181             : 
     182             :     real( kind = core_rknd ) :: & 
     183             :       thlm    ! Liquid potential temperature  [K]
     184             : 
     185             :     ! ---- Begin Code ----
     186             : 
     187           0 :     thlm = ( T_in_K - Lv/Cp * rcm ) / exner 
     188             : 
     189             :     return
     190             :   end function T_in_K2thlm
     191             : !-------------------------------------------------------------------------------
     192             : 
     193             : end module T_in_K_module

Generated by: LCOV version 1.14