| 1 |
/* ./src_f77/cgmgdrvd.f -- translated by f2c (version 20030320). |
| 2 |
You must link the resulting object file with the libraries: |
| 3 |
-lf2c -lm (in that order) |
| 4 |
*/ |
| 5 |
|
| 6 |
#include <punc/vf2c.h> |
| 7 |
|
| 8 |
/* Table of constant values */ |
| 9 |
|
| 10 |
static integer c__9 = 9; |
| 11 |
static integer c__1 = 1; |
| 12 |
static integer c__3 = 3; |
| 13 |
static integer c__0 = 0; |
| 14 |
static integer c_n99 = -99; |
| 15 |
static doublereal c_b23 = 0.; |
| 16 |
static integer c__5 = 5; |
| 17 |
|
| 18 |
/* * /////////////////////////////////////////////////////////////////////////// */ |
| 19 |
/* * @file cgmgdrvd.f */ |
| 20 |
/* * @author Michael Holst */ |
| 21 |
/* * @brief Driver for CG preconditioned with MG. */ |
| 22 |
/* * @version $Id: cgmgdrvd.c,v 1.3 2010/08/12 05:45:21 fetk Exp $ */ |
| 23 |
/* * @attention */ |
| 24 |
/* * @verbatim */ |
| 25 |
/* * */ |
| 26 |
/* * PMG -- Parallel algebraic MultiGrid */ |
| 27 |
/* * Copyright (C) 1994-- Michael Holst. */ |
| 28 |
/* * */ |
| 29 |
/* * Michael Holst <[email protected]> */ |
| 30 |
/* * University of California, San Diego */ |
| 31 |
/* * Department of Mathematics, 5739 AP&M */ |
| 32 |
/* * 9500 Gilman Drive, Dept. 0112 */ |
| 33 |
/* * La Jolla, CA 92093-0112 USA */ |
| 34 |
/* * http://math.ucsd.edu/~mholst */ |
| 35 |
/* * */ |
| 36 |
/* * This file is part of PMG. */ |
| 37 |
/* * */ |
| 38 |
/* * PMG is free software; you can redistribute it and/or modify */ |
| 39 |
/* * it under the terms of the GNU General Public License as published by */ |
| 40 |
/* * the Free Software Foundation; either version 2 of the License, or */ |
| 41 |
/* * (at your option) any later version. */ |
| 42 |
/* * */ |
| 43 |
/* * PMG is distributed in the hope that it will be useful, */ |
| 44 |
/* * but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
| 45 |
/* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ |
| 46 |
/* * GNU General Public License for more details. */ |
| 47 |
/* * */ |
| 48 |
/* * You should have received a copy of the GNU General Public License */ |
| 49 |
/* * along with PMG; if not, write to the Free Software */ |
| 50 |
/* * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ |
| 51 |
/* * */ |
| 52 |
/* * Linking PMG statically or dynamically with other modules is making a */ |
| 53 |
/* * combined work based on PMG. Thus, the terms and conditions of the GNU */ |
| 54 |
/* * General Public License cover the whole combination. */ |
| 55 |
/* * */ |
| 56 |
/* * SPECIAL GPL EXCEPTION */ |
| 57 |
/* * In addition, as a special exception, the copyright holders of PMG */ |
| 58 |
/* * give you permission to combine the PMG program with free software */ |
| 59 |
/* * programs and libraries that are released under the GNU LGPL or with */ |
| 60 |
/* * code included in releases of ISIM, PMV, PyMOL, SMOL, VMD, and Vision. */ |
| 61 |
/* * Such combined software may be linked with PMG and redistributed together */ |
| 62 |
/* * in original or modified form as mere aggregation without requirement that */ |
| 63 |
/* * the entire work be under the scope of the GNU General Public License. */ |
| 64 |
/* * This special exception permission is also extended to any software listed */ |
| 65 |
/* * in the SPECIAL GPL EXCEPTION clauses by the FEtk and APBS libraries. */ |
| 66 |
/* * */ |
| 67 |
/* * Note that people who make modified versions of PMG are not obligated */ |
| 68 |
/* * to grant this special exception for their modified versions; it is */ |
| 69 |
/* * their choice whether to do so. The GNU General Public License gives */ |
| 70 |
/* * permission to release a modified version without this exception; this */ |
| 71 |
/* * exception also makes it possible to release a modified version which */ |
| 72 |
/* * carries forward this exception. */ |
| 73 |
/* * */ |
| 74 |
/* * @endverbatim */ |
| 75 |
/* * /////////////////////////////////////////////////////////////////////////// */ |
| 76 |
/* Subroutine */ int cgmgdriv_(integer *iparm, doublereal *rparm, integer * |
| 77 |
iwork, doublereal *rwork, doublereal *u, doublereal *xf, doublereal * |
| 78 |
yf, doublereal *zf, doublereal *gxcf, doublereal *gycf, doublereal * |
| 79 |
gzcf, doublereal *a1cf, doublereal *a2cf, doublereal *a3cf, |
| 80 |
doublereal *ccf, doublereal *fcf, doublereal *tcf) |
| 81 |
{ |
| 82 |
/* Builtin functions */ |
| 83 |
integer s_wsle(cilist *), do_lio(integer *, integer *, char *, ftnlen), |
| 84 |
e_wsle(void); |
| 85 |
|
| 86 |
/* Local variables */ |
| 87 |
extern /* Subroutine */ int cgmgdriv2_(integer *, doublereal *, integer *, |
| 88 |
integer *, integer *, doublereal *, integer *, doublereal *, |
| 89 |
doublereal *, integer *, doublereal *, doublereal *, doublereal *, |
| 90 |
doublereal *, doublereal *, doublereal *, doublereal *, |
| 91 |
doublereal *, doublereal *, doublereal *, doublereal *, |
| 92 |
doublereal *, doublereal *, doublereal *, doublereal *, |
| 93 |
doublereal *, doublereal *); |
| 94 |
static integer nc, nf, nx, ny, nz, nxc, nyc, nzc, k_w1__, k_w2__, k_ac__, |
| 95 |
k_cc__, k_fc__, k_pc__, k_iz__, n_iz__, narr, nlev, niwk; |
| 96 |
extern /* Subroutine */ int mgsz_(integer *, integer *, integer *, |
| 97 |
integer *, integer *, integer *, integer *, integer *, integer *, |
| 98 |
integer *, integer *, integer *, integer *, integer *, integer *, |
| 99 |
integer *, integer *, integer *, integer *); |
| 100 |
static integer nrwk, mxlv, k_ipc__, n_ipc__, k_rpc__, n_rpc__, narrc, |
| 101 |
mgdisc, mgcoar; |
| 102 |
extern integer maxlev_(integer *, integer *, integer *); |
| 103 |
static integer ierror, iretot, iintot, mgsolv; |
| 104 |
|
| 105 |
/* Fortran I/O blocks */ |
| 106 |
static cilist io___7 = { 0, 6, 0, 0, 0 }; |
| 107 |
static cilist io___10 = { 0, 6, 0, 0, 0 }; |
| 108 |
static cilist io___26 = { 0, 6, 0, 0, 0 }; |
| 109 |
static cilist io___27 = { 0, 6, 0, 0, 0 }; |
| 110 |
|
| 111 |
|
| 112 |
/* * ********************************************************************* */ |
| 113 |
/* * purpose: */ |
| 114 |
/* * */ |
| 115 |
/* * multilevel preconditioned cg driver */ |
| 116 |
/* * */ |
| 117 |
/* * author: michael holst */ |
| 118 |
/* * ********************************************************************* */ |
| 119 |
/* * */ |
| 120 |
/* * *** input parameters *** */ |
| 121 |
/* * */ |
| 122 |
/* * *** variables returned from mgsz *** */ |
| 123 |
/* * */ |
| 124 |
/* * *** misc variables *** */ |
| 125 |
/* * */ |
| 126 |
/* * *** decode some parameters *** */ |
| 127 |
/* Parameter adjustments */ |
| 128 |
--tcf; |
| 129 |
--fcf; |
| 130 |
--ccf; |
| 131 |
--a3cf; |
| 132 |
--a2cf; |
| 133 |
--a1cf; |
| 134 |
--gzcf; |
| 135 |
--gycf; |
| 136 |
--gxcf; |
| 137 |
--zf; |
| 138 |
--yf; |
| 139 |
--xf; |
| 140 |
--u; |
| 141 |
--rwork; |
| 142 |
--iwork; |
| 143 |
--rparm; |
| 144 |
--iparm; |
| 145 |
|
| 146 |
/* Function Body */ |
| 147 |
nrwk = iparm[1]; |
| 148 |
niwk = iparm[2]; |
| 149 |
nx = iparm[3]; |
| 150 |
ny = iparm[4]; |
| 151 |
nz = iparm[5]; |
| 152 |
nlev = iparm[6]; |
| 153 |
/* * */ |
| 154 |
/* * *** some checks on input *** */ |
| 155 |
if (nlev <= 0 || nx <= 0 || ny <= 0 || nz <= 0) { |
| 156 |
s_wsle(&io___7); |
| 157 |
do_lio(&c__9, &c__1, "% CGMGDRIV: nx,ny,nz, and nlev must be positi" |
| 158 |
"ve...", (ftnlen)51); |
| 159 |
e_wsle(); |
| 160 |
ierror = -1; |
| 161 |
iparm[51] = ierror; |
| 162 |
return 0; |
| 163 |
} |
| 164 |
mxlv = maxlev_(&nx, &ny, &nz); |
| 165 |
if (nlev > mxlv) { |
| 166 |
s_wsle(&io___10); |
| 167 |
do_lio(&c__9, &c__1, "% CGMGDRIV: max levels for your grid size is: " |
| 168 |
, (ftnlen)47); |
| 169 |
do_lio(&c__3, &c__1, (char *)&mxlv, (ftnlen)sizeof(integer)); |
| 170 |
e_wsle(); |
| 171 |
ierror = -2; |
| 172 |
iparm[51] = ierror; |
| 173 |
return 0; |
| 174 |
} |
| 175 |
/* * */ |
| 176 |
/* * *** basic grid sizes, etc. *** */ |
| 177 |
mgcoar = iparm[18]; |
| 178 |
mgdisc = iparm[19]; |
| 179 |
mgsolv = iparm[21]; |
| 180 |
mgsz_(&mgcoar, &mgdisc, &mgsolv, &nx, &ny, &nz, &nlev, &nxc, &nyc, &nzc, & |
| 181 |
nf, &nc, &narr, &narrc, &n_rpc__, &n_iz__, &n_ipc__, &iretot, & |
| 182 |
iintot); |
| 183 |
/* * */ |
| 184 |
/* * *** allocate space for two additional work vectors *** */ |
| 185 |
iretot += nf << 1; |
| 186 |
/* * */ |
| 187 |
/* * *** some more checks on input *** */ |
| 188 |
if (nrwk < iretot || niwk < iintot) { |
| 189 |
s_wsle(&io___26); |
| 190 |
do_lio(&c__9, &c__1, "% CGMGDRIV: real work space must be: ", ( |
| 191 |
ftnlen)40); |
| 192 |
do_lio(&c__3, &c__1, (char *)&iretot, (ftnlen)sizeof(integer)); |
| 193 |
e_wsle(); |
| 194 |
s_wsle(&io___27); |
| 195 |
do_lio(&c__9, &c__1, "% CGMGDRIV: integer work space must be: ", ( |
| 196 |
ftnlen)40); |
| 197 |
do_lio(&c__3, &c__1, (char *)&iintot, (ftnlen)sizeof(integer)); |
| 198 |
e_wsle(); |
| 199 |
ierror = -3; |
| 200 |
iparm[51] = ierror; |
| 201 |
return 0; |
| 202 |
} |
| 203 |
/* * */ |
| 204 |
/* * *** split up the integer work array *** */ |
| 205 |
k_iz__ = 1; |
| 206 |
k_ipc__ = k_iz__ + n_iz__; |
| 207 |
/* * */ |
| 208 |
/* * *** split up the real work array *** */ |
| 209 |
k_rpc__ = 1; |
| 210 |
k_cc__ = k_rpc__ + n_rpc__; |
| 211 |
k_fc__ = k_cc__ + narr; |
| 212 |
k_w1__ = k_fc__ + narr; |
| 213 |
k_w2__ = k_w1__ + nf; |
| 214 |
k_pc__ = k_w2__ + nf; |
| 215 |
k_ac__ = k_pc__ + narrc * 27; |
| 216 |
/* * ***k_ac_after = 4*nf + 14*narrc */ |
| 217 |
/* * */ |
| 218 |
/* * *** call the multigrid driver *** */ |
| 219 |
cgmgdriv2_(&iparm[1], &rparm[1], &nx, &ny, &nz, &u[1], &iwork[k_iz__], & |
| 220 |
rwork[k_w1__], &rwork[k_w2__], &iwork[k_ipc__], &rwork[k_rpc__], & |
| 221 |
rwork[k_pc__], &rwork[k_ac__], &rwork[k_cc__], &rwork[k_fc__], & |
| 222 |
xf[1], &yf[1], &zf[1], &gxcf[1], &gycf[1], &gzcf[1], &a1cf[1], & |
| 223 |
a2cf[1], &a3cf[1], &ccf[1], &fcf[1], &tcf[1]); |
| 224 |
/* * */ |
| 225 |
/* * *** return and end *** */ |
| 226 |
return 0; |
| 227 |
} /* cgmgdriv_ */ |
| 228 |
|
| 229 |
/* Subroutine */ int cgmgdriv2_(integer *iparm, doublereal *rparm, integer * |
| 230 |
nx, integer *ny, integer *nz, doublereal *u, integer *iz, doublereal * |
| 231 |
w1, doublereal *w2, integer *ipc, doublereal *rpc, doublereal *pc, |
| 232 |
doublereal *ac, doublereal *cc, doublereal *fc, doublereal *xf, |
| 233 |
doublereal *yf, doublereal *zf, doublereal *gxcf, doublereal *gycf, |
| 234 |
doublereal *gzcf, doublereal *a1cf, doublereal *a2cf, doublereal * |
| 235 |
a3cf, doublereal *ccf, doublereal *fcf, doublereal *tcf) |
| 236 |
{ |
| 237 |
/* Format strings */ |
| 238 |
static char fmt_100[] = "(\002 ];\002,4(\002 \002,a7,\002=\002,1pe9.3" |
| 239 |
",\002;\002))"; |
| 240 |
|
| 241 |
/* System generated locals */ |
| 242 |
doublereal d__1; |
| 243 |
|
| 244 |
/* Builtin functions */ |
| 245 |
integer s_wsle(cilist *), do_lio(integer *, integer *, char *, ftnlen), |
| 246 |
e_wsle(void), s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), |
| 247 |
e_wsfe(void); |
| 248 |
|
| 249 |
/* Local variables */ |
| 250 |
extern /* Subroutine */ int buildalg_(integer *, integer *, integer *, |
| 251 |
integer *, integer *, integer *, integer *, doublereal *, |
| 252 |
doublereal *, doublereal *, doublereal *, doublereal *, |
| 253 |
doublereal *, doublereal *), buildops_(integer *, integer *, |
| 254 |
integer *, integer *, integer *, integer *, integer *, integer *, |
| 255 |
integer *, integer *, integer *, integer *, integer *, doublereal |
| 256 |
*, doublereal *, doublereal *, doublereal *, doublereal *, |
| 257 |
doublereal *, doublereal *, doublereal *, doublereal *, |
| 258 |
doublereal *, doublereal *, doublereal *, doublereal *, |
| 259 |
doublereal *, doublereal *, doublereal *, doublereal *), |
| 260 |
buildstr_(integer *, integer *, integer *, integer *, integer *); |
| 261 |
static integer nlev_real__; |
| 262 |
static doublereal bf, oh; |
| 263 |
static integer nu1, nu2, ido, iok; |
| 264 |
extern /* Subroutine */ int cgmg_(integer *, integer *, integer *, |
| 265 |
doublereal *, integer *, doublereal *, doublereal *, doublereal *, |
| 266 |
doublereal *, integer *, integer *, integer *, integer *, |
| 267 |
integer *, integer *, integer *, integer *, integer *, integer *, |
| 268 |
doublereal *, doublereal *, doublereal *, integer *, integer *, |
| 269 |
integer *, doublereal *, doublereal *, doublereal *, integer *, |
| 270 |
doublereal *, doublereal *, doublereal *, doublereal *, |
| 271 |
doublereal *, doublereal *); |
| 272 |
static integer mode, ilev, nlev; |
| 273 |
extern /* Subroutine */ int fcgmg_(integer *, integer *, integer *, |
| 274 |
doublereal *, integer *, doublereal *, doublereal *, doublereal *, |
| 275 |
doublereal *, integer *, integer *, integer *, integer *, |
| 276 |
integer *, integer *, integer *, integer *, integer *, integer *, |
| 277 |
doublereal *, doublereal *, doublereal *, integer *, integer *, |
| 278 |
integer *, doublereal *, doublereal *, doublereal *, integer *, |
| 279 |
doublereal *, doublereal *, doublereal *, doublereal *, |
| 280 |
doublereal *, doublereal *); |
| 281 |
static integer iinfo, mgkey, itmax, ipkey, iters, istop; |
| 282 |
extern /* Subroutine */ int tstop_(doublereal *, doublereal *, doublereal |
| 283 |
*); |
| 284 |
static doublereal omegal; |
| 285 |
static integer mgdisc; |
| 286 |
static doublereal omegan; |
| 287 |
static integer mgcoar; |
| 288 |
extern doublereal epsmac_(integer *); |
| 289 |
extern /* Subroutine */ int fbound_(integer *, integer *, integer *, |
| 290 |
integer *, doublereal *, doublereal *, doublereal *, doublereal *) |
| 291 |
; |
| 292 |
static integer ibound; |
| 293 |
static doublereal epsiln; |
| 294 |
static integer mgprol, mgsmoo, ierror, mgsolv; |
| 295 |
static doublereal errtol, tsolve; |
| 296 |
extern /* Subroutine */ int tstart_(doublereal *, doublereal *), prtstp_( |
| 297 |
integer *, integer *, doublereal *, doublereal *, doublereal *), |
| 298 |
fbound00_(integer *, integer *, integer *, doublereal *); |
| 299 |
static doublereal tsetupc, tsetupf; |
| 300 |
|
| 301 |
/* Fortran I/O blocks */ |
| 302 |
static cilist io___57 = { 0, 6, 0, 0, 0 }; |
| 303 |
static cilist io___59 = { 0, 6, 0, 0, 0 }; |
| 304 |
static cilist io___62 = { 0, 6, 0, 0, 0 }; |
| 305 |
static cilist io___68 = { 0, 6, 0, 0, 0 }; |
| 306 |
static cilist io___70 = { 0, 6, 0, 0, 0 }; |
| 307 |
static cilist io___71 = { 0, 6, 0, fmt_100, 0 }; |
| 308 |
|
| 309 |
|
| 310 |
/* * ********************************************************************* */ |
| 311 |
/* * purpose: */ |
| 312 |
/* * */ |
| 313 |
/* * this routine uses a conjugate gradient iteration combined with a */ |
| 314 |
/* * multigrid v-cycle preconditioner to solve the three-dimensional, */ |
| 315 |
/* * 2nd order elliptic partial differential equation: */ |
| 316 |
/* * */ |
| 317 |
/* * lu = f, u in omega */ |
| 318 |
/* * u = g, u on boundary of omega */ |
| 319 |
/* * where */ |
| 320 |
/* * */ |
| 321 |
/* * omega = [xmin,xmax]x[ymin,ymax]x[zmin,zmax] */ |
| 322 |
/* * */ |
| 323 |
/* * the code requires the operator in the form: */ |
| 324 |
/* * */ |
| 325 |
/* * - \nabla \cdot (a \nabla u) + c u = f */ |
| 326 |
/* * */ |
| 327 |
/* * with */ |
| 328 |
/* * */ |
| 329 |
/* * a(x,y,z),f(x,y,z), scalar functions (possibly discontinuous) */ |
| 330 |
/* * on omega. (discontinuities must be along fine grid lines). */ |
| 331 |
/* * boundary function g(x,y,z) is smooth on boundary of omega. */ |
| 332 |
/* * */ |
| 333 |
/* * the function c(x,y,z) and varies (possibly discontinuously) */ |
| 334 |
/* * with the spatial position. */ |
| 335 |
/* * */ |
| 336 |
/* * user inputs: */ |
| 337 |
/* * */ |
| 338 |
/* * the user must provide the coefficients of the differential */ |
| 339 |
/* * operator, some initial parameter settings in an integer and a */ |
| 340 |
/* * real parameter array, and various work arrays. */ |
| 341 |
/* * */ |
| 342 |
/* * author: michael holst */ |
| 343 |
/* * ********************************************************************* */ |
| 344 |
/* * */ |
| 345 |
/* * *** input parameters *** */ |
| 346 |
/* * */ |
| 347 |
/* * *** misc variables *** */ |
| 348 |
/* * */ |
| 349 |
/* * *** decode the iparm array *** */ |
| 350 |
/* Parameter adjustments */ |
| 351 |
--tcf; |
| 352 |
--fcf; |
| 353 |
--ccf; |
| 354 |
--a3cf; |
| 355 |
--a2cf; |
| 356 |
--a1cf; |
| 357 |
--gzcf; |
| 358 |
--gycf; |
| 359 |
--gxcf; |
| 360 |
--zf; |
| 361 |
--yf; |
| 362 |
--xf; |
| 363 |
--fc; |
| 364 |
--cc; |
| 365 |
--ac; |
| 366 |
--pc; |
| 367 |
--rpc; |
| 368 |
--ipc; |
| 369 |
--w2; |
| 370 |
--w1; |
| 371 |
--iz; |
| 372 |
--u; |
| 373 |
--rparm; |
| 374 |
--iparm; |
| 375 |
|
| 376 |
/* Function Body */ |
| 377 |
nlev = iparm[6]; |
| 378 |
nu1 = iparm[7]; |
| 379 |
nu2 = iparm[8]; |
| 380 |
mgkey = iparm[9]; |
| 381 |
itmax = iparm[10]; |
| 382 |
istop = iparm[11]; |
| 383 |
iinfo = iparm[12]; |
| 384 |
ipkey = iparm[14]; |
| 385 |
mgprol = iparm[17]; |
| 386 |
mgcoar = iparm[18]; |
| 387 |
mgdisc = iparm[19]; |
| 388 |
mgsmoo = iparm[20]; |
| 389 |
mgsolv = iparm[21]; |
| 390 |
errtol = rparm[1]; |
| 391 |
omegal = rparm[9]; |
| 392 |
omegan = rparm[10]; |
| 393 |
/* * */ |
| 394 |
/* * *** intitialize the iteration timer *** */ |
| 395 |
prtstp_(&c__0, &c_n99, &c_b23, &c_b23, &c_b23); |
| 396 |
/* * */ |
| 397 |
/* * *** build the multigrid data structure in iz *** */ |
| 398 |
buildstr_(nx, ny, nz, &nlev, &iz[1]); |
| 399 |
/* * */ |
| 400 |
/* * *** start timer *** */ |
| 401 |
tstart_(&bf, &oh); |
| 402 |
/* * */ |
| 403 |
/* * *** build op and rhs on fine grid *** */ |
| 404 |
ido = 0; |
| 405 |
buildops_(nx, ny, nz, &nlev, &ipkey, &iinfo, &ido, &iz[1], &mgprol, & |
| 406 |
mgcoar, &mgsolv, &mgdisc, &ipc[1], &rpc[1], &pc[1], &ac[1], &cc[1] |
| 407 |
, &fc[1], &xf[1], &yf[1], &zf[1], &gxcf[1], &gycf[1], &gzcf[1], & |
| 408 |
a1cf[1], &a2cf[1], &a3cf[1], &ccf[1], &fcf[1], &tcf[1]); |
| 409 |
/* * */ |
| 410 |
/* * *** stop timer *** */ |
| 411 |
tstop_(&bf, &oh, &tsetupf); |
| 412 |
s_wsle(&io___57); |
| 413 |
do_lio(&c__9, &c__1, "% CGMGDRIV2: fine problem setup time: ", (ftnlen)38) |
| 414 |
; |
| 415 |
do_lio(&c__5, &c__1, (char *)&tsetupf, (ftnlen)sizeof(doublereal)); |
| 416 |
e_wsle(); |
| 417 |
/* * */ |
| 418 |
/* * *** start timer *** */ |
| 419 |
tstart_(&bf, &oh); |
| 420 |
/* * */ |
| 421 |
/* * *** build op and rhs on all coarse grids *** */ |
| 422 |
ido = 1; |
| 423 |
buildops_(nx, ny, nz, &nlev, &ipkey, &iinfo, &ido, &iz[1], &mgprol, & |
| 424 |
mgcoar, &mgsolv, &mgdisc, &ipc[1], &rpc[1], &pc[1], &ac[1], &cc[1] |
| 425 |
, &fc[1], &xf[1], &yf[1], &zf[1], &gxcf[1], &gycf[1], &gzcf[1], & |
| 426 |
a1cf[1], &a2cf[1], &a3cf[1], &ccf[1], &fcf[1], &tcf[1]); |
| 427 |
/* * */ |
| 428 |
/* * *** stop timer *** */ |
| 429 |
tstop_(&bf, &oh, &tsetupc); |
| 430 |
s_wsle(&io___59); |
| 431 |
do_lio(&c__9, &c__1, "% CGMGDRIV2: coarse problem setup time: ", (ftnlen) |
| 432 |
40); |
| 433 |
do_lio(&c__5, &c__1, (char *)&tsetupc, (ftnlen)sizeof(doublereal)); |
| 434 |
e_wsle(); |
| 435 |
/* * */ |
| 436 |
/* * ****************************************************************** */ |
| 437 |
/* * *** this overwrites the rhs array provided by pde specification */ |
| 438 |
/* * ****** compute an algebraically produced rhs for the given tcf *** */ |
| 439 |
mode = 0; |
| 440 |
if (istop == 4 || istop == 5) { |
| 441 |
buildalg_(nx, ny, nz, &mode, &nlev, &iz[1], &ipc[1], &rpc[1], &ac[1], |
| 442 |
&cc[1], &ccf[1], &tcf[1], &fc[1], &fcf[1]); |
| 443 |
} |
| 444 |
/* * ****************************************************************** */ |
| 445 |
/* * */ |
| 446 |
/* * *** determine machine epsilon *** */ |
| 447 |
epsiln = epsmac_(&c__0); |
| 448 |
/* * */ |
| 449 |
/* * *** impose zero dirichlet boundary conditions (now in source fcn) *** */ |
| 450 |
fbound00_(nx, ny, nz, &u[1]); |
| 451 |
/* * */ |
| 452 |
/* * *** MATLAB *** */ |
| 453 |
s_wsle(&io___62); |
| 454 |
do_lio(&c__9, &c__1, " cgmg = [ ", (ftnlen)10); |
| 455 |
e_wsle(); |
| 456 |
/* * */ |
| 457 |
/* * *** start timer *** */ |
| 458 |
tstart_(&bf, &oh); |
| 459 |
/* * */ |
| 460 |
/* * *** call specified multigrid method *** */ |
| 461 |
nlev_real__ = nlev; |
| 462 |
iok = 1; |
| 463 |
ilev = 1; |
| 464 |
if (mgkey == 0) { |
| 465 |
cgmg_(nx, ny, nz, &u[1], &iz[1], &ccf[1], &fcf[1], &w1[1], &w2[1], & |
| 466 |
istop, &itmax, &iters, &ierror, &nlev, &ilev, &nlev_real__, & |
| 467 |
mgsolv, &iok, &iinfo, &epsiln, &errtol, &omegal, &nu1, &nu2, & |
| 468 |
mgsmoo, &a1cf[1], &a2cf[1], &a3cf[1], &ipc[1], &rpc[1], &pc[1] |
| 469 |
, &ac[1], &cc[1], &fc[1], &tcf[1]); |
| 470 |
} else if (mgkey == 1) { |
| 471 |
fcgmg_(nx, ny, nz, &u[1], &iz[1], &ccf[1], &fcf[1], &w1[1], &w2[1], & |
| 472 |
istop, &itmax, &iters, &ierror, &nlev, &ilev, &nlev_real__, & |
| 473 |
mgsolv, &iok, &iinfo, &epsiln, &errtol, &omegal, &nu1, &nu2, & |
| 474 |
mgsmoo, &a1cf[1], &a2cf[1], &a3cf[1], &ipc[1], &rpc[1], &pc[1] |
| 475 |
, &ac[1], &cc[1], &fc[1], &tcf[1]); |
| 476 |
} else { |
| 477 |
s_wsle(&io___68); |
| 478 |
do_lio(&c__9, &c__1, "% CGMGDRIV2: bad mgkey given ", (ftnlen)29); |
| 479 |
e_wsle(); |
| 480 |
} |
| 481 |
/* * */ |
| 482 |
/* * *** stop timer *** */ |
| 483 |
tstop_(&bf, &oh, &tsolve); |
| 484 |
s_wsle(&io___70); |
| 485 |
do_lio(&c__9, &c__1, "% CGMGDRIV2: solve time: ", (ftnlen)25); |
| 486 |
do_lio(&c__5, &c__1, (char *)&tsolve, (ftnlen)sizeof(doublereal)); |
| 487 |
e_wsle(); |
| 488 |
/* * */ |
| 489 |
/* * *** MATLAB *** */ |
| 490 |
s_wsfe(&io___71); |
| 491 |
do_fio(&c__1, "cgmg_sf", (ftnlen)7); |
| 492 |
do_fio(&c__1, (char *)&tsetupf, (ftnlen)sizeof(doublereal)); |
| 493 |
do_fio(&c__1, "cgmg_sc", (ftnlen)7); |
| 494 |
do_fio(&c__1, (char *)&tsetupc, (ftnlen)sizeof(doublereal)); |
| 495 |
do_fio(&c__1, "cgmg_st", (ftnlen)7); |
| 496 |
d__1 = tsetupf + tsetupc; |
| 497 |
do_fio(&c__1, (char *)&d__1, (ftnlen)sizeof(doublereal)); |
| 498 |
do_fio(&c__1, "cgmg_so", (ftnlen)7); |
| 499 |
do_fio(&c__1, (char *)&tsolve, (ftnlen)sizeof(doublereal)); |
| 500 |
e_wsfe(); |
| 501 |
/* * */ |
| 502 |
/* * *** restore boundary conditions *** */ |
| 503 |
ibound = 1; |
| 504 |
fbound_(&ibound, nx, ny, nz, &u[1], &gxcf[1], &gycf[1], &gzcf[1]); |
| 505 |
/* * */ |
| 506 |
/* * *** return and end *** */ |
| 507 |
return 0; |
| 508 |
} /* cgmgdriv2_ */ |
| 509 |
|