Calculation of the nucleon-nucleus optical potential