| 1 |
/* |
| 2 |
* Copyright (C) 1996-2011 Daniel Waggoner and Tao Zha |
| 3 |
* |
| 4 |
* This free software: you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation, either version 3 of the License, or |
| 7 |
* (at your option) any later version. |
| 8 |
* |
| 9 |
* It is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU General Public License for more details. |
| 13 |
* |
| 14 |
* If you did not received a copy of the GNU General Public License |
| 15 |
* with this software, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
#include "switch.h" |
| 19 |
#include "switchio.h" |
| 20 |
#include "VARbase.h" |
| 21 |
#include "VARio.h" |
| 22 |
#include "VARio_matlab.h" |
| 23 |
#include "dw_error.h" |
| 24 |
#include "dw_ascii.h" |
| 25 |
#include "dw_std.h" |
| 26 |
|
| 27 |
#include <stdlib.h> |
| 28 |
#include <string.h> |
| 29 |
|
| 30 |
|
| 31 |
/* |
| 32 |
Creates a standard initialization file from the matlab and specification file. |
| 33 |
*/ |
| 34 |
int main(int nargs, char **args) |
| 35 |
{ |
| 36 |
TStateModel *model; |
| 37 |
FILE *f_out; |
| 38 |
char *filename, *fmt="init_%s.dat", *header="Initial: "; |
| 39 |
|
| 40 |
dw_SetTerminalErrors(ALL_ERRORS); |
| 41 |
dw_SetVerboseErrors(ALL_ERRORS); |
| 42 |
|
| 43 |
if (nargs != 4) |
| 44 |
{ |
| 45 |
printf("Syntax:\n create_init_file <matlab filename> <specs filename> <file tag>\n"); |
| 46 |
dw_exit(0); |
| 47 |
} |
| 48 |
|
| 49 |
model=Combine_matlab_standard(args[1],args[2]); |
| 50 |
ReadConstantParameters(args[1],model); |
| 51 |
|
| 52 |
sprintf(filename=(char*)dw_malloc(strlen(fmt) + strlen(args[3]) - 1),fmt,args[3]); |
| 53 |
f_out=dw_CreateTextFile(filename); |
| 54 |
Write_VAR_Specification(f_out,(char*)NULL,model); |
| 55 |
WriteBaseTransitionMatrices(f_out,(char*)NULL,header,model); |
| 56 |
Write_VAR_Parameters(f_out,(char*)NULL,header,model); |
| 57 |
fclose(f_out); |
| 58 |
FreeStateModel(model); |
| 59 |
|
| 60 |
return 0; |
| 61 |
} |