****************************************************************
                  program hitran_gauss_convert 
****************************************************************
c
c       This program calculates a set of gaussian peaks from 
c       an input file

c	To compile non-graphics programs use : 
c                  gfortran ir_spec.f -o ir_spec 
c
        parameter (n = 240000)
        parameter (m = 100000)
        real*8 w(n), g(n),t(n)
        real*8 w0(m), r(m)
        real*8 sigma, Pi 
        character*40    fname
        character*40    gname
        integer	    i,j,npts
        integer	    icolumn,iostatus 
        integer         cnunit 
        parameter ( cnunit = 10 )
c
      Pi = 3.1415926
c 
      print *,'Input filename:'
      read(5,*) fname
c
      open(unit=cnunit,file=fname,status='old',form='formatted')
   
       print *, 'Enter number of HITRAN data points: '
       read(5, *) npts 

      do i=1,npts
          read(cnunit,*,err=3000) w0(i), r(i) 
          r(i) = r(i)*6.022e19
c           print *, w0(i), r(i)
       end do 
c

        print *, 'Enter Gaussian Variance: '
        read(5, *) sigma
c:        sigma = 0.13
c
         print *,'Enter Output Filename: '
         read(5,*) gname
c
         open(unit=7,file=gname,form='formatted',
     $                            status='new',err=990)
c
      do j=1,240000
        w(j)=j*0.01
        t(j)=0.0
      end do
      do i = 1, npts
         do j = max(1,int(w0(i)*100)-130),min(240000,int(w0(i)*100)+130)
           g(j) = (w(j) - w0(i)) * (w(j) - w0(i)) / (2 * sigma * sigma)
           t(j) = t(j) + r(i) * exp(-g(j)) / sqrt(2 * Pi) / sigma
         end do
      end do
      do j=1,240000
        write(7,210) w(j),t(j)
      end do
210      format(f8.3,' , ',f16.12)
         goto 999
3000      continue
         print *,'Error in input file'
         goto 999
990      continue
         print *,'Error in output file'
999      continue
c
         end

