Fmake_WORK.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/bin/bash
  2. ######################################################
  3. # Author : Rachid Benshila for NEMO
  4. # Contact : rblod@locean-ipsl.upmc.fr
  5. #
  6. # Some functions called from makenemo
  7. # Fmake_WORK : create links in the WORK
  8. ######################################################
  9. #set -x
  10. set -o posix
  11. #set -u
  12. #set -e
  13. #+
  14. #
  15. # =============
  16. # Fmake_WORK.sh
  17. # =============
  18. #
  19. # -----------------------
  20. # Make the WORK directory
  21. # -----------------------
  22. #
  23. # SYNOPSIS
  24. # ========
  25. #
  26. # ::
  27. #
  28. # $ Fmake_WORK.sh
  29. #
  30. #
  31. # DESCRIPTION
  32. # ===========
  33. #
  34. #
  35. # Make the WORK directory:
  36. #
  37. # - Create line in NEW_CONF/WORK
  38. # - Use specified sub-directories previously
  39. # - OPA has to be done first !!!
  40. #
  41. #
  42. # EXAMPLES
  43. # ========
  44. #
  45. # ::
  46. #
  47. # $ ./Fmake_WORK.sh ORCA2_LIM OPA_SRC LIM_SRC_2
  48. #
  49. #
  50. # TODO
  51. # ====
  52. #
  53. # option debug
  54. #
  55. #
  56. # EVOLUTIONS
  57. # ==========
  58. #
  59. # $Id: Fmake_WORK.sh 4990 2014-12-15 16:42:49Z timgraham $
  60. #
  61. #
  62. #
  63. # * creation
  64. #
  65. #-
  66. declare ZSRC=$1 ; shift
  67. declare ZCONF=$1 ; shift
  68. ZTAB=( $@ )
  69. declare i=0 ; declare NDIR=${#ZTAB[@]}
  70. echo "Creating ${ZCONF}/WORK = ${ZTAB[*]} for ${ZCONF}"
  71. [ ! -d ${ZCONF}/MY_SRC ] && \mkdir ${ZCONF}/MY_SRC
  72. [ -d ${ZCONF}/WORK ] || \mkdir ${ZCONF}/WORK
  73. if [ "${ZSRC}" != "none" ] ; then
  74. if [ -d ${ZSRC} ] ; then
  75. ln -sf ${ZSRC}/*.[Ffh]90 ${ZCONF}/MY_SRC/.
  76. echo "MY_SRC content is linked to ${ZSRC}"
  77. else
  78. echo "External directory for MY_SRC does not exist. Using default."
  79. fi
  80. else
  81. echo "MY_SRC directory is : ${ZCONF}/MY_SRC"
  82. fi
  83. \rm -f ../${1}/WORK/*
  84. while [ $i -lt $NDIR ]
  85. do
  86. [ "${ZTAB[i]}" = "OPA_SRC" ] && ln -sf ${NEMO_DIR}/OPA_SRC/*.[Ffh]90 ${ZCONF}/WORK
  87. [ "${ZTAB[i]}" = "OPA_SRC" ] && ln -sf ${NEMO_DIR}/OPA_SRC/*/*.[Ffh]90 ${ZCONF}/WORK && break
  88. let i=$i+1
  89. done
  90. i=0
  91. while [ $i -lt $NDIR ]
  92. do
  93. if [ "${ZTAB[i]}" != "OPA_SRC" ]; then
  94. ln -sf ${NEMO_DIR}/${ZTAB[i]}/*.[Ffh]90 ${ZCONF}/WORK
  95. ln -sf ${NEMO_DIR}/${ZTAB[i]}/*/*.[Ffh]90 ${ZCONF}/WORK
  96. ln -sf ${NEMO_DIR}/${ZTAB[i]}/*/*/*.[Ffh]90 ${ZCONF}/WORK 2>/dev/null
  97. fi
  98. let i=$i+1
  99. done
  100. for i in `(cd ${ZCONF}/MY_SRC ; ls *.[Ffh]90 2>/dev/null ) `
  101. do
  102. [ -f ${ZCONF}/MY_SRC/$i ] && ln -sf $PWD/${ZCONF}/MY_SRC/${i} ${ZCONF}/WORK/.
  103. done
  104. unset -v ZCONF
  105. unset -v ZTAB
  106. unset -v i
  107. unset -v NDIR