      PROGRAM GET_NETCDF
      CHARACTER TARNAME*27,WFILENAMEPREFIX*13,WFILENAME*20
      CHARACTER PATHSTRING*80,BINDIR*80,FORMATBIN*80
      CALL GETARG(1,BINDIR)
      IBINDIR=LEN_TRIM(BINDIR)
      OPEN(80,FILE='listanalysis.tars')
      OPEN(81,FILE='tarscript')
      OPEN(82,FILE='infilelist')
      WRITE(81,'("rm infilelist")')
      WRITE(81,'(A)')'rm jobfile* infile* outfile* azi*'
 1    READ(80,100,END=999)TARNAME
 100  FORMAT(A27)
      WRITE(81,200)TARNAME
 200  FORMAT('tar xvf ',A27,'.tar jobfile_radar.gz')
      WRITE(81,210)TARNAME
 210  FORMAT('tar xvf ',A27,'.tar jobfile_radar_profile_in.gz')
      WRITE(81,220)TARNAME
 220  FORMAT('tar xvf ',A27,'.tar jobfile_radar_profile_out.gz')
      WRITE(81,230)TARNAME
 230  FORMAT('tar xvf ',A27,'.tar infiles*')
      WRITE(81,240)TARNAME
c      TESTSTRING='sed -n 2p infiles > infiletest'
c      STATUS=SYSTEM(TESTSTRING)
      READ(82,'(A13)')WFILENAMEPREFIX
c      CLOSE(82)
 240  FORMAT('tar xvf ',A27,'.tar outfiles*')
      WRITE(81,250)TARNAME
 250  FORMAT('tar xvf ',A27,'.tar azirad*')
      WRITE(81,'(A)')'gunzip -f jobfile*gz'
      WRITE(81,'(A)')'gunzip -f azirad*gz'
      WRITE(81,249)WFILENAMEPREFIX
 249  FORMAT('while [ ! -f ./',A13,'_xy_rel.w.gz ]; do sleep 60; done')
      WRITE(81,251)WFILENAMEPREFIX
 251  FORMAT('gunzip -f ',A13,'*.w.gz')
      IF(IBINDIR.LT.10)THEN
         WRITE(FORMATBIN,252)IBINDIR
 252     FORMAT("(A",I1,",'windtonetcdf')")
         WRITE(81,FORMATBIN)BINDIR
         WRITE(FORMATBIN,253)IBINDIR
 253     FORMAT("(A",I1,",'profiletonetcdf')")
         WRITE(81,FORMATBIN)BINDIR
      ELSE
         WRITE(FORMATBIN,254)IBINDIR
 254     FORMAT("(A",I2,",'windtonetcdf')")
         WRITE(81,FORMATBIN)BINDIR
         WRITE(FORMATBIN,255)IBINDIR
 255     FORMAT("(A",I2,",'profiletonetcdf')")
         WRITE(81,FORMATBIN)BINDIR
      ENDIF
C      WRITE(81,'(A)')
C     +'/home/hrd/transferscriptsource/windtonetcdf'
C      WRITE(81,'(A)')
C     +'/home/hrd/transferscriptsource/profiletonetcdf'
      WRITE(81,'(A)')'rm jobfile* infile* outfile* azi*'
      WRITE(81,'("gzip -f *.w")')
      WRITE(81,'("gzip -f *.nc")')
      WRITE(81,'(A)')
      GO TO 1
 999  CLOSE(80)
      CLOSE(81)
      STOP
      END
