How to specify RECFM, LRECL, and BLKSIZE

For OS files and terminal files, the values of RECFM, LRECL, and BLKSIZE are significant. When you open a file, z/OS® XL C/C++ searches for the RECFM, LRECL, and BLKSIZE values in the following places:

  1. The fopen() or freopen() statement that opens the file
  2. The DD statement (described in DDnames)
  3. The values set in the existing file
  4. The default values for fopen() or freopen().
When you call fopen() and specify a write mode (w, wb, w+, wb+, w+b) for an existing file, z/OS XL C/C++ uses the default values for fopen() if:

These defaults are listed in Table 1. To force z/OS XL C/C++ to use existing attributes when you are opening a file, specify recfm=* (or recfm=+) on the fopen() or freopen() call.

recfm=* (or recfm=+) is valid only for existing DASD data sets. It is ignored in all other cases.

recfm=+ is identical to recfm=* with the following exceptions:
Notes:
  1. When specifying a ddname on fopen() or freopen() you should be aware of the following when opening the ddname using one of the write modes:
  2. If the ddname is allocated to an already existing file and that ddname has not yet been opened, then the DD statement will not contain the recfm, lrecl, or blksize. That information is not filled in until the ddname is opened for the first time. If the first open uses one of the write modes (w,wb, w+, wb+, w+b) and recfm=* (or recfm=+) is not specified, then the existing file attributes are not considered. Therefore, since the DD statement has not yet been filled in, the fopen() defaults are used.
  3. If the ddname is allocated at the same time the file is created, then the DD statement will contain the same recfm, lrecl, and blksize specified for the file. If the first open uses one of the write modes (w, wb, w+, wb+, w+b) and recfm=* (or recfm=+) is not specified, then z/OS XL C/C++ picks up the existing file attributes from the DD statement since they were placed there at the time of allocation.
You can specify the record format in

Certain categories of I/O may ignore or simulate some attributes such as BLKSIZE or RECFM that are not physically supported on the device. Table 1 lists all the categories of I/O that z/OS XL C/C++ supports and directs you to where you can find more information about them.

You can specify the logical record length in

If you are creating a file and you do not select a record size, z/OS XL C/C++ uses a default. See fopen() defaults for details on how defaults are calculated.

You can specify the block size in

If you are creating a file and do not select a block size, z/OS XL C/C++ uses a default. The defaults are listed in Table 1.