drmaa2_dict_create
- drmaa2_dict_create, Creates a DRMAA2 dictionary.
#include "drmaa2.h"
typedef void (*drmaa2_dict_entryfree)(char key, char val);
drmaa2_dict drmaa2_dict_create(const drmaa2_dict_entryfree callback);
Creates a new string dictionary where pairs of strings are stored as key and values. The given callback function is called for each entry when it is deleted either by drmaa2_dict_del(3) or by freeing the dictionary with drmaa2_dict_free(3). The callback function must be from type drmaa2_dict_entryfree
or NULL of no callback should be used.
Upon successful completion drmaa2_dict_create(3) returns a newly allocated drmaa2_dict
dictionary. In case of an error NULL is returned and the specific error is set for the calling thread. The error can be read out by using drmaa2_lasterror(3) and/or drmaa2_lasterror_text(3).
drmaa2_j job;
drmaa2_jtemplate jt = drmaa2_jtemplate_create();
jt->jobName = strdup("EnvironmentTest");
jt->remoteCommand = strdup("env");
/* Create dictionary for job environment variables.
* Because variables are non-allocated strings a callback
* is not required.
*/
if ((environment = drmaa2_dict_create(NULL)) == NULL) {
printf("Error: Could not create a new dictionary.\n");
error = 1;
}
if (drmaa2_dict_set(environment, "my_environment_variable", "has_a_value") != DRMAA2_SUCCESS) {
printf("Error: Could not set a new environment variable in the dictionary.\n");
error = 1;
}
if (drmaa2_dict_set(environment, "my_empty_variable", "") != DRMAA2_SUCCESS) {
printf("Error: Could not set an empty environment variable in the dictionary.\n");
error = 1;
}
jt->jobEnvironment = environment;
/* submit job */
if ((job = drmaa2_jsession_run_job(js, jt)) == NULL) {
printf("Error: Could not submit job.\n");
}
/* Calls drmaa2_dict_free(3) implicitly. */
drmaa2_jtemplate_free(&jt);
drmaa2_dict_create(3), drmaa2_dict_free(3), drmaa2_dict_list(3), drmaa2_dict_has(3), drmaa2_dict_get(3), drmaa2_dict_del(3), drmaa2_dict_set(3)
Copyright Univa Corporation 2013