!************************************
!***CSV File of Basic Data/Results***
!************************************
	SUBROUTINE CSVFILE()
	USE WINTERACTER
	USE RESOURCE
	USE SHAREDVARS
	INTEGER IPARM,IPLOT,IDAT,LENGTH
	CALL WSELECTFILE('',0,OUTFILE,'CSV FILE SELECT')
	OPEN(UNIT=2,FILE=OUTFILE,STATUS='REPLACE')
	LENGTH=LEN(TRIM(HEADERSTRING))
	WRITE(2,"('''',A<LENGTH>,'''')") HEADERSTRING
	WRITE(2,"('PARAMETER VALUES AND ECP CLS')")
	DO IPARM=1,NPARM
		IF(IPARM.EQ.2) THEN
			WRITE(2,"('''',A7,'''',',',F10.5,',',F10.5,',',F10.5)") PARMNAME(IPARM,MODELOPT),PARMSOLUT(IPARM),PARMLCL,PARMUCL
		ELSE
			WRITE(2,"('''',A7,'''',',',F10.5,',',F10.5,',',F10.5)") PARMNAME(IPARM,MODELOPT),PARMSOLUT(IPARM)
		ENDIF
	ENDDO
	WRITE(2,"('INDIVIDUAL DATA')")
	IDAT=0
	DO IPLOT=1,NPLOT
		IDAT=IDAT+1			
		WRITE(2,"(F10.3,',',I8,',',I6,',',I6,',',F10.3)") XPLOT(IPLOT),NINT(YPLOT(IPLOT)*MPLOT(IPLOT)),NINT(MPLOT(IPLOT)),CPLOT(IPLOT),YPLOT(IPLOT)
	ENDDO
	CLOSE(UNIT=2)
	END SUBROUTINE CSVFILE
