We present a method for electronic structure calculations that retains all of the advantages of real space, but addresses the major weakness of a regular grid, i.e., its inability to treat some regions of space with more resolution than others. The computations are carried out on a regular mesh in curvilinear space, which allows natural and efficient decomposition on parallel computers, and effective use of iterative numerical methods. A novel feature is the use of error analysis to optimize the curvilinear grid for highly inhomogeneous electronic distributions. We report accurate all-electron calculations for H 2 , O, and O 2 .