-qsave

Category

Language element control

Purpose

Specifies the default storage class for local variables.

Syntax

Read syntax diagramSkip visual syntax diagram
>>- -q--+-nosave-----------------------+-----------------------><
        '-save--+--------------------+-'   
                '-=--+-all---------+-'     
                     '-defaultinit-'       

@PROCESS:

@PROCESS SAVE[({ALL | DEFAULTINIT})] | NOSAVE

Defaults

The default for this option depends on the invocation command used:
  • When xlf is used to compile the .f, .F, .f77, or .F77 files, the default is -qsave=all.
  • For the f77 and fort77 invocation commands, the default is -qsave=all.
  • For all the other invocation commands, the default is -qnosave.

Parameters

The -qsave suboptions include:

all
The default storage class is STATIC.
defaultinit
The default storage class is STATIC for variables of derived type that have default initialization specified, and AUTOMATIC otherwise.

The all and defaultinit suboptions are mutually exclusive.

Usage

The -qnosave option sets the default storage class to AUTOMATIC. This usage is usually necessary for multithreaded applications and subprograms that are compiled with the -qrecur option.

You can specify the -qsave option to duplicate the behavior of FORTRAN 77 programs. The xlf, f77 and fort77 commands have -qsave listed as a default option in the configuration file to preserve the previous behavior. The default configuration file path is /opt/IBM/xlf/15.1.0/etc/xlf.cfg.nn

Examples

The following example illustrates the impact of the -qsave option on derived data type:

        PROGRAM P
          CALL SUB
          CALL SUB
        END PROGRAM P

        SUBROUTINE SUB
          LOGICAL, SAVE :: FIRST_TIME = .TRUE.
          STRUCTURE /S/
            INTEGER I/17/
          END STRUCTURE
          RECORD /S/ LOCAL_STRUCT
          INTEGER LOCAL_VAR

          IF (FIRST_TIME) THEN
            LOCAL_STRUCT.I = 13
            LOCAL_VAR = 19
            FIRST_TIME = .FALSE.
          ELSE
            ! Prints " 13" if compiled with -qsave or -qsave=all
            ! Prints " 13" if compiled with -qsave=defaultinit
            ! Prints " 17" if compiled with -qnosave
            PRINT *, LOCAL_STRUCT
            ! Prints " 19" if compiled with -qsave or -qsave=all
            ! Value of LOCAL_VAR is undefined otherwise
            PRINT *, LOCAL_VAR
          END IF
        END SUBROUTINE SUB

Related information