Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions IC/R8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import argparse
from bitsea.commons.mask import Mask
from IC import RSTwriter
from bitsea.commons.dataextractor import DataExtractor

def argument():
parser = argparse.ArgumentParser(description = '''
Generates restarts for R8 vars, reading from R6 ones
Applied rule is : R8 = R6 * 0.1
''')
parser.add_argument( '--file_prefix', '-o',
type = str,
required = True,
default = "out/dir/RST.19950101-00:00:00",
help = 'Path of outfiles without .R1l.nc'
)
parser.add_argument( '--maskfile','-m',
type = str,
required = True,
help = 'Path of the mask file'
)
return parser.parse_args()

args = argument()

TheMask = Mask.from_file(args.maskfile)

for var in ["c","n","p","s"]:
inputfile = f"{args.file_prefix}.R6{var}.nc"
outfile = f"{args.file_prefix}.R8{var}.nc"
R6 = DataExtractor(TheMask,inputfile,f"TRNR6{var}").values
R8 = R6 * 0.1
RSTwriter(outfile, f"R8{var}", R8,TheMask)

34 changes: 34 additions & 0 deletions IC/create_R8_rst.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# also adds R8 to the ATL BC file

module load nco

INDIR_RS=/g100_work/OGS_devC/camadio/Neccton_hindcast1999_2022/wrkdir/IC
OUTDIR_RS=/g100_work/OGS23_PRACE_IT/ggalli00/OGSTM-BFM/OGSTM-BFM_setup/RESTARTS

INDIR_BC=/g100_work/OGS_devC/Benchmark/HC/wrkdir/MODEL/BC
OUTDIR_BC=/g100_work/OGS23_PRACE_IT/ggalli00/OGSTM-BFM/OGSTM-BFM_setup/BCs

constituents=(c n p s)

#rsync -aP $INDIR_BC/ATL_yyyy0630-00:00:00.nc $OUTDIR_BC/ATL_yyyy0630-00:00:00.nc

RST_HEAD=RST.19990101-00:00:00.

for currc in "${constituents[@]}"; do

echo $currc

# # make restart
rsync -aP $INDIR_RS/${RST_HEAD}R6${currc}.nc $OUTDIR_RS/${RST_HEAD}R8${currc}.nc
ncap2 -O -s "TRNR8${currc}=TRNR6${currc}*0.1" $OUTDIR_RS/${RST_HEAD}R8${currc}.nc $OUTDIR_RS/${RST_HEAD}R8${currc}.nc
ncap2 -O -s "where(TRNR8${currc} > 1.e+10) TRNR8${currc}=1.e+20" $OUTDIR_RS/${RST_HEAD}R8${currc}.nc $OUTDIR_RS/${RST_HEAD}R8${currc}.nc
ncks -C -O -x -v TRNR6${currc} $OUTDIR_RS/${RST_HEAD}R8${currc}.nc $OUTDIR_RS/${RST_HEAD}R8${currc}.nc

# make ATL BC
# ncap2 -O -s "R8${currc}=R6${currc}*0.1" $OUTDIR_BC/ATL_yyyy0630-00:00:00.nc $OUTDIR_BC/ATL_yyyy0630-00:00:00.nc
# ncap2 -O -s "where(R8${currc} > 1.e+10) R8${currc}=1.e+20" $OUTDIR_BC/ATL_yyyy0630-00:00:00.nc $OUTDIR_BC/ATL_yyyy0630-00:00:00.nc

done