In this paper, we investigate the resource allocation algorithm design for multicarrier solar-powered unmanned aerial vehicle (UAV) communication systems. In particular, the UAV is powered by solar energy enabling sustainable communication services to multiple ground users. We study the joint design of the three-dimensional (3D) aerial trajectory and the wireless resource allocation for maximization of the system sum throughput over a given time period. As a performance benchmark, we first consider an offline resource allocation design assuming non-causal knowledge of the channel gains. The algorithm design is formulated as a mixed-integer non-convex optimization problem taking into account the aerodynamic power consumption, solar energy harvesting, a finite energy storage capacity, and the quality-of-service (QoS) requirements of the users. Despite the non-convexity of the optimization problem, we solve it optimally by applying monotonic optimization to obtain the optimal 3D-trajectory and the optimal power and subcarrier allocation policy. Subsequently, we focus on online algorithm design which only requires real-time and statistical knowledge of the channel gains. The optimal online resource allocation algorithm is motivated by the offline scheme and entails a high computational complexity. Hence, we also propose a low-complexity iterative suboptimal online scheme based on successive convex approximation. Our simulation results reveal that both proposed online schemes closely approach the performance of the benchmark offline scheme and substantially outperform two baseline schemes. Furthermore, our results unveil the tradeoff between solar energy harvesting and power-efficient communication. In particular, the solar-powered UAV first climbs up to a high altitude to harvest a sufficient amount of solar energy and then descents again to a lower altitude to reduce the path loss of the communication links to the users it serves.