;----------------------------------------------------------------------- ;+ ; NAME: ; DUST_EM ; ; PURPOSE: ; Prints totals of GEOS-CHEM dust emissions for two different ; met field types so that we can scale the emissions accordingly. ; Based on FULLCHEM_EMISSIONS. ; ; CATEGORY: ; GEOS-CHEM Benchmarking ; ; CALLING SEQUENCE: ; DUST_EM ; ; INPUTS: ; None ; ; KEYWORD PARAMETERS: ; FILENEW -> Name of a binary punch file containing model ; output from a "New" version of the GEOS-CHEM. ; ; FILEOLD -> Name of a binary punch file containing model ; output from a "Old" version of the GEOS-CHEM. ; ; OUTFILENAME -> Name of the text file where emission totals ; and differences will be sent. Default is "emissions.txt". ; ; OUTPUTS: ; None ; ; SUBROUTINES: ; Internal Subroutines: ; ================================== ; GetVersionInfo (function) ; WriteHeader ; WriteTracers ; ; External Subroutines Required: ; ================================== ; CTM_SUM_EMISSIONS ; UNDEFINE ; ; REQUIREMENTS: ; References routines from both GAMAP and TOOLS packages. ; ; NOTES: ; (1) Assumes the version number is located at the end of ; both FILENEW and FILEOLD ; ; (2) Assumes that both FILENEW and FILEOLD contain the ; following GEOS-CHEM diagnostic categories: ; (a) ND11 ("ACETSRCE") (e) ND34 ("BIOFSRCE") ; (b) ND28 ("BIOBSRCE") (f) ND36 ("ANTHSRCE") ; (c) ND29 ("CO--SRCE") (g) ND46 ("BIOGSRCE") ; (d) ND32 ("NOX-AC-$", "NOX-AN-$", "NOX-BIOB", ; "NOX-FERT", "NOX-LI-$", "NOX-SOIL") ; (h) ND13 ("DMS-BIOG", "SO2-AC-$", "SO2-AN-$", ; "SO2-EV-$", "SO2-NV-$", "SO4-AN-$", ; "NH3-ANTH", "NH3-BIOB", "NH3-BIOG", ; "NH3-NATU", "SO2-SHIP") ; (i) ND06 ( ) ; (j) ND07 ("DUSTSRCE") ; (k) ND08 ("SALTSRCE") ; ; EXAMPLE: ; FULLCHEM_EMISSIONS, FILENEW='ctm.bpch.v6-02-05', $ ; FILEOLD='ctm.bpch.v6-02-04', $ ; OUTFILENAME='emissions.txt' ; ; ; Prints emissions & differences between ; ; versions 6-02-05 and 6-02-04 ; ; MODIFICATION HISTORY: ; bmy, 18 Jun 2001: VERSION 1.00 ; bmy, 20 Jun 2001: VERSION 1.01 ; - now omit ALD2 (#11) from ANTHROPOGENIC ; bmy, 20 Sep 2001: VERSION 1.02 ; - now print ND11 acetone sources, sinks ; bmy, 15 Aug 2002: VERSION 1.03 ; - renamed to FULLCHEM_EMISSIONS ; - renamed FILE_NEW to FILENEW and ; FILE_OLD to FILEOLD ; bmy, 17 Jan 2003: VERSION 1.04 ; - also sum up sulfate emission categories ; bmy, 27 Mar 2003: VERSION 1.05 ; - adjust FORMAT string for branch versions ; - now also print out NH3-NATU source ; bmy, 09 Apr 2004: VERSION 1.06 ; - Now print out emissions of BC/OC tracers ; - Now print out hydrophilic BC/OC which ; came from hydrophobic BC/OC ; bmy, 28 Apr 2004: VERSION 1.07 ; - Now print out dust emissions ; bmy, 03 May 2004: VERSION 1.08 ; - Now print out seasalt emissions ; bmy, 21 May 2004: VERSION 1.09 ; - Now print out ship exhaust SO2 emissions ; bmy, 08 Jul 2005: VERSION 1.10 ; - Updated for 43 tracers ; ;- ; Copyright (C) 2001-2005, Bob Yantosca, Harvard University ; This software is provided as is without any warranty ; whatsoever. It may be freely used, copied or distributed ; for non-commercial purposes. This copyright notice must be ; kept with any copy of this software. If this software shall ; be used commercially or sold as part of a larger package, ; please contact the author. ; Bugs and comments should be directed to bmy@io.harvard.edu ; with subject "IDL routine fullchem_emissions" ;----------------------------------------------------------------------- function GetVersionInfo, FileName ;==================================================================== ; Internal subroutine GetVersionInfo extracts the GEOS-CHEM ; version string (e.g. v4-15) from an input file name. ;==================================================================== ; Look for the last period in the FILENAME string Ind = StrPos( FileName, '.', /Reverse_Search ) ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ;%%% KLUDGE: just take the last 6 chars (geosfp/merra2) ;%%% ;%%% ;%%%; Version string is between the last period and the end of the string if ( Ind[0] ge 0 ) then begin Version = StrMid( FileName, Ind[0]+1, StrLen( FileName )-Ind[0]+1 ) endif else begin S = StrTrim( FileName ) + ' does not contain a version string!' Message, S endelse ;%%% ;Version = StrRight( FileName, 6 ) ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ; Return the version string to the main program return, Version end ;----------------------------------------------------------------------------- pro WriteHeader, Ilun, Title, Version_New, Version_Old ;==================================================================== ; Internal subroutine WriteHeader writes a header for each emissions ; category with a top title and also the version string information. ;==================================================================== ; Get string lengths Lnew = StrLen( Version_New ) Lold = StrLen( Version_Old ) ; Pick FORMAT string based on the length of the version strings if ( Lnew gt 5 AND Lold gt 5 ) then begin Format = '('' Tracer '',a6,6x,a6,7x,a6,'' - '',a6,2x,''Unit Scale Factor'')' endif else if ( Lnew gt 5 AND Lold le 5 ) then begin Format = '('' Tracer '',a6,6x,a5,8x,a6,'' - '',a5,3x,''Unit Scale Factor'')' endif else begin Format = '('' Tracer '',a5,7x,a5,7x,a5,'' - '',a5,4x,''Unit Scale Factor'')' endelse PrintF, Ilun, Title PrintF, Ilun, Version_New, Version_Old, Version_New, Version_Old, $ Format=Format PrintF, Ilun, ' ======================================================================' ; Return to main program return end ;----------------------------------------------------------------------------- pro WriteTracers, Ilun, New, Old, Advance=Advance ;==================================================================== ; Internal subroutine WriteTracers writes tracer sums and ; differences for a given emissions category. ;==================================================================== ; Error check if ( N_Elements( New ) ne N_Elements( Old ) ) then begin Message, 'NEW and OLD do not have the same # of elements!' endif ; Write totals & difference to OUTFILENAME for N = 0L, N_Elements( New ) - 1L do begin Scale_Factor = 1.0 / ( 1 + ( New[N].Sum - Old[N].Sum ) / Old[N].Sum ) PrintF, Ilun, New[N].Name, New[N].Sum, Old[N].Sum, $ New[N].Sum - Old[N].Sum, New[N].Unit, $ Scale_Factor, $ Format='(2x,a4,4x,f10.6,2x,f10.6,3x,f10.6,7x,a2,2x,f10.6)' endfor ; Write some spacers -- if /ADVANCE is set if ( Keyword_Set( Advance ) ) then begin PrintF, Ilun PrintF, Ilun endif ; Return to main program return end ;----------------------------------------------------------------------------- pro Dust_Em_Merra2, FileNew=FileNew, $ FileOld=FileOld, $ OutFileName=OutFileName ;==================================================================== ; Initialization ;==================================================================== ; Pass external functions FORWARD_FUNCTION GetVersionInfo ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ;%%% KLUDGE: Modified for testing GEOS-5 vs. MERRA ;%%% ;%%% Hardwire file names ; ;%%% For comparing GEOS-5 and MERRA2 ;Dir1 = '~/regal/MERRA2/dust_lightning/geos5_4x5_tropchem/bpch/' ;;FileOld = Dir1 + 'trac_avg.dustsrce.2005.geos5' ;FileOld = Dir1 + 'trac_avg.dustsrce.2012.geos5' ;Dir2 = '~/regal/MERRA2/dust_lightning/merra2_4x5_tropchem/bpch/' ;FileNew = Dir2 + 'trac_avg.dustsrce.2012.merra2' ;OutFileName = 'dust_em.merra2_geos5.log' ; ;%%% For comparing GEOS-FP and MERRA2 ;Dir1 = '~/regal/MERRA2/dust_lightning/geosfp_4x5_tropchem/bpch/' ;FileOld = Dir1 + 'trac_avg.dustsrce.geosfp' ;Dir2 = '~/regal/MERRA2/dust_lightning/merra2_4x5_tropchem/bpch/' ;FileNew = Dir2 + 'trac_avg.dustsrce.2013.merra2' ;OutFileName = 'dust_em.merra2_geosfp.log' ; ;%%% For comparing GEOS-5 and MERRA2 for nested NA ;Dir1 = '~/regal/MERRA2/dust_lightning/geos5_05x0666_tropchem_na/bpch/' ;FileOld = Dir1 + 'trac_avg.dustsrce.2012.geos5' ;Dir2 = '~/regal/MERRA2/dust_lightning/merra2_05x0625_tropchem_na/bpch/' ;FileNew = Dir2 + 'trac_avg.dustsrce.2012.merra2' ;OutFileName = 'dust_em.merra2_geos5.na.log' ; ;%%% For comparing GEOS-5 and MERRA2 for nested CH Dir1 = '~/regal/MERRA2/dust_lightning/geos5_05x0666_tropchem_ch/bpch/' FileOld = Dir1 + 'trac_avg.dustsrce.2011.geos5' Dir2 = '~/regal/MERRA2/dust_lightning/merra2_05x0625_tropchem_ch/bpch/' FileNew = Dir2 + 'trac_avg.dustsrce.2011.merra2_mod' OutFileName = 'dust_em.merra2_geos5.ch.log' ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ; Keyword settings if ( N_Elements( FileNew ) ne 1 ) then Message, 'FILENEW not passed!' if ( N_Elements( FileOld ) ne 1 ) then Message, 'FILEOLD not passed!' ; Get version information from input & output files Version_New = GetVersionInfo( FileNew ) Version_Old = GetVersionInfo( FileOld ) ; Default output file neame if ( N_Elements( OutFileName ) ne 1 ) $ then OutFileName = Version_New + '.emissions.txt' ;==================================================================== ; DUST emissions ;==================================================================== ; Open output file and get version strings from FILE_NEW and FILE_OLD Open_File, OutFileName, Ilun, /Write ; ==== Dust tracers ==== Tracer = [ 38, 39, 40, 41 ] CTM_Sum_Emissions, 'DUSTSRCE', $ File=FileNew, Tracer=Tracer, /Cum_Only, Result=New, /Kg, /No_Sec CTM_Sum_Emissions, 'DUSTSRCE', $ File=FileOld, Tracer=Tracer, /Cum_Only, Result=Old, /Kg, /No_Sec WriteHeader, Ilun, 'DUST EMISSIONS', Version_New, Version_Old WriteTracers, Ilun, New, Old, /Advance UnDefine, New UnDefine, Old ;==================================================================== ; Close file and quit ;==================================================================== quit: Close, Ilun Free_LUN, Ilun return end