	PROGRAM PARAMETER
C***************************************************************************
C
C 	 This program creates a file of parameters, prompting the user for
C   values and indicating default values as well. 
C
C***************************************************************************
	CHARACTER*1 RADINT, TDEP, DDEP, VCUBE, TSINT, ANRAD, DARAD
	REAL HOUR, HOURD
C
C  Open the output file     
C
	OPEN(UNIT=8, FILE='params.in', STATUS='UNKNOWN')
C
C  Define the default values
C
C  Radiation parameters:
C
	SCOND=1382.0
	RLATD=10.0
	MONTHD=1
	IDAYD=1
	HOURD=12.0
	COSZD=0.46
	ALBD=0.32
	CO2D=330.0
C
C  Vertical velocity parameters:
C
	PERIODD=2000.0
	VMAXD=0.0    
	PVZEROD=150.0
	PVMAXD=600.0
C
C  Ocean mixed layer parameters
C
	DEPTHD=1.0
	VSURFD=7.0
C
C  Computational parameters:
C
	PFIXD=0.0
	DTD=10.0
	ENDTIMED=100.0
	AVTIMED=2.0
	RADFREQD=24.0
	PRINFREQD=24.0	
C
C  Ask for parameter values:
C
	PRINT*, 'Do you want interactive radiation? (y or n)'
	READ(*,4) RADINT
    4	FORMAT(A1)
	IF(RADINT.EQ.'n'.OR.RADINT.EQ.'N')THEN
	 TSINT='n'
	 TDEP='n'
	 DARAD='n'
	 ANRAD='n'
	 DDEP='n'
	 GOTO 5
	END IF
	PRINT*, 'Do you want interactive sea surface temperature? (y or n)'
	READ(*,4) TSINT	
	PRINT*, 'Do you want to use annual average radiation? (y or n)'
	READ(*,4) ANRAD
	IF(ANRAD.EQ.'y'.OR.ANRAD.EQ.'Y')THEN
         TDEP='n'
	 DDEP='n'
	 DARAD='n'
	 GOTO 5
	END IF
	PRINT*, 'Do you want the radiation to vary with date? (y or n)'
	PRINT*, '(if y, the date will advance and the radiation will'
	PRINT*,  '      vary accordingly)'
	READ(*,4)DDEP
	PRINT*, 'Do you want to use diurnally-averaged radiation? (y or n)'
	READ(*,4) DARAD
	IF(DARAD.EQ.'y'.OR.DARAD.EQ.'Y')THEN  
         TDEP='n'
         GOTO 5
	END IF
	PRINT*, 'Do you want time-dependent solar zenith angle? (y or n)'
	PRINT*, '(if y, angle is calculated as a function of the time of day)'
	READ(*,4) TDEP
    5	CONTINUE	
	PRINT*, 'Do you want to use a cubic profile of omega? (y or n)'
	PRINT*, '(if not, profile of omega read in from sounding file)'
	READ(*,4) VCUBE
	PRINT*, ' '
	PRINT*, ' '
	PRINT*, 'In the following, enter zero if default value is desired'
	PRINT*, ' '
	IF(RADINT.EQ.'n'.OR.RADINT.EQ.'N')THEN
	 SCON=SCOND
	 RLAT=RLATD
	 MONTH=MONTHD
	 IDAY=IDAYD
	 HOUR=HOURD
	 COSZ=COSZD
	 ALB=ALBD
	 CO2=CO2D
	 GOTO 7 
	END IF
	PRINT*, 'Enter solar constant (w/m^2; default value is 1382.0)'
	READ*, SCON
	RLAT=RLATD
	MONTH=MONTHD
	IDAY=IDAYD
	HOUR=HOURD
	COSZ=COSZD
	PRINT*, 'Enter latitude (degrees; default value is 10.0)'
	READ*, RLAT
	IF(ANRAD.EQ.'n'.OR.ANRAD.EQ.'N')THEN
	 PRINT*, '(The following parameters are interpreted as the'
	 PRINT*, '  starting time if the radiation varies with date)'
	 PRINT*, ' '
	 PRINT*, 'Enter month (1-12; default value is 1)'
	 READ*, MONTH
	 PRINT*, 'Enter starting day of month (1-31; default is 1)'
	 READ*, IDAY
	 IF(DARAD.EQ.'n'.OR.DARAD.EQ.'N')THEN
	  PRINT*, 'Enter starting hour of day (1-24; default is 12.0)'
	  READ*, HOUR
	  IF(TDEP.EQ.'n'.OR.TDEP.EQ.'N')THEN
	   PRINT*, 'Enter cosine of solar zenith angle (default=0.460)'
	   READ*, COSZ
	  END IF
	 END IF
	END IF
	PRINT*, 'Enter albedo (default value is 0.320)'
	READ*, ALB
	PRINT*, 'Enter amount of CO2 in ppm'                     
	PRINT*, '   (default value is 330.0)'
	READ*, CO2
    7	CONTINUE
	PRINT*, 'Enter ocean mixed layer depth (m; default is 1.0)'
	READ *, DEPTH
	PRINT *, 'Enter surface wind speed (m/s; default is 7.0)'
	READ*, VSURF
	IF(VCUBE.EQ.'n'.OR.VCUBE.EQ.'N')THEN
	 PERIOD=PERIODD
	 VMAX=VMAXD
	 PVZERO=PVZEROD
	 PVMAX=PVMAXD
	 GOTO 8
	END IF
	PRINT*, 'Enter period of oscillation of omega (days);'
	PRINT*, '   (default value is 2000.0; if greater than 1000'
	PRINT*, '    omega will be steady)'
	READ*, PERIOD
	PRINT*, 'Enter extreme value of omega (mb/hr; default is 0.0);'
	PRINT*, '  (used only if sine profile is chosen)'
	READ*, VMAX
	PRINT*, 'Enter pressure at which omega goes to zero (mb; default'
	PRINT*, '   value is 150.0; used only when sine profile chosen)'
	READ*, PVZERO
	PRINT*, 'Enter pressure at which omega has extreme value (mb;'
	PRINT*, '  Default is 600.0; used only when sine profile chosen)'
	READ*, PVMAX
    8	CONTINUE
	PRINT*, 'Enter pressure level above which sounding is fixed'
	PRINT*, '  at its initial value (mb; default value is 0.0)'
	READ*, PFIX
	PRINT*, 'Enter time step (minutes; default value is 10.0)'
	READ*, DT
	PRINT*, 'Enter end time (days; default value is 100.0)'
	READ*, ENDTIME
	PRINT*, 'Enter period over which to average certain graphic'
	PRINT*, '  variables at the end of the integration (days;'
	PRINT*, '   default value is 2.0)'
	READ*, AVTIME  
	IF(RADINT.EQ.'n'.OR. RADINT.EQ.'N')THEN
	 RADFREQ=RADFREQD
	 GOTO 11
	END IF
	PRINT*, 'Enter frequency with with radiation is calculated (hrs;'
	PRINT*, '   default value is 24.0)'
	READ*, RADFREQ
   11	CONTINUE
	PRINT*, 'Enter frequency of output of certain time-dependent'
	PRINT*, '  graphic variables (hrs; default value is 24.0)'
	PRINT*, '  (Note that total number of values must not exceed'
	PRINT*, '  the value of parameter NTIME)'
	READ*, PRINFREQ
