MESH3D%NPOIN and MESH2D%NPOIN are the numbers of points of the subdomain, you should not have a need to use the global number of points.
The total number of points of the original domain is the maximum of all MESH3D%KNOLG%I() on all points of all subdomains.
If N is a point number on the bottom, the point above will be N+NPOIN2, so it is not N/2 but N-NPOIN2 that you should take in your example.
With best regards,
Jean-Michel Hervouet