/**********************************************************************
 * TDRP params for Grib2toMdv
 **********************************************************************/

//======================================================================
//
// Grib2toMdv PARAMETER FILE.
//
// Grib2toMdv creates MDV from grib2 data files.
//
//======================================================================
 
//======================================================================
//
// PROGRAM MODES OF OPERATION.
//
//======================================================================
 
///////////// debug ///////////////////////////////////
//
// Debug option.
//
// 0 = No Debug info
// 1 = Regular Debug info
// 2 = Full Grib2 file output (see printSec params).
//
//
// Type: int
//

debug = 0;

///////////// instance ////////////////////////////////
//
// Instance.
//
// Process instance for registration with process mapper.
//
//
// Type: string
//

instance = "gfs_0.25a";

///////////// procmap_register_interval_secs //////////
//
// Interval for procmap registration.
//
// Set to a high value if processing takes a long time. This will 
//   prevent the auto_restarter from killing and restarting the app.
//
//
// Type: int
//

procmap_register_interval_secs = 120;

///////////// input_dir ///////////////////////////////
//
// Input directory.
//
// Directory which contains input grib2 files. Used only if files are 
//   not specified on the command line.
//
//
// Type: string
//

input_dir = "";

///////////// input_suffix ////////////////////////////
//
// Input file suffix.
//
// Input file suffixes will be checked against this string. Used only if 
//   files are not specified on the command line.
//
//
// Type: string
//

input_suffix = "grb2";

///////////// input_substring /////////////////////////
//
// Input file substring check.
//
// Input files will be checked against this string.Can be used to filter 
//   different forecast times.Used only if files are not specified on the 
//   command line.
//
//
// Type: string
//

input_substring = "";

///////////// input_substrings ////////////////////////
//
// Input file substrings check.
//
// Input files will be checked against these strings. Can be used to 
//   filter different forecast times. Used only if files are not specified 
//   on the command line and input_substring is set to an empty string.
//
//
// Type: string
// 1D array - variable length.
//

input_substrings = {
 "f0000",
 "f0003",
 "f0006",
 "f0009",
 "f0012"
};

///////////// max_input_data_age //////////////////////
//
// Max age (in seconds) of input data.
//
// Used only if files are not specified on the command line.
//
// Minimum val: 60
//
// Type: int
//

max_input_data_age = 21600;

///////////// latest_data_info_avail //////////////////
//
// If TRUE, watch input_dir for change in _latest_data_info.
//
// If FALSE, watch input_dir for new files.
//
//
// Type: boolean
//

latest_data_info_avail = FALSE;

///////////// recursive_search ////////////////////////
//
// Option to recurse when searching for new files.
//
// Only applies if latest_data_info_avail is FALSE.
//
//
// Type: boolean
//

recursive_search = TRUE;

///////////// latest_file_only ////////////////////////
//
// Option to only process the latest file in directory.
//
// If TRUE, only the latest file will be processed. If FALSE, 
//   previously-written files will be processed.
//
//
// Type: boolean
//

latest_file_only = TRUE;

///////////// data_check_interval_secs ////////////////
//
// How often to check for new data (secs).
//
//
// Type: int
//

data_check_interval_secs = 60;

//======================================================================
//
// PRINT SECTIONS PARAMETERS.
//
// Parameters only used with -printSec or debug > 1
// For each grib message prints the sections defined below.
//
//======================================================================
 
///////////// printSec_is /////////////////////////////
//
// If TRUE prints the Indicator Section.
//
// Only prints with -printSec or debug > 1.
//
//
// Type: boolean
//

printSec_is = FALSE;

///////////// printSec_ids ////////////////////////////
//
// If TRUE prints the Identification Section.
//
// Only prints with -printSec or debug > 1.
//
//
// Type: boolean
//

printSec_ids = TRUE;

///////////// printSec_lus ////////////////////////////
//
// If TRUE prints the Local Use Section (if present).
//
// Only prints with -printSec or debug > 1.
//
//
// Type: boolean
//

