Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Annotation of /trunk/gadget/interruptinterface.cc
[mareframe] / trunk / gadget / interruptinterface.cc Repository:
ViewVC logotype

Annotation of /trunk/gadget/interruptinterface.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : agomez 1 #include "interruptinterface.h"
2 :     #include "charptrvector.h"
3 :     #include "ecosystem.h"
4 :     #include "gadget.h"
5 :    
6 :     extern Ecosystem* EcoSystem;
7 :    
8 :     void InterruptInterface::printMenu() {
9 :     if (EcoSystem->getFuncEval() != 0)
10 :     cout << "\nInterrupted after " << EcoSystem->getFuncEval() << " iterations ...";
11 :     cout << "\nInterrupted at year " << EcoSystem->getCurrentYear() << ", step "
12 :     << EcoSystem->getCurrentStep() << " (" << EcoSystem->getCurrentTime()
13 :     << " of " << EcoSystem->numTotalSteps() << " timesteps)\n"
14 :     << " q -> quit simulation\n"
15 :     << " c -> continue simulation\n"
16 :     << " p -> write current parameters to file\n"
17 :     << " f -> dump current model to file\n";
18 :     cout.flush();
19 :     }
20 :    
21 :     int InterruptInterface::menu() {
22 :    
23 :     char userinput[MaxStrLength];
24 :     char interruptfile[MaxStrLength];
25 :     strncpy(userinput, "", MaxStrLength);
26 :     strncpy(interruptfile, "", MaxStrLength);
27 :    
28 :     this->printMenu();
29 :     while (1) {
30 :     cout << "> ";
31 :     cout.flush();
32 :     while (fgets(userinput, MaxStrLength, stdin) == 0) {};
33 :     switch (userinput[0]) {
34 :     case 'c':
35 :     case 'C':
36 :     cout << "\nContinuing current simulation ...\n";
37 :     cout.flush();
38 :     return 1;
39 :     case 'q':
40 :     case 'Q':
41 :     cout << "\nQuitting current simulation ...\nThe best parameter values will be written to file (called interrupt.out)\n";
42 :     cout.flush();
43 :     return 0;
44 :     case 'f':
45 :     case 'F':
46 :     cout << "\nWriting current model to file (called modeldump.out) ...\n";
47 :     strcpy(interruptfile, "modeldump.out");
48 :     EcoSystem->writeStatus(interruptfile);
49 :     strncpy(interruptfile, "", MaxStrLength); //JMB clear the text string
50 :     break;
51 :     case 'p':
52 :     case 'P':
53 :     cout << "\nWriting current parameters to file (called current.out) ...\n";
54 :     strcpy(interruptfile, "current.out");
55 :     EcoSystem->writeParams(interruptfile, 0);
56 :     strncpy(interruptfile, "", MaxStrLength); //JMB clear the text string
57 :     break;
58 :     case 'h':
59 :     case 'H':
60 :     case '?':
61 :     this->printMenu();
62 :     break;
63 :     default:
64 :     break;
65 :     }
66 :     }
67 :     return 1; //JMB default return value
68 :     }

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge