From 6043e9749af428503f144e070fa6acfa7e567e7a Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Tue, 24 Nov 2015 08:17:00 +0000
Subject: [PATCH] more fixes for 2.2 - this routine should be rewritten to
 simply ignire any fields that it does not need

---
 utils/converters/matlab/load_gmsh2.m | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/utils/converters/matlab/load_gmsh2.m b/utils/converters/matlab/load_gmsh2.m
index 5dba29f48d..b7a98cf08d 100644
--- a/utils/converters/matlab/load_gmsh2.m
+++ b/utils/converters/matlab/load_gmsh2.m
@@ -124,11 +124,7 @@ elseif (strcmp(tline, '$MeshFormat'))
         disp (sprintf('Syntax error (no $EndMeshFormat) in: %s',  filename));
         fileformat = 0;
     end
-    tline = fgetl(fid);    % this should be $Nodes
-    if (feof(fid))
-        disp (sprintf('Syntax error (no $Nodes) in: %s',  filename));
-        fileformat = 0;
-    end
+    tline = fgetl(fid);    % this should be $Nodes or $PhysicalNames
 end
 
 if (~fileformat)
@@ -136,6 +132,16 @@ if (~fileformat)
     return
 end
 
+%% Read (and ignore) physical names
+
+if strcmp(tline, '$PhysicalNames')
+  np = fscanf(fid, '%d', 1);
+  tline = fgetl(fid);
+  for I = 1:np+2
+    tline = fgetl(fid);
+  end
+end
+
 %% Read nodes
 
 if strcmp(tline, '$NOD') || strcmp(tline, '$Nodes')
-- 
GitLab