	SUBROUTINE FXRLD(LOG2N,L2REM,ISGN,IFORM,WORK,L2NEL,NELEM,
     *  NRECT)
C	FOR IFORM = 0, CONVERT THE TRANSFORM OF A DOUBLED-UP REAL ARRAY,
C	CONSIDERED COMPLEX, INTO ITS TRUE TRANSFORM.  SUPPLY ONLY THE
C	FIRST HALF OF THE COMPLEX TRANSFORM, AS THE SECOND HALF HAS
C	CONJUGATE SYMMETRY.  FOR IFORM = -1, CONVERT THE FIRST HALF
C	OF THE TRUE TRANSFORM INTO THE TRANSFORM OF A DOUBLED-UP REAL
C	ARRAY.  LET N = 2**LOG2N AND NREM = 2**L2REM.  THEN
C	USING COMPLEX NOTATION AND SUBSCRIPTS STARTING AT ZERO, THE
C	TRANSFORMATION IS--
C	DIMENSION DATA(N/2,NREM)
C	ZSTP = EXP(ISGN*2*PI*I/N)
C	DO 10 I2=0,NREM-1
C	DATA(0,I2) = CONJ(DATA(0,I2))*(1+I)
C	DO 10 I1=1,N/4
C	Z = (1+(2*IFORM+1)*I*ZSTP**I1)/2
C	I1CNJ = N/2-I1
C	DIF = DATA(I1,I2)-CONJ(DATA(I1CNJ,I2))
C	TEMP = Z*DIF
C	DATA(I1,I2) = (DATA(I1,I2)-TEMP)*(1-IFORM)
C 10  DATA(I1CNJ,I2) = (DATA(I1CNJ,I2)+CONJ(TEMP))*(1-IFORM)
C	IF I1=I1CNJ, THE CALCULATION FOR THAT VALUE COLLAPSES INTO
C	A SIMPLE CONJUGATION OF DATA(I1,I2).
CC	DIMENSION WORK(1)
	DIMENSION WORK(*)


	IP0=2
	NWORD=IP0*NELEM
	NWORD1=NWORD+1
	IF (LOG2N-L2NEL-1) 10,20,20
10	I1STP=IP0*2**(LOG2N-1)
	IRSTP=1
	GO TO 30
20	I1STP=NWORD
	IRSTP=2**(LOG2N-L2NEL-1)
30	IF (IFORM) 40,100,100
C	PACK THE N/2+1'ST ROW INTO THE 1'ST ROW.
40	IRECB=NRECT+1
	I2=NWORD1
	DO 90 IRECA=1,NRECT,IRSTP
	CALL DREAD(IRECA,WORK,1,NELEM)
	IF (I2-NWORD1) 50,50,60
50	CALL DREAD(IRECB,WORK(NWORD1),1,NELEM)
60	DO 70 I1=1,NWORD,I1STP
	WORK(I1+1)=WORK(I2)
70	I2=I2+IP0
	CALL DWRITE(IRECA,WORK,1,NELEM)
	IF (I2-2*NWORD-1) 90,80,80
80	IRECB=IRECB+1
	I2=NWORD1
90	CONTINUE
100	THETA=6.2831853071795865D0*DBLE(ISGN)/DBLE(2.**LOG2N)
	SINTH=SIN(THETA/2.)
	ZSTPR=-2.*SINTH*SINTH
	ZSTPI=SIN(THETA)
	IF (L2NEL+2-LOG2N) 110,250,250
C
C	2*NELEM IS LESS THAN N/2.  EFFECTIVELY WE HAVE
C	DIMENSION DATA(NELEM,(N/2)/NELEM,NREM)
110	DO 240 IRMIN=1,NRECT,IRSTP
	IRECA=IRMIN
	IRECB=IRMIN+IRSTP-1
	CALL DREAD(IRECA,WORK,1,NELEM)
	CALL DREAD(IRECB,WORK(NWORD1),1,NELEM)
	TEMPR=WORK(1)
	WORK(1)=WORK(1)+WORK(2)
	WORK(2)=TEMPR-WORK(2)
	I2=IP0+1
	I2CNJ=2*NWORD-IP0+1
	ZR=(1.-ZSTPI)/2.
	ZI=(1.+ZSTPR)/2.
	IF (IFORM) 120,170,170
120	ZR=1.-ZR
	ZI=-ZI
	GO TO 170
130	DIFR=WORK(I2)-WORK(I2CNJ)
	DIFI=WORK(I2+1)+WORK(I2CNJ+1)
	TEMPR=DIFR*ZR-DIFI*ZI
	TEMPI=DIFR*ZI+DIFI*ZR
	WORK(I2)=WORK(I2)-TEMPR
	WORK(I2+1)=WORK(I2+1)-TEMPI
	WORK(I2CNJ)=WORK(I2CNJ)+TEMPR
	WORK(I2CNJ+1)=WORK(I2CNJ+1)-TEMPI
	IF (IFORM) 140,150,150
140	WORK(I2)=WORK(I2)+WORK(I2)
	WORK(I2+1)=WORK(I2+1)+WORK(I2+1)
	WORK(I2CNJ)=WORK(I2CNJ)+WORK(I2CNJ)
	WORK(I2CNJ+1)=WORK(I2CNJ+1)+WORK(I2CNJ+1)
