cloudy  trunk
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vary_input.cpp
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2008 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 /*vary_input sets input lines to feed into cloudy in optimization runs */
4 #include "cddefines.h"
5 #include "input.h"
6 #include "optimize.h"
7 /* #include "grid.h" */
8 
9 void vary_input(bool *lgLimOK)
10 {
11  long int i,
12  np;
13 
14  DEBUG_ENTRY( "vary_input()" );
15 
16  /* set up chCardSav(n) array like Gary's input file, using input
17  * variable parameters p(i), and format information held in
18  * the common block /parmv/. Results written to common /kardsv/.
19  */
20 
21  fprintf( ioQQQ, " **************************************************\n" );
22 
23  /* will be set false if limit to a variable exceeded
24  * this is returned to calling code as problem indication*/
25  *lgLimOK = true;
26 
27  /* echo the variable input lines for this run */
28  for( i=0; i < optimize.nvary; i++ )
29  {
30  bool lgLimitHit = false;
31 
32  np = optimize.nvfpnt[i];
33 
34  /* write formatted to the character string chCardSav(np),
35  * using the format held in chVarFmt(np) */
36 
37  /* >>chng 05 aug 09, by RP, both were == change to > and < */
38  /* >>chng 05 oct 28, moved test, use vparm[0][i] instead of vpused[i], PvH */
39  if( optimize.vparm[0][i] < optimize.varang[i][0] ||
40  optimize.vparm[0][i] > optimize.varang[i][1] )
41  {
42  *lgLimOK = false;
43  lgLimitHit = true;
44  }
45 
48 
49  /* now generate the actual command with parameter,
50  * there will be from 1 to 3 numbers on the line */
51  if( optimize.nvarxt[i] == 1 )
52  {
53  /* case with 1 parameter */
54  sprintf( input.chCardSav[np] , optimize.chVarFmt[i], optimize.vparm[0][i] );
55  }
56 
57  else if( optimize.nvarxt[i] == 2 )
58  {
59  /* case with 2 parameters */
60  sprintf( input.chCardSav[np], optimize.chVarFmt[i], optimize.vparm[0][i],
61  optimize.vparm[1][i] );
62  }
63 
64  else if( optimize.nvarxt[i] == 3 )
65  {
66  /* case with 3 parameters */
67  sprintf( input.chCardSav[np], optimize.chVarFmt[i], optimize.vparm[0][i],
68  optimize.vparm[1][i], optimize.vparm[2][i] );
69  }
70 
71  else if( optimize.nvarxt[i] == 4 )
72  {
73  /* case with 4 parameters */
74  sprintf( input.chCardSav[np], optimize.chVarFmt[i], optimize.vparm[0][i],
75  optimize.vparm[1][i], optimize.vparm[2][i], optimize.vparm[3][i] );
76  }
77 
78  else if( optimize.nvarxt[i] == 5 )
79  {
80  /* case with 5 parameters */
81  sprintf( input.chCardSav[np] , optimize.chVarFmt[i],
82  optimize.vparm[0][i], optimize.vparm[1][i] , optimize.vparm[2][i] ,
83  optimize.vparm[3][i] , optimize.vparm[4][i]);
84  }
85 
86  else
87  {
88  fprintf(ioQQQ,"The number of variable options on this line makes no sense to me5\n");
89  cdEXIT(EXIT_FAILURE);
90  }
91 
92  fprintf( ioQQQ, " %s\n", input.chCardSav[np] );
93  if( lgLimitHit )
94  fprintf( ioQQQ, " >>> Limit to variable exceeded.\n" );
95  }
96 
97  return;
98 }

Generated for cloudy by doxygen 1.8.1.2