Annotation of OpenXM/src/kan96xx/Doc/ox_old.sm1, Revision 1.1
1.1 ! takayama 1: %%%%%%%%%%% $OpenXM$
! 2:
! 3: /ox.sm1.loaded 1 def
! 4: %%%%%%%%%%%% Configuration: Specify your server path
! 5: %%%%% ox, ox_sm1, oxlog are contained in kxx.tgz
! 6: %%%%% These should be under /usr/local/lib/sm1 or LOAD_SM1_PATH
! 7: /oxpath.ox (bin/ox) def
! 8: /oxpath.oxsm1 (bin/ox_sm1) def
! 9: /oxpath.oxlog (bin/oxlog) def
! 10: /oxpath.xterm (/usr/X11R6/bin/xterm -icon -e ) def
! 11: /oxpath.null ( ) def
! 12: /oxpath.null00 ( >& /dev/null ) def %%cf. oxNoX
! 13: /oxpath.null00-pure-sh ( 2>&1 >/dev/null) def %%TODO:It does not work in our case
! 14: %%%%%%%%%%%%% The following is used only for sm1connectr-ssh.
! 15: %%%%%%%%%%%%% Configure path for ox and ox_sm1 on your remote machine.
! 16: /oxpath.oxlog.xterm-ssh (/home/taka/OpenXM/bin/oxlog /usr/X11R6/bin/xterm -icon -e ) def
! 17: /oxpath.oxsm1-ssh (/home/taka/OpenXM/bin/ox_sm1) def
! 18: /oxpath.ox-ssh (/home/taka/OpenXM/bin/ox) def
! 19: /myhostname-ssh (yama.math.kobe-u.ac.jp) def
! 20: %% for debugging.
! 21: %/oxpath.oxlog.xterm-ssh ( ) def
! 22: %/oxpath.oxsm1-ssh (/home/nobuki/OpenXM/bin/ox_sm1) def
! 23: %/oxpath.ox-ssh (/home/nobuki/OpenXM/bin/ox) def
! 24: %/myhostname-ssh (localhost) def
! 25: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
! 26: %% Old full path.
! 27: %/oxpath.ox (/home/nobuki/kxx/ox) def
! 28: %/oxpath.oxsm1 (/home/nobuki/kxx/ox_sm1) def
! 29: %/oxpath.oxlog (/home/nobuki/kxx/oxlog) def
! 30: %/oxpath.xterm (/usr/X11R6/bin/xterm -icon -e ) def
! 31:
! 32: %% This macro is invoked when this package is loaded.
! 33: /initializePathNamesForOx {
! 34: [oxpath.ox] getPathNameSm1 /oxpath.ox set
! 35: [oxpath.oxsm1] getPathNameSm1 /oxpath.oxsm1 set
! 36: [oxpath.oxlog] getPathNameSm1 /oxpath.oxlog set
! 37: /oxpath.oxlog.xterm [oxpath.oxlog ( ) oxpath.xterm] cat def
! 38: } def
! 39:
! 40: %% Execute this macro, then xterm will not be executed and the output
! 41: %% will be redirected to /dev/null.
! 42: /oxNoX {
! 43: /oxpath.null oxpath.null00 def
! 44: /oxpath.oxlog.xterm [oxpath.oxlog ( )] cat def
! 45: (oxpath.oxlog.xterm is set to ) messagen
! 46: oxpath.oxlog.xterm message
! 47: } def
! 48:
! 49: /ox.ccc.init {
! 50: ox.ccc ( [(oxPrintMessage) 0] extension pop ) oxsubmit
! 51: (Ox103_loaded) boundp
! 52: { ox.ccc ox103_sm1_init }
! 53: { } ifelse
! 54: } def
! 55:
! 56: /ox.verbose 0 def
! 57: /ox.version (2.981105) def
! 58: ox.version [(Version)] system_variable gt
! 59: { (This package requires the latest version of kan/sm1) message
! 60: (Please get it from http://www.math.kobe-u.ac.jp/KAN) message
! 61: error
! 62: } { } ifelse
! 63: (ox.sm1, ---OpenXM protocol module 08/22, 2001 (C) N.Takayama. oxhelp for help) message-quiet
! 64:
! 65: /ox.ccc load isArray
! 66: { }
! 67: { /ox.ccc [ ] def } ifelse
! 68:
! 69:
! 70:
! 71: /ox.logsize 10 def
! 72: /ox.log [1 1 ox.logsize {pop 0} for ] def
! 73: /ox.mod { dup ox.logsize idiv ox.logsize mul sub } def
! 74: /ox.takelog 1 def
! 75:
! 76: /SM_executeStringByLocalParser 268 def
! 77: /SM_execute 268 def
! 78: /SM_popString 263 def
! 79: /SM_mathcap 264 def
! 80:
! 81: /SM_popCMO 262 def
! 82: /SM_executeFunction 269 def
! 83: /SM_DUMMY_sendcmo 2147418112 1 add def %%% SM_PRIVATE+1
! 84: /SM_sync_ball 281 def
! 85:
! 86: /SM_pops 265 def
! 87: /SM_setName 266 def
! 88: /SM_evalName 267 def
! 89:
! 90: /SM_setMathCap 273 def
! 91:
! 92: /SM_getsp 275 def
! 93: /SM_dupErrors 276 def
! 94:
! 95: /SM_control_kill 1024 def
! 96: /SM_control_reset_connection 1030 def
! 97: /SM_control_spawn_server 1027 def
! 98:
! 99: /Etag_error 257 def
! 100:
! 101: /enginesList [
! 102: [(localhost) 1300 1200]
! 103: [(localhost) 2300 2200]
! 104: ] def
! 105: %% cf. startengines
! 106: /enginesList.2 [
! 107: [(dc1) 1300 1200]
! 108: [(dc2) 2300 2200]
! 109: ] def
! 110: %% cf. se12
! 111:
! 112: /oxconnect {
! 113: /arg1 set
! 114: [(oxCreateClient) arg1 aload pop] extension
! 115: } def
! 116: [(oxconnect)
! 117: [([hostname data-port control-port] oxconnect pid)
! 118: (oxconnect is used to connect this to a server on the hostname with data-port)
! 119: (and control-port)
! 120: (Example 1: ox -ox ox_sm1 -data 1300 -control 1200 <== on server.)
! 121: ( [$localhost$ 1300 1200] oxconnect /ox.ccc set <== on client.)
! 122: (Example 2: ox -ox ox_sm1 -host s.OpenXM.org -insecure -data 1300 -control 1200 <== on server.)
! 123: ( [$s.OpenXM.org$ 1300 1200] oxconnect /ox.ccc set <== on client.)
! 124: (Example 3: ox -ox ox_sm1 -data 1300 -control 1200 >& /dev/null &<== on server.)
! 125: ( [$localhost$ 1300 1200] oxconnect /ox.ccc set <== on client.)
! 126: ( cf. oxNoX)
! 127: (See also ox)
! 128: ]
! 129: ] putUsages
! 130:
! 131: [(ox)
! 132: [
! 133: (client aa oxpushcmo (oxsendcmo), client oxpopcmo dd, client popstring dd, client ss oxrpc)
! 134: (Example: ox.ccc [1 2 3] oxpushcmo ox.ccc oxpopcmo /ff set ff :: )
! 135: ( )
! 136: (client ss oxexecutestring(oxsubmit) <<executeString>>, client ss oxexec <<executeFunction>>)
! 137:
! 138: (Example: ox.ccc (0 1 10 { pop $Hello$ message } for) oxexecutestring )
! 139: (Example: ox.ccc (2).. oxpushcmo ox.ccc (10).. oxpushcmo )
! 140: ( ox.ccc (power) oxexec ox.ccc oxpopcmo :: )
! 141: ( )
! 142: (client str oxevalname, client str oxsetname, client num oxpops, client oxget)
! 143: ( )
! 144: (client oxmathcap, client oxsetmathcap, oxgenportfile, oxremoveportfile)
! 145: ( )
! 146: (client oxgetsp --- get stack pointer, client oxgeterrors --- get all errors)
! 147: (cleint oxisData, client oxreset, client oxshutdown)
! 148: (oxhelp for this message, [(oxWatch) client] extension to start a log.)
! 149: ([(oxSerial)] extension serial-number-of-out-going-ox-packet.)
! 150: (oxpopcmo1, oxpopcmo2, sm1connect2, sm1connect3)
! 151: (sm1connectr ox_launch, ox_launch_nox)
! 152: (oxNoX : set an environment to invoke oxlog without xterm and to call oxlog with >& /dev/null)
! 153: (oxresetAll, oxIsInterruptable, [(oxGetClientList)] extension )
! 154: $ ex 1. (ox.sm1) run oxNoX sm1connectr $
! 155: $ ex 2. (oxasir.sm1) run oxNoX (x^2-1). fctr pmat ; $
! 156: ]
! 157: ] putUsages
! 158:
! 159: /oxhelp {
! 160: (oxconnect) usage
! 161: ( ) message
! 162: (ox) usage
! 163: } def
! 164: [(oxhelp)
! 165: [(oxhelp outputs help messages for ox commands.)
! 166: ]] putUsages
! 167:
! 168: ox.verbose { oxhelp } { } ifelse
! 169:
! 170: /sm1connect2 {
! 171: [oxpath.oxlog.xterm oxpath.ox ( -ox ) oxpath.oxsm1
! 172: oxpath.null
! 173: ( &)] cat system-csh
! 174: % (kterm -iconic -e /home/nobuki/kxx/ox -ox /home/nobuki/kxx/ox_sm1 &) system
! 175: % For MSRI, or Eterm,
! 176: %(xterm -icon -e /u/nobuki/tmp/kxx/ox -ox /u/nobuki/tmp/Ox/ox_sm1 &) system
! 177: (If you start the server automatically, you may have a trouble to) message
! 178: (oxreset. In order to avoid this trouble, start the server by hand.) message
! 179: (sleep 5) system-csh
! 180: [(localhost) 1300 1200] oxconnect /ox.ccc set
! 181: (The server is binded to the variable ox.ccc) message
! 182: ox.ccc.init
! 183: } def
! 184:
! 185: /sm1connect3 {
! 186: [oxpath.oxlog.xterm oxpath.ox ( -ox ) oxpath.oxsm1
! 187: ( -data 2300 -control 2200 )
! 188: oxpath.null
! 189: ( &)] cat system-csh
! 190: % (kterm -iconic -e /home/nobuki/kxx/ox -ox /home/nobuki/kxx/ox_sm1 -data 2300 -control 2200 &) system-csh
! 191: % For MSRI
! 192: %(xterm -icon -e /u/nobuki/tmp/kxx/ox -ox /u/nobuki/tmp/Ox/ox_sm1 -data 2300 -control 2200&) system-csh
! 193: (If you start the server automatically, you may have a trouble to) message
! 194: (oxreset. In order to avoid this trouble, start the server by hand.) message
! 195: (sleep 5) system-csh
! 196: [(localhost) 2300 2200] oxconnect /ox.ccc2 set
! 197: (The server is binded to the variable ox.ccc2) message
! 198: } def
! 199:
! 200: /sm1connect4 {
! 201: %% test version.
! 202: /ox.ccc.portfile oxgenportfile def
! 203: [oxpath.oxlog.xterm oxpath.ox ( -ox ) oxpath.oxsm1
! 204: ( -portfile ) ox.ccc.portfile
! 205: oxpath.null
! 206: ( &)] cat system-csh
! 207: (sleep 5) system-csh
! 208: [(oxReadPortFile) ox.ccc.portfile] extension /ox.ccc.control set
! 209: ox.ccc.control message
! 210: [(localhost) ox.ccc.control 1200] /ox.ccc set
! 211: (The server is binded to the variable ox.ccc) message
! 212: oxremoveportfile
! 213: } def
! 214:
! 215: /oxpushcmo { oxsendcmo } def
! 216: /oxsendcmo {
! 217: /arg1 set
! 218: /arg2 set
! 219: ox.takelog { ox.log [(oxSerial)] extension ox.mod arg1 put
! 220: } { } ifelse
! 221: [(oxReq) arg2 SM_DUMMY_sendcmo arg1] extension pop
! 222: } def
! 223:
! 224: /oxpopcmo {
! 225: /arg1 set
! 226: [(oxReq) arg1 SM_popCMO ] extension pop
! 227: [(oxGet) arg1] extension
! 228: } def
! 229:
! 230: /oxgetsp {
! 231: /arg1 set
! 232: [(oxReq) arg1 SM_getsp ] extension pop
! 233: [(oxReq) arg1 SM_popCMO ] extension pop
! 234: [(oxGet) arg1] extension
! 235: } def
! 236:
! 237: /oxgeterrors {
! 238: /arg1 set
! 239: [(oxReq) arg1 SM_dupErrors ] extension pop
! 240: [(oxReq) arg1 SM_popCMO ] extension pop
! 241: [(oxGet) arg1] extension
! 242: } def
! 243:
! 244: /oxmathcap0 {
! 245: /arg1 set
! 246: [(oxReq) arg1 SM_mathcap ] extension pop
! 247: } def
! 248: /oxmathcap {
! 249: /arg1 set
! 250: [/in-oxmathcap /mypeer /mmm] pushVariables
! 251: [ /mypeer arg1 def
! 252: mypeer oxmathcap0
! 253: mypeer oxpopcmo /mmm set
! 254: mypeer 10 mmm put %% set math cap.
! 255: ] pop
! 256: popVariables
! 257: } def
! 258: /oxsetmathcap {
! 259: /arg1 set
! 260: [/in-oxsetmathcap /mypeer /mymathcap] pushVariables
! 261: [
! 262: /mypeer arg1 def
! 263: /mymathcap [(cmoMathCap)] extension (array) dc def
! 264: [(oxReq)
! 265: mypeer SM_setMathCap
! 266: mymathcap
! 267: ] extension pop
! 268: ] pop
! 269: popVariables
! 270: } def
! 271: /oxsetmathcap.old {
! 272: /arg1 set
! 273: [(oxReq)
! 274: arg1 SM_setMathCap
! 275: [(mathcap-object)
! 276: [[199901160 (sm1)]
! 277: [2130706434 , 1 , 2 , 4 , 17 , 19 , 20 , 22 , 23 , 24 , 25 , 26 , 30 ]
! 278: %% mathcap for sm1.
! 279: %% [1 2 3 4 5] %% for test. cf. cmoCheckMathCap, Sm1_mathcap()
! 280: ]
! 281: ] %% Never write a broken data here.
! 282: ] extension pop
! 283: } def
! 284: /oxpopcmo1 { %% ask of the transmission.
! 285: /arg1 set
! 286: [(oxReq) arg1 SM_popCMO ] extension pop
! 287: } def
! 288: /oxpopcmo2 { %% wait the data.
! 289: /arg1 set
! 290: [(oxGet) arg1] extension
! 291: } def
! 292:
! 293:
! 294: /oxpopstring {
! 295: /arg1 set
! 296: [(oxReq) arg1 SM_popString ] extension pop
! 297: [(oxGet) arg1] extension
! 298: } def
! 299:
! 300: /oxrpc {
! 301: /arg1 set
! 302: /arg2 set
! 303: [/ans /ff] pushVariables
! 304: [
! 305: /ff arg2 def
! 306: ox.takelog { ox.log [(oxSerial)] extension ox.mod arg1 put
! 307: ox.log [(oxSerial)] extension 1 add ox.mod (executeString) put
! 308: } { } ifelse
! 309: [(oxReq) ff SM_execute arg1] extension pop
! 310: [(oxReq) ff SM_popCMO] extension pop
! 311: [(oxGet) ff] extension /ans set
! 312: ans etag Etag_error eq {
! 313: (Got an error object.) message
! 314: /arg1 ans def
! 315: }
! 316: { /arg1 ans def
! 317: } ifelse
! 318: ] pop
! 319: popVariables
! 320: arg1
! 321: } def
! 322:
! 323: /oxexecutestring { oxsubmit } def
! 324: /oxsubmit {
! 325: /arg1 set
! 326: /arg2 set
! 327: ox.takelog { ox.log [(oxSerial)] extension ox.mod arg1 put
! 328: ox.log [(oxSerial)] extension 1 add ox.mod (executeString) put
! 329: } { } ifelse
! 330: [(oxReq) arg2 SM_execute arg1] extension pop
! 331: } def
! 332:
! 333: /oxexec {
! 334: /arg1 set
! 335: /arg2 set
! 336: ox.takelog { ox.log [(oxSerial)] extension ox.mod arg1 put
! 337: ox.log [(oxSerial)] extension 1 add ox.mod (executeFunction) put
! 338: } { } ifelse
! 339: [(oxReq) arg2 SM_executeFunction arg1] extension pop
! 340: } def
! 341: /oxsubmit2 {
! 342: oxexec
! 343: } def
! 344:
! 345: /oxpops {
! 346: /arg1 set
! 347: /arg2 set
! 348: [(oxReq) arg2 SM_pops arg1] extension pop
! 349: } def
! 350:
! 351: /oxsetname {
! 352: /arg1 set
! 353: /arg2 set
! 354: [(oxReq) arg2 SM_setName arg1] extension pop
! 355: } def
! 356:
! 357: /oxevalname {
! 358: /arg1 set
! 359: /arg2 set
! 360: [(oxReq) arg2 SM_evalName arg1] extension pop
! 361: } def
! 362:
! 363:
! 364: /oxreset {
! 365: /arg1 set
! 366: [(oxReq) arg1 SM_control_reset_connection] extension pop
! 367: %% [(oxGetFromControl) arg1 ] extension pop
! 368: [(oxGet) arg1] extension message
! 369: } def
! 370:
! 371: /oxisData {
! 372: /arg1 set
! 373: [/pp /ff] pushVariables
! 374: [
! 375: /ff arg1 def
! 376: [(oxMultiSelect) [ff] 10] extension /pp set
! 377: pp message
! 378: pp 0 get 1 eq {
! 379: pp 1 get 0 get 1 eq { %% data is in the data stream.
! 380: /arg1 [(oxGet) ff] extension def
! 381: } {/arg1 (no data) def } ifelse
! 382: }
! 383: { /arg1 (no data) def }
! 384: ifelse
! 385: ] pop
! 386: popVariables
! 387: arg1
! 388: } def
! 389:
! 390: /oxget {
! 391: oxisData
! 392: } def
! 393:
! 394:
! 395: /oxshutdown {
! 396: /arg1 set
! 397: [(fp2fclose) arg1 1 get] extension
! 398: [(oxReq) arg1 SM_control_kill] extension
! 399: arg1 0 (closed) put
! 400: } def
! 401:
! 402: /oxgenportfile {
! 403: [(oxGenPortFile)] extension
! 404: }def
! 405: /oxremoveportfile {
! 406: [(oxRemovePortFile)] extension
! 407: }def
! 408:
! 409: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
! 410: /enginescmd
! 411: $ /computesp {
! 412: /arg1 set
! 413: [arg1 myid] arg1 message
! 414: } def
! 415: $
! 416: def
! 417:
! 418:
! 419: /genPairs {
! 420: /arg1 set
! 421: [/n /i /j] pushVariables
! 422: [
! 423: /n arg1 def
! 424: /genPairs.list [ ] def
! 425: /genPairs.i 0 def
! 426: 0 1 n 1 sub {
! 427: /i set
! 428: i 1 add 1 n 1 sub {
! 429: /j set
! 430: genPairs.list [i j] append /genPairs.list set
! 431: } for
! 432: } for
! 433: /genPairs.n genPairs.list length def
! 434: ] pop
! 435: popVariables
! 436: } def
! 437:
! 438: /getPair {
! 439: [/i ] pushVariables
! 440: [
! 441: genPairs.i genPairs.n lt {
! 442: genPairs.list genPairs.i get /ans set
! 443: genPairs.i 1 add /genPairs.i set
! 444: }
! 445: { [-1 -1] /ans set} ifelse
! 446: /arg1 ans def
! 447: ] pop
! 448: popVariables
! 449: arg1
! 450: } def
! 451:
! 452: /sumUp {
! 453: /arg1 set
! 454: [/ans /v /i /n] pushVariables
! 455: [
! 456: /v arg1 def
! 457: /n v length def
! 458: /ans 0 def
! 459: 0 1 n 1 sub {
! 460: /i set
! 461: ans v i get add /ans set
! 462: } for
! 463: /arg1 ans def
! 464: ] pop
! 465: popVariables
! 466: arg1
! 467: } def
! 468:
! 469:
! 470: /dist {
! 471: /dist.debug 0 def
! 472: /result [ ] def
! 473: enginesList {oxconnect} map /engines set
! 474: /enginesN engines length def
! 475: % broadcast the program.
! 476: (ox-1.sm1) pushfile /enginescmd set %% read a file.
! 477: [(parse) enginescmd] extension
! 478: engines {enginescmd oxsubmit} map
! 479: engines { (slave-start) oxsubmit} map %% initialize slave codes.
! 480: %% send pid.
! 481: 0 1 enginesN 1 sub {
! 482: /i set
! 483: engines i get i oxsendcmo
! 484: engines i get (/myid set) oxsubmit
! 485: } for
! 486:
! 487: master-start %% initialize master codes
! 488: %% gbsize genPairs %% obsolete
! 489: /gbsize ans length def
! 490: ans makePairs /genPairs.list set
! 491: /genPairs.i 0 def /genPairs.n genPairs.list length def
! 492:
! 493:
! 494: /exhausted 0 def
! 495: % clear the busy flag.
! 496: /busy [1 1 enginesN { pop 0 } for ] def
! 497: (date) system-csh
! 498: {{
! 499: exhausted 0 eq {
! 500: 0 1 enginesN 1 sub {
! 501: /i set
! 502: busy i get 0 eq {
! 503: getPair /p set
! 504: p 0 get -1 eq {/exhausted 1 def exit} { } ifelse
! 505: busy i 1 put
! 506: engines i get p oxsendcmo
! 507: engines i get ( computesp ) oxsubmit
! 508: engines i get oxpopcmo1
! 509: } { } ifelse
! 510: } for
! 511: } { } ifelse
! 512: dist.debug { (busy=) messagen busy message } { } ifelse
! 513: busy sumUp 0 eq { result message exit error } { } ifelse
! 514: [(oxMultiSelect) engines -1] extension /status set
! 515: /datastatus status 1 get def
! 516: dist.debug { (datastatus=) messagen datastatus message } { } ifelse
! 517: 0 1 enginesN 1 sub {
! 518: /i set
! 519: datastatus i get 1 eq {
! 520: engines i get oxpopcmo2 /ans set
! 521: busy i 0 put
! 522: result ans append /result set
! 523: } { } ifelse
! 524: } for
! 525: } loop } timer
! 526: (date) system-csh
! 527: (result is in result) message
! 528: (Number of s-pairs checked is ) messagen result length message
! 529: } def
! 530:
! 531: ox.verbose {
! 532: (dist for experiments for distributed computing. cf. startengines) message
! 533: } { } ifelse
! 534:
! 535: /oxIsServerReady {
! 536: /arg1 set
! 537: [/in-isServerReady /sdata /ans] pushVariables
! 538: [
! 539: /sdata arg1 def
! 540: /ans 0 def
! 541: sdata isArray {
! 542: sdata length 1 gt {
! 543: sdata 0 get (client) eq { /ans 1 def } { } ifelse
! 544: } { } ifelse
! 545: } { } ifelse
! 546: /arg1 ans def
! 547: ] pop
! 548: popVariables
! 549: arg1
! 550: } def
! 551:
! 552:
! 553: %%%%%%%%%%%%%%% tests
! 554: ox.verbose {
! 555: (test10 : test to read and write ox-data and ox-command to a file) message
! 556: } { } ifelse
! 557:
! 558: /test10 {
! 559: [(oxCreateClientFile) (afo) (w)] extension /ccc set
! 560: [(oxWatch) ccc] extension
! 561: ccc (x-1). oxsendcmo
! 562: [(oxReq) ccc SM_executeStringByLocalParser
! 563: ( dup add message )] extension pop
! 564: ccc (quit) oxsendcmo
! 565:
! 566: [(oxCloseClient) ccc] extension
! 567: } def
! 568:
! 569: /test11 {
! 570: [(oxCreateClientFile) (afo) (r)] extension /ccc set
! 571: [(oxGet) ccc] extension ::
! 572: [(oxGet) ccc] extension ::
! 573: } def
! 574:
! 575: ox.verbose {
! 576: (test12 : ccc is the client. ff poly in Q<x,y,z,dx,dy,dz> ) message
! 577: } { } ifelse
! 578: /test12 {
! 579: [(localhost) 1300 1200] oxconnect /ccc set
! 580: [(x,y,z) ring_of_differential_operators ( ) elimination_order 0] define_ring
! 581: (x+y). /ff set
! 582: /eee (hello) (error) dc def
! 583: /eee0 eee (error) dc def
! 584: (eee is the CMO_ERROR2 object [CMO_ERROR2 hello], eee0 is the CMO_ERROR object) message
! 585: } def
! 586:
! 587: /sm1connectr {
! 588: [/in-sm1connectr /pass /peer /data /control ] pushVariables
! 589: [
! 590: /pass [(oxGenPass)] extension def
! 591: /peer [(oxGetPort) (localhost)] extension def
! 592: /data peer 1 get toString def
! 593: /control peer 3 get toString def
! 594: peer message
! 595: [oxpath.oxlog.xterm oxpath.ox ( -reverse -ox ) oxpath.oxsm1
! 596: ( -data ) data ( -control ) control ( -pass ) pass
! 597: oxpath.null
! 598: ( &)] cat system-csh
! 599: [(oxCreateClient2) peer 0 pass] extension /ox.ccc set
! 600: %% 0 means connect from only localhost.
! 601: (The server is binded to the variable ox.ccc) message
! 602: ox.ccc.init
! 603: ] pop
! 604: popVariables
! 605: } def
! 606:
! 607: /sm1connectr-ssh {
! 608: /arg1 set
! 609: [/in-sm1connectr /pass /peer /data /control /name /machine
! 610: /your-peer /comm
! 611: ] pushVariables
! 612: [
! 613: /machine arg1 0 get def
! 614: /name arg1 1 get def
! 615:
! 616: /pass [(oxGenPass)] extension def
! 617: /peer [(oxGetPort) myhostname-ssh] extension def
! 618: /data peer 1 get toString def
! 619: /control peer 3 get toString def
! 620: peer message
! 621: [(ssh -f ) machine ( -l ) name ( ")
! 622: oxpath.oxlog.xterm-ssh oxpath.ox-ssh ( -reverse -ox ) oxpath.oxsm1-ssh
! 623: ( -host ) myhostname-ssh
! 624: ( -data ) data ( -control ) control ( -pass ) pass
! 625: oxpath.null
! 626: ( ")
! 627: ] cat /comm set
! 628: (Executing the command : ) messagen comm message message
! 629: comm system
! 630: (sleep 5) system-csh
! 631: [(oxCreateClient2) peer 1 pass] extension /your-peer set
! 632: /arg1 your-peer def
! 633: ] pop
! 634: popVariables
! 635: arg1
! 636: } def
! 637: [(sm1connectr-ssh)
! 638: [([hostname login-name] sm1connectr-ssh client)
! 639: (Starting oxpath.oxsm1-ssh by the launcher oxpath.ox-ssh on the "hostname".)
! 640: (cf. oxNoX )
! 641: (Set the following varialbes to appropriate values:)
! 642: (oxpath.oxlog.xterm-ssh oxpath.oxsm1-ssh oxpath.ox-ssh myhostname-ssh )
! 643: $Example 1: $
! 644: $ *** Path names on the remote machine dc1.math.kobe-u.ac.jp $
! 645: $ /oxpath.oxlog.xterm-ssh (/home/taka/OpenXM/bin/oxlog /usr/X11R6/bin/xterm -icon -e ) def $
! 646: $ /oxpath.oxsm1-ssh (/home/taka/OpenXM/bin/ox_sm1) def $
! 647: $ /oxpath.ox-ssh (/home/taka/OpenXM/bin/ox) def $
! 648: $ *** The machine name on which you are running sm1. $
! 649: $ /myhostname-ssh (yama.math.kobe-u.ac.jp) def $
! 650: $ [(dc1.math.kobe-u.ac.jp) (taka)] sm1connectr-ssh /ox.ccc set $
! 651: $Example 2: $
! 652: $ *** Path names on the remote machine dc2.math.kobe-u.ac.jp $
! 653: $ *** We will not use X11 debug windows. $
! 654: $ oxNoX $
! 655: $ /oxpath.oxlog.xterm-ssh (/home/taka/OpenXM/bin/oxlog ) def $
! 656: $ /oxpath.oxsm1-ssh (/home/taka/OpenXM/bin/ox_sm1) def $
! 657: $ /oxpath.ox-ssh (/home/taka/OpenXM/bin/ox) def $
! 658: $ *** the machine name on which you are running sm1. $
! 659: $ /myhostname-ssh (dc1.math.kobe-u.ac.jp) def $
! 660: $ [(dc2.math.kobe-u.ac.jp) (taka)] sm1connectr-ssh /ox.ccc set $
! 661: ]] putUsages
! 662:
! 663: /addSlash {
! 664: /arg1 set
! 665: [/in-addSlash /ss /aaa /ans] pushVariables
! 666: [
! 667: /ss arg1 def
! 668: ss (array) dc /aaa set
! 669: aaa length 0 eq {
! 670: /ans (/) def
! 671: }{
! 672: aaa aaa length 1 sub get 47 eq %% The last equals / ?
! 673: {
! 674: /ans ss def
! 675: }{
! 676: /ans [ss (/)] cat def
! 677: } ifelse
! 678: } ifelse
! 679: /arg1 ans def
! 680: ] pop
! 681: arg1
! 682: } def
! 683:
! 684: /getPathNameSm1 {
! 685: /arg1 set
! 686: [/in-getPathNameSm1 /fname /fullname /tname] pushVariables
! 687: [
! 688: /fname arg1 0 get def
! 689: %% If fullname is given, use it.
! 690: fname (array) dc 0 get
! 691: (/) (array) dc 0 get eq
! 692: { /fullname fname def
! 693: /getPathNameSm1.LLL goto
! 694: } { } ifelse
! 695:
! 696: %% Else first try to find it in LOAD_SM1_PATH
! 697: [(getenv) (LOAD_SM1_PATH)] extension /tname set
! 698: tname isString
! 699: {
! 700: tname addSlash /tname set
! 701: [(stat) [tname fname] cat] extension
! 702: 0 get isInteger %% The file was found.
! 703: { /fullname [tname fname] cat def
! 704: /getPathNameSm1.LLL goto
! 705: } { } ifelse
! 706: } { } ifelse
! 707:
! 708: %% Else first try to find it in OpenXM_HOME
! 709: [(getenv) (OpenXM_HOME)] extension /tname set
! 710: tname isString
! 711: {
! 712: tname addSlash /tname set
! 713: [tname (lib/sm1/)] cat /tname set
! 714: [(stat) [tname fname] cat] extension
! 715: 0 get isInteger %% The file was found.
! 716: { /fullname [tname fname] cat def
! 717: /getPathNameSm1.LLL goto
! 718: } { } ifelse
! 719: } { } ifelse
! 720:
! 721: %% Else try to find it in /usr/local/lib/sm1
! 722: [(stat) [(/usr/local/lib/sm1/) fname] cat] extension
! 723: 0 get isInteger %% The file was found.
! 724: { /fullname [(/usr/local/lib/sm1/) fname] cat def
! 725: /getPathNameSm1.LLL goto
! 726: } { } ifelse
! 727:
! 728: %% Otherwise error.
! 729: [(getPathNameSm1: The file ) fname
! 730: ( could not be found )
! 731: (neigher in LOAD\_SM1\_PATH=)
! 732: [(getenv) (LOAD_SM1_PATH)] extension
! 733: ( nor in OpenXM\_HOME/lib/sm1=)
! 734: [(getenv) (OpenXM_HOME)] extension
! 735: (/lib/sm1)
! 736: ( nor in /usr/local/lib/sm1)
! 737: ] cat /getPathNameSm1.errorMessage set
! 738: getPathNameSm1.errorMessage message
! 739: ] pop popVariables getPathNameSm1.errorMessage error
! 740:
! 741: /getPathNameSm1.LLL
! 742: /arg1 fullname def
! 743: ] pop
! 744: popVariables
! 745: arg1
! 746: } def
! 747: [(getPathNameSm1)
! 748: [([fname] getPathNameSm1 fullname)
! 749: (string fname, fullname)
! 750: (This command searches the fname in LOAD_SM1_PATH, )
! 751: (OpenXM_HOME/lib/sm1, and /usr/local/lib/sm1)
! 752: (It returns the fullname.)
! 753: ]] putUsages
! 754:
! 755: /getPathNameAsir {
! 756: /arg1 set
! 757: [/in-getPathNameAsir /fname /fullname /tname] pushVariables
! 758: [
! 759: /fname arg1 0 get def
! 760: %% If fullname is given, use it.
! 761: fname (array) dc 0 get
! 762: (/) (array) dc 0 get eq
! 763: { /fullname fname def
! 764: /getPathNameAsir.LLL goto
! 765: } { } ifelse
! 766:
! 767: %% Else try to find it in ASIR_LIBDIR
! 768: [(getenv) (ASIR_LIBDIR)] extension /tname set
! 769: tname isString
! 770: {
! 771: [(stat) [tname (/) fname] cat] extension
! 772: 0 get isInteger %% The file was found.
! 773: { /fullname [tname (/) fname] cat def
! 774: /getPathNameAsir.LLL goto
! 775: } { } ifelse
! 776:
! 777: } { } ifelse
! 778:
! 779: %% Else try to find it in /usr/local/lib/asir
! 780: [(stat) [(/usr/local/lib/asir/) fname] cat] extension
! 781: 0 get isInteger %% The file was found.
! 782: { /fullname [(/usr/local/lib/asir/) fname] cat def
! 783: /getPathNameAsir.LLL goto
! 784: } { } ifelse
! 785:
! 786: %% Otherwise error.
! 787: [ (getPathNameAsir: The file )
! 788: fname (ox_asir) eq
! 789: {(ox\_asir)} { fname }ifelse
! 790: ( could not be found )
! 791: (neigher in /usr/local/lib/asir nor in ASIR\_LIBDIR. )
! 792: ] cat /getPathNameAsir.errorMessage set
! 793: getPathNameAsir.errorMessage message
! 794: ] pop popVariables getPathNameAsir.errorMessage error
! 795:
! 796: /getPathNameAsir.LLL
! 797: /arg1 fullname def
! 798: ] pop
! 799: popVariables
! 800: arg1
! 801: } def
! 802: [(getPathNameAsir)
! 803: [([fname] getPathNameAsir fullname)
! 804: (string fname, fullname)
! 805: (This command searches the fname in /usr/local/lib/asir and ASIR_LIBDIR)
! 806: (and returns the fullname.)
! 807: ]] putUsages
! 808:
! 809:
! 810: /ox_launch_nox {
! 811: /@@@.ox_launch_nox 1 def
! 812: ox_launch_aux
! 813: } def
! 814: /ox_launch {
! 815: /@@@.ox_launch_nox 0 def
! 816: ox_launch_aux
! 817: } def
! 818:
! 819: /ox_launch_aux {
! 820: /arg1 set
! 821: [/in-launch_nox /pass /peer /data /control /name /machine
! 822: /your-peer /comm /remoteOpenXMbin /remoteServer /myhost
! 823: /argNumber /aaa
! 824: ] pushVariables
! 825: [
! 826: /aaa arg1 def
! 827: /argNumber aaa length def
! 828: /machine aaa 0 get def
! 829: machine (localhost) eq argNumber 5 lt and {
! 830: aaa 1 get ox_launch_localhost /your-peer set
! 831: /LLL.end goto
! 832: } {
! 833: /remoteOpenXMbin aaa 1 get def
! 834: /remoteServer aaa 2 get def
! 835: /name aaa 3 get def
! 836: /myhost aaa 4 get def
! 837: } ifelse
! 838:
! 839: /pass [(oxGenPass)] extension def
! 840: /peer [(oxGetPort) myhost] extension def
! 841: /data peer 1 get toString def
! 842: /control peer 3 get toString def
! 843: peer message
! 844: [(ssh -f ) machine ( -l ) name ( ")
! 845:
! 846: @@@.ox_launch_nox {
! 847: } {
! 848: remoteOpenXMbin(/oxlog )
! 849: ( /usr/X11R6/bin/xterm -icon -e )
! 850: } ifelse
! 851:
! 852: ( ) remoteOpenXMbin (/ox )
! 853: ( -reverse -ox ) remoteServer
! 854: ( -host ) myhost
! 855: ( -data ) data ( -control ) control ( -pass ) pass
! 856: oxpath.null
! 857: ( ")
! 858: ] cat /comm set
! 859: (Executing the command : ) messagen comm message message
! 860: comm system
! 861: (sleep 5) system-csh
! 862: [(oxCreateClient2) peer 1 pass] extension /your-peer set
! 863: /LLL.end
! 864: /arg1 your-peer def
! 865: ] pop
! 866: popVariables
! 867: arg1
! 868: } def
! 869:
! 870: [(ox_launch)
! 871: [( [remote remote-OpenXM-bin remote-ox-server remote-login-name myhostname] )
! 872: ( ox_launch client )
! 873: $or $
! 874: $ [(localhost) ox-server-name] ox_launch client$
! 875: (Example 1: )
! 876: $ [(tau.math.kobe-u.ac.jp) (/home/taka/OpenXM/bin) $
! 877: $ (/home/taka/OpenXM/src/ox_math/ox_math) (taka) (dc4.math.kobe-u.ac.jp) $
! 878: $ ] ox_launch /@@@.oxmath set $
! 879: ]] putUsages
! 880:
! 881: [(ox_launch_nox)
! 882: [( [remote remote-OpenXM-bin remote-ox-server remote-login-name myhostname] )
! 883: ( ox_launch_nox client )
! 884: (Example 1: )
! 885: $ [(tau.math.kobe-u.ac.jp) (/home/taka/OpenXM/bin) $
! 886: $ (/home/taka/OpenXM/src/ox_math/ox_math) (taka) (dc4.math.kobe-u.ac.jp) $
! 887: $ ] ox_launch_nox /@@@.oxmath set $
! 888: ]] putUsages
! 889:
! 890: /system-csh {
! 891: /arg1 set
! 892: [/in-system-csh /com /com2] pushVariables
! 893: [
! 894: /com arg1 def
! 895: [(/bin/csh -c ") com (")] cat
! 896: /com2 set
! 897: %%com2 message
! 898: com2 system
! 899: ] pop
! 900: popVariables
! 901: } def
! 902:
! 903: /ox_launch_localhost {
! 904: /arg1 set
! 905: [/in-ox_launch_localhost /pass /peer /data /control /oxserver
! 906: /my-peer] pushVariables
! 907: [
! 908: /oxserver arg1 def
! 909: /pass [(oxGenPass)] extension def
! 910: /peer [(oxGetPort) (localhost)] extension def
! 911: /data peer 1 get toString def
! 912: /control peer 3 get toString def
! 913: peer message
! 914: [oxpath.oxlog.xterm oxpath.ox ( -reverse -ox ) oxserver
! 915: ( -data ) data ( -control ) control ( -pass ) pass
! 916: oxpath.null
! 917: ( &)] cat system-csh
! 918: [(oxCreateClient2) peer 0 pass] extension /my-peer set
! 919: %% 0 means connect from only localhost.
! 920: (The server is binded to the variable ox.ccc) message
! 921: /arg1 my-peer def
! 922: ] pop
! 923: popVariables
! 924: arg1
! 925: } def
! 926:
! 927: %% Test code for oxCreateControl_RFC_101
! 928: /sm1StartControl101 {
! 929: [/in-sm1connectr /pass /peer /data /control ] pushVariables
! 930: [
! 931: /pass [(oxGenPass)] extension def
! 932: /peer [(oxGetPort1) (localhost)] extension def
! 933: /data peer 1 get toString def
! 934: peer message
! 935: [(/home/nobuki/OpenXM/src/oxc/oxc)
! 936: ( -c ) pass ( -h ) (localhost) ( -p ) data ( -x )
! 937: oxpath.null
! 938: ( &)] cat system-csh
! 939:
! 940: [(oxCreateControl_RFC_101) peer 0 pass] extension /ox.ccc set
! 941: %% 0 means connect from only localhost.
! 942: (The server is binded to the variable ox.ccc) message
! 943: ox.ccc
! 944: ] pop
! 945: popVariables
! 946: } def
! 947:
! 948: /sm1StartEngine101 {
! 949: [/in-sm1StartEngine101 /peer /data /control /engineID] pushVariables
! 950: [
! 951: /peer [(oxGetPort1) (localhost)] extension def
! 952: /data peer 1 get def
! 953:
! 954: ox.ccc data oxpushcmo
! 955: ox.ccc (/home/nobuki/OpenXM/bin/ox_sm1) oxpushcmo
! 956: [(oxPushCMD) ox.ccc SM_control_spawn_server] extension
! 957: ox.ccc oxpopcmo /engineID set
! 958: [(oxCreateEngine_RFC_101) peer 0 (Empty) engineID] extension
! 959: /ox.ddd set
! 960: (The engine is binded to the variables ox.ddd) message
! 961: ] pop
! 962: popVariables
! 963: arg1
! 964: } def
! 965:
! 966: /OxWorkDirCreated false def
! 967: /oxWorkDir {
! 968: [/in-oxWorkDir /workHome /work] pushVariables
! 969: [
! 970: [(getenv) (OpenXM_tmp)] extension tag 0 eq {
! 971: /workHome [
! 972: [(getenv) (HOME)] extension
! 973: (/OpenXM_tmp)
! 974: ] cat def
! 975: }{
! 976: /workHome
! 977: [(getenv) (OpenXM_tmp)] extension
! 978: def
! 979: }ifelse
! 980: /work [workHome (/) [(getpid)] extension toString] cat def
! 981:
! 982: OxWorkDirCreated not {
! 983: [(stat) workHome] extension 0 get tag 0 eq {
! 984: [(Working directory ) workHome ( will be created.)] cat
! 985: message
! 986: [(mkdir ) workHome] cat system
! 987: }{
! 988: } ifelse
! 989:
! 990: [(stat) work] extension 0 get tag 0 eq {
! 991: [(Working directory ) work ( will be created.)] cat
! 992: message
! 993: [(mkdir ) work] cat system
! 994: }{
! 995: } ifelse
! 996: /OxWorkDirCreated true def
! 997: }{ } ifelse
! 998: /arg1 work def
! 999: ] pop
! 1000: popVariables
! 1001: arg1
! 1002: } def
! 1003: [(oxWorkDir)
! 1004: [(oxWorkDir returns a name of working directory for OpenXM processes.)
! 1005: (If the working direcotry does not exist, it creates ~/OpenXM_tmp/[pid].)
! 1006: (The name can be changed by setting a value to the environmental variable)
! 1007: (OpenXM_tmp. cf. oxNewFileName)
! 1008: ]
! 1009: ] putUsages
! 1010:
! 1011: /OxFileName 0 def
! 1012: /oxNewFileName {
! 1013: [/in-oxNewFileName /name] pushVariables
! 1014: [
! 1015: /name [(work) OxFileName toString] cat def
! 1016: /OxFileName OxFileName 1 add def
! 1017: /arg1 name def
! 1018: ] pop
! 1019: popVariables
! 1020: arg1
! 1021: } def
! 1022: [(oxNewFileName)
! 1023: [(oxNewFileName returns a unique file name for a working file.)
! 1024: (cf. oxWorkDir)
! 1025: ]
! 1026: ] putUsages
! 1027:
! 1028: /ox_get_os {
! 1029: [/in-ox_get_ox /os1 /os2] pushVariables
! 1030: [
! 1031: /os1 [(ostype)] extension 0 get def
! 1032: os1 (windows) eq {
! 1033: [(getenv) (WINDOWID)] extension tag 0 eq not {
! 1034: %% expect cygwin X
! 1035: /os2 (xcygwin) def
! 1036: }{
! 1037: [(getenv) (OSTYPE)] extension tag 0 eq not
! 1038: [(getenv) (MACHTYPE)] extension tag 0 eq not or
! 1039: [(getenv) (PWD)] extension tag 0 eq not or
! 1040: {
! 1041: %% expect cygwin environment
! 1042: /os2 (cygwin) def
! 1043: }{
! 1044: %% expect the native windows environment
! 1045: /os2 (native) def
! 1046: } ifelse
! 1047: } ifelse
! 1048: }{
! 1049: /os2 null def
! 1050: } ifelse
! 1051: /arg1 [os1 os2] def
! 1052: ] pop
! 1053: popVariables
! 1054: arg1
! 1055: } def
! 1056:
! 1057: /ox.ostype ox_get_os def
! 1058:
! 1059: /ox_backslash_to_slash {
! 1060: /arg1 set
! 1061: [/in-ox_backslash_to_slash /sss ] pushVariables
! 1062: [
! 1063: /sss arg1 def
! 1064: sss (array) dc /sss set
! 1065: sss { dup 92 eq { pop 47 } { } ifelse } map
! 1066: { (string) dc } map cat /arg1 set
! 1067: ] pop
! 1068: popVariables
! 1069: arg1
! 1070: } def
! 1071: /ox_slash_to_backslash {
! 1072: /arg1 set
! 1073: [/in-ox_slash_to_backslash /sss ] pushVariables
! 1074: [
! 1075: /sss arg1 def
! 1076: sss (array) dc /sss set
! 1077: sss { dup 47 eq { pop 92 } { } ifelse } map
! 1078: { (string) dc } map cat /arg1 set
! 1079: ] pop
! 1080: popVariables
! 1081: arg1
! 1082: } def
! 1083:
! 1084: /oxIsInterruptable {
! 1085: /arg1 set % Client Object
! 1086: [/in-ox_get_server_name /mcap /ans /sname] pushVariables
! 1087: [
! 1088: /mcap arg1 def
! 1089: /ans 0 def
! 1090: mcap tag 6 eq {
! 1091: mcap 10 get tag 6 eq {
! 1092: mcap 10 get 1 get 0 get 1 get /sname set
! 1093: }{ /sname ( ) def } ifelse
! 1094: }{
! 1095: /sname ( ) def
! 1096: } ifelse
! 1097: (ox_sm1) sname isSubstr -1 eq {
! 1098: } { /ans 1 def } ifelse
! 1099: (ox_asir) sname isSubstr -1 eq {
! 1100: } { /ans 1 def } ifelse
! 1101: /arg1 ans def
! 1102: ] pop
! 1103: popVariables
! 1104: arg1
! 1105: } def
! 1106:
! 1107: /oxresetAll {
! 1108: [(oxGetClientList)] extension
! 1109: { dup oxIsInterruptable { oxreset } { pop } ifelse } map
! 1110: } def
! 1111:
! 1112: /oxrpc2 {
! 1113: /arg2 set
! 1114: /arg1 set
! 1115: [/in-oxrpc2 /pid /n /comm /i] pushVariables
! 1116: [
! 1117: /pid arg1 def
! 1118: /comm arg2 def
! 1119: /n comm length def
! 1120: n 1 sub -1 1 {
! 1121: /i set
! 1122: pid comm i get oxsendcmo
! 1123: } for
! 1124: pid n 1 sub oxsendcmo
! 1125: pid comm 0 get oxexec
! 1126: ] pop
! 1127: popVariables
! 1128: } def
! 1129:
! 1130: [(oxrpc2)
! 1131: [(Remote procedure call by using oxexec)
! 1132: (client [function-name arg1 arg2 ...] oxrpc2 )
! 1133: (cf. ox-cmo-rpc in Risa/Asir)
! 1134: (Example: )
! 1135: $ (oxasir.sm1) run (x^2-1). fctr $
! 1136: (oxasir.ccc [(igcd) (6).. (10)..] oxrpc2)
! 1137: (oxasir.ccc oxpopcmo :: )
! 1138: ]
! 1139: ] putUsages
! 1140:
! 1141:
! 1142: [(ostype)] extension 0 get
! 1143: (windows) eq {
! 1144: (ox-win.sm1.loaded) boundp {
! 1145: }{
! 1146: [(parse) (ox-win.sm1) pushfile] extension
! 1147: } ifelse
! 1148: }{
! 1149: initializePathNamesForOx %% This should be
! 1150: } ifelse
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>