Skip to content

Commit

Permalink
Merge pull request gamer-project#407 from ChunYen-Chen/int_format
Browse files Browse the repository at this point in the history
Add the runtime parameter `OPT__OUTPUT_TEXT_LENGTH_INT`
  • Loading branch information
hyschive authored Jan 16, 2025
2 parents 96c76f4 + c4de6bc commit 40891ef
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ For variables with `Default/Min/Max` labeled as `Depend`, click the parameter na
| [[ OPT__OUTPUT_PRES \| Runtime-Parameters:-Outputs#OPT__OUTPUT_PRES ]] | 0 | None | None | output gas pressure [0] ##HYDRO ONLY## |
| [[ OPT__OUTPUT_RESTART \| Runtime-Parameters:-Outputs#OPT__OUTPUT_RESTART ]] | 0 | None | None | output data immediately after restart [0] |
| [[ OPT__OUTPUT_TEMP \| Runtime-Parameters:-Outputs#OPT__OUTPUT_TEMP ]] | OutTempDefault | None | None | output gas temperature [0 (HD) or 1 (SRHD)] ##HYDRO ONLY## |
| [[ OPT__OUTPUT_TEXT_FORMAT_FLT \| Runtime-Parameters:-Outputs#OPT__OUTPUT_TEXT_FORMAT_FLT ]] | "%24.16e" | None | None | string format of output text files [%24.16e] |
| [[ OPT__OUTPUT_TEXT_FORMAT_FLT \| Runtime-Parameters:-Outputs#OPT__OUTPUT_TEXT_FORMAT_FLT ]] | "%24.16e" | None | None | string format of floating-point variables in output text files [%24.16e] |
| [[ OPT__OUTPUT_TEXT_LENGTH_INT \| Runtime-Parameters:-Outputs#OPT__OUTPUT_TEXT_LENGTH_INT ]] | 12 | 0 | None | string length of integer variables in output text files [12] |
| [[ OPT__OUTPUT_TOTAL \| Runtime-Parameters:-Outputs#OPT__OUTPUT_TOTAL ]] | 1 | 0 | 2 | output the simulation snapshot: (0=off, 1=HDF5, 2=C-binary) [1] |
| [[ OPT__OUTPUT_USER \| Runtime-Parameters:-Outputs#OPT__OUTPUT_USER ]] | 0 | None | None | output the user-specified data -> edit "Output_User.cpp" [0] |
| [[ OPT__OUTPUT_USER_FIELD \| Runtime-Parameters:-Outputs#OPT__OUTPUT_USER_FIELD ]] | 0 | None | None | output user-defined derived fields [0] -> edit "Flu_DerivedField_User.cpp" |
Expand Down
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_LENGTH_INT](#OPT__OUTPUT_TEXT_LENGTH_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,12 @@ This will affect files generated by, for example,
[OPT__OUTPUT_BASEPS](#OPT__OUTPUT_BASEPS).
* **Restriction:**

<a name="OPT__OUTPUT_TEXT_LENGTH_INT"></a>
* #### `OPT__OUTPUT_TEXT_LENGTH_INT` &ensp; (&#8805;0) &ensp; [12]
* **Description:**
String length of integer data in output text files.
* **Restriction:**

<a name="OPT__OUTPUT_USER"></a>
* #### `OPT__OUTPUT_USER` &ensp; (0=off, 1=on) &ensp; [0]
* **Description:**
Expand Down
2 changes: 1 addition & 1 deletion example/test_problem/ELBDM/DiskHeating/Input__Parameter
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ SPEC_INT_GHOST_BOUNDARY 4 # ghost boundary size for spectral int
# data dump
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_FLT %24.16e # string format of floating-point variables in output text files [%24.16e]
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_BASEPS 0 # output the base-level power spectrum [0]
Expand Down
3 changes: 2 additions & 1 deletion example/test_problem/Template/Input__Parameter
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ SPEC_INT_GHOST_BOUNDARY 4 # ghost boundary size for spectral int
# data dump
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_FLT %24.16e # string format of floating-point variables in output text files [%24.16e]
OPT__OUTPUT_TEXT_LENGTH_INT 12 # string length of integer variables in output text files [12]
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
1 change: 1 addition & 0 deletions include/Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ extern bool OPT__OPTIMIZE_AGGRESSIVE, OPT__INIT_GRID_WITH_OMP, OPT__NO_FLA
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 int OPT__OUTPUT_TEXT_LENGTH_INT;
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 @@ -831,6 +831,7 @@ struct InputPara_t
int Opt__Output_Step;
double Opt__Output_Dt;
char *Opt__Output_Text_Format_Flt;
int Opt__Output_Text_Length_Int;
double Output_PartX;
double Output_PartY;
double Output_PartZ;
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 @@ -1582,6 +1582,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_LENGTH_INT % d\n", OPT__OUTPUT_TEXT_LENGTH_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_ByRestart_HDF5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2357,6 +2357,7 @@ void Check_InputPara( const char *FileName, const int FormatVersion )
LoadField( "Opt__Output_Step", &RS.Opt__Output_Step, SID, TID, NonFatal, &RT.Opt__Output_Step, 1, NonFatal );
LoadField( "Opt__Output_Dt", &RS.Opt__Output_Dt, SID, TID, NonFatal, &RT.Opt__Output_Dt, 1, NonFatal );
LoadField( "Opt__Output_Text_Format_Flt", &RS.Opt__Output_Text_Format_Flt, SID, TID, NonFatal, RT.Opt__Output_Text_Format_Flt, 1, NonFatal );
LoadField( "Opt__Output_Text_Length_Int", &RS.Opt__Output_Text_Length_Int, SID, TID, NonFatal, &RT.Opt__Output_Text_Length_Int, 1, NonFatal );
}
if ( OPT__OUTPUT_PART ) {
LoadField( "Output_PartX", &RS.Output_PartX, SID, TID, NonFatal, &RT.Output_PartX, 1, NonFatal );
Expand Down
3 changes: 2 additions & 1 deletion src/Init/Init_Load_Parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,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_LENGTH_INT",&OPT__OUTPUT_TEXT_LENGTH_INT, 12, 0, NoMax_int );
# ifdef PARTICLE
ReadPara->Add( "OPT__OUTPUT_PAR_MODE", &OPT__OUTPUT_PAR_MODE, 0, 0, 2 );
# ifdef TRACER
Expand All @@ -517,7 +518,7 @@ void Init_Load_Parameter()
ReadPara->Add( "OPT__OUTPUT_CC_MAG", &OPT__OUTPUT_CC_MAG, true, Useless_bool, Useless_bool );
# endif
# ifdef GRAVITY
ReadPara->Add( "OPT__OUTPUT_POT", &OPT__OUTPUT_POT, true, Useless_bool, Useless_bool );
ReadPara->Add( "OPT__OUTPUT_POT", &OPT__OUTPUT_POT, true, Useless_bool, Useless_bool );
# endif
# ifdef PARTICLE
ReadPara->Add( "OPT__OUTPUT_PAR_DENS", &OPT__OUTPUT_PAR_DENS, PAR_OUTPUT_DENS_PAR_ONLY, 0, 2 );
Expand Down
1 change: 1 addition & 0 deletions src/Main/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ bool OPT__OPTIMIZE_AGGRESSIVE, OPT__INIT_GRID_WITH_OMP, OPT__NO_
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];
int OPT__OUTPUT_TEXT_LENGTH_INT;
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 = 2500)
// Function : Output_DumpData_Total_HDF5 (FormatVersion = 2501)
// 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 @@ -263,6 +263,7 @@ Procedure for outputting new variables:
// 2481 : 2024/12/11 --> output OPT__FLAG_ANGULAR, FlagTable_Angular, FLAG_ANGULAR_CEN_X, FLAG_ANGULAR_CEN_Y, FLAG_ANGULAR_CEN_Z
// OPT__FLAG_RADIAL, FlagTable_Radial, FLAG_RADIAL_CEN_X, FLAG_RADIAL_CEN_Y, FLAG_RADIAL_CEN_Z
// 2500 : 2024/07/01 --> output particle integer attributes
// 2501 : 2025/01/15 --> output OPT__OUTPUT_TEXT_LENGTH_INT
//-------------------------------------------------------------------------------------------------------
void Output_DumpData_Total_HDF5( const char *FileName )
{
Expand Down Expand Up @@ -1598,7 +1599,7 @@ void FillIn_KeyInfo( KeyInfo_t &KeyInfo, const int NFieldStored )

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

KeyInfo.FormatVersion = 2500;
KeyInfo.FormatVersion = 2501;
KeyInfo.Model = MODEL;
KeyInfo.NLevel = NLEVEL;
KeyInfo.NCompFluid = NCOMP_FLUID;
Expand Down Expand Up @@ -2767,6 +2768,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_Length_Int = OPT__OUTPUT_TEXT_LENGTH_INT;
InputPara.Output_PartX = OUTPUT_PART_X;
InputPara.Output_PartY = OUTPUT_PART_Y;
InputPara.Output_PartZ = OUTPUT_PART_Z;
Expand Down Expand Up @@ -3808,6 +3810,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_Length_Int", HOFFSET(InputPara_t,Opt__Output_Text_Length_Int), H5T_NATIVE_INT );
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
8 changes: 2 additions & 6 deletions src/Particle/Par_Output_TextFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void Par_Output_TextFile( const char *FileName )
fprintf( File, " %*s", (v==0)?StrLen_Flt-1:StrLen_Flt, ParAttFltLabel[v] );

for (int v=0; v<PAR_NATT_INT_TOTAL; v++)
fprintf( File, " %*s", StrLen_Flt, ParAttIntLabel[v] );
fprintf( File, " %*s", OPT__OUTPUT_TEXT_LENGTH_INT, ParAttIntLabel[v] );

fprintf( File, "\n" );

Expand All @@ -59,11 +59,7 @@ void Par_Output_TextFile( const char *FileName )
if ( amr->Par->Mass[p] < 0.0 ) continue;

for (int v=0; v<PAR_NATT_FLT_TOTAL; v++) fprintf( File, BlankPlusFormat_Flt, amr->Par->AttributeFlt[v][p] );
# ifdef INT8_PAR
for (int v=0; v<PAR_NATT_INT_TOTAL; v++) fprintf( File, " %*ld", StrLen_Flt, amr->Par->AttributeInt[v][p] );
# else
for (int v=0; v<PAR_NATT_INT_TOTAL; v++) fprintf( File, " %*d", StrLen_Flt, amr->Par->AttributeInt[v][p] );
# endif
for (int v=0; v<PAR_NATT_INT_TOTAL; v++) fprintf( File, " %*ld", OPT__OUTPUT_TEXT_LENGTH_INT, (long)amr->Par->AttributeInt[v][p] );

fprintf( File, "\n" );
}
Expand Down

0 comments on commit 40891ef

Please sign in to comment.