PageRenderTime 91ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/src/MDandTB/ClustepDiag.java

https://github.com/abinit/abinitgui
Java | 1170 lines | 883 code | 140 blank | 147 comment | 118 complexity | 20a68fb86bd5d76c715674a032689c21 MD5 | raw file
Possible License(s): GPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. /*--
  2. ClustepDiag.java - Created October 30, 2012
  3. Copyright (c) 2009-2013 Flavio Miguel ABREU ARAUJO.
  4. Université catholique de Louvain, Louvain-la-Neuve, Belgium
  5. All rights reserved.
  6. Redistribution and use in source and binary forms, with or without
  7. modification, are permitted provided that the following conditions
  8. are met:
  9. 1. Redistributions of source code must retain the above copyright
  10. notice, this list of conditions, and the following disclaimer.
  11. 2. Redistributions in binary form must reproduce the above copyright
  12. notice, this list of conditions, and the disclaimer that follows
  13. these conditions in the documentation and/or other materials
  14. provided with the distribution.
  15. 3. The names of the author may not be used to endorse or promote
  16. products derived from this software without specific prior written
  17. permission.
  18. In addition, we request (but do not require) that you include in the
  19. end-user documentation provided with the redistribution and/or in the
  20. software itself an acknowledgement equivalent to the following:
  21. "This product includes software developed by the
  22. Abinit Project (http://www.abinit.org/)."
  23. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  24. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  25. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT
  27. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  28. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  29. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  30. USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  31. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  33. OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  34. SUCH DAMAGE.
  35. For more information on the Abinit Project, please see
  36. <http://www.abinit.org/>.
  37. */
  38. package MDandTB;
  39. import core.MainFrame;
  40. import core.RetMSG;
  41. import core.Utils;
  42. import java.awt.Color;
  43. import java.io.BufferedInputStream;
  44. import java.io.BufferedWriter;
  45. import java.io.DataInputStream;
  46. import java.io.File;
  47. import java.io.FileInputStream;
  48. import java.io.FileNotFoundException;
  49. import java.io.FileOutputStream;
  50. import java.io.IOException;
  51. import java.io.OutputStreamWriter;
  52. import java.io.PrintWriter;
  53. import javax.swing.JCheckBox;
  54. import javax.swing.JFileChooser;
  55. import javax.swing.JTextField;
  56. /**
  57. *
  58. * @author flavio
  59. */
  60. public class ClustepDiag extends javax.swing.JDialog {
  61. private MainFrame MF;
  62. /**
  63. * Creates new form ClustepDiag
  64. */
  65. public ClustepDiag(java.awt.Frame parent, boolean modal) {
  66. super(parent, modal);
  67. initComponents();
  68. MF = (MainFrame) parent;
  69. }
  70. /**
  71. * This method is called from within the constructor to initialize the form.
  72. * WARNING: Do NOT modify this code. The content of this method is always
  73. * regenerated by the Form Editor.
  74. */
  75. @SuppressWarnings("unchecked")
  76. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  77. private void initComponents() {
  78. buttonGroup1 = new javax.swing.ButtonGroup();
  79. openClustepInputFileLabel = new javax.swing.JLabel();
  80. displayClustepInputFileButton = new javax.swing.JButton();
  81. geditClustepInputButton = new javax.swing.JButton();
  82. openClustepInputFileDialogButton = new javax.swing.JButton();
  83. openClustepInputFileTextField = new javax.swing.JTextField();
  84. openClustepPositionFileLabel = new javax.swing.JLabel();
  85. displayClustepPositionFileButton = new javax.swing.JButton();
  86. geditClustepPositionButton = new javax.swing.JButton();
  87. openClustepPositionFileDialogButton = new javax.swing.JButton();
  88. openClustepPositionFileTextField = new javax.swing.JTextField();
  89. sendSIMClustepButton = new javax.swing.JButton();
  90. sendClustepCheckBox = new javax.swing.JCheckBox();
  91. getEvolutionFileButton = new javax.swing.JButton();
  92. getFilmFileButton = new javax.swing.JButton();
  93. needSGECheckBox = new javax.swing.JCheckBox();
  94. SGEconfigPanel = new javax.swing.JPanel();
  95. timeLabel = new javax.swing.JLabel();
  96. nodesLabel = new javax.swing.JLabel();
  97. ramLabel = new javax.swing.JLabel();
  98. hdmLabel = new javax.swing.JLabel();
  99. timeTextField = new javax.swing.JTextField();
  100. nodesTextField = new javax.swing.JTextField();
  101. ramTextField = new javax.swing.JTextField();
  102. hdmTextField = new javax.swing.JTextField();
  103. emailLabel = new javax.swing.JLabel();
  104. emailTextField = new javax.swing.JTextField();
  105. sequentialCheckBox = new javax.swing.JCheckBox();
  106. parallelCheckBox = new javax.swing.JCheckBox();
  107. abinitParaTextField = new javax.swing.JTextField();
  108. abinitParaLabel = new javax.swing.JLabel();
  109. openClustepInputFileLabel.setText("Open the Clustep input file");
  110. displayClustepInputFileButton.setText("Display");
  111. displayClustepInputFileButton.addActionListener(new java.awt.event.ActionListener() {
  112. public void actionPerformed(java.awt.event.ActionEvent evt) {
  113. displayClustepInputFileButtonActionPerformed(evt);
  114. }
  115. });
  116. geditClustepInputButton.setText("Edit");
  117. geditClustepInputButton.addActionListener(new java.awt.event.ActionListener() {
  118. public void actionPerformed(java.awt.event.ActionEvent evt) {
  119. geditClustepInputButtonActionPerformed(evt);
  120. }
  121. });
  122. openClustepInputFileDialogButton.setText("...");
  123. openClustepInputFileDialogButton.addActionListener(new java.awt.event.ActionListener() {
  124. public void actionPerformed(java.awt.event.ActionEvent evt) {
  125. openClustepInputFileDialogButtonActionPerformed(evt);
  126. }
  127. });
  128. openClustepPositionFileLabel.setText("Open the Clustep position file");
  129. displayClustepPositionFileButton.setText("Display");
  130. displayClustepPositionFileButton.addActionListener(new java.awt.event.ActionListener() {
  131. public void actionPerformed(java.awt.event.ActionEvent evt) {
  132. displayClustepPositionFileButtonActionPerformed(evt);
  133. }
  134. });
  135. geditClustepPositionButton.setText("Edit");
  136. geditClustepPositionButton.addActionListener(new java.awt.event.ActionListener() {
  137. public void actionPerformed(java.awt.event.ActionEvent evt) {
  138. geditClustepPositionButtonActionPerformed(evt);
  139. }
  140. });
  141. openClustepPositionFileDialogButton.setText("...");
  142. openClustepPositionFileDialogButton.addActionListener(new java.awt.event.ActionListener() {
  143. public void actionPerformed(java.awt.event.ActionEvent evt) {
  144. openClustepPositionFileDialogButtonActionPerformed(evt);
  145. }
  146. });
  147. sendSIMClustepButton.setText("<HTML> <center> <b>Send the simulation</b><br> the simulation will start at server side </HTML>");
  148. sendSIMClustepButton.addActionListener(new java.awt.event.ActionListener() {
  149. public void actionPerformed(java.awt.event.ActionEvent evt) {
  150. sendSIMClustepButtonActionPerformed(evt);
  151. }
  152. });
  153. sendClustepCheckBox.setText("Send CLUSTEP source code and compile");
  154. getEvolutionFileButton.setText("Download Evolution File");
  155. getEvolutionFileButton.addActionListener(new java.awt.event.ActionListener() {
  156. public void actionPerformed(java.awt.event.ActionEvent evt) {
  157. getEvolutionFileButtonActionPerformed(evt);
  158. }
  159. });
  160. getFilmFileButton.setText("Download Film File");
  161. getFilmFileButton.addActionListener(new java.awt.event.ActionListener() {
  162. public void actionPerformed(java.awt.event.ActionEvent evt) {
  163. getFilmFileButtonActionPerformed(evt);
  164. }
  165. });
  166. needSGECheckBox.setForeground(new java.awt.Color(0, 128, 0));
  167. needSGECheckBox.setSelected(true);
  168. needSGECheckBox.setText("SGE script");
  169. needSGECheckBox.setToolTipText("If checked, a SGE script is created and is used to submit the calculation job.");
  170. needSGECheckBox.addActionListener(new java.awt.event.ActionListener() {
  171. public void actionPerformed(java.awt.event.ActionEvent evt) {
  172. needSGECheckBoxActionPerformed(evt);
  173. }
  174. });
  175. SGEconfigPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "SGE script configuration", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("DejaVu Sans", 3, 14), java.awt.Color.darkGray)); // NOI18N
  176. timeLabel.setText("Time [h]");
  177. nodesLabel.setText("# nodes");
  178. ramLabel.setText("RAM [Mb]");
  179. hdmLabel.setText("HDM [Mb]");
  180. timeTextField.setText("1");
  181. nodesTextField.setText("1");
  182. nodesTextField.setEnabled(false);
  183. ramTextField.setText("200");
  184. hdmTextField.setText("2000");
  185. hdmTextField.setEnabled(false);
  186. emailLabel.setText("E-mail where to send feedback");
  187. emailTextField.setText("email@provider.ext");
  188. org.jdesktop.layout.GroupLayout SGEconfigPanelLayout = new org.jdesktop.layout.GroupLayout(SGEconfigPanel);
  189. SGEconfigPanel.setLayout(SGEconfigPanelLayout);
  190. SGEconfigPanelLayout.setHorizontalGroup(
  191. SGEconfigPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  192. .add(SGEconfigPanelLayout.createSequentialGroup()
  193. .addContainerGap()
  194. .add(SGEconfigPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
  195. .add(org.jdesktop.layout.GroupLayout.LEADING, timeTextField)
  196. .add(org.jdesktop.layout.GroupLayout.LEADING, timeLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  197. .add(18, 18, 18)
  198. .add(SGEconfigPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
  199. .add(nodesTextField)
  200. .add(nodesLabel))
  201. .add(18, 18, 18)
  202. .add(SGEconfigPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
  203. .add(ramTextField)
  204. .add(ramLabel))
  205. .add(18, 18, 18)
  206. .add(SGEconfigPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
  207. .add(hdmTextField)
  208. .add(hdmLabel))
  209. .add(18, 18, 18)
  210. .add(SGEconfigPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  211. .add(emailLabel)
  212. .add(emailTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 217, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
  213. .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  214. );
  215. SGEconfigPanelLayout.setVerticalGroup(
  216. SGEconfigPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  217. .add(SGEconfigPanelLayout.createSequentialGroup()
  218. .addContainerGap()
  219. .add(SGEconfigPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  220. .add(SGEconfigPanelLayout.createSequentialGroup()
  221. .add(SGEconfigPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
  222. .add(hdmLabel)
  223. .add(emailLabel))
  224. .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  225. .add(SGEconfigPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
  226. .add(hdmTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
  227. .add(emailTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
  228. .add(SGEconfigPanelLayout.createSequentialGroup()
  229. .add(ramLabel)
  230. .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  231. .add(ramTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
  232. .add(SGEconfigPanelLayout.createSequentialGroup()
  233. .add(nodesLabel)
  234. .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  235. .add(nodesTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
  236. .add(SGEconfigPanelLayout.createSequentialGroup()
  237. .add(timeLabel)
  238. .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  239. .add(timeTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
  240. .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  241. );
  242. buttonGroup1.add(sequentialCheckBox);
  243. sequentialCheckBox.setForeground(java.awt.Color.red);
  244. sequentialCheckBox.setSelected(true);
  245. sequentialCheckBox.setText("Sequential");
  246. sequentialCheckBox.addActionListener(new java.awt.event.ActionListener() {
  247. public void actionPerformed(java.awt.event.ActionEvent evt) {
  248. sequentialCheckBoxActionPerformed(evt);
  249. }
  250. });
  251. buttonGroup1.add(parallelCheckBox);
  252. parallelCheckBox.setForeground(java.awt.Color.blue);
  253. parallelCheckBox.setText("Parallel");
  254. parallelCheckBox.addActionListener(new java.awt.event.ActionListener() {
  255. public void actionPerformed(java.awt.event.ActionEvent evt) {
  256. parallelCheckBoxActionPerformed(evt);
  257. }
  258. });
  259. abinitParaTextField.setEnabled(false);
  260. abinitParaLabel.setText("(local max = ?)");
  261. abinitParaLabel.setEnabled(false);
  262. org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
  263. getContentPane().setLayout(layout);
  264. layout.setHorizontalGroup(
  265. layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  266. .add(layout.createSequentialGroup()
  267. .addContainerGap()
  268. .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  269. .add(layout.createSequentialGroup()
  270. .add(openClustepInputFileLabel)
  271. .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  272. .add(displayClustepInputFileButton)
  273. .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  274. .add(geditClustepInputButton))
  275. .add(sendSIMClustepButton)
  276. .add(layout.createSequentialGroup()
  277. .add(openClustepPositionFileLabel)
  278. .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  279. .add(displayClustepPositionFileButton)
  280. .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  281. .add(geditClustepPositionButton))
  282. .add(layout.createSequentialGroup()
  283. .add(openClustepInputFileDialogButton)
  284. .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  285. .add(openClustepInputFileTextField))
  286. .add(layout.createSequentialGroup()
  287. .add(openClustepPositionFileDialogButton)
  288. .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  289. .add(openClustepPositionFileTextField))
  290. .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
  291. .add(0, 0, Short.MAX_VALUE)
  292. .add(SGEconfigPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
  293. .add(layout.createSequentialGroup()
  294. .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  295. .add(sendClustepCheckBox)
  296. .add(layout.createSequentialGroup()
  297. .add(getEvolutionFileButton)
  298. .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  299. .add(getFilmFileButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 161, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
  300. .add(layout.createSequentialGroup()
  301. .add(needSGECheckBox)
  302. .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  303. .add(sequentialCheckBox)
  304. .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  305. .add(parallelCheckBox)
  306. .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  307. .add(abinitParaTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
  308. .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  309. .add(abinitParaLabel)))
  310. .add(0, 0, Short.MAX_VALUE)))
  311. .addContainerGap())
  312. );
  313. layout.setVerticalGroup(
  314. layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  315. .add(layout.createSequentialGroup()
  316. .addContainerGap()
  317. .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
  318. .add(openClustepInputFileLabel)
  319. .add(geditClustepInputButton)
  320. .add(displayClustepInputFileButton))
  321. .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  322. .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
  323. .add(openClustepInputFileDialogButton)
  324. .add(openClustepInputFileTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
  325. .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
  326. .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
  327. .add(openClustepPositionFileLabel)
  328. .add(geditClustepPositionButton)
  329. .add(displayClustepPositionFileButton))
  330. .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  331. .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
  332. .add(openClustepPositionFileDialogButton)
  333. .add(openClustepPositionFileTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
  334. .add(18, 18, 18)
  335. .add(sendSIMClustepButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
  336. .add(39, 39, 39)
  337. .add(sendClustepCheckBox)
  338. .add(18, 18, 18)
  339. .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
  340. .add(getEvolutionFileButton)
  341. .add(getFilmFileButton))
  342. .add(18, 18, 18)
  343. .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
  344. .add(needSGECheckBox, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  345. .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
  346. .add(sequentialCheckBox)
  347. .add(parallelCheckBox)
  348. .add(abinitParaTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
  349. .add(abinitParaLabel)))
  350. .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  351. .add(SGEconfigPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
  352. );
  353. pack();
  354. }// </editor-fold>//GEN-END:initComponents
  355. private void sendSIMClustepButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendSIMClustepButtonActionPerformed
  356. sendSIMClustepButton.setEnabled(false);
  357. Runnable r = new Runnable() {
  358. @Override
  359. public void run() {
  360. if (MF.localAbinitRadioButton().isSelected() && Utils.osName().startsWith("Windows")) {
  361. MF.printERR("Please connect to a remote CLUSTEP host before submitting a simulation !");
  362. sendSIMClustepButton.setEnabled(true);
  363. return;
  364. }
  365. if ((MF.remoteGatewayRadioButton().isSelected() || MF.remoteAbinitRadioButton().isSelected()) && MF.remoteExec == null) {
  366. MF.printERR("Please connect to a CLUSTEP host before submitting a simulation !");
  367. sendSIMClustepButton.setEnabled(true);
  368. return;
  369. }
  370. MF.createFiletree();
  371. String ClustepProgPath = "";
  372. if (MF.remoteGatewayRadioButton().isSelected() || MF.remoteAbinitRadioButton().isSelected()) {
  373. ClustepProgPath = "~/CLUSTEP/clustep0";
  374. } else {
  375. ClustepProgPath = "../../../CLUSTEP/clustep0";
  376. }
  377. String rootPath = MF.mySimulationsTextField().getText();
  378. String clustepFolder = "clustep";
  379. // ***************************************************************
  380. String cwd = "";
  381. String CMD = "pwd";
  382. RetMSG retmsg;
  383. if (MF.remoteGatewayRadioButton().isSelected() || MF.remoteAbinitRadioButton().isSelected()) {
  384. if (MF.remoteExec != null) {
  385. retmsg = MF.remoteExec.sendCommand(CMD);
  386. if (retmsg.getRetCode() == RetMSG.SUCCES) {
  387. MF.printOUT("PWD: " + retmsg.getRetMSG());
  388. cwd = MF.removeEndl(retmsg.getRetMSG());
  389. } else {
  390. //printERR("Error (RetVal = " + retmsg.getRetCode() + "): " + retmsg.getRetMSG());
  391. MF.printERR("Error: " + retmsg.getRetMSG() + " !");
  392. }
  393. } else {
  394. MF.printERR("First connect to an CLUSTEP host please !");
  395. }
  396. } else if (MF.localAbinitRadioButton().isSelected()) {
  397. if (MF.localExec != null) {
  398. retmsg = MF.localExec.sendCommand(CMD);
  399. if (retmsg.getRetCode() == RetMSG.SUCCES) {
  400. MF.printOUT("PWD: " + retmsg.getRetMSG());
  401. cwd = MF.removeEndl(retmsg.getRetMSG());
  402. } else {
  403. //printERR("Error (RetVal = " + retmsg.getRetCode() + "): " + retmsg.getRetMSG());
  404. MF.printERR("Error: " + retmsg.getRetMSG() + " !");
  405. }
  406. }
  407. } else { // Le choix n'a pas été fait
  408. MF.printERR("Choose a destination option please at config. tab !");
  409. }
  410. // ***************************************************************
  411. String sep = Utils.fileSeparator();
  412. String inputFile = openClustepInputFileTextField.getText();
  413. String inputFileName = Utils.getLastToken(inputFile.replace('\\', '/'), "/");
  414. // Test de l'existance de inputfile
  415. if (!Utils.exists(inputFile)) {
  416. MF.printERR("The file " + inputFile + " doesn't exist !");
  417. sendSIMClustepButton.setEnabled(true);
  418. return;
  419. }
  420. String simName = null;
  421. if (inputFileName != null) {
  422. int idx = inputFileName.indexOf('-');
  423. if (idx > 0 && idx < inputFileName.length()) {
  424. simName = inputFileName.substring(0, idx);
  425. } else {
  426. simName = inputFileName;
  427. }
  428. }
  429. // Creation du dossier clustepFolder local
  430. MF.mkdir(rootPath + "/" + clustepFolder);
  431. // Creation du dossier simName dans clustepFolder local
  432. MF.mkdir(rootPath + "/" + clustepFolder + "/" + simName);
  433. if (MF.remoteGatewayRadioButton().isSelected()
  434. || MF.remoteAbinitRadioButton().isSelected()) {
  435. // Creation du dossier clustepFolder
  436. MF.mkdirR(rootPath + "/" + clustepFolder);
  437. // Creation du dossier simName dans clustepFolder
  438. MF.mkdirR(rootPath + "/" + clustepFolder + "/" + simName);
  439. }
  440. if (sendClustepCheckBox.isSelected()) {
  441. if (MF.remoteGatewayRadioButton().isSelected()
  442. || MF.remoteAbinitRadioButton().isSelected()) {
  443. // Creation du dossier CLUSTEP de destination de clustep0
  444. MF.mkdirR("./CLUSTEP");
  445. // Envoie du code source de clustep0
  446. MF.putFile("./CLUSTEP_src.tar.gz ./CLUSTEP_src.tar.gz");
  447. } else {
  448. // Creation du dossier CLUSTEP de destination de clustep0
  449. MF.mkdir("./CLUSTEP");
  450. }
  451. // Unzip the compressed file CLUSTEP_src.tar.gz
  452. MF.sendCommand("tar -zxf ./CLUSTEP_src.tar.gz");
  453. // Compilation de clustep0
  454. MF.sendCommand("make -C ./CLUSTEP_src/");
  455. MF.sendCommand("mv ./CLUSTEP_src/clustep0 ./CLUSTEP");
  456. //sendCommand("make clean -C ./CLUSTEP_src/");
  457. MF.sendCommand("rm -rf ./CLUSTEP_src/");
  458. if (MF.remoteGatewayRadioButton().isSelected()
  459. || MF.remoteAbinitRadioButton().isSelected()) {
  460. MF.sendCommand("rm -f ./CLUSTEP_src.tar.gz");
  461. }
  462. }
  463. if (!inputFile.equals("")) {
  464. int nbProc;
  465. if (abinitParaTextField.isEnabled()) { // Tjs actif pour cette version du gui
  466. try {
  467. nbProc = Integer.parseInt(abinitParaTextField.getText());
  468. } finally {
  469. MF.printDEB("Please set up the number of processors to use ! nbProc was set to 1!");
  470. nbProc = 1;
  471. }
  472. } else {
  473. nbProc = 1;
  474. }
  475. if (needSGECheckBox.isSelected()) {
  476. int time, nodes, ram, hdm;
  477. String email;
  478. try {
  479. time = Integer.parseInt(timeTextField.getText());
  480. nodes = Integer.parseInt(nodesTextField.getText());
  481. ram = Integer.parseInt(ramTextField.getText());
  482. hdm = Integer.parseInt(hdmTextField.getText());
  483. email = emailTextField.getText();
  484. } catch (Exception e) {
  485. //printERR("Exception in sendSIMButtonActionPerformed:" + e + "");
  486. MF.printERR("The SGE script configuration is probably wrong !");
  487. sendSIMClustepButton.setEnabled(true);
  488. return;
  489. }
  490. // Création du script SGE
  491. try {
  492. //String rootPath_ = (new File(rootPath)).getCanonicalPath();
  493. String PBSfileName = rootPath + sep + clustepFolder + sep
  494. + simName + sep + simName + ".SGE.sh";
  495. OutputStreamWriter fw = new OutputStreamWriter(new FileOutputStream(PBSfileName), MF.CharSet);
  496. //FileWriter fw = new FileWriter(PBSfileName);
  497. BufferedWriter bw = new BufferedWriter(fw);
  498. PrintWriter pw = new PrintWriter(bw);
  499. //*********************************************************************************************
  500. String fileContent = "#!/bin/bash" + "\n"
  501. + "#" + "\n"
  502. + "# On old Green node" + "\n"
  503. + "#$ -l nb=false" + "\n"
  504. + "#" + "\n"
  505. + "# Ask for pe=parrallel environment, snode or openmpi" + "\n"
  506. + "# snode= same node, as the shared memory communication is the fastest" + "\n"
  507. + "#$ -pe openmpi 1" + "\n"
  508. + "# -pe snode8 8" + "\n"
  509. + "\n"
  510. + "# keep current working directory" + "\n"
  511. + "#$ -cwd" + "\n"
  512. + "\n"
  513. + "#$ -o SGE_out-$JOB_ID.log" + "\n"
  514. + "#$ -e SGE_err-$JOB_ID.log" + "\n"
  515. + "\n"
  516. + "# give a name to your job" + "\n"
  517. + "#$ -N " + simName + "\n"
  518. + "\n"
  519. + "# keep all the defined variables" + "\n"
  520. + "#$ -V" + "\n"
  521. + "#$ -l nb=false" + "\n"
  522. + "\n"
  523. + "# not mandatory: highmem=true (hm=true) for 32GB node" + "\n"
  524. + "# or hm=false for 16GB node" + "\n"
  525. + "# no hm argument does not take about the kind of node ram (16/32)" + "\n"
  526. + "# -l hm=true" + "\n"
  527. + "\n"
  528. + "# IMPORTANT: You need to specify the mem_free" + "\n"
  529. + "# h_vmem can also be set but mf is mandatory!" + "\n"
  530. + "# max 31G if hm=true and max 15G if hm=false" + "\n"
  531. + "#$ -l mf=" + ram + "M" + "\n"
  532. + "\n"
  533. + "# Specify the requested time" + "\n"
  534. + "#$ -l h_rt=" + time + ":00:00" + "\n"
  535. + "\n"
  536. + "# To be informed by email (besa= begin,end,stop,abort)" + "\n"
  537. + "#$ -M " + email + "\n"
  538. + "#$ -m besa" + "\n"
  539. //+ "# ---------------------------" + "\n"
  540. + "\n"
  541. + "echo \"Project " + simName + " is running!\"" + "\n"
  542. + "cd " + rootPath + "/" + clustepFolder + "/" + simName + "/" + "\n"
  543. + ClustepProgPath + " < " + cwd + "/"
  544. + rootPath.replaceFirst("./", "") + "/" + clustepFolder + "/"
  545. + simName + "/" + simName + ".files >& " + cwd + "/"
  546. + rootPath.replaceFirst("./", "") + "/" + clustepFolder
  547. + "/" + simName + "/" + simName + ".log";
  548. pw.print(fileContent);
  549. //*********************************************************************************************
  550. pw.println();
  551. pw.close();
  552. bw.close();
  553. fw.close();
  554. } catch (IOException e) {
  555. //printERR("Exception in sendSIMButtonActionPerformed:" + e + "");
  556. MF.printERR("The SGE script could not be created !");
  557. sendSIMClustepButton.setEnabled(true);
  558. return;
  559. }
  560. } else {
  561. // Création du script BASH
  562. try {
  563. String BASHfileName = rootPath + sep + clustepFolder + sep
  564. + simName + sep + simName + ".sh";
  565. OutputStreamWriter fw = new OutputStreamWriter(new FileOutputStream(BASHfileName), MF.CharSet);
  566. //FileWriter fw = new FileWriter(BASHfileName);
  567. BufferedWriter bw = new BufferedWriter(fw);
  568. PrintWriter pw = new PrintWriter(bw);
  569. pw.println("#!/bin/bash");
  570. pw.println("echo \"Project " + simName + " is running!\"");
  571. pw.println("cd " + rootPath + "/" + clustepFolder + "/" + simName + "/");
  572. pw.print(ClustepProgPath + " < " + cwd + "/"
  573. + rootPath.replaceFirst("./", "") + "/" + clustepFolder + "/"
  574. + simName + "/" + simName + ".files >& " + cwd + "/"
  575. + rootPath.replaceFirst("./", "") + "/" + clustepFolder
  576. + "/" + simName + "/" + simName + ".log &");
  577. pw.println();
  578. pw.close();
  579. bw.close();
  580. fw.close();
  581. } catch (IOException e) {
  582. //printDEB("Exception in sendSIMButtonActionPerformed:" + e + "");
  583. MF.printERR("The bash script could not be created !");
  584. sendSIMClustepButton.setEnabled(true);
  585. return;
  586. }
  587. }
  588. // Envoie (copie) du fichier d'input *******************************************************************
  589. String inputFileR = rootPath + "/" + clustepFolder + "/" + simName + "/" + simName + "-input";
  590. if (MF.remoteGatewayRadioButton().isSelected() || MF.remoteAbinitRadioButton().isSelected()) {
  591. if (Utils.osName().startsWith("Windows")) {
  592. Utils.dos2unix(new File(inputFile));
  593. }
  594. }
  595. MF.putFile(inputFile + " " + inputFileR);
  596. // if (remoteGatewayRadioButton.isSelected() || remoteAbinitRadioButton.isSelected()) {
  597. // if (Utils.osName().startsWith("Windows")) {
  598. // sendCommand("dos2unix " + inputFileR);
  599. // }
  600. // }
  601. // Envoie (copie) du fichier des positions atomiques ***************************************************
  602. String positionFile = openClustepPositionFileTextField.getText();
  603. String positionFileR = rootPath + "/" + clustepFolder + "/" + simName + "/" + simName + "-pos";
  604. if (MF.remoteGatewayRadioButton().isSelected() || MF.remoteAbinitRadioButton().isSelected()) {
  605. if (Utils.osName().startsWith("Windows")) {
  606. Utils.dos2unix(new File(positionFile));
  607. }
  608. }
  609. MF.putFile(positionFile + " " + positionFileR);
  610. // if (remoteGatewayRadioButton.isSelected() || remoteAbinitRadioButton.isSelected()) {
  611. // if (Utils.osName().startsWith("Windows")) {
  612. // sendCommand("dos2unix " + positionFileR);
  613. // }
  614. // }
  615. // Création du fichier de configuration
  616. try {
  617. String FILESfileName = rootPath + sep + clustepFolder
  618. + sep + simName + sep + simName + ".files";
  619. OutputStreamWriter fw = new OutputStreamWriter(new FileOutputStream(FILESfileName), MF.CharSet);
  620. //FileWriter fw = new FileWriter(FILESfileName);
  621. BufferedWriter bw = new BufferedWriter(fw);
  622. PrintWriter pw = new PrintWriter(bw);
  623. String configFileContent = "";
  624. configFileContent += simName + "-input\n";
  625. configFileContent += simName + "-evol.dat\n";
  626. configFileContent += simName + "-pos\n";
  627. configFileContent += simName + "-film.xyz\n";
  628. pw.print(configFileContent);
  629. pw.close();
  630. bw.close();
  631. fw.close();
  632. } catch (IOException e) {
  633. //printERR(e.getMessage());
  634. MF.printERR("The configuration file (*.files) could not be created !");
  635. sendSIMClustepButton.setEnabled(true);
  636. return;
  637. }
  638. if (MF.remoteGatewayRadioButton().isSelected() || MF.remoteAbinitRadioButton().isSelected()) {
  639. String configFile = rootPath + sep + clustepFolder + sep + simName + sep + simName + ".files";
  640. String configFileR = rootPath + "/" + clustepFolder + "/" + simName + "/" + simName + ".files";
  641. if (Utils.osName().startsWith("Windows")) {
  642. Utils.dos2unix(new File(configFile));
  643. }
  644. // Envoie du fichier de configuration
  645. MF.putFile(configFile + " " + configFileR);
  646. // if (Utils.osName().startsWith("Windows")) {
  647. // sendCommand("dos2unix " + configFileR);
  648. // }
  649. }
  650. if (needSGECheckBox.isSelected()) {
  651. if (MF.remoteGatewayRadioButton().isSelected() || MF.remoteAbinitRadioButton().isSelected()) {
  652. String sgeSHFile = rootPath + sep + clustepFolder + sep + simName + sep + simName + ".SGE.sh";
  653. String sgeSHFileR = rootPath + "/" + clustepFolder + "/" + simName + "/" + simName + ".SGE.sh";
  654. if (Utils.osName().startsWith("Windows")) {
  655. Utils.dos2unix(new File(sgeSHFile));
  656. }
  657. // Envoie du fichier SGE
  658. MF.putFile(sgeSHFile + " " + sgeSHFileR);
  659. // if (Utils.osName().startsWith("Windows")) {
  660. // sendCommand("dos2unix " + sgeSHFileR);
  661. // }
  662. }
  663. // lancement des commandes d'exécution de la simulation
  664. MF.sendCommand("qsub " + rootPath + "/" + clustepFolder + "/"
  665. + simName + "/" + simName + ".SGE.sh");
  666. } else {
  667. String SHFile = rootPath + sep + clustepFolder + sep + simName + sep + simName + ".sh";
  668. String SHFileR = rootPath + "/" + clustepFolder + "/" + simName + "/" + simName + ".sh";
  669. if (MF.remoteGatewayRadioButton().isSelected() || MF.remoteAbinitRadioButton().isSelected()) {
  670. if (Utils.osName().startsWith("Windows")) {
  671. Utils.dos2unix(new File(SHFile));
  672. }
  673. // Envoie du fichier BASH
  674. MF.putFile(SHFile + " " + SHFileR);
  675. // if (Utils.osName().startsWith("Windows")) {
  676. // sendCommand("dos2unix " + SHFileR);
  677. // }
  678. }
  679. // lancement des commandes d'exécution de la simulation
  680. MF.sendCommand("bash " + SHFileR);
  681. }
  682. } else {
  683. MF.printERR("Please setup the inputfile textfield !");
  684. sendSIMClustepButton.setEnabled(true);
  685. return;
  686. }
  687. if (MF.localAbinitRadioButton().isSelected()) {
  688. MF.printOUT("The simulation was submitted to the local CLUSTEP server.");
  689. } else {
  690. MF.printOUT("The simulation was submitted to the remote CLUSTEP server " + MF.hostTextField().getText());
  691. if (MF.remoteGatewayRadioButton().isSelected()) {
  692. MF.printOUT(" via the gateway " + MF.gatewayHostTextField().getText() + ".");
  693. } else {
  694. //printOUT(".");
  695. }
  696. }
  697. MF.printDEB("The submission thread ended successfully! (Clustep)");
  698. sendSIMClustepButton.setEnabled(true);
  699. }
  700. };
  701. Thread t = new Thread(r);
  702. t.start();
  703. }//GEN-LAST:event_sendSIMClustepButtonActionPerformed
  704. private void displayClustepInputFileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_displayClustepInputFileButtonActionPerformed
  705. MF.clustepInputFileDisplayer.setVisible(true);
  706. // TODO : pour quand ce sera éditable
  707. //clustepInputFileDisplayer.setEditable(true);
  708. String fileContent = "";
  709. try {
  710. File file = new File(openClustepInputFileTextField.getText());
  711. FileInputStream fis = new FileInputStream(file);
  712. // Here BufferedInputStream is added for fast reading.
  713. BufferedInputStream bis = new BufferedInputStream(fis);
  714. DataInputStream dis = new DataInputStream(bis);
  715. while (dis.available() != 0) {
  716. fileContent += dis.readLine() + "\n";
  717. }
  718. // dispose all the resources after using them.
  719. fis.close();
  720. bis.close();
  721. dis.close();
  722. } catch (FileNotFoundException e) {
  723. MF.printERR(e.getMessage());
  724. } catch (IOException e) {
  725. MF.printERR(e.getMessage());
  726. }
  727. MF.clustepInputFileDisplayer.setText(fileContent);
  728. }//GEN-LAST:event_displayClustepInputFileButtonActionPerformed
  729. private void geditClustepInputButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_geditClustepInputButtonActionPerformed
  730. String fileName = openClustepInputFileTextField.getText();
  731. MF.editFile(fileName, true);
  732. }//GEN-LAST:event_geditClustepInputButtonActionPerformed
  733. private void openClustepInputFileDialogButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openClustepInputFileDialogButtonActionPerformed
  734. JFileChooser fc = new JFileChooser(".");
  735. File currDir = new File(".");
  736. String currPath = currDir.getAbsolutePath();
  737. String basePath = basePath = currPath.replace("\\", "/").replace(".", "");
  738. MF.printDEB(basePath);
  739. fc.setMultiSelectionEnabled(false);
  740. int retValue = fc.showOpenDialog(this);
  741. if (retValue == JFileChooser.APPROVE_OPTION) {
  742. File file = fc.getSelectedFile();
  743. String relPath = file.getAbsolutePath().replace("\\", "/").replace(basePath, "./");
  744. openClustepInputFileTextField.setText(relPath);
  745. }
  746. }//GEN-LAST:event_openClustepInputFileDialogButtonActionPerformed
  747. private void displayClustepPositionFileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_displayClustepPositionFileButtonActionPerformed
  748. MF.clustepPositionFileDisplayer.setVisible(true);
  749. // TODO : pour quand ce sera éditable
  750. //clustepPositionFileDisplayer.setEditable(true);
  751. String fileContent = "";
  752. try {
  753. File file = new File(openClustepPositionFileTextField.getText());
  754. FileInputStream fis = new FileInputStream(file);
  755. // Here BufferedInputStream is added for fast reading.
  756. BufferedInputStream bis = new BufferedInputStream(fis);
  757. DataInputStream dis = new DataInputStream(bis);
  758. while (dis.available() != 0) {
  759. fileContent += dis.readLine() + "\n";
  760. }
  761. // dispose all the resources after using them.
  762. fis.close();
  763. bis.close();
  764. dis.close();
  765. } catch (FileNotFoundException e) {
  766. MF.printERR(e.getMessage());
  767. } catch (IOException e) {
  768. MF.printERR(e.getMessage());
  769. }
  770. MF.clustepPositionFileDisplayer.setText(fileContent);
  771. }//GEN-LAST:event_displayClustepPositionFileButtonActionPerformed
  772. private void geditClustepPositionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_geditClustepPositionButtonActionPerformed
  773. String fileName = openClustepPositionFileTextField.getText();
  774. MF.editFile(fileName, true);
  775. }//GEN-LAST:event_geditClustepPositionButtonActionPerformed
  776. private void openClustepPositionFileDialogButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openClustepPositionFileDialogButtonActionPerformed
  777. JFileChooser fc = new JFileChooser(".");
  778. File currDir = new File(".");
  779. String currPath = currDir.getAbsolutePath();
  780. String basePath = basePath = currPath.replace("\\", "/").replace(".", "");
  781. MF.printDEB(basePath);
  782. fc.setMultiSelectionEnabled(false);
  783. int retValue = fc.showOpenDialog(this);
  784. if (retValue == JFileChooser.APPROVE_OPTION) {
  785. File file = fc.getSelectedFile();
  786. String relPath = file.getAbsolutePath().replace("\\", "/").replace(basePath, "./");
  787. openClustepPositionFileTextField.setText(relPath);
  788. }
  789. }//GEN-LAST:event_openClustepPositionFileDialogButtonActionPerformed
  790. private void getEvolutionFileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_getEvolutionFileButtonActionPerformed
  791. Runnable r = new Runnable() {
  792. @Override
  793. public void run() {
  794. if ((MF.remoteGatewayRadioButton().isSelected() || MF.remoteAbinitRadioButton().isSelected()) && MF.remoteExec == null) {
  795. MF.printERR("Please connect to a CLUSTEP host before doing anything!");
  796. getEvolutionFileButton.setEnabled(true);
  797. return;
  798. }
  799. String rootPath = MF.mySimulationsTextField().getText();
  800. String clustepFolder = "clustep";
  801. String inputFile = "";
  802. String inputFileName = "";
  803. inputFile = openClustepInputFileTextField.getText();
  804. inputFileName = Utils.getLastToken(inputFile.replace('\\', '/'), "/");
  805. // Test de l'existance de inputfile
  806. if (!Utils.exists(inputFile)) {
  807. MF.printERR("The file " + inputFile + " do…

Large files files are truncated, but you can click here to view the full file