C
C  If parameter is zero, set it equal to the default value
C
	IF(SCON.EQ.0)SCON=SCOND
	IF(RLAT.EQ.0)RLAT=RLATD
	IF(MONTH.EQ.0)MONTH=MONTHD
	IF(IDAY.EQ.0)IDAY=IDAYD
	IF(HOUR.EQ.0)HOUR=HOURD
	IF(COSZ.EQ.0)COSZ=COSZD
	IF(ALB.EQ.0)ALB=ALBD
	IF(CO2.EQ.0)CO2=CO2D
	IF(DEPTH.EQ.0)DEPTH=DEPTHD
	IF(VSURF.EQ.0)VSURF=VSURFD
	IF(PERIOD.EQ.0)PERIOD=PERIODD
	IF(VMAX.EQ.0)VMAX=VMAXD
	IF(PVZERO.EQ.0)PVZERO=PVZEROD
	IF(PVMAX.EQ.0)PVMAX=PVMAXD
	IF(PFIX.EQ.0)PFIX=PFIXD
	IF(DT.EQ.0)DT=DTD
	IF(ENDTIME.EQ.0)ENDTIME=ENDTIMED
	IF(AVTIME.EQ.0)AVTIME=AVTIMED
	IF(RADFREQ.EQ.0)RADFREQ=RADFREQD
	IF(PRINFREQ.EQ.0)PRINFREQ=PRINFREQD
