int mca_sharedfp_individual_file_close (mca_io_ompio_file_t *fh)
{
    mca_sharedfp_individual_header_record* headnode = NULL;
    struct mca_sharedfp_base_data_t *sh;
    int err = OMPI_SUCCESS;

    if ( NULL == fh->f_sharedfp_data ){
	if ( mca_sharedfp_individual_verbose ) {
                opal_output(ompi_sharedfp_base_framework.framework_output,
                    "sharedfp_inidividual_file_close - shared file pointer structure not initialized\n");
	}
        return OMPI_SUCCESS;
    }
    sh = fh->f_sharedfp_data;

    /* Merge data from individal files to final output file */
    err = mca_sharedfp_individual_collaborate_data (sh);

    headnode = (mca_sharedfp_individual_header_record*)(sh->selected_module_data);
    if (headnode)  {
        /*Close datafile*/
        if (headnode->datafilehandle)  {
            /*TODO: properly deal with returned error code*/
            err = mca_common_ompio_file_close(headnode->datafilehandle);
            /* NOTE: No neeed to manually delete the file,
	    ** the amode should have been set to delete on close
	    */
        }
        if(headnode->datafilename){
            free(headnode->datafilename);
        }

        /*Close metadatafile*/
        if (headnode->metadatafilehandle)  {
            /*TODO: properly deal with returned error code*/
            err = mca_common_ompio_file_close(headnode->metadatafilehandle);
            /* NOTE: No neeed to manually delete the file,
	    ** the amode should have been set to delete on close
	    */
        }
        if(headnode->metadatafilename){
            free(headnode->metadatafilename);
        }
    }

    /* Close the main file opened by this component*/
    err = mca_common_ompio_file_close(sh->sharedfh);

    /*free shared file pointer data struct*/
    free(sh);

    return err;
}
int mca_sharedfp_addproc_file_close (mca_io_ompio_file_t *fh)
{
    struct mca_sharedfp_base_data_t *sh=NULL;
    int err = OMPI_SUCCESS;
    long sendBuff = 0;
    int count = 1;
    int rank;
    struct mca_sharedfp_addproc_data * addproc_data = NULL;

    if ( NULL == fh->f_sharedfp_data){
	/* Can happen with lazy initialization of the sharedfp structures */
	if ( mca_sharedfp_addproc_verbose ) {
	    opal_output(0, "sharedfp_addproc_file_close - shared file pointer structure not initialized\n");
	}
        return OMPI_SUCCESS;
    }
    sh = fh->f_sharedfp_data;

    rank = ompi_comm_rank ( sh->comm );

    /* Make sure that all processes are ready to release the
    ** shared file pointer resources
    */
    sh->comm->c_coll.coll_barrier(sh->comm, sh->comm->c_coll.coll_barrier_module );

    addproc_data = (struct mca_sharedfp_addproc_data*)(sh->selected_module_data);

    if (addproc_data) {
        /*tell additional proc to stop listening*/
        if(0 == rank){
            MCA_PML_CALL(send( &sendBuff, count, OMPI_OFFSET_DATATYPE, 0, END_TAG,
			       MCA_PML_BASE_SEND_STANDARD, addproc_data->intercom));
        }

        /* Free  intercommunicator */
        if(addproc_data->intercom){
            ompi_comm_free(&(addproc_data->intercom));
        }
        free(addproc_data);
    }

    /* Close the main file opened by this component*/
    err = mca_common_ompio_file_close(sh->sharedfh);

    /*free shared file pointer data struct*/
    free(sh);
    return err;
}
Пример #3
0
int mca_io_ompio_file_close (ompi_file_t *fh)
{
    int ret = OMPI_SUCCESS;
    mca_io_ompio_data_t *data;

    data = (mca_io_ompio_data_t *) fh->f_io_selected_data;
    if ( NULL == data ) {
	/* structure has already been freed, this is an erroneous call to file_close */
	return ret;
    }
    ret = mca_common_ompio_file_close(&data->ompio_fh);

    if ( NULL != data ) {
      free ( data );
    }

    return ret;
}
Пример #4
0
int mca_sharedfp_lockedfile_file_close (mca_io_ompio_file_t *fh)
{
    int err = OMPI_SUCCESS;
    struct mca_sharedfp_lockedfile_data * module_data = NULL;
    struct mca_sharedfp_base_data_t *sh;
    int rank = ompi_comm_rank ( fh->f_comm );

    if ( fh->f_sharedfp_data==NULL){
	/* Can happen with lazy_open being set */
	if ( mca_sharedfp_lockedfile_verbose ) {
	    opal_output(0, "sharedfp_lockedfile_file_close - shared file pointer structure not initialized\n");
	}
        return OMPI_SUCCESS;
    }
    sh = fh->f_sharedfp_data;

    module_data = (lockedfile_data*)(sh->selected_module_data);
    if ( module_data)   {
        /*Close lockedfile handle*/
        if ( module_data->handle)  {
            close (module_data->handle );
	    if ( 0 == rank ) {
		unlink ( module_data->filename);
	    }
        }
        if ( NULL != module_data->filename ){
            free ( module_data->filename);
        }
        free ( module_data );
    }

    /* Close the main file opened by this component*/
    err = mca_common_ompio_file_close(sh->sharedfh);

    /*free shared file pointer data struct*/
    free(sh);

    return err;

}
Пример #5
0
int mca_io_ompio_file_close (ompi_file_t *fh)
{
    int ret = OMPI_SUCCESS;
    mca_io_ompio_data_t *data;

    data = (mca_io_ompio_data_t *) fh->f_io_selected_data;
    if ( NULL == data ) {
	/* structure has already been freed, this is an erroneous call to file_close */
	return ret;
    }
    /* No locking required for file_close according to my understanding.
       Multiple threads closing the same file handle at the same time
       is a clear user error.
    */
    ret = mca_common_ompio_file_close(&data->ompio_fh);

    if ( NULL != data ) {
      free ( data );
    }

    return ret;
}