printSec_lus = FALSE;

///////////// printSec_gds ////////////////////////////
//
// If TRUE prints the Grid Definition Section.
//
// Only prints with -printSec or debug > 1.
//
//
// Type: boolean
//

printSec_gds = TRUE;

///////////// printSec_pds ////////////////////////////
//
// If TRUE prints the Product Definition Section.
//
// Only prints with -printSec or debug > 1.
//
//
// Type: boolean
//

printSec_pds = TRUE;

///////////// printSec_drs ////////////////////////////
//
// If TRUE prints the Data Representation Section.
//
// Only prints with -printSec or debug > 1.
//
//
// Type: boolean
//

printSec_drs = FALSE;

///////////// printSec_bms ////////////////////////////
//
// If TRUE prints the Bit-map Section.
//
// Only prints with -printSec or debug > 1.
//
//
// Type: boolean
//

printSec_bms = FALSE;

///////////// printSec_ds /////////////////////////////
//
// If TRUE prints the Data Section.
//
// Only prints with -printSec or debug > 1.
//
//
// Type: boolean
//

printSec_ds = FALSE;

//======================================================================
//
// MDV OUTPUT PARAMETERS.
//
//======================================================================
 
///////////// autoset_missing_value ///////////////////
//
// This option will infer the missing value from the data if possible.
//
// Grib2 doesnt allow for setting a missing value unless complex data 
//   packing used. .
//
//
// Type: boolean
//

autoset_missing_value = TRUE;

///////////// check_lead_time /////////////////////////
//
// Option to limit the lead time of output files.
//
// If set, we check the lead time before writing files.
//
//
// Type: boolean
//

check_lead_time = FALSE;

///////////// max_lead_time_secs //////////////////////
//
// Maximum lead time for output files (secs).
//
// See 'check_lead_time'.
//
//
// Type: int
//

max_lead_time_secs = 43200;

///////////// lead_time_subsampling ///////////////////
//
// Lead time subsampling flag.
//
// Set to true to enable lead time subsampling.
//
//
// Type: boolean
//

lead_time_subsampling = FALSE;

///////////// subsample_lead_times ////////////////////
//
// The subsampled lead times to process.
//
//
// Type: int
// 1D array - variable length.
//

subsample_lead_times = {
};

///////////// write_forecast //////////////////////////
//
// Write mdv files in a forecast directory structure.
//
// If this is true, mdv files will be written in the rap forecast 
//   directory structure.  Note that if write_non_forecast is also set to 
//   true, two mdv files will be written.
//
//
// Type: boolean
//

write_forecast = TRUE;

///////////// forecast_mdv_url ////////////////////////
//
// Url for mdv files in forecast structure.
//
//
// Type: string
//

forecast_mdv_url = "mdvp:://localhost::$(GFS_0.25A)";

///////////// write_non_forecast //////////////////////
//
// Write mdv files in a non-forecast directory structure.
//
// If this is true, mdv files will be written in the regular 
//   (non-forecast) rap directory structure.  Note that if write_forecast 
//   is also set to true, two mdv files will be written.  Note also that 
//   this option allows for overwriting files, since the forecast time 
//   will be used as the data time in this case.  This is a temporary 
//   option to allow for easier display of the data.
//
//
// Type: boolean
//

write_non_forecast = FALSE;

///////////// non_forecast_mdv_url ////////////////////
//
// Url for mdv files in non-forecast structure.
//
//
// Type: string
//

non_forecast_mdv_url = "mdvp:://localhost::./mdv";

///////////// non_forecast_timestamp //////////////////
//
// This parameter allows user to timestamp non-forecast mdv files based 
//   on the model's run time or the forecast time.
//
// The choices are TIMESTAMP_GEN_TIME and TIMESTAMP_FCAST_TIME.
//
//
// Type: enum
// Options:
//     TIMESTAMP_GEN_TIME
//     TIMESTAMP_FCAST_TIME
//

non_forecast_timestamp = TIMESTAMP_FCAST_TIME;

