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

Add the runtime parameter OPT__OUTPUT_TEXT_LENGTH_INT #407

Merged
merged 12 commits into from
Jan 16, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Parameters described on this page:
[OPT__OUTPUT_TOTAL](#OPT__OUTPUT_TOTAL),  
[OPT__OUTPUT_PART](#OPT__OUTPUT_PART),  
[OPT__OUTPUT_TEXT_FORMAT_FLT](#OPT__OUTPUT_TEXT_FORMAT_FLT),  
[OPT__OUTPUT_TEXT_FORMAT_INT](#OPT__OUTPUT_TEXT_FORMAT_INT),  
[OPT__OUTPUT_USER](#OPT__OUTPUT_USER),  
[OPT__OUTPUT_PAR_MODE](#OPT__OUTPUT_PAR_MODE),  
[OPT__OUTPUT_PAR_MESH](#OPT__OUTPUT_PAR_MESH),  
Expand Down Expand Up @@ -75,6 +76,13 @@ This will affect files generated by, for example,
[OPT__OUTPUT_BASEPS](#OPT__OUTPUT_BASEPS).
* **Restriction:**

<a name="OPT__OUTPUT_TEXT_FORMAT_INT"></a>
* #### `OPT__OUTPUT_TEXT_FORMAT_INT` &ensp; (%XX.YYe) &ensp; [%24.16e]
* **Description:**
String format of integer data in output text files.
Please use the scientific notation `%XXld` such as `%12ld`.
* **Restriction:**

<a name="OPT__OUTPUT_USER"></a>
* #### `OPT__OUTPUT_USER` &ensp; (0=off, 1=on) &ensp; [0]
* **Description:**
Expand Down
1 change: 1 addition & 0 deletions example/test_problem/Template/Input__Parameter
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ SPEC_INT_GHOST_BOUNDARY 4 # ghost boundary size for spectral int
OPT__OUTPUT_TOTAL 1 # output the simulation snapshot: (0=off, 1=HDF5, 2=C-binary) [1]
OPT__OUTPUT_PART 0 # output a single line or slice: (0=off, 1=xy, 2=yz, 3=xz, 4=x, 5=y, 6=z, 7=diag) [0]
OPT__OUTPUT_TEXT_FORMAT_FLT %24.16e # string format of output text files [%24.16e]
OPT__OUTPUT_TEXT_FORMAT_INT %12ld # string format of output text files [%12ld]
OPT__OUTPUT_USER 0 # output the user-specified data -> edit "Output_User.cpp" [0]
OPT__OUTPUT_PAR_MODE 0 # output the particle data: (0=off, 1=text-file, 2=C-binary) [0] ##PARTICLE ONLY##
OPT__OUTPUT_PAR_MESH 1 # output the attributes of tracer particles mapped from mesh quantities -> edit "Input__Par_Mesh" [1] ##PARTICLE ONLY##
Expand Down
6 changes: 3 additions & 3 deletions include/Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ extern long FixUpVar_Flux, FixUpVar_Restrict;
extern int PassiveNorm_NVar, PassiveNorm_VarIdx[NCOMP_PASSIVE];
extern int PassiveIntFrac_NVar, PassiveIntFrac_VarIdx[NCOMP_PASSIVE];

extern int StrLen_Flt;
extern char BlankPlusFormat_Flt[MAX_STRING+1];
extern int StrLen_Flt, StrLen_Int;
extern char BlankPlusFormat_Flt[MAX_STRING+1], BlankPlusFormat_Int[MAX_STRING+1];

extern double BOX_SIZE, DT__MAX, DT__FLUID, DT__FLUID_INIT, END_T, OUTPUT_DT, OUTPUT_WALLTIME, DT__SYNC_PARENT_LV, DT__SYNC_CHILDREN_LV;
extern long int END_STEP;
Expand All @@ -78,7 +78,7 @@ extern bool OPT__CK_CONSERVATION, OPT__RESET_FLUID, OPT__FREEZE_FLUID, OPT
extern bool OPT__OPTIMIZE_AGGRESSIVE, OPT__INIT_GRID_WITH_OMP, OPT__NO_FLAG_NEAR_BOUNDARY;
extern bool OPT__RECORD_NOTE, OPT__RECORD_UNPHY, INT_OPP_SIGN_0TH_ORDER;
extern bool OPT__INT_FRAC_PASSIVE_LR, OPT__CK_INPUT_FLUID, OPT__SORT_PATCH_BY_LBIDX;
extern char OPT__OUTPUT_TEXT_FORMAT_FLT[MAX_STRING];
extern char OPT__OUTPUT_TEXT_FORMAT_FLT[MAX_STRING], OPT__OUTPUT_TEXT_FORMAT_INT[MAX_STRING];
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;
Expand Down
1 change: 1 addition & 0 deletions include/HDF5_Typedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,7 @@ struct InputPara_t
int Opt__Output_Step;
double Opt__Output_Dt;
char *Opt__Output_Text_Format_Flt;
char *Opt__Output_Text_Format_Int;
double Output_PartX;
double Output_PartY;
double Output_PartZ;
Expand Down
4 changes: 4 additions & 0 deletions src/Auxiliary/Aux_Check_Parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ void Aux_Check_Parameter()
Aux_Message( stderr, "WARNING : StrLen_Flt (%d) <= 0 (OPT__OUTPUT_TEXT_FORMAT_FLT=%s) --> text output might be misaligned !!\n",
StrLen_Flt, OPT__OUTPUT_TEXT_FORMAT_FLT );

if ( StrLen_Int <= 0 )
Aux_Message( stderr, "WARNING : StrLen_Int (%d) <= 0 (OPT__OUTPUT_TEXT_FORMAT_INT=%s) --> text output might be misaligned !!\n",
StrLen_Int, OPT__OUTPUT_TEXT_FORMAT_INT );

if ( OPT__CK_REFINE )
Aux_Message( stderr, "WARNING : \"%s\" check may fail due to the proper-nesting constraint !!\n",
"OPT__CK_REFINE" );
Expand Down
1 change: 1 addition & 0 deletions src/Auxiliary/Aux_TakeNote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,7 @@ void Aux_TakeNote()
fprintf( Note, "OPT__OUTPUT_PART % d\n", OPT__OUTPUT_PART );
fprintf( Note, "OPT__OUTPUT_USER % d\n", OPT__OUTPUT_USER );
fprintf( Note, "OPT__OUTPUT_TEXT_FORMAT_FLT %s\n", OPT__OUTPUT_TEXT_FORMAT_FLT );
fprintf( Note, "OPT__OUTPUT_TEXT_FORMAT_INT %s\n", OPT__OUTPUT_TEXT_FORMAT_INT );
# ifdef PARTICLE
fprintf( Note, "OPT__OUTPUT_PAR_MODE % d\n", OPT__OUTPUT_PAR_MODE );
# ifdef TRACER
Expand Down
1 change: 1 addition & 0 deletions src/Init/Init_Load_Parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ void Init_Load_Parameter()
ReadPara->Add( "OPT__OUTPUT_PART", &OPT__OUTPUT_PART, 0, 0, 7 );
ReadPara->Add( "OPT__OUTPUT_USER", &OPT__OUTPUT_USER, false, Useless_bool, Useless_bool );
ReadPara->Add( "OPT__OUTPUT_TEXT_FORMAT_FLT", OPT__OUTPUT_TEXT_FORMAT_FLT, "%24.16e", Useless_str, Useless_str );
ReadPara->Add( "OPT__OUTPUT_TEXT_FORMAT_INT", OPT__OUTPUT_TEXT_FORMAT_INT, "%12ld", Useless_str, Useless_str );
# ifdef PARTICLE
ReadPara->Add( "OPT__OUTPUT_PAR_MODE", &OPT__OUTPUT_PAR_MODE, 0, 0, 2 );
# ifdef TRACER
Expand Down
7 changes: 7 additions & 0 deletions src/Init/Init_ResetParameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,13 @@ void Init_ResetParameter()
StrLen_Flt = MAX( abs(atoi(OPT__OUTPUT_TEXT_FORMAT_FLT+1)), abs(atoi(OPT__OUTPUT_TEXT_FORMAT_FLT+2)) );
sprintf( BlankPlusFormat_Flt, " %s", OPT__OUTPUT_TEXT_FORMAT_FLT );

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

StrLen_Int = MAX( abs(atoi(OPT__OUTPUT_TEXT_FORMAT_INT+1)), abs(atoi(OPT__OUTPUT_TEXT_FORMAT_INT+2)) );
sprintf( BlankPlusFormat_Int, " %s", OPT__OUTPUT_TEXT_FORMAT_INT );


// ELBDM parameters
# if ( MODEL == ELBDM )
Expand Down
6 changes: 3 additions & 3 deletions src/Main/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ int *UM_IC_RefineRegion = NULL;
long FixUpVar_Flux, FixUpVar_Restrict;
int PassiveNorm_NVar, PassiveNorm_VarIdx[NCOMP_PASSIVE];
int PassiveIntFrac_NVar, PassiveIntFrac_VarIdx[NCOMP_PASSIVE];
int StrLen_Flt;
char BlankPlusFormat_Flt[MAX_STRING+1];
int StrLen_Flt, StrLen_Int;
char BlankPlusFormat_Flt[MAX_STRING+1], BlankPlusFormat_Int[MAX_STRING+1];

int MPI_Rank, MPI_Rank_X[3], MPI_SibRank[26], NX0[3], NPatchTotal[NLEVEL];
int *BaseP = NULL;
Expand Down Expand Up @@ -70,7 +70,7 @@ bool OPT__CK_CONSERVATION, OPT__RESET_FLUID, OPT__FREEZE_FLUID,
bool OPT__OPTIMIZE_AGGRESSIVE, OPT__INIT_GRID_WITH_OMP, OPT__NO_FLAG_NEAR_BOUNDARY;
bool OPT__RECORD_NOTE, OPT__RECORD_UNPHY, INT_OPP_SIGN_0TH_ORDER;
bool OPT__INT_FRAC_PASSIVE_LR, OPT__CK_INPUT_FLUID, OPT__SORT_PATCH_BY_LBIDX;
char OPT__OUTPUT_TEXT_FORMAT_FLT[MAX_STRING];
char OPT__OUTPUT_TEXT_FORMAT_FLT[MAX_STRING], OPT__OUTPUT_TEXT_FORMAT_INT[MAX_STRING];
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;
Expand Down
7 changes: 5 additions & 2 deletions src/Output/Output_DumpData_Total_HDF5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Procedure for outputting new variables:


//-------------------------------------------------------------------------------------------------------
// Function : Output_DumpData_Total_HDF5 (FormatVersion = 2480)
// Function : Output_DumpData_Total_HDF5 (FormatVersion = 2481)
// Description : Output all simulation data in the HDF5 format, which can be used as a restart file
// or loaded by YT
//
Expand Down Expand Up @@ -260,6 +260,7 @@ Procedure for outputting new variables:
// output DENS and PHAS for the hybrid scheme (discard STUB)
// output use_wave_flag[lv] for the hybrid scheme
// 2480 : 2024/07/17 --> output OPT__OUTPUT_PAR_MESH and particle attributes mapped from mesh quantities
// 2481 : 2025/01/08 --> output OPT__OUTPUT_TEXT_FORMAT_INT
//-------------------------------------------------------------------------------------------------------
void Output_DumpData_Total_HDF5( const char *FileName )
{
Expand Down Expand Up @@ -1553,7 +1554,7 @@ void FillIn_KeyInfo( KeyInfo_t &KeyInfo, const int NFieldStored )

const time_t CalTime = time( NULL ); // calendar time

KeyInfo.FormatVersion = 2480;
KeyInfo.FormatVersion = 2481;
KeyInfo.Model = MODEL;
KeyInfo.NLevel = NLEVEL;
KeyInfo.NCompFluid = NCOMP_FLUID;
Expand Down Expand Up @@ -2697,6 +2698,7 @@ void FillIn_InputPara( InputPara_t &InputPara, const int NFieldStored, char Fiel
InputPara.Opt__Output_Step = OUTPUT_STEP;
InputPara.Opt__Output_Dt = OUTPUT_DT;
InputPara.Opt__Output_Text_Format_Flt = OPT__OUTPUT_TEXT_FORMAT_FLT;
InputPara.Opt__Output_Text_Format_Int = OPT__OUTPUT_TEXT_FORMAT_INT;
InputPara.Output_PartX = OUTPUT_PART_X;
InputPara.Output_PartY = OUTPUT_PART_Y;
InputPara.Output_PartZ = OUTPUT_PART_Z;
Expand Down Expand Up @@ -3710,6 +3712,7 @@ void GetCompound_InputPara( hid_t &H5_TypeID, const int NFieldStored )
H5Tinsert( H5_TypeID, "Opt__Output_Step", HOFFSET(InputPara_t,Opt__Output_Step ), H5T_NATIVE_INT );
H5Tinsert( H5_TypeID, "Opt__Output_Dt", HOFFSET(InputPara_t,Opt__Output_Dt ), H5T_NATIVE_DOUBLE );
H5Tinsert( H5_TypeID, "Opt__Output_Text_Format_Flt", HOFFSET(InputPara_t,Opt__Output_Text_Format_Flt), H5_TypeID_VarStr );
H5Tinsert( H5_TypeID, "Opt__Output_Text_Format_Int", HOFFSET(InputPara_t,Opt__Output_Text_Format_Int), H5_TypeID_VarStr );
H5Tinsert( H5_TypeID, "Output_PartX", HOFFSET(InputPara_t,Output_PartX ), H5T_NATIVE_DOUBLE );
H5Tinsert( H5_TypeID, "Output_PartY", HOFFSET(InputPara_t,Output_PartY ), H5T_NATIVE_DOUBLE );
H5Tinsert( H5_TypeID, "Output_PartZ", HOFFSET(InputPara_t,Output_PartZ ), H5T_NATIVE_DOUBLE );
Expand Down