[19753] | 1 | //TIMESTEPPING class definition
|
---|
| 2 | //
|
---|
| 3 | // Usage:
|
---|
| 4 | // timestepping=new timestepping();
|
---|
| 5 |
|
---|
| 6 | function timestepping (){
|
---|
| 7 | //methods
|
---|
| 8 | this.setdefaultparameters = function(){// {{{
|
---|
| 9 | //time between 2 time steps
|
---|
| 10 | this.time_step=1./2.;
|
---|
| 11 |
|
---|
| 12 | //final time
|
---|
| 13 | this.final_time=10.*this.time_step;
|
---|
| 14 |
|
---|
| 15 | //should we interpolate forcings between timesteps?
|
---|
| 16 | this.interp_forcings=1;
|
---|
[26195] | 17 | this.cycle_forcing=0;
|
---|
[19753] | 18 | }// }}}
|
---|
| 19 | this.disp= function(){// {{{
|
---|
[19860] | 20 |
|
---|
| 21 | var unit;
|
---|
[19753] | 22 | console.log(sprintf(' timestepping parameters:'));
|
---|
[19857] | 23 | unit = 'yr';
|
---|
[19753] | 24 | fielddisplay(this,'start_time','simulation starting time ['+ unit + ']');
|
---|
| 25 | fielddisplay(this,'final_time','final time to stop the simulation ['+ unit + ']');
|
---|
| 26 | fielddisplay(this,'time_step','length of time steps [' +unit+ ']');
|
---|
| 27 | fielddisplay(this,'interp_forcings','interpolate in time between requested forcing values ? (0 or 1)');
|
---|
[26195] | 28 | fielddisplay(this,'cycle_forcing','cycle through forcing ? (0 or 1)');
|
---|
[22459] | 29 | fielddisplay(this,'coupling_time','length of coupling time steps with ocean model [' +unit+ ']');
|
---|
[19753] | 30 |
|
---|
| 31 | }// }}}
|
---|
[19791] | 32 | this.classname= function(){// {{{
|
---|
| 33 | return "timestepping";
|
---|
| 34 |
|
---|
| 35 | }// }}}
|
---|
[21787] | 36 | this.checkconsistency = function(md,solution,analyses) { //{{{
|
---|
[19791] | 37 |
|
---|
[21787] | 38 | checkfield(md,'fieldname','timestepping.start_time','numel',[1],'NaN',1,'Inf',1);
|
---|
| 39 | checkfield(md,'fieldname','timestepping.final_time','numel',[1],'NaN',1,'Inf',1);
|
---|
| 40 | checkfield(md,'fieldname','timestepping.time_step','numel',[1],'>=',0,'NaN',1,'Inf',1);
|
---|
| 41 | checkfield(md,'fieldname','timestepping.interp_forcings','numel',[1],'values',[0,1]);
|
---|
[26195] | 42 | checkfield(md,'fieldname','timestepping.cycle_forcing','numel',[1],'values',[0,1]);
|
---|
[22459] | 43 | checkfield(md,'fieldname','timestepping.coupling_time','numel',[1],'>=',0,'NaN',1,'Inf',1);
|
---|
[21787] | 44 | if (this.final_time-this.start_time<0){
|
---|
| 45 | md.checkmessage('timestepping.final_time should be larger than timestepping.start_time');
|
---|
| 46 | }
|
---|
| 47 | } // }}}
|
---|
| 48 | this.marshall=function(md,prefix,fid) { //{{{
|
---|
[19791] | 49 |
|
---|
[21787] | 50 | var scale;
|
---|
| 51 | scale = md.constants.yts;
|
---|
| 52 |
|
---|
| 53 | WriteData(fid,prefix,'name','md.timestepping.type','data',1,'format','Integer');
|
---|
| 54 | WriteData(fid,prefix,'object',this,'fieldname','start_time','format','Double','scale',scale);
|
---|
| 55 | WriteData(fid,prefix,'object',this,'fieldname','final_time','format','Double','scale',scale);
|
---|
| 56 | WriteData(fid,prefix,'object',this,'fieldname','time_step','format','Double','scale',scale);
|
---|
| 57 | WriteData(fid,prefix,'object',this,'fieldname','interp_forcings','format','Boolean');
|
---|
[26195] | 58 | WriteData(fid,prefix,'object',this,'fieldname','cycle_forcing','format','Boolean');
|
---|
[22459] | 59 | WriteData(fid,prefix,'object',this,'fieldname','coupling_time','format','Double','scale',scale);
|
---|
[21787] | 60 |
|
---|
| 61 | }//}}}
|
---|
| 62 | this.fix=function() { //{{{
|
---|
| 63 | }//}}}
|
---|
[19753] | 64 | //properties
|
---|
| 65 | // {{{
|
---|
| 66 | this.start_time = 0.;
|
---|
| 67 | this.final_time = 0.;
|
---|
| 68 | this.time_step = 0.;
|
---|
| 69 | this.interp_forcings = 1;
|
---|
[26195] | 70 | this.cycle_forcing = 0;
|
---|
[22459] | 71 | this.coupling_time = 0.;
|
---|
[19753] | 72 |
|
---|
| 73 | this.setdefaultparameters();
|
---|
| 74 | //}}}
|
---|
| 75 | }
|
---|