R routines

All GAMAP Routines

List routines by category:
Atmospheric Sciences | Benchmarking | Color | Date/Time | Doc | File & I/O | BPCH Format | Scientific Data Formats | GAMAP Examples | GAMAP Internals | GAMAP Utilities | GAMAP Data Manipulation | GAMAP Models & Grids | GAMAP Plotting | General | Graphics | Math & Units | Plotting | Regridding | Strings | Structures | Time Series

List routines by alphabetical order:
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Last modified: Tue Apr 4 10:50:27 2017.


List of Routines


Routine Descriptions

RATIOS

[Next Routine] [List of Routines]
 NAME:
        RATIOS

 PURPOSE:
        Creates ratio plots ( New/Old ) for GEOS-Chem tracers and OH. 

 CATEGORY:
        Benchmarking

 CALLING SEQUENCE:
        RATIOS, FILES, LEVELS, TAUS, VERSIONS, [, Keywords ]

 INPUTS:
        FILES -> A 2-element vector containing the names of files
             from the "old" and "new" GEOS-Chem model versions
             that are to be compared. 

        LEVELS -> A 4-element vector containing the level indices
             for the GEOS-Chem surface layer and 500 hPa layer.
             for both models (e.g. SFC_1, SFC_2, 500_1, 500_2).
             NOTE: This is in Fortran notation (starting from 1!)

        TAUS -> A 2-element vector contaning TAU values (hours GMT
             from /1/1985) corresponding to the "old" and "new"
             GEOS-Chem model versions.

        TRACERS -> The list of transported tracers (i.e. diagnostic
             category "IJ-AVG-$").

        VERSIONS -> A 2-element vector containing the version
             numbers for the "old" and "new" GEOS-Chem model
             versions.

 KEYWORD PARAMETERS:
        /DO_FULLCHEM -> Set this switch to plot the chemically
             produced OH in addition to the advected tracers.

        /DYNRANGE -> Set this switch to create plots using the whole
             dynamic range of the data.  Default is to restrict
             the plot range from 0.5 to 2.0.

        /PS -> Set this switch to generate PostScript output.

        OUTFILENAME -> If /PS is set, will write PostScript output 
             to a file whose name is specified by this keyword.
             Default is "tracer_ratio.pro".

 OUTPUTS:
        None

 SUBROUTINES:
        Internal Subroutines Included:
        ===========================================
        ComputeRatios   PlotRatio

        External Subroutines Required:
        ============================================
        OPEN_DEVICE     CLOSE_DEVICE
        MULTIPANEL      COLORBAR_NDIV    (function)
        TVMAP           UNDEFINE 
        CTM_GET_DATA,   EXTRACT_FILENAME (function)     
     
 REQUIREMENTS:
        References routines from both GAMAP and TOOLS packages.
        
 NOTES:
        (1) Meant to be called from BENCHMARK_1MON.

 EXAMPLES:
        FILES    = [ 'ctm.bpch.v7-04-10', 'ctm.bpch.v7-04-11' ]
        LEVELS   = [ 1, 1, 13, 13 ]
        TAUS     = [ NYMD2TAU( 20010701 ), NYMD2TAU( 20010701 ) ]
        TRACERS  = INDGEN( 43 ) + 1
        VERSIONS = [ 'v7-04-10', 'v7-04-11' ]
 
        RATIOS, FILES, LEVELS, TAUS, TRACERS, VERSIONS, $
             /DO_FULLCHEM, /PS, OUTFILENAME='myplot.ps'

             ; Creates ratio plots of two GEOS-CHEM versions
             ; (in this case v7-04-11 / v7-04-11) for July 2001.
             ; Output is sent to PostScript file "myplot.ps".
             ; The min & max of the data will be fixed at -/+ 5%.

        RATIOS, FILES, LEVELS, TAUS, TRACERS, VERSIONS, $
             /DYNRANGE, /PS, OUTFILENAME='myplot.ps'

             ; Same as above, but this time the full dynamic range
             ; of the data will be displayed.


 MODIFICATION HISTORY:
        bmy, 14 Nov 2007: VERSION 1.01
                          - based on older routine "tracer_ratio.pro"
        bmy, 20 Nov 2007: VERSION 1.02
                          - Now draw out-of-bounds triangles for
                            the colorbar when using the "small"
                            data ranges.  New feature of TVMAP.;
        bmy, 07 May 2008: VERSION 1.03
                          - Now allow for comparing models on 2
                            different vertical grids.
        bmy, 08 Feb 2011: VERSION 1.04
                          - Now display in the top-of-plot title
                            if the dynamic range option is used.
        bmy, 08 Jun 2011: VERSION 1.05
                          - Now create log plots in range 0.5 - 2.0
                          - Added /DO_FULLCHEM keyword
                          - Adjust colorbar so that the 0.9 - 1.1
                            range shows up in white.
                          - Now restore !MYCT sysvar to previous
                            settings upon exiting the program
                          - Better adjust colorbar position for /PS
        mps, 29 Mar 2013: - Now plot HO2 ratios
 

(See /n/home09/ryantosca/IDL/gamap2/benchmark/ratios.pro)


READDATA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        READDATA

 PURPOSE:
        This subroutine reads in  almost any ASCII file and returns 
        two arrays containing the names of the variables and their 
        values.  The data is read line by line or in one step if 
        LINES is specified.

 CATEGORY:
        File & I/O

 CALLING SEQUENCE:
       READDATA, FILENAME, DATA, HEADER [, NCOL, NDAT ] [, KEYWORDS ]

 INPUTS:
       FNAME -> Name of fname to be read, e.g. 'flight12.dat'

 KEYWORD PARAMETERS:
       COLS -> number of columns to be read (must be used if no header 
             is read in, i.e. /NOHEADER is specified). Can be used
             to read in a subset of columns if the file contains a header
             line with variable names (i.e. if *not* /NOHEADER).

       LINES -> number of lines to be read (not much faster for large
             data sets, but allows to read in a subset of the data)

       DELIM -> Separator between names in the header (default=',')

       SKP1 -> Number of lines to be skipped before the variable 
             definition (default=0)

       SKP2 -> .. after the variable definition (default=0)

       SKIP -> same as SKP1 (SKP1 will overwrite SKIP. SKIP may be
             not longer supported in future versions !)

       AUTOSKIP  -> for files that state the number of comment lines 
             in the first line. If keyword NOHEADER is not set, READDATA 
             expects a list of variable names as last comment line.
             AUTOSKIP overrides settings of SKP1 and SKP2.

       TRANSPOSE -> Normally, 1st array dimension is for variables, 
             2nd is for observations. /TRANSPOSE will reverse that 
             order (see note).

       NOHEADER -> don't read a header (COLS must be specified in 
             this case !)

       NODATA -> don't read data (stop after header). DATA parameter 
             must still be specified !

       COMMENTS -> returns string array of all the comment lines in 
             the data file for later use

       MAXCOMMENTS -> limits maximum number of comment lines to be 
             retrieved (default: 255)

       QUIET -> Normally, READDATA prints the number of variables 
             found and  number of data lines read.  Use this option 
             to suppress all output.

       /DOUBLE -> If set, will return data in double precision.
             (Default is to return data in single precision.)

       NAN_REPLACEMENT -> Allows you to provide a replacement value
             for the following types of missing data fields: NaN,
             nan, NA, na, Infinity, infinity, Missing, missing.

 OUTPUTS:
       DATA -> data array that was read in

       NAMES -> string array of names in header

       NCOL -> integer containing the number of columns

       NDAT -> long integer containing the number of observations

       COMMENTS  -> string array containing all header lines.  
             If AUTOSKIP is set, skp1, and skp2 will contain the 
             actual amount of lines to skip (e.g. for re-storing 
             header information in EXPLORE)

 SUBROUTINES:
      External Subroutines Required:
      ==============================
      OPEN_FILE
      STRBREAK (function)
      USAGE

 REQUIREMENTS:
      None

 NOTES:
      Default of the returned DATA array is: 1st index = variable, 
      2nd index = observation. Use the /TRANSPOSE option for reverse order

      If /NOHEADER is used, then COLS must specify the actual number of
      data columns in FNAME. Otherwise it can be used to read a subset of 
      the data from 0 to cols-1 columns.

      IDL Parameters are optional. Of course, you should not readdata without
      passing a DATA argument, but you can ignore the HEADER,NCOL, and NDAT 
      params.

 EXAMPLES:
      (1)
      READDATA,'mydata.dat',DATA,HEADER,DELIM=' ',SKIP=5

      ... will read in the ASCII file mydata.dat and store the data in DATA.
      The header information will be stored in HEADER. The header items are
      seperated by blank spaces, and the first 5 lines should be ignored.
      To pick a certain variable afterwards, type:
      VAR = DATA(WHERE HEADER EQ 'MYVAR'),*)

      (2)
      READDATA,'noheader.dat',DATA,DELIM=';',NCOLS=3

      ... will read a three column ASCII file with no header information.
      You can manually make up a header with 
      HEADER = ['VAR1','VAR2','VAR3'] 
      or you can pass the HEADER argument and receive ['X1','X2','X3'] as
      header.

      (3)
      READDATA,'mydata.dat',DATA,HEADER,DELIM=' ',SKP1=5,LINES=60,COLS=4, $
         COMMENTS=COMMENTS

      ... will read in 60 lines and 4 columns of the ASCII file mydata.dat 
      and return 6 comment lines in COMMENTS (5 + variable names)


 MODIFICATION HISTORY:
         mgs  03/12/1997: - last update : 05/22/97
         mgs 01 Aug 1997: - added template
         mgs 15 Sep 1997: - added LINES option and removed some twitch in the
                            handling of TRANSPOSE. Unfortunately,
                            LINES does not improve the speed as
                            desired, but you can restrict the reading to
                            a smaller subset of the data.
         mgs 26 Sep 1997: MAJOR REVIEW
                          - bug fixes in noheader option
                          - bug fixes in COLS and NCOL handling
                          - removed units option and created comments 
                            keyword instead.  program now reads in
                            all header lines into a string array
                            including the variable names line.
                          - automatic generation of a header if 
                            /NOHEADER is specified
         mgs 06 Nov 1997: - Added AUTOSKIP option for easier reading 
                            of e.g. NASA formatted files.
         mgs 01 Dec 1997: added MAXCOMMENTS keyword and limit
                          - skp1 now returns correct amount if
                            autoskip is set
         mgs 30 Dec 1997: added NODATA keyword
         mgs 21 Aug 1998: now uses open_file routine to allow wildcards
         bmy 12 May 2005: added /DOUBLE keyword to force double precision
  bmy & phs, 21 Aug 2007: GAMAP VERSION 2.10
                          - Now use STRBREAK, which is version independent
                          - Remove internal function USE_READDATA; we
                            now call USAGE to display program options
                            if the wrong # of arguments are passed
                          - Updated comments
        bmy, 12 Dec 2012: GAMAP VERSION 2.16 
                          - Now give the user the option to read in
                            data as characters and then to strip out
                            strings such as "NaN" or "NA" via the
                          - NAN_REPLACEMENT keyword

(See /n/home09/ryantosca/IDL/gamap2/file_io/readdata.pro)


READ_BDT0001

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        READ_BDT0001

 PURPOSE:
        Read a simple binary data file with size information
        and variable names and units (format BDT0001).

 CATEGORY:
        File & I/O

 CALLING SEQUENCE:
        READ_BDT0001,filename,data,vardesc,nvars,nlines [,keywords]

 INPUTS:
        FILENAME -> Name of the file to read or a file mask that
            will be used in the PICKFILE dialog (see OPEN_FILE)
            If FILENAME is a named variable, the actual filename
            will be returned and replace a template.

 KEYWORD PARAMETERS:
        NAMES -> a named variable will contain a string array with
            NVARS variable names

        UNITS -> ... a string array with NVARS physical units

        COMMENTS -> A named variable that will return comment lines
            stored in the data file. NOTE that comments are not
            saved in vardesc.

        DEFAULTMASK -> Default mask for PICKFILE dialog (see
            OPEN_FILE).

        FILE_ID -> A named variable will return the file identifier
            string (80 characters). This string will be returned
            even if the file is of wrong type and no data was read.

        TYPE -> A named variable will contain the data type

        _EXTRA keywords are passed on to OPEN_FILE

 OUTPUTS:
        DATA -> an array with NLINES * NVARS values. The type of the
            data array depends on the information stored in the file.

        VARDESC -> A variable descriptor structure (see GTE_VARDESC)

        NVARS -> number of variables in file

        NLINES -> number of data lines


 SUBROUTINES:

 REQUIREMENTS:
        Uses OPEN_FILE

 NOTES:
        See also WRITE_BDT0001

        Format specification:
        file_ID  :      80 byte character string
        NVARS, NLINES, NCOMMENTS, TYPE : 4 byte integer (long)
        NAMES :         NVARS*40 byte character string
        UNITS :         NVARS*40 byte character string
        COMMENTS :      NCOMMENTS records of 80 byte length
        DATA  :         8 byte float (double) array NLINES*NVARS

 EXAMPLE:
        READ_BDT0001,'~/tmp/*.bdt',data,vardesc,comments=comments

        ; Will read a file that the user selects with the PICKFILE
        ; dialog. No information about the actual filename is
        ; returned.

        FILE = '~/tmp/*.bdt'
        READ_BDT0001,FILE,data,vardesc,nvars,nlines,file_id=file_id

        ; Does the same thing, but this time FILE will contain the
        ; actual filename. The number of variables and lines are
        ; returned in NVARS and NLINES, the file identifier string
        ; is returned in file_id

 MODIFICATION HISTORY:
        mgs, 24 Aug 1998: VERSION 1.00
        mgs, 23 Dec 1998: VERSION 1.10:
                          - DATA now undefined if unsuccessful
  bmy & phs, 13 Jul 2007: GAMAP VERSION 2.10
        bmy, 02 Apr 2008: GAMAP VERSION 2.12
                          - Now read data as big-endian

(See /n/home09/ryantosca/IDL/gamap2/file_io/read_bdt0001.pro)


READ_BIN AND PLOT_BIN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        READ_BIN  and  PLOT_BIN

 PURPOSE:
        Read a simple binary 2-D file. The file must be F77 
        unformatted and contain the XDIM and YDIM information
        as LONG integers in the first record.

 CATEGORY:
        File & I/O

 CALLING SEQUENCE:
        READ_BIN,FILENAME,DATA [,keywords]
        PLOT_BIN,DATA [,keywords]

 INPUTS:
        FILENAME -> Name of the file to read

        DATA (for PLOT_BIN) -> The data array as read with READ_BIN 

 KEYWORD PARAMETERS:
        XDIM, YDIM -> return the dimensions of the data set.

        _EXTRA -> used to pass extra keywords to OPEN_FILE. Probably
              only useful with /SWAP_ENDIAN.

        /PLOT -> Call PLOT_BIN directly.

        (for PLOT_BIN)
        MIN, MAX -> minimum and maximum to be used for conversion of
              data to a byte array for display with TVIMAGE

        TOP -> top value for BYTSCL

        CT -> colortable numebr to use

        /MAP -> set this keyword to overlay a map (isotropic cylindrical
              projection)

 OUTPUTS:
        DATA -> The data array returned from READ_BIN

 SUBROUTINES:
        Uses OPEN_FILE and TVIMAGE

 REQUIREMENTS:
        None

 NOTES:
        Rather primitive program but demonstrates the principle use
        of binary data files and TVIMAGE.

 EXAMPLES:
        READ_BIN,'~/mydata/*.bdat', DATA
        PLOT_BIN, DATA, MIN=MIN(DATA,MAX=M), MAX=M

        ; is equivalent to 
        READ_BIN, '~/mydata/*.bdat', DATA, /PLOT

 MODIFICATION HISTORY:
        mgs, 15 Jan 1999: VERSION 1.00
        mgs, 15 Jun 1999: - added header
                          - added PLOT keyword and _EXTRA
  bmy & phs, 13 Jul 2007: GAMAP VERSION 2.10
        bmy, 02 Apr 2008: GAMAP VERSION 2.12
                          - Now read data as big-endian
             

(See /n/home09/ryantosca/IDL/gamap2/file_io/read_bin.pro)


READ_CONC_RANGE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        READ_CONC_RANGE

 PURPOSE:
        Reads a file containing default plotting range for given 
        GEOS-Chem tracers.  This will be used to create absolute 
        difference plots for GEOS-Chem benchmarking.

 CATEGORY:
        Benchmarking

 CALLING SEQUENCE:
        READ_CONC_RANGE, INPUTFILE

 INPUTS:
        INPUTFILE -> Name of the file that contains the default
             plotting ranges for each GEOS-Chem tracer.  Default
             is "diff_range.1mon".

 KEYWORD PARAMETERS:
        None

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        ================================
        OPEN_FILE   STRBREAK (function)

 REQUIREMENTS:
        READ_CONC_RANGE must be called first to read the file with
        default plotting ranges.  This is normally done at the top
        of driver routine BENCHMARK_1MON.  After this has been done,
        function GET_CONC_RANGE may be used to return the default
        plotting range from within another program.

 NOTES:
        (1) Meant to be used in conjunction with the GEOS-Chem 
            benchmark plotting codes.
 
        (2) Default ranges for each tracer are read from a file by 
            this routine and stored in the GDR common block.

 EXAMPLE:
        READ_CONC_RANGE, 'conc_range.1mon'
        GET_CONC_RANGE, 'NOx', THIS_LOBOUND, THIS_HIBOUND, UNIT
        PRINT*, THIS_LOBOUND, THIS_HIBOUND, UNIT
            -0.100000  0.100000, ppbv
   
            ; Prints the default plotting range for NOx

 MODIFICATION HISTORY:
        bmy, 05 Sep 2012: VERSION 1.00
        bmy, 24 Jan 2014: GAMAP VERSION 2.17
                          - Updated comments

(See /n/home09/ryantosca/IDL/gamap2/benchmark/read_conc_range.pro)


READ_DIFF_RANGE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        READ_DIFF_RANGE

 PURPOSE:
        Reads a file containing default plotting range for given 
        GEOS-Chem tracers.  This will be used to create absolute 
        difference plots for GEOS-Chem benchmarking.

 CATEGORY:
        Benchmarking

 CALLING SEQUENCE:
        READ_DIFF_RANGE, INPUTFILE

 INPUTS:
        INPUTFILE -> Name of the file that contains the default
             plotting ranges for each GEOS-Chem tracer.  Default
             is "diff_range.1mon".

 KEYWORD PARAMETERS:
        None

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        ================================
        OPEN_FILE   STRBREAK (function)

 REQUIREMENTS:
        READ_DIFF_RANGE must be called first to read the file with
        default plotting ranges.  This is normally done at the top
        of driver routine BENCHMARK_1MON.  After this has been done,
        function GET_DIFF_RANGE may be used to return the default
        plotting range from within another program.

 NOTES:
        (1) Meant to be used in conjunction with the GEOS-Chem 
            benchmark plotting codes.
 
        (2) Default ranges for each tracer are read from a file by 
            this routine and stored in the GDR common block.

 EXAMPLE:
        READ_DIFF_RANGE, 'diff_range.1mon'
        PRINT, GET_DIFF_RANGE( 'NOx' )
            -0.100000  0.100000
   
            ; Prints the default plotting range for NOx

 MODIFICATION HISTORY:
        bmy, 14 Nov 2007: VERSION 1.00

(See /n/home09/ryantosca/IDL/gamap2/benchmark/read_diff_range.pro)


