#include #include #include "mpi.h" MPI_File NSSCreateLustreFile( MPI_Comm comm, const char* path, int stripeCount, size_t stripeSize, int *errorCode ) { struct stat fInfo; if ( stat(path, &fInfo) != 0 ) { int rc = 0; MPI_File fh = NULL; MPI_Info finfo = NULL; if ( (rc = MPI_Info_create(&finfo)) == 0 ) { char strForm[32]; if ( stripeCount < 0 ) stripeCount = -1; snprintf(strForm, sizeof(strForm), "%d", stripeCount); if ( (rc = MPI_Info_set(finfo, "striping_factor", strForm)) == 0 ) { if ( stripeSize < 0 ) stripeSize = 0; snprintf(strForm, sizeof(strForm), "%ld", stripeSize); if ( (rc = MPI_Info_set(finfo, "striping_unit", strForm)) == 0 ) { rc = MPI_File_open( comm, (char*)path, MPI_MODE_RDWR | MPI_MODE_CREATE, finfo, &fh ); } } MPI_Info_free(&finfo); } if ( rc ) { if ( errorCode ) *errorCode = rc; return NULL; } return fh; } else { if ( errorCode ) *errorCode = EEXIST; } return NULL; }