📄 flib.gml
字号:
.ix 'subprograms' 'FSIGNAL function'
.ix 'utility subprograms' 'FSIGNAL function'
.ix 'FSIGNAL function'
The INTEGER function
.id FSIGNAL
allows your application to respond to certain events that occur during
execution.
.begnote $setptnt 12
:DTHD.Event
:DDHD.Meaning
.note SIGBREAK
.ix 'Ctrl/Break'
an interactive attention (Ctrl/Break on keyboard) is signalled
.note SIGFPE
an erroneous floating-point operation occurs (such as division by
zero, overflow and underflow)
.note SIGILL
illegal instruction encountered
.note SIGINT
an interactive attention (Ctrl/C on keyboard) is signalled
.note SIGSEGV
an illegal memory reference is detected
.note SIGTERM
a termination request is sent to the program
.note SIGIDIVZ
integer division by zero
.note SIGIOVFL
integer overflow
.endnote
.np
The function
.id FSIGNAL
requires two arguments.
The first argument is an INTEGER argument and must be one of the events
described above.
The second argument, called the handler, is one of the following.
.autopoint
.point
a subprogram that is called when the event occurs
.point
the value SIG_DFL, causing the default action to be taken when the event
occurs
.point
the value SIG_IGN, causing the event to be ignored
.endpoint
.np
.id FSIGNAL
returns SIG_ERR if the request could not be processed, or the previous
event handler.
.exam begin
INCLUDE 'FSIGNAL.FI'
EXTERNAL BREAK_HANDLER
LOGICAL BREAK_FLAG
COMMON BREAK_FLAG
BREAK_FLAG = .FALSE.
CALL FSIGNAL( SIGBREAK, BREAK_HANDLER )
WHILE( .NOT. VOLATILE( BREAK_FLAG ) ) CONTINUE
PRINT *, 'Program Interrupted'
END
SUBROUTINE BREAK_HANDLER()
LOGICAL BREAK_FLAG
COMMON BREAK_FLAG
BREAK_FLAG = .TRUE.
END
.exam end
.autonote Notes:
.note
The FORTRAN include file :FNAME.fsignal.fi:eFNAME. contains typing and
calling information for
.id FSIGNAL
and should be included when using this function.
This file is located in the :FNAME.&pathnam.&pc.src&pc.fortran:eFNAME.
directory.
The :FNAME.&pathnam.&pc.src&pc.fortran:eFNAME. directory should be
included in the
.ev &incvarup
environment variable so that the compiler can locate the include file.
.note
The intrinsic function
.id VOLATILE
is used to indicate that the reference to the variable
.id break_flag
is volatile.
A volatile reference prevents the compiler from caching a variable in
a register.
In this case, we want to retrieve the value of
.id break_flag
from memory each time the loop is iterated.
.endnote
.*
.do end
.*
.section INTEGER Function FSPAWN
.*
.np
.ix 'subprograms' 'FSPAWN function'
.ix 'utility subprograms' 'FSPAWN function'
.ix 'FSPAWN function'
The INTEGER function
.id FSPAWN
allows an application to run another program as a
subprocess.
When the program completes, execution is returned to the
invoking application.
There must be enough available free memory to start the subprocess.
.np
The function
.id FSPAWN
requires two arguments of type CHARACTER.
The first argument is a character string representing the name of
the program to be run.
The string must end in a NULL character (i.e.,
a character with the binary value 0).
.np
The second argument is a character string argument list to be passed
to the program.
The first character of the second argument must
contain, in binary, the length of the remainder of the argument list.
For example, if the argument is the string "HELLO" then
the first character would be CHAR(5) and the remaining characters
would be "HELLO" (see the example below).
.np
.id FSPAWN
returns an INTEGER value representing the status of
subprocess execution.
If the value is negative then the program could not be run.
If the value is positive then the value represents the program's
return code.
.exam begin
INCLUDE 'FSUBLIB.FI'
INTEGER CMDLEN, STATUS
CHARACTER CMD*128, CMDLIN*128
* COMSPEC will tell us where DOS 'COMMAND.COM' is hiding
CMDLEN = FGETENV( 'COMSPEC', CMD )
CMD(CMDLEN+1:CMDLEN+1) = CHAR( 0 )
CMDLIN = '/c dir *.for'
CMDLIN(13:13) = CHAR( 0 )
STATUS = FSPAWN( CMD, CMDLIN )
PRINT *, 'Program status = ', STATUS
END
.exam end
.autonote Notes:
.note
The FORTRAN include file :FNAME.fsublib.fi:eFNAME., located in the
:FNAME.&pathnam.&pc.src&pc.fortran:eFNAME. directory, contains typing
and calling information for this subprogram.
The :FNAME.&pathnam.&pc.src&pc.fortran:eFNAME. directory should be
included in the
.ev &incvarup
environment variable so that the compiler can locate the include file.
.note
The INTEGER function
.id FSYSTEM,
which is described in a later section, implements a more general form
of the example given above.
We recommend its use.
.endnote
.*
.section INTEGER Function FSYSTEM
.*
.np
.ix 'execute a program'
.ix 'subprograms' 'FSYSTEM function'
.ix 'utility subprograms' 'FSYSTEM function'
.ix 'FSYSTEM function'
The INTEGER function
.id FSYSTEM
allows an application to run another program or execute an operating
system command.
.np
The function
.id FSYSTEM
requires one argument of type CHARACTER.
This argument represents a operating system command or a program name
together with any arguments.
.id FSYSTEM
returns an INTEGER value representing the status of subprocess
execution.
If the value is negative, the operating system command interpreter or
shell could not be run (an attempt is made to invoke the system
command interpreter to run the program).
If the value is positive, the value represents the program's
return code.
.np
In the following example, a "COPY" command is executed
and then a hypothetical sorting program is run.
.exam begin
INCLUDE 'FSUBLIB.FI'
INTEGER STATUS
STATUS = FSYSTEM( 'COPY *.FOR &pc.BACKUP&pc.FOR&pc.SRC' )
PRINT *, 'Status of COPY command = ', STATUS
STATUS = FSYSTEM( 'SORTFILE/IN=INP.DAT/OUT=OUT.DAT' )
PRINT *, 'Status of SORT program = ', STATUS
END
.exam end
.autonote Notes:
.note
The FORTRAN include file :FNAME.fsublib.fi:eFNAME., located in the
:FNAME.&pathnam.&pc.src&pc.fortran:eFNAME. directory, contains typing
and calling information for this subprogram.
The :FNAME.&pathnam.&pc.src&pc.fortran:eFNAME. directory should be
included in the
.ev &incvarup
environment variable so that the compiler can locate the include file.
.endnote
.*
.if '&cmpclass' ne 'load-n-go' .do begin
.*
.section Subroutine FTRACEBACK
.*
.np
.ix 'subprograms' 'FTRACEBACK subroutine'
.ix 'utility subprograms' 'FTRACEBACK subroutine'
.ix 'FTRACEBACK subroutine'
The subroutine
.id FTRACEBACK
allows your application to generate a run-time traceback.
The application must be compiled with the "DEBUG" or "TRACE" option.
It is useful when you wish to disclose a problem in an application and
provide an informative report of where the problem occurred in the
application.
.np
The
.id FTRACEBACK
subroutine requires no arguments.
The
.id FTRACEBACK
subroutine does not terminate program execution.
.exam begin
SUBROUTINE READREC( UN )
INCLUDE 'FSUBLIB.FI'
INTEGER UN
INTEGER RLEN
CHARACTER*35 INPUT
RLEN = FNEXTRECL( UN )
IF( RLEN .GT. 35 )THEN
PRINT *, 'Error: Record too long', RLEN
CALL FTRACEBACK
STOP
ELSE
PRINT *, 'Record length=', RLEN
READ( UNIT=UN ) INPUT(1:RLEN)
PRINT *, INPUT(1:RLEN)
ENDIF
END
.exam end
.autonote Notes:
.note
The FORTRAN include file :FNAME.fsublib.fi:eFNAME., located in the
:FNAME.&pathnam.&pc.src&pc.fortran:eFNAME. directory, contains typing
and calling information for this subprogram.
The :FNAME.&pathnam.&pc.src&pc.fortran:eFNAME. directory should be
included in the
.ev &incvarup
environment variable so that the compiler can locate the include file.
.endnote
.*
.do end
.*
.section Subroutine GETDAT
.*
.np
.ix 'subprograms' 'subroutine GETDAT'
.ix 'utility subprograms' 'subroutine GETDAT'
.ix 'GETDAT subroutine'
The subroutine
.id GETDAT
allows an application to obtain the current date.
.np
The subroutine
.id GETDAT
has three arguments of type
.id INTEGER*2.
When control is returned from
.id GETDAT,
they contain the year, month and day
of the current date.
.np
The following program prints the current date in the form
"YY-MM-DD".
.exam begin
INCLUDE 'FSUBLIB.FI'
INTEGER*2 YEAR, MONTH, DAY
CALL GETDAT( YEAR, MONTH, DAY )
PRINT 100, YEAR, MONTH, DAY
100 FORMAT( 1X, I4, '-', I2.2, '-', I2.2 )
END
.exam end
.autonote Notes:
.note
The FORTRAN include file :FNAME.fsublib.fi:eFNAME., located in the
:FNAME.&pathnam.&pc.src&pc.fortran:eFNAME. directory, contains typing
and calling information for this subprogram.
The :FNAME.&pathnam.&pc.src&pc.fortran:eFNAME. directory should be
included in the
.ev &incvarup
environment variable so that the compiler can locate the include file.
.note
The arguments to
.id GETDAT
must be of type INTEGER*2 in order to obtain correct results.
.endnote
.*
.section Subroutine GETTIM
.*
.np
.ix 'subprograms' 'subroutine GETTIM'
.ix 'utility subprograms' 'subroutine GETTIM'
.ix 'GETTIM subroutine'
The subroutine
.id GETTIM
allows an application to obtain the current time.
.np
The subroutine
.id GETTIM
has four arguments of type
.id INTEGER*2.
When control is returned from
.id GETTIM,
they contain the hours, minutes, seconds, and hundredths of seconds
of the current time.
.np
The following program prints the current time in the form
"HH:MM:SS.TT".
.exam begin
INCLUDE 'FSUBLIB.FI'
INTEGER*2 HRS, MINS, SECS, HSECS
CALL GETTIM( HRS, MINS, SECS, HSECS )
PRINT 100, HRS, MINS, SECS, HSECS
100 FORMAT( 1X, I2.2, ':', I2.2, ':', I2.2, '.', I2.2 )
END
.exam end
.autonote Notes:
.note
The FORTRAN include file :FNAME.fsublib.fi:eFNAME., located in the
:FNAME.&pathnam.&pc.src&pc.fortran:eFNAME. directory, contains typing
and calling information for this subprogram.
The :FNAME.&pathnam.&pc.src&pc.fortran:eFNAME. directory should be
included in the
.ev &incvarup
environment variable so that the compiler can locate the include file.
.note
The arguments to
.id GETTIM
must be of type INTEGER*2 in order to obtain correct results.
.endnote
.*
.section INTEGER Function GROWHANDLES
.*
.np
.ix 'subprograms' 'GROWHANDLES function'
.ix 'utility subprograms' 'GROWHANDLES function'
.ix 'GROWHANDLES function'
The INTEGER function
.id GROWHANDLES
allows an application to increase the maximum number of files that can
be opened.
It requires one argument of type INTEGER representing the maximum
number of files that can be opened and returns an INTEGER value
representing the actual limit.
The actual limit may differ from the specified limit.
For example, memory constraints or system parameters may be such that
the request cannot be satisfied.
.np
The following example attempts to increase the limit on the number of
open files to sixty-four.
.exam begin
INCLUDE 'FSUBLIB.FI'
INTEGER NEW_LIMIT
NEW_LIMIT = GROWHANDLES( 64 )
END
.exam end
.autonote Notes:
.note
The FORTRAN include file :FNAME.fsublib.fi:eFNAME., located in the
:FNAME.&pathnam.&pc.src&pc.fortran:eFNAME. directory, contains typing
and calling information for this subprogram.
The :FNAME.&pathnam.&pc.src&pc.fortran:eFNAME. directory should be
included in the
.ev &incvarup
environment variable so that the compiler can locate the include file.
.endnote
.*
.section Functions IARGC and IGETARG
.*
.np
.ix 'subprograms' 'function IARGC'
.ix 'utility subprograms' 'function IARGC'
.ix 'IARGC function'
.ix 'subprograms' 'function IGETARG'
.ix 'utility subprograms' 'function IGETARG'
.ix 'IGETARG function'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -