• George James

    George James - 2007-08-16

    %GTM-E-IMAGENAME, The executing module name should be mumps instead of gtm

    Short of recompiling from the source, is there any way that I can have GT.M use a different name?

    • Narayanan S Rajamani

      Currently NO.


      • K.S. Bhaskar

        K.S. Bhaskar - 2007-08-17

        Actually, since GT.M integrates well with C, you can create a C main{} program that does a call-in to GT.M MUMPS code.  Then, your program can be called anything you want it to be called.  If you want to get into direct mode via a different name, just create a one line GT.M function "F  B" and call it from C.

        -- Bhaskar

        • Bob Isch

          Bob Isch - 2007-08-17

          I'm guessing that what you really want is something like:

            $ alias gtm='/var/gtm/mumps'


            $ alias gtm='/var/gtm/mumps -run dirmode'

          where dirmode.m contains something like:

            dirmode ; my direct mode stuff
                    set $zprompt="gtm>"                     ; (or whatever you like) - optional
                    if $zcmdline'="" xecute $zcmdline halt  ; optional - allows handy things like: $ gtm 'zwr ^foo("someindex",*)' | grep something
                    for  break                              ; the loop is actually optional too - without it 'zc' at the top level will exit

          Obviously you can add options, debugging stuff, etc. as you see fit.

          Hope that helps,

    • George James

      George James - 2007-11-18

      When I have a lot of GT.M processing running on a system, it's not easy to tell which are which, because they all have the same process name.

      So, using Bhaskar's suggestion, I've devised a method of giving each process a name of my choosing.  The code below does this by creating a wrapper process that calls GT.M using the call-in interface.  There's a shell script which copies the wrapper to a name of my choosing, dynamically creates a call table, and then invokes the wrapper.  The process then shows up with a distinct name when ps or top is used.  This makes it a lot easier to manage the system as I can then tell which process is which.

      I've provided the code to do this below.

      It's called by issuing the command:

      $gtmrun tag^myRoutine foo

      This runs myRoutine as you would expect, but will create a process called foo instead of mumps.  If no second argument is provided then the name of the routine will be used. So in this example, if there were no second argument, the process would actually be named tag^myRoutine.

      To use this code do the following:

      1) create two directories /whatever/gtmx and /whatever/gtmx/run. 

      2) Place all of the files (gtmrun, gtmrunx.c, direct.m, make) in the directory named gtmx.  make sure that gtmrun and make are executable using chmod +x.

      3) Compile gtmrunx using the gcc compiler.  You can run the script named make to do this (it works for debian etch, your mileage with other distributions may vary).

      4) You can then, for convenience, add the following symbols to your profile:
      $gtmx='/whatever/gtmx/' ; export gtmx
      $gtmrun='$gtmx/gtmrun' ; export gtmrun
      $gtm='$gtmx/gtmrun ^direct gtm"; export gtm
      $gde='$gtmx/gtmrun ^GDE GDE"; export gde

      And here's all the code:

      # Run a GTM routine as a named process
      # Copy the generic gtmrunx wrapper to the appropriate name in the run directory
      # Create a calltable that containing an entry for the routine to be run
      # Create a symbol GTMCI that points to the calltable
      # Invoke the appropriately re-named gtmrunx wrapper

      # If there is a second argument then use that as the name of the process instead of the
      # routine name.

      if [ "$2" = "" ]; then
              cp $gtmx/gtmrunx $gtmx/run/$1
              export GTMCI=$gtmx/run/$1.ci
              echo "gtm :void $1()" >$gtmx/run/$1.ci
              cp $gtmx/gtmrunx $gtmx/run/$2
              export GTMCI=$gtmx/run/$2.ci
              echo "gtm :void $1()" >$gtmx/run/$2.ci

      #include <stdio.h>
      #include <unistd.h>
      #include <stdlib.h>
      #include <termios.h>
      #include "gtmxc_types.h"
      #define BUF_LEN 1024

      struct termios saved_attributes;

      reset_input_mode (void)
              tcsetattr (STDIN_FILENO, TCSANOW, &saved_attributes);

      int main(int argc, char *argv[])
              gtm_char_t      msgbuf[BUF_LEN];
              gtm_status_t    status;

              if (isatty (STDIN_FILENO))
                      tcgetattr (STDIN_FILENO, &saved_attributes);
                      atexit ((void(*)())reset_input_mode);

              status = gtm_init();
              if (status != 0)
                  gtm_zstatus(msgbuf, BUF_LEN);
                  return status;
              status = gtm_ci("gtm");
              if (status != 0)
                  gtm_zstatus(msgbuf, BUF_LEN);
                  fprintf(stderr, "%s\n", msgbuf);
                  return status;
              return 0;

      # Make gtmrunx
      gcc -c gtmrunx.c -I$gtm_dist
      gcc gtmrunx.o -o gtmrunx -L$gtm_dist -Wlgtmshr -Wlc -WR $gtm_dist/libgtmshr.so

      direct  ; Enter direct mode



Log in to post a comment.