loop_outputs_oras4.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. #SBATCH -n 1
  3. #SBATCH -t 60:00:00
  4. #SBATCH -J oras4_O1L46
  5. #SBATCH --mail-user <virginie.guemas@ic3.cat>
  6. #SBATCH --mail-type FAIL
  7. #SBATCH -o oras4_O1L46-%j.out
  8. #SBATCH -e oras4_O1L46-%j.err
  9. set -evx
  10. year0=1958
  11. yearf=2013
  12. fc0=4
  13. fcf=4
  14. config='O1L46'
  15. TMPDIR=/scratch/vguemas/$$
  16. mkdir $TMPDIR
  17. cd $TMPDIR
  18. cp /home/vguemas/CFU_tools_new/prep_restarts/script_interp_vert_ocean_outputs.bash .
  19. for ((fc=${fc0};fc<=${fcf};fc++)) ; do
  20. for ((year=${year0};year<=${yearf};year++)) ; do
  21. for ((mon=1;mon<=12;mon++)) ; do
  22. # Fetching the input file
  23. cp /cfu/releases/nudging/ocean/s4/ORCA1/fc${fc}/s4_fc${fc}_${year}$(printf "%02d" $mon)_grid_T.nc.gz .
  24. gunzip s4_fc${fc}_${year}$(printf "%02d" $mon)_grid_T.nc.gz
  25. # Vertical interpolation + horizontal and vertical extrapolation + filling empty seas
  26. bash script_interp_vert_ocean_outputs.bash s4_fc${fc}_${year}$(printf "%02d" $mon)_grid_T.nc votemper ${config}_s4_fc${fc}_${year}$(printf "%02d" $mon)_grid_T.nc $(printf "%02d" $mon)
  27. bash script_interp_vert_ocean_outputs.bash s4_fc${fc}_${year}$(printf "%02d" $mon)_grid_T.nc vosaline vosaline.nc $(printf "%02d" $mon)
  28. ncks -A vosaline.nc ${config}_s4_fc${fc}_${year}$(printf "%02d" $mon)_grid_T.nc; rm -f vosaline.nc
  29. # The output file is masked to be able to check the mask but EC-Earth does not accept masks
  30. cdo setmisstoc,0 ${config}_s4_fc${fc}_${year}$(printf "%02d" $mon)_grid_T.nc tmp.nc; rm -f ${config}_s4_fc${fc}_${year}$(printf "%02d" $mon)_grid_T.nc; mv tmp.nc ${config}_s4_fc${fc}_${year}$(printf "%02d" $mon)_grid_T.nc
  31. # Formatting
  32. ncks -O -v vosaline,votemper ${config}_s4_fc${fc}_${year}$(printf "%02d" $mon)_grid_T.nc ${config}_s4_fc${fc}_${year}$(printf "%02d" $mon)_grid_T.nc
  33. ncecat -O -h ${config}_s4_fc${fc}_${year}$(printf "%02d" $mon)_grid_T.nc ${config}_s4_fc${fc}_${year}$(printf "%02d" $mon)_grid_T.nc
  34. ncrename -d record,time ${config}_s4_fc${fc}_${year}$(printf "%02d" $mon)_grid_T.nc
  35. # Storage
  36. gzip ${config}_s4_fc${fc}_${year}$(printf "%02d" $mon)_grid_T.nc
  37. mv ${config}_s4_fc${fc}_${year}$(printf "%02d" $mon)_grid_T.nc.gz /cfu/releases/nudging/ocean/s4/ORCA1L46/fc${fc}/s4_fc${fc}_${year}$(printf "%02d" $mon)_grid_T.nc.gz
  38. rm -f s4_fc${fc}_${year}$(printf "%02d" $mon)_grid_T.nc.gz
  39. done
  40. done
  41. done
  42. rm -f script_interp_vert_ocean_outputs.bash
  43. ls
  44. rm -rf $TMPDIR