
-------------------------------------------
Notes for Pre-processing data for Nudging:
-------------------------------------------

./Grid-Reference        : Contains refernce files for topography, vertical 
                          model levels, and SEgrid pentagons that specfy 
                          the grid structure of the generated data.

./Gen_Data_SETNAME_ne30 : Directory to be used as a template for processing 
                          data from 'SETNAME'. Contains the ncl processing scripts 
                          and 2 example csh scripts used to process YOTC and ERA-I 
                          data. Generally, it is best to create a separate directoy
                          for each dataset/resolution processed.

                          Processing programs/routines:
                          ------------------------------
                            ESMF_regridding.ncl
                            makeIC_Create_field_Master_List.ncl
                            makeIC_extract_analyses_info.ncl
                            MAKEIC.f90
                            MAKEIC.stub
                            makeIC_se_001.ncl
                            makeIC_se_002.ncl
                            makeIC_se_procedures.ncl

                          Work directories for processing:
                          ---------------------------------
                            Config/
                            LOG/
                            TMP/

                          Example Processing scripts:
                          ----------------------------
                            Gen_ERAI_ne30.csh
                            Gen_YOTC_ne120.csh


-----------------------------
Script CONFIGURATION SECTION:
-----------------------------
  RUNNUM   : Index so that processing can run with concurrent scripts running
  REF_DATE : 'YYYYMMDD'  Year month and day to begin processing
  NUM_DAYS : Number of days to process

  NAMELIST  : './Config/Config_makeIC-'$RUNNUM'.nl'    <-- Work directories
  MYLOGDIR  : './LOG/LOG_002.'$RUNNUM'/'               <-- Work directories
  MYTMPDIR  : './TMP/TMP_002.'$RUNNUM'/'               <-- Work directories

  MYOUTDIR  : '/PATH-FOR-OUTPUT-DATA/'                 <-- SET THIS PATH
  INPUTDIR  : '/PATH-TO-REANALYSES-INPUT/'             <-- SET THIS PATH

  ESMF_interp :                                        <-- NOTHING TO CHANGE HERE!
  ESMF_pole   :                                        <-- NOTHING TO CHANGE HERE!
  ESMF_clean  :                                        <-- NOTHING TO CHANGE HERE!
  TMP_clean   :                                        <-- NOTHING TO CHANGE HERE!

  CASE                   : 'ROOT-NAME-OF-OUTPUTDATA'   <-- SET THE NAME OF YOUR DATA FILES
  DYCORE                 : 'se'                        <-- LEAVE ALONE
  PRECISION              : 'float'                     <-- LEAVE ALONE
  VORT_DIV_TO_UV         : 'True'                      <-- CALC U,V from VOR/DIV VALUES?
  SST_MASK               : 'False'                     <-- YOUR CHOICE??
  ICE_MASK               : 'False'                     <-- YOUR CHOICE??
  OUTPUT_PHIS            : 'True'                      <-- YOUR CHOICE??
  REGRID_ALL             : 'False'                     <-- PROCESS OTHER CONTENTS IN DATASET?
  ADJUST_STATE_FROM_TOPO : 'True'                      <-- YOUR CHOICE??
  MASS_FIX               : 'True'                      <-- YOUR CHOICE??

                                                       <-- SELECT EITHER THE ne30 of ne120 files
  fname_grid_info        : '../Grid-Reference/cami_0000-01-01_ne30np4_L30_c120315.nc'
  fname_phis_output      : '../Grid-Reference/USGS-gtopo30_ne30np4_16xdel2-PFC-consistentSGH.nc'
 #fname_grid_info        : '../Grid-Reference/cami-mam3_0000-01-ne120np4_L30_c110928.nc'
 #fname_phis_output      : '../Grid-Reference/USGS-gtopo30_ne120np4_16xdel2-PFC-consistentSGH.nc'
  ftype_phis_output      : 'SE_TOPOGRAPHY'             <-- LEAVE ALONE

  fname   : ( none none none none none none )          <-- NOTHING TO CHANGE HERE!
  ftype   : ( none none none none none none )          <-- NOTHING TO CHANGE HERE!
  ftime   : ( none none none none none none )          <-- NOTHING TO CHANGE HERE!
  hoursec : ( 00000 21600 43200 64800 )                <-- NOTHING TO CHANGE HERE!
  hourstr : (   00    06    12    18  )                <-- NOTHING TO CHANGE HERE!

  fname[1] : "YYYYMM/ei.oper.an.ml.regn128sc.YYYYMMDDHH" <-- TEMPLATE FOR REANALYSES FILES
  ftype[1] : "Era_Interim_627.0_sc"                      <-- TYPE OF REANALYSES DATA
  ftime[1] : "1X"                                        <-- # OF RECORDS IN FILE

  fields       : ( U V T PS Q )                         <-- FIELDS TO PROCESS
  field_findex : ( 1 1 1 1  1 )                         <-- FILE CONTAINING THE FILED
  phis_findex  : 1                                      <-- FILE CONTAINING 'PHIS'


  WHAT TO DO:
  -----------
   (1) Set REF_DATE to the begining date of reanalyses data, and NUM_DAYS, the 
       number of days of data to process.
   (2) Processing the data is SLOW, SLOW, SLOW,  particularly at ne120. To get done
       in a timely mannor, multiple copies of the script need to be run concurrently. 
       RUNNUM is an index so that concurrent runs don't interfere with eachother.
       Also, for example, the format for the YOTC data changes during the 2 year 
       length, which requires separate processing scripts.
   (3) Set the path to the reanalyses source data and the path where processed output 
       should be stored.
   (4) Set the CASE name, the root anme of your processed files.
   (5) Set { VORT_DIV_TO_UV, SST_MASK, ICE_MASK, OUTPUT_PHIS, } as you desire.
           { REGRID_ALL, ADJUST_STATE_FROM_TOPO, MASS_FIX     }
   (6) Slelect the grid/phis values for the desired resolution
   (7) Determine the reanalyses files that contain the data you desire. Then set 
       fname[N],ftype[N],ftime[N] values for each of the N files you need. 
       (For ERA-I all of the values are contined in a single file, for YOTC the data 
        is spread across 3 different files.)

       fname[n] - Is a template in which YYYY,MM,DD,HH will be replaced with the 
                   values at a given time. 
       ftype[n] - Identifies the type of reanalyses file - see 'makeIC_extract_analyses_info.ncl'
       ftime[n] - "4X" - for daily files containing 4 time recoeds
                  "1X" - for 1 record per file.

   (8) Add the data to be processed into fields. In 'field_findex' set the file index N that
       contains that data.
   (9) Set the index for the file which contains PHIS.
  (10) The PROCESSING Section may need some minor mods depending on the structure of 
       the file names. Compare Gen_ERAI_ne30.csh to Gen_YOTC_ne120.csh to see the 
       mod that was needed when the time of day is specified in Hours instead of Seconds.
   
  (11) **IMPORTANT** 
    - Conservative mapping with ESMF is not possible using the descriptor files
      it generates for the SE grid. To make the 'conserve' option work, the ne30 and
      ne120 pentagons files were specified directly by hand. So the file 'makeIC_se_002.ncl'
      needs to be edited to use the correct files for the desired resolution. 
      Search fo 'ne30' to get to the line that needs to be changed. Fixing this
      work around is on the TODO list... near the bottom.
    - Different versions of this ncl program can be created, one just needs to change
      the name of the NCL script onvoked by the Gen_XXX.csh script (near the bottom).

    
