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