int artio_fileset_commit_particles( artio_fileset *handle ) { artio_particle_file *phandle; int64_t *total_particles_per_species; int ret; if ( handle == NULL ) { return ARTIO_ERR_INVALID_HANDLE; } if (handle->open_mode != ARTIO_FILESET_WRITE || handle->particle == NULL ) { return ARTIO_ERR_INVALID_FILESET_MODE; } phandle = handle->particle; /* compute total number of particles per species */ total_particles_per_species = (int64_t *)malloc( phandle->num_species * sizeof(int64_t)); if ( total_particles_per_species == NULL ) { return ARTIO_ERR_MEMORY_ALLOCATION; } #ifdef ARTIO_MPI MPI_Allreduce( phandle->local_particles_per_species, total_particles_per_species, phandle->num_species, MPI_INT64_T, MPI_SUM, handle->context->comm ); #else int i; for ( i = 0; i < phandle->num_species; i++ ) { total_particles_per_species[i] = phandle->local_particles_per_species[i]; } #endif artio_parameter_set_long_array(handle, "num_particles_per_species", phandle->num_species, total_particles_per_species ); free( total_particles_per_species ); phandle->file_sfc_index = (int64_t*)malloc( (phandle->num_particle_files+1)*sizeof(int64_t) ); phandle->ffh = (artio_fh **)malloc(phandle->num_particle_files * sizeof(artio_fh *)); if ( phandle->file_sfc_index == NULL || phandle->ffh == NULL ) { artio_particle_file_destroy(phandle); return ARTIO_ERR_MEMORY_ALLOCATION; } ret = artio_fileset_distribute_sfc_to_files( handle, phandle->sfc_list, phandle->sfc_size, phandle->num_particle_files, phandle->allocation_strategy, particle_file_suffix, phandle->file_sfc_index, phandle->ffh ); if ( ret != ARTIO_SUCCESS ) { artio_particle_file_destroy(phandle); return ret; } artio_parameter_set_long_array(handle, "particle_file_sfc_index", phandle->num_particle_files + 1, phandle->file_sfc_index); phandle->sfc_count = 0; return ARTIO_SUCCESS; }
int artio_parameter_set_long(artio_fileset *handle, const char * key, int64_t value) { int64_t tmp = value; return artio_parameter_set_long_array(handle, key, 1, &tmp); }