#!/bin/bash

echo `date`
#select one of them; QSUB is still on going
#LoadManager="QSUB"   # PBS (qsub) for parallel run on multiple nodes
LoadManager="SLURM"  # SLURM (sbatch) for parallel run on multiple nodes
LoadManager="LINUX"  # single node run (no load manager)

#################################
##### for target domains (country or regional) in Africa

region="eafrica"  # All (Dont do it), eafrica, wafrica,cafrica, safrica 
isstate=True   # isstate=True will override region
             # if True, add lat lon and country name below

if [[ $isstate == "True" ]]; then
     mycountry="GHA"     # See  templateShapeFileNames.ncl
     latS=4.5
     latN=11.5
     lonW=-3.5
     lonE=1.5
fi

##############################################
###### Select predictors or use all

#slctprdctors=(MGI ATL3 rNino34 Nino34 WVG IOD SIOD PCS1 PCS2 PCS3 PCS4 PCS5 PCS6 PCR1 PCR2 PCR3 PCR4 PCR5 PCR6 ALLP_INT)

slctprdctors=(ATL3 rNino34 PCR1 ALLP_INT)

#######################################################
#### SST Domain for Indian Ocean to the Atlantic (must be 0 <= lon < 360.)
lonWeof=50.
lonEeof=340.
latSeof=-20.
latNeof=20.

#### Model intitial date and forecast period
currentyr=2026
startmon=6
sznlen=3
ilead=1
seasonname="JAS"

#### For R
testLength=5
#obst="LOCAL"
#obst="ENACT"
obst="MSWEP"

masklev=15
shaderain=True

#### For ploting  and climate
yrsstsc=1991
yrsstec=2020

allcolors="${HOME}/seasonal"   # colors and shape files directory
WMOshpfiles="${allcolors}/shpfiles/WMO_basemap.shp" #shpfile loc

### For obsevations
firstyr=1991
endyr=2025
monthly=True
obsres=0.5
obsprecip="prec${seasonname}_${firstyr}-${endyr}${obst}.nc"

#############################
allmodelNames=(canesm5 gem5nemo nasa ccsm4 cfsv2 cesm1 ensmean)

###### Select from these
#allprdctors=(MGI ATL3 rNino34 Nino34 WVG IOD SIOD PCS1 PCS2 PCS3 PCS4 PCS5 PCS6 PCR1 PCR2 PCR3 PCR4 PCR5 PCR6 ALLP_INT)

#slctprdctors=(MGI ATL3 rNino34 Nino34 WVG IOD SIOD PCS1 PCS2 PCS3 PCS4 PCS5 PCS6 PCR1 PCR2 PCR3 PCR4 PCR5 PCR6 ALLP_INT)

#slctprdctors=(ATL3 rNino34 PCS4 PCR1 ALLP_INT)

allprdctors=$slctprdctors
##############################################
### Diagnostics
printProb=False
printProbRaw=False
#Diagnostic Domain for Costa Rica
tlats=9.
tlatn=10.
tlonw=40.0 
tlone=41.0 

#######################################################
if [[ $isstate == "False" ]]; then

  if [[ $region == "All" ]]; then
    latS=-30.0
    latN=30.0
    lonW=-20
    lonE=55.0   # This is going to need some adjustment
  elif [[ $region == "eafrica" ]]; then
    latS=-13.5
    latN=24.5
    lonW=20.5
    lonE=53.0
  elif [[ $region == "wafrica" ]]; then
    latS=9.0
    latN=22.0
    lonW=-20.0  
    lonE=10.0  
  elif [[ $region == "safrica" ]]; then
    latS=10.0
    latN=22.0
    lonW=11.0
    lonE=54.0  
  elif [[ $region == "cafrica" ]]; then
    latS=-15.0
    latN=13.0
    lonW=6.0
    lonE=32.0  
  fi
fi

###############################
####### No edit needed below this line
###############################
#### For both R and NCL
###########
obsstartmon=$((ilead + startmon))
obsendmon=$((obsstartmon + sznlen - 1))
if [[ $sznlen = 4 ]]; then
szn4mon=True
else
szn4mon=False
fi

leadi=$ilead
leadf=$((ilead + sznlen - 1))

##### Number of SST and Precip EOFs
numeof=6

leave3Out=TRUE
runserial=FALSE

##############################################
