cloudy
trunk
|
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 /*ParseNorm parse parameters on the normalize command */ 00004 #include "cddefines.h" 00005 #include "lines.h" 00006 #include "input.h" 00007 #include "parse.h" 00008 #include "lines_service.h" 00009 00010 void ParseNorm(char *chCard) 00011 { 00012 bool lgEOL; 00013 long int i; 00014 char chLabel[INPUT_LINE_LENGTH]; 00015 00016 DEBUG_ENTRY( "ParseNorm()" ); 00017 00018 /* these are flags saying that normalization line has been set */ 00019 LineSave.lgNormSet = true; 00020 00021 /* >>chng 01 aug 23, insist on a line label */ 00022 /* 00023 * get possible label - must do first since it can contain a number.*/ 00024 /* is there a double quote on the line? if so then this is a line label */ 00025 if( strchr( chCard , '\"' ) != NULL ) 00026 { 00027 00028 /* GetQuote does the following - 00029 * first copy original version of name into chLabel, 00030 * string does include null termination. 00031 * set label in OrgCard and second parameter to spaces so 00032 * that not picked up below as keyword */ 00033 GetQuote( chLabel , chCard , true ); 00034 if( chLabel[4] !=0 ) 00035 { 00036 fprintf( ioQQQ, " The label identifying the line on the normalize command must be exactly 4 char long.\n" ); 00037 fprintf( ioQQQ, " The command line was as follows:\n %s\n", input.chCardSav[input.nRead] ); 00038 fprintf( ioQQQ, " The label I found was: \"%s\", where were not 4 characters between the quotes.\n", chLabel ); 00039 fprintf( ioQQQ, "Sorry.\n" ); 00040 cdEXIT(EXIT_FAILURE); 00041 } 00042 00043 /* copy first four char of label into caps, and null terminate*/ 00044 cap4( LineSave.chNormLab, chLabel); 00045 } 00046 else 00047 { 00048 fprintf( ioQQQ, "The normalize command does not have a valid line.\n" ); 00049 fprintf( ioQQQ, "A 4 char long line label must also be specified, between double quotes, like \"H 1\" 4861.\n" ); 00050 fprintf( ioQQQ, "Sorry.\n" ); 00051 cdEXIT(EXIT_FAILURE); 00052 } 00053 00054 /* normalise lines to this rather than h-b, sec number is scale factor */ 00055 i = 5; 00056 LineSave.WavLNorm = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 00057 if( lgEOL ) 00058 { 00059 NoNumb(chCard); 00060 } 00061 else if( LineSave.WavLNorm < 0 ) 00062 { 00063 fprintf( ioQQQ, "A negative wavelength does not make sense to me.\n" ); 00064 fprintf( ioQQQ, "Sorry.\n" ); 00065 cdEXIT(EXIT_FAILURE); 00066 } 00067 00068 /* now find out what the units of the wavelength were - options are 00069 * microns, cm, default is Angstroms */ 00070 if( input.chCARDCAPS[i-1] == 'M' ) 00071 { 00072 /* microns */ 00073 LineSave.WavLNorm *= 1e4f; 00074 } 00075 else if( input.chCARDCAPS[i-1] == 'C' ) 00076 { 00077 /* centimeters */ 00078 LineSave.WavLNorm *= 1e8f; 00079 } 00080 00081 /* get the error assocated with the 4 significant figures that are visible, 00082 * wavelength of 0 (a continuum) has error of zero */ 00083 LineSave.errorwave = WavlenErrorGet( LineSave.WavLNorm ); 00084 00085 LineSave.ScaleNormLine = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 00086 00087 if( lgEOL ) 00088 LineSave.ScaleNormLine = 1.; 00089 00090 /* confirm that scale factor is positive */ 00091 if( LineSave.ScaleNormLine <= 0. ) 00092 { 00093 fprintf( ioQQQ, " The scale factor for relative intensities must be greater than zero.\n" ); 00094 fprintf( ioQQQ, "Sorry.\n" ); 00095 cdEXIT(EXIT_FAILURE); 00096 } 00097 return; 00098 }