MainframeMaster

DYNALLOC

OPTION DYNALLOC tells DFSORT that it may dynamically allocate sortwork datasets—temporary work files used during the sort or merge. Instead of you coding SORTWK01, SORTWK02, … in JCL, DFSORT asks the system (MVS) to create and allocate work datasets as needed. That is useful when the amount of work space is variable or when you want to avoid maintaining a long list of SORTWK DD statements. This page explains what DYNALLOC does, when to use it, how it interacts with SORTWK and FILSZ, and typical syntax.

OPTION Statement
Progress0 of 0 lessons

What Dynamic Allocation Means

During a sort or merge, DFSORT needs work space—temporary datasets—to hold data between phases. You can supply that space by defining SORTWK01, SORTWK02, … in your JCL. Alternatively, if your installation allows it, DFSORT can request that the system create and allocate those datasets at run time. That run-time creation is called dynamic allocation. OPTION DYNALLOC enables this: DFSORT may allocate additional work datasets (or, depending on installation, use only dynamically allocated work) instead of relying solely on the SORTWK DDs you provide.

Why Use DYNALLOC

  • Variable sort size — When input size changes from run to run, you may not know in advance how many SORTWK datasets to define. With DYNALLOC, DFSORT can request what it needs based on FILSZ and other options.
  • Simpler JCL — You do not have to maintain a long list of SORTWK01 through SORTWKnn. One OPTION DYNALLOC (and often a good FILSZ) can be enough for many jobs.
  • Fewer static datasets — Dynamically allocated datasets are created for the step and then deleted; you do not need to pre-define or name them in catalogs.

The trade-off is that you give up explicit control over where the work datasets go (volume, storage group). Some shops require sortwork on specific devices; in those cases they use explicit SORTWK DDs instead of or in addition to DYNALLOC.

Syntax and Typical Forms

You code OPTION DYNALLOC in SYSIN. Exact syntax can vary by DFSORT version and installation. Common forms:

  • OPTION DYNALLOC — Enable dynamic allocation; DFSORT uses installation defaults for how many work datasets to allocate.
  • OPTION DYNALLOC=(,n) — In some versions, n is the number of work datasets to allocate dynamically (e.g. DYNALLOC=(,16) for 16). The first operand may be reserved for other uses; check your documentation.
text
1
2
OPTION DYNALLOC,FILSZ=E5000000 SORT FIELDS=(1,80,CH,A)

Providing FILSZ along with DYNALLOC helps DFSORT decide how much space to request; without a good estimate, it may under-allocate (risk of ICE046A, ICE083A, SB37-04) or over-allocate. See the FILSZ estimation tutorial for details.

DYNALLOC vs Explicit SORTWK

DYNALLOC vs SORTWK in JCL
AspectDYNALLOCExplicit SORTWK DDs
Who allocatesDFSORT requests; system allocates at run timeYou define SORTWK01, SORTWK02, … in JCL
Control over locationUsually system default volumes/storageYou choose volume, unit, storage group
JCL maintenanceMinimal; no SORTWK DDs neededMust size and maintain SORTWKnn
When size variesDFSORT can request more or less via FILSZMust size for worst case or use many DDs

When Both SORTWK and DYNALLOC Are Present

If you code both SORTWK DDs and OPTION DYNALLOC, behavior depends on your installation. Some installations use a option such as DYNAUTO=IGNWKDD: in that case, DFSORT may ignore your SORTWK DDs and use only dynamically allocated work. Others may use your SORTWK datasets first and then allocate more dynamically if needed. Check your site’s DFSORT installation guide to see how SORTWK and DYNALLOC interact so you can design JCL and options correctly.

Default Number of Dynamic Work Datasets

DFSORT’s shipped default for the number of dynamically allocated work datasets is often a small number (e.g. 4). For large sorts, that may not be enough; you may need to specify a larger number via DYNALLOC=(,n) or equivalent, or provide explicit SORTWK DDs. Your installation may have overridden the default; refer to local documentation or your systems programmer.

Interaction with FILSZ and SIZE

FILSZ gives DFSORT an estimate of input (or total) size so it can plan how much sortwork to request. With DYNALLOC, a good FILSZ is important so that the dynamically allocated datasets are sufficient. SIZE (or MOSIZE) controls how much memory DFSORT uses; that can affect how much data is kept in memory versus written to sortwork, and thus how many work datasets are needed. So for reliable DYNALLOC behavior, combine it with a realistic FILSZ and appropriate SIZE when tuning.

JOINKEYS and DYNALLOC

JOINKEYS steps run internal sort/merge tasks that also need sortwork. DYNALLOC and size-related options may need to be specified in the control DD used by the join (e.g. JNF1CNTL), not only in the main SYSIN, depending on your DFSORT release. See the JOINKEYS performance tuning tutorial and your product documentation for where to specify DYNALLOC and FILSZ in JOINKEYS.

Explain It Like I'm Five

When you sort cards, you need extra tables to put piles on. You can either bring your own tables (SORTWK in JCL) or tell the teacher “get me as many tables as I need” (DYNALLOC). DYNALLOC means the teacher gets the tables for you when you need them, so you don’t have to bring a fixed number. You still have to say roughly how many cards you have (FILSZ) so they bring enough tables!

Exercises

  1. Your job sometimes gets ICE046A when input is large. You currently use DYNALLOC but do not specify FILSZ. What could you add to the OPTION statement, and why?
  2. Your shop requires all sortwork on volume SORTV1. Can you use OPTION DYNALLOC alone to meet that? What alternative do you have?
  3. Look up your DFSORT documentation: what is the exact syntax for requesting 16 dynamic work datasets (e.g. DYNALLOC=(,16)) and does your installation support it?
  4. If you provide both SORTWK01–SORTWK04 in JCL and OPTION DYNALLOC, how does your site’s DFSORT use them—together, or does it ignore SORTWK? Where did you find the answer?

Quiz

Test Your Knowledge

1. What does OPTION DYNALLOC do in DFSORT?

  • Dynamically allocates the input file
  • Allows DFSORT to dynamically allocate sortwork datasets so it can create work datasets as needed without your coding SORTWK01, SORTWK02, etc. in JCL
  • Allocates output to tape
  • Disables dynamic allocation

2. When might you prefer DYNALLOC over coding SORTWK DDs in JCL?

  • When you never want sortwork
  • When the amount of sortwork needed is variable or hard to predict, or when you want to avoid maintaining many static SORTWKnn definitions
  • Only for MERGE
  • Only when FILSZ is omitted

3. Can you use both SORTWK DDs and DYNALLOC together?

  • No; they are mutually exclusive
  • Yes; behavior depends on installation. Some installations (e.g. with DYNAUTO=IGNWKDD) may ignore your SORTWK DDs and use only dynamically allocated work; others may use your SORTWK first and then DYNALLOC for additional datasets
  • Only SORTWK is used
  • Only DYNALLOC is used

4. What can influence how much space DYNALLOC allocates?

  • Only the number of input records
  • FILSZ (size estimate), SIZE/MOSIZE (memory options), and DYNALLOC=(,n) or similar limits; the exact parameters depend on your DFSORT version
  • Only the OPTION statement
  • Only the SORT FIELDS length

5. Why might a shop still use explicit SORTWK DDs instead of DYNALLOC?

  • DFSORT does not support DYNALLOC
  • To control which volumes or storage group get sortwork, to meet change-control or capacity rules, or when dynamic allocation is restricted by policy
  • SORTWK is faster than DYNALLOC
  • DYNALLOC is only for JOINKEYS