void mpi_file_open_(MPI_Fint *comm,_fcd filename_fcd,MPI_Fint *amode, MPI_Fint *info, MPI_Fint *fh, MPI_Fint *ierr) { char *filename = _fcdtocp(filename_fcd); int str_len = _fcdlen(filename_fcd); #else /* Prototype to keep compiler happy */ /* FORTRAN_API void FORT_CALL mpi_file_open_(MPI_Comm *comm,char *filename,MPI_Fint *amode, MPI_Fint *info, MPI_Fint *fh, MPI_Fint *ierr, int str_len ); FORTRAN_API void FORT_CALL mpi_file_open_(MPI_Comm *comm,char *filename,MPI_Fint *amode, MPI_Fint *info, MPI_Fint *fh, MPI_Fint *ierr, int str_len ) */ /* Prototype to keep compiler happy */ FORTRAN_API void FORT_CALL mpi_file_open_(MPI_Fint *comm,char *filename FORT_MIXED_LEN_DECL,MPI_Fint *amode, MPI_Fint *info, MPI_Fint *fh, MPI_Fint *ierr FORT_END_LEN_DECL); FORTRAN_API void FORT_CALL mpi_file_open_(MPI_Fint *comm,char *filename FORT_MIXED_LEN(str_len),MPI_Fint *amode, MPI_Fint *info, MPI_Fint *fh, MPI_Fint *ierr FORT_END_LEN(str_len)) { #endif char *newfname; MPI_File fh_c; int real_len, i; MPI_Info info_c; info_c = MPI_Info_f2c(*info); /* strip trailing blanks */ if (filename <= (char *) 0) { FPRINTF(stderr, "MPI_File_open: filename is an invalid address\n"); MPI_Abort(MPI_COMM_WORLD, 1); } for (i=str_len-1; i>=0; i--) if (filename[i] != ' ') break; if (i < 0) { FPRINTF(stderr, "MPI_File_open: filename is a blank string\n"); MPI_Abort(MPI_COMM_WORLD, 1); } real_len = i + 1; newfname = (char *) ADIOI_Malloc((real_len+1)*sizeof(char)); ADIOI_Strncpy(newfname, filename, real_len); newfname[real_len] = '\0'; *ierr = MPI_File_open((MPI_Comm)(*comm), newfname, *amode, info_c, &fh_c); *fh = MPI_File_c2f(fh_c); ADIOI_Free(newfname); }
/* * The following routines provide handles to the calling Fortran program */ void f2cfile_( int *file ) { MPI_File cFile; int rc; rc = MPI_File_open( MPI_COMM_WORLD, (char*)"temp", MPI_MODE_RDWR | MPI_MODE_DELETE_ON_CLOSE | MPI_MODE_CREATE, MPI_INFO_NULL, &cFile ); if (rc) { *file = 0; } else { *file = MPI_File_c2f( cFile ); } }