From research!arpa!mdaali.cancer.utexas.edu!s Wed May 17 10:19:23 CDT 1989
Date: Wed, 17 May 89 10:19:23 cdt
From: s@mdaali.cancer.utexas.edu (S admin. acct.)
Posted-Date: Wed, 17 May 89 10:19:23 cdt
Message-Id: <8905171519.AA05991@mdaali.cancer.utexas.edu>
Received: by mdaali.cancer.utexas.edu (4.12/5.51)
	id AA05991; Wed, 17 May 89 10:19:23 cdt
To: rab@research.att.com
Subject: Installing New S on Alliant -- results
Status: R

Greetings,

Enclosed are the results of our efforts to install new S on our Alliant FX/40
running a variant of BSD 4.2.  Barry Brown and Neely Atkinson spoke with you
at the recent Interface conference and told you something about this.
Allen Mcintosh's fix for the printer plot problem fixed our problem, also.
The major remaining problem is dynamic loading.  I will be calling Alliant
Customer Support in a few days to see whether they can provide any assistance
on this one.  Let me know if I can provide you with any further information
about our installation.

Eric M. Sisson			Internet:	ems@mdaali.cancer.utexas.edu
Applications Analyst		BITnet:		AN124041@UTHVM1
Department of Biomathematics	voice:		(713) 792-2600, 792-2608
University of Texas M. D. Anderson Cancer Center
Houston, Texas  77030

#-#-#-#-#-#-#-#  cut here #-#-#-#-#-#-#-#
Instructions for installing New S on an Alliant.


These instructions were derived from use of Concentrix version 4.1.0,
FX/Fortran version 4.1.35, and the 'cc' (not FX/C) compiler on an FX/40.

As of 1989/April/28, the changes described here are sufficient to create new S
on the Alliant with the following restrictions:

	(a)	Dynamic loading does not work.  The dynamic load command acts
		as though it works, but an attempt to use the dynamically-
		loaded routine results in a bus error.  This can be gotten
		around by having users create a locally-modified version of S,
		but at two megabytes a pop, this is not a viable long-term
		solution.

	(b)	When running the 'prob' test ($SHOME/adm/test/NEW/prob),
		an error message about invalid macro syntax is generated.
		Since macros go away in New S, this does not seem serious.



(1)	S uses the C library function popen()(3).  Unfortunately, the
	declaration of this function is missing from <stdio.h> in Concentrix.
	This is supposed to be fixed in the next version of Concentrix.

=-=-=-=-=-=-=

	cp /usr/include/stdio.h /usr/include/stdio.h.orig
	(apply the following diff)

62c62
< FILE *fopen(),*fdopen(),*freopen();
---
> FILE *fopen(),*fdopen(),*freopen(),*popen();

=-=-=-=-=-=-=


(2)	Make a machines subdirectory for Alliant with files from the Sun 
	subdirectory (both are 68020-type machines) and modify the files
	appropriately.

	(a)	The Alliant allegedly is not quite IEEE floating-point because
		it lacks soft underflow.

	(b)	The smallest normalized number on the Alliant is larger than
		that specified for the Sun.

	(c)	The largest floating-point numberr on the Alliant is larger
		than that on the Sun.  See "FX/Fortran Programmer's Handbook",
		July, 1988, appx. E.

	(d)	The Alliant Fortran compiler cannot handle escaped characters
		appearing in character strings, for example,
			"this\nis a newline"
		will not compile a newline character into the string.

