/*GetOptColDen read observed column densities & errors for optimizer */ #include #include "cddefines.h" #ifdef DEFERR # undef DEFERR #endif #define DEFERR 0.05 #include "varypar.h" #include "trace.h" #include "cap4.h" #include "ffmtread.h" #include "readar.h" #include "getoptcolden.h" #include "caps.h" void GetOptColDen(char *chCard ) { char chCap[81]; int lgEOF, lgEOL; long int i; # ifdef DEBUG_FUN fputs( "<+>GetOptColDen()\n", debug_fp ); # endif /* read observed column densities & errors */ VaryPar.ncobs = 0; /* get first line */ readar(chCard,&lgEOF); if( lgEOF ) { fprintf( ioQQQ, " Hit EOF while reading column density list; use END to end list.\n" ); puts( "[Stop in GetOptColDen]" ); exit(1); } /* now copy this line to chCap, then convert to caps */ strcpy( chCap, chCard ); caps(chCap); while( !lgEOF ) { if( VaryPar.ncobs > NCOLLM ) { fprintf( ioQQQ, " Too many column densities have been entered; the limit is%4ld. Increase variable NCOLLM.\n", NCOLLM ); puts( "[Stop in GetOptColDen]" ); exit(1); } /* order on line is label (col 1-4), ionization stage, column density, err */ /* copy cap'd version of first 4 char of chCard to chColmnLab */ cap4((char*)chVaryPar.chColmnLab[VaryPar.ncobs] , chCard ); /* the original translated code has a mess going into cap4, and the following */ /*f_subscpy( chCard, 0, 3, chCard_s - 1, _p0 );*/ i = 5; VaryPar.ionam[VaryPar.ncobs] = (long int)FFmtRead(chCard,&i,76,&lgEOL); if( lgEOL ) { fprintf( ioQQQ, " %80.80s\n", chCard ); fprintf( ioQQQ, " The ionization stage MUST appear on this line. Sorry.\n" ); puts( "[Stop in GetOptColDen]" ); exit(1); } else if( VaryPar.ionam[VaryPar.ncobs] <= 0 ) { fprintf( ioQQQ, " %80.80s\n", chCard ); fprintf( ioQQQ, " An ionization stage of%4ld does not make sense. Sorry.\n", VaryPar.ionam[VaryPar.ncobs] ); puts( "[Stop in GetOptColDen]" ); exit(1); } VaryPar.amcol[VaryPar.ncobs] = (float)pow(10.,FFmtRead(chCard,&i, 76,&lgEOL)); if( lgEOL ) { fprintf( ioQQQ, " %80.80s\n", chCard ); fprintf( ioQQQ, " An observed column density MUST be entered. Sorry.\n" ); puts( "[Stop in GetOptColDen]" ); exit(1); } VaryPar.amcerr[VaryPar.ncobs] = (float)FFmtRead(chCard,&i,76,&lgEOL); if( VaryPar.amcerr[VaryPar.ncobs] <= 0.0 ) { /* this is the relative error allowed */ VaryPar.amcerr[VaryPar.ncobs] = (float)DEFERR; } /* check if number is a limit - if '<' appears on the line then it is */ if( strchr( chCard , '<' ) != NULL ) { /* value is an upper limit only, use negative error to flag */ VaryPar.amcerr[VaryPar.ncobs] = -VaryPar.amcerr[VaryPar.ncobs]; } readar(chCard,&lgEOF); strcpy( chCap, chCard ); caps(chCap); if( lgEOF ) { fprintf( ioQQQ, " Hit EOF while reading column density list; use END to end list.\n" ); puts( "[Stop in GetOptColDen]" ); exit(1); } if( strncmp( chCap , "END" , 3) == 0 ) { lgEOF = TRUE; } /* now increment the number of columns we have entered */ VaryPar.ncobs += 1; } if( trace.lgTrace && VaryPar.lgTrOpt ) { fprintf( ioQQQ, "%4ld colunms were entered, they were;\n", VaryPar.ncobs ); for( i=0; i < VaryPar.ncobs; i++ ) { fprintf( ioQQQ, " %4.4s ion=%5ld%10.2e%10.2e\n", chVaryPar.chColmnLab[i], VaryPar.ionam[i], VaryPar.amcol[i], VaryPar.amcerr[i] ); } } # ifdef DEBUG_FUN fputs( " <->GetOptColDen()\n", debug_fp ); # endif return; }