Converting ASTERIX code from VMS to UNIX |
The process of converting third party ASTERIX software is greatly facilitated by the use of the ADAM infrastructure software. It is quite possible to have source code compatability between VMS and UNIX versions of application software.
The following is a procedure for porting a hypothetical spectral analysis program which contains the following VMS components,
SAPPLIC.FOR
.
SAPP_1.FOR
and SAPP_2.FOR
.
SAPPLIC_CMN.FOR
which is referenced
in the source code using INCLUDE 'SAPPLIC_CMN'
.
DAT__
must contain the line INCLUDE 'DAT_PAR'
LIB$GET_LUN FIO_GUNIT( LUN, STATUS ) LIB$FREE_LUN FIO_PUNIT( LUN, STATUS ) SYS$TRNLNM PSX_GETENV(SYM, VALUE, STATUS ) LIB$GET_SYMBOL LIB$GET_VM PSX_MALLOC( NBYTES, PTR, STATUS ) open( ... ) FIO_OPEN( FILE, ACMODE, TFORM, RECSZ, FD, STATUS )Note that replacing
OPEN
statements is not always
required (except for file access mode not supported on UNIX, such
as keyed access). However, the FIO package neatly takes account
of machine differences in the options of OPEN
and
prevents annoying compiler warnings. Click
here to read
the FIO programmer guide.
LIB$DELETE_FILE UTIL_DELETE( FILE, STATUS ) LIB$RENAME_FILE UTIL_RENAME( FILE, STATUS ) printer spooling UTIL_SPOOL( FILE, TYPE, DELETE, STATUS )
FOR
to .f
. Rename any
include files so that their UNIX filename is exactly the same as the name
referenced in the INCLUDE
statement (ie. including case). In
the example above we'd now have the following files SAPPLIC_CMN sapplic.f sapplic.ifl sapp_1.f sapp_2.fNow start up the ASTERIX development system.
% astdevThe VMS style include file names must be converted to UNIX ones. An ASTERIX script is provided for this purpose.
% v2u_include -l SAPPLIC_CMN sapplic.f % v2u_include -l SAPPLIC_CMN sapp_1.f % v2u_include -l SAPPLIC_CMN sapp_2.fThe
-l
option tells ASTERIX that the named include file is
local and not a system include file.
Compile the Fortran files using the following commands (the -c
option tells the compiler not to generate an executable),
% f77 -c sapplic.f % f77 -c sapp_1.f % f77 -c sapp_2.fThis generates three object files with extension
.o
which are now combined into an executable by the Starlink linking script
alink
.% alink sapplic.o sapp_1.o sapp_2.o `spec_link` `ast_link`The last two arguments are linker options scripts which incorporate the spectral fitting library and the ASTERIX libraries respectively. These scripts correspond exactly to their VMS option file counterparts. The link command on VMS for the above would have been,
$ ALINK SAPPLIC,SAPP_1,SAPP_2,SPECLIB/OPT,ASTOPT/OPTFinally, compile the interface file and start your application,
% compifl sapplic COMPIFL: Successful completion % sapplic