get_jobdescription_type () { echo "json" } gen_values_array () { local v_base=$1 local v_idx=0 local v_var="${v_base}${v_idx}" v_json="" while [ -n "${!v_var}" ]; do v_json="${v_json}${json_coma}\"${!v_var}\"" json_coma="," v_idx=$(( v_idx + 1 )) v_var="${v_base}${v_idx}" done echo $v_json } gen_key_value_object () { local f1_base=$1 local f2_base=$2 f_json="" f_idx=0 f_var="${f1_base}${f_idx}" while [ -n "${!f_var}" ]; do f_location_var="${f2_base}${f_idx}" f_json="${f_json}${json_coma}{\"${!f_var}\":\"${!f_location_var}\"}" json_coma="," f_idx=$((f_idx+1)) f_var="${f1_base}${f_idx}" done echo $f_json } gen_job_description () { local json_f=$1 [ -n "$CPUS" ] && NPRC=$CPUS || NPRC=$((${NODES:-1}*${PPN:-1})) [ -n "$WALLTIME" ] && _WALLTIME="\"wallTime\":\"${WALLTIME}\"," [ -n "$DISK" ] && _DISK="\"disk\":\"${DISK}\"," [ -n "$MEMORY" ] && _MEMORY="\"memory\":\"${MEMORY}\"," [ -n "$NPRC" ] && _NPRC="\"cpus\":\"${NPRC}\"" cat < $json_f { "request_type": "newjob", "jobinfo": { "jobname" : "$JOBNAME", "executable" : "$EXECUTABLE" }, "resources": { $_WALLTIME $_DISK $_MEMORY $_NPRC }, "environment": [ $( gen_key_value_object "ENVIRONMENT_NAME_" "ENVIRONMENT_VALUE_" ) ], "runtime_software": [ $( gen_values_array "RUNTIME_VALUE_" ) ], "runtime_features": [ $( gen_values_array "RUNTIME_FEATURE_" ) ], "input_files": [ $( gen_key_value_object "INPUT_FILES_NAME_" "INPUT_FILES_LOCATION_" ) ], "output_files": [ $( gen_key_value_object "OUTPUT_FILES_NAME_" "OUTPUT_FILES_LOCATION_" ) ] } END } jobdescription_gen_params () { cat <