LCOV - code coverage report
Current view: | top level - chemistry/mozart - chem_prod_loss_diags.F90 (source / functions) |  |  | Hit | Total | Coverage
Test: | coverage.info |  | Lines: | 32 | 38 | 84.2 %
Date: | 2024-12-17 22:39:59 |  | 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        1536 :   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        1536 :     call phys_getopts( history_scwaccm_forcing_out = history_scwaccm_forcing )
          26             :
          27       47616 :     do i = 1,clscnt4
          28       46080 :        j = clsmap(i,4)
          29       92160 :        call addfld( trim(solsym(j))//'_CHMP', (/ 'lev' /), 'I', '/cm3/s', 'chemical production rate' )
          30       92160 :        call addfld( trim(solsym(j))//'_CHML', (/ 'lev' /), 'I', '/cm3/s', 'chemical loss rate' )
          31       47616 :        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        3072 :     do i = 1,clscnt1
          41        1536 :        j = clsmap(i,1)
          42        3072 :        if (history_scwaccm_forcing ) then
          43           0 :           if ( trim(solsym(j))=='CH4' .or. &
          44             :                trim(solsym(j))=='CFC11' .or. &
          45           0 :                trim(solsym(j))=='CFC12' .or. &
          46             :                trim(solsym(j))=='N2O' ) then
          47           0 :              call add_default( trim(solsym(j))//'_CHML', 1, ' ')
          48             :           endif
          49             :        endif
          50             :     enddo
          51             :
          52        3072 :     call addfld('H_PEROX_CHMP', (/ 'lev' /), 'I', '/cm3/s', 'total ROOH production rate' ) !PJY changed "RO2" to "ROOH"
          53             :
          54        1536 :   end subroutine chem_prod_loss_diags_init
          55             :
          56             :   !-----------------------------------------------------------------------------
          57             :   !-----------------------------------------------------------------------------
          58     1489176 :   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     2978352 :     real(r8), dimension(ncol,pver,max(1,clscnt4)) :: prod_out, loss_out
          68     2978352 :     real(r8), dimension(ncol,pver) :: prod_hydrogen_peroxides_out
          69             :     integer :: lev, i, k, j, m
          70             :
          71   139982544 :     level_loop : do lev = 1,pver
          72  2314006344 :        column_loop : do i = 1,ncol
          73             :
          74             :           !-----------------------------------------------------------------------
          75             :           ! ... Prod/Loss history buffers...
          76             :           !-----------------------------------------------------------------------
          77 67533231168 :           cls_loop2: do k = 1,clscnt4
          78 65220714000 :              j = clsmap(k,4)
          79 65220714000 :              m = permute(k,4)
          80 65220714000 :              prod_out(i,lev,k) = prod_in(i,lev,m)
          81 67394737800 :              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  2314006344 :     prod_hydrogen_peroxides_out(:,:) = 0._r8
          87             :
          88    46164456 :     do i = 1,clscnt4
          89    44675280 :        j = clsmap(i,4)
          90 69420190320 :        prod_out(:,:,i) = prod_out(:,:,i)*xhnm(:,:)
          91 69420190320 :        loss_out(:,:,i) = loss_out(:,:,i)*xhnm(:,:)
          92    44675280 :        call outfld( trim(solsym(j))//'_CHMP', prod_out(:,:,i), ncol, lchnk )
          93    44675280 :        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    46164456 :             .or.trim(solsym(j)) == 'XOOH' ) then
         112           0 :           prod_hydrogen_peroxides_out(:,:) = prod_hydrogen_peroxides_out(:,:) + prod_out(:,:,i)
         113             :        end if
         114             :     enddo
         115             :
         116     1489176 :     call outfld( 'H_PEROX_CHMP', prod_hydrogen_peroxides_out(:,:), ncol, lchnk )
         117             :
         118     1489176 :   end subroutine chem_prod_loss_diags_out
         119             :
         120             : end module chem_prod_loss_diags
         121             :

Generated by: LCOV version 1.14