From b455a6211b57ef290469c16dbf24d079fdc06ea0 Mon Sep 17 00:00:00 2001 From: Tiago Pereira Date: Sat, 8 Jan 2011 00:22:22 +0000 Subject: [PATCH] atmos.h, backgropac_xdr.c, spectrum.h, xdr.h, background.c, brs_xdr.c, hydrogen.c, ltepops.c, planck.c, pops_xdr.c, writeatmos_xdr.c, writeopac_xdr.c: * Changing Nspace, backgrrecno to long. inputs.h, readinput.c: * Added new inputs for 1.5D version --- atmos.h | 6 +++--- backgropac_xdr.c | 4 ++-- background.c | 4 ++-- brs_xdr.c | 10 ++++++---- hydrogen.c | 13 +++++++------ inputs.h | 2 ++ ltepops.c | 3 ++- planck.c | 2 +- pops_xdr.c | 7 ++++--- readinput.c | 18 +++++++++++++++++- spectrum.h | 2 +- writeatmos_xdr.c | 2 +- writeopac_xdr.c | 3 ++- xdr.h | 2 +- 14 files changed, 51 insertions(+), 27 deletions(-) diff --git a/atmos.h b/atmos.h index 4bd9f5f..75a6ea6 100644 --- a/atmos.h +++ b/atmos.h @@ -43,9 +43,9 @@ typedef struct { typedef struct { char ID[ATMOS_ID_WIDTH]; bool_t moving, H_LTE, Stokes, hydrostatic; - int Ndim, *N, Nspace, Nrays, Nelem, Natom, Nmolecule, Nrlk, - *backgrrecno, Npf, NHydr, fd_background, NPRDactive, - Nactiveatom, Nactivemol; + int Ndim, *N, Nrays, Nelem, Natom, Nmolecule, Nrlk, Npf, + NHydr, fd_background, NPRDactive,Nactiveatom, Nactivemol; + long Nspace, *backgrrecno; double *T, *ne, *vturb, totalAbund, avgMolWght, wght_per_H, gravity, vmicro_char, vmacro_tresh, lambda_ref, *wmu, *Tpf, *nHtot, **nH, *nHmin, *B, *gamma_B, *chi_B, B_char, diff --git a/backgropac_xdr.c b/backgropac_xdr.c index 2d8d3fd..f25473c 100644 --- a/backgropac_xdr.c +++ b/backgropac_xdr.c @@ -30,7 +30,7 @@ enum opac_type {ABSORPTION, SCATTERING}; /* --- Function prototypes -- -------------- */ bool_t write_contrib_xdr(XDR *xdrs, char *label, enum opac_type type, - int Nspace, double *scatt); + long Nspace, double *scatt); /* --- Global variables -- -------------- */ @@ -197,7 +197,7 @@ void backgrOpac(int Nlambda, double *lambda) /* ------- begin -------------------------- write_contrib_xdr.c ----- */ bool_t write_contrib_xdr(XDR *xdrs, char *label, enum opac_type type, - int Nspace, double *scatt) + long Nspace, double *scatt) { bool_t result = TRUE; diff --git a/background.c b/background.c index 7b7443b..cca58b3 100644 --- a/background.c +++ b/background.c @@ -289,9 +289,9 @@ void Background(bool_t analyzeoutput, bool_t equilibria_only) if (atmos.moving || atmos.Stokes) { atmos.backgrrecno = - (int *) malloc(2*spectrum.Nspect*atmos.Nrays * sizeof(int)); + (long *) malloc(2*spectrum.Nspect*atmos.Nrays * sizeof(long)); } else - atmos.backgrrecno = (int *) malloc(spectrum.Nspect * sizeof(int)); + atmos.backgrrecno = (long *) malloc(spectrum.Nspect * sizeof(long)); /* --- Open output file for background opacity, emissivity, scattering -- -------------- */ diff --git a/brs_xdr.c b/brs_xdr.c index 14f08bd..a7c3ca3 100644 --- a/brs_xdr.c +++ b/brs_xdr.c @@ -96,7 +96,9 @@ bool_t xdr_BRS(XDR *xdrs) char *atmosID; bool_t result = TRUE, *hasline, *ispolarized; - int Nspace, Nsp, Nrecno; + int Nsp; + long Nspace, Nrecno; + hasline = (bool_t *) malloc(spectrum.Nspect * sizeof(bool_t)); @@ -111,7 +113,7 @@ bool_t xdr_BRS(XDR *xdrs) if (xdrs->x_op == XDR_ENCODE) { atmosID = atmos.ID; result &= xdr_counted_string(xdrs, &atmosID); - result &= xdr_int(xdrs, &atmos.Nspace); + result &= xdr_long(xdrs, &atmos.Nspace); result &= xdr_int(xdrs, &spectrum.Nspect); /* --- Flags for presence of background line -- -------------- */ @@ -129,7 +131,7 @@ bool_t xdr_BRS(XDR *xdrs) sizeof(bool_t), (xdrproc_t) xdr_bool); } else { atmos.backgrflags = (flags *) malloc(spectrum.Nspect * sizeof(flags)); - atmos.backgrrecno = (int *) malloc(Nrecno * sizeof(int)); + atmos.backgrrecno = (long *) malloc(Nrecno * sizeof(long)); result &= xdr_counted_string(xdrs, &atmosID); if (!strstr(atmosID, atmos.ID)) { @@ -140,7 +142,7 @@ bool_t xdr_BRS(XDR *xdrs) } free(atmosID); - result &= xdr_int(xdrs, &Nspace); + result &= xdr_long(xdrs, &Nspace); result &= xdr_int(xdrs, &Nsp); if (Nspace != atmos.Nspace || Nsp != spectrum.Nspect) { free(hasline); diff --git a/hydrogen.c b/hydrogen.c index b94447a..4ed93b7 100644 --- a/hydrogen.c +++ b/hydrogen.c @@ -68,7 +68,8 @@ void distribute_nH() register int k, i; char config[4], *ptr; - int *quantumNo, Nspace = atmos.Nspace, iq; + int *quantumNo, iq; + long Nspace = atmos.Nspace; double *g_total, g_i; /* --- Redistribute the hydrogen levels for use in the background @@ -222,7 +223,7 @@ void Hydrogen_ff(double lambda, double *chi) register int k; - int Nspace = atmos.Nspace; + long Nspace = atmos.Nspace; double hc_kla, C0, sigma, g_ff, stim, nu3, *np; C0 = SQ(Q_ELECTRON)/(4.0*PI*EPSILON_0) / sqrt(M_ELECTRON); @@ -305,7 +306,7 @@ bool_t Hminus_bf(double lambda, double *chi, double *eta) 3.38, 3.14, 2.85, 2.54, 2.20, 1.83, 1.46, 1.06, 0.71, 0.40, 0.17, 0.0}; bool_t hunt; - int Nspace = atmos.Nspace; + long Nspace = atmos.Nspace; double hc_kla, stimEmis, twohnu3_c2, alpha_bf; if ((lambda <= lambdaBF[0]) || (lambda >= lambdaBF[NBF-1])) @@ -435,7 +436,7 @@ bool_t Hminus_ff(double lambda, double *chi) 7.97e+01, 8.32e+01, 8.67e+01, 9.01e+01 }; - int Nspace = atmos.Nspace; + long Nspace = atmos.Nspace; double theta, pe, lambda_index, kappa; if (lambda == 0.0) { @@ -635,7 +636,7 @@ bool_t H2minus_ff(double lambda, double *chi) { 1.26e+02, 1.38e+02, 1.47e+02 }; - int Nspace = atmos.Nspace; + long Nspace = atmos.Nspace; double theta, pe, lambda_index, kappa, *nH2; if (lambda == 0.0) { @@ -756,7 +757,7 @@ bool_t H2plus_ff(double lambda, double *chi) 1.39, 1.18, 1.02, 0.90, 0.73, 0.60, 0.52, 0.46, 0.37, 0.31 }; - int Nspace = atmos.Nspace; + long Nspace = atmos.Nspace; double T, lambda_index, kappa, *np; if (lambda == 0.0) { diff --git a/inputs.h b/inputs.h index 4aab80f..849900e 100644 --- a/inputs.h +++ b/inputs.h @@ -78,6 +78,8 @@ typedef struct { int isum, Ngdelay, Ngorder, Ngperiod, NmaxIter, PRD_NmaxIter, PRD_Ngdelay, PRD_Ngorder, PRD_Ngperiod, NmaxScatter, Nthreads; + /* Tiago, added this for 1.5D version */ + int p15d_x0, p15d_x1, p15d_xst, p15d_y0, p15d_y1, p15d_yst; double iterLimit, PRDiterLimit, metallicity; pthread_attr_t thread_attr; diff --git a/ltepops.c b/ltepops.c index d7d5190..dd4659e 100644 --- a/ltepops.c +++ b/ltepops.c @@ -35,7 +35,8 @@ void LTEpops(Atom *atom, bool_t Debeye) register int k, i, m; char labelStr[MAX_LINE_SIZE]; - int Z, dZ, *nDebeye, Nspace = atmos.Nspace; + int Z, dZ, *nDebeye; + long Nspace = atmos.Nspace; double *cNe_T, *dE_kT, *dEion, dE, gi0, c1, *sum, c2; /* --- Computes LTE populations of a given atom. diff --git a/planck.c b/planck.c index 537fb38..3747c2c 100644 --- a/planck.c +++ b/planck.c @@ -32,7 +32,7 @@ /* ------- begin -------------------------- Planck.c ---------------- */ -void Planck(int Nspace, double *T, double lambda, double *Bnu) +void Planck(long Nspace, double *T, double lambda, double *Bnu) { register int k; diff --git a/pops_xdr.c b/pops_xdr.c index 36f6948..4174326 100644 --- a/pops_xdr.c +++ b/pops_xdr.c @@ -29,14 +29,15 @@ extern char messageStr[]; /* ------- begin -------------------------- xdr_populations.c ------- */ -bool_t xdr_populations(XDR *xdrs, char *atmosID, int Nlevel, int Nspace, +bool_t xdr_populations(XDR *xdrs, char *atmosID, int Nlevel, long Nspace, double *n, double *nstar) { const char routineName[] = "xdr_populations"; char *ID; bool_t result = TRUE; - int Npop = Nlevel * Nspace, Nl, Ns; + int Nl, Ns; + long Npop = Nlevel * Nspace; /* --- The actual reading/writing routine. Upon input the values for atmosID, Nlevel and Nspace in the file are checked against @@ -45,7 +46,7 @@ bool_t xdr_populations(XDR *xdrs, char *atmosID, int Nlevel, int Nspace, if (xdrs->x_op == XDR_ENCODE) { result &= xdr_counted_string(xdrs, &atmosID); result &= xdr_int(xdrs, &Nlevel); - result &= xdr_int(xdrs, &Nspace); + result &= xdr_long(xdrs, &Nspace); } else { result &= xdr_counted_string(xdrs, &ID); if (!strstr(ID, atmosID)) { diff --git a/readinput.c b/readinput.c index 8dd1808..fb2cb06 100644 --- a/readinput.c +++ b/readinput.c @@ -167,7 +167,23 @@ void readInput() {"LIMIT_MEMORY", "FALSE", FALSE, KEYWORD_DEFAULT, &input.limit_memory, setboolValue}, {"ALLOW_PASSIVE_BB", "TRUE", FALSE, KEYWORD_DEFAULT, - &input.allow_passive_bb, setboolValue} + &input.allow_passive_bb, setboolValue}, + + /* --- 1.5D version related inputs go here -- --------------- */ + {"X_START", "0", FALSE, KEYWORD_OPTIONAL, &input.p15d_x0, + setintValue}, + {"X_END", "-1", FALSE, KEYWORD_OPTIONAL, &input.p15d_x1, + setintValue}, + {"X_STEP", "1", FALSE, KEYWORD_OPTIONAL, &input.p15d_xst, + setintValue}, + + {"Y_START", "0", FALSE, KEYWORD_OPTIONAL, &input.p15d_y0, + setintValue}, + {"Y_END", "-1", FALSE, KEYWORD_OPTIONAL, &input.p15d_y1, + setintValue}, + {"Y_STEP", "1", FALSE, KEYWORD_OPTIONAL, &input.p15d_yst, + setintValue} + }; Nkeyword = sizeof(theKeywords) / sizeof(Keyword); diff --git a/spectrum.h b/spectrum.h index dcec5ef..6ffecf3 100644 --- a/spectrum.h +++ b/spectrum.h @@ -71,7 +71,7 @@ void alloc_as(int nspect, bool_t crosscoupling); void free_as(int nspect, bool_t crosscoupling); void initSpectrum(void); void Opacity(int nspect, int mu, bool_t top_to_bottom, bool_t activate); -void Planck(int Nspace, double *T, double lambda0, double *Bnu); +void Planck(long Nspace, double *T, double lambda0, double *Bnu); void readJlambda(int nspect, double *J); void writeJlambda(int nspect, double *J); diff --git a/writeatmos_xdr.c b/writeatmos_xdr.c index 2380777..0c92aa2 100644 --- a/writeatmos_xdr.c +++ b/writeatmos_xdr.c @@ -61,7 +61,7 @@ void writeAtmos(Atmosphere *atmos) register int n; bool_t result = TRUE; - int Nspace = atmos->Nspace; + long Nspace = atmos->Nspace; char *elemID, *atmosID; FILE *fp_out; XDR xdrs; diff --git a/writeopac_xdr.c b/writeopac_xdr.c index 10e7c69..2a4c241 100644 --- a/writeopac_xdr.c +++ b/writeopac_xdr.c @@ -54,7 +54,8 @@ void writeOpacity(void) bool_t to_obs, initialize, crosscoupling, boundbound, polarized, PRD_angle_dep, result = TRUE; - int Nspace = atmos.Nspace, record, *as_rn, Nrecord; + long Nspace = atmos.Nspace; + int record, *as_rn, Nrecord; FILE *fp_out; XDR xdrs; ActiveSet *as; diff --git a/xdr.h b/xdr.h index 661e6da..d7c722b 100644 --- a/xdr.h +++ b/xdr.h @@ -27,7 +27,7 @@ bool_t writeFlux(char *fileName); bool_t writeMetals(char *fileName); bool_t xdr_atom(XDR *xdrs, Atom *atom); bool_t xdr_counted_string(XDR *xdrs, char **p); -bool_t xdr_populations(XDR *xdrs, char *atmosID, int Nlevel, int Nspace, +bool_t xdr_populations(XDR *xdrs, char *atmosID, int Nlevel, long Nspace, double *n, double *nstar); bool_t xdr_BRS(XDR *xdrs);