///////////// data_is_non_forecast ////////////////////
//
// Write mdv files as regular data files.
//
// If this is true, the output mdv files are assumed to be non-forecast 
//   data.  If this flag is set true, the write_non_forecast flag must 
//   also be set true and the non_forecast_mdv_url must be set.  If this 
//   flag is set false, and write_non_forecast_mdv_url is true, the output 
//   is assumed to be forecast data, but written into a regular 
//   (non-forecast) rap directory structure anyway.
//
//
// Type: boolean
//

data_is_non_forecast = FALSE;

///////////// writeLdataInfo //////////////////////////
//
// Write _latest_data_info files for output data.
//
// If false, will suppress writing of _latest_data_info files.
//
//
// Type: boolean
//

writeLdataInfo = TRUE;

///////////// data_set_info ///////////////////////////
//
// Data set info.
//
// This is placed in the MDV master header for documentation purposes.
//
//
// Type: string
//

data_set_info = "Converted to MDV with Grib2toMdv.";

///////////// data_set_name ///////////////////////////
//
// Data set name.
//
// This is placed in the MDV master header for documentation purposes.
//
//
// Type: string
//

data_set_name = "GFS 0.25deg model output.";

///////////// data_set_source /////////////////////////
//
// Data set source details.
//
// This is placed in the MDV master header for documentation purposes.
//
//
// Type: string
//

data_set_source = "Grib2.";

///////////// process_everything //////////////////////
//
// Flag to process all fields.
//
// If TRUE, all fields will be processed.
// If FALSE, only fields listed in output_fields list will be processed.
//
//
// Type: boolean
//

process_everything = FALSE;

///////////// output_fields ///////////////////////////
//
// List of output fields, which are descibed by the field parameter and 
//   vertical level type.
//
// To determine the available params and levels, use the command line 
//   argument -printSummary -file [filename]
//   No Mdv output will be created, only a list of params and associated 
//   levels contained in the GRIB file.
// Note: process_everything must be set to FALSE to use this list.
//                                  
// out_field_t structure definition:
//   param:string GRIB2 product ID.
//   level:string GRIB2 level ID.
//   mdv_name:string MDV short field name. Overrides default name.
//                   Use empty string to keep default (param) name.
//   out_units:out_units_t simple unit conversion utility. Options are:
//     NO_CHANGE            -- no change to units
//     MPS_TO_KNOTS         -- convert m/s to knots
//     M_TO_KM              -- convert meters to kilometers
//     M_TO_FT              -- convert meters to feet, 
//     M_TO_MI              -- convert meters to miles, 
//     M_TO_100FT           -- convert meters to 100's of feet, 
//                             flight levels
//     PASCALS_TO_MBAR      -- convert pascals to millibars
//     KELVIN_TO_CELCIUS    -- convert degrees kelvin to to degrees
//                             celcius
//     KGPKG_TO_GPKG        -- convert kilogram per kilogram to gram
//                             per kilogram
//     PERCENT_TO_FRACTION  -- convert percentage to fraction, values
//                             between 0 and 1
//     FRACTION_TO_PERCENT  -- convert fraction to percentage, values
//                             between 0 and 100
//                                            
//    upper_range_limit:double upper limit threshold for field.
//    lower_range_limit:double lower limit threshold for field. 
//                             When both upper and lower limits are set
//                             to zero no thresholds are applied.
//   encoding_type:encoding_type_t  Output variable encoding type
//   qc_default_type:qc_default_t Replacement value for inputs outside
//                                of the range_limit
//   qc_default_value:double User defined replacement value.
//   vert_level_min: minimum integer level that will be processed(If set 
//   to -1,
//                   no restrictions will be set.)
//   vert_level_max: maximum integer level that will be processed(If set 
//   to -1,
//                   no restrictions will be set.)
//   vert_level_dz:  integer change in vertical levels that will be 
//   processed.
//
// Default behavior is to process everything with no changes.
//
//
// Type: struct
//   typedef struct {
//      string param;
//      string level;
//      string mdv_name;
//      out_units_t units;
//        Options:
//          NO_CHANGE
//          MPS_TO_KNOTS
//          M_TO_KM
//          M_TO_100FT
//          PASCALS_TO_MBAR
//          KELVIN_TO_CELCIUS
//          KGPKG_TO_GPKG
//          PERCENT_TO_FRACTION
//          FRACTION_TO_PERCENT
//          M_TO_FT
//          M_TO_MI
//          M_TO_KFT
//          MM_S_TO_MM_HR
//      double upper_range_limit;
//      double lower_range_limit;
//      encoding_type_t encoding_type;
//        Options:
//          ENCODING_ASIS
//          ENCODING_INT8
//          ENCODING_INT16
//          ENCODING_FLOAT32
//      qc_default_t qc_default_type;
//        Options:
//          BAD_VALUE
//          UNKNOWN_VALUE
//          USER_DEFINED
//      double qc_default_value;
//      int vert_level_min;
//      int vert_level_max;
//      int vert_level_dz;
//      boolean use_additional_bad_data_value;
//      double additional_bad_data_value;
//      boolean use_additional_missing_data_value;
//      double additional_missing_data_value;
//   }
//
// 1D array - variable length.
//

