source: LMDZ6/branches/cirrus/libf/phylmd/ecrad.v1.5.1/drhook.h @ 5435

Last change on this file since 5435 was 3908, checked in by idelkadi, 4 years ago

Online implementation of the radiative transfer code ECRAD in the LMDZ model.

  • Inclusion of the ecrad directory containing the sources of the ECRAD code
    • interface routine : radiation_scheme.F90
  • Adaptation of compilation scripts :
    • compilation under CPP key CPP_ECRAD
    • compilation with option "-rad ecard" or "-ecard true"
    • The "-rad old/rtm/ecran" build option will need to replace the "-rrtm true" and "-ecrad true" options in the future.
  • Runing LMDZ simulations with ecrad, you need :
    • logical key iflag_rrtm = 2 in physiq.def
    • namelist_ecrad (DefLists?)
    • the directory "data" containing the configuration files is temporarily placed in ../libfphylmd/ecrad/
  • Compilation and execution are tested in the 1D case. The repository under svn would allow to continue the implementation work: tests, verification of the results, ...
File size: 7.1 KB
Line 
1/**
2 * (C) Copyright 2014- ECMWF.
3 *
4 * This software is licensed under the terms of the Apache Licence Version 2.0
5 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6 *
7 * In applying this licence, ECMWF does not waive the privileges and immunities
8 * granted to it by virtue of its status as an intergovernmental organisation
9 * nor does it submit to any jurisdiction.
10 */
11
12#ifndef _DRHOOK_H_
13#define _DRHOOK_H_
14
15#ifndef GNUC_BTRACE
16#define GNUC_BTRACE 128
17#endif
18
19#ifdef _DRHOOK_C_
20
21#if defined(__GNUC__)
22#define _GNU_SOURCE
23#endif
24
25#include <stdio.h>
26#include <string.h>
27#include <stdlib.h>
28#include <sys/time.h>
29#include <sys/resource.h>
30#include <unistd.h>
31#include <ctype.h>
32#include <signal.h>
33#include <errno.h>
34#include <time.h>
35#include <math.h>
36#include <sys/syscall.h>
37#include <sys/types.h>
38#include <pthread.h>
39#include <limits.h>
40#ifdef __NEC__
41static int backtrace(void **buffer, int size) { return 0; }
42#else
43#include <execinfo.h>
44#endif
45#include <sys/file.h>
46
47//#ifdef _OPENMP
48//#include <omp.h>
49//#endif
50
51#ifdef RS6K
52#include <fptrap.h>
53#endif
54
55#ifdef VPP
56#include <ucontext.h>
57#endif
58
59int drhook_lhook = 1;
60#else
61extern int drhook_lhook;
62#endif
63
64#ifndef O_LOCK_DONE
65#define O_LOCK_DONE
66
67/* OpenMP/ODB lock type */
68/* Keep consistent with "odb/include/privpub.h" */
69/* Be ALSO consistent with OML_LOCK_KIND in ifsaux/module/oml_mod.F90 */
70
71typedef long long int o_lock_t; /* i.e. 64-bit integer */
72
73#define INIT_LOCKID_WITH_NAME(mylock, lockname) \
74  coml_init_lockid_with_name_(mylock, lockname, strlen(lockname))
75
76extern void coml_set_debug_(const int *konoff, int *kret);
77extern void coml_init_lock_();
78extern void coml_init_lockid_(o_lock_t *mylock);
79extern void coml_init_lockid_with_name_(o_lock_t *mylock, const char *name, int name_len);
80extern void coml_set_lock_();
81extern void coml_set_lockid_(o_lock_t *mylock);
82extern void coml_unset_lock_();
83extern void coml_unset_lockid_(o_lock_t *mylock);
84extern void coml_test_lock_(int *is_set);
85extern void coml_test_lockid_(int *is_set, o_lock_t *mylock);
86extern void coml_in_parallel_(int *is_parallel_region);
87
88#endif
89
90/* drhook.c external interfaces */
91
92extern void
93c_drhook_getenv_(const char *s,
94                 char *value,
95                 /* Hidden arguments */
96                 int slen,
97                 const int valuelen);
98
99extern void
100c_drhook_memcounter_(const int *thread_id,
101                     const long long int *size,
102                     long long int *keyptr_addr);
103
104extern void
105c_drhook_raise_(const int *sig);
106
107extern void
108c_drhook_print_(const int *ftnunitno,
109                const int *thread_id,
110                const int *print_option, /*
111                                            1=raw call counts
112                                            2=calling tree
113                                            3=profiling info
114                                         */
115                int *level);
116
117extern void
118c_drhook_init_signals_(const int *enforce);
119
120extern void
121c_drhook_set_lhook_(const int *lhook);
122
123extern void 
124c_drhook_init_(const char *progname,
125               const int *num_threads
126               /* Hidden length */
127               ,int progname_len);
128
129extern void
130c_drhook_start_(const char *name, 
131                const int *thread_id, 
132                double *key,
133                const char *filename,
134                const int *sizeinfo
135                /* Hidden length */
136                ,int name_len, int filename_len);
137
138extern void
139c_drhook_end_(const char *name,
140              const int *thread_id,
141              const double *key,
142              const char *filename,
143              const int *sizeinfo
144              /* Hidden length */
145              ,int name_len, int filename_len);
146
147extern void
148c_drhook_watch_(const int *onoff,
149                const char *array_name,
150                const void *array_ptr,
151                const int *nbytes,
152                const int *abort_if_changed,
153                const int *printkey,
154                const int *nvals,
155                const int *print_traceback_when_set
156                /* Hidden length */
157                ,int array_name_len);
158
159extern void
160c_drhook_check_watch_(const char *where,
161                      const int *allow_abort
162                      /* Hidden length */
163                      , int where_len);
164
165/* see dr_hook_prt.F90 for below */
166extern void dr_hook_prt_logical_(const int *ftnunitno, const void *ptr, const int *nmax);
167extern void dr_hook_prt_char_(const int *ftnunitno, const void *ptr, const int *nmax);
168extern void dr_hook_prt_i4_(const int *ftnunitno, const void *ptr, const int *nmax);
169extern void dr_hook_prt_i8_(const int *ftnunitno, const void *ptr, const int *nmax);
170extern void dr_hook_prt_r4_(const int *ftnunitno, const void *ptr, const int *nmax);
171extern void dr_hook_prt_r8_(const int *ftnunitno, const void *ptr, const int *nmax);
172
173extern void ec_meminfo_(const int *KU, const char *CDSTRING, 
174                        const int *KCOMM, const int *KBARR, 
175                        const int *KIOTASK, const int *KCALL,
176                        int len_CDSTRING); /* see ec_meminfo.F90 */
177
178
179/* see comp_binding.F90 */
180extern void coml_get_max_threads_(int *numthreads);
181extern void coml_get_num_threads_(int *numthreads);
182extern void coml_my_thread_(int *mytid);
183
184/* see drhook.c */
185extern const char *drhook_TIMESTR(int tid);
186extern const char *drhook_PREFIX(int tid);
187
188/**** C-interface to Dr.Hook ****/
189
190extern void
191Dr_Hook(const char *name, int option, double *handle, 
192        const char *filename, int sizeinfo,
193        int name_len, int filename_len);
194
195#define DRHOOK_START_RECUR(name,recur) \
196  static const char *drhook_name = #name; \
197  static const int drhook_name_len = sizeof(#name) - 1; /* Compile time eval */ \
198  static const char *drhook_filename = __FILE__; \
199  static const int drhook_filename_len = sizeof(__FILE__) - 1; /* Compile time eval */ \
200  double zhook_handle; \
201  if (!recur && drhook_lhook) Dr_Hook(drhook_name, 0, &zhook_handle, \
202                                      drhook_filename, 0, \
203                                      drhook_name_len, drhook_filename_len); {
204
205#define DRHOOK_START(name) DRHOOK_START_RECUR(name,0)
206
207#define DRHOOK_START_BY_STRING_RECUR(name, recur) \
208  static const char *drhook_name = name; \
209  static const int drhook_name_len = sizeof(name) - 1; /* Compile time eval */ \
210  static const char *drhook_filename = __FILE__; \
211  static const int drhook_filename_len = sizeof(__FILE__) - 1; /* Compile time eval */ \
212  double zhook_handle; \
213  if (!recur && drhook_lhook) Dr_Hook(drhook_name, 0, &zhook_handle, \
214                                      drhook_filename, 0, \
215                                      drhook_name_len, drhook_filename_len); {
216
217#define DRHOOK_START_BY_STRING(name) DRHOOK_START_BY_STRING_RECUR(name,0)
218
219#define DRHOOK_RETURN_RECUR(sizeinfo,recur) \
220  if (!recur && drhook_lhook) Dr_Hook(drhook_name, 1, &zhook_handle, \
221                                      drhook_filename, sizeinfo, \
222                                      drhook_name_len, drhook_filename_len)
223
224#define DRHOOK_RETURN(sizeinfo) DRHOOK_RETURN_RECUR(sizeinfo,0)
225
226#define DRHOOK_END_RECUR(sizeinfo,recur) ; } DRHOOK_RETURN_RECUR(sizeinfo,recur)
227
228#define DRHOOK_END(sizeinfo) DRHOOK_END_RECUR(sizeinfo,0)
229
230/* Fortran routines */
231
232extern void
233dr_hook_prt_(const int *ftnunitno,
234             const char *s
235             /* Hidden arguments */
236             , int s_len);
237
238extern void
239dr_hook_procinfo_(int *myproc, int *nproc);
240
241#endif  /* _DRHOOK_H_ */
242
Note: See TracBrowser for help on using the repository browser.