PRO rmw2wdsk,infile ; This program reformats tidal stage data from the SFPORTS station at Richmond. ; The data is assumed to be in comma-delimted ascii. There are two ; data words: ; word 1: Tidal stage, in m. ; word 2: time in days, PST, with 0.0 = the start of Jan. 1, ; 1970. ; RWB, June 5, 2001. IF n_params() ne 1 THEN BEGIN print,'rmw2wdsk,infile' print,' infile = name of SFPORTS stage values, comma-delimited' print," Example: rmw2wdsk,'/d4/Darmat/data/naut/tid/2000/11/asd01112.rmw'" RETURN ENDIF outfile=strmid(infile,0,strlen(infile)-12)+'arr'+strmid(infile, $ strlen(infile)-9,9); files for IDL arrays have names starting with arr. print,'infile = ',infile print,'outfile = ',outfile npts=10000; 30 days at one observation every six min. gives 7200. h=fltarr(npts) t=dblarr(npts) str1='' openr,lunin,infile,'r',/get_lun idat=0 WHILE not eof(lunin) DO BEGIN readf,lunin,str1 ; print,'str1 = ',str1 split,str1,',',nstr,strings ; print,'nstr, strings = ',nstr,strings ; print,'n_elements(strings) = ',n_elements(strings) IF n_elements(strings) ne 2 THEN BEGIN print,"String with the wrong number of data strings." RETURN ENDIF h(idat)=float(strings(0)) t(idat)=double(strings(1)) idat=idat+1 ENDWHILE ndat=idat close,lunin h=h(0:ndat-1); Truncate the stage array. t=t(0:ndat-1); Truncate the time array. ;***** Set bad data equal to zero.***** FOR id=0,ndat-1 DO IF h(id) eq 999.99 THEN h(id)=0 wdsk,h,outfile,1,/new wdsk,t,outfile,2 END