[BACK]Return to ox.sm1 CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / Doc

Annotation of OpenXM/src/kan96xx/Doc/ox.sm1, Revision 1.18

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>