#!/bin/csh -x
#SBATCH --ntasks=32
#SBATCH --nodes=1
#SBATCH --time=00:30:00
#SBATCH --account=marine-cpu
#SBATCH --job-name=archm_year_mean
#SBATCH --output=joblog/archm_year_mean.joblog.o%j
#SBATCH -q debug
#set -x


## get the mean year archive
# directory where the monthly means are
setenv S /scratch2/NCEPDEV/marine/Shastri.Paturi/COAPS/MOM6_HYCOM_025/GLBm0.25/expt_10.2/MONTHLY

#/p/work/abozec/HYCOm-examples/GOMb0.01/expt_01.0/data/meanstd

# make sure to have the grid and depth file in the same directory
#ln -s ${S}/../regional.grid.* ${S}
#ln -s ${S}/../regional.depth.* ${S}

setenv E 102
cd ${S}/
setenv Y 2000
setenv KDM 41
 
cat <<E-o-D  > file_mean.IN
 ${KDM}    'kk    ' = number of layers involved
  0    'meansq' = form meansq, rather than mean (0=F,1=T)
 12    'narchs' = number of archives to read (==0 to end input)
${E}_archm.2019_m01.a
${E}_archm.2019_m02.a
${E}_archm.2019_m03.a
${E}_archm.2019_m04.a
${E}_archm.2019_m05.a
${E}_archm.2019_m06.a
${E}_archm.2019_m07.a
${E}_archm.2019_m08.a
${E}_archm.2019_m09.a
${E}_archm.2019_m10.a
${E}_archm.2019_m11.a
${E}_archm.2019_m12.a
  0     'narchs' = number of archives to read (==0 to end input)
${E}_archm.2019
E-o-D

cp /scratch2/NCEPDEV/marine/Zulema.Garraffo/HYCOM-tools/MPI/meanstd/src/hycom_mnsq .
#~/HYCOM-tools/MPI/meanstd/src/hycom_mnsq .
cp file_mean.IN blkdat.input
#aprun -n 44  ./hycom_mnsq
srun -n 32 ./hycom_mnsq

## create yearly square
cat <<E-o-D  > file_mean.IN
 ${KDM}    'kk    ' = number of layers involved
  1    'meansq' = form meansq, rather than mean (0=F,1=T)
 12    'narchs' = number of archives to read (==0 to end input)
${E}_archsq.2019_m01.a
${E}_archsq.2019_m02.a
${E}_archsq.2019_m03.a
${E}_archsq.2019_m04.a
${E}_archsq.2019_m05.a
${E}_archsq.2019_m06.a
${E}_archsq.2019_m07.a
${E}_archsq.2019_m08.a
${E}_archsq.2019_m09.a
${E}_archsq.2019_m10.a
${E}_archsq.2019_m11.a
${E}_archsq.2019_m12.a
  0     'narchs' = number of archives to read (==0 to end input)
${E}_archsq.2019
E-o-D

cp /scratch2/NCEPDEV/marine/Zulema.Garraffo/HYCOM-tools/MPI/meanstd/src/hycom_mnsq .
#~/HYCOM-tools/MPI/meanstd/src/hycom_mnsq .
cp file_mean.IN blkdat.input
#aprun -n 44  ./hycom_mnsq
srun -n 32 ./hycom_mnsq

