Skip to content

Commit 60e6168

Browse files
committed
write_group: simplify logic
1 parent 78b9dd6 commit 60e6168

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/write/write.f90

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,25 +123,23 @@
123123
sp = 1
124124
ep = 0
125125

126-
do
126+
grps: do
127127
ep = index(group_path(sp+1:L), "/")
128-
129-
! no subgroup found
130128
if (ep == 0) return
131129

132130
! check subgroup exists
133131
sp = sp + ep
134132
call h5lexists_f(self%file_id, group_path(:sp-1), gexist, ier)
135133
if (ier /= 0) error stop "ERROR:h5fortran:write_group: check exists group " // group_path // " in " // self%filename
136134

137-
if(.not.gexist) then
138-
call h5gcreate_f(self%file_id, group_path(:sp-1), gid, ier)
139-
if (ier /= 0) error stop "ERROR:h5fortran:write_group: create group " // group_path // " in " // self%filename
135+
if(gexist) cycle grps
140136

141-
call h5gclose_f(gid, ier)
142-
if (ier /= 0) error stop "ERROR:h5fortran:write_group: close new group " // group_path // " in " // self%filename
143-
endif
144-
end do
137+
call h5gcreate_f(self%file_id, group_path(:sp-1), gid, ier)
138+
if (ier /= 0) error stop "ERROR:h5fortran:write_group: create group " // group_path // " in " // self%filename
139+
140+
call h5gclose_f(gid, ier)
141+
if (ier /= 0) error stop "ERROR:h5fortran:write_group: close new group " // group_path // " in " // self%filename
142+
end do grps
145143

146144
end procedure write_group
147145

0 commit comments

Comments
 (0)