📄 fdosedit.gml
字号:
.ix 'compiler statistics'
At the end of the program listing, we find some statistics such as how
long it took to compile the program and the number of error messages
that were issued.
The compile and execution times are reported as actual elapsed time in
seconds using the "time-of-day" clock.
.np
Some statistics on memory utilization also appear.
The object code size is the number of bytes of executable code
generated by &cmpname for the program.
The local data area size includes scalar variables (undimensioned
variables), numeric and logical constants, and temporaries used
in evaluating expressions.
The global data area size includes character variables, dimensioned
variables, and common blocks.
The amount of unused memory is reflected in the "Object bytes free"
statistic.
This number represents the amount of memory still available to the
compiler for object code.
.ix 'CODESIZE option'
.ix 'options' 'CODESIZE'
The amount of memory used for object code can be set by using the
"CODESIZE=" option.
The default is 512k.
.np
A number appears to the left of
.us some
of the FORTRAN source lines.
This number is generated by the compiler for each FORTRAN statement.
It is used primarily at execution time when the compiler detects an
error and issues a message.
.ix 'statement number'
.ix 'internal statement number'
.ix 'ISN'
The statement number is sometimes referred to as an "Internal
Statement Number" or ISN.
We will demonstrate the usefulness of the ISN in a subsequent example.
.np
Upon checking out the rules about the use of the
.id SQRT
function, we find that the argument must be a floating-point
quantity of type real, double precision, complex, or double
precision complex.
Because of the rules of FORTRAN,
.id NUMBER
is an integer variable by default.
The program must be corrected either by changing the name of the
variable or by explicitly declaring the type of the variable.
.np
This is just one example of how &cmpname handles compile-time
errors.
.ix compile-time
We use the term "compile-time" since the error was detected
before any execution of the program was attempted.
.np
Let us take this example and correct the error but also introduce a
new one.
First we should empty the contents of the listing workspace using
the editor's "DELETE" command.
Enter the command:
.millust *delete
and the screen will display:
:cmt. .cp 8
:cmt. .mbox begin
:cmt. .in -2
:cmt.
:cmt. <beginning of file>
:cmt. <end of file>
:cmt.
:cmt. .in +2
:cmt. .mbox end
:picture file='UGPRG9' text='Deleting Workspace Contents'.
.np
We erase the contents of the listing workspace for two reasons:
.begpoint
.point (i)
to ensure that as much memory as possible is available for
processing the FORTRAN source program, and
.point (ii)
to ensure that the next time we edit the listing file, we
will get a fresh copy from the disk.
.endpoint
.np
To return to our original workspace, we can enter the command:
.millust edit
.np
Change the program by adding a variable declaration so that it
resembles the following:
:cmt. .cp 15
:cmt. .mbox begin
:cmt. .in -2
:cmt.
:cmt. <beginning of file>
:cmt. * Program to compute a square root
:cmt.
:cmt. REAL NUMBER
:cmt. NUMBER = -144
:cmt. SQROOT = SQRT( NUMBER )
:cmt. PRINT *, SQROOT
:cmt. END
:cmt. <end of file>
:cmt.
:cmt. .in +2
:cmt. .mbox end
:picture file='UGPRG10' text='Square Root Revision 1'.
.np
Run the revised program using the "run/list" command.
This time a different message is displayed on the screen:
.code begin
*ERR* LI-03 argument must not be negative
- Executing in MAIN PROGRAM, statement 3 in file root&cxt.
.code end
.pc
.ix execution-time
This message is issued at execution time.
.ix trace-back
Execution-time messages are accompanied by a program "trace-back".
The trace-back is a sequence of one or more messages which describes
the state of the executing program at the time the error was detected.
.np
If you edit the listing file, you will find something similar to the
following.
:cmt. .cp 25
:cmt. .cbox begin
:cmt. .in -2
:cmt. <beginning of file>
:cmt. &product &ver &cdate
:cmt. .cpyrit 1984
:cmt. .trdmrk
:cmt.
:cmt. Options: list,disk,extensions,reference,warnings,terminal,run,xtype,check,
:cmt. arraycheck,statements=0,pages=0,time=0,codesize=524288,pagesize=66,fover
:cmt.
:cmt. * Program to compute a square root
:cmt.
:cmt. 1 REAL NUMBER
:cmt. 2 NUMBER = -144
:cmt. 3 SQROOT = SQRT( NUMBER )
:cmt. 4 PRINT *, SQROOT
:cmt. 5 END
:cmt.
:cmt. *ERR* LI-03 argument must not be negative
:cmt. - Executing in MAIN PROGRAM, statement 3 in file root&cxt.
:cmt.
:cmt. Compile time (in seconds): 0 Execution time (in seconds): 0
:cmt. Size of object code: 114 Number of extensions: 0
:cmt. Size of local data area(s): 80 Number of warnings: 0
:cmt. Size of global data area: 0 Number of errors: 1
:cmt. Object bytes free: 524244 Statements Executed: 2
:cmt. <end of file>
:cmt.
:cmt. .in +2
:cmt. .cbox end
:picture file='UGPRG11' text='Listing of Revision 1'.
.np
.ix ISN
Here, we see the use of the ISN.
The error has occurred in the third
.us statement
of the FORTRAN program.
Note that this is
.us not
the third line in the file.
.np
The name of the file which contained the program is also
displayed in the trace-back messages (in this case
:FNAME.root&cxt.:eFNAME.).
This is done since FORTRAN source lines can come from several
different files.
.np
The above illustrates the execution-time error detection
(or diagnostic) capability of &cmpname..
.np
We would like to close this discussion by correcting the program
so that it produces the desired result.
Delete all the lines in the listing file workspace.
Use the "EDIT" command to return to the original workspace and
change the program as follows:
:cmt. .cp 15
:cmt. .mbox begin
:cmt. .in -2
:cmt.
:cmt. <beginning of file>
:cmt. * Program to compute a square root
:cmt.
:cmt. REAL NUMBER
:cmt. NUMBER = 144
:cmt. SQROOT = SQRT( NUMBER )
:cmt. PRINT *, SQROOT
:cmt. END
:cmt. <end of file>
:cmt.
:cmt. .in +2
:cmt. .mbox end
:picture file='UGPRG12' text='Square Root Revision 2'.
.np
When you run the program, the result
.millust begin
12.0000000
.millust end
.pc
is displayed on the screen.
This is indeed the square root of the number 144.
The decimal point and trailing zeroes indicate that the result is
a floating-point quantity.
.np
If you edit the listing file, you will find something similar to
the following.
:cmt. .cp 25
:cmt. .cbox begin
:cmt. .in -2
:cmt. <beginning of file>
:cmt. &product &ver &cdate
:cmt. .cpyrit 1984
:cmt. .trdmrk
:cmt.
:cmt. Options: list,disk,extensions,reference,warnings,terminal,run,xtype,check,
:cmt. arraycheck,statements=0,pages=0,time=0,codesize=524288,pagesize=66,fover
:cmt.
:cmt. * Program to compute a square root
:cmt.
:cmt. 1 REAL NUMBER
:cmt. 2 NUMBER = 144
:cmt. 3 SQROOT = SQRT( NUMBER )
:cmt. 4 PRINT *, SQROOT
:cmt. 5 END
:cmt.
:cmt.
:cmt. Compile time (in seconds): 0 Execution time (in seconds): 0
:cmt. Size of object code: 114 Number of extensions: 0
:cmt. Size of local data area(s): 80 Number of warnings: 0
:cmt. Size of global data area: 0 Number of errors: 0
:cmt. Object bytes free: 524100 Statements Executed: 4
:cmt. <end of file>
:cmt.
:cmt. .in +2
:cmt. .cbox end
:picture file='UGPRG13' text='Listing of Revision 2'.
.np
You may have noticed that the printed result of this program appeared
on the screen but not in the listing file.
.ix listing
.ix 'printed result'
.ix 'NOXTYPE option'
.ix 'options' 'NOXTYPE'
&cmpname provides an option ("NOXTYPE") which allows you to direct
such printed results to the listing file instead of the screen.
Rerun the program but this time also specify the "NOXTYPE" option.
.millust run/list/noxtype
Don't forget to delete the listing file workspace and return to the
program workspace.
See the chapter entitled "Compiler Options" for more information on
the "NOXTYPE" option.
.*
.section Saving the Finished Program
.*
.np
Now that you have a completely correct FORTRAN program, you probably
will want to save a copy of it on the disk.
As we saw in an earlier section, you can use the editor's "PUT"
command to save the program.
.ix 'editor commands' PUT
.millust put
If you forget to do this and exit from &cmpname then any changes since
the last "put" will be lost.
.hint
If you have an up-to-date listing file, you could extract the lost
source lines from this file but it can be a lot of work!
.ehint
.np
It is a good policy to save your program on disk from time to time
("checkpointing") just in case something goes wrong.
For example, you might accidentally delete the program from the
workspace.
Checkpointing also allows you to back up a step when the latest
revision to a program is disastrously wrong.
The editor has an automatic checkpointing capability.
Look at the description of the editor's "AUTOSAVE" command.
.*
.section More Examples Using Compiler Options
.*
.np
Assume that the workspace contains the following statements.
:cmt. .cp 15
:cmt. .mbox begin
:cmt. .in -2
:cmt.
:cmt. <beginning of file>
:cmt. X=12.
:cmt. Y=X*-X
:cmt. PRINT *,X,Y
:cmt. END
:cmt. <end of file>
:cmt.
:cmt. .in +2
:cmt. .mbox end
:picture file='UGPRG14' text='Another FORTRAN Program'.
.np
Run this program using the following command.
.millust run/list/type
On the screen will appear something similar to the following:
:cmt. .cp 18
:cmt. .cbox begin
:cmt. .in -2
:cmt. &product &ver &cdate
:cmt. .cpyrit 1984
:cmt. .trdmrk
:cmt.
:cmt. Options: list,extensions,reference,warnings,terminal,run,xtype,check,
:cmt. arraycheck,statements=0,pages=0,time=0,codesize=524288,pagesize=66,fover
:cmt.
:cmt. 1 X=12.
:cmt. 2 Y=X*-X
:cmt. $
:cmt. *ERR* SX-02 bad sequence of operators
:cmt. 3 PRINT *,X,Y
:cmt. 4 END
:cmt.
:cmt.
:cmt. Compile time (in seconds): 0 Execution time (in seconds): 0
:cmt. Size of object code: 0 Number of extensions: 0
:cmt. Size of local data area(s): 0 Number of warnings: 0
:cmt. Size of global data area: 0 Number of errors: 1
:cmt. Object bytes free: 0 Statements Executed: 0
:cmt. .in +2
:cmt. .cbox end
:picture file='UGPRG15' text='Screen Output'.
.np
.ix 'TYPE option'
.ix 'options' 'TYPE'
In this case, we have used the "TYPE" option.
This option causes &cmpname to output the program listing,
complete with diagnostics, to the screen instead of a disk file.
.millust begin
run/list/nowarn/ext d:example1
.millust end
.pc
This command requests &cmpname to compile and execute the file
:FNAME.d:example1&cxt.:eFNAME.,
specifying that no warning messages are to be issued, and that
extension messages are to be issued.
In this case, we have specified a file on disk (we are assuming
that there is no workspace in memory with the name
:FNAME.d:example1&cxt.:eFNAME.).
.ix 'TYPE option'
.ix 'options' 'TYPE'
Since we did not use the "TYPE" option, &cmpname produces a file
with an extension of "LST" using the source filename as the
filename for the listing file.
.ix 'listing file'
If you were to examine the contents of the current directory
of the default disk, you would find the listing file:
.millust begin
EXAMPLE1.LST
.millust end
.np
.ix 'ERRORFILE option'
.ix 'options' 'ERRORFILE'
The following example is similar to the previous one except that the
"ERRORFILE" option is also specified.
.millust begin
run/list/nowarn/ext/errorfile d:example1
.millust end
.np
If any diagnostic messages are issued, &cmpname produces a file with
an extension of "ERR" using the source filename as the filename for
the error file.
.ix 'error file'
If diagnostic messages were issued and you were to examine the
contents of the current directory of the default disk, you
would find the error file:
.millust begin
EXAMPLE1.ERR
.millust end
.np
The error file will contain a summary of the error messages that
also appear in the listing file.
The messages are presented in the same form as they appear on the
screen.
.cp 25
.remark
The listing and error file names are constructed by using only
the filename part of the full source file specification.
.ix 'listing file'
.ix 'error file'
.millust begin
C:\IMSL\SINGLE\MAIN\LINEQSMN.FOR
.millust end
.pc
Given the source file specification above, &cmpname constructs
the following names.
.millust begin
Listing file name: LINEQSMN.LST
Error file name: LINEQSMN.ERR
.millust end
.np
If the current directory is
.millust begin
B:\TESTS
.millust end
.pc
then the full listing and error file specifications are:
.millust begin
Listing file: B:\TESTS\LINEQSMN.LST
Error file: B:\TESTS\LINEQSMN.ERR
.millust end
.eremark
.*
.section Halting an Executing FORTRAN Program
.*
.np
.ix 'compilation' halting
.ix 'execution' halting
.ix 'interrupting execution'
.ix 'interrupting compilation'
When a FORTRAN program is "RUN" two steps are performed.
The program is first compiled, that is, it is translated into
computer instructions.
It is then placed into execution, provided that there were no
compile-time errors.
.np
.ix 'Ctrl/Break'
While the FORTRAN program is being compiled, &cmpname may be halted by
entering a Ctrl/Break sequence from the keyboard.
Compilation of the program will be terminated.
.np
.ix 'Ctrl/Break'
While a FORTRAN program is executing, it may also be halted by
entering a Ctrl/Break sequence from the keyboard.
A message will appear indicating that the program was interrupted and
then a program traceback will follow.
.ix 'DEBUG option'
.ix 'options' 'DEBUG'
If the "DEBUG" option was specified with the "RUN" command then the
&cmpname debugger will be entered.
Otherwise, a prompt will appear which will allow you to resume or
terminate execution.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -