MOVE a locally-built group into the schema — g is consumed
(allocatables transferred). Move semantics on purpose: intrinsic
assignment deep-copies the polymorphic key boxes, which NVHPC
miscompiles (heap corruption); move_alloc transfers descriptors
only. Error stop on duplicate name.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(nml_schema_t), | intent(inout) | :: | this | |||
| type(nml_group_t), | intent(inout) | :: | g |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | i | ||||
| integer, | private | :: | n | ||||
| type(nml_group_t), | private, | allocatable | :: | tmp(:) |
subroutine schema_add_group(this, g) !! MOVE a locally-built group into the schema — `g` is consumed !! (allocatables transferred). Move semantics on purpose: intrinsic !! assignment deep-copies the polymorphic key boxes, which NVHPC !! miscompiles (heap corruption); move_alloc transfers descriptors !! only. Error stop on duplicate name. class(nml_schema_t), intent(inout) :: this type(nml_group_t), intent(inout) :: g type(nml_group_t), allocatable :: tmp(:) integer :: n, i if (.not. allocated(this%groups)) allocate (this%groups(0)) n = size(this%groups) do i = 1, n if (lower(this%groups(i)%name) == lower(g%name)) then call global_logger%error("duplicate group '"//g%name//"' in schema") error stop "rdb_nml_schema: duplicate group registration" end if end do allocate (tmp(n + 1)) do i = 1, n call move_group(this%groups(i), tmp(i)) end do call move_group(g, tmp(n + 1)) call move_alloc(tmp, this%groups) end subroutine schema_add_group