Authors:Szulágyi et alAbstract:We present three-dimensional simulations with nested meshes of the dynamics of the gas around a Jupiter mass planet with the jupiter and fargoca codes. We implemented a radiative transfer module into the jupiter code to account for realistic heating and cooling of the gas. We focus on the circumplanetary gas flow, determining its characteristics at very high resolution (80 per cent of Jupiter's diameter). In our nominal simulation where the temperature evolves freely by the radiative module and reaches 13000 K at the planet, a circumplanetary envelope was formed filling the entire Roche lobe. Because of our equation of state is simplified and probably overestimates the temperature, we also performed simulations with limited maximal temperatures in the planet region (1000, 1500, and 2000 K). In these fixed temperature cases circumplanetary discs (CPDs) were formed. This suggests that the capability to form a CPD is not simply linked to the mass of the planet and its ability to open a gap. Instead, the gas temperature at the planet's location, which depends on its accretion history, plays also fundamental role. The CPDs in the simulations are hot and cooling very slowly, they have very steep temperature and density profiles, and are strongly sub-Keplerian. Moreover, the CPDs are fed by a strong vertical influx, which shocks on the CPD surfaces creating a hot and luminous shock-front. In contrast, the pressure supported circumplanetary envelope is characterized by internal convection and almost stalled rotation.