AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
AbstractLinAlgPack_MA28Solver.cpp
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
5 // Copyright (2003) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #include "Moocho_ConfigDefs.hpp"
43 
44 
45 #ifdef HAVE_MOOCHO_MA28
46 
47 
48 #include "AbstractLinAlgPack_MA28Solver.hpp"
49 
50 // Initialize static variables
51 MA28_Cpp::MA28Solver* MA28_Cpp::MA28Solver::curr_solver_ = 0;
52 
53 // Initialize the references to the ma28 common blocks defined in the fortran code.
54 MA28_Cpp::MA28CommonBlockReferences MA28_Cpp::MA28Solver::ma28_common_blocks_(
55  MA28_CppDecl::ma28ed_cb,
56  MA28_CppDecl::ma28fd_cb,
57  MA28_CppDecl::ma28gd_cb,
58  MA28_CppDecl::ma28hd_cb,
59  MA28_CppDecl::ma30ed_cb,
60  MA28_CppDecl::ma30fd_cb,
61  MA28_CppDecl::ma30gd_cb,
62  MA28_CppDecl::ma30hd_cb,
63  MA28_CppDecl::ma30id_cb,
64  MA28_CppDecl::mc23bd_cb
65  );
66 
67 // Save the default values of the ma28 common block variables.
68 // By setting the references to the common block variables first we are guarented that
69 // references will be bound to the proper memory locations. The only problem with this is that
70 // how can I be sure that the initializations for the fortran BLOCK DATA units have
71 // be performed before these global initializations are carried out. I need to look into this in
72 // different platforms to ensure that this will work. Otherwise I will just have to set the
73 // default values myself.
74 MA28_Cpp::MA28CommonBlockStorage MA28_Cpp::MA28Solver::default_common_blocks_(
75  MA28Solver::ma28_common_blocks_);
76 
77 // ///////////////////////////////
78 // Member functions
79 
81  : common_blocks_(default_common_blocks_), changed_(false)
82 {
83  mp(0); // We can't print to standard fortran streams from C++
84  lp(0);
85 }
86 
87 MA28_Cpp::MA28Solver::MA28Solver(const MA28Solver& s)
88  : common_blocks_(s.common_blocks_), changed_(false)
89 {}
90 
91 void MA28_Cpp::MA28Solver::set_common_block_data() {
92  // Copy to the ma28 ma28 common blocks if this is not the current solver.
93  if( (this != curr_solver_ )|| ( (this == curr_solver_) && changed_ ) )
94  ma28_common_blocks_ = common_blocks_;
95  // Make this solver the current solver
96  curr_solver_ = this;
97  changed_ = false;
98 }
99 
100 void MA28_Cpp::MA28Solver::get_common_block_data() {
101  // You must save the common block data back in order to get the return parameters.
102  // Later I should differentiate what is control and what is return but for
103  // now this is the easiest thing to do.
104  common_blocks_ = ma28_common_blocks_;
105 }
106 
107 
108 #endif // HAVE_MOOCHO_MA28
MA28Solver()
Construct a solver object that is initialized with the default common block data variables.
MA28 Basic Encapsulation Class.