READ_EPTOMS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        READ_EPTOMS

 PURPOSE:
        Read Earth Probe TOMS data as retrieved from 
        http://jwocky.gsfc.nasa.gov and store them as datainfo
        records so that they can be displayed with GAMAP.

 CATEGORY:
        GAMAP Utilities, GAMAP Data Manipulation

 CALLING SEQUENCE:
        READ_EPTOMS [,DATA] [,keywords]

 INPUTS:

 KEYWORD PARAMETERS:
        FILENAME -> filename of TOMS data

        DATAINFO -> A named variable will return the newly
             created daatinfo structure.

        MODELINFO, GRIDINFO -> named variables will return 
             the "model" and grid information for the EP-TOMS
             data. The grid is a 2-dimensional "generic" grid.

 OUTPUTS:
        DATA -> contains 2D array with EP-TOMS data (for use without
             GAMAP).

 SUBROUTINES:
        uses open_file, ctm_type, ctm_grid, ctm_make_datainfo

 REQUIREMENTS:
        None

 NOTES:
        For tropical ozone in March, I used the following options
        in the call to GAMAP:
           myct,27,ncol=32,bot=20,range=[0.15,0.8]
           c_lev = [150,200,220,230,240,250,260,270,280,  $
                    290,300,310,320,330,340,350,375,400]
           gamap,/nofile,c_lev=c_lev,c_col=[0,17,2*indgen(21)+18],  $
                    /cbar,mlinethick=2,ncolors=32,bottom=18,  $
                    cbmin=220,cbmax=400,div=10  [,frame0=4]
           
           (the frame0 keyword is used to save GIF files)

 EXAMPLE:
        read_eptoms,file='/data/pem-tb/satellite/eptoms/*.ept'
        gamap [... options]

 MODIFICATION HISTORY:
        mgs, 02 Apr 1999: VERSION 1.00
  bmy & phs, 13 Jul 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/gamap_util/read_eptoms.pro)


READ_H5DATASET

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        READ_H5DATASET

 PURPOSE: 
        Convenience routine to read dataset variables 
        from Hierarchical Data Format version 5 (HDF5) files.
        Also works for HDF-EOS files!

 CATEGORY:
        File & I/O, Scientific Data Formats

 CALLING SEQUENCE:
        DATAFIELD = READ_H5DATASET( FID, DATASET_NAME )

 INPUTS:
        FID -> HDF5 File ID, as returned by routine H5F_OPEN

        DATASET_NAME -> Name of the scientific dataset variable that
             you want to extract from the file.  

 KEYWORD PARAMETERS:
        None

 OUTPUTS:
        DATAFIELD -> Array containing extracted data from the HDF file.

 SUBROUTINES:
        None

 REQUIREMENTS:
        Need to use a version of IDL w/ HDF5 library installed.

 NOTES:
        From Trevor Beck (trevor.beck@noaa.gov) for GOME-2.
        
 EXAMPLE:

        ; Specify the file name
        FILE = 'GOME_xxx_1B_M02_20070105012056Z_20070105030556Z_R_O_20080613081807Z.337p4_356p1.brs.hcho.he5'

        ; Make sure the file is a HDF5 file
        IF ( H5F_IS_HDF5( FILE ) eq 0 ) then MESSAGE, 'Not an HDF-5 file!'

        ; Open the HDF file and get the file ID # (FID)
        FID = H5F_OPEN( FILE ) 
        IF ( FID lt 0 ) then MESSAGE, 'Error opening file!'

        ; Read the AMF field from disk
        ; NOTE: the swath name is "Column"
        AMF = READ_H5DATASET( FID, "/Column/Amf" )

        ; Close the file 
        H5_CLOSE, FID

 MODIFICATION HISTORY:
        bmy, 28 May 2009: VERSION 1.00

(See /n/home09/ryantosca/IDL/gamap2/file_io/read_h5dataset.pro)


READ_MLD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        READ_MLD

 PURPOSE:
        Read Ocean mixed layer depth data as retrieved from 
        http://www.nodc.noaa.gov/OC5/mixdoc.html and store 
        them as datainfo records so that they can be displayed 
        with GAMAP.

 CATEGORY:
        GAMAP Utilities, GAMAP Data Manipulation

 CALLING SEQUENCE:
        READ_MLD [,DATA] [,keywords]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        FILENAME -> filename of MLD data

        DATAINFO -> A named variable will return the newly
             created daatinfo structure.

        MODELINFO, GRIDINFO -> named variables will return 
             the "model" and grid information for the EP-TOMS
             data. The grid is a 2-dimensional "generic" grid.

 OUTPUTS:
        DATA -> contains 2D array with mixed layer depth data 
             (for use without GAMAP).

 SUBROUTINES:
        uses open_file, ctm_type, ctm_grid, ctm_make_datainfo

 REQUIREMENTS:
        None

 NOTES:
        In the call to GAMAP you must use the /NOFILE option.

 EXAMPLE:
        READ_MLD, FILE='~/download/mixed_layer_depth/mld*'
        GAMAP, /NOFILE, ...

 MODIFICATION HISTORY:
        mgs, 30 Jun 1999: VERSION 1.00 (derived from read_eptoms)
  bmy & phs, 13 Jul 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/gamap_util/read_mld.pro)


READ_SONDE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        READ_SONDE

 PURPOSE:
        Read climatological ozone sonde data as compiled by 
        Jennifer A. Logan at Harvard University.
        If successful, the procedure returns a structure 
        with all information from a sondeXXX.* file.
        Ozone concentrations are automatically converted to ppbv.
        The data can be downloaded via ftp from io.harvard.edu
        path= pub/exchange/sonde. Please read the README files!

 CATEGORY:
        Atmospheric Sciences, File & I/O

 CALLING SEQUENCE:
        READ_SONDE,filename,data

 INPUTS:
        filename -> Name of the file containing the sonde data.
            This parameter can contain wildcards (*,?) in which case
            a file selection dialog will be displayed. If filename
            is a variable, it will be replaced by the actual filename
            that was opened.

 KEYWORD PARAMETERS:
        MBAR -> return ozone concentrations in mbar rather than ppbv

        STATIONS -> Can be used either as input or output for a list
            of station codes, locations and names as retrieved with
            procedure read_sondestations. STATIONS must be specified
            (or is returned) as an array of structures.

 OUTPUTS:
        DATA -> A structure containing the following fields:
                TITLE           STRING    'Ozone sonde data'
                STATION         STRING    
                STATIONCODE     INT       
                TIMERANGE       STRING    

(See /n/home09/ryantosca/IDL/gamap2/atm_sci/read_sonde.pro)


READ_SONDESTATIONS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        READ_SONDESTATIONS

 PURPOSE:
        Retrieve station codes and geographical locations for 
        ozone sonding stations as listed in file station.codes
        from Jennifer A. Logan's ozone sonde climatology.
        This routine is called from procedure READ_SONDE, and
        only needs to be called explicitely if the station.codes
        file resides neither in the current directory nor the 
        directory of the sonde data files.
        The procedure will read the file station.codes once then
        store the information in a common block for later use.

 CATEGORY:
        Atmospheric Sciences, File & I/O

 CALLING SEQUENCE:
        READ_SONDESTATIONS,stations [,filename]

 INPUTS:
        FILENAME (optional) -> if given, it specifies the path and filename
              of the file that is normally called station.codes.
              FILENAME may contain wildcards (*,?) in which case a 
              file selector dialog is displayed. 

 KEYWORD PARAMETERS:
        None

 OUTPUTS:
        STATIONS -> An array with structures containing the stations
              codes (integer), latitude, longitude, altitude (float),
              amd name (string). 

 SUBROUTINES:
        Uses OPEN_FILE and EXTRACT_FILENAME (used in OPEN_FILE)

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        read_sondestations,stations,'station.codes'
        ; if called for the first time, reads file station.codes
        ; and returns information for all stations in stations.
        ; NOTE: In this case, the filename argument could have been
        ; omitted.


 MODIFICATION HISTORY:
        mgs, 02 Nov 1998: VERSION 1.00
  bmy & phs, 13 Jul 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/atm_sci/read_sondestations.pro)


RECTANGLE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        RECTANGLE

 PURPOSE:
        Converts a vector with corner coordinates into X and Y 
        vectors that can be used with PLOTS, POLYFILL, or similar
        IDL plotting commands.
     
 CATEGORY:
        Plotting

 CALLING SEQUENCE:
        RECTANGLE, CORNERS, XVEC, YVEC [, Keywords ]

 INPUTS:
        CORNERS -> A 1-D vector with [ X0, Y0, X1, Y1 ] coordinates.
             (X0,Y0) is the bottom left corner of the plot region and
             (X1,Y1) is the top right corner of the plot region.

 KEYWORD PARAMETERS:
        EXPAND -> A value that will be used to expand the size 
             of the rectangle by the same amount on all sides.
             Default is 0.
 
 OUTPUTS:
        XVEC -> A 1-D vector with the X-coordinates listed in the
             proper order for the POLYFILL or PLOTS commands.
 
        YVEC -> A 1-D vector with the X-coordinates listed in the
             proper order for the POLYFILL or PLOTS commands.

 SUBROUTINES:
        None

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:         
        ; Get a plot position vector from MULTIPANEL
        MULTIPANEL, 2, POSITION=POSITION
        PRINT, POSITION
             0.112505   0.0874544  0.466255  0.956280

        ; Convert to X and Y vectors for PLOTS input
        RECTANGLE, POSITION, XPOINTS, YPOINTS
        PRINT, XPOINTS
             0.112505   0.466255   0.466255  0.112505  0.112505
        PRINT, YPOINTS
             0.0874544  0.0874544  0.956280  0.956280  0.0874544

        ; Call PLOTS to draw a box
        PLOTS, XPOINTS, YPOINTS, THICK=2, COLOR=1, /NORMAL

 MODIFICATION HISTORY:
        mgs, 13 Apr 1998: INITIAL VERSION
  bmy & phs, 13 Jul 2007: GAMAP VERSION 2.10
                          - Updated comments, cosmetic changes

(See /n/home09/ryantosca/IDL/gamap2/plotting/rectangle.pro)


REGRIDAVHRR_LAI

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDAVHRR_LAI

 PURPOSE:
        Regrids LAI from a 0.5 x 0.5 grid onto a
        CTM grid of equal or coarser horizontal resolution.
        
 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDAVHRR_LAI [, Keywords ]

 INPUTS:
        NONE

 KEYWORD PARAMETERS:
        YEAR (string) -> 4 character string for the year in process

        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        OUTDIR -> Name of the directory where the output file will
             be written.  Default is './'.  

 OUTPUTS:
        Writes files:
             vegtype.global
             lai{MONTHNUM}.global
             lai.global.{YEAR}.bpch
  
 SUBROUTINES:
        External Subroutines Required:
        ===============================================
        CTM_TYPE   (function)   CTM_GRID (function)
        CTM_RESEXT (function)   CTM_GETWEIGHT
        CTM_Make_DataInfo (function)
        CTM_WriteBpch (fucntion)
        nymd2tau   (function)

        Internal Subroutines:
        ==============================
        RL_GETWEIGHT

 REQUIREMENTS:
        References routines from both GAMAP and TOOLS directories

 NOTES:
        (1) Filenames are hardwired -- change as necessary
        (2) Regridding can take a while, especially at 1x1 resolution.

 EXAMPLE: 
        REGRIDAVHRR_LAI, '2000', MODELNAME='GEOS1', RES=2, OUTDIR='~/scratch/bmy/'
 
             ; Regrids 1 x 1 NOx fertilizer data onto the GEOS-1
             ; 2 x 2.5 resolution grid.  The output file will be
             ; written to the '~/scratch/bmy/' directory.

 MODIFICATION HISTORY:
        bmy, 04 Aug 2000: VERSION 1.00
                          - adapted from old FORTRAN code
        bmy, 15 Jan 2003: VERSION 1.01
                          - renamed to "regridh_lai.pro"
                          - renamed MODELNAME to OUTMODELNAME
                          - renamed RESOLUTION to OUTRESOLUTION
        tmf, 18 Jun 2003: VERSION 2.00
                          - adapted from bmy's "regridh_lai.pro"
                          - renamed to "regridavhrr.pro" 
                          - modified to read in Boston University's
                            0.5x0.5 AVHRR LAI    
                          - modified to output bpch files on CTM grid   
                            at the same time

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridavhrr_lai.pro)


REGRIDH_3D_OH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_3D_OH

 PURPOSE:
        Horiziontally regrids 3-D OH data from one CTM grid to another.
        
 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_3D_OH [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing OH data to be 
             regridded.  If not specified, then a dialog box 
             will ask the user to supply a file name.

        OUTFILENAME -> Name of file to contain the regridded OH.
             If not specified, then REGRID_3D_OH will use default 
             output file name "OH_3Dglobal.{MODELNAME}.{RESOLUTION}".

        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.  If
             OUTMODELNAME is not specified, then REGRID_3D_OH will
             use the same model name as the input grid.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        ==============================================
        CTM_TYPE    (function)   CTM_GRID   (function)
        CTM_NAMEXT  (function)   CTM_RESEXT (function)
        CTM_REGRIDH (function)

 REQUIREMENTS:
        References routines from both GAMAP and TOOLS packages

 NOTES:
        (1) The merged OH file is generated by "merge_oh.pro".

 EXAMPLE:
        REGRIDH_3D_OH, INFILENAME='OH_3Dglobal.geos3.2x25', $
                       OUTFILENAME='OH_3Dglobal.geos3.4x5', $
                       OUTRESOLUTION=4

             ; Horizontally regrids 3-D OH file from the GEOS-3
             ; 2 x 2.5 grid to the GEOS-3 4 x 5 grid.
              
 MODIFICATION HISTORY:
        bmy, 12 Sep 2002: VERSION 1.01
        bmy, 22 Dec 2003: VERSION 1.02
                          - totally rewritten for GAMAP v2-01
                          - now call PTR_FREE to free the memory
                          - added DIAGN keyword

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_3d_oh.pro)


REGRIDH_AEROSOL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_AEROSOL

 PURPOSE:
        Horiziontally regrids aerosol concentrations from
        one CTM grid to another.  Total mass is conserved.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_AEROSOL [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        MONTH -> Month of year for which to process data.
             Default is 1 (January).

        INFILENAME -> Name of the file containing data to be regridded.
             If omitted, then REGRIDH_AEROSOL will prompt the user to
             select a filename with a dialog box.

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  If OUTMODELNAME is not specified, 
             REGRIDH_AEROSOL will use the same model name as the
             input grid.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  OUTRESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        OUTFILENAME -> Name of the file which will contain the
            regridded data.  

        DIAGN -> Diagnostic category of the data blocks that you 
            wish to regrid.  Default is "ARSL-L=$".

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        =================================================
        CTM_GRID    (function)   CTM_TYPE          (function)
        CTM_REGRIDH (function)   CTM_NAMEXT        (function)   
        CTM_RESEXT  (function)   CTM_MAKE_DATAINFO (function)
        CTM_GET_DATA             CTM_WRITEBPCH            
        GETMODELANDGRIDINFO      UNDEFINE

 REQUIREMENTS:
        References routines from the GAMAP and TOOLS packages.

 NOTES:
        (1) It is best to regrid the aeorsol dust files 1 month
            at a time, since it can take quite a while to regrid
            all of the tracers and levels.  One can then use GAMAP
            to concatenate the monthly files.

        (2) Aerosol concentrations are used in the photolysis code
            since they also cause the incoming solar radiation
            to be scattered out of a column.

        (3) Assumes that the input file is already in binary punch
            format.  To regrid data directly from Paul Ginoux's
            GOCART model simulations, use "regridh_dust.raw.pro".

 EXAMPLE:
        REGRIDH_AEROSOL, INFILENAME='aerosol.geos3.2x25', $
                         OUTFILENAME='aerosol.geos3.4x5', $
                         OUTRESOLUTION=4, MONTH=1
           
             ; Regrids January aerosol data from 2 x 2.5 GEOS-3
             ; resolution to 4 x 5 resolution.

 MODIFICATION HISTORY:
        bmy, 15 Jan 2003: VERSION 1.01
        bmy, 22 Dec 2003: VERSION 1.02
                          - rewritten for GAMAP v2-01
                          - call PTR_FREE to free the pointer heap memory 
                

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_aerosol.pro)


REGRIDH_AIRCRAFT_DATA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_AIRCRAFT_DATA

 PURPOSE:
        Driver program for routines REGRIDH_AIRCRAFT_NOX 
        and REGRIDH_AIRCRAFT_FUEL.  

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_AIRCRAFT_DATA [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        /NOX -> Set this switch to regrid aircraft NOx data.

        /SOx -> Set this switch to regrid aircraft SOx data.

        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the NOx emissions will be regridded.
             Default is 'GEOS3'.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the NOX emissions will be regridded.  
             OUTRESOLUTION can be either a 2 element vector with 
             [ DI, DJ ] or a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 
             1=1x1, 0.5=0.5x0.5).  Default is 1.

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        ================================
        REGRIDH_AIRCRAFT_NOX  (function)
        REGRIDH_AIRCRAFT_FUEL (function)

 REQUIREMENTS:
        References routines from the GAMAP and TOOLS packages.

 NOTES:
        Input & output directories are hardwired for now, 
        you can change them as is necessary.

 EXAMPLE:
        REGRIDH_AIRCRAFT_DATA, /NOX,                 $
                               OUTMODELNAME='GEOS3', $
                               OUTRESOLUTION=1
           
             ; Regrids aircraft NOx data from native
             ; resolution to GEOS-3 1x1 grid.

 MODIFICATION HISTORY:
        bmy, 23 Dec 2003: VERSION 1.01
                          - Initial version
        bmy, 28 Apr 2008: GAMAP VERSION 2.12
                          - Corrected typo at line 142
                                

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_aircraft_data.pro)


REGRIDH_AIRCRAFT_FUEL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_AIRCRAFT_FUEL

 PURPOSE:
        Regrids aircraft  emissions to GEOS-CHEM grid resolution.
        Can also trim to nested-grid resolution if necessary.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_AIRCRAFT_FUEL [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the input file containing data to be 
             trimmed down to "nested" model grid resolution.  If 
             omitted, a dialog box will prompt the user to supply
             a filename.

        OUTFILENAME -> Name of the file that will contain trimmed
             data on the "nested" model grid.  OUTFILENAME will be
             in binary punch resolution.  If omitted, a dialog box 
             will prompt the user to supply a filename.

        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the NOx emissions will be regridded.
             Default is 'GEOS3'.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the NOX emissions will be regridded.  
             OUTRESOLUTION can be either a 2 element vector with 
             [ DI, DJ ] or a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 
             1=1x1, 0.5=0.5x0.5).  Default is 1.

        XRANGE -> A 2-element vector containing the minimum and
             maximum box center longitudes which define the nested
             model grid. Default is [-180,180].

        YRANGE -> A 2-element vector containing the minimum and
             maximum box center latitudes which define the nested
             model grid. Default is [-180,180].

        /USE_SAVED_WEIGHTS -> Set this flag to tell CTM_REGRIDH to
             use previously-saved mapping weights.  Useful if you
             are regridding many files at once.  

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        ================================================
        CTM_TYPE    (function)   CTM_GRID (function)
        CTM_REGRIDH (function)   OPEN_FILE

 REQUIREMENTS:
        References routines from both GAMAP and TOOLS packages

 NOTES:

 EXAMPLE:
        REGRIDH_AIRCRAFT_FUEL, INFILENAME='total_1992_apr.kg_day.3d', $
                               OUTFILENAME='airapr.1x1',              $
                               OUTMODELNAME='GEOS3',                  $
                               OUTRESOLUTION=1,                       $
                               XRange=[-140,40],                      $
                               YRange=[10,60] 

             ; Regrids aircraft fuel emissions to a GEOS-3 1x1
             ; nested grid resolution given by 

 MODIFICATION HISTORY:
        bmy, 10 Apr 2003: VERSION 1.00
        bmy, 29 Nov 2006: VERSION 1.01
                          - Updated for SO2 output

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_aircraft_fuel.pro)


REGRIDH_AIRCRAFT_NOX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_AIRCRAFT_NOX

 PURPOSE:
        Regrids aircraft NOx emissions to GEOS-CHEM grid resolution.
        Can also trim to nested-grid resolution if necessary.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_AIRCRAFT_NOX [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the input file containing data to be 
             trimmed down to "nested" model grid resolution.  If 
             omitted, a dialog box will prompt the user to supply
             a filename.

        OUTFILENAME -> Name of the file that will contain trimmed
             data on the "nested" model grid.  If omitted, a dialog 
             box will prompt the user to supply a filename.

        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the NOx emissions will be regridded.
             Default is 'GEOS3'.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the NOX emissions will be regridded.  
             OUTRESOLUTION can be either a 2 element vector with 
             [ DI, DJ ] or a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 
             1=1x1, 0.5=0.5x0.5).  Default is 1.

        /USE_SAVED_WEIGHTS -> Set this flag to tell CTM_REGRIDH to
             use previously-saved mapping weights.  Useful if you
             are regridding many files at once.  

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        ================================================
        CTM_TYPE    (function)   CTM_GRID (function)
        CTM_REGRIDH (function)   OPEN_FILE

 REQUIREMENTS:
        References routines from both GAMAP and TOOLS packages

 NOTES:

 EXAMPLE:
        REGRIDH_AIRCRAFT_NOX, InFileName='total_1992_apr.kg_day.3d', $
                              OutFileName='airapr.1x1',              $
                              OUTMODELNAME='GEOS3',                  $
                              OUTRESOLUTION=1,                       $
                              XRange=[-140,40],                      $
                              YRange=[10,60] 

             ; Regrids aircraft NOx emissions to a GEOS-3 1x1
             ; nested grid resolution given by 

 MODIFICATION HISTORY:
        bmy, 10 Apr 2003: VERSION 1.00

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_aircraft_nox.pro)


