&(executable="{{ jd.script_name }}")
 (jobname="{{ jd.job_name }}")
{%- if jd.script_args %}
 (arguments={% for arg in jd.script_args %}"{{ arg }}" {% endfor %})
{%- endif %}
 (stdout="{{ jd.output }}")
 (stderr="{{ jd.error }}")
{%- if jd.logdir %}
 (gmlog="{{ jd.logdir }}")
{%- endif -%}
{%- if jd.wall_time_limit %}
 (wallTime="{{ jd.wall_time_limit }} seconds")
{%- endif -%}
{%- if jd.memory_limit %}
 (memory="{{ (jd.memory_limit + 1048575) // 1048576 }}")
{%- endif %}
 (inputfiles=
  ("{{ jd.script_name }}" "file:{{ jd.script_path }}" "overwrite=yes")
{%- for fn, url, url_opts in jd.staged_inputs %}
  ("{{ fn }}" "{{ url or '' }}" "overwrite=yes"
   {%- for url_opt in url_opts %} "{{ url_opt }}"{% endfor %})
{%- endfor -%})
{%- if jd.staged_outputs %}
 (outputfiles=
{%- for fn, url, url_opts in jd.staged_outputs %}
  ("{{ fn }}" "{{ url or '' }}" "overwrite=yes"
   {%- for url_opt in url_opts %} "{{ url_opt }}"{% endfor %})
{%- endfor -%})
{%- endif -%}

{%- if jd.queue_name %}
(queue="{{ jd.queue_name }}")
{%- endif -%}

{%- for rte in jd.runtime_environments %}
 (runTimeEnvironment="{{rte}}")
{%- endfor -%}
{{"\n"}}
