To advance green communications, we propose an orthogonal frequency division multiplexing (OFDM) based cooperative relay system, where the relay node not only can forward the data to the destination node, but is also capable of transferring energy to the source node. In particular, to maximize the overall system capacity in multiple subchannels and multiple time slots while meeting the power constraints, a power allocation optimization problem is formulated and solved in three steps. First, at each data transmission and data forwarding cycle, we split the total transmission power of relay into two parts, one for data forwarding and the other as power supplement for the source node. Then, our analysis indicates that at each cycle, once all of the subchannels are sorted in a certain order, the relay node will only provide forwarding power to the subchannels with index greater than a certain value. Meanwhile, the incentive for the relay node to provide power supplement should be strong enough such that relay chooses not to simultaneously transmit data and energy. Then, an equivalent convex constrained optimization problem is formulated and the solution is derived by solving the Lagrange function. The solution takes the form of water-filling in combination with a cooperative feature. Numerical results demonstrate that energy cooperation notably improves the system capacity.