REGRIDH_ANTHRO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_ANTHRO

 PURPOSE:
        Regrids 1 x 1 GEIA anthropogenic emissions "merge file" 
        onto a CTM grid of equal or coarser resolution.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_ANTHRO [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        OUTFILENAME -> Name of the directory where the output file will
             be written.  Default is 'merge_nobiofuels.geos.{resolution}'.  

        /COPY -> If set, will just copy the 1 x 1 data from the ASCII
             file to a binary punch file format, w/o regridding.

 OUTPUTS:
        Writes to binary "merge" file:
             merge.{MODELNAME}.{RESOLUTION}.bpch

 SUBROUTINES:
        External Subroutines Required:
        =================================================
        CTM_GRID    (function)   CTM_TYPE   (function)
        CTM_BOXSIZE (function)   CTM_REGRID (function)
        CTM_RESEXT  (function)   CTM_MAKE_DATAINFO (function)


 REQUIREMENTS:
        References routines from the GAMAP and TOOLS packages.

 NOTES:
        (1) The path names for the files containing 1 x 1 data are
            hardwired -- change this number as is necessary.

        (2) Also assumes 10 fossil fuel emission species -- 
            change this number as is necessary.

        (3) Now use CTM_REGRIDH, which is much quicker since it
            saves the mapping weights

 EXAMPLE:
        REGRIDH_ANTHRO, OUTMODELNAME='GEOS_STRAT', $
                        OUTRESOLUTION=4 
           
             ; Regrids 1 x 1 GEIA fossil fuel emissions onto the
             ; 4 x 5 GEOS-STRAT grid.  The default output filename
             ; will be "merge_nobiofuels.geos.4x5".  

 MODIFICATION HISTORY:
        bmy, 01 Aug 2000: VERSION 1.00
        bmy, 14 Mar 2001: VERSION 1.01
                          - now write output to binary punch file format
        bmy, 30 Oct 2001: VERSION 1.02
                          - added /COPY keyword
                          - now can also copy data from 1 x 1 ASCII
                            file to binary punch file w/o regridding
        bmy, 09 Jan 2003: VERSION 1.03
                          - renamed to "regridh_anthro.pro"
                          - now uses CTM_REGRIDH, which is faster
                            when regridding multiple arrays

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_anthro.pro)


REGRIDH_AVHRRCO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_AVHRRCO

 PURPOSE:
        Regrids AVHRR biomass burning emissions at 
        1 x 1 resolution to CTM resolution.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_AVHRRCO [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        /COPY -> Use this switch to write the original 1 x 1
             biomass burning data to a binary punch file without
             regridding.  

 OUTPUTS:
        Writes binary punch files: 
             bioburn.avhrr.mon.{RESOLUTION}

 SUBROUTINES:
        External Subroutines Required:
        =================================================
        CTM_GRID      (function)   CTM_TYPE   (function)
        CTM_BOXSIZE   (function)   CTM_RESEXT (function)   
        CTM_NAMEXT    (function)   NYMD2TAU   (function)
        CTM_REGRIDH   (function)   CTM_WRITEBPCH

 REQUIREMENTS:
        References routines from the GAMAP and TOOLS packages.

 NOTES:
        (1) The path names for the files containing 1 x 1 data are
            hardwired -- change as necessary!

        (2) Sometimes you might have to close all files and call
            "ctm_cleanup.pro" in between calls to this routine.

        (3) Can be extended to other tracers than CO...

 EXAMPLE:
        REGRIDH_AVHRRCO, OUTMODELNAME='GEOS_STRAT', $
                         OUTRESOLUTION=4
           
             ; Regrids 1 x 1 AVHRR CO biomass burning data
             ; onto the 4 x 5 GEOS-STRAT grid

 MODIFICATION HISTORY:
  clh & bmy, 09 Jun 2000: VERSION 1.00
                          - adapted from "regrid_bioburn.pro"  
        bmy, 14 Nov 2002: VERSION 1.01
                          - now use CTM_REGRIDH for horiz regridding
                          - renamed to "regridh_avhrrco.pro"
        bmy, 23 Dec 2003: VERSION 1.02
                          - updated for GAMAP v2-01

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_avhrrco.pro)


