From e2131c7ee45d9b0aefc3f9304fd7851978cc4b51 Mon Sep 17 00:00:00 2001 From: Magnus Lundborg Date: Mon, 28 Oct 2013 11:31:02 +0100 Subject: Added *_write_interval_set() to replace *_write_frequency_set() The old functions are still kept for compatibility, but should not be used. diff --git a/include/tng_io.h b/include/tng_io.h index 8622596..3bec8a9 100644 --- a/include/tng_io.h +++ b/include/tng_io.h @@ -1872,7 +1872,7 @@ tng_function_status DECLSPECDLLEXPORT tng_data_interval_get * will be filled with data. The length of the array will be (n_frames * n_values_per_frame). * Since **values is allocated in this function it is the callers * responsibility to free the memory. - * @param stride_length is set to the stride length (writing frequency) of + * @param stride_length is set to the stride length (writing interval) of * the data. * @param n_values_per_frame is set to the number of values per frame in the data. * This is needed to properly reach and/or free the data afterwards. @@ -2023,7 +2023,7 @@ tng_function_status DECLSPECDLLEXPORT tng_particle_data_interval_get * (n_frames * n_particles * n_values_per_frame). * Since **values is allocated in this function it is the callers * responsibility to free the memory. - * @param stride_length is set to the stride length (writing frequency) of + * @param stride_length is set to the stride length (writing interval) of * the data. * @param n_particles is set to the number of particles in the returned data. This is * needed to properly reach and/or free the data afterwards. @@ -2131,7 +2131,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_close * which will contain the positions. The data is stored sequentially in order * of frames. For each frame the positions (x, y and z coordinates) are stored. * The memory must be freed afterwards. - * @param stride_length will be set to the writing frequency of the stored data. + * @param stride_length will be set to the writing interval of the stored data. * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error * has occured. @@ -2149,7 +2149,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_pos_read * which will contain the velocities. The data is stored sequentially in order * of frames. For each frame the velocities (in x, y and z) are stored. * The memory must be freed afterwards. - * @param stride_length will be set to the writing frequency of the stored data. + * @param stride_length will be set to the writing interval of the stored data. * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error * has occured. @@ -2167,7 +2167,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_vel_read * which will contain the forces. The data is stored sequentially in order * of frames. For each frame the forces (in x, y and z) are stored. * The memory must be freed afterwards. - * @param stride_length will be set to the writing frequency of the stored data. + * @param stride_length will be set to the writing interval of the stored data. * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error * has occured. @@ -2185,7 +2185,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_force_read * of frames. For each frame the box shape is stored as nine values. * If the box shape is not modified during the trajectory, but as general data, * that will be returned instead. - * @param stride_length will be set to the writing frequency of the stored data. + * @param stride_length will be set to the writing interval of the stored data. * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error * has occured. @@ -2205,7 +2205,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_read * which will contain the positions. The data is stored sequentially in order * of frames. For each frame the positions (x, y and z coordinates) are stored. * The memory must be freed afterwards. - * @param stride_length will be set to the writing frequency of the stored data. + * @param stride_length will be set to the writing interval of the stored data. * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error * has occured. @@ -2227,7 +2227,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_pos_read_range * which will contain the velocities. The data is stored sequentially in order * of frames. For each frame the velocities (in x, y and z) are stored. * The memory must be freed afterwards. - * @param stride_length will be set to the writing frequency of the stored data. + * @param stride_length will be set to the writing interval of the stored data. * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error * has occured. @@ -2249,7 +2249,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_vel_read_range * which will contain the forces. The data is stored sequentially in order * of frames. For each frame the forces (in x, y and z) are stored. * The memory must be freed afterwards. - * @param stride_length will be set to the writing frequency of the stored data. + * @param stride_length will be set to the writing interval of the stored data. * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error * has occured. @@ -2272,7 +2272,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_force_read_range * of frames. For each frame the box shape is stored as nine values. * If the box shape is not modified during the trajectory, but as general data, * that will be returned instead. - * @param stride_length will be set to the writing frequency of the stored data. + * @param stride_length will be set to the writing interval of the stored data. * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error * has occured. @@ -2285,14 +2285,14 @@ tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_read_range int64_t *stride_length); /** - * @brief High-level function for setting the writing frequency of data blocks. + * @brief High-level function for setting the writing interval of data blocks. * @param tng_data is the trajectory to use. - * @param f is the output frequency, i.e. f == 10 means data written every 10th + * @param i is the output interval, i.e. i == 10 means data written every 10th * frame. * @param n_values_per_frame is the number of values to store per frame. If the * data is particle dependent there will be n_values_per_frame stored per * particle each frame. - * @param block_id is the ID of the block, of which to set the output frequency. + * @param block_id is the ID of the block, of which to set the output interval. * @param block_name is a string that will be used as name of the block. * @param particle_dependency should be TNG_NON_PARTICLE_BLOCK_DATA (0) if the * data is not related to specific particles (e.g. box shape) or @@ -2306,9 +2306,43 @@ tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_read_range * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error * has occured. */ +tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_interval_set + (tng_trajectory_t tng_data, + const int64_t i, + const int64_t n_values_per_frame, + const int64_t block_id, + const char *block_name, + const char particle_dependency, + const char compression); + +/** + * @brief High-level function for setting the writing interval of data blocks. + * Obsolete! Use tng_util_generic_write_interval_set() + * @param tng_data is the trajectory to use. + * @param i is the output interval, i.e. i == 10 means data written every 10th + * frame. + * @param n_values_per_frame is the number of values to store per frame. If the + * data is particle dependent there will be n_values_per_frame stored per + * particle each frame. + * @param block_id is the ID of the block, of which to set the output interval. + * @param block_name is a string that will be used as name of the block. + * @param particle_dependency should be TNG_NON_PARTICLE_BLOCK_DATA (0) if the + * data is not related to specific particles (e.g. box shape) or + * TNG_PARTICLE_BLOCK_DATA (1) is it is related to specific particles (e.g. + * positions). + * @param compression is the compression routine to use when writing the data. + * @details n_values_per_frame, block_name, particle_dependency and + * compression are only used if the data block did not exist before calling + * this function, in which case it is created. + * This function is replaced by the more correcly named + * tng_util_generic_write_interval_set(), but is kept for compatibility. + * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error + * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error + * has occured. + */ tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_frequency_set (tng_trajectory_t tng_data, - const int64_t f, + const int64_t i, const int64_t n_values_per_frame, const int64_t block_id, const char *block_name, @@ -2316,68 +2350,140 @@ tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_frequency_set const char compression); /** - * @brief High-level function for setting the writing frequency of position + * @brief High-level function for setting the writing interval of position * data blocks. * @param tng_data is the trajectory to use. - * @param f is the output frequency, i.e. f == 10 means data written every 10th + * @param i is the output interval, i.e. i == 10 means data written every 10th + * frame. + * @details This function uses tng_util_generic_write_interval_set() and will + * create a positions data block if none exists. + * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error + * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error + * has occured. + */ +tng_function_status DECLSPECDLLEXPORT tng_util_pos_write_interval_set + (tng_trajectory_t tng_data, + const int64_t i); + +/** + * @brief High-level function for setting the writing interval of position + * data blocks. Obsolete! Use tng_util_pos_write_interval_set() + * @param tng_data is the trajectory to use. + * @param i is the output interval, i.e. i == 10 means data written every 10th * frame. - * @details This function uses tng_util_generic_write_frequency_set() and will + * @details This function uses tng_util_generic_write_interval_set() and will * create a positions data block if none exists. + * This function is replaced by the more correcly named + * tng_util_pos_write_interval_set(), but is kept for compatibility. * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error * has occured. */ tng_function_status DECLSPECDLLEXPORT tng_util_pos_write_frequency_set (tng_trajectory_t tng_data, - const int64_t f); + const int64_t i); /** - * @brief High-level function for setting the writing frequency of velocity + * @brief High-level function for setting the writing interval of velocity * data blocks. * @param tng_data is the trajectory to use. - * @param f is the output frequency, i.e. f == 10 means data written every 10th + * @param i is the output interval, i.e. i == 10 means data written every 10th * frame. - * @details This function uses tng_util_generic_write_frequency_set() and will + * @details This function uses tng_util_generic_write_interval_set() and will * create a velocities data block if none exists. * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error * has occured. */ +tng_function_status DECLSPECDLLEXPORT tng_util_vel_write_interval_set + (tng_trajectory_t tng_data, + const int64_t i); + +/** + * @brief High-level function for setting the writing interval of velocity + * data blocks. Obsolete! Use tng_util_vel_write_interval_set() + * @param tng_data is the trajectory to use. + * @param i is the output interval, i.e. i == 10 means data written every 10th + * frame. + * @details This function uses tng_util_generic_write_interval_set() and will + * create a velocities data block if none exists. + * This function is replaced by the more correcly named + * tng_util_vel_write_interval_set(), but is kept for compatibility. + * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error + * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error + * has occured. + */ tng_function_status DECLSPECDLLEXPORT tng_util_vel_write_frequency_set (tng_trajectory_t tng_data, - const int64_t f); + const int64_t i); /** - * @brief High-level function for setting the writing frequency of force + * @brief High-level function for setting the writing interval of force * data blocks. * @param tng_data is the trajectory to use. - * @param f is the output frequency, i.e. f == 10 means data written every 10th + * @param i is the output interval, i.e. i == 10 means data written every 10th * frame. - * @details This function uses tng_util_generic_write_frequency_set() and will + * @details This function uses tng_util_generic_write_interval_set() and will * create a forces data block if none exists. * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error * has occured. */ +tng_function_status DECLSPECDLLEXPORT tng_util_force_write_interval_set + (tng_trajectory_t tng_data, + const int64_t i); + +/** + * @brief High-level function for setting the writing interval of force + * data blocks. Obsolete! Use tng_util_force_write_interval_set() + * @param tng_data is the trajectory to use. + * @param i is the output interval, i.e. i == 10 means data written every 10th + * frame. + * @details This function uses tng_util_generic_write_interval_set() and will + * create a forces data block if none exists. + * This function is replaced by the more correcly named + * tng_util_force_write_interval_set(), but is kept for compatibility. + * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error + * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error + * has occured. + */ tng_function_status DECLSPECDLLEXPORT tng_util_force_write_frequency_set (tng_trajectory_t tng_data, - const int64_t f); + const int64_t i); /** - * @brief High-level function for setting the writing frequency of box shape + * @brief High-level function for setting the writing interval of box shape * data blocks. * @param tng_data is the trajectory to use. - * @param f is the output frequency, i.e. f == 10 means data written every 10th + * @param i is the output interval, i.e. i == 10 means data written every 10th + * frame. + * @details This function uses tng_util_generic_write_interval_set() and will + * create a box shape data block if none exists. + * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error + * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error + * has occured. + */ +tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_write_interval_set + (tng_trajectory_t tng_data, + const int64_t i); + +/** + * @brief High-level function for setting the writing interval of velocity + * data blocks. Obsolete! Use tng_util_box_shape_write_interval_set() + * @param tng_data is the trajectory to use. + * @param i is the output interval, i.e. i == 10 means data written every 10th * frame. - * @details This function uses tng_util_generic_write_frequency_set() and will + * @details This function uses tng_util_generic_write_interval_set() and will * create a box shape data block if none exists. + * This function is replaced by the more correcly named + * tng_util_box_shape_write_interval_set(), but is kept for compatibility. * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error * has occured. */ tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_write_frequency_set (tng_trajectory_t tng_data, - const int64_t f); + const int64_t i); /** * @brief High-level function for writing data of one frame to a data block. @@ -2389,7 +2495,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_write_frequency_set * @param n_values_per_frame is the number of values to store per frame. If the * data is particle dependent there will be n_values_per_frame stored per * particle each frame. - * @param block_id is the ID of the block, of which to set the output frequency. + * @param block_id is the ID of the block, of which to set the output interval. * @param block_name is a string that will be used as name of the block. * @param particle_dependency should be TNG_NON_PARTICLE_BLOCK_DATA (0) if the * data is not related to specific particles (e.g. box shape) or diff --git a/src/lib/tng_io.c b/src/lib/tng_io.c index 89f9b0d..8bb8f43 100644 --- a/src/lib/tng_io.c +++ b/src/lib/tng_io.c @@ -14935,9 +14935,9 @@ tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_read_range return(stat); } -tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_frequency_set +tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_interval_set (tng_trajectory_t tng_data, - const int64_t f, + const int64_t i, const int64_t n_values_per_frame, const int64_t block_id, const char *block_name, @@ -14947,7 +14947,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_frequency_set tng_trajectory_frame_set_t frame_set; tng_particle_data_t p_data; tng_non_particle_data_t np_data; - int64_t n_particles, n_frames = 100*f; + int64_t n_particles, n_frames = 100*i; tng_function_status stat; stat = tng_check_trajectory_container(tng_data); @@ -14958,10 +14958,10 @@ tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_frequency_set return(stat); } - if(f <= 0) + if(i <= 0) { printf("Cannot set writing frequency to %"PRId64". %s: %d\n", - f, __FILE__, __LINE__); + i, __FILE__, __LINE__); return(TNG_FAILURE); } @@ -14993,7 +14993,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_frequency_set block_name, TNG_FLOAT_DATA, TNG_TRAJECTORY_BLOCK, - n_frames, n_values_per_frame, f, + n_frames, n_values_per_frame, i, 0, n_particles, compression, 0); if(stat != TNG_SUCCESS) @@ -15005,7 +15005,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_frequency_set p_data = &frame_set->tr_particle_data[frame_set-> n_particle_data_blocks - 1]; stat = tng_allocate_particle_data_mem(tng_data, p_data, n_frames, - f, n_particles, + i, n_particles, n_values_per_frame); if(stat != TNG_SUCCESS) { @@ -15016,7 +15016,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_frequency_set } else { - p_data->stride_length = f; + p_data->stride_length = i; } } else @@ -15026,7 +15026,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_frequency_set stat = tng_data_block_add(tng_data, block_id, block_name, TNG_FLOAT_DATA, TNG_TRAJECTORY_BLOCK, n_frames, n_values_per_frame, - f, compression, 0); + i, compression, 0); if(stat != TNG_SUCCESS) { printf("Error %s adding data block. %s: %d\n", block_name, @@ -15036,7 +15036,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_frequency_set np_data = &frame_set->tr_data[frame_set-> n_data_blocks - 1]; stat = tng_allocate_data_mem(tng_data, np_data, n_frames, - f, n_values_per_frame); + i, n_values_per_frame); if(stat != TNG_SUCCESS) { printf("Error allocating particle data memory. %s: %d\n", @@ -15046,57 +15046,109 @@ tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_frequency_set } else { - np_data->stride_length = f; + np_data->stride_length = i; } } return(TNG_SUCCESS); } +tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_frequency_set + (tng_trajectory_t tng_data, + const int64_t i, + const int64_t n_values_per_frame, + const int64_t block_id, + const char *block_name, + const char particle_dependency, + const char compression) +{ + printf("Using obsolete function tng_util_generic_write_frequency_set()." + "See documentation. %s: %d", __FILE__, __LINE__); + return(tng_util_generic_write_interval_set(tng_data, i, n_values_per_frame, + block_id, block_name, + particle_dependency, + compression)); +} +tng_function_status DECLSPECDLLEXPORT tng_util_pos_write_interval_set + (tng_trajectory_t tng_data, + const int64_t i) +{ + return(tng_util_generic_write_interval_set(tng_data, i, 3, + TNG_TRAJ_POSITIONS, + "POSITIONS", + TNG_PARTICLE_BLOCK_DATA, + TNG_TNG_COMPRESSION)); +} + tng_function_status DECLSPECDLLEXPORT tng_util_pos_write_frequency_set (tng_trajectory_t tng_data, - const int64_t f) + const int64_t i) { - return(tng_util_generic_write_frequency_set(tng_data, f, 3, - TNG_TRAJ_POSITIONS, - "POSITIONS", - TNG_PARTICLE_BLOCK_DATA, - TNG_TNG_COMPRESSION)); + printf("Using obsolete function tng_util_pos_write_frequency_set()." + "See documentation. %s: %d", __FILE__, __LINE__); + return(tng_util_pos_write_interval_set(tng_data, i)); +} + +tng_function_status DECLSPECDLLEXPORT tng_util_vel_write_interval_set + (tng_trajectory_t tng_data, + const int64_t i) +{ + return(tng_util_generic_write_interval_set(tng_data, i, 3, + TNG_TRAJ_VELOCITIES, + "VELOCITIES", + TNG_PARTICLE_BLOCK_DATA, + TNG_TNG_COMPRESSION)); } tng_function_status DECLSPECDLLEXPORT tng_util_vel_write_frequency_set (tng_trajectory_t tng_data, - const int64_t f) + const int64_t i) +{ + printf("Using obsolete function tng_util_vel_write_frequency_set()." + "See documentation. %s: %d", __FILE__, __LINE__); + return(tng_util_vel_write_interval_set(tng_data, i)); +} + +tng_function_status DECLSPECDLLEXPORT tng_util_force_write_interval_set + (tng_trajectory_t tng_data, + const int64_t i) { - return(tng_util_generic_write_frequency_set(tng_data, f, 3, - TNG_TRAJ_VELOCITIES, - "VELOCITIES", - TNG_PARTICLE_BLOCK_DATA, - TNG_TNG_COMPRESSION)); + return(tng_util_generic_write_interval_set(tng_data, i, 3, + TNG_TRAJ_FORCES, + "FORCES", + TNG_PARTICLE_BLOCK_DATA, + TNG_GZIP_COMPRESSION)); } tng_function_status DECLSPECDLLEXPORT tng_util_force_write_frequency_set (tng_trajectory_t tng_data, - const int64_t f) + const int64_t i) { - return(tng_util_generic_write_frequency_set(tng_data, f, 3, - TNG_TRAJ_FORCES, - "FORCES", - TNG_PARTICLE_BLOCK_DATA, - TNG_GZIP_COMPRESSION)); + printf("Using obsolete function tng_util_force_write_frequency_set()." + "See documentation. %s: %d", __FILE__, __LINE__); + return(tng_util_force_write_interval_set(tng_data, i)); } -tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_write_frequency_set +tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_write_interval_set (tng_trajectory_t tng_data, - const int64_t f) + const int64_t i) { - return(tng_util_generic_write_frequency_set(tng_data, f, 9, + return(tng_util_generic_write_interval_set(tng_data, i, 9, TNG_TRAJ_BOX_SHAPE, "BOX SHAPE", TNG_NON_PARTICLE_BLOCK_DATA, TNG_GZIP_COMPRESSION)); } +tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_write_frequency_set + (tng_trajectory_t tng_data, + const int64_t i) +{ + printf("Using obsolete function tng_util_box_shape_write_frequency_set()." + "See documentation. %s: %d", __FILE__, __LINE__); + return(tng_util_box_shape_write_interval_set(tng_data, i)); +} + tng_function_status DECLSPECDLLEXPORT tng_util_generic_write (tng_trajectory_t tng_data, const int64_t frame_nr, -- cgit v0.10.1