| [70c4392] | 1 | /*
|
|---|
| 2 | A simple 2D hydro code
|
|---|
| 3 | (C) Romain Teyssier : CEA/IRFU -- original F90 code
|
|---|
| 4 | (C) Pierre-Francois Lavallee : IDRIS -- original F90 code
|
|---|
| 5 | (C) Guillaume Colin de Verdiere : CEA/DAM -- for the C version
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | /*
|
|---|
| 9 |
|
|---|
| 10 | This software is governed by the CeCILL license under French law and
|
|---|
| 11 | abiding by the rules of distribution of free software. You can use,
|
|---|
| 12 | modify and/ or redistribute the software under the terms of the CeCILL
|
|---|
| 13 | license as circulated by CEA, CNRS and INRIA at the following URL
|
|---|
| 14 | "http://www.cecill.info".
|
|---|
| 15 |
|
|---|
| 16 | As a counterpart to the access to the source code and rights to copy,
|
|---|
| 17 | modify and redistribute granted by the license, users are provided only
|
|---|
| 18 | with a limited warranty and the software's author, the holder of the
|
|---|
| 19 | economic rights, and the successive licensors have only limited
|
|---|
| 20 | liability.
|
|---|
| 21 |
|
|---|
| 22 | In this respect, the user's attention is drawn to the risks associated
|
|---|
| 23 | with loading, using, modifying and/or developing or reproducing the
|
|---|
| 24 | software by the user in light of its specific status of free software,
|
|---|
| 25 | that may mean that it is complicated to manipulate, and that also
|
|---|
| 26 | therefore means that it is reserved for developers and experienced
|
|---|
| 27 | professionals having in-depth computer knowledge. Users are therefore
|
|---|
| 28 | encouraged to load and test the software's suitability as regards their
|
|---|
| 29 | requirements in conditions enabling the security of their systems and/or
|
|---|
| 30 | data to be ensured and, more generally, to use and operate it in the
|
|---|
| 31 | same conditions as regards security.
|
|---|
| 32 |
|
|---|
| 33 | The fact that you are presently reading this means that you have had
|
|---|
| 34 | knowledge of the CeCILL license and that you accept its terms.
|
|---|
| 35 |
|
|---|
| 36 | */
|
|---|
| 37 | #ifndef UTILS_H_INCLUDED
|
|---|
| 38 | #define UTILS_H_INCLUDED
|
|---|
| 39 |
|
|---|
| 40 | #include "parametres.h"
|
|---|
| 41 |
|
|---|
| 42 | #ifndef Square
|
|---|
| 43 | #define Square(x) ((x) * (x))
|
|---|
| 44 | #endif /* */
|
|---|
| 45 |
|
|---|
| 46 | #ifndef MAX
|
|---|
| 47 | #define MAX(x, y) ((x) > (y)? (x): (y))
|
|---|
| 48 | #endif /* */
|
|---|
| 49 | #ifndef MIN
|
|---|
| 50 | #define MIN(x, y) ((x) < (y)? (x): (y))
|
|---|
| 51 | #endif /* */
|
|---|
| 52 |
|
|---|
| 53 | real_t **allocate(int imin, int imax, int nvar);
|
|---|
| 54 | real_t *DMalloc(size_t n);
|
|---|
| 55 | int *IMalloc(size_t n);
|
|---|
| 56 | void DFree(real_t ** adr, size_t n);
|
|---|
| 57 | void IFree(int ** adr, size_t n);
|
|---|
| 58 |
|
|---|
| 59 | // 0 means perfect memory management from the code ;-)
|
|---|
| 60 | // static const int MallocGuard = 0;
|
|---|
| 61 | #define MallocGuard 0
|
|---|
| 62 | void printuoldf(FILE * fic, const hydroparam_t H, hydrovar_t * Hv);
|
|---|
| 63 | void printarray(FILE * fic, real_t *a, int n, const char *nom, const hydroparam_t H);
|
|---|
| 64 | void printarrayi(FILE * fic, int *a, int n, const char *nom);
|
|---|
| 65 | void printarrayv(FILE * fic, real_t *a, int n, const char *nom, const hydroparam_t H);
|
|---|
| 66 | void printarrayv2(FILE * fic, real_t *a, int n, const char *nom, const hydroparam_t H);
|
|---|
| 67 | void timeToString(char *buf, const double timeInS);
|
|---|
| 68 |
|
|---|
| 69 | #ifndef PRINTUOLD
|
|---|
| 70 | #ifndef HMPP
|
|---|
| 71 | #define PRINTUOLD(f,x,y) if ((x).prt) { printuoldf((f), (x), (y)); }
|
|---|
| 72 | #define PRINTARRAY(f,x,y,z,t) if ((t).prt) { printarray((f), (real_t *) (x), (y), (z), (t)); }
|
|---|
| 73 | #define PRINTARRAYI(f,x,y,z,t) if ((t).prt) { printarrayi((f), (x), (y), (z)); }
|
|---|
| 74 | #define PRINTARRAYV(f,x,y,z,t) if ((t).prt) { printarrayv((f), (real_t *) (x), (y), (z), (t)); }
|
|---|
| 75 | #define PRINTARRAYV2(f,x,y,z,t) if ((t).prt) { printarrayv2((f), (real_t *) (x), (y), (z), (t)); }
|
|---|
| 76 | #else /* */
|
|---|
| 77 | // HMPP doesn't support prints : kill them
|
|---|
| 78 | #define PRINTUOLD(x, y)
|
|---|
| 79 | #define PRINTARRAY(x, y, z, t)
|
|---|
| 80 | #define PRINTARRAYI(x, y, z, t)
|
|---|
| 81 | #define PRINTARRAYV(x, y, z, t)
|
|---|
| 82 | #endif /* */
|
|---|
| 83 | #endif /* */
|
|---|
| 84 |
|
|---|
| 85 | #ifndef WHERE
|
|---|
| 86 | #ifndef HMPP
|
|---|
| 87 | // #define WHERE(n) do { if (H.prt) {fprintf(stdout, "@@%s in %s\n", (n), __FILE__); }} while (0)
|
|---|
| 88 | #define WHERE(n) do { if (0) {fprintf(stdout, "@@%s\n", (n)); }} while (0)
|
|---|
| 89 | #else /* */
|
|---|
| 90 | #define WHERE(n)
|
|---|
| 91 | #endif /* */
|
|---|
| 92 | #endif /* */
|
|---|
| 93 |
|
|---|
| 94 | #ifndef HMPP
|
|---|
| 95 | #define RESTRICT __restrict
|
|---|
| 96 | #else /* */
|
|---|
| 97 | #define RESTRICT __restrict
|
|---|
| 98 | #endif /* */
|
|---|
| 99 |
|
|---|
| 100 | // #ifndef __MIC__
|
|---|
| 101 | // #pragma message "collapse activated (2)"
|
|---|
| 102 | // #define COLLAPSE collapse(2)
|
|---|
| 103 | // #else
|
|---|
| 104 | // #pragma message "collapse deactivated on MIC"
|
|---|
| 105 | #define COLLAPSE
|
|---|
| 106 | // #endif
|
|---|
| 107 |
|
|---|
| 108 | #endif // UTILS_H_INCLUDED
|
|---|