[cig-commits] r19641 - seismo/3D/FAULT_SOURCE/branches/new_fault_db/utils

ampuero at geodynamics.org ampuero at geodynamics.org
Wed Feb 15 21:45:46 PST 2012


Author: ampuero
Date: 2012-02-15 21:45:45 -0800 (Wed, 15 Feb 2012)
New Revision: 19641

Modified:
   seismo/3D/FAULT_SOURCE/branches/new_fault_db/utils/FSEM3D_read_fault_nodes.m
Log:
fixed fault node reader

Modified: seismo/3D/FAULT_SOURCE/branches/new_fault_db/utils/FSEM3D_read_fault_nodes.m
===================================================================
--- seismo/3D/FAULT_SOURCE/branches/new_fault_db/utils/FSEM3D_read_fault_nodes.m	2012-02-16 01:36:53 UTC (rev 19640)
+++ seismo/3D/FAULT_SOURCE/branches/new_fault_db/utils/FSEM3D_read_fault_nodes.m	2012-02-16 05:45:45 UTC (rev 19641)
@@ -11,24 +11,28 @@
 
 function xyz = FSEM3D_snapshot(filename,NGLL)
 
+SINGLE = 4; % number of bytes per single real
+NINT = 1; % number of single words per integer
+
 if ~exist(filename,'file'), error(sprintf('File %s does not exist',filename)), end
+
 fid=fopen(filename);
-BinRead = fread(fid,[1,inf],'single')' ;
-fclose(fid);
+fseek(fid,SINGLE,-1);
+nfaults = fread(fid,1,'int');
+fseek(fid,2*SINGLE,0);
+nspec = fread(fid,1,'int');
+nglob = fread(fid,1,'int');
+fseek(fid,(1+(2+NGLL^2*nspec*NINT)*2 + 2+NGLL^2*nspec*3 + (2+NINT*nglob)*2 +1)*SINGLE,0);
 
-nspec = BinRead(2);
-nglob = BinRead(3);
+xyz(:,1) = fread(fid,nglob,'single') ;
+fseek(fid,2*SINGLE,0);
 
-NINT = 1; % number of single words (4 bytes) per integer
+xyz(:,2) = fread(fid,nglob,'single') ;
+fseek(fid,2*SINGLE,0);
 
-N1 = 2+2*NINT + (2+NGLL^2*nspec*NINT)*2 + 2+NGLL^2*nspec*3 + (2+NINT*nglob)*2 +1;
-xyz(:,1) = BinRead(N1+1:N1+nglob);
-N1 = N1+nglob+2;
-xyz(:,2) = BinRead(N1+1:N1+nglob);
-N1 = N1+nglob+2;
-xyz(:,3) = BinRead(N1+1:N1+nglob);
+xyz(:,3) = fread(fid,nglob,'single') ;
+fseek(fid,SINGLE,0)
 
-clear BinRead
+fclose(fid);
 
-
 return



More information about the CIG-COMMITS mailing list