%----------------------------------------
%   ProcessCountryData_S_Module
%----------------------------------------
%   Profiles are extended till age 110
%   L(x) profiles are calculate (single year of age) from l(x) and e(x)
%   ASFR5 profile is distributed to single ages
%   economic profiles are normalized

femRatio = 1/(1+Bm2Bf);                         %   Calculate Femal2Total birth ratio
%   Scale profiles
ExtendDemographicVariables_S_Module           %   Extend popul, ll, ll_f, and expec to 110
populOld = popul;    popul = populN;
[c_prof, yl_prof, tgi_prof, tgo_prof] = ScaleProfiles_S(c_prof, yl_prof, tgi_prof, tgo_prof, popul); 

%   Calculate L(x) for combined sexes
L = zeros(1,AGE_MAX+1);
L = Calc_End_L(L,llN,expecN);      % calculate End points
L = Calc_Mid_L(L,llN);             % calculate Mid points
%   Calculate Lf(x) for female (only mid points are needed)
L_f = zeros(1,AGE_MAX+1);
L_f = Calc_Mid_L(L_f,ll_fN);

%   Calculate single-age-group ASFR and TFR
%   Average values are assigned to each year within the same age group,
%   say, 15-19. 
%   Alternatives (not provided in this version; please contact dswongkaren@gmail.com for more info)
%       A more precise function (providing ASFR natural shape) 
%       could be applied here instead. Alternatively, single year rates could
%       be directly read from the file.
ASFR_1 = asfr_5to1(ASFR_5, min_asfr5, max_asfr5);  
 