Program Appl in Elec Comp Engr
Program Appl in Elec Comp Engr ECE 3331
Popular in Course
Popular in Electrical Engineering
This 3 page Class Notes was uploaded by Karolann Wiegand on Saturday September 19, 2015. The Class Notes belongs to ECE 3331 at University of Houston taught by Betty Barr in Fall. Since its upload, it has received 24 views. For similar materials see /class/208301/ece-3331-university-of-houston in Electrical Engineering at University of Houston.
Reviews for Program Appl in Elec Comp Engr
Report this Material
What is Karma?
Karma is the currency of StudySoup.
Date Created: 09/19/15
Using Compaq Visual Fortran The Compaq Visual Fortran development environment has many similarities to the Microsoft Visual C development environment The three main areas used when writing a program are the workspace the project and the source le A workspace is simply a container to easily organize projects A project is a container to hold any number of source les Typically all the source les in a project are interrelated often to produce a single executable program le The hierarchy of areas listed from highest to lowest is the workspace then the project and nally the source le You can build many different kinds of projects with Visual Fortran For our purposes only one the console application is of interest A Fortran console application exe is a characterbased program that does not require screen graphics output It looks similar to a program running on a UNIX workstation or a terminal connected to a mainframe computer Fortran console projects operate in a single window and let you interact with your program through normal read and write commands Console applications are better suited to problems that require pure numerical processing rather than graphical output or a graphical user interface This type of application is also more portable to other platforms than other types of application Creating a Workspace 1 Once the Visual Fortran program has been started choose the New option from the File dropdown menu at the top of the screen 2 A new dialog box will appear Choose the Workspaces tab 3 Type a name for your workspace in the Workspace Name edit box for example ece333 lfort might be a good choice 4 Pick a location to save using the browse button a small button with an ellipses on it The directory must exist before you can choose it Visual Studio will create a directory within the directory you choose and it will be assigned a name identical to your workspace name 5 Click OK to create the workspace Creating a Project 1 To create a project within your workspace choose New from the File dropdown menu A dialog box will appear 2 Make sure you are on the Project tab This should be the default tab when the dialog box appears 3 Select Fortran Console Application from the list 4 Type a name for your project in the Project Name edit box for example cp6 might be a good choice 5 Pick a location to save using the browse button a small button with an ellipses on it The directory must exist before you can choose it Visual Studio will create a directory within the directory you choose and it will be assigned a name identical to your project name For example you could choose the ece3331fort workspace created above Using this kind of directory structure is a good way to organize several projects within a single workspace 6 When the next dialog appears make sure to choose An empty project and click Finish 7 Click OK for the next dialog box 8 On the left side of the Visual Fortran application pane choose the File View tab Notice that your newly created project is nested within the workspace Notice that the words cp6 les are in bold letters This means that this is the current project and any source les created will be added to this project Creating Source Files 1 From the Project dropdown menu choose Add to Project and then New in the popout menu A dialog box will appear 2 Make sure the Files tab is chosen This should be the default when the dialog box opens 3 If you are creating a Fortran 77 program select Fortran Fixed Format Source File in the list If you are creating a Fortran 9095 program select Fortran Free Format Source File in the list 4 Type the name of your source le in the File name edit box for example cp6 might be a good choice You do not need to type an extension Visual Fortran will assign a for extension to Fortran 77 les and a f90 extension to Fortran 9095 les If you change this Visual Fortran will have a problem when it tries to compile the le The compiler must know whether the source le is xed format or free format 5 You probably do not need to choose the location to save this le The current projects directory will be listed in the Location edit box 6 Click OK and the source le will be created and opened You can now type your source code Compiling the Source Code Visual Fortran allows you to compile either a single source le or the entire project assuming there are many les in a particular project this will not be the case for ECE 3331 1 To compile only one source le highlight the le from the Source Files list in the left hand pane of the Visual Fortran application window From the Build dropdown menu choose Compile lename ext where lenameext will be the source le that you have highlighted Any errors in the source le will be listed at the bottom of the screen 2 To compile the entire project choose Build from the dropdown menu and then choose Build projectexe where project exe is the project you wish to compile This command will compile all source les within the project link their respective object les and create an executable le assuming there are no errors 3 If errors arise during compilation of the source code they will be listed in the Build window at the bottom of the Visual Fortran application window Simply doubleclick on the error message and the line of code that contains the error will be highlighted Debugging the Source Code One of the nice features of Compaq Visual Fortran is the debugging environment It is intuitive to follow and easy to learn 1 The debugger can only be employed when an executable le is made If the source code does not compile the debugger will not be available 2 To force the debugger to pause execution of the program prior to reaching its end breakpoints must be set within the program A breakpoint is a location in a process where execution is stopped to allow the developer to examine the process s code variables and register values and as necessary make changes continue execution or terminate execution 3 To set a breakpoint at a sourcecode line do the following o In a source window move the insertion point to the line where you want the program to break Choose the InsertRemove Breakpoint toolbar button or press F9 A red dot appears in the left margin indicating that the breakpoint is set Note If you want to set a breakpoint on a source statement extending across two or more lines you must set the breakpoint on the last line of the statement 4 To set a breakpoint at the beginning of a function or subroutine do the following o In the Find box on the Standard toolbar type the function or subroutine name 0 Click the InsertRemove Breakpoint toolbar button or press F9 5 9 gt1 00 gt0 0 While in debug mode a red dot appears in your source code in the left margin at the beginning of the function or subroutine indicating that the breakpoint is set To set a breakpoint at the return point of a function or subroutine do the following 0 Start debugging and pause the debugger in break mode program is waiting for user input after completing a debugging command 0 On the View menu click Debug Windows then click Call Stack o In the Call Stack window move the insertion point to the function or subroutine where you want the program to break 0 Click the InsertRemove Breakpoint toolbar button or press F9 0 While in debug mode a red dot appears in the left margin of your source code indicating that the breakpoint is set To set a breakpoint at a label do the following o In the Find box on the Standard toolbar type the name of the label 0 Click the InsertRemove Breakpoint toolbar button or press F9 0 While in debug mode a red dot appears in your source code in the left margin at the line containing the label indicating that the breakpoint is set To initiate the debugger choose Build from the dropdown menu then pick Start Debug and then select Go Pressing F5 will also start the debugger The program will then stop at the rst breakpoint it encounters At this point there are several options for working through the program To continue to the neXt breakpoint press F5 To step into the neXt statement press Fll To step over the neXt statement press F10 To step out of a loop or subprogram press shiftFl 1 To execute to the current cursor position press ctrlF10 Note all of the above commands are available on the debugging toolbar This toolbar becomes active as soon as the debug session is initiated It is possible during the debug session to view the value of most variables This is not possible if the variable is being held in a register To view the variables in the current subprogram press the Locals tab at the bottom of the application window To view a particular variable the variable name can be entered on one line of the watch window and its current value will be displayed