#!/bin/bash
set -evx

year=1997
mon=05
mon1=04

cp /home/eexarchou/Generate_restarts_GS5/script_interp_vert_ocean_restart_GS5_ORCA025L75.bash  . 
ln -sf /cfunas/exp/MetOffice/GS5/restarts/${year}/${year}${mon}01__restart00.tar  ${year}${mon}01__restart00.tar  
ln -sf /cfu/autosubmit/con_files/mesh_mask_nemo.Ec3.0_O25L75_ClosedSeas.nc mesh_mask_nemo.Ec3.0_O25L75_ClosedSeas.nc 
ln -sf /cfu/autosubmit/con_files/new_mask.GloSea5_O25L75.nc mask_GS5.nc
ln -sf /cfu/pub/scripts/prep_restarts/auxfiles/masks/Tofill_ecearth.v3.0.ORCA025L75.extrap.glosea5.nc Tofill_extrap.nc 
ln -sf /cfu/pub/scripts/prep_restarts/auxfiles/masks/Tofill_ecearth.v3.0.ORCA025L75.clim.glosea5.nc   Tofill_clim.nc  

tar -xvf  ${year}${mon}01__restart00.tar  
gunzip restart.nc.gz

./script_interp_vert_ocean_restart_GS5_ORCA025L75.bash  restart  restart_out  11 

ncecat -O -h restart_out.nc    tmp1.nc
ncrename -d record,t  tmp1.nc  tmp2.nc
cdo setmisstoc,0  tmp2.nc      GLOSEA5_fc0_${year}${mon1}30_restart.nc
ncrename -d z,lev              GLOSEA5_fc0_${year}${mon1}30_restart.nc

gzip -c GLOSEA5_fc0_${year}${mon1}30_restart.nc > /cfu/releases/ic/ocean/ORCA025L75/GLOSEA5/GLOSEA5_fc0_${year}${mon1}30_restart.nc.gz  

