ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
model17.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00007 #include <admodel.h>
00008 
00009 streampos ad_comm::change_datafile_name(const adstring& s,
00010   const streampos& off)
00011 {
00012   streampos tmp=0;
00013   if(ad_comm::global_datafile)
00014   {
00015     tmp=ad_comm::global_datafile->tellg();
00016     delete ad_comm::global_datafile;
00017   }
00018   adstring tmpstring;
00019   if (ad_comm::wd_flag)
00020     tmpstring += ad_comm::working_directory_path + s;
00021   else
00022     tmpstring=s;
00023   global_datafile= new cifstream(tmpstring);
00024   if ( (!global_datafile) || !(*global_datafile))
00025   {
00026     cerr << "Error trying to open data input file " <<  s << endl;
00027     delete global_datafile;
00028     global_datafile=NULL;
00029     exit(1);
00030   }
00031   if (off)
00032   {
00033     ad_comm::global_datafile->seekg(off);
00034   }
00035   return tmp;
00036 }
00037 
00038 streampos ad_comm::change_pinfile_name(const adstring& s,
00039   const streampos& off)
00040 {
00041   streampos tmp=0;
00042   if(ad_comm::global_parfile)
00043   {
00044     tmp=ad_comm::global_parfile->tellg();
00045     delete ad_comm::global_parfile;
00046   }
00047   global_parfile= new cifstream(s);
00048   if ( (!global_parfile) || !(*global_parfile))
00049   {
00050     cerr << "Error trying to open parameter input file " <<  s << endl;
00051     delete global_parfile;
00052     global_parfile=NULL;
00053     exit(1);
00054   }
00055   if (off)
00056   {
00057     ad_comm::global_parfile->seekg(off);
00058   }
00059   return tmp;
00060 }