; ; file_check.pro checks to see if a netcdf file other than the netcdf file being created ; exists in the program directory, and returns the name of the netcdf file. ; pro file_check_all,file_exists,filename,armfile ; ; Create a list of cdf files in the current directory ; unix_command='ls '+armfile+' > cdf_files.dat' spawn,unix_command ; ; Wordcount the list of cdf files and direct the output to a file ; spawn,'wc -l cdf_files.dat > num_cdf_files.dat' ; ; Get the number of cdf files in the directory from the wordcount output ; num_cdf_files=' ' openr,50,'num_cdf_files.dat' readf,50,num_cdf_files close,50 nums=strsplit(num_cdf_files,/extract) num = nums[0] ; ; Determine if the cdf file exists. If it exists, then ; get the name and send it back to the main program. ; If there are two files for the same data, then chose the ; first one. No real reason for this decision. if num ge 1 then begin file_exists='yes' filenames=strarr(num) openr,60,'cdf_files.dat' readf,60,filenames close,60 filename=filenames[0] if num gt 1 then begin for i=1,num-1 do begin unix_command='rm '+filenames[i] endfor endif endif else if num lt 1 then file_exists='no' return end