CROCO-TOY (wav or atm)
----------------------

``myenv_mypath.sh`` should already have been filled in before the compilation. 

In ``TOY_IN``, you must have the executable ``toy_wav``. First go to the 
"Compiling in coupled mode" section otherwise.
 
To prepare the run you need to modify the files ``myjob.sh`` and ``mynamelist.sh``.

* In ``myjob.sh`` , you will have to fill in information about dates, job sequence:
  ::

      # Real job duration in sec (converted to MACHINE format in submit job)
      export TIMEJOB=1800

      #-------------------------------------------------------------------------------
      # Run date settings
      #-------------------------------------------------------------------------------
      # Your run can be divided into several jobs (e.g.: 1 year run into 12 jobs of 1 month)

      # Start date of the first Job
      export YEAR_BEGIN_JOB=2005
      export MONTH_BEGIN_JOB=1
      export DAY_BEGIN_JOB=1

      # Duration of each Job
      export JOB_DUR_MTH=1
      export JOB_DUR_DAY=0

      # How many jobs do you want to launch?
      export NBJOB=1

      # Do we start from a restart?
      export RESTART_FLAG="FALSE"

  Along with the number of cpu you will use for each model
  ::
    
      # nb of CPUs for each model
      export NP_OCEX=2
      export NP_OCEY=2
      export NP_TOY=2


* In ``mynamelist.sh``, first specify the run type, and the name of the experiment:
  ::

      # Run type (o/a/w, w.Afrc, oa, 2o1a, owa, owa.full...)
      #  - Will select the models to use reading letters o/w/a/toywav/toyoce/toyatm 
      #  - Will select the executables, and some options (see in the following sections)
      #  - In coupled mode corresponds to the suffix of the OASIS_IN/namcouple.base.$RUNtype to use
      export RUNtype=ow.toywav
      export MOD=`echo $RUNtype | cut -d . -f 1`
       
      #  Name of the experiment you are about to launch (max 30. CHAR)
      export CEXPER=BENGUELA_example_${RUNtype}

  Then, there is a section indicating where the run will be executed and where 
  the outputs and restarts will be stored:
  ::

      #-------------------------------------------------------------------------------
      # RUN_DIR
      #-------------------------------------------------------------------------------
      
      export EXEDIR_ROOT="$CWORK/rundir/${CEXPER}_execute"
      export OUTPUTDIR_ROOT="$CWORK/rundir/${CEXPER}_outputs"
      export RESTDIR_ROOT="$CWORK/rundir/${CEXPER}_restarts"
      
      export  JOBDIR_ROOT=${CHOME}/jobs_${CEXPER}

  Then, there are sections for the different components. 

  For the coupler settings:
  ::

      #-------------------------------------------------------------------------------
      # CPL
      #-------------------------------------------------------------------------------
      
      # Namelist
      #---------
      # Note: namelist example files are provided in OASIS_IN/
      # if you want to use a pre-built weight file for grid interpolations, point to 
      # e.g. namcouple.base.oa.smtho2a 
      export namcouplename=namcouple.base.${RUNtype}
      
      # Coupling frequency
      #-------------------
      export CPL_FREQ=21600
      
      # Restart files for OASIS
      #------------------------
      # If TRUE: create OASIS restart files from pre-existing atm/oce/wav outputs.
      # If FALSE: create OASIS restart files from calm conditions (need to read at least the grid for each model)
      export CPL_restart="FALSE"
      export oce_rst_file="${OCE_FILES_DIR}/croco_grd.nc"
      export oce_rst_timeind=-1 # time index (-1 is last) in the file to extract as restart
      export atm_rst_file="${ATM_FILES_DIR}/wrfinput_dXX_2005_01_01_00" # the domain dXX will be automatically replaced
      export atm_rst_timeind=-1 # time index (-1 is last) in the file to extract as restart
      export wav_rst_file="${WAV_FILES_DIR}/ww3.200501.nc"
      export wav_rst_timeind=-1 # time index (-1 is last) in the file to extract as restart
      
  You should check the coupling frequency, the restart flag and path towards model files to use to create oasis restart files.

  For CROCO settings, first indicate if you request CROCO compilation:
  ::

      #-------------------------------------------------------------------------------
      # OCE
      #-------------------------------------------------------------------------------

      # Where to find or put the croco execuatble
      export OCE_EXE_DIR=${CHOME}/CROCO_IN
      
      # Online Compilation
      #-------------------
      #!!!!!!! IMPORTANT NOTE !!!!!!!
      # If activated, creates croco executable depending on this namelist. 
      #   - In param.h it modifies the grid size, the number of procs in x and y direction with those given in myjob.sh
      #   - In cppdefs.h it modifies the following options with informations given below
      #       MPI, OA_COUPLING, OW_COUPLING, MRL_WCI, 
      #       XIOS, LOGFILE, MPI_NOLAND,
      #       AGRIF, AGRIF_2WAY, 
      #       BULK_FLUX, ONLINE, AROME, ARPEGE, ERA_ECMWF
      #       FRC_BRY, CLIMATOLOGY
      #       TIDES, PSOURCE, PSOURCE_NCFILE, PSOURCE_NCFILE_TS
      # Other changes of parameterizations, numerical schemes, etc should be made "by hand" in CROCO_IN/cppdefs.h.base
      #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      export ONLINE_COMP=1

  Then, edit model time steps:
  ::

      # Time steps
      #-----------
      export DT_OCE=3600
      export NDTFAST=60

  Then several options for zooms, wave coupling are provided. 
  They are generally automatically set-up depending on the ``RUNtype`` defined at the beginning. 

  Then, edit the options regarding the forcing files:
  ::

      # Forcings
      #---------
      export ini_ext='ini_SODA' # ini extension file (ini_SODA,...)
      export bdy_ext='bry_SODA' # bry extension file (clm_SODA,bry_SODA,...)
      
      # flag for surface forcing should be true except in the case of atm coupling
      if [[ $MOD =~ .*a.* ]] ; then
          export surfrc_flag="FALSE"
      else
          export surfrc_flag="TRUE"
      fi
      export interponline=0 # switch (1=on, 0=off) for online surface interpolation. Only works with MONTHLY input files!
      export frc_ext='blk_ERA5' # surface forcing extension(blk_ERA5, frc_ERA5,...). If interponline=1 precise the type (ERA_ECMWF or AROME,  [CFSR by default], names as cppkey name in croco)
      
      export tide_flag="FALSE" # the forcing extension must be blk_??? otherwise tide forcing overwrites it 
      export river_flag="FALSE"

  Finally edit CROCO output settings:
  ::

      # Output settings
      #----------------
      #!!! WARNING: when XIOS is activated the following values (for the model) are not taken into account
      export oce_his_sec=86400     # history output interval (in number of second) 
      export oce_avg_sec=86400     # average output interval (in number of second) 

  Then go down to the TOY model section, and set the toy options, and model files 
  the toy model should use:
  ::

      #-------------------------------------------------------------------------------
      # TOY
      #-------------------------------------------------------------------------------
      
      # Where to find the toy executable(s)
      export TOY_EXE_DIR=${CHOME}/TOY_IN
      
      # Choose for which model you use the toy 
      # If several separate with spaces
      # options are: oce atm wav
      #---------------------------------------
      export toytype=("wav") 
      
      # Forcing files that will be read by the toy
      #-------------------------------------------
      export toyfile=("$CWORK/TOY_FILES/ww3.201301.nc")
      export toytimerange=('2,124')
      
* Now that you have completed the necessary files, you are ready to run your 
  simulation. To do so, simply do
  ::

      ./submitjob.sh
   