=-=-=-=-=-=-=

	mkdir $SHOME/machines/alliant
	cp $SHOME/machines/sun/* $SHOME/machines/alliant

=-=-=-=-=-=-=

	(apply the following diff to '$SHOME/machines/mach.m')

16c16
< define(`BIGEXP',38)define(`BIG',1e`'BIGEXP)define(`SMALL',1e-BIGEXP)
---
> define(`BIGEXP',38)define(`BIG',1e`'BIGEXP)define(`SMALL',1.3e-BIGEXP)
24,29c24,29
< define(`EOS',`"\\0"')
< define(`ESCAPE',`"\\\\"')
< define(`NEWLINE',`"\\n"')
< define(`BACKSPACE',`"\\b"')
< define(`TAB',`"\\t"')
< define(`TSTRING',`"$1\\0"')
---
> define(`EOS',`char(0)')
> define(`ESCAPE',`char(92)')
> define(`NEWLINE',`char(10)')
> define(`BACKSPACE',`char(8)')
> define(`TAB',`char(9)')
> define(`TSTRING',`"$1"//char(0)')
62,63c62,63
< define(`R1MACH',`ifelse($1,1,0.29387359E-38,
< $1,2,0.17014117E39,
---
> define(`R1MACH',`ifelse($1,1,0.11754944E-37,
> $1,2,0.34028235E39,

=-=-=-=-=-=-=

	(apply the following diff to '$SHOME/machines/alliant/system.h')

85c85
< #define SMALL 1e-38
---
> #define SMALL 1.3e-38

=-=-=-=-=-=-=


(3)	The file 'natst.C' should be copied into $P in place of '$P/natst.r'
	(it is a version that tests for IEEE NaNs as NAs).

=-=-=-=-=-=-=

	rm $P/natst.r
	cp $SHOME/machines/alliant/natst.C $P

=-=-=-=-=-=-=


(4)	(At this point, the command '$A/MACHINE' can be entered.)


(5)	You will probably have to make a new version of m4.  You can execute the
	sysgen procedure and it will tell you if a new m4 is required, or else,
	just create the new m4 right now.
		cd $SHOME/src/m4
		make
	execute
		cd $C
		cp makehead makehead.orig
		chmod +w makehead
	and then edit makehead to define M4 as $SHOME/src/m4/a.out.
	The fixed line should look like:
		M4=$${SHOME}/src/m4/a.out


(6)	Changes to makefiles --

	(a)	The FX/Fortran compiler is invoked as 'fortran', not 'f77'.

	(b)	Try specifying the following flags --
			FFLAGS= -OM -dq -recursive
			CFLAGS= -ce
			LDFLAGS=

		FFLAGS	-dq		much of the Fortran code produced uses
					double-quotes for character delimiters,
					which is not ANSI; this option will
					allow this usage
			-recursive	the code has hidden recursion
			-OM		suppress optimization messages;
					voluminous output will be the result
					otherwise

		CFLAGS	-ce		generate code optimized for CEs

	(c)	The library file '/lib/libfortran.a' must be added to the list
		of library files searched.

=-=-=-=-=-=-=

	(apply the following diffs to $C/makehead)

3,5c3,5
< M4=/usr/bin/m4
< F77=f77
< F77COMPILE=f77
---
> M4=$${SHOME}/src/m4/a.out
> F77=fortran
> F77COMPILE=fortran
10,11c10,11
< CFLAGS= -O
< FFLAGS=
---
> CFLAGS= -O -ce
> FFLAGS= -OM -dq -recursive

=-=-=-=-=-=-=

	cp $QPE/S_makefile $QPE/S_makefile.orig
	(apply the following diffs)

4c4
< F77=f77
---
> F77=fortran
7c7
< CFLAGS= -I$$SHOME/newfun/include $(CCFLAGS)
---
> CFLAGS= -I$$SHOME/newfun/include $(CCFLAGS) -ce
9c9
< FFLAGS=
---
> FFLAGS= -OM -dq -recursive

=-=-=-=-=-=-=

	cp $QPE/Makefile $QPE/Makefile.orig
	(apply the following diffs)

10c10
< SYSLIB = /usr/lib/libF77.a /usr/lib/libI77.a -lm
---
> SYSLIB = /lib/libfortran.a /usr/lib/libF77.a /usr/lib/libI77.a -lm
20c20
< F77 = f77
---
> F77 = fortran
32,33c32,33
< CFLAGS = -I$$I $(CCFLAGS)
< FFLAGS =
---
> CFLAGS = -I$$I $(CCFLAGS) -ce
> FFLAGS = -OM -dq -recursive

=-=-=-=-=-=-=

	cp $SHOME/newfun/lib/S_makefile $SHOME/newfun/lib/S_makefile.orig
	(apply the following diff -- Note: this problem was discovered only
	after S was built; this modification may have to wait until that time.)

41c41
< SYSLIB=/usr/lib/libF77.a /usr/lib/libI77.a -lm
---
> SYSLIB=/lib/libfortran.a /usr/lib/libF77.a /usr/lib/libI77.a -lm

=-=-=-=-=-=-=


(7)	The FX/Fortran compiler has a nasty bug.  An expression of the form

		i = ichar(char(j))

	generates an internal compiler error; this has been reported to Alliant.
	(A communication dated 1989/Apr/13 said that it was assigned bug #2455
	and is fixed as of FX/Fortran V4.2, not yet scheduled for release.)
	Expressions of this sort are generated after macro expansion of various
	routines.  The following changes are necessary (or at least sufficient)
	to avoid occurrences of this expression.

=-=-=-=-=-=-=

	cp $SHOME/newfun/include/macro.m $SHOME/newfun/include/macro.m.orig
	(apply the following diff)

59c59
< define(`END_MACRO',`ICHAR(BACKSPACE)')        # unlikely to occur in macros!
---
> define(`END_MACRO',`8')       # unlikely to occur in macros!

=-=-=-=-=-=-=

	cp $SHOME/src/fun/macro/macchr.r $SHOME/src/fun/macro/macchr.r.orig
	(apply the following diff)

6c6
< M_BLANK=ICHAR(" "); M_TAB=ICHAR(TAB); M_NEWLINE=ICHAR(NEWLINE)
---
> M_BLANK=ICHAR(" "); M_TAB=9; M_NEWLINE=10

=-=-=-=-=-=-=

	cp $GRZ/plot1.r $GRZ/plot1.r.orig
	(apply the following diff)

251a252
> CHARACTER(ztemp,1)
324,325c325,328
<               if (parms(2)!=-1)
<                       SPECIFY( pch(CHARMAKE(parms(2))) )
---
>               if (parms(2)!=-1) {
>                       ztemp = char(parms(2))
>                       am(15) = ichar(ztemp)
>                       }

=-=-=-=-=-=-=


(8)	In $QPE, a header file (structure.h) defines a structure type 'vector'.
	Unfortunately, Concentrix has an identically-named structure in one of
	its system header files (<machine/reg.h>).  In programs where both of
	these files are included, chaos and countless compiler errors result.
	The file '<machine/reg.h>' is not included in any S routines directly,
	but rather indirectly through the inclusion of file '<signal.h>'.
	The file '<signal.h>' itself is called indirectly in a few places.

	The simplest fix for this is to copy the relevant system include files
	into $QPE and edit them (and the files that call them) to remove the
	conflict.  This process consists in summary of the following steps:

	(a)	copy '/usr/include/machine/reg.h' to $QPE and rename structure
		'vector'

	(b)	copy '/usr/include/signal.h' to $QPE and modify it so that it
		includes the modified 'reg.h'

	(c)	copy '/usr/include/setjmp.h' to $QPE and modify it so that it
		includes the modified 'signal.h'

	(d)	copy '/usr/include/sys/param.h' to $QPE and modify it so that it
		includes the modified 'signal.h'

	(e)	edit the files that include the system 'signal.h' to include the
		modified 'signal.h'

	(f)	edit the files that include the system 'setjmp.h' to include the
		modified 'setjmp.h'

	(g)	edit the files that include the system 'sys/param.h' to include
		the modified 'param.h'

=-=-=-=-=-=-=

	cp /usr/include/machine/reg.h $QPE/reg.h
	chmod +w $QPE/reg.h
	(apply the following diffs)

46c46
< } vector;
---
> } vectrr;
62c62
<       vector  v[8];           /* vector registers 0-7                 */
---
>       vectrr  v[8];           /* vector registers 0-7                 */