REGRIDH_BIOBURN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_BIOBURN

 PURPOSE:
        Regrids 1 x 1 biomass burning emissions for various tracers
        onto a CTM grid of equal or coarser resolution.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_BIOBURN [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        OUTDIR -> Name of the directory where the output file will
             be written.  Default is './'.  

        /COPY -> Use this switch to write the original 1 x 1
             biomass burning data to a binary punch file without
             regridding.  

        /SEASONAL -> Use this switch to process seasonal biomass
             burning files (instead of interannual variability
             files).

        YEAR -> 4-digit year number for which to regrid data 
             for interannual variability biomass burning.  YEAR
             is ignored if SEASONAL=0.  Default is 1996.
             
 OUTPUTS:
        Writes binary punch files: 
             bioburn.seasonal.{MODELNAME}.{RESOLUTION} OR
             bioburn.interannual.{MODELNAME}.{RESOLUTION}.YEAR  

 SUBROUTINES:
        Internal Subroutines:
        =================================================
        RBB_GetWeight     RBB_GetTracerInfo (function)
        RBB_ReadData

        External Subroutines Required:
        =================================================
        CTM_GRID      (function)   CTM_TYPE   (function)
        CTM_BOXSIZE   (function)   CTM_REGRID (function)
        CTM_NAMEXT    (function)   CTM_RESEXT (function)
        CTM_WRITEBPCH

 REQUIREMENTS:
        References routines from the GAMAP and TOOLS packages.

 NOTES:
        (1) The path names for the files containing 1 x 1 data are
            hardwired -- change as necessary!

        (2) Now assumes 13 biomass burning tracers -- change this
            number as necessary.

        (3) REGRID_BIOBURN now will produce output for a whole
            year in one file.  This is most convenient.

        (4) Sometimes you might have to close all files and call
            "ctm_cleanup.pro" in between calls to this routine.

 EXAMPLE:
        REGRIDH_BIOBURN, OUTMODELNAME='GEOS_STRAT', OUTRESOLUTION=4, $
                         /SEASONAL, WEIGHTFILE="weights_gen1x1_geos4x5.dat"
           
             ; Regrids seasonal 1 x 1 biomass burning data from February
             ; for CO (tracer #2) onto the 4 x 5 GEOS-STRAT grid, using
             ; mapping weights stored in "weights_gen1x1_geos4x5.dat".

 MODIFICATION HISTORY:
        bmy, 09 Jun 2000: VERSION 1.00
        bmy, 14 Jul 2000: VERSION 1.01
                          - adapted for 9 biomass burning tracers
        bmy, 24 Jul 2000: - added OUTDIR keyword
        bmy, 13 Feb 2001: VERSION 1.02
                          - added ALK4, CH4, CH3I as biomass 
                            burning tracers
        bmy, 15 Feb 2001: VERSION 1.03
                          - now use pre-saved mapping weights, 
                            for computational expediency
                          - now no longer use
                          - added /SEASONAL keyword to regrid
                            seasonal climatological biomass burning
                            instead of interannual variability BB.
        bmy, 28 Jun 2001: VERSION 1.04
                          - added COPY keyword, to just write a 1x1
                            binary punch file w/o regridding
        bmy, 02 Jul 2001: VERSION 1.05
                          - YEAR is now 4 digits
                          - now uses 1985 TAU values for seasonal
                            BB emissions and TAU values corresponding
                            to YEAR for interannual BB emissions
        bmy, 21 Sep 2001: VERSION 1.06
                          - modified to handle Randall's year 2000
                            files for interannual variability
                          - renamed MODELNAME to OUTMODELNAME and
                            RESOLUTION to OUTRESOLUTION
        bmy, 24 Sep 2001: VERSION 1.07
                          - now created TINFO array of structures
                            w/ information about each biomass tracer
                          - also save TOTB (CTM tracer #33) as g/cm2 
        bmy, 11 Feb 2002: VERSION 1.08
                          - now regrid all months of 2000
        bmy, 14 Nov 2002: VERSION 1.09
                          - renamed to REGRIDH_BIOBURN
                          - removed WEIGHTFILE keyword
        bmy, 23 Dec 2003: VERSION 1.10
                          - updated for GAMAP v2-01

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_bioburn.pro)


REGRIDH_BIOBURN2

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_BIOBURN2

 PURPOSE:
        Regrids 1 x 1 biomass burning emissions for various tracers
        onto a CTM grid of equal or coarser resolution.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_BIOBURN [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        OUTFILENAME -> 

        DIAGN -> 
             
 OUTPUTS:
        Writes binary punch files: 
             bioburn.seasonal.{MODELNAME}.{RESOLUTION} OR
             bioburn.interannual.{MODELNAME}.{RESOLUTION}.YEAR  

 SUBROUTINES:

        External Subroutines Required:
        =================================================
        CTM_GRID   (function)   CTM_TYPE   (function)
        CTM_REGRID (function)   CTM_NAMEXT (function)   
        CTM_RESEXT (function)   CTM_WRITEBPCH
        UNDEFINE

 REQUIREMENTS:
        References routines from the GAMAP and TOOLS packages.

 NOTES:
        none

 EXAMPLE:
        REGRIDH_BIOBURN, INFILENAME='biomass.seasonal.generic.1x1', $
                         OUTMODELNAME='GEOS4'
                         OUTRESOLUTION=2 $
                         OUTFILENAME='biomass.seasonal.geos.2x25'GEOS_STRAT', 
           
             ; Regrids seasonal 1 x 1 biomass burning data 
             ; onto the GEOS_4 2 x 2.5 grid.

 MODIFICATION HISTORY:
        bmy, 08 Apr 2004: VERSION 1.00
        bmy, 20 Oct 2005: VERSION 1.01
                          - If units are per m3, m2, cm3, or cm2 then 
                            set PER_UNIT_AREA flag in routine CTM_REGRIDH;

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_bioburn2.pro)


REGRIDH_BIOFUEL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_BIOFUEL

 PURPOSE:
        Regrids 1 x 1 biofuel burning emissions for NOx or CO
        onto a CTM grid of equal or coarser resolution.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_BIOFUEL [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        OUTDIR -> Name of the directory where the output file will
             be written.  Default is './'.  
 
        /COPY -> If set, then will just copy 1 x 1 "raw" biofuel
             data from native ASCII format to binary punch format.

 OUTPUTS:
        Writes binary punch files: 
             biofuel.generic.1x1        (if /COPY is set)  OR
             biofuel.geos.{RESOLUTION}  (if OUTRESOLUTION=2 or =4)

 SUBROUTINES:
        External Subroutines Required:
        ===============================================
        CTM_GRID    (function)   CTM_TYPE    (function)
        CTM_REGRIDH (function)   CTM_NAMEXT  (function)   
        CTM_RESEXT  (function)   CTM_WRITEBPCH

        Internal Subroutines
        ===============================================
        RBF_READDATA (function) 

 REQUIREMENTS:
        References routines from the GAMAP and TOOLS packages.

 NOTES:
        The path names for the files containing 1 x 1 data are
        hardwired -- change as necessary!

 EXAMPLE:
        (1)
        REGRIDH_BIOFUEL, MODELNAME='GEOS_STRAT', RESOLUTION=[5,4]
           
             ; Regrids 1 x 1 biofuel data to the 4 x 5 GEOS-STRAT grid

 MODIFICATION HISTORY:
        bmy, 09 Jun 2000: VERSION 1.00
        bmy, 12 Jul 2000: VERSION 1.01 
                          - added NOx keyword
                          - now read original data with 
                            internal function RBF_READDATA
        bmy, 24 Jul 2000: - added OUTDIR keyword
        bmy, 26 Jan 2001: VERSION 1.02
                          - added extra species names
        bmy, 29 Oct 2001: VERSION 1.03
                          - added /COPY keyword to just copy data
                            from ASCII format to binary punch format
                          - now loop over multiple tracer names
                          - removed TRCNAME keyword
        bmy, 28 Jan 2002: VERSION 1.04
                          - bug fix: now convert C2H6, C3H8 and 
                            ACET from kg/yr to kg C/yr
        bmy, 14 Nov 2002: VERSION 1.05
                          - renamed to REGRIDH_BIOFUEL
        bmy, 23 Dec 2003: VERSION 1.06
                          - updated for GAMAP v2-01

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_biofuel.pro)


REGRIDH_C3H8_C2H6

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_C3H8_C2H6

 PURPOSE:
        Horizontally regrids emissions of C3H8 and C2H6
        from one CTM grid to another. 

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_C3H8_C2H6 [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing C3H8 and C2H6 to
             be regridded.  If omitted, then REGRIDH_C3H8_C2H6 will
             prompt the user to select a filename via a dialog box.

        OUTFILENAME -> Name of output file containing the regridded
             data.  If OUTFILENAME is not specified, then REGRIDH_C3H8_C2H6 
             will ask the user to specify a file via a dialog box.

        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.  If
             OUTMODELNAME is not specified, REGRIDH_C3H8_C2H6 will 
             use the same model name as the input grid.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        DIAGN -> Diagnostic category of the data blocks that you 
            wish to regrid.  Default is "IJ-AVG-$".

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        =======================================================
        CTM_GRID          (function)   CTM_TYPE     (function)
        CTM_REGRIDH       (function)   CTM_RESEXT   (function)
        CTM_MAKE_DATAINFO (function)   CTM_WRITEBPCH            
        UNDEFINE

 REQUIREMENTS:
        References routines from the GAMAP and TOOLS packages.

 NOTES:
        None

 EXAMPLE:
        REGRIDH_C3H8_C2H6, INFILENAME='C3H8_C2H6_ngas.geos.4x5',   $
                           OUTFILENAME='C3H8_C2H6_ngas.geos.2x25', $
                           OUTRESOLUTION=2,                        $

             ; Regrids C3H8 and C2H6 data onto from the 4 x 5
             ; GEOS-3 grid to the the 2 x 2.5 GEOS-3 grid.

 MODIFICATION HISTORY:
        bmy, 08 Jan 2003: VERSION 1.00
        bmy, 22 Dec 2003: VERSION 1.01
                          - rewritten for GAMAP v2-01 
                          - now call PTR_FREE to free pointer memory

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_c3h8_c2h6.pro)


REGRIDH_CM2_S

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_CM2_S

 PURPOSE:
        Horizontally Regrids a CTM quantity (such as emissions) in 
        units of [molec/cm2/s] or [atoms C/cm2/s] to a new CTM grid.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_CM2_S [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing data to be regridded.
             If INFILENAME is not specified, then REGRIDH_RESTART
             will prompt the user to select a file via a dialog box.

        OUTFILENAME -> Name of the file which will contain the regridded 
             data.  If OUTFILENAME is not specified, then REGRIDH_RESTART
             will prompt the user to select a file via a dialog box.
 
        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.  If not
             passed, then the model name corresponding to the data
             contained in INPUTFILE will be used as the default.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        DIAGN -> Diagnostic category of the data blocks that you 
            wish to regrid.  Default is "IJ-AVG-$".
             
 OUTPUTS:
        Writes binary punch files: 
             bioburn.seasonal.{MODELNAME}.{RESOLUTION} OR
             bioburn.interannual.{MODELNAME}.{RESOLUTION}.YEAR  

 SUBROUTINES:

        External Subroutines Required:
        =================================================
        CTM_GRID   (function)   CTM_TYPE   (function)
        CTM_REGRID (function)   CTM_NAMEXT (function)   
        CTM_RESEXT (function)   CTM_WRITEBPCH
        UNDEFINE

 REQUIREMENTS:
        References routines from the GAMAP and TOOLS packages.

 NOTES:
        none

 EXAMPLE:
        REGRIDH_BIOBURN, INFILENAME='biomass.seasonal.generic.1x1', $
                         OUTMODELNAME='GEOS4'
                         OUTRESOLUTION=2 $
                         OUTFILENAME='biomass.seasonal.geos.2x25'GEOS_STRAT', 
           
             ; Regrids seasonal 1 x 1 biomass burning data 
             ; onto the GEOS_4 2 x 2.5 grid.

 MODIFICATION HISTORY:
        bmy, 08 Apr 2004: VERSION 1.00

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_cm2_s.pro)


REGRIDH_CROPLANDS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_CROPLANDS

 PURPOSE:
        Regrids crop land fraction data from 0.5 x 0.5 degree 
        resolution to a coarser CTM grid.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_CROPLANDS [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of a netCDF file containing input 
             data to be be regridded.  Default is 
             '~rmy/Croplands/crop92_v1.1_0.5.nc'.

        OUTFILENAME -> Name of the binary punch file to contain
             output data.  Default is "croplands.bpch"

        OUTMODELNAME -> A string containing the name of the model
             grid on which the input data resides.  Default is GENERIC.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             on which the input data resides.  RESOLUTION can be 
             either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default is 1.

 OUTPUTS:
        None -- writes output to file

 SUBROUTINES:
        Internal Subroutines
        ===================================================
        RC_ReadData (function)
 
        External Subroutines Required:
        ===================================================
        NCDF_READ             CTM_MAKE_DATAINFO (function) 
        CTM_TYPE (function)   CTM_GRID          (function)  
        CTM_WRITEBPCH         UNDEFINE

 REQUIREMENTS:
        References routines from both GAMAP and TOOLS packages.

 NOTES:
        Some hardwiring for now...this is OK.

 EXAMPLE:
        REGRID_CROPLANDS, INFILENAME='croplands.nc',       $
                          OUTMODELNAME='generic',          $
                          OUTRESOLUTION=1,                 $
                          OUTFILENAME='newcroplands.bpch'


             ; Regrids 0.5 x 0.5 croplands data from "croplands.nc"
             ; file to 1 x 1 resolution.  Output is to the binary
             ; punch file "newcroplands.bpch".

 MODIFICATION HISTORY:
        bmy, 19 Jul 2001: VERSION 1.00
        bmy, 09 Jan 2003: VERSION 1.02
                          - Now use CTM_REGRIDH to regrid data
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_croplands.pro)


REGRIDH_DUST

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_DUST

 PURPOSE:
        Horizontally regrids mineral dust concentrations [kg/m3]
        from one CTM grid to another.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_DUST [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        MONTH -> Month of year for which to process data.  Default is
             1 (January).  Since the dust files are very large, it may
             take several iterations to regrid an entire year of
             data.  You can break the job down 1 month at a time.

        INFILENAME -> Name of the file containing the dust data 
             which is to be regridded.  If INFILENAME is not specified,
             then REGRIDH_DUST will prompt the user to specify a file
             name via a dialog box.

        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.  If not
             specified, then OUTMODELNAME will be set to the same
             value as the grid stored in INFILENAME.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  OUTRESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        OUTFILENAME -> Name of the directory where the output file will
             be written.  If not specified, then a dialog box
             will ask the user to supply a file name.

        DIAGN -> Diagnostic category of data block that you want
             to regrid.  Default is "MDUST-$".

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        ======================================================
        CTM_GRID     (function)   CTM_TYPE          (function)
        CTM_REGRID   (function)   CTM_NAMEXT        (function)  
        CTM_RESEXT   (function)   CTM_MAKE_DATAINFO (function)
        CTM_WRITEBPCH             GETMODELANDGRIDINFO
        UNDEFINE

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        REGRIDH_DUST, INFILENAME='dust.geos3.2x25', $
                      OUTRESOLUTION=4,              $
                      OUTFILENAME='dust.geos3.4x5'
           
             ; Regrids dust data from 2 x 2.5 native resolution
             ; to 4 x 5 resolution for the GEOS-3 grid

 MODIFICATION HISTORY:
        bmy, 09 Jun 2000: VERSION 1.00
        rvm, 18 Jun 2000: VERSION 1.01
        bmy, 07 Jul 2000: VERSION 1.10
                          - added OUTDIR keyword
                          - save regridded data one month at a time
                            since regridding takes so long 
        bmy, 19 Dec 2003: VERSION 1.11
                          - Rewritten for GAMAP v2-01
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_dust.pro)


REGRIDH_FERT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_FERT

 PURPOSE:
        Regrids fertilizer NOx from a 1 x 1 grid onto a
        CTM grid of equal or coarser horizontal resolution.
        
 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_FERT [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        OUTFILENAME -> Name of the binary punch file that will hold
             regridded data.  If not specified, the default OUTFILENAME
             will be nox_fert.geos.{OUTRESOLUTION}

 OUTPUTS:
        None
  
 SUBROUTINES:
        External Subroutines Required:
        ==============================================
        CTM_TYPE    (function)   CTM_GRID   (function)
        CTM_NAMEXT  (function)   CTM_RESEXT (function)
        CTM_REGRIDH (function)   CTM_WRITEBPCH
        

 REQUIREMENTS:
        None

 NOTES:
        (1) Filenames are hardwired -- change as necessary
        (2) Regridding can take a while, especially at 1x1 resolution.

 EXAMPLE: 
        REGRIDH_FERT, OUTMODELNAME='GEOS1', $
                      OUTRESOLUTION=2,      $
                      OUTFILENAME='nox_fert.geos.2x25'
 
             ; Regrids 1 x 1 NOx fertilizer data onto the GEOS-1
             ; 2 x 2.5 resolution grid.  

 MODIFICATION HISTORY:
        bmy, 01 Aug 2000: VERSION 1.00
        bmy, 13 Jan 2003: VERSION 1.01
                          - renamed to "regridh_fert.pro"
                          - now uses CTM_REGRIDH
                          - removed OUTDIR, added OUTFILENAME
                          - updated comments
        bmy, 23 Dec 2003: VERSION 1.02
                          - updated for GAMAP v2-01
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_fert.pro)


REGRIDH_JO1D

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_JO1D

 PURPOSE:
        Regrids JO1D data (used for acetone emissions) 
        from one CTM grid to another.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_JO1D, [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the input file containing JO1D data
             to be regridded.  If INFILENAME is not specified, then 
             REGRIDH_JO1D will prompt the user to select a file via 
             a dialog box.

        OUTFILENAME -> Name of the binary punch file which
             will contain regridded data.  Default is 
             "JO1D.{MODELNAME}.{RESOLUTION}"

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  If OUTMODELNAME is not specified, 
             then REGRIDH_RESTART will use the same model name as the
             input grid.

        OUTRESOLUTION -> Specifies the resolution of the output
             model grid onto which the data will be regridded.
             OUTRESOLUTION can be either a 2 element vector with 
             [ DI, DJ ] or a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 
             1=1x1, 0.5=0.5x0.5).  Default for all models is 4x5.

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        ========================================================
        CTM_TYPE          (function)   CTM_GRID       (function)
        CTM_NAMEXT        (function)   CTM_RESEXT     (function)
        CTM_MAKE_DATAINFO (function)   INTERPOLATE_2D (function)
        CTM_GET_DATA                   GETMODELANDGRIDINFO
        UNDEFINE       
 
 REQUIREMENTS:
        References routines from both GAMAP and TOOLS packages.

 NOTES:
        None

 EXAMPLE:
        REGRIDH_JOID, INFILENAME='JO1D.geos.4x5',   $
                      OUTFILENAME='JO1D.geos.2x25', $
                      OUTRESOLUTION=2

             ; Regrids JO1D data from 4 x 5 to 2 x 2.5 resolution.

 MODIFICATION HISTORY:
        bmy, 11 Aug 2000: VERSION 1.01
        bmy, 23 Dec 2003: VERSION 1.02
                          - updated for GAMAP v2-01
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_jo1d.pro)


REGRIDH_JV

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_JV

 PURPOSE:
        Horizontally interpolates J-values from one CTM grid to another.
        Can also be used to interpolate other data quantities.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_JV, [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing data to be regridded.
             If INFILENAME is not specified, then REGRIDH_JV
             will prompt the user to select a file via a dialog box.

        OUTFILENAME -> Name of the file which will contain the regridded 
             data.  If OUTFILENAME is not specified, then REGRIDH_JV
             will prompt the user to select a file via a dialog box.

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  If OUTMODELNAME is not specified, 
             then REGRIDH_JV will use the same model name as the
             input grid.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  OUTRESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        DIAGN -> Diagnostic category of the data blocks that you 
            wish to regrid.  Default is "IJ-AVG-$".

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        ==========================================================
        CTM_TYPE           (function)   CTM_GRID       (function)
        CTM_NAMEXT         (function)   CTM_RESEXT     (function)
        CTM_MAKE_DATAINFO  (function)   INTERPOLATE_2D (function)
        GETMODELANDGRIDINFO             UNDEFINE

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        REGRIDV_JV, INFILENAME='JH2O2.geos4.4x5', $
                    OUTRESOLUTION='2'
                    OUTFILENAME='JH2O2.geos4.2x25'

             ; Regrids GEOS-4 stratospheric J-value data 
             ; at 4 x 5 resolution to 2 x 2.5 resolution.

 MODIFICATION HISTORY:
        bmy, 11 Aug 2000: VERSION 1.01
        bmy, 22 Dec 2003: VERSION 1.02
                          - updated for GAMAP v2-01
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_jv.pro)


REGRIDH_KG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_KG

 PURPOSE:
        Regrids 1 x 1 data (e.g. emissions) in units of [kg], [kg/yr] 
        or similar mass units from one CTM grid to another.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_KG [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> A string containing the name of the binary 
             punch (bpch) file with the data to be regridded.

        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        OUTFILENAME -> Name of the directory where the output file will
             be written.  Default is 'merge_nobiofuels.geos.{resolution}'.  

        DIAGN -> GAMAP diagnostic category name of the data blocks
             to be regridded.

        USE_SAVED_WEIGHTS -> Set this switch to manually force 
             REGRIDH_KG to re-use the mapping weights for regridding.
             The default is to reset the mapping weights for each
             new file that is read in. 

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        =================================================
        CTM_GRID    (function)   CTM_TYPE   (function)
        CTM_BOXSIZE (function)   CTM_REGRID (function)
        CTM_RESEXT  (function)   CTM_MAKE_DATAINFO (function)

 REQUIREMENTS:
        None

 NOTES:
        Can also be used to regrid other quantities that are
        are not per unit area (e.g. kg/s, kg/yr, Tg, etc.)

 EXAMPLE:
        REGRIDH_KG, INFILENAME="biofuel.generic.1x1",$
                    OUTFILENAME="biofuel.geos.1x1",  $
                    OUTMODELNAME='GEOS3',                     $
                    OUTRESOLUTION=1 
           
             ; Regrids 1 x 1 biofuel fuel emissions on the
             ; GENERIC 1x1 GRID to the GEOS 1x1 GRID.

 MODIFICATION HISTORY:
        bmy, 28 Jun 2006: VERSION 1.00
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_kg.pro)


REGRIDH_LAI[1]

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_LAI

 PURPOSE:
        Regrids Leaf Area Indices and Olson Land Types from a 
        0.5 x 0.5 grid onto a CTM grid of equal or coarser 
        horizontal resolution.
        
 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_LAI [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        OUTDIR -> Name of the directory where the output file will
             be written.  Default is './'.  

 OUTPUTS:
        Writes files:
             vegtype.global
             lai{MONTHNUM}.global
  
 SUBROUTINES:
        External Subroutines Required:
        ===============================================
        CTM_TYPE   (function)   CTM_GRID (function)
        CTM_RESEXT (function)   CTM_GETWEIGHT

        Internal Subroutines:
        ==============================
        RL_GETWEIGHT

 REQUIREMENTS:
        None

 NOTES:
        (1) Filenames are hardwired -- change as necessary
        (2) Regridding can take a while, especially at 1x1 resolution.

 EXAMPLE: 
        REGRIDH_LAI, MODELNAME='GEOS1', RES=2, OUTDIR='~/scratch/bmy/'
 
             ; Regrids 1 x 1 NOx fertilizer data onto the GEOS-1
             ; 2 x 2.5 resolution grid.  The output file will be
             ; written to the '~/scratch/bmy/' directory.

 MODIFICATION HISTORY:
        bmy, 04 Aug 2000: VERSION 1.00
                          - adapted from old FORTRAN code
        bmy, 15 Jan 2003: VERSION 1.01
                          - renamed to "regridh_lai.pro"
                          - renamed MODELNAME to OUTMODELNAME
                          - renamed RESOLUTION to OUTRESOLUTION
        bmy, 18 Jun 2004: VERSION 1.02
                          - Bug fix: TMPAREA array needs to be
                            defined with N_TYPE, not N_MON
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_avhrr_lai.pro)


REGRIDH_LAI[2]

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_LAI

 PURPOSE:
        Regrids Leaf Area Indices and Olson Land Types from a 
        0.5 x 0.5 grid onto a CTM grid of equal or coarser 
        horizontal resolution.
        
 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_LAI [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        OUTDIR -> Name of the directory where the output file will
             be written.  Default is './'.  

 OUTPUTS:
        Writes files:
             vegtype.global
             lai{MONTHNUM}.global
  
 SUBROUTINES:
        External Subroutines Required:
        ===============================================
        CTM_TYPE   (function)   CTM_GRID (function)
        CTM_RESEXT (function)   CTM_GETWEIGHT

        Internal Subroutines:
        ==============================
        RL_GETWEIGHT

 REQUIREMENTS:
        None

 NOTES:
        (1) Filenames are hardwired -- change as necessary
        (2) Regridding can take a while, especially at 1x1 resolution.

 EXAMPLE: 
        REGRIDH_LAI, MODELNAME='GEOS1', RES=2, OUTDIR='~/scratch/bmy/'
 
             ; Regrids 1 x 1 NOx fertilizer data onto the GEOS-1
             ; 2 x 2.5 resolution grid.  The output file will be
             ; written to the '~/scratch/bmy/' directory.

 MODIFICATION HISTORY:
        bmy, 04 Aug 2000: VERSION 1.00
                          - adapted from old FORTRAN code
        bmy, 15 Jan 2003: VERSION 1.01
                          - renamed to "regridh_lai.pro"
                          - renamed MODELNAME to OUTMODELNAME
                          - renamed RESOLUTION to OUTRESOLUTION
        bmy, 18 Jun 2004: VERSION 1.02
                          - Bug fix: TMPAREA array needs to be
                            defined with N_TYPE, not N_MON
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_lai.pro)


REGRIDH_MOLEC_CM2

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_MOLEC_CM2

 PURPOSE:
        Regrids 1 x 1 data (e.g. emissions) in units of [molec/cm2/s] 
        onto a CTM grid of equal or coarser resolution.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_MOLEC_CM2 [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> A string containing the name of the binary 
             punch (bpch) file with the data to be regridded.

        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        OUTFILENAME -> Name of the directory where the output file will
             be written.  Default is 'merge_nobiofuels.geos.{resolution}'.  

        DIAGN -> GAMAP diagnostic category name of the data blocks
             to be regridded.

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        =================================================
        CTM_GRID    (function)   CTM_TYPE   (function)
        CTM_BOXSIZE (function)   CTM_REGRID (function)
        CTM_RESEXT  (function)   CTM_MAKE_DATAINFO (function)

 REQUIREMENTS:
        None

 NOTES:
        Can also be used to regrid other quantities that are
        per unit area (e.g. kg/m2/s, molec/cm3/s, etc).

 EXAMPLE:
        REGRIDH_MOLEC_CM2, INFILENAME="merge_nobiofuels.generic.1x1",$
                           OUTFILENAME="merge_nobiofuels.geos.1x1",  $
                           OUTMODELNAME='GEOS3',                     $
                           OUTRESOLUTION=1 
           
             ; Regrids 1 x 1 fossil fuel emissions on the
             ; GENERIC 1x1 grid to the GEOS 1x1 grid.

 MODIFICATION HISTORY:
        bmy, 28 Jun 2006: VERSION 1.00
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_molec_cm2.pro)


REGRIDH_NEP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_NEP

 PURPOSE:
        Horizontally regrids NEP data from its resolution to a CTM grid.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_NEP [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing data to be regridded.
             Default is: '~bmy/S/CO2/nep_gpp.nc'.

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  Default is 'GEOS3'.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  OUTRESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        DIAGN -> Diagnostic category of the data blocks that you 
            wish to regrid.  Default is "IJ-AVG-$".

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        =======================================================
        CTM_TYPE          (function)   CTM_GRID      (function)
        CTM_RESEXT        (function)   CTM_REGRIDH   (function)
        CTM_MAKE_DATAINFO (function)   CTM_WRITEBPCH
        UNDEFINE
 
 REQUIREMENTS:
        None

 NOTES:
        Output filenames are hardwired.

 EXAMPLE:
        REGRIDH_NEP, INFILENAME='nep_gpp.nc', $
                     OUTMODELNAME='GEOS3',    $
                     OUTRESOLUTION=4

             ; Regrids NEP data to the GEOS-3 4x5 grid.

 MODIFICATION HISTORY:
        bmy, 15 Apr 2003: VERSION 1.00
        bmy, 23 Dec 2003: VERSION 1.01
                          - updated for GAMAP v2-01
                          - added DIAGN keyword
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_nep.pro)


REGRIDH_NH3

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_NH3

 PURPOSE:
        Horizontally regrids NH3 emissions (anthro, biofuel, or 
        natural source) from one CTM grid to another.  Can also
        be used to regrid other data which have units of kg.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_NH3 [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing data to be regridded.
             If INFILENAME is not specified, then REGRIDH_RESTART
             will prompt the user to select a file via a dialog box.

        OUTFILENAME -> Name of the file which will contain the regridded 
             data.  If OUTFILENAME is not specified, then REGRIDH_RESTART
             will prompt the user to select a file via a dialog box.

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  If OUTMODELNAME is not specified, 
             then REGRIDH_NH3 will use the same model name as the
             input grid.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  OUTRESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        ===============================================
        CTM_GRID    (function)   CTM_TYPE (function)
        CTM_REGRIDH (function)   GETMODELANDGRIDINFO
        CTM_RESEXT  (function)   CTM_GET_DATA
        CTM_WRITEBPCH            UNDEFINE

 REQUIREMENTS:
        None

 NOTES:
        Assumes that input data is either [kg NH3/box] or [kg N/box].

 EXAMPLE:
        (1)
        REGRIDH_NH3, INFILENAME='NH3_anthsrce.geos.2x25', $
                     OUTFILENAME='NH3_anthsrce.geos.1x1', $
                     OUTRESOLUTION=1
           
             ; Regrids 2 x 2.5 NH3 anthropogenic emissions 
             ; to the 1 x 1 GEOS grid.

 MODIFICATION HISTORY:
        bmy, 28 Mar 2003: VERSION 1.01
        bmy, 22 Dec 2003: VERSION 1.02
                          - rewritten for GAMAP v2-01
                          - now call PTR_FREE to free pointer memory
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_nh3.pro)


REGRIDH_NPP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_NPP

 PURPOSE:
        Horizontally regrids NPP data from native
        resolution to a CTM grid.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_NPP [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing data to be regridded.
             Default is: '~bmy/S/CO2/nep_gpp.nc'.

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  Default is 'GEOS3'.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  OUTRESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        DIAGN -> Diagnostic category of the data blocks that you 
            wish to regrid.  Default is "IJ-AVG-$".

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        =======================================================
        CTM_TYPE          (function)   CTM_GRID      (function)
        CTM_RESEXT        (function)   CTM_REGRIDH   (function)
        CTM_MAKE_DATAINFO (function)   CTM_WRITEBPCH
        UNDEFINE
 
 REQUIREMENTS:
        None

 NOTES:
        Output filenames are hardwired.

 EXAMPLE:
        REGRIDH_NEP, INFILENAME='nep_gpp.nc', $
                     OUTMODELNAME='GEOS3',    $
                     OUTRESOLUTION=4

             ; Regrids NEP data to the GEOS-3 4x5 grid.

 MODIFICATION HISTORY:
        bmy, 15 Apr 2003: VERSION 1.00
        bmy, 23 Dec 2003: VERSION 1.01
                          - updated for GAMAP v2-01
                          - added DIAGN keyword
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_npp.pro)


REGRIDH_O3PL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_O3PL

 PURPOSE:
        Horizontally regrids files containing GEOS-CHEM P(O3) and L(O3).

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_O3PL [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing data to be regridded.
             If INFILENAME is not specified, then REGRIDV_O3PL
             will prompt the user to select a file via a dialog box.

        OUTFILENAME -> Name of the file which will contain the regridded 
             data.  If OUTFILENAME is not specified, then REGRIDV_PORL
             will prompt the user to select a file via a dialog box.

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  If omitted then OUTMODELNAME will
             be determined automatically from INFILENAME.

        OUTRESOLUTION -> Resolution of the model grid onto which
             the data will be regridded.  Default is 4.

        DIAGN -> Diagnostic category of the data blocks that you 
            wish to regrid.  Default is "PORL-L=$".

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        ===========================================================
        CTM_TYPE          (function)   CTM_GRID          (function)
        CTM_GET_DATABLOCK (function)   CTM_MAKE_DATAINFO (function)
        TAU2YYMMDD        (function)   ZSTAR             (function)
        REPLACE_TOKEN     (function)   GETMODELANDGRIDINFO 
        UNDEFINE

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        REGRIDH_O3PL, INFILENAME='~/2x25/rate.20010101', $
                      OUTFILENAME='~/4x5/rate.20010101', $ 
                      OUTRESOLUTION=4

             ; Regrids P(O3) and L(O3) data from 2x2.5 to 4x5

 MODIFICATION HISTORY:
        bmy, 27 Mar 2001: VERSION 1.00
        bmy, 23 Dec 2003: VERSION 1.01
                          - renamed to "regridv_o3pl.pro"
                          - rewritten for GAMAP v2-01
                          - now looks for sfc pressure in ~/IDL/regrid/PSURF
        bmy, 24 Feb 2004: VERSION 1.02
                          - now convert P(Ox) to kg/s and L(Ox) 1/s for
                            regridding -- then convert back after regridding
                          - now use REGRID_COLUMN to regrid P(Ox) in kg/s
                          - now use INTERPOL to regrid L(Ox) in 1/s
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_o3pl.pro)


REGRIDH_OCEAN_ACET

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_OCEAN_ACET

 PURPOSE:
        Regrids ocean production & loss for tagged CO.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_OCEAN_ACET [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing data to be regridded.
             If INFILENAME is not specified, then REGRIDH_OCEAN_ACET
             will prompt the user to select a file via a dialog box.

        OUTFILENAME -> Name of the file which will contain the regridded 
             data.  Default is "acetone.geos.{RESOLUTION}".

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  If OUTMODELNAME is not specified, 
             then REGRIDH_OCEAN_ACET will use the same model name as the
             input grid.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  OUTRESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        DIAGN -> Diagnostic category of the data blocks that you 
            wish to regrid.  Default is "EMISACET".
 
 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        =====================================================
        CTM_GRID    (function)   CTM_TYPE          (function)
        CTM_REGRIDH (function)   CTM_MAKE_DATAINFO (function)
        CTM_RESEXT  (function)   CTM_WRITEBPCH
        UNDEFINE

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        REGRIDH_OCEAN_ACET, INFILENAME='acetone.geos.2x25', $
                            OUTFILENAME='acetone.geos.1x1'
                            OUTRESOLUTION=1,                $
           
             ; Regrids 2 x 2.5 ocean acetone data to the 1x1 grid.

 MODIFICATION HISTORY:
        bmy, 15 Jun 2003: VERSION 1.00
        bmy, 23 Dec 2003: VERSION 1.01
                          - rewritten for GAMAP v2-01
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_ocean_acet.pro)


REGRIDH_POPS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_POPS

 PURPOSE:
        Regrids 1 x 1 POPS (persistent organic pollutants) emissions 
        onto a CTM grid of equal or coarser resolution.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_POPS [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name (or array of names) of the ASCII file(s) 
             which contain(s) emissions for a POP species.  If
             omitted, then the user will be prompted to select a 
             file via a dialog box.
 
        OUTFILENAME -> Name of the bpch file which will contain
             regridded data.  If omitted, then the user will be
             prompted to select a file via a dialog box.
 
        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        =======================================================
        CTM_GRID     (function)   CTM_TYPE          (function)
        CTM_REGRIDH  (function)   CTM_MAKE_DATAINFO (function) 
        CTM_WRITEBPCH             READDATA

 REQUIREMENTS:
        None

 NOTES:
        Assumes GAMAP diagnostic category name of "POP-ANTH".

 EXAMPLE:
        REGRIDH_POPS, INFILENAME='EmisPCB28Mean',$
                      OUTMODELNAME='GEOS3',      $
                      OUTRESOLUTION=2,           $
                      OUTFILENAME='PCB28.bpch'
           
             ; Regrids 1x1 POPS emissions [kg/yr] to 4x5 GEOS grid

 MODIFICATION HISTORY:
        bmy, 23 May 2005: VERSION 1.00
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_pops.pro)


REGRIDH_PORL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_PORL

 PURPOSE:
        Horizontally regrids production/loss or other data 
        in [molec/cm3/s] from one CTM grid to another.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_PORL [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing data to be regridded.
             If omitted, then REGRIDH_PORL will prompt the user to
             select a filename with a dialog box.

        OUTFILENAME -> Name of the file which will contain the regridded 
             data.  If OUTFILENAME is not specified, then REGRIDH_PORL
             will prompt the user to select a file via a dialog box.

        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.  If not
             specified, then OUTMODELNAME will be set to the same
             value as the grid stored in INFILENAME.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  OUTRESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        DIAGN -> Diagnostic category of data block that you want
             to regrid.  Default is "PORL-L=$".

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        =================================================
        CTM_GRID    (function)   CTM_TYPE    (function)
        CTM_NAMEXT  (function)   CTM_RESEXT  (function)   
        CTM_REGRIDH (function)   CTM_GET_DATA             
        CTM_WRITEBPCH            GETMODELANDGRIDINFO      
        UNDEFINE   

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        REGRIDH_PORL, INFILENAME='data.geos3.4x5', $
                      OUTFILENAME="data.geoss.4x5'
                      OUTRESOLUTION=2,             $

             ; Regrids data in molec/cm3 from GEOS-3 vertical
             ; resolution from 4x5 to 2 x 2.5 GEOs-3 resolution.

 MODIFICATION HISTORY:
        bmy, 01 Nov 2002: VERSION 1.01
        bmy, 19 Sep 2003: VERSION 1.02
                          - now call PTR_FREE to free pointer memory
        bmy, 19 Dec 2003: VERSION 1.03
                          - rewritten for GAMAP v2-01
                          - added DIAGN keyword
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_porl.pro)


REGRIDH_RESP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_RESP

 PURPOSE:
        Horizontally regrids heterogeneous respiration data (used for 
        acetone emissions) from one CTM grid to another.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_RESP, [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing data to be regridded.
             If INFILENAME is not specified, then REGRIDH_RESP
             will prompt the user to select a file via a dialog box.

        OUTFILENAME -> Name of the file which will contain the regridded 
             data.  Default is "resp.geos.{RESOLUTION}".

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  If OUTMODELNAME is not specified, 
             then REGRIDH_RESP will use the same model name as the
             input grid.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  OUTRESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        DIAGN -> Diagnostic category of the data blocks that you 
            wish to regrid.  Default is "HET-RESP".

 OUTPUTS:

 SUBROUTINES:
        External Subroutines Required:
        ======================================================
        CTM_TYPE          (function)   CTM_GRID    (function)
        CTM_RESEXT        (function)   CTM_REGRIDH (function)   
        CTM_MAKE_DATAINFO (function)   CTM_GET_DATA
        CTM_WRITEBPCH                  UNDEFINE

 REQUIREMENTS:
        None

 NOTES:
        Assumes het-resp data has units [g C/m2/month].


 EXAMPLE:
        REGRIDH_RESP, INFILENAME='resp.geos.2x25', $
                      OUTFILENAME='resp.geos.4x5', $
                      OUTRESOLUTION=2

             ; Regrids heterogeneous respiration data from the
             ; 2 x 2.5 GEOS grid (surface only) to the 4 x 5 grid.

 MODIFICATION HISTORY:
        bmy, 11 Aug 2000: VERSION 1.01
        bmy, 22 Dec 2003: VERSION 1.02
                          - rewritten for GAMAP v2-01
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_resp.pro)


REGRIDH_RESTART

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_RESTART

 PURPOSE:
        Horizontally regrids data in [v/v] mixing ratio from one
        model grid to another.  Data is converted to [kg] for 
        regridding, and then converted back to [v/v].       

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_RESTART [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing data to be regridded.
             If INFILENAME is not specified, then REGRIDH_RESTART
             will prompt the user to select a file via a dialog box.

        OUTFILENAME -> Name of the file which will contain the regridded 
             data.  If OUTFILENAME is not specified, then REGRIDH_RESTART
             will prompt the user to select a file via a dialog box.

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  If OUTMODELNAME is not specified, 
             then REGRIDH_RESTART will use the same model name as the
             input grid.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  OUTRESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        DIAGN -> Diagnostic category of the data blocks that you 
            wish to regrid.  Default is "IJ-AVG-$".

        /GCAP -> Set this switch to regrid a 4x5 GEOS-3 or GEOS-4 
            restart file to a "fake" GEOS grid containing 45 latitudes
            but the same # of levels.  You can then regrid the file
            vertically using regridv_restart.pro.

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        =================================================
        CTM_GRID       (function)   CTM_TYPE    (function)
        CTM_BOXSIZE    (function)   CTM_REGRIDH (function)
        CTM_NAMEXT     (function)   CTM_RESEXT  (function)
        CTM_WRITEBPCH               GETMODELANDGRIDINFO 
        INTERPOLATE_2D (function)   UNDEFINE 

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        REGRIDH_RESTART, INFILENAME='geos3.2x25.bpch', $
                         OUTFILENAME='geos3.4x5.bpch', $
                         OUTRESOLUTION=4
           
             ; Regrids GEOS-3 data from 2 x 2.5 to 4 x 5 resolution.

 MODIFICATION HISTORY:
        bmy, 22 Jan 2003: VERSION 1.01
        bmy, 15 Apr 2003: VERSION 1.02
                          - now reads bpch file w/o using CTM_GET_DATA;
                            this keeps us from running out of memory
        bmy, 22 Dec 2003: VERSION 1.03
                          - rewritten for GAMAP v2-01
                          - rewritten so that we can now regrid files
                            containing less than GRIDINFO.LMX levels
                          - reorganized a few things for clarity
        bmy, 13 Apr 2004: VERSION 1.04
                          - now use surface pressure files on both
                            the input and output grids
                          - now use separate arrays for airmass
                            on the two grids
                          - now adjusts polar latitudes so as to avoid
                            artificial buildup of concentration when
                            regridding from coarse --> fine grids
        bmy, 31 Jan 2005: VERSION 1.05
                          - Minor bug fix: INAREA and OUTAREA should
                            have units of [m2] for the airmass computation
                          - Now use /QUIET and /NOPRINT keywords in
                            call to CTM_GET_DATABLOCK
        bmy, 26 May 2005: VERSION 1.06
                          - added /GCAP keyword for special handling
                            when creating restart files on 4x5 GCAP grid
                          - now references INTERPOLATE_2D function
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10
                          - fixed typo for fine -> coarse regridding
                          - Now use FILE_WHICH to locate surf prs files
        bmy, 22 Nov 2010: GAMAP VERSION 2.15
                          - Remove pointer stuff to avoid errors.
                            Now just use the assignment 
                            InData = *( DataInfo[D].Data )

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_restart.pro)


REGRIDH_RESTART_NC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_RESTART_NC

 PURPOSE:
        Horizontally regrids data in [v/v] mixing ratio from one
        model grid to another.  Data is converted to [kg] for 
        regridding, and then converted back to [v/v].       

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_RESTART [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing data to be regridded.
             If INFILENAME is not specified, then REGRIDH_RESTART
             will prompt the user to select a file via a dialog box.

        OUTFILENAME -> Name of the file which will contain the regridded 
             data.  If OUTFILENAME is not specified, then REGRIDH_RESTART
             will prompt the user to select a file via a dialog box.

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  If OUTMODELNAME is not specified, 
             then REGRIDH_RESTART will use the same model name as the
             input grid.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  OUTRESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        DIAGN -> Diagnostic category of the data blocks that you 
            wish to regrid.  Default is "IJ-AVG-$".

        /GCAP -> Set this switch to regrid a 4x5 GEOS-3 or GEOS-4 
            restart file to a "fake" GEOS grid containing 45 latitudes
            but the same # of levels.  You can then regrid the file
            vertically using regridv_restart.pro.

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        =================================================
        CTM_GRID       (function)   CTM_TYPE    (function)
        CTM_BOXSIZE    (function)   CTM_REGRIDH (function)
        CTM_NAMEXT     (function)   CTM_RESEXT  (function)
        CTM_WRITEBPCH               GETMODELANDGRIDINFO 
        INTERPOLATE_2D (function)   UNDEFINE 

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        REGRIDH_RESTART_NC, INFILENAME='geos3.2x25.nc', $
                            OUTFILENAME='geos3.4x5.nc', $
                            OUTRESOLUTION=4
           
             ; Regrids GEOS-3 data from 2 x 2.5 to 4 x 5 resolution.

 MODIFICATION HISTORY:
        jaf, 01 May 2016: Initial version based on regridh_restart.pro and
                          bpch2coards.pro

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_restart_nc.pro)


REGRIDH_SCALEFOSS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_SCALEFOSS

 PURPOSE:
        Regrids 0.5 x 0.5 fossil fuel scale factors onto a 
        CTM grid of equal or coarser resolution.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRID_SCALEFOSS [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        MODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        RESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.;

        YEAR -> 4-digit year number (e.g. 1994) correspoinding
             to the data to be regridded.  Default is 1994.

        OUTDIR -> Name of the directory where the output file will
             be written.  Default is './'. 

 OUTPUTS:
        Writes output to binary files (*NOT* binary punch files):
             scalefoss.liq.{RESOLUTION}.{YEAR}
             scalefoss.tot.{RESOLUTION}.{YEAR}

 SUBROUTINES:
        External Subroutines Required:
        ================================================
        CTM_GRID    (function)    CTM_TYPE   (function)
        CTM_REGRID  (function)    CTM_NAMEXT (function)   
        CTM_RESEXT  (function)

        Internal Subroutines:
        ================================================
        RS_READ_DATA (function)   RS_WRITE_DATA

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        REGRID_SCALEFOSS, YEAR=1994,              $
                          MODELNAME='GEOS_STRAT', $
                          RESOLUTION=[5,4]
           
             ; Regrids fossil fuel scale factor files for 1994 from
             ; 0.5 x 0.5 resolution onto the 4 x 5 GEOS-STRAT grid

 MODIFICATION HISTORY:
        bmy, 09 Jun 2000: VERSION 1.00
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10
        phs, 08 Feb 2008: GAMAP VERSION 2.12
                          - added swap_endian keyword to OPEN_FILE
                            in RS_Read_Data and RS_WRITE_DATA
                          - fixed keywords checking
                          - replace ctm_regrid w/ ctm_regridh

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_scalefoss.pro)


REGRIDH_SCALEFOSS_SOX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_SCALEFOSS_SOX

 PURPOSE:
        Regrids 0.5 x 0.5 fossil fuel scale factors onto a 
        CTM grid of equal or coarser resolution.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRID_SCALEFOSS [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        MODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        RESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.;

        YEAR -> 4-digit year number (e.g. 1994) correspoinding
             to the data to be regridded.  Default is 1994.

        OUTDIR -> Name of the directory where the output file will
             be written.  Default is './'. 

 OUTPUTS:
        Writes output to binary files (*NOT* binary punch files):
             scalefoss.liq.{RESOLUTION}.{YEAR}
             scalefoss.tot.{RESOLUTION}.{YEAR}

 SUBROUTINES:
        External Subroutines Required:
        ================================================
        CTM_GRID    (function)    CTM_TYPE   (function)
        CTM_REGRID  (function)    CTM_NAMEXT (function)   
        CTM_RESEXT  (function)

        Internal Subroutines:
        ================================================
        RS_READ_DATA (function)   RS_WRITE_DATA

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        REGRID_SCALEFOSS, YEAR=1994,              $
                          MODELNAME='GEOS_STRAT', $
                          RESOLUTION=[5,4]
           
             ; Regrids fossil fuel scale factor files for 1994 from
             ; 0.5 x 0.5 resolution onto the 4 x 5 GEOS-STRAT grid

 MODIFICATION HISTORY:
        bmy, 09 Jun 2000: VERSION 1.00
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_scalefoss_sox.pro)


REGRIDH_SHIPSO2

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_SHIPSO2

 PURPOSE:
        Horizontally regrids emissions SOx from ship emissions
        in [molec/cm2/s] from one CTM grid to another. 

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_SHIPSO2 [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing C3H8 and C2H6 to
             be regridded.  If omitted, then REGRIDH_SHIPSO2 will
             prompt the user to select a filename via a dialog box.

        OUTFILENAME -> Name of output file containing the regridded
             data.  If OUTFILENAME is not specified, then REGRIDH_SHIPSO2 
             will ask the user to specify a file via a dialog box.

        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.  If
             OUTMODELNAME is not specified, REGRIDH_SHIPSO2 will 
             use the same model name as the input grid.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        DIAGN -> Diagnostic category of the data blocks that you 
            wish to regrid.  Default is "IJ-AVG-$".

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        =======================================================
        CTM_GRID          (function)   CTM_TYPE     (function)
        CTM_REGRIDH       (function)   CTM_RESEXT   (function)
        CTM_MAKE_DATAINFO (function)   CTM_WRITEBPCH            
        UNDEFINE

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        REGRIDH_SHIPSO2, INFILENAME='shipSOx.geos.2x25',  $
                         OUTFILENAME='shipSOx.geos.4x5',  $
                         OUTRESOLUTION=4

             ; Regrids C3H8 and C2H6 data onto from the 4 x 5
             ; GEOS-3 grid to the the 2 x 2.5 GEOS-3 grid.

 MODIFICATION HISTORY:
        bmy, 08 Jan 2003: VERSION 1.00
        bmy, 22 Dec 2003: VERSION 1.01
                          - rewritten for GAMAP v2-01 
                          - now call PTR_FREE to free pointer memory
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_shipso2.pro)


REGRIDH_SOILPREC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_SOILPREC

 PURPOSE:
        Regrids soil precipitation from 0.5 x 0.5 resolution 
        onto a CTM grid of equal or coarser resolution.
        
 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_SOILPREC [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing data to be regridded.
             Default: "~bmy/archive/data/soil_NOx_200203/05x05_gen/lcprc.asc"

        OUTFILENAME -> Name of the file which will contain the regridded 
             data.  Default is "soil_precip.geos.{RESOLUTION}".

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  Default is "GEOS3".

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  OUTRESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        DIAGN -> Diagnostic category of the data blocks that you 
            wish to regrid.  Default is "SOILPREC".

 OUTPUTS:
        None
  
 SUBROUTINES:
        External Subroutines Required:
        ==============================================
        CTM_TYPE    (function)   CTM_GRID   (function)
        CTM_NAMEXT  (function)   CTM_RESEXT (function)
        CTM_REGRIDH (function)   CTM_BOXSIZE
        CTM_WRITEBPCH            UNDEFINE
 
 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE: 
        REGRIDH_SOILPREC, OUTMODELNAME='GEOS3', $
                          OUTRESOLUTION=2,      $
                          OUTFILENAME='soil_precip.geos.2x25'

             ; Regrids 0.5 x 0.5 soil precipitation data onto
             ; the GEOS-1 2 x 2.5 grid.  Output will be sent
             ; to the "~bmy/regrid" directory.  

 MODIFICATION HISTORY:
        bmy, 01 Aug 2000: VERSION 1.00
        bmy, 08 Jan 2003: VERSION 1.01
                          - renamed to "regridh_soilprec.pro"
                          - removed OUTDIR, added OUTFILENAME
                          - updated comments
        bmy, 23 Dec 2003: VERSION 1.02
                          - updated for GAMAP v2-01
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10
        bmy, 24 Apr 2008: GAMAP VERSION 2.12
                          - bug fix: N_ELEMENTS was misspelled

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_soilprec.pro)


REGRIDH_SST

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_SST

 PURPOSE:
        Horizontally regrids SST data from one CTM grid to another.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_SST, [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing data to be regridded.
             If omitted, then REGRIDH_SST will prompt the user to
             select a filename with a dialog box.

        OUTFILENAME -> Name of the file which will contain the regridded 
             data.   If omitted, then REGRIDH_SST will prompt the
             user to select a filename with a dialog box.

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  Default is "SST.{MODELNAME}.{RESOLUTION}".

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  OUTRESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        DIAGN -> Diagnostic category of the data blocks that you 
            wish to regrid.  Default is "GMAO-2D".

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        ====================================================
        CTM_TYPE          (function)   CTM_GRID   (function)
        CTM_NAMEXT        (function)   CTM_RESEXT (function)
        CTM_MAKE_DATAINFO (function)   CTM_WRITEBPCH 
        GETMODELANDGRIDINFO            UNDEFINE

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        REGRID_SST, INFILENAME='SST.geos.2x25', $
                    OUTFILENAME='SST.geos.1x1', $
                    OUTRESOLUTION=1

             ; Regrids SST data from 2 x 2.5 to 1x1 horizontal grid.

 MODIFICATION HISTORY:
        bmy, 28 Mar 2003: VERSION 1.01
        bmy, 22 Dec 2003: VERSION 1.02
                          - rewritten for GAMAP v2-01
                          - now call PTR_FREE to free pointer memory
                          - added DIAGN keyword
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_sst.pro)


REGRIDH_STRATJV

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_STRATJV

 PURPOSE:
        Horizontally regrids 2-D stratospheric J-Value files 
        from one CTM grid to another CTM grid.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_STRATJV [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing data to be regridded.
       Default: ~bmy/archive/data/stratjv_200203/2x25_geos/stratjv.geos3.2x25

        OUTFILENAME -> Name of output file containing the regridded
             data.  Default is "stratjv.{MODELNAME}.{RESOLUTION}.

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  If OUTMODELNAME is not specified, 
             REGRIDV_DUST will use the same model name as the
             input grid.

        DIAGN -> Diagnostic category of data block that you want
             to regrid.  Default is "JV-MAP-$".

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        ===========================================================
        CTM_TYPE          (function)   CTM_GRID          (function)
        CTM_NAMEXT        (function)   CTM_RESEXT        (function)
        CTM_GET_DATABLOCK (function)   CTM_MAKE_DATAINFO (function)
        GETMODELANDGRIDINFO            CTM_WRITEBPCH 
        UNDEFINE

 REQUIREMENTS:
        None

 NOTES:
        (1) 2-D Stratospheric J-Values are needed for the simple chemistry 
            mechanism in the stratosphere.  They are originally obtained 
            by running the GEOS model with SLOW-J and then archiving 
            the J-Values with the ND22 diagnostic.  These can then be
            regridded to other vertical resolutions via REGRIDV_STRATJV.

 EXAMPLE:
        REGRIDV_STRATJV, INFILENAME='stratjv.geos3.4x5'
                         OUTFILENAME='stratjv.geos3.2x25'
                         OUTRESOLUTION=2

             ; Regrids GEOS-3 4x5 J-value data to 2x2.5 resolution.

 MODIFICATION HISTORY:
        bmy, 13 Jan 2003: VERSION 1.00
        bmy, 22 Dec 2003: VERSION 1.01
                          - rewritten for GAMAP v2-01
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_stratjv.pro)


REGRIDH_TAGCO_MASK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_TAGCO_MASK

 PURPOSE:
        Regrids country mask (used to separate Tagged CO emissions)
        from the GEOS-4 1 x 1.25 grid to another CTM grid.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_TAGCO_MASK [, Keywords ]

 INPUTS:

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the input file to be regridded.  This
             file is stored as binary F77 unformatted, with short
             integers.  The default filename is:
          '~/bmy/archive/data/tagged_CO_200106/1x125_geos/tagco_mask.f77_unf'

        OUTFILENAME -> Name of the file which will contain the
             regridded data.  Default is "tagco_mask.geos.{RESOLUTION}".

        OUTMODELNAME -> Name of the CTM grid onto which the data will 
             be regridded.  Default is "GEOS_4".  NOTE: Since the 
             country mask is 2-D data, the vertical dimension of the
             CTM grid will be ignored.

        OUTRESOLUTION -> Resolution of the CTM grid onto which the
             data will be regridded.  Default is 4.

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        ========================================================
        CTM_TYPE          (function)   CTM_GRID       (function)
        CTM_MAKE_DATAINFO (function)   INTERPOLATE_2D (function)
        CTM_WRITEBPCH                  OPEN_FILE

 REQUIREMENTS:
        Requires routines from both the GAMAP and TOOLS packages.

 NOTES:
        None

 EXAMPLE:
        REGRIDH_TAGCO_MASK, INFILENAME='tagco_mask.f77_unf',$
                            OUTMODELNAME='GEOS_4",          $
                            OUTRESOLUTION=2,                $
                            OUTFILENAME='tagco_mask.geos.2x25' 

             ; Regrids country mask for Tagged CO

 MODIFICATION HISTORY:
        bmy, 22 Jun 2004: VERSION 1.00
        bmy, 02 Apr 2008: GAMAP VERSION 2.12
                          - Read input data as big-endian

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_tagco_mask.pro)


