int main(int argc, char *argv[]) { drmaa2_string name; drmaa2_version version; name = drmaa2_get_drmaa_name(); printf("=========================================\n"); printf("This is %s C bindings.\n", name); drmaa2_string_free(&name); version = drmaa2_get_drmaa_version(); printf("=========================================\n"); printf("This DRMAA version is %s.%s.\n", version->major, version->minor); drmaa2_version_free(&version); name=drmaa2_get_drms_name(); printf("=========================================\n"); printf("The DRM is %s.\n", name); drmaa2_string_free(&name); version = drmaa2_get_drms_version(); printf("=========================================\n"); printf("The DRM version is %s.%s\n", version->major, version->minor); printf("=========================================\n"); drmaa2_version_free(&version); return 0; }
void drmaa2_version_free(drmaa2_version * vRef) { if (*vRef != NULL) { drmaa2_string_free(&((*vRef)->major)); drmaa2_string_free(&((*vRef)->minor)); free(*vRef); *vRef=NULL; } }
void drmaa2_notification_free(drmaa2_notification *nRef) { drmaa2_notification n = *nRef; if (n != NULL) { drmaa2_string_free(&(n->jobId)); drmaa2_string_free(&(n->sessionName)); free(n); *nRef = NULL; } }
void drmaa2_rtemplate_free(drmaa2_rtemplate * rtRef) { drmaa2_rtemplate rt = *rtRef; if (rt != NULL) { drmaa2_string_free(&(rt->reservationName)); drmaa2_string_free(&(rt->jobCategory)); drmaa2_list_free(&(rt->usersACL)); drmaa2_list_free(&(rt->candidateMachines)); free(rt); *rtRef = NULL; } }
void drmaa2_rinfo_free(drmaa2_rinfo * riRef) { drmaa2_rinfo ri = *riRef; if (ri != NULL) { drmaa2_string_free(&(ri->reservationId)); drmaa2_string_free(&(ri->reservationName)); drmaa2_list_free (&(ri->usersACL)); drmaa2_list_free (&(ri->reservedMachines)); free(ri); *riRef = NULL; } }
void drmaa2_slotinfo_free(drmaa2_slotinfo * siRef) { drmaa2_slotinfo si = *siRef; if (si != NULL) { drmaa2_string_free(&(si->machineName)); free(si); *siRef = NULL; } }
void drmaa2_machineinfo_free(drmaa2_machineinfo * miRef) { if (*miRef != NULL) { drmaa2_string_free (&((*miRef)->name)); drmaa2_version_free(&((*miRef)->machineOSVersion)); free(*miRef); *miRef = NULL; } }
void drmaa2_queueinfo_free(drmaa2_queueinfo * qiRef) { drmaa2_queueinfo qi = *qiRef; if (qi != NULL) { drmaa2_string_free(&(qi->name)); free(qi); *qiRef = NULL; } }
void drmaa2_jtemplate_free(drmaa2_jtemplate * jtRef) { drmaa2_jtemplate jt = *jtRef; if (jt != NULL) { drmaa2_string_free(&(jt->remoteCommand)); drmaa2_list_free(&(jt->args)); drmaa2_dict_free(&(jt->jobEnvironment)); drmaa2_string_free(&(jt->workingDirectory)); drmaa2_string_free(&(jt->jobCategory)); drmaa2_list_free(&(jt->email)); drmaa2_string_free(&(jt->jobName)); drmaa2_string_free(&(jt->inputPath)); drmaa2_string_free(&(jt->outputPath)); drmaa2_string_free(&(jt->errorPath)); drmaa2_string_free(&(jt->reservationId)); drmaa2_string_free(&(jt->queueName)); drmaa2_list_free(&(jt->candidateMachines)); drmaa2_dict_free(&(jt->stageInFiles)); drmaa2_dict_free(&(jt->stageOutFiles)); drmaa2_dict_free(&(jt->resourceLimits)); drmaa2_string_free(&(jt->accountingId)); free(jt); *jtRef = NULL; } }
void drmaa2_jinfo_free(drmaa2_jinfo * jiRef) { drmaa2_jinfo ji = *jiRef; if (ji != NULL) { drmaa2_string_free(&(ji->jobId)); drmaa2_string_free(&(ji->terminatingSignal)); drmaa2_string_free(&(ji->annotation)); drmaa2_string_free(&(ji->jobSubState)); drmaa2_list_free (&(ji->allocatedMachines)); drmaa2_string_free(&(ji->submissionMachine)); drmaa2_string_free(&(ji->jobOwner)); drmaa2_string_free(&(ji->queueName)); free(ji); *jiRef = NULL; } }
drmaa2_jarray drmaa2_jsession_run_bulk_jobs(const drmaa2_jsession js, const drmaa2_jtemplate jt, long long begin_index, long long end_index, long long step, long long max_parallel) { if (end_index < begin_index) { drmaa2_lasterror_v = DRMAA2_INVALID_ARGUMENT; drmaa2_lasterror_text_v = "The beginIndex value must be less than or equal to endIndex."; return NULL; } else if (begin_index < 1) { drmaa2_lasterror_v = DRMAA2_INVALID_ARGUMENT; drmaa2_lasterror_text_v = "Only positive index numbers are allowed for the beginIndex."; return NULL; } unsigned long index = begin_index; drmaa2_j j; drmaa2_string_list sl = drmaa2_list_create(DRMAA2_STRINGLIST, (drmaa2_list_entryfree)drmaa2_string_free); char *workingDirectory = jt->workingDirectory; char *inputPath = jt->inputPath; char *outputPath = jt->outputPath; char *errorPath = jt->errorPath; while (index <= end_index) { // Start replace placeholders char *index_c; char *tmp_working_dir; char *tmp_input_path; char *tmp_output_path; char *tmp_error_path; if (-1 == asprintf(&index_c, "%lu", index)) { drmaa2_lasterror_v = DRMAA2_INTERNAL; drmaa2_lasterror_text_v = "Error on asprintf() usage."; return NULL; } tmp_working_dir = str_replace(jt->workingDirectory, "$DRMAA2_INDEX$", index_c); jt->workingDirectory = str_replace(tmp_working_dir, "$DRMAA2_HOME_DIR$", "~"); drmaa2_string_free(&tmp_working_dir); tmp_input_path = str_replace(jt->inputPath, "$DRMAA2_INDEX$", index_c); jt->inputPath = str_replace(tmp_input_path, "$DRMAA2_HOME_DIR$", "~"); drmaa2_string_free(&tmp_input_path); tmp_input_path = jt->inputPath; jt->inputPath = str_replace(tmp_input_path, "$DRMAA2_WORKING_DIR$", "."); drmaa2_string_free(&tmp_input_path); tmp_output_path = str_replace(jt->outputPath, "$DRMAA2_INDEX$", index_c); jt->outputPath = str_replace(tmp_output_path, "$DRMAA2_HOME_DIR$", "~"); drmaa2_string_free(&tmp_output_path); tmp_output_path = jt->outputPath; jt->outputPath = str_replace(tmp_output_path, "$DRMAA2_WORKING_DIR$", "."); drmaa2_string_free(&tmp_output_path); tmp_error_path = str_replace(jt->errorPath, "$DRMAA2_INDEX$", index_c); jt->errorPath = str_replace(tmp_error_path, "$DRMAA2_HOME_DIR$", "~"); drmaa2_string_free(&tmp_error_path); tmp_error_path = jt->errorPath; jt->errorPath = str_replace(tmp_error_path, "$DRMAA2_WORKING_DIR$", "."); drmaa2_string_free(&tmp_error_path); // End replace placeholders j = drmaa2_jsession_run_job(js, jt); // Start clean up replacement variables tmp_working_dir = jt->workingDirectory; jt->workingDirectory = workingDirectory; drmaa2_string_free(&tmp_working_dir); tmp_input_path = jt->inputPath; jt->inputPath = inputPath; drmaa2_string_free(&tmp_input_path); tmp_output_path = jt->outputPath; jt->outputPath = outputPath; drmaa2_string_free(&tmp_output_path); tmp_error_path = jt->errorPath; jt->errorPath = errorPath; drmaa2_string_free(&tmp_error_path); free(index_c); // End clean up replacement variables drmaa2_list_add(sl, strdup(j->id)); drmaa2_j_free(&j); index += step; } long long template_id = save_jtemplate(jt, js->name); long long id = save_jarray(js->name, template_id, sl); drmaa2_list_free(&sl); drmaa2_jarray ja = (drmaa2_jarray)malloc(sizeof(drmaa2_jarray_s)); char *cid; if (-1 == asprintf(&cid, "%lld", id)) { drmaa2_lasterror_v = DRMAA2_INTERNAL; drmaa2_lasterror_text_v = "Error on asprintf() usage."; return NULL; } ja->id = cid; //already allocated ja->session_name = strdup(js->name); return ja; }