1 | //SMBforcing Class definition
|
---|
2 | //
|
---|
3 | // Usage:
|
---|
4 | // SMB=SMBforcing();
|
---|
5 |
|
---|
6 | function SMBforcing(){
|
---|
7 | //methods
|
---|
8 | this.setdefaultparameters = function(){// {{{
|
---|
9 | } // }}}
|
---|
10 | this.disp = function(){ // {{{
|
---|
11 | console.log(sprintf(' surface forcings parameters:'));
|
---|
12 | fielddisplay(this,'mass_balance','surface mass balance [m/yr ice eq]');
|
---|
13 | fielddisplay(this,'requested_outputs','additional outputs requested');
|
---|
14 | } // }}}
|
---|
15 | this.defaultoutputs = function(){ // {{{
|
---|
16 | return '';
|
---|
17 | }//}}}
|
---|
18 | this.classname = function(){ // {{{
|
---|
19 | return "SMBforcing";
|
---|
20 | } // }}}
|
---|
21 | this.initialize = function(md) {// {{{
|
---|
22 |
|
---|
23 | if (isNaN(self.mass_balance)){
|
---|
24 | self.mass_balance=NewArrayFill(md.mesh.numberofvertices,0);
|
---|
25 | console.log(' no smb.mass_balance specified: values set as zero');
|
---|
26 | }
|
---|
27 |
|
---|
28 | } // }}}
|
---|
29 | this.checkconsistency = function(md,solution,analyses) { //{{{
|
---|
30 |
|
---|
31 | if(ArrayAnyEqual(ArrayIsMember(MasstransportAnalysisEnum(),analyses),1)){
|
---|
32 | checkfield(md,'fieldname','smb.mass_balance','timeseries',1,'NaN',1);
|
---|
33 | }
|
---|
34 | if(ArrayAnyEqual(ArrayIsMember(BalancethicknessAnalysisEnum(),analyses),1)){
|
---|
35 | checkfield(md,'fieldname','smb.mass_balance','size',[md.mesh.numberofvertices,1],'NaN',1);
|
---|
36 | }
|
---|
37 | checkfield(md,'fieldname','smb.requested_outputs','stringrow',1);
|
---|
38 |
|
---|
39 | } // }}}
|
---|
40 | this.marshall=function(md,fid) { //{{{
|
---|
41 |
|
---|
42 | var yts=365.0*24.0*3600.0;
|
---|
43 |
|
---|
44 | WriteData(fid,'enum',SmbEnum(),'data',SMBforcingEnum(),'format','Integer');
|
---|
45 | WriteData(fid,'object',this,'class','smb','fieldname','mass_balance','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1);
|
---|
46 |
|
---|
47 | //process requested outputs
|
---|
48 | outputs = this.requested_outputs;
|
---|
49 | for (var i=0;i<outputs.length;i++){
|
---|
50 | if (outputs[i] == 'default') {
|
---|
51 | outputs.splice(i,1);
|
---|
52 | newoutputs=this.defaultoutputs(md);
|
---|
53 | for (var j=0;j<newoutputs.length;j++) outputs.push(newoutputs[j]);
|
---|
54 | }
|
---|
55 | }
|
---|
56 | WriteData(fid,'data',outputs,'enum',SmbRequestedOutputsEnum(),'format','StringArray');
|
---|
57 |
|
---|
58 | }//}}}
|
---|
59 | //properties
|
---|
60 | this.mass_balance = NaN;
|
---|
61 | this.requested_outputs = [];
|
---|
62 | this.setdefaultparameters();
|
---|
63 | }
|
---|