Last change
on this file since 5054 was
3908,
checked in by idelkadi, 3 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:
1.3 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 | // cas.h |
---|
13 | // |
---|
14 | // compare_and_swap -based locks |
---|
15 | // |
---|
16 | // Thanks to https://github.com/majek/dump/blob/master/msqueue/queue_lock_myspinlock1.c |
---|
17 | // |
---|
18 | |
---|
19 | #include <signal.h> |
---|
20 | #include <sched.h> |
---|
21 | |
---|
22 | #ifndef INLINE |
---|
23 | #define INLINE __inline__ |
---|
24 | #endif |
---|
25 | |
---|
26 | #if defined(__GNUC__) && !defined(__NEC__) |
---|
27 | |
---|
28 | #define CAS(lock,oldval,newval) __sync_bool_compare_and_swap(lock,oldval,newval) |
---|
29 | |
---|
30 | #else |
---|
31 | |
---|
32 | #warning *** CAS-locks self-implemented *** |
---|
33 | |
---|
34 | static INLINE int CAS(volatile sig_atomic_t *lock, int oldval, int newval) |
---|
35 | { |
---|
36 | int tmp = *lock; |
---|
37 | if (tmp == oldval) *lock = newval; |
---|
38 | return tmp; |
---|
39 | } |
---|
40 | |
---|
41 | #endif |
---|
42 | |
---|
43 | static INLINE void cas_init(volatile sig_atomic_t *lock) |
---|
44 | { |
---|
45 | if (lock) *lock = 0; |
---|
46 | } |
---|
47 | |
---|
48 | static INLINE void cas_lock(volatile sig_atomic_t *lock) |
---|
49 | { |
---|
50 | while (1) { |
---|
51 | int i; |
---|
52 | for (i=0; i < 10000; ++i) { |
---|
53 | if (CAS(lock, 0, 1)) return; |
---|
54 | } |
---|
55 | sched_yield(); |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | static INLINE void cas_unlock(volatile sig_atomic_t *lock) |
---|
60 | { |
---|
61 | CAS(lock, 1, 0); |
---|
62 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.