added README_changes.txt
[wrffire.git] / wrfv2_fire / external / RSL / RSL / comp_slabs.c
bloba9c27e2f59c31ac6dfe22b05e56ec1eba4d36741
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 *rp[RSL_MAXDOMAINS] ;
63 /*@
64 RSL_COMPUTE_ISLAB - apply a routine to each islab locally stored points
66 Synopsis:
67 subroutine RSL_COMPUTE_ISLAB ( d, f )
68 integer d
69 external f
71 Input parameters:
72 . d - domain descriptor
73 . f - subroutine to be applied
75 Notes:
76 This is one of the principal computational routines of RSL. It applies
77 a function that represents some piece of work -- compute a time step
78 -- to be done on a horizontal grid point. RSL_COMPUTE_ISLAB will
79 call the subroutine for each continguous run of points local to the
80 processor up the minor dimension of the domain.
82 The subroutine, f, provided should be slab-callable
83 and have six
84 integer dummy arguments which are shown in the example below.
86 Example:
88 $ -- prototypical function --
89 $ subroutine F( inest, irun, i1, j1, ig1, jg1 )
90 $ integer inest ! nest level (1 is top)
91 $ integer irun ! number of points in the run
92 $ integer i, j ! index of starting point in local memory
93 $ integer ig, jg ! index of starting point in global domain
95 $ j = j1
96 $ ig = ig1-1
97 $ do i = i1, i1+irun-1
98 $ ig = ig+1
99 $ -- computation --
100 $ enddo
102 $ return
103 $ end
105 $ -- top level routine --
107 $ external f, m
108 $ logical m
109 $ --
110 $ call rsl_compute_islab ( d, f )
111 $ --
113 BREAKTHEEXAMPLECODE
118 RSL_INIT_NEXTISLAB - Initialize a traversal over local slabs
120 RSL_C_NEXTISLAB - Get indices and run length of next slab in traversal
122 Notes:
123 These routines are called from within RSL_COMPUTE_ISLAB and are not
124 typically used by the application programmer.
127 int RSL_INIT_NEXTISLAB ( d_p )
128 int_p d_p ;
130 rsl_index_t d ;
132 d = *d_p ;
133 RSL_TEST_ERR( d < 0 || d >= RSL_MAXDOMAINS,
134 "rsl_init_nextislab: bad domain descriptor") ;
135 RSL_TEST_ERR( domain_info[d].valid != RSL_VALID,
136 "rsl_init_nextislab: invalid domain descriptor") ;
138 rp[d] = domain_info[d].iruns ;
139 return(0) ;
142 int RSL_C_NEXTISLAB ( d_p, irun_p, min_p, maj_p, min_g_p, maj_g_p, retval_p )
143 int_p d_p, irun_p, min_p, maj_p, min_g_p, maj_g_p, retval_p ;
145 rsl_index_t d ;
146 rsl_runrec_t *rrec ;
148 d = *d_p ;
149 RSL_TEST_ERR( d < 0 || d >= RSL_MAXDOMAINS,
150 "rsl_init_nextcell: bad domain") ;
151 RSL_TEST_ERR( domain_info[d].valid != RSL_VALID,
152 "rsl_init_nextcell: invalid domain") ;
153 if ( domain_info[d].decomposed != 1 )
155 default_decomposition( d_p,
156 &(domain_info[*d_p].loc_m),
157 &(domain_info[*d_p].loc_n) ) ;
160 if ( rp[d] == NULL )
162 *retval_p = 0 ; /* no more */
164 else
166 rrec = (rsl_runrec_t *)(rp[d]->data) ;
167 *irun_p = rrec->runlength ;
168 *min_g_p = rrec->ig + 1;
169 *maj_g_p = rrec->jg + 1;
170 *min_p = *min_g_p - domain_info[d].ilocaloffset ;
171 *maj_p = *maj_g_p - domain_info[d].jlocaloffset ;
172 rp[d] = rp[d]->next ;
173 *retval_p = 1 ;
175 return(0) ;