LCOV - code coverage report
Current view: top level - chemistry/mozart - chem_prod_loss_diags.F90 (source / functions) Hit Total Coverage
Test: coverage.info Lines: 30 32 93.8 %
Date: 2025-03-14 01:26:08 Functions: 2 2 100.0 %

          Line data    Source code
       1             : module chem_prod_loss_diags
       2             :   use shr_kind_mod, only : r8 => shr_kind_r8
       3             :   use chem_mods, only : clscnt1, clscnt4, gas_pcnst, clsmap, permute
       4             :   use ppgrid, only : pver
       5             :   use chem_mods, only : rxntot
       6             :   use cam_history, only : addfld, outfld, add_default
       7             :   use mo_tracname, only : solsym
       8             : 
       9             :   implicit none
      10             : 
      11             :   private
      12             :   public :: chem_prod_loss_diags_init
      13             :   public :: chem_prod_loss_diags_out
      14             : 
      15             : contains
      16             : 
      17             :   !-----------------------------------------------------------------------------
      18             :   !-----------------------------------------------------------------------------
      19         768 :   subroutine chem_prod_loss_diags_init
      20             :     use phys_control, only : phys_getopts
      21             : 
      22             : 
      23             :     integer :: i,j
      24             :     logical :: history_scwaccm_forcing
      25         768 :     call phys_getopts( history_scwaccm_forcing_out = history_scwaccm_forcing )
      26             : 
      27      107520 :     do i = 1,clscnt4
      28      106752 :        j = clsmap(i,4)
      29      213504 :        call addfld( trim(solsym(j))//'_CHMP', (/ 'lev' /), 'I', '/cm3/s', 'chemical production rate' )
      30      213504 :        call addfld( trim(solsym(j))//'_CHML', (/ 'lev' /), 'I', '/cm3/s', 'chemical loss rate' )
      31      107520 :        if (history_scwaccm_forcing ) then
      32             :           if ( trim(solsym(j))=='CH4' .or. &
      33             :                trim(solsym(j))=='CFC11' .or. &
      34           0 :                trim(solsym(j))=='CFC12' .or. &
      35             :                trim(solsym(j))=='N2O' ) then
      36           0 :              call add_default( trim(solsym(j))//'_CHML', 1, ' ')
      37             :           endif
      38             :        endif
      39             :     enddo
      40             :     do i = 1,clscnt1
      41             :        j = clsmap(i,1)
      42             :        if (history_scwaccm_forcing ) then
      43             :           if ( trim(solsym(j))=='CH4' .or. &
      44             :                trim(solsym(j))=='CFC11' .or. &
      45             :                trim(solsym(j))=='CFC12' .or. &
      46             :                trim(solsym(j))=='N2O' ) then
      47             :              call add_default( trim(solsym(j))//'_CHML', 1, ' ')
      48             :           endif
      49             :        endif
      50             :     enddo
      51             : 
      52        1536 :     call addfld('H_PEROX_CHMP', (/ 'lev' /), 'I', '/cm3/s', 'total ROOH production rate' ) !PJY changed "RO2" to "ROOH"
      53             : 
      54         768 :   end subroutine chem_prod_loss_diags_init
      55             : 
      56             :   !-----------------------------------------------------------------------------
      57             :   !-----------------------------------------------------------------------------
      58       21888 :   subroutine chem_prod_loss_diags_out( ncol, lchnk, base_sol, reaction_rates, prod_in, loss_in, xhnm )
      59             : 
      60             :     integer,  intent(in) :: ncol, lchnk
      61             :     real(r8), intent(in) :: base_sol(ncol,pver,gas_pcnst)
      62             :     real(r8), intent(in) :: reaction_rates(ncol,pver,max(1,rxntot))
      63             :     real(r8), intent(in) :: prod_in(ncol,pver,max(1,clscnt4))
      64             :     real(r8), intent(in) :: loss_in(ncol,pver,max(1,clscnt4))
      65             :     real(r8), intent(in) :: xhnm(ncol,pver)
      66             : 
      67       43776 :     real(r8), dimension(ncol,pver,max(1,clscnt4)) :: prod_out, loss_out
      68       43776 :     real(r8), dimension(ncol,pver) :: prod_hydrogen_peroxides_out
      69             :     integer :: lev, i, k, j, m
      70             : 
      71     2867328 :     level_loop : do lev = 1,pver
      72    37012608 :        column_loop : do i = 1,ncol
      73             : 
      74             :           !-----------------------------------------------------------------------
      75             :           ! ... Prod/Loss history buffers...
      76             :           !-----------------------------------------------------------------------
      77  4783184640 :           cls_loop2: do k = 1,clscnt4
      78  4746193920 :              j = clsmap(k,4)
      79  4746193920 :              m = permute(k,4)
      80  4746193920 :              prod_out(i,lev,k) = prod_in(i,lev,m)
      81  4780339200 :              loss_out(i,lev,k) = loss_in(i,lev,m)
      82             :           end do cls_loop2
      83             :        end do column_loop
      84             :     end do level_loop
      85             : 
      86    37012608 :     prod_hydrogen_peroxides_out(:,:) = 0._r8
      87             : 
      88     3064320 :     do i = 1,clscnt4
      89     3042432 :        j = clsmap(i,4)
      90  5144752512 :        prod_out(:,:,i) = prod_out(:,:,i)*xhnm(:,:)
      91  5144752512 :        loss_out(:,:,i) = loss_out(:,:,i)*xhnm(:,:)
      92     3042432 :        call outfld( trim(solsym(j))//'_CHMP', prod_out(:,:,i), ncol, lchnk )
      93     3042432 :        call outfld( trim(solsym(j))//'_CHML', loss_out(:,:,i), ncol, lchnk )
      94             :        !
      95             :        ! added code for ROOH production !PJY not "RO2 production"
      96             :        !
      97             :        if ( trim(solsym(j)) == 'ALKOOH' &
      98             :             .or.trim(solsym(j)) == 'C2H5OOH' &
      99             :             .or.trim(solsym(j)) == 'CH3OOH' & !PJY added this
     100             :             .or.trim(solsym(j)) == 'CH3COOH' &
     101             :             .or.trim(solsym(j)) == 'CH3COOOH' &
     102             :             .or.trim(solsym(j)) == 'C3H7OOH' & !PJY corrected this (from CH3H7OOH)
     103             :             .or.trim(solsym(j)) == 'EOOH' &
     104             :             .or.trim(solsym(j)) == 'ISOPOOH' &
     105             :             .or.trim(solsym(j)) == 'MACROOH' &
     106             :             .or.trim(solsym(j)) == 'MEKOOH' &
     107             :             .or.trim(solsym(j)) == 'POOH' &
     108             :             .or.trim(solsym(j)) == 'ROOH' &
     109             :             .or.trim(solsym(j)) == 'TERPOOH' &
     110             :             .or.trim(solsym(j)) == 'TOLOOH' &
     111     3064320 :             .or.trim(solsym(j)) == 'XOOH' ) then
     112    37012608 :           prod_hydrogen_peroxides_out(:,:) = prod_hydrogen_peroxides_out(:,:) + prod_out(:,:,i)
     113             :        end if
     114             :     enddo
     115             : 
     116       21888 :     call outfld( 'H_PEROX_CHMP', prod_hydrogen_peroxides_out(:,:), ncol, lchnk )
     117             : 
     118       21888 :   end subroutine chem_prod_loss_diags_out
     119             : 
     120             : end module chem_prod_loss_diags
     121             : 

Generated by: LCOV version 1.14