REGRIDH_UNIT_AREA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_UNIT_AREA

 PURPOSE:
        Horizontally regrids quantities (such as emissions) in units 
        of [molec/cm2/s], [atoms C/cm2/s], [molec/m2/s], [atoms C/m2/s], 
        etc., from one CTM grid to another.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_UNIT_AREA [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing data to be regridded.
             If INFILENAME is not specified, then REGRIDH_RESTART
             will prompt the user to select a file via a dialog box.

        OUTFILENAME -> Name of the file which will contain the regridded 
             data.  If OUTFILENAME is not specified, then REGRIDH_RESTART
             will prompt the user to select a file via a dialog box.
 
        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.  If not
             passed, then the model name corresponding to the data
             contained in INPUTFILE will be used as the default.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        DIAGN -> Diagnostic category of the data blocks that you 
            wish to regrid.  Default is "IJ-AVG-$".
             
 OUTPUTS:
        None

 SUBROUTINES:

        External Subroutines Required:
        ========================================================
        CTM_GRID          (function)   CTM_TYPE      (function)
        CTM_REGRIDH       (function)   CTM_WRITEBPCH
        CTM_MAKE_DATAINFO (function)   UNDEFINE
 
 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        REGRIDH_UNIT_AREA, $
               INFILENAME='biomass.seasonal.generic.1x1', $
               OUTMODELNAME='GEOS4'
               OUTRESOLUTION=2 $
               OUTFILENAME='biomass.seasonal.geos.2x25'GEOS_STRAT', 
           
             ; Regrids seasonal 1 x 1 biomass burning data 
             ; onto the GEOS_4 2 x 2.5 grid.

 MODIFICATION HISTORY:
        bmy, 18 Aug 2005: VERSION 1.00
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_unit_area.pro)


