24.05.2014 Views

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

-qsave Option<br />

Syntax<br />

-qsave[={all|defaultinit}] | -qnosave<br />

SAVE[({all|defaultinit})] NOSAVE<br />

This specifies the default storage class <strong>for</strong> local variables.<br />

If -qsave=all is specified, the default storage class is STATIC; if -qnosave is<br />

specified, the default storage class is AUTOMATIC; if -qsave=defaultinit is<br />

specified, the default storage class is STATIC <strong>for</strong> variables of derived type that<br />

have default initialization specified, and AUTOMATIC otherwise. The default<br />

suboption <strong>for</strong> the -qsave option is all. The two suboptions are mutually exclusive.<br />

The default <strong>for</strong> this option depends on the invocation used. For example, you may<br />

need to specify -qsave to duplicate the behavior of FORTRAN 77 programs. The<br />

xlf, xlf_r, xlf_r7, f77, and <strong>for</strong>t77 commands have -qsave listed as a default option<br />

in /etc/xlf.cfg to preserve the previous behavior.<br />

The following example illustrates the impact of the -qsave option on derived data<br />

type:<br />

PROGRAM P<br />

CALL SUB<br />

CALL SUB<br />

END PROGRAM P<br />

SUBROUTINE SUB<br />

LOGICAL, SAVE :: FIRST_TIME = .TRUE.<br />

STRUCTURE /S/<br />

INTEGER I/17/<br />

END STRUCTURE<br />

RECORD /S/ LOCAL_STRUCT<br />

INTEGER LOCAL_VAR<br />

IF (FIRST_TIME) THEN<br />

LOCAL_STRUCT.I = 13<br />

LOCAL_VAR = 19<br />

FIRST_TIME = .FALSE.<br />

ELSE<br />

! Prints " 13" if compiled with -qsave or -qsave=all<br />

! Prints " 13" if compiled with -qsave=defaultinit<br />

! Prints " 17" if compiled with -qnosave<br />

PRINT *, LOCAL_STRUCT<br />

! Prints " 19" if compiled with -qsave or -qsave=all<br />

! Value of LOCAL_VAR is undefined otherwise<br />

PRINT *, LOCAL_VAR<br />

END IF<br />

END SUBROUTINE SUB<br />

Related In<strong>for</strong>mation<br />

The -qnosave option is usually necessary <strong>for</strong> multi-threaded applications and<br />

subprograms that are compiled with the “-qrecur Option” on page 224.<br />

See Storage Classes <strong>for</strong> Variables in the <strong>XL</strong> <strong>Fortran</strong> <strong>Enterprise</strong> <strong>Edition</strong> <strong>for</strong> <strong>AIX</strong> Language<br />

Reference <strong>for</strong> in<strong>for</strong>mation on how this option affects the storage class of variables.<br />

228 <strong>XL</strong> <strong>Fortran</strong> <strong>Enterprise</strong> <strong>Edition</strong> <strong>for</strong> <strong>AIX</strong> : User’s <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!