1 /* GamessRunControl.c */
2 /**********************************************************************************************************
3 Copyright (c) 2002-2013 Abdul-Rahman Allouche. All rights reserved
4 
5 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 documentation files (the Gabedit), to deal in the Software without restriction, including without limitation
7 the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
8 and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9 
10   The above copyright notice and this permission notice shall be included in all copies or substantial portions
11   of the Software.
12 
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
14 TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
16 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 DEALINGS IN THE SOFTWARE.
18 ************************************************************************************************************/
19 
20 #include <stdlib.h>
21 #include <ctype.h>
22 #include <math.h>
23 #include <string.h>
24 
25 #include "../../Config.h"
26 #include "../Common/Global.h"
27 #include "../Gamess/GamessTypes.h"
28 #include "../Gamess/GamessGlobal.h"
29 #include "../Gamess/GamessMolecule.h"
30 #include "../Gamess/GamessBasis.h"
31 #include "../Gamess/GamessGuess.h"
32 #include "../Gamess/GamessSCF.h"
33 #include "../Utils/Utils.h"
34 #include "../Utils/UtilsInterface.h"
35 #include "../Utils/GabeditTextEdit.h"
36 #include "../Common/Windows.h"
37 #include "../Utils/Constants.h"
38 
39 static GtkWidget* entrySCFIterations = NULL;
40 static GtkWidget* comboSCF = NULL;
41 static GtkWidget* comboCorrMethod = NULL;
42 static GtkWidget* comboCorrType = NULL;
43 static void setGamessCorrType();
44 /*************************************************************************************************************/
45 static gchar* listRunView[] = {
46         N_("Single Point Energy"), N_("Equilibrium geometry"), N_("Transition State"), N_("Frequencies"),
47         "Gradient", "Trudge", "IRC", "VSCF", "DRC", "GlobOp", "OptFMO", "GradExtr",
48         "Surface", "Drop", "Raman", "NMR", "Morokuma", "Transitn", "FField", "TDHF", "MakeFP"
49 };
50 static gchar* listRunReal[] = {
51         "Energy", "Optimize", "Sadpoint", "Hessian",
52         "Gradient", "Trudge", "IRC", "VSCF", "DRC", "GlobOp", "OptFMO", "GradExtr",
53         "Surface", "Drop", "Raman", "NMR", "Morokuma", "Transitn", "FField", "TDHF", "MakeFP"
54 };
55 static guint numberOfRuns = G_N_ELEMENTS (listRunView);
56 static gchar selectedRun[BSIZE]="ENERGY";
57 /*************************************************************************************************************/
58 static gchar* listSCFView[] = { "RHF", "UHF", "ROHF", "GVB", "MCSCF", "MNDO", "AM1", "PM3", "None" };
59 static gchar* listSCFReal[] = { "RHF", "UHF", "ROHF", "GVB", "MCSCF", "MNDO", "AM1", "PM3", "NONE" };
60 static guint numberOfSCF = G_N_ELEMENTS (listSCFView);
61 static gchar selectedSCF[BSIZE]="RHF";
62 /*************************************************************************************************************/
63 static gchar* listCorrTypeView[] = { N_("None"), N_("Density Functional Theory"), N_("MP2"), N_("Coupled-Cluster")};
64 static gchar* listCorrTypeReal[] = { "NONE", "DFTTYP", "MPLEVL=2","CCTYP"};
65 static guint numberOfCorrType = G_N_ELEMENTS (listCorrTypeView);
66 static gchar selectedCorrType[BSIZE]="NONE";
67 /*************************************************************************************************************/
68 static gchar* listNoneView[] = { N_("None")};
69 static gchar* listNoneReal[] = { "NONE"};
70 static guint numberOfNone = G_N_ELEMENTS (listNoneView);
71 
72 static gchar* listMP2View[] = { N_("MP2")};
73 static gchar* listMP2Real[] = { "MP2"};
74 static guint numberOfMP2 = G_N_ELEMENTS (listMP2View);
75 
76 static gchar* listDFTView[] = {
77 	N_("B3LYP"),
78 	N_("BHHLYP (HF and BECKE exchange + LYP Correlation)"),
79 
80 	N_("BLYP (Becke exchange + LYP Correlation)"),
81 	N_("BVWN (Becke exchange + VWN5 Correlation)"),
82 	N_("BOP (Becke exchange + OP Correlation)"),
83 
84 	N_("GLYP (GILL exchange + LYP Correlation)"),
85 	N_("GVWN (GILL exchange + VWN5 Correlation)"),
86 	N_("GOP (GILL exchange + OP Correlation)"),
87 
88 	N_("PBELYP (PBE exchange + LYP Correlation)"),
89 	N_("PBEVWN (PBE exchange + VWN5 Correlation)"),
90 	N_("PBEOP (PBE exchange + OP Correlation)"),
91 
92 	N_("SLYP (Slater exchange + LYP Correlation)"),
93 	N_("SVWN (Slater exchange + VWN5 Correlation)"),
94 	N_("SOP (Slater exchange + OP Correlation)"),
95 
96 	N_("SLATER (Exchange)"),
97 	N_("BECKE 1988 (Exchange)"),
98 	N_("GILL  1996 (Exchange)"),
99 	N_("PBE (Exchange only)"),
100 
101 	N_("VWN (VWN5 Correlation)"),
102 	N_("LYP (Correlation)"),
103 	N_("OP (Correlation)")
104 };
105 static gchar* listDFTReal[] = {
106 	"B3LYP", "BHHLYP", "BLYP", "BVWN", "BOP", "GLYP", "GVWN", "GOP", "PBELYP", "PBEVWN", "PBEOP",
107 	"SLYP", "SVWN", "SOP", "SLATER", "BECKE", "GILL", "PBE", "VWN", "LYP", "OP",
108 };
109 static guint numberOfDFT = G_N_ELEMENTS (listDFTView);
110 
111 static gchar* listCCView[] = { "LCCD", "CCD", "CCSD", "CCSD(T)","R-CC","CR-CC","CCSD(TQ)","CR-CC(Q)","EOM-CCSD","CR-EOM" };
112 static gchar* listCCReal[] = { "LCCD", "CCD", "CCSD", "CCSD(T)","R-CC","CR-CC","CCSD(TQ)","CR-CC(Q)","EOM-CCSD","CR-EOM" };
113 static guint numberOfCC = G_N_ELEMENTS (listCCView);
114 
115 static guint numberOfCorrMethods = 0;
116 static gchar** listCorrMethodsView = NULL;
117 static gchar** listCorrMethodsReal = NULL;
118 static gchar selectedCorrMethod[BSIZE]="NONE";
119 /*************************************************************************************************************/
120 static gchar* listLocalizedView[] = { N_("None"), "Foster-Boys", "Edmiston-Ruedenberg","Pipek-Mezey"};
121 static gchar* listLocalizedReal[] = { "NONE", "BOYS", "RUEDNBRG","POP" };
122 static guint numberOfLocalized = G_N_ELEMENTS (listLocalizedView);
123 static gchar selectedLocalized[BSIZE]="NONE";
124 /*************************************************************************************************************/
125 static gchar* listEXEView[] = { N_("Normal Run"), N_("Check"), N_("Debug")};
126 static gchar* listEXEReal[] = { "NORMAL", "CHECK", "DEBUG" };
127 static guint numberOfEXE = G_N_ELEMENTS (listEXEView);
128 static gchar selectedEXE[BSIZE]="NORMAL";
129 /*************************************************************************************************************/
gamessSemiEmperical()130 gboolean gamessSemiEmperical()
131 {
132 	if(
133 		strcmp(selectedSCF,"MNDO")==0 ||
134 		strcmp(selectedSCF,"AM1")==0 ||
135 		strcmp(selectedSCF,"PM3")==0
136 	  )return TRUE;
137 	else return FALSE;
138 }
139 /*************************************************************************************************************/
calculWord(gchar * view)140 static gchar* calculWord(gchar* view)
141 {
142 	gint i;
143 	for(i=0;i<numberOfRuns;i++)
144 	{
145 		if(strcmp(view,listRunView[i])==0)return listRunReal[i];
146 	}
147 	return NULL;
148 }
149 /*************************************************************************************************************/
putGamessRunTypeInfoInTextEditor()150 static void putGamessRunTypeInfoInTextEditor()
151 {
152 
153         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
154         gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$SYSTEM",-1);
155         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " MWORDS=20 ",-1);
156         gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$END\n",-1);
157 
158         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
159         gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$CONTRL",-1);
160         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " RUNTYP=",-1);
161         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, selectedRun,-1);
162         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
163         gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$END\n",-1);
164 
165 	if(!strcmp(selectedRun,"Optimize") || !strcmp(selectedRun,"Sadpoint"))
166 	{
167         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
168         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$STATPT",-1);
169         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, "  OptTol=1e-5 NStep=500 ",-1);
170         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$END\n",-1);
171 	}
172 	if(!strcmp(selectedRun,"IRC"))
173 	{
174         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
175         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$IRC",-1);
176         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, "  NPOINT=10 ",-1);
177         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$END\n",-1);
178 	}
179 	if(!strcmp(selectedRun,"Raman") || !strcmp(selectedRun,"Sadpoint") || !strcmp(selectedRun,"IRC"))
180 	{
181         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord,
182 			_("----> Put here the $HESS card.\n      You can obtain it from your old frequecncies calculation(.pun or .irc file)\n"),-1);
183 	}
184 }
185 /*************************************************************************************************************/
putGamessSCFControlInfoInTextEditor()186 static void putGamessSCFControlInfoInTextEditor()
187 {
188   	G_CONST_RETURN gchar *entrytext;
189 	gint maxit=20;
190 	if(strcmp(selectedSCF,"NONE")==0)return;
191 
192 	if(strcmp(selectedSCF,"MNDO")==0 || strcmp(selectedSCF,"AM1")==0 || strcmp(selectedSCF,"PM3")==0)
193 	{
194         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
195         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$BASIS",-1);
196         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " GBASIS=",-1);
197         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, selectedSCF,-1);
198         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
199         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$END\n",-1);
200 		if(getGamessMultiplicity()!=1)
201 		{
202         		gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
203         		gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$CONTRL",-1);
204         		gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " SCFTYP=ROHF ",-1);
205         		gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$END\n",-1);
206 		}
207 	}
208 	else
209 	{
210         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
211         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$CONTRL",-1);
212         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " SCFTYP=",-1);
213         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, selectedSCF,-1);
214         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
215         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$END\n",-1);
216 	}
217   	entrytext = gtk_entry_get_text(GTK_ENTRY(entrySCFIterations));
218 	maxit=atoi(entrytext);
219 	if(maxit==0)maxit=30;
220 	if(maxit!=30)
221 	{
222         	gchar buffer[BSIZE];
223 		sprintf(buffer," MAXIT=%d ",maxit);
224         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
225         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$CONTRL",-1);
226         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, buffer,-1);
227         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$END\n",-1);
228 	}
229 
230 }
231 /*************************************************************************************************************/
putGamessCorrelationInfoInTextEditor()232 static void putGamessCorrelationInfoInTextEditor()
233 {
234 	if(strcmp(selectedCorrType,"NONE")==0)return;
235         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
236 	if(strcmp(selectedCorrType,"DFTTYP")==0)
237         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$DFT",-1);
238 	else
239         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$CONTRL",-1);
240 
241         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
242 
243 	if(strcmp(selectedCorrType,"MPLEVL=2")==0)
244         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, selectedCorrType,-1);
245 	if(strcmp(selectedCorrType,"CCTYP")==0)
246 	{
247         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " CCTYP=",-1);
248         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, selectedCorrMethod,-1);
249 	}
250 	if(strcmp(selectedCorrType,"DFTTYP")==0)
251 	{
252         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " DFTTYP=",-1);
253         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, selectedCorrMethod,-1);
254 	}
255         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
256         gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$END\n",-1);
257 }
258 /*************************************************************************************************************/
putGamessLocalizedInfoInTextEditor()259 static void putGamessLocalizedInfoInTextEditor()
260 {
261 	if(strcmp(selectedLocalized,"NONE")==0)return;
262         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
263         gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$CONTRL",-1);
264         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " LOCAL=",-1);
265         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, selectedLocalized,-1);
266         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
267         gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$END\n",-1);
268 }
269 /*************************************************************************************************************/
putGamessEXEInfoInTextEditor()270 static void putGamessEXEInfoInTextEditor()
271 {
272 	if(strcmp(selectedEXE,"NORMAL")==0)return;
273         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
274         gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$CONTRL",-1);
275         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " EXETYP=",-1);
276         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, selectedEXE,-1);
277         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
278         gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$END\n",-1);
279 }
280 /*************************************************************************************************************/
putGamessControlInfoInTextEditor()281 void putGamessControlInfoInTextEditor()
282 {
283 	putGamessRunTypeInfoInTextEditor();
284 	putGamessSCFControlInfoInTextEditor();
285 	putGamessCorrelationInfoInTextEditor();
286 	putGamessLocalizedInfoInTextEditor();
287 	putGamessEXEInfoInTextEditor();
288 }
289 /************************************************************************************************************/
traitementRunType(GtkComboBox * combobox,gpointer d)290 static void traitementRunType (GtkComboBox *combobox, gpointer d)
291 {
292 	GtkTreeIter iter;
293 	gchar* data = NULL;
294 	gchar* res = NULL;
295 
296 	if (gtk_combo_box_get_active_iter (combobox, &iter))
297 	{
298 		GtkTreeModel* model = gtk_combo_box_get_model(combobox);
299 		gtk_tree_model_get (model, &iter, 0, &data, -1);
300 	}
301 	else return;
302 	res = calculWord(data);
303 	if(res) sprintf(selectedRun,"%s",res);
304 	else  sprintf(selectedRun,"Energy");
305 	setGamessCorrType();
306 
307 }
308 /********************************************************************************************************/
create_list_runtype()309 static GtkWidget *create_list_runtype()
310 {
311         GtkTreeIter iter;
312         GtkTreeStore *store;
313 	GtkTreeModel *model;
314 	GtkWidget *combobox;
315 	GtkCellRenderer *renderer;
316 	gint i;
317         GtkTreeIter iter0;
318 
319 	store = gtk_tree_store_new (1,G_TYPE_STRING);
320 
321 	for(i=0;i<numberOfRuns;i++)
322 	{
323         	gtk_tree_store_append (store, &iter, NULL);
324 		if(i==0) iter0 = iter;
325         	gtk_tree_store_set (store, &iter, 0, listRunView[i], -1);
326 	}
327 
328         model = GTK_TREE_MODEL (store);
329 	combobox = gtk_combo_box_new_with_model (model);
330 	/*
331 	gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
332 	*/
333 	g_object_unref (model);
334 	g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(traitementRunType), NULL);
335 	renderer = gtk_cell_renderer_text_new ();
336 	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
337 	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 0, NULL);
338 
339 	gtk_combo_box_set_active_iter(GTK_COMBO_BOX (combobox), &iter0);
340 
341 	return combobox;
342 }
343 /************************************************************************************************************/
setGamessSCFMethod(gboolean okRHF)344 void setGamessSCFMethod(gboolean okRHF)
345 {
346 	GtkTreeIter iter;
347 	GtkTreeIter iter0;
348 	gint i;
349 	/* gchar* s;*/
350 	if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX(comboSCF), &iter))
351 	{
352 		GtkTreeModel* model = gtk_combo_box_get_model(GTK_COMBO_BOX(comboSCF));
353         	GtkTreeStore *store = GTK_TREE_STORE(model);
354 		gint k = 0;
355 		gtk_tree_store_clear(store);
356 		for(i=0;i<numberOfSCF;i++)
357 		{
358 			if(!okRHF)
359 			if(strcmp(listSCFView[i],"RHF")==0)continue;
360         		gtk_tree_store_append (store, &iter, NULL);
361 			if(k==0) iter0 = iter;
362 			k++;
363         		gtk_tree_store_set (store, &iter, 0, listSCFView[i], -1);
364 		}
365 		gtk_combo_box_set_active_iter(GTK_COMBO_BOX (comboSCF), &iter0);
366 	}
367 }
368 /************************************************************************************************************/
traitementSCF(GtkComboBox * combobox,gpointer d)369 static void traitementSCF (GtkComboBox *combobox, gpointer d)
370 {
371 	GtkTreeIter iter;
372 	gchar* data = NULL;
373 	gchar* res = NULL;
374 	gint i;
375 	gboolean sm=FALSE;
376 	/* gchar* s;*/
377 	if (gtk_combo_box_get_active_iter (combobox, &iter))
378 	{
379 		GtkTreeModel* model = gtk_combo_box_get_model(combobox);
380 		gtk_tree_model_get (model, &iter, 0, &data, -1);
381 	}
382 	else return;
383 	for(i=0;i<numberOfSCF;i++)
384 	{
385 		if(strcmp((gchar*)data,listSCFView[i])==0) res = listSCFReal[i];
386 	}
387 	if(res) sprintf(selectedSCF,"%s",res);
388 	else  sprintf(selectedSCF,"RHF");
389 
390 	if(entrySCFIterations)
391 	{
392 		if(strcmp(selectedSCF,"NONE")==0 && entrySCFIterations)
393 			gtk_widget_set_sensitive(entrySCFIterations, FALSE);
394 		else
395 			gtk_widget_set_sensitive(entrySCFIterations, TRUE);
396 	}
397 	sm = gamessSemiEmperical();
398 	setSensitiveGamessBasisFrame(!sm);
399 	setSensitiveGamessSCFFrame(!sm);
400 	setSensitiveGamessGuessFrame(!sm);
401 	setGamessCorrType();
402 	/* for(s=selectedSCF;*s != 0;s++) *s = toupper(*s);*/
403 }
404 /********************************************************************************************************/
create_list_scf()405 static GtkWidget *create_list_scf()
406 {
407         GtkTreeIter iter;
408         GtkTreeStore *store;
409 	GtkTreeModel *model;
410 	GtkWidget *combobox;
411 	GtkCellRenderer *renderer;
412 	gint i;
413         GtkTreeIter iter0;
414 
415 	store = gtk_tree_store_new (1,G_TYPE_STRING);
416 
417 	for(i=0;i<numberOfSCF;i++)
418 	{
419         	gtk_tree_store_append (store, &iter, NULL);
420 		if(i==0) iter0 = iter;
421         	gtk_tree_store_set (store, &iter, 0, listSCFView[i], -1);
422 	}
423 
424         model = GTK_TREE_MODEL (store);
425 	combobox = gtk_combo_box_new_with_model (model);
426 	/*
427 	gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
428 	*/
429 	g_object_unref (model);
430 	g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(traitementSCF), NULL);
431 	renderer = gtk_cell_renderer_text_new ();
432 	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
433 	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 0, NULL);
434 
435 	gtk_combo_box_set_active_iter(GTK_COMBO_BOX (combobox), &iter0);
436 
437 	return combobox;
438 }
439 /************************************************************************************************************/
setGamessCorrMethod()440 static void setGamessCorrMethod()
441 {
442 	GtkTreeIter iter;
443 	GtkTreeIter iter0;
444 	gint i;
445 
446 	if(strcmp(selectedCorrType,"MPLEVL=2")==0)
447 	{
448 		numberOfCorrMethods = numberOfMP2;
449 		listCorrMethodsView = listMP2View;
450 		listCorrMethodsReal = listMP2Real;
451 	}
452 	else
453 	if(strcmp(selectedCorrType,"DFTTYP")==0)
454 	{
455 		numberOfCorrMethods = numberOfDFT;
456 		listCorrMethodsView = listDFTView;
457 		listCorrMethodsReal = listDFTReal;
458 	}
459 	else
460 	if(strcmp(selectedCorrType,"CCTYP")==0)
461 	{
462 		numberOfCorrMethods = numberOfCC;
463 		listCorrMethodsView = listCCView;
464 		listCorrMethodsReal = listCCReal;
465 	}
466 	else
467 	{
468 		numberOfCorrMethods = numberOfNone;
469 		listCorrMethodsView = listNoneView;
470 		listCorrMethodsReal = listNoneReal;
471 	}
472 
473 	if (comboCorrMethod && gtk_combo_box_get_active_iter (GTK_COMBO_BOX(comboCorrMethod), &iter))
474 	{
475 		GtkTreeModel* model = gtk_combo_box_get_model(GTK_COMBO_BOX(comboCorrMethod));
476         	GtkTreeStore *store = GTK_TREE_STORE(model);
477 		gtk_tree_store_clear(store);
478 
479 		for(i=0;i<numberOfCorrMethods;i++)
480 		{
481         		gtk_tree_store_append (store, &iter, NULL);
482 			if(i==0) iter0 = iter;
483         		gtk_tree_store_set (store, &iter, 0, listCorrMethodsView[i], -1);
484 		}
485 		gtk_combo_box_set_active_iter(GTK_COMBO_BOX (comboCorrMethod), &iter0);
486 	}
487 }
488 /************************************************************************************************************/
setGamessCorrType()489 static void setGamessCorrType()
490 {
491 	GtkTreeIter iter;
492 	GtkTreeIter iter0;
493 	gint i;
494 	gboolean sm = gamessSemiEmperical();
495 
496 	if (comboCorrType && GTK_IS_COMBO_BOX(comboCorrType))
497 	{
498 		GtkTreeModel* model = gtk_combo_box_get_model(GTK_COMBO_BOX(comboCorrType));
499         	GtkTreeStore *store = GTK_TREE_STORE(model);
500 		gtk_tree_store_clear(store);
501 
502 		for(i=0;i<numberOfCorrType;i++)
503 		{
504 			if(strcmp(selectedSCF,"RHF")==0 ||strcmp(selectedSCF,"NONE")==0 )
505 			{
506 				if(
507 				strcmp(selectedRun,"Energy")!=0 &&
508 				strcmp(selectedRun,"Trudge")!=0 &&
509 				strcmp(selectedRun,"Surface")!=0 &&
510 				strcmp(selectedRun,"FField")!=0 &&
511 				strcmp(listCorrTypeReal[i],"CCTYP")==0
512 						) continue;
513 				else
514 				{
515         				gtk_tree_store_append (store, &iter, NULL);
516 					if(i==0) iter0 = iter;
517         				gtk_tree_store_set (store, &iter, 0, listCorrTypeView[i], -1);
518 				}
519 			}
520 			else
521 			{
522 				if( strcmp(listCorrTypeReal[i],"CCTYP")==0) continue;
523 				else
524 				{
525         				gtk_tree_store_append (store, &iter, NULL);
526 					if(i==0) iter0 = iter;
527 					gtk_tree_store_set (store, &iter, 0, listCorrTypeView[i], -1);
528 				}
529 			}
530 			if(i==0 && sm) break;
531 
532 
533 		}
534 		gtk_combo_box_set_active_iter(GTK_COMBO_BOX (comboCorrType), &iter0);
535 	}
536 	setGamessCorrMethod();
537 }
538 /************************************************************************************************************/
traitementCorrType(GtkComboBox * combobox,gpointer d)539 static void traitementCorrType (GtkComboBox *combobox, gpointer d)
540 {
541 	GtkTreeIter iter;
542 	gchar* data = NULL;
543 	gchar* res = NULL;
544 	gint i;
545 	/* gchar* s;*/
546 	if (gtk_combo_box_get_active_iter (combobox, &iter))
547 	{
548 		GtkTreeModel* model = gtk_combo_box_get_model(combobox);
549 		gtk_tree_model_get (model, &iter, 0, &data, -1);
550 	}
551 	else return;
552 	for(i=0;i<numberOfCorrType;i++)
553 	{
554 		if(strcmp((gchar*)data,listCorrTypeView[i])==0) res = listCorrTypeReal[i];
555 	}
556 	if(res) sprintf(selectedCorrType,"%s",res);
557 	else  sprintf(selectedSCF,"NONE");
558 
559 	setGamessCorrMethod();
560 }
561 /********************************************************************************************************/
create_list_corrtype()562 static GtkWidget *create_list_corrtype()
563 {
564         GtkTreeIter iter;
565         GtkTreeStore *store;
566 	GtkTreeModel *model;
567 	GtkWidget *combobox;
568 	GtkCellRenderer *renderer;
569 	gint i;
570         GtkTreeIter iter0;
571 
572 	store = gtk_tree_store_new (1,G_TYPE_STRING);
573 
574 	for(i=0;i<numberOfCorrType;i++)
575 	{
576         	gtk_tree_store_append (store, &iter, NULL);
577 		if(i==0) iter0 = iter;
578         	gtk_tree_store_set (store, &iter, 0, listCorrTypeView[i], -1);
579 	}
580 
581         model = GTK_TREE_MODEL (store);
582 	combobox = gtk_combo_box_new_with_model (model);
583 	/*
584 	gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
585 	*/
586 	g_object_unref (model);
587 	g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(traitementCorrType), NULL);
588 	renderer = gtk_cell_renderer_text_new ();
589 	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
590 	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 0, NULL);
591 
592 	gtk_combo_box_set_active_iter(GTK_COMBO_BOX (combobox), &iter0);
593 
594 	return combobox;
595 }
596 /*************************************************************************************************************/
traitementCorrMethod(GtkComboBox * combobox,gpointer d)597 static void traitementCorrMethod (GtkComboBox *combobox, gpointer d)
598 {
599 	GtkTreeIter iter;
600 	gchar* data = NULL;
601 	gchar* res = NULL;
602 	gint i;
603 
604 	if (gtk_combo_box_get_active_iter (combobox, &iter))
605 	{
606 		GtkTreeModel* model = gtk_combo_box_get_model(combobox);
607 		gtk_tree_model_get (model, &iter, 0, &data, -1);
608 	}
609 	else return;
610 	for(i=0;i<numberOfCorrMethods;i++)
611 	{
612 		if(strcmp((gchar*)data,listCorrMethodsView[i])==0) res = listCorrMethodsReal[i];
613 	}
614 	if(res) sprintf(selectedCorrMethod,"%s",res);
615 	else  sprintf(selectedSCF,"NONE");
616 }
617 /********************************************************************************************************/
create_list_corrmethod()618 static GtkWidget *create_list_corrmethod()
619 {
620         GtkTreeIter iter;
621         GtkTreeStore *store;
622 	GtkTreeModel *model;
623 	GtkWidget *combobox;
624 	GtkCellRenderer *renderer;
625 	gint i;
626         GtkTreeIter iter0;
627 
628 	store = gtk_tree_store_new (1,G_TYPE_STRING);
629 
630 
631 	for(i=0;i<numberOfCorrMethods;i++)
632 	{
633         	gtk_tree_store_append (store, &iter, NULL);
634 		if(i==0) iter0 = iter;
635         	gtk_tree_store_set (store, &iter, 0, listCorrMethodsView[i], -1);
636 	}
637 
638         model = GTK_TREE_MODEL (store);
639 	combobox = gtk_combo_box_new_with_model (model);
640 	/*
641 	gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
642 	*/
643 	g_object_unref (model);
644 	g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(traitementCorrMethod), NULL);
645 	renderer = gtk_cell_renderer_text_new ();
646 	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
647 	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 0, NULL);
648 
649 	gtk_combo_box_set_active_iter(GTK_COMBO_BOX (combobox), &iter0);
650 
651 	return combobox;
652 }
653 /************************************************************************************************************/
traitementLocalized(GtkComboBox * combobox,gpointer d)654 static void traitementLocalized (GtkComboBox *combobox, gpointer d)
655 {
656 	GtkTreeIter iter;
657 	gchar* data = NULL;
658 	gchar* res = NULL;
659 	gint i;
660 	/* gchar* s;*/
661 	if (gtk_combo_box_get_active_iter (combobox, &iter))
662 	{
663 		GtkTreeModel* model = gtk_combo_box_get_model(combobox);
664 		gtk_tree_model_get (model, &iter, 0, &data, -1);
665 	}
666 	for(i=0;i<numberOfLocalized;i++)
667 	{
668 		if(strcmp((gchar*)data,listLocalizedView[i])==0) res = listLocalizedReal[i];
669 	}
670 	if(res) sprintf(selectedLocalized,"%s",res);
671 	else  sprintf(selectedSCF,"NONE");
672 	/* for(s=selectedLocalized;*s != 0;s++) *s = toupper(*s);*/
673 }
674 /********************************************************************************************************/
create_list_localized()675 static GtkWidget *create_list_localized()
676 {
677         GtkTreeIter iter;
678         GtkTreeStore *store;
679 	GtkTreeModel *model;
680 	GtkWidget *combobox;
681 	GtkCellRenderer *renderer;
682 	gint i;
683         GtkTreeIter iter0;
684 
685 	store = gtk_tree_store_new (1,G_TYPE_STRING);
686 
687 	for(i=0;i<numberOfLocalized;i++)
688 	{
689         	gtk_tree_store_append (store, &iter, NULL);
690 		if(i==0) iter0 = iter;
691         	gtk_tree_store_set (store, &iter, 0, listLocalizedView[i], -1);
692 	}
693 
694         model = GTK_TREE_MODEL (store);
695 	combobox = gtk_combo_box_new_with_model (model);
696 	/*
697 	gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
698 	*/
699 	g_object_unref (model);
700 	g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(traitementLocalized), NULL);
701 	renderer = gtk_cell_renderer_text_new ();
702 	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
703 	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 0, NULL);
704 
705 	gtk_combo_box_set_active_iter(GTK_COMBO_BOX (combobox), &iter0);
706 
707 	return combobox;
708 }
709 /************************************************************************************************************/
traitementEXE(GtkComboBox * combobox,gpointer d)710 static void traitementEXE (GtkComboBox *combobox, gpointer d)
711 {
712 	GtkTreeIter iter;
713 	gchar* data = NULL;
714 	gchar* res = NULL;
715 	gint i;
716 	/* gchar* s;*/
717 	if (gtk_combo_box_get_active_iter (combobox, &iter))
718 	{
719 		GtkTreeModel* model = gtk_combo_box_get_model(combobox);
720 		gtk_tree_model_get (model, &iter, 0, &data, -1);
721 	}
722 	for(i=0;i<numberOfEXE;i++)
723 	{
724 		if(strcmp((gchar*)data,listEXEView[i])==0) res = listEXEReal[i];
725 	}
726 	if(res) sprintf(selectedEXE,"%s",res);
727 	else  sprintf(selectedSCF,"NORMAL");
728 	/* for(s=selectedEXE;*s != 0;s++) *s = toupper(*s);*/
729 }
730 /********************************************************************************************************/
create_list_exe()731 static GtkWidget *create_list_exe()
732 {
733         GtkTreeIter iter;
734         GtkTreeStore *store;
735 	GtkTreeModel *model;
736 	GtkWidget *combobox;
737 	GtkCellRenderer *renderer;
738 	gint i;
739         GtkTreeIter iter0;
740 
741 	store = gtk_tree_store_new (1,G_TYPE_STRING);
742 
743 	for(i=0;i<numberOfEXE;i++)
744 	{
745         	gtk_tree_store_append (store, &iter, NULL);
746 		if(i==0) iter0 = iter;
747         	gtk_tree_store_set (store, &iter, 0, listEXEView[i], -1);
748 	}
749 
750         model = GTK_TREE_MODEL (store);
751 	combobox = gtk_combo_box_new_with_model (model);
752 	/*
753 	gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
754 	*/
755 	g_object_unref (model);
756 	g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(traitementEXE), NULL);
757 	renderer = gtk_cell_renderer_text_new ();
758 	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
759 	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 0, NULL);
760 
761 	gtk_combo_box_set_active_iter(GTK_COMBO_BOX (combobox), &iter0);
762 
763 	return combobox;
764 }
765 /************************************************************************************************************/
createGamessControlFrame(GtkWidget * win,GtkWidget * box)766 void createGamessControlFrame(GtkWidget *win, GtkWidget *box)
767 {
768 	GtkWidget* frame;
769 	GtkWidget* vboxFrame;
770 	GtkWidget* sep;
771 	GtkWidget* combo = NULL;
772 	gint l=0;
773 	gint c=0;
774 	gint ncases=1;
775 	GtkWidget *table = gtk_table_new(8,3,FALSE);
776 
777 	entrySCFIterations = NULL;
778 	comboCorrMethod = NULL;
779 	comboCorrType = NULL;
780 
781 	numberOfCorrMethods = numberOfNone;
782 	listCorrMethodsView = listNoneView;
783 	listCorrMethodsReal = listNoneReal;
784 
785 	frame = gtk_frame_new (_("Control"));
786 	gtk_widget_show (frame);
787 	gtk_box_pack_start (GTK_BOX (box), frame, TRUE, TRUE, 3);
788 	gtk_frame_set_label_align (GTK_FRAME (frame), 0.5, 0.5);
789 
790 	vboxFrame = gtk_vbox_new (FALSE, 3);
791 	gtk_widget_show (vboxFrame);
792 	gtk_container_add (GTK_CONTAINER (frame), vboxFrame);
793 	gtk_box_pack_start (GTK_BOX (vboxFrame), table, TRUE, TRUE, 0);
794 
795 	/*------------------ Run Type -----------------------------------------*/
796 	l=0;
797 	c = 0; ncases=1;
798 	add_label_table(table,_("Run Type"),l,c);
799 	c = 1; ncases=1;
800 	add_label_table(table,":",l,c);
801 	combo = create_list_runtype();
802 	c = 2; ncases=1;
803 	gtk_table_attach(GTK_TABLE(table),combo,c,c+ncases,l,l+1,
804 		(GtkAttachOptions)	(GTK_FILL | GTK_EXPAND),
805 		(GtkAttachOptions)	(GTK_FILL | GTK_SHRINK),
806                   2,2);
807 	/*------------------ SCF Type -----------------------------------------*/
808 	l++;
809 	c = 0; ncases=1;
810 	add_label_table(table,_("SCF Type"),l,c);
811 	c = 1; ncases=1;
812 	add_label_table(table,":",l,c);
813 	combo = create_list_scf();
814 	comboSCF=combo;
815 	c = 2; ncases=1;
816 	gtk_table_attach(GTK_TABLE(table),combo,c,c+ncases,l,l+1,
817 		(GtkAttachOptions)	(GTK_FILL | GTK_EXPAND),
818 		(GtkAttachOptions)	(GTK_FILL | GTK_SHRINK),
819                   2,2);
820 
821 	l++;
822 	c = 0; ncases=1;
823 	add_label_table(table,_("Max # SCF iterations"),l,c);
824 	c = 1; ncases=1;
825 	add_label_table(table,":",l,c);
826 	entrySCFIterations = gtk_entry_new ();
827 	gtk_entry_set_text(GTK_ENTRY(entrySCFIterations),"30");
828 	c = 2; ncases=1;
829 	gtk_table_attach(GTK_TABLE(table),entrySCFIterations,c,c+ncases,l,l+1,
830 		(GtkAttachOptions)	(GTK_FILL | GTK_EXPAND),
831 		(GtkAttachOptions)	(GTK_FILL | GTK_SHRINK),
832                   2,2);
833 
834 	/*------------------ Correlation Type -----------------------------------------*/
835 	l++;
836 	c = 0; ncases=1;
837 	add_label_table(table,_("Correlation Type"),l,c);
838 	c = 1; ncases=1;
839 	add_label_table(table,":",l,c);
840 	combo = create_list_corrtype();
841 	comboCorrType = combo;
842 	c = 2; ncases=1;
843 	gtk_table_attach(GTK_TABLE(table),combo,c,c+ncases,l,l+1,
844 		(GtkAttachOptions)	(GTK_FILL | GTK_EXPAND),
845 		(GtkAttachOptions)	(GTK_FILL | GTK_SHRINK),
846                   2,2);
847 	/*------------------ Correlation Method -----------------------------------------*/
848 	l++;
849 	c = 0; ncases=1;
850 	add_label_table(table,_("Correlation Method"),l,c);
851 	c = 1; ncases=1;
852 	add_label_table(table,":",l,c);
853 	combo = create_list_corrmethod();
854 	comboCorrMethod = combo;
855 	c = 2; ncases=1;
856 	gtk_table_attach(GTK_TABLE(table),combo,c,c+ncases,l,l+1,
857 		(GtkAttachOptions)	(GTK_FILL | GTK_EXPAND),
858 		(GtkAttachOptions)	(GTK_FILL | GTK_SHRINK),
859                   2,2);
860 	setGamessCorrType();
861 	/*------------------ Localized Type -----------------------------------------*/
862 	l++;
863 	c = 0; ncases=1;
864 	add_label_table(table,_("Localized Type"),l,c);
865 	c = 1; ncases=1;
866 	add_label_table(table,":",l,c);
867 	combo = create_list_localized();
868 	c = 2; ncases=1;
869 	gtk_table_attach(GTK_TABLE(table),combo,c,c+ncases,l,l+1,
870 		(GtkAttachOptions)	(GTK_FILL | GTK_EXPAND),
871 		(GtkAttachOptions)	(GTK_FILL | GTK_SHRINK),
872                   2,2);
873 
874 	/*------------------ separator -----------------------------------------*/
875 	l++;
876 	sep = gtk_hseparator_new ();;
877 	c = 0; ncases=3;
878 	gtk_table_attach(GTK_TABLE(table),sep,c,c+ncases,l,l+1,
879 		(GtkAttachOptions)	(GTK_FILL | GTK_EXPAND),
880 		(GtkAttachOptions)	(GTK_FILL | GTK_SHRINK),
881                   2,2);
882 	/*------------------ EXE Type -----------------------------------------*/
883 	l++;
884 	c = 0; ncases=1;
885 	add_label_table(table,_("EXE Type"),l,c);
886 	c = 1; ncases=1;
887 	add_label_table(table,":",l,c);
888 	combo = create_list_exe();
889 	c = 2; ncases=1;
890 	gtk_table_attach(GTK_TABLE(table),combo,c,c+ncases,l,l+1,
891 		(GtkAttachOptions)	(GTK_FILL | GTK_EXPAND),
892 		(GtkAttachOptions)	(GTK_FILL | GTK_SHRINK),
893                   2,2);
894 }
895