output_fields = {
  {
    param = "TMP",
    level = "ISBL",
    mdv_name = "",
    units = NO_CHANGE,
    upper_range_limit = 0,
    lower_range_limit = 0,
    encoding_type = ENCODING_FLOAT32,
    qc_default_type = BAD_VALUE,
    qc_default_value = 0,
    vert_level_min = -1,
    vert_level_max = -1,
    vert_level_dz = 1,
    use_additional_bad_data_value = FALSE,
    additional_bad_data_value = 0,
    use_additional_missing_data_value = FALSE,
    additional_missing_data_value = 0
  }
  ,
  {
    param = "TMP",
    level = "TRO",
    mdv_name = "",
    units = NO_CHANGE,
    upper_range_limit = 0,
    lower_range_limit = 0,
    encoding_type = ENCODING_FLOAT32,
    qc_default_type = BAD_VALUE,
    qc_default_value = 0,
    vert_level_min = -1,
    vert_level_max = -1,
    vert_level_dz = 1,
    use_additional_bad_data_value = FALSE,
    additional_bad_data_value = 0,
    use_additional_missing_data_value = FALSE,
    additional_missing_data_value = 0
  }
  ,
  {
    param = "TMP",
    level = "SFC",
    mdv_name = "",
    units = NO_CHANGE,
    upper_range_limit = 0,
    lower_range_limit = 0,
    encoding_type = ENCODING_FLOAT32,
    qc_default_type = BAD_VALUE,
    qc_default_value = 0,
    vert_level_min = -1,
    vert_level_max = -1,
    vert_level_dz = 1,
    use_additional_bad_data_value = FALSE,
    additional_bad_data_value = 0,
    use_additional_missing_data_value = FALSE,
    additional_missing_data_value = 0
  }
  ,
  {
    param = "HGT",
    level = "ISBL",
    mdv_name = "",
    units = NO_CHANGE,
    upper_range_limit = 0,
    lower_range_limit = 0,
    encoding_type = ENCODING_FLOAT32,
    qc_default_type = BAD_VALUE,
    qc_default_value = 0,
    vert_level_min = -1,
    vert_level_max = -1,
    vert_level_dz = 1,
    use_additional_bad_data_value = FALSE,
    additional_bad_data_value = 0,
    use_additional_missing_data_value = FALSE,
    additional_missing_data_value = 0
  }
  ,
  {
    param = "HGT",
    level = "TRO",
    mdv_name = "",
    units = NO_CHANGE,
    upper_range_limit = 0,
    lower_range_limit = 0,
    encoding_type = ENCODING_FLOAT32,
    qc_default_type = BAD_VALUE,
    qc_default_value = 0,
    vert_level_min = -1,
    vert_level_max = -1,
    vert_level_dz = 1,
    use_additional_bad_data_value = FALSE,
    additional_bad_data_value = 0,
    use_additional_missing_data_value = FALSE,
    additional_missing_data_value = 0
  }
  ,
  {
    param = "TCDC",
    level = "CCY",
    mdv_name = "",
    units = NO_CHANGE,
    upper_range_limit = 0,
    lower_range_limit = 0,
    encoding_type = ENCODING_FLOAT32,
    qc_default_type = BAD_VALUE,
    qc_default_value = 0,
    vert_level_min = -1,
    vert_level_max = -1,
    vert_level_dz = 1,
    use_additional_bad_data_value = FALSE,
    additional_bad_data_value = 0,
    use_additional_missing_data_value = FALSE,
    additional_missing_data_value = 0
  }
  // ,
  // {
  //   param = "UGRD",
  //   level = "ISBL",
  //   mdv_name = "",
  //   units = NO_CHANGE,
  //   upper_range_limit = 0,
  //   lower_range_limit = 0,
  //   encoding_type = ENCODING_FLOAT32,
  //   qc_default_type = BAD_VALUE,
  //   qc_default_value = 0,
  //   vert_level_min = -1,
  //   vert_level_max = -1,
  //   vert_level_dz = 1,
  //   use_additional_bad_data_value = FALSE,
  //   additional_bad_data_value = 0,
  //   use_additional_missing_data_value = FALSE,
  //   additional_missing_data_value = 0
  // }
  // ,
  // {
  //   param = "VGRD",
  //   level = "ISBL",
  //   mdv_name = "",
  //   units = NO_CHANGE,
  //   upper_range_limit = 0,
  //   lower_range_limit = 0,
  //   encoding_type = ENCODING_FLOAT32,
  //   qc_default_type = BAD_VALUE,
  //   qc_default_value = 0,
  //   vert_level_min = -1,
  //   vert_level_max = -1,
  //   vert_level_dz = 1,
  //   use_additional_bad_data_value = FALSE,
  //   additional_bad_data_value = 0,
  //   use_additional_missing_data_value = FALSE,
  //   additional_missing_data_value = 0
  // }
};

