Science makes it known,
Engineering makes it work,
Art makes it beautiful.
|
|
Combining Fujitsu COBOL 3.0, PowerCOBOL 3.0, Silverfrost FTN95,
and
Numerical Recipes: The Art of Scientific Computing1
- Overview
This is a tutorial of one way of using a COBOL "wrapper"
(alternatively, an executive or dispatcher) main program
to call a FORTRAN
subroutine to calculate Average, Median, Standard Deviation,
Variance, etc., for a series of grades
(referred to as data points). The COBOL main
program performs
user Input/Output by calling PowerCOBOL sheet(s). This
is a similar (but more refined)
Software Design
as
Combining Fujitsu COBOL 3.0, PowerCOBOL 3.0, and the USPS Address Matching System API.
The user interface,
shown above, STF95IO, is a PowerCOBOL
3.0 sheet. The user inputs the number of
data points and up to 300 data points (or grades), then selects
Calculate from the File menu. The application
then
calculates Average, Variance, etc. by calling FORTRAN
subprograms, and finally displays the results in sheet
STF95IO. This is an
application that uses a:
-
Fujitsu COBOL 3.0 main program to coordinate calls;
developed on a Pentium II running Win98SE;
(Fujitsu's COBOL 3.0 is a conventional 3rd generation
COBOL85 Win32 programming environment);
main program uses different compiler options then the
PowerCOBOL 3.0 sheet(s)
-
Fujitsu COBOL 3.0 subprogram to call PowerCOBOL 3.0
sheets
through routine _POWEROPENSHEET;
subprogram uses same compiler options as the
PowerCOBOL 3.0 sheet(s);
(Fujitsu's PowerCOBOL is a graphical programming environment that allows
COBOL programmers to develop GUI applications with event-driven structures)
-
PowerCOBOL 3.0 sheet(s) for user input/output
(each sheet linked into its own .DLL);
sheet STF95IO, shown above, is used for inputting
data points (using a table)
and displaying the statistical results; may possibly add sheets
to display bar graphs, etc.
developed on a Pentium II running Win98SE
-
and
Numerical Recipes
Statistical Descriptions of Data subroutines
written in Fortran with the Silverfrost FTN95 PLATO3 IDE
(linked into its own .DLL);
developed on a Pentium III running WinXP Pro SP2
Application has been tested on both the Win98SE and WinXP Pro SP2
platforms.
The Project Files
STF95COB.EXE - main Fujitsu COBOL 3.0 executable;
linked using Fujitsu's WINLINK (WINLINK is a
'front-end' for MicroSoft's linker)
STF95COB.COB - main Fujitsu COBOL 3.0 executable
source code;
INVKSHT.LIB - import library file for INVKSHT.DLL - Fujitsu
COBOL 3.0 subprogram compiled and linked from INVKSHT.COB
(invokes PowerCOBOL 3.0 sheet(s) through call to _POWEROPENSHEET);
linked using Fujitsu's WINLINK
F5BBRUNS.LIB - import library file for F5BBRUNS.DLL
(Fujitsu supplied .dll that includes _POWEROPENSHEET function);
STTSTCS.LIB - import library file for
STTSTCS.DLL
(user written FORTRAN Numerical Recipes Statistical
Descriptions of Data subroutines,
source code file STTSTCS.FOR,
compiled and linked with
SilverFrost FTN95
PLATO3 IDE SLINK - be sure to use the correct import library file
- see
linking STTSTCS.OBJ);
SALFLIBC.LIB - import library file for SALFLIBC.DLL
(Silverfrost supplied FTN95 run time .dll);
needed by WINLINK;
various other library files imported by Microsoft linker;
|
|
The COBOL program and PowerCOBOL sheets share data using a
GLOBAL EXTERNAL data area (similar to a FORTRAN COMMON
block). The main COBOL program shares data with
the FORTRAN subroutines BY REFERENCE in the CALL
statement.
Passed Data: Application Binary Interface
(these have been tested [except for COBOL and FORTRAN calling D and
Pascal];
a blank box simply means the combination has
not been tested; also DMD uses name mangling as well as a different
object (.obj) and import library (.lib) file
format than most other linkers, so linking in a D .dll using a D .lib
may prove problematic) Check your platform and
compiler documentation for any restrictions or extensions that may
affect this.
COBOL
Picture
Clause
|
Equivalent FORTRAN Data Type
|
C Data Type
|
D 2 Data Type
|
Object Pascal 3
Data Type
|
Data Range 4
|
Size (bytes)
|
PIC S9(4) COMP-5
|
INTEGER*2
|
short
|
short
|
smallint
|
-32768 to 32767
|
2 |
PIC S9(9) COMP-5
|
INTEGER*4
|
int
|
int
|
longint
|
-2147483648 to 2147483647
|
4
|
COMP-1
|
REAL
(REAL*4)
(KIND=1)
|
float
|
float
|
single
|
-1E-37 to 1E39
|
4
|
|
REAL*8
|
|
double
|
double
|
-5.0E-324 to 1.7E308
|
8
|
|
COMPLEX
5
|
|
cfloat
5
|
|
|
8
|
PIC X(n)
[n is some integer, number of characters (bytes)]
|
CHARACTER*n
|
char <field-name>[n]
(<field-name> is the name of the variable)
data is not null terminated 6
|
char[n] <field-name> 7
|
array [1..n] of AnsiChar 8
|
ASCII Character Codes
|
n
|
1. Press, William H., Brian P. Flannery, Saul A Teukolsky,
and William T. Vetterling (1986). Numerical Recipes: The Art of Scientific
Computing. New York:Press Syndicate of the University of Cambridge.
2. D Programming Language - DMD v2.066.0
(D2 32-bit Command Prompt)
3. Free Pascal
(FPC) is an implementation of Object Pascal
While Object Pascal has Integer and Real data types, depending on compiler
modes/switches, Integer could be mapped to smallint or
longint. Reals are platform dependant. Avoid using Integer
and Real data types for passing data to/from external
functions/procedures/subprograms, use
short/smallint/INTEGER*2, double/double/REAL*8,
etc.
Do not
confuse C and D short with Free Pascal shortint.
Also applicable to
Lazarus
basic data types
4. For the floating point ranges, there is some variation among different
references.
5.
Do not return COMPLEX variables from a
Silverfrost FORTRAN function to a DMD main program. The real and imaginary parts switch
places within the COMPLEX variable. This is probably a side effect
of having to use
extern (Pascal) {...}
declaration in the D program.
Passing and receiving COMPLEX variables to/from a Silverfrost FORTRAN
subroutine and a DMD D program does not produce this error.
6. This is a special COBOL case, see
USPS Address Matching System API AMS ZIP4 Parameters,
AMSZ4PRM.COB COBOL include file.
7. Pascal special case. In D program extern (Pascal) {...}
passed parameter data type, declare passed character data as
ref char[<constant>]; in called Pascal
Library, define character array in type declaration, in
function/procedure received parameter list, define variable as
a var (pass by reference)
8. Put in type declaration.
Char or AnsiChar.
System unit defines AnsiChar to distinguish Char from
WideChar.
In future versions of FPC, the Char type may become an alias for either
WideChar or AnsiChar. For now, Char and AnsiChar
are equivalent.
|