REGRIDH_UVALBEDO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDH_UVALBEDO

 PURPOSE:
        Horiziontally regrids UV albedo data from its native
        resolution (1 x 1 or 1 x 1.25) to a CTM grid.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDH_UVALBEDO [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        OUTFILENAME -> Name of the binary punch file containing
             regridded UV Albedo data.  The default value for
             OUTFILENAME is uvalbedo.geos.{RESOLUTION} 

        FILL -> Value to fill "missing data" with.  Default is
             0.85 (typcial albedo over ice).

 OUTPUTS:
        None

 SUBROUTINES:
        Internal Subroutines Required:
        =====================================================
        READ_UVALBEDO (function)

        External Subroutines Required:
        =====================================================
        MFINDFILE   (function)   CTM_TYPE          (function)
        CTM_NAMEXT  (function)   CTM_RESEXT        (function)
        CTM_REGRIDH (function)   CTM_MAKE_DATAINFO (function)
        CTM_WRITEBPCH            OPEN_FILE
        UNDEFINE

 REQUIREMENTS:
        None

 NOTES:
        (1) Input file names are hardwired -- change as necessary 

 EXAMPLE:
        REGRIDH_UVALBEDO, OUTFILENAME='uvalbedo.geos3.2x25', $
                          OUTMODELNAME='GEOS3',              $
                          OUTRESOLUTION=2     

             ; Regrids UV Albedos from the native grid to the
             ; 2 x 2.5 GEOS-3 horizontal grid.  (This is
             ; actually the same horizontal grid as for 2 x 2.5
             ; GEOS-1, GEOS-STRAT, and GEOS-4.)

 MODIFICATION HISTORY:
        bmy, 06 Jul 2000: VERSION 1.00
        bmy, 24 Jul 2000: VERSION 1.01
                          - added OUTDIR keyword
        bmy, 16 Nov 2001: VERSION 1.02
                          - adapted for Koelemeijer et al 2001 data
        bmy, 15 Jan 2003: VERISON 1.03
                          - renamed to "regridh_uvalbedo.pro"
                          - "read_uvalbedo.pro" is now an internal function
                          - now uses CTM_REGRIDH to do the regridding
        bmy, 23 Dec 2003: VERSION 1.04
                          - updated for GAMAP v2-01
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_uvalbedo.pro)


REGRIDVH_NOY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDVH_NOY

 PURPOSE:
        Regrids zonal mean P(NOY), [NO3], [O3], [NO], and 
        [NO2] data obtained from a 2-D stratospheric model 
        (Hans Schneider, Dylan Jones) onto GEOS-Chem levels.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDVH_NOY [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing data to be regridded.  
             Default is '~bmy/archive/data/pnoy_200106/raw/PNOY.data'.

        OUTFILENAME -> Name of output file containing the regridded
             data.  Default is pnoy_nox_hno3.{MODELNAME}.{RESOLUTION}.
             
        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  Default is "GEOS3".

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        DIAGN -> Diagnostic category of data block that you want
             to regrid.  Default is "PNOY-L=$".

 OUTPUTS:
        None.

 SUBROUTINES:
        Internal Subroutines:
        ============================================================
        RN_ERROR_CHECK    (function)   RN_PLOT_COLUMN    (function)

        External Subroutines Required:
        ============================================================
        CTM_GRID          (function)   CTM_TYPE          (function)
        CTM_NAMEXT        (function)   CTM_RESEXT        (function)
        CTM_GET_DATABLOCK (function)   CTM_MAKE_DATAINFO (function)
        ZSTAR             (function)   CTM_WRITEBPCH              
        UNDEFINE   

 REQUIREMENTS:
        References routines from both the GAMAP & TOOLS packages.

 NOTES:
        None

 EXAMPLE:
        REGRIDVH_NOY, INFILENAME='PNOY.data', $
                      OUTMODELNAME='GEOS1',   $
                      OUTRESOLUTION=2

             ; Regrids P(NOy), HNO3, O3, NO, NO2 data from
             ; its native grid to the 2 x 2.5 GEOS-1 grid.  

 MODIFICATION HISTORY:
        bmy, 29 Jun 2000: VERSION 1.00
        bmy, 11 Aug 2000: VERSION 1.01
                          - added OUTDIR keyword
                          - FILENAME is now a keyword
        bmy, 04 Dec 2000: VERSION 1.02
                          - bug fix: use 801 pts for GEOS-STRAT interpolation
        bmy, 28 Mar 2001: VERSION 1.02
                          - now use cubic spline interpolation
                          - now use CTM_WRITEBPCH, CTM_NAMEXT, CTM_RESEXT
                          - renamed keyword MODELNAME to OUTMODELNAME
                          - renamed keyword RESOLUTION to OUTRESOLUTION
                          - renamed keyword FILENAME to INFILENAME
                          - updated comments
        bmy, 19 Jun 2001: VERSION 1.03
                          - bug fix: make sure output is [v/v/s] or [v/v]
                          - now make sure concentrations aren't negative 
                            after interpolating to CTM grid 
        bmy, 08 Jan 2003: VERSION 1.04
                          - renamed to "regridvh_noy.pro"
                          - now use linear interpolation in vertical
        bmy, 23 Dec 2003: VERSION 1.05
                          - rewritten for GAMAP v2-01
                          - looks for sfc pressure file in ./PSURF subdir
                          - now supports output hybrid grid
        bmy, 06 Aug 2004: VERSION 1.06
                          - now calls GET_GCAP_PRESSURE to get the
                            array of pressures (since it is a hybrid
                            grid w/ a wacky PTOP of 150 hPa.)
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10
                          - Now suppresses verbose output 
                          - Use FILE_WHICH to locate surf prs files

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridvh_noy.pro)


REGRIDVH_PCO_LCO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDVH_PCO_LCO

 PURPOSE:
        Vertically and horizontally regrids zonal mean P(CO) and
        L(CO) data obtained from a 2-D stratospheric model (Hans 
        Schneider, Dylan Jones) onto CTM sigma levels

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDVH_PCO_LCO [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing input 
             data to be regridded to the output grid specified 
             by MODELNAME and RESOLUTION.  Default is "CO.P_L.data".

        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.  

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        =====================================================
        CTM_TYPE   (function)   CTM_GRID          (function) 
        ZSTAR      (function)   CTM_GET_DATABLOCK (function)
        CTM_NAMEXT (function)   CTM_RESEXT        (function)

 REQUIREMENTS:
        None

 NOTES:
        (1) Requires a file containing surface pressures on the 
            output CTM grid -- see /users/ctm/bmy/sup/data/regrid 
            directory for examples.

 EXAMPLE:
        REGRID_PCO_LCO, INFILENAME='CO.P_L.data', $
                        OUTMODELNAME='GEOS1',     $
                        OUTRESOLUTION=2

             ; Regrids P(CO) and L(CO) data from its native grid
             ; to the 2 x 2.5 GEOS-1 grid.  

 MODIFICATION HISTORY:
        bmy, 29 Jun 2000: VERSION 1.00
        bmy, 11 Aug 2000: VERSION 1.01
                          - added OUTDIR keyword
                          - FILENAME is now a keyword
        bmy, 28 Mar 2001: VERSION 1.02
                          - now use cubic spline interpolation
                          - now use CTM_WRITEBPCH, CTM_NAMEXT, CTM_RESEXT
                          - renamed keyword MODELNAME to OUTMODELNAME
                          - renamed keyword RESOLUTION to OUTRESOLUTION
                          - renamed keyword FILENAME to INFILENAME
        bmy, 08 Jan 2003: VERSION 1.03
                          - renamed to "regridvh_pco_lco.pro"l
                          - now do linear interpolation in the vertical
        bmy, 18 Dec 2003: VERSION 1.04
                          - rewritten for GAMAP v2-01
                          - Now looks for 
                          - Now supports hybrid output grid
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10
                          - Use FILE_WHICH to locate surf prs files
        bmy, 28 Jan 2008: GAMAP VERSION 2.12
                          - Bug fix: PSFILE instead of PSFILENAME

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridvh_pco_lco.pro)


REGRIDVH_STRATJV

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDVH_STRATJV

 PURPOSE:
        Vertically regrids 2-D stratospheric J-Value data
        from one CTM grid to another.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDVH_STRATJV [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing data to be regridded.
             Default is "stratjv.{MODELNAME}.{RESOLUTION}".

        OUTFILENAME -> Name of output file containing the regridded
             data.  Default is "stratjv.{MODELNAME}.{RESOLUTION}"

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  Default is "GEOS3".

        OUTRESOLUTION -> Horizontal resolution of the model grid onto 
             which the data will be regridded.  Default=4 (which
             indicates a 4x5 grid).
             
        DIAGN -> Diagnostic category of data block that you want
             to regrid.  Default is "JV-MAP-$".

 OUTPUTS:
        Writes output to the "stratjv.{MODELNAME}.{RESOLUTION}" file.

 SUBROUTINES:
        External Subroutines Required:
        ==========================================================
        CTM_TYPE          (function)  CTM_GRID          (function)
        CTM_NAMEXT        (function)  CTM_RESEXT        (function)
        CTM_GET_DATABLOCK (function)  CTM_MAKE_DATAINFO (function)
        ZSTAR             (function)  GET_GCAP_PRESSURE (function)
        UNDEFINE

 REQUIREMENTS:
        None

 NOTES:
        2-D Stratospheric J-Values are needed for the simple chemistry 
        mechanism in the stratosphere.  They are originally obtained 
        by running the GEOS model with SLOW-J and then archiving 
        the J-Values with the ND22 diagnostic.  These can then be
        regridded to other vertical resolutions via REGRID_STRATJV.

 EXAMPLE:
        REGRIDVH_STRATJV, INFILENAME='stratjv.geoss.4x5'
                          OUTMODELNAME='GEOS3',      $
                          OUTRESOLUTION=4 
                          OUTFILENAME='stratjv.geos3.4x5'
                         
             ; Regrids the 4 x 4 GEOS-STRAT 2-D stratospheric 
             ; J-value field to the GEOS-3 grid.

 MODIFICATION HISTORY:
        bmy, 06 Aug 2004: VERSION 1.01
        bmy, 15 Feb 2007: VERSION 1.02
                          - Suppress verbose output
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10
                          - Use FILE_WHICH to locate surf prs files

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridvh_stratjv.pro)


REGRIDVH_STRATOH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDVH_STRATOH

 PURPOSE:
        Vertically and horizontally regrids 2-D stratospheric OH
        fields (for the simplified stratospheric chemistry loss) 
        from native resolution onto a CTM grid.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDV_STRATOH [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing input data to be
             regridded.  Default is 
             '~bmy/archive/data/stratOH_200203/raw/OH.2d.model.data'

        OUTFILENAME -> Name of file containing regridded output
             data.  Default is "stratoh.{MODELNAME}.{RESOLUTION}"

        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        ================================================
        CTM_TYPE   (function)  CTM_GRID      (function)
        CTM_NAMEXT (function)  CTM_RESEXT    (function)
        ZSTAR      (function)  ZMID          (function)
        ZEDGE      (function)  ADD_SEPARATOR (function)

 
 REQUIREMENTS:
        None

 NOTES:
        Stratospheric OH data was obtained from Hans Schneider 
        and Dylan Jones.

 EXAMPLE:
        REGRIDVH_STRATOH, INFILENAME='OH.2d.model.data', $
                          OUTMODELNAME='GEOS4',          $
                          OUTRESOLUTION=2

             ; Regrids original stratospheric OH data to the 
             ; 2 x 2.5 GEOS-4 grid (with 55 layers)
              
 MODIFICATION HISTORY:
        bmy, 30 Jun 2000: VERSION 1.00
        bmy, 02 Aug 2000: VERSION 1.01
                          - FILENAME is now a keyword
        bmy, 18 Dec 2003: VERSION 1.02
                          - renamed to REGRIDVH_STRATOH
                          - rewritten for GAMAP v2-01
                          - Now supports hybrid output grids
        bmy, 15 Feb 2007: VERSION 1.03
                          - Bug fix for PS file name
                          - Suppress verbose printing
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10
                          - Use FILE_WHICH to locate surf prs files
        bmy, 28 Jan 2008: GAMAP VERSION 2.12
                          - Bug fix: don't hardwire path for PS file

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridvh_stratoh.pro)


REGRIDV_3D_OH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDV_3D_OH

 PURPOSE:
        Vertically regrids 3-D OH data from one CTM grid to another.  

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDV_3D_OH [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing OH data to be
             regridded.  If not specified, then a dialog box
             will ask the user to supply a file name.

        OUTFILENAME -> Name of file to contain the regridded OH.
             Default is "OH_3Dglobal.{MODELNAME}.{RESOLUTION}".

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  If OUTMODELNAME is not specified, 
             REGRIDV_3D_OH will use the same model name as the
             input grid.

        DIAGN -> Diagnostic category of data block that you want
             to regrid.  Default is "IJ-AVG-$".

        /TROP_ONLY -> If set, will only regrid data within the
             tropopause (i.e. up to the level specified by
             MODELINFO.NTROP).  

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        ============================================================
        CTM_TYPE          (function)   CTM_GRID          (function)
        CTM_NAMEXT        (function)   CTM_RESEXT        (function)
        CTM_MAKE_DATAINFO (function)   CTM_GET_DATABLOCK (function)
        REGRID_COLUMN     (function)   GETMODELANDGRIDINFO
        UNDEFINE

 REQUIREMENTS:
        None

 NOTES:
        (1) The merged OH file is generated by "merge_oh.pro".

 EXAMPLE:
        REGRIDV_3D_OH, INFILENAME='OH_3Dglobal.geos3.4x5', $
                       OUTFILENAME='OH_3Dglobal.geos4.4x5',$
                       OUTMODELNAME='GEOS4'

             ; Regrids GEOS-3 merged OH (48 layers) to the GEOS-4 
             ; grid (55 layers) at 4x5 horizontal resolution
              
 MODIFICATION HISTORY:
        bmy, 02 Aug 2000: VERSION 1.00
                          - adapted from "regrid_oh_for_geos2.pro"
        bmy, 05 Feb 2002: VERSION 1.01
                          - now conserves column mass
        bmy, 14 Mar 2002: VERSION 1.02
                          - RENAMED TO "regridv_3d_oh.pro"
        bmy, 22 Dec 2003: VERSION 1.03
                          - totally rewritten for GAMAP v2-01
                          - now supports hybrid grids
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10
                          - Use FILE_WHICH to locate surf prs files

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridv_3d_oh.pro)


REGRIDV_AEROSOL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDV_AEROSOL

 PURPOSE:
        Vertically regrids aerosol concentrations from one
        CTM grid to another.  Total mass is conserved.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDV_AEROSOL [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        MONTH -> Month of year for which to process data.  Default is
             the entire year.  Since the aerosol files are very large,
             it take several iterations to regrid an entire year of
             data.  You can break the job down 1 month at a time.

        INFILENAME -> Name of the file containing data to be regridded.
             If omitted, then REGRIDV_AEROSOL will prompt the user to
             select a filename with a dialog box.

        OUTFILENAME -> Name of output file containing the regridded
             data.  If OUTFILENAME is not specified, then REGRIDV_AEROSOL
             will ask the user to specify a file via a dialog box.

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  If OUTMODELNAME is not specified, 
             REGRIDV_AEROSOL will use the same model name as the
             input grid.

        DIAGN -> Diagnostic category of the data blocks that you 
            wish to regrid.  Default is "ARSL-L=$".

        /TROP_ONLY -> If set, will only regrid data within the
             tropopause (i.e. up to the level specified by
             MODELINFO.NTROP).  

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        =======================================================
        CTM_GRID          (function)   CTM_TYPE          (function)
        CTM_BOXSIZE       (function)   CTM_REGRID        (function)
        CTM_NAMEXT        (function)   CTM_RESEXT        (function)
        CTM_GET_DATABLOCK (function)   CTM_MAKE_DATAINFO (function)
        REGRID_COLUMN     (function)   CTM_WRITEBPCH              
        CTM_GET_DATA                   GETMODELANDGRIDINFO        
        UNDEFINE   

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        REGRIDV_AEROSOL, INFILENAME='aerosol.geos3.4x5',  $
                         OUTFILENAME='aerosol.geos4.4x5', $
                         OUTRESOLUTION=4,                   $

             ; Regrids dust data from the GEOS-3 4 x 5
             ; grid to the GEOS-4 4 x 5 grid.

 MODIFICATION HISTORY:
        bmy, 26 Jan 2001: VERSION 1.00
                          - based on "regrid_dust_weights.pro" 
        bmy, 13 Feb 2001: VERSION 1.01
                          - de-hardwired calls to CTM_BOXSIZE
        bmy, 22 Feb 2001: VERSION 1.02
                          - now use improved version of SUMV.PRO
                            which can handle GEOS-1 --> GEOS-STRAT
                            vertical regridding
        bmy, 28 Feb 2002: VERSION 1.03
                          - Now use REGRID_COLUMN as a robust way
                            to do the vertical regridding
        bmy, 22 Dec 2003: VERSION 1.04
                          - rewritten for GAMAP v2-01
                          - now looks for sfc pressure in ~/IDL/regrid/PSURF
                          - now supports hybrid grids
                          - now call PTR_FREE to clear the heap memory
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10
                          - Use FILE_WHICH to locate surf prs files

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridv_aerosol.pro)


