;+
; Project     : SOLAR-B - EIS
;
; Name        : EIS_CPT_environment_wrapper
;
; Purpose     : Set up input and output directories and the default directory structure used by EIS_CPT
;
; Explanation : This routine sets up input and output directories and the default directory structure used by EIS_CPT.
;               The input, output and internal directories are particular to a given machine.
;               For the output OBSTBL, OBSTBL_MAP, ORL and DATA_RATE directories, if the directory is not defined then
;               the output is not produced.
;               The default directory structure should be constructed so that it is simple to
;               change for a new machine i.e
;                  eis_cpt_output_directory
;                                          /EIS_OBSTBL_directory
;                                          /EIS_ORL_directory
;                                          /EIS_DATA_RATE_directory
;                                          /EIS_MMSL_directory
;                                          /EIS_INTEL_directory
;                                          /EIS_OBSTBL_map_directory
;                                          /EIS_LATEST_directory
;                  eis_cpt_input_directory
;                                          /EIS_engineering_studies
;                  eis_cpt_internal_directory
;                                          /EIS_OBSTBL_INTERNAL_directory
;                                          /EIS_OBSTBL_MAP_INTERNAL_directory
;
; Use         : < eis_cpt_environment_wrapper, internal_directory, engineering_directory, sib_file >
;
; Inputs      : internal_obs_directory : STRING giving internal obstbl directory.
;               internal_map_directory : STRING giving internal obstbl map directory.
;               engineering_directory  : STRING giving engineering directory.
;               sib_file               : STRING giving SIB cmd file.
;
; Opt. Inputs : None.
;
; Outputs     : None.
;
; Opt. Outputs: None.
;
; Keywords    : MSSL      : directory for MSSL output
;               INTEL     : directory for INTEL output
;               OBSTBL    : directory for OBSTBL output
;               DATA_RATE : directory for DATA RATE output
;               MAP       : directory for MAP output
;               ORL       : directory for ORL output
;               LATEST    : directory for external OBSTBL and ORL output
;               LOGFILE   : file for test JOURNAL  output
;
; Calls       : None.
;
; Common      : None.
;
; Restrictions: None.
;
; Side effects: None.
;
; Category    : EIS_CPT.
;
; Prev. Hist. : None.
;
; Written     : Martin Carter RAL 06/10/04
;
; Modified    : Version 0.1, 21/10/04
;                 Added EIS_OP_directory, EIS_SEQEXEC_directory, EIS_DV_directory, EIS_linelist_directory
;                 environment variables
;               Version 0.2, 15/11/04
;                 Changed eis_obstbl_map to directory.
;               Version 0.3, 02/04/05
;                 Changed environment variables associated with MSSL, ISACS PLN and INTEL outputs.
;               Version 0.4, 27/04/05
;                 Removed ISACS PLN directory.
;               Version 0.5, 05/05/05
;                 Added KEYWORDs SOFTWARE and OUTPUT.
;                 Added check that !PATH does not altready include software directory.
;               Version 0.6, 19/07/05
;                 Changed engineering file environment variable name and added real command sequence direcory.
;                 Added INPUT keyword.
;               Version 0.7, 12/09/05
;                 Added EIS_SIB_COMMAND_TABLE environment variable..
;                 Changed 'DV' type to 'DATARATE'
;               Version 0.8, 29/09/05, MKC
;                 Replaced REAL, OP, SEQEXEC files with single ORL file.
;               Version 0.9, 06/06/06, MKC
;                 Renamed EIS CPT environment to EIS CPT setup environment.
;                 Did away with IDL environment variables.
;                 Did away with adding eis cpt software to IDL path.
;                 Did away with SOFTWARE keyword.
;               Version 1.0, 14/06/06, MKC
;                 Did away with setting up software directory.
;                 Renamed routine from eis cpt test environment to eis cpt environment wrapper.
;                 Changed input and output from keywords to arguments.
;               Version 1.1, 15/07/06, MKC
;                 Changed all directories to lower case only.
;               Version 1.2, 08/05/07, MKC
;                 Removed REAL directory.
;               Version 1.3, 27/02/08, MKC
;                 New SIB command table.
;               Version 1.4, 01/07/08, MKC
;                 Added INTERNAL directory tag.
;                 Removed output argument.
;                 Added MSSL, INTEL, OBSTBL, MAP, ORL and DATA_RATE  keywords.
;                 Changed arguments.
;               Version 1.5, 01/10/08, MKC
;                 Changed INTERNAL argument to INTERNAL_OBS and INTERNAL_MAP arguments.
;                 Added LATEST keyword.
;               Version 1.6, 09/06/11, MKC
;                 Added LOGFILE keyword.
;
; Version     : 1.6, 09/06/11
;-
;**********************************************************

PRO eis_cpt_environment_wrapper, internal_obs_directory, internal_map_directory, engineering_directory, sib_file, MSSL=mssl, INTEL=intel, OBSTBL=obstbl, MAP=map, ORL=orl, DATA_RATE=data_rate, LATEST=latest, LOGFILE=logfile

  ; set up EIS CPT environment structure

  environment = {EIS_CPT_environment}

  ; define environment variables used by EIS_CPT

  environment.INTERNAL_OBS_directory          = internal_obs_directory

  environment.INTERNAL_MAP_directory          = internal_map_directory

  environment.engineering_study_directory     = engineering_directory

  environment.SIB_COMMAND_TABLE               = sib_file

  IF KEYWORD_SET(obstbl)    THEN environment.OBSTBL_directory      = obstbl

  IF KEYWORD_SET(orl)       THEN environment.ORL_directory         = orl

  IF KEYWORD_SET(data_rate) THEN environment.DATA_RATE_directory   = data_rate

  IF KEYWORD_SET(mssl)      THEN environment.MSSL_directory        = mssl

  IF KEYWORD_SET(intel)     THEN environment.INTEL_directory       = intel

  IF KEYWORD_SET(map)       THEN environment.OBSTBL_map_directory  = map

  IF KEYWORD_SET(latest)    THEN environment.LATEST_directory      = latest

  IF KEYWORD_SET(logfile)   THEN environment.LOG_file              = logfile

  ; store environment

  dummy = eis_cpt_environment(SETUP=environment)

END