Hi all,<br><br>I believe I've found a bug (unbalanced fopen/fclose) in readsac.m.<br><br>When I read in a large number of sac files in Matlab using <span style="font-family: courier new,monospace;">F=readsac(<i>list-of-files-tens-</i><i>long</i>)</span>, Matlab hangs and crashes. I fixed it in sac-101.2/utils/readsac.m by adding an <span style="font-family: courier new,monospace;">fclose</span> statement as follows:<br>
<br>Original (first line is line 243):<br> <span style="font-family: courier new,monospace;"> if ~ismember(B(7), 1:6) % non-native byte order</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> [comp, mxsize, endian] = computer;</span><br>
<br>Changed:<br> <span style="font-family: courier new,monospace;"> if ~ismember(B(7), 1:6) % non-native byte order</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> <b>fclose(fid);</b> % close original 'fid' since we are about to create a new 'fid'</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> [comp, mxsize, endian] = computer;</span><br><br>Without this <span style="font-family: courier new,monospace;">fclose</span>, Matlab opens each file without closing the previous one. I had to make the same change in sac-101.4/utils/readsac.m.<br>
<br><span><span style="background-color: rgb(255, 255, 255);"></span></span><br>Cheers,<br>Warren<br><br>-- <br>~~~~~~~~~~~~~~~~~~~~~~~~~<br>Warren Caldwell<br>Stanford Geophysics<br><a href="http://pangea.stanford.edu/~warrenc">pangea.stanford.edu/~warrenc</a><br>
<br>