added README_changes.txt
[wrffire.git] / wrfv2_fire / external / RSL / RSL / rsl_child_info.c
blob3491a0870d2e5c212e3a63cb3d029441896da9d8
1 /***********************************************************************
3 COPYRIGHT
5 The following is a notice of limited availability of the code and
6 Government license and disclaimer which must be included in the
7 prologue of the code and in all source listings of the code.
9 Copyright notice
10 (c) 1977 University of Chicago
12 Permission is hereby granted to use, reproduce, prepare
13 derivative works, and to redistribute to others at no charge. If
14 you distribute a copy or copies of the Software, or you modify a
15 copy or copies of the Software or any portion of it, thus forming
16 a work based on the Software and make and/or distribute copies of
17 such work, you must meet the following conditions:
19 a) If you make a copy of the Software (modified or verbatim)
20 it must include the copyright notice and Government
21 license and disclaimer.
23 b) You must cause the modified Software to carry prominent
24 notices stating that you changed specified portions of
25 the Software.
27 This software was authored by:
29 Argonne National Laboratory
30 J. Michalakes: (630) 252-6646; email: michalak@mcs.anl.gov
31 Mathematics and Computer Science Division
32 Argonne National Laboratory, Argonne, IL 60439
34 ARGONNE NATIONAL LABORATORY (ANL), WITH FACILITIES IN THE STATES
35 OF ILLINOIS AND IDAHO, IS OWNED BY THE UNITED STATES GOVERNMENT,
36 AND OPERATED BY THE UNIVERSITY OF CHICAGO UNDER PROVISION OF A
37 CONTRACT WITH THE DEPARTMENT OF ENERGY.
39 GOVERNMENT LICENSE AND DISCLAIMER
41 This computer code material was prepared, in part, as an account
42 of work sponsored by an agency of the United States Government.
43 The Government is granted for itself and others acting on its
44 behalf a paid-up, nonexclusive, irrevocable worldwide license in
45 this data to reproduce, prepare derivative works, distribute
46 copies to the public, perform publicly and display publicly, and
47 to permit others to do so. NEITHER THE UNITED STATES GOVERNMENT
48 NOR ANY AGENCY THEREOF, NOR THE UNIVERSITY OF CHICAGO, NOR ANY OF
49 THEIR EMPLOYEES, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
50 ASSUMES ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE ACCURACY,
51 COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS,
52 PRODUCT, OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD
53 NOT INFRINGE PRIVATELY OWNED RIGHTS.
55 ***************************************************************************/
57 #include <stdio.h>
58 #include <stdlib.h>
59 #include "rsl.h"
61 /* given a coarse domain point and nest index within it, return
62 its nest coords */
63 RSL_CHILD_INFO ( d_p, n_p, ig_p, jg_p, cm_p, cn_p, ni_p, nj_p, nig_p, njg_p )
64 int_p d_p, n_p, ig_p, jg_p, cm_p, cn_p ; /* input */
65 int_p ni_p, nj_p, nig_p, njg_p ; /* output */
67 int d, nst ;
68 int kidid ;
69 rsl_domain_info_t *ninfo, *dinfo ;
70 rsl_point_t *ndomain, *ddomain ;
71 int ig, jg, cn, cm, mlen, nlen, irax_n, irax_m ;
73 d = *d_p ;
74 nst = *n_p ;
75 RSL_TEST_ERR( d < 0 || d > RSL_MAXDOMAINS,
76 "rsl_child_info: bad parent domain descriptor" ) ;
77 RSL_TEST_ERR( nst < 0 || nst > RSL_MAXDOMAINS,
78 "rsl_child_info: bad nested domain descriptor" ) ;
79 RSL_TEST_ERR( d == nst,
80 "rsl_child_info: domain cannot broadcast to itself" ) ;
81 RSL_TEST_ERR( domain_info[nst].parent != d ,
82 "rsl_child_info: the nest is not a child of the parent" ) ;
84 dinfo = &( domain_info[d]) ;
85 ninfo = &( domain_info[nst]) ;
86 RSL_TEST_ERR( dinfo->valid != RSL_VALID,
87 "rsl_child_info: invalid parent domain" ) ;
88 RSL_TEST_ERR( ninfo->valid != RSL_VALID,
89 "rsl_child_info: invalid nested domain" ) ;
90 ddomain = dinfo->domain ;
91 ndomain = ninfo->domain ;
93 ig = *ig_p ;
94 jg = *jg_p ;
95 cn = *cn_p ;
96 cm = *cm_p ;
97 mlen = dinfo->len_m ;
98 nlen = dinfo->len_n ;
99 irax_n = dinfo->irax_n ;
100 irax_m = dinfo->irax_m ;
102 *nig_p = RSL_INVALID ;
103 *njg_p = RSL_INVALID ;
104 *ni_p = RSL_INVALID ;
105 *nj_p = RSL_INVALID ;
107 if ( ddomain[INDEX_2(jg,ig,mlen)].children_p != NULL )
109 kidid = ddomain[INDEX_2(jg,ig,mlen)].children_p->
110 child[INDEX_2(cn,cm,irax_m)] ;
111 *nig_p = ID_IDEX(kidid) ;
112 *njg_p = ID_JDEX(kidid) ;
113 *ni_p = *nig_p + ninfo->idif ;
114 *nj_p = *njg_p + ninfo->jdif ;
116 return ;
119 /* given a nested domain pt, return its coarse domain coords and
120 position within the cd cell */
121 RSL_CHILD_INFO1 ( d_p, n_p, nig_p, njg_p, cm_p, cn_p, i_p, j_p, ig_p, jg_p )
122 int_p d_p, n_p, nig_p, njg_p ; /* input */
123 int_p cm_p, cn_p, i_p, j_p, ig_p, jg_p ; /* output */
125 int d, nst ;
126 int mid ;
127 rsl_domain_info_t *ninfo, *dinfo ;
128 rsl_point_t *ndomain, *ddomain ;
129 int nig, njg, cn, cm, mlen, nlen, irax_n, irax_m ;
131 d = *d_p ;
132 nst = *n_p ;
133 RSL_TEST_ERR( d < 0 || d > RSL_MAXDOMAINS,
134 "rsl_child_info1: bad parent domain descriptor" ) ;
135 RSL_TEST_ERR( nst < 0 || nst > RSL_MAXDOMAINS,
136 "rsl_child_info1: bad nested domain descriptor" ) ;
137 RSL_TEST_ERR( d == nst,
138 "rsl_child_info1: domain cannot broadcast to itself" ) ;
139 RSL_TEST_ERR( domain_info[nst].parent != d ,
140 "rsl_child_info1: the nest is not a child of the parent" ) ;
142 dinfo = &( domain_info[d]) ;
143 ninfo = &( domain_info[nst]) ;
144 RSL_TEST_ERR( dinfo->valid != RSL_VALID,
145 "rsl_child_info1: invalid parent domain" ) ;
146 RSL_TEST_ERR( ninfo->valid != RSL_VALID,
147 "rsl_child_info1: invalid nested domain" ) ;
148 ddomain = dinfo->domain ;
149 ndomain = ninfo->domain ;
151 nig = *nig_p ;
152 njg = *njg_p ;
153 mlen = dinfo->len_m ;
154 nlen = dinfo->len_n ;
155 irax_n = dinfo->irax_n ;
156 irax_m = dinfo->irax_m ;
158 mid = ndomain[INDEX_2(njg,nig,mlen)].mother_id ;
159 *ig_p = ID_IDEX(mid) ;
160 *jg_p = ID_JDEX(mid) ;
161 *i_p = *ig_p + dinfo->idif ;
162 *j_p = *jg_p + dinfo->jdif ;
163 *cn_p = ndomain[INDEX_2(njg,nig,mlen)].which_kid_am_i_n ;
164 *cm_p = ndomain[INDEX_2(njg,nig,mlen)].which_kid_am_i_m ;
166 return ;