📄 paws_test2.cpp
字号:
// -*- C++ -*-
// ACL:license
// ----------------------------------------------------------------------
// This software and ancillary information (herein called "SOFTWARE")
// called POOMA (Parallel Object-Oriented Methods and Applications) is
// made available under the terms described here. The SOFTWARE has been
// approved for release with associated LA-CC Number LA-CC-98-65.
//
// Unless otherwise indicated, this SOFTWARE has been authored by an
// employee or employees of the University of California, operator of the
// Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with
// the U.S. Department of Energy. The U.S. Government has rights to use,
// reproduce, and distribute this SOFTWARE, and to allow others to do so.
// The public may copy and use this SOFTWARE, FOR NONCOMMERCIAL USE ONLY,
// without charge, provided that this Notice and any statement of
// authorship are reproduced on all copies. Neither the Government nor
// the University makes any warranty, express or implied, or assumes any
// liability or responsibility for the use of this SOFTWARE.
//
// If SOFTWARE is modified to produce derivative works, such modified
// SOFTWARE should be clearly marked, so as not to confuse it with the
// version available from LANL.
//
// For more information about POOMA, send e-mail to pooma@acl.lanl.gov,
// or visit the POOMA web page at http://www.acl.lanl.gov/pooma/.
// ----------------------------------------------------------------------
// ACL:license
//-----------------------------------------------------------------------------
// Paws test 2: Send and Receive an int and double set of scalars
// in conjunction with test 1.
//-----------------------------------------------------------------------------
#include "Pooma/Pooma.h"
#include "Pooma/Paws.h"
#include "Utilities/Tester.h"
int main(int argc, char *argv[])
{
// Initialize POOMA and output stream, using Tester class
Pooma::initialize(argc, argv);
Pooma::Tester tester(argc, argv);
tester.out() << argv[0] << ": Paws scalar send/receive test B" << std::endl;
tester.out() << "--------------------------------------------" << std::endl;
// Some scalars to send and receive
int s1 = 1, origs1 = 1;
double s2 = 2.5, origs2 = 2.5;
std::string str1("Sender's Orig");
std::string str2("Sender's Modified");
std::string origstr1 = str1;
// Create a Paws connection
tester.out() << "Creating Connection<Paws> object ..." << std::endl;
Connection<Paws> *paws = new Connection<Paws>("test2", argc, argv);
tester.out() << "Finished creating Connection<Paws> object." << std::endl;
// Establish connections for the two scalars
tester.out() << "Connecting s1 = " << s1 << " for input ..." << std::endl;
paws->connectScalar("s1", s1, ConnectionBase::in);
tester.out() << "Connecting s2 = " << s2 << " for output ..." << std::endl;
paws->connectScalar("s2", s2, ConnectionBase::out);
// Establish connection for the string
tester.out() << "Connecting str1 = '"<< str1 <<"' for input ..."<<std::endl;
paws->connectScalar("str1", str1, ConnectionBase::in);
// Wait for everything to be ready to proceed
tester.out() << "Waiting for ready signal ..." << std::endl;
paws->ready();
tester.out() << "Ready complete, moving on." << std::endl;
// Modify s1, and update
s1 *= 2;
str1 = str2;
tester.out() << "Updating current s1 = " << s1 << "s2 = " << s2;
tester.out() << " and str1 = '" << str1 << "' ..." << std::endl;
paws->update();
// Report the results
tester.out() << "Received update. New values:" << std::endl;
tester.out() << " s1 = " << s1 << " (should be " << origs1 << ")\n";
tester.out() << " s2 = " << s2 << " (should be " << origs2 << ")\n";
tester.out() << "str1 = " << str1 << " (should be " << origstr1 << ")\n";
tester.out() << std::endl;
tester.check("s1 OK", s1 == origs1);
tester.check("s2 OK", s2 == origs2);
tester.check("str1 OK", str1 == origstr1);
// Delete PAWS connection, disconnecting us from the other code.
tester.out() << "Deleting Connection<Paws> object ..." << std::endl;
delete paws;
// Finish up and report results
tester.out() << "-------------------------------------------" << std::endl;
int retval = tester.results("Paws scalar send/receive test B");
Pooma::finalize();
return retval;
}
// ACL:rcsinfo
// ----------------------------------------------------------------------
// $RCSfile: paws_test2.cpp,v $ $Author: bfh $
// $Revision: 1.4 $ $Date: 1999/10/27 22:33:34 $
// ----------------------------------------------------------------------
// ACL:rcsinfo
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -