Microsoft KB Archive/34370

= DOCERR: External Data and Public Variables in FORTRAN =

Article ID: 34370

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft FORTRAN Compiler 4.1
 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1
 * Microsoft FORTRAN Compiler 4.1
 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1

-



This article was previously published under Q34370



SUMMARY
A FORTRAN application cannot declare individual variables to be public. A COMMON block is the only method to declare a publicly accessible variable.

In a FORTRAN program, to declare a variable or set of variables to be public, place them in a COMMON block. Because COMMON blocks are public, an application can access the variables through the COMMON block, but not individually. For example, if a FORTRAN application declares a COMMON block, an application developed in C can access the data by declaring an external structure that contains the same data.



MORE INFORMATION
Section 9.3, &quot;External Data,&quot; of the &quot;Microsoft Mixed-Language Programming Guide&quot; and Section 5.3.3, &quot;External Data,&quot; of the Microsoft FORTRAN &quot;Advanced Topics&quot; manual for version 5.0/5.1 discuss the possibilities for shared data. The documentation includes the following statements:

You can always share data between two languages by passing parameters. In the case of local variables and all BASIC variables, passing parameters is the only convenient way to share data.

However, C, FORTRAN, and Pascal routines can access data directly that are external.

A FORTRAN program can access variables declared external in code developed in C or Pascal; however, a FORTRAN program cannot declare a variable to be public without placing it into a COMMON block. The example on Page 131 of the &quot;Mixed-Language Programming Guide&quot; and on Pages 109-110 of the FORTRAN &quot;Advanced Topics&quot; manual incorrectly show code developed in C and in Pascal accessing a public variable declared in a FORTRAN routine. In FORTRAN, all variable names are local; only the names of COMMON blocks and subprograms are public.

This has been corrected in the FORTRAN PowerStation documentation, in MIXED_C.WRI.

Additional query words: 4.10 nofps 5.00 5.10

Keywords: KB34370

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.