#!/bin/bash

# ============================================================
# Experiment setting
# ============================================================

REST="False"        # True: restart from file; False: start from initial condition
TSTR="0"            # start time
TEND="120"          # end time
TSTEP="1"           # restart/output interval

RDIR="rest/"
RFILE="restart.dddd.nc"

ODIR="out/"
OUTPUTF="out.dddd.nc"

# ============================================================
# External forcing amplitude
# ============================================================

AMP_X="0.0"
AMP_Y="0.0"
AMP_Z="0.0"

# Example for constant forcing:
#AMP_X="0.05"
#AMP_Y="0.05"
#AMP_Z="0.05"

# Example for seasonal forcing:
#AMP_X="-20.0"
#AMP_Y="-20.0"
#AMP_Z="-20.0"

# ============================================================
# Debug output
# ============================================================
# False: output only total X, Y, Z
# True: also output internal and external components

DEBUG_OUTPUT="False"
#DEBUG_OUTPUT="True"

# ============================================================
# File setting
# ============================================================

MODEL="model.py"
SMODEL="Lmodel_climate-v3.py"


# ============================================================
# Run model
# ============================================================

sed -e "s|%REST|$REST|g" \
    -e "s|%TSTR|$TSTR|g" \
    -e "s|%TEND|$TEND|g" \
    -e "s|%TSTEP|$TSTEP|g" \
    -e "s|%RDIR|$RDIR|g" \
    -e "s|%RFILE|$RFILE|g" \
    -e "s|%ODIR|$ODIR|g" \
    -e "s|%OUTPUTF|$OUTPUTF|g" \
    -e "s|%AMP_X|$AMP_X|g" \
    -e "s|%AMP_Y|$AMP_Y|g" \
    -e "s|%AMP_Z|$AMP_Z|g" \
    -e "s|%DEBUG_OUTPUT|$DEBUG_OUTPUT|g" \
    "$SMODEL" > "$MODEL"

python "$MODEL"

rm "$MODEL"
