DIGITAL Visual Fortran Programmer’s Guide Date: December, 1998 Software Version: DIGITAL Visual Fortran Version 6.
Copyright Page Digital Equipment Corporation makes no representations that the use of its products in the manner described in this publication will not infringe on existing or future patent rights, nor do the descriptions contained in this publication imply the granting of licenses to make, use, or sell equipment or software in accordance with the description.
Introduction to the Programmer’s Guide Page 1 of 4 Introduction to the Programmer’s Guide The Programmer’s Guide contains the following information (this color denotes a link): How to build and debug efficient applications: n n n n n Building Programs and Libraries Using the Compiler and Linker from the Command Line Compiler and Linker Options Debugging Fortran Programs Performance: Making Programs Run Faster Special coding and related considerations for certain Visual Fortran project types: n Using
Introduction to the Programmer’s Guide Page 2 of 4 n Using Visual Fortran Tools Note: Visual Fortran contains many extensions to the full ANSI standard language. In this book, the Visual Fortran extensions to the Fortran 90 standard appear in this color. Programmer’s Guide Conventions This section discusses the following: General Conventions Syntax Conventions Platform labels General Conventions The Programmer’s Guide uses the following general conventions.
Introduction to the Programmer’s Guide Page 3 of 4 statement syntax, unless enclosed in brackets as explained above. In the sentence, "The following steps occur when a DO WHILE statement is executed," the phrase DO WHILE is a DIGITAL Fortran keyword. Bold lowercase letters are also used for keywords of other languages. In the sentence, "A Fortran subroutine is the equivalent of a function of type void in C," the word void is a keyword of C.
Introduction to the Programmer’s Guide Page 4 of 4 Fortran. Platform Labels A platform is a combination of operating system and central processing unit (CPU) that provides a distinct environment in which to use a product (in this case, a language). For example, Microsoft® Windows® 98 on Intel® is a platform. Information applies to all supported platforms unless it is otherwise labeled for a specific platform (or platforms), as follows: VMS Applies to OpenVMSTM on Alpha processors.
Building Programs and Libraries Page 1 of 44 Building Programs and Libraries Visual Fortran includes the Microsoft visual development environment (also used by the same version of Visual C++®) and associated Visual Studio software development tools. This industryleading environment makes it easy for you to create, debug, and execute your programs. It includes a full-feature text editor, debugger, and interactive help.
Building Programs and Libraries Page 2 of 44 project but still maintain a consistent source code base from which to work. When you create a new project, the Microsoft visual development environment automatically creates Debug and Release configurations for you. The default configuration is the Debug configuration. To specify the current configuration, select Set Active Configuration from the Build menu. Projects are contained in a workspace.
Building Programs and Libraries Page 3 of 44 Notes in the diagram point to places where you can read more about a particular part of the development process: 1. Building Programs and Libraries (the current chapter) 2. Using the Compiler and Linker from the Command Line 3. Using Visual Fortran Tools 4. The Floating-Point Environment and Handling Run-Time Errors 5. Debugging Fortran Programs 6. Profiling Code from the Command Line 7.
Building Programs and Libraries Page 4 of 44 How Information Is Displayed The Microsoft visual development environment displays information in windows, panes, and folders. One window can contain several panes, and each pane can display one or more folders. A pane is a separate and distinct area of a window; a folder is a visual representation of files in a project.
Building Programs and Libraries Page 5 of 44 Move the mouse pointer into the project window and click the right mouse button. You can now select project commands that are appropriate for your current selection in the project window. Types of Projects When you create the project, you must choose a project type. You need to create a project for each binary executable file to be created.
Building Programs and Libraries Page 6 of 44 The first four projects listed in the preceding table are main project types, requiring main programs. The last two are library projects, without main programs.
Building Programs and Libraries Page 7 of 44 Any graphics routine that your program calls will produce no output, but will return error codes. A program will not automatically exit if such an error occurs, so your code should be written to handle this condition. With a console project, you can use static libraries, DLLs, and dialog boxes, but you cannot use the QuickWin functions. You can select the multithreaded libraries with this and all of the other project types.
Building Programs and Libraries Page 8 of 44 building from the command line, you must specify the /libs:qwins option. You cannot use the runtime functions meant for multiple-window projects if you are building a standard graphics project. You cannot make a Standard Graphics application a DLL. For more information about Standard Graphics (QuickWin single window) applications, see Using Quickwin. Fortran QuickWin Application Projects Fortran QuickWin graphics applications (.
Building Programs and Libraries Page 9 of 44 You cannot make a QuickWin application a DLL. For information on how to use QuickWin functions, including how to open and control multiple windows, see Using Quickwin. Fortran Windows Application Projects Fortran Windows applications (.EXE) are main programs selected by choosing the Fortran Windows Application project type. This type of project lets you calls the Windows APIs directly from Visual Fortran.
Building Programs and Libraries Page 10 of 44 See the online title Platform SDK for information on calling Win32 routines. The full Win32 API set is documented in the Win32 Application Programming Interface for Windows NT Programmer’s Reference, available from Microsoft Press and also distributed as part of the Windows NT Software Development Kit. Fortran Static Library Projects Fortran static libraries (.LIB) are blocks of code compiled and kept separate from the main part of your program.
Building Programs and Libraries Page 11 of 44 You add static libraries to a main project in the visual development environment with the Add to Project, Insert Files option in the Project menu. You can enter the path and library name in the Insert Files into Project dialog box with a .LIB extension on the name. If you are using a foreign makefile, you must add the library by editing the makefile for the main project. If you are building your project from the command line, add the library name with a .
Building Programs and Libraries Page 12 of 44 time library stored in a separate DLL. For more information about DLLs, see: Creating Fortran DLLs Defining Your Project To define your project, you need to: 1. 2. 3. 4. 5. Create the project Populate the project with files Choose a configuration Define build options, including project settings Build (compile and link) the project To create a new project: 1. Click the File menu and select New.
Building Programs and Libraries Page 13 of 44 To add files to an existing project: To add an existing file to the project: 1. If not already open, open the project workspace (use the File menu). 2. In the Project menu, click Add to Project. Select Files... from the submenu. 3. The Insert Files into Project dialog box appears. Use this dialog box to select the Fortran files to be added to the Project. To add more than one file to the project, hold down the Ctrl key as you select each file name.
Building Programs and Libraries Page 14 of 44 2. The Insert Files into Project dialog box appears. Use this dialog box to select the Fortran files to be added to the Project. To add more than one file to the project, hold down the Ctrl key as you select each file name. To add each new file to the project: 1. In the Project menu, select Add to Project. Select New... from the submenu. 2. The New dialog box appears. Specify the file name and its location. 3.
Building Programs and Libraries Page 15 of 44 A Project workspace file - Has the extension .DSW. It stores project workspace information. A Project file - Has the extension .DSP. It is used to build a single project or subproject. A Workspace options file - Has the extension .OPT. It contains environment settings for Visual Fortran, such as window sizes and positions, insertion point locations, state of project breakpoints, contents of the Watch window, and so on. Directly modifying the .DSW and .
Building Programs and Libraries Page 16 of 44 If you use a foreign makefile for a project, the visual development environment calls NMAKE to perform the build. You can run NMAKE from the console command line to perform builds either with makefiles exported by the visual development environment or with foreign makefiles that you have edited. For more about the external program maintenance utility, see Building Projects with NMAKE.
Building Programs and Libraries Page 17 of 44 debug information and no optimizations, whereas the default release configuration supplies minimal debug information and full optimizations. You can also define new configurations within your project. These configurations can use the existing source files in your project, the existing project settings, or other characteristics of existing configurations.
Building Programs and Libraries Page 18 of 44 configuration level. You can set options at the following levels within a configuration: Configuration level Any options set for the current configuration apply to every file in the configuration unless overridden at the file level. Options set for the configuration apply to all actions, such as compilation, linking, and requesting browser information.
Building Programs and Libraries Page 19 of 44 The linker builds an executable program (.EXE), static library (.LIB), or dynamic-link library (.DLL) file from Common Object File Format (COFF) object files and other libraries identified in the linker options. You direct the linker by setting linker options either in the visual development environment, in a build instructions file, or on the console command line.
Building Programs and Libraries Page 20 of 44 4. The Tool Combo box allows you to view the project settings for either the Fortran or the displayed tools (such as Linker). The Release and Debug configuration values are displayed for the selected tab. Verify that the displayed values are acceptable. 5. The edit box titled Saved Fortran Console Environment allows you to specify the name of the environment to be saved. 6. Click the Save Settings button to save the settings as a project settings environment.
Building Programs and Libraries Page 21 of 44 2. For the selected Fortran project type, a list of saved Fortran environments appears. Select a Fortran environment. Verify that the selected environment is correct by viewing the Project Settings options. 3. After selecting the appropriate Fortran environment for the Fortran project being created, click the Apply button to use the saved settings for the new project. 4.
Building Programs and Libraries Page 22 of 44 2. Initially, this dialog box displays the project types for which there are saved Fortran environments. Double-click on the project type name to view the saved Fortran environments for that project type. This dialog box allows you to display the Fortran environments associated with each project type. Double-click the name of a project type to display the Fortran environments associated with that project type. 3.
Building Programs and Libraries Page 23 of 44 Browser information is off by default for projects, but you can turn it on if you wish. To set the browse option for the current configuration: In the visual development environment: 1. In the Project menu, click Settings. 2. In the General category of the Fortran tab, set the Generate Source Browse Information check box. 3. Click the BrowseInfo tab and set the Build Browse info check box. 4. Click OK. 5. Build your application. 6.
Building Programs and Libraries Page 24 of 44 When you select Build projectname from the Build menu (or one of the Build toolbars), the visual development environment automatically updates dependencies, compiles and links all files in your project. When you build a project, the visual development environment processes only the files in the project that have changed since the last build. The Rebuild All mode forces a new compilation of all source files listed for the project.
Building Programs and Libraries Page 25 of 44 You can force the build engine to recompile all source files in the project by selecting Rebuild All from the Build menu. This is useful to verify that all of your source code is clean, especially if you are using a foreign makefile, or if you use a new set of compiler options for all of the files in your project.
Building Programs and Libraries Page 26 of 44 Array elements per dimension 2,147,483,647 or process limit Constants; character and Hollerith 2000 characters Constants; characters read in list-directed I/O 2048 characters Continuation lines 511 DO and block IF statement nesting (combined) 128 DO loop index variable 2,147,483,647 or process limit Format group nesting 8 Fortran source line length 132 characters INCLUDE file nesting 10 Labels in computed or assigned GOTO list 500 Lexical t
Building Programs and Libraries Page 27 of 44 If your program is multithreaded, Windows NT starts each thread on whichever processor is available at the time. On a computer with one processor, the threads all run in parallel, but not simultaneously; the single processor switches among them. On a computer with more than one processor, the threads can run simultaneously.
Building Programs and Libraries Page 28 of 44 The redirection portion of the syntax must appear last on the command line. You can append the output to an existing file by using two greater-than signs (>>) instead of one. If the file does not exist, one is created. For more information about command-line redirection, see Redirecting CommandLine Output to Files. For more information: On using the debugger with Fortran programs, see Debugging Fortran Programs.
Building Programs and Libraries Page 29 of 44 a. In the Configurations dialog box, click the Add button. The Add Project Configuration dialog box appears. b. In the Configuration box, type a new configuration name. The names do not matter, as long as they differ from existing configuration names. c. Select the configuration from which to copy the settings for this configuration and click OK. Usually, you will want to copy the settings from a similar configuration.
Building Programs and Libraries To Locate: Page 30 of 44 Look: Roadmap to the Samples On the Visual Fortran CD-ROM, open the file: Info\Df\Samples\Samples.htm On your hard disk (after installation), open the file: ...\Microsoft Visual Studio\Df98\Samples\Samples.htm Samples folders On the Visual Fortran CD-ROM, locate folders under: Info\Df\Samples On your hard disk (after installation), locate folders under: ...\Microsoft Visual Studio\Df98\Samples For example, after a Custom installation, the ...
Building Programs and Libraries Page 31 of 44 DLL Samples Mixed-Language Programming Samples QuickWin Programming Samples Scientific Graphing (SciGraph) Utility Samples Tutorial Samples (illustrate Fortran language constructs) Miscellaneous Samples: n Includes a sample that converts data files created by Lahey Fortran to unformatted files which can be read by DVF Advanced Within the Advanced category, there are several other categories of samples.
Building Programs and Libraries Page 32 of 44 to rebuild a project configuration. The automation interfaces defined in DSAPPA.F90 are taken from ...\Microsoft Visual Studio\Common\Msdev98\Bin\devshl.dll. The Automation interfaces defined in DSBLDA.F90 are taken from ....\Microsoft Visual Studio\Common\Msdev98\Bin\devbld.pkg. This program is invoked with the following command line: dsbuild project.dsw configuration Where: project.
Building Programs and Libraries Page 33 of 44 window. This method is used to show a flicker-free spinning cube. OpenGL (Advanced\Opengl ) OpenGL is a protocol for performing advanced 3-dimensional graphics. Visual Fortran includes Fortran 90 modules and link libraries for using OpenGL from Fortran. The sample programs included in this section illustrate programs that take advantage of these facilities.
Building Programs and Libraries n n n n n n n n n Page 34 of 44 whenever the letter"A"is typed, up to a maximum of 32. Each thread bounces a happy face of a different color across the screen. All threads are terminated when the letter "Q" is typed. This particular application requires that several compatibility switches be set: /fpscomp:logicals, /fpscomp:ioformat, /fpscomp:general. These are found under the Compatibility entry on the Fortran tab of the BuildSettings dialog box.
Building Programs and Libraries n n n n n Page 35 of 44 identical to bootdisk image). This is a console program that is linked against dfwin.lib. generic: The generic sample demonstrates the basic concepts required in building a Windows application and could be used as a basis for building a first Windows program. The specific features that generic implements are: 1. Custom icon 2. Standard Menu Bar 3. Standard Help Menu 4. Full WinHelp Support 5. Keyboard Accelerator Usage 6.
Building Programs and Libraries Page 36 of 44 child windows. n menu: The menu sample demonstrates the use of popup menus, user defined menus and n n n n n n n n n n menu fuctions. It is a very simple program that allows you to select items off a menu, invoke a pop-up menu, and basically do little else, but is a good example of how to start with menus. mltithrd: The mltitrhd sample demonstrates the use of multiple threads. The main routine, mltithrd.
Building Programs and Libraries n n n n n n n n n n Page 37 of 44 values in the Time and Date edit fields, and click the SetInfo button. To set file attributes, set the appropriate check boxes and click on the SetAttr button. This sample also demonstrates the use of the GetFileTime() and SetFileTime() API calls. sharemem: The sharemem sample demonstrates the use of named shared memory between two independent processes. There are two projects in this sample, sharemem and othrproc.
Building Programs and Libraries Page 38 of 44 n world: The world sample demonstrates scaling and translating an image from a metafile with world coordinate transforms. It uses the calls SetWorldTransform() and PlayEnhMetaFile() to do the linear transformation between world space and page space, and to play the enhanced metafile. The sample provides a single sample metafile, sample.emf, although others could be used. n wxform: The wxform sample demonstrates world transforms.
Building Programs and Libraries Page 39 of 44 C\AxisScale2D: Uses the CAViewer interface to specify axis scales. C\Fractmtn: A C console application that creates a fractal landscape. Input parameters can be used to set the size of the array, the fractal dimension, and whether there is water in the landscape. A unique landscape is generated each time the program runs. C\FractmtnMFC: The MFC dialog-based version of C\Fractmtn. C\Mandel: Displays a fractal image.
Building Programs and Libraries Page 40 of 44 DLL\DLLEXP2: The DLLEXP2 sample demonstrates how COMMON variables defined in a DLL can be shared between multiple programs. Two programs are built against the same DLL. The first program is run, and then PAUSEs. The second program is run and changes the COMMON variables, and exits. When the first program resumes, it displays the changed values. DLL\LoadExp1: The LoadExp1 sample demonstrates how to dynamically map a DLL without using an import library.
Building Programs and Libraries Page 41 of 44 Mixed-Language (Mixlang) Visual Fortran can be called by a number of other languages, including Visual C/C++ and Visual Basic. Also, it can call other languages, such as C/C++. The following samples in subdirectories under ..
Building Programs and Libraries Page 42 of 44 set up a Windows application to call the Win32 API directly rather than using QuickWin to build your program. The following samples demonstrate how to use QuickWin, and how to program around some of the strange paradigms of the package. The following QuickWin examples can be found in subdirectories under ..\Df98\Samples\QuickWin: calendar: The calendar sample is a simple QuickWin application.
Building Programs and Libraries Page 43 of 44 Scientific Graphing Utility (SciGraph) SCIGRAPH is a package of Fortran routines for drawing scientific graphs. Graph types available include line, bar, XY, and pie graphs. All graphs are fully customizable, including control over axis, log scales, data points, colors and shades, error bars, and many other aspects of a scientific graph.
Building Programs and Libraries Page 44 of 44 conditions on intrinsic math calls. It uses the MATHERRQQ subroutine in MATHERR.F90. mbcomp: The mbcomp sample demonstrates the use of the National Language Support routines. namelist: The namelist sample demonstrates the NAMELIST Statement. percent: The percent sample demonstrates a user-defined operator, in this case a unary operator .c. that converts a floating point number to a "percentage".
Using the Compiler and Linker from the Command Line Page 1 of 17 Using the Compiler and Linker from the Command Line The DF command is used to compile and link your programs. In most cases, you will use a single DF command to invoke the compiler and linker. The DF command invokes a driver program that is the actual user interface to the compiler and linker. It accepts a list of command options and file names and directs processing for each file.
Using the Compiler and Linker from the Command Line Page 2 of 17 The DF command accepts the following types of options: Compiler options Linker options The command driver requires that the following rules be observed when specifying the DF command: Except for the linker options, options can be specified in any order. Linker options must be preceded by the keyword /link and must be specified at the end of the command line, following all other options.
Using the Compiler and Linker from the Command Line DF /warn:(argument_checking,declarations) Page 3 of 17 test.f90 Instead of the colon, you can use an equal sign (=): DF /warn=(argument_checking,declarations) test.f90 filename.ext Specifies the files to be processed. You can use wildcard characters (such as *.f90) to indicate multiple files or you can specify each file name. The file extension identifies the type of the file.
Using the Compiler and Linker from the Command Line /fast /[no]fixed /[no]fltconsistency (x86 only) /[no]fpconstant /fpe /fpp /[no]fpscomp /[no]free /granularity (Alpha only) /help or /? /iface /[no]include /[no]inline /[no]intconstant /integer_size /[no]keep /[no]libdir /libs /[no]link /[no]list /[no]logo /[no]machine_code /[no]map /math_library /[no]module /names /[no]object /[no]optimize /[no]pad_source /[no]pdbfile /[no]pipeline (Alpha only) /preprocess_only /real_size
Using the Compiler and Linker from the Command Line Page 5 of 17 For More Information: n On DF command examples, see Examples of the DF Command Format n On using the FL32 command, see Microsoft Fortran PowerStation Command-Line Compatibility n About Fortran Powerstation options (such as /MD) and their DF command equivalents, see Equivalent Visual Fortran Compiler Options Examples of the DF Command Format The following examples demonstrate valid and invalid DF commands: Valid DF commands In the following
Using the Compiler and Linker from the Command Line Page 6 of 17 DF myfile.for test.for /out:myprog.exe A correct form of this command is: DF myfile.for test.for /link /out:myprog.exe In this case, you can alternatively use one of the DF options (/exe) that specifies information to the linker: DF myfile.for test.for /exe:myprog.
Using the Compiler and Linker from the Command Line Page 7 of 17 A browser file (.SBR) if you specify the /browser option You control the production of these files by specifying the appropriate options on the DF command line. Unless you specify the /compile_only option or /keep option, the compiler generates a single temporary object file from one or more source files. The linker is then invoked to link the object file into one executable image file.
Using the Compiler and Linker from the Command Line /list:file .LST /map:file .MAP /pdbfile:file .PDB (default filename is df60.pdb) Page 8 of 17 Temporary Files Temporary files created by the compiler or linker reside in the directory used by the operating system to store temporary files. To store temporary files, the operating system first checks for the TMP environment variable. If the TMP environment variable is defined, the directory that it points to is used for temporary files.
Using the Compiler and Linker from the Command Line Page 9 of 17 and files. The options and files specified by the DF environment variable are added to the DF command; they are processed before any options specified on the command line. You can override an option specified in the DF environment variable by specifying an option on the command line. For information about using the DF environment variable to specify frequentlyused options, see Using the DF Environment Variable to Specify Options.
Using the Compiler and Linker from the Command Line Page 10 of 17 For an introduction to Visual Fortran project types, see Types of Projects. Redirecting Command-Line Output to Files When using the command line, you can redirect standard output and standard error into separate files or into a single file. How you redirect command-line output depends on which operating system you are using: On Windows NT systems, to place standard output into file one.out and standard error into file two.
Using the Compiler and Linker from the Command Line Page 11 of 17 By default, when you use the DF command, your source files are compiled and then linked. To suppress linking, use the /compile_only option.
Using the Compiler and Linker from the Command Line Page 12 of 17 DF myprog.for /show:map If the options specified on the command line conflict with the options specified by the DF environment variable, the option specified on the command line takes precedence. In the following command sequence, the /debug:minimal option specified by the DF environment variable is overridden by the /debug:none option specified on the command line: set DF=/debug:minimal /list DF myprog.
Using the Compiler and Linker from the Command Line Page 13 of 17 file, a separate listing file is generated for each object file created. The content of the listing file is affected by the /show option. For more information about this option, see Compiler and Linker Options. The following command compiles and links a.for, b.for, and c.for. It generates one listing file for the three source files: DF a.for b.for c.for /list The following command compiles a.for, b.for, and c.for.
Using the Compiler and Linker from the Command Line Page 14 of 17 The following command links against single-threaded DLLs. It links against the default libraries and mylib.lib: DF x.f90 /libs:dll mylib.lib For more information on the types of libraries available to link against, see the following: /dbglibs /libs /threads /winapp /fpscomp:libs To request the creation of a dynamic-link library, see /dll.
Using the Compiler and Linker from the Command Line Page 15 of 17 Compiling and Linking for Optimization If you omit both the /compile_only and the /keep options, the specified Fortran source files are compiled together into a single object module and then linked. (The object file is deleted after linking.) Because all the Fortran source files are compiled together into a single object module, full interprocedural optimizations can occur.
Using the Compiler and Linker from the Command Line Page 16 of 17 For more information about compiling and linking Visual Fortran and Visual C++® programs, and the libraries used, see Visual Fortran/Visual C++ Mixed-Language Programs. DF Indirect Command File Use The DF command allows the use of indirect command files. For example, assume the file text.txt contains the following: /pdbfile:testout.pdb /exe:testout.exe /debug:full /optimize:0 test.f90 rest.
Using the Compiler and Linker from the Command Line Page 17 of 17 Diagnostic messages usually provide enough information for you to determine the cause of an error and correct it. When using the command line, make sure that the appropriate environment variables have been set by executing the DFVARS.BAT file or by using the Fortran Command Window from the Visual Fortran program folder (see Using the Command-Line Interface in Getting Started).
Compiler and Linker Options Page 1 of 111 Compiler and Linker Options Most of the compiler and linker options can be specified within the Microsoft visual development environment or on the command line. This section contains a description of the options available to you in building programs. You can set compiler options from: Within the visual development environment, by using the Fortran tab in the Project menu, Settings dialog box. The DF command line.
Compiler and Linker Options Page 2 of 111 Figure: Project Settings, Fortran Tab The options are grouped under functional categories (the initial Category is General, as shown) to help you locate the options needed for your application.
Compiler and Linker Options Page 3 of 111 If a compiler option is not available in the dialog boxes, you can enter the option in the lower part of the Project Settings dialog box just as you would at the command line (under Project Options:).
Compiler and Linker Options Page 4 of 111 Microsoft Fortran PowerStation: Libraries /fpscomp:[no]libs Microsoft Fortran PowerStation: Logical Values /fpscomp:[no]logicals Microsoft Fortran PowerStation: Other Run-time Behaviour /fpscomp:[no]general Microsoft Fortran PowerStation: Predefined Preprocessor Symbols /fpscomp:[no]symbols Compilation Diagnostic Options Compilation Error Limit /[no]error_limit Warning Levels (Ignore, Normal, Treat Warnings as Errors) /warn:nogeneral, default settings,
Compiler and Linker Options Page 5 of 111 External Procedures (and Argument Passing) Options Argument Passing Conventions /[no]iface:keyword External Names Case Interpretation /names:keyword String Length Argument Passing /[no]iface:mixed_str_len_arg Append Underscore to External Names /assume:[no]underscore Fortran Data Options (See also Compatibility) Default REAL and COMPLEX Kind /real_size:num Default INTEGER and LOGICAL Kind /integer_size:num Append Underscore to External Names (under Data
Compiler and Linker Options Page 6 of 111 Fortran Language Options Enable FORTRAN 66 Semantics /[no]f66 Enable Alternate PARAMETER Syntax /[no]altparam Name Case Interpretation /names:keyword Source Form (File Extension, Fixed Form, or Free Form) /[no]free or /[no]fixed Fixed-Form Line Length /[no]extend_source Pad Fixed-Form Source Records /[no]pad_source Library Options (See also External Procedures) Use Multi-Threaded Library /[no]threads Enable Reentrancy Support /[no]reentrancy Use Fort
Compiler and Linker Options Page 7 of 111 Software Instruction Scheduling /[no]pipeline (Alpha only; command line only) Display Help Text File /help or /? (command line only) Specify Custom File Extension for Compiler /source (command line only) Specify Custom File Extension for Compiler /extfor (command line only) Specify Custom File Extension for Linker /extlnk (command line only) Create one object file for each input source file /[no]keep (command line only) Name of Executable Program or DL
Compiler and Linker Options Page 8 of 111 Math Library: Checking or Fast Performance /math_library Inlining Procedures /[no]inline Code Tuning for x86 or Alpha Chip /tune Allow Reordering of Floating-Point Operations /assume:[no]accuracy_sensitive Software Instruction Scheduling /[no]pipeline (Alpha only; command line only) Preprocessor Options Define Preprocessor Symbols /define Default INCLUDE and USE Path /assume:[no]source_include Module path (to place module files) /module[:file] INCL
Compiler and Linker Options Page 9 of 111 /alignment[:keyword...], /noalignment, or /Zpn The /alignment option specifies the alignment of data items in common blocks, record structures, and derived-type structures. The /Zpn option specifies the alignment of data items in derived-type or record structures. The /alignment options are: n /align:[no]commons The /align:commons option aligns the data items of all COMMON data blocks on natural boundaries up to four bytes.
Compiler and Linker Options /Zp4 /align:rec4byte /alignment /Zp8 with /align:dcommons, /alignment:all, or /alignment:(dcommons,records) /noalignment /Zp1, /alignment:none, or /alignment:(nocommons,nodcommons,norecords) Page 10 of 111 /align:rec1byte /align:norecords /align:rec8byte /align:records When you omit the /alignment option, records and components of derived types are naturally aligned, but fields in common blocks are packed.
Compiler and Linker Options Page 11 of 111 The /architecture (/arch) option controls the types of processor-specific instructions generated for this program unit. The /arch:keyword option uses the same keywords as the /tune:keyword option. All processors of a certain architecture type (Alpha or x86) implement a core set of instructions. Certain (more recent) processor versions include additional instruction extensions.
Compiler and Linker Options Page 12 of 111 n /arch:host Generates code for the processor generation in use on the system being used for compilation. Depending on the host system used on Alpha systems, the program may or may not run on other Alpha processor generations: n Programs compiled on an ev4 or ev5 chip Alpha system with the host keyword will run on all Alpha processor generations. n Programs compiled on an ev56 chip system with the host keyword should not be run on ev4 and ev5 processors.
Compiler and Linker Options Page 13 of 111 /asmattributes:keyword, /noasmattributes, /FA, /FAs, /FAc, or /FAcs The /asmattributes option indicates what information, in addition to the assembly code, should be generated in the assembly listing file. In the visual development environment, specify Assembly Options in the Listing File Compiler Option Category. The /asmattributes options are: n /asmattributes:source or /FAs Intersperses the source code as comments in the assembly listing file.
Compiler and Linker Options Page 14 of 111 n /FAs[file] provides interspersed source code as comments in the assembly listing file. n /FAc[file] provides a list of hex machine instructions at the beginning of each line of assembly code. n /FAcs[file] provides interspersed source code as comments and lists hex machine instructions at the beginning of each line of assembly code.
Compiler and Linker Options Page 15 of 111 For more information on /assume:noaccuracy_sensitive, see Arithmetic Reordering Optimizations. n /assume:[no]buffered_io The /assume:buffered_io option controls whether records are written (flushed) to disk as each record is written (default) or accumulated in the buffer.
Compiler and Linker Options Page 16 of 111 In the visual development environment, specify Enable Dummy Argument Aliasing in the Fortran Data (or Optimizations) Compiler Option Category. These program semantics do not strictly obey the Fortran 90 Standard and they slow performance. If you omit /assume:dummy_aliases, the compiler does not need to make these assumptions, which results in better run-time performance.
Compiler and Linker Options Page 17 of 111 In the visual development environment, specify Append Underscore to External Names in the External Procedures (or Fortran Data) Compiler Option Category. Specifying /assume:nounderscore option does not append an underscore character to external user-defined names. This is the default.
Compiler and Linker Options Page 18 of 111 Syntax: /browser[:filename], /nobrowser, or /FR The /browser or /FR option controls the generation of source browser information. When the /browser option is not specified, the compiler will not generate browser files (same as /nobrowser). In the visual development environment, specify Generate Source Browse Information in the General Compiler Option Category. Also, in the BrowseInfo tab, set Build Browse info check box instead of using BCSMAKE.
Compiler and Linker Options Page 19 of 111 /check:bounds (Array and String bounds) /check:flawed_pentium (x86 systems) (Flawed Pentium) /check:format (Edit Descriptor Data Type) /check:output_conversion (Edit Descriptor Data Size) /check:overflow (Integer Overflow) /check:[no]power (Power Operations) /check:underflow (Floating Point Underflow) /4Yb /check:none, /nocheck, or /4Nb /check or /check:all On x86 systems, if you omit these options, the default is: /check:(nobounds,flawed_pentium,noformat
Compiler and Linker Options Page 20 of 111 n /check:format Requests a run-time error message when the data type for an item being formatted for output does not match the FORMAT descriptor. Specifying /check:noformat suppresses the run-time error message for this condition. n /check:output_conversion Requests a run-time message (number 63) when format truncation occurs (when a number is too large to fit in the specified format field length without loss of significant digits).
Compiler and Linker Options Page 21 of 111 Equivalent to: /check:(bounds,flawed_pentium,format,power,output_conversion,overflow,underflow). /[no]comments Syntax: /comments or /nocomments The /comments option writes C-style comments to the output file. The /nocomments option does not write C-style comments to the output file. This option applies only to the FPP preprocessor. For more information, type FPP /? to view FPP options.
Compiler and Linker Options Page 22 of 111 Compatibility Compiler Option Category. The /convert options are: /convert:big_endian /convert:cray /convert:ibm /convert:little_endian /convert:native /convert:vaxd /convert:vaxg n /convert:big_endian Specifies that unformatted files containing numeric data are in IEEE big endian (nonnative) format.
Compiler and Linker Options Page 23 of 111 n Integer data is in native little endian format. n REAL(KIND=4) and COMPLEX(KIND=4) (SINGLE PRECISION) data is in VAX F_floating format. n REAL(KIND=8) and COMPLEX (KIND=8) (DOUBLE PRECISION) data is in VAX D_floating format. n /convert:vaxg Specifies that numeric data in unformatted files is in VAXG little endian format, as follows: n Integer data is in native little endian format.
Compiler and Linker Options Page 24 of 111 /libs:keyword and /[no]threads options, and is one of: libcd.lib, libcmtd.lib, or (see Visual Fortran/Visual C++ Mixed-Language Programs). msvcrtd.lib /[no]debug Syntax: /debug:keyword, /nodebug, /Z7, /Zd, or /Zi The /debug, /Z7, /Zd, or /Zi option controls the level of debugging information associated with the program being compiled. In the visual development environment, specify the Debugging Level in the General or Debug Compiler Option Category.
Compiler and Linker Options Page 25 of 111 smaller than if you specified /debug:full. n /debug:full, /debug, /Zi, or /Z7 If you specify /debug:full, /debug, /Zi, or /Z7, the compiler produces symbol table information needed for full symbolic debugging of unoptimized code and global symbol information needed for linking. This is the default for a debug configuration in the visual development environment.
Compiler and Linker Options Page 26 of 111 Predefined Preprocessor Symbols _DF_VERSION_= 600 (600 for Version 6.
Compiler and Linker Options Page 27 of 111 Syntax: /error_limit[:count] or /noerror_limit The /error_limit option specifies the maximum number of error-level or fatal-level compiler errors allowed for a given file before compilation aborts. If you specify /noerror_limit (command line), there is no limit on the number of errors that are allowed. In the visual development environment, specify the Compilation Error Limit in the Compilation Diagnostics Compiler Option Category.
Compiler and Linker Options Page 28 of 111 /extfor:ext The /extfor: option specifies file extensions to be processed (/extfor) by the DIGITAL Fortran compiler. One or more file extensions can be specified. A leading period before each extension is optional (for and .for are equivalent). /extfpp Syntax: /extfpp:ext The /extfpp option specifies file extensions to be processed (/extfpp) by the FPP preprocessor. One or more file extensions can be specified.
Compiler and Linker Options Page 29 of 111 Syntax: /f77rtl or /nof77rtl The /f77rtl option controls the run-time support that is used when a program is executed. Specifying /f77rtl uses the DIGITAL Fortran 77 run-time behavior. In the visual development environment, specify Enable F77 Run-Time Compatibility in the Compatibility Compiler Option Category. Specifying /nof77rtl uses the Visual Fortran (DIGITAL Fortran 90) run-time behavior. Unless you specify /f77rtl, /nof77rtl is used.
Compiler and Linker Options Page 30 of 111 n Files with an extension of .f90 or .F90 are assumed to be free-format source files. n Files with an extension of .f, .for, .FOR, or .i are assumed to be fixed-format files. /[no]fltconsistency (x86 only) Syntax: /fltconsistency, /nofltconsistency, or /Op The /fltconsistency or /Op option enables improved floating-point consistency on x86 systems.
Compiler and Linker Options Page 31 of 111 /fpe Syntax: /fpe:level The /fpe:level option controls floating-point exception handling at run time for the main program. This includes whether exceptional floating-point values are allowed and how precisely run-time exceptions are reported. The /fpe:level option specifies how the compiler should handle the following floating-point exceptions: n When floating-point calculations result in a divide by zero, overflow, or invalid data.
Compiler and Linker Options Page 32 of 111 only) displayed only if /check:underflow is also specified. Use of a denormalized (or exceptional) number in an arithmetic expression results in program continuation, but with slower performance. /fpe:3 (default on x86 systems) Leaves any calculated denormalized The program continues. No message is value as is. The program continues, displayed. A NaN or Infinity (+ or -) allowing gradual underflow. Use of will be generated.
Compiler and Linker Options Page 33 of 111 zero (0). The program continues. The number of underflowed results are counted and messages are displayed for the first two occurrences. /fpe:0 Yes Yes The underflowed result is set to zero (0). The program continues. The number of underflowed results are counted and messages are displayed for the first two occurrences. /fpe:3 No No Denormalized results are allowed and the program continues. Traps are masked and no handlers are invoked.
Compiler and Linker Options Page 34 of 111 For more information on IEEE floating-point exception handling, see the IEEE Standard for Binary Floating-Point Arithmetic (ANSI/IEEE Standard 754-1985). /fpp Syntax: /fpp[:"options"] The /fpp option activates the FPP preprocessor and optionally passes options to FPP as is. The FPP preprocessor can process both free- and fixed-form Fortran source files.
Compiler and Linker Options Page 35 of 111 language features within the compiler are compatible with Visual Fortran or Microsoft Fortran PowerStation. If you experience problems when porting applications from Fortran PowerStation, specify /fpscomp:keyword (or /fpscomp:all). When porting applications from DIGITAL Fortran, use /fpscomp:none or /fpscomp:libs (the default). In the visual development environment, specify the PowerStation 4.0 Compatibility Options in the Compatibility Compiler Option Category.
Compiler and Linker Options Page 36 of 111 For example, assume a program OPENTEST contains the following statements: OPEN(UNIT = 2, FILE = ’ ’) OPEN(UNIT = 3, FILE = ’ ’) OPEN(UNIT = 4, FILE = ’ ’) The command line, opentest test.dat " " assigns the file TEST.DAT to Unit 2, prompts the user for a filename to associate with Unit 3, then prompts again for a filename to associate with Unit 4.
Compiler and Linker Options Page 37 of 111 Note: Allowing files that are not opened with sequential access (such as ACCESS="DIRECT") to be used with the REWIND statement violates the Fortran 90 standard and may be removed in the future. Section 9.5 states the following: "A file that is not connected for sequential access must not be referred to by a BACKSPACE, an ENDFILE, or a REWIND statement..." n The READ statement n Formatted: READ(eunit, format [, advance][, iostat]...
Compiler and Linker Options Page 38 of 111 n The UNFORMATTED specifier returns the value "NO" instead of "UNKNOWN" when it is not known whether unformatted I/O can be performed to the file and when /fpscomp:general is set. Note: Returning the value "NO" instead of "UNKNOWN" for this specifier violates the Fortran 90 standard and may be removed in the future. See Section 9.6.1.12.
Compiler and Linker Options Page 39 of 111 n Gives direct access formatted files the same record type as Fortran PowerStation when /fpscomp:general is set. This means accounting for the trailing Carriage Return/Line Feed pair () which is part of the record. n The STOP statement Writes the Fortran PowerStation output string and/or returns the same exit condition values when /fpscomp:general is set. n The WRITE statement n Formatted: WRITE(eunit, format [, advance][, iostat]...
Compiler and Linker Options Page 40 of 111 Fortran PowerStation semantic conventions and record formats (see Microsoft Fortran PowerStation Compatible Files). Specify /fpscomp:noioformat to request DIGITAL Fortran semantic conventions. This affects the following Fortran features: n The WRITE statement n Formatted List-Directed: WRITE(eunit, * [, iostat]...) n Formatted Internal List-Directed: WRITE(iunit, * [, iostat]...) n Formatted Namelist: WRITE(eunit, nml-group [, iostat]...
Compiler and Linker Options Page 41 of 111 REAL(4) 1PG15.7E2 1PG16.6E2 REAL(8) 1PG24.15E3 1PG25.15E3 COMPLEX(4) ’( ’,1PG14.7E2, ’, ’,1PG14.7E2, ’) ’ ’( ’,1PG16.6E2, ’, ’,1PG16.6E2, ’) ’ COMPLEX(8) ’( ’,1PG23.15E3, ’, ’,1PG23.15E3, ’) ’ ’( ’,1PG25.15E3, ’, ’,1PG25.15E3, ’) ’ CHARACTER Aw 3 Aw 3 n The READ statement n Formatted List-Directed: READ(eunit, * [, iostat]...) n Formatted Internal List-Directed: READ(iunit, * [, iostat]...) n Formatted Namelist: READ(eunit, nml-group [, iostat]...
Compiler and Linker Options Page 42 of 111 n The INQUIRE statement specifiers OPENED, IOFOCUS, EXISTS, and NAMED. n The EOF intrinsic function. n The BTEST intrinsic function. n The lexical intrinsic functions LLT, LLE, LGT, and LGE. n /fpscomp:[no]symbols Adds one or more symbols related to Microsoft Fortran PowerStation to preprocessor and compiler invocations. The symbol currently set by specifying /fpscomp:symbols is _MSFORTRAN_=401.
Compiler and Linker Options Page 43 of 111 /granularity:keyword On Alpha systems, the /granularity option ensures that data of the specified or larger size can be accessed from different threads sharing data in memory. Such data must be aligned on the natural boundary and declared as VOLATILE (so it is not held in registers). This option is ignored on x86 processor systems. In the visual development environment, specify the Thread Access Granularity in the Fortran Data Compiler Option Category.
Compiler and Linker Options Page 44 of 111 for general arguments and for hidden-length character arguments. In the visual development environment, specify the Default Calling Conventions and the String Length Argument Passing in the External Procedures Compiler Option Category. The /iface keywords are as follows: n The general argument-passing convention keywords are one of: cref, stdref, and default (stdref and default are equivalent).
Compiler and Linker Options Page 45 of 111 In the visual development environment, specify Custom INCLUDE and USE Path in the Preprocessor Compiler Option Category. When module or include file names do not begin with a device or directory name, the directories searched are as follows: 1. The directory containing the first source file or the current directory (depends on whether /assume:source_include was specified). 2. The current default directory where the compilation is taking place 3.
Compiler and Linker Options Page 46 of 111 Prevents the inlining of procedures, except for statement functions. This type of inlining occurs when you specify /optimize:0 or /Od. n /inline:manual Prevents the inlining of procedures, except for statement functions. This type of inlining occurs when you specify /optimize:0 or /Od. n /inline:size Inlines procedures that will improve run-time performance without significantly increasing program size.
Compiler and Linker Options Page 47 of 111 Integer Kind in the Fortran Data Compiler Option Category. These options are: n /integer_size:16 or /4I2 makes the default integer and logical variables 2 bytes long. INTEGER and LOGICAL declarations are treated as (KIND=2). n /integer_size:32 makes the default integer and logical variables 4 bytes long (default). INTEGER and LOGICAL declarations are treated as (KIND=4).
Compiler and Linker Options Page 48 of 111 n /libdir:automatic Requests the insertion of linker search path directives for libraries automatically determined by the DF command driver (default libraries). To prevent the insertion of linker directives for default libraries, specify /libdir:noautomatic or /Zl. In the visual development environment, specify Disable Default Library Search Rules (for /libdir:noautomatic) in the Libraries Compiler Option Category.
Compiler and Linker Options Page 49 of 111 Specifying /libs:static with /nothreads and /dbglibs is equivalent to /MLd. Specifying /libs:static with /threads is equivalent to /MT. Specifying /libs:static with /threads and /dbglibs is equivalent to /MTd. n /libs:qwin or /MW Specifying /libs:qwin or /MW requests linking with libraries required of a Fortran QuickWin multi-doc (QuickWin) application.
Compiler and Linker Options Page 50 of 111 n Click the Linker tab n Select the General category n Type the additional library name to be linked with under Object/Library modules, such as mylib.lib n Click OK when done The /nolink option suppresses linking and forces an object file to be produced even if only one program is compiled. Any options specified after the /nolink option are ignored.
Compiler and Linker Options Page 51 of 111 /[no]machine_code Syntax: /machine_code or /nomachine_code The /machine_code option requests that a machine language representation be included in the listing file. The /machine_code option is a synonym for /show:code. In the visual development environment, specify Source Listing Options, Machine Code in the Listing File Compiler Option Category. This option is ignored unless you specify /list[:file] or /Fsfile.
Compiler and Linker Options Page 52 of 111 with good performance and error checking. This is the default on Alpha systems (unless the /fast option is specified). The standard math library routines are designed to obtain very accurate "near correctly rounded" results and provide the robustness needed to check for IEEE exceptional argument values, rather than achieve the fastest possible run-time execution speed.
Compiler and Linker Options Page 53 of 111 The /module option controls where the module files (extension MOD) are placed. If you omit this option (or specify /nomodule), the .MOD files are placed in the directory where the source file being compiled resides. When /module:path is specified, the path specifies the directory location where the module files will be placed. In the visual development environment, specify the Module Path in the Preprocessor Compiler Option Category.
Compiler and Linker Options Page 54 of 111 /nodefine Syntax: /nodefine The /nodefine option requests that all symbols specified by the accompanying /define:symbols option apply only to the Fortran preprocessor, FPP, and are not available to conditional compilation directives (such as the IF Directive Construct).
Compiler and Linker Options Page 55 of 111 The /optimize option controls the level of optimization performed by the compiler. To provide efficient run-time performance, DIGITAL Fortran increases compile time in favor of decreasing run time. If an operation can be performed, eliminated, or simplified at compile time, the compiler does so rather than have it done at run time.
Compiler and Linker Options Page 56 of 111 Specifying /Ox sets: /optimize:4, /math_library:check, and /assume:nodummy_aliases. Specifying /Oxp sets: /optimize:4, /math_library:check, /assume:nodummy_aliases, and /fpconsistency (x86 systems). n /optimize:5 On x86 systems, activates the loop transformation optimizations (also set by /transform_loops).
Compiler and Linker Options Page 57 of 111 /pad_source or /nopad_source The /pad_source option requests that source records shorter than the statement field width are to be padded with spaces on the right out to the end of the statement field. This affects the interpretation of character and Hollerith literals that are continued across source records. In the visual development environment, specify the Pad Fixed-Form Source Records in the Fortran Language Compiler Option Category.
Compiler and Linker Options Page 58 of 111 in the Optimizations Compiler Option Category. For this version of Visual Fortran, loops chosen for software pipelining are always innermost loops and do not contain branches, procedure calls, or COMPLEX floating-point data. Software pipelining can be more effective when you combine /pipeline with the appropriate /tune:keyword keyword option for the target Alpha processor generation.
Compiler and Linker Options Page 59 of 111 n /real_size:32 Defines REAL declarations, constants, functions, and intrinsics as REAL(KIND=4) (SINGLE PRECISION). It also defines COMPLEX declarations, constants, functions, and intrinsics as COMPLEX(KIND=4) (COMPLEX). This is the default. n /real_size:64 or /4R8 Defines REAL declarations, constants, functions, and intrinsics as REAL(KIND=8) (DOUBLE PRECISION). It also defines COMPLEX declarations, constants, functions, and intrinsics as COMPLEX(KIND=8).
Compiler and Linker Options Page 60 of 111 /rounding_mode (Alpha only) Syntax: /rounding_mode:keyword On Alpha systems, the /rounding_mode option allows you to control how rounding occurs during floating-point calculations. The rounding mode applies to each program unit being compiled. For information on setting the rounding mode on x86 systems, see Floating-Point Control Word (x86 only). In the visual development environment, specify the Rounding Mode in the Floating Point Compiler Option Category.
Compiler and Linker Options Page 61 of 111 /[no]show Syntax: /show:keyword... or /noshow The /show option specifies what information is included in a listing. In the visual development environment, specify the Source Listing Options in the Listing File Compiler Option Category.
Compiler and Linker Options Page 62 of 111 The /source or /Tf option indicates that the file is a Fortran source file with a non-standard file extension (not one of .F, .FOR, or .F90) that needs to be compiled. The default for any file that does not have an extension of .F90 or .f90 is to be a fixed-format Fortran file.
Compiler and Linker Options Page 63 of 111 compiler under the following circumstances: n The statements contain ordinary syntax and semantic errors. n A source program containing nonconforming statements is compiled with the /stand or /check options. Given these circumstances, the compiler is able to detect most instances of nonconforming usage. It does not detect all instances because the /stand option does not produce checks for all nonconforming usage at compile time.
Compiler and Linker Options Page 64 of 111 instruction that causes it. This slows program execution, so only specify it when debugging a specific problem, such as locating the source of an exception. In the visual development environment, specify Enable Synchronous Exceptions in the RunTime (or Floating Point) Compiler Option Category.
Compiler and Linker Options Page 65 of 111 /traceback or /notraceback or /Zt The /traceback option requests that the compiler generate extra information in the object file that allows the display of source file traceback information at run time when a severe error occurs. Specifying /traceback: n Provides source file, routine name, and line number correlation information in the text that is displayed when a severe error occurs.
Compiler and Linker Options Page 66 of 111 The /transform_loops (or /optimize:5) option activates a group of loop transformation optimizations that apply to array references within loops. These optimizations can improve the performance of the memory system and usually apply to multiple nested loops. The loops chosen for loop transformation optimizations are always counted loops (which include DO or IF loops, but not uncounted DO WHILE loops).
Compiler and Linker Options Page 67 of 111 Tuning for a specific implementation can improve run-time performance; it is also possible that code tuned for a specific processor may run slower on another processor. Regardless of the /tune:keyword option you use, the generated code runs correctly on all implementations of the processor architecture. If you omit /tune:keyword, /tune:generic is used. In the visual development environment, specify the Optimize For in the Optimizations Compiler Option Category.
Compiler and Linker Options Page 68 of 111 Generates and schedules code for the 21164 chip implementations that use the byte and word manipulation instruction extensions of the Alpha architecture. n /tune:pca56 (Alpha only) Generates and schedules code for the 21164PC chip implementation that uses the byte and word manipulation instruction extensions and multimedia instruction extensions of the Alpha architecture.
Compiler and Linker Options Page 69 of 111 and grouping more instructions together to allow efficient overlapped instruction execution (instruction pipelining). The best candidates for loop unrolling are innermost loops with limited control flow. Especially on x86 systems, specifying a higher value may improve run-time performance of certain applications. For more information, see Loop Unrolling.
Compiler and Linker Options Page 70 of 111 n Changes internal file writes using list-directed I/O. A list-directed write to an internal file results in removal of the first character from the first element; the field length is decremented accordingly. n The run-time direct access READ routine checks the first byte of the retrieved record. If this byte is ’@’ or NULL (’\0’), then ATTACCNON is returned.
Compiler and Linker Options Page 71 of 111 If you omit /warn, the defaults are: n For the DF command: /warn:(alignments,noargument_checking,nodeclarations,noerrors,fileopts, general,granularity,nostderrors,notruncated_source,uncalled,uninitialized,nounused,usage) n For the FL32 command: /warn:(alignments,argument_checking,nodeclarations,noerrors,nofileopts, general,granularity,nostderrors,notruncated_source,uncalled,uninitialized,nounused,usage) The /warn keywords are: n /warn:noalignments Suppresses wa
Compiler and Linker Options Page 72 of 111 n /warn:truncated_source Requests that the compiler issue a warning diagnostic message when it reads a source line with a statement field that exceeds the maximum column width in fixed-format source files. The maximum column width for fixed-format files is column 72 or 132, depending whether the /extend_source option was specified. This option has no effect on truncation; lines that exceed the maximum column width are always truncated.
Compiler and Linker Options Page 73 of 111 /watch[:keyword] or /nowatch The /watch option requests the display of processing information to the console terminal. The default is /watch:source.
Compiler and Linker Options Page 74 of 111 n /[no]threads n /[no]dbglibs n /fpscomp:libs For information on Fortran Windows Applications, including requesting additional link libraries with the FULLAPI.F90 file, see Creating Windows Applications. Linker Options and Related Information You can set Linker options from: n The DF command line. When using the DF command line, specify linker options after the /LINK option. For example: DF file.f90 file.lib /LINK /NODEFAULTLIB n The LINK command line.
Compiler and Linker Options Page 75 of 111 Microsoft format (CV), COFF format, or both. /DEF Passes a module-definition (.DEF) file to the linker. /DEFAULTLIB Adds one or more libraries to the list of libraries that LINK searches when resolving references. /DELAY Controls the delayed loading of DDLs. /DELAYHOLD Causes delayed loading of DLLs. /DLL Builds a DLL as the main output file when using the command line. /DRIVER Used to build a Windows NT kernel mode driver.
Compiler and Linker Options Page 76 of 111 /MACHINE Specifies the target platform for the program. /MAP Informs the linker to generate a mapfile. You can also specify the file name. /MAPINFO Informs the linker to include the specified information in a map file (requested by /MAP). /MERGE Combines the first section with the second section and names the resulting section.
Compiler and Linker Options Page 77 of 111 to the Output window. /VERSION Informs the linker to put a version number in the header of the executable file or DLL. /VXD Creates a virtual device driver (VxD). /WARN Determines the output of LINK warnings. /WS Adds the WS_AGGRESSIVE attribute to your application’s image. This table lists the Linker options with the equivalent Microsoft visual development environment category if one is available.
Compiler and Linker Options Page 78 of 111 /PROFILE General Category /STACK Output Category /VERBOSE Customize Category /VERSION Output Category Besides discussing linker options individually, this section also discusses Module-Definition Files and Linker Reserved Words. Setting LINK Options in the Visual Development Environment You can set linker options in the Microsoft visual development environment by using the Link tab in the Build Settings dialog box.
Compiler and Linker Options Page 79 of 111 Input category Command-line equivalent Object/Library Modules filename on command line Ignore Libraries /NODEFAULTLIB:library Ignore All Default Libraries /NODEFAULTLIB Force Symbol References /INCLUDE:symbol MS-DOS Stub File Name /STUB:filename Customize category Command-line equivalent Use Program Database /PDB:filename Link Incrementally /INCREMENTAL:{YES|NO} Program Database Name /PDB:filename Output File Name /OUT:filename Force File Output
Compiler and Linker Options Page 80 of 111 Specify numeric arguments in decimal or C-language notation. (The digits 1-9 specify decimal values, an integer constant preceded by a zero (0) specifies an octal value, and an integer constant preceded by zero and x (0x or 0X) specifies a hexadecimal value.) Option names and their keyword or filename arguments are not case sensitive, but identifiers as arguments are case sensitive. LINK first processes options specified in the LINK environment variable.
Compiler and Linker Options Page 81 of 111 program. Indicate a comment by a semicolon (;). Comments can be on the same or a separate line. The linker ignores all text from the semicolon to the end of the line. The following example shows part of such a file: main one two 0x00010000 0x28000000 0x28100000 0x08000000 0x00100000 0x00300000 ; for PROJECT.EXE ; for DLLONE.DLL ; for DLLTWO.DLL If the file that contains these lines is called DLLS.TXT, the following example command applies this information.
Compiler and Linker Options Page 82 of 111 An executable file or DLL created for debugging contains the name and path of the corresponding PDB. Visual Fortran reads the embedded name and uses the PDB when you debug the program. The linker uses the base name of the program and the extension .PDB to name the PDB, and embeds the path where it was created. To override this default, use /PDB:filename. The object files must contain debugging information.
Compiler and Linker Options Page 83 of 111 n /DEBUGTYPE:BOTH This option generates both COFF debugging information and old-style Microsoft debugging information. When you set this option, the linker does not create a PDB; in addition, incremental linking is disabled. The linker must call the CVPACK.EXE tool to process the old-style Microsoft debugging information. CVPACK must be in the same directory as LINK or in a directory in the PATH environment variable.
Compiler and Linker Options Page 84 of 111 /DELAY Syntax: /DELAY[:dllname] Controls delayed loading of DDLs: n The unload qualifier tells the delay-load helper function to support explicit unloading of the DLL by resetting the IAT to its original form, invalidating IAT pointers and causing them to be overwritten. n The nobind qualifier tells the linker not to include a bindable IAT in the final image. The resulting image cannot be statically bound.
Compiler and Linker Options Page 85 of 111 In the visual development environment, you can set this option by choosing Dynamic-Link Library under Project Type in the New Project dialog box. /DRIVER Syntax: /DRIVER[:UPONLY] Builds a Windows NT kernel mode driver. The linker will perform some special optimizations if this option is selected.
Compiler and Linker Options Page 86 of 111 Syntax: /EXETYPE:DYNAMIC Used when building a virtual device driver (VxD). A VxD is linked using the /VXD option. Specify DYNAMIC to create a dynamically-loaded VxD. /EXPORT Syntax: /EXPORT:entryname[=internalname][, @ordinal [, NONAME]] [, DATA] Lets you export a function from your program to allow other programs to call the function. You can also export data. Exports are usually defined in a DLL.
Compiler and Linker Options Page 87 of 111 and how to use decorated names, see Adjusting Naming Conventions in Mixed-Language Programming. /FIXED Syntax: /FIXED Tells the operating system to load the program only at its preferred base address. If the preferred base address is unavailable, the operating system does not load the file. For more information on base address, see /BASE. When you specify /FIXED, LINK does not generate a relocation section in the program.
Compiler and Linker Options Page 88 of 111 /GPSIZE:num For Alpha systems, controls whether communal variables (uninitialized global data items) are allocated in .sdata or .bss. Communal variables smaller than or equal to the /GPSIZE value are allocated in .sdata. Communal variables larger than this value are allocated in .bss. /HEAP Syntax: /HEAP:reserve,[commit] Sets the size of the heap in bytes. The reserve argument specifies the total heap allocation in virtual memory. The default heap size is 1MB.
Compiler and Linker Options Page 89 of 111 /IMPORT Syntax: /IMPORT This option is specific to MACOS and does not apply to Visual Fortran. /INCLUDE Syntax: /INCLUDE:symbol Tells the linker to add a specified symbol to the symbol table. Specify a symbol name in the text box. To specify multiple symbols, specify /INCLUDE:symbol once for each symbol. The linker resolves symbol by adding the object that contains the symbol definition to the program.
Compiler and Linker Options Page 90 of 111 options are incompatible with incremental linking. LINK performs a full link if any of the following options are specified: n n n n n n n Link Incrementally is turned off (/INCREMENTAL:NO) COFF Format (/DEBUGTYPE:COFF) Both Formats (/DEBUGTYPE:BOTH) /OPT:REF is selected. /OPT:ICF is selected. /ORDER is selected. Use Program Database is not selected (/PDB:NONE) when Generate Debug Info (/DEBUG) is selected.
Compiler and Linker Options Page 91 of 111 Syntax: /LINK50COMPAT Generates import libraries in the old (Visual C++ version 5.0) format for backward compatibility. /MACHINE Syntax: /MACHINE:{IX86|ALPHA} Specifies the target platform for the program (for Visual Fortran, specify either IX86 or ALPHA). Usually, you do not need to specify the /MACHINE option. LINK infers the machine type from the .OBJ files.
Compiler and Linker Options Page 92 of 111 Syntax: /MAPINFO:{EXPORTS|FIXUPS|LINES} Informs the linker to include the specified information in a map file, which is created if you specify the /MAP option: n EXPORTS tells the linker to include exported functions. n FIXUPS tells the linker to include base-relocation information in the mapfile if relocation information exists in the image. Base relocations will be present in the image if you link with /FIXED:NO. n LINES includes line-number information.
Compiler and Linker Options Page 93 of 111 /NOENTRY Syntax: /NOENTRY This option is required for creating a resource-only DLL. Use this option to prevent LINK from linking a reference to _main into the DLL. /NOLOGO Syntax: /NOLOGO Prevents display of the copyright message and version number. This option also suppresses echoing of command files. By default, this information is sent by the linker to the Output window. On the command line, it is sent to standard output and can be redirected to a file.
Compiler and Linker Options Page 94 of 111 Syntax: /ORDER:@filename Lets you perform optimization by telling LINK to place certain packaged functions into the image in a predetermined order. It is not possible to make packaged functions with the Visual Fortran compiler. This description is included for mixed-language applications with languages such as Visual C++ that support packaged functions (with the /Gy compiler option).
Compiler and Linker Options Page 95 of 111 The /OUT option controls the default base name for a mapfile or import library. For details, see the descriptions of /MAP and /IMPLIB. /PDB Syntax: /PDB[:filename] Controls how the linker produces debugging information. The optional filenameargument overrides the default filename for the program database. The default filename for the PDB has the base name of the program and the extension .PDB.
Compiler and Linker Options Page 96 of 111 If SEPT[YPES] is specified, linking can be significantly faster. The advantages are: n The debugger startup time may be slightly faster. n Less hard disk space is needed to store data. n The disadvantage is more files are needed for the debugger to find the debug information when debugging. Use this option when you plan to debug privately. Do not use this option when the debug build is to be used by multiple users.
Compiler and Linker Options Page 97 of 111 /SECTION Syntax: /SECTION:name,[E][C][I][R][W][S][D][K][L][P][X] Changes the properties of a section, overriding the properties set when the .OBJ file for the section was compiled. A section in a portable executable (PE) file is roughly equivalent to a segment or the resources in an NE file. Sections contain either code or data. Unlike segments, sections are blocks of contiguous memory with no size constraints.
Compiler and Linker Options Page 98 of 111 Syntax: /STACK:reserve[,commit] Sets the size of the stack in bytes. The reserve argument specifies the total stack allocation in virtual memory. The default stack size is 1MB. The linker rounds up the specified value to the nearest 4 bytes. The optional commit argument is subject to interpretation by the operating system. In Windows NT, it specifies the amount of physical memory to allocate at a time.
Compiler and Linker Options Page 99 of 111 in the MS-DOS Stub File Name box in the Input category of the Link tab of the Project Settings dialog box. /SUBSYSTEM Syntax: /SUBSYSTEM:{CONSOLE|WINDOWS|NATIVE|POSIX|WINDOWSCE}[,major [.minor]] Tells the operating system how to run the executable file. The subsystem is specified as follows: n The CONSOLE subsystem is used for Win32 character-mode applications. Console applications are given a console by the operating system.
Compiler and Linker Options Page 100 of 111 /VERBOSE Syntax: /VERBOSE[:LIB] The linker sends information about the progress of the linking session to the Output window. If specified on the command line, the information is sent to standard output and can be redirected to a file. The displayed information includes the library search process and lists each library and object name (with full path), the symbol being resolved from the library, and the list of objects that reference the symbol.
Compiler and Linker Options Page 101 of 111 Driver Kit. A .VXD file is not in Common Object File Format, and it cannot be used with DUMPBIN or EDITBIN. It does not contain debugging information. However, you can create a map file when you link a .VXD file. A .VXD file cannot be incrementally linked. For related information, see /EXETYPE. /WARN Syntax: /WARN[:level] Lets you determine the output of LINK warnings. Specify the level as one of the following: level Meaning 0 Suppress all warnings.
Compiler and Linker Options Page 102 of 111 Module-Definition Files A module-definition (.DEF) file is a text file that contains statements that define an executable file or DLL. (These should not be confused with module program units, described in Program Units and Procedures.) The following sections describe the statements in a .DEF file and Rules for Module-Definition Statements discusses rules for DEF files.
Compiler and Linker Options Page 103 of 111 Many statements have an equivalent LINK command-line option. See the Linker Options and Related Information for additional details. DESCRIPTION Syntax: DESCRIPTION "text" This statement writes a string into an .rdata section. Enclose the specified text in single or double quotation marks (’ or "). To use a literal quotation mark (either single or double) in the string, enclose the string with the other type of mark.
Compiler and Linker Options Page 104 of 111 LIBRARY [library] [BASE=address] This statement tells LINK to create a DLL. LINK creates an import library at the same time, unless you use an .EXP file in the build. The library argument specifies the internal name of the DLL. (Use the Output File Name (/OUT) option to specify the DLL’s output name.) The BASE=address argument sets the base address that the operating system uses to load the DLL. This argument overrides the default DLL location of 0x10000000.
Compiler and Linker Options Page 105 of 111 option. Linker Reserved Words The following table lists words reserved by the linker. You can use these names as arguments in module-definition statements only if you enclose the name in double quotation marks (").
Compiler and Linker Options Page 106 of 111 Microsoft Fortran PowerStation Command-Line Compatibility This section provides compatibility information for FL32 command-line users of Microsoft Fortran PowerStation Version 4. It includes the following topics: n Using the DF or FL32 Command Line n Equivalent Visual Fortran Compiler Options Using the DF or FL32 Command Line You can use either the DF or FL32 commands to compile (and link) your application.
Compiler and Linker Options Page 107 of 111 n Activate the same compiler, the DIGITAL Fortran compiler. For new programs and most existing applications, use the DIGITAL Fortran compiler (default). The DIGITAL Fortran compiler and language used by Visual Fortran provides a superset of the Fortran 90 standard with extensions for compatibility with previous versions of DIGITAL Fortran (DEC FortranTM), VAX FORTRANTM, and Microsoft Fortran PowerStation Version 4.
Compiler and Linker Options Page 108 of 111 /FA Assembly listing. Specify /noasmattributes with /asmfile[:file] or /FA. /FAc Assembly listing with machine code. Specify /asmattributes:machine with /asmfile[:file] or /FAc. /FAs Assembly listing with source code. Specify /asmattributes:source with /asmfile[:file] or /FAs. /FAcs Assembly listing with machine instructions and source code. Specify /asmattributes:all with /asmfile[:file] or /FAcs. /Fa[file] Assembly listing to file file.
Compiler and Linker Options Page 109 of 111 /4Lnn Line length for Fortran 90 fixed-form source (nn is 72, 80, or 132). Specify /extend_source[:nn] or /4Lnn. /4Yb or /4Nb Enable/disable extended error checking. Specify /check[:keyword], /4Yb, or /4Nb. /4Yd or /4Nd Warnings about undeclared variables. Specify /warn: [no] declarations, /4Yd or /4Nd. /W0 Suppress warnings. Specify /nowarn or /W0. /W1 Show warnings (default). Specify /warn:general or /W1. /WX Interpret all warnings as errors.
Compiler and Linker Options Page 110 of 111 /dll:file, or /Fe[file] /Fm[file] Controls creation of link map file. Specify /map[:file] or /Fm[file] /Fo[file] Controls creation of object file. Specify /object[:file] or /Fo[file] /GNa Keep external names as is and treat source code identifiers as case sensitive. Specify /names:as_is or /GNa /GNl Make external names lowercase and ignore the case of source code identifiers.
Compiler and Linker Options Page 111 of 111 /V"string" Place string in object file. Specify /bintext:string or /V"string" /Z7 Request full debug information in object file. Specify /debug:full with /nopdbfile or /Z7 /Zd Request minimal debug information. Specify /debug:minimal with /pdbfile or /Zd /Zi Request full debug information and create PDB file. Specify /debug:full with /pdbfile or /Zi /Zla Do not insert any library names in object file.
Debugging Fortran Programs Page 1 of 22 Debugging Fortran Programs Although you can use the command line to develop your programs, Visual Fortran programs are typically debugged in the Microsoft visual development environment intergrated debugger. This chapter discusses how to use the intergrated debugger to debug Visual Fortran programs.
Debugging Fortran Programs Page 2 of 22 6. In the Build menu, click Set Active Configuration and select the debug configuration. 7. To check your Project Settings, in the Project menu, click Settings, then click the Fortran tab. 8. To compile your program: n Click (select) the source file to be compiled n In the Build menu, click Compile filename 9. Eliminate any compiler diagnostic messages in the text editor and recompile if needed. 10. To build your application, in the Build menu, click Build file.EXE.
Debugging Fortran Programs Page 3 of 22 3. Start the Microsoft visual development environment. 4. In the File menu, click the Open Workspace item. Specify the file name of the executable (.EXE) file to be debugged. 5. In the File menu, click Open. Specify the name of the source file (such as .F90 or .FOR) that corresponds to the file being debugged. The text editor window appears.
Debugging Fortran Programs Page 4 of 22 6. Set breakpoints in the source file and debug the program, as described in Debugging the Squares Example Program. To add Source Browser Information to your debug configuration, see Source Browser Information for a Configuration. Debugging the Squares Example Program The following program (SQUARES) uses the Fortran Console project type. The SQUARES program reads formatted data from the file datafile.dat and displays the calculated results.
Debugging Fortran Programs Page 5 of 22 When the program was executed with array bounds checking on, the output appears as follows: You can either build this program from the command line or within the visual development environment (see Preparing Your Program for Debugging). This example assumes a project workspace already exists. To debug this program: 1. From the Visual Fortran program folder, start the visual development environment. 2. In the File menu, click Open Workspace. 3.
Debugging Fortran Programs Page 6 of 22 The following toolbars are shown: n Build toolbar n Standard toolbar n Fortran toolbar To change the displayed toolbars, select Customize in the Tools menu and click the Toolbars tab. You can move toolbars by dragging the anchor (double vertical line on the left of the toolbar). 5. Click the first executable line to set the cursor position. In this case, click on the beginning of the OPEN statement line: OPEN(UNIT=8, FILE=’datafile.dat’, STATUS=’OLD’) 6.
Debugging Fortran Programs Page 7 of 22 The red circle in the left margin of the text editor/debugger window shows where a breakpoint is set. 7. This example assumes you have previously built your application (see Preparing Your Program for Debugging). In the Build menu, click the Start Debug, Go item: 8. The debugger is now active.
Debugging Fortran Programs Page 8 of 22 The Debug menu appears on the visual development environment title bar in place of the Build menu. If not displayed previously, the Debug toolbar appears. If needed, you can set another breakpoint, position the cursor at the line where you want to add or remove a breakpoint and do either of the following: n In the Build toolbar, click the Set/Remove Breakpoint button. n In the Edit menu, click Breakpoints.
Debugging Fortran Programs Page 9 of 22 9. Repeat the Step Over action and follow program execution into the DO loop. Repeat the Step Over action until you are at the end of the program. Position the cursor over the variable K to view its value (called Data Tips): The error seems related to the value of variable K! 10. In the text editor, add the line K = K + 1 as follows: ! Square all nonzero elements and store in OUTARR. K = 0 DO I = 1, N IF (INARR(I) .NE.
Debugging Fortran Programs Page 10 of 22 n In the Build menu, click Build Squares.exe n In the Build menu, click Execute Squares.exe or click the exclamation point (!) on the Build toolbar. The output screen appears as follows: 12. Although the program generates better results, you can examine the values of both the input array INARR (read from the file) and the output array OUTARR that the program calculates. In the text editor window, the previously set breakpoint remains set.
Debugging Fortran Programs Page 11 of 22 14. In the Variables window, click the Locals tab to display the values of your local variables: You can view the values of the local variables by using the Locals tab, including the arrays (click on the plus sign).
Debugging Fortran Programs Page 12 of 22 The Variables window displays a Context menu (after the word Context:). The Context menu can help you debug exceptions. The Locals tab does not let you display module variables or other non-local variables. To display non-local variables, display the Watch window: 15. Although this example does not use module variables or non-local variables, you can drag a variable name into the Watch window so the variable can be displayed.
Debugging Fortran Programs Page 13 of 22 16. Also drag the OUTARR array name to the Watch window. Click on the Plus sign (+) to the left of the OUTARR variable’s name to display the values of its array elements. 17. Execute lines of the program by using the Step Over button on the Debug toolbar. As the program executes, you can view the values of scalar variables with the data tips feature and view the values of arrays (or other variables) in the Watch window.
Debugging Fortran Programs Page 14 of 22 If you have the Visual Fortran Professional Edition, you can use the Array Viewer to display and graph multidimensional array element values. For More Information: On viewing different types of Fortran data, see Viewing Fortran Data Types in the Debugger. On displaying array values in the Array Viewer, see Using the Array Viewer in the Debugger. On locating errors in your program, see Locating Run-Time Errors in the Debugger.
Debugging Fortran Programs Page 15 of 22 integer foo(10) You can specify the following statement in a watch window to see the 2nd, 5th, and 8th elements: foo(2:10:3) When working with character arrays, this syntax may be combined with a substring specification.
Debugging Fortran Programs Page 16 of 22 You can change the display format of variables in the Watch window using the formatting symbols in the following table: Symbol Format Value Displays d,i signed decimal integer 0xF000F065 -268373915 o unsigned octal integer 0xF065 0170145 x,X Hexadecimal integer 61541 (decimal) #0000F065 f signed floating-point 3./2. 1.5000000 e signed scientific notation 3./2. 0.
Debugging Fortran Programs md 4 doublewords Page 17 of 22 0x0012ffac 00CB34B3 80943084 308A22FF 00002657 With the memory location formatting symbols, you can type any value or expression that evaluates to a location. A formatting character can follow an expression also: rep+1,x alps[0],mb xloc,g count,d Note: You can apply formatting symbols to structures, arrays, pointers, and objects as unexpanded variables only. If you expand the variable, the specified formatting affects all members.
Debugging Fortran Programs Page 18 of 22 4.
Debugging Fortran Programs Page 19 of 22 To display the Fortran toolbar: 1. In the Tools menu, select Customize. 2. Click the Toolbars tab. 3. Set the Fortran toolbar check box. The Array Viewer as well as a Fortran Arrays window appears: In the upper part (data window), Array Viewer displays the values of the array elements for VAL. In the lower part (graph window), the view shown for array VAL is a two-dimensional view.
Debugging Fortran Programs Page 20 of 22 n Create another instance of Array Viewer with an updated view of the data by clicking the Fortran Arrays button in the Fortran toolbar. The second instance may contain different value limits on the graph. 6.
Debugging Fortran Programs Page 21 of 22 n If you specify the /fpe:3 compiler option, certain floating-point exceptions will not be caught, since this setting allows IEEE exceptional values and program continuation. n On Alpha systems, the /synchronous_exceptions option (and certain /fpe:n options) influence the reporting of floating-point arithmetic exceptions at run-time. Your program will automatically stop at the point where the exception occurs.
Debugging Fortran Programs Page 22 of 22 for the routine (use the arrow at the right to display selections). This action all occurs after the error message and traceback information has been displayed. The error message and traceback information is available in the program output window. To view the program output window, either iconize (minimize) the visual development environment or click on the icon for the output window in the task bar.
Performance: Making Programs Run Faster Page 1 of 51 Performance: Making Programs Run Faster This chapter discusses the following topics related to improving run-time performance of DIGITAL Visual Fortran programs: Software Environment and Efficient Compilation Important software environment suggestions that apply to nearly all applications, including using the most recent version of the compiler, related performance tools, and efficient ways to compile using the DF command Analyze Program Performanc
Performance: Making Programs Run Faster Page 2 of 51 To ensure that your software development environment can significantly improve the run-time performance of your applications, obtain and install the following optional software products: The latest version of Visual Fortran New releases of the DIGITAL Visual Fortran compiler and its associated run-time libraries may provide new features that improve run-time performance.
Performance: Making Programs Run Faster Page 3 of 51 together. For information on creating (exporting) makefile for command-line use, see Files in a Project; for information about using NMAKE, see Building Projects with NMAKE.
Performance: Making Programs Run Faster /fast Sets the following performance-related options: /align:dcommons, /assume:noaccuracy_sensitive, and /math_library:fast. Page 4 of 51 See description of each option /assume:noaccuracy_sensitive Allows the compiler to reorder code based on algebraic identities to improve performance, enabling certain optimizations. The numeric results can be slightly different from the default (accuracy_sensitive) because of the way intermediate results are rounded.
Performance: Making Programs Run Faster Page 5 of 51 types of optimizations performed. The default optimization level is /optimize:4, unless you specify /debug, which changes the default to /optimize:0 (no optimizations). Use /optimize:5 to activate loop transformation optimizations and (on Alpha systems) the software pipelining optimizations. Levels: the /optimize Option /transform_loops Activates a group of loop transformation optimizations (a subset of /optimize:5).
Performance: Making Programs Run Faster Page 6 of 51 routines (used by intrinsic functions) that provide faster /math_library speed. Using this option may cause a slight loss of accuracy and provides less reliable arithmetic exception checking to get significant performance improvements in those functions. /optimize:level /pipeline Controls the optimization level and thus the types of optimization performed.
Performance: Making Programs Run Faster Page 7 of 51 compiling multiple source files, also specify /object:file to compile many source files together into one object file. Separate compilations prevent certain interprocedural optimizations, the same as using multiple DF commands or using /compile_only without the /object:file option. Appropriate Options and Multiple Source Files /check:bounds Generates extra code for array bounds checking at run time.
Performance: Making Programs Run Faster Page 8 of 51 /synchronous_exceptions (Alpha only) Generates extra code to associate an See [no] arithmetic exception with the instruction synchronous_exceptions that causes it, slowing instruction execution. Use this option only when troubleshooting, such as when identifying the source of an exception. /vms Controls certain VMS-related run-time defaults, including alignment.
Performance: Making Programs Run Faster Page 9 of 51 Methods of Timing Your Application To perform application timings, use a version of the TIME command in a .BAT file (or the function timing profiling option). You might consider modifying the program to call routines within the program to measure execution time (possibly using conditionally compiled lines). For example: l DIGITAL Fortran intrinsic procedures, such as CPU_TIME, SYSTEM_CLOCK, DATE_AND_TIME, and TIME.
Performance: Making Programs Run Faster Page 10 of 51 time
Performance: Making Programs Run Faster l l l l Page 11 of 51 The time spent in functions and the number of times a function was called (function timing). Only the number of times a function was called (function counting). A list of functions executed or not executed (function coverage). Information about the stack when each function is called (function attribution). Function profiling does not require debug information (it obtains addresses from a .MAP file).
Performance: Making Programs Run Faster Page 12 of 51 performance bottlenecks. l Other performance tools are available in the Microsoft® Win32 SDK (see the online Platform SDK Tools Guide, Tuning section in HTMLHelp Viewer). You can also purchase separate products to perform performance analysis and profiling. Efficient Source Code Once you have determined those sections of code where most of the program execution time is spent, examine these sections for coding efficiency.
Performance: Making Programs Run Faster Page 13 of 51 Options Controlling Alignment Causes of Unaligned Data and Ensuring Natural Alignment Common blocks (COMMON statement), derived-type data, and DIGITAL Fortran record structures (RECORD statement) usually contain multiple items within the context of the larger structure. The following declarations can force data to be unaligned: Common blocks (COMMON statement) The order of variables in the COMMON statement determines their storage order.
Performance: Making Programs Run Faster Page 14 of 51 Equivalenced data EQUIVALENCE statements can force unaligned data or cause data to span natural boundaries. To avoid unaligned data in a common block, derived-type data, or record structures, use one or both of the following: For new programs or for programs where the source code declarations can be modified easily, plan the order of data declarations with care.
Performance: Making Programs Run Faster Page 15 of 51 For More Information: On the /align options, see Options Controlling Alignment. Checking for Inefficient Unaligned Data During compilation, the DIGITAL Fortran compiler naturally aligns as much data as possible. Exceptions that can result in unaligned data are described in Causes of Unaligned Data and Ensuring Natural Alignment.
Performance: Making Programs Run Faster Page 16 of 51 Arranging Data Items in Derived-Type Data Arranging Data Items in Digital Fortran Record Structures Arranging Data Items in Common Blocks The order of data items in a COMMON statement determine the order in which the data items are stored.
Performance: Making Programs Run Faster Page 17 of 51 As shown in the following figure, if you arrange the order of variables from largest to smallest size and place character data last, the data items will be naturally aligned. Common Block with Naturally Aligned Reordered Data When modifying or creating all source files that use common block data, consider placing the common block data declarations in a module so the declarations are consistent.
Performance: Making Programs Run Faster Page 18 of 51 inserted by the compiler when the /align records option is in effect. Derived-Type Naturally Aligned Data (in CATALOG_SPRING()) Arranging Data Items in DIGITAL Fortran Record Structures Record structures are a DIGITAL language extension to the FORTRAN 77 and Fortran 90 Standards. Record structures use the RECORD statement and optionally the STRUCTURE statement, which are also DIGITAL Fortran language extensions.
Performance: Making Programs Run Faster Page 19 of 51 record structures: The /align:commons option Requests that data in common blocks be aligned on up to 4-byte boundaries, by adding padding bytes as needed. Unless you specify /fast, the default is /align:nocommons or arbitrary byte alignment of common block data.
Performance: Making Programs Run Faster Page 20 of 51 performance, especially when using large arrays. This section discusses the following topics: Accessing Arrays Efficiently Passing Array Arguments Efficiently Accessing Arrays Efficiently On both x86 and Alpha systems, many of the array access efficiency techniques described in this section are applied automatically by the DIGITAL Fortran loop transformation optimizations (set at /optimization:5).
Performance: Making Programs Run Faster Page 21 of 51 leftmost subscript varies most rapidly with a stride of one. Whole array access uses columnmajor order. Avoid row-major order, as is done by C, where the rightmost subscript varies most rapidly.
Performance: Making Programs Run Faster Page 22 of 51 INTEGER X(5,3), Y(5,3), I, J Y = 0 DO I=1,3 ! I outer loop varies slowest DO J=1,5 ! J inner loop varies fastest X (J,I) = Y(J,I) + 1 ! Efficient column-major storage order END DO ! (leftmost subscript varies fastest) END DO . . . END PROGRAM Code written to access multidimensional arrays in row-major order (like C) or random order can often make inefficient use of the CPU memory cache.
Performance: Making Programs Run Faster Page 23 of 51 performance, but at the expense of some unused elements. Because loop index variables I and J are used in the calculation, changing the nesting order of the DO loops changes the results. l To minimize data storage and memory cache misses with arrays, use 32-bit data rather than 64-bit data, unless you require the greater range and precision of double precision floating-point numbers or, on Alpha systems, the numeric range of 8-byte integers.
Performance: Making Programs Run Faster Page 24 of 51 Output Argument Array Types Input Arguments Array Types Explicit-Shape Arrays Deferred-Shape and AssumedShape Arrays Explicit-Shape Arrays Very efficient. Does not use an array temporary. Does not pass an array descriptor. Interface block optional. Efficient. Only allowed for assumed-shape arrays (not deferred-shape arrays). Does not use an array temporary. Passes an array descriptor. Requires an interface block.
Performance: Making Programs Run Faster Page 25 of 51 The following sections discuss I/O performance considerations in more detail: Use Unformatted Files Instead of Formatted Files Write Whole Arrays or Strings Write Array Data in the Natural Storage Order Use Memory for Intermediate Results Enable Implied-DO Loop Collapsing Use of Variable Format Expressions Efficient Use of Record Buffers and Disk I/O Specify RECL Use the Optimal Record Type Use Unformatted Files Instead of Formatted
Performance: Making Programs Run Faster Page 26 of 51 If the whole array is not being written, natural storage order is the best order possible. If you must use an unnatural storage order, in certain cases it might be more efficient to transfer the data to memory and reorder the data before performing the I/O operation. Use Memory for Intermediate Results Performance can improve by storing intermediate results in memory rather than storing them in a file on a peripheral device.
Performance: Making Programs Run Faster S1 400 S2 500 Page 27 of 51 WRITE (6,400) (A(I), I=1,N) FORMAT (1X, F5.2) . . . WRITE (CHFMT,500) ’(1X,’,N,’F5.2)’ FORMAT (A,I3,A) WRITE (6,FMT=CHFMT) (A(I), I=1,N) Efficient Use of Record Buffers and Disk I/O Records being read or written are transferred between the user’s program buffers and one or more disk block I/O buffers, which are established when the file is opened by the DIGITAL Fortran runtime system.
Performance: Making Programs Run Faster Page 28 of 51 of space in the block is wasted. Avoid using values larger than the block capacity, because they create very inefficient moves for the excess data only slightly filling a block (allocating extra memory for the buffer and writing partial blocks are inefficient). The RECL value unit for formatted files is always 1-byte units. For unformatted files, the RECL unit is 4-byte units, unless you specify the /assume:byterecl option to request 1-byte units.
Performance: Making Programs Run Faster Page 29 of 51 To minimize data storage and memory cache misses with arrays, use 32-bit data rather than 64-bit data, unless you require the greater range and precision of double precision floating-point numbers or, on Alpha systems, the numeric range of 8-byte integers. On Alpha systems, avoid using integer or logical data less than 32 bits (KIND=4).
Performance: Making Programs Run Faster Page 30 of 51 n Integer (also see Avoid Small Integer and Small Logical Data Items (Alpha only)) n Single-precision real, expressed explicitly as REAL, REAL(KIND=4), or REAL(4) n Double-precision real, expressed explicitly as DOUBLE PRECISION, REAL (KIND=8), or REAL(8) However, keep in mind that in an arithmetic expression, you should avoid mixing integer and floating-point (REAL) data (see Avoid Mixed Data Type Arithmetic Expressions).
Performance: Making Programs Run Faster Page 31 of 51 For more information, see Compile With Appropriate Options and Multiple Source Files. Code DO Loops for Efficiency Minimize the arithmetic operations and other operations in a DO loop whenever possible. Moving unnecessary operations outside the loop will improve performance (for example, when the intermediate nonvarying values within the loop are not needed).
Performance: Making Programs Run Faster Page 32 of 51 Loop transformation x Automatic inlining x x x x x x x x x x x x x Additional global optimizations Global optimizations Local (minimal) optimizations x The default is /optimize:4. However, when /debug is specified, the default is /optimize:0 (no optimizations).
Performance: Making Programs Run Faster Page 33 of 51 The following sections discuss I/O performance considerations in more detail: Optimizations Performed at All Optimization Levels Local (Minimal) Optimizations Global Optimizations Additional Global Optimizations Automatic Inlining Loop Transformation and Software Pipelining Optimizations Performed at All Optimization Levels The following optimizations occur at any optimization level (/optimize:0 through /optimize:5): Space optimizations
Performance: Making Programs Run Faster Page 34 of 51 higher). Implied-DO loop collapsing DO loop collapsing reduces a major overhead in I/O processing. Normally, each element in an I/O list generates a separate call to the Visual Fortran RTL. The processing overhead of these calls can be most significant in implied-DO loops.
Performance: Making Programs Run Faster Page 35 of 51 DIMENSION A(25,25), B(25,25) A(I,J) = B(I,J) Without optimization, these statements can be coded as follows: t1 = ((J-1)*25+(I-1))*4 t2 = ((J-1)*25+(I-1))*4 A(t1) = B(t2) Variables t1 and t2 represent equivalent expressions.
Performance: Making Programs Run Faster Page 36 of 51 Lower-ranked constants are converted to the data type of the higher-ranked operand: REAL X, Y X = 10 * Y ! Becomes: X = 10.
Performance: Making Programs Run Faster Page 37 of 51 . IF (I.GT.1) GOTO 10 10 A(I) = 3.0*Q Dead Store Elimination If a variable is assigned but never used, Visual Fortran eliminates the entire assignment statement: X = Y*Z . . . !If X is not used in between, X=Y*Z is eliminated. X = A(I,J)* PI Some programs used for performance analysis often contain such unnecessary operations.
Performance: Making Programs Run Faster Page 38 of 51 . . . X = SIN(Y)*V . . . V = PI*X . . . Y = COS(Y)*V Visual Fortran may choose one register to hold the first use of V and another register to hold the second. Both registers can be used for other purposes at points in between. There may be times when the value of the variable does not exist anywhere in the registers. If the value of V is never needed in memory, it might not ever be assigned.
Performance: Making Programs Run Faster Page 39 of 51 Global optimizations include: Data-flow analysis Split lifetime analysis Strength reduction (replaces a CPU-intensive calculation with one that uses fewer CPU cycles) Code motion (also called code hoisting) Instruction scheduling Data-flow and split lifetime analysis (global data analysis) traces the values of variables and whole arrays as they are created and used in different parts of a program unit.
Performance: Making Programs Run Faster Page 40 of 51 Visual Fortran limits optimizations on data items in common blocks. If common block data items are referenced inside called routines, their values might be altered. In the following example, variable I might be altered by FOO, so Visual Fortran cannot predict its value in subsequent references. COMMON /X/ I DO J=1,N I = J CALL FOO A(I) = I ENDDO Variables in Fortran 90 modules Visual Fortran limits optimizations on variables in Fortran 90 modules.
Performance: Making Programs Run Faster Page 41 of 51 Loop Unrolling At optimization level /optimize:3 or above, Visual Fortran attempts to unroll certain innermost loops, minimizing the number of branches and grouping more instructions together to allow efficient overlapped instruction execution (instruction pipelining). The best candidates for loop unrolling are innermost loops with limited control flow. As more loops are unrolled, the average size of basic blocks increases.
Performance: Making Programs Run Faster . . . branch to exit1 . . . exit1: move 1 into R0 return Page 42 of 51 return . . . move 1 into R0 return . . . move 1 into R0 return Similarly, code replication can also occur within a loop that contains a small amount of shared code at the bottom of a loop and a case-type dispatch within the loop. The loop-end test-and-branch code might be replicated at the end of each case to create efficient instruction pipelining within the code for each case.
Performance: Making Programs Run Faster Page 43 of 51 Use of constant arguments You can specify: One of the /optimize options to control the optimization level. For example, specifying /optimize:4 or /optimize:5 enables interprocedure optimizations. Different /optimize options set different /inline:keyword options. For example, /optimize:4 sets /inline:speed. One of the /inline options to directly control the inlining of procedures (see Controlling the Inlining of Procedures).
Performance: Making Programs Run Faster Page 44 of 51 can improve the performance of the memory system and usually apply to multiple nested loops. The loops chosen for loop transformation optimizations are always counted loops. Counted loops are those loops that use a variable to count iterations in a manner that the number of iterations can be determined before entering the loop. For example, most DO loops are counted loops.
Performance: Making Programs Run Faster Page 45 of 51 Loop unrolling (enabled at /optimize:3 or above) cannot schedule across iterations of a loop. Because software pipelining can schedule across loop iterations, it can perform more efficient scheduling to eliminate instruction stalls within loops.
Performance: Making Programs Run Faster Page 46 of 51 other compiler options can prevent or facilitate improved optimizations, as discussed in the following sections: Options Set by the /fast Option Controlling Loop Unrolling Controlling the Inlining of Procedures Arithmetic Reordering Optimizations Dummy Aliasing Assumption Requesting Optimized Code for a Specific Processor Generation Requesting Code Generation for a Specific Processor Generation Loop Transformation Software Pipelining
Performance: Making Programs Run Faster Page 47 of 51 /inline:manual Inlines statement functions but not other procedures. This type of inlining occurs if you omit /inline options. /inline:size In addition to inlining statement functions, inlines any procedures that the DIGITAL Fortran optimizer expects will improve run-time performance with no likely significant increase in program size.
Performance: Making Programs Run Faster Page 48 of 51 Unoptimized Code Optimized Code DO I=1,N . . . B(I)= A(I)/V END DO T= 1/V DO I=1,N . . . B(I)= A(I)*T END DO The transformation in the optimized loop increases performance significantly, and loses little or no accuracy. However, it does have the potential for raising overflow or underflow arithmetic exceptions.
Performance: Making Programs Run Faster Page 49 of 51 IF (N.LE.0) RETURN IF (DA.EQ.0.0) RETURN IF (INCX.EQ.1.AND.INCY.EQ.1) GOTO 20 C C C C 20 40 Code for unequal increments or equal increments not equal to 1. . . . RETURN Code for both increments equal to 1. Clean-up loop M = MOD(N,4) IF (M.EQ.0) GOTO 40 DO I=1,M DY(I) = DY(I) + DA*DX(I) END DO IF (N.LT.
Performance: Making Programs Run Faster Page 50 of 51 On Alpha systems, regardless of the specified keyword, the generated code will run correctly on all implementations of the Alpha architecture. Specifying the correct keyword for /tune for the target Alpha processor generation type usually slightly improves run-time performance.
Performance: Making Programs Run Faster For more information, see /architecture.
Using QuickWin Page 1 of 32 Using QuickWin This chapter introduces the major categories of QuickWin library routines. It gives an overview of QuickWin features and their use in creating and displaying graphics, and customizing your QuickWin applications with custom menus and mouse routines. Drawing Graphics Elements, and Using Fonts from the Graphics Library cover graphics and fonts in more detail.
Using QuickWin Page 2 of 32 QuickWin Programming Precautions Simulating Nonblocking I/O Capabilities of QuickWin You can use the QuickWin library to do the following: Compile console programs into simple applications for Windows. Minimize and maximize QuickWin applications like any Windows-based application. Call graphics routines. Load and save bitmaps. Select, copy and paste text, graphics, or a mix of both. Detect and respond to mouse clicks. Display graphics output.
Using QuickWin Page 3 of 32 applications support only one window and do not support programmable menus. Fortran QuickWin applications support multiple windows and user-defined menus. Any Fortran program, whether it contains graphics or not, can be compiled as a QuickWin application. You can use the Microsoft visual development environment to create, debug, and execute Fortran Standard Graphics programs and Fortran QuickWin programs.
Using QuickWin Page 4 of 32 Fortran QuickWin Graphics Applications The following shows a typical Fortran QuickWin application. The frame window has a border, title bar, scroll bars, and default menu bar. You can modify, add, or delete the default menu items, respond to mouse events, and create multiple child windows within the frame window using QuickWin enhanced features. Routines to create enhanced features are listed in Enhancing QuickWin Applications.
Using QuickWin Page 5 of 32 All QuickWin applications create an application or frame window; child windows are optional. Fortran Standard Graphics applications and Fortran QuickWin applications have these general characteristics: Window contents can be copied as bitmaps or text to the Clipboard for printing or pasting to other applications. In Fortran QuickWin applications, any portion of the window can be selected and copied. Vertical and horizontal scroll bars appear automatically, if needed.
Using QuickWin Page 6 of 32 The resulting graphics might appear somewhat distorted whenever the logical graphics screen is enlarged or reduced with the Size to Fit and Full Screen commands. While in Full Screen or Size To Fit mode, cursors are not scaled. Figure: State Menu Figure: Window Menu Figure: Help Menu For instructions on replacing the About default information within the Help menu with your own text message, see Defining an About Box.
Using QuickWin Page 7 of 32 Depending on the type of routines used by your application, other USE statements that include other Visual Fortran modules may be needed in addition to USE DFLIB. The description of each Visual Fortran routine in the Language Reference (see Introduction to the Language Reference) indicates the module that needs to be included for external routines (such as USE DFLIB, USE DFPORT).
Using QuickWin Page 8 of 32 resolution will be set for your system, given the other fields you specify, if any. You can set the actual size of the window by specifying parameters that influence the window size -- the number of x and y pixels, the number of rows and columns, and the font size. If you do not call SETWINDOWCONFIG, the window defaults to the best possible resolution and a font size of 8 by 16. The number of colors depends on the video driver used.
Using QuickWin Page 9 of 32 becomes the active window. When a window gains focus, the window that previously had focus will lose focus. If a window needs to be brought to the foreground, it must be given focus. The window that has the focus is always on top, and all other windows have their title bars grayed out. A window can have the focus and yet not be active and not have graphics output directed to it. Graphical output is independent of focus.
Using QuickWin Page 10 of 32 WRITE (11, *) ’Giving focus to Child 2.’ ! Give focus to Child Window 1 with the FOCUSQQ function: status = FOCUSQQ(10) ... ! Find out the unit number of the child window that currently has focus: status = INQFOCUSQQ(focusunit) SETACTIVEQQ makes a child window active without bringing it to the foreground. GETACTIVEQQ returns the unit number of the currently active child window. GETHWNDQQ converts the unit number into a Windows handle for functions that require it.
Using QuickWin Page 11 of 32 ! Get maximum size of frame window. status = GETWSIZEQQ(QWIN$FRAMEWINDOW, QWIN$SIZEMAX, winfo) WRITE (*,*) "Max frame window size is ", winfo.H, " by ", winfo.W SETWSIZEQQ is used to set the visible window position and size. For example: USE DFLIB INTEGER(4) status TYPE (QWINFO) winfo OPEN (4, FILE=’USER’) winfo.H = 30 winfo.W = 80 winfo.
Using QuickWin Page 12 of 32 SETGTEXTROTATION sets the current orientation for font text output, and GETGTEXTROTATION returns the current setting. The current orientation is used in calls to OUTGTEXT. For more information on these routines, see the Language Reference. Setting Graphics Coordinates The coordinate-setting routines control where graphics can appear on the screen.
Using QuickWin Page 13 of 32 specified values. See the Visual Fortran Sample SINE.F90 in the ...\DF98\SAMPLES\TUTORIAL folder for an example of this technique. GETPHYSCOORD converts viewport coordinates to physical coordinates, and GETVIEWCOORD translates from physical coordinates to viewport coordinates. Similarly, GETVIEWCOORD_W converts window coordinates to viewport coordinates, and GETWINDOWCOORD converts viewport coordinates to window coordinates.
Using QuickWin Page 14 of 32 SETBKCOLORRGB (or SETBKCOLOR) retrieve or set the current background color. GETFILLMASK and SETFILLMASK return or set the current fill mask. The mask is an 8-by-8-bit array with each bit representing a pixel. If a bit is 0, the pixel in memory is left untouched: the mask is transparent to that pixel. If a bit is 1, the pixel is assigned the current color value. The array acts as a template that repeats over the entire fill area.
Using QuickWin Page 15 of 32 ELLIPSE, ELLIPSE_W Draws an ellipse or circle FLOODFILL, FLOODFILL_W Fills an enclosed area of the screen with the current color index using the current fill mask FLOODFILLRGB, FLOODFILLRGB_W Fills an enclosed area of the screen with the current RGB color using the current fill mask GETARCINFO Determines the endpoints of the most recently drawn arc or pie GETCURRENTPOSITION, GETCURRENTPOSITION_W Returns the coordinates of the current graphicsoutput position GETPIXEL,
Using QuickWin Page 16 of 32 SETPIXELSRGB Set the Red-Green-Blue color value of multiple pixels Most of these routines have multiple forms. Routine names that end with _W use the windowcoordinate system and REAL(8) argument values. Routines without this suffix use the viewportcoordinate system and INTEGER(2) argument values. Curved figures, such as arcs and ellipses, are centered within a bounding rectangle, which is specified by the upper-left and lower-right corners of the rectangle.
Using QuickWin Page 17 of 32 GETTEXTCOLORRGB Returns the current text Red-Green-Blue color value GETTEXTPOSITION Returns the current text-output position GETTEXTWINDOW Returns the boundaries of the current text window OUTTEXT Sends text to the screen at the current position SCROLLTEXTWINDOW Scrolls the contents of a text window SETBKCOLOR Sets the current background color index SETBKCOLORRGB Sets the current background Red-Green-Blue color value SETTEXTCOLOR Sets the current text color to a n
Using QuickWin Page 18 of 32 Routine Description GETFONTINFO Returns the current font characteristics GETGTEXTEXTENT Determines the width of specified text in the current font GETGTEXTROTATION Gets the current orientation for font text output in 0.
Using QuickWin Page 19 of 32 These routines allow you to cut, paste, and move images around the screen. Transferring Images in Memory The GETIMAGE and PUTIMAGE routines transfer images between memory and the screen and give you options that control the way the image and screen interact. When you hold an image in memory, the application allocates a memory buffer for the image. The IMAGESIZE routines calculate the size of the buffer needed to store a given image.
Using QuickWin Page 20 of 32 Once you have selected a portion of the screen, you can copy it onto the Clipboard by using the Edit/Copy option or by using the Ctrl+INS key combination. If the screen area you have selected contains only text, it is copied onto the Clipboard as text. If the selected screen area contains graphics, or a mix of text and graphics, it is copied onto the Clipboard as a bitmap. The Edit menu’s Paste option will only paste text.
Using QuickWin Menu items Page 21 of 32 CLICKMENUQQ Simulates the effect of clicking or selecting a menu item APPENDMENUQQ Appends a menu item DELETEMENUQQ Deletes a menu item INSERTMENUQQ Inserts a menu item MODIFYMENUFLAGSQQ Modifies a menu item’s state MODIFYMENUROUTINEQQ Modifies a menu item’s callback routine MODIFYMENUSTRINGQQ Changes a menu item’s text string SETWINDOWMENUQQ Sets the menu to which a list of current child window names are appended Directional keys PASSDIRKEYSQQ En
Using QuickWin Page 22 of 32 Program Control of Menus You do not have to use the default QuickWin menus. You can eliminate and alter menus, menu item lists, menu titles or item titles.
Using QuickWin Page 23 of 32 PROGRAM MENUS USE DFLIB LOGICAL(4) res INTERFACE LOGICAL(4) FUNCTION INITIALSETTINGS END FUNCTION END INTERFACE OPEN (10, FILE="User") WRITE(10, *) "Hello, child window" END QuickWin executes your INITIALSETTINGS function during initialization, before creating the frame window. When your function is done, control returns to QuickWin and it does the remaining initialization. The control then passes to the Visual Fortran application. Your function should return .TRUE.
Using QuickWin Page 24 of 32 menu item’s state might not be properly updated when you change it (put a check mark next to it, gray it out, or disable, or enable it). You cannot insert a menu item or menu beyond the existing number; for example, inserting item 7 when 5 and 6 have not been defined yet. To insert an entire menu, specify menu item 0. The new menu can take any position among or immediately after existing menus.
Using QuickWin WINTILE, Page 25 of 32 and uses MODIFYMENUFLAGSQQ to put a check mark next to the menu item: status = MODIFYMENUSTRINGQQ( 1, 4, ’Tile Windows’C) status = MODIFYMENUROUTINEQQ( 1, 4, WINTILE) status = MODIFYMENUFLAGSQQ( 1, 4, $MENUCHECKED) Creating a Menu List of Available Child Windows By default, the Windows menu contains a list of all open child windows in your QuickWin applications. SETWINDOWMENUQQ changes the menu which lists the currently open child windows to the menu you specify.
Using QuickWin USE DFLIB INTEGER(4) response response = MESSAGEBOXQQ(’Retry or Cancel?’C, ’Smith Chart & Simulator’C, MB$RETRYCANCELQWIN .OR. MB$DEFBUTTON2) Page 26 of 32 & Defining an About Box The ABOUTBOXQQ function specifies the message displayed in the message box that appears when the user selects the About command from a QuickWin application’s Help menu. (If your program does not call ABOUTBOXQQ, the QuickWin run-time library supplies a default string.
Using QuickWin Page 27 of 32 4. Create a script file to hold your icons. Select File/Save As. You will be prompted for the name of the script file that will contain your icons. Name the script file. It must end with the extension .RC; for example, myicons.rc. Using this method, the icons and their string values will be automatically saved in the script file. (Alternatively, you can create a script file with any editor and add the icon names and their string values by hand.) 5.
Using QuickWin Page 28 of 32 For example: USE DFLIB INTEGER(4) result OPEN (4, FILE= ’USER’) ... result = REGISTERMOUSEEVENT (4, MOUSE$LBUTTONDBLCLK, CALCULATE) This registers the routine CALCULATE, to be called when the user double-clicks the left mouse button while the mouse cursor is in the child window opened as unit 4.
Using QuickWin Page 29 of 32 END SUBROUTINE END INTERFACE The unit parameter is the unit number associated with the child window where events are to be detected, and the mouseevent parameter is one of those listed in the preceding table. The MouseXpos and the MouseYpos parameters specify the x and y positions of the mouse during the event.
Using QuickWin if ((MOUSE$KS_CONTROL .AND. keystate) == MOUSE$KS_CONTROL) then & write (*,*) ’Ctrl key was down’ Page 30 of 32 & Your application passes a mouse event parameter, which can be any ORed combination of mouse events, to WAITONMOUSEEVENT. The function then waits and blocks execution until one of the specified events occurs.
Using QuickWin Page 31 of 32 When QuickWin has two blocking calls pending, it displays a message in the status bar that corresponds to the blocking call first encountered. If there are further callbacks with other blocking procedures in the two threads, the status bar may not correspond to the actual input pending, execution can appear to be taking place in one thread when it is really blocked in another, and the application can be confusing and misleading to the user.
Using QuickWin Page 32 of 32 One way to simulate PEEKCHARQQ with QuickWin applications is to use a multithread application. One thread does a READ or GETCHARQQ and is blocked until a character typed. The other thread is in a loop doing useful work and checking in the loop to see if the other thread has received input. For more information, see the Visual Fortran Samples PEEKAPP and PEEKAPP3 in the ...\DF98 \SAMPLES\QUICKWIN folder.
Creating Fortran DLLs Page 1 of 10 Creating Fortran DLLs A dynamic-link library (DLL) contains one or more subprogram procedures (functions or subroutines) that are compiled, linked, and stored separately from the applications using them. Because the functions or subroutines are separate from the applications using them, they can be shared or replaced easily. Like a static library, a DLL is an executable file.
Creating Fortran DLLs Page 2 of 10 Coding requirements include using cDEC$ ATTRIBUTES DLLIMPORT and DLLEXPORT compiler directives. Variables and routines declared in the main program and in the DLL are not visable to each another unless you use DLLIMPORT and DLLEXPORT. This section discusses aspects of sharing subprogram procedures (functions and subroutines) in a Fortran DLL. To export and import each DLL subprogram: 1. Within your Fortran DLL, export each subprogram that will be used outside the DLL.
Creating Fortran DLLs Page 3 of 10 3. Build the DLL and then build the main program, as described in Building and Using DynamicLink Libraries. Fortran and C applications can call Fortran and C DLLs provided the calling conventions are consistent (see Programming with Mixed Languages, especially Visual Fortran/Visual C++ MixedLanguage Programs).
Creating Fortran DLLs Page 4 of 10 DLLEXPORT compiler directives. These directives enable the compiler and linker to map to the correct portions of the address space so that the data and routines can be shared, allowing use of common block data across multiple images. You can use DLLEXPORT to declare that a common block in a DLL is being exported to a program or another DLL.
Creating Fortran DLLs Page 5 of 10 REAL C, B, A, Q EQUIVALENCE (A,Q) END SUBROUTINE SETA END INTERFACE A = 0. I = 0 WRITE (6,*) ’In Main program before calling SETA...’ WRITE (6,*) ’values of A and I:’ , A, I CALL SETA(I) WRITE (6,*) ’In Main program after calling SETA...’ WRITE (6,*) ’values of A and I:’ , Q, I A = A + 1. I = I + 1 WRITE (6,*) ’In Main program after incrementing values’ END PROGRAM COMMONX 3.
Creating Fortran DLLs Page 6 of 10 For more information, see: Building Dynamic-Link Libraries The DLL Build Output Checking the DLL Symbol Export Table Building Executables that Use DLLs DLL Sample Programs Building Dynamic-Link Libraries When you first create a DLL, you follow the general steps described in Defining Your Project. Select Fortran Dynamic-Link Library as the project type when you create a new project in the Microsoft visual development environment.
Creating Fortran DLLs Page 7 of 10 5. Build your Fortran DLL project. The Microsoft visual development environment automatically selects the correct linker instructions for loading the proper run-time library routines (located in a DLL themselves). Your DLL is created as a multithread-enabled library. An import library (.LIB) is created for use when you link images that reference the DLL. To build the DLL from the command line: 1.
Creating Fortran DLLs Page 8 of 10 enabled library. For more information, see: The DLL Build Output Checking the DLL Symbol Export Table Building Executables that Use DLLs DLL Sample Programs The DLL Build Output When a DLL is built, two library files are created: An import library (.LIB), which the linker uses to associate a main program with the DLL. The .DLL file containing the library’s executable code. Both files have the same basename as the library project by default.
Creating Fortran DLLs Page 9 of 10 category (the /alignment option) as was used to create the DLL: n Consistently specify whether padding is needed to ensure that imported data items are naturally aligned. In the Fortran Data compiler option category, specify the appropriate values for Common Element Alignment (common block data) and Structure Element Alignment (structures in a module). This sets the /alignment option.
Creating Fortran DLLs Page 10 of 10 DF /align:commons mainapp.f90 dllfile.lib DLL Sample Programs Visual Fortran provides Sample programs are installed in ...\Df98\SAMPLES\ when you request the Samples with a custom installation. You can copy the Samples folders from the ...\DF\SAMPLES\ folder on the Visual Fortran CD-ROM to your hard disk. For an example of a DLL, see the Samples folder ...\DF98\SAMPLES\ADVANCED\WIN32\TLS , which creates a DLL as a subproject.
Creating Windows Applications Page 1 of 5 Creating Windows Applications With Visual Fortran, you can build Fortran applications that are also fully-featured Windows applications. You can create full Windows applications that use the familiar Windows interface, complete with tool bars, pull-down menus, dialog boxes, and other features. You can include data entry and mouse control, and interaction with programs written in other languages or commercial programs such as Microsoft Excel.
Creating Windows Applications Page 2 of 5 Sample Fortran Windows Applications Getting Help with Windows Programming Coding Requirements for Fortran Windows Applications Coding requirements for Fortran Windows applications include (in the following order): 1. WinMain function declaration and interface The WinMain function declaration and interface are required for Windows Graphical User Interface (GUI) applications (typically use at least the GDI and USER32 Win32 routines).
Creating Windows Applications Page 3 of 5 integer function WinMain( hInstance, hPrevInstance, lpszCmdLine, nCmdShow ) !DEC$ IF DEFINED(_X86_) !DEC$ ATTRIBUTES STDCALL, ALIAS : ’_WinMain@16’ :: WinMain !DEC$ ELSE !DEC$ ATTRIBUTES STDCALL, ALIAS : ’WinMain’ :: WinMain !DEC$ ENDIF use dfwin integer integer integer integer . . .
Creating Windows Applications Page 4 of 5 structurename$bitfieldname These functions take an integer argument and return an integer. All bit fields are unsigned integers. The following is an example of the translation from Win32 structures to Fortran derived types. WINDOWS.
Creating Windows Applications Page 5 of 5 The Visual Fortran Samples ...\DF98\SAMPLES\ADVANCED folder contains many Fortran Windows applications that demonstrate Windows functionality or a particular Win32 function. Each sample application is in separate folder. Users unfamiliar with full Windows applications should start by looking at the sample programs in ...\DF98\SAMPLES\ADVANCED\WIN32 , such as PLATFORM or POLYDRAW.
Portability and Design Considerations Page 1 of 16 Portability and Design Considerations Before you can start to write new programs or port existing ones to Visual Fortran, you must decide what to build and how to build it.
Portability and Design Considerations Page 2 of 16 FORTRAN IV American National Standard Programming Language FORTRAN, ANSI X3.9-1966. This was the first attempt to standardize the languages called FORTRAN by many vendors. FORTRAN 77 American National Standard Programming Language FORTRAN, ANSI X3.9-1978. This standard added new features based on vendor extensions to FORTRAN IV and addressed problems associated with large-scale projects, such as improved control structures.
Portability and Design Considerations Page 3 of 16 on a wide range of platforms, and if a system you are porting a program to supports an extension, there is no reason to avoid using it. There is no guarantee, however, that the same feature on another system will be implemented in the same way as it is in Visual Fortran. Only the Fortran standard is guaranteed to coexist uniformly on all platforms. DIGITAL Fortran supports many language extensions on multiple platforms, including DIGITAL Alpha systems.
Portability and Design Considerations Page 4 of 16 The operating system envelops your program and influences it both externally and internally. To achieve portability, you need to minimize the amount of operating-system-specific information required by your program. The Fortran language standards do not specify this information. Operating-system-specific information consists of nonintrinsic extensions to the language, compiler and linker options, and possibly the graphical user interface of Windows.
Portability and Design Considerations Page 5 of 16 Size of Basic Types The intrinsic data types are INTEGER, REAL, LOGICAL, COMPLEX, and CHARACTER, whose sizes are shown in the following table.
Portability and Design Considerations Page 6 of 16 For more information, see: Big End or Little End Ordering Binary Representations Declaring Data Types Big End or Little End Ordering Computer memory is a linear sequence of bits organized into a hierarchical structure of bytes and words. One system is the "Big End," where bits and bytes are numbered starting at the most significant bit (MSB, "left," or high end).
Portability and Design Considerations Page 7 of 16 If you serially transfer bytes now from the Big End words to the Little End words (BE byte 0 to LE byte 0, BE byte 1 to LE byte 1, ...), the left half of the figure shows how the data ends up in the Little End words. Note that data of size one byte (characters in this case) is ordered correctly, but that integer data no longer correctly represents the original binary values.
Portability and Design Considerations Page 8 of 16 representation. Additionally, the bit representation of binary floating-point numbers is not unique. If you transport binary data to or from a different system, you need to know the respective representations to convert the binary data appropriately. Declaring Data Types Use default data types unless you anticipate memory problems, or if your data is sensitive to overflow limits.
Portability and Design Considerations Page 9 of 16 assistance using this or any other dialog box, choose the Help button in the dialog box.) The visual development environment also provides a default text editor, which is integrated with Help, the debugger, and error tracking features.
Portability and Design Considerations Page 10 of 16 Fortran console applications are the most portable to other systems because they are text-only and do not support graphics. With Fortran standard graphics (QuickWin single document) applications, you can add graphics to your text without the additional overhead of menus and other interface features of typical programs for Windows.
Portability and Design Considerations Page 11 of 16 The simplest way to build an application is to compile all of your Visual Fortran source files (.FOR) and then link the resulting object files (.OBJ) into a single executable file (.EXE). You can build single-file executables either with the visual development environment or by using the DF (or FL32) command from the console command line.
Portability and Design Considerations Page 12 of 16 Internal procedures have the advantage of host association, that is, variables declared and used in the main program are also available to any internal procedure it may contain. For more information on procedures and host association, see Program Units and Procedures. Internal procedures, like modules, provide a means of encapsulation.
Portability and Design Considerations Page 13 of 16 Mixed-Language Issues Porting Data Between Systems Porting Fortran Source Code Between Systems In general, Visual Fortran is a portable language. One of the main advantages of the language is the availability of large and well-tested libraries of Fortran code. You also might have existing code addressing your problem that you want to reuse. Math and scientific code libraries from most vendors should port to Visual Fortran with virtually no problems.
Portability and Design Considerations Page 14 of 16 example, by specifying ANSI/ISO syntax adherence in the Project Settings (Fortran tab) dialog box or on the command line, you can have the compiler enforce Fortran 90 or 95 syntax. Code that compiles cleanly with this option set is very likely to compile cleanly on any other computer with a Fortran compiler that obeys strict Fortran syntax.
Portability and Design Considerations Page 15 of 16 If you try to transfer unformatted binary data between systems, you need to be aware of the different orders (low-order byte first or high-order byte first) in which different systems store bytes within words. If you need to transfer unformatted binary data, review Portability and Converting Unformatted Numeric Data. You can avoid these problems by using a formatted ASCII file.
Portability and Design Considerations Page 16 of 16 You can take further advantage of preemptive multitasking by designing your program so that portions of it, called threads, can be executed in parallel. For example, one thread can perform a lengthy input/output operation while another thread processes data. All of the threads in your application share the same virtual address space. Windows 98, Windows 95, and Windows NT support multithreading.
Using Dialogs Page 1 of 31 Using Dialogs Dialogs are a user-friendly way to solicit application control. As your application executes, you can make a dialog box appear on the screen and the user can click on a dialog box control to enter data or choose what happens next. With the dialog functions provided with Visual Fortran, you can add dialog boxes to your application.
Using Dialogs Page 2 of 31 1. From the Insert menu, choose Resource. 2. From the list of possible resources, choose Dialog. 3. Click the New button. The dialog editor appears on the screen as shown below. A blank dialog box appears at the left and a toolbar of available controls appears on the right. If you place the cursor over a control on the toolbar, the name of the control appears. Figure: Dialog Editor Sample 1 To add controls to the dialog box 1.
Using Dialogs Page 3 of 31 To specify the names and properties of the added controls 1. Click twice on one of the controls in your dialog box with the left mouse button. A Properties box appears showing the default name and properties for that control. The following figure shows the Properties box for the Horizontal Scroll bar with the default values. 2. Change the control name by typing over the default name (IDC_SCROLLBAR1 in the following figure). 3.
Using Dialogs Page 4 of 31 To use the controls from within a program, you need symbolic names for each of them. In this example, the Horizontal Scroll bar symbolic name is changed in the Properties box to IDC_SCROLLBAR_TEMPERATURE . This is how the control will be referred to in your program; for example, when you get the slide position: INTEGER slide_position retlog = DLGGET (dlg, IDC_SCROLLBAR_TEMPERATURE, slide_position, DLG_POSITION) & The top Edit box is named IDC_EDIT_CELSIUS .
Using Dialogs Page 5 of 31 Figure: Dialog Editor Sample 4 To save the dialog box as a resource file 1. From the File menu, choose Save As. 2. Enter a resource filename for your file. In this example, the resource file is given the name TEMP.RC.
Using Dialogs Page 6 of 31 environment saves the resource file and creates an include file with the name RESOURCE.FD. At this point the appearance of the dialog box is finished and the controls are named, but the box cannot function on its own. An application must be created to run it. Not all the controls on the Resource Editor control toolbar bar are supported by Visual Fortran dialog functions.
Using Dialogs Page 7 of 31 Each control in a dialog box has a unique integer identifier. When the Resource Editor creates the include file (.FD), it assigns the PARAMETER attribute to each control and to the dialog box itself, so they become named constants. It also assigns each control and the dialog box an integer value. You can read the list of names and values in your dialog boxes include file (for example, TEMP.FD).
Using Dialogs Page 8 of 31 This code associates the dialog type with the dialog (IDD_TEMP in this example) defined in your resource and include files (TEMP.RC and TEMP.FD in this example). You give your application access to your dialog resource file by adding the .RC file to your project. You give your application access to the dialog include file by including the .FD file in each subprogram. You associate the dialog properties in these files with the dialog type by calling DLGINIT with your dialog name.
Using Dialogs Page 9 of 31 example: retlog = DlgSet( dlg, IDC_SCROLLBAR_TEMPERATURE, 200, DLG_RANGEMAX) In this statement, the dialog function DLGSET assigns the control named IDC_SCROLLBAR_TEMPERATURE a value of 200. The index DLG_RANGEMAX specifies that this value is a scroll bar maximum range.
Using Dialogs Page 10 of 31 SUBROUTINE UpdateTemp( dlg, control_name, callbacktype ) USE DFLOGM IMPLICIT NONE TYPE (dialog) dlg INTEGER control_name INTEGER callbacktype INCLUDE ’TEMP.FD’ CHARACTER(256) text INTEGER cel, far, retint LOGICAL retlog ! Suppress compiler warnings for unreferenced arguments. INTEGER local_callbacktype local_callbacktype = callbacktype SELECT CASE (control_name) CASE (IDC_EDIT_CELSIUS) ! Celsius value was modified by the user so ! update both Fahrenheit and Scroll bar values.
Using Dialogs Page 11 of 31 user’s action. Calling DLGSET does not cause a callback to be called for the changing value of a control. In particular, when inside a callback, performing a DLGSET on a control will not cause the associated callback for that control to be called. Calling DLGSET before or after DLGMODAL or DLGMODELESS has been called also does not cause the callback to be called. If the callback needs to be called, it can be called manually using CALL after the DLGSET is performed.
Using Dialogs lret lret lret lret lret = = = = = Page 12 of 31 DlgSetSub(dlg_thermometer, IDD_THERMOMETER, ThermometerSub) DlgSet(dlg_thermometer, IDC_PROGRESS1, 32, DLG_RANGEMIN) DlgSet(dlg_thermometer, IDC_PROGRESS1, 212, DLG_RANGEMAX) DlgSet(dlg_thermometer, IDC_PROGRESS1, 32) DlgModeless(dlg_thermometer, nCmdShow) ! Read and process messages until GetMessage returns 0 because ! PostQuitMessage has been called do while( GetMessage (mesg, NULL, 0, 0) ) ! Note that DlgIsDlgMessage must be called in or
Using Dialogs Page 13 of 31 DLGGETCHAR Gets the value of a character control variable DLGGETINT Gets the value of an integer control variable DLGGETLOG Gets the value of a logical control variable DLGINIT Initializes the dialog DLGINITWITHRESOURCEHANDLE Initializes the dialog (alternative to DLGINIT) DLGISDLGMESSAGE Determines whether a message is intended for a modeless dialog box DLGMODAL Displays a modal dialog box DLGMODELESS Displays a modeless dialog box DLGSENDCTRLMESSAGE Sends a mes
Using Dialogs Page 14 of 31 Scroll bar position Scroll bar minimum range Scroll bar maximum range Position change if the user clicks on the scroll bar space next to the slide (big step) Dialog controls and their indexes are discussed in: Control Indexes Available Indexes for Each Dialog Control Specifying Control Indexes Control Indexes The value of a dialog control’s index is set with the DLGSET functions: DLGSET, DLGSETINT, DLGSETLOG, DLGSETCHAR, and DLGSETSUB.
Using Dialogs Page 15 of 31 DLG_DBLCLICK A subroutine called when a control is double-clicked DLG_DEFAULT Same as not specifying a control index DLG_ENABLE The enable state of the control (value = .TRUE. means enabled, value = .FALSE. means disabled) DLG_GAINFOCUS A subroutine called when an Edit Box receives input focus. DLG_LOSEFOCUS A subroutine called when an Edit Box loses input focus.
Using Dialogs Page 16 of 31 The control identifier specified in DLGSETSUB can also be the identifier of the dialog box. In this case, the index must be the value listed in the Dialog Indexes table: Table: Dialog Indexes Dialog index How the value is interpreted DLG_INIT A subroutine called after the dialog box is created but before it is displayed (with callbacktype=DLG_INIT) and immediately before the dialog box is destroyed (with callbacktype=DLG_DESTROY).
Using Dialogs Page 17 of 31 Sets or returns the text of a particular item Dropdown list box Use DLG_NUMITEMS or DLG_STATE: DLG_NUMITEMS (default) Sets or returns the total number of items in a list DLG_STATE Sets or returns the index of the selected item DLG_ENABLE Use DLG_STATE, DLG_SELCHANGE DLG_ADDSTRING, (default) or an index: DLG_DBLCLICK DLG_STATE By default, sets or returns the text of the selected item or first item in the list, or you can include an index, 1 to n, to set or return indicates the
Using Dialogs Page 18 of 31 An index, 1 to n Determines which list items have been selected and their order DLG_ADDSTRING Used with DLGSETCHAR to add a new item. It automatically increments DLG_NUMITEMS.
Using Dialogs Tab control Use DLG_NUMITEMS (default), DLG_STATE, or an index: DLG_NUMITEMS Sets or returns the total number of tabs DLG_STATE Sets or returns the currently selected tab Page 19 of 31 DLG_ENABLE Use DLG_STATE or DLG_SELCHANGE an index: (default) DLG_SELCHANGING DLG_STATE By default, sets or returns the currently selected tab An index, 1 to n Sets or returns the text of a particular Tab An index, 1 to n Sets or returns the dialog name of the dialog box associated with a particular tab For
Using Dialogs Page 20 of 31 or DLGSETLOG: retlog = DLGSETLOG (dlg, IDC_TEXT_CELSIUS, .FALSE., DLG_ENABLE) retlog = DLGSET (dlg, IDC_TEXT_CELSIUS, .FALSE., DLG_ENABLE) In both these cases, the control index DLG_ENABLE can be omitted because there is only one logical control index for Static text controls. You can query the value of a particular control index with the DLGGET functions, DLGGET, DLGGETINT, DLGGETLOG, and DLGGETCHAR.
Using Dialogs Page 21 of 31 default, the tab order of the controls follows the order in which they were created. This may not be the order you want. You can change the order by opening the Layout menu and choosing Tab Order (or by pressing the key combination Ctrl+D) in the Resource Editor. A tab number will appear next to each control. Click the mouse on the control you want to be first, then on the control you want to be second in the tab order and so on.
Using Dialogs Page 22 of 31 by the user are interpreted by your application as character strings. Likewise, numbers you write to the Edit box are sent as character strings. You can convert between numbers and strings by using internal read and write statements to make type conversions. To read a number in the Edit box, retrieve it as a character string with DLGGET or DLGGETCHAR, and then execute an internal read using a variable of the numeric type you want (such as integer or real).
Using Dialogs Page 23 of 31 Disabling the Group box disables the hotkey, but does not disable any of the controls within the group. As a matter of style, you should generally disable the controls in a group when you disable the Group box. Using Check Boxes and Radio Buttons Check boxes and Radio buttons present the user with an either-or choice. A Radio button is pushed or not, and a Check box is checked or not. You use DLGGET or DLGGETLOG to check the state of these controls.
Using Dialogs Page 24 of 31 a Combo box, only one selection can be made at a time in a Drop-down list box, but, like a List box, the selected value cannot be edited. A Drop-down list box serves the same function as a List box except for the disadvantage that the user can choose only a single selection, and the advantage that it takes up less dialog screen space. Visual Fortran dialog functions do not support user-drawn List boxes or user-drawn Combo boxes.
Using Dialogs Page 25 of 31 If Larry alone had been selected, the List box selection index values would be: Selection index Value 1 2 (for Larry) 2 0 (no more selections) To determine the items selected, the List box values can be read with DLGGET until a zero is encountered. For example: INTEGER j, num, test INTEGER, ALLOCATABLE :: values(:) LOGICAL retlog retlog = DLGGET (dlg, IDC_LISTBOX1, num, DLG_NUMITEMS) ALLOCATE (values(num)) j = 1 test = -1 DO WHILE (test .NE.
Using Dialogs Page 26 of 31 lowercase letters. For example, if the List box in the example above with the list "Moe," "Larry," "Curly," and "Shemp" were sorted, before a callback or after DLGMODAL returned, index 1 would refer to "Curly," index 2 to "Larry," index 3 to "Moe," and index 4 to "Shemp." For this reason, when using sorted List boxes, indexes should not be counted on to be the same once the dialog is displayed and any change is made to the list items.
Using Dialogs Page 27 of 31 Like List boxes, Combo boxes can be specified as sorted or unsorted. The notes about sorted List boxes also apply to sorted Combo boxes.
Using Dialogs Page 28 of 31 You can also set the increment taken when the user clicks in the blank area above or below the slide in a vertical Scroll bar, or to the left or right of the slide in a horizontal Scroll bar, by setting the control index DLG_BIGSTEP. For example: retlog = DLGSET (dlg, IDC_SCROLLBAR1, 20, DLG_BIGSTEP) When the user clicks on the arrow buttons of the Scroll bar, the position is always incremented or decremented by 1.
Using Dialogs Page 29 of 31 The Spin Control calls the DLG_CHANGE callback whenever the user changes the current value of the control. The Spin control is named the "Up-down" control in Windows programming documentation. Using Sliders The Slider Control is a window that contains a slider and optional tick marks. Your application sets or gets the range of the Slider control’s values, using DLG_RANGEMIN and DLG_RANGEMAX, and the current value, using DLG_POSITION.
Using Dialogs Page 30 of 31 1. Set the "Style" to "Child" 2. Set "Border" to "None" 3. Uncheck "Title Bar" Before displaying the dialog box that contains the Tab control (using DLGMODAL or DLGMODELESS): 1. Call DLGSETSUB to define a DLG_INIT callback for the dialog box 2. Call DLGINIT for each Tab dialog In the DLG_INIT callback of the dialog box that contains the Tab control, if the callbacktype is DLG_INIT, call DLGMODELESS for each of the Tab dialog boxes.
Using Dialogs Page 31 of 31 DLGEXIT returns control back to the dialog manager, not immediately after calling DLGEXIT. That is, if there are other statements following DLGEXIT within the callback routine that contains it, those statements are executed and the callback routine returns before the dialog box is exited.
Drawing Graphics Elements Page 1 of 22 Drawing Graphics Elements The graphics routines provided with Visual Fortran set points, draw lines, draw text, change colors, and draw shapes such as circles, rectangles, and arcs. This section assumes you have read the overview in Using QuickWin. This section uses the following terms: The origin (point 0, 0) is the upper-left corner of the screen or the client area (defined user area) of the child window being written to.
Drawing Graphics Elements Page 2 of 22 subdirectory defines a derived type, windowconfig, that GETWINDOWCONFIG uses as a parameter: \INCLUDE TYPE windowconfig INTEGER(2) numxpixels INTEGER(2) numypixels INTEGER(2) numtextcols INTEGER(2) numtextrows INTEGER(2) numcolors INTEGER(4) fontsize CHARACTER(80) title INTEGER(2) bitsperpixel END TYPE windowconfig ! ! ! ! ! ! ! ! Number of pixels on x-axis Number of pixels on y-axis Number of text columns available Number of text rows available Number of color i
Drawing Graphics Elements Page 3 of 22 Like many programs, graphics programs work well when written in small units. Using discrete routines aids debugging by isolating the functional components of the program. The following example program and its associated subroutines show the steps involved in initializing, drawing, and closing a graphics program. The SINE program draws a sine wave. Its procedures call many of the common graphics routines.
Drawing Graphics Elements Page 4 of 22 Activating a Graphics Mode If you call a graphics routine without setting a graphics mode with SETWINDOWCONFIG, QuickWin automatically sets the graphics mode with default values.
Drawing Graphics Elements Page 5 of 22 ! INTEGER(2) FUNCTION newy( ycoord ) INTEGER(2) ycoord, maxx, maxy REAL(4) tempy COMMON maxx, maxy tempy = maxy / 1000.0 tempy = ycoord * tempy + 0.5 newy = tempy END You can set up a similar independent coordinate system with window coordinates, described in Understanding Coordinate Systems.
Drawing Graphics Elements Page 6 of 22 Because the coordinates for the two corners are ( 0, 0 ) and ( maxx, maxy ), the call to RECTANGLE frames the entire screen. The program calls SETVIEWORG to change the location of the viewport origin.
Drawing Graphics Elements EXTERNAL newx, newy PARAMETER ! ! Page 7 of 22 ( PI = 3.14159 ) Calculate each position and display it on the screen. color = #0000FF ! red ! DO i = 0, rad = locx = locy = dummy = END DO END 999, 3 -SIN( PI * i / 250.0 ) newx( i ) newy( INT2( rad * 250.0 ) ) SETPIXELRGB( locx, locy, color ) SETPIXELRGB takes the two location parameters, locx and locy, and sets the pixel at that position with the specified color value (red).
Drawing Graphics Elements Page 8 of 22 ELLIPSE draws an ellipse using parameters similar to those for RECTANGLE. It, too, requires a fill flag and two corners of a bounding rectangle. The following figure shows how an ellipse uses a bounding rectangle: Figure: Bounding Rectangle The $GFILLINTERIOR constant fills the shape with the current fill pattern. To create a pattern, pass the address of an 8-byte array to SETFILLMASK.
Drawing Graphics Elements Page 9 of 22 If you use a palette, you are restricted to the colors available in the palette. In order to access all colors available on your system, you need to specify an explict Red-Green-Blue (RGB) value, not a palette index. When you select a color index, you specify one of the colors in the system’s predefined palette. SETCOLOR, SETBKCOLOR, and SETTEXTCOLOR set the current color, background color, and text color to a palette index.
Drawing Graphics Elements Page 10 of 22 Dull Yellow #008080 Bright Yellow #00FFFF Dull Blue #800000 Bright Blue #FF0000 Dull Magenta #800080 Bright Magenta #FF00FF Dull Turquoise #808000 Bright Turquoise #FFFF00 Dark Gray Light Gray #808080 #C0C0C0 If you have a 64K-color machine and you set an RGB color value that is not equal to one of the 64K preset RGB color values, the system approximates the requested RGB color to the closest available RGB value.
Drawing Graphics Elements Page 11 of 22 If you request an RGB color that is not in the palette, the color selected from the palette is the closest approximation to the RGB color requested. If the RGB color was previously placed in the palette with REMAPPALETTERGB or REMAPALLPALETTERGB, then that exact RGB color is available. Remapping the palette has no effect on 64K-color machines, SVGA, or true-color machines, unless you limit yourself to a palette by using color index functions such as SETCOLOR.
Drawing Graphics Elements Page 12 of 22 Several different coordinate systems are supported by the Visual Fortran QuickWin Library. Text coordinates work in rows and columns; physical coordinates serve as an absolute reference and as a starting place for creating custom window and viewport coordinates. Conversion routines make it simple to convert between different coordinate systems.
Drawing Graphics Elements Page 13 of 22 Figure: Physical Coordinates The upper-left corner is the origin. The x- and y-coordinates for the origin are always (0, 0). Physical coordinates refer to each pixel directly and are therefore integers (that is, the window's client area cannot display a fractional pixel). If you use variables to refer to pixel locations, declare them as integers or use type-conversion routines when passing them to graphics functions.
Drawing Graphics Elements Page 14 of 22 The default clipping region occupies the entire screen. The QuickWin Library ignores any attempts to draw outside the screen. You can change the clipping region by calling SETCLIPRGN. For example, suppose you entered a screen resolution of 320x200 pixels.
Drawing Graphics Elements Page 15 of 22 Window Coordinates Functions that refer to coordinates on the client-area screen and within the viewport require integer values. However, many applications need floating-point values--for frequency, viscosity, mass, and so on. SETWINDOW lets you scale the screen to almost any size. In addition, window-related functions accept double-precision values. Window coordinates use the current viewport as their boundaries. A window overlays the current viewport.
Drawing Graphics Elements Page 16 of 22 axis into a small range (such as 151.25 to 151.45) or into a large range (-50000.0 to +80000.0), depending on the type of data you graph. In addition, by changing the window coordinates, you can create the effects of zooming in or panning across a figure. The window coordinates also make your drawings independent of the computer’s hardware. Output to the viewport is independent of the actual screen resolution. Real Coordinates Sample Program The program REALG.
Drawing Graphics Elements Page 17 of 22 The gridshape subroutine, which draws the graphs, uses the same data in each case. However, the program uses three different coordinate windows. The two viewports in the top half are the same size in physical coordinates, but have different window sizes. Each window uses different maximum and minimum values. In all three cases, the graph area is two units wide.
Drawing Graphics Elements ! ! ! Page 18 of 22 First window CALL SETVIEWPORT( INT2(0), INT2(0), halfx - 1, halfy - 1 ) CALL SETTEXTWINDOW( INT2(1), INT2(1), rows / 2, cols / 2 ) status = SETWINDOW( .FALSE., -2.0_8, -2.0_8, 2.0_8, 2.0_8) The 2.
Drawing Graphics Elements window. The gridshape subroutine plots the data on the screen. ! GRIDSHAPE - This subroutine plots data for REALG.F90 ! SUBROUTINE gridshape( numc ) ! USE DFLIB INTEGER(2) numc, i, status INTEGER(4) rgbcolor, oldcolor CHARACTER(8) str REAL(8) bananas(21), x TYPE (windowconfig) myscreen TYPE (wxycoord) wxy TYPE (rccoord) curpos COMMON myscreen ! ! Data for the graph: ! DATA bananas / -0.3, -0.2, -0.224, -0.1, -0.5, 0.21, 2.9, & & 0.3, 0.2, 0.0, -0.885, -1.1, -0.3, -0.2, & & 0.
Drawing Graphics Elements Page 20 of 22 END The routine names that end with _W work in the same way as their viewport equivalents, except that you pass double-precision floating-point values instead of integers. For example, you pass INTEGER (2) to LINETO, but REAL(8) values to LINETO_W. The two other windows are similar to the first. All three call the gridshape function, which draws a grid from location (-1.0, -1.0) to (1.0, 1.0).
Drawing Graphics Elements Page 21 of 22 The OpenGL Reference Manual, Addison-Wesley, ISBN 0-201-46140-4. The OpenGL Programming Guide, Addison-Wesley, ISBN 0-201-46138-2. OpenGL SuperBible: The Complete Guide to OpenGL Programming on Windows NT and Windows 95, Richard Wright and Michael Sweet, Waite Group Press (Division of Sams Publishing), 1996, ISBN 1-57169-073-5. OpenGL documentation in the Windows NT, Windows 98, and Windows 95 Platform SDK in HTMLHelp Viewer.
Drawing Graphics Elements Page 22 of 22 GLuint, GLenum, GLbitfield INTEGER(4) GLvoid not needed pointers INTEGER Visual Fortran Samples that use OpenGL are available in separate folders in ...\DF98 \SAMPLES\ADVANCED\OPENGL . For example, OLYMPIC is a Fortran QuickWin project and CUBE5 is a Fortran Windows project.
Using Fonts from the Graphics Library Page 1 of 4 Using Fonts from the Graphics Library The Visual Fortran Graphics Library includes routines that print text in various sizes and type styles. These routines provide control over the appearance of your text and add visual interest to your screen displays. This section assumes you have read Drawing Graphics Elements and that you understand the general terminology it introduces.
Using Fonts from the Graphics Library Page 2 of 4 TrueType text to any size, but the characters sometimes don’t look quite as solid as the bitmapped characters on the screen. Usually this screen effect is hardly noticable, and when printed, TrueType fonts are as smooth or smoother than bitmapped fonts. The bitmapped typefaces come in preset sizes measured in pixels. The exact size of any font depends on screen resolution and display type.
Using Fonts from the Graphics Library Page 3 of 4 The following example sets the typeface to Arial, the character height to 14, with proportional spacing and italics (the pi codes): index = SETFONT(’t’’Arial’’h14pi’) If SETFONT successfully sets the font, it returns the font's index number. If the function fails, it returns a negative integer. Call GRSTATUS to find the source of the problem; its return value indicates why the function failed.
Using Fonts from the Graphics Library Page 4 of 4 the typeface. MOVETO then establishes the starting point for each text string. The program sends a message of sample text to the screen for each font initialized: ! Abbreviated version of SHOWFONT.F90. USE DFLIB INTEGER(2) grstat, numfonts,indx, curr_height TYPE (xycoord) xyt TYPE (fontinfo) f CHARACTER(6) str ! 5 chars for font num ! (max. is 32767), 1 for ’n’ ! Initialization. numfonts=INITIALIZEFONTS( ) IF (numfonts.LE.
Using National Language Support Routines Page 1 of 8 Using National Language Support Routines Visual Fortran provides a complete National Language Support (NLS) library of languagelocalization routines and multibyte-character routines. You can use these routines to write applications in many different languages.
Using National Language Support Routines Page 2 of 8 program. They do not change the system default settings. The codepage you select, which can be set independently, controls the multibyte (MB routines) character routines described in this section. Only users with special multibyte-character code sets installed on their computers need to use MB routines. The standard code sets all use single-byte character code sets.
Using National Language Support Routines Page 3 of 8 names when writing your applications. Locale Setting and Inquiry Routines At program startup, the current language and country setting is retrieved from the operating system. The user can change this setting through the Control Panel Regional Settings icon. The current codepage is also retrieved from the system. There is a system default console codepage and a system default Windows codepage.
Using National Language Support Routines Page 4 of 8 strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME3, str) print *, str ! prints miércoles END NLS Formatting Routines You can set time, date, currency and number formats from the Control Panel, by clicking on the Regional Settings icon. The NLS Library also provides formatting routines for the current locale. These routines are summarized in the following table.
Using National Language Support Routines Page 5 of 8 Routines discussed in this section are: MBCS Inquiry Routines MBCS Conversion Routines MBCS Fortran Equivalent Routines Standard Fortran 90 Routines That Handle MBCS Characters MBCS Inquiry Routines The MBCS inquiry routines provide information on the maximum length of multibyte characters, the length, number and position of multibyte characters in strings, and whether a multibyte character is a leading or trailing byte.
Using National Language Support Routines Page 6 of 8 PRINT ’(/,1X,’’MBLead = ’’,\)’ DO i = 1, len(str) PRINT ’(L2,\)’,mblead(str(i:i)) END DO PRINT ’(/,1X,’’String as whole = ’’,A,\)’,str PRINT ’(/,1X,’’MBStrLead = ’’,\)’ DO i = 1, len(str) PRINT ’(L1,\)’,MBStrLead(str,i) END DO END This code produces the following output for str = · , " ¿ MBCS Conversion Routines There are four MBCS conversion routines: two convert Japan Industry Standard characters to Microsoft Kanji characters or vice versa, and the
Using National Language Support Routines Page 7 of 8 Name Procedure Type MBINCHARQQ Function Same as INCHARQQ but can read a single multibyte character at once and returns the number of bytes read MBINDEX Function Same as INDEX except that multibyte characters can be included in its arguments MBLGE, MBLGT, MBLLE, Functions MBLLT, MBLEQ, MBLNE Description Same as LGE, LGT, LLE, LLT and the operators .EQ. and .NE.
Using National Language Support Routines Page 8 of 8 Standard Fortran Routines That Handle MBCS Characters This section describes Fortran routines that work as usual even if MBCS characters are included in strings. Because a space can never be a lead or tail byte, many routines that deal with spaces work as expected on strings containing MBCS characters.
Portability Library Page 1 of 9 Portability Library Visual Fortran includes functions and subroutines that ease porting of code from a different platform to a PC, or allow you to write code on a PC that is compatible with other platforms. Frequently used functions are included in a module called DFPORT.
Portability Library Page 2 of 9 Convention) file names. A forward slash in a path name is treated as a backslash. All path names can contain drive specifications as well as MBCS (multiple-byte character set) characters. For information on MBCS characters, see Using National Language Support Routines.
Portability Library Page 3 of 9 by file name or unit number. Use INQUIRE as an equivalent to FSTAT, LSTAT or STAT. LSTAT and STAT return the same information; STAT is the preferred function. Process Control Routines Process control routines control the operation of a process or subprocess. You can wait for a subprocess to complete with either SLEEP or ALARM, monitor its progress and send signals via KILL, and stop its execution with ABORT.
Portability Library Page 4 of 9 Portability routine Description BESJ0, BESJ1, BESJN, BESY0, BESY1, BESYN Computes the single precision values of Bessel functions of the first and second kind of orders 1, 2, and n, respectively DBESJ0, DBESJ1, DBESJN, DBESY0, DBESY1, DBESYN Computes the double-precision values of Bessel functions of the first and second kind of orders 1, 2, and n, respectively LONG Converts an INTEGER(2) variable to an INTEGER(4) type SHORT Converts an INTEGER(4) variable to an IN
Portability Library Page 5 of 9 On units with CARRIAGECONTROL=’FORTRAN’ (the default),PUTC and FPUTC characters are treated as carriage control characters if they appear in column 1. On sequentially formatted units, the C string "\n"c, which represents the carriage return/line feed escape sequence, is written as CHAR(13) (carriage return) and CHAR(10) (line feed), instead of just line feed, or CHAR(10). On input, the sequence 13 followed by 10 is returned as just 10.
Portability Library Page 6 of 9 The sample output column of the following table assumes the current date to be 2/24/97 7:11 pm Pacific Daylight Time. The third column shows what each routine returns, either when reporting the current time or when that date and time is passed to it in an appropriate argument. Full details of parameters and output are given in the description of each routine (A to Z Reference) in the Language Reference.
Portability Library Page 7 of 9 less the value of its argument TIME As a subroutine, returns the time formatted as hh:mm:ss Subroutine: "07:11:00" Function: 762145860 As a function, returns the time in seconds since midnight GMT Jan 1, 1970 TIMEF The number of seconds since the first time 0.0 this function was called (or zero) TIME and DATE are available as either a function or subroutine.
Portability Library Page 8 of 9 Portability routine Description LNBLNK Returns the index of the last non-blank character in a string. QSORT Sorts a one-dimensional array of a specified number of elements of a named size. RINDEX Returns the index of the last occurrence of a substring in a string. Other Compatibility Routines If you need to call a routine not listed in the portability library, you may find it in the standard Visual Fortran library.
Portability Library SYMLNK Page 9 of 9 Creates a symbolic link between two files none Note: CreateProcess is a Win32 API call described in Creating Multithread Applications.
Files, Devices, and I/O Hardware Page 1 of 17 Files, Devices, and I/O Hardware This chapter discusses Visual Fortran files and devices, and using your input/output (I/O) hardware. Together with the sections on I/O statements and I/O editing, these sections explain where and how Fortran data is input and output.
Files, Devices, and I/O Hardware Page 2 of 17 associated PRINT, which always writes to standard output, unless the FOR_PRINT environment variable is defined. READ statements that contain only an I/O list and format specifier, which read from standard input (UNIT=5), unless the FOR_READ environment variable is defined. WRITE statements that contain only an I/O list and format specifier, which write to standard output, unless the FOR_PRINT environment variable is defined.
Files, Devices, and I/O Hardware Page 3 of 17 The following example writes to the preconnected unit 6 (the screen), then reconnects unit 6 to an external file and writes to it, and finally reconnects unit 6 to the screen and writes to it: REAL a, b Write to the screen (preconnected unit 6). WRITE(6, ’(’’ This is unit 6’’)’) ! Use the OPEN statement to connect unit 6 ! to an external file named ’COSINES’. OPEN (UNIT = 6, FILE = ’COSINES’, STATUS = ’NEW’) DO a = 0.1, 6.3, 0.
Files, Devices, and I/O Hardware Page 4 of 17 reading from an internal file converts the ASCII representations into numeric, logical, or character representations, and writing to an internal file converts these representations into their ASCII representations. This feature makes it possible to read a string of characters without knowing its exact format, examine the string, and interpret its contents.
Files, Devices, and I/O Hardware Page 5 of 17 the beginning of the file. By specifying relative record numbers, you can directly retrieve, add, or delete records regardless of their locations. (Detecting deleted records is only available if you specified the /vms option when the program was compiled. For information, see the /vms option.) DIGITAL Fortran supports two methods of file access (sequential and direct) and three kinds of file structure (formatted, unformatted, and binary).
Files, Devices, and I/O Hardware Page 6 of 17 Data in sequential files must be accessed in order, one record after the other (unless you change your position in the file with the REWIND or BACKSPACE statements). Some methods of I/O are possible only with sequential files, including nonadvancing I/O, list-directed I/O, and namelist I/O. Internal files also must be sequential files. You must use sequential access for files associated with sequential devices.
Files, Devices, and I/O Hardware Page 7 of 17 Variable-length The variable-length record type is generally the most portable record type across multi-vendor platforms. It can be used only with the sequential file organization. Segmented The segmented record type can only be used with sequential file organization and only for unformatted sequential access.
Files, Devices, and I/O Hardware Page 8 of 17 Variable-Length Records Variable-length records can contain any number of bytes, up to a specified maximum record length, and only apply to sequential files. These records are generally prefixed and suffixed by four bytes of control information containing count fields. The 4-byte integer value stored in each count field indicates the number of data bytes (excluding overhead bytes) in that particular variable-length record.
Files, Devices, and I/O Hardware Page 9 of 17 record length (2.14 billion bytes), but each segment (physical record) individually cannot exceed the maximum record length. To access an unformatted sequential file that contains segmented records, specify FORM='UNFORMATTED' and RECORDTYPE='SEGMENTED' when you open the file. Otherwise, the file may be processed erroneously. As shown below, the layout of segmented records consists of 4 bytes of control information followed by the user data.
Files, Devices, and I/O Hardware Page 10 of 17 The layout of stream_CR records appears below. Stream_LF Records A stream_LF record is a variable-length record whose length is indicated by explicit record terminators embedded in the data, not by a count. These terminators are automatically added when you write records to a stream-type file, and they are removed when you read records.
Files, Devices, and I/O Hardware Page 11 of 17 CLOSE (3) END Figure: Formatted Sequential File Formatted Direct Files In a formatted direct file, all of the records are the same length and can be written or read in any order. The record size is specified with the RECL option in an OPEN statement and should be equal to or greater than the number of bytes in the longest record. The carriage return (CR) and line feed (LF) characters are record separators and are not included in the RECL value.
Files, Devices, and I/O Hardware Page 12 of 17 Unformatted Sequential Files Unformatted sequential files are organized slightly differently on different platforms. This section describes unformatted sequential files created by Visual Fortran when the /fpscomp:ioformat option was specified. If you are accessing files from another platform that organizes them differently, see Converting Unformatted Numeric Data or you can use the conversion utility in the ...\DF98\SAMPLES\TUTORIAL folder called UNFSEQ.
Files, Devices, and I/O Hardware ! ! Page 13 of 17 -1 is FF FF FF FF hexadecimal. CHARACTER xyz(3) INTEGER(4) idata(35) DATA idata /35 * -1/, xyz /’x’, ’y’, ’z’/ ! ! ! Open the file and write out a 140-byte record: 128 bytes (block) + 12 bytes = 140 for IDATA, then 3 bytes for XYZ. OPEN (3, FILE=’UFSEQ’,FORM=’UNFORMATTED’) WRITE (3) idata WRITE (3) xyz CLOSE (3) END Figure: Unformatted Sequential File Unformatted Direct Files An unformatted direct file is a series of unformatted records.
Files, Devices, and I/O Hardware Page 14 of 17 Binary Sequential Files A binary sequential file is a series of values written and read in the same order and stored as binary numbers. No record boundaries exist, and no special bytes indicate file structure. Data is read and written without changes in form or length. For any I/O data item, the sequence of bytes in memory is the sequence of bytes in the file.
Files, Devices, and I/O Hardware Page 15 of 17 direct file would cause an error. Valid I/O operations for unformatted direct files produce identical results when they are performed on binary direct files, provided the operations do not depend on zero padding in partial records.
Files, Devices, and I/O Hardware Page 16 of 17 background applications.) Once you have copied your screen onto the Clipboard, open Paintbrush and select Edit/Paste to paste the image from the Clipboard into Paintbrush, then select File/Print to print it to the printer connected to your computer. You can also save the image as a bitmap (.BMP) file. Physical Devices I/O statements that do not refer to a specific file or I/O device read from standard input and write to standard output.
Files, Devices, and I/O Hardware CONIN$ Page 17 of 17 Standard input 1 If you use one of these names with an extension -- for example, LINE.TXT -- Fortran will write to a file rather than to the device.
Using COM and Automation Objects Page 1 of 12 Using COM and Automation Objects Visual Fortran provides a wizard to simplify the use of Component Object Model (COM) and Automation (formerly called OLE Automation) objects. The Visual Fortran Module Wizard generates Fortran 90 modules that simplify calling COM and Automation services from Fortran programs.
Using COM and Automation Objects Page 2 of 12 4. Write a Fortran 90 program to invoke the code generated by the Visual Fortran module wizard. To understand more about calling the interfaces and jacket routines created by the module wizard, see Additional Information About COM and Automation Objects. Using the Module Wizard to Generate Code To run the Visual Fortran Module Wizard, choose the Tools menu item Fortran Module Wizard.
Using COM and Automation Objects Page 3 of 12 After you select one of the five choices, one of two different screens will appear depending on the selection made. The "Module Name" in the initial Module Wizard screen is used as the name of the Fortran module being generated. It is also used as the default file name of the generated source file.
Using COM and Automation Objects Page 4 of 12 Microsoft recommends that object servers provide a type library. However some applications do not, but do provide type information dynamically when running. Use this option for such an application. Enter the name of the application, name of the object, and version number. The version number is optional. If you do not specify it, you will get the latest version of the object.
Using COM and Automation Objects Page 5 of 12 Choose the type library (or file containing the type library), and optionally specific components of the type library. At the top of the dialog box is a combo box that lists all of the type libraries that have been registered with the system. You will notice a number of different file extensions, for example, .OLB (object libraries) and .OCX (ActiveX® controls).
Using COM and Automation Objects Page 6 of 12 The use of modules allows the Visual Fortran Module Wizard to encapsulate the data structures and procedures exposed by an object or DLL in a single place. You can then share these definitions in multiple Fortran programs. The appropriate USE statement needs to be added in your program, as well as function invocations or subroutine calls. The routines generated by the Visual Fortran Module Wizard are designed to be called from Fortran.
Using COM and Automation Objects COMUninitialize Page 7 of 12 Uninitializes the COM library. This must be the last COM routine that you call. DFAUTO Automation Routines (AUTOxxxxx) AUTOAddArg Passes an argument name and value and adds the argument to the argument list data structure. AUTOAllocateInvokeArgs Allocates an argument list data structure that holds the arguments that you will pass to AUTOInvoke. AUTODeallocateInvokeArgs Deallocates an argument list data structure.
Using COM and Automation Objects Page 8 of 12 Example of Generated Code Used by the DSLINES Sample The DLINES Sample contains the code that invokes this and other Microsoft visual development environment functionality using COM interfaces. The following code shows an annotated version of the code generated by the Fortran Module Wizard from the COM type information in ...\Common\MSDev98\Bin\devshl.dll .
Using COM and Automation Objects Page 9 of 12 The interface of a COM member function looks very similar to the interface for a dynamic link library function with one major exception. Unlike a DLL function, the address of a COM member function is never known at program link time. You must get a pointer to an object’s interface at runtime, and the address of a particular member function is computed from that.
Using COM and Automation Objects Page 10 of 12 Arguments to a COM or Automation routine can be optional. The wrapper handles the invocation details for specifying an optional argument that is not present in the call. The offset of the "Save" member function is 84. The code assigns the computed address to the function pointer IGenericDocument_Save_PTR, which was declared in the previous example, and then calls the function.
Using COM and Automation Objects Page 11 of 12 AUTOAllocateInvokeArgs allocates a data structure that is used to collect the arguments that you will pass to the method. AUTOAddArg adds an argument to this data structure. AUTOInvoke invokes the named method passing the argument list. This returns a status result. If the caller supplied a status argument, the code copies the status result to it. AUTODeallocateInvokeArgs deallocates the memory used by the argument list data structure.
Using COM and Automation Objects Page 12 of 12 Object Identification Object identification enables the use of COM objects created by disparate groups of developers. To provide a method of uniquely identifying an object class regardless of where it came from, COM uses globally unique identifiers (GUIDs). A GUID is a 16-byte integer value that is guaranteed (for all practical purposes) to be unique across space and time.
Programming with Mixed Languages Page 1 of 47 Programming with Mixed Languages Mixed-language programming is the process of building programs in which the source code is written in two or more languages.
Programming with Mixed Languages Pag e 2 of 47 Mixed-language programming is possible with Visual Fortran, Visual C/C++, Visual Basic, and assembly language (MASM) because each language implements functions, subroutines, and procedures in approximately the same way. The following table shows how different kinds of routines from each language correspond to each other. For example, a C main program could call an externa lvoid function, which is actually implemented as a Fortran subroutine.
Programming with Mixed Languages Pag e 3 of 47 the same version of the visual development environment for your languages (see Mixed-Language Development Support i nGetting Started). This section provides an explanation of the keywords, attributes, and techniques you can use to reconcile differences between Fortran and other languages.
Programming with Mixed Languages Page 4 of 47 3. The caller routine and the called routine use a calling convention to select the option of passing a variable number of arguments. 4. The caller routine and the called routine use a calling convention to pass arguments by value (values passed) or by reference (addresses passed). Individual Fortran arguments can also be designated with ATTRIBUTES option VALUE or REFERENCE. 5.
Programming with Mixed Languages Page 5 of 47 On Alpha systems, there is no leading underscore for external names like MY_SUB, so the correct !DEC$ ATTRIBUTES line is: !DEC$ ATTRIBUTES C, ALIAS:’My_Sub’ :: MY_SUB ! Alpha systems To write code for both x86 and Alpha platforms, use the conditional compilation features of the IF Directive Construct, perhaps using the predefined preprocessor macros _X86_ and _ALPHA_ (listed under the /define option).
Programming with Mixed Languages Page 6 of 47 Derived Type [value] Value, size dependent Value, size dependent Value, size dependent Value, size dependent Value, size dependent Derived Type [reference] Reference Reference Reference Reference Reference F90 Pointer Descriptor Descriptor Descriptor Descriptor Descriptor F90 Pointer [value] Error Error Error Error Error F90 Pointer [reference] Descriptor Descriptor Descriptor Descriptor Descriptor Procedure Name Suffix @n (x86 s
Programming with Mixed Languages Page 7 of 47 No Len l Len: Mixed applies when /iface:mixed_str_len_arg is set. The length of the string is pushed (by value) on the stack immediately after the address of the beginning of the string. l No Len applies when /iface:nomixed_str_len_arg is set. The length of the string is not available to the called procedure. No Len For string arguments, the length of the string is not available to the called procedure.
Programming with Mixed Languages Page 8 of 47 Visual Basic CDECL keyword C MASM C (in PROTO and PROC declarations) C MASM STDCALL (in PROTO and PROC declarations) STDCALL The ALIAS option can be used with any other Fortran calling-convention option to preserve mixedcase names. Note: When interfacing to the Windows graphical user interface or making API calls, you will typically use STDCALL. See Creating Windows Applications for more information on Windows programming.
Programming with Mixed Languages Page 9 of 47 Alternatively, instead of changing the calling convention of the C code, you can adjust the Fortran source code by using the C option. This is set with the ATTRIBUTES directive.
Programming with Mixed Languages Page 10 of 47 As an example, the following Fortran and MASM statements set up a MASM function that can be called from Visual Fortran, using the STDCALL calling convention: !Fortran STDCALL prototype. INTERFACE INTEGER FUNCTION forfunc(I1, I2) !DEC$ ATTRIBUTES STDCALL :: forfunc INTEGER I1 INTEGER(2) I2 END INTERFACE WRITE (*,*) forfunc(I1,I2) ;MASM STDCALL Prototype .MODEL FLAT, STDCALL forfunc PROTO STDCALL, forint: SDWORD, shorti: ptr SWORD .
Programming with Mixed Languages Page 11 of 47 error. This section discusses: Visual C/C++ and Visual Basic Naming Conventions MASM Naming Conventions Naming Conventions for Fortran, C, Visual C++, Visual Basic, and MASM Reconciling the Case of Names Fortran Module Names and ATTRIBUTES Visual C/C++ and Visual Basic Naming Conventions Visual C/C++ and Visual Basic preserve case sensitivity in their symbol tables while Fortran by default does not, a difference that requires attention.
Programming with Mixed Languages Page 12 of 47 For more information on the extern "C" linkage specification, see the Microsoft Visual C++ Language Reference. MASM Naming Conventions In MASM (Microsoft Assembler, for x86 systems), specifying the C or STDCALL naming convention in PROC and PROTO statements preserves case sensitivity if no CASEMAP option exists.
Programming with Mixed Languages Page 13 of 47 extern int __stdcall Sum_Up( int a, int b, int c ); Each integer occupies 4 bytes, so the symbol name placed in the .OBJ file on x86 systems is: _Sum_Up@12 On Alpha systems, the symbol name placed in the .
Programming with Mixed Languages Page 14 of 47 STDCALL options change the name to all lowercase. You cannot call a Visual Basic routine from Fortran directly (see Fortran/Visual Basic Mixed-Language Programs), so Basic routine names are never translated. Mixed-case Names If the name of a routine appears as mixed-case in C or MASM and you cannot change the name, then you can resolve this naming conflict by using the Fortran ATTRIBUTES ALIAS option.
Programming with Mixed Languages Page 15 of 47 Compiler options can affect the naming of module data and procedures. Note: Except for ALIAS, ATTRIBUTES options do not affect the module name, which remains uppercase. The following table shows how each ATTRIBUTES option affects the subroutine in the previous example module. Effect of ATTRIBUTES options on Fortran Module Names ATTRIBUTES Option Given to Routine ’b’ Procedure name in .OBJ file on x86 systems Procedure name in .
Programming with Mixed Languages Page 16 of 47 The routine statement defines either a FUNCTION or a SUBROUTINE, where the choice depends on whether a value is returned or not, respectively. The optional routine ATTRIBUTE options (such as C and STDCALL) determine the calling, naming, and argument-passing conventions for the routine in the prototype statement. The optional argument ATTRIBUTE options (such as VALUE and REFERENCE) are properties attached to individual arguments.
Programming with Mixed Languages Page 17 of 47 argument lists just as you can within each language (for example, the argument list a, b and c in CALL MYSUB(a,b,c)). There are two ways to pass individual arguments: By value, which passes the argument’s value. By reference, which passes the address of the argument. (In Fortran, Visual Basic, C, and Visual C++, all addresses are 4 bytes on x86 and Alpha systems.
Programming with Mixed Languages Page 18 of 47 In Visual Basic, arguments are passed by reference by default. To pass arguments by value, you use the keyword BYVAL in front of the argument in the DECLARE statement. For example: Declare Sub TESTPROC Lib "C:\f90\TESTPROC.DLL" (ByVal Valparm As Long, Refparm As Long) Strings are a special case. See the discussion on character strings in Handling Character Strings.
Programming with Mixed Languages Page 19 of 47 option Visual C/C++ value Non-arrays Pointer argument_name Default Arrays Default Struct {type} array_name Visual Basic All types Default ByVal Assembler (x86) MASM All types PTR Default This table does not describe argument passing of strings and Fortran 90 pointer arguments in Visual Fortran, which are constructed differently than other arguments. By default, Fortran passes strings by reference along with the string length.
Programming with Mixed Languages Page 20 of 47 When the C++ code resides in a .cpp file (created when you select C/C++ file from the visual development environment), C++ semantics are applied to external names, often resulting in linker errors. In this case, use the extern "C" syntax (see Visual C/C++ and Visual Basic Naming Conventions): \* C code accessing module data in .
Programming with Mixed Languages Page 21 of 47 USE CPROC CALL PYTHAGORAS (3.0, 4.0, X) TYPE *,X END Using Common External Data in Mixed-Language Programming Common external data structures include Fortran common blocks, and C structures and variables that have been declared global or external. All of these data specifications create external variables, which are variables available to routines outside the routine that defines them.
Programming with Mixed Languages Page 22 of 47 .MODEL directive.
Programming with Mixed Languages Page 23 of 47 #pragma pack(2) struct { int N; char INFO[30]; } examp; #pragma pack() To restore the original packing, you must add #pragma pack( ) at the end of the structure. (Remember: Fortran module data can be shared directly with C structures with appropriate naming.) Once you have dealt with alignment and padding, you can give C access to an entire common block or set of common blocks.
Programming with Mixed Languages Page 24 of 47 In the following example, the C function initcb receives the address of a common block with the first variable named n, which it considers to be a pointer to a structure with three fields: Fortran source code: ! INTERFACE SUBROUTINE initcb (BLOCK) !DEC$ ATTRIBUTES C :: initcb !DEC$ ATTRIBUTES REFERENCE :: BLOCK INTEGER BLOCK END SUBROUTINE END INTERFACE ! INTEGER n REAL(8) x, y COMMON /CBLOCK/n, x, y . . .
Programming with Mixed Languages Page 25 of 47 Fortran data type C data type Visual Basic data type MASM data type INTEGER(1) char --- SBYTE INTEGER(2) short Integer SWORD INTEGER(4) int, long Long SDWORD REAL(4) float Single REAL4 REAL(8) double Double REAL8 CHARACTER(1) unsigned char --- BYTE CHARACTER*(*) See Handling Character Strings COMPLEX(4) struct complex4 { float real, imag; }; --- COMPLEX4 STRUCT 4 real REAL4 0 imag REAL4 0 COMPLEX4 ENDS COMPLEX(8) struct compl
Programming with Mixed Languages Page 26 of 47 two fields, both of which are 4-byte floating-point numbers; the first contains the real-number component, and the second contains the imaginary-number component. The type COMPLEX is equivalent to the type COMPLEX(4). The type COMPLEX(8) is similar except that each field contains an 8-byte floating-point number. Note: Fortran functions of type COMPLEX place a hidden COMPLEX argument at the beginning of the argument list.
Programming with Mixed Languages Page 27 of 47 When a Fortran 90 array pointer or array is passed to another language, either its descriptor or its base address can be passed. The following shows how allocatable arrays and Fortran 90 array pointers are passed with different attributes in effect: If the property of the array pointer or array is none, it is passed by descriptor, regardless of the property of the passing procedure (None; C; STDCALL; C, REFERENCE; or STDCALL, REFERENCE).
Programming with Mixed Languages Page 28 of 47 END SUBROUTINE Ptr_Sub END INTERFACE REAL A(10), VAR(10) POINTER (p, VAR) ! VAR is the pointer-based ! variable, p is the int. p = LOC(A) CALL Ptr_Sub (p) WRITE(*,*) ’A(4) = ’, A(4) END ! //C subprogram void Ptr_Sub (float *p) { p[3] = 23.
Programming with Mixed Languages Page 29 of 47 Iptr_Sub (&a[0]); printf("a[3] = %i\n", a[3]); } On Alpha systems, the alias name for Iptr_Sub should not have a leading underscore, as follows: !DEC$ ATTRIBUTES C, ALIAS:’Iptr_Sub’ :: Iptr_Sub When the main C program and Fortran subroutine are built and executed, the following output appears if the STAT.
Programming with Mixed Languages Page 30 of 47 the array name. You then access each element relative to the first, skipping the total number of bytes of the previous elements. For example: xarray REAL4 1.1, 2.2, 3.3, 4.4 ; initializes ; a four element array with ; each element 4 bytes Referencing xarray in MASM refers to the first element, the element containing 1.1. To refer to the second element, you must refer to the element 4 bytes beyond the first with xarray[4] or xarray+4.
Programming with Mixed Languages Page 31 of 47 Language Array declaration Array reference from Fortran Fortran DIMENSION x(i, k) -ortype x(i, k) x(i, k) Visual Basic DIM x(i, k) As type x( i -1, k -1) Visual C/C++ type x[ k ] [ i ] MASM x( i -1, k -1) Declare and reference arrays as elements in consecutive storage Visual Fortran Array Descriptor Format For cases where Fortran 90 needs to keep track of more than a pointer memory address, the DIGITAL Visual Fortran compiler uses an array descrip
Programming with Mixed Languages Page 32 of 47 The components of the current Visual Fortran array descriptor follow: The first longword (bytes 0 to 3) contains the base address. The base address plus the offset defines the first memory location (start) of the array. The second longword (bytes 4 to 7) contains the size of a single element of the array. The third longword (bytes 8 to 11) contains the offset. The offset is added to the base address to define the start of the array.
Programming with Mixed Languages Page 33 of 47 Handling Character Strings By default, Visual Fortran passes a hidden length argument for strings. The hidden length argument consists of an unsigned 4-byte integer, always passed by value, immediately following the address of the character string. You can alter the default way strings are passed by using attributes. The following table shows the effect of various attributes on passed strings.
Programming with Mixed Languages Page 34 of 47 For string arguments passed by reference with default ATTRIBUTES: n When /iface:mixed_str_len_arg is set, the length of the string is pushed (by value) on the stack immediately after the address of the beginning of the string. n When /iface:nomixed_str_len_arg is set, the length of the string is not available to the called procedure. Since all strings in C are pointers, C expects strings to be passed by reference, without a string length.
Programming with Mixed Languages Page 35 of 47 This interface handles the hidden-length argument, but you must still reconcile C strings that are nullterminated and Fortran strings that are not. In addition, if the data assigned to the Fortran string is less than the declared length, the Fortran string will be blank padded. Rather than trying to handle these string differences in your C routines, the best approach in Fortran/C mixed programming is to adopt C string behavior whenever possible.
Programming with Mixed Languages Page 36 of 47 ! Fortran CODE TYPE LOTTA_DATA SEQUENCE REAL A INTEGER B CHARACTER(30) INFO COMPLEX CX CHARACTER(80) MOREINFO END TYPE LOTTA_DATA TYPE (LOTTA_DATA) D1, D2 COMMON /T_BLOCK/ D1, D2 /* C code accessing D1 and D2 */ extern struct { struct { float a; int b; char info[30]; struct { float real, imag; } cx; char moreinfo[80]; } d1, d2; } T_BLOCK; Visual Fortran/Visual C++ Mixed-Language Programs When you understand and reconcile the calling, naming and argument pass
Programming with Mixed Languages Page 37 of 47 reasons, you may prefer to use the C compiler first or get your project settings for both Fortran and C to agree on the default C library to link against. You need to link your application against one and only one copy of the C library.
Programming with Mixed Languages Menu Item Selected CL Option or Project Type Enabled Page 38 of 47 Default Library Specified in Object File Single-threaded /ML libc.lib Multithreaded /MT libcmt.lib Multithreaded DLL /MD msvcrt.lib (msvcrt.dll) Debug Single-threaded /MLd libcd.lib Debug Multithreaded /MTd libcmtd.lib Debug Multithreaded DLL /MDd msvcrtd.lib (msvcrt.
Programming with Mixed Languages Page 39 of 47 subprograms. The Visual Basic development environment is separate from the Visual Fortran Version 6 development environment. However, the two languages can coexist in the same final application. The usual case is to call Fortran subprograms from Visual Basic. Because Visual Basic subprograms are interpreted and not compiled, they cannot be called directly from compiled language programs like Fortran.
Programming with Mixed Languages Page 40 of 47 you declared it. Optionally, you can specify a directory path to the Fortran DLL in the declaration. The following Visual Basic example declares a Fortran subroutine named FortranCall that takes two single-precision arguments: Declare Sub FortranCall Lib "d:\MyProjects\FCall.
Programming with Mixed Languages Page 41 of 47 integer size in Basic is 2 bytes, equivalent to INTEGER(2) in Fortran. No extra action is required by either language to access integer arguments. Floating point By default, both Visual Basic and Visual Fortran pass single- and double-precision floating point numbers by reference. The size of a single-precision floating point number is 4 bytes in both languages. The size of a double-precision floating point number is 8 bytes in both languages.
Programming with Mixed Languages Page 42 of 47 Visual Basic code: Declare Sub FortString1 Lib "forttest" (ByVal S1 as String, ByVal L1 as Long) Dim S1 as String * 12 Call FortString1(S1, Len(S1)) Visual Fortran code: Subroutine FortString1 (mystring) !DEC$ ATTRIBUTES DLLEXPORT, ALIAS : "FortString1" :: FortString1 CHARACTER*(*) mystring The following example shows shows passing strings where the length of the string will be constant and known by both the Basic and Fortran code, so you do not need to pas
Programming with Mixed Languages Page 43 of 47 Debugging the Fortran DLL Visual Basic Error 53: File not found: yy.dll Visual Basic Error 453: Can’t find DLL entry point xx in yy.dll Debugging the Fortran DLL In Visual Basic, create an executable of your project. Use the pulldown menu item File-Make myproject.exe. Note where the executable was created. In the Visual Fortran development environment: 1. In the Project menu, click Settings 2. Click the Debug tab 3.
Programming with Mixed Languages Page 44 of 47 Make sure the Fortran code has specified an ATTRIBUTES ALIAS name that exactly matches the name declared by the Basic code (see the cDEC$ ALIAS directive, which also can be used as an ATTRIBUTES option ALIAS). Make sure you are referencing the correct yy.dll. For an example of calling a Fortran DLL from Visual Basic, see Examples of Fortran/Visual Basic Programs.
Programming with Mixed Languages Page 45 of 47 r1 = 456.78 Call FortranCall(r1, Num) Text1.Text = Str$(Num) End Sub 6. Select Project..Add Module and click on Open to create a new module. Add the following code to the module: Declare Sub FortranCall Lib"c:\MyProjects\Fcall\Debug\Fcall.dll" (r1 As Single, Num As Single) Replace the filename with the location of the Fortran DLL, if it is different. 7. Run the Basic program by pressing F5. Click on the Do it! button.
Programming with Mixed Languages Page 46 of 47 ... POWER2 ENDP END In the example, the Fortran call to MASM is power2(v,e), which is identical to a Fortran function call. There are two differences between this mixed-language call and a call between two Fortran modules: The subprogram power2(v,e) is implemented in MASM using standard MASM syntax. The PROTO declaration in MASM specifies that the procedure use the STDCALL calling convention.
Programming with Mixed Languages Page 47 of 47 To return REAL and COMPLEX floating-point values, records, arrays, and values larger than 4 bytes and return user-defined types larger than 8 bytes from assembly language to Fortran, you must use a special convention. Fortran creates space in the stack segment to hold the actual return value and passes an extra parameter as the last parameter pushed onto the stack. This extra parameter contains the address of the stack space that contains the return value.
Creating Multithread Applications Page 1 of 14 Creating Multithread Applications Visual Fortran provides support for creating multithread applications. You should consider using more than one thread if your application needs to manage multiple activities, such as simultaneous keyboard input and calculations. One thread can process keyboard input while a second thread performs data transformation calculations. A third thread can update the display screen based on data from the keyboard thread.
Creating Multithread Applications Page 2 of 14 when they should run. Threads of lower priority might need to wait while higher priority threads complete their tasks. On multiprocessor machines, the scheduler can move individual threads to different processors to balance the CPU load. Because threads require less system overhead and are easier to create than an entire process, they are useful for time- or resource-intensive operations that can be performed concurrently with other tasks.
Creating Multithread Applications Page 3 of 14 A module called DFMT.MOD is supplied with Visual Fortran. It contains interface statements to the underlying Win32 API routines as well as parameter and structure definitions used by the routines. You need to include a USE DFMT statement in the declarations section of every Fortran program unit (program, subroutine, function, or module) that uses multithread APIs. The source code for the DFMT module (file name DFMT.
Creating Multithread Applications Page 4 of 14 The second argument, stack, defines the stack size of the new thread. All of an application's default stack space is allocated to the first thread of execution. As a result, you must specify how much memory to allocate for a separate stack for each additional thread your program needs. The CreateThread call allows you to specify the value for the stack size on each thread you create.
Creating Multithread Applications Page 5 of 14 Other Thread Support Functions Scheduling thread priorities is supported through the functions GetThreadPriority and SetThreadPriority. Use the priority class of a thread to differentiate between applications that are time critical and those that have normal or below normal scheduling requirements. If you need to manipulate priorities, be very careful not to give a thread too high a priority, or it can consume all of the available CPU time.
Creating Multithread Applications Page 6 of 14 Sharing Resources Each thread has its own stack and its own copy of the CPU registers. Other resources, such as files, units, static data, and heap memory, are shared by all threads in the process. Threads using these common resources must coordinate their work. There are several ways to synchronize resources: Critical section--A block of code that accesses a non-shareable resource.
Creating Multithread Applications Page 7 of 14 OpenMutex does not change a mutex object to a signaled state; this is accomplished by one of the wait routines described in Synchronizing Threads. ReleaseMutex changes a mutex from the not-signaled state to the signaled state. This function only has an effect if the thread calling it also owns the mutex. When the mutex is in a signaled state, any thread waiting for it can acquire it and begin executing.
Creating Multithread Applications Page 8 of 14 Variables declared as automatic are placed on the stack, which is part of the thread context saved with the thread. Automatic variables within procedures are discarded when the procedure completes execution. I/O Operations Although files and units are shared between threads, you may not need to coordinate the use of these shared resources by threads. Fortran treats each input/output statement as an atomic operation.
Creating Multithread Applications Page 9 of 14 completes. WaitForMultipleObjects is similar, except that its second parameter is an array of Windows object handles. Specify the number of handles to wait for in the first parameter. This can be less than the total number of threads created, and its maximum is 64. The function can either wait until all events have completed, or resume as soon as any one of the objects completes. Deadlocks occur when a thread waits for objects that never become available.
Creating Multithread Applications Page 10 of 14 for a new process must be loaded. All threads of a process share the same address space and can access the process’s global variables, which can simplify communications between threads. All threads of a process can use open handles to resources such as files and pipes. If you want to create an independent process that runs concurrently with the current one, use CreateProcess.
Creating Multithread Applications Page 11 of 14 CreateThread Creates a thread to execute within the address space of the calling process. DeleteCriticalSection Releases all resources used by an unowned critical section object. DuplicateHandle Duplicates an object handle. EnterCriticalSection Waits for ownership of the specified critical section object. ExitProcess Ends a process and all its threads. ExitThread Ends a thread. GetCurrentProcess Returns a pseudohandle for the current process.
Creating Multithread Applications Page 12 of 14 ResumeThread Decrements a thread’s suspend count. When the suspend count is zero, execution of the thread resumes. SetEvent Sets the state of the specified event object to signaled. SetLastError Sets the last-error code for the calling thread. SetPriorityClass Sets the priority class for the specified process. SetThreadPriority Sets the priority value for the specified thread. SuspendThread Suspends the specified thread.
Creating Multithread Applications Page 13 of 14 Build menu. Listed following are the steps for compiling and linking your own multithread program using the visual development environment. To compile and link your multithread program: 1. Create a new project. Choose the Project tab, then specify the Project type. (The sample THREADS.F90 is a QuickWin project.) 2. Add the file containing the source code to the project. 3. From the Project menu, select Settings. The Project Settings dialog box appears. 4.
Creating Multithread Applications Page 14 of 14 ramifications of adding multiple threads to the user interface. This article not only offers alternatives to multiple threads, but also covers window management and message loops for multithreading. n "Multithreading for Rookies," by Ruediger R. Asche, focuses on practical applications of multithreading. n "Detecting Deadlocks in Multithreaded Win32 Applications," by Ruediger R. Asche, presents deadlock detection techniques.
Data Representation Page 1 of 9 Data Representation DIGITAL Fortran expects numeric data to be in native little endian order, in which the leastsignificant, right-most zero bit (bit 0) or byte has a lower address than the most-significant, left-most bit (or byte). For information on using nonnative big endian and DIGITAL VAX floating-point formats, see Converting Unformatted Numeric Data.
Data Representation Page 2 of 9 DOUBLE PRECISION T_floating format ranging from 2.2250738585072013D308 to 1.7976931348623158D308. Values between 2.2250738585072008D-308 and 4.94065645841246544D-324 are denormalized (subnormal). COMPLEX (KIND=4) (COMPLEX) 8 bytes (64 bits) Single-precision complex floating-point values in a pair of IEEE S_floating format parts: real and imaginary. The real and imaginary parts range from 1.17549435E-38 to 3.40282347E38. Values between 1.17549429E-38 and 1.
Data Representation Page 3 of 9 The following sections discuss the intrinsic data types in more detail: Integer Data Representations Logical Data Representations Native IEEE Floating-Point Representations Character Representation Hollerith Representation Integer Data Representations On x86 systems, integer data lengths can be 1-, 2-, or 4-bytes in length. On Alpha systems, integer data lengths can be 1-, 2- 4-, or 8-bytes in length.
Data Representation Page 4 of 9 INTEGER(KIND=2) values range from -32,768 to 32,767 and are stored in 2 contiguous bytes, as shown below: Figure: INTEGER(KIND=2) Data Representation Integers are stored in a two’s complement representation. For example: +22 = 0016(hex) -7 = FFF9(hex) INTEGER(KIND=4) Representation INTEGER(KIND=4) values range from -2,147,483,648 to 2,147,483,647 and are stored in 4 contiguous bytes, as shown below.
Data Representation Page 5 of 9 On Alpha systems, logical data lengths can be 1-, 2-, 4-, or 8-bytes in length. The default data size used for a LOGICAL data declaration is LOGICAL(KIND=4), unless the /integer_size:16 or /integer_size:64 (Alpha systems) option was specified. To improve performance on Alpha systems, use LOGICAL(KIND=4) (or LOGICAL(KIND=8)) rather than LOGICAL(KIND=2) or LOGICAL(KIND=1). LOGICAL(KIND=1) values are stored in 1 byte. In addition to having logical values .TRUE. and .FALSE.
Data Representation Page 6 of 9 normalization"). This bit is assumed to be 1 unless the exponent is 0. If the exponent equals 0, then the value represented is denormalized (subnormal) or plus or minus zero.
Data Representation Page 7 of 9 The form of REAL(KIND=8) data is sign magnitude, with bit 63 the sign bit (0 for positive numbers, 1 for negative numbers), bits 62:52 a binary exponent in excess 1023 notation, and bits 51:0 a normalized 53-bit fraction including the redundant most-significant fraction bit not represented. The value of data is in the approximate range: 2.2250738585072013D-308 (normalized) to 1.7976931348623158D308. The IEEE denormalized (subnormal) limit is 4.94065645841246544D324.
Data Representation Page 8 of 9 Character Representation A character string is a contiguous sequence of bytes in memory, as shown below. Figure: CHARACTER Data Representation A character string is specified by two attributes: the address A of the first byte of the string, and the length L of the string in bytes. The length L of a string is in the range 1 through 65,535. Hollerith Representation Hollerith constants are stored internally, one character per byte, as shown below.
Data Representation Page 9 of 9
Handling Run-Time Errors Page 1 of 29 Handling Run-Time Errors This section contains information on the following topics: Default Run-Time Error Processing, which describes the message format and values returned at program termination. Methods of Handling Errors, which describes using the END, EOR, and ERR I/O statement branch specifiers and the IOSTAT specifier. Locating Run-Time Errors, which describes suggested compiler options and information about debugging exceptions.
Handling Run-Time Errors Page 2 of 29 error. How arithmetic exception conditions are reported and handled depends on the cause of the exception and how the program was compiled. Unless the program was compiled to handle exceptions, the exception might not be reported until after the instruction that caused the exception condition.
Handling Run-Time Errors Page 3 of 29 This is the message number, also the IOSTAT value for I/O statements. message-text Explains the event that caused the message. The following table explains the severity levels of run-time messages, in the order of greatest to least severity. Severity Levels of Run-Time Messages Severity Description severe Must be corrected.
Handling Run-Time Errors Page 4 of 29 Whenever possible, the Visual Fortran RTL does certain error handling, such as generating appropriate messages and taking necessary action to recover from errors. You can explicitly supplement or override default actions by using the following methods: To transfer control to error-handling code within the program, use the END, EOR, and ERR branch specifiers in I/O statements, see Using the END, EOR, and ERR Branch Specifiers.
Handling Run-Time Errors Page 5 of 29 When using nonadvancing I/O, use the EOR specifier to handle the end-of-record condition. For example: 150 FORMAT (F10.2, F10.2, I6) READ (UNIT=20, FMT=150, SIZE=X, ADVANCE=’NO’, EOR=700) A, F, I You can also use ERR as a specifier in an OPEN, CLOSE, or INQUIRE statement. For example: OPEN (UNIT=10, FILE=’FILNAM’, STATUS=’OLD’, ERR=999) If an error is detected during execution of this OPEN statement, control transfers to the statement at label 999.
Handling Run-Time Errors Page 6 of 29 CHARACTER(LEN=40) :: FILNM INCLUDE ’iosdef.for’ DO I=1,4 FILNM = ’’ WRITE (6,*) ’Type file name ’ READ (5,*) FILNM OPEN (UNIT=1, FILE=FILNM, STATUS=’OLD’, IOSTAT=IERR, ERR=100) WRITE (6,*) ’Opening file: ’, FILNM (process the input file) CLOSE (UNIT=1) STOP ! 100 IF (IERR .EQ. FOR$IOS_FILNOTFOU) THEN WRITE (6,*) ’File: ’, FILNM, ’ does not exist ’ ELSE IF (IERR .EQ.
Handling Run-Time Errors Page 7 of 29 source listing are usually needed to locate the cause of the error. Certain traceback-related information accompanies severe run-time errors, as described in Using Traceback Information. The /fpe option controls the handling of floating-point arithmetic exceptions (IEEE arithmetic) at run-time. In the visual development environment, specify the Floating-Point Exception Handling in the Floating Point Compiler Option Category.
Handling Run-Time Errors DFORRT.dll DFORRT.dll DFORRT.dll teof.exe teof.exe teof.exe teof.exe teof.exe teof.exe teof.exe KERNEL32.dll 10009324 10009596 10024193 004011A9 004010DD 004010A7 00401071 00401035 004013D9 004012DF 77F1B304 Page 8 of 29 Unknown Unknown Unknown AGAIN GO WE HERE TEOF Unknown Unknown Unknown Unknown Unknown Unknown 21 15 11 7 3 Unknown Unknown Unknown Unknown Unknown Unknown teof.for teof.for teof.for teof.for teof.
Handling Run-Time Errors 1. 2. 3. 4. 5. 6. 7. Page 9 of 29 Choose Settings from the Project menu Click the Fortran tab Select the Listing Files category Click (check) "Source Listing" Click "Machine Code" Click "Include Files" Make any other changes needed to the Project Settings, then click OK. When compiling from the command line, specify /show:all and /list: DF file.f90 /list /show:all To generate a link map (.map) file: When using the visual development environment: 1. 2. 3. 4. 5.
Handling Run-Time Errors Page 10 of 29 FOR_DIAGNOSTIC_LOG_FILE If set to the name of a file, writes diagnostic output to the specified file. The Fortran run-time system attempts to open that file (append output) and write the error information (ASCII text) to the file. The setting of FOR_DIAGNOSTIC_LOG_FILE is independent of FOR_DISABLE_DIAGNOSTIC_DISPLAY, so you can disable the screen display of information but still capture the error information in a file.
Handling Run-Time Errors Page 11 of 29 Using the /traceback option to get automatic PC correlation does increase the size of an image. For any application, the developer must decide if the increase in image size is worth the benefit of automatic PC correlation or if manually correlating PC’s with a map file is acceptable.
Handling Run-Time Errors Page 12 of 29 Stack trace terminated abnormally Be forewarned, however, it is also possible for memory to be corrupted in such a way that a stack trace can seem to complete successfully with no hint of a problem. The bit patterns it finds in corrupted memory where the stack used to be, and then uses to access memory, may constitute perfectly valid memory addresses for the program to be accessing. They just do not happen to have any connection to what the stack used to look like.
Handling Run-Time Errors Page 13 of 29 end integer*4 function again( ) integer*4 a open(10,file=’xxx.dat’,form=’unformatted’,status=’unknown’) read(10) a again=a end The diagnostic output that results when this program is built with traceback enabled and linked against the dynamic Fortran run-time library on the x86 platform: forrtl: severe (24): end-of-file during read, unit 10, file E:\USERS\xxx.dat Image PC Routine Line Source DFORRT.dll 1000A3B2 Unknown Unknown Unknown DFORRT.
Handling Run-Time Errors forrtl: severe Image teof.exe teof.exe teof.exe teof.exe teof.exe teof.exe teof.exe teof.exe teof.exe teof.exe teof.exe teof.exe KERNEL32.dll Page 14 of 29 (24): end-of-file during read, unit 10, file E:\USERS\xxx.dat PC Routine Line Source 004067D2 Unknown Unknown Unknown 0040659F Unknown Unknown Unknown 00405754 Unknown Unknown Unknown 004059C5 Unknown Unknown Unknown 00403543 Unknown Unknown Unknown 004011A9 AGAIN 21 teof.for 004010DD GO 15 teof.for 004010A7 WE 11 teof.
Handling Run-Time Errors 0001:00000000 0001:00000000 0001:00000000 0001:0000003d 0001:0000003d 0001:0000006d 0001:0000006d 0001:0000009d 0001:0000009d 0001:000000cd 0001:000000cd 0001:00000180 ... Page 15 of 29 _TEOF _TEOF@0 _MAIN__ _HERE _HERE@0 _WE@0 _WE _GO _GO@0 _AGAIN _AGAIN@0 _for_rtl_init_ 00401000 00401000 00401000 0040103d 0040103d 0040106d 0040106d 0040109d 0040109d 004010cd 004010cd 00401180 f f f f f f f f f f f f teof.obj teof.obj teof.obj teof.obj teof.obj teof.obj teof.obj teof.
Handling Run-Time Errors Page 16 of 29 For this simple example, the traceback correlation information added 512 bytes to the image size. In a real application, this would probably be much larger. For any application, the developer must decide if the increase in image size is worth the benefit of automatic PC correlation or if manually correlating PC’s with a map file is acceptable.
Handling Run-Time Errors Page 17 of 29 When this program is compiled with /traceback and /optimization:0 on an Alpha system, the traceback output appears as follows: forrtl: error (72): floating overflow Image PC Routine ovf.exe 0040210C BELOW ovf.exe 004020DC OUT ovf.exe 004020B4 WATCH ovf.exe 0040208C HEY ovf.exe 00402040 OVF ovf.exe 00402428 Unknown ovf.exe 0040226C Unknown KERNEL32.dll 77E8F2AC Unknown Line 26 21 16 11 5 Unknown Unknown Unknown Source ovf.for ovf.for ovf.for ovf.for ovf.
Handling Run-Time Errors 58011040 58011040 58011040 FC1FFFF9 A75E0000 47E03400 23DE0010 6BFA8001 2FFE0000 2FFE0000 2FFE0000 Page 18 of 29 0034 0038 003C 0040 0044 0048 004C 0050 0054 0058 005C muls muls muls bgt ldq mov lda ret unop unop unop .end f0, f1, f0 f0, f1, f0 f0, f1, A .T2_, L$1 ra, (sp) 1, v0 sp, 16(sp) (ra) MAIN__ ... The main program, OVF, no longer calls routine HEY. While the output is not quite what one might have expected intuitively, it is still entirely correct.
Handling Run-Time Errors FltF12: FltF14: FltF16: FltF18: FltF20: FltF22: FltF24: FltF26: FltF28: FltF30: ...
Handling Run-Time Errors Page 20 of 29 exception occurred. The following lines describe the call stack. On Alpha, the math library is bundled in as part of the Fortran run-time library so math library routines, in this example, will be reported as part of image DFORRT.DLL. Whenever the math library needs to report an exceptional condition, it calls the WIN32 routine RaiseException( ) to do so. RaiseException( ) is in KERNEL32.DLL but actually uses code in NTDLL.DLL to execute the call.
Handling Run-Time Errors Page 21 of 29 map file for the application, we can see that the reported PC, 00401161, is greater than the start of routine _Unlucky, but less than the start of routine _down1_C, so we at least know the error occurred in routine _Unlucky.
Handling Run-Time Errors Page 22 of 29 been called. At the higher optimization level, the compiler has inlined function DOWN1 so that the call to routine down1_C is now made from FPING. The correlated line number still points to the correct line in the source code. You can see that DOWN1 was inlined by looking in the listing file, FPING.LST: 55 EC8B 04EC83 53 000000E8 00 04EC83 0008058D 0002 50 000000E8 00 0004058D 0002 50 000000E8 00 000035FF 0000 000035FF 0000 0000 0000 0001 0003 0006 0007 .
Handling Run-Time Errors fpingmain.exe fpingmain.exe fpingmain.exe fpingmain.exe KERNEL32.dll 00401073 0040104B 004013C9 004012BF 77F1B304 Page 23 of 29 DOWN1 FPING Unknown Unknown Unknown 11 5 Unknown Unknown Unknown fping1.for fpingmain.for Unknown Unknown Unknown Notice that the line number and source file correlation information has changed to reflect the new design of the code. Here are the sources used in the above examples: ************************************ FPING.
Handling Run-Time Errors real*4 b [VALUE] !DEC$ IF DEFINED(_X86_) INTERFACE TO SUBROUTINE Unlucky [C,ALIAS:’_Unlucky’] (a,c) !DEC$ ELSE INTERFACE TO SUBROUTINE Unlucky [C,ALIAS:’Unlucky’] (a,c) !DEC$ ENDIF REAL*4 a [VALUE] REAL*4 c [REFERENCE] END real*4 a call Unlucky(b,a) down4 = a end ************************************ CPONG.C ************************************ #include
Handling Run-Time Errors a=-10.0 b=down1(a) end ************************************ FPING1.FOR ************************************ real*4 function down1(b) real*4 b !DEC$ IF DEFINED(_X86_) INTERFACE TO REAL*4 FUNCTION down1_C [C,ALIAS:’_down1_C’] (n) !DEC$ ELSE INTERFACE TO REAL*4 FUNCTION down1_C [C,ALIAS:’down1_C’] (n) !DEC$ ENDIF REAL*4 n [VALUE] END real*4 down1_C down1 = down1_C(b) end ************************************ FPING2.
Handling Run-Time Errors Page 26 of 29 !DEC$ ELSE INTERFACE TO SUBROUTINE Unlucky [C,ALIAS:’Unlucky’] (a,c) !DEC$ ENDIF REAL*4 a [VALUE] REAL*4 c [REFERENCE] END real*4 a call Unlucky(b,a) down4 = a end Run-Time Environment Variables The Visual Fortran run-time system recognizes the following environment variables: Environment Variable Description FOR_ACCEPT The ACCEPT statement does not include an explicit logical unit number.
Handling Run-Time Errors Page 27 of 29 FOR_ENABLE_VERBOSE_STACK_TRACE If set to true, displays more detailed call stack information in the event of an error. For information on using stack trace information, see Using Traceback Information. FOR_FULL_SRC_FILE_SPEC By default, the traceback output displays only the file name and extension in the source file field. To display complete file name information including the path, set the environment variable FOR_FULL_SRC_FILE_SPEC to true.
Handling Run-Time Errors Page 28 of 29 unit number does not include an explicit logical unit number. Instead, it uses an implicit internal logical unit number and the FOR_READ environment variable. If FOR_READ is not defined, the code READ (*,f) iolist or READ f,iolist reads from CONIN$ (standard input). If FOR_READ is defined (as a filename optionally containing a path), the specified file would be read.
Handling Run-Time Errors Page 29 of 29 From within your program, you can set the appropriate environment variable by calling the SETENVQQ routine: program ENVVAR use dflib integer*4 res ! Add other data declarations here ! call SETENVQQ as a function res=SETENVQQ("FOR_GENERATE_DEBUG_EXCEPTION=T") ... For a list of environment variables used with the DF command, see Environment Variables Used with the DF Command.
The Floating-Point Environment Page 1 of 19 The Floating-Point Environment This section describes the Visual Fortran numeric environment using IEEE® arithmetic for x86 and Alpha systems.
The Floating-Point Environment Page 2 of 19 not using floating-point numbers in LOGICAL comparisons or by giving them a tolerance (for example, IF (x <= 10.001)), and by not attempting to combine or compare numbers that differ by more than the number of significant bits. (For more information on programming methods to reduce the effects of imprecision, see Rounding Errors.
The Floating-Point Environment Page 3 of 19 (0 or 1). The precision P is the number of bits in the nonexponential part of the number (the significand), and E is the exponent. With these parameters, binary floating-point numbers approximate real numbers with the values: ( - 1)s b0 . b 1 b2 ...
The Floating-Point Environment Page 4 of 19 BitViewer utility. This tool is accessed from the command line with the command BITVIEW. By default Visual Fortran installs the BitViewer utility in the folder ...\DF98\BIN. The following figure shows the logical layout of the single and double formats. The figure shows the contents of each field, its width, and the location of the most significant bit (MSB) and the least significant bit (LSB).
The Floating-Point Environment Page 5 of 19 Note: BitViewer lets you view and manipulate integer and character data as well as floatingpoint, and to translate between different data types. Refer to the BitViewer Help file for more information. Special Values Special cases of the exponent-significand combination represent four types of special values in addition to the normalized numbers. The following table shows all five types of values.
The Floating-Point Environment Page 6 of 19 Denormalized numbers Denormalized numbers (denormals) fill the gap between the smallest positive number and the smallest negative number. Otherwise only (±) 0 occurs in that interval. Denormalized numbers permit gradual underflow for intermediate results calculated internally in extended-double format. A status flag (on x86 systems, the precision bit in the FPU Status Word exception field) is set when a number loses precision due to denormalization.
The Floating-Point Environment Page 7 of 19 representation of x result: INTEGER(4) FRACTION FRACTION(x). Returns the fractional part (significand) of the representation of x x: Real result: same type as x HUGE HUGE(x). Returns largest number that can be represented by data of type x x: Integer or Real result: same type as x MAXEXPONENT MAXEXPONENT(x). Returns the largest positive decimal exponent for data of the same type as x x: Real result: INTEGER(4) MINEXPONENT MINEXPONENT(x).
The Floating-Point Environment Page 8 of 19 number and its nearest floating-point representation. The floating-point number representing a rounded real number is called inexact. Normally, calculations proceed when an inexact value results. Almost any floating-point operation can produce an inexact result. The rounding mode (round up, round down, round nearest, truncate) is determined by the floating-point control word.
The Floating-Point Environment Page 9 of 19 /nofltconsistency compiler options on x86 systems. Rounding error accumulates in x because the floating-point representation of 0.2 is inexact, then accumulates in s, and affects the final value for n: INTEGER n REAL s, x n = 0 s = 0. x = 0. 1 n = n + 1 x = x + 0.2 s = s + x IF ( x .LE. 10.
The Floating-Point Environment Page 10 of 19 ULPs, Relative Error, and Machine Epsilon /rounding_mode (Alpha only) ULPs, Relative Error, and Machine Epsilon Several terms describe the magnitude of rounding error. A floating-point approximation to a real constant or to a computed result may err by as much as 1/2 unit in the last place (the bP-1 bit). The abbreviation ULP represents the measure "unit in the last place.
The Floating-Point Environment name Meaning FPSW Floating-point status word Page 11 of 19 FPCW Floating-point control word SIG Signal FPE Floating-point exception MTH Math function The suffix option is one of the options available for that name.
The Floating-Point Environment Page 12 of 19 FPSW$ZERODIVIDE #0004 A divide by zero occurred FPSW$OVERFLOW #0008 An overflow occurred FPSW$UNDERFLOW #0010 An underflow occurred FPSW$INEXACT Inexact precision occurred #0020 You can find out which exceptions have occurred by retrieving the status word and comparing it to the exception parameters. For example: USE DFLIB INTEGER(2) status CALL GETSTATUSFPQQ(status) IF ((status .AND.
The Floating-Point Environment Page 13 of 19 FPCW$DOWN #0400 Round down FPCW$NEAR #0000 Round to nearest FPCW$MCW_EM #003F Exception mask FPCW$INVALID #0001 Allow invalid numbers FPCW$DENORMAL #0002 Allow denormals (very small numbers) FPCW$ZERODIVIDE #0004 Allow divide by zero FPCW$OVERFLOW #0008 Allow overflow FPCW$UNDERFLOW #0010 Allow underflow FPCW$INEXACT Allow inexact precision #0020 The control word defaults are: 53-bit precision Round to nearest (rounding mode) The
The Floating-Point Environment Page 14 of 19 CALL GETCONTROLFPQQ(control) newcontrol = (control .OR. FPCW$INVALID) ! Invalid exception set (disabled). CALL SETCONTROLFPQQ(newcontrol) Precision Parameters On x86 systems, the precision bits control the precision to which the FPU rounds floating-point numbers. For example: USE DFLIB INTEGER(2) control, holdcontrol, newcontrol CALL GETCONTROLFPQQ(control) ! Clear any existing precision flags. holdcontrol = (control .AND. (.NOT.
The Floating-Point Environment Page 15 of 19 Handling Run-Time Math Exceptions (x86 only) Handling Floating-Point Exceptions If a floating-point exception is disabled (set to 1), it will not generate an interrupt signal if it occurs. The floating-point process will return an appropriate special value (for example, NaN or signed infinity), and the program will continue. If a floating-point exception is enabled (set to 0), it will generate an interrupt signal (software interrupt) if it occurs.
The Floating-Point Environment Page 16 of 19 exception. An example of an exception-handling routine follows. The exception-handling routine hand_fpe and the program that invokes it are both contained in SIGTEST.F90 in the Visual Fortran Samples folder ...\DF98\SAMPLES\TUTORIAL . The comments at the beginning of the SIGTEST.F90 file describe how to compile this example. ! SIGTEST.F90 !Establish the name of the exception handler as the ! function to be invoked if an exception happens.
The Floating-Point Environment Page 17 of 19 exceptions result in a standard run-time error (such as forrtl: severe (nnnn): sqrt: domain error). If you want to alter the behavior of one or more math exceptions, you need to provide your own version of MATHERRQQ. You have more flexibility in the way you handle run-time math exceptions than floating-point exceptions, because your error handling routine can return to the program unit that caused the exception. The module DFLIB.F90 in the ...
The Floating-Point Environment Page 18 of 19 END The following is a Visual Fortran Sample program (MATHTEST.F90 in the .../DF98/SAMPLES/TUTORIAL folder) that causes MATHERQQ to be called: REAL(4) r1, r2 /-1.0/ REAL(8) r3, r4 /-1.0/ COMPLEX(4) c1, c2 /(0.0, 0.
The Floating-Point Environment Page 19 of 19 for floating-point operations. Refer to your operating system documentation for more information. If the operating system has been configured for software emulation, then all floating-point operations in Visual Fortran will always operate correctly, including the above program.
Converting Unformatted Numeric Data Page 1 of 8 Converting Unformatted Numeric Data This section describes how you can use DIGITAL Visual Fortran to read and write nonnative unformatted numeric data, including DIGITAL Fortran for OpenVMS systems numeric data.
Converting Unformatted Numeric Data Page 2 of 8 Little and Big Endian Storage of an INTEGER Value Moving unformatted data files between big endian and little endian computers requires that the data be converted. Visual Fortran provides the capability for programs to read and write unformatted data (originally written using unformatted I/O statements) in several nonnative floating-point formats and in big endian INTEGER or floating-point format.
Converting Unformatted Numeric Data Page 3 of 8 FDX Little endian integer data of the appropriate size (one, two, four, or on Alpha systems, eight bytes) and DIGITAL VAX floating-point data of format F_floating for REAL(KIND=4) or COMPLEX(KIND=4), and D_Floating for REAL(KIND=8) or COMPLEX(KIND=8).
Converting Unformatted Numeric Data Page 4 of 8 (such as an array) instead of their respective variables, the fields will not be converted. When they are later examined as separate fields by the program, they will remain in the binary format they were stored in on disk, unless the program is modified.
Converting Unformatted Numeric Data Page 5 of 8 Environment Variable FORT_CONVERTn Method You can use this method to specify multiple formats in a single program, usually one format for each specified unit number. You specify the numeric format at run time by setting the appropriate environment variable before an implicit or explicit OPEN to that unit number.
Converting Unformatted Numeric Data Page 6 of 8 This method takes precedence over the OPTIONS statement and the compiler option /convert:keyword method, but has a lower precedence than the environment variable method.
Converting Unformatted Numeric Data Page 7 of 8 Compiler Option /convert Method You can only specify one numeric format for all unformatted file unit numbers using the compiler option /convert method unless you also use one (or both) of the previous methods. You specify the numeric format at compile time and must compile all routines under the same /convert:keyword compiler option, which is listed under the Compatability category in the visual development environment, Fortran tab.
Converting Unformatted Numeric Data Page 8 of 8 default record type (RECORDTYPE) with DIGITAL Fortran depends on the values for the ACCESS and FORM specifiers for the OPEN statement (also described in the DIGITAL Fortran Language Reference Manual). Certain vendors use a different identifier for the logical data types, such as hex FF instead of 01 to denote "true." Source code being ported may be coded specifically for big endian use.
Hexadecimal-Binary-Octal-Decimal Conversions Page 1 of 1 +H[DGHFLPDO %LQDU\ 2FWDO 'HFLPDO &RQYHUVLRQV 7KH IROORZLQJ WDEOH OLVWV KH[DGHFLPDO ELQDU\ RFWDO DQG GHFLPDO FRQYHUVLRQ +H[DGHFLPDO %LQDU\ 2FWDO DQG 'HFLPDO &RQYHUVLRQ +H[ 1XPEHU %LQDU\ 1XPEHU 2FWDO 1XPEHU 'HFLPDO 1XPEHU $ % & '
Using the IMSL Mathematical and Statistical Libraries Page 1 of 6 Using the IMSL Mathematical and Statistical Libraries The Professional Edition of Visual Fortran includes the IMSLTM libraries, a collection of nearly 1000 mathematical and statistical functions easily accessible from the Microsoft visual development environment. The IMSL libraries are installed with the Visual Fortran Professional Edition, as described in Using Setup to Install Visual Fortran and Related Software in Getting Started.
Using the IMSL Mathematical and Statistical Libraries Page 2 of 6 c. In the drop-down list for Show Directories, select Library files and view the library paths. d. In the drop-down list for Show Directories, select Include files and view the include file paths. e. Click OK if you have changed any information. 2. You may need to explicitly pass IMSL libraries to the Linker. In most cases, these are passed automatically by using the OBJCOMMENT LIB directive.
Using the IMSL Mathematical and Statistical Libraries Page 3 of 6 For more information about calling the Fortran 90 MP routines, see the IMSL Libraries online help file. The free-form Fortran 90 example program below invokes the function AMACH and the subroutine UMACH from the IMSL Libraries. The AMACH function retrieves real machine constants that define the computer’s real arithmetic. A value for positive machine infinity is returned (Infinity). The subprogram UMACH retrieves the output unit number.
Using the IMSL Mathematical and Statistical Libraries SF90MP Page 4 of 6 Fortran 90 MP library, a new generation of Fortran 90-based algorithms, optimized for multiprocessor and other high-performance systems. The IMSL FORTRAN 77 Numerical Libraries are for applications in general applied mathematics and for analyzing and presenting statistical data in scientific and business applications. For command-line window development, excuting the DFVARS.
Using the IMSL Mathematical and Statistical Libraries x = amach(0) CLOSE(9) END ! Illegal parameter error The standard output from IMSL routine VHSTP written to STD.TXT is: 1 Histogram Plot Frequency------------------------9 * I * 8 * I * 7 * I * 6 * I I * 5 * I I I I * 4 * I I I I I * 3 * I I I I I I I * 2 * I I I I I I I I * 1 * I I I I I I I I I I * ---------------------------------Class 5 10 The error output from IMSL routine AMACH written to ERR.TXT is: *** TERMINAL ERROR 5 from AMACH.
Using the IMSL Mathematical and Statistical Libraries Page 6 of 6 _exit(0); } This C language example demonstrates the use of: The _stdcall modifier in the function prototype needed when calling the IMSL libraries. The & address operator passes the address of the variable to the subprogram (IMSL libraries expect arguments passed by reference). The C example can be compiled by the cl command to create an object file that can be linked using the DF command.
Compatibility Information Page 1 of 6 Compatibility Information Visual Fortran uses the same DIGITAL Fortran compiler available on DIGITAL UNIX® and OpenVMSTM Alpha systems. DIGITAL Visual Fortran supports extensions to the ISO and ANSI standards, including a number of extensions defined by: Microsoft® Fortran PowerStation 4.
Compatibility Information Page 2 of 6 Integer Pointers (Cray pointers) VAX Structures = F90 sequence derived types Mixing logicals and numerics - logicals used with arithmetic operators and variables Argument matching for procedure calls Mixing integer kinds to intrinsics Byte data type = INTEGER*1 $ATTRIBUTES [ ] Form $ATTRIBUTES ALIAS - external name for a subprogram $ATTRIBUTES C, STDCALL - calling and naming conven
Compatibility Information Page 3 of 6 CRAY pointer support for procedure names (for COM/OLE support) $ATTRIBUTES ALLOCATABLE - allocatable array Mixing subroutines/functions in generic interfaces $MESSAGE - output message during compilation Listing directives - $TITLE, $SUBTITLE STATIC attribute-static storage class EOF checks for end of file LOC equivalent to %LOC HFIX converts to short integer INT1 converts to one byte integer by truncating INT2 converts to t
Compatibility Information Page 4 of 6 In addition to DIGITAL Visual Fortran systems, DIGITAL Fortran platforms include: DIGITAL Fortran 90 and DIGITAL Fortran 77 on DIGITAL UNIX (formerly DEC OSF/1®) Alpha systems DIGITAL Fortran 90 and DIGITAL Fortran 77 on OpenVMS Alpha systems DIGITAL Fortran 77 on OpenVMS VAXTM systems Major additions to the FORTRAN 77 standard introduced by the Fortran 90 standard include: Array operations Improved facilities for numeric computation Parameterized intrinsi
Compatibility Information n n n n Page 5 of 6 LOGICAL*4 REAL*4 REAL*8 COMPLEX*8 Support for 64-bit signed integers using INTEGER*8 and LOGICAL*8 (on Alpha platforms only) A set of data types: n BYTE n LOGICAL*1, LOGICAL*2, LOGICAL*4 n INTEGER*1, INTEGER*2, INTEGER*4 n LOGICAL*8 and INTEGER*8 on Alpha platforms only n REAL*4, REAL*8 n COMPLEX*8, COMPLEX*16, DOUBLE COMPLEX n DIGITAL Fortran POINTER statement (CRAY style) Data statement style initialization in
Compatibility Information Page 6 of 6 found n Choosing whether executing code will be thread-reentrant Kind types for all of the hardware-supported data types: n For 1-, 2-, and 4-byte LOGICAL data: LOGICAL (KIND=1), LOGICAL (KIND=2), n n n n LOGICAL (KIND=4) For 1-, 2-, and 4-byte INTEGER data: INTEGER (KIND=1), INTEGER (KIND=2), INTEGER (KIND=4) For 8-byte LOGICAL and INTEGER data on Alpha platforms only: LOGICAL (KIND=8), INTEGER (KIND=8) For 4- and 8-byte REAL data: REAL (KIND=4), REAL (KIND=8) For
Using Visual Fortran Tools Page 1 of 69 Using Visual Fortran Tools This section summarizes the available Visual Fortran tools and describes how to use tools from the Console command line: Overview of Visual Fortran Tools Using Tools From the Command Line Setting Up the Command Console Fortran Compiler and Linker MS-DOS Editor Building Projects with NMAKE Resource Compiler Options Managing Libraries with LIB Editing Files with EDITBIN Examining Files with DUMPBIN Editing Format
Using Visual Fortran Tools Source Browser (BSCMAKE) Page 2 of 69 Creates an information file with details about the symbols in your program. The browse window displays this information and lets you move among instances of the symbols in your source code. For more information, see Source Browser Information for a Configuration. Additional Tools1 Linker (LINK) Lets you link object files and libraries, creating 32-bit executable images or DLLs.
Using Visual Fortran Tools Page 3 of 69 PView (PVIEW) Lets you examine and modify processes and threads running on your system. For more information, see "Windows Utilities" in the Visual C++ User’s Guide. Resource Compiler (RC) Compiles various resources so they can be included in an image. For more information, see Resource Compiler Command Line. Running Object Table Viewer (IROTVIEW) Lets you view the contents of the OLE Running Object Table.
Using Visual Fortran Tools Page 4 of 69 Configure any COM class (including JavaTM-based classes) on your system. This includes Distributed COM activation and security settings. Configure system-wide COM settings, including enabling or disabling Distributed COM. Test any COM class by double-clicking its name. The list of interfaces that class supports will be displayed. Double-clicking an interface entry allows you to invoke a viewer that will "exercise" that interface.
Using Visual Fortran Tools n n n n n n n n n n n Page 5 of 69 Setting Up the Command Console Fortran Compiler and Linker MS-DOS Editor Building Projects with NMAKE Resource Compiler Options Managing Libraries with LIB Editing Files with EDITBIN Examining Files with DUMPBIN Editing Format Descriptors with the Format Editor Profiling Code from the Command Line Fortran Tools: FSPLIT and FPR For a summary of all Visual Fortran tools, see Overview of Visual Fortran Tools.
Using Visual Fortran Tools Page 6 of 69 The size of the command console text buffer and the position of the command console window if it is presented in a window. The colors used to display text in the command console. The size of the command history buffer used to store commands that scroll out of view. The amount of each type of memory that is available to programs running in the command console. Special configuration files to be run when the console session begins.
Using Visual Fortran Tools Page 7 of 69 having the same names as those needed by Visual Fortran. As described in Using the Command-Line Interface in Getting Started, the Visual Fortran Fortran command window sets these variables for you automatically. To activate this command window, select the Fortran Command Prompt icon in the Visual Fortran program folder. Fortran Compiler and Linker The DF (or FL32) command is the driver for running the compiler and linker.
Using Visual Fortran Tools Page 8 of 69 Inline Files in a Makefile Macros and NMAKE NMAKE Inference Rules Dot Directives Makefile Preprocessing Running NMAKE The syntax for NMAKE is: NMAKE [option...] [macros...] [targets...] [@commandfile...] NMAKE builds only specified targets or, if none is specified, the first target in the makefile is used. The first makefile target can be a pseudotarget (a label used in place of a filename in a dependency line) that builds other targets.
Using Visual Fortran Tools Page 9 of 69 (resolution of two seconds or less). /C Suppresses default output, including nonfatal NMAKE errors or warnings, timestamps, and NMAKE copyright message. Suppresses warnings issued by the /K option. /D Displays timestamps of each evaluated target and dependent and a message when a target does not exist. Useful with the /P option for debugging a makefile.
Using Visual Fortran Tools Page 10 of 69 /T Updates timestamps of command-line targets (or first makefile target) and executes preprocessing commands but does not run the build. /X filename The option /X filename sends NMAKE error output to filename instead of standard error. Spaces or tabs can precede filename. To send error output to standard output, specify a dash (-) for filename. Does not affect output from commands to standard error. /Y Disables batch-mode inference rules.
Using Visual Fortran Tools Page 11 of 69 Macros Inference Rules Dot Directives Preprocessing Directives Other features of a makefile include wildcards, long filenames, comments, and special characters. Wildcards and NMAKE NMAKE expands filename wildcards (* and ?) in dependency lines. A wildcard specified in a command is passed to the command; NMAKE does not expand it. Long Filenames in a Makefile Enclose long filenames in double quotation marks, as follows: all : "VeryLongFileName.
Using Visual Fortran Tools Page 12 of 69 In macros, a backslash followed by a newline character is replaced by a space. In commands, a percent symbol (%) is a file specifier. To represent a percent symbol (%) literally in a command, specify a double percent sign (%%) in place of a single one. In other situations, NMAKE interprets a single % literally, but it always interprets a double %% as a single %.
Using Visual Fortran Tools Page 13 of 69 A pseudotarget used as a dependent must also appear as a target in another dependency; however, that dependency does not need to have a commands block. Pseudotarget names follow the filename syntax rules for targets. However, if the name does not have an extension (that is, does not contain a period), it can exceed the 8-character limit for filenames and can be up to 256 characters long.
Using Visual Fortran Tools Page 14 of 69 echo Building climb.exe... leap.exe : jump.obj # invokes an inference rule Targets in Multiple Description Blocks To update a target in more than one description block using different commands, specify two consecutive colons (::) between targets and dependents. For example: target.lib :: one.f90 two.f90 three.f90 df one.f90 two.f90 three.f90 lib target one.obj two.obj three.obj target.lib :: four.c five.c df /c four.for five.for lib target four.obj five.
Using Visual Fortran Tools Page 15 of 69 any valid filename or pseudotarget. Separate multiple dependents with one or more spaces or tabs. Dependents are not case sensitive. Paths are permitted with filenames. Inferred Dependents An inferred dependent is derived from an inference rule and is evaluated before explicit dependents. If an inferred dependent is out-of-date with respect to its target, NMAKE invokes the commands block for the dependency.
Using Visual Fortran Tools Page 16 of 69 Command Modifiers in NMAKE You can specify one or more command modifiers preceding a command, optionally separated by spaces or tabs. As with commands, modifiers must be indented. The following table lists the command modifiers: Modifier Action @command Prevents display of the command. Display by commands is not suppressed. By default, NMAKE echoes all executed commands. Use the /S option to suppress display for the entire makefile; use .
Using Visual Fortran Tools Page 17 of 69 An inline file contains text you specify in the makefile. Its name can be used in commands as input (for example, a LINK command file), or it can pass commands to the operating system. The file is created on disk when a command that creates the file is run.
Using Visual Fortran Tools Page 18 of 69 Reusing Inline Files in Makefiles To reuse an inline file, specify <
Using Visual Fortran Tools Page 19 of 69 only spaces or tabs. The string can contain a macro invocation. Special Characters in NMAKE Macros A number sign (#) after a definition specifies a comment. To specify a literal number sign in a macro, use a caret (^), as in ^#. A dollar sign ($) specifies a macro invocation. To specify a literal $, use $$. To extend a definition to a new line, end the line with a backslash (\).
Using Visual Fortran Tools Page 20 of 69 Using an NMAKE Macro To use a macro, enclose its name in parentheses preceded by a dollar sign ($): $(macroname) No spaces are allowed. The parentheses are optional if macroname is a single character. The definition string replaces $(macroname); an undefined macro is replaced by a null string.
Using Visual Fortran Tools Page 21 of 69 Macro Meaning $@ Current target’s full name (path, base name, extension), as currently specified. $$@ Current target’s full name (path, base name, extension), as currently specified. Valid only as a dependent in a dependency. $* Current target’s path and base name minus file extension. $** All dependents of the current target. $? All dependents with a later timestamp than the current target.
Using Visual Fortran Tools Page 22 of 69 undefined.
Using Visual Fortran Tools Page 23 of 69 extension, NMAKE uses a rule whose extensions match the target and an existing file in the current or specified directory. If more than one rule matches existing files, the .SUFFIXES list determines which to use; list priority descends from left to right. If a dependent file doesn’t exist and is not listed as a target in another description block, an inference rule can create the missing dependent from another file with the same base name.
Using Visual Fortran Tools Page 24 of 69 Batch-Mode Rules Batch-mode inference rules provide only one invocation of the inference rule when N commands go through this inference rule. Without batch-mode inference rules, it would require N commands to be invoked. N is the number of dependents that trigger the inference rule. Makefiles that contain batch-mode inference rules must use NMAKE version 1.62 or higher. To check the NMAKE version, run the _NMAKE_VER macro available with NMAKE version 1.
Using Visual Fortran Tools Page 25 of 69 .cbl.exe $(COBOL) $(COBFLAGS) $*.cbl, $*.exe; cobol $*.cbl, $*.exe; .cbl.obj $(COBOL) $(COBFLAGS) $*.cbl; cobol $*.cbl; .for.exe $(FOR) $(FFLAGS) $*.for fl32 $*.for .f90.exe $(FOR) $(FFLAGS) $*.f90 fl32 $*.f90 .f.exe $(FOR) $(FFLAGS) $*.f fl32 $*.f .for.obj $(FOR) /c $(FFLAGS) $*.for fl32 $*.for /c .f90.obj $(FOR) /c $(FFLAGS) $*.f90 fl32 $*.f90 /c .f.obj $(FOR) /c $(FFLAGS) $*.f fl32 $*.f /c .pas.exe $(PASCAL) $(PFLAGS) $*.pas pl $*.pas .
Using Visual Fortran Tools Page 26 of 69 sensitive and are uppercase. Directive Action .IGNORE : Ignores nonzero exit codes returned by commands, from the place it is specified to the end of the makefile. By default, NMAKE halts if a command returns a nonzero exit code. To restore error checking, use !CMDSWITCHES (described in Makefile Preprocessing Directives). To ignore the exit code for a single command, use the dash modifier. To ignore exit codes for an entire file, use the /I option. .
Using Visual Fortran Tools Page 27 of 69 Expressions in Makefile Preprocessing Makefile Preprocessing Operators Executing a Program in Preprocessing Makefile Preprocessing Directives Preprocessing directives are not case sensitive. The initial exclamation point (!) must appear at the beginning of the line. Zero or more spaces or tabs can appear after the exclamation point, for indentation. The following are preprocessing directives: !CMDSWITCHES {+ | -}option...
Using Visual Fortran Tools Page 28 of 69 defined. A null macro is considered to be defined. !IFNDEF macroname Processes statements between !IFNDEF and the next !ELSE or !ENDIF if macroname is not defined. !ELSE [IF constantexpression | IFDEF macroname | IFNDEF macroname] Processes statements between !ELSE and the next !ENDIF if the prior !IF, !IFDEF, or !IFNDEF statement evaluated to zero. The optional keywords give further control of preprocessing. !ELSEIF Synonym for !ELSE IF.
Using Visual Fortran Tools Page 29 of 69 equivalent to !IFDEF or !ELSE IFDEF. However, unlike these directives, DEFINED can be used in complex expressions using binary logical operators. The EXIST operator is a logical operator that acts on a file-system path. EXIST (path) is true if path exists. The result from EXIST can be used in binary expressions. If path contains spaces, enclose it in double quotation marks.
Using Visual Fortran Tools Page 30 of 69 The Microsoft visual development environment includes a special dialog editor for creating dialogs and placing the controls within them, and a graphic editor for drawing or importing icons. You must use the dialog editor and graphic editor in the visual development environment to design dialogs and icons. Once you have created a dialog or icon, you can compile it from the command line using the Resource Compiler (RC).
Using Visual Fortran Tools Page 31 of 69 After creating individual resource files for your application’s dialog box and icon resources, you create a resource-definition file, or script. A script is a text file with the extension .RC. The script lists every resource in your application and describes some types of resources in great detail. For a resource that exists in a separate file, such as an icon or cursor, the script names the resource and the file that contains it.
Using Visual Fortran Tools Page 32 of 69 The menu definition, enclosed by the BEGIN and END keywords, specifies each menu item and the menu identifier that is returned when the user selects that item. For example, the first item on the menu, Clear, returns the menu identifier ID_CLEAR when the user selects it. The menu identifiers are defined in the application header file, SHAPES.H. Once you create the resource-definition script (RC) file, use the Resource Compiler Command Line to create the RES file.
Using Visual Fortran Tools /x Page 33 of 69 Prevents RC from checking the INCLUDE environment variable when searching for header files or resource files. Options are not case sensitive and a dash (-) can be used in place of a forward slash (/). You can combine single-letter options if they do not require additional arguments. For example, the following commands are equivalent: RC /V /X SAMPLE.RC rc -vx sample.
Using Visual Fortran Tools Page 34 of 69 Delete a member from a library Use the /REMOVE option. LIB processes any specifications of /REMOVE after combining all input objects, regardless of command-line order. Note: You cannot both delete a member and extract it to a file in the same step. You must first extract the member object using /EXTRACT, then run LIB again using /REMOVE. This section describes the Microsoft 32-Bit Library Manager (LIB.EXE).
Using Visual Fortran Tools Page 35 of 69 LIB Output Files The output files produced by LIB depend on the usage mode as follows: Mode Output Default (building or modifying a library) COFF library (.LIB) Extracting a member with /EXTRACT Object (.OBJ) file Building an export file and import library with /DEF Import library (.LIB) and export (.EXP) file Other LIB Output In the default mode, you can use the /LIST option to display information about the resulting library.
Using Visual Fortran Tools Page 36 of 69 To run LIB, type the command LIB followed by the options and filenames for the task you are using LIB to perform. LIB also accepts command-line input in command files. LIB does not use an environment variable. Note: If you are accustomed to the LINK32.EXE and LIB32.
Using Visual Fortran Tools Page 37 of 69 Suppresses display of the LIB copyright message and version number and prevents echoing of command files. /VERBOSE Displays details about the progress of the session. The information is sent to standard output and can be redirected to a file. Other options apply only to specific modes of LIB. These options are discussed in the sections describing each mode. LIB Options The default mode for LIB is to build or modify a library of COFF objects.
Using Visual Fortran Tools Page 38 of 69 Other LIB options are described in: Building an Import Library and Export File Extracting a Library Member Using LIB Options The files can be COFF object files, 32-bit OMF object files, and existing COFF libraries. LIB creates one library that contains all objects in the specified files. If an input file is a 32-bit OMF object file, LIB converts it to COFF before building the library.
Using Visual Fortran Tools Page 39 of 69 You can use LIB to create an object (.OBJ) file that contains a copy of a member of an existing library. To extract a copy of a member, use the following syntax: LIB library /EXTRACT:member /OUT:objectfile This command creates an .OBJ file called objectfile that contains a copy of a member of a library. The member name is case sensitive. You can extract only one member in a single command. The /OUT option is required; there is no default output name.
Using Visual Fortran Tools Page 40 of 69 The following options apply to building an import library and export file: /DEBUGTYPE:{CV|COFF|BOTH} This option sets the format of debugging information. Specify CV for new-style Microsoft Symbolic Debugging Information, required by Visual C++ and Visual Fortran. Specify COFF for Common Object File Format (COFF) debugging information. Specify BOTH for both COFF debugging information and old-style Microsoft debugging information.
Using Visual Fortran Tools Page 41 of 69 exports to ONE.DLL, the import library for TWO.DLL won’t exist yet when ONE.DLL is linked. When circular exports exist, you must use LIB to create an import library and exports file for one of the programs. To begin, choose one of the programs on which to run LIB. In the LIB command, list all objects and libraries for the program and specify the /DEF option. If the program uses a .DEF file or /EXPORT specifications, specify these as well.
Using Visual Fortran Tools Page 42 of 69 Specify one or more files for the objects or images to be changed, and one or more options for changing the files. When you type the command EDITBIN without any other command-line input, EDITBIN displays a usage statement that summarizes its options. EDITBIN Options An option consists of an option specifier, which is either a dash ( - ) or a forward slash ( / ), followed by the name of the option. Option names cannot be abbreviated.
Using Visual Fortran Tools Page 43 of 69 If a program has been modified with the /BIND option, and if the base addresses for the executable file and its DLLs do not conflict with DLLs that are already loaded, the operating system does not need to set these addresses. In a situation where the files are incorrectly based, the operating system will relocate the program’s DLLs and recalculate the entry-point addresses; this adds to the program’s load time.
Using Visual Fortran Tools Page 44 of 69 BASEFILE Creates a file named COFFBASE.TXT, which is a text file in the format expected by LINK’s /BASE option. DOWN Tells EDITBIN to reassign base addresses downward from an ending address. The files are reassigned in the order specified, with the first file located in the highest possible address below the end of the address range. BASE must be used with DOWN to ensure sufficient address space for basing the files.
Using Visual Fortran Tools s shared u uninitialized data w write Page 45 of 69 To control alignment, specify the character "a" followed by a character to set the size of alignment in bytes, as follows: Character Alignment size in bytes 1 1 2 2 4 4 8 8 p 16 t 32 s 64 x no alignment Specify the properties and alignment characters as a string with no white space. The characters are not case sensitive.
Using Visual Fortran Tools Page 46 of 69 Options. EDITBIN Option /SWAPRUN This option edits the image to tell the operating system to copy the image to a swap file and run it from there. Use this option for images that reside on networks or removable media. It has the following form: /SWAPRUN:{[!]NET|[!]CD} You can add or remove the NET or CD qualifiers: NET indicates that the image resides on a network. CD indicates that the image resides on a CD-ROM or similar removable medium.
Using Visual Fortran Tools Page 47 of 69 There are times when you must examine or change OBJ, EXE, and DLL files. In the visual development environment, you can open any file as a Binary rather than as an ASCII text file and work with both hexadecimal and ASCII versions of the contents. From the command line, you can use the Microsoft Binary File Dumper (DUMPBIN) to edit these types of files. This section describes the Microsoft COFF Binary File Dumper (DUMPBIN.EXE).
Using Visual Fortran Tools Page 48 of 69 Option Description /ALL Displays all available information except code disassembly. Use the /DISASM option to display disassembly. You can use /RAWDATA:NONE with the /ALL option to omit the raw binary details of the file. /ARCHIVEMEMBERS Displays minimal information about member objects in a library. /ARCH Dumps the .arch section of an image. /DEPENDENTS Dumps the names of the DLLs from which the image imports functions.
Using Visual Fortran Tools Page 49 of 69 Argument Result BYTES The default. Contents are displayed in hexadecimal bytes, and also as ASCII if they have a printed representation. SHORTS Contents are displayed in hexadecimal words. LONGS Contents are displayed in hexadecimal longwords. NONE Raw data is suppressed. This is useful to control the output of the /ALL option. number Displayed lines are set to a width that holds number values per line.
Using Visual Fortran Tools Page 50 of 69 Format Editor writes the updated format statement and generates new continuation marks. Similarly, the part of a formatted I/O statement that follows the formatting directives is lost when the Format Editor writes the updated directive string back to the file. When you are finished editing the format statement, the Format Editor rewrites the source file with code for the format you have developed. If the file has the extension .
Using Visual Fortran Tools Page 51 of 69 5. A default value is used for the descriptor you choose (for example, I5). To change the descriptor value, select the value and type in the new value. (For example, select 5 from I5 and type 8 to get an I8 format.) To insert a new format statement: 1. Place the cursor on a blank line. 2. From the Edit menu, choose Format Editor. The Format Editor inserts the words label FORMAT into the file at the cursor.
Using Visual Fortran Tools Page 52 of 69 profiling, you must write batch files to invoke PREP, PROFILE, and PLIST. You can redirect the output of the batch file to a designated file by using the redirection character (>). A typical profiler batch file might look like this: PREP /OM /FT /EXC nafxcwd.lib %1 if errorlevel == 1 goto done PROFILE %1 %2 %3 %4 %5 %6 %7 %8 %9 if errorlevel == 1 goto done PREP /M %1 if errorlevel == 1 goto done PLIST /SC %1 >%1.
Using Visual Fortran Tools Page 53 of 69 If the preceding batch file was named FTIME.BAT, and you wanted to profile the program TEST from the command prompt, you would type: FTIME C:\Program Files\DF\MYDIR\TEST.EXE Profiler Batch Files Like the linker, all three profiler programs accept response files. The command line: PREP /OM /FT /EXC nafxcwd.lib %1 can be replaced by the line: PREP @opts.rsp %1 if you create a file OPTS.
Using Visual Fortran Tools Page 54 of 69 /OM /FT /EXC nafxcwd.lib # this is a comment The # character in a response file defines a comment that runs through the end of the line. Five standard batch files ship with the profiler: Filename Description FTIME.BAT Function timing FCOUNT.BAT Function counting FCOVER.BAT Function coverage LCOUNT.BAT Line counting LCOVER.BAT Line coverage These batch files contain only the minimum parameters for the initial call to PREP.
Using Visual Fortran Tools Page 55 of 69 Control the kind of profiling, the inclusion and exclusion of code to be profiled, whether to merge profiles, and other profiling features. See the PREP Options table. options programname1 Filename of primary program to profile (.DBG, .EXE, or .DLL). PROFILE adds the .EXE extension if no extension is given. This parameter must be specified in the first call to PREP and not the second call. programname2 Additional programs to profile.
Using Visual Fortran Tools /IT filename X Merges an existing .PBT file (the file generated by the second call to PREP to be passed to PLIST). Up to eight .PBT files can be merged at a time. You cannot merge .PBT files from different profiling methods. The default extension is .PBT. /LC X Selects line count profiling. /LV X Selects line coverage profiling. /M filename Page 56 of 69 X Substitutes for /IT, /IO, and /OT options. /NOLOGO X X Suppresses the PREP copyright message.
Using Visual Fortran Tools Page 57 of 69 In this example, the /EXCALL option excludes all modules from the profile, and the /INC option supercedes that to include only lines 3 - 41 and lines 50 - 67 from the source file TEST.F90. Note the absence of spaces in the source specification. To specify all source lines in a particular module, specify the .OBJ file like this: /EXCALL /INC TEST.OBJ or by using the source filename with zero line numbers like this: /EXCALL /INC TEST.
Using Visual Fortran Tools Page 58 of 69 Option Description /A Appends any redirected error messages to an existing file. If the /E command-line option is used without the /A option, the file os overwritten. This option is valid only with the /E option. /E filename Sends profiler-generated error messages to filename. /H[ELP] Provides a short summary of PROFILE options. / I filename Specifies a .PBI file to be read. This file is generated by PREP. /NOLOGO Suppresses the PROFILE copyright message.
Using Visual Fortran Tools Page 59 of 69 PLIST [options] inputfile PLIST reads the command line from left to right, so the rightmost options override contradictory options to the left. None of the options are case sensitive. You must prefix options with a forward slash (/) or a dash (-), and options must be separated by spaces. PLIST results are sent to STDOUT by default. Use the greater-than (>) redirection PLIST must be run from the directory in which the profiled program was compiled.
Using Visual Fortran Tools Page 60 of 69 /SLS Forces line count profile output to be printed in coverage format. /SN Sorts output in alphabetical order by function name. This option is available only when profiling by function. /SNS Displays function timing or function counting information in function coverage format. Sorts output in alphabetical order by function name. /ST Sorts output by time, highest first. /T Tab-separated output. Generates a tab-delimited database from the .
Using Visual Fortran Tools Page 61 of 69 Generating the Tab-Delimite Report Using the PROFILER.XLM Macro Changing the PROFILER.XLM Selection Criteria The PLIST /T command-line option causes PLIST to dump the contents of a .PBT file into a tabdelimited format suitable for import into a spreadsheet or database. This format can also be used by user-written programs. For example, to create a tab-delimited file called MYPROG.TXT from MYPROG.PBT, enter: PLIST /T MYPROG > MYPROG.
Using Visual Fortran Tools Page 62 of 69 Tab-delimited reports are generated with global information records first, organized in numerical order by format tag. The local information records, containing information about specific lines or functions, are generated last. Local information records are organized by line number. If the .PBT file contains information from more than one .EXE or .DLL file, the global information will cover them all.
Using Visual Fortran Tools 521 Profile: Function counting, sorted by function name 522 Profile: Function timing, sorted by function name 524 Profile: Function coverage, sorted by function name Page 63 of 69 Profiling Time and Depth 2 Total Time Outside Time Call Depth Field Explanation 2 Format tag number Total Time Total amount of time used by the program being profiled.
Using Visual Fortran Tools Date Page 64 of 69 The date/time the profile was run (ASCII format) Command Line The PLIST command-line arguments Profiling Starting Function Name 5 Starting Function Name Field Explanation 5 Format tag number Starting Function Name The decorated name of the starting function identified by the PREP /SF parameter Local Information Records The local information records contain information about specific lines or functions that were profiled.
Using Visual Fortran Tools 7 Format tag number Exe ASCII name of the executable file that contains this function Page 65 of 69 Source ASCII name of the source that contains the first line of this function Line Line number of this line Count Number of times this line has been executed.
Using Visual Fortran Tools Function name Page 66 of 69 Each function s name on the stack. The number of names that appear here will be equal to the stack size field in Profiling Stack Hits and Timing (above). Steps to Analyze Profiler Statistics The profiler tab-delimited report format can contain a great deal of information. You can process this data in a spreadsheet, database, or user-written program. To process the data in the tab-delimited report: 1.
Using Visual Fortran Tools Page 67 of 69 1. Open PROFILER.XLM by choosing Open from the File menu. 2. Open the tab-delimited report that was created by PLIST by choosing Open from the File menu. 3. If you have several open worksheets, activate the one containing the profiler data by selecting it with the mouse or by choosing its title from the Windows menu. 4. Run the macro: n Press Ctrl+C for a chart based on hit counts. n Press Ctrl+T for a chart based on timing.
Using Visual Fortran Tools Page 68 of 69 The command options are: -e:name Processes only the program unit name. You can specify more than one -e name on a command line. extend_source Treats the statement field of each source line as ending in column 132, instead of column 72. -help, ? Displays information about the FSPLIT command. -nologo Suppresses the copyright notice that is displayed when FSPLIT or F90SPLIT is run.
Using Visual Fortran Tools Page 69 of 69 formatted according to line printer conventions. The FPR command has the following form: FPR [-f record-size] [filename] record-size Specifies a fixed-length record as input. The record-size must be a decimal integer. filename Specifies the data file to be transformed. FPR copies the input filename onto itself, replacing the carriage control characters with characters that will produce the intended effects when printed using the PRINT command.