Microsoft KB Archive/51496

= Code Example Demonstrates Using a BLOCK DATA Subprogram =

Article ID: 51496

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft FORTRAN Compiler 4.0
 * Microsoft FORTRAN Compiler 4.01
 * 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 Q51496



SUMMARY
A BLOCK DATA subprogram must appear at the beginning of the main program file, prior to the PROGRAM statement, or at the end of the file, after the END statement that closes the main program.



MORE INFORMATION
The restrictions that apply to the placement of the BLOCK DATA statement in a source file are documented on page 123 of the Microsoft FORTRAN &quot;Reference&quot; manual for versions 5.0 and 5.1.

The following code example demonstrates using the BLOCK DATA subprogram to initialize variables grouped in a named COMMON block.

Sample Code
C Compile options needed: None

C ******** BLOCK DATA statement at beginning of file ***

BLOCK DATA MYBLOCK INTEGER*2  INT1 REAL*4     REAL1 CHARACTER*2 CHAR1 LOGICAL    LOG1 COMMON /TEST/ INT1, REAL1, CHAR1, LOG1 DATA INT1, REAL1, CHAR1, LOG1 /1, 4.0, 'ZZ', .TRUE./ END

C ******** Beginning of main program *******************

PROGRAM BLOCK

INTEGER*2  INT1 REAL*4     REAL1 CHARACTER*2 CHAR1 LOGICAL    LOG1 COMMON /TEST/ INT1, REAL1, CHAR1, LOG1

WRITE (*,100) INT1, REAL1, CHAR1, LOG1 100  FORMAT (1X, I1, 3X, F3.1, 3X, A2, 3X, L1)

END Program BLOCK produces the following output:

1 4.0 ZZ T

The code example above would also produce the same results if the BLOCK DATA subprogram was placed after the END statement that terminates the main program.

Additional query words: kbinf 4.00 nofps 4.01 4.10 5.00 5.10

Keywords: KB51496

-

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

© Microsoft Corporation. All rights reserved.