/home66/gary/public_html/cloudy/c08_branch/source/vary_input.cpp

Go to the documentation of this file.
00001 /* This file is part of Cloudy and is copyright (C)1978-2008 by Gary J. Ferland and
00002  * others.  For conditions of distribution and use see copyright notice in license.txt */
00003 /*vary_input sets input lines to feed into cloudy in optimization runs */
00004 #include "cddefines.h"
00005 #include "input.h"
00006 #include "optimize.h"
00007 /* #include "grid.h" */
00008 
00009 void vary_input(bool *lgLimOK)
00010 {
00011         long int i, 
00012           np;
00013 
00014         DEBUG_ENTRY( "vary_input()" );
00015 
00016         /* set up chCardSav(n) array like Gary's input file, using input
00017          * variable parameters p(i), and format information held in
00018          * the common block /parmv/. Results written to common /kardsv/.
00019          */
00020 
00021         fprintf( ioQQQ, " **************************************************\n" );
00022 
00023         /* will be set false if limit to a variable exceeded
00024          * this is returned to calling code as problem indication*/
00025         *lgLimOK = true;
00026 
00027         /* echo the variable input lines for this run */
00028         for( i=0; i < optimize.nvary; i++ )
00029         {
00030                 bool lgLimitHit = false;
00031 
00032                 np = optimize.nvfpnt[i];
00033 
00034                 /* write formatted to the character string chCardSav(np),
00035                  * using the format held in chVarFmt(np) */
00036 
00037                 /* >>chng 05 aug 09, by RP, both were == change to > and < */
00038                 /* >>chng 05 oct 28, moved test, use vparm[0][i] instead of vpused[i], PvH */
00039                 if( optimize.vparm[0][i] < optimize.varang[i][0] ||
00040                     optimize.vparm[0][i] > optimize.varang[i][1] )
00041                 {
00042                         *lgLimOK = false;
00043                         lgLimitHit = true;
00044                 }
00045 
00046                 optimize.vpused[i] = (realnum)MIN2(optimize.vparm[0][i],optimize.varang[i][1]);
00047                 optimize.vpused[i] = (realnum)MAX2(optimize.vpused[i],optimize.varang[i][0]);
00048 
00049                 /* now generate the actual command with parameter,
00050                  * there will be from 1 to 3 numbers on the line */
00051                 if( optimize.nvarxt[i] == 1 )
00052                 {
00053                         /* case with 1 parameter */
00054                         sprintf( input.chCardSav[np] , optimize.chVarFmt[i], optimize.vparm[0][i] );
00055                 }
00056 
00057                 else if( optimize.nvarxt[i] == 2 )
00058                 {
00059                         /* case with 2 parameters */
00060                         sprintf( input.chCardSav[np], optimize.chVarFmt[i], optimize.vparm[0][i],
00061                                  optimize.vparm[1][i] );
00062                 }
00063 
00064                 else if( optimize.nvarxt[i] == 3 )
00065                 {
00066                         /* case with 3 parameters */
00067                         sprintf( input.chCardSav[np], optimize.chVarFmt[i], optimize.vparm[0][i],
00068                                  optimize.vparm[1][i], optimize.vparm[2][i] );
00069                 }
00070 
00071                 else if( optimize.nvarxt[i] == 4 )
00072                 {
00073                         /* case with 4 parameters */
00074                         sprintf( input.chCardSav[np], optimize.chVarFmt[i], optimize.vparm[0][i],
00075                                  optimize.vparm[1][i], optimize.vparm[2][i], optimize.vparm[3][i] );
00076                 }
00077 
00078                 else if( optimize.nvarxt[i] == 5 )
00079                 {
00080                         /* case with 5 parameters */
00081                         sprintf( input.chCardSav[np] , optimize.chVarFmt[i], 
00082                                 optimize.vparm[0][i], optimize.vparm[1][i] , optimize.vparm[2][i] , 
00083                                 optimize.vparm[3][i] , optimize.vparm[4][i]);
00084                 }
00085 
00086                 else
00087                 {
00088                         fprintf(ioQQQ,"The number of variable options on this line makes no sense to me5\n");
00089                         cdEXIT(EXIT_FAILURE);
00090                 }
00091 
00092                 fprintf( ioQQQ, " %s\n", input.chCardSav[np] );
00093                 if( lgLimitHit )
00094                         fprintf( ioQQQ, " >>> Limit to variable exceeded.\n" );
00095         }
00096 
00097         return;
00098 }

Generated on Mon Feb 16 12:01:28 2009 for cloudy by  doxygen 1.4.7