#!/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)
LoadManager="QSUB"
#################################
##### for target domain in Central America (country or regional)
region="camerica"  # camerica, hispaniola, All,  caribbean,lesserAntilles, greaterAntilles
region="All"
isstate=True    # isstate=True will override region; 
              # if True, add lat lon and country name below

if [[ $isstate == "True" ]]; then
     mycountry="BRB"     #  Costa Rica. See  templateShapeFileNames.ncl
     latS=12.9
     latN=14.0
     lonW=-60.0
     lonE=-59.0
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 RA IV climate (Atlantic, Pacific)

lonWeof=130.
lonEeof=340.
latSeof=-20.
latNeof=20.

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

UseMask=False
DownloadDat=True
DoRaster=True

masklev=20
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

### For obsevations
firstyr=1991
endyr=2025
obsres=0.06
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=7.5
tlatn=12.
tlonw=-86.0  
tlone=-83.5 

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

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

   if [[ $region == "camerica" ]]; then
       latS=7.0
       latN=20.0
       lonW=-93.0 
       lonE=-76.0 
   elif [[ $region == "hispaniola" ]]; then
       latS=17.5
       latN=20.5
       lonW=-75.0 
       lonE=-68.0 
   elif [[ $region == "All" ]]; then
       latS=-5.0
       latN=33.0
       lonW=-118.0  
       lonE=-58.0    
   elif [[ $region == "caribbean" ]]; then
       latS=9.0
       latN=22.0
       lonW=-90.0 
       lonE=-60.0  
   elif [[ $region == "lesserAntilles" ]]; then
       latS=10.0
       latN=22.0
       lonW=-70.0  
       lonE=-58.0 
   elif [[ $region == "greaterAntilles" ]]; then
       latS=17.0
       latN=24.0
       lonW=-85.0  
       lonE=-63.0  
   fi
fi

###############################
####### No edit needed below this line
###############################
#### For both R and NCL
###########
obsstartmon=$((ilead + startmon))
obsendmon=$((obsstartmon + sznlen - 1))

#[[ $sznlen -eq 4 ]] && { szn4mon="TRUE";  monthly="FALSE"; }
#[[ $sznlen -eq 3 ]] && { szn4mon="FALSE"; monthly="FALSE"; }
#[[ $sznlen -eq 1 ]] && monthly="TRUE"

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
##############################################

