Revision 752 branches/threaded2/src/nh99/mod_sd.cpp

mod_sd.cpp (revision 752)
4 4
 * Author: David Fournier
5 5
 * Copyright (c) 2008-2012 Regents of the University of California 
6 6
 */
7
#include <sstream>
8
#include <thread>
9
#include <cassert>
7 10
#if defined(USE_LAPLACE)
8 11
#  include <df1b2fun.h>
9 12
#endif
......
58 61
  {
59 62
    //if ((initial_params::varsptr[i])->phase_start
60 63
     // <= initial_params::current_phase)
61
    if (withinbound(0,(initial_params::varsptr[i])->phase_start,
64
    if (withinbound(0,(initial_params::varsptr->operator[](i))->phase_start,
62 65
      initial_params::current_phase))
63 66
    {
64 67
      param_labels[ii]=
65
       (initial_params::varsptr[i])->label();
68
       (initial_params::varsptr->operator[](i))->label();
66 69
      param_size[ii]=
67
       (initial_params::varsptr[i])->size_count();
70
       (initial_params::varsptr->operator[](i))->size_count();
68 71
      if (max_name_length<param_labels[ii].size())
69 72
      {
70 73
        max_name_length=param_labels[ii].size();
......
96 99
  dvector v(1,nvar);  // need to read in v from model.rep
97 100
  dmatrix S(1,nvar,1,nvar);
98 101
  {
99
    uistream cif("admodel.cov");
100
    int tmp_nvar;
101
    cif >> tmp_nvar;
102
    if (nvar !=tmp_nvar)
102
    std::thread::id this_thread_id = std::this_thread::get_id();
103
    std::ostringstream oss;
104
    oss << *ad_comm::adprogram_name << this_thread_id << ".cov";
105
    uistream cif(oss.str().c_str());
106
    if (cif.is_open())
103 107
    {
104
      cerr << "Incorrect number of independent variables in file"
105
        " model.cov" << endl;
106
      exit(1);
108
      int tmp_nvar;
109
      cif >> tmp_nvar;
110
      assert(nvar == tmp_nvar);
111

  
112
      cif >> S;
113
      cif.close();
107 114
    }
108
    cif >> S;
109
    if (!cif)
115
    else
110 116
    {
111
      cerr << "error reading covariance matrix from model.cov" << endl;
112
      exit(1);
117
      cerr << "Error: Unable to open " << oss.str() << " for covariance matrix.\n";
118
      //JCA exit(1);
113 119
    }
114 120
  }
115 121
  int sgn;
......
121 127
  dvector tmp(1,nvar1+ndvar);
122 128

  
123 129
  {
124
    ofstream ofs("admodel.tmp");
125

  
126

  
130
    std::thread::id this_thread_id = std::this_thread::get_id();
131
    std::ostringstream oss;
132
    oss << "admodel" << this_thread_id << ".tmp";
133
    ofstream ofs(oss.str().c_str());
127 134
    #if defined(__GNU__) || defined(DOS386)  || defined(__GNUDOS__)
128 135
    // *******************************************************
129 136
    // *******************************************************
......
142 149
          diag(i)=tmp(i);
143 150
        }
144 151
        dmatrix tv(1,ndvar,1,nvar1);
145
        adstring tmpstring="admodel.dep";
146
        if (ad_comm::wd_flag)
147
           tmpstring = ad_comm::adprogram_name + ".dep";
148
        cifstream cif((char*)tmpstring);
152
        std::ostringstream oss2;
153
        oss2 << *ad_comm::adprogram_name << this_thread_id << ".dep";
154
        cifstream cif(oss2.str().c_str());
149 155
      
150 156
        int tmp_nvar,tmp_ndvar;
151 157
        cif >> tmp_nvar >> tmp_ndvar;
152
        if (tmp_nvar!=nvar1)
153
        {
154
          cerr << " tmp_nvar != nvar1 in file " << tmpstring
155
                 << endl;
156
          ad_exit(1);
157
        }
158
        assert(tmp_nvar == nvar1);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff