// File: JRLamontagne[P]cdice_sa/CDICEInit.cpp
// Function: initTS(DICE*)
void initTS(DICE *dice)
{

  for (int i=0; i<dice->config.nPeriods; i++) {
    
    dice->config.dateSeries[i] = dice->config.startYear + (dice->config.tstep * i);
    dice->econ.l[i] = 0.0;
    dice->econ.al[i] = 0.0;		
    dice->econ.sigma[i] = 0.0;	 
    dice->econ.rr[i] = 0.0;		
    dice->econ.ga[i] = 0.0;		
    dice->carb.forcoth[i] = 0.0;
    dice->econ.gl[i] = 0.0;		
    dice->econ.gcost[i] = 0.0;
    dice->econ.gsig[i] = 0.0;		
    dice->econ.etree[i] = 0.0;
    dice->econ.cumetree[i] = 0.0;
    dice->econ.cost1[i] = 0.0;
    //dice->econ.gfacpop[i] = 0.0;	// Appears in GAMS version, but is never used
    dice->econ.pbacktime[i] = 0.0;
    dice->econ.scc[i] = 0.0;
    dice->econ.cpricebase[i] = 0.0;
    dice->econ.photel[i] = 0.0;

    //dice->dvars.miu[i] = dice->dvars.miu0;
    dice->carb.forc[i] = 0.0;
    dice->carb.mat[i] = 0.0;
    dice->carb.mu[i] = 0.0;
    dice->carb.ml[i] = 0.0;
    dice->carb.atfrac[i] = 0.0;
    dice->carb.atfrac2010[i] = 0.0;
    dice->carb.ppm[i] = 0.0;
    dice->econ.e[i] = 0.0;
    dice->econ.eind[i] = 0.0;
    dice->econ.c[i] = 0.0;
    dice->econ.k[i] = 0.0;
    dice->econ.cpc[i] = 0.0;
    dice->econ.i[i] = 0.0;
    dice->econ.ri[i] = 0.0;
    dice->econ.y[i] = 0.0;
    dice->econ.ygross[i] = 0.0;
    dice->econ.ynet[i] = 0.0;
    dice->econ.damages[i] = 0.0;
    dice->econ.damfrac[i] = 0.0;
    dice->econ.abatecost[i] = 0.0;
    dice->econ.mcabate[i] = 0.0;
    dice->econ.cca[i] = 0.0;
    dice->econ.ccatot[i] = 0.0;
    dice->econ.periodu[i] = 0.0;
    dice->econ.cprice[i] = 0.0;
    dice->econ.cemutotper[i] = 0.0;

    dice->econ.ri_disc[i] = 0.0;
    dice->econ.pv_damages[i] = 0.0;
    dice->econ.pv_abatecost[i] = 0.0;
    dice->econ.totalcost[i] = 0.0;
    dice->econ.pv_totalcost[i] = 0.0;

    // If not using DOEclim, then initialize DICE clim time series
    if(dice->ctrl.use_doeclim == 0) {
      dice->clim.tatm[i] = 0.0;
      dice->clim.tocean[i] = 0.0;
    }
    
  }
	
	// If using DOEclim...
	if(dice->ctrl.use_doeclim == 1) {

		// Initialize the appropriate time series
		for(int i=0; i<dice->config.ns; i++) {
  	  dice->clim.temp[i] = 0.0;
    	dice->clim.temp_landair[i] = 0.0;
	    dice->clim.temp_sst[i] = 0.0;
  	  dice->clim.heat_mixed[i] = 0.0;
    	dice->clim.heat_interior[i] = 0.0;
	    dice->clim.heatflux_mixed[i] = 0.0;
 	   dice->clim.heatflux_interior[i] = 0.0;
  	}

  
  }

  // Calculate values for the exogenous variables -------------------------
  // dice->econ.partfract is used to determine the upper limit of the
  // control policy 'miu'
  calcExog(dice);
  for(int i=0; i<dice->config.nPeriods; i++) {
    if (i < 29) {
      dice->lims.miu_up[i] = 1.0;
    }
    else	{
      dice->lims.miu_up[i] = dice->dvars.limmiu;
    }
  }
  
  return;

}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
movq 0x10(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x13e2d
movq 0x10(%rsp), %rax
cvtsi2sdl 0x10(%rax), %xmm1
movq 0x10(%rsp), %rax
movsd 0x8(%rax), %xmm0
cvtsi2sdl 0xc(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movslq 0xc(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x288(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x290(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x2f0(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x2c8(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x2d0(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x468(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x2d8(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x2e0(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x2e8(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x2f8(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x300(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x298(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x2a8(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x2b0(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x2b8(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x2c0(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x470(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x478(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x480(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x488(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x490(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x498(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x4a0(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x3b8(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x3c0(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x308(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x310(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x318(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x320(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x328(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x330(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x338(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x340(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x348(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x350(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x358(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x360(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x3c8(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x3d0(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x368(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x370(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x378(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x388(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x390(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x398(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x3a0(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x3a8(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
cmpl $0x0, 0x58(%rax)
jne 0x13e1b
movq 0x10(%rsp), %rax
movq 0x128(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x130(%rax), %rax
movslq 0xc(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x13e1d
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x13901
movq 0x10(%rsp), %rax
cmpl $0x1, 0x58(%rax)
jne 0x13f17
movl $0x0, 0x8(%rsp)
movl 0x8(%rsp), %eax
movq 0x10(%rsp), %rcx
cmpl 0x28(%rcx), %eax
jge 0x13f15
movq 0x10(%rsp), %rax
movq 0x140(%rax), %rax
movslq 0x8(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x148(%rax), %rax
movslq 0x8(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x150(%rax), %rax
movslq 0x8(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x158(%rax), %rax
movslq 0x8(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x160(%rax), %rax
movslq 0x8(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x168(%rax), %rax
movslq 0x8(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x170(%rax), %rax
movslq 0x8(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0x13e44
jmp 0x13f17
movq 0x10(%rsp), %rdi
callq 0x15740
movl $0x0, 0x4(%rsp)
movl 0x4(%rsp), %eax
movq 0x10(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x13f8c
cmpl $0x1d, 0x4(%rsp)
jge 0x13f5d
movq 0x10(%rsp), %rax
movq 0x528(%rax), %rax
movslq 0x4(%rsp), %rcx
movsd 0x80b2(%rip), %xmm0     # 0x1c008
movsd %xmm0, (%rax,%rcx,8)
jmp 0x13f7d
movq 0x10(%rsp), %rax
movsd 0x38(%rax), %xmm0
movq 0x10(%rsp), %rax
movq 0x528(%rax), %rax
movslq 0x4(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x13f7f
movl 0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0x13f29
addq $0x18, %rsp
retq
nopw %cs:(%rax,%rax)