cns_solve_env_sh-1.3_p7 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. #!/bin/sh
  2. #
  3. # This file sets up the appropriate environmental variables and paths
  4. # for CNSsolve. In the case of the same machines with different versions
  5. # of the OS, backward compatibility is assumed - ie. a later version will
  6. # be setup for a previous version of the OS if nothing else is available.
  7. #
  8. # written by: Paul Adams
  9. #
  10. # copyright Yale University
  11. #
  12. # ==========================================================================
  13. #
  14. # >>>>>> Important: define the location of the CNSsolve directory <<<<<<
  15. #
  16. # CHANGE THE NEXT LINE TO POINT TO THE LOCATION OF THE CNSsolve DIRECTORY
  17. CNS_SOLVE=_CNSsolve_location_
  18. #
  19. # ==========================================================================
  20. #
  21. # full expansion of the CNS_SOLVE variable prior to use.
  22. #
  23. export CNS_SOLVE; CNS_SOLVE=$CNS_SOLVE
  24. #
  25. # ==========================================================================
  26. #
  27. # get the machine architecture
  28. #
  29. if [ -d $CNS_SOLVE ]; then
  30. if [ ! "$CNS_ARCH" ]; then
  31. export CNS_ARCH; CNS_ARCH=`$CNS_SOLVE/bin/getarch`
  32. fi
  33. else
  34. export CNS_ARCH; CNS_ARCH='unknown'
  35. fi
  36. #
  37. # ==========================================================================
  38. #
  39. # system variables for OpenMP
  40. #
  41. # The default stack sizes are usually insufficient, especially when
  42. # CNS is compiled using OpenMP. If the stack sizes are too
  43. # small segfaults may occur. Recommended setting for "stacksize":
  44. limit stacksize unlimited
  45. #
  46. # KMP_STACKSIZE is specific for Intel ifort, icc:
  47. ##setenv KMP_STACKSIZE 256m
  48. #
  49. # OMP_STACKSIZE is used by all compilers:
  50. setenv OMP_STACKSIZE 256m
  51. #
  52. # Uncomment the following line and change as appropriate to set the number
  53. # of processors (threads) to use.
  54. ###setenv OMP_NUM_THREADS 4
  55. #
  56. # ==========================================================================
  57. #
  58. # general environmental variables
  59. #
  60. export CNS_LIB; CNS_LIB=$CNS_SOLVE/libraries
  61. export CNS_MODULE; CNS_MODULE=$CNS_SOLVE/modules
  62. export CNS_TOPPAR; CNS_TOPPAR=$CNS_LIB/toppar
  63. export CNS_CONFDB; CNS_CONFDB=$CNS_LIB/confdb
  64. export CNS_XTALLIB; CNS_XTALLIB=$CNS_LIB/xtal
  65. export CNS_NMRLIB; CNS_NMRLIB=$CNS_LIB/nmr
  66. export CNS_XRAYLIB; CNS_XRAYLIB=$CNS_LIB/xray
  67. export CNS_XTALMODULE; CNS_XTALMODULE=$CNS_MODULE/xtal
  68. export CNS_NMRMODULE; CNS_NMRMODULE=$CNS_MODULE/nmr
  69. export CNS_HELPLIB; CNS_HELPLIB=$CNS_SOLVE/helplib
  70. #
  71. # general user aliases
  72. #
  73. cns_web () { $CNS_SOLVE/bin/cns_web; }
  74. cns_header () { $CNS_SOLVE/bin/cns_header; }
  75. cns_info () { cat $CNS_SOLVE/bin/cns_info; }
  76. cns_transfer () { $CNS_SOLVE/bin/cns_transfer; }
  77. if [ -x $CNS_SOLVE/bin/cns_edit_local ]; then
  78. cns_edit () { $CNS_SOLVE/bin/cns_edit_local; }
  79. else
  80. cns_edit () { $CNS_SOLVE/bin/cns_edit; }
  81. fi
  82. #
  83. # g77 compilation and use
  84. #
  85. g77on () { CNS_G77=ON; . $CNS_SOLVE/.cns_solve_env_sh; }
  86. g77off () { unset CNS_G77; . $CNS_SOLVE/.cns_solve_env_sh; }
  87. #
  88. # developer aliases
  89. #
  90. run_tests () { $CNS_SOLVE/bin/run_tests; }
  91. run_diffs () { $CNS_SOLVE/bin/run_diffs; }
  92. maketar () { $CNS_SOLVE/bin/maketar; }
  93. create_patch () { $CNS_SOLVE/bin/create_patch; }
  94. #
  95. #
  96. # ==========================================================================
  97. #
  98. # to do expansions - unset noglob just in case user has it otherwise
  99. #
  100. set +f
  101. #
  102. # try to set up appropriate path
  103. #
  104. # first strip off any trailing information (eg. _g77)
  105. #
  106. CNS_ARCH=`echo ${CNS_ARCH} | sed -e 's/_g77//g'`
  107. #
  108. cns_vendor=`echo $CNS_ARCH | awk 'BEGIN{FS="-"}{print $1}'`
  109. cns_cpu=`echo $CNS_ARCH | awk 'BEGIN{FS="-"}{print $2}'`
  110. cns_os=`echo $CNS_ARCH | awk 'BEGIN{FS="-"}{print $3}'`
  111. cns_major=`echo $CNS_ARCH | awk 'BEGIN{FS="-"}{print $4}'`
  112. cns_minor=`echo $cns_major | sed -e 's/\./ /g'`
  113. #
  114. # if we are looking for a specific type of setup then limit search
  115. #
  116. cns_dirs=""
  117. if [ ! "$CNS_G77" ]; then
  118. if /bin/ls -d $CNS_SOLVE/$cns_vendor-* >/dev/null 2>&1 ; then
  119. cns_dirs="`/bin/ls -d $CNS_SOLVE/$cns_vendor-* 2>&1 | awk 'BEGIN{FS="/"}{print $NF}' | sort -t\- -n -r -k 3 -k 4`"
  120. fi
  121. else
  122. CNS_ARCH="${CNS_ARCH}_g77"
  123. if /bin/ls -d $CNS_SOLVE/$cns_vendor-*_g77 >/dev/null 2>&1 ; then
  124. cns_dirs="`/bin/ls -d $CNS_SOLVE/$cns_vendor-*_g77 2>&1 | awk 'BEGIN{FS="/"}{print $NF}' | sort -t\- -n -r -k 3 -k 4`"
  125. fi
  126. fi
  127. #
  128. # first look for an exact match (with os version)
  129. #
  130. #
  131. cns_found=0
  132. if [ -n "$cns_dirs" ]; then
  133. for cns_dir in $cns_dirs ; do
  134. cns_tmp_major=`echo $cns_dir | awk 'BEGIN{FS="-"}{print $4}'`
  135. if [ -f $CNS_SOLVE/$cns_dir/bin/cns_solve ]; then
  136. if [ $cns_dir = ${cns_vendor}-${cns_cpu}-${cns_os}-${cns_major} -o \
  137. $cns_dir = ${cns_vendor}-${cns_cpu}-${cns_os}-${cns_major}_g77 ]; then
  138. cns_archenv=$cns_dir
  139. cns_found=1
  140. fi
  141. fi
  142. done
  143. #
  144. #
  145. # now look for an exact match (without os version)
  146. #
  147. if [ $cns_found -eq 0 ]; then
  148. for cns_dir in $cns_dirs ; do
  149. if [ -f $CNS_SOLVE/$cns_dir/bin/cns_solve ]; then
  150. if [ $cns_dir = ${cns_vendor}-${cns_cpu}-${cns_os} -o \
  151. $cns_dir = ${cns_vendor}-${cns_cpu}-${cns_os}_g77 ]; then
  152. cns_archenv=$cns_dir
  153. cns_found=1
  154. fi
  155. fi
  156. done
  157. fi
  158. #
  159. # now look for a backwards compatible match (with os version major/minor)
  160. #
  161. if [ $cns_found -eq 0 ]; then
  162. for cns_dir in $cns_dirs ; do
  163. if [ $cns_found -eq 0 ]; then
  164. cns_tmp_major=`echo $cns_dir | awk 'BEGIN{FS="-"}{print $4}' | sed 's/_g77//g'`
  165. if [ -f $CNS_SOLVE/$cns_dir/bin/cns_solve ]; then
  166. if [ $cns_dir = ${cns_vendor}-${cns_cpu}-${cns_os}-* ]; then
  167. osv_test=`echo $cns_major $cns_tmp_major | awk '{if ($1 > $2) print 1}'`
  168. if [ $osv_test -eq 1 ]; then
  169. cns_archenv=$cns_dir
  170. cns_found=1
  171. fi
  172. fi
  173. fi
  174. fi
  175. done
  176. fi
  177. #
  178. # now look for a wildcard match on cpu
  179. #
  180. if [ $cns_found -eq 0 ]; then
  181. cpu_cpu=`echo $cns_cpu | sed 's/[0-9]*\.*[0-9]*$//'`
  182. cpu_ver=`echo $cns_cpu | sed 's/[A-Za-z]*//'`
  183. for cns_dir in $cns_dirs ; do
  184. if [ $cns_found -eq 0 ]; then
  185. cns_tmp_cpu=`echo $cns_dir | awk 'BEGIN{FS="-"}{print $2}' | sed 's/[0-9]*\.*[0-9]*$//'`
  186. cns_tmp_ver=`echo $cns_dir | awk 'BEGIN{FS="-"}{print $2}' | sed 's/[A-Za-z]*//'`
  187. if [ -f $CNS_SOLVE/$cns_dir/bin/cns_solve ]; then
  188. if [ $cns_dir = ${cns_vendor}-${cpu_cpu}*-${cns_os}-${cns_major} -o \
  189. $cns_dir = ${cns_vendor}-${cpu_cpu}*-${cns_os}-${cns_major}_g77 ]; then
  190. cpu_test=`echo $cpu_ver $cns_tmp_ver | awk '{if ($1 > $2) print 1}'`
  191. if [ $cpu_test -eq 1 ]; then
  192. cns_archenv=$cns_dir
  193. cns_found=1
  194. fi
  195. fi
  196. fi
  197. fi
  198. done
  199. fi
  200. fi
  201. #
  202. # if found set environment
  203. #
  204. if [ $cns_found -eq 1 ]; then
  205. #
  206. # set installation and source directory
  207. #
  208. export CNS_INST; CNS_INST=$CNS_SOLVE/$cns_archenv
  209. export CNS_SOURCE; CNS_SOURCE=$CNS_INST/source
  210. #
  211. # path for CNSsolve utility programs
  212. #
  213. if [ -d $CNS_SOLVE/$cns_archenv/utils ]; then
  214. export PATH; PATH=`$CNS_SOLVE/bin/modify_path -sh $CNS_SOLVE/$cns_archenv/utils`
  215. fi
  216. #
  217. # path for CNSsolve executable if installed
  218. #
  219. if [ -d $CNS_SOLVE/$cns_archenv/bin ]; then
  220. export PATH; PATH=`$CNS_SOLVE/bin/modify_path -sh $CNS_SOLVE/$cns_archenv/bin`
  221. fi
  222. fi
  223. #
  224. unset cns_vendor cns_cpu cns_os cns_major cns_minor cns_tmp_major cns_tmp_minor
  225. unset cns_dir cns_dirs cns_found cns_archenv cns_diff cns_count cns_same
  226. unset cpu_cpu cpu_ver cns_tmp_cpu cns_tmp_ver cpu_test osv_test
  227. #