Original WRF subgrid support version from John Michalakes without fire
[wrffire.git] / wrfv2_fire / external / RSL / RSL / comp_cells.c
bloba1738a0b6364e040427f4771640fb1f13a7219a9
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 static rsl_list_t *lp[RSL_MAXDOMAINS] ;
64 /*@
65 RSL_COMPUTE_CELLS - apply a subroutine to all points of a domain
67 Synopsis:
68 RSL_COMPUTE_CELLS ( d, f )
69 INTEGER d ! (I) RSL domain descriptor
70 EXTERNAL f ! (I) Subroutine
72 Notes:
73 This routine is supported but considered obsolete.
74 RSL now provides more integrated means for iterating over decomposed
75 domain dimensions --- see LoopMacros.
77 RSL_COMPUTE_CELLS calls
78 a subroutine for each grid point of the domain.
79 By default, the
80 cells on each processor are traversed in an M-minor, N-major ordering.
81 This ordering can be changed
82 using RSL_ORDER. Use RSL_COMPUTE_MASK to iterate over a subset of a domain.
83 The subroutine F takes five
84 integer arguments (see example) that provide local and global indices of
85 a point and nest level. Other model data must be provided to the subroutine
86 through common or through a USE statement (Fortran90).
88 Example:
90 $ subroutine F( inest, i, j, ig, jg )
91 $ integer inest ! nest level (1 is top)
92 $ integer i, j ! index of point in local memory
93 $ integer ig, jg ! index of point in global domain
94 $ -- computation for point --
95 $ return
96 $ end
98 $ external f
99 $ --
100 $ call rsl_compute_cells ( d, f )
101 $ --
102 $ stop
103 $ end
105 BREAKTHEEXAMPLECODE
107 The subroutine F is
108 called for a point of the domain d if M evaluates true.
110 See also:
111 LoopMacros, RSL_ORDER, RSL_COMPUTE_MASK
116 RSL_COMPUTE_MASK - apply a subroutine to selected points in a domain
118 Synopsis:
119 RSL_COMPUTE_MASK ( d, f, m )
120 INTEGER d ! (I) RSL domain descriptor
121 EXTERNAL f ! (I) Subroutine
122 EXTERNAL m ! (I) Mask function
123 LOGICAL m
125 Notes:
126 This routine is supported but considered obsolete.
127 RSL now provides more integrated means for iterating over decomposed
128 domain dimensions --- see LoopMacros.
130 RSL_COMPUTE_MASK calls
131 a subroutine for grid points of the domain based on evaluation of a
132 mask function. See also RSL_COMPUTE_CELLS.
134 Example:
135 $ subroutine F( inest, i, j, ig, jg )
136 $ integer inest ! nest level (1 is top)
137 $ integer i, j ! index of point in local memory
138 $ integer ig, jg ! index of point in global domain
139 $ -- computation for point --
140 $ return
141 $ end
143 $ logical function M ( inest, i, j, ig, jg )
144 $ M = < .true. if included in computation >
145 $ return
146 $ end
148 $ external f, m
149 $ logical m
150 $ --
151 $ call rsl_compute_mask ( d, f, m )
152 $ --
153 BREAKTHEEXAMPLECODE
155 The subroutine F is
156 called for a point of the domain d if M evaluates true.
158 See also:
159 LoopMacros, RSL_ORDER, RSL_COMPUTE_MASK
163 int RSL_INIT_NEXTCELL ( d_p )
164 int_p d_p ;
166 rsl_index_t d ;
168 d = *d_p ;
169 RSL_TEST_ERR( d < 0 || d >= RSL_MAXDOMAINS,
170 "rsl_init_nextcell: bad domain") ;
171 RSL_TEST_ERR( domain_info[d].valid != RSL_VALID,
172 "rsl_init_nextcell: invalid domain") ;
173 if ( domain_info[d].decomposed != 1 )
175 default_decomposition( d_p,
176 &(domain_info[*d_p].loc_m),
177 &(domain_info[*d_p].loc_n) ) ;
179 lp[d] = domain_info[d].pts ;
180 return(0) ;
183 int RSL_INIT_GHOST ( d_p )
184 int_p d_p ;
186 rsl_index_t d ;
188 d = *d_p ;
189 RSL_TEST_ERR( d < 0 || d >= RSL_MAXDOMAINS,
190 "rsl_init_nextcell: invalid domain") ;
191 RSL_TEST_ERR( domain_info[d].valid != RSL_VALID,
192 "rsl_init_nextcell: invalid domain") ;
193 lp[d] = domain_info[d].ghost_pts ;
194 return(0) ;
197 int RSL_C_NEXTCELL ( d_p, min_p, maj_p, min_g_p, maj_g_p, retval_p )
198 int_p d_p, min_p, maj_p, min_g_p, maj_g_p, retval_p ;
200 rsl_index_t d ;
201 rsl_point_t *pt ;
203 d = *d_p ;
204 RSL_TEST_ERR( d < 0 || d >= RSL_MAXDOMAINS,
205 "rsl_init_nextcell: invalid domain") ;
207 if ( lp[d] == NULL )
209 *retval_p = 0 ; /* no more */
211 else
213 pt = (rsl_point_t *) lp[d]->data ;
214 *min_g_p = ID_IDEX( pt->id ) + 1;
215 *maj_g_p = ID_JDEX( pt->id ) + 1;
216 *min_p = *min_g_p - domain_info[d].ilocaloffset ;
217 *maj_p = *maj_g_p - domain_info[d].jlocaloffset ;
218 #if 0
219 fprintf(stderr,"%d comp_cells point -> %d %d %d %d; jlocaloffset %d\n",
220 rsl_myproc, *min_p, *maj_p, *min_g_p, *maj_g_p,
221 domain_info[d].jlocaloffset) ;
222 #endif
223 lp[d] = lp[d]->next ;
224 *retval_p = 1 ;
226 return(0) ;