Changeset 24579
- Timestamp:
- 02/25/20 14:07:05 (5 years ago)
- Location:
- issm/trunk-jpl
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/analyses/SmbAnalysis.cpp
r24385 r24579 96 96 iomodel->FindConstant(&isfirnwarming,"md.smb.isfirnwarming"); 97 97 iomodel->FetchDataToInput(inputs2,elements,"md.smb.smb_corr",SmbSmbCorrEnum); 98 iomodel->FetchDataToInput(inputs2,elements,"md.smb.precipitation",SmbPrecipitationEnum);99 iomodel->FetchDataToInput(inputs2,elements,"md.smb.monthlytemperatures",SmbMonthlytemperaturesEnum);100 98 iomodel->FetchDataToInput(inputs2,elements,"md.smb.precipitation_anomaly",SmbPrecipitationsAnomalyEnum); 101 99 iomodel->FetchDataToInput(inputs2,elements,"md.smb.temperature_anomaly",SmbTemperaturesAnomalyEnum); 100 iomodel->FetchDataToDatasetInput(inputs2,elements,"md.smb.monthlytemperatures",SmbMonthlytemperaturesEnum); 101 iomodel->FetchDataToDatasetInput(inputs2,elements,"md.smb.precipitation",SmbPrecipitationEnum); 102 102 break; 103 103 case SMBd18opddEnum: -
issm/trunk-jpl/src/c/classes/Elements/Element.cpp
r24561 r24579 3030 3030 IssmDouble mu = MU_0*(1000.0*86400.0)*(rho_ice/rho_water); // (d*deg C)/(mm WE) --> (s*deg C)/(m IE) 3031 3031 3032 /*Get inputs*/ 3033 DatasetInput2* dinput =this->GetDatasetInput2(SmbMonthlytemperaturesEnum); _assert_(dinput); 3034 DatasetInput2* dinput2=this->GetDatasetInput2(SmbPrecipitationEnum); _assert_(dinput2); 3032 3035 3033 3036 /*loop over vertices: */ … … 3035 3038 for(int month=0;month<12;month++){ 3036 3039 3037 /*Recover monthly temperatures and precipitation*/3038 Input2* dinput =this->GetInput2(SmbMonthlytemperaturesEnum,reCast<IssmDouble>(month+1)/12.*yts); _assert_(dinput);3039 Input2* dinput2=this->GetInput2(SmbPrecipitationEnum,reCast<IssmDouble>(month+1)/12.*yts); _assert_(dinput2);3040 3041 3040 for(int iv=0;iv<NUM_VERTICES;iv++){ 3042 3041 gauss->GaussVertex(iv); 3043 dinput->GetInputValue(&monthlytemperatures[iv*12+month],gauss );3042 dinput->GetInputValue(&monthlytemperatures[iv*12+month],gauss,month); 3044 3043 monthlytemperatures[iv*12+month]=monthlytemperatures[iv*12+month]-273.15; // conversion from Kelvin to celcius for PDD module 3045 dinput2->GetInputValue(&monthlyprec[iv*12+month],gauss );3044 dinput2->GetInputValue(&monthlyprec[iv*12+month],gauss,month); 3046 3045 monthlyprec[iv*12+month]=monthlyprec[iv*12+month]*yts; 3047 3046 } -
issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
r24578 r24579 233 233 234 234 /*Intermediaries*/ 235 int vertexsids[NUMVERTICES]; 236 int vertexlids[NUMVERTICES]; 235 237 IssmDouble nodeinputs[NUMVERTICES]; 236 int vertexlids[NUMVERTICES];237 238 238 239 /*Some sanity checks*/ … … 244 245 _assert_(iomodel->elements); 245 246 for(int i=0;i<NUMVERTICES;i++){ 246 int vertexid =reCast<int>(iomodel->elements[NUMVERTICES*this->Sid()+i]); //ids for vertices are in the elements array from Matlab 247 248 vertexlids[i]=iomodel->my_vertices_lids[vertexid-1]; 249 nodeinputs[i]=array[vertexid*N+i]; 247 vertexsids[i] = reCast<int>(iomodel->elements[NUMVERTICES*this->Sid()+i])-1; 248 vertexlids[i] = iomodel->my_vertices_lids[vertexsids[i]]; 250 249 } 251 250 252 251 /*Create inputs and add to DataSetInput*/ 253 252 for(int i=0;i<num_inputs;i++){ 254 this->inputs2->SetTriaDatasetInput(input_enum,individual_enums[i],P1Enum,NUMVERTICES,vertexlids,nodeinputs); break; 253 for(int j=0;j<NUMVERTICES;j++) nodeinputs[j]=array[vertexsids[j]*N+i]; 254 inputs2->SetTriaDatasetInput(input_enum,individual_enums[i],P1Enum,NUMVERTICES,vertexlids,nodeinputs); 255 255 } 256 256 } -
issm/trunk-jpl/src/c/classes/Inputs2/DatasetInput2.cpp
r24335 r24579 207 207 if(index == -1){ 208 208 this->Echo(); 209 _error_("Could not find input "<<id<<" ("<<EnumToStringx(id)<<" ) in DatasetInput");209 _error_("Could not find input "<<id<<" ("<<EnumToStringx(id)<<"?) in DatasetInput"); 210 210 } 211 211 -
issm/trunk-jpl/src/c/classes/IoModel.cpp
r24335 r24579 1663 1663 int integer; 1664 1664 IssmDouble scalar; 1665 char *string = NULL;1666 1665 IssmDouble *doublearray = NULL; 1667 1666 int M,N; … … 1723 1722 /*Free ressources*/ 1724 1723 xDelete<IssmDouble>(doublearray); 1725 xDelete<char>(string); 1724 } 1725 /*}}}*/ 1726 void IoModel::FetchDataToDatasetInput(Inputs2* inputs2,Elements* elements,const char* vector_name,int input_enum){/*{{{*/ 1727 1728 /*First, look whether it is not already loaded in this->data*/ 1729 vector<IoData*>::iterator iter; 1730 for(iter=data.begin();iter<data.end();iter++){ 1731 IoData* iodata=*iter; 1732 if(strcmp(iodata->name,vector_name)==0){ 1733 for(int i=0;i<elements->Size();i++){ 1734 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 1735 _error_("to be implemented..."); 1736 //element->InputCreate(iodata->data,inputs2,this,iodata->M,iodata->N,iodata->layout,input_enum,iodata->code);//we need i to index into elements. 1737 } 1738 return; 1739 } 1740 } 1741 1742 /*intermediary: */ 1743 int code,vector_layout; 1744 IssmDouble *doublearray = NULL; 1745 int M,N; 1746 1747 /*First of, find the record for the name, and get code of data type: */ 1748 this->SetFilePointerToData(&code,&vector_layout,vector_name); 1749 1750 switch(code){ 1751 case 1: //boolean constant 1752 _error_("not implemented yet"); 1753 break; 1754 case 2: //integer constant 1755 _error_("not implemented yet"); 1756 break; 1757 case 3: //IssmDouble constant 1758 _error_("not implemented yet"); 1759 break; 1760 case 5: //boolean vector 1761 _error_("not implemented yet"); 1762 break; 1763 case 6: //int vector 1764 _error_("not implemented yet"); 1765 break; 1766 case 7: //IssmDouble vector 1767 { 1768 this->FetchData(&doublearray,&M,&N,vector_name); 1769 if(!doublearray) _error_("\""<<vector_name<<"\" not found in binary file"); 1770 1771 int* ids = xNew<int>(N); 1772 for(int i=0;i<N;i++) ids[i] = i; 1773 1774 for(int i=0;i<elements->Size();i++){ 1775 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 1776 element->DatasetInputCreate(doublearray,M,N,ids,N,inputs2,this,input_enum); 1777 } 1778 xDelete<int>(ids); 1779 } 1780 break; 1781 default: 1782 _error_("data code " << code << " not supported yet (detected while processing \""<<vector_name<<"\")"); 1783 break; 1784 } 1785 /*Free ressources*/ 1786 xDelete<IssmDouble>(doublearray); 1726 1787 } 1727 1788 /*}}}*/ -
issm/trunk-jpl/src/c/classes/IoModel.h
r24459 r24579 141 141 void FetchDataToInput(Inputs2* inputs2,Elements* elements,const char* vector_name,int input_enum); 142 142 void FetchDataToInput(Inputs2* inputs2,Elements* elements,const char* vector_name,int input_enum,IssmDouble default_value); 143 void FetchDataToDatasetInput(Inputs2* inputs2,Elements* elements,const char* vector_name,int input_enum); 143 144 void FetchIndependent(const char* dependent_name); 144 145 void FetchMultipleData(char*** pstringarray,int* pnumstrings,const char* data_name); -
issm/trunk-jpl/test/NightlyRun/test245.m
r23317 r24579 18 18 for imonth=0:11 19 19 md.smb.monthlytemperatures(1:md.mesh.numberofvertices,imonth+1)=md.materials.meltingpoint+temp_ma_present+(temp_mj_present-temp_ma_present)*sin(double(imonth+1-4)*pi/6.0); 20 md.smb.monthlytemperatures(md.mesh.numberofvertices+1,imonth+1)=((imonth+1)/12);21 20 md.smb.precipitation(1:md.mesh.numberofvertices,imonth+1)=precipitation; 22 md.smb.precipitation(md.mesh.numberofvertices+1,imonth+1)=((imonth+1)/12);23 21 end 24 22 -
issm/trunk-jpl/test/NightlyRun/test245.py
r24261 r24579 30 30 for imonth in range(12): 31 31 md.smb.monthlytemperatures[0:md.mesh.numberofvertices, imonth] = md.materials.meltingpoint + temp_ma_present + (temp_mj_present - temp_ma_present) * np.sin((imonth + 1. - 4.) * np.pi / 6.0) 32 md.smb.monthlytemperatures[md.mesh.numberofvertices, imonth] = ((imonth + 1) / 12.)33 32 md.smb.precipitation[0:md.mesh.numberofvertices, imonth] = precipitation 34 md.smb.precipitation[md.mesh.numberofvertices, imonth] = ((imonth + 1) / 12.)35 33 36 34 # time steps and resolution
Note:
See TracChangeset
for help on using the changeset viewer.