#!/bin/bash
#Script to extract a section from MOM6 data for a period 
# v1-Oct2026-Rosio Camayo
# OBS: Change period, positions of section and output file's name

dir_orig=/p/projetos/monan_goc/emanuel.giarolla/monan006/outputs🏁😎/history/original
dir_out=/p/projetos/monan_goc/rosio.camayo/mom6/section_mom6
#mkdir -p tmp

rm -f ${dir_out}/temp_2023_*.nc ${dir_out}/mom6_TS_section_30W_2023.nc 

for year in `seq 2023 2023`
do
 for month in `seq -f "%02g" 1 12 `
 do
    cdo -s -w -selname,temp,salt -selindexbox,1000,1000,1,720  ${dir_orig}/tempsalt_${year}_${month}.nc ${dir_out}/temp_${year}_${month}.nc	 
    echo "extracting for $year/$month"
 done
done
 cdo mergetime ${dir_out}/temp_2023_*.nc ${dir_out}/mom6_TS_section_30W_2023.nc
 rm -f ${dir_out}/temp_2023_*.nc 

