Image caption A view across the Fjord in Greenlandic capital, Nuuk

BBC political correspondent Carolyn Quinn explores how Britain would exit the EU if voters opt to leave in the referendum.

We don't know when David Cameron will call the EU referendum but for a BBC radio documentary, How to Make a Brexit, I examined what would happen in the days, the weeks and the months after that referendum if the British people vote to leave the EU.

We're not talking about the raging arguments over whether we would prosper or fade economically, or whether we'd make better policy choices than the bureaucrats in Brussels. We're talking about the exact steps that would need to be followed should voters favour Brexit.

Until 2007, joining the European club was assumed to be a one-way ticket. There was no formal mechanism in the rules setting out how a state could leave the European Union.

But there is now. Article 50 of the Lisbon Treaty sets out a road map. It boils down to a couple of deceptively simple steps. The prime minister would have to write a letter to the President of the European Council notifying him of the intention to leave. The council would appoint a lead negotiator and a negotiating team.

A two-year window to negotiate a withdrawal treaty would follow - if Britain decides it wants one. The window could be expanded by a year if necessary. Any withdrawal treaty would be concluded by the European Council through qualified majority voting and then ratified by the European Parliament and the Westminster Parliament.

Listen to How to Make a Brexit at 20:00 GMT on BBC Radio 4 on Tuesday, 5 January and again at 17:00 GMT on Sunday or anytime on the BBC website

Britain would be carving out an unprecedented path. No nation state has ever held a referendum and then left the EU.

But there is one part of one country that has gone through the process of getting out - Greenland, one of Denmark's overseas territories and the world's largest island that is not a continent. It staged a referendum in 1982 after gaining a high degree of self-government from Denmark.

Greenlanders voted 52/48 to leave the EU. There followed a series of difficult and protracted negotiations between the Greenland and Danish governments, and the Danish government and the European Commission, particularly with regard to fisheries.

I travelled to Greenland - a vast land mass that is almost entirely ice cap, with scattered settlements around the coast. The main settlements on the island are not linked together by road.

Image caption Lars-Emil Johansen led Greenland's Out campaign in the 1980s

On the day we landed, it was -29C. It has a population of about 56,000 - a quarter of them live in Nuuk, the capital, on the south-west coast just below the Arctic Circle.

There, I spoke to the men who led Greenland's Out campaign in the 1980s.

"I was very proud when we won our referendum in 1982. There were 500 million people in Europe, and we, in Greenland were just 50,000, but we said 'no,'" said Lars-Emil Johansen, now speaker of the Greenlandic Parliament.

Veteran activist and politician Kaj Kleist said: "I cried at that moment, when we won the referendum in 1982 I remember that the chairman of the commission Jacques Delors said tonight we just lost 60% of the EU's territory."

He explained that Greenlandic fishermen resented being told by Brussels how much fish they could take out of their own waters and watching their fish stocks being hoovered up by EU factory trawlers.

Henrik Leth, who chairs the largest privately-run fishing company in Greenland - Polar Seafood, said there was a noticeable change for the industry after leaving the EU.

"We built up, and now have a very powerful industry," he said.

Two of the biggest fisheries companies in Denmark were Greenlandic, he said, and Polar Seafood was in the top 10 in Europe.

Image caption Greenland's fishing industry improved after its exit, industry figures say

As Henrik took me on a drive around Nuuk - with its three sets of traffic lights (the only ones in the whole of Greenland) he told me more about the deal struck with the EEC.

In return for allowing continued European access to its waters, Greenland was given tariff-free access to the Community market for fisheries products. It also got EU funding on top of the money it received and continues to receive from Denmark.

Interestingly, Henrik now wonders whether the time might be right for Greenland to consider rejoining the EU, as it would give Greenland access to even greater markets like Japan and China.

He told me "little Greenland" had very little leverage with the Chinese as a nation on its own.

Image caption 16,500 people live in the capital, Nuuk

"What do we have to give? I mean we can tell China we will not buy Chinese products but there are more people in an office block in Shanghai than there are in Greenland so we can't possibly put on the same sort of pressure as the European Union and other big nations can."

But he admits asking to go back into the EU would be a tricky step to take.

"It has to be analysed and will be a bitter pill to swallow but on the other hand, now we have our fishing industry they will not be able to take that away from us and go back to what it was like before 1985," said Henrik.

It took the best part of three years to negotiate Greenland's exit deal. It finally left the EU in 1985. What does that tell us about Britain's prospects?

In Britain's case, the economy is many times larger and more complex, and the responsibilities and membership of the EU have ballooned over the past 30 years. If the prime minister were to invoke Article 50 and inform the European Council of Britain's intention to leave, there would be a staggering array of issues to negotiate including:

What sort of trading relationship would apply in future?

How would the UK's trade relations outside the EU be affected by ending UK participation in EU trade agreements?

How would the government deal with the several thousand pieces of EU legislation including regulations and directives that have become part of the UK. Which laws would be preserved? Which repealed?

What agreements could be reached over the rights and obligations of EU citizens in the UK and UK citizens in the EU?

I took a trip to the European Parliament in Brussels to ask what would happen to the UK's small army of ministers, MEPs, commissioners and civil servants working within EU institutions.

UKIP's Diane James assured me that British MEPs would fulfil their role right to the very end - even agreeing or opposing pieces of legislation that, in the end, could have no impact on a departed Britain.

I sought the advice of Stephen Booth, head of the Open Europe think tank which supports EU reform. The group organised its own day of wargames to test out some of the pinch points in any potential Brexit negotiations, and is planning another later in January.

Economist Ruth Lea and Charles Grant from the pro-EU think tank, the Centre for European Reform, disagreed over how ready the UK was for the potential negotiating task ahead.

"We don't have any trade negotiators in Whitehall - we haven't had any since 1973," said Mr Grant. "The British government would be hard-pressed to find people to do a trade negotiation. They might have to borrow civil servants from other European countries or get old people out of retirement."

But Ruth Lea insisted: "I'm not worried about that because we are very good in this country at importing talent if we want to, for example we have a Canadian as governor of the Bank of England".

Another question I pose in the documentary is about the preparedness of Whitehall for the Brexit negotiations, should they come.

'Walk away'

Former Cabinet Secretary Lord O'Donnell believes that every civil servant will be thinking: "What if?... There will be a lot of work going on mentally, but how much they write down is a different question. That is one of the potential drawbacks of the world of Freedom of Information we live in."

And finally with a referendum due to take place at the latest by the end of 2017, could all of the detailed unravelling required in the case of a Brexit be completed in a two, or possibly three, year negotiating window?

Constitutional lawyer Martin Howe QC has his doubts, and says he would rather not see the UK stay in an unreformed EU. He believes Britain should just walk away if it hasn't reached a deal by the end of two years.

"The two-year time limit would allow the process to be completed and concluded within the current parliament," he said.

"But, if it is extended, you will then be going across into a new Parliament with a General Election and in the meantime there might be a change of government and, at minimum, the negotiation process then gets tangled up in the General Election campaign."

All depends now on the outcome of the referendum.

Lord O'Donnell said in the end Britain and the EU would have to work out ways of co-existing.

Divorce can sometimes be painful, he said, but it did not have to be messy. The secret to breaking up is the same for states as for people - good planning, good sense and an ability to learn how to live and trade together in a shrinking world.

How to make a Brexit is broadcast at 20:00 GMT on BBC Radio 4 on Tuesday, 5 January and again at 17:00 GMT on Sunday or anytime on the BBC website.