1 /**********************************************************************************************************
2 Copyright (c) 2002-2013 Abdul-Rahman Allouche. All rights reserved
3 
4 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 documentation files (the Gabedit), to deal in the Software without restriction, including without limitation
6 the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
7 and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 
9   The above copyright notice and this permission notice shall be included in all copies or substantial portions
10   of the Software.
11 
12 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
13 TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
14 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
15 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
16 DEALINGS IN THE SOFTWARE.
17 ************************************************************************************************************/
18 
19 #ifndef __GABEDIT_UTILS_H__
20 #define __GABEDIT_UTILS_H__
21 
22 #define NHOSTMAX  	5
23 #define LOGFILE  	0
24 #define OUTFILE  	1
25 #define MOLDENFILE  	2
26 #define ALLFILES  	3
27 typedef struct _Point
28 {
29  gdouble C[3];
30 }Point;
31 
32 typedef struct _DataTree
33 {
34  gchar *projectname;
35  gchar *datafile;
36  gchar *localdir;
37 
38  gchar *remotehost;
39  gchar *remoteuser;
40  gchar *remotepass;
41  gchar *remotedir;
42  GabEditNetWork netWorkProtocol;
43 
44  gint itype;
45  gchar* command;
46  GtkTreeIter* noeud;
47 }DataTree;
48 
49 void timing(double* cpu,double *sys);
50 #ifdef G_OS_WIN32
51 gboolean winsockCheck(FILE* );
52 void addUnitDisk(FILE* file, G_CONST_RETURN gchar* name);
53 #endif /* G_OS_WIN32 */
54 void free_gaussian_commands();
55 void free_molpro_commands();
56 void free_mpqc_commands();
57 gchar* get_time_str();
58 gboolean this_is_a_backspace(gchar *st);
59 void changeDInE(gchar *st);
60 FILE* FOpen(const gchar *fileutf8, const gchar* type);
61 void  set_file_open(gchar* remotehost,gchar* remoteuser,gchar* remotedir, GabEditNetWork netWorkProtocol);
62 gboolean  this_is_an_object(GtkObject *obj);
63 G_CONST_RETURN gchar *get_local_user();
64 void Waiting(gdouble tsecond);
65 void Debug(char *fmt,...);
66 void add_host(const gchar *hostname, const gchar* username, const gchar* password, const gchar* dir);
67 gchar* get_line_chars(gchar c,gint n);
68 gchar* cat_file(gchar* namefile,gboolean tabulation);
69 gchar *run_command(gchar *command);
70 void run_local_command(gchar *outfile,gchar *errfile,gchar* command,gboolean under);
71 const gchar *gabedit_directory(void);
72 void DeleteLastChar(gchar *);
73 gchar *get_filename_without_ext(const gchar* allname);
74 gchar *get_suffix_name_file(const gchar*);
75 gchar *get_dir_file_name(G_CONST_RETURN gchar* dirname, G_CONST_RETURN gchar* filename);
76 gchar *get_name_dir(const gchar* );
77 gchar *get_name_file(const gchar* );
78 Point get_produit_vectoriel(Point V1,Point V2);
79 gchar *get_distance_points(Point P1,Point P2,gboolean f3);
80 gdouble get_module(Point V);
81 gdouble get_scalaire(Point V1,Point V2);
82 gchar *get_angle_vectors(Point V1,Point V2);
83 void create_hosts_file();
84 void create_ressource_file();
85 void read_ressource_file();
86 gchar *ang_to_bohr(gchar *);
87 gchar *bohr_to_ang(gchar *);
88 guint get_number_electrons(guint);
89 gdouble get_value_variableZmat(gchar *);
90 gdouble get_value_variableXYZ(gchar *);
91 guint get_num_variableXYZ(gchar *);
92 guint get_num_variableZmat(gchar *);
93 gboolean geometry_with_medium_layer();
94 gboolean geometry_with_lower_layer();
95 void uppercase(gchar *);
96 void lowercase(gchar *);
97 void initialise_batch_commands();
98 void initialise_name_file();
99 void reset_name_files();
100 void initialise_global_variables();
101 void run_molden (gchar *);
102 gboolean variable_name_valid(gchar *);
103 gboolean testa(char );
104 gboolean test(const gchar *);
105 gboolean testapointeE(char );
106 gboolean testpointeE(const gchar *);
107 void create_commands_file();
108 void create_network_file();
109 void create_fonts_file();
110 void set_tab_size (GtkWidget *view, gint tab_size);
111 void set_font (GtkWidget *view, gchar *fontname);
112 void set_font_style (GtkStyle* style,gchar *fontname);
113 GtkStyle *set_text_style(GtkWidget *text,gushort red,gushort green,gushort blue);
114 GtkStyle *set_base_style(GtkWidget *text,gushort red,gushort green,gushort blue);
115 GtkStyle *set_fg_style(GtkWidget *wid,gushort red,gushort green,gushort blue);
116 GtkStyle *set_bg_style(GtkWidget *wid,gushort red,gushort green,gushort blue);
117 gint numb_of_string_by_row(gchar *str);
118 gint numb_of_reals_by_row(gchar *str);
119 gchar** gab_split(gchar *str);
120 void gab_strfreev (char **str);
121 void get_dipole_from_gamess_output_file(FILE* fd);
122 void get_dipole_from_turbomole_output_file(FILE* fd);
123 void get_dipole_from_gaussian_output_file(FILE* fd);
124 void get_dipole_from_molpro_output_file(FILE* fd);
125 void get_dipole_from_dalton_output_file(FILE* fd);
126 void get_dipole_from_orca_output_file(FILE* fd);
127 void get_dipole_from_vasp_output_file(FILE* fd);
128 void get_dipole_from_nwchem_output_file(FILE* fd);
129 void get_dipole_from_psicode_output_file(FILE* fd);
130 void get_dipole_from_qchem_output_file(FILE* fd);
131 void get_dipole_from_mopac_output_file(FILE* fd);
132 void get_dipole_from_mopac_aux_file(FILE* fd);
133 void set_dipole(GtkWidget* fp,gpointer data);
134 void init_dipole();
135 void read_commands_file();
136 void read_network_file();
137 void set_path();
138 void read_hosts_file();
139 void read_fonts_file();
140 void delete_last_spaces(gchar* str);
141 void delete_first_spaces(gchar* str);
142 void delete_all_spaces(gchar* str);
143 void str_delete_n(gchar* str);
144 gchar* get_to_str(gchar* str,gchar* end);
145 gboolean isInteger(gchar *t);
146 gboolean isFloat(const gchar *t);
147 void get_symb_type_charge(gchar* str,gchar symb[], gchar type[], gchar charge[]);
148 gchar* get_font_label_name();
149 gint get_type_of_program(FILE* file);
150 void gabedit_string_get_pixel_size(GtkWidget* parent, PangoFontDescription *font_desc, G_CONST_RETURN gchar* t, int *width, int* height);
151 void gabedit_draw_string(GtkWidget* parent, GdkPixmap* pixmap, PangoFontDescription *font_desc, GdkGC* gc , gint x, gint y, G_CONST_RETURN gchar* t, gboolean centerX, gboolean centerY);
152 void gabedit_save_image(GtkWidget* widget, gchar *fileName, gchar* type);
153 G_CONST_RETURN gchar* get_open_babel_command();
154 gchar** get_one_block_from_aux_mopac_file(FILE* file, gchar* blockName,  gint* n);
155 gint get_num_orbitals_from_aux_mopac_file(FILE* file, gchar* blockName,  gint* begin, gint* end);
156 gchar** free_one_string_table(gchar** table, gint n);
157 gboolean zmat_mopac_irc_output_file(gchar *FileName);
158 gboolean zmat_mopac_scan_output_file(gchar *FileName);
159 GabEditTypeFile get_type_output_file(gchar* fileName);
160 GabEditTypeFile get_type_input_file(gchar* fileName);
161 GabEditTypeFile get_type_file(gchar* filename);
162 gchar * mystrcasestr(G_CONST_RETURN gchar *haystack, G_CONST_RETURN gchar *needle);
163 gint get_one_int_from_fchk_gaussian_file(FILE* file, gchar* blockName);
164 gdouble get_one_real_from_fchk_gaussian_file(FILE* file, gchar* blockName);
165 gint* get_array_int_from_fchk_gaussian_file(FILE* file, gchar* blockName, gint* nElements);
166 gdouble* get_array_real_from_fchk_gaussian_file(FILE* file, gchar* blockName, gint* nElements);
167 gchar** get_array_string_from_fchk_gaussian_file(FILE* file, gchar* blockName, gint* nElements);
168 void getvScaleBond(gdouble r, gdouble Center1[], gdouble Center2[], gdouble vScal[]);
169 void getPositionsRadiusBond3(gdouble r, gdouble Orig[], gdouble Center1[], gdouble Center2[], gdouble C11[], gdouble C12[],  gdouble C21[],  gdouble C22[], gdouble C31[],  gdouble C32[], gdouble radius[], gint type);
170 void getPositionsRadiusBond2(gdouble r, gdouble Orig[], gdouble Center1[], gdouble Center2[], gdouble C11[], gdouble C12[],  gdouble C21[],  gdouble C22[], gdouble radius[], gint type);
171 gdouble get_multipole_rank();
172 void getCoefsGradient(gint nBoundary, gdouble xh, gdouble yh, gdouble zh, gdouble* fcx, gdouble* fcy, gdouble* fcz);
173 void getCoefsLaplacian(gint nBoundary, gdouble xh, gdouble yh, gdouble zh, gdouble* fcx, gdouble* fcy, gdouble* fcz, gdouble* cc);
174 void swapDouble(gdouble* a, gdouble* b);
175 gdouble* newVectorDouble(gint n);
176 void initVectorDouble(gdouble* v, gint n, gdouble val);
177 void freeVectorDouble(gdouble** v);
178 void printVectorDoubleCutOff(gdouble* C, gint n, gdouble cutoff);
179 gdouble** newMatrixDouble(gint nrows, gint ncolumns);
180 void freeMatrixDouble(gdouble*** M, gint nrows);
181 void initMatrixDouble(gdouble** M, gint nrows, gint ncolumns, gdouble val);
182 void symmetrizeMatrixDouble(gdouble** M, gint nrows, gint ncolumns, gdouble cutOff);
183 void printMatrixDouble(gdouble** M, gint nrows, gint ncolumns);
184 void printMatrixDoubleCutOff(gdouble** M, gint nrows, gint ncolumns, gdouble cutoff);
185 gdouble*** newCubeDouble(gint nrows, gint ncolumns, gint nslices);
186 void printCubeDouble(gdouble*** C, gint nrows, gint ncolumns, gint nslices);
187 void printCubeDoubleCutOff(gdouble*** C, gint nrows, gint ncolumns, gint nslices, gdouble cutoff);
188 void symmetrizeCubeDouble(gdouble*** C, gint nrows, gint ncolumns,  gint nslices, gdouble cutOff);
189 void initCubeDouble(gdouble*** C, gint nrows, gint ncolumns, gint nslices, gdouble val);
190 void freeCubeDouble(gdouble**** C, gint nrows, gint ncolumns);
191 gdouble**** newQuarticDouble(gint nrows, gint ncolumns, gint nslices, gint nl);
192 void printQuarticDouble(gdouble**** C, gint nrows, gint ncolumns, gint nslices, gint nl);
193 void printQuarticDoubleCutOff(gdouble**** C, gint nrows, gint ncolumns, gint nslices, gint nl, gdouble cutoff);
194 void initQuarticDouble(gdouble**** C, gint nrows, gint ncolumns, gint nslices, gint nl, gdouble val);
195 void freeQuarticDouble(gdouble***** C, gint nrows, gint ncolumns, gint nl);
196 void symmetrizeQuarticDouble(gdouble**** Q, gint nrows, gint ncolumns,  gint nslices, gint nq, gdouble cutOff);
197 gint* newVectorInt(gint n);
198 void initVectorInt(gint* v, gint n, gint val);
199 void freeVectorInt(gint** v);
200 gint** newMatrixInt(gint nrows, gint ncolumns);
201 void initMatrixInt(gint** M, gint nrows, gint ncolumns, gint val);
202 void freeMatrixInt(gint*** M, gint nrows);
203 gint*** newCubeInt(gint nrows, gint ncolumns, gint nslices);
204 void initCubeInt(gint*** C, gint nrows, gint ncolumns, gint nslices, gint val);
205 void freeCubeInt(gint**** C, gint nrows, gint ncolumns);
206 gint**** newQuarticInt(gint nrows, gint ncolumns, gint nslices, gint nl);
207 void printQuarticInt(gint**** C, gint nrows, gint ncolumns, gint nslices, gint nl);
208 void initQuarticInt(gint**** C, gint nrows, gint ncolumns, gint nslices, gint nl, gint val);
209 void freeQuarticInt(gint***** C, gint nrows, gint ncolumns, gint nslices);
210 gchar* mystrcasestr(const gchar *haystack, const gchar *needle);
211 gboolean readOneReal(FILE* file, gchar* tag, gdouble*value);
212 gboolean readOneRealFromAFile(gchar* namefile, gchar* tag, gdouble* value);
213 gboolean readOneInt(FILE* file, gchar* tag, gint*value);
214 gboolean readOneIntFromAFile(gchar* namefile, gchar* tag, gint* value);
215 gboolean readOneBoolean(FILE* file, gchar* tag, gboolean*value);
216 gboolean readOneBooleanFromAFile(gchar* namefile, gchar* tag, gboolean* value);
217 gboolean readOneStringFromAFile(gchar* namefile, gchar* tag, gint* value);
218 gboolean readOneString(FILE* file, gchar* tag, gchar**value);
219 void strDeleten(gchar* str);
220 void deleteLastSpaces(gchar* str);
221 void deleteFirstSpaces(gchar* str);
222 void deleteAllSpaces(gchar* str);
223 gboolean goToStr(FILE* file, gchar* tag);
224 gchar** get_one_block_from_wfx_file(FILE* file, gchar* blockName,  gint* n);
225 gint* get_one_block_int_from_wfx_file(FILE* file, gchar* blockName,  gint* n);
226 gdouble* get_one_block_real_from_wfx_file(FILE* file, gchar* blockName,  gint* n);
227 gboolean get_one_int_from_wfx_file(FILE* file, gchar* blockName, gint* n);
228 gdouble* get_one_orbital_from_wfx_file(FILE* file, gint* n, gint*numOrb);
229 gchar *readFile(gchar *filename);
230 
231 #endif /* __GABEDIT_UTILS_H__ */
232 
233