function [lonGm, latGm, lonPolGm, colatPolGm] = Geog2Geom(any, lonGg0, latGg0)
lonGg = lonGg0; lonGg = lonGg(:)'; lonGm = lonGg0;
latGg = latGg0; latGg = latGg(:)'; latGm = latGg0;
%any = 1998.5;
%latGm =-46.5897180534852; lonGm = 143.838311168691;
RutaiNomArxIGRF = './IGRF11.txt';
disp(['Utilitzant ', RutaiNomArxIGRF])
% Import the file
newData1 = importdata(RutaiNomArxIGRF);
data = newData1.data;
textdata = newData1.textdata;
clear newData1
CoefsIGRF = data(:, 3: end - 1);
SV = data(:, end);
CapFil = textdata(1, 4: end);
AnysCapFil = str2num(cell2mat(CapFil(1: end-1)'))';
prany = str2double(CapFil{1});
ultany = str2double(CapFil{end - 1});
CapCol = [textdata(2: end, 1), num2cell(data(:, 1: 2))];
if (any >= prany) && (any <= ultany)
    g10 = interp1(AnysCapFil', CoefsIGRF(1, :)', any);
    g11 = interp1(AnysCapFil', CoefsIGRF(2, :)', any);
    h11 = interp1(AnysCapFil', CoefsIGRF(3, :)', any);
elseif any < prany
    disp('Cal refinar el model IGRF!')
    g10 = interp1(AnysCapFil', CoefsIGRF(1, :)', any, 'linear', 'extrap');
    g11 = interp1(AnysCapFil', CoefsIGRF(2, :)', any, 'linear', 'extrap');
    h11 = interp1(AnysCapFil', CoefsIGRF(3, :)', any, 'linear', 'extrap');
elseif any > ultany
    if any > ultany + 5
        disp('Compte, cal actualitzar el model IGRF!')
    end
    g10 = CoefsIGRF(1, end) + SV(1)*(any - ultany);
    g11 = CoefsIGRF(2, end) + SV(2)*(any - ultany);
    h11 = CoefsIGRF(3, end) + SV(3)*(any - ultany);
end
colatPolGm = acosd(-g10/sqrt(g10^2 + g11^2 + h11^2));
lonPolGm = 180/pi*atan2(-h11, -g11);
x1 = [cosd(colatPolGm); 0; -sind(colatPolGm)];
y1 = [0; 1; 0];
z1 = [sind(colatPolGm); 0; cosd(colatPolGm)];
R1 = [x1, y1, z1];
x2 = [cosd(lonPolGm); sind(lonPolGm); 0];
y2 = [-sind(lonPolGm); cosd(lonPolGm); 0];
z2 = [0; 0; 1];
R2 = [x2, y2, z2];
R = R2*R1;

vGg = [cosd(latGg).*cosd(lonGg); cosd(latGg).*sind(lonGg); sind(latGg)];
vGm = R\vGg;
[lonGmrad, latGmrad] = cart2sph(vGm(1, :), vGm(2, :), vGm(3, :));
lonGm(:) = lonGmrad(:)*180/pi; 
latGm(:) = latGmrad(:)*180/pi;