4

I would to ask you if there is a way to put a MAGMA command that stop a function in a script if the occurring time is greater than a certain prefixed time $T\geq 0$ (for example $T=15 $ minutes ). After this stop, I would that the script goes on to compute.

I looked at the website MAGMA but it seems there isn’t anything that could do this.

Any help will be appreciate.

Federico Fallucca
  • 8,593
  • 1
  • 9
  • 20

1 Answers1

2

Option 1. Magma's Alarm(s) function (described here).
This will quit Magma after s seconds. So, if you are fine with closing Magma completely, you could insert Alarm(15 * 60); at the appropriate location.

Option 2. For whatever reason, you may not want to completely quit Magma and maybe move on to the next lines. This seems equivalent to wanting to cancel a command midway, i.e., pressing Ctrl-C. However, note that this may not immediately terminate the command, as Magma tries to tries to interrupt at a "convenient point" (source).

Here is one outline how you can simulate the Ctrl-C, using Sage: Note that Sage has a Magma interface (more details here).

Sage also has an "alarm" function that can time certain processes. (Maybe you can Google this and find a more canonical reference, but here is what I have.)

An example of how you could now use it is as follows:
Suppose your Magma code is

A := 1;
DoSomethingDifficult(A);
DoEasyThings(A);

You would convert it to the following Sage code:

magma.eval("A := 1;")
alarm(15 * 60)
try:
    magma.eval("DoSomethingDifficult(A);")
except KeyboardInterrupt:
    print("Did not work! :(")
cancel_alarm()
magma.eval("DoEasyThings(A);")

Note: This seems like a quite hack-y workaround, and I don't know the internal workings well enough to assure that "nothing weird will go wrong".