⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mast-client

📁 EM算法的改进
💻
字号:
#!/bin/csh## $Id: mast-client.txt 1339 2006-09-21 19:46:28Z tbailey $# $Log$# Revision 1.5  2006/01/03 06:37:00  tbailey# Fix "MEME_BINbin" bug in mast-client.txt.# Fix indentation in meme-server.c and meme-client.c.## Revision 1.4  2005/10/05 06:18:35  nadya# use full path for "rm". Asssume everybody has /bin/rm.## Revision 1.3  2005/10/02 05:41:17  nadya# add sourcing file to set all the environment# use variables when calling real binaries.## Revision 1.2  2005/10/02 05:01:49  nadya# remove ".csh" from the name. Use extension ".bin" to call a real executable## Revision 1.1.1.1  2005/07/30 02:21:41  nadya# Importing from meme-3.0.14, and adding configure/make### This script was created by the MEME install commandset pgm = $0set pgm = $pgm:t## set the directories we need and get the machine/OS type## set the environment setenv CONF /root/etc/meme_config.cshif ( -f $CONF) then    source $CONFelse    echo "$CONF does not exist. Meme installation is incomplete"    exit 1endif## check for no arguments#if ($#argv < 1) then  usage:  cat << USAGE  USAGE:	mast-client <datafile> [<host> <port>]	<datafile>		file to send to server	[<host> <port>]		ping this host on this port	Pings server on first CPU if <datafile> is "__PING__" and exits with	status 0 if it is running.  If arguments follow the first argument 	"__PING__", pings a single host.USAGEexitendif## execute the binary version of the program with the arguments given# during install and the arguments on the command line# @ i = 1set args = ""# protect each argument with single quotes so they won't get lumpedwhile ($i <= $#argv) set a = \'"$argv[$i]"\' set args = "$args $a" @ i++end## initialize names of available cpus and port numbers#set cpus = (localhost.localdomain); set sockets = (3013);set ncpus = $#cpus## initialize semaphore stuff#set patience = 10				# wait up to 10 seconds forset down = $pgm.cpunum.down			# down semaphore file nameset up = $pgm.cpunum.up				# up semaphore file name						# semaphore## test-and-set a semaphore file containing the next cpu number# quit after $patience tries to prevent lockout and to create the# semaphore the first time#@ i = 1						# patience counterloop1:mv -f $down $up >& /dev/null			# test-and-setif ($status && $i <= $patience) then		# wait 1 second then loop  sleep 1					  @ i++						# bump patience counter  goto loop1endif ## get the number of the cpu to use#if ($i > $patience) then			# test-and-set failed   set cpunum = 1				# use first cpuelse						# test and set succeeded  @ cpunum = `cat $up`				# get cpu number from semaphoreendif## see if cpu is running server; if not, loop until a living cpu is found or all# have been tried#if ($cpunum > $ncpus) set cpunum = 1		# in case fewer cpus than beforeset first = $cpunumset ping = $pgm.$$.ping.tmpecho "ping" > $pingset exe_status = 0onintr cleanupwhile (1)  set cpu = $cpus[$cpunum]			# name of cpu  if ($#argv == 3 && $1 == __PING__) then    set cpus = ($2)    set sockets = ($3)    set ncpus = 1  endif  # ping the server  $MEME_BIN/$MEME_CLIENT_EXEC $sockets[$cpunum] $cpus[$cpunum] $ping 1  set exe_status = $status			# save the status  if ($1 == __PING__) goto cleanup		# exit if this was a ping  if ($exe_status == 0) break;			# server is alive  # server is dead; get next cpu number mod n and loop  @ cpunum++	 				  if ($cpunum > $ncpus) @ cpunum = 1  # check to see if out of cpus to try  if ($cpunum == $first) then			# tried them all    mv -f $up $down >& /dev/null		# clear the semaphore    echo "Sorry. No server is currently running."    goto cleanup                                # quit  endifend## clear the semaphore setting next cpu number to use#@ next = $cpunum + 1				# next numberif ($next > $ncpus) @ next = 1			# modulo n echo $next >! $up				# store next cpu numberchmod 777 $up					# so I can read itmv -f $up $down					# clear semaphore## execute the client#eval $MEME_BIN/$MEME_CLIENT_EXEC $sockets[$cpunum] $cpus[$cpunum] $argsset exe_status = $status			# save the status## cleanup temporary files#cleanup:if (-e $ping) /bin/rm -f $ping			# delete the ping fileexit $exe_status

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -