Welcome to the community. I realize you are new at this but you should step back and think about what you posted and what you expect the community to do.
While doing this remember:
You didn't mention:
- what board you are using
- What GPS
- what magnetometer
- How things are connected.
- Where you found the code
- What is causing your "trouble running" this code.