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

[Bugfix] Fix #425 #430

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion doc/wiki/Adding-Parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ Mandatory steps are marked by 📌.

1. 📌 Add new global variables to both `src/GAMER/Main.cpp` and `include/Global.h`

2. 📌 Edit `src/Init/Init_Load_Parameter.cpp` to load new parameters
> [!IMPORTANT]
> The length of the string variable must be `MAX_STRING`.

2. 📌 Edit `src/Init/Init_Load_Parameter.cpp` to load new parameters

3. Add notes in `src/Auxiliary/Aux_TakeNote.cpp` [optional but recommended]

Expand Down
2 changes: 1 addition & 1 deletion include/Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ extern int OPT__UM_IC_FLOAT8;
extern double COM_CEN_X, COM_CEN_Y, COM_CEN_Z, COM_MAX_R, COM_MIN_RHO, COM_TOLERR_R;
extern int COM_MAX_ITER;
extern double ANGMOM_ORIGIN_X, ANGMOM_ORIGIN_Y, ANGMOM_ORIGIN_Z;
extern char OUTPUT_DIR[MAX_STRING-100];
extern char OUTPUT_DIR[MAX_STRING];
extern double FLAG_ANGULAR_CEN_X, FLAG_ANGULAR_CEN_Y, FLAG_ANGULAR_CEN_Z;
extern double FLAG_RADIAL_CEN_X, FLAG_RADIAL_CEN_Y, FLAG_RADIAL_CEN_Z;

