| Fortran 77 Language Reference |
VMS Language Extensions
This chapter describes the VMS language extensions that Sun WorkShop Fortran 77 supports. These extensions are all, of course, nonstandard.
![]()
Background
This FORTRAN compiler includes the VMS extensions to make it as easy as possible to port FORTRAN programs from VMS environments to Solaris environments. The compiler provides almost complete compatibility with VMS FORTRAN. These extensions are included in
dbxas well asf77.VMS Language Features in Sun Fortran
This list is a summary of the VMS features that are included in
f77. Details are elsewhere in this manual.
- Namelist I/O
- Unlabeled
DO...ENDDO- Indefinite
DOWHILE...ENDDOBYTEdata type- Logical operations on integers, and arithmetic operations on logicals
- Additional field and edit descriptors for
FORMATstatements:- Default field indicators for w, d, and e fields in
FORMATstatements- Reading into Hollerith edit descriptors
APPENDoption forOPEN- Long names (32 characters)
_and$in names- Long source lines (132-character), if the
-eoption is on- Records, structures, unions, and maps
- Getting addresses by the
%LOCfunction- Passing arguments by the
%VALfunction- End-of-line comments
OPTIONSstatement- VMS Tab-format source lines are valid.
- Initialize in common
- You can initialize variables in common blocks outside of
BLOCKDATAsubprograms. You can initialize portions of common blocks, but you cannot initialize portions of one common block in more than one subprogram.- Radix-50
- Radix-50 constants are implemented as
f77bit-string constants, that is, no type is assumed.IMPLICITNONEis treated asIMPLICITUNDEFINED(A-Z)VIRTUALis treated asDIMENSION.- Initialize in declarations
- Initialization of variables in declaration statements is allowed. Example:
CHARACTER*10 NAME /'Nell'/- Noncharacter format specifiers
- If a runtime format specifier is not of type
CHARACTER, the compiler accepts that too, even though the FORTRAN Standard requires theCHARACTERtype.- Omitted arguments in subprogram calls
- The compiler accepts omitted actual argument in a subroutine call, that is, two consecutive commas compile to a null pointer. Reference to that dummy argument gives a segmentation fault.
REAL*16
- (SPARC only) The compiler treats variables of type
REAL*16as quadruple precision.- Noncharacter variables
- The FORTRAN Standard requires the
FILE=specifier forOPENandINQUIREto be an expression of typeCHARACTER.f77accepts a numeric variable or array element reference.- Consecutive operators
f77allows two consecutive arithmetic operators when the second operator is a unary+or-. Here are two consecutive operators:
X = A ** -B- The above statement is treated as follows:
X = A ** (-B)- Illegal real expressions
- When the compiler finds a
REALexpression where it expects an integer expression, it truncates and makes a type conversion toINTEGER.- Examples: Contexts for illegal real expressions that
f77converts to integer:
- Alternate
RETURN- Dimension declarators and array subscripts
- Substring selectors
- Computed
GOTO- Logical unit number, record number, and record length
- Typeless numeric constants
- Binary, hexadecimal and octal constants are accepted in VMS form.
- Example: Constants-Binary (
B), Octal (O), Hexadecimal (XorZ):
DATA N1 /B'0011111'/, N2/O'37'/, N3/X'1f'/, N4/Z'1f'/- Function length on function name, rather than on the word
FUNCTION
- The compiler accepts nonstandard length specifiers in function declarations.
- Example: Size on function name, rather than on the word
FUNCTION:
INTEGER FUNCTION FCN*2 ( A, B, C )
TYPEandACCEPTstatements are allowed.- Alternate return
- The nonstandard
&syntax for alternate-return actual arguments is treated as the standard FORTRAN*syntax. Example
:
CALL SUBX ( I, *100, Z)! StandardCALL SUBX ( I, &100, Z ) ! Nonstandard alternate syntax- The
ENCODEandDECODEstatements are accepted.- Direct I/O with
'Nrecord specifier
- The nonstandard record specifier
'Nfor direct-access I/O statements is accepted.- Example: A nonstandard form for record specifier:
READ ( K ' N ) LIST- The above is treated as:
READ ( UNIT=K, REC=N ) LIST- The logical unit number is
Kand the number of the record isN.NAME,RECORDSIZE, andTYPEoptions--OPENhas the following alternative options:DISPOSE=p
- The
DISPOSE=p clause in theCLOSEstatement is treated asSTATUS=p.- Special Intrinsics
- The compiler processes certain special intrinsic functions:
%VALis accepted%LOCis treated asLOC%REF(expr)is treated as expr (with a warning if exprisCHARACTER)%DESCRis reported as an untranslatable feature- Variable Expressions in
FORMATStatements
- In general, inside a
FORMATstatement, any integer constant can be replaced by an arbitrary expression; the single exception is the n in an nH...edit descriptor. The expression itself must be enclosed in angle brackets.
- Example: The
6in the following statement is a constant:
1 FORMAT( 3F6.1 )6can be replaced by the variableN, as in:
1 FORMAT( 3F<N>.1 )VMS Features Requiring
-xlor-vax=specYou get most VMS features automatically without any special options. For a few of them, however, you must add the
-xloption on thef77command line.In general, you need this
-xloption if a source statement can be interpreted for either a VMS way of behavior or anf77way of behavior, and you want the VMS way of behavior. The-xloption forces the compiler to interpret it as VMS FORTRAN.Note also the
-vax=spec option, which allows specification of these VMS extensions individually. See the Fortran User's Guide for details.Summary of Features That Require
-xl[d]You must use
-xl[d]to access the following features:
- Unformatted record
sizein words rather than bytes (-xl)- VMS-style logical file names (
-xl)- Quote (
") character introducing octal constants (-xl)- Backslash (
\) as ordinary character within character constants (-xl)- Nonstandard form of the
PARAMETERstatement (-xl)- Debugging lines as comment lines or FORTRAN statements (
-xld)- Align structures as in VMS FORTRAN (
-xl)Details of Features That Require
-xl[d]
- Unformatted record
sizein words rather than bytes
- In
f77, direct-access, unformatted files are always opened with the logical record size in bytes.- If the
-xl[d]option is not set, then the argument n in theOPENoptionRECL=n is assumed to be the number of bytes to use for the record size.- If the
-xl[d]option is set, then the argument n in theOPENoptionRECL=n is assumed to be the number of words, so the compiler uses n*4as the number of bytes for the record size.- If the
-xl[d]option is set, and if the compiler cannot determine if the file is formatted or unformatted, then it issues a warning message that the record size may need to be adjusted. This result could happen if the information is passed in variable character strings.- The record size returned by an
INQUIREstatement is not adjusted by the compiler; that is,INQUIREalways returns the number of bytes.- These record sizes apply to direct-access, unformatted files only.
- VMS-style logical file names
- If the
-xl[d]option is set, then the compiler interprets VMS logical file names on theINCLUDEstatement if it finds the environment variable,LOGICALNAMEMAPPING, to define the mapping between the logical names and the UNIX path name.- You set the environment variable to a string of the form:
"lname1=path1; lname2=path2; ... " - Remember these rules for VMS style logical file names:
- Each lname is a logical name and each path1, path2, and so forth, is the path name of a directory (without a trailing
/).- It ignores all blanks when parsing this string.
- It strips any trailing
/[no]listfrom the file name in theINCLUDEstatement.- Logical names in a file name are delimited by the first
:in the VMS file name.- It converts file names from lname1:file to the path1/file form.
- For logical names, uppercase and lowercase are significant. If a logical name is encountered on the
INCLUDEstatement which is not specified in theLOGICALNAMEMAPPING, the file name is used, unchanged.- Quote (
") character introducing octal constants
- If the
-xl[d]compiler option is on, a VMS FORTRAN octal integer constant is treated as its decimal form.- Example: VMS octal integer constant:
JCOUNT = ICOUNT + "703- The above statement is treated as:
JCOUNT = ICOUNT + 451- If the
-xl[d]option is not on, then the"703is an error.- With
-xl[d], the VMS FORTRAN notation"703signalsf77to convert from the integer octal constant to its integer decimal equivalent, 451 in this case. In VMS FORTRAN,"703cannot be the start of a character constant, because VMS FORTRAN character constants are delimited by apostrophes, not quotes.- Backslash (
\) as ordinary character within character constants
- If the
-xl[d]option is on, a backslash in a character string is treated as an ordinary character; otherwise, it is treated as an escape character.- Nonstandard form of the
PARAMETERstatement
- The alternate
PARAMETERstatement syntax is allowed, if the-xl[d]option is on.- Example: VMS alternate form of
PARAMETERstatement omits the parentheses:
PARAMETER FLAG1 = .TRUE.- Debugging lines as comment lines or FORTRAN statements (
-xld)
- The compiler interprets debugging lines as comment lines or FORTRAN statements, depending on whether the
-xldoption is set. If set, they are compiled; otherwise, they are treated as comments.- Example: Debugging lines:
REAL A(5) / 5.0, 6.0, 7.0, 8.0, 9.0 /DO I = 1, 5X = A(I)**2D PRINT *, I, XEND DOPRINT *, 'done'END- With
-xld, this code printsIandX. Without-xld, it does not print them.- Align structures as in VMS FORTRAN
- Use this feature if your program has some detailed knowledge of how VMS structures are implemented. If you need to share structures with C, you should use the default: no
-xlUnsupported VMS FORTRAN
Most VMS FORTRAN extensions are incorporated into the
f77compiler. The compiler writes messages to standard error for any unsupported statements in the source file. The following is a list of the few VMS statements that are not supported.
DEFINEFILEstatementDELETEstatementUNLOCKstatementFINDstatementREWRITEstatementKEYIDand key specifiers inREADstatements- Nonstandard
INQUIREspecifiers- Nonstandard
OPENspecifiers
ASSOCIATEVARIABLEBLOCKSIZEBUFFERCOUNTCARRIAGECONTROLDEFAULTFILEDISP[OSE]EXTENDSIZEINITIALSIZEKEYMAXRECNOSPANBLOCKSORGANIZATIONRECORDTYPESHAREDUSEROPEN- The intrinsic function,
%DESCR- The following parameters on the
OPTIONSstatement:- Some of the
INCLUDEstatement
- Some aspects of the
INCLUDEstatement are converted. TheINCLUDEstatement is operating system-dependent, so it cannot be completely converted automatically. The VMS version allows a module-name and aLISTcontrol directive that are indistinguishable from a continuation of a UNIX file name. Also, VMS ignores alphabetic case, so if you are inconsistent about capitalization, distinctions are made where none are intended.- Getting a long integer--expecting a short
- In VMS FORTRAN, you can pass a long integer argument to a subroutine that expects a short integer. This feature works if the long integer fits in 16 bits, because the VAX addresses an integer by its low-order byte. This feature does not work on SPARC systems.
- Those VMS system calls that are directly tied to that operating system
- Initializing a common block in more than one subprogram
- Alphabetizing common blocks so you can rely or depend on the order in which blocks are loaded. You can specify the older with the
-Mmapfile option told.- If you use the defaults for both of the following:
- then formatted numeric input ignores imbedded and trailing blanks. The corresponding VMS defaults treat them as zeros.
|
Sun Microsystems, Inc. Copyright information. All rights reserved. Feedback |
Library | Contents | Previous | Next | Index |