=-=-=-=-=-=-=

	cp /usr/include/signal.h $QPE/signal.h
	chmod +w $QPE/signal.h
	(apply the following diffs)

117c117
< #include <machine/reg.h>
---
> #include "reg.h"

=-=-=-=-=-=-=

	cp /usr/include/setjmp.h $QPE/setjmp.h
	chmod +w $QPE/setjmp.h
	(apply the following diffs)

19c19
< #include <signal.h>
---
> #include "signal.h"

=-=-=-=-=-=-=

	cp /usr/include/sys/param.h $QPE/param.h
	chmod +w $QPE/param.h
	(apply the following diffs)

27c27
< #include <signal.h>
---
> #include "signal.h"

=-=-=-=-=-=-=

	Replace the line
		#include <signal.h>
	with the line
		#include "signal.h"
	in the following files (all in $QPE) --
		Spost.c
		Sprinter.c
		Stek4014.c	(second occurrence only, line 219)
		Stek4105.c	(second occurrence only, line 204)
		audit.c
		comp_util.c
		debug.c
		eval.c
		main.c
		put_data.c
		runit.c
		subset.c
		sys_funs.c

=-=-=-=-=-=-=

	Replace the line
		#include <setjmp.h>
	with the line
		#include "setjmp.h"
	in the following files (all in $QPE) --
		audit.c
		comp_util.c
		eval.c
		main.c
		runit.c

