MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / OPS_send

Function OPS_send

SRC/interpreter/OpenSeesMiscCommands.cpp:1637–1716  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1635}
1636
1637int OPS_send()
1638{
1639#ifdef _PARALLEL_INTERPRETERS
1640
1641 // get ids
1642 int otherPID = -1;
1643 int myPID = 0;
1644 MPI_Comm_rank(MPI_COMM_WORLD, &myPID);
1645
1646 int np = 0;
1647 MPI_Comm_size(MPI_COMM_WORLD, &np);
1648
1649 if (OPS_GetNumRemainingInputArgs() < 1) {
1650 opserr << "WARNING: need send <'-pid' pid> data\n";
1651 return -1;
1652 }
1653
1654 // get other pid
1655 const char *sdata = OPS_GetString();
1656 if (strcmp(sdata, "-pid") == 0) {
1657 if (OPS_GetNumRemainingInputArgs() > 0) {
1658 int num = 1;
1659 if (OPS_GetIntInput(&num, &otherPID) < 0) {
1660 opserr << "WARNING: failed to get pid\n";
1661 return -1;
1662 }
1663 if (otherPID<0 || otherPID>=np || otherPID==myPID) {
1664 opserr << "WARNING: invalid pid "<<otherPID<<"\n";
1665 return -1;
1666 }
1667 } else {
1668 opserr << "WARNING: need pid\n";
1669 return -1;
1670 }
1671 } else {
1672 opserr << "WARNING: -pid is required\n";
1673 return -1;
1674 }
1675
1676 // get data type
1677 int num = OPS_GetNumRemainingInputArgs();
1678 if (num < 1) {
1679 opserr << "WARNING: need data\n";
1680 return -1;
1681 }
1682
1683 std::vector<double> ddata(num);
1684 MPI_Datatype datatype = MPI_DOUBLE;
1685 if (OPS_GetDoubleInput(&num, &ddata[0]) < 0) {
1686 if (num > 1) {
1687 opserr << "WARNING: data is string and size must be 1\n";
1688 return -1;
1689 }
1690 datatype = MPI_CHAR;
1691 OPS_ResetCurrentInputArg(-1);
1692 sdata = OPS_GetString();
1693 }
1694

Callers 2

Tcl_ops_sendFunction · 0.85
Py_ops_sendFunction · 0.85

Calls 5

OPS_GetStringFunction · 0.70
OPS_GetIntInputFunction · 0.70
OPS_GetDoubleInputFunction · 0.70
OPS_ResetCurrentInputArgFunction · 0.70

Tested by

no test coverage detected