The following session shows the process of compiling, linking and running an example program,
derived from SUN/101, on the Sun.
% source /star/etc/login
%
% ls
repdim2.f repdim2.ifl example.sdf
%
% cat repdim2.f
* Program to report the dimensions of an NDF.
* The CHR package is used to produce a nice output message.
* See SUN/101, section 11.
SUBROUTINE REPDIM2 (STATUS)
IMPLICIT NONE
INCLUDE ’SAE_PAR’
INTEGER DIM(10), I, NCHAR, NDF1, NDIM, STATUS
CHARACTER*100 STRING
* Check inherited global status.
IF (STATUS.NE.SAI__OK) RETURN
* Begin an NDF context.
CALL NDF_BEGIN
* Get the name of the input NDF file and associate an NDF
* identifier with it.
CALL NDF_ASSOC (’INPUT’, ’READ’, NDF1, STATUS)
* Enquire the dimension sizes of the NDF.
CALL NDF_DIM (NDF1, 10, DIM, NDIM, STATUS)
* Set the token ’NDIM’ with the value NDIM.
CALL MSG_SETI (’NDIM’, NDIM)
* Report the message.
CALL MSG_OUT (’ ’, ’No. of dimensions is ^NDIM’, STATUS)
* Report the dimensions.
NCHAR = 0
CALL CHR_PUTC (’Array dimensions are ’, STRING, NCHAR)
DO I = 1, NDIM
* Add a ‘x’ between the dimensions if there are more than one.
IF (I.GT.1) CALL CHR_PUTC (’ x ’, STRING, NCHAR)
* Add the next dimension to the string.
CALL CHR_PUTI (DIM(I), STRING, NCHAR)
ENDDO
CALL MSG_OUT (’ ’, STRING(1:NCHAR), STATUS)
* End the NDF context.
CALL NDF_END (STATUS)
END
%
% cat repdim2.ifl
interface REPDIM2
parameter INPUT
position 1
prompt ’Input NDF structure’
default example
association ’->global.ndf’
endparameter
endinterface
%
% star_dev
% alink repdim2.f ‘ndf_link_adam‘
f77 -g -c repdim2.f
repdim2.f:
repdim2:
dtask_applic.f:
dtask_applic:
%
% repdim2
INPUT - Input NDF structure /@example/ >
No. of dimensions is 1
Array dimensions are 856
%
% ls ~/adam
repdim2.sdf GLOBAL.sdf
%
% compifl repdim2
!! COMPIFL: Successful completion
%
% ls
example.sdf repdim2.f repdim2.ifl
repdim2 repdim2.ifc repdim2.o
%
Note that whether or not the file repdim2.o is retained depends upon the compiler used.