Hi all,
Here is the "makems" Perl script I use to make the Msieve files and
then run the linear algebra using Msieve, starting with the "n.poly"
file in GGNFS.
No guarantees, but should work OK - just read the comments...
Rgds,
--Bob.
#!/usr/bin/perl
#
# Make Msieve NFS format files from GGNFS poly file
# -- Bob Backstrom Oct 2007 --
#
# Run GGNFS with "$SAVEPAIRS=1;" in factLat.pl to
# save rels in gzip format at each cycle.
#
# msieve.dat Write N ddddd to first line then
# append rels with cmd:
# gunzip -c spairs.save.gz >> msieve.dat
#
# or manually:
# cat spairs.dump.i >> msieve.dat
# for all dump files.
#
# msieve.fb N ddddd, R0, R1 (R1 = 1 if m present),
# Y0 -> R0 and Y1 -> R1
# coeffs ci -> Ai 0<= i <= {deg}
#
# worktodo.ini N
#
# ------------------------------------------------
$PREFIX = "n"; # Poly file prefix
$SAVE = "spairs.save.gz"; # Rels save file
$MSIEVE = "msieve -nc -v"; # Msieve NFS, verbose
# ------------------------------------------------
$FILE1 = "$PREFIX.poly"; # Input poly file
$FILE2 = "msieve.dat"; # Output dat file
$FILE3 = "msieve.fb"; # Factor base file
$FILE4 = "worktodo.ini"; # Work to do file
$r[0] = "0";
$r[1] = "0";
# c5: 9000
# c4: -76048988
# ...
$deg = 0;
open(IN, "$FILE1"); # Find poly degree
while($line = <IN>)
{
$line = lc($line);
if($line =~ /^\s*c(\d+)/)
{
if($deg < $1) { $deg = $1 }
}
}
if(!$deg)
{
close(IN);
print "Coeffs \"cn: [-]ddd\" not found in \"$FILE1\"\n";
exit 1;
}
for($i = 0; $i <= $deg; $i++){ $c[$i] = "0"; }
if( -e $FILE2 ) # Check for dat file
{
print "\nFile: \"$FILE2\" already present\n\n";
open(REP, "-");
while(print "Overwrite (y/n): ")
{
$reply = <REP>;
$reply = lc($reply);
if($reply =~ /^\s*n\s*$/)
{
print "\nExit\n\n";
close(IN);
close(REP);
exit 1;
}
elsif($reply =~ /^\s*y\s*$/)
{
print "\nCont...\n";
close(REP);
last;
}
}
}
print "\ndeg: $deg\n";
seek(IN, 0, 0); # rewind input file
open(OUT1, ">$FILE2"); # dat file
open(OUT2, ">$FILE3"); # fb file
open(OUT3, ">$FILE4"); # worktodo file
while($line = <IN>)
{
$line = lc($line); # lower case
if($line =~ /^\s*n\s*:\s*(\d+)/) # n: ddd
{
$n = $1;
}
elsif($line =~ /^\s*m\s*:\s*(\d+)/) # m: ddd
{
$r[0] = "-" . $1; # (no arith, just strings)
$r[1] = 1;
}
elsif($line =~ /^\s*y(\d+)\s*:\s*(-*)(\d+)/)
{
$r[$1] = $2 . $3; # yi: [-]ddd
}
# deg: 5
# c5: 200
# c0: -7
elsif($line =~ /^\s*c(\d+)\s*:\s*(-*)(\d+)/)
{
$c[$1] = $2 . $3; # ci: [-]ddd
}
# rlim: 3000000
# alim: 3000000
elsif($line =~ /^\s*rlim\s*:\s*(\d+)/) # rlim: ddd
{
$frmax = $1;
}
elsif($line =~ /^\s*alim\s*:\s*(\d+)/) # alim: ddd
{
$famax = $1;
}
# lpbr: 28
# lpba: 28
elsif($line =~ /^\s*lpbr\s*:\s*(\d+)/) # lpbr: ddd
{
$srtfbits = $1;
}
elsif($line =~ /^\s*lpba\s*:\s*(\d+)/) # lpba: ddd
{
$satfbits = $1;
}
}
print OUT1 "N $n\n"; # N ddd to dat
print OUT3 "$n\n"; # ddd to worktodo
print OUT2 "N $n\n"; # N ddd to fb
print "N $n\n";
$s = "R0 $r[0]\n" .
"R1 $r[1]\n";
print OUT2 $s; # R0, R1 to fb
print $s;
for($i = 0, $s = ""; $i <= $deg; $i++)
{
$s = $s . "A$i $c[$i]\n";
}
print OUT2 $s; # A0 - A{deg} to fb
print $s;
$s = "FRMAX $frmax\n" .
"FAMAX $famax\n" .
"SRTFBITS $srtfbits\n" .
"SATFBITS $satfbits\n";
print OUT2 $s; # FRMAX etc to fb
print $s;
close(IN);
close(OUT1);
close(OUT2);
close(OUT3);
$cmd = "gunzip -c $SAVE >> $FILE2";
print "==> $cmd\n";
system($cmd); # Append rels to dat
$cmd = "$MSIEVE";
print "==> $cmd\n";
system($cmd); # Run Msieve
# Send 5 BELLS at end of run
use IO::Handle;
STDOUT->autoflush(1);
for($i = 0; $i < 5; $i++){sleep 1;print "\a";}