From 7b0850f929f449b1d094d887b05f36e30f5b60f9 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 29 Jan 2020 00:10:05 +0100 Subject: [PATCH] only read relevant lines --- src/mesh_FEM.f90 | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/mesh_FEM.f90 b/src/mesh_FEM.f90 index cc3d4c6eb..331ed5edc 100644 --- a/src/mesh_FEM.f90 +++ b/src/mesh_FEM.f90 @@ -119,21 +119,24 @@ subroutine mesh_init if (worldrank == 0) then fileContent = IO_read_ASCII(geometryFile) - j = 0 l = 0 - found = .false. do l = l + 1 - if (IO_isBlank(fileContent(l))) cycle ! need also to ignore C and C++ style comments? - if (trim(fileContent(l)) == '$EndElements') exit - if (trim(fileContent(l)) == '$Elements') found = .true. - if (found) then - chunkPos = IO_stringPos(fileContent(l)) - if (chunkPos(1) == 3+IO_intValue(fileContent(l),chunkPos,3)+dimPlex+1) then - call DMSetLabelValue(globalMesh,'material',j,IO_intValue(fileContent(l),chunkPos,4),ierr) - CHKERRQ(ierr) - j = j + 1 - endif ! count all identifiers to allocate memory and do sanity check + if (IO_isBlank(fileContent(l))) cycle ! need also to ignore C and C++ style comments? + if (trim(fileContent(l)) == '$Elements') then + j = 0 + l = l + 1 + do + l = l + 1 + if (trim(fileContent(l)) == '$EndElements') exit + chunkPos = IO_stringPos(fileContent(l)) + if (chunkPos(1) == 3+IO_intValue(fileContent(l),chunkPos,3)+dimPlex+1) then + call DMSetLabelValue(globalMesh,'material',j,IO_intValue(fileContent(l),chunkPos,4),ierr) + CHKERRQ(ierr) + j = j + 1 + endif + enddo + exit endif enddo call DMClone(globalMesh,geomMesh,ierr)