lucia 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. #!/bin/bash
  2. # "To make a prairie
  3. # It takes a clover
  4. # And one bee"
  5. # E. Dickinson
  6. #
  7. #
  8. ####################################################################
  9. # LUCIA
  10. ####################################################################
  11. #
  12. # Load-balancing Utility and Coupling Implementation Appraisal
  13. #
  14. # - OASIS3-MCT performance analyser -
  15. #
  16. # arguments:
  17. #
  18. # without : processing all lucia.* files in ./ directory
  19. #
  20. # -c : compilation
  21. # -V : version
  22. # -h : help
  23. #
  24. #
  25. # Authors: E. Maisonnave (CERFACS) 02/12
  26. # U. Fladrich, M. Evaldsson (SMHI)
  27. # Modifs:
  28. # E.M, Arnaud Caubel (LSCE) 12/13: add interpolation timing
  29. #
  30. #
  31. # Version 1.0
  32. #
  33. #set -vx
  34. #
  35. #
  36. #################### Do not modifiy below this line ######################
  37. #
  38. # Find gnuplot
  39. #
  40. GNUPLOT=`which gnuplot 2>oas_dumm`
  41. #
  42. if [ ! "$GNUPLOT" ]; then
  43. echo "lucia WARNING: Gnuplot not available"
  44. echo "Results on text file info.dat only"
  45. fi
  46. rm -f oas_dumm
  47. #
  48. # Path check
  49. #
  50. begin_path=`pwd`
  51. end_path=$0
  52. if [ -f ${begin_path}/${end_path} ]; then
  53. complete_path=${begin_path}/${end_path}
  54. else
  55. complete_path=${end_path}
  56. fi
  57. lucia_PATH=`dirname $complete_path`
  58. if [ ! -f ${lucia_PATH}/lucia ]; then
  59. echo "lucia ERROR: cannot find \"lucia\" shell script path"
  60. exit
  61. fi
  62. # Arguments check
  63. if [ $# -gt 1 ]; then
  64. echo "Usage: lucia [-c] [-V] [-h] "
  65. exit
  66. fi
  67. # Default
  68. compil=0
  69. while getopts chV opt
  70. do
  71. case $opt in
  72. V) echo lucia v1.0. Global Change Team, CERFACS, 2013 ; echo ; exit ;;
  73. h) echo "Usage: "; echo "lucia [-V] [-h]" ; echo; exit ;;
  74. c) echo "Compiling ..." ; compil=1; echo ;;
  75. esac
  76. done
  77. # Fortran compilations if required
  78. if [ "$compil" == "1" -o ! -f ${lucia_PATH}/lucia.exe ]; then
  79. #
  80. # Compilation
  81. #
  82. # You could add compiler here (or add it to the command-line) e.g. F90=ifort ./lucia -c
  83. [ -z $F90 ] && F90=my_compiler
  84. #
  85. # Find a fortran compiler
  86. #
  87. F90_oa=""
  88. for compilers in pgf90 ifort gfortran mpif90 g95 $F90
  89. do
  90. test_compiler=`which $compilers 2>oas_dumm`
  91. if [ "$test_compiler" ]; then
  92. F90_oa=$compilers
  93. fi
  94. done
  95. if [ ${F90_oa}"false" == "false" ]; then
  96. echo "lucia ERROR: no FORTRAN compiler available"
  97. exit
  98. fi
  99. echo "lucia compilation needed"
  100. echo "Compiler: "$F90_oa
  101. cd ${lucia_PATH}
  102. $F90_oa main-lucia.F90 -o lucia.exe
  103. cd -
  104. if [ -f ${lucia_PATH}/lucia.exe ]; then
  105. chmod +x ${lucia_PATH}/lucia.exe
  106. echo "Compilation completed successfully"
  107. echo "lucia ready to launch"
  108. exit
  109. else
  110. echo "lucia ERROR: Unsuccessfull compilation"
  111. echo "Check compilation options in lucia script"
  112. exit
  113. fi
  114. fi
  115. # Select information on prt files
  116. arg_line=''
  117. #for model_name in 01 02 03 04 05
  118. num_models=`ls -l lucia.??.000000 | wc -l`
  119. for i in `seq 1 $num_models`
  120. do
  121. model_name=$(printf "%02d" $i)
  122. if [ -f lucia.${model_name}.000000 ]; then
  123. nb_file=`ls lucia.${model_name}.*|wc -l`
  124. if [ $nb_file -lt 1 -a "$model_name" == "01" ]; then
  125. echo "lucia ERROR: log files not found"
  126. exit
  127. fi
  128. rank_last=`ls lucia.${model_name}.*|tail -1|sed -e s/lucia....//`
  129. arg_line=$arg_line" "$model_name" "$nb_file" "$rank_last
  130. fi
  131. done
  132. #
  133. # Fortran code launch
  134. #
  135. # GOOOOOOOOOOOOOOOOOOOOO !
  136. #
  137. echo $arg_line
  138. ${lucia_PATH}/lucia.exe $arg_line
  139. #
  140. # gnuplot if possible
  141. if [ "$GNUPLOT" ]; then
  142. gnuplot ${lucia_PATH}/balance.gnu
  143. echo "Result on graphical format in oasis_balance.eps file"
  144. fi
  145. # Cleaning
  146. rm -f oas_dumm
  147. # End
  148. echo
  149. echo lucia: CERFACS -2013-