150	TEMP=ZR-.5
	ZR=ZSTPR*TEMP-ZSTPI*ZI+ZR
	ZI=ZSTPR*ZI+ZSTPI*TEMP+ZI
C	OMIT THE NEXT THREE CARDS IF ROUNDED ARITHMETIC IS USED.
	FACTR=1.5-2.*((ZR-.5)*(ZR-.5)+ZI*ZI)
	ZR=.5+(ZR-.5)*FACTR
	ZI=ZI*FACTR
	I2=I2+IP0
	I2CNJ=I2CNJ-IP0
	IF (I2-IP0-1) 160,160,170
160	CALL DWRITE(IRECB,WORK(NWORD1),1,NELEM)
	IRECB=IRECB-1
	CALL DREAD(IRECB,WORK(NWORD1),1,NELEM)
	I2CNJ=2*NWORD-IP0+1
170	IF (I2CNJ-NWORD1) 180,180,130
180	IF (IRECA-IRECB+1) 190,200,200
190	CALL DWRITE(IRECA,WORK,1,NELEM)
	IRECA=IRECA+1
	CALL DREAD(IRECA,WORK,1,NELEM)
	I2=1
	GO TO 130
200	IF (ISGN*(2*IFORM+1)) 210,220,220
210	WORK(I2CNJ+1)=-WORK(I2CNJ+1)
220	IF (IFORM) 230,240,240
230	WORK(I2CNJ)=WORK(I2CNJ)+WORK(I2CNJ)
	WORK(I2CNJ+1)=WORK(I2CNJ+1)+WORK(I2CNJ+1)
240	CALL DWRITE(IRECA,WORK,2,NELEM)
	GO TO 390
C
C	2*NELEM IS GREATER THAN OR EQUAL THAN N/2.  EFFECTIVELY
C	DIMENSION DATA(N/2,(2*NELEM)/(N/2),NREM)
250	IP1=IP0*2**(LOG2N-1)
	IP2=2*NWORD
	DO 380 IREC=1,NRECT,2
	CALL DREAD(IREC,WORK,2,NELEM)
	ZR=.5
	ZI=.5
	IF (IFORM) 260,270,270
260	ZI=-ZI
270	I1MAX=IP1/2+1
	DO 370 I1=1,I1MAX,IP0
	I2CNJ=IP1+2-I1
	DO 360 I2=I1,IP2,IP1
	IF (I1-1) 280,280,290
280	TEMPR=WORK(I2)
	WORK(I2)=WORK(I2)+WORK(I2+1)
	WORK(I2+1)=TEMPR-WORK(I2+1)
	GO TO 360
290	IF (I2-I2CNJ) 330,300,300
300	IF (ISGN*(2*IFORM+1)) 310,320,320
310	WORK(I2CNJ+1)=-WORK(I2CNJ+1)
320	IF (IFORM) 350,360,360
330	DIFR=WORK(I2)-WORK(I2CNJ)
	DIFI=WORK(I2+1)+WORK(I2CNJ+1)
	TEMPR=DIFR*ZR-DIFI*ZI
	TEMPI=DIFR*ZI+DIFI*ZR
	WORK(I2)=WORK(I2)-TEMPR
	WORK(I2+1)=WORK(I2+1)-TEMPI
	WORK(I2CNJ)=WORK(I2CNJ)+TEMPR
	WORK(I2CNJ+1)=WORK(I2CNJ+1)-TEMPI
	IF (IFORM) 340,360,360
340	WORK(I2)=WORK(I2)+WORK(I2)
	WORK(I2+1)=WORK(I2+1)+WORK(I2+1)
350	WORK(I2CNJ)=WORK(I2CNJ)+WORK(I2CNJ)
	WORK(I2CNJ+1)=WORK(I2CNJ+1)+WORK(I2CNJ+1)
360	I2CNJ=I2CNJ+IP1
	TEMP=ZR-.5
	ZR=ZSTPR*TEMP-ZSTPI*ZI+ZR
	ZI=ZSTPR*ZI+ZSTPI*TEMP+ZI
C	OMIT THE NEXT THREE CARDS IF ROUNDED ARITHMETIC IS USED.
	FACTR=1.5-2.*((ZR-.5)*(ZR-.5)+ZI*ZI)
	ZR=.5+(ZR-.5)*FACTR
370	ZI=ZI*FACTR
380	CALL DWRITE(IREC,WORK,2,NELEM)
390	IF (IFORM) 450,400,400
C	UNPACK THE N/2+1'ST ROW FROM THE 1'ST ROW.
400	IRECB=NRECT+1
	I2=NWORD1
	DO 430 IRECA=1,NRECT,IRSTP
	CALL DREAD(IRECA,WORK,1,NELEM)
	DO 410 I1=1,NWORD,I1STP
	WORK(I2)=WORK(I1+1)
	WORK(I2+1)=0.
	WORK(I1+1)=0.
410	I2=I2+IP0
	CALL DWRITE(IRECA,WORK,1,NELEM)
	IF (I2-2*NWORD-1) 430,420,420
420	CALL DWRITE(IRECB,WORK(NWORD1),1,NELEM)
	IRECB=IRECB+1
	I2=NWORD1
430	CONTINUE
	IF (I2-NWORD1) 450,450,440
440	CALL DWRITE(IRECB,WORK(NWORD1),1,NELEM)
450	RETURN
	END
