rebuild_nemo 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/ksh
  2. #
  3. # Script to run the NEMO rebuild tool to rebuild NEMO
  4. # diagnostic or restart files.
  5. #
  6. # The scripts creates the nam_rebuild namelist based upon
  7. # the command line options you give it (see usage below)
  8. #
  9. # Ed Blockley, September 2011
  10. #
  11. #
  12. #set -ax
  13. usage ()
  14. {
  15. echo
  16. echo " NEMO Rebuild"
  17. echo " ************"
  18. echo
  19. echo " usage: ${0##*/} [-t -c] filebase ndomain [rebuild dimensions]"
  20. echo
  21. echo " flags: -t num use num threads"
  22. echo " -c num split 4D vars into time chuncks of size num"
  23. echo
  24. exit 1
  25. }
  26. while getopts c:t: opt
  27. do
  28. case ${opt} in
  29. t)
  30. OMP_NUM_THREADS=${OPTARG}
  31. ;;
  32. c)
  33. NCHUNKSIZE=${OPTARG}
  34. ;;
  35. esac
  36. done
  37. shift $(expr ${OPTIND} - 1)
  38. if [[ $# < 2 ]] ; then
  39. usage
  40. fi
  41. script_dir=$(dirname $0)
  42. file=$1
  43. ndomain=$2
  44. DIM1=$3
  45. DIM2=$4
  46. export OMP_NUM_THREADS=${OMP_NUM_THREADS:-16}
  47. if [[ -n ${DIM1} && -n ${DIM2} ]] ; then
  48. dim_str=" dims '${DIM1}','${DIM2}'"
  49. dims="dims='${DIM1}','${DIM2}'"
  50. echo ${dim_str} >> nam_rebuild
  51. fi
  52. echo "file ${file}, num_domains ${ndomain}, num_threads ${OMP_NUM_THREADS}${dim_str}"
  53. cat > nam_rebuild << EOC
  54. &nam_rebuild
  55. filebase='${file}'
  56. ndomain=${ndomain}
  57. EOC
  58. if [[ -n ${dims} ]] ; then
  59. echo ${dims} >> nam_rebuild
  60. fi
  61. if [[ -n ${NCHUNKSIZE} ]] ; then
  62. echo " nchunksize=${NCHUNKSIZE}" >> nam_rebuild
  63. fi
  64. echo "/" >> nam_rebuild
  65. # run the rebuild code
  66. ${script_dir}/rebuild_nemo.exe