REGRIDV_DUST

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDV_DUST

 PURPOSE:
        Vertically regrids mineral dust concentrations [kg/m3]
        from one CTM grid to another.  Total mass is conserved.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDV_DUST [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        MONTH -> Month of year for which to process data.  Default is
             the entire year.  Since the dust files are very large,
             it take several iterations to regrid an entire year of
             data.  You can break the job down 1 month at a time.

        INFILENAME -> Name of the file containing data to be regridded.
             If omitted, then REGRIDV_DUST will prompt the user to
             select a filename with a dialog box.

        OUTFILENAME -> Name of output file containing the regridded
             data.  If OUTFILENAME is not specified, then REGRIDV_DUST
             will ask the user to specify a file via a dialog box.

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  If OUTMODELNAME is not specified, 
             REGRIDV_DUST will use the same model name as the
             input grid.

        DIAGN -> Diagnostic category of data block that you want
             to regrid.  Default is "MDUST-$".

        /TROP_ONLY -> If set, will only regrid data within the
             tropopause (i.e. up to the level specified by
             MODELINFO.NTROP).  

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        =======================================================
        CTM_GRID          (function)   CTM_TYPE          (function)
        CTM_BOXSIZE       (function)   CTM_REGRID        (function)
        CTM_NAMEXT        (function)   CTM_RESEXT        (function)
        CTM_GET_DATABLOCK (function)   CTM_MAKE_DATAINFO (function)
        REGRID_COLUMN     (function)   CTM_WRITEBPCH              
        CTM_GET_DATA                   GETMODELANDGRIDINFO        
        UNDEFINE   

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        REGRIDV_DUST, MONTH=1,                          $
                      INFILENAME='dust.geos3.2x25',     $
                      OUTFILENAME='dust.geos4.4x5.01',  $
                      OUTRESOLUTION=4

             ; Vertically regrids dust data from the GEOS-3
             ; 2 x 2.5 grid to the GEOS-3 4 x 5 grid for January.

 MODIFICATION HISTORY:
        bmy, 26 Jan 2001: VERSION 1.00
                          - based on "regrid_dust_weights.pro" 
        bmy, 13 Feb 2001: VERSION 1.01
                          - de-hardwired calls to CTM_BOXSIZE
        bmy, 22 Feb 2001: VERSION 1.02
                          - now use improved version of SUMV.PRO
                            which can handle GEOS-1 --> GEOS-STRAT
                            vertical regridding
        bmy, 28 Feb 2002: VERSION 1.03
                          - Now use REGRID_COLUMN as a robust way
                            to do the vertical regridding
        bmy, 23 Dec 2003: VERSION 1.04
                          - rewritten for GAMAP v2-01
                          - now looks for sfc pressure ~/IDL/regrid/PSURF
                          - now supports hybrid grids
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10
                          - Use FILE_WHICH to locate surf prs files

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridv_dust.pro)


REGRIDV_JV

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDV_JV

 PURPOSE:
        Vertically regrids J-values from one CTM grid to another.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDV_JV, [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing input data to be
             regridded to the output grid specified by MODELNAME
             and RESOLUTION.

        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        OUTFILENAME -> Name of file containing regridded output
             data.  Written in binary punch format.

        /TROP_ONLY -> Set this switch to only save data below
             the tropopause.

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        =======================================================
        CTM_TYPE     (function)   CTM_GRID           (function)
        CTM_NAMEXT   (function)   CTM_RESEXT         (function)
        ZSTAR        (function)   CTM_GET_DATABLOCK  (function)
        CTM_GET_DATA              CTM_MAKE_DATAINFO  (function)
        CTM_WRITEBPCH             GETMODELANDGRIDINFO  

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        REGRIDV_JV, INFILENAME='JH2O2.geos3.4x5',  $
                    OUTFILENAME='JH2O2.geos4.4x5', $
                    OUTMODELNAME='GEOS4'

             ; Regrids GEOS-3 stratospheric J-value data at 4 x 5
             ; resolution from GEOS-3 to GEOS-4 vertical resolution.

 MODIFICATION HISTORY:
        bmy, 11 Aug 2000: VERSION 1.01
        bmy, 22 Dec 2003: VERSION 1.02
                          - renamed to "regridv_jv"
                          - now looks for sfc pressure in ~/IDL/regrid/PSURF
                          - now updated for GAMAP v2-01
                          - added /TROP_ONLY keyword
                          - updated comments
        bmy, 07 Jul 2005: VERSION 1.03
                          - Now pass /QUIET keyword to CTM_GET_DATA
                          - Now pass /NOPRINT keyword to CTM_GET_DATABLOCK
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10
                          - Use FILE_WHICH to locate surf prs files
        ccc, 09 Oct 2009: GAMAP VERSION 2.13
                          - fix size of outdata 3rd dimension

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridv_jv.pro)


REGRIDV_O3PL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDV_O3PL

 PURPOSE:
        Vertically regrids files containing GEOS-CHEM P(O3) and L(O3).

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRID_O3PL [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing data to be regridded.
             If INFILENAME is not specified, then REGRIDV_O3PL
             will prompt the user to select a file via a dialog box.

        OUTFILENAME -> Name of the file which will contain the regridded 
             data.  If OUTFILENAME is not specified, then REGRIDV_PORL
             will prompt the user to select a file via a dialog box.

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  Default is "GEOS3".

        DIAGN -> Diagnostic category of the data blocks that you 
            wish to regrid.  Default is "PORL-L=$".

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        ===========================================================
        CTM_TYPE          (function)   CTM_GRID          (function)
        CTM_GET_DATABLOCK (function)   CTM_MAKE_DATAINFO (function)
        TAU2YYMMDD        (function)   ZSTAR             (function)
        REPLACE_TOKEN     (function)   GETMODELANDGRIDINFO 
        UNDEFINE

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        REGRIDV_O3PL, INFILENAME='~/geoss/rate.971130', $
                      OUTFILENAME='~/geos3/rate.971130', $ 
                      OUTMODELNAME='GEOS3'

             ; Regrids P(O3) and L(O3) data from GEOS-STRAT 
             ; 4 x 5 grid to GEOS-3 4 x 5 grid.

 MODIFICATION HISTORY:
        bmy, 27 Mar 2001: VERSION 1.00
        bmy, 23 Dec 2003: VERSION 1.01
                          - renamed to "regridv_o3pl.pro"
                          - rewritten for GAMAP v2-01
                          - now looks for sfc pressure in ~/IDL/regrid/PSURF
        bmy, 24 Feb 2004: VERSION 1.02
                          - now convert P(Ox) to kg/s and L(Ox) 1/s for
                            regridding -- then convert back after regridding
                          - now use REGRID_COLUMN to regrid P(Ox) in kg/s
                          - now use INTERPOL to regrid L(Ox) in 1/s
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10
                          - Use FILE_WHICH to locate surf prs files

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridv_o3pl.pro)


REGRIDV_PORL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDV_PORL

 PURPOSE:
        Regrids production/loss or other data in [molec/cm3/s]
        from one vertical CTM grid to another.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDV_PORL [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the file containing data to be regridded.
             If INFILENAME is not specified, then REGRIDV_PORL
             will prompt the user to select a file via a dialog box.

        OUTFILENAME -> Name of the file which will contain the regridded 
             data.  If OUTFILENAME is not specified, then REGRIDV_PORL
             will prompt the user to select a file via a dialog box.

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  Default is "GEOS3".

        DIAGN -> Diagnostic category of the data blocks that you 
            wish to regrid.  Default is "PORL-L=$".

        /TROP_ONLY -> Set this switch to only save regridded data
             from the surface to the highest tropopause level
             (e.g. MODELINFO.NTROP as returned from CTM_TYPE).

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        =======================================================
        CTM_GRID          (function)   CTM_TYPE          (function)
        CTM_BOXSIZE       (function)   CTM_REGRID        (function)
        CTM_NAMEXT        (function)   CTM_RESEXT        (function)
        CTM_GET_DATABLOCK (function)   CTM_MAKE_DATAINFO (function)
        REGRID_COLUMN     (function)   CTM_WRITEBPCH              
        CTM_GET_DATA                   GETMODELANDGRIDINFO        
        UNDEFINE   

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        REGRIDV_PORL, INFILENAME='data.geos3.4x5',  $
                      OUTFILENAME="data.geos4.4x5', $
                      OUTMODELNAME='GEOS4'

             ; Regrids data in molec/cm3 from GEOS-3 vertical
             ; resolution to GEOS_4 vertical resolution.

 MODIFICATION HISTORY:
        bmy, 01 Nov 2002: VERSION 1.01
        bmy, 19 Dec 2003: VERSION 1.02
                          - rewritten for GAMAP v2-01
                          - now looks for sfc pressure in ~/IDL/regrid/PSURF/
                          - now supports hybrid grids
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10
                          - Use FILE_WHICH to locate surf prs files
        ccc, 09 Oct 2009: GAMAP VERSION 2.13
                          - fix a keyword check

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridv_porl.pro)


REGRIDV_RESTART

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRIDV_RESTART

 PURPOSE:
        Vertically regrids data in [v/v] mixing ratio from one
        model grid to another.  Data is converted to [kg] for 
        regridding, and then converted back to [v/v].       

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRIDV_RESTART [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        INFILENAME -> Name of the input file containing data to
             be regridded.  If not specified, then REGRIDV_RESTART
             will prompt the user to select a file name with a
             dialog box.

        OUTFILENAME -> Name of the directory where the output file
             will be written.  If OUTFILENAME is not specified, then 
             REGRIDV_RESTART will prmopt the user to specify a file
             name via a dialog box.

        OUTMODELNAME -> Name of the model grid onto which the data
             will be regridded.  If OUTMODELNAME is not specified, 
             REGRIDV_AEROSOL will use the same model name as the
             input grid.

        DIAGN -> Diagnostic category of data block that you want
             to regrid.  Default is "IJ-AVG-$".

        /TROP_ONLY -> If set, will only regrid data within the
             tropopause (i.e. up to the level specified by
             MODELINFO.NTROP).  

        /GCAP -> Set this flag to denote that we are regridding from
             a 4x5 restart file on a GEOS-3 or GEOS-4 grid which has
             previously been regridded to 45 latitudes.

 OUTPUTS:
        None

 SUBROUTINES:
        Internal Subroutines:
        =======================================================
        RVR_GetAirMass (function)      RVR_GetPEdge (function)

        External Subroutines Required:
        ===========================================================
        CTM_GRID          (function)   CTM_TYPE          (function)
        CTM_BOXSIZE       (function)   CTM_REGRID        (function)
        CTM_NAMEXT        (function)   CTM_RESEXT        (function)
        CTM_GET_DATABLOCK (function)   CTM_MAKE_DATAINFO (function)
        REGRID_COLUMN     (function)   GETMODELANDGRIDINFO        
        CTM_WRITEBPCH                  UNDEFINE   

 REQUIREMENTS:
        None

 NOTES:
        None.

 EXAMPLE:
        REGRIDV_RESTART, INFILENAME='data.geos3.4x5', $
                         OUTMODELNAME='geos_strat',   $
                         OUTFILENAME='data.geoss.4x5'

             ; Regrids 4 x 5 GEOS-3 data to the GEOS-STRAT grid.
              
 MODIFICATION HISTORY:
        bmy, 21 Jan 2003: VERSION 1.00
                          - adapted from "regridv_3d_oh.pro
        bmy, 25 Jun 2003: VERSION 1.01
                          - added routine RVR_GetPEdge
                          - now uses ETA coords for GEOS-4 hybrid grid
        bmy, 31 Oct 2003: VERSION 1.02
                          - now call PTR_FREE to free pointer memory
                          - now recognizes GEOS3_30L model name
                          - now recognizes GEOS4_30L model name
        bmy, 19 Dec 2003: VERSION 1.03
                          - now supports hybrid grids
                          - added /TROP_ONLY switch to regrid only
                            as high as the tropopause
                          - now looks for sfc pressure in ~/IDL/regrid/PSURF
                          - removed routine RVR_GetPEdge
                          - modified routine RVR_GetAirMass
        bmy, 17 Feb 2004: VERSION 1.04
                          - bug fix: replaced D with N as loop index
        bmy, 01 Feb 2005  - Now suppress excessive printing to screen
                            with keywords /QUIET and /NOPRINT in
                            call to CTM_GET_DATABLOCK
        bmy, 26 May 2005: VERSION 1.05
                          - added /GCAP keyword for special handling
                            when creating restart files on 4x5 GCAP grid
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10
                          - Use FILE_WHICH to locate surf prs files
        bmy, 04 Nov 2013: GAMAP VERSION 2.17
                          - Now make sure that the GCAP output grid uses
                            the proper vertical edge pressurs.
                          - Also remove all pointer references, use
                            *( DataInfo[D].Data ) directly

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridv_restart.pro)


REGRID_BIOFUEL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRID_BIOFUEL

 PURPOSE:
        Regrids 1 x 1 biomass burning emissions for NOx or CO
        onto a CTM grid of equal or coarser resolution.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRID_BIOFUEL [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        MODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        RESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        /NOX -> If set, will regrid NOx biofuel data.  Default is
             to regrid CO biofuel data.

        OUTDIR -> Name of the directory where the output file will
             be written.  Default is './'.  

 OUTPUTS:
        Writes binary punch files: 
             biofuel.NOx.{MODELNAME}.{RESOLUTION}  (when NOX=1)
             biofuel.CO.{MODELNAME}.{RESOLUTION}   (when NOX=0)

 SUBROUTINES:
        External Subroutines Required:
        ================================================
        CTM_GRID     (function)   CTM_TYPE   (function)
        CTM_BOXSIZE  (function)   CTM_REGRID (function)
        CTM_NAMEXT   (function)   CTM_RESEXT (function)
        CTM_WRITEBPCH

        Internal Subroutines
        ================================================
        RBF_READDATA (function) 

 REQUIREMENTS:
        None

 NOTES:
        The path names for the files containing 1 x 1 data are
        hardwired -- change as necessary!

 EXAMPLE:
        (1)
        REGRID_BIOFUEL, MODELNAME='GEOS_STRAT', RESOLUTION=[5,4]
           
             ; Regrids 1 x 1 CO biofuel data to the 4 x 5 GEOS-STRAT grid

        (2)
        REGRID_BIOFUEL, MODELNAME='GEOS_1', RESOLUTION=2, /NOX
           
             ; Regrids 1 x 1 NOx biofuel data to the 2 x 2.5 GEOS-1 grid

 MODIFICATION HISTORY:
        bmy, 09 Jun 2000: VERSION 1.00
        bmy, 12 Jul 2000: VERSION 1.01 
                          - added NOx keyword
                          - now read original data with 
                            internal function RBF_READDATA
        bmy, 24 Jul 2000: - added OUTDIR keyword
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regrid_biofuel.pro)


REGRID_COLUMN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRID_COLUMN

 PURPOSE:
        Vertically regrids a column quantity in such a way
        as to preserve the total mass.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        DATA2 = REGRID_COLUMN( DATA1, PEDGE1, PEDGE2 [, keywords ] )

 INPUTS:
        DATA1 -> Column vector containing data on the original
             grid.  DATA1 must be a mass-like quantity that does
             not have any vertical dependence (e.g. molecules,
             g, kg, kg/m2, molec/cm2, etc.) 

        PEDGE1 -> Pressures [hPa] at the edges of each layer on 
             the old vertical grid.  PEDGE1 will thus have one 
             more element element than DATA1 (since DATA1 is 
             specified on the midpoints of each layer).

        PEDGE2 -> Pressures [hPa] at the edges of each layer on 
             the new vertical grid.  PEDGE2 will thus have one 
             more element element than DATA2 (since DATA2 is 
             specified on the midpoints of each layer).

 KEYWORD PARAMETERS:
        /DEBUG -> If set, will print debug information to the
             screen, including totals before and after regridding.

        /NO_CHECK -> If this keyword is set, then REGRID_COLUMN
             will not check to see if the column sum was preserved
             in going from the old grid to the new grid.  This is 
             useful if you are regridding data from a grid with a
             high model top to a grid with a lower model top 
             (such as from GEOS-3 to GEOS-1).

 OUTPUTS:
        DATA2 -> Column vector containing data on the new vertical 
             grid.  The column sum of DATA2 will equal that of
             DATA1. DATA2 will also be a mass-like quantity.


 SUBROUTINES:
        None

 REQUIREMENTS:
        None

 NOTES:
        (1) Adapted from FORTRAN code by Amanda Staudt, Bob
        Yantosca, and Dale Allen originally used to interpolate
        GEOS-3 data from Pressure to Sigma coordinates.

        (2) The algorithm is brute force, but it works for all 
        kinds of grids.  It will even work for grids where the new
        vertical resolution is smaller than the original vertical
        resolution.

        (3) Processes one column at a time.  For an entire lat/lon
        region, you have to loop over each surface grid location
        and call REGRID_COLUMN to process each column separately.

        (4) Added /NO_CHECK keyword to facilitate regridding from
        GEOS-3 to GEOS-1.  Otherwise, you should never use this
        keyword.

 EXAMPLE:
 
        ; Surface pressure (assume same for both grids)
        PSurf = 1000.0

        ; Define Input grid -- use GAMAP routines
        InType   = CTM_Type( 'GEOS_STRAT', res=2 )
        InGrid   = CTM_Grid( InType )
        InPEdge  = ( InGrid.SigEdge * ( PSurf - InType.PTOP ) ) + $
                   Intype.PTOP
        
        ; Define Output grid -- use GAMAP routines
        OutType  = CTM_Type( 'GEOS3', res=2, PSurf=1000.0 )
        OutGrid  = CTM_Grid( OutType )
        OutPEdge = ( OutGrid.SigEdge * ( PSurf - OutType.PTOP ) ) +
                    OutType.PTOP

        ; Assume INDATA is in [kg], OUTDATA will be too
        OutData = Regrid_Column( InData, InPEdge, OutPEdge )

             ; Regrid a column of mass from the 2 x 2.5
             ; GEOS-STRAT grid to the 2 x 2.5 GEOS-3 grid

 MODIFICATION HISTORY:
        bmy, 22 Jan 2002: TOOLS VERSION 1.50
        bmy, 14 Mar 2002: - added /NO_CHECK keyword
  bmy & phs, 20 Jun 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/regridding/regrid_column.pro)


