[793] | 1 | //----------------------------------------------------------------------------// |
---|
| 2 | // Current revisions: |
---|
| 3 | // ----------------- |
---|
| 4 | // |
---|
[921] | 5 | // |
---|
[793] | 6 | // Former revisions: |
---|
| 7 | // ----------------- |
---|
| 8 | // $Id: mainwindow.cpp 921 2012-06-05 10:16:11Z hoffmann $ |
---|
| 9 | // |
---|
[921] | 10 | // mainwindow.cpp 920 2012-06-05 09:56:53Z maronga |
---|
| 11 | // Added -Z option (disable combine_plot_fields) |
---|
| 12 | // |
---|
[819] | 13 | // 818 2012-02-08 16:11:23Z maronga |
---|
| 14 | // New: flag parameter -z implemented (used for skipping parameter file check) |
---|
| 15 | // |
---|
[812] | 16 | // 811 2012-01-31 09:45:54Z maronga |
---|
| 17 | // Bugfix: waitForFinished time exceeded limits, adjusted to 1h waiting time |
---|
| 18 | // |
---|
[810] | 19 | // 809 2012-01-30 13:32:58Z marong |
---|
| 20 | // Bugfix: waiting for 20 minutes does not suffice for local runs |
---|
| 21 | // |
---|
[794] | 22 | // 793 2011-12-12 15:15:24Z maronga |
---|
| 23 | // Initial revision |
---|
| 24 | // |
---|
[793] | 25 | // Description: |
---|
| 26 | // ------------ |
---|
| 27 | // All subroutines for mrungui |
---|
| 28 | //----------------------------------------------------------------------------// |
---|
| 29 | |
---|
| 30 | #include <QtGui/QApplication> |
---|
| 31 | #include "mainwindow.h" |
---|
| 32 | #include "ui_mainwindow.h" |
---|
| 33 | #include "ui_about.h" |
---|
| 34 | #include "ui_help.h" |
---|
| 35 | #include <QString> |
---|
| 36 | #include <QFileDialog> |
---|
| 37 | #include <QDateTime> |
---|
| 38 | #include "stdlib.h" |
---|
| 39 | #include <QProcess> |
---|
| 40 | #include <QTextStream> |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | // Define username on host as global variable |
---|
| 44 | QString username = getenv("USER"); |
---|
| 45 | // Define variable branch (location of mrungui, e.g. |
---|
| 46 | // "/home/user/palm/current_version" |
---|
| 47 | QString branch; |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | //****************************************************************************// |
---|
| 51 | // Initialization of the main window |
---|
| 52 | MainWindow::MainWindow(QWidget *parent) : |
---|
| 53 | QMainWindow(parent), |
---|
| 54 | ui(new Ui::MainWindow) |
---|
| 55 | { |
---|
| 56 | ui->setupUi(this); |
---|
| 57 | |
---|
| 58 | // Empty the mrun command line (hereafter mrunline) |
---|
| 59 | ui->commandline->setText(""); |
---|
| 60 | |
---|
| 61 | // Get path of the program and set default file |
---|
| 62 | branch = QCoreApplication::applicationDirPath(); |
---|
| 63 | branch = branch.left(branch.length() - 14); |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | QFile file(branch+"/.mrun.gui.default"); |
---|
| 67 | |
---|
| 68 | // Read default settings |
---|
| 69 | if ( file.exists() == true && file.size() > 10) |
---|
| 70 | { |
---|
| 71 | |
---|
| 72 | QString mrunline; |
---|
| 73 | if ( file.open(QIODevice::ReadOnly | QIODevice::Text ) ) |
---|
| 74 | { |
---|
| 75 | |
---|
| 76 | // File opened successfully |
---|
| 77 | QTextStream in(&file); |
---|
| 78 | |
---|
| 79 | QString line = in.readLine(); |
---|
| 80 | while (!line.isNull()) |
---|
| 81 | { |
---|
| 82 | mrunline = line; |
---|
| 83 | line = in.readLine(); |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | file.close(); |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | mrunline = mrunline.right(mrunline.length() - 17); |
---|
| 90 | ui->commandline->setText(mrunline); |
---|
| 91 | |
---|
| 92 | setup_gui(mrunline); |
---|
| 93 | |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | // Load jobs into the recent jobs list |
---|
| 97 | recent_jobs(10); |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | |
---|
| 101 | //****************************************************************************// |
---|
| 102 | // Routine for listing jobs in the recent jobs list |
---|
| 103 | int MainWindow::recent_jobs(int noj) |
---|
| 104 | { |
---|
| 105 | branch = QCoreApplication::applicationDirPath(); |
---|
| 106 | branch = branch.left(branch.length() - 14); |
---|
| 107 | |
---|
| 108 | QFile file(branch+"/.mrun.history"); |
---|
| 109 | QString listitem, timestamp; |
---|
| 110 | |
---|
| 111 | // Read mrun history and select the last used jobs |
---|
| 112 | if ( file.exists() == true && file.size() > 10) |
---|
| 113 | { |
---|
| 114 | |
---|
| 115 | // Open history |
---|
| 116 | QStringList history, tmphistory; |
---|
| 117 | if ( file.open(QIODevice::ReadOnly | QIODevice::Text ) ) |
---|
| 118 | { |
---|
| 119 | |
---|
| 120 | // file opened successfully |
---|
| 121 | QTextStream in(&file); |
---|
| 122 | |
---|
| 123 | QString line = in.readLine(); |
---|
| 124 | while (!line.isNull()) |
---|
| 125 | { |
---|
| 126 | history.append(line); |
---|
| 127 | line = in.readLine(); |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | file.close(); |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | int j = 0; |
---|
| 134 | |
---|
| 135 | ui->list_jobname->clear(); |
---|
| 136 | |
---|
| 137 | // Read history entries and append to recent job list |
---|
| 138 | for (int i=history.count(); i>=1; i--) |
---|
| 139 | { |
---|
| 140 | timestamp = history[i-1].left(16); |
---|
| 141 | listitem = history[i-1].right(history[i-1].length() - 17); |
---|
| 142 | listitem = listitem.split("-d ", QString::SkipEmptyParts)[1]; |
---|
| 143 | listitem = listitem.split(" -", QString::SkipEmptyParts)[0]; |
---|
| 144 | listitem = listitem.replace(" ",""); |
---|
| 145 | |
---|
| 146 | QList<QListWidgetItem *> matchitems = \ |
---|
| 147 | ui->list_jobname->findItems(listitem, Qt::MatchExactly); |
---|
| 148 | |
---|
| 149 | if ( matchitems.count() == 0 ) |
---|
| 150 | { |
---|
| 151 | ui->list_jobname->addItem(listitem); |
---|
| 152 | tmphistory.append(listitem+" ("+timestamp+")"); |
---|
| 153 | j++; |
---|
| 154 | } |
---|
| 155 | if ( j == noj ) |
---|
| 156 | { |
---|
| 157 | break; |
---|
| 158 | } |
---|
| 159 | } |
---|
| 160 | |
---|
| 161 | // Send to list |
---|
| 162 | ui->list_jobname->clear(); |
---|
| 163 | for (int i=tmphistory.count(); i>=1; i--) |
---|
| 164 | { |
---|
| 165 | ui->list_jobname->addItem(tmphistory[i-1]); |
---|
| 166 | } |
---|
| 167 | |
---|
| 168 | } |
---|
| 169 | return 0; |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | //****************************************************************************// |
---|
| 173 | // Exit program |
---|
| 174 | MainWindow::~MainWindow() |
---|
| 175 | { |
---|
| 176 | |
---|
| 177 | delete ui; |
---|
| 178 | } |
---|
| 179 | |
---|
| 180 | |
---|
| 181 | //****************************************************************************// |
---|
| 182 | // Start the mrun command via xterm |
---|
| 183 | int MainWindow::startmrun() |
---|
| 184 | { |
---|
| 185 | |
---|
| 186 | QString xtermoutput; |
---|
| 187 | QString mrunline_save; |
---|
| 188 | QString history_line; |
---|
| 189 | QString mrunline = ui->commandline->text(); |
---|
| 190 | QString userline = ui->line_user->text(); |
---|
| 191 | |
---|
| 192 | // Check for empty line |
---|
| 193 | mrunline_save = mrunline; |
---|
| 194 | if (userline != "") |
---|
| 195 | { |
---|
| 196 | mrunline = mrunline + " " + userline; |
---|
| 197 | } |
---|
| 198 | history_line = mrunline; |
---|
| 199 | |
---|
| 200 | // Disable the main window |
---|
| 201 | ui->group_job->setEnabled(false); |
---|
| 202 | ui->group_execution->setEnabled(false); |
---|
| 203 | ui->group_runcontrol->setEnabled(false); |
---|
| 204 | ui->group_advanced->setEnabled(false); |
---|
| 205 | ui->check_advanced->setEnabled(false); |
---|
| 206 | ui->check_verbose->setEnabled(false); |
---|
[818] | 207 | ui->check_namelist_check->setEnabled(false); |
---|
[793] | 208 | ui->button_start->setEnabled(false); |
---|
| 209 | ui->button_start->setText("wait..."); |
---|
| 210 | |
---|
| 211 | branch = QCoreApplication::applicationDirPath(); |
---|
| 212 | branch = branch.left(branch.length() - 14); |
---|
| 213 | |
---|
| 214 | ui->commandline->setText("Executing MRUN in xterm..."); |
---|
| 215 | |
---|
| 216 | // Wait until all commands have been executed (ugly) |
---|
| 217 | for(int i=0; i<20; i++) |
---|
| 218 | qApp->processEvents(); |
---|
| 219 | |
---|
| 220 | // Start xterm as QProcess |
---|
| 221 | QProcess mrun; |
---|
| 222 | mrun.setProcessChannelMode(QProcess::MergedChannels); |
---|
| 223 | mrun.setWorkingDirectory(branch); |
---|
| 224 | |
---|
| 225 | mrunline = " -title \"Executing MRUN...\" -geometry \"100x55+970+0\" -e \""\ |
---|
| 226 | +mrunline.replace("\"","\'")\ |
---|
| 227 | +";echo -n '--> Press Enter to continue...';read yesno\""; |
---|
| 228 | |
---|
| 229 | mrun.start("xterm"+mrunline); |
---|
| 230 | |
---|
| 231 | if(!mrun.waitForStarted()) |
---|
| 232 | return 0; |
---|
| 233 | |
---|
| 234 | // while(mrun.waitForReadyRead()) |
---|
| 235 | // xtermoutput = xtermoutput+mrun.readAllStandardOutput(); |
---|
| 236 | |
---|
[811] | 237 | // Wait until mrun has finished or wait for 200 minutes |
---|
| 238 | mrun.waitForFinished(3600000); |
---|
[793] | 239 | |
---|
| 240 | |
---|
| 241 | // Jobs has been submitted or aborted. Continuing... |
---|
| 242 | // Save the mrun command to history file |
---|
| 243 | QString filename = branch+"/.mrun.history"; |
---|
| 244 | |
---|
| 245 | QDateTime time = QDateTime::currentDateTime(); |
---|
| 246 | QString tmptime = time.toString("yyyy/MM/dd hh:mm"); |
---|
| 247 | |
---|
| 248 | QFile file(filename); |
---|
| 249 | file.open(QIODevice::Append | QIODevice::Text); |
---|
| 250 | QTextStream out(&file); |
---|
| 251 | out << tmptime + " " + history_line + "\n"; |
---|
| 252 | file.close(); |
---|
| 253 | |
---|
| 254 | // Enable main window again |
---|
| 255 | ui->group_job->setEnabled(true); |
---|
| 256 | ui->group_execution->setEnabled(true); |
---|
| 257 | ui->group_runcontrol->setEnabled(true); |
---|
| 258 | if ( ui->check_advanced->isChecked() == true) |
---|
| 259 | { |
---|
| 260 | ui->group_advanced->setEnabled(true); |
---|
| 261 | } |
---|
| 262 | ui->check_advanced->setEnabled(true); |
---|
| 263 | ui->check_verbose->setEnabled(true); |
---|
[818] | 264 | ui->check_namelist_check->setEnabled(true); |
---|
[793] | 265 | ui->button_start->setEnabled(true); |
---|
| 266 | ui->action_save->setEnabled(true); |
---|
| 267 | ui->button_start->setText("MRUN Start"); |
---|
| 268 | ui->commandline->setText(mrunline_save); |
---|
| 269 | |
---|
| 270 | // Reload recent jobs |
---|
| 271 | recent_jobs(10); |
---|
| 272 | |
---|
| 273 | return 0; |
---|
| 274 | } |
---|
| 275 | |
---|
| 276 | |
---|
| 277 | //****************************************************************************// |
---|
| 278 | // Disable/Enable advanced settings dialog |
---|
| 279 | int MainWindow::enable_advanced() |
---|
| 280 | { |
---|
| 281 | bool status; |
---|
| 282 | |
---|
| 283 | status = ui->group_advanced->isEnabled(); |
---|
| 284 | if (status == true) |
---|
| 285 | { |
---|
| 286 | ui->group_advanced->setEnabled(false); |
---|
| 287 | } |
---|
| 288 | else |
---|
| 289 | { |
---|
| 290 | ui->group_advanced->setEnabled(true); |
---|
| 291 | } |
---|
| 292 | |
---|
| 293 | return 0; |
---|
| 294 | } |
---|
| 295 | |
---|
| 296 | |
---|
| 297 | //****************************************************************************// |
---|
| 298 | // Disable/enable dialog for coupled runs |
---|
| 299 | int MainWindow::enable_coupled() |
---|
| 300 | { |
---|
| 301 | QString status; |
---|
| 302 | |
---|
| 303 | status = ui->drop_job->currentText(); |
---|
| 304 | if (status == "Coupled restart") |
---|
| 305 | { |
---|
| 306 | ui->label_coupled1->setEnabled(true); |
---|
| 307 | ui->label_coupled2->setEnabled(true); |
---|
| 308 | ui->label_coupled3->setEnabled(true); |
---|
| 309 | ui->line_PE_atmos->setEnabled(true); |
---|
| 310 | ui->line_PE_ocean->setEnabled(true); |
---|
| 311 | |
---|
| 312 | QString pe_total = ui->line_pe->text(); |
---|
| 313 | QString pe_atmos = ui->line_PE_atmos->text(); |
---|
| 314 | QString pe_ocean = ui->line_PE_ocean->text(); |
---|
| 315 | if (pe_total != "") |
---|
| 316 | { |
---|
| 317 | int PE_split = pe_total.toInt()/2; |
---|
| 318 | ui->line_PE_atmos->setText(QString::number(PE_split)); |
---|
| 319 | ui->line_PE_ocean->setText(QString::number(PE_split)); |
---|
| 320 | } |
---|
| 321 | } |
---|
| 322 | else |
---|
| 323 | { |
---|
| 324 | ui->label_coupled1->setEnabled(false); |
---|
| 325 | ui->label_coupled2->setEnabled(false); |
---|
| 326 | ui->label_coupled3->setEnabled(false); |
---|
| 327 | ui->line_PE_atmos->setEnabled(false); |
---|
| 328 | ui->line_PE_ocean->setEnabled(false); |
---|
| 329 | } |
---|
| 330 | |
---|
| 331 | return 0; |
---|
| 332 | } |
---|
| 333 | |
---|
| 334 | |
---|
| 335 | //****************************************************************************// |
---|
| 336 | // Choose job from dialog |
---|
| 337 | int MainWindow::choosejob() |
---|
| 338 | { |
---|
| 339 | QString filename; |
---|
| 340 | branch = QCoreApplication::applicationDirPath(); |
---|
| 341 | branch = branch.left(branch.length() - 14); |
---|
| 342 | |
---|
| 343 | QString jobdir = branch+"/JOBS"; |
---|
| 344 | |
---|
| 345 | |
---|
| 346 | // Pick a job from dialog |
---|
| 347 | filename = QFileDialog::getExistingDirectory(this, \ |
---|
| 348 | tr("Choose a job directory"), branch+"/JOBS", \ |
---|
| 349 | QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks | \ |
---|
| 350 | QFileDialog::DontUseNativeDialog | QFileDialog::ReadOnly | \ |
---|
| 351 | QFileDialog::DontConfirmOverwrite); |
---|
| 352 | |
---|
| 353 | |
---|
| 354 | |
---|
| 355 | |
---|
| 356 | |
---|
| 357 | // If a file was selected, load it into mainwindow |
---|
| 358 | if ( filename != "") |
---|
| 359 | { |
---|
| 360 | filename = filename.right(filename.length() - jobdir.length() - 1); |
---|
| 361 | |
---|
| 362 | ui->line_jobname->setText(filename); |
---|
| 363 | ui->list_jobname->clearSelection(); |
---|
| 364 | |
---|
| 365 | // Change mrunline accordingly |
---|
| 366 | change_commandline("d",""); |
---|
| 367 | change_commandline("r",""); |
---|
| 368 | return 0; |
---|
| 369 | } |
---|
| 370 | else |
---|
| 371 | { |
---|
| 372 | return 1; |
---|
| 373 | } |
---|
| 374 | } |
---|
| 375 | |
---|
| 376 | |
---|
| 377 | //****************************************************************************// |
---|
| 378 | // Choose job from the recent job list and load all settings |
---|
| 379 | int MainWindow::choosejob_list() |
---|
| 380 | { |
---|
| 381 | QString filename, timestamp, jobname; |
---|
| 382 | |
---|
| 383 | // Get selected item from list |
---|
| 384 | filename = ui->list_jobname->currentItem()->text(); |
---|
| 385 | int itemint = ui->list_jobname->currentRow(); |
---|
| 386 | |
---|
| 387 | // Reload list |
---|
| 388 | ui->setupUi(this); |
---|
| 389 | recent_jobs(10); |
---|
| 390 | |
---|
| 391 | // Set selected item to jobname |
---|
| 392 | ui->list_jobname->item(itemint)->setSelected(true); |
---|
| 393 | |
---|
| 394 | timestamp = filename.right(17).left(16); |
---|
| 395 | jobname = filename.left(filename.length() - 19); |
---|
| 396 | |
---|
| 397 | branch = QCoreApplication::applicationDirPath(); |
---|
| 398 | branch = branch.left(branch.length() - 14); |
---|
| 399 | QFile file(branch+"/.mrun.history"); |
---|
| 400 | QString listitem; |
---|
| 401 | |
---|
| 402 | // Load history |
---|
| 403 | if ( file.exists() == true && file.size() > 10) |
---|
| 404 | { |
---|
| 405 | |
---|
| 406 | QStringList history; |
---|
| 407 | if ( file.open(QIODevice::ReadOnly | QIODevice::Text ) ) |
---|
| 408 | { |
---|
| 409 | |
---|
| 410 | // file opened successfully |
---|
| 411 | QTextStream in(&file); |
---|
| 412 | |
---|
| 413 | QString line = in.readLine(); |
---|
| 414 | while (!line.isNull()) |
---|
| 415 | { |
---|
| 416 | history.append(line); |
---|
| 417 | line = in.readLine(); |
---|
| 418 | } |
---|
| 419 | |
---|
| 420 | file.close(); |
---|
| 421 | } |
---|
| 422 | |
---|
| 423 | for (int i=history.count(); i>=1; i--) |
---|
| 424 | { |
---|
| 425 | listitem = history[i-1].right(history[i-1].length() - 17); |
---|
| 426 | listitem = listitem.split("-d ", QString::SkipEmptyParts)[1]; |
---|
| 427 | listitem = listitem.split(" -", QString::SkipEmptyParts)[0]; |
---|
| 428 | listitem = listitem.replace(" ",""); |
---|
| 429 | |
---|
| 430 | |
---|
| 431 | // Select command line with correct timestamp and jobname |
---|
| 432 | if (history[i-1].left(16) == timestamp && listitem == jobname) |
---|
| 433 | { |
---|
| 434 | QString mrunline = history[i-1]; |
---|
| 435 | mrunline = mrunline.right(mrunline.length() - 17); |
---|
| 436 | ui->commandline->setText(mrunline); |
---|
| 437 | |
---|
| 438 | setup_gui(mrunline); |
---|
| 439 | } |
---|
| 440 | } |
---|
| 441 | } |
---|
| 442 | |
---|
| 443 | return 0; |
---|
| 444 | } |
---|
| 445 | |
---|
| 446 | |
---|
| 447 | //****************************************************************************// |
---|
| 448 | // Change run identifer (initial, restart, coupled...) |
---|
| 449 | int MainWindow::change_rc_list() |
---|
| 450 | { |
---|
| 451 | |
---|
| 452 | |
---|
| 453 | QString drop_job = ui->drop_job->currentText(); |
---|
| 454 | |
---|
| 455 | change_commandline("r",""); |
---|
| 456 | |
---|
| 457 | // Enable PE distribution for atmosphere/ocean |
---|
| 458 | if ( drop_job == "Coupled restart") |
---|
| 459 | { |
---|
| 460 | QString drop_atmos = ui->line_PE_atmos->text(); |
---|
| 461 | QString drop_ocean = ui->line_PE_ocean->text(); |
---|
| 462 | |
---|
| 463 | change_commandline("Y",drop_atmos+" "+drop_ocean); |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | // Check of ocean runs |
---|
| 467 | else |
---|
| 468 | { |
---|
| 469 | delete_commandline("Y"); |
---|
| 470 | if (drop_job == "Precursor run (Ocean)") |
---|
| 471 | { |
---|
| 472 | activate_flag("y"); |
---|
| 473 | } |
---|
| 474 | else |
---|
| 475 | { |
---|
| 476 | deactivate_flag("y"); |
---|
| 477 | } |
---|
| 478 | } |
---|
| 479 | |
---|
| 480 | |
---|
| 481 | return 0; |
---|
| 482 | } |
---|
| 483 | |
---|
| 484 | |
---|
| 485 | //****************************************************************************// |
---|
| 486 | // Routine for processing any changes in the mainwindow settings |
---|
| 487 | int MainWindow::change_commandline(QString id,QString fwstring) |
---|
| 488 | { |
---|
| 489 | |
---|
| 490 | // First get the mrunline |
---|
| 491 | QString newmrunline; |
---|
| 492 | bool initialize=false; |
---|
| 493 | |
---|
| 494 | QString mrunline = ui->commandline->text(); |
---|
| 495 | |
---|
| 496 | QStringList splitline = mrunline.split(" -"+id+"", QString::SkipEmptyParts); |
---|
| 497 | if ( splitline.count() == 1) |
---|
| 498 | { |
---|
| 499 | splitline.append(" "); |
---|
| 500 | } |
---|
| 501 | else if ( splitline.count() == 0 ) |
---|
| 502 | { |
---|
| 503 | splitline.append("mrun"); |
---|
| 504 | splitline.append(" "); |
---|
| 505 | initialize = true; |
---|
| 506 | } |
---|
| 507 | |
---|
| 508 | QStringList param = splitline[1].split("-"); |
---|
| 509 | |
---|
| 510 | // Change in parameter "d" (jobname) |
---|
| 511 | if (id == "d") |
---|
| 512 | { |
---|
| 513 | QString filename = ui->line_jobname->text(); |
---|
| 514 | |
---|
| 515 | param[0] = filename.replace(" ",""); |
---|
| 516 | |
---|
| 517 | if ( initialize == true && ui->group_runcontrol->isEnabled() == true ) |
---|
| 518 | { |
---|
| 519 | ui->group_runcontrol->setEnabled(true); |
---|
| 520 | ui->group_execution->setEnabled(true); |
---|
| 521 | ui->drop_job->setEnabled(true); |
---|
| 522 | ui->check_advanced->setEnabled(true); |
---|
| 523 | ui->button_start->setEnabled(true); |
---|
| 524 | ui->action_save->setEnabled(true); |
---|
| 525 | } |
---|
| 526 | else if ( param[0] == "") |
---|
| 527 | { |
---|
| 528 | ui->group_runcontrol->setEnabled(false); |
---|
| 529 | ui->group_execution->setEnabled(false); |
---|
| 530 | ui->drop_job->setEnabled(false); |
---|
| 531 | ui->button_start->setEnabled(false); |
---|
| 532 | ui->action_save->setEnabled(false); |
---|
| 533 | ui->group_advanced->setEnabled(false); |
---|
| 534 | ui->check_advanced->setEnabled(false); |
---|
| 535 | delete_commandline("d"); |
---|
| 536 | change_commandline("r","remove"); |
---|
| 537 | ui->label_usercode->setText(""); |
---|
| 538 | return 1; |
---|
| 539 | } |
---|
| 540 | else |
---|
| 541 | { |
---|
| 542 | |
---|
| 543 | // Check if user code is available |
---|
| 544 | branch = QCoreApplication::applicationDirPath(); |
---|
| 545 | branch = branch.left(branch.length() - 14); |
---|
| 546 | QDir usercode = branch+"/USER_CODE/"+param[0]; |
---|
| 547 | if (usercode.exists() == true) |
---|
| 548 | { |
---|
| 549 | ui->label_usercode->setText("User code found."); |
---|
| 550 | } |
---|
| 551 | else |
---|
| 552 | { |
---|
| 553 | ui->label_usercode->setText("Warning: no user code found!"); |
---|
| 554 | } |
---|
| 555 | |
---|
| 556 | // Check if _pdf file is available, otherwise notice user |
---|
| 557 | if (ui->check_restarts->checkState() == 2) |
---|
| 558 | { |
---|
| 559 | QString jobname = ui->line_jobname->text(); |
---|
| 560 | QFile restartfile(branch+"/JOBS/"+jobname+"/INPUT/"+jobname+"_p3df"); |
---|
| 561 | if (restartfile.exists() == true) |
---|
| 562 | { |
---|
| 563 | ui->label_restart->setText(""); |
---|
| 564 | } |
---|
| 565 | else |
---|
| 566 | { |
---|
| 567 | ui->label_restart->setText("Warning: No p3df file found!"); |
---|
| 568 | } |
---|
| 569 | } |
---|
| 570 | |
---|
| 571 | ui->group_runcontrol->setEnabled(true); |
---|
| 572 | ui->group_execution->setEnabled(true); |
---|
| 573 | ui->drop_job->setEnabled(true); |
---|
| 574 | ui->check_advanced->setEnabled(true); |
---|
| 575 | |
---|
| 576 | if ( ui->check_advanced->isChecked() == true ) |
---|
| 577 | { |
---|
| 578 | ui->group_advanced->setEnabled(true); |
---|
| 579 | if ( ui->line_i->text() != "" || ui->line_o->text() != "") |
---|
| 580 | { |
---|
| 581 | change_commandline("r","remove"); |
---|
| 582 | ui->group_runcontrol->setEnabled(false); |
---|
| 583 | } |
---|
| 584 | } |
---|
| 585 | } |
---|
| 586 | |
---|
| 587 | } |
---|
| 588 | |
---|
| 589 | // Change in parameter "r" (run control list) |
---|
| 590 | else if (id == "r") |
---|
| 591 | { |
---|
| 592 | int status_ts = ui->check_ts->checkState(); |
---|
| 593 | int status_pr = ui->check_pr->checkState(); |
---|
| 594 | int status_xy = ui->check_xy->checkState(); |
---|
| 595 | int status_xz = ui->check_xz->checkState(); |
---|
| 596 | int status_yz = ui->check_yz->checkState(); |
---|
| 597 | int status_3d = ui->check_3d->checkState(); |
---|
| 598 | int status_ma = ui->check_ma->checkState(); |
---|
| 599 | int status_sp = ui->check_sp->checkState(); |
---|
| 600 | int status_pts = ui->check_pts->checkState(); |
---|
| 601 | int status_prt = ui->check_prt->checkState(); |
---|
| 602 | |
---|
| 603 | QString drop_job = ui->drop_job->currentText(); |
---|
| 604 | QString rc_flag = "#"; |
---|
| 605 | |
---|
| 606 | if (drop_job == "Initial run") |
---|
| 607 | { |
---|
| 608 | rc_flag = "#"; |
---|
| 609 | } |
---|
| 610 | else if (drop_job == "Restart run") |
---|
| 611 | { |
---|
| 612 | rc_flag = "f"; |
---|
| 613 | } |
---|
| 614 | else if (drop_job == "Precursor run (Atmosphere)") |
---|
| 615 | { |
---|
| 616 | rc_flag = "#"; |
---|
| 617 | } |
---|
| 618 | else if (drop_job == "Precursor run (Ocean)") |
---|
| 619 | { |
---|
| 620 | rc_flag = "o#"; |
---|
| 621 | } |
---|
| 622 | else if (drop_job == "Coupled restart") |
---|
| 623 | { |
---|
| 624 | rc_flag = "f"; |
---|
| 625 | } |
---|
| 626 | |
---|
| 627 | param[0] = "\"d3"+rc_flag; |
---|
| 628 | |
---|
| 629 | if (status_ts == 2) |
---|
| 630 | { |
---|
| 631 | param[0] = param[0]+" ts"+rc_flag; |
---|
| 632 | } |
---|
| 633 | if (status_pr == 2) |
---|
| 634 | { |
---|
| 635 | param[0] = param[0]+" pr"+rc_flag; |
---|
| 636 | } |
---|
| 637 | if (status_xy == 2) |
---|
| 638 | { |
---|
| 639 | param[0] = param[0]+" xy"+rc_flag; |
---|
| 640 | } |
---|
| 641 | if (status_xz == 2) |
---|
| 642 | { |
---|
| 643 | param[0] = param[0]+" xz"+rc_flag; |
---|
| 644 | } |
---|
| 645 | if (status_yz == 2) |
---|
| 646 | { |
---|
| 647 | param[0] = param[0]+" yz"+rc_flag; |
---|
| 648 | } |
---|
| 649 | if (status_3d == 2) |
---|
| 650 | { |
---|
| 651 | param[0] = param[0]+" 3d"+rc_flag; |
---|
| 652 | } |
---|
| 653 | if (status_ma == 2) |
---|
| 654 | { |
---|
| 655 | param[0] = param[0]+" ma"+rc_flag; |
---|
| 656 | } |
---|
| 657 | if (status_sp == 2) |
---|
| 658 | { |
---|
| 659 | param[0] = param[0]+" sp"+rc_flag; |
---|
| 660 | } |
---|
| 661 | if (status_prt == 2) |
---|
| 662 | { |
---|
| 663 | param[0] = param[0]+" prt"+rc_flag; |
---|
| 664 | } |
---|
| 665 | if (status_pts == 2) |
---|
| 666 | { |
---|
| 667 | param[0] = param[0]+" pts"+rc_flag; |
---|
| 668 | } |
---|
| 669 | |
---|
| 670 | if (drop_job == "Coupled restart") |
---|
| 671 | { |
---|
| 672 | rc_flag = "of"; |
---|
| 673 | param[0] = param[0]+" d3"+rc_flag; |
---|
| 674 | |
---|
| 675 | if (status_ts == 2) |
---|
| 676 | { |
---|
| 677 | param[0] = param[0]+" ts"+rc_flag; |
---|
| 678 | } |
---|
| 679 | if (status_pr == 2) |
---|
| 680 | { |
---|
| 681 | param[0] = param[0]+" pr"+rc_flag; |
---|
| 682 | } |
---|
| 683 | if (status_xy == 2) |
---|
| 684 | { |
---|
| 685 | param[0] = param[0]+" xy"+rc_flag; |
---|
| 686 | } |
---|
| 687 | if (status_xz == 2) |
---|
| 688 | { |
---|
| 689 | param[0] = param[0]+" xz"+rc_flag; |
---|
| 690 | } |
---|
| 691 | if (status_yz == 2) |
---|
| 692 | { |
---|
| 693 | param[0] = param[0]+" yz"+rc_flag; |
---|
| 694 | } |
---|
| 695 | if (status_3d == 2) |
---|
| 696 | { |
---|
| 697 | param[0] = param[0]+" 3d"+rc_flag; |
---|
| 698 | } |
---|
| 699 | if (status_ma == 2) |
---|
| 700 | { |
---|
| 701 | param[0] = param[0]+" ma"+rc_flag; |
---|
| 702 | } |
---|
| 703 | if (status_sp == 2) |
---|
| 704 | { |
---|
| 705 | param[0] = param[0]+" sp"+rc_flag; |
---|
| 706 | } |
---|
| 707 | if (status_prt == 2) |
---|
| 708 | { |
---|
| 709 | param[0] = param[0]+" prt"+rc_flag; |
---|
| 710 | } |
---|
| 711 | if (status_pts == 2) |
---|
| 712 | { |
---|
| 713 | param[0] = param[0]+" pts"+rc_flag; |
---|
| 714 | } |
---|
| 715 | } |
---|
| 716 | |
---|
| 717 | int status_restarts = ui->check_restarts->checkState(); |
---|
| 718 | |
---|
| 719 | |
---|
| 720 | |
---|
| 721 | if (status_restarts == 2) |
---|
| 722 | { |
---|
| 723 | param[0]=param[0]+" restart"; |
---|
| 724 | |
---|
| 725 | // Check if _pdf file is available, otherwise notice user |
---|
| 726 | if (ui->check_restarts->checkState() == 2) |
---|
| 727 | { |
---|
| 728 | QString jobname = ui->line_jobname->text(); |
---|
| 729 | branch = QCoreApplication::applicationDirPath(); |
---|
| 730 | branch = branch.left(branch.length() - 14); |
---|
| 731 | QFile restartfile(branch+"/JOBS/"+jobname+"/INPUT/"+jobname+ \ |
---|
| 732 | "_p3df"); |
---|
| 733 | if (restartfile.exists() == true) |
---|
| 734 | { |
---|
| 735 | ui->label_restart->setText(""); |
---|
| 736 | } |
---|
| 737 | else |
---|
| 738 | { |
---|
| 739 | ui->label_restart->setText("Warning: No p3df file found!"); |
---|
| 740 | } |
---|
| 741 | } |
---|
| 742 | |
---|
| 743 | } |
---|
| 744 | else { |
---|
| 745 | ui->label_restart->setText(""); |
---|
| 746 | } |
---|
| 747 | |
---|
| 748 | param[0]=param[0]+"\" "; |
---|
| 749 | |
---|
| 750 | if ( fwstring == "remove") |
---|
| 751 | { |
---|
| 752 | delete_commandline(id); |
---|
| 753 | return 1; |
---|
| 754 | } |
---|
| 755 | else |
---|
| 756 | { |
---|
| 757 | ui->button_start->setEnabled(true); |
---|
| 758 | ui->action_save->setEnabled(true); |
---|
| 759 | } |
---|
| 760 | } |
---|
| 761 | // Change in any other parameter |
---|
| 762 | else |
---|
| 763 | { |
---|
| 764 | if ( fwstring != "") |
---|
| 765 | { |
---|
| 766 | param[0] = "\""+fwstring+"\""; |
---|
| 767 | } |
---|
| 768 | else |
---|
| 769 | { |
---|
| 770 | delete_commandline(id); |
---|
| 771 | return 1; |
---|
| 772 | } |
---|
| 773 | |
---|
| 774 | } |
---|
| 775 | param[0] = param[0] + " "; |
---|
| 776 | |
---|
| 777 | // Join the new mrunline |
---|
| 778 | splitline[1]= param.join("-"); |
---|
| 779 | newmrunline = splitline.join(" -"+id+" "); |
---|
| 780 | |
---|
| 781 | // Print the new mrunline to mainwindow |
---|
| 782 | newmrunline.replace(" "," "); |
---|
| 783 | ui->commandline->setText(newmrunline); |
---|
| 784 | |
---|
| 785 | return 0; |
---|
| 786 | } |
---|
| 787 | |
---|
| 788 | |
---|
| 789 | //****************************************************************************// |
---|
| 790 | // Get all signals from mainwindow and perform change via change_commandline() |
---|
| 791 | int MainWindow::change_lineinput() |
---|
| 792 | { |
---|
| 793 | QString tmptext; |
---|
| 794 | |
---|
| 795 | if ( sender() == ui->line_host ) |
---|
| 796 | { |
---|
| 797 | tmptext = ui->line_host->text(); |
---|
| 798 | change_commandline("h",tmptext); |
---|
| 799 | } |
---|
| 800 | else if ( sender() == ui->line_jobname) |
---|
| 801 | { |
---|
| 802 | tmptext = ui->line_jobname->text(); |
---|
| 803 | change_commandline("d",tmptext); |
---|
| 804 | } |
---|
| 805 | else if ( sender() == ui->line_q) |
---|
| 806 | { |
---|
| 807 | tmptext = ui->line_q->text(); |
---|
| 808 | change_commandline("q",tmptext); |
---|
| 809 | } |
---|
| 810 | else if ( sender() == ui->line_account) |
---|
| 811 | { |
---|
| 812 | tmptext = ui->line_account->text(); |
---|
| 813 | change_commandline("u",tmptext); |
---|
| 814 | } |
---|
| 815 | else if ( sender() == ui->line_pe) |
---|
| 816 | { |
---|
| 817 | tmptext = ui->line_pe->text(); |
---|
| 818 | change_commandline("X",tmptext); |
---|
| 819 | } |
---|
| 820 | else if ( sender() == ui->line_tpn) |
---|
| 821 | { |
---|
| 822 | tmptext = ui->line_tpn->text(); |
---|
| 823 | change_commandline("T",tmptext); |
---|
| 824 | } |
---|
| 825 | else if ( sender() == ui->line_branch) |
---|
| 826 | { |
---|
| 827 | tmptext = ui->line_branch->text(); |
---|
| 828 | change_commandline("K",tmptext); |
---|
| 829 | } |
---|
| 830 | else if ( sender() == ui->line_time) |
---|
| 831 | { |
---|
| 832 | tmptext = ui->line_time->text(); |
---|
| 833 | change_commandline("t",tmptext); |
---|
| 834 | } |
---|
| 835 | else if ( sender() == ui->line_M) |
---|
| 836 | { |
---|
| 837 | tmptext = ui->line_M->text(); |
---|
| 838 | change_commandline("M",tmptext); |
---|
| 839 | } |
---|
| 840 | else if ( sender() == ui->line_m) |
---|
| 841 | { |
---|
| 842 | tmptext = ui->line_m->text(); |
---|
| 843 | change_commandline("m",tmptext); |
---|
| 844 | } |
---|
| 845 | else if ( sender() == ui->line_a) |
---|
| 846 | { |
---|
| 847 | tmptext = ui->line_a->text(); |
---|
| 848 | change_commandline("a",tmptext); |
---|
| 849 | } |
---|
| 850 | else if ( sender() == ui->line_D) |
---|
| 851 | { |
---|
| 852 | tmptext = ui->line_D->text(); |
---|
| 853 | change_commandline("D",tmptext); |
---|
| 854 | } |
---|
| 855 | else if ( sender() == ui->line_c) |
---|
| 856 | { |
---|
| 857 | tmptext = ui->line_c->text(); |
---|
| 858 | if ( tmptext == ".mrun.config") |
---|
| 859 | { |
---|
| 860 | tmptext = ""; |
---|
| 861 | } |
---|
| 862 | change_commandline("c",tmptext); |
---|
| 863 | } |
---|
| 864 | else if ( sender() == ui->line_p) |
---|
| 865 | { |
---|
| 866 | tmptext = ui->line_p->text(); |
---|
| 867 | change_commandline("p",tmptext); |
---|
| 868 | } |
---|
| 869 | else if ( sender() == ui->line_s) |
---|
| 870 | { |
---|
| 871 | tmptext = ui->line_s->text(); |
---|
| 872 | change_commandline("s",tmptext); |
---|
| 873 | } |
---|
| 874 | else if ( sender() == ui->line_i) |
---|
| 875 | { |
---|
| 876 | tmptext = ui->line_i->text(); |
---|
| 877 | if ( tmptext != "") |
---|
| 878 | { |
---|
| 879 | change_commandline("r","remove"); |
---|
| 880 | ui->group_runcontrol->setEnabled(false); |
---|
| 881 | |
---|
| 882 | ui->button_start->setEnabled(true); |
---|
| 883 | ui->action_save->setEnabled(true); |
---|
| 884 | } |
---|
| 885 | else if (ui->line_o->text() == "" ) |
---|
| 886 | { |
---|
| 887 | ui->group_runcontrol->setEnabled(true); |
---|
| 888 | change_commandline("r",""); |
---|
| 889 | } |
---|
| 890 | |
---|
| 891 | change_commandline("i",tmptext); |
---|
| 892 | } |
---|
| 893 | else if ( sender() == ui->line_o) |
---|
| 894 | { |
---|
| 895 | tmptext = ui->line_o->text(); |
---|
| 896 | if ( tmptext != "") |
---|
| 897 | { |
---|
| 898 | change_commandline("r","remove"); |
---|
| 899 | ui->button_start->setEnabled(true); |
---|
| 900 | ui->action_save->setEnabled(true); |
---|
| 901 | ui->group_runcontrol->setEnabled(false); |
---|
| 902 | } |
---|
| 903 | else if (ui->line_i->text() == "" ) |
---|
| 904 | { |
---|
| 905 | ui->group_runcontrol->setEnabled(true); |
---|
| 906 | change_commandline("r",""); |
---|
| 907 | } |
---|
| 908 | |
---|
| 909 | change_commandline("o",tmptext); |
---|
| 910 | |
---|
| 911 | } |
---|
| 912 | else if ( sender() == ui->line_w) |
---|
| 913 | { |
---|
| 914 | tmptext = ui->line_w->text(); |
---|
| 915 | change_commandline("w",tmptext); |
---|
| 916 | } |
---|
| 917 | else if ( sender() == ui->line_PE_atmos || sender() == ui->line_PE_ocean) |
---|
| 918 | { |
---|
| 919 | tmptext = ui->line_PE_atmos->text() + " " + ui->line_PE_ocean->text(); |
---|
| 920 | change_commandline("Y",tmptext); |
---|
| 921 | int PE_total = ui->line_PE_atmos->text().toInt() + \ |
---|
| 922 | ui->line_PE_ocean->text().toInt(); |
---|
| 923 | ui->line_pe->setText(QString::number(PE_total)); |
---|
| 924 | change_commandline("X",QString::number(PE_total)); |
---|
| 925 | } |
---|
| 926 | |
---|
| 927 | else if ( sender() == ui->combo_n) |
---|
| 928 | { |
---|
| 929 | tmptext = ui->combo_n->currentText(); |
---|
| 930 | if ( tmptext == "default") |
---|
| 931 | { |
---|
| 932 | tmptext = ""; |
---|
| 933 | } |
---|
| 934 | change_commandline("n",tmptext); |
---|
| 935 | } |
---|
| 936 | else if ( sender() == ui->line_user) |
---|
| 937 | { |
---|
| 938 | return 0; |
---|
| 939 | } |
---|
| 940 | |
---|
| 941 | return 0; |
---|
| 942 | } |
---|
| 943 | |
---|
| 944 | |
---|
| 945 | //****************************************************************************// |
---|
| 946 | // Delete a parameter from mrunline |
---|
| 947 | int MainWindow::delete_commandline(QString id) |
---|
| 948 | { |
---|
| 949 | |
---|
| 950 | // Read mrunline |
---|
| 951 | QString newmrunline; |
---|
| 952 | QString mrunline = ui->commandline->text(); |
---|
| 953 | QStringList splitline = mrunline.split(" -"+id, QString::SkipEmptyParts); |
---|
| 954 | if ( splitline.count() == 1) |
---|
| 955 | { |
---|
| 956 | return 0; |
---|
| 957 | } |
---|
| 958 | else |
---|
| 959 | { |
---|
| 960 | QStringList param = splitline[1].split("-"); |
---|
| 961 | param[0] = ""; |
---|
| 962 | splitline[1]= param.join(" -"); |
---|
| 963 | newmrunline = splitline.join(""); |
---|
| 964 | |
---|
| 965 | // Print new mrunline to screen |
---|
| 966 | ui->commandline->setText(newmrunline); |
---|
| 967 | |
---|
| 968 | return 0; |
---|
| 969 | } |
---|
| 970 | } |
---|
| 971 | |
---|
| 972 | |
---|
| 973 | //****************************************************************************// |
---|
| 974 | // Check routine for all flag parameters |
---|
| 975 | int MainWindow::check_flags() |
---|
| 976 | { |
---|
| 977 | |
---|
| 978 | int status = ui->check_delete_tmp_files->checkState(); |
---|
| 979 | |
---|
| 980 | if (status == 2) |
---|
| 981 | { |
---|
| 982 | activate_flag("B"); |
---|
| 983 | } |
---|
| 984 | else |
---|
| 985 | { |
---|
| 986 | deactivate_flag("B"); |
---|
| 987 | } |
---|
| 988 | |
---|
| 989 | status = ui->check_verbose->checkState(); |
---|
| 990 | |
---|
| 991 | if (status == 2) |
---|
| 992 | { |
---|
| 993 | activate_flag("v"); |
---|
| 994 | } |
---|
| 995 | else |
---|
| 996 | { |
---|
| 997 | deactivate_flag("v"); |
---|
| 998 | } |
---|
| 999 | |
---|
[818] | 1000 | status = ui->check_namelist_check->checkState(); |
---|
| 1001 | |
---|
| 1002 | if (status == 2) |
---|
| 1003 | { |
---|
| 1004 | activate_flag("z"); |
---|
| 1005 | } |
---|
| 1006 | else |
---|
| 1007 | { |
---|
| 1008 | deactivate_flag("z"); |
---|
| 1009 | } |
---|
| 1010 | |
---|
[793] | 1011 | status = ui->check_A->checkState(); |
---|
| 1012 | |
---|
| 1013 | if (status == 2) |
---|
| 1014 | { |
---|
| 1015 | activate_flag("A"); |
---|
| 1016 | } |
---|
| 1017 | else |
---|
| 1018 | { |
---|
| 1019 | deactivate_flag("A"); |
---|
| 1020 | } |
---|
| 1021 | |
---|
| 1022 | status = ui->check_b->checkState(); |
---|
| 1023 | |
---|
| 1024 | if (status == 2) |
---|
| 1025 | { |
---|
| 1026 | activate_flag("b"); |
---|
| 1027 | } |
---|
| 1028 | else |
---|
| 1029 | { |
---|
| 1030 | deactivate_flag("b"); |
---|
| 1031 | } |
---|
| 1032 | |
---|
| 1033 | status = ui->check_F->checkState(); |
---|
| 1034 | |
---|
| 1035 | if (status == 2) |
---|
| 1036 | { |
---|
| 1037 | activate_flag("F"); |
---|
| 1038 | } |
---|
| 1039 | else |
---|
| 1040 | { |
---|
| 1041 | deactivate_flag("F"); |
---|
| 1042 | } |
---|
| 1043 | status = ui->check_I->checkState(); |
---|
| 1044 | |
---|
| 1045 | if (status == 2) |
---|
| 1046 | { |
---|
| 1047 | activate_flag("I"); |
---|
| 1048 | } |
---|
| 1049 | else |
---|
| 1050 | { |
---|
| 1051 | deactivate_flag("I"); |
---|
| 1052 | } |
---|
| 1053 | status = ui->check_k->checkState(); |
---|
| 1054 | |
---|
| 1055 | if (status == 2) |
---|
| 1056 | { |
---|
| 1057 | activate_flag("k"); |
---|
| 1058 | } |
---|
| 1059 | else |
---|
| 1060 | { |
---|
| 1061 | deactivate_flag("k"); |
---|
| 1062 | } |
---|
| 1063 | status = ui->check_O->checkState(); |
---|
| 1064 | |
---|
| 1065 | if (status == 2) |
---|
| 1066 | { |
---|
| 1067 | activate_flag("O"); |
---|
| 1068 | } |
---|
| 1069 | else |
---|
| 1070 | { |
---|
| 1071 | deactivate_flag("O"); |
---|
| 1072 | } |
---|
| 1073 | status = ui->check_S->checkState(); |
---|
| 1074 | |
---|
| 1075 | if (status == 2) |
---|
| 1076 | { |
---|
| 1077 | activate_flag("S"); |
---|
| 1078 | } |
---|
| 1079 | else |
---|
| 1080 | { |
---|
| 1081 | deactivate_flag("S"); |
---|
| 1082 | } |
---|
| 1083 | status = ui->check_x->checkState(); |
---|
| 1084 | |
---|
| 1085 | if (status == 2) |
---|
| 1086 | { |
---|
| 1087 | activate_flag("x"); |
---|
| 1088 | } |
---|
| 1089 | else |
---|
| 1090 | { |
---|
| 1091 | deactivate_flag("x"); |
---|
| 1092 | } |
---|
[920] | 1093 | |
---|
| 1094 | status = ui->check_Z->checkState(); |
---|
| 1095 | |
---|
| 1096 | if (status == 2) |
---|
| 1097 | { |
---|
| 1098 | activate_flag("Z"); |
---|
| 1099 | } |
---|
| 1100 | else |
---|
| 1101 | { |
---|
| 1102 | deactivate_flag("Z"); |
---|
| 1103 | } |
---|
[793] | 1104 | return 0; |
---|
| 1105 | |
---|
| 1106 | } |
---|
| 1107 | |
---|
| 1108 | |
---|
| 1109 | //****************************************************************************// |
---|
| 1110 | // Activate flag |
---|
| 1111 | int MainWindow::activate_flag(QString id) |
---|
| 1112 | { |
---|
| 1113 | QString newmrunline; |
---|
| 1114 | |
---|
| 1115 | QString mrunline = ui->commandline->text(); |
---|
| 1116 | |
---|
| 1117 | QStringList splitline = mrunline.split(" -"+id, QString::SkipEmptyParts); |
---|
| 1118 | if ( splitline.count() == 1) |
---|
| 1119 | { |
---|
| 1120 | splitline.append(""); |
---|
| 1121 | newmrunline = splitline.join(" -"+id); |
---|
| 1122 | |
---|
| 1123 | // print new commandline to screen |
---|
| 1124 | newmrunline.replace(" "," "); |
---|
| 1125 | ui->commandline->setText(newmrunline); |
---|
| 1126 | |
---|
| 1127 | return 0; |
---|
| 1128 | } |
---|
| 1129 | else |
---|
| 1130 | { |
---|
| 1131 | return 0; |
---|
| 1132 | } |
---|
| 1133 | } |
---|
| 1134 | |
---|
| 1135 | |
---|
| 1136 | //****************************************************************************// |
---|
| 1137 | // Deactivate flag |
---|
| 1138 | int MainWindow::deactivate_flag(QString id) |
---|
| 1139 | { |
---|
| 1140 | QString newmrunline; |
---|
| 1141 | |
---|
| 1142 | QString mrunline = ui->commandline->text(); |
---|
| 1143 | |
---|
| 1144 | QStringList splitline = mrunline.split(" -"+id, QString::SkipEmptyParts); |
---|
| 1145 | |
---|
| 1146 | newmrunline = splitline.join(""); |
---|
| 1147 | // print new commandline to screen |
---|
| 1148 | newmrunline.replace(" "," "); |
---|
| 1149 | ui->commandline->setText(newmrunline); |
---|
| 1150 | |
---|
| 1151 | return 0; |
---|
| 1152 | } |
---|
| 1153 | |
---|
| 1154 | |
---|
| 1155 | //****************************************************************************// |
---|
| 1156 | // Mainwindow reset |
---|
| 1157 | int MainWindow::reset_window() |
---|
| 1158 | { |
---|
| 1159 | ui->setupUi(this); |
---|
| 1160 | recent_jobs(10); |
---|
| 1161 | return 0; |
---|
| 1162 | } |
---|
| 1163 | |
---|
| 1164 | |
---|
| 1165 | //****************************************************************************// |
---|
| 1166 | // Save current setting as default |
---|
| 1167 | int MainWindow::save_default() |
---|
| 1168 | { |
---|
| 1169 | |
---|
| 1170 | // Get mrunline |
---|
| 1171 | QString mrunline_save; |
---|
| 1172 | QString mrunline = ui->commandline->text(); |
---|
| 1173 | QString userline = ui->line_user->text(); |
---|
| 1174 | |
---|
| 1175 | mrunline_save = mrunline; |
---|
| 1176 | if (userline != "") |
---|
| 1177 | { |
---|
| 1178 | mrunline = mrunline + " " + userline; |
---|
| 1179 | } |
---|
| 1180 | |
---|
| 1181 | |
---|
| 1182 | // Define filename |
---|
| 1183 | branch = QCoreApplication::applicationDirPath(); |
---|
| 1184 | branch = branch.left(branch.length() - 14); |
---|
| 1185 | |
---|
| 1186 | QString filename = branch+"/.mrun.gui.default"; |
---|
| 1187 | |
---|
| 1188 | // Prepare data output |
---|
| 1189 | QDateTime time = QDateTime::currentDateTime(); |
---|
| 1190 | QString tmptime = time.toString("yyyy/MM/dd hh:mm"); |
---|
| 1191 | |
---|
| 1192 | // Write to file |
---|
| 1193 | QFile file(filename); |
---|
| 1194 | file.open(QIODevice::WriteOnly | QIODevice::Text); |
---|
| 1195 | QTextStream out(&file); |
---|
| 1196 | if ( mrunline == "" || mrunline == " ") |
---|
| 1197 | { |
---|
| 1198 | out << ""; |
---|
| 1199 | } |
---|
| 1200 | else |
---|
| 1201 | { |
---|
| 1202 | out << tmptime + " " + mrunline; |
---|
| 1203 | } |
---|
| 1204 | |
---|
| 1205 | file.close(); |
---|
| 1206 | |
---|
| 1207 | return 0; |
---|
| 1208 | } |
---|
| 1209 | |
---|
| 1210 | |
---|
| 1211 | //****************************************************************************// |
---|
| 1212 | // Save current settings to a file of choice |
---|
| 1213 | int MainWindow::save_to_file() |
---|
| 1214 | { |
---|
| 1215 | |
---|
| 1216 | // Get mrunline |
---|
| 1217 | QString mrunline_save; |
---|
| 1218 | QString mrunline = ui->commandline->text(); |
---|
| 1219 | QString userline = ui->line_user->text(); |
---|
| 1220 | |
---|
| 1221 | mrunline_save = mrunline; |
---|
| 1222 | if (userline != "") |
---|
| 1223 | { |
---|
| 1224 | mrunline = mrunline + " " + userline; |
---|
| 1225 | } |
---|
| 1226 | |
---|
| 1227 | // Define a filename |
---|
| 1228 | QString filename = QFileDialog::getSaveFileName(this, tr("Save to file"), \ |
---|
| 1229 | "", tr("Save files (*.sav)")); |
---|
| 1230 | QString extension = filename.right(4); |
---|
| 1231 | |
---|
| 1232 | if ( extension != ".sav" ) |
---|
| 1233 | { |
---|
| 1234 | filename = filename + ".sav"; |
---|
| 1235 | } |
---|
| 1236 | |
---|
| 1237 | // Prepare data output |
---|
| 1238 | QDateTime time = QDateTime::currentDateTime(); |
---|
| 1239 | QString tmptime = time.toString("yyyy/MM/dd hh:mm"); |
---|
| 1240 | |
---|
| 1241 | // Write to file |
---|
| 1242 | QFile file(filename); |
---|
| 1243 | file.open(QIODevice::WriteOnly | QIODevice::Text); |
---|
| 1244 | QTextStream out(&file); |
---|
| 1245 | out << tmptime + " " + mrunline; |
---|
| 1246 | file.close(); |
---|
| 1247 | |
---|
| 1248 | return 0; |
---|
| 1249 | } |
---|
| 1250 | |
---|
| 1251 | |
---|
| 1252 | //****************************************************************************// |
---|
| 1253 | // Open job from file (previously saved by the user) |
---|
| 1254 | int MainWindow::open_from_file() |
---|
| 1255 | { |
---|
| 1256 | |
---|
| 1257 | // Select filename and open it |
---|
| 1258 | QString filename = QFileDialog::getOpenFileName(this, tr("Open File"), \ |
---|
| 1259 | "", tr("Save files (*.sav)")); |
---|
| 1260 | |
---|
| 1261 | QFile file(filename); |
---|
| 1262 | QString mrunline; |
---|
| 1263 | if ( filename != "") |
---|
| 1264 | { |
---|
| 1265 | if ( file.open(QIODevice::ReadOnly | QIODevice::Text ) ) |
---|
| 1266 | { |
---|
| 1267 | |
---|
| 1268 | // File opened successfully |
---|
| 1269 | QTextStream in(&file); |
---|
| 1270 | |
---|
| 1271 | QString line = in.readLine(); |
---|
| 1272 | while (!line.isNull()) |
---|
| 1273 | { |
---|
| 1274 | mrunline = line; |
---|
| 1275 | line = in.readLine(); |
---|
| 1276 | } |
---|
| 1277 | file.close(); |
---|
| 1278 | } |
---|
| 1279 | |
---|
| 1280 | // In case a mrunline was found, load it to mainwindow |
---|
| 1281 | if ( mrunline != "") |
---|
| 1282 | { |
---|
| 1283 | |
---|
| 1284 | mrunline = mrunline.right(mrunline.length() - 17); |
---|
| 1285 | ui->commandline->setText(mrunline); |
---|
| 1286 | |
---|
| 1287 | setup_gui(mrunline); |
---|
| 1288 | } |
---|
| 1289 | } |
---|
| 1290 | return 0; |
---|
| 1291 | } |
---|
| 1292 | |
---|
| 1293 | |
---|
| 1294 | //****************************************************************************// |
---|
| 1295 | // Open the last submitted job |
---|
| 1296 | int MainWindow::open_last() |
---|
| 1297 | { |
---|
| 1298 | branch = QCoreApplication::applicationDirPath(); |
---|
| 1299 | branch = branch.left(branch.length() - 14); |
---|
| 1300 | |
---|
| 1301 | QFile file(branch+"/.mrun.history"); |
---|
| 1302 | |
---|
| 1303 | // Load mrun history |
---|
| 1304 | QString mrunline; |
---|
| 1305 | if ( file.open(QIODevice::ReadOnly | QIODevice::Text ) ) |
---|
| 1306 | { |
---|
| 1307 | |
---|
| 1308 | // file opened successfully |
---|
| 1309 | QTextStream in(&file); |
---|
| 1310 | |
---|
| 1311 | QString line = in.readLine(); |
---|
| 1312 | while (!line.isNull()) |
---|
| 1313 | { |
---|
| 1314 | mrunline = line; |
---|
| 1315 | line = in.readLine(); |
---|
| 1316 | } |
---|
| 1317 | |
---|
| 1318 | file.close(); |
---|
| 1319 | } |
---|
| 1320 | |
---|
| 1321 | // Select the last submitted job and print it to mainwindow |
---|
| 1322 | if ( mrunline != "" ) |
---|
| 1323 | { |
---|
| 1324 | mrunline = mrunline.right(mrunline.length() - 17); |
---|
| 1325 | ui->commandline->setText(mrunline); |
---|
| 1326 | |
---|
| 1327 | setup_gui(mrunline); |
---|
| 1328 | } |
---|
| 1329 | return 0; |
---|
| 1330 | } |
---|
| 1331 | |
---|
| 1332 | //****************************************************************************// |
---|
| 1333 | // Display help window |
---|
| 1334 | int MainWindow::help() |
---|
| 1335 | { |
---|
| 1336 | |
---|
| 1337 | QDialog *child_help = new QDialog; |
---|
| 1338 | Ui::child_help ui; |
---|
| 1339 | ui.setupUi(child_help); |
---|
| 1340 | child_help->show(); |
---|
| 1341 | |
---|
| 1342 | |
---|
| 1343 | return 0; |
---|
| 1344 | } |
---|
| 1345 | |
---|
| 1346 | //****************************************************************************// |
---|
| 1347 | // Display about window |
---|
| 1348 | int MainWindow::about_gui() |
---|
| 1349 | { |
---|
| 1350 | |
---|
| 1351 | QDialog *about = new QDialog; |
---|
| 1352 | Ui::about ui; |
---|
| 1353 | ui.setupUi(about); |
---|
| 1354 | about->show(); |
---|
| 1355 | |
---|
| 1356 | return 0; |
---|
| 1357 | } |
---|
| 1358 | |
---|
| 1359 | //****************************************************************************// |
---|
| 1360 | // Setup mainwindow according to a given mrunline |
---|
| 1361 | int MainWindow::setup_gui(QString mrunline) |
---|
| 1362 | { |
---|
| 1363 | |
---|
| 1364 | // Some initial settings |
---|
| 1365 | QString user = ""; |
---|
| 1366 | |
---|
| 1367 | bool coupled_run = false; |
---|
| 1368 | bool ocean_run = false; |
---|
| 1369 | bool advanced = false; |
---|
| 1370 | bool nojob = false; |
---|
| 1371 | bool rc_manual = false; |
---|
| 1372 | |
---|
| 1373 | // Split parameters in mrunline |
---|
| 1374 | QStringList splitline = mrunline.split(" -", QString::SkipEmptyParts); |
---|
| 1375 | |
---|
| 1376 | if ( splitline[0] != "mrun") |
---|
| 1377 | { |
---|
| 1378 | return 1; |
---|
| 1379 | |
---|
| 1380 | } |
---|
| 1381 | else |
---|
| 1382 | { |
---|
| 1383 | ui->group_job->setEnabled(true); |
---|
| 1384 | |
---|
| 1385 | // Loop for all parameters in mrunline |
---|
| 1386 | for(int i=splitline.count()-1; i>=1; i--) |
---|
| 1387 | { |
---|
| 1388 | |
---|
| 1389 | // Determine parameter |
---|
| 1390 | QStringList splitparameter = splitline[i].split(" ", \ |
---|
| 1391 | QString::SkipEmptyParts); |
---|
| 1392 | |
---|
| 1393 | QString parameter = splitparameter[0]; |
---|
| 1394 | splitparameter.removeFirst(); |
---|
| 1395 | QString options = splitparameter.join(" "); |
---|
| 1396 | options = options.replace("\"",""); |
---|
| 1397 | |
---|
| 1398 | // Check for suitable switch |
---|
| 1399 | if ( parameter == "d") |
---|
| 1400 | { |
---|
| 1401 | if ( options != "") |
---|
| 1402 | { |
---|
| 1403 | ui->line_jobname->setText(options); |
---|
| 1404 | nojob = false; |
---|
| 1405 | } |
---|
| 1406 | else |
---|
| 1407 | { |
---|
| 1408 | nojob = true; |
---|
| 1409 | } |
---|
| 1410 | } |
---|
| 1411 | else if ( parameter == "h") |
---|
| 1412 | { |
---|
| 1413 | ui->line_host->setText(options); |
---|
| 1414 | } |
---|
| 1415 | else if ( parameter == "q") |
---|
| 1416 | { |
---|
| 1417 | ui->line_q->setText(options); |
---|
| 1418 | } |
---|
| 1419 | else if ( parameter == "K") |
---|
| 1420 | { |
---|
| 1421 | ui->line_branch->setText(options); |
---|
| 1422 | } |
---|
| 1423 | else if ( parameter == "u") |
---|
| 1424 | { |
---|
| 1425 | ui->line_account->setText(options); |
---|
| 1426 | } |
---|
| 1427 | else if ( parameter == "X") |
---|
| 1428 | { |
---|
| 1429 | ui->line_pe->setText(options); |
---|
| 1430 | } |
---|
| 1431 | else if ( parameter == "T") |
---|
| 1432 | { |
---|
| 1433 | ui->line_tpn->setText(options); |
---|
| 1434 | } |
---|
| 1435 | else if ( parameter == "t") |
---|
| 1436 | { |
---|
| 1437 | ui->line_time->setText(options); |
---|
| 1438 | } |
---|
| 1439 | else if ( parameter == "B") |
---|
| 1440 | { |
---|
| 1441 | ui->check_delete_tmp_files->setChecked(true); |
---|
| 1442 | } |
---|
| 1443 | else if ( parameter == "v") |
---|
| 1444 | { |
---|
| 1445 | ui->check_verbose->setChecked(true); |
---|
| 1446 | } |
---|
[818] | 1447 | else if ( parameter == "z") |
---|
| 1448 | { |
---|
| 1449 | ui->check_namelist_check->setChecked(true); |
---|
| 1450 | } |
---|
[793] | 1451 | else if ( parameter == "A") |
---|
| 1452 | { |
---|
| 1453 | ui->check_A->setChecked(true); |
---|
| 1454 | } |
---|
| 1455 | else if ( parameter == "b") |
---|
| 1456 | { |
---|
| 1457 | ui->check_b->setChecked(true); |
---|
| 1458 | advanced = true; |
---|
| 1459 | } |
---|
| 1460 | else if ( parameter == "F") |
---|
| 1461 | { |
---|
| 1462 | ui->check_F->setChecked(true); |
---|
| 1463 | advanced = true; |
---|
| 1464 | } |
---|
| 1465 | else if ( parameter == "I") |
---|
| 1466 | { |
---|
| 1467 | ui->check_I->setChecked(true); |
---|
| 1468 | advanced = true; |
---|
| 1469 | } |
---|
| 1470 | else if ( parameter == "k") |
---|
| 1471 | { |
---|
| 1472 | ui->check_k->setChecked(true); |
---|
| 1473 | advanced = true; |
---|
| 1474 | } |
---|
| 1475 | else if ( parameter == "O") |
---|
| 1476 | { |
---|
| 1477 | ui->check_O->setChecked(true); |
---|
| 1478 | advanced = true; |
---|
| 1479 | } |
---|
| 1480 | else if ( parameter == "S") |
---|
| 1481 | { |
---|
| 1482 | ui->check_S->setChecked(true); |
---|
| 1483 | advanced = true; |
---|
| 1484 | } |
---|
| 1485 | else if ( parameter == "x") |
---|
| 1486 | { |
---|
| 1487 | ui->check_x->setChecked(true); |
---|
| 1488 | advanced = true; |
---|
| 1489 | } |
---|
[920] | 1490 | else if ( parameter == "Z") |
---|
| 1491 | { |
---|
| 1492 | ui->check_Z->setChecked(true); |
---|
| 1493 | advanced = true; |
---|
| 1494 | } |
---|
[793] | 1495 | else if ( parameter == "m") |
---|
| 1496 | { |
---|
| 1497 | ui->line_m->setText(options); |
---|
| 1498 | advanced = true; |
---|
| 1499 | } |
---|
| 1500 | else if ( parameter == "M") |
---|
| 1501 | { |
---|
| 1502 | ui->line_M->setText(options); |
---|
| 1503 | advanced = true; |
---|
| 1504 | } |
---|
| 1505 | else if ( parameter == "a") |
---|
| 1506 | { |
---|
| 1507 | ui->line_a->setText(options); |
---|
| 1508 | advanced = true; |
---|
| 1509 | } |
---|
| 1510 | else if ( parameter == "D") |
---|
| 1511 | { |
---|
| 1512 | ui->line_D->setText(options); |
---|
| 1513 | advanced = true; |
---|
| 1514 | } |
---|
| 1515 | else if ( parameter == "c") |
---|
| 1516 | { |
---|
| 1517 | ui->line_c->setText(options); |
---|
| 1518 | advanced = true; |
---|
| 1519 | } |
---|
| 1520 | else if ( parameter == "p") |
---|
| 1521 | { |
---|
| 1522 | ui->line_p->setText(options); |
---|
| 1523 | advanced = true; |
---|
| 1524 | } |
---|
| 1525 | else if ( parameter == "s") |
---|
| 1526 | { |
---|
| 1527 | ui->line_s->setText(options); |
---|
| 1528 | advanced = true; |
---|
| 1529 | } |
---|
| 1530 | else if ( parameter == "i") |
---|
| 1531 | { |
---|
| 1532 | ui->line_i->setText(options); |
---|
| 1533 | advanced = true; |
---|
| 1534 | rc_manual = true; |
---|
| 1535 | } |
---|
| 1536 | else if ( parameter == "o") |
---|
| 1537 | { |
---|
| 1538 | ui->line_o->setText(options); |
---|
| 1539 | advanced = true; |
---|
| 1540 | rc_manual = true; |
---|
| 1541 | } |
---|
| 1542 | else if ( parameter == "w") |
---|
| 1543 | { |
---|
| 1544 | ui->line_w->setText(options); |
---|
| 1545 | advanced = true; |
---|
| 1546 | } |
---|
| 1547 | |
---|
| 1548 | // Determine settings for coupled restart runs |
---|
| 1549 | else if ( parameter == "Y") |
---|
| 1550 | { |
---|
| 1551 | QStringList optionssplit = options.split(" ", \ |
---|
| 1552 | QString::SkipEmptyParts); |
---|
| 1553 | |
---|
| 1554 | ui->line_PE_atmos->setEnabled(true); |
---|
| 1555 | ui->line_PE_ocean->setEnabled(true); |
---|
| 1556 | ui->label_coupled1->setEnabled(true); |
---|
| 1557 | ui->label_coupled2->setEnabled(true); |
---|
| 1558 | ui->label_coupled3->setEnabled(true); |
---|
| 1559 | ui->label_coupling->setEnabled(true); |
---|
| 1560 | |
---|
| 1561 | if (optionssplit.count() == 2) |
---|
| 1562 | { |
---|
| 1563 | ui->line_PE_atmos->setText(optionssplit[0]); |
---|
| 1564 | ui->line_PE_ocean->setText(optionssplit[1]); |
---|
| 1565 | } |
---|
| 1566 | else |
---|
| 1567 | { |
---|
| 1568 | ui->line_PE_atmos->setText(""); |
---|
| 1569 | ui->line_PE_ocean->setText(""); |
---|
| 1570 | } |
---|
| 1571 | coupled_run = true; |
---|
| 1572 | } |
---|
| 1573 | else if ( parameter == "n") |
---|
| 1574 | { |
---|
| 1575 | if ( options == "shared") |
---|
| 1576 | { |
---|
| 1577 | ui->combo_n->setCurrentIndex(1); |
---|
| 1578 | } |
---|
| 1579 | else if ( options == "non_shared") |
---|
| 1580 | { |
---|
| 1581 | ui->combo_n->setCurrentIndex(2); |
---|
| 1582 | } |
---|
| 1583 | else |
---|
| 1584 | { |
---|
| 1585 | ui->combo_n->setCurrentIndex(0); |
---|
| 1586 | } |
---|
| 1587 | } |
---|
| 1588 | else if ( parameter == "y") |
---|
| 1589 | { |
---|
| 1590 | ui->drop_job->setCurrentIndex(3); |
---|
| 1591 | } |
---|
| 1592 | |
---|
| 1593 | // Determine settings for the run control list |
---|
| 1594 | else if ( parameter == "r") |
---|
| 1595 | { |
---|
| 1596 | QStringList optionssplit = options.split(" ", \ |
---|
| 1597 | QString::SkipEmptyParts); |
---|
| 1598 | |
---|
| 1599 | QString options_2; |
---|
| 1600 | QString options_all; |
---|
| 1601 | for (int j=0; j<optionssplit.count(); j++) |
---|
| 1602 | { |
---|
| 1603 | options_all = optionssplit[j]; |
---|
| 1604 | options_2 = optionssplit[j].left(2); |
---|
| 1605 | if (options_2 == "ts") |
---|
| 1606 | { |
---|
| 1607 | ui->check_ts->setChecked(true); |
---|
| 1608 | } |
---|
| 1609 | if (options_2 == "pr" && options_all.left(3) != "prt") |
---|
| 1610 | { |
---|
| 1611 | ui->check_pr->setChecked(true); |
---|
| 1612 | } |
---|
| 1613 | if (options_2 == "xy") |
---|
| 1614 | { |
---|
| 1615 | ui->check_xy->setChecked(true); |
---|
| 1616 | } |
---|
| 1617 | if (options_2 == "xz") |
---|
| 1618 | { |
---|
| 1619 | ui->check_xz->setChecked(true); |
---|
| 1620 | } |
---|
| 1621 | if (options_2 == "yz") |
---|
| 1622 | { |
---|
| 1623 | ui->check_yz->setChecked(true); |
---|
| 1624 | } |
---|
| 1625 | if (options_2 == "3d") |
---|
| 1626 | { |
---|
| 1627 | ui->check_3d->setChecked(true); |
---|
| 1628 | } |
---|
| 1629 | if (options_2 == "ma") |
---|
| 1630 | { |
---|
| 1631 | ui->check_ma->setChecked(true); |
---|
| 1632 | } |
---|
| 1633 | if (options_2 == "sp") |
---|
| 1634 | { |
---|
| 1635 | ui->check_sp->setChecked(true); |
---|
| 1636 | } |
---|
| 1637 | if (options_all.left(3) == "prt") |
---|
| 1638 | { |
---|
| 1639 | ui->check_prt->setChecked(true); |
---|
| 1640 | } |
---|
| 1641 | if (options_all.left(3) == "pts") |
---|
| 1642 | { |
---|
| 1643 | ui->check_pts->setChecked(true); |
---|
| 1644 | } |
---|
| 1645 | if (options_2 == "d3") |
---|
| 1646 | { |
---|
| 1647 | if (options_all.left(3).right(1) == "#") |
---|
| 1648 | { |
---|
| 1649 | ui->drop_job->setCurrentIndex(0); |
---|
| 1650 | } |
---|
| 1651 | else if (options_all.left(3).right(1) == "f") |
---|
| 1652 | { |
---|
| 1653 | ui->drop_job->setCurrentIndex(1); |
---|
| 1654 | } |
---|
| 1655 | else if (options_all.left(3).right(1) == "o") |
---|
| 1656 | { |
---|
| 1657 | ocean_run = true; |
---|
| 1658 | } |
---|
| 1659 | } |
---|
| 1660 | if (options_all == "restart") |
---|
| 1661 | { |
---|
| 1662 | ui->check_restarts->setChecked(true); |
---|
| 1663 | // Check if _pdf file is available, otherwise notice user |
---|
| 1664 | QString jobname = ui->line_jobname->text(); |
---|
| 1665 | branch = QCoreApplication::applicationDirPath(); |
---|
| 1666 | branch = branch.left(branch.length() - 14); |
---|
| 1667 | |
---|
| 1668 | QFile restartfile(branch+"/JOBS/"+jobname+"/INPUT/"+ \ |
---|
| 1669 | jobname+"_p3df"); |
---|
| 1670 | if (restartfile.exists() == true) |
---|
| 1671 | { |
---|
| 1672 | ui->label_restart->setText(""); |
---|
| 1673 | } |
---|
| 1674 | else |
---|
| 1675 | { |
---|
| 1676 | ui->label_restart->setText("Warning: No p3df file \ |
---|
| 1677 | found!"); |
---|
| 1678 | } |
---|
| 1679 | } |
---|
| 1680 | |
---|
| 1681 | } |
---|
| 1682 | |
---|
| 1683 | } |
---|
| 1684 | |
---|
| 1685 | // All unknown parameters are set as extra user parameters |
---|
| 1686 | else |
---|
| 1687 | { |
---|
| 1688 | user = user + "-" + parameter + " \"" + options + "\" "; |
---|
| 1689 | splitline.removeAt(i); |
---|
| 1690 | } |
---|
| 1691 | } |
---|
| 1692 | |
---|
| 1693 | // Change drop box state in case of ocean precursor or coupled restart runs |
---|
| 1694 | if ( ocean_run == true ) |
---|
| 1695 | { |
---|
| 1696 | if ( coupled_run == true ) |
---|
| 1697 | { |
---|
| 1698 | ui->drop_job->setCurrentIndex(4); |
---|
| 1699 | } |
---|
| 1700 | else |
---|
| 1701 | { |
---|
| 1702 | ui->drop_job->setCurrentIndex(3); |
---|
| 1703 | } |
---|
| 1704 | } |
---|
| 1705 | |
---|
| 1706 | if ( user != "") |
---|
| 1707 | { |
---|
| 1708 | ui->line_user->setText(user); |
---|
| 1709 | } |
---|
| 1710 | |
---|
| 1711 | // Join mrunline and post it to mainwindow |
---|
| 1712 | mrunline = splitline.join(" -"); |
---|
| 1713 | ui->commandline->setText(mrunline); |
---|
| 1714 | |
---|
| 1715 | // Check if advanced settings are used and enable advanced dialog |
---|
| 1716 | if ( advanced == true ) |
---|
| 1717 | { |
---|
| 1718 | ui->check_advanced->setChecked(true); |
---|
| 1719 | } |
---|
| 1720 | |
---|
| 1721 | // Disable mainwindow if no job was found, otherwise enable |
---|
| 1722 | if ( nojob == true ) |
---|
| 1723 | { |
---|
| 1724 | ui->group_execution->setEnabled(false); |
---|
| 1725 | ui->group_runcontrol->setEnabled(false); |
---|
| 1726 | ui->button_start->setEnabled(false); |
---|
| 1727 | ui->action_save->setEnabled(false); |
---|
| 1728 | ui->drop_job->setEnabled(false); |
---|
| 1729 | ui->group_advanced->setEnabled(false); |
---|
| 1730 | ui->check_advanced->setEnabled(false); |
---|
| 1731 | } |
---|
| 1732 | else |
---|
| 1733 | { |
---|
| 1734 | ui->group_execution->setEnabled(true); |
---|
| 1735 | ui->group_runcontrol->setEnabled(true); |
---|
| 1736 | ui->button_start->setEnabled(true); |
---|
| 1737 | ui->action_save->setEnabled(true); |
---|
| 1738 | ui->check_advanced->setEnabled(true); |
---|
| 1739 | ui->drop_job->setEnabled(true); |
---|
| 1740 | if ( advanced == true ) |
---|
| 1741 | { |
---|
| 1742 | ui->group_advanced->setEnabled(true); |
---|
| 1743 | } |
---|
| 1744 | else |
---|
| 1745 | { |
---|
| 1746 | ui->group_advanced->setEnabled(false); |
---|
| 1747 | } |
---|
| 1748 | } |
---|
| 1749 | |
---|
| 1750 | // Disable run control box, if manual settings of -i and -o are used |
---|
| 1751 | if ( rc_manual == true ) |
---|
| 1752 | { |
---|
| 1753 | ui->group_runcontrol->setEnabled(false); |
---|
| 1754 | change_commandline("r","remove"); |
---|
| 1755 | ui->button_start->setEnabled(true); |
---|
| 1756 | ui->action_save->setEnabled(true); |
---|
| 1757 | } |
---|
| 1758 | |
---|
| 1759 | } |
---|
| 1760 | |
---|
| 1761 | return 0; |
---|
| 1762 | } |
---|