We optimize the operation of a fuel cell hybrid train using convex optimization. The main objective is to minimize hydrogen fuel consumption for a target journey time while considering battery thermal constraints. The state trajectories: train speed, energy management system, and battery temperature, are all optimized concurrently within a single optimization problem. A novel thermal model is proposed in order to include battery temperature yet maintain formulation convexity. Simulations show fuel savings and better thermal management when temperature is optimized concurrently with the other states rather than sequentially-separately afterwards. The fuel reduction is caused by reduced cooling effort which is motivated by the formulation's awareness of active cooling energy consumption. The benefit is more pronounced for warmer ambient temperatures that require more cooling.