LCOV - code coverage report
Current view: top level - chemistry/mozart - mo_mass_xforms.F90 (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 27 0.0 %
Date: 2024-12-17 17:57:11 Functions: 0 7 0.0 %

          Line data    Source code
       1             : module mo_mass_xforms
       2             : 
       3             :   use ppgrid,       only : pcols, pver
       4             :   use shr_kind_mod, only : r8 => shr_kind_r8
       5             : 
       6             : 
       7             :   private
       8             :   public :: mmr2vmr, mmr2vmri, vmr2mmr, vmr2mmri, h2o_to_vmr, h2o_to_mmr, init_mass_xforms
       9             :   save
      10             : 
      11             :   real(r8) :: adv_mass_h2o = 18._r8
      12             : 
      13             : contains
      14             : 
      15           0 :   subroutine init_mass_xforms
      16             :     use mo_chem_utls, only : get_spc_ndx
      17             :     use chem_mods,    only : adv_mass
      18             : 
      19             :     implicit none
      20             : 
      21             :     integer  :: id_h2o
      22             : 
      23           0 :     id_h2o = get_spc_ndx('H2O')
      24             : 
      25           0 :     if ( id_h2o > 0 ) then
      26           0 :        adv_mass_h2o = adv_mass(id_h2o)
      27             :     else
      28           0 :        adv_mass_h2o = 18._r8
      29             :     endif
      30             : 
      31           0 :   endsubroutine init_mass_xforms
      32             : 
      33           0 :   subroutine mmr2vmr( mmr, vmr, mbar, ncol )
      34             :     !-----------------------------------------------------------------
      35             :     !   ... Xfrom from mass to volume mixing ratio
      36             :     !-----------------------------------------------------------------
      37             : 
      38             :     use chem_mods, only : adv_mass, gas_pcnst
      39             : 
      40             :     implicit none
      41             : 
      42             :     !-----------------------------------------------------------------
      43             :     !   ... Dummy args
      44             :     !-----------------------------------------------------------------
      45             :     integer, intent(in)     :: ncol
      46             :     real(r8), intent(in)    :: mbar(ncol,pver)
      47             :     real(r8), intent(in)    :: mmr(ncol,pver,gas_pcnst)
      48             :     real(r8), intent(inout) :: vmr(ncol,pver,gas_pcnst)
      49             : 
      50             :     !-----------------------------------------------------------------
      51             :     !   ... Local variables
      52             :     !-----------------------------------------------------------------
      53             :     integer :: k, m
      54             : 
      55             :     do m = 1,gas_pcnst
      56             :        if( adv_mass(m) /= 0._r8 ) then
      57             :           do k = 1,pver
      58             :              vmr(:ncol,k,m) = mbar(:ncol,k) * mmr(:ncol,k,m) / adv_mass(m)
      59             :           end do
      60             :        end if
      61             :     end do
      62             : 
      63           0 :   end subroutine mmr2vmr
      64             : 
      65           0 :   subroutine mmr2vmri( mmr, vmr, mbar, mi, ncol )
      66             :     !-----------------------------------------------------------------
      67             :     !   ... Xfrom from mass to volume mixing ratio
      68             :     !-----------------------------------------------------------------
      69             : 
      70             :     implicit none
      71             : 
      72             :     !-----------------------------------------------------------------
      73             :     !   ... Dummy args
      74             :     !-----------------------------------------------------------------
      75             :     integer, intent(in)     :: ncol
      76             :     real(r8), intent(in)    :: mi
      77             :     real(r8), intent(in)    :: mbar(ncol,pver)
      78             :     real(r8), intent(in)    :: mmr(ncol,pver)
      79             :     real(r8), intent(inout) :: vmr(ncol,pver)
      80             : 
      81             :     !-----------------------------------------------------------------
      82             :     !   ... Local variables
      83             :     !-----------------------------------------------------------------
      84             :     integer  :: k
      85             :     real(r8) :: rmi
      86             : 
      87           0 :     rmi = 1._r8/mi
      88           0 :     do k = 1,pver
      89           0 :        vmr(:ncol,k) = mbar(:ncol,k) * mmr(:ncol,k) * rmi
      90             :     end do
      91             : 
      92           0 :   end subroutine mmr2vmri
      93             : 
      94           0 :   subroutine vmr2mmr( vmr, mmr, mbar, ncol )
      95             :     !-----------------------------------------------------------------
      96             :     !   ... Xfrom from volume to mass mixing ratio
      97             :     !-----------------------------------------------------------------
      98             : 
      99             :     use m_spc_id
     100             :     use chem_mods, only : adv_mass, gas_pcnst
     101             : 
     102             :     implicit none
     103             : 
     104             :     !-----------------------------------------------------------------
     105             :     !   ... Dummy args
     106             :     !-----------------------------------------------------------------
     107             :     integer, intent(in)     :: ncol
     108             :     real(r8), intent(in)    :: mbar(ncol,pver)
     109             :     real(r8), intent(in)    :: vmr(ncol,pver,gas_pcnst)
     110             :     real(r8), intent(inout) :: mmr(ncol,pver,gas_pcnst)
     111             : 
     112             :     !-----------------------------------------------------------------
     113             :     !   ... Local variables
     114             :     !-----------------------------------------------------------------
     115             :     integer :: k, m
     116             : 
     117             :     !-----------------------------------------------------------------
     118             :     !   ... The non-group species
     119             :     !-----------------------------------------------------------------
     120             :     do m = 1,gas_pcnst
     121             :        if( adv_mass(m) /= 0._r8 ) then
     122             :           do k = 1,pver
     123             :              mmr(:ncol,k,m) = adv_mass(m) * vmr(:ncol,k,m) / mbar(:ncol,k)
     124             :           end do
     125             :        end if
     126             :     end do
     127             : 
     128           0 :   end subroutine vmr2mmr
     129             : 
     130           0 :   subroutine vmr2mmri( vmr, mmr, mbar, mi, ncol )
     131             :     !-----------------------------------------------------------------
     132             :     !   ... Xfrom from volume to mass mixing ratio
     133             :     !-----------------------------------------------------------------
     134             : 
     135             :     implicit none
     136             : 
     137             :     !-----------------------------------------------------------------
     138             :     !   ... dummy args
     139             :     !-----------------------------------------------------------------
     140             :     integer, intent(in)     :: ncol
     141             :     real(r8), intent(in)    :: mi
     142             :     real(r8), intent(in)    :: mbar(ncol,pver)
     143             :     real(r8), intent(in)    :: vmr(ncol,pver)
     144             :     real(r8), intent(inout) :: mmr(ncol,pver)
     145             : 
     146             :     !-----------------------------------------------------------------
     147             :     !   ... local variables
     148             :     !-----------------------------------------------------------------
     149             :     integer :: k, m
     150             : 
     151             :     !-----------------------------------------------------------------
     152             :     !   ... mass to volume mixing for individual species
     153             :     !-----------------------------------------------------------------
     154           0 :     do k = 1,pver
     155           0 :        mmr(:ncol,k) = mi * vmr(:ncol,k) / mbar(:ncol,k)
     156             :     end do
     157             : 
     158           0 :   end subroutine vmr2mmri
     159             : 
     160           0 :   subroutine h2o_to_vmr( h2o_mmr, h2o_vmr, mbar, ncol )
     161             :     !-----------------------------------------------------------------------
     162             :     !     ... Transform water vapor from mass to volumetric mixing ratio
     163             :     !-----------------------------------------------------------------------
     164             : 
     165             :     use chem_mods, only : adv_mass
     166             : 
     167             :     implicit none
     168             : 
     169             :     !-----------------------------------------------------------------------
     170             :     !   ... Dummy arguments
     171             :     !-----------------------------------------------------------------------
     172             :     integer, intent(in) ::    ncol
     173             :     real(r8), dimension(ncol,pver), intent(in) :: &
     174             :          h2o_mmr                ! specific humidity ( mmr )
     175             :     real(r8), dimension(ncol,pver), intent(in)  :: &
     176             :          mbar                   ! atmos mean mass
     177             :     real(r8), dimension(ncol,pver), intent(out) :: &
     178             :          h2o_vmr                ! water vapor vmr
     179             : 
     180             :     !-----------------------------------------------------------------------
     181             :     !   ... Local variables
     182             :     !-----------------------------------------------------------------------
     183             :     integer ::   k
     184             : 
     185           0 :     do k = 1,pver
     186           0 :        h2o_vmr(:ncol,k) = mbar(:ncol,k) * h2o_mmr(:ncol,k) / adv_mass_h2o
     187             :     end do
     188             : 
     189           0 :   end subroutine h2o_to_vmr
     190             : 
     191           0 :   subroutine h2o_to_mmr( h2o_vmr, h2o_mmr, mbar, ncol )
     192             :     !-----------------------------------------------------------------------
     193             :     !     ... Transform water vapor from volumetric to mass mixing ratio
     194             :     !-----------------------------------------------------------------------
     195             : 
     196             :     use chem_mods, only : adv_mass
     197             : 
     198             :     implicit none
     199             : 
     200             :     !-----------------------------------------------------------------------
     201             :     !   ... Dummy arguments
     202             :     !-----------------------------------------------------------------------
     203             :     integer, intent(in) ::    ncol
     204             :     real(r8), dimension(ncol,pver), intent(in)  :: &
     205             :          mbar                   ! atmos mean mass
     206             :     real(r8), dimension(ncol,pver), intent(in)  :: &
     207             :          h2o_vmr               ! water vapor vmr
     208             :     real(r8), dimension(ncol,pver), intent(out) :: &
     209             :          h2o_mmr                ! specific humidity ( mmr )
     210             : 
     211             :     !-----------------------------------------------------------------------
     212             :     !   ... Local variables
     213             :     !-----------------------------------------------------------------------
     214             :     integer ::   k
     215             : 
     216           0 :     do k = 1,pver
     217           0 :        h2o_mmr(:ncol,k) = h2o_vmr(:ncol,k) * adv_mass_h2o / mbar(:ncol,k)
     218             :     end do
     219             : 
     220           0 :   end subroutine h2o_to_mmr
     221             : 
     222             : end module mo_mass_xforms

Generated by: LCOV version 1.14