
         Program era5

         Parameter(nx=200000)

         Real temp(nx),dp(nx),wb(nx),pres(nx),
     *   wspd(nx),wdir(nx),precip(nx)

         Character*80 infile,outfile

         open(10,file='fileera5',status='unknown')

         read(10,22)infile,outfile
c22      format(a16,1x,a26)
 22      format(a23,1x,a34)

         open(11,file=infile,status='unknown')
         open(20,file=outfile,status='unknown')

         read(11,*)

         k1=1
         do i=1,nx
         read(11,*,err=999,end=999)iyear,mon,iday,
     *   ka,ma,isec,temp(k1),dp(k1),wspd(k1),wdir(k1),
     *   pres(k1),precip(k1)
         if(mon.eq.1)jday=iday
         if(mon.eq.2)jday=iday+31
         if(mon.eq.3)jday=iday+59
         if(mon.eq.4)jday=iday+90
         if(mon.eq.5)jday=iday+120
         if(mon.eq.6)jday=iday+151
         if(mon.eq.7)jday=iday+181
         if(mon.eq.8)jday=iday+212
         if(mon.eq.9)jday=iday+243
         if(mon.eq.10)jday=iday+273
         if(mon.eq.11)jday=iday+304
         if(mon.eq.12)jday=iday+334
         tc=temp(k1)
         dew=dp(k1)
         pmb=pres(k1)
         call wetbulbcal(tc,pmb,dew,wbb,xmin)
         wb(k1)=wbb
         write(20,33,err=999)iyear,jday,ka,wspd(k1),wdir(k1),
     *   temp(k1),wb(k1),dp(k1),pres(k1),precip(k1)
 33      format(3i5,6f10.3,f12.5)
         k1=k1+1
 999     enddo
         k1=k1-1

         print*,k1

         stop
         end
         
     
