
00001 /* -*- Mode: C; c-basic-offset:4 ; -*- */ 00002 /* 00003 * $Id$ 00004 * 00005 * Copyright (C) 1997 University of Chicago. 00006 * See COPYRIGHT notice in top-level directory. 00007 */ 00008 00009 #include "mpioimpl.h" 00010 00011 #ifdef HAVE_WEAK_SYMBOLS 00012 00013 #if defined(HAVE_PRAGMA_WEAK) 00014 #pragma weak MPI_File_c2f = PMPI_File_c2f 00015 #elif defined(HAVE_PRAGMA_HP_SEC_DEF) 00016 #pragma _HP_SECONDARY_DEF PMPI_File_c2f MPI_File_c2f 00017 #elif defined(HAVE_PRAGMA_CRI_DUP) 00018 #pragma _CRI duplicate MPI_File_c2f as PMPI_File_c2f 00019 /* end of weak pragmas */ 00020 #endif 00021 00022 /* Include mapping from MPI->PMPI */ 00023 #define MPIO_BUILD_PROFILING 00024 #include "mpioprof.h" 00025 #endif 00026 #include "adio_extern.h" 00027 00028 /*@ 00029 MPI_File_c2f - Translates a C file handle to a Fortran file handle 00030 00031 Input Parameters: 00032 . fh - C file handle (handle) 00033 00034 Return Value: 00035 Fortran file handle (integer) 00036 @*/ 00037 MPI_Fint MPI_File_c2f(MPI_File fh) 00038 { 00039 #ifndef INT_LT_POINTER 00040 return (MPI_Fint) fh; 00041 #else 00042 int i; 00043 00044 if ((fh <= (MPI_File) 0) || (fh->cookie != ADIOI_FILE_COOKIE)) 00045 return (MPI_Fint) 0; 00046 if (!ADIOI_Ftable) { 00047 ADIOI_Ftable_max = 1024; 00048 ADIOI_Ftable = (MPI_File *) 00049 ADIOI_Malloc(ADIOI_Ftable_max*sizeof(MPI_File)); 00050 ADIOI_Ftable_ptr = 0; /* 0 can't be used though, because 00051 MPI_FILE_NULL=0 */ 00052 for (i=0; i<ADIOI_Ftable_max; i++) ADIOI_Ftable[i] = MPI_FILE_NULL; 00053 } 00054 if (ADIOI_Ftable_ptr == ADIOI_Ftable_max-1) { 00055 ADIOI_Ftable = (MPI_File *) ADIOI_Realloc(ADIOI_Ftable, 00056 (ADIOI_Ftable_max+1024)*sizeof(MPI_File)); 00057 for (i=ADIOI_Ftable_max; i<ADIOI_Ftable_max+1024; i++) 00058 ADIOI_Ftable[i] = MPI_FILE_NULL; 00059 ADIOI_Ftable_max += 1024; 00060 } 00061 ADIOI_Ftable_ptr++; 00062 ADIOI_Ftable[ADIOI_Ftable_ptr] = fh; 00063 return (MPI_Fint) ADIOI_Ftable_ptr; 00064 #endif 00065 }
1.5.5