| 1 |
c* /////////////////////////////////////////////////////////////////////////// |
| 2 |
c* @file maind.f |
| 3 |
c* @author Michael Holst |
| 4 |
c* @brief Main FORTRAN driver for PMG. |
| 5 |
c* @version $Id: mainf.f,v 1.2 2010/08/12 05:53:01 fetk Exp $ |
| 6 |
c* @attention |
| 7 |
c* @verbatim |
| 8 |
c* |
| 9 |
c* PMG -- Parallel algebraic MultiGrid |
| 10 |
c* Copyright (C) 1994-- Michael Holst. |
| 11 |
c* |
| 12 |
c* Michael Holst <[email protected]> |
| 13 |
c* University of California, San Diego |
| 14 |
c* Department of Mathematics, 5739 AP&M |
| 15 |
c* 9500 Gilman Drive, Dept. 0112 |
| 16 |
c* La Jolla, CA 92093-0112 USA |
| 17 |
c* http://math.ucsd.edu/~mholst |
| 18 |
c* |
| 19 |
c* This file is part of PMG. |
| 20 |
c* |
| 21 |
c* PMG is free software; you can redistribute it and/or modify |
| 22 |
c* it under the terms of the GNU General Public License as published by |
| 23 |
c* the Free Software Foundation; either version 2 of the License, or |
| 24 |
c* (at your option) any later version. |
| 25 |
c* |
| 26 |
c* PMG is distributed in the hope that it will be useful, |
| 27 |
c* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 28 |
c* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 29 |
c* GNU General Public License for more details. |
| 30 |
c* |
| 31 |
c* You should have received a copy of the GNU General Public License |
| 32 |
c* along with PMG; if not, write to the Free Software |
| 33 |
c* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 34 |
c* |
| 35 |
c* Linking PMG statically or dynamically with other modules is making a |
| 36 |
c* combined work based on PMG. Thus, the terms and conditions of the GNU |
| 37 |
c* General Public License cover the whole combination. |
| 38 |
c* |
| 39 |
c* SPECIAL GPL EXCEPTION |
| 40 |
c* In addition, as a special exception, the copyright holders of PMG |
| 41 |
c* give you permission to combine the PMG program with free software |
| 42 |
c* programs and libraries that are released under the GNU LGPL or with |
| 43 |
c* code included in releases of ISIM, PMV, PyMOL, SMOL, VMD, and Vision. |
| 44 |
c* Such combined software may be linked with PMG and redistributed together |
| 45 |
c* in original or modified form as mere aggregation without requirement that |
| 46 |
c* the entire work be under the scope of the GNU General Public License. |
| 47 |
c* This special exception permission is also extended to any software listed |
| 48 |
c* in the SPECIAL GPL EXCEPTION clauses by the FEtk and APBS libraries. |
| 49 |
c* |
| 50 |
c* Note that people who make modified versions of PMG are not obligated |
| 51 |
c* to grant this special exception for their modified versions; it is |
| 52 |
c* their choice whether to do so. The GNU General Public License gives |
| 53 |
c* permission to release a modified version without this exception; this |
| 54 |
c* exception also makes it possible to release a modified version which |
| 55 |
c* carries forward this exception. |
| 56 |
c* |
| 57 |
c* @endverbatim |
| 58 |
c* /////////////////////////////////////////////////////////////////////////// |
| 59 |
|
| 60 |
c* /////////////////////////////////////////////////////////////////////////// |
| 61 |
c* Welcome to PMG (MG/XMG). |
| 62 |
c* /////////////////////////////////////////////////////////////////////////// |
| 63 |
c* |
| 64 |
c* ====================== |
| 65 |
c* The Author Information |
| 66 |
c* ====================== |
| 67 |
c* |
| 68 |
c* The computer codes PMG (MG/XMG, "the Code"), including FORTRAN/C/C++ |
| 69 |
c* language multilevel subroutines called "MG" and the C-language X-Window |
| 70 |
c* interface called "XMG", were developed by: |
| 71 |
c* |
| 72 |
c* Michael Holst TELE: (858) 534-4899 |
| 73 |
c* Department of Mathematics FAX: (858) 534-5273 |
| 74 |
c* UC San Diego, AP&M 5739 EMAIL: [email protected] |
| 75 |
c* La Jolla, CA 92093 USA WEB: http://www.scicomp.ucsd.edu/~mholst |
| 76 |
c* |
| 77 |
c* ==================================================== |
| 78 |
c* Licensing, permission to use, modify, and distribute |
| 79 |
c* ==================================================== |
| 80 |
c* |
| 81 |
c* The code has been placed under the GNU General Public License (GPL). |
| 82 |
c* |
| 83 |
c* This means that essentially you can use and modify the code as you like, |
| 84 |
c* under a few conditions, such as acknowledging the authors of the original |
| 85 |
c* code in any derived works, such as new programs or research results using |
| 86 |
c* the code. |
| 87 |
c* |
| 88 |
c* Please have a look at the GPL which should have accompanied the code. |
| 89 |
c* If it is missing, please write to the Free Software Foundation, Inc., |
| 90 |
c* 675 Mass Ave, Cambridge, MA 02139, USA. |
| 91 |
c* |
| 92 |
c* It would have been easier for me to just keep the code completely private, |
| 93 |
c* or to hand out very restricted use copies. However, in the interests of |
| 94 |
c* freedom of information, the advancement of science, the future of the |
| 95 |
c* planet, and so on, I decided to distribute the code in this very free way. |
| 96 |
c* The GNU world functions very much on the honor system. I want you to have |
| 97 |
c* all of my source code because I think it will do more toward helping you |
| 98 |
c* understand the ideas in there than anything else. The GNU idea is that in |
| 99 |
c* return for all of my work on the source code and the ideas behind it, all I |
| 100 |
c* ask for is some acknowledgment in your derived works for using my original |
| 101 |
c* code and the original ideas that went into the code. For GNU to be viable, |
| 102 |
c* we all need to abide by this very minimal requirement. |
| 103 |
c* |
| 104 |
c* I'm typing this on a nearly all-GNU system right now, namely Linux 1.2.8, |
| 105 |
c* a GNU version of UN*X available under the same conditions as PMG. |
| 106 |
c* I.e., you get all of the source code for the entire UN*X operating system. |
| 107 |
c* For more information about Linux, see: http://sunsite.unc.edu/mdw/linux.html |
| 108 |
c* |
| 109 |
c* ==================================================================== |
| 110 |
c* Pointers to Papers and other Reference Materials Related to the Code |
| 111 |
c* ==================================================================== |
| 112 |
c* |
| 113 |
c* The methods and techniques implemented in the Code were developed by |
| 114 |
c* Michael Holst as a part of his PhD research, and are described in detail in |
| 115 |
c* the PhD thesis: |
| 116 |
c* |
| 117 |
c* @phdthesis{Hols93a, |
| 118 |
c* author = "M. Holst", |
| 119 |
c* title = "Multilevel Methods for the {Poisson-Boltzmann} Equation", |
| 120 |
c* note = "Also published as Tech. Rep. UIUCDCS-R-03-1821", |
| 121 |
c* school = "Numerical Computing Group, |
| 122 |
c* Department of Computer Science, |
| 123 |
c* University of Illinois at Urbana-Champaign", |
| 124 |
c* year = 1993 } |
| 125 |
c* |
| 126 |
c* Also refer to the supporting papers: |
| 127 |
c* |
| 128 |
c* @manual{Hols94d, |
| 129 |
c* author = "M. Holst", |
| 130 |
c* title = "The {Poisson-Boltzmann} Equation: |
| 131 |
c* Analysis and Multilevel Numerical Solution", |
| 132 |
c* note = "Monograph (updated and extended form of the |
| 133 |
c* Ph.D. thesis~\cite{Hols93a})." } |
| 134 |
c* |
| 135 |
c* @article{SHHN94, |
| 136 |
c* author = "R. Sampogna and J. Hecht and M. Holst and A. Nicholls |
| 137 |
c* and B. Honig", |
| 138 |
c* title = "Nonlinear {Poisson-Boltzmann} Calculation of {pKa} |
| 139 |
c* Values", |
| 140 |
c* journal = "Biophysics", |
| 141 |
c* note = "(In Progress?)", |
| 142 |
c* year = 1994 } |
| 143 |
c* |
| 144 |
c* @article{HoVa94b, |
| 145 |
c* author = "M. Holst and S. Vandewalle", |
| 146 |
c* title = "Schwarz Methods: to Symmetrize or not to Symmetrize", |
| 147 |
c* journal = SINUM, |
| 148 |
c* note = "(Accepted)", |
| 149 |
c* year = 1994 } |
| 150 |
c* |
| 151 |
c* @article{Hols94e, |
| 152 |
c* author = "M. Holst and F. Saied", |
| 153 |
c* title = "Numerical Solution of the Nonlinear {Poisson-Boltzmann} |
| 154 |
c* Equation: Developing More Robust and Efficient Methods", |
| 155 |
c* journal = JCC, |
| 156 |
c* volume = "16", |
| 157 |
c* number = "3", |
| 158 |
c* pages = "337--364", |
| 159 |
c* year = 1995 } |
| 160 |
c* |
| 161 |
c* @article{HoSa93a, |
| 162 |
c* author = "M. Holst and F. Saied", |
| 163 |
c* title = "Multigrid Solution of the {Poisson-Boltzmann} Equation", |
| 164 |
c* journal = JCC, |
| 165 |
c* volume = "14", |
| 166 |
c* number = "1", |
| 167 |
c* pages = "105--113", |
| 168 |
c* year = 1993 } |
| 169 |
c* |
| 170 |
c* @article{HKSS94, |
| 171 |
c* author = "M. Holst and R. Kozack and F. Saied and S. Subramaniam", |
| 172 |
c* title = "Protein Electrostatics: Rapid Multigrid-based {Newton} |
| 173 |
c* Algorithm for Solution of the Full Nonlinear |
| 174 |
c* {Poisson-Boltzmann} Equation", |
| 175 |
c* journal = "J. Biomol. Struct. Dyn.", |
| 176 |
c* volume = "11", |
| 177 |
c* pages = "1437--1445", |
| 178 |
c* year = 1994 } |
| 179 |
c* |
| 180 |
c* @article{HKSS93b, |
| 181 |
c* author = "M. Holst and R. Kozack and F. Saied and S. Subramaniam", |
| 182 |
c* title = "Treatment of Electrostatic Effects in Proteins: |
| 183 |
c* Multigrid-based-{Newton} Iterative Method for Solution |
| 184 |
c* of the Full Nonlinear {Poisson-Boltzmann} Equation", |
| 185 |
c* journal = "Proteins: Structure, Function, and Genetics", |
| 186 |
c* volume = "18", |
| 187 |
c* number = "3", |
| 188 |
c* pages = "231--245", |
| 189 |
c* year = 1994 } |
| 190 |
c* |
| 191 |
c* @techreport{Hols94h, |
| 192 |
c* author = "M. Holst", |
| 193 |
c* title = "A Theoretical Analysis of the {Poisson-Boltzmann} |
| 194 |
c* Equation: A priori Estimates and Well-posedness", |
| 195 |
c* institution = "Applied Mathematics and CRPC, |
| 196 |
c* California Institute of Technology", |
| 197 |
c* year = 1994 } |
| 198 |
c* |
| 199 |
c* @inproceedings{HoVa95a, |
| 200 |
c* author = "M. Holst and S. Vandewalle", |
| 201 |
c* title = "Schwarz Methods: To Symmetrize or not to Symmetrize", |
| 202 |
c* booktitle = "Proceedings of the Seventh Copper Mountain Conference on |
| 203 |
c* Multigrid Methods, April 2-7, 1995, Copper Mountain, |
| 204 |
c* Colorado", |
| 205 |
c* editor = "J. Mandel and S. McCormick", |
| 206 |
c* publisher = "NASA Langley Research Center", |
| 207 |
c* year = "1995" } |
| 208 |
c* |
| 209 |
c* @inproceedings{HoSa93b, |
| 210 |
c* author = "M. Holst and F. Saied", |
| 211 |
c* title = "Multigrid and Domain Decomposition Methods for |
| 212 |
c* Electrostatics Problems", |
| 213 |
c* booktitle = "Domain Decomposition Methods in Science and Engineering |
| 214 |
c* (Proceedings of the Seventh International Conference on |
| 215 |
c* Domain Decomposition, October 27-30, 1993, |
| 216 |
c* The Pennsylvania State University)", |
| 217 |
c* editor = "D. E. Keyes and J. Xu", |
| 218 |
c* publisher = "American Mathematical Society, Providence", |
| 219 |
c* year = "1995" } |
| 220 |
c* |
| 221 |
c* @techreport{HoVa94a, |
| 222 |
c* author = "M. Holst and S. Vandewalle", |
| 223 |
c* title = "Schwarz Methods: to Symmetrize or not to Symmetrize", |
| 224 |
c* institution = "Applied Mathematics and CRPC, |
| 225 |
c* California Institute of Technology", |
| 226 |
c* number = "CRPC-94-13", |
| 227 |
c* year = 1994 } |
| 228 |
c* |
| 229 |
c* @techreport{Hols94c, |
| 230 |
c* author = "M. Holst", |
| 231 |
c* title = "{An} {Algebraic} {Schwarz} {Theory}", |
| 232 |
c* institution = "Applied Mathematics and CRPC, |
| 233 |
c* California Institute of Technology", |
| 234 |
c* number = "CRPC-94-12", |
| 235 |
c* year = 1994 } |
| 236 |
c* |
| 237 |
c* @techreport{Hols94f, |
| 238 |
c* author = "M. Holst", |
| 239 |
c* title = "A Robust and Efficient Numerical Method for Nonlinear |
| 240 |
c* Protein Modeling Equations", |
| 241 |
c* institution = "Applied Mathematics and CRPC, |
| 242 |
c* California Institute of Technology", |
| 243 |
c* number = "CRPC-94-9", |
| 244 |
c* year = 1994 } |
| 245 |
c* |
| 246 |
c* @techreport{HoSa93c, |
| 247 |
c* author = "M. Holst and F. Saied", |
| 248 |
c* title = "A Short Note Comparing Multigrid and Domain Decomposition |
| 249 |
c* for Protein Modeling Equations", |
| 250 |
c* institution = "Applied Mathematics and CRPC, |
| 251 |
c* California Institute of Technology", |
| 252 |
c* number = "CRPC-94-10", |
| 253 |
c* year = 1994 } |
| 254 |
c* |
| 255 |
c* ===================== |
| 256 |
c* PMG Bugs and Notes |
| 257 |
c* ===================== |
| 258 |
c* |
| 259 |
c* The timing routine, found in "secd.c", is machine dependent. We have |
| 260 |
c* implemented a number of routines for different machines, including a |
| 261 |
c* generic routine for a standard unix machine with the getrusage system |
| 262 |
c* routine. |
| 263 |
c* |
| 264 |
c* ============================= |
| 265 |
c* PMG Last Modification Date |
| 266 |
c* ============================= |
| 267 |
c* |
| 268 |
c* MG: 10-01-95 |
| 269 |
c* XMG: 10-01-95 |
| 270 |
c* |
| 271 |
c* /////////////////////////////////////////////////////////////////////////// |
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
program mgmain |
| 276 |
c*********************************************************************** |
| 277 |
c* pupose: |
| 278 |
c* ------- |
| 279 |
c* |
| 280 |
c* this program uses a numerical method to solve the following |
| 281 |
c* three-dimensional, 2nd order linear elliptic partial |
| 282 |
c* differential equation: |
| 283 |
c* |
| 284 |
c* lu = f, u in omega |
| 285 |
c* u = g, u on boundary of omega |
| 286 |
c* |
| 287 |
c* where |
| 288 |
c* |
| 289 |
c* omega = [xmin,xmax] x [ymin,ymax] x [zmin,zmax] |
| 290 |
c* |
| 291 |
c* the multigrid code requires the operator in the form: |
| 292 |
c* |
| 293 |
c* - \nabla \cdot (a \nabla u) + c u = f |
| 294 |
c* |
| 295 |
c* with; |
| 296 |
c* |
| 297 |
c* a=(a1(x,y,z),a2(x,y,z),a3(x,y,z)), c(x,y,z), f(x,y,z), |
| 298 |
c* all scalar functions (possibly discontinuous) on omega. |
| 299 |
c* (the discontinuities must be along grid lines on fine grid.) |
| 300 |
c* the boundary function g(x,y,z) is smooth on boundary of omega. |
| 301 |
c* |
| 302 |
c* user inputs: |
| 303 |
c* ------------ |
| 304 |
c* |
| 305 |
c* the user selects one of several possible methods: |
| 306 |
c* (1) multigrid |
| 307 |
c* (2) ... |
| 308 |
c* |
| 309 |
c* the calls to each of the routines are as follows: |
| 310 |
c* |
| 311 |
c* call mgdriv (iparm,rparm,iwork,rwork,u, |
| 312 |
c* . xf,yf,zf,gxcf,gycf,gzcf,a1cf,a2cf,a3cf,ccf,fcf,tcf) |
| 313 |
c* |
| 314 |
c* where the parameters are as follows: |
| 315 |
c* |
| 316 |
c* iparm = integer parameters for the solver |
| 317 |
c* rparm = real parameters for the solver |
| 318 |
c* iwork = some integer work space |
| 319 |
c* rwork = some real work space |
| 320 |
c* u = solution (perhaps some initial approximation) |
| 321 |
c* xf = the x-coordinates of the tensor-product mesh |
| 322 |
c* yf = the y-coordinates of the tensor-product mesh |
| 323 |
c* zf = the z-coordinates of the tensor-product mesh |
| 324 |
c* gxcf = the x=xmin and x=xmax boundary types and conditions |
| 325 |
c* gycf = the y=ymin and y=ymax boundary types and conditions |
| 326 |
c* gzcf = the z=zmin and z=zmax boundary types and conditions |
| 327 |
c* a1cf = entry (1,1) of the diagonal tensor "a" above |
| 328 |
c* a2cf = entry (2,2) of the diagonal tensor "a" above |
| 329 |
c* a3cf = entry (3,3) of the diagonal tensor "a" above |
| 330 |
c* ccf = the coefficient "c" above |
| 331 |
c* fcf = the sourse function "f" above |
| 332 |
c* tcf = the true solution of the pde if available (for testing) |
| 333 |
c* (must always be provided as may be used for storage) |
| 334 |
c* |
| 335 |
c* the sizes of the arrays must be as follows: |
| 336 |
c* |
| 337 |
c* nxm = number of x-points in the tensor-product mesh |
| 338 |
c* nym = number of y-points in the tensor-product mesh |
| 339 |
c* nzm = number of z-points in the tensor-product mesh |
| 340 |
c* nf = nxm * nym * nzm (total number of nodes) |
| 341 |
c* |
| 342 |
c* ifudge = 1000 |
| 343 |
c* nfarr = nf + nf/6 + ifudge |
| 344 |
c* niwk = calculated by multigrid code based on input parameters |
| 345 |
c* nrwk = calculated by multigrid code based on input parameters |
| 346 |
c* |
| 347 |
c* iparm = iparm(100) |
| 348 |
c* rparm = rparm(100) |
| 349 |
c* iwork = iwork(niwk) |
| 350 |
c* rwork = rwork(nrwk) |
| 351 |
c* a1cf = a1cf(nfarr) |
| 352 |
c* a2cf = a2cf(nfarr) |
| 353 |
c* a3cf = a3cf(nfarr) |
| 354 |
c* ccf = ccf(nfarr) |
| 355 |
c* fcf = fcf(nfarr) |
| 356 |
c* tcf = tcf(nfarr) |
| 357 |
c* u = u(nfarr) |
| 358 |
c* xf = xf(nxm*5) |
| 359 |
c* yf = yf(nym*5) |
| 360 |
c* zf = zf(nzm*5) |
| 361 |
c* gxcf = gxcf(nym*nzm*10) |
| 362 |
c* gycf = gycf(nxm*nzm*10) |
| 363 |
c* gzcf = gzcf(nxm*nym*10) |
| 364 |
c* |
| 365 |
c* note that all of the above arrays are written over by the multigrid |
| 366 |
c* code during processing; there is no extra storage here. |
| 367 |
c* |
| 368 |
c* the parameters that must be initialized in the iparm and rparm |
| 369 |
c* arrays in different ways for the three methods. for example, |
| 370 |
c* the multigrid code requires the following: |
| 371 |
c* |
| 372 |
c* *** integer parameters *** |
| 373 |
c* iparm(1) = nrwk |
| 374 |
c* iparm(2) = niwk |
| 375 |
c* iparm(3) = nx |
| 376 |
c* iparm(4) = ny |
| 377 |
c* iparm(5) = nz |
| 378 |
c* iparm(6) = nlev |
| 379 |
c* iparm(7) = nu1 |
| 380 |
c* iparm(8) = nu2 |
| 381 |
c* iparm(9) = mgkey |
| 382 |
c* iparm(10) = itmax |
| 383 |
c* iparm(11) = istop |
| 384 |
c* iparm(12) = iinfo |
| 385 |
c* iparm(13) = irite |
| 386 |
c* iparm(14) = ipkey |
| 387 |
c* iparm(15) = ipcon |
| 388 |
c* iparm(16) = nonlin |
| 389 |
c* iparm(17) = mgprol |
| 390 |
c* iparm(18) = mgcoar |
| 391 |
c* iparm(19) = mgdisc |
| 392 |
c* iparm(20) = mgsmoo |
| 393 |
c* iparm(21) = mgsolv |
| 394 |
c* iparm(22) = iperf |
| 395 |
c* |
| 396 |
c* *** real parameters *** |
| 397 |
c* rparm(1) = errtol |
| 398 |
c* rparm(3) = xmin |
| 399 |
c* rparm(4) = xmax |
| 400 |
c* rparm(5) = ymax |
| 401 |
c* rparm(6) = ymax |
| 402 |
c* rparm(7) = zmax |
| 403 |
c* rparm(8) = zmax |
| 404 |
c* rparm(9) = omegal |
| 405 |
c* rparm(10) = omegan |
| 406 |
c* |
| 407 |
c* the following are returned from the multigrid solver: |
| 408 |
c* |
| 409 |
c* u = the computed solution |
| 410 |
c* iparm(50) = iters (number of iters taken to reach tolerance) |
| 411 |
c* iparm(51) = ierror (=0 if tolerance reached, <>0 if problems) |
| 412 |
c* |
| 413 |
c* author: michael holst |
| 414 |
c*********************************************************************** |
| 415 |
implicit none |
| 416 |
c* |
| 417 |
c* *** the three main storage allocation parameters *** |
| 418 |
integer ngrid,nrwk,niwk |
| 419 |
c*********************************************************************** |
| 420 |
c* ***parameter (ngrid=5, nrwk=2465, niwk=2000) |
| 421 |
c* ***parameter (ngrid=9, nrwk=11885, niwk=2000) |
| 422 |
c* ***parameter (ngrid=17, nrwk=130149, niwk=2000) |
| 423 |
c* ***parameter (ngrid=25, nrwk=363620, niwk=2000) |
| 424 |
c* ***parameter (ngrid=33, nrwk=837892, niwk=2000) |
| 425 |
parameter (ngrid=49, nrwk=2827484, niwk=2000) |
| 426 |
c*********************************************************************** |
| 427 |
c* ***parameter (ngrid=65, nrwk=3025573, niwk=2000) |
| 428 |
c* ***parameter (ngrid=65, nrwk=3456041, niwk=2000) |
| 429 |
c* ***parameter (ngrid=65, nrwk=6202291, niwk=2000) |
| 430 |
c*********************************************************************** |
| 431 |
c* ***parameter (ngrid=97, nrwk=9960712, niwk=2000) |
| 432 |
c* ***parameter (ngrid=97, nrwk=11320640, niwk=2000) |
| 433 |
c* ***parameter (ngrid=97, nrwk=20447370, niwk=2000) |
| 434 |
c*********************************************************************** |
| 435 |
c* ***parameter (ngrid=129, nrwk=23315466, niwk=2000) |
| 436 |
c*********************************************************************** |
| 437 |
c* ***parameter (ngrid=193, nrwk=77735113, niwk=2000) |
| 438 |
c*********************************************************************** |
| 439 |
c* ***parameter (ngrid=257, nrwk=183123727, niwk=2000) |
| 440 |
c*********************************************************************** |
| 441 |
c* ***parameter (ngrid=65, nrwk=6202291, niwk=2000) |
| 442 |
c* ***parameter (ngrid=65, nrwk=4005291, niwk=2000) |
| 443 |
c* ***parameter (ngrid=97, nrwk=11320640, niwk=2000) |
| 444 |
c* |
| 445 |
c* *** other parameters *** |
| 446 |
integer nxm,nym,nzm,nf,nfarr,ifudge |
| 447 |
parameter (nxm=ngrid,nym=ngrid,nzm=ngrid) |
| 448 |
parameter (nf=nxm*nym*nzm,ifudge=100,nfarr=nf+nf/6+ifudge) |
| 449 |
c* |
| 450 |
c* *** main storage *** |
| 451 |
integer nx,ny,nz,key,meth,nlev,mgcoar,mgdisc,mgsolv |
| 452 |
integer nrwk_tot,niwk_tot |
| 453 |
integer iparm(100), iwork(niwk) |
| 454 |
double precision rparm(100), rwork(nrwk) |
| 455 |
double precision a1cf (nfarr) |
| 456 |
double precision a2cf (nfarr) |
| 457 |
double precision a3cf (nfarr) |
| 458 |
double precision ccf (nfarr) |
| 459 |
double precision fcf (nfarr) |
| 460 |
double precision tcf (nfarr) |
| 461 |
double precision u (nfarr) |
| 462 |
double precision xf (nxm,5) |
| 463 |
double precision yf (nym,5) |
| 464 |
double precision zf (nzm,5) |
| 465 |
double precision gxcf (nym,nzm,10) |
| 466 |
double precision gycf (nxm,nzm,10) |
| 467 |
double precision gzcf (nxm,nym,10) |
| 468 |
double precision bf,oh,cputme |
| 469 |
c* |
| 470 |
c* *** start timer *** |
| 471 |
call tstart(bf,oh) |
| 472 |
c* |
| 473 |
c* *** some i/o *** |
| 474 |
niwk_tot = 100 + niwk |
| 475 |
nrwk_tot = 100 + nrwk + 7*nfarr |
| 476 |
2 + nxm*5 + nym*5 + nzm*5 |
| 477 |
3 + nym*nzm*10 + nxm*nzm*10 + nxm*nym*10 |
| 478 |
print*,'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' |
| 479 |
print*,'% MGMAIN: TOTAL FP STORAGE DECLARED: ',nrwk_tot |
| 480 |
print*,'% MGMAIN: TOTAL INT STORAGE DECLARED: ',niwk_tot |
| 481 |
print*,'% MGMAIN: max number of unknowns: ',nf |
| 482 |
print*,'% MGMAIN: max vector length for all levels: ',nfarr |
| 483 |
print*,'% MGMAIN: DECLARED fp work array size: ',nrwk |
| 484 |
print*,'% MGMAIN: DECLARED int work array size: ',niwk |
| 485 |
print*,'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' |
| 486 |
c* |
| 487 |
c* *** read input options *** |
| 488 |
call readit (iparm,rparm,nx,ny,nz,nlev,nrwk,niwk,key,meth) |
| 489 |
c* |
| 490 |
c* *** print out the required sizes *** |
| 491 |
mgcoar = iparm(18) |
| 492 |
mgdisc = iparm(19) |
| 493 |
mgsolv = iparm(21) |
| 494 |
call mgsize(mgcoar,mgdisc,mgsolv,nx,ny,nz,nlev) |
| 495 |
if ((nx.gt.nxm).or.(ny.gt.nym).or.(nz.gt.nzm)) then |
| 496 |
print*,'% MGMAIN: (nx,ny,nz) too large...' |
| 497 |
goto 99 |
| 498 |
endif |
| 499 |
c* |
| 500 |
c* *** fill the coefficient arrays *** |
| 501 |
call fillco (iparm,rparm,nx,ny,nz, |
| 502 |
2 xf,yf,zf,gxcf,gycf,gzcf,a1cf,a2cf,a3cf,ccf,fcf,tcf) |
| 503 |
c* |
| 504 |
c* *** stop timer *** |
| 505 |
call tstop(bf,oh,cputme) |
| 506 |
print*,'% MGMAIN: time to read in problem description: ',cputme |
| 507 |
c* |
| 508 |
c* *** start timer *** |
| 509 |
call tstart(bf,oh) |
| 510 |
c* |
| 511 |
c* *** call linear solvers *** |
| 512 |
print*,'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' |
| 513 |
if (meth .eq. 0) then |
| 514 |
print*,'% MGMAIN: calling cgmg (linear) ... ' |
| 515 |
call cgmgdriv (iparm,rparm,iwork,rwork,u, |
| 516 |
2 xf,yf,zf,gxcf,gycf,gzcf,a1cf,a2cf,a3cf,ccf,fcf,tcf) |
| 517 |
elseif (meth .eq. 1) then |
| 518 |
print*,'% MGMAIN: calling newton (nonlinear) ... ' |
| 519 |
call newdriv (iparm,rparm,iwork,rwork,u, |
| 520 |
2 xf,yf,zf,gxcf,gycf,gzcf,a1cf,a2cf,a3cf,ccf,fcf,tcf) |
| 521 |
elseif (meth .eq. 2) then |
| 522 |
print*,'% MGMAIN: calling nmg (linear/nonlinear) ... ' |
| 523 |
call mgdriv (iparm,rparm,iwork,rwork,u, |
| 524 |
2 xf,yf,zf,gxcf,gycf,gzcf,a1cf,a2cf,a3cf,ccf,fcf,tcf) |
| 525 |
elseif (meth .eq. 3) then |
| 526 |
print*,'% MGMAIN: calling ncg (linear/nonlinear) ... ' |
| 527 |
call ncghsdriv (iparm,rparm,iwork,rwork,u, |
| 528 |
2 xf,yf,zf,gxcf,gycf,gzcf,a1cf,a2cf,a3cf,ccf,fcf,tcf) |
| 529 |
elseif (meth .eq. 4) then |
| 530 |
print*,'% MGMAIN: calling nsor (linear/nonlinear) ... ' |
| 531 |
call nsordriv (iparm,rparm,iwork,rwork,u, |
| 532 |
2 xf,yf,zf,gxcf,gycf,gzcf,a1cf,a2cf,a3cf,ccf,fcf,tcf) |
| 533 |
elseif (meth .eq. 5) then |
| 534 |
print*,'% MGMAIN: calling ngsrb (linear/nonlinear) ... ' |
| 535 |
call ngsrbdriv (iparm,rparm,iwork,rwork,u, |
| 536 |
2 xf,yf,zf,gxcf,gycf,gzcf,a1cf,a2cf,a3cf,ccf,fcf,tcf) |
| 537 |
elseif (meth .eq. 6) then |
| 538 |
print*,'% MGMAIN: calling nwjac (linear/nonlinear) ... ' |
| 539 |
call nwjacdriv (iparm,rparm,iwork,rwork,u, |
| 540 |
2 xf,yf,zf,gxcf,gycf,gzcf,a1cf,a2cf,a3cf,ccf,fcf,tcf) |
| 541 |
elseif (meth .eq. 7) then |
| 542 |
print*,'% MGMAIN: calling nrich (linear/nonlinear) ... ' |
| 543 |
call nrichdriv (iparm,rparm,iwork,rwork,u, |
| 544 |
2 xf,yf,zf,gxcf,gycf,gzcf,a1cf,a2cf,a3cf,ccf,fcf,tcf) |
| 545 |
else |
| 546 |
print*,'% MGMAIN: bad method key ... ' |
| 547 |
endif |
| 548 |
print*,'% MGMAIN: returned from iterative solver.' |
| 549 |
print*,'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' |
| 550 |
c* |
| 551 |
c* *** stop timer *** |
| 552 |
call tstop(bf,oh,cputme) |
| 553 |
print*,'% MGMAIN: total time spent in solve routine: ',cputme |
| 554 |
print*,'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' |
| 555 |
c* |
| 556 |
c* *** write soln *** |
| 557 |
call writit (iparm,rparm,nx,ny,nz,u, |
| 558 |
2 xf,yf,zf,gxcf,gycf,gzcf,a1cf,a2cf,a3cf,ccf,fcf,tcf,key) |
| 559 |
c* |
| 560 |
c* *** end it *** |
| 561 |
99 continue |
| 562 |
stop 'mgmain' |
| 563 |
end |
| 564 |
|