Expand Down
2 changes: 1 addition & 1 deletion src/Auxiliary/Aux_Check_Conservation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void Aux_Check_Conservation( const char *comment )
{

static bool FirstTime = true;
char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__Conservation", OUTPUT_DIR );


Expand Down
6 changes: 3 additions & 3 deletions src/Auxiliary/Aux_Check_Parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,9 @@ void Aux_Check_Parameter()
# endif // #if ( MODEL == HYDRO )


if ( strlen(OUTPUT_DIR) > MAX_STRING-100-1 )
Aux_Error( ERROR_INFO, "Length of OUTPUT_DIR (%d) should be smaller than MAX_STRING-100-1 (%d) !!\n",
strlen(OUTPUT_DIR), MAX_STRING-100-1 );
if ( strlen(OUTPUT_DIR) > MAX_STRING-1 )
Aux_Error( ERROR_INFO, "Length of OUTPUT_DIR (%d) should be smaller than MAX_STRING-1 (%d) !!\n",
strlen(OUTPUT_DIR), MAX_STRING-1 );

if ( ! Aux_CheckFolderExist( OUTPUT_DIR ) )
Aux_Error( ERROR_INFO, "\"%s\" folder set by OUTPUT_DIR does not exist !!\n", OUTPUT_DIR );
Expand Down
2 changes: 1 addition & 1 deletion src/Auxiliary/Aux_GetMemInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void Aux_GetMemInfo()
const int NInfo = 4; // number of memory information to be recorded (VmSize/Peak, VmRSS/HWM)

static bool FirstTime=true;
char FileName_Record[MAX_STRING], FileName_Status[MAX_STRING], Useless[NInfo][MAX_STRING], *line=NULL;
char FileName_Record[2*MAX_STRING], FileName_Status[MAX_STRING], Useless[NInfo][MAX_STRING], *line=NULL;
char VmSize[MAX_STRING], VmPeak[MAX_STRING], VmRSS[MAX_STRING], VmHWM[MAX_STRING];
bool GetVmSize=false, GetVmPeak=false, GetVmRSS=false, GetVmHWM=false;
double Vm_double[NInfo], Vm_max[NInfo], Vm_sum[NInfo];
Expand Down
2 changes: 1 addition & 1 deletion src/Auxiliary/Aux_Record_Center.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void Aux_Record_Center()
{

static bool FirstTime = true;
char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__Center", OUTPUT_DIR );


Expand Down
2 changes: 1 addition & 1 deletion src/Auxiliary/Aux_Record_CorrUnphy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void Aux_Record_CorrUnphy()
{

static bool FirstTime = true;
char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__NCorrUnphy", OUTPUT_DIR );

long NCorrAllRank[NLEVEL];
Expand Down
2 changes: 1 addition & 1 deletion src/Auxiliary/Aux_Record_PatchCount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
void Aux_Record_PatchCount()
{

char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__PatchCount", OUTPUT_DIR );

static bool FirstTime = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Auxiliary/Aux_Record_Performance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void Aux_Record_Performance( const double ElapsedTime )
{

static bool FirstTime = true;
char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__Performance", OUTPUT_DIR );


Expand Down
2 changes: 1 addition & 1 deletion src/Auxiliary/Aux_Record_User.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void Aux_Record_User_Template()
{

static bool FirstTime = true;
char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__User", OUTPUT_DIR );

if ( FirstTime )
Expand Down
4 changes: 2 additions & 2 deletions src/Auxiliary/Aux_TakeNote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void Aux_TakeNote()


FILE *Note;
char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__Note", OUTPUT_DIR );


Expand All @@ -38,7 +38,7 @@ void Aux_TakeNote()
fprintf( Note, "***********************************************************************************\n" );
fclose( Note );

char Command[MAX_STRING];
char Command[2*MAX_STRING];
sprintf( Command, "cat ./Input__Note >> %s/Record__Note", OUTPUT_DIR );
system( Command );

Expand Down
4 changes: 2 additions & 2 deletions src/Auxiliary/Aux_Timing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void Aux_Record_Timing()
{

FILE *File = NULL;
char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__Timing", OUTPUT_DIR );

const char Comment_LB[][4] = { "Max", "Min", "Ave" };
Expand Down Expand Up @@ -988,7 +988,7 @@ void Aux_AccumulatedTiming( const double TotalT, double InitT, double OtherT )

const char Comment_LB[][4] = { "Max", "Min", "Ave" };
const int NNewTimer = 2;
char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__Timing", OUTPUT_DIR );

double dt_P, Flu_P, Gra_P, Src_P, Che_P, SF_P, FB_P, FixUp_P, Flag_P, Refine_P, Sum_P, MPI_Grid_P;
Expand Down
2 changes: 1 addition & 1 deletion src/Fluid/Flu_Close.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ void CorrectUnphysical( const int lv, const int NPG, const int *PID0_List,
const bool CheckMinPres_No = false;
real In[NCOMP_TOTAL], tmp[NCOMP_TOTAL];

char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/FailedPatchGroup_r%03d_lv%02d_PID0-%05d", OUTPUT_DIR, MPI_Rank, lv, PID0_List[TID] );

// use "a" instead of "w" since there may be more than one failed cell in a given patch group
Expand Down
2 changes: 1 addition & 1 deletion src/GPU_API/CUAPI_DiagnoseDevice.cu
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void CUAPI_DiagnoseDevice()


// record the device properties
char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__Note", OUTPUT_DIR );

if ( MPI_Rank == 0 )
Expand Down
2 changes: 1 addition & 1 deletion src/LoadBalance/LB_EstimateLoadImbalance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ double LB_EstimateLoadImbalance()
if ( OPT__RECORD_LOAD_BALANCE )
{
static bool FirstTime = true;
char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__LoadBalance", OUTPUT_DIR );

if ( FirstTime )
Expand Down
2 changes: 1 addition & 1 deletion src/LoadBalance/LB_GetBufferData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1639,7 +1639,7 @@ void LB_GetBufferData( const int lv, const int FluSg, const int MagSg, const int
# ifdef TIMING
if ( OPT__TIMING_MPI )
{
char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__TimingMPI_Rank%05d", OUTPUT_DIR, MPI_Rank );

char ModeName[100];
Expand Down
4 changes: 2 additions & 2 deletions src/Main/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int OPT__UM_IC_FLOAT8;
double COM_CEN_X, COM_CEN_Y, COM_CEN_Z, COM_MAX_R, COM_MIN_RHO, COM_TOLERR_R;
int COM_MAX_ITER;
double ANGMOM_ORIGIN_X, ANGMOM_ORIGIN_Y, ANGMOM_ORIGIN_Z;
char OUTPUT_DIR[MAX_STRING-100];
char OUTPUT_DIR[MAX_STRING];
double FLAG_ANGULAR_CEN_X, FLAG_ANGULAR_CEN_Y, FLAG_ANGULAR_CEN_Z;
double FLAG_RADIAL_CEN_X, FLAG_RADIAL_CEN_Y, FLAG_RADIAL_CEN_Z;

Expand Down Expand Up @@ -856,7 +856,7 @@ int main( int argc, char *argv[] )

if ( MPI_Rank == 0 && OPT__RECORD_NOTE )
{
char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__Note", OUTPUT_DIR );

FILE *Note = fopen( FileName, "a" );
Expand Down
2 changes: 1 addition & 1 deletion src/Miscellaneous/Mis_GetTimeStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ double Mis_GetTimeStep( const int lv, const double dTime_SyncFaLv, const double

static bool FirstTime = true;
const int NdTimeMax = 20;
char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__TimeStep", OUTPUT_DIR );

char (*dTime_Name)[MAX_STRING] = new char [NdTimeMax][MAX_STRING];
Expand Down
2 changes: 1 addition & 1 deletion src/Model_ELBDM/ELBDM_Aux_Record_Hybrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void ELBDM_Aux_Record_Hybrid()


static bool FirstTime = true;
char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__Hybrid", OUTPUT_DIR );
FILE *File = NULL;

Expand Down
2 changes: 1 addition & 1 deletion src/Model_Hydro/MHD_Aux_Check_DivergenceB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void MHD_Aux_Check_DivergenceB( const bool Verbose, const char *comment )
if ( MPI_Rank == 0 )
{
static bool FirstTime = true;
char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__DivB", OUTPUT_DIR );

// output header
Expand Down
2 changes: 1 addition & 1 deletion src/Output/Output_BoundaryFlagList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void Output_BoundaryFlagList( const int option, const int lv, const char *commen
Aux_Error( ERROR_INFO, "incorrect parameter %s = %d !!\n", "option", option );


char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
if ( option ) sprintf( FileName, "%s/BoundaryFlagList_%d_%d", OUTPUT_DIR, MPI_Rank, lv );
else sprintf( FileName, "%s/BufferFlagList_%d_%d", OUTPUT_DIR, MPI_Rank, lv );

Expand Down
6 changes: 3 additions & 3 deletions src/Output/Output_DumpData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ void Output_DumpData( const int Stage )


// set the file names for all output functions
char FileName_Total[MAX_STRING], FileName_Part[MAX_STRING], FileName_Temp[MAX_STRING], FileName_PS[MAX_STRING];
char FileName_Total[2*MAX_STRING], FileName_Part[2*MAX_STRING], FileName_Temp[2*MAX_STRING], FileName_PS[2*MAX_STRING];
# ifdef PARTICLE
char FileName_Particle[MAX_STRING];
char FileName_Particle[2*MAX_STRING];
# endif

if ( OPT__OUTPUT_TOTAL )
Expand Down Expand Up @@ -318,7 +318,7 @@ void Output_DumpData( const int Stage )
void Write_DumpRecord()
{

char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__Dump", OUTPUT_DIR );


Expand Down
2 changes: 1 addition & 1 deletion src/Output/Output_ExchangeDataPatchList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void Output_ExchangeDataPatchList( const int option, const int lv, const char *c
Aux_Error( ERROR_INFO, "incorrect parameter %s = %d !!\n", "option", option );


char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
if ( option ) sprintf( FileName, "%s/SendDataPatchList_%d_%d", OUTPUT_DIR, MPI_Rank, lv );
else sprintf( FileName, "%s/RecvDataPatchList_%d_%d", OUTPUT_DIR, MPI_Rank, lv );

Expand Down
2 changes: 1 addition & 1 deletion src/Output/Output_ExchangeFluxPatchList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void Output_ExchangeFluxPatchList( const int option, const int lv, const char *c
Aux_Error( ERROR_INFO, "incorrect parameter %s = %d !!\n", "lv", lv );


char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
switch ( option )
{
case 0: sprintf( FileName, "%s/SendFluxPatchList_%d_%d", OUTPUT_DIR, MPI_Rank, lv );
Expand Down
2 changes: 1 addition & 1 deletion src/Output/Output_ExchangePatchMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void Output_ExchangePatchMap( const int lv, const int xyz, const char *comment )
}


char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/ExchangePatchMap_%d_%d_%2s", OUTPUT_DIR, MPI_Rank, lv, Dim[1] );
if ( comment != NULL )
{
Expand Down
2 changes: 1 addition & 1 deletion src/Output/Output_FlagMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void Output_FlagMap( const int lv, const int xyz, const char *comment )
}


char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/FlagMap_%d_%d_%2s", OUTPUT_DIR, MPI_Rank, lv, Dim[1] );
if ( comment != NULL )
{
Expand Down
2 changes: 1 addition & 1 deletion src/Output/Output_Flux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void Output_Flux( const int lv, const int PID, const int Sib, const char *commen

patch_t *Relation = amr->patch[0][lv][PID];

char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Flux_r%d_lv%d_p%d%c%c", OUTPUT_DIR, MPI_Rank, lv, PID, 45-2*(Sib%2), 120+Sib/2 );
if ( comment != NULL )
{
Expand Down
4 changes: 2 additions & 2 deletions src/Output/Output_L1Error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void Output_L1Error( void (*AnalFunc_Flu)( real fluid[], const double x, const d


// output filename
char FileName[NERR][MAX_STRING];
char FileName[NERR][2*MAX_STRING];

# if ( MODEL == HYDRO )
sprintf( FileName[ 0], "%s/%s_Dens_%06d", OUTPUT_DIR, Prefix, DumpID );
Expand Down Expand Up @@ -276,7 +276,7 @@ void Output_L1Error( void (*AnalFunc_Flu)( real fluid[], const double x, const d

for (int v=0; v<NERR; v++) L1_Err_Sum[v] /= Norm;

char FileName_L1[MAX_STRING];
char FileName_L1[2*MAX_STRING];
sprintf( FileName_L1, "%s/Record__L1Err", OUTPUT_DIR );
FILE *File_L1 = fopen( FileName_L1, "a" );

Expand Down
2 changes: 1 addition & 1 deletion src/Output/Output_Patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void Output_Patch( const int lv, const int PID, const int FluSg, const int MagSg
real (*pot)[PS1][PS1] = amr->patch[PotSg][lv][PID]->pot;
# endif

char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Patch_r%d_lv%d_p%d", OUTPUT_DIR, MPI_Rank, lv, PID );
if ( comment != NULL )
{
Expand Down
2 changes: 1 addition & 1 deletion src/Output/Output_PatchCorner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
void Output_PatchCorner( const int lv, const char *comment )
{

char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/PatchCorner_%05d_%02d", OUTPUT_DIR, MPI_Rank, lv );
if ( comment != NULL )
{
Expand Down
2 changes: 1 addition & 1 deletion src/Output/Output_PatchMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void Output_PatchMap( const int lv, const int PID, const int TSg, const int Comp
patch_t *Relation = amr->patch[ 0][lv][PID];
patch_t *Data = amr->patch[TSg][lv][PID];

char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/PatchMap_r%d_lv%d_p%d_v%d", OUTPUT_DIR, MPI_Rank, lv, PID, Comp );
if ( comment != NULL )
{
Expand Down
2 changes: 1 addition & 1 deletion src/Output/Output_PreparedPatch_Fluid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void Output_PreparedPatch_Fluid( const int TLv, const int TPID,
// begin to output the prepared data
patch_t *Relation = amr->patch[0][TLv][TPID];

char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/PrePatch_Fluid_r%d_lv%d_p%d", OUTPUT_DIR, MPI_Rank, TLv, TPID );
if ( comment != NULL )
{
Expand Down
2 changes: 1 addition & 1 deletion src/Particle/LoadBalance/Par_LB_SendParticleData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void Par_LB_SendParticleData( const int NParAttFlt, const int NParAttInt, int *S
dtime = Timer->GetValue() - time0;

// output to the same log file as LB_GetBufferData
char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__TimingMPI_Rank%05d", OUTPUT_DIR, MPI_Rank );

FILE *File = fopen( FileName, "a" );
Expand Down
2 changes: 1 addition & 1 deletion src/Particle/Par_Aux_Record_ParticleCount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void Par_Aux_Record_ParticleCount()
{

static bool FirstTime = true;
char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__ParticleCount", OUTPUT_DIR );

if ( MPI_Rank == 0 && FirstTime )
Expand Down
2 changes: 1 addition & 1 deletion src/TestProblem/Hydro/Bondi/Record_Bondi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extern int Bondi_SinkNCell;
void Record_Bondi()
{

char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__BondiAccretionRate", OUTPUT_DIR );

static bool FirstTime = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ void Aux_Record_Gravity()
if ( MPI_Rank == 0 )
{
// header
char FileName[MAX_STRING];
char FileName[2*MAX_STRING];
sprintf( FileName, "%s/Record__PoissonPerformance", OUTPUT_DIR );

if ( !Aux_CheckFileExist(FileName) )
Expand Down