source: issm/trunk-jpl/src/c/modules/TotalSmbx/TotalSmbx.cpp@ 13798

Last change on this file since 13798 was 13798, checked in by Mathieu Morlighem, 12 years ago

CHG: use dynamic_cast instead of C-style casting

File size: 877 bytes
Line 
1/*!\file TotalSmbx
2 * \brief: compute total ice sheet surface mass balance
3 */
4
5#include "./TotalSmbx.h"
6
7#include "../../shared/shared.h"
8#include "../../include/include.h"
9#include "../../toolkits/toolkits.h"
10#include "../../EnumDefinitions/EnumDefinitions.h"
11
12void TotalSmbx(IssmDouble* pSmb, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials,Parameters* parameters,bool process_units){
13
14 IssmDouble local_smb = 0;
15 IssmDouble total_smb;
16
17 for(int i=0;i<elements->Size();i++){
18 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
19 local_smb+=element->TotalSmb();
20 }
21 #ifdef _HAVE_MPI_
22 MPI_Reduce(&local_smb,&total_smb,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
23 MPI_Bcast(&total_smb,1,MPI_DOUBLE,0,IssmComm::GetComm());
24 #else
25 total_smb=local_smb;
26 #endif
27
28 /*Assign output pointers: */
29 *pSmb=total_smb;
30}
Note: See TracBrowser for help on using the repository browser.