Estimated time to completion: $hrs_est hours.
Estimated client disk usage: $client_mb MB
Estimated server disk usage: $server_mb MB
";
show_button("lammps.php?action=submit&tmpfile=$tmpfile", "Submit Batch");
page_tail();
}
function submit_job($app, $batch_id, $info, $cmdline, $i) {
$cmd = "cd ../..; ./bin/create_work --appname $app->name --batch $batch_id --rsc_fpops_est $info->rsc_fpops_est";
if ($cmdline) {
$cmd .= " --command_line \"$cmdline\"";
}
$cmd .= " --wu_name batch_".$batch_id."_".$i;
$cmd .= " $info->structure_file_path";
$cmd .= " $info->command_file_path";
echo "
$cmd\n"; return;
$ret = system($cmd);
if ($ret === FALSE) {
error_page("can't create job");
}
}
function submit_batch($user, $app) {
$tmpfile = get_str('tmpfile');
$x = file_get_contents("$tmpfile");
$info = unserialize($x);
$cmdlines = file($info->cmdline_file_path);
$njobs = count($cmdlines);
$now = time();
$batch_name = time_str($now);
// $batch_id = BoincBatch::insert(
// "(user_id, create_time, njobs, name, app_id) values ($user->id, $now, $njobs, '$batch_name', $app->id)"
// );
$batch_id=99;
$i = 0;
foreach ($cmdlines as $cmdline) {
submit_job($app, $batch_id, $info, $cmdline, $i);
$i++;
}
}
$user = get_logged_in_user();
$user_submit = BoincUserSubmit::lookup_userid($user->id);
if (!$user_submit) error_page("no submit access");
$app = BoincApp::lookup("name='lammps'");
if (!$app) error_page("no lammps app");
if (!$user_submit->submit_all) {
$usa = BoincUserSubmitApp::lookup("user_id=$user->id and app_id=$app->id");
if (!$usa) {
error_page("no submit access");
}
}
$action = get_str('action', true);
switch ($action) {
case '': show_submit_form(); break;
case 'prepare': prepare_batch($user); break;
case 'submit': submit_batch($user, $app); break;
default: error_page("no such action $action");
}
?>