Bulk copied from 2dlattice.c + use gengetopts Former-commit-id: 27a21038f292dc10bfbb36f3dfd509f2d0871240
Former-commit-id: 622e0884f31c4284bd62e47527f9a96794650d25