C
C  Make sure AVTIME is equal to a period if latter is finite
C
	IF(PERIOD.LT.1000.0)AVTIME=PERIOD
C
C  Make sure that PVZERO is in troposphere
C
	PVZERO=MAX(PVZERO,100.0)
C
C  Write values to file
C
	WRITE(8,10)
   10	FORMAT(2X, 'Parameter',T35, 'Value',T50, 'Units')
	WRITE(8,20)
   20	FORMAT(2X, '---------',T35, '-----',T50, '-----')
	WRITE(8,30)RADINT
   30	FORMAT(2X, 'Interactive radiation?',T37, A1)
	WRITE(8,40)TSINT
   40	FORMAT(2X,'Interactive surface temp?',T37, A1)
	WRITE(8,45)SCON
   45	FORMAT(2X,'Solar constant',T32, F12.6,T50,'watts/m^2')
	WRITE(8,50)RLAT
   50	FORMAT(2X,'Latitude',T32, F12.6,T50, 'degrees')
	WRITE(8,60)MONTH
   60	FORMAT(2X,'Month',T32, I6)
	WRITE(8,70)IDAY
   70	FORMAT(2X,'Starting day',T32, I6,T50, 'days')
	WRITE(8,80)HOUR
   80	FORMAT(2X, 'Starting hour',T32, F12.6,T50, '1-24')
	WRITE(8,90)TDEP
   90	FORMAT(2X,'Time-dependent radiation?',T37, A1)
	WRITE(8,95)DDEP
   95	FORMAT(2X,'Date-dependent radiation?',T37, A1)
	WRITE(8,96)DARAD
   96   FORMAT(2X,'Diurnal-average radiation?',T37, A1)
	WRITE(8,97)ANRAD
   97   FORMAT(2X,'Annual-average radiation?',T37, A1)
	WRITE(8,100)COSZ
  100	FORMAT(2X,'Cosine of sol. zen. ang.',T32, F12.6)
	WRITE(8,110)ALB
  110	FORMAT(2X,'Surface albedo', T32, F12.6)
	WRITE(8,120)CO2
  120	FORMAT(2X,'Amount of CO2', T32, F12.6, T50, 'ppm')
	WRITE(8,162)DEPTH
  162	FORMAT(2X, 'Mixed layer depth', T32, F12.6, T50, 'm')
	WRITE(8,163)VSURF
  163	FORMAT(2X, 'Surface wind speed', T32, F12.6, T50, 'm/s')
	WRITE(8,165)VCUBE
  165	FORMAT(2X,'Cubic profile of omega?',T37,A1)
  	WRITE(8,170)PERIOD
  170	FORMAT(2X, 'Period of omega', T32, F12.6, T50, 'days')
	WRITE(8,180)VMAX
  180	FORMAT(2X, 'Extreme value of omega', T32, F12.6, T50,'mb/hour')
	WRITE(8,190)PVZERO
  190	FORMAT(2X,'P at which omega=0', T32, F12.6, T50,'mb')
	WRITE(8,200)PVMAX
  200	FORMAT(2X,'P at which omega=extr. value',T32, F12.6,T50,'mb')
	WRITE(8,210)PFIX
  210   FORMAT(2X,'P above which sndg. fixed',T32,F12.6,T50,'mb')
	WRITE(8,220)DT
  220	FORMAT(2X,'Time step', T32, F12.6, T50, 'minutes')
	WRITE(8,230)ENDTIME
  230	FORMAT(2X,'End time of integration', T32, F12.6,T50,'days')
	WRITE(8,240)AVTIME
  240	FORMAT(2X, 'Graphics averaging time',T32,F12.6,T50,'days')
	WRITE(8,250)RADFREQ
  250	FORMAT(2X,'Frequency of radiation calls',T32,F12.6,T50,'hours')
	WRITE(8,260)PRINFREQ
  260	FORMAT(2X,'Frequency of graphics output',T32,F12.6,T50,'hours')
C
C
	CLOSE(UNIT=8,DISPOSE='SAVE')
	STOP
	END