=-=-=-=-=-=-=

	Replace the line
		#include <sys/param.h>
	with the line
		#include "param.h"
	in the following files (all in $QPE) --
		subset.c
		sys_funs.c

=-=-=-=-=-=-=


(9)	File '$QPE/get_data.c' contains an expression that is too complicated
	for the Alliant 'cc' compiler.

=-=-=-=-=-=-=

	cp $QPE/get_data.c $QPE/get_data.c.orig
	(apply the following diff)

1784c1784
<                               for(i=0; i<4 && isdigit((cc=sgetc)) ; i++)
---
>                               for(i=0; i<4 && (cc=sgetc,isdigit(cc)) ; i++)

=-=-=-=-=-=-=


(10)	File '$QPE/sys_funs.c' contains a line of code with several errors.
	This was found when the compiler complained of an integer/pointer
	mismatch.
	This fix was provided by Richard Becker (rab@research.att.com).

=-=-=-=-=-=-=

	cp $QPE/sys_funs.c $QPE/sys_funs.c.orig
	(apply the following diff)

323c323,324
<               return(dmode == DOUBLE || dmode == REAL || DOUBLE == INT);
---
>               return((dmode == DOUBLE || dmode == REAL || dmode == INT) ?
>                       blt_in_TRUE : blt_in_FALSE);

=-=-=-=-=-=-=


(11)	File $QPE/Sprinter.c requires a fix to prevent three extra copies of
	printer plots, rotated about the x axis, from being generated.
	This fix was provided by Allen Mcintosh (mcintosh@flash.bellcore.com).

=-=-=-=-=-=-=

	cp $QPE/Sprinter.c $QPE/Sprinter.c.orig
	(apply the following diff)

201,205c201,207
< {
<       int i;
<       for(i = width-1; i>=0; i--) if(*(p+i) != ' ') break;
<       fprintf(outfile,"%.*s\n", i+1, p);
< }
---
>   {
>       int i;
>       for(i = width-1; i>=0; i--) if(*(p+i) != ' ') break;
>       if( i >= 0 )
>           fwrite(p, sizeof(char), i+1, outfile);
>       putc('\n', outfile);
>   }

=-=-=-=-=-=-=


(12)	The order of type statements is significant to the FX/Fortran compiler,
	and the distributed code has some errors.

=-=-=-=-=-=-=

	cp $QPE/linear.r $QPE/linear.r.orig
	(apply the following diffs)

323c323
< double precision a(p,1),work(1); integer p,jpvt(1),job,info(1)
---
> integer p,jpvt(1),job,info(1); double precision a(p,1),work(1)
2465c2465
< double precision x(p,p),b(p,q); integer p,k,q,info
---
> integer p,k,q,info; double precision x(p,p),b(p,q)

	Additionally, reverse the order of lines 1688 and 1689 from
		integer m(n,p); logical vec(1)
		integer n,p
	to
		integer n,p
		integer m(n,p); logical vec(1)

	and the order of lines 1700 and 1701 from
		integer m(n,p); logical vec(1)
		integer n,p
	to
		integer n,p
		integer m(n,p); logical vec(1)

	(the diffs for these reversals do not make clear what is happening).

=-=-=-=-=-=-=


(13)	C library routine 'memcpy' is not available on the Alliant, so
	references to it must be replace by references to 'bcopy'.

=-=-=-=-=-=-=

	cp $QPE/reverse.c $QPE/reverse.c.orig
	(apply the following diff)

64c64
<       if(i)memcpy(buf + n, buf, i);
---
>       if(i)bcopy(buf, buf + n, i);

=-=-=-=-=-=-=


(14)	The S function 'sum' conflicts with an FX/Fortran intrinsic function of
	the same name.  An 'external' statement will force use of the S routine.

=-=-=-=-=-=-=

	cp $P/rbiwt.r $P/rbiwt.r.orig
	(apply the following diff)

11a12
> external sum

=-=-=-=-=-=-=


(15)	Some routines have type statements 'automatic'; these are not recognized
	by FX/Fortran and must be commented out or simply deleted.

=-=-=-=-=-=-=

	cp $S/gtds.r $S/gtds.r.orig
	(apply the following diff)

7,8d6
< automatic entry, value, p, mode, file, length, nread
< automatic stype, fd2, i, sname, np, tlen, vl, vr

=-=-=-=-=-=-=

	cp $S/ptds.r $S/ptds.r.orig
	(apply the following diff)

7d6
< automatic mode, length, i, nwrite, name, value

=-=-=-=-=-=-=



