Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address segmentation fault due to domain not being allocated #1059

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions source/rad_hydro_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <gsl/gsl_errno.h>


#include "atomic.h"
#include "python.h"
Expand Down Expand Up @@ -143,7 +145,7 @@ main (argc, argv)

struct photon ptest; //We need a test photon structure in order to compute t

FILE *fptr_hc, *fptr_drive, *fptr_ion, *fptr_spec, *fptr_pcon, *fptr_debug, *fptr_flux, *fptr_flux_theta, *fptr_flux_phi, *fptr_flux_r, *fopen (); /*This is the file to communicate with zeus */
FILE *fptr_hc, *fptr_drive, *fptr_ion, *fptr_spec, *fptr_pcon, *fptr_debug, *fptr_flux, *fptr_flux_theta, *fptr_flux_phi, *fptr_flux_r, *fopen (); /*This is the file to communicate with zeus */
domain = geo.hydro_domain_number;

/* Initialize MPI, which is needed because some of the routines are MPI enabled */
Expand All @@ -166,7 +168,8 @@ main (argc, argv)

/* MPI intialiazation is complete */


/* Disable GSL error handling, so we can handle errors ourselves */
gsl_set_error_handler_off ();

strcpy (parameter_file, "NONE");

Expand All @@ -181,9 +184,13 @@ main (argc, argv)
strcat (windsavefile, ".wind_save");
strcat (outputfile, ".txt");


/* Read in the wind file */

/* Allocate memory required for domain, and read in the wind file */
zdom = calloc (MAX_DOM, sizeof (domain_dummy));
if (zdom == NULL)
{
Error ("Failed to allocate memory for domain\n");
return (EXIT_FAILURE);
}
if (wind_read (windsavefile) < 0)
{
Error ("py_wind: Could not open %s", windsavefile);
Expand Down Expand Up @@ -269,7 +276,7 @@ main (argc, argv)
}
else if (zdom[domain].coord_type == RTHETA)
{
fprintf (fptr_drive, "i j rcen thetacen vol rho ne F_vis_x F_vis_y F_vis_z F_vis_mod F_UV_theta F_UV_phi F_UV_r F_UV_mod F_Xray_x F_Xray_y F_Xray_z F_Xray_mod es_f_x es_f_y es_f_z es_f_mod bf_f_x bf_f_y bf_f_z bf_f_mod\n"); //directional flux by band
fprintf (fptr_drive, "i j rcen thetacen vol rho ne F_vis_x F_vis_y F_vis_z F_vis_mod F_UV_theta F_UV_phi F_UV_r F_UV_mod F_Xray_x F_Xray_y F_Xray_z F_Xray_mod es_f_x es_f_y es_f_z es_f_mod bf_f_x bf_f_y bf_f_z bf_f_mod\n"); //directional flux by band
fprintf (fptr_flux, "i j rcen thetacen F_vis_x F_vis_y F_vis_z F_vis_mod F_UV_x F_UV_y F_UV_z F_UV_mod F_Xray_x F_Xray_y F_Xray_z F_Xray_mod\n"); //directional flux by band
}

Expand Down Expand Up @@ -305,8 +312,8 @@ main (argc, argv)
nplasma = wmain[nwind].nplasma;
wind_n_to_ij (domain, plasmamain[nplasma].nwind, &i, &j);

fprintf (fptr_flux_theta, "%3d %3d %3d %10.3e %10.3e ", i, j, wmain[nwind].inwind, wmain[nwind].xcen[0], wmain[nwind].xcen[2]); //output geometric things
fprintf (fptr_flux_phi, "%3d %3d %3d %10.3e %10.3e ", i, j, wmain[nwind].inwind, wmain[nwind].xcen[0], wmain[nwind].xcen[2]); //output geometric things
fprintf (fptr_flux_theta, "%3d %3d %3d %10.3e %10.3e ", i, j, wmain[nwind].inwind, wmain[nwind].xcen[0], wmain[nwind].xcen[2]); //output geometric things
fprintf (fptr_flux_phi, "%3d %3d %3d %10.3e %10.3e ", i, j, wmain[nwind].inwind, wmain[nwind].xcen[0], wmain[nwind].xcen[2]); //output geometric things
fprintf (fptr_flux_r, "%3d %3d %3d %10.3e %10.3e ", i, j, wmain[nwind].inwind, wmain[nwind].xcen[0], wmain[nwind].xcen[2]); //output geometric things
for (ii = 0; ii < NFLUX_ANGLES; ii++)
{
Expand Down
Loading