Skip to content

Commit

Permalink
mods to fix fire emissions bug (#265)
Browse files Browse the repository at this point in the history
Fixes an issue with how coefficients are applied to individual fire components.
  • Loading branch information
fvitt authored Jan 20, 2022
1 parent 4322867 commit c03f5a4
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions cesm/nuopc_cap_share/shr_fire_emis_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ module shr_fire_emis_mod
character(len=name_len) :: name ! emissions component name (in fire emissions input table)
integer :: index
real(r8), pointer :: emis_factors(:) ! function of plant-function-type (PFT)
real(r8) :: coeff ! emissions component coeffecient
real(r8) :: molec_weight ! molecular weight of the fire emissions compound (g/mole)
type(shr_fire_emis_comp_t), pointer :: next_emiscomp ! points to next member in the linked list
endtype shr_fire_emis_comp_t
Expand All @@ -55,6 +54,7 @@ module shr_fire_emis_mod
type shr_fire_emis_mechcomp_t
character(len=16) :: name ! compound name
type(shr_fire_emis_comp_ptr), pointer :: emis_comps(:) ! an array of pointers to fire emis components
real(r8), pointer :: coeffs(:) ! coeffecients to emissions components
integer :: n_emis_comps ! number of fire emis compounds that make up the emissions for this mechanis compound
end type shr_fire_emis_mechcomp_t

Expand Down Expand Up @@ -96,7 +96,7 @@ subroutine shr_fire_emis_readnl( NLFileName, emis_nflds )
! corresponding chemical tracers.
!
!-------------------------------------------------------------------------

! input/output variables
character(len=*), intent(in) :: NLFileName ! name of namelist file
integer , intent(out) :: emis_nflds
Expand Down Expand Up @@ -125,12 +125,12 @@ subroutine shr_fire_emis_readnl( NLFileName, emis_nflds )
! If other processes have already initialized megan - then the info will just be re-initialized

call ESMF_VMGetCurrent(vm, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return

call ESMF_VMGet(vm, localPet=localPet, mpiCommunicator=mpicom, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return

! Note the following still needs to be called on all processors since the mpi_bcast is a collective
! Note the following still needs to be called on all processors since the mpi_bcast is a collective
! call on all the pes of mpicom
if (localPet==0) then
inquire( file=trim(NLFileName), exist=exists)
Expand Down Expand Up @@ -205,9 +205,12 @@ subroutine shr_fire_emis_init( specifier )
endif
shr_fire_emis_mechcomps(i)%n_emis_comps = item%n_terms
allocate(shr_fire_emis_mechcomps(i)%emis_comps(item%n_terms))
allocate(shr_fire_emis_mechcomps(i)%coeffs(item%n_terms))

shr_fire_emis_mechcomps(i)%coeffs(:) = item%coeffs(:)

do j = 1,item%n_terms
shr_fire_emis_mechcomps(i)%emis_comps(j)%ptr => add_emis_comp( item%vars(j), item%coeffs(j) )
shr_fire_emis_mechcomps(i)%emis_comps(j)%ptr => add_emis_comp( item%vars(j) )
enddo
shr_fire_emis_mechcomps_n = shr_fire_emis_mechcomps_n+1

Expand All @@ -224,10 +227,9 @@ end subroutine shr_fire_emis_init

!-------------------------------------------------------------------------

function add_emis_comp( name, coeff ) result(emis_comp)
function add_emis_comp( name ) result(emis_comp)

character(len=*), intent(in) :: name
real(r8), intent(in) :: coeff
type(shr_fire_emis_comp_t), pointer :: emis_comp

emis_comp => get_emis_comp_by_name(shr_fire_emis_linkedlist, name)
Expand All @@ -245,7 +247,6 @@ function add_emis_comp( name, coeff ) result(emis_comp)
emis_comp%index = shr_fire_emis_comps_n+1

emis_comp%name = trim(name)
emis_comp%coeff = coeff
nullify(emis_comp%next_emiscomp)

call add_emis_comp_to_list(emis_comp)
Expand Down

0 comments on commit c03f5a4

Please sign in to comment.