C**** SOAP3_EVAP_AREA
c
      subroutine soap3_evap_area( igrd, ncol_grid, nrow_grid,
     &                    nlay_grid, nlay_ems, evap_factors,
     &                   temperature, hoa_evap_emis, svoa_evap_emis,
     &                                            area_emis, numspcs)
      use chmstry
      implicit none
c
c----CAMx v7.40 260801
c
c-----------------------------------------------------------------------
c    Description:
c-----------------------------------------------------------------------
c
c     This routine applies factors to evaporate POA to SVOA and
c     updates the emissions array so emissions are injected into
c     the appropriate model species.
c
c      Copyright Ramboll
c
c     Input arguments:
c        igrd             grid index
c        ncol_grid        number of columns
c        nrow_grid        number of rows
c        nlay_grid        number of layers in grid
c        nlay_ems         number of layers in emissions foles
c        numspcs          number of model species
c        temperature      temperature in aloft layers
c        area_evap_emis   area emissions rate (grams/s)
c     Output arguments:
c        hoa_evap_emis    area emissions rate (grams/s)
c        svoa_evap_emis   area emissions rate (grams/s)
c
c-----------------------------------------------------------------------
c    LOG:
c-----------------------------------------------------------------------
c
c     02/20/24   --gwilson--    Original development
c
c-----------------------------------------------------------------------
c    Include files:
c-----------------------------------------------------------------------
c
      include 'camx.prm'
      include 'camx.inc'
      include 'soap3.inc'
c
c-----------------------------------------------------------------------
c    Argument declarations:
c-----------------------------------------------------------------------
c
      integer igrd
      integer ncol_grid
      integer nrow_grid
      integer nlay_grid
      integer nlay_ems
      integer numspcs
      real    evap_factors(3,NUM_SOAP_EMISS)
      real    temperature(ncol_grid,nrow_grid,nlay_grid)
      real    hoa_evap_emis(ncol_grid,nrow_grid,nlay_ems)
      real    svoa_evap_emis(ncol_grid,nrow_grid,nlay_ems)
      real    area_emis(ncol_grid,nrow_grid,nlay_ems,numspcs)
c
c-----------------------------------------------------------------------
c    External functions:
c-----------------------------------------------------------------------
c
c-----------------------------------------------------------------------
c    Local variables:
c-----------------------------------------------------------------------
c
      integer imod, iems
      integer icl, jcl, klay, isoa, ipt
      real    evap_fact, evap_mass, convfac
c
c-----------------------------------------------------------------------
c    Entry point:
c-----------------------------------------------------------------------

c
c  ---- don't change anything if SVOA or HOA not found ---
c
       if( idx_ems_svoa .LE. 0 ) goto 9999
c
c  --- loop over grid and update all affected species ----
c
       do klay=1,nlay_ems
         do jcl=1,nrow_grid
           do icl=1,ncol_grid
             hoa_evap_emis(icl,jcl,klay) = 0. 
             svoa_evap_emis(icl,jcl,klay) = 0. 
c
c  --- see if POA species was found ---
c
             do isoa=IDX_SOAP_POA_OP,IDX_SOAP_POA_BB
                if( idx_ems_soap3(isoa) .LE. 0 ) cycle
                if( area_emis(icl,jcl,klay,idx_ems_soap3(isoa)) .LE. 0 ) cycle
c
c ---- evaporate POA into SVOA ---
c
                 evap_fact = MIN(1.0,
     &                       (evap_factors(1,isoa) * temperature(icl,jcl,klay)**2 + 
     &                        evap_factors(2,isoa) * temperature(icl,jcl,klay) + 
     &                        evap_factors(3,isoa) ))
                 evap_mass = area_emis(icl,jcl,klay,idx_ems_soap3(isoa)) * 
     &                       (1. - evap_fact)
                 if( ksvoa .NE. 0 .and. ksvoa .NE. numspcs+1 )
     &                svoa_evap_emis(icl,jcl,klay) = 
     &                     svoa_evap_emis(icl,jcl,klay) + 
     &                                 MAX( 0.,evap_mass/mole_weight(ksvoa) )
c
c ---- back out the evap emissions from each POA species ---
c
                 hoa_evap_emis(icl,jcl,klay) = hoa_evap_emis(icl,jcl,klay) + 
     &              MAX( 0.,area_emis(icl,jcl,klay,idx_ems_soap3(isoa)) - evap_mass)
             enddo
           enddo
         enddo
       enddo
c
c-----------------------------------------------------------------------
c    Error messages:
c-----------------------------------------------------------------------
c
 9999 continue
      return
      end
