Optical-model calculations with a realistic nucleon-nucleon interaction