Next: Available Libraries
Up: ADAM
Previous: Example Session
Link Script Details
The link scripts firstly have to create a subroutine, DTASK_APPLIC, which is
called by the ADAM fixed part and in turn calls the user's top-level
routine.
The difference between alink and ilink is just that the
template DTASK_APPLIC for alink contains a call to close down the
parameter system after each invocation of the task unless the environment
variable ADAM_TASK_TYPE is set to `I'.
If the user's main routine is written in C, a temporary routine,
DTASK_WRAP is created as a Fortran-callable wrapper for the user's
routine. DTASK_APPLIC will call DTASK_WRAP, which in turn calls the user's
routine.
During installation (as part of the DTASK library in the
PCS
package), the actual compile/link command within alink/ilink is edited
depending upon the platform and setting of various environment variables.
The template command is:
F77 $FFLAGS -o $EXENAME \
$XDBX \
/star/lib/dtask_main.o \
dtask_applic.f \
$ALINK_FLAGS1 \
$ARGS \
-L/star/lib \
-lhdspar_adam \
-lpar_adam \
`dtask_link_adam` \
$ALINK_FLAGS2 \
Additional system libraries
Notes:
- F77 is replaced by whatever the FC environment variable is when
alink/ilink is installed.
- Any C source files specified will be compiled separately and linked in
the above Fortran command. The C compiler command used will be of the form:
% CC -c $CFLAGS $CARGS -I/star/include
where:
- CC
- is replaced by the CC environment variable when
alink/ilink script is installed.
- $CFLAGS
- is the value of the CFLAGS environment variable when
alink/ilink is invoked.
- $CARGS
- is any C files or -I or -D arguments
on the alink/ilink command line, plus, if the main routine is C,
dtask_wrap.c
- $EXENAME is the basename of the prog_module
argument of alink/ilink with any .f, .c or
.o suffix removed.
- Environment variable FFLAGS may be used to specify any options which
must be included at the start of the command line.
- $XDBX is set to -g if the -xdbx argument
is given.
- $ALINK_FLAGS1 may be set to determine the type of linking
required. For instance:
% setenv ALINK_FLAGS1 -L/star/share
would cause the linker to find the Starlink
shared libraries (on platforms where they are installed), thus producing a
dynamically linked executable.
- $ARGS is the prog_module argument (with .o
appended if the original extension was not .f, .c or
.o)
or $EXENAME.o dtask_wrap.o if the main routine was in C, followed
by the remaining arguments unchanged except that any .c file
extensions are replaced by .o.
- To speed up the link, pkg_link_adam scripts are only used
selectively.
dtask_link_adam refers to DTASK, TASK and ERR libraries directly then
invokes subpar_link_adam which references the necessary
libraries directly, apart from HDS, HLP and PSX whose link_adam scripts are
invoked.
- ALINK_FLAGS2 may be useful in controlling the way system
libraries are accessed.
- Additional system libraries A platform-dependent list of
required system libraries which are not searched automatically is added to
alink/ilink at installation time.
- Other adjustments are made during installation if PCS is not being
installed in /star.
In particular, a -L option is added to include the newly installed libraries
before those in /star/lib.
Similarly with -I options in the C compilation.
The -xdbx argument is provided to overcome some awkward problems which
can arise when debugging ADAM applications. Usually it is sufficient to
include -g in the arguments of alink/ilink but sometimes,
notably when using xdbx and ups on SunOS, the debuggers do
not behave sensibly if required source files are missing so the -xdbx
argument should be used instead.
The effects of the argument are:
- A dummy source file for dtask_main, the main routine of every
ADAM task, is created in the working directory.
The file contains an explanatory message to the user and the name of the
user's top-level subroutine (which may be helpful in selecting a breakpoint).
- The source file of DTASK_APPLIC is not deleted from the working
directory.
- -g is inserted in the compile/link command.
Next: Available Libraries
Up: ADAM
Previous: Example Session
ADAM
Starlink User Note 144
A J Chipperfield
17 August 2001
E-mail:ussc@star.rl.ac.uk
Copyright © 2000 Council for the Central Laboratory of the Research Councils