source: issm/oecreview/Archive/25834-26739/ISSM-26196-26197.diff

Last change on this file was 26740, checked in by Mathieu Morlighem, 3 years ago

CHG: added 25834-26739

File size: 1.4 KB
  • ../trunk-jpl/src/c/classes/Inputs/TransientInput.cpp

     
    419419        this->parameters->FindParam(&linear_interp,TimesteppingInterpForcingsEnum);
    420420        this->parameters->FindParam(&cycle,TimesteppingCycleForcingEnum);
    421421
    422         if(cycle) _error_("not implemented yet");
     422        /*Change input time if we cycle through the forcing*/
     423        IssmDouble time0 = this->timesteps[0];
     424        IssmDouble time1 = this->timesteps[this->numtimesteps - 1];
     425        if(cycle && (time<time0 || time>time1)){
    423426
     427                /*See by how many intervals we have to offset time*/
     428                IssmDouble deltat = time1-time0;
     429
     430                //int num_intervals = floor((time-time0)/deltat); //Cannot do that because of AD!
     431                int num_intervals = reCast<int,IssmDouble>(fabs(time-time0)/deltat);
     432                if(time<time0) num_intervals = -num_intervals-1;
     433
     434                /*Now offset time so that we do the right interpolation below*/
     435                time = time - num_intervals*deltat;
     436        }
     437
    424438        /*Figure step out*/
    425439        int offset;
    426440        if(!binary_search(&offset,time,this->timesteps,this->numtimesteps)){
     
    479493                this->current_input->Scale(alpha1);
    480494                this->current_input->AXPY(input2,alpha2);
    481495        }
    482 
    483496}/*}}}*/
    484497void TransientInput::SetAverageAsCurrentTimeInput(IssmDouble start_time,IssmDouble end_time, int averaging_method){/*{{{*/
    485498
Note: See TracBrowser for help on using the repository browser.