u have to go to the cave of origin and talk to steven and he'll ask u where rayquaza is, tell him sky pillar. its right next to pacifidlog city, just keep looking. make it to the top, where rayquaza is. walk in front of it and press a and it will fly to sootopolis to stop groudon and kyogre. fly to sootopolis and rayquaza will stop them from fighting and go to rest at the sky pillar, where u will catch him. after u are done with that, the gymn will be unlocked. pm me if u need any more help.

Its been a long time since i've played this game, but i remember that the sky Pillar's door is locked, i think you have to enter the cave of origin first or battle the sootopolis gym leader, but i completely forgot how to unlock that gym and get that old man to move outta the way.