	PROGRAM READSOUND
C
C  ***     THIS PROGRAM READS A SOUNDING INTO A FILE WHICH   ***
C  ***            CAN THEN BE READ BY OTHER ROUTINES         ***
C
	PARAMETER (NA=60)
	DIMENSION P(NA),R(NA),T(NA)
	CHARACTER*4 WV
	OPEN(UNIT=12,FILE='sounding',STATUS='NEW')
	PRINT *,'Do you wish to enter mixing ratios,'
        PRINT *,'relative humidities, or dewpoints? '
        PRINT *, '(Enter mr, rh, or dp)'                
	READ (*,12) WV
   12	FORMAT(A2)
	IF(WV.EQ.'MR')WV='mr'
	IF(WV.EQ.'RH')WV='rh'
	IF(WV.EQ.'DP')WV='dp'
	IF(WV.EQ.'dp')THEN
	 DO 50 I=1,NA
	  PRINT *,'Enter p (mb), T (C), Td (C) (0,0,0 to stop)'
	  READ *,P1,T1,TD1
	  IF(P1.LT.1.0)GOTO 60
	  P(I)=P1
	  T(I)=T1
	  ES=6.112*EXP(17.67*TD1/(243.5+TD1))
	  R(I)=622.0*ES/(P1-ES)
	  N=I
   50	 CONTINUE
   60	 CONTINUE
	ELSE IF(WV.EQ.'rh')THEN
	 DO 100 I=1,NA
	  PRINT *, 'Enter p (mb), T (C), RH (%) (0,0,0 to stop)'
	  READ *, P1,T1,RH
	  IF(P1.LT.1.0)GOTO 110
	  P(I)=P1
	  T(I)=T1
	  ES=6.112*EXP(17.67*T1/(243.5+T1))
	  ER=0.01*RH*ES
	  R(I)=622.0*ER/(P1-ER)
	  N=I
  100	CONTINUE
  110	CONTINUE
	ELSE IF(WV.EQ.'mr')THEN
	 DO 150 I=1,NA
	  PRINT *, 'Enter p(mb), T (C), mr (g/kg) (0,0,0 to stop)'
	  READ *, P1,T1,RR
	  IF(P1.LT.1.0)GOTO 160
	  P(I)=P1
	  T(I)=T1
	  R(I)=RR
	  N=I
  150	CONTINUE
  160	CONTINUE
	END IF	
	WRITE(12,200)N
  200	FORMAT(2X,'N=',I3)
        WRITE(12,250)
  250   FORMAT(3X,'Pressure (mb)',5X,'Temperature (C)',5X,
     1    'Mixing Ratio (g/kg)')
	WRITE(12,300)
  300   FORMAT(3X,'-------------',5X,'---------------',5X,
     1   '-------------------')
	DO 400 I=1,N
	WRITE(12,350)P(I),T(I),R(I)
  350	FORMAT(5X,F9.3,8X, F9.3,12X,F9.3)
  400	CONTINUE
	CLOSE(UNIT=12,DISPOSE='SAVE')
	STOP
	END
