From 5f934debcd3cc60655e40096a5fa53bf4489f02d Mon Sep 17 00:00:00 2001 From: jhmatthews Date: Fri, 26 Sep 2014 15:35:07 +0100 Subject: [PATCH 01/10] First proposal for advanced mode, see #111 --- diag.c | 5 +- estimators.c | 2 +- extract.c | 2 +- foo.h | 1 + log.h | 2 + python.c | 132 ++++++++++++++++++++++++++++++++++++++++++++++----- python.h | 13 +++++ radiation.c | 2 +- rdpar.c | 33 +++++++++++++ templates.h | 1 + trans_phot.c | 4 +- 11 files changed, 177 insertions(+), 20 deletions(-) diff --git a/diag.c b/diag.c index dca4f5020..d2e53bcd1 100755 --- a/diag.c +++ b/diag.c @@ -4,6 +4,7 @@ Synopsis: open_diagfile sets up diagnostic files for use in python when the extra.diagnostics flag is + Arguments: PhotPtr p; the photon @@ -42,14 +43,14 @@ open_diagfile () FILE *cellfile; /*File that may or may not exist, pointing to cells we want to write out photon stats for */ int cell; /*Temporary storage of cell to use */ - if (eplinit == 0) + if (eplinit == 0 && save_extract_photons) { epltptr = fopen ("python.ext", "w"); eplinit = 1; } ncstat = 0; /*Zero the counter for the number of cells to be tracked */ - if (pstatinit == 0) /* Check we havent already done this */ + if (pstatinit == 0 && save_cell_stats) /* Check we havent already done this */ { cellfile = fopen ("diag_cells.dat", "r"); /*This is the file containing cells to track */ if (cellfile != NULL) /*If there actually *is* a file read it */ diff --git a/estimators.c b/estimators.c index 488c24f22..0bbd29618 100755 --- a/estimators.c +++ b/estimators.c @@ -86,7 +86,7 @@ bf_estimators_increment (one, p, ds) /* JM -- 1310 -- check if the user requires extra diagnostics and has provided a file diag_cells.dat to store photons stats for cells they have specified */ - if (diag_on_off == 1 && ncstat > 0) + if (save_cell_stats && ncstat > 0) { save_photon_stats(one, p, ds); // save photon statistics (extra diagnostics) } diff --git a/extract.c b/extract.c index eebb884aa..834d85448 100755 --- a/extract.c +++ b/extract.c @@ -156,7 +156,7 @@ one is odd. We do frequency here but weighting is carried out in extract */ } - if (diag_on_off && 1545.0 < 2.997925e18 / pp.freq + if (save_extract_photons && 1545.0 < 2.997925e18 / pp.freq && 2.997925e18 / pp.freq < 1565.0) { fprintf (epltptr, diff --git a/foo.h b/foo.h index b5b228431..2676e4ccd 100755 --- a/foo.h +++ b/foo.h @@ -25,6 +25,7 @@ int get_spectype(int yesno, char *question, int *spectype); int qdisk_init(void); int qdisk_save(char *diskfile, double ztot); int read_non_standard_disk_profile(char *tprofile); +int get_advanced_info(void); /* photon2d.c */ int translate(WindPtr w, PhotPtr pp, double tau_scat, double *tau, int *nres); int translate_in_space(PhotPtr pp); diff --git a/log.h b/log.h index ba58ea6ab..5172ce7d1 100644 --- a/log.h +++ b/log.h @@ -18,6 +18,8 @@ int rdline(char question[], char answer[]); int get_root(char root[], char total[]); int rdpar_set_mpi_rank(int rank); int rdpar_set_verbose(int vlevel); +int rd_advanced(char firstword[], double *answer, int *wordlength, int *noptions); +int test(int *point); /* log.c */ int Log_init(char *filename); int Log_append(char *filename); diff --git a/python.c b/python.c index 5a7acd788..5a79fc77f 100755 --- a/python.c +++ b/python.c @@ -1556,9 +1556,6 @@ if (geo.coord_type==RTHETA && geo.wind_type==2) //We need to generate an rtheta else Log ("OK, basic Monte Carlo spectrum\n"); -/* Determine whether to produce additonal diagnostics */ - - rdint ("Extra.diagnostics(0=no)", &diag_on_off); /* 57h -- New section of inputs to provide more control over how the program is @@ -1579,6 +1576,10 @@ run -- 07jul -- ksl rdint ("Keep.photoabs.during.final.spectrum(1=yes)", &keep_photoabs); } + + + + /* 081221 - 67c - Establish limits on the frequency intervals to be used by the ionization cycles and * the fraquency bands for stratified sampling. Changes here were made to allow more control * over statified sampling, since we have expanded the temperature ranges of the types of systems @@ -1604,6 +1605,17 @@ run -- 07jul -- ksl freqs_init (freqmin, freqmax); + /* Do we require advanced mode or not */ + rdint ("Use.advanced.mode(1=yes)", &iadvanced_mode); + + if (iadvanced_mode) + { + get_advanced_info(); + } + + + + /* Wrap up and save all the inputs */ @@ -1634,7 +1646,7 @@ run -- 07jul -- ksl w = wmain; - if (diag_on_off) + if (save_cell_stats) { /* Open a diagnostic file or files. These are all fixed files */ open_diagfile (); @@ -1750,9 +1762,9 @@ run -- 07jul -- ksl -#if DEBUG + if (ispymode) ispy_init ("python", geo.wcycle); -#endif + geo.n_ioniz = 0.0; geo.lum_ioniz = 0.0; @@ -1854,9 +1866,9 @@ run -- 07jul -- ksl if (geo.rt_mode == 2) Log("Luminosity taken up by adiabatic kpkt destruction %18.12e number of packets %d\n", zz_adiab, nn_adiab); -#if DEBUG + if (print_windrad_summary) wind_rad_summary (w, windradfile, "a"); -#endif + @@ -2017,9 +2029,9 @@ run -- 07jul -- ksl -#if DEBUG + if (ispymode) ispy_close (); -#endif + /* Calculate and store the amount of heating of the disk due to radiation impinging on the disk */ qdisk_save (diskfile, ztot); @@ -2036,7 +2048,7 @@ run -- 07jul -- ksl /* In a diagnostic mode save the wind file for each cycle (from thread 0) */ - if (diag_on_off) + if (keep_ioncycle_windsaves) { strcpy (dummy, ""); sprintf (dummy, "python%02d.wind_save", geo.wcycle); @@ -2218,9 +2230,9 @@ run -- 07jul -- ksl xsignal (root, "%-20s Starting %d of %d spectral cycle \n", "NOK", geo.pcycle, geo.pcycles); -#if DEBUG + if (ispymode) ispy_init ("python", geo.pcycle + 1000); -#endif + Log ("!!Cycle %d of %d to calculate a detailed spectrum\n", geo.pcycle, geo.pcycles); @@ -2878,3 +2890,97 @@ read_non_standard_disk_profile (tprofile) return (0); } + + + + + +int get_advanced_info() +{ + int wordlength; + char firstword[LINELENGTH]; + int noptions, rdstat; + double answer; + + + noptions = 0; + wordlength = 0; + rdstat = 0; + + Log("Advanced mode should only be used if you know what you're doing!\n"); + + while (noptions < NMAX_OPTIONS && rdstat == 0) + { + + rdstat = rd_advanced(firstword, &answer, &wordlength, &noptions); + + if (rdstat) + exit(0); + + Log("%s %8.4e\n", firstword, answer); + + /* would you like to save cell photon statistics */ + if (strncmp ("save_cell_statistics", firstword, wordlength) == 0) + { + save_cell_stats = answer; + Log("You are tracking photon statistics by cell\n"); + } + + /* would you like to use ispy mode */ + else if (strncmp ("ispymode", firstword, wordlength) == 0) + { + ispymode = answer; + Log("ISPY mode is on\n"); + } + + /* would you like to turn on use of reverberation mapping */ + else if (strncmp ("reverberation_mode", firstword, wordlength) == 0) + { + reverb_mode = answer; + Log("You are recording reverberation mapping data\n"); + } + + /* would you like to track resonant scatters */ + else if (strncmp ("track_resonant_scatters", firstword, wordlength) == 0) + { + track_resonant_scatters = answer; + Log("You are recording reverberation mapping data\n"); + } + + /* would you like keep windsave files for each cycle */ + else if (strncmp ("keep_ioncycle_windsaves", firstword, wordlength) == 0) + { + keep_ioncycle_windsaves = answer; + Log("You are recording reverberation mapping data\n"); + } + + /* would you like to save data on extract */ + else if (strncmp ("save_extract_photons", firstword, wordlength) == 0) + { + save_extract_photons = answer; + Log("You are saving data on extract\n"); + } + + /* would you like to print wind_rad_summary*/ + else if (strncmp ("print_windrad_summary", firstword, wordlength) == 0) + { + print_windrad_summary = answer; + Log("You are printing wind_rad_summary\n"); + } + + else + { + Error("Didn't understand question %s, continuing!\n", firstword); + } + } + + + return 0; +} + + + + + + + diff --git a/python.h b/python.h index 7a6f34810..ed24a953d 100755 --- a/python.h +++ b/python.h @@ -1110,3 +1110,16 @@ int ncell_stats[NCSTAT]; //the numbers of the cells we are going to log /* Added variables which count number of times two situations occur (See #91) */ int nerr_no_Jmodel; int nerr_Jmodel_wrong_freq; + + + +// advanced mode variables +int iadvanced_mode; +int reverb_mode; +int save_cell_stats; +int ispymode; +int keep_ioncycle_windsaves; +int track_resonant_scatters; +int save_extract_photons; +int print_windrad_summary; +#define NMAX_OPTIONS 20 diff --git a/radiation.c b/radiation.c index 4fbd6153e..44c16fd9c 100755 --- a/radiation.c +++ b/radiation.c @@ -417,7 +417,7 @@ radiation (p, ds) /* JM -- 1310 -- check if the user requires extra diagnostics and has provided a file diag_cells.dat to store photons stats for cells they have specified */ - if (diag_on_off == 1 && ncstat > 0) + if (save_cell_stats && ncstat > 0) { save_photon_stats (one, p, ds); // save photon statistics (extra diagnostics) } diff --git a/rdpar.c b/rdpar.c index ea1105bd9..4506db0de 100644 --- a/rdpar.c +++ b/rdpar.c @@ -722,6 +722,39 @@ int rdpar_set_verbose (vlevel) return(0); } +int rd_advanced(firstword, answer, wordlength, noptions) + char firstword[]; + double *answer; + int *wordlength; + int *noptions; +{ + int nwords; + char secondword[LINELEN]; + char line[LINELEN]; + char *ccc, *index (); + + if (fgets (line, LINELEN, rdin_ptr) == NULL) + { + if (noptions == 0) + Error("EOF: No advanced mode options read, but advanced mode on!\n"); + + return(1); + } + + noptions++; + + nwords = sscanf (line, "%s %s", firstword, secondword); + + if ((ccc = index (firstword, '(')) != NULL) + { + *wordlength = (int) (ccc - firstword); + } + + sscanf (secondword, "%le", answer); + + return (0); +} + diff --git a/templates.h b/templates.h index b5b228431..2676e4ccd 100755 --- a/templates.h +++ b/templates.h @@ -25,6 +25,7 @@ int get_spectype(int yesno, char *question, int *spectype); int qdisk_init(void); int qdisk_save(char *diskfile, double ztot); int read_non_standard_disk_profile(char *tprofile); +int get_advanced_info(void); /* photon2d.c */ int translate(WindPtr w, PhotPtr pp, double tau_scat, double *tau, int *nres); int translate_in_space(PhotPtr pp); diff --git a/trans_phot.c b/trans_phot.c index a97fafe50..97c293d8a 100755 --- a/trans_phot.c +++ b/trans_phot.c @@ -94,7 +94,7 @@ trans_phot (w, p, iextract) /* 05jul -- not clear whether this is needed and why it is different from DEBUG */ - if (diag_on_off && plinit == 0) + if (track_resonant_scatters && plinit == 0) { pltptr = fopen ("python.xyz", "w"); plinit = 1; @@ -471,7 +471,7 @@ the current version of scattering really does what the old code did for two-leve { pp.nrscat++; /* This next statement writes out the position of every resonant scattering event to a file */ - if (diag_on_off) + if (track_resonant_scatters) fprintf (pltptr, "Photon %i has resonant scatter at %.2e %.2e %.2e in wind cell %i (grid cell=%i). Freq=%e Weight=%e\n", nphot, pp.x[0], pp.x[1], pp.x[2], From 747d0d5ca297f7e262b0793ecb1b91d8256c5611 Mon Sep 17 00:00:00 2001 From: jhmatthews Date: Fri, 26 Sep 2014 15:37:59 +0100 Subject: [PATCH 02/10] Corrected some prints and removed exit 0 --- python.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python.c b/python.c index 5a79fc77f..1f45b397f 100755 --- a/python.c +++ b/python.c @@ -2915,7 +2915,7 @@ int get_advanced_info() rdstat = rd_advanced(firstword, &answer, &wordlength, &noptions); if (rdstat) - exit(0); + return(0); Log("%s %8.4e\n", firstword, answer); @@ -2944,14 +2944,14 @@ int get_advanced_info() else if (strncmp ("track_resonant_scatters", firstword, wordlength) == 0) { track_resonant_scatters = answer; - Log("You are recording reverberation mapping data\n"); + Log("You are tracking resonant scatters\n"); } /* would you like keep windsave files for each cycle */ else if (strncmp ("keep_ioncycle_windsaves", firstword, wordlength) == 0) { keep_ioncycle_windsaves = answer; - Log("You are recording reverberation mapping data\n"); + Log("You are keeping windsave files for each cycle\n"); } /* would you like to save data on extract */ From 6c789c7a5f96123bf01d7c849744ff05cf5c77a6 Mon Sep 17 00:00:00 2001 From: jhmatthews Date: Tue, 7 Oct 2014 16:08:57 +0100 Subject: [PATCH 03/10] Implemented a first attempt at an advanced mode accessed with -d flag --- source/corona.c | 8 +++- source/diag.c | 4 +- source/elvis.c | 9 ++++- source/estimators.c | 2 +- source/extract.c | 2 +- source/foo.h | 3 +- source/homologous.c | 9 ++++- source/knigge.c | 9 +++-- source/log.h | 1 - source/proga.c | 10 +++-- source/python.c | 93 ++++++++++++++++++++++++++++++------------- source/python.h | 27 ++++++++----- source/radiation.c | 2 +- source/rdpar.c | 2 +- source/shell_wind.c | 8 +++- source/stellar_wind.c | 10 ++++- source/sv.c | 36 ++++++++++------- source/templates.h | 3 +- source/trans_phot.c | 7 ++-- source/yso.c | 8 +++- 20 files changed, 172 insertions(+), 81 deletions(-) diff --git a/source/corona.c b/source/corona.c index bf056d03b..1367f633d 100755 --- a/source/corona.c +++ b/source/corona.c @@ -63,8 +63,12 @@ get_corona_params () geo.wind_thetamin = 0.0; geo.wind_thetamax = 0.0; - geo.xlog_scale = 0.3 * geo.corona_rmin; - geo.zlog_scale = 0.3 * geo.corona_scale_height; + /* if modes.adjust_grid is 1 then we have already adjusted the grid manually */ + if (modes.adjust_grid == 0) + { + geo.xlog_scale = 0.3 * geo.corona_rmin; + geo.zlog_scale = 0.3 * geo.corona_scale_height; + } /* Prior to 01dec, windcones were defined here. But this broke a capability to continue a calculation. To fix this, wind_cone definition was moved backed to python.c. To diff --git a/source/diag.c b/source/diag.c index d2e53bcd1..8f2c4a93c 100755 --- a/source/diag.c +++ b/source/diag.c @@ -43,14 +43,14 @@ open_diagfile () FILE *cellfile; /*File that may or may not exist, pointing to cells we want to write out photon stats for */ int cell; /*Temporary storage of cell to use */ - if (eplinit == 0 && save_extract_photons) + if (eplinit == 0 && modes.save_extract_photons) { epltptr = fopen ("python.ext", "w"); eplinit = 1; } ncstat = 0; /*Zero the counter for the number of cells to be tracked */ - if (pstatinit == 0 && save_cell_stats) /* Check we havent already done this */ + if (pstatinit == 0 && modes.save_cell_stats) /* Check we havent already done this */ { cellfile = fopen ("diag_cells.dat", "r"); /*This is the file containing cells to track */ if (cellfile != NULL) /*If there actually *is* a file read it */ diff --git a/source/elvis.c b/source/elvis.c index 3918fce8c..f398b4f2b 100755 --- a/source/elvis.c +++ b/source/elvis.c @@ -117,8 +117,13 @@ get_elvis_wind_params () geo.wind_thetamin = geo.sv_thetamin; geo.wind_thetamax = geo.sv_thetamax; //OLD geo.xlog_scale = geo.sv_rmin + (geo.elvis_offset * tan (geo.sv_thetamin)); - geo.xlog_scale = geo.sv_rmin; - geo.zlog_scale = 1e15; /* Big number - for AGN */ + + /* if modes.adjust_grid is 1 then we have already adjusted the grid manually */ + if (modes.adjust_grid == 0) + { + geo.xlog_scale = geo.sv_rmin; + geo.zlog_scale = 1e15; /* Big number - for AGN */ + } /*Now calculate the normalization factor for the wind*/ diff --git a/source/estimators.c b/source/estimators.c index 0bbd29618..6750cc25f 100755 --- a/source/estimators.c +++ b/source/estimators.c @@ -86,7 +86,7 @@ bf_estimators_increment (one, p, ds) /* JM -- 1310 -- check if the user requires extra diagnostics and has provided a file diag_cells.dat to store photons stats for cells they have specified */ - if (save_cell_stats && ncstat > 0) + if (modes.save_cell_stats && ncstat > 0) { save_photon_stats(one, p, ds); // save photon statistics (extra diagnostics) } diff --git a/source/extract.c b/source/extract.c index 834d85448..44003e50a 100755 --- a/source/extract.c +++ b/source/extract.c @@ -156,7 +156,7 @@ one is odd. We do frequency here but weighting is carried out in extract */ } - if (save_extract_photons && 1545.0 < 2.997925e18 / pp.freq + if (modes.save_extract_photons && 1545.0 < 2.997925e18 / pp.freq && 2.997925e18 / pp.freq < 1565.0) { fprintf (epltptr, diff --git a/source/foo.h b/source/foo.h index d0755488d..685665a47 100755 --- a/source/foo.h +++ b/source/foo.h @@ -25,7 +25,8 @@ int get_spectype(int yesno, char *question, int *spectype); int qdisk_init(void); int qdisk_save(char *diskfile, double ztot); int read_non_standard_disk_profile(char *tprofile); -int get_advanced_info(void); +int init_advanced_modes(void); +int get_extra_diagnostics(void); /* photon2d.c */ int translate(WindPtr w, PhotPtr pp, double tau_scat, double *tau, int *nres); int translate_in_space(PhotPtr pp); diff --git a/source/homologous.c b/source/homologous.c index 7116bb476..6e9689918 100755 --- a/source/homologous.c +++ b/source/homologous.c @@ -71,8 +71,13 @@ get_homologous_params () /* define the the variables that determine the gridding */ geo.wind_rho_min = 0; geo.wind_rho_max = geo.rmax; - geo.xlog_scale = 0.3 * geo.rstar; - geo.zlog_scale = 0.3 * geo.rstar; + + /* if modes.adjust_grid is 1 then we have already adjusted the grid manually */ + if (modes.adjust_grid == 0) + { + geo.xlog_scale = 0.3 * geo.rstar; + geo.zlog_scale = 0.3 * geo.rstar; + } return (0); } diff --git a/source/knigge.c b/source/knigge.c index 3114ebfbe..2ef135c78 100755 --- a/source/knigge.c +++ b/source/knigge.c @@ -146,9 +146,12 @@ in units of WD radii */ * edge of the wind */ - geo.xlog_scale = geo.rstar; - geo.zlog_scale = geo.rstar; - + /* if modes.adjust_grid is 1 then we have already adjusted the grid manually */ + if (modes.adjust_grid == 0) + { + geo.xlog_scale = geo.rstar; + geo.zlog_scale = geo.rstar; + } /*Now calculate the normalization factor for the wind*/ diff --git a/source/log.h b/source/log.h index 5172ce7d1..0a722c515 100644 --- a/source/log.h +++ b/source/log.h @@ -19,7 +19,6 @@ int get_root(char root[], char total[]); int rdpar_set_mpi_rank(int rank); int rdpar_set_verbose(int vlevel); int rd_advanced(char firstword[], double *answer, int *wordlength, int *noptions); -int test(int *point); /* log.c */ int Log_init(char *filename); int Log_append(char *filename); diff --git a/source/proga.c b/source/proga.c index 7e37e822e..d7313c2aa 100755 --- a/source/proga.c +++ b/source/proga.c @@ -158,9 +158,13 @@ Log ("geo.wind_rhomax=%e\n",geo.wind_rho_min); // geo.wind_thetamin=20.0/RADIAN; // geo.wind_thetamax=65./RADIAN; - geo.xlog_scale = 0.3 * geo.rstar; - geo.zlog_scale = 0.3 * geo.rstar; - + /* if modes.adjust_grid is 1 then we have already adjusted the grid manually */ + if (modes.adjust_grid == 0) + { + geo.xlog_scale = 0.3 * geo.rstar; + geo.zlog_scale = 0.3 * geo.rstar; + } + return (0); } diff --git a/source/python.c b/source/python.c index 1f45b397f..4b300d730 100755 --- a/source/python.c +++ b/source/python.c @@ -322,6 +322,10 @@ should allocate the space for the spectra to avoid all this nonsense. 02feb ksl restart_stat = 0; time_max = -1; + /* initialise options for advanced mode (all set to 0) */ + init_advanced_modes(); + + if (argc == 1) { printf ("Input file (interactive=stdin):"); @@ -379,7 +383,7 @@ should allocate the space for the spectra to avoid all this nonsense. 02feb ksl } else if (strcmp (argv[i], "-d") == 0) { - Log_debug(1); + modes.iadvanced = 1; i++; } else if (strncmp (argv[i], "-", 1) == 0) @@ -713,6 +717,20 @@ should allocate the space for the spectra to avoid all this nonsense. 02feb ksl } + /* If we are in advanced then allow the user to modify scale lengths */ + if (modes.iadvanced) + { + rdint ("adjust_grid(0=no,1=yes)", &modes.adjust_grid); + + if (modes.adjust_grid) + { + rddoub ("geo.xlog_scale", &geo.xlog_scale); + if (geo.coord_type) + rddoub ("geo.zlog_scale", &geo.zlog_scale); + } + } + + //080808 - 62 - Ionization section has been cleaned up -- ksl /* ??? ksl - Acoording to line 110 of ioniztion. option 4 is LTE with SIM_correction. It would be good to * know what this is actually. Note that pairwise is the appraoch which cboses between pairwise_bb, and pairwise_pow. @@ -1260,7 +1278,7 @@ Modified again in python 71b to take account of change in parametrisation of she /* Get the filling factor of the wind*/ geo.fill=1.; - rddoub("wind.filling_factor(1=smooth,<1=clumpted)",&geo.fill); + rddoub("wind.filling_factor(1=smooth,<1=clumped)",&geo.fill); } // End of block to define a model for the first time else @@ -1604,13 +1622,22 @@ run -- 07jul -- ksl */ freqs_init (freqmin, freqmax); + + if (modes.iadvanced) + { + /* do we want debug statements to print */ + rdint ("Use_Debug_Statements(0=no, 1=yes)", &modes.use_debug); - /* Do we require advanced mode or not */ - rdint ("Use.advanced.mode(1=yes)", &iadvanced_mode); + if (modes.use_debug) + Log_debug(modes.use_debug); // communicate that we want to print debug statements - if (iadvanced_mode) - { - get_advanced_info(); + /* Do we require extra diagnostics or not */ + rdint ("Extra.diagnostics(0=no, 1=yes) ", &modes.diag_on_off); + + if (modes.diag_on_off) + { + get_extra_diagnostics(); + } } @@ -1646,7 +1673,7 @@ run -- 07jul -- ksl w = wmain; - if (save_cell_stats) + if (modes.save_cell_stats) { /* Open a diagnostic file or files. These are all fixed files */ open_diagfile (); @@ -1762,7 +1789,7 @@ run -- 07jul -- ksl - if (ispymode) + if (modes.ispy) ispy_init ("python", geo.wcycle); @@ -1866,7 +1893,7 @@ run -- 07jul -- ksl if (geo.rt_mode == 2) Log("Luminosity taken up by adiabatic kpkt destruction %18.12e number of packets %d\n", zz_adiab, nn_adiab); - if (print_windrad_summary) + if (modes.print_windrad_summary) wind_rad_summary (w, windradfile, "a"); @@ -2029,7 +2056,7 @@ run -- 07jul -- ksl - if (ispymode) + if (modes.ispy) ispy_close (); @@ -2048,7 +2075,7 @@ run -- 07jul -- ksl /* In a diagnostic mode save the wind file for each cycle (from thread 0) */ - if (keep_ioncycle_windsaves) + if (modes.keep_ioncycle_windsaves) { strcpy (dummy, ""); sprintf (dummy, "python%02d.wind_save", geo.wcycle); @@ -2230,7 +2257,7 @@ run -- 07jul -- ksl xsignal (root, "%-20s Starting %d of %d spectral cycle \n", "NOK", geo.pcycle, geo.pcycles); - if (ispymode) + if (modes.ispy) ispy_init ("python", geo.pcycle + 1000); @@ -2529,7 +2556,8 @@ init_geo () geo.t_bl = 100000.; - strcpy (geo.atomic_filename, "data/standard73"); + + strcpy (geo.atomic_filename, "data/standard77"); strcpy (geo.fixed_con_file, "none"); // Note that geo.model_list is initialized through get_spectype @@ -2894,8 +2922,24 @@ read_non_standard_disk_profile (tprofile) +int init_advanced_modes() +{ + modes.iadvanced = 0; // this is controlled by the -d flag, global mode control. + modes.save_cell_stats = 0; // want to save photons statistics by cell + modes.ispy = 0; // want to use the ispy function + modes.keep_ioncycle_windsaves = 0; // want to save wind file each ionization cycle + modes.track_resonant_scatters = 0; // want to track resonant scatters + modes.save_extract_photons = 0; // we want to save details on extracted photons + modes.print_windrad_summary = 0; // we want to print the wind rad summary each cycle + modes.adjust_grid = 0; // the user wants to adjust the grid scale + modes.diag_on_off = 0; // extra diagnostics + + return (0); +} + -int get_advanced_info() + +int get_extra_diagnostics() { int wordlength; char firstword[LINELENGTH]; @@ -2922,49 +2966,42 @@ int get_advanced_info() /* would you like to save cell photon statistics */ if (strncmp ("save_cell_statistics", firstword, wordlength) == 0) { - save_cell_stats = answer; + modes.save_cell_stats = answer; Log("You are tracking photon statistics by cell\n"); } /* would you like to use ispy mode */ else if (strncmp ("ispymode", firstword, wordlength) == 0) { - ispymode = answer; + modes.ispy = answer; Log("ISPY mode is on\n"); } - /* would you like to turn on use of reverberation mapping */ - else if (strncmp ("reverberation_mode", firstword, wordlength) == 0) - { - reverb_mode = answer; - Log("You are recording reverberation mapping data\n"); - } - /* would you like to track resonant scatters */ else if (strncmp ("track_resonant_scatters", firstword, wordlength) == 0) { - track_resonant_scatters = answer; + modes.track_resonant_scatters = answer; Log("You are tracking resonant scatters\n"); } /* would you like keep windsave files for each cycle */ else if (strncmp ("keep_ioncycle_windsaves", firstword, wordlength) == 0) { - keep_ioncycle_windsaves = answer; + modes.keep_ioncycle_windsaves = answer; Log("You are keeping windsave files for each cycle\n"); } /* would you like to save data on extract */ else if (strncmp ("save_extract_photons", firstword, wordlength) == 0) { - save_extract_photons = answer; + modes.save_extract_photons = answer; Log("You are saving data on extract\n"); } /* would you like to print wind_rad_summary*/ else if (strncmp ("print_windrad_summary", firstword, wordlength) == 0) { - print_windrad_summary = answer; + modes.print_windrad_summary = answer; Log("You are printing wind_rad_summary\n"); } diff --git a/source/python.h b/source/python.h index 3e9299f90..c43af01f7 100755 --- a/source/python.h +++ b/source/python.h @@ -1123,12 +1123,21 @@ int nerr_Jmodel_wrong_freq; // advanced mode variables -int iadvanced_mode; -int reverb_mode; -int save_cell_stats; -int ispymode; -int keep_ioncycle_windsaves; -int track_resonant_scatters; -int save_extract_photons; -int print_windrad_summary; -#define NMAX_OPTIONS 20 +struct advanced_modes +{ + /* these are all 0=off, 1=yes */ + int iadvanced; // this is controlled by the -d flag, global mode control. + int save_cell_stats; // want to save photons statistics by cell + int ispy; // want to use the ispy function + int keep_ioncycle_windsaves; // want to save wind file each ionization cycle + int track_resonant_scatters; // want to track resonant scatters + int save_extract_photons; // we want to save details on extracted photons + int print_windrad_summary; // we want to print the wind rad summary each cycle + int adjust_grid; // the user wants to adjust the grid scale + int diag_on_off; // extra diagnostics + int use_debug; // print out debug statements +} +modes; + + +#define NMAX_OPTIONS 20 diff --git a/source/radiation.c b/source/radiation.c index 44c16fd9c..3d205d4f6 100755 --- a/source/radiation.c +++ b/source/radiation.c @@ -417,7 +417,7 @@ radiation (p, ds) /* JM -- 1310 -- check if the user requires extra diagnostics and has provided a file diag_cells.dat to store photons stats for cells they have specified */ - if (save_cell_stats && ncstat > 0) + if (modes.save_cell_stats && ncstat > 0) { save_photon_stats (one, p, ds); // save photon statistics (extra diagnostics) } diff --git a/source/rdpar.c b/source/rdpar.c index 4506db0de..9b0738648 100644 --- a/source/rdpar.c +++ b/source/rdpar.c @@ -395,7 +395,7 @@ string_process (question, dummy) if (fgets (line, LINELEN, rdin_ptr) == NULL) { printf ("Error: string_proces: Unexpectedly reached EOF\n"); - printf (" Switching to inteactive mode\n"); + printf (" Switching to interactive mode\n"); rdpar_stat = 1; goto b; } diff --git a/source/shell_wind.c b/source/shell_wind.c index 61f58d856..e5106e275 100755 --- a/source/shell_wind.c +++ b/source/shell_wind.c @@ -128,9 +128,13 @@ get_shell_wind_params () /* define the the variables that determine the gridding */ geo.wind_rho_min = 0; geo.wind_rho_max = geo.rmax; - geo.xlog_scale = 0.3 * geo.rstar; - geo.zlog_scale = 0.3 * geo.rstar; + /* if modes.adjust_grid is 1 then we have already adjusted the grid manually */ + if (modes.adjust_grid == 0) + { + geo.xlog_scale = 0.3 * geo.rstar; + geo.zlog_scale = 0.3 * geo.rstar; + } /* Since this is a diagnostic routine, we will write out some information to check it is doing what we think) */ Log ("shell rmin=%f shell rmax=%f\n", shell_rmin, shell_rmax); diff --git a/source/stellar_wind.c b/source/stellar_wind.c index 3250f4847..3eab20b54 100755 --- a/source/stellar_wind.c +++ b/source/stellar_wind.c @@ -99,9 +99,15 @@ get_stellar_wind_params () /* define the the variables that determine the gridding */ geo.wind_rho_min = 0; geo.wind_rho_max = geo.rmax; - geo.xlog_scale = 0.3 * geo.rstar; - geo.zlog_scale = 0.3 * geo.rstar; + + /* if modes.adjust_grid is 1 then we have already adjusted the grid manually */ + if (modes.adjust_grid == 0) + { + geo.xlog_scale = 0.3 * geo.rstar; + geo.zlog_scale = 0.3 * geo.rstar; + } + return (0); } diff --git a/source/sv.c b/source/sv.c index ed7726cd6..09e9bdd8a 100755 --- a/source/sv.c +++ b/source/sv.c @@ -93,25 +93,33 @@ get_sv_wind_params () geo.wind_rho_max = geo.sv_rmax; geo.wind_thetamin = geo.sv_thetamin; geo.wind_thetamax = geo.sv_thetamax; - geo.xlog_scale = geo.sv_rmin; - /* !! 70b - This change is to accomodate the torus, but it is not obvious this is the - * best way to set the scales now. It might be better do do this in make_grid!! */ - if (geo.compton_torus && geo.compton_torus_rmin < geo.xlog_scale) + + /* if modes.adjust_grid is 1 then we have already adjusted the grid manually */ + if (modes.adjust_grid == 0) { - geo.xlog_scale = geo.compton_torus_rmin; + geo.xlog_scale = geo.sv_rmin; + + /* !! 70b - This change is to accomodate the torus, but it is not obvious this is the + * best way to set the scales now. It might be better do do this in make_grid!! */ + if (geo.compton_torus && geo.compton_torus_rmin < geo.xlog_scale) + { + geo.xlog_scale = geo.compton_torus_rmin; + } + + /*70d - ksl - This change made to give one a chance of being able to do an + agn and a CV with the sv model. The underlying assumption is that the + effective radius provides a good scale factor in the verticla direction. + An alternative would be to use sv_rmin. + */ + + //OLD70d geo.zlog_scale = 1e7; + geo.zlog_scale = geo.rstar; } -/*70d - ksl - This change made to give one a chance of being able to do an - agn and a CV with the sv model. The underlying assumption is that the - effective radius provides a good scale factor in the verticla direction. - An alternative would be to use sv_rmin. - */ - -//OLD70d geo.zlog_scale = 1e7; - geo.zlog_scale = geo.rstar; + -/*Now calculate the normalization factor for the wind*/ + /*Now calculate the normalization factor for the wind*/ geo.mdot_norm = qromb (sv_wind_mdot_integral, geo.sv_rmin, geo.sv_rmax, 1e-6); diff --git a/source/templates.h b/source/templates.h index d0755488d..685665a47 100755 --- a/source/templates.h +++ b/source/templates.h @@ -25,7 +25,8 @@ int get_spectype(int yesno, char *question, int *spectype); int qdisk_init(void); int qdisk_save(char *diskfile, double ztot); int read_non_standard_disk_profile(char *tprofile); -int get_advanced_info(void); +int init_advanced_modes(void); +int get_extra_diagnostics(void); /* photon2d.c */ int translate(WindPtr w, PhotPtr pp, double tau_scat, double *tau, int *nres); int translate_in_space(PhotPtr pp); diff --git a/source/trans_phot.c b/source/trans_phot.c index 97c293d8a..77aff2fb9 100755 --- a/source/trans_phot.c +++ b/source/trans_phot.c @@ -94,7 +94,7 @@ trans_phot (w, p, iextract) /* 05jul -- not clear whether this is needed and why it is different from DEBUG */ - if (track_resonant_scatters && plinit == 0) + if (modes.track_resonant_scatters && plinit == 0) { pltptr = fopen ("python.xyz", "w"); plinit = 1; @@ -470,8 +470,9 @@ the current version of scattering really does what the old code did for two-leve if (nres > -1 && nres < nlines) { pp.nrscat++; -/* This next statement writes out the position of every resonant scattering event to a file */ - if (track_resonant_scatters) + + /* This next statement writes out the position of every resonant scattering event to a file */ + if (modes.track_resonant_scatters) fprintf (pltptr, "Photon %i has resonant scatter at %.2e %.2e %.2e in wind cell %i (grid cell=%i). Freq=%e Weight=%e\n", nphot, pp.x[0], pp.x[1], pp.x[2], diff --git a/source/yso.c b/source/yso.c index 74eadfe9c..087bcee57 100755 --- a/source/yso.c +++ b/source/yso.c @@ -104,8 +104,12 @@ in units of WD radii */ geo.diskrad - (zdisk (geo.diskrad) * tan (geo.wind_thetamax)); } - geo.xlog_scale = geo.rstar; - geo.zlog_scale = 1e7; + /* if modes.adjust_grid is 1 then we have already adjusted the grid manually */ + if (modes.adjust_grid == 0) + { + geo.xlog_scale = geo.rstar; + geo.zlog_scale = 1e7; + } return (0); } From d545ac895b45138715b87a7f7168d102945a4716 Mon Sep 17 00:00:00 2001 From: jhmatthews Date: Tue, 7 Oct 2014 17:00:15 +0100 Subject: [PATCH 04/10] added option to turn on and off dvds diagnostics --- source/gradv.c | 34 ++++++++++++++++------------------ source/python.c | 9 +++++++++ source/python.h | 5 +++++ 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/source/gradv.c b/source/gradv.c index 8dfd9db3c..6a99b4be2 100755 --- a/source/gradv.c +++ b/source/gradv.c @@ -169,18 +169,15 @@ dvds_ave () double dvds_max, lmn[3]; int n; int icell; -#if DEBUG - FILE *fopen (), *optr; //TEST - char filename[LINELENGTH]; -#endif double dvds_min, lmn_min[3]; //TEST + char filename[LINELENGTH]; - -#if DEBUG strcpy (filename, basename); strcat (filename, ".dvds.diag"); - optr = fopen (filename, "w"); //TEST -#endif + if (modes.print_dvds_info) + { + optr = fopen (filename, "w"); //TEST + } for (icell = 0; icell < NDIM2; icell++) { @@ -243,19 +240,20 @@ dvds_ave () wmain[icell].dvds_max = dvds_max / ds; stuff_v (lmn, wmain[icell].lmn); -#if DEBUG - fprintf (optr, - "%d %8.3e %8.3e %8.3e %8.3e %8.3e %8.3e %8.3e %8.3e %8.3e %8.3e %8.3e %8.3e \n", - icell, p.x[0], p.x[1], p.x[2], dvds_max / ds, - dvds_min / ds, lmn[0], lmn[1], lmn[2], lmn_min[0], - lmn_min[1], lmn_min[2], dot (lmn, lmn_min)); -#endif + if (modes.print_dvds_info) + { + fprintf (optr, + "%d %8.3e %8.3e %8.3e %8.3e %8.3e %8.3e %8.3e %8.3e %8.3e %8.3e %8.3e %8.3e \n", + icell, p.x[0], p.x[1], p.x[2], dvds_max / ds, + dvds_min / ds, lmn[0], lmn[1], lmn[2], lmn_min[0], + lmn_min[1], lmn_min[2], dot (lmn, lmn_min)); + } } -#if DEBUG - fclose (optr); -#endif + if (modes.print_dvds_info) + fclose (optr); + return (0); } diff --git a/source/python.c b/source/python.c index 4b300d730..26f043e91 100755 --- a/source/python.c +++ b/source/python.c @@ -2922,6 +2922,7 @@ read_non_standard_disk_profile (tprofile) + int init_advanced_modes() { modes.iadvanced = 0; // this is controlled by the -d flag, global mode control. @@ -2933,6 +2934,7 @@ int init_advanced_modes() modes.print_windrad_summary = 0; // we want to print the wind rad summary each cycle modes.adjust_grid = 0; // the user wants to adjust the grid scale modes.diag_on_off = 0; // extra diagnostics + modes.print_dvds_info = 0; return (0); } @@ -3005,6 +3007,13 @@ int get_extra_diagnostics() Log("You are printing wind_rad_summary\n"); } + /* would you like to print dvds_info */ + else if (strncmp ("print_dvds_info", firstword, wordlength) == 0) + { + modes.print_dvds_info = answer; + Log("You are printing dvds_info\n"); + } + else { Error("Didn't understand question %s, continuing!\n", firstword); diff --git a/source/python.h b/source/python.h index c43af01f7..8339dd149 100755 --- a/source/python.h +++ b/source/python.h @@ -1136,8 +1136,13 @@ struct advanced_modes int adjust_grid; // the user wants to adjust the grid scale int diag_on_off; // extra diagnostics int use_debug; // print out debug statements + int print_dvds_info; } modes; + +FILE *optr; //pointer to a diagnostic file that will contain dvds information + + #define NMAX_OPTIONS 20 From 8ed8f7ea9a96e69df61c784729c654e9556b542d Mon Sep 17 00:00:00 2001 From: jhmatthews Date: Wed, 15 Oct 2014 17:16:55 +0100 Subject: [PATCH 05/10] Commenting and moving around code --- source/diag.c | 181 ++++++++++++++++++++++++++++++++++++++++++++- source/foo.h | 4 +- source/log.h | 2 +- source/python.c | 118 ++++++----------------------- source/radiation.c | 53 ------------- source/rdpar.c | 20 ++++- source/templates.h | 4 +- 7 files changed, 225 insertions(+), 157 deletions(-) diff --git a/source/diag.c b/source/diag.c index 8f2c4a93c..452505a91 100755 --- a/source/diag.c +++ b/source/diag.c @@ -1,3 +1,7 @@ +/* diag.c contains a number of routines relating to extra diagnositics + and related file i/o. + JM 1410 -- moved a few routines here relating to extra diagnostics +*/ /*********************************************************** Southampton @@ -21,6 +25,7 @@ 12jun nsh 72 Added lines to set up a file for outputting photons in given cells. The cells are read in from a file called diag_cells.dat. The existance of this file defined wether the diagnostic takes place. 13jul jm changed print statements to logs and made more descriptive + 14oct jm changed to reflect move to 'advanced mode', see #111 and #120 **************************************************************/ @@ -30,6 +35,7 @@ #include #include #include +#include #include "atomic.h" #include "python.h" @@ -83,6 +89,179 @@ open_diagfile () pstatinit = 1; /* We have initialised this routine */ } -// diag_on_off = 0; // 0=off everything else is on + // diag_on_off = 0; // 0=off everything else is on + return (0); +} + + + + + + +/*********************************************************** + University of Southampton + +Synopsis: + get_extra_diagnostics reads in extra diagnostics if + the user has asked for them. It uses rd_extra() in rdpar.c + to get the actual lines, and then checks them against + hardwired options via a number of if loops. + +Arguments: + none + +Returns: + modifies the modes structure to turn on whichever modes + are asked for. + +Description: + +Notes: + see #111 and #120 + +History: + 1410 -- JM -- Coded +**************************************************************/ + +int get_extra_diagnostics() +{ + int wordlength; + char firstword[LINELENGTH]; + int noptions, rdstat; + double answer; + + + noptions = 0; + wordlength = 0; + rdstat = 0; + + if (modes.iadvanced == 0) + Error("Getting extra_diagnostics but advanced mode is off!\n"); + + Log("get_extra_diagnostics: Getting extra diagnostics as requested...\n"); + + while (noptions < NMAX_OPTIONS && rdstat == 0) + { + + rdstat = rd_extra(firstword, &answer, &wordlength, &noptions); + + + /* if rdstat is 1 we reached EOF, so exit this routine */ + if (rdstat) + return(0); + + Log("%s %8.4e\n", firstword, answer); + + /* would you like to save cell photon statistics */ + if (strncmp ("save_cell_statistics", firstword, wordlength) == 0) + { + modes.save_cell_stats = answer; + Log("You are tracking photon statistics by cell\n"); + } + + /* would you like to use ispy mode */ + else if (strncmp ("ispymode", firstword, wordlength) == 0) + { + modes.ispy = answer; + Log("ISPY mode is on\n"); + } + + /* would you like to track resonant scatters */ + else if (strncmp ("track_resonant_scatters", firstword, wordlength) == 0) + { + modes.track_resonant_scatters = answer; + Log("You are tracking resonant scatters\n"); + } + + /* would you like keep windsave files for each cycle */ + else if (strncmp ("keep_ioncycle_windsaves", firstword, wordlength) == 0) + { + modes.keep_ioncycle_windsaves = answer; + Log("You are keeping windsave files for each cycle\n"); + } + + /* would you like to save data on extract */ + else if (strncmp ("save_extract_photons", firstword, wordlength) == 0) + { + modes.save_extract_photons = answer; + Log("You are saving data on extract\n"); + } + + /* would you like to print wind_rad_summary*/ + else if (strncmp ("print_windrad_summary", firstword, wordlength) == 0) + { + modes.print_windrad_summary = answer; + Log("You are printing wind_rad_summary\n"); + } + + /* would you like to print dvds_info */ + else if (strncmp ("print_dvds_info", firstword, wordlength) == 0) + { + modes.print_dvds_info = answer; + Log("You are printing dvds_info\n"); + } + + else + { + Error("get_extra_diagnostics: didn't understand question %s, continuing!\n", firstword); + } + } + + return 0; +} + + + + +/*********************************************************** + Southampton University + +Synopsis: + save_photon_stats prints photon statistics to a file + +Arguments: + One WindPtr for the cell + p Photon pointer + ds ds travelled + +Returns: + +Description: + the loop below is if the user requires extra diagnostics and + has provided a file diag_cells.dat to store photons stats for cells they have specified + +Notes: + Moved here to save duplicating code between bf_estimators_increment and radiation. + +History: + 1410 JM Coding began + 1410 JM Moved here from python.c + +**************************************************************/ + + + +int +save_photon_stats (one, p, ds) + WindPtr one; + PhotPtr p; + double ds; +{ + int i; + + /* JM -- 1310 -- the loop below is if the user requires extra diagnostics and + has provided a file diag_cells.dat to store photons stats for cells they have specified + */ + + for (i = 0; i < ncstat; i++) + { + /* check if the cell is in the specified list - ncell_stats is global variable */ + if (one->nplasma == ncell_stats[i]) + { + fprintf (pstatptr, + "PHOTON_DETAILS %3d %8.3e %8.3e %8.3e cell%3d wind cell%3d\n", + geo.wcycle, p->freq, p->w, ds, one->nplasma, one->nwind); + } + } return (0); } diff --git a/source/foo.h b/source/foo.h index 685665a47..d3eb78705 100755 --- a/source/foo.h +++ b/source/foo.h @@ -26,7 +26,6 @@ int qdisk_init(void); int qdisk_save(char *diskfile, double ztot); int read_non_standard_disk_profile(char *tprofile); int init_advanced_modes(void); -int get_extra_diagnostics(void); /* photon2d.c */ int translate(WindPtr w, PhotPtr pp, double tau_scat, double *tau, int *nres); int translate_in_space(PhotPtr pp); @@ -133,7 +132,6 @@ double sigma_phot_verner(struct innershell *x_ptr, double freq); double den_config(PlasmaPtr xplasma, int nconf); double pop_kappa_ff_array(void); int update_banded_estimators(PlasmaPtr xplasma, PhotPtr p, double ds, double w_ave); -int save_photon_stats(WindPtr one, PhotPtr p, double ds); double mean_intensity(PlasmaPtr xplasma, double freq, int mode); /* wind_updates2d.c */ int wind_update(WindPtr (w)); @@ -257,6 +255,8 @@ double badnell_gs_rr(int nion, double T); double milne_gs_rr(int nion, double T); /* diag.c */ int open_diagfile(void); +int get_extra_diagnostics(void); +int save_photon_stats(WindPtr one, PhotPtr p, double ds); /* sv.c */ int get_sv_wind_params(void); double sv_velocity(double x[], double v[]); diff --git a/source/log.h b/source/log.h index 0a722c515..2ca6706b7 100644 --- a/source/log.h +++ b/source/log.h @@ -18,7 +18,7 @@ int rdline(char question[], char answer[]); int get_root(char root[], char total[]); int rdpar_set_mpi_rank(int rank); int rdpar_set_verbose(int vlevel); -int rd_advanced(char firstword[], double *answer, int *wordlength, int *noptions); +int rd_extra(char firstword[], double *answer, int *wordlength, int *noptions); /* log.c */ int Log_init(char *filename); int Log_append(char *filename); diff --git a/source/python.c b/source/python.c index c4d5fb773..ab36e68ef 100755 --- a/source/python.c +++ b/source/python.c @@ -28,7 +28,8 @@ v to 5 causes the routine to print out all the information which outputs have included previously. The current default is set to 4 which suppresses Log_silent and Error_silent - -d To have statements from Debug command logged + -d Enters debug or advanced mode. Allows one to have statements from Debug command + logged, access extra diagnostics and -e Alter the maximum number of errors before the program quits @@ -2919,7 +2920,28 @@ read_non_standard_disk_profile (tprofile) } +/*********************************************************** + University of Southampton + +Synopsis: + init_advanced_modes simply initialises the set of + advanced modes stored in the modes structure to a + default value. For now, this is 0 (off). +Arguments: + none + +Returns: + just initialises modes which is declared in python.h + +Description: + +Notes: + see #111 and #120 + +History: + 1410 -- JM -- Coded +**************************************************************/ int init_advanced_modes() @@ -2936,96 +2958,4 @@ int init_advanced_modes() modes.print_dvds_info = 0; return (0); -} - - - -int get_extra_diagnostics() -{ - int wordlength; - char firstword[LINELENGTH]; - int noptions, rdstat; - double answer; - - - noptions = 0; - wordlength = 0; - rdstat = 0; - - Log("Advanced mode should only be used if you know what you're doing!\n"); - - while (noptions < NMAX_OPTIONS && rdstat == 0) - { - - rdstat = rd_advanced(firstword, &answer, &wordlength, &noptions); - - if (rdstat) - return(0); - - Log("%s %8.4e\n", firstword, answer); - - /* would you like to save cell photon statistics */ - if (strncmp ("save_cell_statistics", firstword, wordlength) == 0) - { - modes.save_cell_stats = answer; - Log("You are tracking photon statistics by cell\n"); - } - - /* would you like to use ispy mode */ - else if (strncmp ("ispymode", firstword, wordlength) == 0) - { - modes.ispy = answer; - Log("ISPY mode is on\n"); - } - - /* would you like to track resonant scatters */ - else if (strncmp ("track_resonant_scatters", firstword, wordlength) == 0) - { - modes.track_resonant_scatters = answer; - Log("You are tracking resonant scatters\n"); - } - - /* would you like keep windsave files for each cycle */ - else if (strncmp ("keep_ioncycle_windsaves", firstword, wordlength) == 0) - { - modes.keep_ioncycle_windsaves = answer; - Log("You are keeping windsave files for each cycle\n"); - } - - /* would you like to save data on extract */ - else if (strncmp ("save_extract_photons", firstword, wordlength) == 0) - { - modes.save_extract_photons = answer; - Log("You are saving data on extract\n"); - } - - /* would you like to print wind_rad_summary*/ - else if (strncmp ("print_windrad_summary", firstword, wordlength) == 0) - { - modes.print_windrad_summary = answer; - Log("You are printing wind_rad_summary\n"); - } - - /* would you like to print dvds_info */ - else if (strncmp ("print_dvds_info", firstword, wordlength) == 0) - { - modes.print_dvds_info = answer; - Log("You are printing dvds_info\n"); - } - - else - { - Error("Didn't understand question %s, continuing!\n", firstword); - } - } - - - return 0; -} - - - - - - - +} \ No newline at end of file diff --git a/source/radiation.c b/source/radiation.c index 3d205d4f6..114284481 100755 --- a/source/radiation.c +++ b/source/radiation.c @@ -1023,60 +1023,7 @@ update_banded_estimators (xplasma, p, ds, w_ave) return (0); } - - - - -/*********************************************************** - Southampton University - -Synopsis: - save_photon_stats prints photon statistics to a file - -Arguments: - One WindPtr for the cell - p Photon pointer - ds ds travelled - -Returns: -Description: - the loop below is if the user requires extra diagnostics and - has provided a file diag_cells.dat to store photons stats for cells they have specified - -Notes: - Moved here to save duplicating code between bf_estimators_increment and radiation. - -History: - 1402 JM Coding began - -**************************************************************/ - - -int -save_photon_stats (one, p, ds) - WindPtr one; - PhotPtr p; - double ds; -{ - int i; - - /* JM -- 1310 -- the loop below is if the user requires extra diagnostics and - has provided a file diag_cells.dat to store photons stats for cells they have specified - */ - - for (i = 0; i < ncstat; i++) - { - /* check if the cell is in the specified list - ncell_stats is global variable */ - if (one->nplasma == ncell_stats[i]) - { - fprintf (pstatptr, - "PHOTON_DETAILS %3d %8.3e %8.3e %8.3e cell%3d wind cell%3d\n", - geo.wcycle, p->freq, p->w, ds, one->nplasma, one->nwind); - } - } - return (0); -} /************************************************************* diff --git a/source/rdpar.c b/source/rdpar.c index 9b0738648..dfa593623 100644 --- a/source/rdpar.c +++ b/source/rdpar.c @@ -695,9 +695,6 @@ get_root (root, total) - - - /* JM130717 the next set of routines are designed to clean up the code * in parallel mode */ @@ -713,6 +710,10 @@ int rdpar_set_mpi_rank (rank) return(0); } + +/* sets the verbosity level + */ + int rdpar_set_verbose (vlevel) int vlevel; { @@ -722,7 +723,18 @@ int rdpar_set_verbose (vlevel) return(0); } -int rd_advanced(firstword, answer, wordlength, noptions) + + +/* JM 141015 -- rd_extra is a function designed + to help address #111. We want to implement + extra diagnostics which can be supplied at the + end of the file if extra_diagnostics is set to + 1 in the parameter file. This function is used + by get_extra_diagnostics() to do this +*/ + + +int rd_extra(firstword, answer, wordlength, noptions) char firstword[]; double *answer; int *wordlength; diff --git a/source/templates.h b/source/templates.h index 685665a47..d3eb78705 100755 --- a/source/templates.h +++ b/source/templates.h @@ -26,7 +26,6 @@ int qdisk_init(void); int qdisk_save(char *diskfile, double ztot); int read_non_standard_disk_profile(char *tprofile); int init_advanced_modes(void); -int get_extra_diagnostics(void); /* photon2d.c */ int translate(WindPtr w, PhotPtr pp, double tau_scat, double *tau, int *nres); int translate_in_space(PhotPtr pp); @@ -133,7 +132,6 @@ double sigma_phot_verner(struct innershell *x_ptr, double freq); double den_config(PlasmaPtr xplasma, int nconf); double pop_kappa_ff_array(void); int update_banded_estimators(PlasmaPtr xplasma, PhotPtr p, double ds, double w_ave); -int save_photon_stats(WindPtr one, PhotPtr p, double ds); double mean_intensity(PlasmaPtr xplasma, double freq, int mode); /* wind_updates2d.c */ int wind_update(WindPtr (w)); @@ -257,6 +255,8 @@ double badnell_gs_rr(int nion, double T); double milne_gs_rr(int nion, double T); /* diag.c */ int open_diagfile(void); +int get_extra_diagnostics(void); +int save_photon_stats(WindPtr one, PhotPtr p, double ds); /* sv.c */ int get_sv_wind_params(void); double sv_velocity(double x[], double v[]); From eb7460f1883fe68342f48b7d1d7ec316e5fdee02 Mon Sep 17 00:00:00 2001 From: jhmatthews Date: Wed, 29 Oct 2014 14:08:59 -0400 Subject: [PATCH 06/10] Included diag.o in makefile py_wind_objects --- source/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Makefile b/source/Makefile index 06f89fe6e..489a685c3 100755 --- a/source/Makefile +++ b/source/Makefile @@ -187,7 +187,7 @@ py_wind_objects = py_wind.o get_atomicdata.o py_wind_sub.o windsave.o py_wind_io matom.o estimators.o yso.o elvis.o photon2d.o cylindrical.o rtheta.o spherical.o \ cylind_var.o bilinear.o gridwind.o py_wind_macro.o partition.o auger_ionization.o\ spectral_estimators.o shell_wind.o compton.o torus.o zeta.o dielectronic.o \ - variable_temperature.o bb.o rdpar.o log.o direct_ion.o + variable_temperature.o bb.o rdpar.o log.o direct_ion.o diag.o From 0a6a5c278365fa2ca921e29b2b6d9e7bc1df0546 Mon Sep 17 00:00:00 2001 From: jhmatthews Date: Thu, 6 Nov 2014 11:11:02 -0500 Subject: [PATCH 07/10] multiple changes- DEBUG statements replaced with Debug in get_atomicdata, added function to modes which controls whether to print out a summary of the atomic data to file, replaced a few other instances of #if DEBUG. --- source/get_atomicdata.c | 39 ++++++++++++++++++++++----------------- source/py_wind_sub.c | 9 +++++++-- source/python.c | 33 +++++++++++++++++++-------------- source/python.h | 9 ++++++--- source/trans_phot.c | 5 +++-- 5 files changed, 57 insertions(+), 38 deletions(-) diff --git a/source/get_atomicdata.c b/source/get_atomicdata.c index 7a00b8552..bf767358e 100755 --- a/source/get_atomicdata.c +++ b/source/get_atomicdata.c @@ -9,8 +9,8 @@ #include "log.h" - -#define DEBUG 0 /* nonzero implies debug */ +// DEBUG is deprecated as described by #111 +//#define DEBUG 0 /* nonzero implies debug */ /*********************************************************** Space Telescope Science Institute @@ -140,6 +140,8 @@ than once 12jul nsh 73 - added structures and routines to read in badnell style total recombination rate data 12sept nsh 73 - added structures and routines to read in gaunt factor data from sutherland 1997 + 14nov JM -- removed DEBUG usage, replaced with Debug statements, see #111, #120. + Also used modes.write_atomicdata to control if summary is written to file. **************************************************************/ @@ -704,8 +706,8 @@ ksl 04Apr ?? n++; if (n == nelements) { - if (DEBUG) - Error + + Debug ("get_atomic_data: file %s line %d has ion for unknown element with z %d\n", file, lineno, z); break; @@ -916,8 +918,8 @@ the program working in both cases, and certainly mixed cases 04apr ksl */ n++; if (n == nions) { - if (DEBUG) - Error + + Debug ("get_atomic_data: file %s line %d has level for unknown ion \n", file, lineno); break; @@ -1104,8 +1106,8 @@ is already incremented n++; if (n == nions) { - if (DEBUG) - Error + + Debug ("get_atomic_data: file %s line %d has level for unknown ion \n", file, lineno); break; @@ -1156,8 +1158,8 @@ described as macro-levels. */ /* Check whether we already have too many levels specified for this ion. If so, skip */ if (ion[n].nmax == ion[n].nlevels) { - if (DEBUG) - Error + + Debug ("get_atomic_data: file %s line %d has level exceeding the number allowed for ion[%d]\n", file, lineno, n); @@ -1428,8 +1430,8 @@ for the ionstate. n++; if (n == nlevels) { - if (DEBUG) - Error + + Debug ("No ion found to match PhotTop data in file %s on line %d. Data ignored.\n", file, lineno); break; // There was no pre-existing ion @@ -1543,8 +1545,8 @@ for the ionstate. } else if (ion[n].phot_info == 1) { - if (DEBUG) - Error + + Debug ("Get_atomic_data: file %s Ignoring VFKY photoinization for ion %d with topbase photoionization\n", file, n); } @@ -2635,8 +2637,9 @@ or zero so that simple checks of true and false can be used for them */ bb_max, NBBJUMPS); /* Now, write the data to a file so you can check it later if you wish */ - -#if DEBUG +/* JM 1411 -- this is now controlled by one of the -d flag modes */ + if (modes.write_atomicdata) + { if ((fptr = fopen ("data.out", "w")) == NULL) { @@ -2718,7 +2721,9 @@ or zero so that simple checks of true and false can be used for them */ } fclose (fptr); -#endif + } // end of if statement based on modes.write_atomicdata + + /* Finally create frequency ordered pointers to the various portions * of the atomic data diff --git a/source/py_wind_sub.c b/source/py_wind_sub.c index 25dee5f16..9443f28ab 100755 --- a/source/py_wind_sub.c +++ b/source/py_wind_sub.c @@ -1731,9 +1731,14 @@ coolheat_summary (w, rootname, ochoice) 1409 ksl Eliminated several files that were of limited use to users. The deleted files are printed out if - DEBUG is set. + DEBUG is set. + 1411 JM debug is now deprecated so replaced with FULL_ION_SUMMARTY ************************************************************************/ + +#define FULL_ION_SUMMARY 0 + + int complete_file_summary (w, root, ochoice) WindPtr w; @@ -1772,7 +1777,7 @@ complete_file_summary (w, root, ochoice) ion_summary (w, 14, 4, 1, root, ochoice); ion_summary (w, 14, 5, 1, root, ochoice); -#if DEBUG +#if FULL_ION_SUMMARY ion_summary (w, 6, 3, 2, root, ochoice); ion_summary (w, 6, 4, 2, root, ochoice); ion_summary (w, 6, 5, 2, root, ochoice); diff --git a/source/python.c b/source/python.c index ab36e68ef..071198546 100755 --- a/source/python.c +++ b/source/python.c @@ -1193,8 +1193,11 @@ Afterwards, the photons are used to compute the sim parameters. */ * debugged. But one can continue debugging it by setting the DEBUG variatble to true */ geo.compton_torus=0; -#if DEBUG + + /* JM 1411 -- we only ask about the Torus if we've used the -d flag */ + if (modes.iadvanced) rdint ("Torus(0=no,1=yes)", &geo.compton_torus); + if (geo.compton_torus) { rddoub ("Torus.rmin(cm)", &geo.compton_torus_rmin); @@ -1210,7 +1213,7 @@ Afterwards, the photons are used to compute the sim parameters. */ geo.compton_torus_tau); } } -#endif + /* Describe the wind */ @@ -1627,13 +1630,13 @@ run -- 07jul -- ksl if (modes.iadvanced) { /* do we want debug statements to print */ - rdint ("Use_Debug_Statements(0=no, 1=yes)", &modes.use_debug); + rdint ("Use_Debug_Statements(0=no,1=yes)", &modes.use_debug); if (modes.use_debug) Log_debug(modes.use_debug); // communicate that we want to print debug statements /* Do we require extra diagnostics or not */ - rdint ("Extra.diagnostics(0=no, 1=yes) ", &modes.diag_on_off); + rdint ("Extra.diagnostics(0=no,1=yes) ", &modes.diag_on_off); if (modes.diag_on_off) { @@ -2299,9 +2302,9 @@ run -- 07jul -- ksl trans_phot (w, p, select_extract); -#if DEBUG + if (modes.print_windrad_summary) wind_rad_summary (w, windradfile, "a"); -#endif + spectrum_create (p, freqmin, freqmax, nangles, select_extract); @@ -2608,9 +2611,9 @@ photon_checks (p, freqmin, freqmax, comment) * 11apr--NSH-decreased freqmin to 0.4, to take account of double redshifted photons. * shift. */ -#if DEBUG - Log ("photon_checks: %s\n", comment); -#endif + + Debug ("photon_checks: %s\n", comment); + freqmax *= (1.8); freqmin *= (0.6); for (nn = 0; nn < NPHOT; nn++) @@ -2657,10 +2660,10 @@ photon_checks (p, freqmin, freqmax, comment) } } Log ("NSH Geo.n_ioniz=%e\n", geo.n_ioniz); -#if DEBUG + if (nnn == 0) - Log ("photon_checks: All photons passed checks successfully\n"); -#endif + Debug ("photon_checks: All photons passed checks successfully\n"); + return (0); } @@ -2948,14 +2951,16 @@ int init_advanced_modes() { modes.iadvanced = 0; // this is controlled by the -d flag, global mode control. modes.save_cell_stats = 0; // want to save photons statistics by cell - modes.ispy = 0; // want to use the ispy function + modes.ispy = 0; // want to use the ispy function modes.keep_ioncycle_windsaves = 0; // want to save wind file each ionization cycle modes.track_resonant_scatters = 0; // want to track resonant scatters modes.save_extract_photons = 0; // we want to save details on extracted photons modes.print_windrad_summary = 0; // we want to print the wind rad summary each cycle modes.adjust_grid = 0; // the user wants to adjust the grid scale modes.diag_on_off = 0; // extra diagnostics - modes.print_dvds_info = 0; + modes.use_debug = 0; + modes.print_dvds_info = 0; // print out information on velocity gradients + modes.write_atomicdata = 0; // print out summary of atomic data return (0); } \ No newline at end of file diff --git a/source/python.h b/source/python.h index 5e0464430..38f6b2be8 100755 --- a/source/python.h +++ b/source/python.h @@ -6,7 +6,8 @@ int np_mpi_global; /// Global variable which holds the number of M int rank_global; -#define DEBUG 0 /* 0 means do not debug */ +// DEBUG is deprecated, see #111, #120 +//#define DEBUG 0 /* 0 means do not debug */ int verbosity; /* verbosity level. 0 low, 10 is high */ /* the functions contained in log., rdpar.c and lineio.c are @@ -1022,7 +1023,8 @@ char hubeny_list[132]; //Location of listing of files representing hubeny atmos // Allow for a diagnostic file FILE *epltptr; //TEST -int diag_on_off; // on is non-zero //TEST +// diag_on_off is deprecated see #111, #120 +//int diag_on_off; // on is non-zero //TEST /* These variables are stored or used by the routines for anisotropic scattering */ @@ -1136,7 +1138,8 @@ struct advanced_modes int adjust_grid; // the user wants to adjust the grid scale int diag_on_off; // extra diagnostics int use_debug; // print out debug statements - int print_dvds_info; + int print_dvds_info; // print out information on the velocity gradients + int write_atomicdata; // print out summary of atomic data } modes; diff --git a/source/trans_phot.c b/source/trans_phot.c index 77aff2fb9..2ea32ca9b 100755 --- a/source/trans_phot.c +++ b/source/trans_phot.c @@ -93,6 +93,7 @@ trans_phot (w, p, iextract) n = 0; // To avoid -O3 warning /* 05jul -- not clear whether this is needed and why it is different from DEBUG */ + /* 1411 -- JM -- Debug usage has been altered. See #111, #120 */ if (modes.track_resonant_scatters && plinit == 0) { @@ -288,9 +289,9 @@ it from translate. ?? 02jan ksl */ -#if DEBUG + if (modes.ispy) ispy (&pp, n); -#endif + if (istat == -1) { From 49ab9e5d81ad1845dbfd33398d5327bba7bc4e5e Mon Sep 17 00:00:00 2001 From: jhmatthews Date: Thu, 6 Nov 2014 11:38:27 -0500 Subject: [PATCH 08/10] edited get_atomicdata to use separate variable to modes structure as does not include python.h --- source/atomic.h | 4 ++++ source/get_atomicdata.c | 6 +++--- source/python.c | 9 ++++++++- source/python.h | 2 +- source/rdpar.c | 4 ++-- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/source/atomic.h b/source/atomic.h index 52157119b..1c9a94052 100755 --- a/source/atomic.h +++ b/source/atomic.h @@ -497,3 +497,7 @@ typedef struct gaunt_total } Gaunt_total, *Gaunt_totalptr; Gaunt_total gaunt_total[MAX_GAUNT_N_GSQRD]; //Set up the structure + +/* a variable which controls whether to save a summary of atomic data + this is defined in atomic.h, rather than the modes structure */ +int write_atomicdata; diff --git a/source/get_atomicdata.c b/source/get_atomicdata.c index bf767358e..f5abc18be 100755 --- a/source/get_atomicdata.c +++ b/source/get_atomicdata.c @@ -141,7 +141,7 @@ 12jul nsh 73 - added structures and routines to read in badnell style total recombination rate data 12sept nsh 73 - added structures and routines to read in gaunt factor data from sutherland 1997 14nov JM -- removed DEBUG usage, replaced with Debug statements, see #111, #120. - Also used modes.write_atomicdata to control if summary is written to file. + Also used write_atomicdata to control if summary is written to file. **************************************************************/ @@ -2637,8 +2637,8 @@ or zero so that simple checks of true and false can be used for them */ bb_max, NBBJUMPS); /* Now, write the data to a file so you can check it later if you wish */ -/* JM 1411 -- this is now controlled by one of the -d flag modes */ - if (modes.write_atomicdata) +/* JM 1411 -- this is now controlled by one of the -d flag modes, defined in atomic.h */ + if (write_atomicdata) { if ((fptr = fopen ("data.out", "w")) == NULL) diff --git a/source/python.c b/source/python.c index 071198546..e4ab76087 100755 --- a/source/python.c +++ b/source/python.c @@ -614,6 +614,12 @@ should allocate the space for the spectra to avoid all this nonsense. 02feb ksl and old wind files, we also got the atomic data */ rdstr ("Atomic_data", geo.atomic_filename); + + /* read a variable which controls whether to save a summary of atomic data + this is defined in atomic.h, rather than the modes structure */ + if (modes.iadvanced) + rdint ("write_atomicdata", write_atomicdata); + get_atomic_data (geo.atomic_filename); } @@ -2960,7 +2966,8 @@ int init_advanced_modes() modes.diag_on_off = 0; // extra diagnostics modes.use_debug = 0; modes.print_dvds_info = 0; // print out information on velocity gradients - modes.write_atomicdata = 0; // print out summary of atomic data + write_atomicdata = 0; // print out summary of atomic data + //note this is defined in atomic.h, rather than the modes structure return (0); } \ No newline at end of file diff --git a/source/python.h b/source/python.h index 38f6b2be8..d2973834f 100755 --- a/source/python.h +++ b/source/python.h @@ -1139,7 +1139,7 @@ struct advanced_modes int diag_on_off; // extra diagnostics int use_debug; // print out debug statements int print_dvds_info; // print out information on the velocity gradients - int write_atomicdata; // print out summary of atomic data + } modes; diff --git a/source/rdpar.c b/source/rdpar.c index dfa593623..bca94e9c0 100644 --- a/source/rdpar.c +++ b/source/rdpar.c @@ -747,8 +747,8 @@ int rd_extra(firstword, answer, wordlength, noptions) if (fgets (line, LINELEN, rdin_ptr) == NULL) { - if (noptions == 0) - Error("EOF: No advanced mode options read, but advanced mode on!\n"); + if (*noptions == 0) + Error("EOF: No extra options read, but extra diagnostics on!\n"); return(1); } From 4d9b166c882d7fd492887b3673b577b8d1b8a365 Mon Sep 17 00:00:00 2001 From: jhmatthews Date: Fri, 7 Nov 2014 16:01:56 -0500 Subject: [PATCH 09/10] control debug with verbosity, fix some extra_diags readin, and add example pf file --- examples/sv_detailedmode.pf | 87 ++++++ source/diag.c | 14 +- source/foo.h | 528 ------------------------------------ source/log.c | 33 ++- source/log.h | 3 +- source/python.c | 14 +- source/rdpar.c | 10 +- 7 files changed, 128 insertions(+), 561 deletions(-) create mode 100644 examples/sv_detailedmode.pf diff --git a/examples/sv_detailedmode.pf b/examples/sv_detailedmode.pf new file mode 100644 index 000000000..b6c4f846a --- /dev/null +++ b/examples/sv_detailedmode.pf @@ -0,0 +1,87 @@ +Wind_type() 0 +Atomic_data data/standard77 +write_atomicdata 1 +photons_per_cycle 10000 +Ionization_cycles 1 +spectrum_cycles 100 +Coord.system(0=spherical,1=cylindrical,2=spherical_polar,3=cyl_var) 1 +Wind.dim.in.x_or_r.direction 5 +Wind.dim.in.z_or_theta.direction 5 +adjust_grid(0=no,1=yes) 1 +geo.xlog_scale 1e7 +geo.zlog_scale 1e7 +Wind_ionization(0=on.the.spot,1=LTE,2=fixed,3=recalc_bb,5=recalc_pow) 3 +Line_transfer() 3 +Thermal_balance_options(0=everything.on,1=no.adiabatic) 0 +System_type(0=star+disk,1=star+disk+secondary,2=agn) 0 +Star_radiation(y=1) 1 +Disk_radiation(y=1) 1 +Boundary_layer_radiation(y=1) 1 +Wind_radiation(y=1) 0 +Rad_type_for_star(0=bb,1=models)_to_make_wind 0 +Rad_type_for_disk(0=bb,1=models)_to_make_wind 0 +Rad_type_for_bl(0=bb,1=models)_to_make_wind 0 +mstar(msol) 0.8 +rstar(cm) 7e8 +tstar 40000 +disk.type(0=no.disk,1=standard.flat.disk,2=vertically.extended.disk) 1 +disk.mdot(msol/yr) 1e-8 +Disk.illumination.treatment() 0 +Disk.temperature.profile(0=standard;1=readin) 0 +disk.radmax(cm) 2.38e10 +lum_bl 0 +t_bl 10000 +Torus(0=no,1=yes) 0 +wind.radmax(cm) 1e12 +wind.t.init 40000 +wind.mdot(msol/yr) 1e-20 +sv.diskmin(wd_rad) 4 +sv.diskmax(wd_rad) 12 +sv.thetamin(deg) 20 +sv.thetamax(deg) 65 +sv.mdot_r_exponent 0 +sv.v_infinity(in_units_of_vescape 3 +sv.acceleration_length(cm) 7e10 +sv.acceleration_exponent 1.5 +wind.filling_factor(1=smooth,<1=clumpted) 1 +Rad_type_for_star()_in_final_spectrum 0 +Rad_type_for_disk(0=bb,1=models,2=uniform)_in_final_spectrum 0 +Model_file data/disk14/kur_tlusty_hybrid.ls +spectrum_wavemin 4000 +spectrum_wavemax 6900 +no_observers 10 +angle(0=pole) 0 +angle(0=pole) 5 +angle(0=pole) 10 +angle(0=pole) 15 +angle(0=pole) 20 +angle(0=pole) 30 +angle(0=pole) 40 +angle(0=pole) 50 +angle(0=pole) 60 +angle(0=pole) 80 +phase(0=inferior_conjunction) 0.5 +phase(0=inferior_conjunction) 0.5 +phase(0=inferior_conjunction) 0.5 +phase(0=inferior_conjunction) 0.5 +phase(0=inferior_conjunction) 0.5 +phase(0=inferior_conjunction) 0.5 +phase(0=inferior_conjunction) 0.5 +phase(0=inferior_conjunction) 0.5 +phase(0=inferior_conjunction) 0.5 +phase(0=inferior_conjunction) 0.5 +phase(0=inferior_conjunction) 0.5 +live.or.die(0).or.extract(anything_else) 1 +Select_specific_no_of_scatters_in_spectra(y/n) n +Select_photons_by_position(y/n) n +spec.type(flambda(1),fnu(2),basic(other) 1 +Use.standard.care.factors(1=yes) 1 +Photon.sampling.approach(0=T,1=(f1,f2),2=cv,3=yso,4=user_defined), 2 +Extra.diagnostics(0=no,1=yes) 1 +ispymode(1=yes) 1 +keep_ioncycle_windsaves(1=yes) 1 +track_resonant_scatters(1=yes) 1 +print_windrad_summary(1=yes) 1 +print_dvds_info(1=yes) 1 +save_extract_photons(1=yes) 1 + diff --git a/source/diag.c b/source/diag.c index 452505a91..bbb8c92c1 100755 --- a/source/diag.c +++ b/source/diag.c @@ -143,12 +143,17 @@ int get_extra_diagnostics() while (noptions < NMAX_OPTIONS && rdstat == 0) { - rdstat = rd_extra(firstword, &answer, &wordlength, &noptions); + rdstat = rd_extra(firstword, &answer, &wordlength); /* if rdstat is 1 we reached EOF, so exit this routine */ if (rdstat) - return(0); + { + if (noptions == 0) + Error("get_extra_diagnostics: EOF: %i options read, but extra diagnostics on!\n", noptions); + + return(0); + } Log("%s %8.4e\n", firstword, answer); @@ -203,8 +208,11 @@ int get_extra_diagnostics() else { - Error("get_extra_diagnostics: didn't understand question %s, continuing!\n", firstword); + Error("get_extra_diagnostics: didn't understand question %s, continuing!\n", firstword); + noptions--; // this isn't a real option, so decrement it before we increment it...! } + + noptions++; // increment noptions } return 0; diff --git a/source/foo.h b/source/foo.h index d3eb78705..e69de29bb 100755 --- a/source/foo.h +++ b/source/foo.h @@ -1,528 +0,0 @@ -/* bb.c */ -double planck(double t, double freqmin, double freqmax); -double get_rand_pow(double x1, double x2, double alpha); -double get_rand_exp(double alpha_min, double alpha_max); -double integ_planck_d(double alphamin, double alphamax); -int init_integ_planck_d(void); -double planck_d(double alpha); -double emittance_bb(double freqmin, double freqmax, double t); -double check_fmax(double fmin, double fmax, double temp); -/* get_atomicdata.c */ -int get_atomic_data(char masterfile[]); -int index_lines(void); -int index_phot_top(void); -int index_phot_verner(void); -int index_collisions(void); -void indexx(int n, float arrin[], int indx[]); -int limit_lines(double freqmin, double freqmax); -int tabulate_verner(void); -/* python.c */ -int main(int argc, char *argv[]); -int help(void); -int init_geo(void); -int photon_checks(PhotPtr p, double freqmin, double freqmax, char *comment); -int get_spectype(int yesno, char *question, int *spectype); -int qdisk_init(void); -int qdisk_save(char *diskfile, double ztot); -int read_non_standard_disk_profile(char *tprofile); -int init_advanced_modes(void); -/* photon2d.c */ -int translate(WindPtr w, PhotPtr pp, double tau_scat, double *tau, int *nres); -int translate_in_space(PhotPtr pp); -double ds_to_wind(PhotPtr pp); -int translate_in_wind(WindPtr w, PhotPtr p, double tau_scat, double *tau, int *nres); -int walls(PhotPtr p, PhotPtr pold); -/* photon_gen.c */ -int define_phot(PhotPtr p, double f1, double f2, long nphot_tot, int ioniz_or_final, int iwind, int freq_sampling); -double populate_bands(double f1, double f2, int ioniz_or_final, int iwind, struct xbands *band); -int xdefine_phot(double f1, double f2, int ioniz_or_final, int iwind); -int xmake_phot(PhotPtr p, double f1, double f2, int ioniz_or_final, int iwind, double weight, int iphot_start, int nphotons); -double star_init(double r, double tstar, double freqmin, double freqmax, int ioniz_or_final, double *f); -int photo_gen_star(PhotPtr p, double r, double t, double weight, double f1, double f2, int spectype, int istart, int nphot); -double disk_init(double rmin, double rmax, double m, double mdot, double freqmin, double freqmax, int ioniz_or_final, double *ftot); -int photo_gen_disk(PhotPtr p, double weight, double f1, double f2, int spectype, int istart, int nphot); -int phot_gen_sum(char filename[], char mode[]); -double bl_init(double lum_bl, double t_bl, double freqmin, double freqmax, int ioniz_or_final, double *f); -/* saha.c */ -int nebular_concentrations(PlasmaPtr xplasma, int mode); -int concentrations(PlasmaPtr xplasma, int mode); -int saha(PlasmaPtr xplasma, double ne, double t); -int lucy(PlasmaPtr xplasma); -int lucy_mazzali1(double nh, double t_r, double t_e, double www, int nelem, double ne, double density[], double xne, double newden[]); -int fix_concentrations(PlasmaPtr xplasma, int mode); -double get_ne(double density[]); -/* spectra.c */ -int spectrum_init(double f1, double f2, int nangle, double angle[], double phase[], int scat_select[], int top_bot_select[], int select_extract, double rho_select[], double z_select[], double az_select[], double r_select[]); -int spectrum_create(PhotPtr p, double f1, double f2, int nangle, int select_extract); -int spectrum_summary(char filename[], char mode[], int nspecmin, int nspecmax, int select_spectype, double renorm, int loglin); -/* wind2d.c */ -int define_wind(void); -int where_in_grid(double x[]); -int vwind_xyz(PhotPtr p, double v[]); -int wind_div_v(WindPtr w); -double rho(WindPtr w, double x[]); -int mdot_wind(WindPtr w, double z, double rmax); -int get_random_location(int n, int icomp, double x[]); -int zero_scatters(void); -int check_corners_inwind(int n, int icomp); -/* wind.c */ -int where_in_wind(double x[]); -int wind_check(WindPtr www, int n); -double model_velocity(double x[], double v[]); -int model_vgrad(double x[], double v_grad[][3]); -double model_rho(double x[]); -/* vector.c */ -double dot(double a[], double b[]); -double length(double a[]); -int renorm(double a[], double scalar); -int cross(double a[], double b[], double c[]); -int vmove(double u[], double lmn[], double s, double result[]); -int vsub(double u[], double v[], double result[]); -int vadd(double u[], double v[], double result[]); -int stuff_v(double vin[], double vout[]); -double dot_tensor_vec(double tensor[3][3], double vin[3], double vout[3]); -int project_from_xyz_cyl(double a[], double b[], double result[]); -int project_from_cyl_xyz(double a[], double b[], double result[]); -int create_basis(double u[], double v[], struct basis *basis_new); -int project_from(struct basis *basis_from, double v_in[], double v_out[]); -int project_to(struct basis *basis_from, double v_in[], double v_out[]); -int reorient(struct basis *basis_from, struct basis *basis_to, double v_from[], double v_to[]); -/* debug.c */ -int DebugStr(char *string); -/* recipes.c */ -double qromb(double (*func)(double), double a, double b, double eps); -double trapzd(double (*func)(double), double a, double b, int n); -void polint(double xa[], double ya[], int n, double x, double *y, double *dy); -double zbrent(double (*func)(double), double x1, double x2, double tol); -void spline(double x[], double y[], int n, double yp1, double ypn, double y2[]); -void splint(double xa[], double ya[], double y2a[], int n, double x, double *y); -double expint(int n, double x); -double *vector(int i, int j); -void free_vector(double *a, int i, int j); -double rtsafe(void (*funcd)(double, double *, double *), double x1, double x2, double xacc); -double golden(double ax, double bx, double cx, double (*f)(double), double tol, double *xmin); -/* trans_phot.c */ -int trans_phot(WindPtr w, PhotPtr p, int iextract); -/* phot_util.c */ -int stuff_phot(PhotPtr pin, PhotPtr pout); -int move_phot(PhotPtr pp, double ds); -int comp_phot(PhotPtr p1, PhotPtr p2); -int phot_hist(PhotPtr p, int iswitch); -int phot_history_summarize(void); -double ds_to_cone(ConePtr cc, struct photon *p); -double ds_to_sphere(double r, struct photon *p); -double ds_to_sphere2(double x[], double r, struct photon *p); -int quadratic(double a, double b, double c, double r[]); -double ds_to_plane(struct plane *pl, struct photon *p); -double ds_to_closest_approach(double x[], struct photon *p, double *impact_parameter); -/* resonate.c */ -double calculate_ds(WindPtr w, PhotPtr p, double tau_scat, double *tau, int *nres, double smax, int *istat); -int select_continuum_scattering_process(double kap_cont, double kap_es, double kap_ff, PlasmaPtr xplasma); -double kappa_bf(PlasmaPtr xplasma, double freq, int macro_all); -int kbf_need(double fmin, double fmax); -double sobolev(WindPtr one, PhotPtr p, double den_ion, struct lines *lptr, double dvds); -int doppler(PhotPtr pin, PhotPtr pout, double v[], int nres); -int scatter(PhotPtr p, int *nres, int *nnscat); -/* radiation.c */ -int radiation(PhotPtr p, double ds); -double kappa_ff(PlasmaPtr xplasma, double freq); -double sigma_phot(struct photoionization *x_ptr, double freq); -double sigma_phot_topbase(struct topbase_phot *x_ptr, double freq); -double sigma_phot_verner(struct innershell *x_ptr, double freq); -double den_config(PlasmaPtr xplasma, int nconf); -double pop_kappa_ff_array(void); -int update_banded_estimators(PlasmaPtr xplasma, PhotPtr p, double ds, double w_ave); -double mean_intensity(PlasmaPtr xplasma, double freq, int mode); -/* wind_updates2d.c */ -int wind_update(WindPtr (w)); -int wind_rad_init(void); -int wind_rad_summary(WindPtr w, char filename[], char mode[]); -int wind_ip(void); -/* windsave.c */ -int wind_save(char filename[]); -int wind_read(char filename[]); -int wind_complete(WindPtr w); -int spec_save(char filename[]); -int spec_read(char filename[]); -/* extract.c */ -int extract(WindPtr w, PhotPtr p, int itype); -int extract_one(WindPtr w, PhotPtr pp, int itype, int nspec); -/* pdf.c */ -int pdf_gen_from_func(PdfPtr pdf, double (*func)(double), double xmin, double xmax, int njumps, double jump[]); -double gen_array_from_func(double (*func)(double), double xmin, double xmax, int pdfsteps); -int pdf_gen_from_array(PdfPtr pdf, double x[], double y[], int n_xy, double xmin, double xmax, int njumps, double jump[]); -double pdf_get_rand(PdfPtr pdf); -int pdf_limit(PdfPtr pdf, double xmin, double xmax); -double pdf_get_rand_limit(PdfPtr pdf); -int pdf_to_file(PdfPtr pdf, char filename[]); -int pdf_check(PdfPtr pdf); -int recalc_pdf_from_cdf(PdfPtr pdf); -/* roche.c */ -int binary_basics(void); -double ds_to_roche_2(PhotPtr p); -int hit_secondary(PhotPtr p); -double pillbox(PhotPtr p, double *smin, double *smax); -double phi(double s); -double dphi_ds(double s); -double d2phi_ds2(double s); -double roche_width(double x); -double roche2_width_max(void); -void roche(double s, double *value, double *derivative); -void roche_deriv(double s, double *value, double *derivative); -/* random.c */ -int randvec(double a[], double r); -int randvcos(double lmn[], double north[]); -double vcos(double x); -/* stellar_wind.c */ -int get_stellar_wind_params(void); -double stellar_velocity(double x[], double v[]); -double stellar_rho(double x[]); -int stellar_vel_grad(double x[], double velgrad[][3]); -/* homologous.c */ -int get_homologous_params(void); -double homologous_velocity(double x[], double v[]); -double homologous_rho(double x[]); -/* proga.c */ -int get_proga_wind_params(void); -int get_proga(void); -double proga_velocity(double x[], double v[]); -double proga_rho(double x[]); -double proga_temp(double x[]); -int rtheta_make_zeus_grid(WindPtr w); -int rtheta_zeus_volumes(WindPtr w); -/* corona.c */ -int get_corona_params(void); -double corona_velocity(double x[], double v[]); -double corona_rho(double x[]); -/* knigge.c */ -int get_knigge_wind_params(void); -double kn_velocity(double x[], double v[]); -double kn_rho(double x[]); -double kn_vzero(double r); -double kn_wind_mdot_integral(double r); -double kn_rho_zero(double r); -/* disk.c */ -double tdisk(double m, double mdot, double r); -double teff(double t, double x); -double gdisk(double mass, double mdot, double rmin); -double geff(double g0, double x); -double vdisk(double x[], double v[]); -double zdisk(double r); -double ds_to_disk(struct photon *p, int miss_return); -void disk_deriv(double s, double *value, double *derivative); -/* lines.c */ -double total_line_emission(WindPtr one, double f1, double f2); -double lum_lines(WindPtr one, int nmin, int nmax); -int lum_pdf(PlasmaPtr xplasma, double lumlines); -double q21(struct lines *line_ptr, double t); -double q12(struct lines *line_ptr, double t); -double a21(struct lines *line_ptr); -double two_level_atom(struct lines *line_ptr, PlasmaPtr xplasma, double *d1, double *d2); -double line_nsigma(struct lines *line_ptr, PlasmaPtr xplasma); -double scattering_fraction(struct lines *line_ptr, PlasmaPtr xplasma); -double p_escape(struct lines *line_ptr, PlasmaPtr xplasma); -double p_escape_from_tau(double tau); -int line_heat(PlasmaPtr xplasma, PhotPtr pp, int nres); -/* continuum.c */ -double one_continuum(int spectype, double t, double g, double freqmin, double freqmax); -double emittance_continuum(int spectype, double freqmin, double freqmax, double t, double g); -/* emission.c */ -double wind_luminosity(double f1, double f2); -double total_emission(WindPtr one, double f1, double f2); -double adiabatic_cooling(WindPtr one, double t); -int photo_gen_wind(PhotPtr p, double weight, double freqmin, double freqmax, int photstart, int nphot); -double one_line(WindPtr one, double freqmin, double freqmax, int *nres); -double total_free(WindPtr one, double t_e, double f1, double f2); -double ff(WindPtr one, double t_e, double freq); -double one_ff(WindPtr one, double f1, double f2); -double gaunt_ff(double gsquared); -/* recomb.c */ -double fb_verner_partial(double freq); -double fb_topbase_partial(double freq); -double integ_fb(double t, double f1, double f2, int nion, int fb_choice); -double total_fb(WindPtr one, double t, double f1, double f2); -double one_fb(WindPtr one, double f1, double f2); -int num_recomb(PlasmaPtr xplasma, double t_e); -double fb(PlasmaPtr xplasma, double t, double freq, int ion_choice, int fb_choice); -int init_freebound(double t1, double t2, double f1, double f2); -double get_nrecomb(double t, int nion); -double get_fb(double t, int nion, int narray); -double xinteg_fb(double t, double f1, double f2, int nion, int fb_choice); -int fb_save(char filename[]); -int fb_read(char filename[]); -double total_rrate(int nion, double T); -double badnell_gs_rr(int nion, double T); -double milne_gs_rr(int nion, double T); -/* diag.c */ -int open_diagfile(void); -int get_extra_diagnostics(void); -int save_photon_stats(WindPtr one, PhotPtr p, double ds); -/* sv.c */ -int get_sv_wind_params(void); -double sv_velocity(double x[], double v[]); -double sv_rho(double x[]); -double sv_find_wind_rzero(double p[]); -int sv_zero_init(double p[]); -double sv_zero_r(double r); -double sv_theta_wind(double r); -double sv_wind_mdot_integral(double r); -/* ionization.c */ -int ion_abundances(PlasmaPtr xplasma, int mode); -int convergence(PlasmaPtr xplasma); -int check_convergence(void); -int one_shot(PlasmaPtr xplasma, int mode); -double calc_te(PlasmaPtr xplasma, double tmin, double tmax); -double zero_emit(double t); -/* ispy.c */ -int ispy_init(char filename[], int icycle); -int ispy_close(void); -int ispy(PhotPtr p, int n); -/* levels.c */ -int levels(PlasmaPtr xplasma, int mode); -/* gradv.c */ -double dvwind_ds(PhotPtr p); -int dvds_ave(void); -/* reposition.c */ -int reposition(WindPtr w, PhotPtr p); -/* anisowind.c */ -int randwind(PhotPtr p, double lmn[3], double north[3]); -double vrandwind(double x); -double reweightwind(PhotPtr p); -int make_pdf_randwind(double tau); -int randwind_thermal_trapping(PhotPtr p, int *nnscat); -/* util.c */ -int fraction(double value, double array[], int npts, int *ival, double *f, int mode); -int linterp(double x, double xarray[], double yarray[], int xdim, double *y, int mode); -int coord_fraction(int ichoice, double x[], int ii[], double frac[], int *nelem); -int where_in_2dcell(int ichoice, double x[], int n, double *fx, double *fz); -int wind_n_to_ij(int n, int *i, int *j); -int wind_ij_to_n(int i, int j, int *n); -/* density.c */ -double get_ion_density(PhotPtr p, int nion); -/* detail.c */ -int detailed_balance(PlasmaPtr xplasma, int nelem, double newden[]); -int rebalance(double rates_up[], double rates_down[], double fraction[], int ntot); -int wind_update_after_detailed_balance(PlasmaPtr xplasma, int nelem, double newden[]); -/* bands.c */ -int bands_init(int imode, struct xbands *band); -int freqs_init(double freqmin, double freqmax); -/* time.c */ -double timer(void); -int get_time(char curtime[]); -/* matom.c */ -int matom(PhotPtr p, int *nres, int *escape); -double b12(struct lines *line_ptr); -double alpha_sp(struct topbase_phot *cont_ptr, PlasmaPtr xplasma, int ichoice); -double alpha_sp_integrand(double freq); -int kpkt(PhotPtr p, int *nres, int *escape); -int fake_matom_bb(PhotPtr p, int *nres, int *escape); -int fake_matom_bf(PhotPtr p, int *nres, int *escape); -int macro_pops(PlasmaPtr xplasma, double xne); -int macro_gov(PhotPtr p, int *nres, int matom_or_kpkt, int *which_out); -double get_kpkt_f(void); -double get_matom_f(void); -int photo_gen_kpkt(PhotPtr p, double weight, int photstart, int nphot); -int photo_gen_matom(PhotPtr p, double weight, int photstart, int nphot); -int emit_matom(WindPtr w, PhotPtr p, int *nres, int upper); -double q_ioniz(struct topbase_phot *cont_ptr, double electron_temperature); -double q_recomb(struct topbase_phot *cont_ptr, double electron_temperature); -/* estimators.c */ -int bf_estimators_increment(WindPtr one, PhotPtr p, double ds); -int bb_estimators_increment(WindPtr one, PhotPtr p, double tau_sobolev, double dvds, int nn); -int mc_estimator_normalise(int n); -double total_fb_matoms(PlasmaPtr xplasma, double t_e, double f1, double f2); -double total_bb_cooling(PlasmaPtr xplasma, double t_e); -double macro_bb_heating(PlasmaPtr xplasma, double t_e); -double macro_bf_heating(PlasmaPtr xplasma, double t_e); -int bb_simple_heat(PlasmaPtr xplasma, PhotPtr p, double tau_sobolev, double dvds, int nn); -double get_gamma(struct topbase_phot *cont_ptr, PlasmaPtr xplasma); -double gamma_integrand(double freq); -double get_gamma_e(struct topbase_phot *cont_ptr, PlasmaPtr xplasma); -double gamma_e_integrand(double freq); -double get_alpha_st(struct topbase_phot *cont_ptr, PlasmaPtr xplasma); -double alpha_st_integrand(double freq); -double get_alpha_st_e(struct topbase_phot *cont_ptr, PlasmaPtr xplasma); -double alpha_st_e_integrand(double freq); -/* wind_sum.c */ -int xtemp_rad(WindPtr w); -/* yso.c */ -int get_yso_wind_params(void); -double yso_velocity(double x[], double v[]); -double yso_rho(double x[]); -/* elvis.c */ -int get_elvis_wind_params(void); -double elvis_velocity(double x[], double v[]); -double elvis_rho(double x[]); -double elvis_find_wind_rzero(double p[]); -int elvis_zero_init(double p[]); -double elvis_zero_r(double r); -double elvis_theta_wind(double r); -double elvis_wind_mdot_integral(double r); -double ds_to_pillbox(PhotPtr pp, double rmin, double rmax, double height); -/* cylindrical.c */ -double cylind_ds_in_cell(PhotPtr p); -int cylind_make_grid(WindPtr w); -int cylind_wind_complete(WindPtr w); -int cylind_volumes(WindPtr w, int icomp); -int cylind_where_in_grid(double x[]); -int cylind_get_random_location(int n, int icomp, double x[]); -int cylind_extend_density(WindPtr w); -int cylind_is_cell_in_wind(int n, int icomp); -/* rtheta.c */ -double rtheta_ds_in_cell(PhotPtr p); -int rtheta_make_grid(WindPtr w); -int rtheta_make_cones(WindPtr w); -int rtheta_wind_complete(WindPtr w); -int rtheta_volumes(WindPtr w, int icomp); -int rtheta_where_in_grid(double x[]); -int rtheta_get_random_location(int n, int icomp, double x[]); -int rtheta_extend_density(WindPtr w); -int rtheta_is_cell_in_wind(int n, int icomp); -/* spherical.c */ -double spherical_ds_in_cell(PhotPtr p); -int spherical_make_grid(WindPtr w); -int spherical_wind_complete(WindPtr w); -int spherical_volumes(WindPtr w, int icomp); -int spherical_where_in_grid(double x[]); -int spherical_get_random_location(int n, int icomp, double x[]); -int spherical_extend_density(WindPtr w); -int shell_make_grid(WindPtr w); -/* cylind_var.c */ -double cylvar_ds_in_cell(PhotPtr p); -int cylvar_make_grid(WindPtr w); -int cylvar_wind_complete(WindPtr w); -int cylvar_volumes(WindPtr w, int icomp); -int cylvar_where_in_grid(double x[], int ichoice, double *fx, double *fz); -int cylvar_get_random_location(int n, int icomp, double x[]); -int cylvar_extend_density(WindPtr w); -int cylvar_coord_fraction(int ichoice, double x[], int ii[], double frac[], int *nelem); -/* bilinear.c */ -int bilin(double x[], double x00[], double x01[], double x10[], double x11[], double *f, double *g); -int xquadratic(double a, double b, double c, double r[]); -/* gridwind.c */ -int create_maps(int ichoice); -int calloc_wind(int nelem); -int calloc_plasma(int nelem); -int check_plasma(PlasmaPtr xplasma, char message[]); -int calloc_macro(int nelem); -int calloc_estimators(int nelem); -int calloc_dyn_plasma(int nelem); -/* partition.c */ -int partition_functions(PlasmaPtr xplasma, int mode); -int partition_functions_2(PlasmaPtr xplasma, int xnion, double temp, double weight); -/* signal.c */ -int xsignal(char *root, char *format, ...); -int xsignal_rm(char *root); -int set_max_time(char *root, double t); -int check_time(char *root); -/* auger_ionization.c */ -int auger_ionization(PlasmaPtr xplasma); -/* agn.c */ -double agn_init(double r, double lum, double alpha, double freqmin, double freqmax, int ioniz_or_final, double *f); -double emittance_pow(double freqmin, double freqmax, double lum, double alpha); -double emittance_bpow(double freqmin, double freqmax, double lum, double alpha); -int photo_gen_agn(PhotPtr p, double r, double alpha, double weight, double f1, double f2, int spectype, int istart, int nphot); -/* shell_wind.c */ -int get_shell_wind_params(void); -/* compton.c */ -double kappa_comp(PlasmaPtr xplasma, double freq); -double kappa_ind_comp(PlasmaPtr xplasma, double freq); -double total_comp(WindPtr one, double t_e); -double klein_nishina(double nu); -/* torus.c */ -double torus_rho(double x[]); -double ds_to_cylinder(double rho, struct photon *p); -double ds_to_torus(PhotPtr pp); -/* zeta.c */ -double compute_zeta(double temp, int nion, int mode); -/* dielectronic.c */ -int compute_dr_coeffs(double temp); -double total_dr(WindPtr one, double t_e); -/* spectral_estimators.c */ -int spectral_estimators(PlasmaPtr xplasma); -double pl_alpha_func_log(double alpha); -double pl_logmean(double alpha, double lnumin, double lnumax); -double pl_log_w(double j, double alpha, double lnumin, double lnumax); -double pl_log_stddev(double alpha, double lnumin, double lnumax); -double exp_temp_func(double exp_temp); -double exp_mean(double exp_temp, double numin, double numax); -double exp_w(double j, double exp_temp, double numin, double numax); -double exp_stddev(double exp_temp, double numin, double numax); -/* variable_temperature.c */ -int variable_temperature(PlasmaPtr xplasma, int mode); -double bb_correct_2(double xtemp, double t_r, double www, int nion); -double temp_func(double solv_temp); -double pl_correct_2(double xtemp, int nion); -double tb_planck1(double freq); -double tb_logpow1(double freq); -double tb_exp1(double freq); -/* matom_diag.c */ -int matom_emiss_report(void); -/* direct_ion.c */ -int compute_di_coeffs(double T); -double total_di(WindPtr one, double t_e); -/* py_wind_sub.c */ -int zoom(int direction); -int overview(WindPtr w, char rootname[]); -int position_summary(WindPtr w); -int abs_summary(WindPtr w, char rootname[], int ochoice); -int adiabatic_cooling_summary(WindPtr w, char rootname[], int ochoice); -int lum_summary(WindPtr w, char rootname[], int ochoice); -int photo_summary(WindPtr w, char rootname[], int ochoice); -int recomb_summary(WindPtr w, char rootname[], int ochoice); -int electron_summary(WindPtr w, char rootname[], int ochoice); -int rho_summary(WindPtr w, char rootname[], int ochoice); -int plasma_cell(WindPtr w, char rootname[], int ochoice); -int freq_summary(WindPtr w, char rootname[], int ochoice); -int nphot_summary(WindPtr w, char rootname[], int ochoice); -int temp_summary(WindPtr w, char rootname[], int ochoice); -int temp_rad(WindPtr w, char rootname[], int ochoice); -int weight_summary(WindPtr w, char rootname[], int ochoice); -int velocity_summary(WindPtr w, char rootname[], int ochoice); -int mo_summary(WindPtr w, char rootname[], int ochoice); -int vol_summary(WindPtr w, char rootname[], int ochoice); -int wind_element(WindPtr w); -int tau_h_summary(WindPtr w, char rootname[], int ochoice); -int coolheat_summary(WindPtr w, char rootname[], int ochoice); -int complete_file_summary(WindPtr w, char root[], int ochoice); -int wind_reg_summary(WindPtr w, char rootname[], int ochoice); -int dvds_summary(WindPtr w, char rootname[], int ochoice); -int inner_shell_summary(WindPtr w, char rootname[], int ochoice); -int IP_summary(WindPtr w, char rootname[], int ochoice); -int alpha_summary(WindPtr w, char rootname[], int ochoice); -int J_summary(WindPtr w, char rootname[], int ochoice); -int J_scat_summary(WindPtr w, char rootname[], int ochoice); -int phot_split(WindPtr w, char rootname[], int ochoice); -int thompson(WindPtr w, char rootname[], int ochoice); -int nscat_split(WindPtr w, char rootname[], int ochoice); -int convergence_summary(WindPtr w, char rootname[], int ochoice); -int convergence_all(WindPtr w, char rootname[], int ochoice); -int model_bands(WindPtr w, char rootname[], int ochoice); -int heatcool_summary(WindPtr w, char rootname[], int ochoice); -/* py_wind_ion.c */ -int ion_summary(WindPtr w, int element, int istate, int iswitch, char rootname[], int ochoice); -int tau_ave_summary(WindPtr w, int element, int istate, double freq, char rootname[], int ochoice); -int line_summary(WindPtr w, int element, int istate, char rootname[], int ochoice); -int total_emission_summary(WindPtr w, char rootname[], int ochoice); -int modify_te(WindPtr w, char rootname[], int ochoice); -int partial_measure_summary(WindPtr w, int element, int istate, char rootname[], int ochoice); -/* py_wind_write.c */ -int write_array(char filename[], int choice); -int display(char name[]); -/* py_wind_macro.c */ -int xadiabatic_cooling_summary(WindPtr w, char rootname[], int ochoice); -int macro_summary(WindPtr w, char rootname[], int ochoice); -int ion_overview(int icell); -int config_overview(int n, int icell); -int depcoef_overview(int icell); -int copy_plasma(PlasmaPtr x1, PlasmaPtr x2); -int depcoef_overview_specific(int version, int nconfig, WindPtr w, char rootname[], int ochoice); -int level_popsoverview(int nplasma, WindPtr w, char rootname[], int ochoice); -int level_emissoverview(int nlev, WindPtr w, char rootname[], int ochoice); -int level_escapeoverview(int nlev, WindPtr w, char rootname[], int ochoice); -/* py_wind.c */ -int main(int argc, char *argv[]); -int one_choice(int choice, char *root, int ochoice); -int py_wind_help(void); -/* test_saha.c */ -int main(int argc, char *argv[]); diff --git a/source/log.c b/source/log.c index 15c326462..31087e413 100644 --- a/source/log.c +++ b/source/log.c @@ -38,7 +38,8 @@ int Log_parallel(message) Log statement for parallel reporting - int Leg_debug(value) Turn on logging of Debug statements if value is non-zero + JM- Debug statements are controlled by verbosity now, so no need for Log_Debug + int Log_debug(value) Turn on logging of Debug statements if value is non-zero int Debug( char *format, ...) Log an statement to the screen. This is essentially a intended to replace a printf statement in situations where @@ -111,6 +112,8 @@ know about (no photons in band, no model in band) but do not want to crash the code. 1407 JM removed warning - we would like to throw errors + 1411 JM debug statements are controlled by verbosity now, + so no need for Log_Debug **************************************************************/ @@ -129,7 +132,7 @@ #define SHOW_PARALLEL 1 #define SHOW_LOG 2 #define SHOW_ERROR 2 -#define SHOW_WARNING 3 +#define SHOW_DEBUG 4 #define SHOW_LOG_SILENT 5 #define SHOW_ERROR_SILENT 5 @@ -155,7 +158,9 @@ int nerrors; FILE *diagptr; int init_log = 0; int log_verbosity=5; // A parameter which can be used to suppress what would normally be logged or printed -int log_debug=0; //A parameter which is set to cause Debug commands to be logged + +//1411 JM debug statements are controlled by verbosity now, so no need for Log_Debug +//int log_debug=0; //A parameter which is set to cause Debug commands to be logged int Log_init (filename) @@ -227,7 +232,7 @@ int Log_set_verbosity(vlevel) int vlevel; { log_verbosity=vlevel; - rdpar_set_verbose(vlevel); + rdpar_set_verbose(vlevel); return(0); } @@ -500,13 +505,13 @@ int Log_parallel(char *format, ...) /* Set a flag to which cause Debug statements to be logged */ -int Log_debug(value) - int value; -{ - log_debug=value; - return(0); -} - +// int Log_debug(value) +// int value; +// { +// log_debug=value; +// return(0); +// } +/* JM- Debug statements are controlled by verbosity now, so no need for Log_Debug */ /* Log a debug statement if the external varialbe log_debug * has been set to a non-zero value */ @@ -517,14 +522,12 @@ Debug (char *format, ...) va_list ap,ap2; int result; - if (log_debug == 0) return(0); + if (log_verbosity < SHOW_DEBUG) + return(0); if (init_log == 0) Log_init ("logfile"); - if (log_verbosity < SHOW_LOG) - return(0); - va_start (ap, format); va_copy (ap2,ap); /*NSH 121212 - Line added to allow error logging to work */ if (my_rank==0) // only want to print errors if master thread diff --git a/source/log.h b/source/log.h index 2ca6706b7..79a83936d 100644 --- a/source/log.h +++ b/source/log.h @@ -18,7 +18,7 @@ int rdline(char question[], char answer[]); int get_root(char root[], char total[]); int rdpar_set_mpi_rank(int rank); int rdpar_set_verbose(int vlevel); -int rd_extra(char firstword[], double *answer, int *wordlength, int *noptions); +int rd_extra(char firstword[], double *answer, int *wordlength); /* log.c */ int Log_init(char *filename); int Log_append(char *filename); @@ -38,5 +38,4 @@ int error_summary(char *message); int Log_flush(void); int Log_set_mpi_rank(int rank, int n_mpi); int Log_parallel(char *format, ...); -int Log_debug(int value); int Debug(char *format, ...); diff --git a/source/python.c b/source/python.c index e4ab76087..0e790db90 100755 --- a/source/python.c +++ b/source/python.c @@ -306,7 +306,7 @@ should allocate the space for the spectra to avoid all this nonsense. 02feb ksl is initially set to the lifetime of the universe */ - verbosity = 4; /* Set the default verbosity to 4. To get more info raise the verbosity level to a higher number. To + verbosity = 3; /* Set the default verbosity to 3. To get more info raise the verbosity level to a higher number. To get less set the verbosity to a lower level. */ time_to_quit = 100000; // Initialise variable @@ -618,7 +618,10 @@ should allocate the space for the spectra to avoid all this nonsense. 02feb ksl /* read a variable which controls whether to save a summary of atomic data this is defined in atomic.h, rather than the modes structure */ if (modes.iadvanced) - rdint ("write_atomicdata", write_atomicdata); + rdint ("write_atomicdata", &write_atomicdata); + + if (write_atomicdata) + Log("You have opted to save a summary of the atomic data\n"); get_atomic_data (geo.atomic_filename); @@ -731,6 +734,7 @@ should allocate the space for the spectra to avoid all this nonsense. 02feb ksl if (modes.adjust_grid) { + Log("You have opted to adjust the grid scale lengths\n"); rddoub ("geo.xlog_scale", &geo.xlog_scale); if (geo.coord_type) rddoub ("geo.zlog_scale", &geo.zlog_scale); @@ -1636,10 +1640,10 @@ run -- 07jul -- ksl if (modes.iadvanced) { /* do we want debug statements to print */ - rdint ("Use_Debug_Statements(0=no,1=yes)", &modes.use_debug); + //rdint ("Use_Debug_Statements(0=no,1=yes)", &modes.use_debug); - if (modes.use_debug) - Log_debug(modes.use_debug); // communicate that we want to print debug statements + //if (modes.use_debug) + // Log_debug(modes.use_debug); // communicate that we want to print debug statements /* Do we require extra diagnostics or not */ rdint ("Extra.diagnostics(0=no,1=yes) ", &modes.diag_on_off); diff --git a/source/rdpar.c b/source/rdpar.c index bca94e9c0..82fbee0b7 100644 --- a/source/rdpar.c +++ b/source/rdpar.c @@ -734,11 +734,10 @@ int rdpar_set_verbose (vlevel) */ -int rd_extra(firstword, answer, wordlength, noptions) +int rd_extra(firstword, answer, wordlength) char firstword[]; double *answer; int *wordlength; - int *noptions; { int nwords; char secondword[LINELEN]; @@ -747,14 +746,9 @@ int rd_extra(firstword, answer, wordlength, noptions) if (fgets (line, LINELEN, rdin_ptr) == NULL) { - if (*noptions == 0) - Error("EOF: No extra options read, but extra diagnostics on!\n"); - - return(1); + return (1); // get_extra_diagnostics uses this return value } - noptions++; - nwords = sscanf (line, "%s %s", firstword, secondword); if ((ccc = index (firstword, '(')) != NULL) From 6d8b04297b49c9a64207c43b55f2e195ea905a28 Mon Sep 17 00:00:00 2001 From: jhmatthews Date: Fri, 7 Nov 2014 16:11:48 -0500 Subject: [PATCH 10/10] changed comment in python.c --- source/python.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/python.c b/source/python.c index 0e790db90..88d58643b 100755 --- a/source/python.c +++ b/source/python.c @@ -26,10 +26,10 @@ -v num determines the amount of information that is printed out. If num is small, then less information is printed out; if num is large more is printed out. Setting v to 5 causes the routine to print out all the information which outputs have - included previously. The current default is set to 4 which suppresses Log_silent + included previously. The current default is set to 3 which suppresses Debug, Log_silent and Error_silent - -d Enters debug or advanced mode. Allows one to have statements from Debug command - logged, access extra diagnostics and + -d Enters detailed or advanced mode. Allows one to access extra diagnositics and some + other advanced commands -e Alter the maximum number of errors before the program quits