#!/bin/bash

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

#################################
##### for target domain in Central America (country or regional)
region="eafrica"  # 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
 mycountry="ETH"
 latS=2.5
 latN=16.0
 lonW=32.5
 lonE=48.
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=(MGI 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=7
ilead=1
sznlen=1           # Season Length -- Can be 1, 3, 4
seasonname="Aug"   # Three letter month or 3/4 letter season depending on SznLen


UseMask=True
DownloadDat=True
DoRaster=True

masklev=10
shaderain=True

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


#### For ploting -- Change country
yrsstsc=1991
yrsstec=2020
allcolors="${HOME}/seasonal"   # colors and shape files directory
WMOshpfiles="${allcolors}/shpfiles/WMO_basemap.shp" #shpfile loc
allcolors="/cpc/int_desk/IndianOcean/allFiles/ethiopia/"    # color
WMOshpfiles="/cpc/int_desk/IndianOcean/shpfiles/WMO_basemap.shp" #shpfile loc

### For obsevations
firstyr=1991
endyr=2025
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.0
tlatn=11.
tlonw=40.0  
tlone=42.5 

##############################################
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 == "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 -eq 1 ]]; then
monthly="TRUE"
else
monthly="FALSE"
fi

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

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

leave3Out=TRUE
runserial=FALSE
##############################################

