cns_solve_env_sh 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. # set the number of threads for SGI multiprocessors
  28. # if this causes a problem on other systems it can be commented out
  29. #
  30. export MP_SET_NUMTHREADS; MP_SET_NUMTHREADS=1
  31. #
  32. # ==========================================================================
  33. #
  34. # get the machine architecture
  35. #
  36. if [ -d $CNS_SOLVE ]; then
  37. if [ ! "$CNS_ARCH" ]; then
  38. export CNS_ARCH; CNS_ARCH=`$CNS_SOLVE/bin/getarch`
  39. fi
  40. else
  41. export CNS_ARCH; CNS_ARCH='unknown'
  42. fi
  43. #
  44. # system variables (this is needed for openmp)
  45. #
  46. ulimit -s unlimited
  47. # ==========================================================================
  48. #
  49. # general environmental variables
  50. #
  51. export CNS_LIB; CNS_LIB=$CNS_SOLVE/libraries
  52. export CNS_MODULE; CNS_MODULE=$CNS_SOLVE/modules
  53. export CNS_TOPPAR; CNS_TOPPAR=$CNS_LIB/toppar
  54. export CNS_CONFDB; CNS_CONFDB=$CNS_LIB/confdb
  55. export CNS_XTALLIB; CNS_XTALLIB=$CNS_LIB/xtal
  56. export CNS_NMRLIB; CNS_NMRLIB=$CNS_LIB/nmr
  57. export CNS_XRAYLIB; CNS_XRAYLIB=$CNS_LIB/xray
  58. export CNS_XTALMODULE; CNS_XTALMODULE=$CNS_MODULE/xtal
  59. export CNS_NMRMODULE; CNS_NMRMODULE=$CNS_MODULE/nmr
  60. export CNS_HELPLIB; CNS_HELPLIB=$CNS_SOLVE/helplib
  61. #
  62. # general user aliases
  63. #
  64. cns_web () { $CNS_SOLVE/bin/cns_web; }
  65. cns_header () { $CNS_SOLVE/bin/cns_header; }
  66. cns_info () { cat $CNS_SOLVE/bin/cns_info; }
  67. cns_transfer () { $CNS_SOLVE/bin/cns_transfer; }
  68. if [ -x $CNS_SOLVE/bin/cns_edit_local ]; then
  69. cns_edit () { $CNS_SOLVE/bin/cns_edit_local; }
  70. else
  71. cns_edit () { $CNS_SOLVE/bin/cns_edit; }
  72. fi
  73. run_tutorial () { "csh -f tutorial.csh"; }
  74. #
  75. # g77 compilation and use
  76. #
  77. g77on () { CNS_G77=ON; . $CNS_SOLVE/.cns_solve_env_sh; }
  78. g77off () { unset CNS_G77; . $CNS_SOLVE/.cns_solve_env_sh; }
  79. #
  80. # developer aliases
  81. #
  82. run_tests () { $CNS_SOLVE/bin/run_tests; }
  83. run_diffs () { $CNS_SOLVE/bin/run_diffs; }
  84. maketar () { $CNS_SOLVE/bin/maketar; }
  85. create_patch () { $CNS_SOLVE/bin/create_patch; }
  86. #
  87. #
  88. # ==========================================================================
  89. #
  90. # to do expansions - unset noglob just in case user has it otherwise
  91. #
  92. set +f
  93. #
  94. # try to set up appropriate path
  95. #
  96. # first strip off any trailing information (eg. _g77)
  97. #
  98. CNS_ARCH=`echo ${CNS_ARCH} | sed -e 's/_g77//g'`
  99. #
  100. cns_vendor=`echo $CNS_ARCH | awk 'BEGIN{FS="-"}{print $1}'`
  101. cns_cpu=`echo $CNS_ARCH | awk 'BEGIN{FS="-"}{print $2}'`
  102. cns_os=`echo $CNS_ARCH | awk 'BEGIN{FS="-"}{print $3}'`
  103. cns_major=`echo $CNS_ARCH | awk 'BEGIN{FS="-"}{print $4}'`
  104. cns_minor=`echo $cns_major | sed -e 's/\./ /g'`
  105. #
  106. # if we are looking for a specific type of setup then limit search
  107. #
  108. cns_dirs=""
  109. if [ ! "$CNS_G77" ]; then
  110. if /bin/ls -d $CNS_SOLVE/$cns_vendor-* >/dev/null 2>&1 ; then
  111. cns_dirs="`/bin/ls -d $CNS_SOLVE/$cns_vendor-* 2>&1 | awk 'BEGIN{FS="/"}{print $NF}' | sort -t\- -n -r -k 3 -k 4`"
  112. fi
  113. else
  114. CNS_ARCH="${CNS_ARCH}_g77"
  115. if /bin/ls -d $CNS_SOLVE/$cns_vendor-*_g77 >/dev/null 2>&1 ; then
  116. 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`"
  117. fi
  118. fi
  119. #
  120. # first look for an exact match (with os version)
  121. #
  122. #
  123. cns_found=0
  124. if [ -n "$cns_dirs" ]; then
  125. for cns_dir in $cns_dirs ; do
  126. cns_tmp_major=`echo $cns_dir | awk 'BEGIN{FS="-"}{print $4}'`
  127. if [ -f $CNS_SOLVE/$cns_dir/bin/cns_solve ]; then
  128. if [ $cns_dir = ${cns_vendor}-${cns_cpu}-${cns_os}-${cns_major} -o \
  129. $cns_dir = ${cns_vendor}-${cns_cpu}-${cns_os}-${cns_major}_g77 ]; then
  130. cns_archenv=$cns_dir
  131. cns_found=1
  132. fi
  133. fi
  134. done
  135. #
  136. #
  137. # now look for an exact match (without os version)
  138. #
  139. if [ $cns_found -eq 0 ]; then
  140. for cns_dir in $cns_dirs ; do
  141. if [ -f $CNS_SOLVE/$cns_dir/bin/cns_solve ]; then
  142. if [ $cns_dir = ${cns_vendor}-${cns_cpu}-${cns_os} -o \
  143. $cns_dir = ${cns_vendor}-${cns_cpu}-${cns_os}_g77 ]; then
  144. cns_archenv=$cns_dir
  145. cns_found=1
  146. fi
  147. fi
  148. done
  149. fi
  150. #
  151. # now look for a backwards compatible match (with os version major/minor)
  152. #
  153. if [ $cns_found -eq 0 ]; then
  154. for cns_dir in $cns_dirs ; do
  155. if [ $cns_found -eq 0 ]; then
  156. cns_tmp_major=`echo $cns_dir | awk 'BEGIN{FS="-"}{print $4}' | sed 's/_g77//g'`
  157. if [ -f $CNS_SOLVE/$cns_dir/bin/cns_solve ]; then
  158. if [ $cns_dir = ${cns_vendor}-${cns_cpu}-${cns_os}-* ]; then
  159. osv_test=`echo $cns_major $cns_tmp_major | awk '{if ($1 > $2) print 1}'`
  160. if [ $osv_test -eq 1 ]; then
  161. cns_archenv=$cns_dir
  162. cns_found=1
  163. fi
  164. fi
  165. fi
  166. fi
  167. done
  168. fi
  169. #
  170. # now look for a wildcard match on cpu
  171. #
  172. if [ $cns_found -eq 0 ]; then
  173. cpu_cpu=`echo $cns_cpu | sed 's/[0-9]*\.*[0-9]*$//'`
  174. cpu_ver=`echo $cns_cpu | sed 's/[A-Za-z]*//'`
  175. for cns_dir in $cns_dirs ; do
  176. if [ $cns_found -eq 0 ]; then
  177. cns_tmp_cpu=`echo $cns_dir | awk 'BEGIN{FS="-"}{print $2}' | sed 's/[0-9]*\.*[0-9]*$//'`
  178. cns_tmp_ver=`echo $cns_dir | awk 'BEGIN{FS="-"}{print $2}' | sed 's/[A-Za-z]*//'`
  179. if [ -f $CNS_SOLVE/$cns_dir/bin/cns_solve ]; then
  180. if [ $cns_dir = ${cns_vendor}-${cpu_cpu}*-${cns_os}-${cns_major} -o \
  181. $cns_dir = ${cns_vendor}-${cpu_cpu}*-${cns_os}-${cns_major}_g77 ]; then
  182. cpu_test=`echo $cpu_ver $cns_tmp_ver | awk '{if ($1 > $2) print 1}'`
  183. if [ $cpu_test -eq 1 ]; then
  184. cns_archenv=$cns_dir
  185. cns_found=1
  186. fi
  187. fi
  188. fi
  189. fi
  190. done
  191. fi
  192. fi
  193. #
  194. # if found set environment
  195. #
  196. if [ $cns_found -eq 1 ]; then
  197. #
  198. # set installation and source directory
  199. #
  200. export CNS_INST; CNS_INST=$CNS_SOLVE/$cns_archenv
  201. export CNS_SOURCE; CNS_SOURCE=$CNS_INST/source
  202. #
  203. # path for CNSsolve utility programs
  204. #
  205. if [ -d $CNS_SOLVE/$cns_archenv/utils ]; then
  206. export PATH; PATH=`$CNS_SOLVE/bin/modify_path -sh $CNS_SOLVE/$cns_archenv/utils`
  207. fi
  208. #
  209. # path for CNSsolve executable if installed
  210. #
  211. if [ -d $CNS_SOLVE/$cns_archenv/bin ]; then
  212. export PATH; PATH=`$CNS_SOLVE/bin/modify_path -sh $CNS_SOLVE/$cns_archenv/bin`
  213. fi
  214. fi
  215. #
  216. unset cns_vendor cns_cpu cns_os cns_major cns_minor cns_tmp_major cns_tmp_minor
  217. unset cns_dir cns_dirs cns_found cns_archenv cns_diff cns_count cns_same
  218. unset cpu_cpu cpu_ver cns_tmp_cpu cns_tmp_ver cpu_test osv_test
  219. #