REGRID_DUST

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRID_DUST

 PURPOSE:
        Regrids 2.5 x 2.5 mineral dust concentrations 
        onto a CTM grid of equal or coarser resolution.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRID_DUST [, Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        MONTH -> Month of year for which to process data.
             Default is 1 (January).

        MODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        RESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        OUTDIR -> Name of the directory where the output file will
             be written.  Default is './'.  

 OUTPUTS:
        Writes binary punch file:
             dust.{MODELNAME}.{RESOLUTION}

 SUBROUTINES:
        External Subroutines Required:
        =================================================
        CTM_GRID      (function)   CTM_TYPE   (function)
        CTM_BOXSIZE   (function)   CTM_REGRID (function)
        CTM_NAMEXT    (function)   CTM_RESEXT (function)
        CTM_WRITEBPCH  

 REQUIREMENTS:
        References routines from the GAMAP and TOOLS packages.

 NOTES:
        (1) The path names for the files containing dust data are
            hardwired -- change as necessary!

        (2) Even though photolysis rates are only needed in the 
            troposphere, we need to save the mineral dust for all
            levels of the model.  Scattering by mineral dust is
            used to compute the actinic flux, and therefore we need
            to account for this all the way to the atmosphere top.

        (3) The regridding process can take a very long time to
            complete.  If you are regridding, it is recommended to
            process one month at a time, and then to concatenate
            the binary punch files using GAMAP.

 EXAMPLE:
        REGRID_DUST, MODELNAME='GEOS_STRAT', RESOLUTION=4
           
             ; Regrids dust data from 2 x 2.5 native resolution
             ; to 4 x 5 resolution for the GEOS-STRAT grid

 MODIFICATION HISTORY:
        bmy, 09 Jun 2000: VERSION 1.00
        rvm, 18 Jun 2000: VERSION 1.01
        bmy, 07 Jul 2000: VERSION 1.10
                          - added OUTDIR keyword
                          - save regridded data one month at a time
                            since regridding takes so long 
        bmy, 02 Apr 2008: GAMAP VERSION 2.12
                          - Now read input files as big-endian
                

(See /n/home09/ryantosca/IDL/gamap2/regridding/regridh_dust_raw.pro)


REGRID_TOMS_SBUV

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REGRID_TOMS_SBUV

 PURPOSE:
        Regrids 5 x 10 O3 column data from both 
        TOMS and SBUV instruments onto a CTM grid.

 CATEGORY:
        Regridding

 CALLING SEQUENCE:
        REGRID_TOMS_SBUV [ , Keywords ]

 INPUTS:
        None

 KEYWORD PARAMETERS:
        OUTMODELNAME -> A string containing the name of the model 
             grid onto which the data will be regridded.

        OUTRESOLUTION -> Specifies the resolution of the model grid
             onto which the data will be regridded.  RESOLUTION
             can be either a 2 element vector with [ DI, DJ ] or
             a scalar (DJxDI: 8=8x10, 4=4x5, 2=2x2.5, 1=1x1, 
             0.5=0.5x0.5).  Default for all models is 4x5.

        OUTDIR -> Name of the directory where the output file will
             be written.  Default is './'.  ;
 OUTPUTS:
        Writes regridded O3 columns to file.

 SUBROUTINES:
        

 REQUIREMENTS:
        References routines from both GAMAP and TOOLS packages.

 NOTES:
        (1) Input filename is hardwired -- change as necessary

 EXAMPLE:
        REGRID_TOMS_SBUV, OUTMODELNAME='GEOS1', $
                          OUTRESOLUTION=4,      $
                          OUTDIR='/scratch/'
 
             ; Regrids O3 column data to GEOS-1 4 x 5 grid,
             ; writes output file to /scratch directory

 MODIFICATION HISTORY:
        bmy, 16 Mar 2001: VERSION 1.00
        bmy, 29 Mar 2001: VERSION 1.01
                          - renamed to REGRID_TOMS_SBUV
                          - renamed keyword MODELNAME to OUTMODELNAME
                          - renamed keyword RESOLUTION to OUTRESOLUTION
                          - now use routine INTERPOLATE_2D

(See /n/home09/ryantosca/IDL/gamap2/regridding/regrid_toms_sbuv.pro)


REPLACE_TOKEN (FUNCTION)

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REPLACE_TOKEN (function)

 PURPOSE:
        Replaces occurrences of tokens with text. Can also
        be used to expand wildcards with a name list.

 CATEGORY:
        Strings

 CALLING SEQUENCE:
        RESULT = REPLACE_TOKEN( STR, TOKEN, TEXT, [, Keywords ] )

 INPUTS:
        STR -> The string to be searched for tokens. This must be
             a scalar string.
 
        TOKEN -> A string or string array containing the token text
             *OR* a structure. If TOKEN is a structure, the tag
             names will be used as Tokens and the tag values will
             be converted to string and used as TEXT.  TOKEN is 
             case-insensitive and will always be used as uppercase.

        TEXT -> A string or string array containing the replacement 
             text. TEXT may be some other type than string on input. 
             In this case it will be returned as string and formatted 
             according to the optional FORMAT keyword.  If TOKEN is 
             provided as a structure, TEXT will return the (formatted)
             tag values as strings.  TOKEN and TEXT must have the same 
             number of elements with one exception: If TOKEN contains 
             only one element while TEXT is an array, the result will 
             be a string array where each string has TOKEN replaced 
             with the corresponding TEXT value (wildcard replacement). 
             [see example 7]

 KEYWORD PARAMETERS:
        DELIMITER  -> The delimiter character for TOKEN.  Default is 
             '%'.  The delimiter will be automatically appended to the
             beginning and end of TOKEN if not already there.

        COUNT -> Number of tokens that were replaced. If TOKEN has 
             more than one element or tag, COUNT will be an integer 
             array.

        VERBOSE -> Will print a warning message if no tokens are found.

        FORMAT -> A string or string array containing format 
            specifications for each element of TEXT or each tag of 
            the TOKEN structure. If FORMAT contains only one element, 
            this will be used throughout. For wildcard replacement, 
            the default format is I14 (number will be trimmed).

        TFORMAT -> (type format) If TOKEN is provided as a structure, 
            it may contain data of various types. You can use TFORMAT 
            to specify a format code for each data type (see IDL SIZE
            function) instead of each tag number as with the FORMAT 
            keyword. TFORMAT should contain at least 6 elements to 
            allow formatting of double precision data, or 8 elements 
            if you want to output complex data.

 OUTPUTS:
        RESULT -> String with replaced text.  If TOKEN is a single 
            string and TEXT is an array, then the result is an array 
            with N(text) elements.  In case of errors, an empty string
             is returned.

 SUBROUTINES:
        External Subroutines Used:
        ========================================
        CHKSTRU (function)   STRRIGHT (function)
 
 REQUIREMENTS:
        None

 NOTES:
        (1) The original input string (STR) is not altered.

        (2) REPLACE_TOKEN will search for and replace multiple
            occurrences of the same token in the input string (STR).

        (3) Use DELIM='' for wildcard replacement.

        (4) If no tokens are found in the input string, then
            REPLACE_TOKEN returns the original input string (STR)
            as the value of the function.  

        (5) The use of structures for TOKEN allows for different
            data types.

 EXAMPLE:
        (1)
        STR     = 'Hello, My Name is %NAME% and %NAME%.'
        NEWSTR  = REPLACE_TOKEN( Str, 'NAME', 'Robert' )
        PRINT, NEWSTR
           Hello, my name is Robert and Robert.

             ; Replace multiple tokens in the input string

        (2) 
        STR   = 'His name is %NAME% and he lives in %STREET%, %CITY%'
        TOKEN = { NAME   : 'Henry', $
                  STREET : '29 Oxford St.', $
                  CITY   : 'Cambridge, MA',   $
                  ZIP    : '02138' }
        PRINT, REPLACE_TOKEN( STR, TOKEN )
           His name is Henry and he lives in 
           29 Oxford St., Cambridge, MA
           
           ; Use a structure to replace several items at once
           ; (Note: ZIP code is not used!)

        (3) 
        STR = 'His name is NAME and he lives in STREET, CITY'
        PRINT, REPLACE_TOKEN( STR, TOKEN, DELIM='' )
           His Henry is Henry and he lives in ...

             ; Use of an empty delimiter (same TOKEN as above)
             ; (Exercise: what went wrong ?)

        (4) 
        STR = 'The date is 2003/01/01.'
        PRINT, REPLACE_TOKEN( STR, '2003', 2005', DELIM='' )
           The date is 2005/01/01.

             ; Another use of an empty delimiter
             ; (very useful for switching dates/times!!!)

        (5) 
        STR    = 'She earns %Salary%.'
        FORMAT = '("$",g0.10)'
        PRINT, REPLACE_TOKEN( STR, 'Salary', 39000., FORMAT=FORMAT )
           She earns $39000.

             ; Use of FORMAT

        (6) 
        STR     = '%Name% earns %Salary%.'
        VAL     = { NAME   : 'Sally', $
                    SALARY : 39000. }
        TFORMAT = [ '(A)','','','','("$",g0.10)','("$",g0.10)' ]
             ; (format codes for string, float and double)

        PRINT, REPLACE_TOKEN( STR, VAL, TFORMAT=TFORMAT )
           Sally earns $39000.

             ; Use of TFORMAT

        (7) 
        FILEMASK = '~/data/cruise$$.dat'
        CRUISES  = indgen(10)+1   
        PRINT, REPLACE_TOKEN( FILEMASK, '$$', $
                              CRUISES, DELIM='', FORMAT='(I2.2)' )
           ~/data/cruise01.dat 
           ~/data/cruise02.dat ...
           ~/data/cruise10.dat

             ; Wildcard replacement

 MODIFICATION HISTORY:
        bmy, 23 Sep 1998: VERSION 1.00
        bmy, 24 Sep 1998: - added VERBOSE keyword and improved comments
        mgs, 24 Sep 1998: - improved error handling
                          - TOKEN and TEXT may now be arrays
                          - *or* TOKEN may be a structure
                          - TEXT is trimmed
                          - added FORMAT and TFORMAT keywords
        mgs, 23 Dec 1998: - added wildcard (isarray) functionality
  bmy & phs, 13 Jul 2007: GAMAP VERSION 2.10
                          - updated comments

(See /n/home09/ryantosca/IDL/gamap2/strings/replace_token.pro)


RESOLVE_EVERY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	RESOLVE_EVERY


 PURPOSE:
	Resolve (by compiling) all procedures and functions.
	This is useful when preparing .sav files containing all the IDL
	routines required for an application.

 CATEGORY:
       General

 CALLING SEQUENCE:
	RESOLVE_EVERY

 INPUTS:
	None.

 KEYWORD PARAMETERS:
	QUIET = if set, produce no messages.
 	SKIP_ROUTINES = an optional string array containing the names
 	    of routines to NOT resolve.  This is useful when a library
 	    file containing the designated routines will be later included.

 OUTPUTS:
	No explicit outputs.

 COMMON BLOCKS:
	None.

 SIDE EFFECTS:
       None

 RESTRICTIONS:
	Will not resolve procedures or functions that are called via
	CALL_PROCEDURE, CALL_FUNCTION, or EXECUTE.  Only explicit calls
	are resolved.

	If an unresolved procedure or function is not in the IDL 
	search path, an error occurs, and no additional routines
	are resolved.

 PROCEDURE:
	This routine iteratively determines the names of unresolved calls
	to user-written or library procedures and functions, and then
	compiles them.  The process stops when there are no unresolved
	routines.

 EXAMPLE:
	RESOLVE_EVERY.

 MODIFICATION HISTORY:
 	Written by:
	DMS, RSI, January, 1995.
	DMS, RSI, April, 1997, Added SKIP_ROUTINES keyword.
       mgs, Harvard, 21 Apr 1998: use findfile before trying to resolve
                                  a routine
       bmy, 28 May 2004: TOOLS VERSION 2.02 
                          - Now use MFINDFILE which will call FILE_SEARCH
                            for IDL 5.5+ or FINDFILE for IDL 5.4-
  bmy & phs, 13 Jul 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/general/resolve_every.pro)


REVISIONS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        REVISIONS

 PURPOSE:
        Extract information about file modifications and create
        REVISIONS file for all files w/in a directory.

 CATEGORY:
        Documentation

 CALLING SEQUENCE:
        REVISIONS, DIRNAME

 INPUTS:
        DIRNAME -> directory name to be searched for *.pro files

 KEYWORD PARAMETERS:
        None

 OUTPUTS:
        None

 SUBROUTINES:
        External Subroutines Required:
        =================================================
        ADD_SEPARATOR (function)   MFINDFILE
        STRDATE       (function)   STRRIGHT  (function)

 REQUIREMENTS:
        The program files must have a standard header with tag
        "MODIFICATION HISTORY" as last item. This must be followed
        with a ;- line (!! NOT ;----- !!).

        The REVISIONS file will be written in the directory DIRNAME,
        thus the user must have write permission.

 NOTES:
        (1) All *.pro file in the given directory will be analyzed.
        (2) Also see IDL routine ADD_TEMPLATE

 EXAMPLE:
        REVISIONS, '~/IDL/gamap2/doc/'

             ; Will produce a REVISIONS file for all of the
             ; *.pro files w/in the '~/IDL/gamap2/doc' directory

 MODIFICATION HISTORY:
        mgs, 16 Jun 1998: VERSION 1.00
        mgs, 25 May 1999: - added caution for tag detection in this
                            routine itself.
        bmy, 24 Oct 2003: TOOLS VERSION 1.53
                          - Bug fix: EXPAND_PATH strips the directory
                            separator string from the end of DIRNAME
                            in IDL 6.0+.  Add this back manually.
                          - use MFINDFILE instead of FINDFILE to fix
                            file listing bug in IDL 5.2-
  bmy & phs, 13 Jul 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/doc/revisions.pro)


REWRITE_AGPROD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	 REWRITE_AGPROD


 PURPOSE:
        To rewrite a APROD / GPROD restart file with a different
        timestamp TAU0. The correspondence b/w file name and timestamp
        is enforced, as required by GEOS-Chem.

 CATEGORY:
	 Date & Time


 CALLING SEQUENCE:
	 REWRITE_AGPROD, INFILE='old_file_name', TAU0=tau | YMD=yyyymmdd

 INPUTS:
	 None

 KEYWORD PARAMETERS:

        INFILENAME -> initial restart_aprod_gprod file. If not
             passed, a dialog window will pop up.

        TAU0 (double) -> the new time stamp you want, in Tau units

        YMD (long) -> the new time stamp you want, in YYMMDD or YYYYMMDD

        HH -> hour for this date (e.g. 6 for 6 a.m.)  Default is 0.

        Either TAU0 or YMD should be passed. If both are passed,
        TAU0 is used.

 OUTPUTS:
 	 None.

 SIDE EFFECTS:
	 A file named restart_aprod_gprod.YYYYMMDDHH where YYYYMMDDHH
        corresponds with TAU0 in the data blocks is created.

 RESTRICTIONS:
	 The input file must be a restart_aprod_gprod file.

 NOTES:
        This is not a regridding routine. To regrid a
        restart_aprod_gprod file, use :

           REGRIDV_RESTART, ..., DIAGN=0

        or/and

           REGRIDH_RESTART, ..., DIAGN=0

 EXAMPLE:
        REWRITE_AGPROD, YMD=20010701

 MODIFICATION HISTORY:
	 phs,    Jul 2007: version 0.1
        phs, 04 Apr 2007: GAMAP VERSION 2.12
                          - commemts
                          - clean non_global pointers
                          - added YMD and HH keywords
        ccc, 09 Aug 2010: GAMAP VERSION 2.14
                          - add automatic definition of outfilename

(See /n/home09/ryantosca/IDL/gamap2/date_time/rewrite_agprod.pro)


RH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        RH     

 PURPOSE:
        Calculates relative humidity from temperature and
        dew/frostpoint

 CATEGORY:
        Atmospheric Sciences

 CALLING SEQUENCE:
        RESULT = RH( DEWPOINT, TEMPERATURE [,/WATER] [,/ICE] )

 INPUTS:
        DEWPOINT --> dewpoint (or frostpoint) temperature [K]

        TEMPERATURE --> dry (or static) air temperature [K]

 KEYWORD PARAMETERS:
        /WATER --> always calculate dewpoint temperature

        /ICE --> always calculate frostpoint temperature

 OUTPUTS:
        RESULT -> Relative humidity [%]

 SUBROUTINES:
        External Subroutines Required:
        ===============================
        E_H2O (function)

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        PRINT, RH( 266., 278. )
          41.4736

             ; Prints the RH for dewpoint=266K and temp=278K.

 MODIFICATION HISTORY:
        mgs, 23 Feb 1997: VERSION 1.00
        mgs, 03 Aug 1997: split e_h2o and rh, renamed, added template
  bmy & phs, 13 Jul 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/atm_sci/rh.pro)


ROUTINE_NAME (FUNCTION)

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        ROUTINE_NAME  (function)

 PURPOSE:
        return the name of the routine which calls this function.

 CATEGORY
        File & I/O

 CALLING SEQUENCE:
        rname = ROUTINE_NAME()

 INPUTS:
        none

 KEYWORD PARAMETERS:
        FILENAME -> returns the file in which the routine can be found

        /CALLER -> returns information about the caller of the routine
           instead of the routine itself

 OUTPUTS:
        The name of the caller routine is returned in lowercase
        characters (can be used to construct a filename by adding
        ".pro")

 SUBROUTINES:
        None

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        From the command line:
             PRINT, ROUTINE_NAME()
        results in   $main$

        Very useful in conjunction with USAGE.PRO:
             USAGE, ROUTINE_NAME()
        displays help information on the current routine.

 MODIFICATION HISTORY:
        mgs, 27 Mar 1998: VERSION 1.00
        mgs, 22 Apr 1998: - added FILENAME and CALLER keywords
        mgs, 14 Jan 1998: - needed fix for filename when working on PC:
                            $MAIN$ allows no str_sep
        bmy, 07 Aug 2002: TOOLS VERSION 1.51
                          - Now use routine STRBREAK to split the line
                            instead of STR_SEP.  STR_SEP has been removed
                            from the IDL distribution in IDL 5.4+.
  bmy & phs, 13 Jul 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/file_io/routine_name.pro)


RSEARCH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
        RSEARCH

 PURPOSE:
        Wrapper for routines STRPOS and RSTRPOS.  
        Needed for backwards compatibility for GAMAP users 
        who are running versions of IDL prior to 5.2.

 CATEGORY:
        Strings

 CALLING SEQUENCE:
        RESULT = RSEARCH( STR, PATTERN )

 INPUTS:
        STR -> The string to be searched.  

        PATTERN -> The pattern to search for in STR.

 KEYWORD PARAMETERS:
        None
           
 OUTPUTS:
        RESULT -> Character index where PATTERN is found in STR

 SUBROUTINES:
        None

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        STR = "This is a test: Hello!"
        PRINT, RSEARCH( STR, 'test:' )
          10
             ; Location where PATTERN is found in STR

 MODIFICATION HISTORY:
        bmy, 17 Jan 2002: TOOLS VERSION 1.50
        bmy, 14 Apr 2005: TOOLS VERSION 2.04
                          - Now uses CALL_FUNCTION to call STRPOS
                            and RSTRPOS so as to avoid bugs at
                            compile-time 
  bmy & phs, 13 Jul 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/strings/rsearch.pro)


RUN_AV (FUNCTION)

[Previous Routine] [List of Routines]
 NAME:
        RUN_AV (function)

 PURPOSE:
        Compute running average or running total of a
        data vector. Compared to the IDL function TS_SMOOTH,
        this function takes into account missing values or
        gaps in an optional x vector, and it allows for 
        even bandwidths. It can also be used to compute cumulative
        totals.

 CATEGORY:
        Math & Units

 CALLING SEQUENCE:
        result = RUN_AV(Y [,X] [,keywords] )

 INPUTS:
        Y -> the data vector (a 2-D array will be treated as a vector)

        X -> an optional X vector defining e.g. the sample times.
             This only has an effect when the DELTAX keyword is specified.
             X must be monotonically increasing and have the same 
             number of elements as Y.

 KEYWORD PARAMETERS:
        WIDTH -> The number of points to use for the average or total
             Default is 1, i.e. Y is returned unchanged.

        MINWIDTH -> The minimum number of points that must be valid 
             in order to return a average or total for the given point.
             Default is MINWIDTH=WIDTH, i.e. all points must be valid
             (and if X and DELTAX are specified, all points must lie
             within WIDTH*DELTAX). 

        MIN_VALID -> The minimum value for valid data. Data with less than
             MIN_VALID will be considered missing. MIN_VALID is also used
             to indicate invalid totals or averages (1% is subtracted).

        DELTAX -> The maximum gap between two consecutive x values.
             Only effective when X is given.

        COUNT -> A named variable will return the number of points used 
             in each average or total.

        /TOTAL -> Set this keyword to compute running totals instead 
             of running averages.

 OUTPUTS:
        The function returns a vector with running averages or totals.
        The number of elements in the result vector always equals the 
        number of elements in Y (unless an error occurs). 

 SUBROUTINES:

 REQUIREMENTS:

 NOTES:
        This function can also be used to compute accumulative totals.
        Simply set WIDTH to n_elements(Y) and MINWIDTH to 1 and use
        the /TOTAL keyword. However, this is very uneffective for large 
        data vectors!

 EXAMPLE:
        y = findgen(20)
        print,run_av(y,width=4)
        ; IDL prints: -1E31 -1E31 -1E31  1.5  2.5  3.5  4.5 ...

        print,run_av(y,width=4,/TOTAL)
        ; IDL prints: -1E31 -1E31 -1E31  6  10  14  18 ...

        ; (cumulative total)
        print,run_av(y,width=n_elements(y),minwidth=1,/TOTAL)
        ; IDL prints:  0  1  3  ...  190

        x = [ 0, 2, 4, 6, 16, 20, 24, 25, 26, 27, 28, 29, 30, 32, 33 ]
        y = fltarr(n_elements(x)) + 1.
        print,run_av(y,x,width=4,count=c)
        ; IDL prints: -1E31  -1E31  -1E31  1  1  1  1  ...
        print,c
        ; IDL prints:  1  2  3  4  4  4  4  4  4  4  4  4  4  4  4

        print,run_av(y,x,deltax=2,width=4,count=c)
        ; IDL prints: -1E31  -1E31  -1E31  1  -1E31  -1E31  -1E31
        ;             -1E31  -1E31  -1E31  1   1   1   1   1
        print,c
        ; IDL prints:  1  2  3  4  3  2  1  1  2  3  4  4  4  4  4

 MODIFICATION HISTORY:
        mgs, 21 Oct 1998: VERSION 1.00
        mgs, 07 Jun 1999: - changed loop variable to LONG type.
  bmy & phs, 13 Jul 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/math_units/run_av.pro)