!#################################################################
!
!       purpose
!       -------
!       perform emissions needed for TM5 
!
!       interface
!       ---------
!       call declare_emission
!       call emission_apply
!       call free_emission
!
!       method
!       ------
!       subroutine declare_emission is called from ss_monthly_update
!       subroutine emission_apply   is called from sources_sinks_apply
!       subroutine free_emission    is called from trace_end
!
!### macro's #####################################################
!
#define TRACEBACK write (gol,'("in ",a," (",a,", line",i5,")")') rname, __FILE__, __LINE__; call goErr
#define IF_NOTOK_RETURN(action) if (status/=0) then; TRACEBACK; action; return; end if
#define IF_ERROR_RETURN(action) if (status> 0) then; TRACEBACK; action; return; end if
!
#include "tm5.inc"
!
!#################################################################

module emission

  use GO, only : gol, goPr, goErr
  
  use dims,      only: nregions

  implicit none
  
  
  ! --- in/out --------------------------------------------

  private

  public   :: declare_emission, emission_apply, free_emission


contains

   
  subroutine declare_emission
    !
    !       purpose
    !       -------
    !       allocate space needed to handle the emissions
    !
    !       interface
    !       ---------
    !       declare_emission is called from ss_monthly_update (start and newmonth)
    !
    !       method
    !       ------
    !       dynamic allocation, depending on dimensions problem
    !       opening of daily input files
    !       reading monthly/yearly emissions
    !       
    !---------------------------------------------------------------------   
     
    implicit none

  end subroutine declare_emission


  subroutine emission_apply(region)
  !
    implicit none
    !___________________IO_____________________
    integer, intent(in)        :: region
    !___________________local__________________
    
  end subroutine emission_apply

  subroutine free_emission(budget_file)
    !
    !       purpose
    !       -------
    !       deallocate space needed to handle the emissions
    !
    !       interface
    !       ---------
    !       call free_emission is called from trace_end
    !
    !       method
    !       ------
    !       collecting budgets on coarser budget regions
    !       writing budget file
    !       deallocation of memory
    !       closing of input files
    !---------------------------------------------------------------------   
   implicit none
   ! IO
   character(len=*)                         :: budget_file
   ! local
   end subroutine free_emission

end module emission
