test.sh 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. #!/bin/bash
  2. source ../classic/librunscript.sh
  3. source ecconf.cfg
  4. function mpirun()
  5. {
  6. # This function overrides the mpi command to be able to use the native launch function
  7. :
  8. }
  9. function get_hosts()
  10. {
  11. # This function overrides get_hosts from ecconf.cfg in order to use dummy testing nodes
  12. hosts=(node01 node02 node03 node04 node05 node06 node07 node08 node09 \
  13. node10 node11 node12 node13 node14 node15 node16 node17 node18 \
  14. node19 node20 node21 node22 node23 node24 node25 node26 node27)
  15. }
  16. function machinefile_config()
  17. {
  18. # This function overrides the user configuration to fix an environment
  19. if has_config ifs nemo pisces rnfmapper xios lpjg ; then
  20. if ! has_config tm5 ; then
  21. ifs_ppn=48 #ifs_numproc=384
  22. nem_ppn=42 #nem_numproc=331
  23. xio_ppn=5 #xio_numproc=5
  24. lpjg_ppn=6 #lpjg_numproc=42
  25. else
  26. ifs_ppn=44 #ifs_numproc=256
  27. nem_ppn=48 #nem_numproc=192
  28. xio_ppn=39 #xio_numproc=39
  29. lpjg_ppn=4 #lpjg_numproc=28
  30. tm5_ppn=4 #tm5_numproc=2x2
  31. fi
  32. else
  33. # Add any new exclusive binary here
  34. ifs_exc=TRUE
  35. nem_exc=TRUE
  36. xio_exc=TRUE
  37. lpjg_exc=TRUE
  38. tm5_exc=TRUE
  39. # Modify the allocation to each binary using more than one process here
  40. ifs_ppn=48
  41. nem_ppn=48
  42. xio_ppn=48
  43. lpjg_ppn=48
  44. tm5_ppn=45
  45. fi
  46. }
  47. function esm_launch()
  48. {
  49. # Launch function call as it is on ece-esm.sh
  50. has_config nemo && \
  51. cmd="${xio_numproc} ${xio_exe_file} -- \
  52. ${nem_numproc} ${nem_exe_file} -- \
  53. ${ifs_numproc} ${ifs_exe_file} -v ecmwf -e ${exp_name}" || \
  54. cmd="${ifs_numproc} ${ifs_exe_file} -v ecmwf -e ${exp_name}"
  55. has_config lpjg && cmd=${cmd}" -- ${lpjg_numproc} ${lpjg_exe_file} guess.ins -parallel"
  56. has_config tm5 && cmd=${cmd}" -- ${tm5_numproc} ${tm5_exe_file} tm5-run.rc"
  57. has_config amip && cmd=${cmd}" -- ${amip_numproc} ${amip_exe_file}"
  58. has_config nemo && cmd=${cmd}" -- ${rnf_numproc} ${rnf_exe_file}"
  59. launch $cmd
  60. }
  61. function nemo_launch()
  62. {
  63. # Launch function call as it is on ece-nemo.sh
  64. launch ${xio_numproc} ${xio_exe_file} -- ${nem_numproc} ${nem_exe_file}
  65. }
  66. function test_machinefile()
  67. {
  68. # Function that indirectly calls the launch function to then validate the output
  69. use_machinefile="true"
  70. launch_output=$(has_config ifs && esm_launch || nemo_launch)
  71. validate_machinefile "$launch_output"
  72. }
  73. function validate_machinefile()
  74. {
  75. # Function that validates the test taking into account the expected output and the expected test result
  76. success="false"
  77. # Validate that both machine file and output (errors) are equal to the expected.
  78. # The machine is in a summarized format: group and count repeated consecutive lines, remove line breaks and squeeze repeated spaces.
  79. [ "$(cat machinefile | uniq -c | paste -d" " -s | tr -s " ")" == "$expected_machinefile" ] && \
  80. [ "$launch_output" == "$expected_output" ] && success="true"
  81. rm machinefile
  82. [ "$success" == "true" ] && echo "TEST OK" || echo "TEST FAILED"
  83. }
  84. proc_per_node=48
  85. ifs_exe_file="somedir/ifs"
  86. nem_exe_file="somedir/nemo"
  87. rnf_exe_file="somedir/runoff-mapper"
  88. lpjg_exe_file="somedir/guess"
  89. amip_exe_file="somedir/amip-forcing"
  90. tm5_exe_file="somedir/tm5"
  91. xio_exe_file="somedir/xios_server"
  92. ifs_numproc=480
  93. nem_numproc=229
  94. rnf_numproc=1
  95. lpjg_numproc=96
  96. amip_numproc=1
  97. tm5_numproc=45
  98. xio_numproc=48
  99. expected_output=""
  100. #1 XIOS NEMO IFS RUNOFF_MAPPER
  101. config='ifs nemo:elpin lim3 rnfmapper xios:detached oasis save_ic:end_leg'
  102. expected_machinefile=' 48 node01 48 node02 48 node03 48 node04 48 node05 37 node06 48 node07 48 node08 48 node09 48 node10 48 node11 48 node12 48 node13 48 node14 48 node15 48 node16 1 node06'
  103. test_machinefile
  104. #2 XIOS NEMO IFS TM5 RUNOFF-MAPPER
  105. ifs_numproc=40
  106. nem_numproc=24
  107. xio_numproc=10
  108. config='ifs nemo lim3 rnfmapper xios oasis tm5'
  109. expected_machinefile=' 10 node01 24 node02 40 node03 45 node04 1 node01'
  110. test_machinefile
  111. #3 IFS AMIP TM5
  112. config='ifs amip oasis tm5'
  113. expected_machinefile=' 40 node01 45 node02 1 node01'
  114. test_machinefile
  115. #4 IFS AMIP
  116. ifs_numproc=479
  117. config='ifs amip oasis'
  118. expected_machinefile=' 48 node01 48 node02 48 node03 48 node04 48 node05 48 node06 48 node07 48 node08 48 node09 48 node10'
  119. test_machinefile
  120. #5 XIOS NEMO
  121. nem_numproc=336
  122. xio_numproc=96
  123. config='nemo lim3 xios'
  124. expected_machinefile=' 48 node01 48 node02 48 node03 48 node04 48 node05 48 node06 48 node07 48 node08 48 node09'
  125. test_machinefile
  126. #6 XIOS NEMO IFS LPJG RUNOFF-MAPPER
  127. nem_numproc=331
  128. ifs_numproc=384
  129. xio_numproc=5
  130. lpjg_numproc=42
  131. config='ifs nemo pisces rnfmapper xios lpjg'
  132. expected_machinefile=' 47 node01 42 node02 42 node03 42 node04 42 node05 42 node06 42 node07 37 node08 48 node09 48 node10 48 node11 48 node12 48 node13 48 node14 48 node15 48 node16 6 node02 6 node03 6 node04 6 node05 6 node06 6 node07 6 node08 1 node01'
  133. test_machinefile
  134. #7 XIOS NEMO IFS LPJG TM5 RUNOFF-MAPPER
  135. ifs_numproc=256
  136. nem_numproc=192
  137. xio_numproc=39
  138. lpjg_numproc=28
  139. tm5_numproc=4
  140. config='ifs nemo pisces rnfmapper xios lpjg tm5'
  141. expected_machinefile=' 39 node01 48 node02 48 node03 48 node04 48 node05 44 node06 44 node07 44 node08 44 node09 44 node10 36 node11 4 node01 4 node06 4 node07 4 node08 4 node09 4 node10 4 node11 5 node01'
  142. test_machinefile
  143. #8 INVALID CONFIGURATION TEST: INSUFFICIENT RESOURCES
  144. nem_numproc=9999
  145. xio_numproc=48
  146. config='ifs nemo lim3 rnfmapper xios oasis'
  147. expected_output="Not enough computing nodes"
  148. expected_machinefile=' 48 node01 48 node02 48 node03 48 node04 48 node05 48 node06 48 node07 48 node08 48 node09 48 node10 48 node11 48 node12 48 node13 48 node14 48 node15 48 node16 48 node17 48 node18 48 node19 48 node20 48 node21 48 node22 48 node23 48 node24 48 node25 48 node26 48 node27'
  149. test_machinefile