00001
00002
00003
00004
00005
00006
00007
00008 #include "adio.h"
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 void ADIOI_Shfp_fname(ADIO_File fd, int rank)
00020 {
00021 double tm;
00022 int i, len;
00023 char *slash, *ptr, tmp[128];
00024
00025 fd->shared_fp_fname = (char *) ADIOI_Malloc(256);
00026
00027 if (!rank) {
00028 tm = MPI_Wtime();
00029 while (tm > 1000000000.0) tm -= 1000000000.0;
00030 i = (int) tm;
00031 tm = tm - (double) i;
00032 tm *= 1000000.0;
00033 i = (int) tm;
00034
00035 ADIOI_Strncpy(fd->shared_fp_fname, fd->filename, 256);
00036
00037 #ifdef ROMIO_NTFS
00038 slash = strrchr(fd->filename, '\\');
00039 #else
00040 slash = strrchr(fd->filename, '/');
00041 #endif
00042 if (!slash) {
00043 ADIOI_Strncpy(fd->shared_fp_fname, ".", 2);
00044 ADIOI_Strncpy(fd->shared_fp_fname + 1, fd->filename, 255);
00045 }
00046 else {
00047 ptr = slash;
00048 #ifdef ROMIO_NTFS
00049 slash = strrchr(fd->shared_fp_fname, '\\');
00050 #else
00051 slash = strrchr(fd->shared_fp_fname, '/');
00052 #endif
00053 ADIOI_Strncpy(slash + 1, ".", 2);
00054 len = 256 - (slash+2 - fd->shared_fp_fname);
00055 ADIOI_Strncpy(slash + 2, ptr + 1, len);
00056 }
00057
00058 ADIOI_Snprintf(tmp, 128, ".shfp.%d", i);
00059 ADIOI_Strnapp(fd->shared_fp_fname, tmp, 256);
00060
00061 len = (int)strlen(fd->shared_fp_fname);
00062 MPI_Bcast(&len, 1, MPI_INT, 0, fd->comm);
00063 MPI_Bcast(fd->shared_fp_fname, len+1, MPI_CHAR, 0, fd->comm);
00064 }
00065 else {
00066 MPI_Bcast(&len, 1, MPI_INT, 0, fd->comm);
00067 MPI_Bcast(fd->shared_fp_fname, len+1, MPI_CHAR, 0, fd->comm);
00068 }
00069 }