Overview of MS Fortran Compiler
2009.09.04 09:01
[출처] http://physics.gmu.edu/~amin/phys251/Topics/Languages/For_ms51.htm
PHYS 251 - Introduction to Computer Techniques in Physiscs
Overview of MS Fortran Compiler
PC Version 5.1, 1991
Getting Started with MS Fortran
The MS Fortran Compiler, Version 5.1, is somewhat outdated compiler but still has some uses. We suggest the following steps to get started in writing, compiling, and executing your own Fortran programs with MS Fortran 5.1.
- There are several restrictions that you should follow as a courtesy to other students in this and other physics courses.
- Do not reconfigure the machines through the AUTOEXEC.BAT or CONFIG.SYS files. DeVries suggests the use of a Set command; do not alter the AUTOEXEC.BAT on Physics Department machines. Your machine, yes, our machines no.
- Do not place your personal files in directories containing software used by others, such as the MS Fortran Compiler. Make your own directory under a root directory called TMP, such as \TMP\Brown.
- Note that periodically the machines in both rooms are cleaned and reloaded with software. Therefore, do not depend on your files remaining on a machine; back them up to a floppy disk at the end of each working session.
- DeVries recommends that his library, FCCP.lib, be placed in the directory \FORTRAN\LIB. You may link to his library from your directory as follows.
- When using the FL command, discussed below, create a compile_link BAT file in your directory, such as CL.BAT. Put the path for libraries into the BAT file as follows.
- FL /Gt /4Nt /4Yb /4Yd yourfile.for /link C:\your_directory\LIB\FCCP.lib+C:\FORTRAN\LIB\GRAPHICS.lib
- With an editor you may change the BAT file and, since it is an executable file, the BAT file will carry out the invoking of the compiler.
- For an editor, you may use PWB (see below) that is included with MS Fortran, or the DOS editor, or even NOTEPAD under WINDOWS. Word processors can be used as editors as long as your restrict to text-only files, no embeded format codes. There are any number of respectable editors that will serve the purpose. The important point is to become familiar with one.
PWB Editor
The Programmer's WorkBench (PWB) provides an integrated environment for developing Fortran programs. With PWB, you can write and edit source and other teext files, define development projects, and build applications form one or more files.
- PWB - The syntax for invoking PWB is
- PWB [[options]] [[myfile.for]]
- Examples:
- PWB demo.for
- PWB demo.for two.for
- PWB Options - The options are case sensitive.
- /?
- Lists the PWB command-line options.
- /r
- Starts PWB in no-edit mode. All editing functions that modify files are disabled.
Compiling and Linking with the FL Command
The FL command automatically compiles and links your Fortran program in a single step. FL executes the three compiler passes, then calls LINK (the Microsoft Segmented-Executable Linker) to link the object files. Except for a few unusual situations, FL is the only command you need to compile and link your Fortran source files. The result of the FL command, if successful, is a runtime executable file for DOS with the extension .EXE.
- FL Command - The FL command compiles and links one or more Fortran source files. The general syntax for the FL command is
- FL [[options]] myfile_1.for [[options]] [[myfile_2.for]]...[[/link [[libfield]] [[link options]]...]]
- Examples:
- FL myfile.for
- FL /Gt /4Nt /4Yb /4Yd myfile.for /link C:\my_directory\FCCP+C:\FORTRAN\LIB\GRAPHICS
- Compiling Options - There are a large number of options available, some being more important than others. We will concentrate on a few that are particularly relevant. Options are generally case sensitive.
- FL /HELP
- Lists all FL options on the standard output. This option is not case sensitive.
- FL /c filespec.for
- Compiles without linking.
- FL /4Nt filespec.for
- Enables (/4Yt) or disables (/4Nt) truncation of variable names to 6 characters. /4Nt is the default or truncation to 6 characters. Thus for variable names longer than 6 characters one must override the compiler default.
- FL /4Yd filespec.for
- Enables (/4Yd) or diaables (/4Nd) warnings about undeclared variables. /4Nd is the default. Since Fortran compilers will not enforce strong typing, i.e. explicitly declaring the type of each variable, we can take the next best action. This is for the compiler to issue a warning message about undeclared variables.
- FL /4Yb filespec.for
- Enables (/4Yb) or disables (/4Nb) extended error handling at run time. /4Nb is the default. The compiler will issue extend error messages at run time with this option enabled.
- FL /Aletter filespec.for
- Selects the memory model. The letter can be M, L, or H,, for Medium, Large, Or Huge, respectivly. /AL is the default.
- FL /Gt[[number]] filespec.for
- Places data items greater than or equal to number bytes in a new segment. Defaults to 32,767 bytes if this option is not specified. If /Gt is specified without a number, defaults to 256 bytes. This option has no effect with the Medium memory model. This option will, for example, allow the storage of very large arrays of data.
Managing Libraries with LIB Utility
LIB creates, organizes, and maintains standard libraries. Standard libraries are collections of compiled or assembled object modules, and provide a common set of useful routines and/or data. These libraries provide your program with routines and data at link time. With LIB one creates a library file and adds or deletes modules in a library.
- LIB Utility - The LIB utility creates and maintains libraries developed by the user. The syntax for invoking the LIB utility is the following.
- LIB oldlibrary [[options]] [[commands]] [[,[[newlibrary]] ]] [[;]]
- Example: LIB FCCP.lib +myfile.obj, FCCPNEW.lib;
- The options are not case sensitive and can be abbreviated to the shortest unique name.
- One can also invoke LIB by typing LIB and press ENTER and reponding to the prompts that LIB displays.
- If the oldlibrary file does not exist, LIB prompts by:
- Library file does not exist. Create?
- Press Y to create the library file or N to end the LIB session.
- The newlibrary field specifies a name for the changed library file. If you do not change the name, LIB stores the original library file with the extension .BAK.
- If you do not specify all expected input on the command line and do not end the line with a semicolon, LIB asks you for the missing input by displaying the following four prompts and waits for your response to each.
- Library name: your response FCCP.lib
- Operations: your response +myfile.obj
- List file: your response FCCPNEW.lst
- Output library: your response FCCPNEW.lib
- LIB Options
- /H[[ELP]]
- Calls the QuickHelp utility. If LIB cannot locate the help file for QuickHelp, it displays a brief summary of LIB command-line syntax.
- /?
- Displays a brief summary of LIB command-line syntax.
- LIB Commands
- +name
- Appends an object file or library file to oldlibrary
- -name
- Deletes a module from oldlibrary
- -+name
- Replaces a module in oldlibrary by first deleting it and then appending an object file with the same name as the module
- *name
- Copies a module to an object file without deleting it from oldlibrary
- -*name
- Deletes a module from oldlibrary after saving it in an object file
Linking User and System Libraries
- Linking Libraries - The compiler will automatically link those libraries that it needs to produce an executable file (such as myprogram.exe) for a DOS-based platform. However, there are special system libraries, such as a graphics library, or user-developed libraries that must be explicitly specified in order that they be link in at the time an executable file is produced.
- Using FL to Link without Compiling - Just as the FL command can compile source files without linking the resulting object code, FL can link object files that were previously compiled. If all of the files you give FL have extensions other than .FOR, and if no /Tf options appear, FL skips the compiling stage and links your files. The following syntax applies to linking without compiling:
- FL myfile_1.obj [[,myfile_2.obj...]] /link [[libfield]] [[linkoptions]]
- When FL links object files, it gives the resulting executable file the base name of the first object file on the command line, plus an .EXE extension, by default.
- The FL command normally links without having to specify the /link option. However, you can include the /link option in an FL command line if you wish to modify the linking process, such as by specifying a different library.
- Linking Object Files with the LINK Utility - LINK is a bound application that runs under DOS and can create executable files for DOS. LINK uses the following syntax:
- LINK objfilelist
- The objfilelist can also specify library files. However, a library file must specify the filename extension, otherwise LINK treats it as an .OBJ file.
Physics & Astronomy Department, George Mason University
Maintained by J. C. Evans; jevans@gmu.edu
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.