	SUBROUTINE DYNAMIC(ADDRESS,NWORDS,DATAFORMAT,ALLOCATE)
C
C  Note:  This is the UNIX version.
C
C       This subroutine performs a dynamic allocation of memory
C  via the malloc C function.
C				Donald H. Gudehus, September 19 1994
C
C	ADDRESS		(R)	The address at which memory is available
C	NWORDS		(C)	The number of words requested
C	DATAFORMAT	(C)	The data format.  This can be I2, I4,
C				R4, or R8.  It is right justified.
C	ALLOCATE	(C)	This is .TRUE. is memory is desired.
C				.FALSE. if memory is being given up.
C
	INTEGER ADDRESS
	CHARACTER*(*) DATAFORMAT
	LOGICAL ALLOCATE  ! If .TRUE. allocate, else deallocate
C
	DECODE (1,1000,DATAFORMAT(4:4)) NBYTES_PER_WORD
1000	FORMAT(I1)
	NBYTES=NBYTES_PER_WORD*NWORDS
	IF (ALLOCATE) THEN
	  CALL DYNAMIC_C(ADDRESS,NBYTES)
	  IF (ADDRESS.EQ.0) THEN
C	    CALL PRTMSG(ISTAT,'F'X)
	    CALL ERROR(-3,'DYNAMIC_C failed in DYNAMIC')
	  END IF
	ELSE
	  CALL RELEASE_MEMORY_C(ADDRESS)
	END IF
C
	RETURN
	END