///////////// encoding_type ///////////////////////////
//
// File encoding type, Used only when process_everything is true.
//
//
// Type: enum
// Options:
//     ENCODING_ASIS
//     ENCODING_INT8
//     ENCODING_INT16
//     ENCODING_FLOAT32
//

encoding_type = ENCODING_FLOAT32;

///////////// compression_type ////////////////////////
//
// File compression type, Used only when process_everything is true.
//
//
// Type: enum
// Options:
//     COMPRESSION_ASIS
//     COMPRESSION_NONE
//     COMPRESSION_RLE
//     COMPRESSION_LZO
//     COMPRESSION_ZLIB
//     COMPRESSION_BZIP
//     COMPRESSION_GZIP
//

compression_type = COMPRESSION_GZIP;

///////////// output_scaling_info /////////////////////
//
// Options for user defined scale and bias.
//
// Only applies if ENCODING type is INT8 or INT16.
// If SpecifyScaling is true then the following scale and bias values 
//   will be used. If false dynamic scaling is applied.
//
//
// Type: struct
//   typedef struct {
//      boolean SpecifyScaling;
//      double scale;
//      double bias;
//   }
//
//

output_scaling_info = {
    SpecifyScaling = FALSE,
    scale = 0.5,
    bias = -32
};

///////////// remap_output ////////////////////////////
//
// If TRUE remaps output.
//
//
// Type: boolean
//

remap_output = FALSE;

