1 /// \file
2
3 // -*- Mode : c++ -*-
4 //
5 // SUMMARY :
6 // USAGE :
7 // ORG :
8 // AUTHOR : Frederic Hecht
9 // E-MAIL : hecht@ann.jussieu.fr
10 //
11
12 /*
13
14 This file is part of Freefem++
15
16 Freefem++ is free software; you can redistribute it and/or modify
17 it under the terms of the GNU Lesser General Public License as published by
18 the Free Software Foundation; either version 2.1 of the License, or
19 (at your option) any later version.
20
21 Freefem++ is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU Lesser General Public License for more details.
25
26 You should have received a copy of the GNU Lesser General Public License
27 along with Freefem++; if not, write to the Free Software
28 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30 #include <iostream>
31 #include <cstdio>
32
33
34 namespace ffapi {
35
36 // void init) ();
37 // need #include <iostream>
38 // need #include <sstream>
39 // need using namespace std;
40 std::istream * (*cin)();
41 std::ostream *(*cout)();
42 std::ostream *(*cerr)();
43
44 // <<mingw32_stdout>> Cannot name these functions identically to the original file pointers under MingW32 (compile
45 // error). Impacts [[file:InitFunct.hpp::LOADINITIO]]. Changed from stdxxx_ptr() to ffstdxxx() according to the way FF
46 // itself was changed.
47
48 FILE *(*ffstdout)();
49 FILE *(*ffstderr)();
50 FILE *(*ffstdin)();
51
52 /// Initiate graphical pipe output. I need a separate function for this to warn ffcs to check the corresponding ffglut
53 /// magic number
54
55 size_t (*fwriteinit)(const void *ptr, size_t size, size_t nmemb,FILE *stream);
56
57 /// Indicates the begining of a new plot to avoid sending socket control data with each plot item.
58
59 void (*newplot)();
60
61 /// Redefinition of standard system calls
62
63 FILE *(*ff_popen)(const char *command, const char *type);
64 int (*ff_pclose)(FILE *stream); // [[file:ffapi.cpp::ff_pclose]]
65 size_t (*ff_fwrite)(const void *ptr, size_t size, size_t nmemb,FILE *stream);
66 int (*ff_fflush)(FILE *stream);
67 int (*ff_ferror)(FILE *stream);
68 int (*ff_feof)(FILE *stream);
69
70 // Windows file mode
71 // -----------------
72
73 /// Changing file mode needs to be disabled when the file is a TCP socket to FFCS. Since the treatment is different in
74 /// FF and in FFLANG executables, they have to be stored in a DLL that changes between these two programs.
75
76 void (*wintextmode)(FILE *f);
77 void (*winbinmode)(FILE *f);
78
79 // Transfer basic MPI control
80 // --------------------------
81
82 void (*mpi_init)(int &argc, char **& argv);
83 void (*mpi_finalize)();
84
85 // Permanent server control
86 // ------------------------
87
88 /// if true, FF is considered to be accessible from remote anonymous connections and some commands (like shell
89 /// commands) are not allowed.
90
91 bool (*protectedservermode)();
92
93 }
94
95 // TODO: remove this block as soon as autoconf is removed from FreeFem++
96 #ifndef CMAKE
97 #include <config.h>
98 #endif
99
100 #include <complex>
101 #include "AFunction.hpp"
102 #include "error.hpp"
103 #include "lex.hpp"
104 #include "RNM.hpp"
105 #include <queue>
106 #include "environment.hpp"
107 #include "ufunction.hpp"
108 using namespace std;
109
110
111
112
113
114
115 #define FF_GRAPH_PTR_DCL
116 #include "rgraph.hpp"
117 #include "fem.hpp"
118 #include "Mesh3dn.hpp"
119
120 #include "HashMatrix.hpp"
121 #include "SparseLinearSolver.hpp"
122 #include "MeshPoint.hpp"
123
124 bool NoGraphicWindow=false;
125
126 /// <<verbosity>>
127 long verbosity = 1;
128 long searchMethod = 0; //pichon
129 long npichon2d=0, npichon3d=0;
130 long npichon2d1=0, npichon3d1=0;
131
132 FILE *ThePlotStream=0; // Add for new plot. FH oct 2008
133
134 KN<String> *pkarg;// for the list of argument mars 2010
135 Map_type_of_map map_type_of_map ; // to store te type
136 Map_type_of_map map_pair_of_type ; // to store te type
137
138 basicForEachType * typevarreal, * typevarcomplex; // type of real and complex variable
139
140 /// <<zzzfff>> see [[file:lex.hpp::mylex]]
141 mylex *zzzfff;
142 bool lexdebug;
143
144 /// <<plglval>> see [[file:../lglib/lg.ypp::YYSTYPE]] and [[file:../lglib/lg.ypp::yylval]]
145 #include "lg.tab.hpp"
146 YYSTYPE *plglval;
147
148 int TheCurrentLine=-1; // unset: by default
149 //int NbNewVarWithDel =0; // add FH sep 2016 (bof bof global variable not got but hard to set in E_F0 or C_F0
150 long mpisize=0,mpirank=0;
151
152
153 C_F0 *pOne=0,*pZero=0,*pminusOne=0;
154 // const C_F0 & One(*pOne), &Zero(*pZero);
155
156 Polymorphic * TheOperators=0, //=new Polymorphic(),
157 * TheRightOperators=0;//=new Polymorphic();
158
159 /// <<Global>> Contains all FreeFem++ language keywords. Declaration in [[file:AFunction.hpp::Global]]
160
161 TableOfIdentifier Global;
162
163 long E_Border::Count =0;
164
165 /// <<tables_of_identifier>> declared at [[file:AFunction.hpp::tables_of_identifier]]
166 typedef list<TableOfIdentifier *> ListOfTOfId;
167 ListOfTOfId tables_of_identifier;
168
169 const int AC_F0::MaxSize=1024; // maximal number of parameters
170
171
172
173 map<const string,basicForEachType *> map_type;
174 bool showCPU= false;
175
176
177 size_t CodeAlloc::nb=0, CodeAlloc::lg=0,CodeAlloc::nbpx=0,CodeAlloc::chunk=2048;
178 size_t CodeAlloc::nbt,CodeAlloc::nbdl=0;
179 CodeAlloc ** CodeAlloc::mem=0;
180 size_t CodeAlloc::memoryusage=0;
181 bool CodeAlloc::sort=true;
182 bool CodeAlloc::cleanning=false;
183 bool echo_edp=true; // add F.H of remove script dump
184
185 // add F. Hecht
186 EnvironmentData ffenvironment;
187
188 basicForEachType *basicForEachType::tnull=0;
189 E_F0 *E_F0::tnull=0;
190
191 long newconvect3=0;// old convect 3d
192
193 CodeAlloc *CodeAlloc::tnull=0;
194
195 #include <RefCounter.hpp>
196 RefCounter *RefCounter::tnull=0;
197 double ff_tgv=1e30;
198 bool lockOrientation=true;
199
InitMeshPoint(void * p)200 void InitMeshPoint(void * p)
201 {
202 EF23::MeshPoint*mps=static_cast<EF23::MeshPoint*>(p);
203 mps->unset();
204 }
205
206 string *def_solver=0,*def_solver_sym=0, *def_solver_sym_dp=0;
207