launch_conversion_uf.bash 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/bin/bash
  2. ##### BASH:
  3. # - launch p_prep_obs slurm
  4. # prepare obs in observation.txt and observation.uf files
  5. # - creat dir in scratch
  6. # - copy exe + mask (=src dir) in scratch
  7. # - launch p_prep with input path/file.nc var tag_date
  8. #
  9. # 2024/06/17 A. Delhasse alison.delhasse@uclouvain.be
  10. #
  11. #########
  12. #SBATCH -n 1
  13. #SBATCH -t 00:10:00
  14. #SBATCH -J post_perturbation
  15. #SBATCH -o log/slurm_conversion-%j.out
  16. #SBATCH -e log/slurm_conversion-%j.err
  17. #SBATCH --partition=debug # Partition sur laquelle lancer le travail
  18. ##SBATCH --exclusive # Ressources exclusives
  19. #SBATCH --account=limhr # Compte associé au travail
  20. #SBATCH --mem-per-cpu=64000
  21. ### LOAD MODULES
  22. #module load Python/3.10.4-GCCcore-11.3.0
  23. module --force purge
  24. module load EasyBuild/2023a
  25. module load netCDF-Fortran/4.6.1-gompi-2023a
  26. module load Perl-bundle-CPAN/5.36.1-GCCcore-12.3.0
  27. module load ScaLAPACK/2.2.0-gompi-2023a-fb
  28. module load FFTW.MPI/3.3.10-gompi-2023a
  29. set -x
  30. set -e
  31. ## add read txt where obs are avail
  32. indir=/gpfs/scratch/acad/limhr/adelhass/obs/OSI-450-430-a/interpo
  33. outdir=/gpfs/scratch/acad/limhr/adelhass/obs/OSI-450-430-a/uf-siconc
  34. yb=1988
  35. ye=1988
  36. for year in $yb $ye; do
  37. for mm in `seq 1 12`; do
  38. #year=1990
  39. #month="02"
  40. ### upgrade with good date if not the 1sr of the month ??
  41. day='01'
  42. month=$(printf "%02d" $mm)
  43. tagdate=${year}${month}${day}
  44. #create scratch_conversion_uf_dir_${tagdate}
  45. rm -rf /gpfs/scratch/acad/limhr/adelhass/conversion_uf_${tagdate}
  46. mkdir /gpfs/scratch/acad/limhr/adelhass/conversion_uf_${tagdate}
  47. cd /gpfs/scratch/acad/limhr/adelhass/conversion_uf_${tagdate}
  48. cp -r ~/git/EnKF/src_conversion/* .
  49. ## test if file exist, else, skip the date
  50. if [ -f ${indir}/ice_conc_OSISAF-eORCA1_${tagdate}.nc ] ; then
  51. ## launch conversion itself
  52. ./prep_obs_ORCA1 ${indir}/ice_conc_OSISAF-eORCA1_${tagdate}.nc sic ${tagdate}
  53. cpt=0
  54. while [ ! -f observations.uf ] && [ ! -f observations.txt ] ; do
  55. cpt=$((cpt+1))
  56. sleep 20
  57. if [ ${cpt} -gt 10 ] ; then
  58. [ $? -ne 0 ] && exit 1
  59. fi
  60. done
  61. cp observations.txt ${outdir}/observations_${tagdate}.txt
  62. cp observations.uf ${outdir}/observations_${tagdate}.uf
  63. if [ ! -f ${outdir}/observations_${tagdate}.txt ] || [ ! -f ${outdir}/observations_${tagdate}.uf ] ; then
  64. echo "Something wrong ${outdir}/observations_${tagdate}.* don't exist! "
  65. exit 2
  66. else
  67. echo "conversion ${tagdate} DONE! and file in ${outdir}/observations_${tagdate}.*"
  68. echo "Remove tmp working dir /gpfs/scratch/acad/limhr/adelhass/conversion_uf_${tagdate} "
  69. rm -rf /gpfs/scratch/acad/limhr/adelhass/conversion_uf_${tagdate}
  70. fi
  71. else
  72. echo "File ${indir}/ice_conc_OSISAF-eORCA1_${tagdate}.nc doesn't exist, skip until next date."
  73. ### create an empty file "observations_${tagdate}_missing" in the output rep
  74. echo '' > ${outdir}/observations_${tagdate}_missing
  75. fi
  76. done #month
  77. done #year