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