int test(string appname ="dial_cbnt", string appversion ="0.92") { bool ok = true; XmlParser parser; string tskname = "cbnt"; // For now this cannot be changed string tskinit = tskname + ".kumac"; string tskxml = "task_" + appname + ".xml"; // Create DTD files. DtdRegistry::instance("dataset").write(); DtdRegistry::instance("dial").write(); // Scheduler sch is created in rootlogon so that jobs will be handled // properly if they last past invocations of this script. // Select application. dial::Application app(appname, appversion); // Define names for task files. dial::Task::TextList ttnames; if ( appname == "dial_cbnt" ) { ttnames.push_back(Text("init.kumac")); ttnames.push_back(Text("cbnt.f")); } else if ( appname == "atlasreco" ) { } else if ( appname == "atlasreco-8.3.0" ) { } else if ( appname == "atlasreco-8.4.0" ) { } else if ( appname == "atlasreco-8.5.0" ) { } else if ( appname == "aodhisto" ) { //cout << "Application aodhisto is not yet supported " << endl; ttnames.push_back(Text("Analysis_jobOptions.txt")); } else { cout << "Unknown application: " << appname << endl; return 10; } // If task XML does not exist, create it from the task files. if ( ! FileStatus(tskxml).exists() ) { cout << "*** Creating task" << endl; //system("rm -f cbnt.hbk"); dial::Task newtsk(ttnames); XmlElement* pxnewtsk = newtsk.xml(); if ( pxnewtsk == 0 ) { cout << "Unable to create new task XML" << endl; cout << newtsk << endl; return 11; } parser.write(tskxml, *pxnewtsk); } if ( ! FileStatus(tskxml).exists() ) { cout << "Error creating task" << endl; } const XmlElement* pxtsk = parser.parse(tskxml); dial::Task tsk(*pxtsk); if ( ! tsk.is_valid() ) { cout << "Task is invalid" << endl; return 12; } // Select dataset. // The ID for a single-file dataset may constructed using the fields lidh // and lidl in the DRC. See the link from // http://www.usatlas.bnl.gov/~dladams/dataset/atlas_catalogs // to browse this table. DatasetId did; if ( appname == "dial_cbnt" ) { did = DatasetId(10003, 1); } else if ( appname.substr(0,9) == "atlasreco" ) { did = DatasetId(10006, 3); } else if ( appname == "aodhisto" ) { did = DatasetId(10006, 6); } const dset::Dataset* pdst = ddb.extract(did, true); if ( pdst == 0 ) { cout << "Unable to find dataset " << did.to_string() << " in DDB" << endl; return 13; } const dset::Dataset& dst = *pdst; if ( ! dst.is_valid() ) { cout << "Invalid dataset" << endl; return 14; } // Install task. // Use XML description if it is present. If not, create a // new task from the code and result. cout << "*** Installing task" << endl; bool tstat = lsch.add_task(app, tsk); if ( ! tstat ) { cout << "Unable to install task " << tsk.id() << endl; cout << "------------- log file ------------------------" << endl; cout << lsch.log() << endl; cout << "------------- end log file --------------------" << endl; return 15; } // Submit job. cout << "*** Submitting job" << endl; jid = lsch.submit(app, tsk, dst); dial::Job& job = lsch.job(jid); // Write job ID. Text tjid("jobid"); tjid.append(jid.to_string()); tjid.write(); // Check job status. cout << "*** Submitted job status:" << endl; if ( jid.is_valid() ) { cout << job << endl; } else { cout << "Job submission failed" << endl; cout << lsch.log() << endl; } cout << endl; return 0; }