///////////// out_projection_info /////////////////////
//
// This is the user defined projection.
//
// If remap_output is true this defines the projection to remap to.
//
// The choice of projections are PROJ_LATLON, PROJ_LAMBERT_CONF and 
//   PROJ_FLAT.
//
// PROJ_LATLON is a latitude/longitude projection, and if it is chosen 
//   the remaining parameters can be ignored.
//
// PROJ_FLAT is a flat projection, and if it is chosen the parameters 
//   rotation, origin_lat, origin_lon must be set.
//
// PROJ_LAMBERT_CONF is a Lambert conformal projection, and if it is 
//   chosen the parameters origin_lat, origin_lon, ref_lat_1 and ref_lat_2 
//   must be set.
//
//
// Type: struct
//   typedef struct {
//      projection_t type;
//        Options:
//          PROJ_LATLON
//          PROJ_LAMBERT_CONF
//          PROJ_FLAT
//      double rotation;
//      double origin_lat;
//      double origin_lon;
//      double ref_lat_1;
//      double ref_lat_2;
//   }
//
//

out_projection_info = {
    type = PROJ_LATLON,
    rotation = 0,
    origin_lat = 25,
    origin_lon = -95,
    ref_lat_1 = 25,
    ref_lat_2 = 25
};

///////////// out_grid_info ///////////////////////////
//
// This is the user defined grid.
//
// If remap_output is true this defines the grid info for the remap.
//
// For a LATLON projection:
//   minx = minLon
//   miny = minLat
//   dx = deltaLon
//   dy = deltaLat.
//
//
// Type: struct
//   typedef struct {
//      int nx;
//      int ny;
//      double minx;
//      double miny;
//      double dx;
//      double dy;
//   }
//
//

out_grid_info = {
    nx = 1440,
    ny = 520,
    minx = 72,
    miny = -60,
    dx = 0.25,
    dy = 0.25
};

///////////// override_vlevels ////////////////////////
//
// Option to override the vlevels in the vlevel header of the specified 
//   level types.
//
// If not empty, will replace the vlevels of variables with the 
//   specified vlevel type with those specified in 'vlevel_array'.
// Normal vlevel types to replace are: 'SIGL', 'SIGMA', or 'HYBL'.
// Please note using this functionality can create incorrect levels, use 
//   carefully!.
//
//
// Type: string
//

override_vlevels = "";

///////////// vlevel_array ////////////////////////////
//
// vlevel values to override what is already in the file.
//
// See 'override_vlevels'.
//
//
// Type: double
// 1D array - variable length.
//

vlevel_array = {
 0
};

//======================================================================
//
// INTERPOLATE INTO HEIGHT LEVELS (km MSL).
//
// Option to interpolate the model data into height levels. This 
//   requires that (a) the vertical coords are pressure levels and (b) the 
//   geopotential height field is included in the input data.
//
//======================================================================
 
///////////// interp_vlevels_to_height ////////////////
//
// Option to interpolate onto height levels (km MSL).
//
// (a) The vertical coords of the input data set MUST be PRESSURE 
//   levels. (b) Also, geopotential height must be available in the data 
//   set. This field is used for the interpolation.
//
//
// Type: boolean
//

interp_vlevels_to_height = FALSE;

///////////// height_field_mdv_name ///////////////////
//
// Name of geopotential height field in MDV file.
//
// See output_fields array.
//
//
// Type: string
//

height_field_mdv_name = "HGT";

///////////// height_levels ///////////////////////////
//
// Array of output height levels (km MSL).
//
// The data fields are intepolated onto this set of height levels.
//
//
// Type: double
// 1D array - variable length.
//

height_levels = {
 0,
 1,
 2,
 3,
 4,
 5,
 6,
 7,
 8,
 9,
 10,
 11,
 12,
 13,
 14,
 15,
 16
};

///////////// compute_heights_from_pressure_levels ////
//
// Option to determine the heights from the pressure levels.
//
// If TRUE, we use the ICAO standard atmosphere to compute the target 
//   heights from the pressure levels. In this case, the height_levels 
//   array is ignored.
//
//
// Type: boolean
//

compute_heights_from_pressure_levels = FALSE;

///////////// min_height_from_pressure_levels /////////
//
// Minimum height when computing from pressure levels (km).
//
// Any heights below this are removed when converting from pressure 
//   levels.
//
//
// Type: double
//

min_height_from_pressure_levels = 0;