diff -ruN mpich-1.2.6/mpid/globus2/setup_globus2 gridftp/mpid/globus2/setup_globus2 --- mpich-1.2.6/mpid/globus2/setup_globus2 2004-08-02 15:34:15.000000000 -0400 +++ gridftp/mpid/globus2/setup_globus2 2004-08-24 14:12:48.000000000 -0400 @@ -191,7 +191,7 @@ $gmh -flavor=$flavor \ globus_common globus_gram_client globus_io globus_data_conversion \ globus_duroc_runtime globus_duroc_bootstrap globus_ftp_control \ - globus_core \ + globus_ftp_client globus_core \ >mpid/${DEVICE}/Makefile.mpich.header if test $? != 0 ; then print_error "ERROR: failed globus-makefile-header: missing Globus components" diff -ruN mpich-1.2.6/romio/Makefile.in gridftp/romio/Makefile.in --- mpich-1.2.6/romio/Makefile.in 2004-01-27 18:27:35.000000000 -0500 +++ gridftp/romio/Makefile.in 2004-08-24 14:11:52.000000000 -0400 @@ -14,7 +14,7 @@ MPIO_DIRS = mpi-io EXTRA_SRC_DIRS = @EXTRA_SRC_DIRS@ FILE_SYS_DIRS = @FILE_SYS_DIRS@ -ALL_DIRS = mpi-io mpi-io/fortran mpi2-other/info mpi2-other/info/fortran mpi2-other/array mpi2-other/array/fortran adio/common adio/ad_pfs adio/ad_piofs adio/ad_nfs adio/ad_ufs adio/ad_xfs adio/ad_hfs adio/ad_sfs adio/ad_testfs adio/ad_pvfs adio/ad_pvfs2 test +ALL_DIRS = mpi-io mpi-io/fortran mpi2-other/info mpi2-other/info/fortran mpi2-other/array mpi2-other/array/fortran adio/common adio/ad_pfs adio/ad_piofs adio/ad_nfs adio/ad_ufs adio/ad_xfs adio/ad_hfs adio/ad_sfs adio/ad_testfs adio/ad_pvfs adio/ad_pvfs2 adio/ad_gridftp test SHELL = /bin/sh @VPATH@ diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/Makefile.in gridftp/romio/adio/ad_gridftp/Makefile.in --- mpich-1.2.6/romio/adio/ad_gridftp/Makefile.in 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/Makefile.in 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,27 @@ +CC = @CC@ +AR = @AR@ +LIBNAME = @LIBNAME@ +srcdir = @srcdir@ + +INCLUDE_DIR = -I@MPI_INCLUDE_DIR@ -I${srcdir}/../include -I../include +CFLAGS = @CFLAGS@ $(INCLUDE_DIR) + +@VPATH@ + +AD_GRIDFTP_OBJECTS = ad_gridftp_close.o ad_gridftp_read.o ad_gridftp_rdcoll.o \ + ad_gridftp_wrcoll.o ad_gridftp_open.o ad_gridftp_write.o \ + ad_gridftp_done.o ad_gridftp_fcntl.o ad_gridftp_iread.o \ + ad_gridftp_iwrite.o ad_gridftp_wait.o ad_gridftp_flush.o \ + ad_gridftp_seek.o ad_gridftp_resize.o ad_gridftp_hints.o \ + ad_gridftp_delete.o ad_gridftp.o globus_routines.o + +default: $(LIBNAME) + +.c.o: + $(CC) $(CFLAGS) -c $< + +$(LIBNAME): $(AD_GRIDFTP_OBJECTS) + $(AR) $(LIBNAME) $(AD_GRIDFTP_OBJECTS) + +clean: + @rm -f *.o diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp.c gridftp/romio/adio/ad_gridftp/ad_gridftp.c --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,37 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $Id: ad_gridftp.c,v 1.2 2002/10/24 17:01:03 gropp Exp $ + * + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +#include "ad_gridftp.h" + +/* adioi.h has the ADIOI_Fns_struct define */ +#include "adioi.h" + +struct ADIOI_Fns_struct ADIO_GRIDFTP_operations = { + ADIOI_GRIDFTP_Open, /* Open */ + ADIOI_GRIDFTP_ReadContig, /* ReadContig */ + ADIOI_GRIDFTP_WriteContig, /* WriteContig */ + ADIOI_GRIDFTP_ReadStridedColl, /* ReadStridedColl */ + ADIOI_GRIDFTP_WriteStridedColl, /* WriteStridedColl */ + ADIOI_GRIDFTP_SeekIndividual, /* SeekIndividual */ + ADIOI_GRIDFTP_Fcntl, /* Fcntl */ + ADIOI_GRIDFTP_SetInfo, /* SetInfo */ + ADIOI_GRIDFTP_ReadStrided, /* ReadStrided */ + ADIOI_GRIDFTP_WriteStrided, /* WriteStrided */ + ADIOI_GRIDFTP_Close, /* Close */ + ADIOI_GRIDFTP_IreadContig, /* IreadContig */ + ADIOI_GRIDFTP_IwriteContig, /* IwriteContig */ + ADIOI_GRIDFTP_ReadDone, /* ReadDone */ + ADIOI_GRIDFTP_WriteDone, /* WriteDone */ + ADIOI_GRIDFTP_ReadComplete, /* ReadComplete */ + ADIOI_GRIDFTP_WriteComplete, /* WriteComplete */ + ADIOI_GRIDFTP_IreadStrided, /* IreadStrided */ + ADIOI_GRIDFTP_IwriteStrided, /* IwriteStrided */ + ADIOI_GRIDFTP_Flush, /* Flush */ + ADIOI_GRIDFTP_Resize, /* Resize */ + ADIOI_GRIDFTP_Delete, /* Delete */ +}; diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp.h gridftp/romio/adio/ad_gridftp/ad_gridftp.h --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp.h 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp.h 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,96 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +#ifndef AD_GRIDFTP_INCLUDE +#define AD_GRIDFTP_INCLUDE + +#include +#include +#include +#include +#include "adio.h" +#include + +/* These live in globus_routines.c */ +extern int num_gridftp_handles; +#ifndef ADIO_GRIDFTP_HANDLES_MAX +#define ADIO_GRIDFTP_HANDLES_MAX 200 +#endif /* ! ADIO_GRIDFTP_HANDLES_MAX */ +extern globus_ftp_client_handle_t gridftp_fh[ADIO_GRIDFTP_HANDLES_MAX]; +extern globus_ftp_client_operationattr_t oattr[ADIO_GRIDFTP_HANDLES_MAX]; + +void ADIOI_GRIDFTP_Open(ADIO_File fd, int *error_code); +void ADIOI_GRIDFTP_Close(ADIO_File fd, int *error_code); +void ADIOI_GRIDFTP_ReadContig(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Status *status, int + *error_code); +void ADIOI_GRIDFTP_WriteContig(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Status *status, int + *error_code); +void ADIOI_GRIDFTP_IwriteContig(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Request *request, int + *error_code); +void ADIOI_GRIDFTP_IreadContig(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Request *request, int + *error_code); +int ADIOI_GRIDFTP_ReadDone(ADIO_Request *request, ADIO_Status *status, int + *error_code); +int ADIOI_GRIDFTP_WriteDone(ADIO_Request *request, ADIO_Status *status, int + *error_code); +void ADIOI_GRIDFTP_ReadComplete(ADIO_Request *request, ADIO_Status *status, int + *error_code); +void ADIOI_GRIDFTP_WriteComplete(ADIO_Request *request, ADIO_Status *status, + int *error_code); +void ADIOI_GRIDFTP_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, + int *error_code); +void ADIOI_GRIDFTP_WriteStrided(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Status *status, + int *error_code); +void ADIOI_GRIDFTP_ReadStrided(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Status *status, int + *error_code); +void ADIOI_GRIDFTP_WriteStridedColl(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Status *status, int + *error_code); +void ADIOI_GRIDFTP_ReadStridedColl(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Status *status, int + *error_code); +void ADIOI_GRIDFTP_IreadStrided(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Request *request, int + *error_code); +void ADIOI_GRIDFTP_IwriteStrided(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Request *request, int + *error_code); +void ADIOI_GRIDFTP_Flush(ADIO_File fd, int *error_code); +void ADIOI_GRIDFTP_Resize(ADIO_File fd, ADIO_Offset size, int *error_code); +ADIO_Offset ADIOI_GRIDFTP_SeekIndividual(ADIO_File fd, ADIO_Offset offset, + int whence, int *error_code); +void ADIOI_GRIDFTP_SetInfo(ADIO_File fd, MPI_Info users_info, int *error_code); +void ADIOI_GRIDFTP_Get_shared_fp(ADIO_File fd, int size, + ADIO_Offset *shared_fp, + int *error_code); +void ADIOI_GRIDFTP_Set_shared_fp(ADIO_File fd, ADIO_Offset offset, + int *error_code); +void ADIOI_GRIDFTP_Delete(char *filename, int *error_code); + +void globus_err_handler(const char *routine, const char *caller, + globus_result_t result); + +#endif + + + + diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_close.c gridftp/romio/adio/ad_gridftp/ad_gridftp_close.c --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_close.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp_close.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,47 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $Id: ad_gridftp_close.c,v 1.2 2002/10/24 17:01:03 gropp Exp $ + * + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +#include "ad_gridftp.h" +#include "adioi.h" + +void ADIOI_GRIDFTP_Close(ADIO_File fd, int *error_code) +{ + char myname[]="ADIOI_GRIDFTP_Close"; + int myrank, nprocs; + globus_result_t result; + + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_Close called on %s\n", myrank, + nprocs, fd->filename); +#endif /* PRINT_ERR_MSG */ + MPI_Barrier(fd->comm); + + /* Destroy the ftp handle and opattr */ + if ( (result=globus_ftp_client_operationattr_destroy(&(oattr[fd->fd_sys])))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_operationattr_destroy",myname,result); + *error_code = MPI_ERR_FILE; + ADIOI_Error(fd,*error_code,myname); + return; + } + if ( (result=globus_ftp_client_handle_destroy(&(gridftp_fh[fd->fd_sys])))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_handle_destroy",myname,result); + *error_code = MPI_ERR_FILE; + ADIOI_Error(fd,*error_code,myname); + return; + } + + *error_code = MPI_SUCCESS; + fd->fd_sys = -1; + fd->fp_ind=0; + fd->fp_sys_posn=0; + num_gridftp_handles--; +} diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_delete.c gridftp/romio/adio/ad_gridftp/ad_gridftp_delete.c --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_delete.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp_delete.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,80 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $Id: ad_gridftp_delete.c,v 1.2 2002/10/24 17:01:03 gropp Exp $ + * + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +#include "ad_gridftp.h" +#include "adioi.h" + +static globus_mutex_t lock; +static globus_cond_t cond; +static globus_bool_t delete_done, delete_success; +static void delete_cb(void *myarg, globus_ftp_client_handle_t *handle, globus_object_t *error) +{ + + if (error) + { + fprintf(stderr, "%s\n", globus_object_printable_to_string(error)); + } + else + { + delete_success=GLOBUS_TRUE; + } + delete_done=GLOBUS_TRUE; +} + +void ADIOI_GRIDFTP_Delete(char *filename, int *error_code) +{ + char myname[]="ADIOI_GRIDFTP_Delete"; + int myrank, nprocs; + globus_ftp_client_handle_t handle; + globus_result_t result; + + *error_code = MPI_SUCCESS; + + MPI_Comm_size(MPI_COMM_WORLD, &nprocs); + MPI_Comm_rank(MPI_COMM_WORLD, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_Delete called on %s\n", + myrank, nprocs, filename); +#endif /* PRINT_ERR_MSG */ + + globus_module_activate(GLOBUS_FTP_CLIENT_MODULE); + if ( (result=globus_ftp_client_handle_init(&handle,GLOBUS_NULL))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_handle_init",myname,result); + *error_code=MPI_ERR_IO; + ADIOI_Error(ADIO_FILE_NULL,*error_code,myname); + return; + } + + delete_done=GLOBUS_FALSE; + delete_success=GLOBUS_FALSE; + if ( (result=globus_ftp_client_delete(&handle,filename,GLOBUS_NULL,delete_cb,GLOBUS_NULL))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_delete",myname,result); + *error_code=MPI_ERR_IO; + ADIOI_Error(ADIO_FILE_NULL,*error_code,myname); + return; + } + globus_mutex_lock(&lock); + while ( delete_done!=GLOBUS_TRUE ) + globus_cond_wait(&cond,&lock); + globus_mutex_unlock(&lock); + if ( (result=globus_ftp_client_handle_destroy(&handle))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_handle_destroy",myname,result); + *error_code=MPI_ERR_IO; + ADIOI_Error(ADIO_FILE_NULL,*error_code,myname); + return; + } + + if ( delete_success!=GLOBUS_TRUE ) + { + *error_code = MPI_ERR_FILE; + ADIOI_Error(ADIO_FILE_NULL,*error_code,myname); + } +} diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_done.c gridftp/romio/adio/ad_gridftp/ad_gridftp_done.c --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_done.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp_done.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,68 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $Id: ad_gridftp_done.c,v 1.3 2002/10/24 17:01:03 gropp Exp $ + * + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +#include "ad_gridftp.h" +#include "adioi.h" + +int ADIOI_GRIDFTP_ReadDone(ADIO_Request *request, ADIO_Status *status, int + *error_code) +{ + int myrank, nprocs; + + *error_code = MPI_SUCCESS; + + if (*request == ADIO_REQUEST_NULL) { + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_ReadDone called on ADIO_REQUEST_NULL\n", + myrank, nprocs); + return 1; + } + + MPI_Comm_size((*request)->fd->comm, &nprocs); + MPI_Comm_rank((*request)->fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_ReadDone called on %s\n", + myrank, nprocs, (*request)->fd->filename); +#endif /* PRINT_ERR_MSG */ + +#ifdef HAVE_STATUS_SET_BYTES + MPIR_Status_set_bytes(status, (*request)->datatype, (*request)->nbytes); +#endif + (*request)->fd->async_count--; + ADIOI_Free_request((ADIOI_Req_node *) (*request)); + *request = ADIO_REQUEST_NULL; + return 1; +} + +int ADIOI_GRIDFTP_WriteDone(ADIO_Request *request, ADIO_Status *status, int + *error_code) +{ + int myrank, nprocs; + + *error_code = MPI_SUCCESS; + + if (*request == ADIO_REQUEST_NULL) { + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_WriteDone called on ADIO_REQUEST_NULL\n", + myrank, nprocs); + return 1; + } + + MPI_Comm_size((*request)->fd->comm, &nprocs); + MPI_Comm_rank((*request)->fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_WriteDone called on %s\n", + myrank, nprocs, (*request)->fd->filename); +#endif /* PRINT_ERR_MSG */ + +#ifdef HAVE_STATUS_SET_BYTES + MPIR_Status_set_bytes(status, (*request)->datatype, (*request)->nbytes); +#endif + (*request)->fd->async_count--; + ADIOI_Free_request((ADIOI_Req_node *) (*request)); + *request = ADIO_REQUEST_NULL; + return 1; +} diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_fcntl.c gridftp/romio/adio/ad_gridftp/ad_gridftp_fcntl.c --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_fcntl.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp_fcntl.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,165 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $Id: ad_gridftp_fcntl.c,v 1.3 2002/10/24 17:01:03 gropp Exp $ + * + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +#include "ad_gridftp.h" +#include "adioi.h" +#include "adio_extern.h" + +globus_mutex_t fcntl_size_lock; +globus_cond_t fcntl_size_cond; +globus_bool_t fcntl_size_done; + +void fcntl_size_cb(void *myargs, globus_ftp_client_handle_t *handle, + globus_object_t *error) +{ + if (error) + { + fprintf(stderr, "%s\n", globus_object_printable_to_string(error)); + } + globus_mutex_lock(&fcntl_size_lock); + fcntl_size_done=GLOBUS_TRUE; + globus_cond_signal(&fcntl_size_cond); + globus_mutex_unlock(&fcntl_size_lock); +} + +void ADIOI_GRIDFTP_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, + int *error_code) +{ + MPI_Datatype copy_etype, copy_filetype; + int combiner, i, j, k, filetype_is_contig, err; + ADIOI_Flatlist_node *flat_file; + char myname[]="ADIOI_GRIDFTP_Fcntl"; + + int myrank, nprocs; + + *error_code = MPI_SUCCESS; + + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_Fcntl called on %s\n", + myrank, nprocs, fd->filename); +#endif /* PRINT_ERR_MSG */ + + switch(flag) { +#if 0 /* not needed on modern romio --pw */ + case ADIO_FCNTL_SET_VIEW: + /* free copies of old etypes and filetypes and delete flattened + version of filetype if necessary */ + + MPI_Type_get_envelope(fd->etype, &i, &j, &k, &combiner); + if (combiner != MPI_COMBINER_NAMED) MPI_Type_free(&(fd->etype)); + + ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig); + if (!filetype_is_contig) ADIOI_Delete_flattened(fd->filetype); + + MPI_Type_get_envelope(fd->filetype, &i, &j, &k, &combiner); + if (combiner != MPI_COMBINER_NAMED) MPI_Type_free(&(fd->filetype)); + + /* set new info */ + ADIO_SetInfo(fd, fcntl_struct->info, &err); + + /* set new etypes and filetypes */ + + MPI_Type_get_envelope(fcntl_struct->etype, &i, &j, &k, &combiner); + if (combiner == MPI_COMBINER_NAMED) fd->etype = fcntl_struct->etype; + else { + MPI_Type_contiguous(1, fcntl_struct->etype, ©_etype); + MPI_Type_commit(©_etype); + fd->etype = copy_etype; + } + MPI_Type_get_envelope(fcntl_struct->filetype, &i, &j, &k, &combiner); + if (combiner == MPI_COMBINER_NAMED) + fd->filetype = fcntl_struct->filetype; + else { + MPI_Type_contiguous(1, fcntl_struct->filetype, ©_filetype); + MPI_Type_commit(©_filetype); + fd->filetype = copy_filetype; + ADIOI_Flatten_datatype(fd->filetype); + /* this function will not flatten the filetype if it turns out + to be all contiguous. */ + } + + MPI_Type_size(fd->etype, &(fd->etype_size)); + fd->disp = fcntl_struct->disp; + + /* reset MPI-IO file pointer to point to the first byte that can + be accessed in this view. */ + + ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig); + if (filetype_is_contig) fd->fp_ind = fcntl_struct->disp; + else { + flat_file = ADIOI_Flatlist; + while (flat_file->type != fd->filetype) + flat_file = flat_file->next; + for (i=0; icount; i++) { + if (flat_file->blocklens[i]) { + fd->fp_ind = fcntl_struct->disp + flat_file->indices[i]; + break; + } + } + } + *error_code = MPI_SUCCESS; + break; +#endif + + case ADIO_FCNTL_GET_FSIZE: + { + globus_result_t result; + globus_off_t fsize=0; + + globus_mutex_init(&fcntl_size_lock,GLOBUS_NULL); + globus_cond_init(&fcntl_size_cond,GLOBUS_NULL); + fcntl_size_done=GLOBUS_FALSE; + if ( (result=globus_ftp_client_size(&(gridftp_fh[fd->fd_sys]), + fd->filename, + &(oattr[fd->fd_sys]), + &(fsize), + fcntl_size_cb, + GLOBUS_NULL))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_size",myname,result); + *error_code=MPI_ERR_IO; + ADIOI_Error(fd,*error_code,myname); + return; + } + globus_mutex_lock(&fcntl_size_lock); + while ( fcntl_size_done!=GLOBUS_TRUE ) + globus_cond_wait(&fcntl_size_lock,&fcntl_size_cond); + globus_mutex_unlock(&fcntl_size_lock); + globus_mutex_destroy(&fcntl_size_lock); + globus_cond_destroy(&fcntl_size_cond); + fcntl_struct->fsize=fsize; + } + *error_code = MPI_SUCCESS; + break; + + case ADIO_FCNTL_SET_DISKSPACE: + *error_code = MPI_SUCCESS; + break; + + case ADIO_FCNTL_SET_IOMODE: + /* for implementing PFS I/O modes. will not occur in MPI-IO + implementation.*/ + if (fd->iomode != fcntl_struct->iomode) { + fd->iomode = fcntl_struct->iomode; + MPI_Barrier(MPI_COMM_WORLD); + } + *error_code = MPI_SUCCESS; + break; + + case ADIO_FCNTL_SET_ATOMICITY: + fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1; + *error_code = MPI_SUCCESS; + break; + + default: + FPRINTF(stderr, "Unknown flag passed to ADIOI_GRIDFTP_Fcntl\n"); + MPI_Abort(MPI_COMM_WORLD, 1); + } +} diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_flush.c gridftp/romio/adio/ad_gridftp/ad_gridftp_flush.c --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_flush.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp_flush.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,26 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $Id: ad_gridftp_flush.c,v 1.2 2002/10/24 17:01:04 gropp Exp $ + * + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +#include "ad_gridftp.h" +#include "adioi.h" + +/* GridFTP doesn't give you a way to cache writes on the client side, so + is essentially a no-op */ +void ADIOI_GRIDFTP_Flush(ADIO_File fd, int *error_code) +{ + int myrank, nprocs; + + *error_code = MPI_SUCCESS; + + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_Flush called on %s\n", + myrank, nprocs, fd->filename); +#endif /* PRINT_ERR_MSG */ +} diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_getsh.c gridftp/romio/adio/ad_gridftp/ad_gridftp_getsh.c --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_getsh.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp_getsh.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,26 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $Id: ad_gridftp_getsh.c,v 1.2 2002/10/24 17:01:04 gropp Exp $ + * + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +#include "ad_gridftp.h" +#include "adioi.h" + +void ADIOI_GRIDFTP_Get_shared_fp(ADIO_File fd, int size, + ADIO_Offset *shared_fp, + int *error_code) +{ + int myrank, nprocs; + + *error_code = MPI_SUCCESS; + + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_Get_shared_fp called on %s\n", + myrank, nprocs, fd->filename); +#endif /* PRINT_ERR_MSG */ +} diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_hints.c gridftp/romio/adio/ad_gridftp/ad_gridftp_hints.c --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_hints.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp_hints.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,69 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $Id: ad_gridftp_hints.c,v 1.4 2002/10/24 17:01:04 gropp Exp $ + * + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +/* + +Valid hints for ftp:// and gsiftp:// URLs (aside from the std. ones): + + ftp_control_mode extended|block|stream|compressed + (default extended for gsiftp:// URLs and stream for ftp:// URLs) + + parallelism integer number of simultaneous threads connecting to + ftp server (default 1) + + striped_ftp true|false or enable|disable; enables gsiftp striped data transfer + + tcp_buffer integer size of tcp stream buffers in bytes + + transfer_type ascii or binary (default binary) + +These *must* be specified at open time currently. +*/ + +#include "ad_gridftp.h" +#include "adioi.h" + +void ADIOI_GRIDFTP_SetInfo(ADIO_File fd, MPI_Info users_info, int *error_code) +{ + + if (!(fd->info)) + { + if ( users_info==MPI_INFO_NULL ) + { + /* This must be part of the open call. */ + MPI_Info_create(&(fd->info)); + } + else + { + MPI_Info_dup(users_info,&(fd->info)); + } + } + else + { + int i,nkeys,valuelen,flag; + char key[MPI_MAX_INFO_KEY], value[MPI_MAX_INFO_VAL]; + + if ( users_info!=MPI_INFO_NULL ) + { + MPI_Info_get_nkeys(users_info,&nkeys); + for (i=0;iinfo,key,value); + } + } + } + } + + /* let the generic ROMIO and MPI-I/O stuff happen... */ + ADIOI_GEN_SetInfo(fd, users_info, error_code); +} diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_iread.c gridftp/romio/adio/ad_gridftp/ad_gridftp_iread.c --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_iread.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp_iread.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,94 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $Id: ad_gridftp_iread.c,v 1.3 2002/10/24 17:01:04 gropp Exp $ + * + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +#include "ad_gridftp.h" +#include "adioi.h" + +/* ADIOI_GRIDFTP_IreadContig() + * + * Implemented by immediately calling ReadContig() + */ +void ADIOI_GRIDFTP_IreadContig(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Request *request, int + *error_code) +{ + ADIO_Status status; + int myrank, nprocs, typesize, len; + + *error_code = MPI_SUCCESS; + + *request = ADIOI_Malloc_request(); + (*request)->optype = ADIOI_WRITE; + (*request)->fd = fd; + (*request)->queued = 0; + (*request)->datatype = datatype; + + MPI_Type_size(datatype, &typesize); + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); +#ifdef _PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_IreadContig called on %s\n", + myrank, nprocs, fd->filename); + FPRINTF(stdout, "[%d/%d] calling ADIOI_GRIDFTP_ReadContig\n", + myrank, nprocs); +#endif /* PRINT_ERR_MSG */ + + len = count * typesize; + ADIOI_GRIDFTP_ReadContig(fd, buf, len, MPI_BYTE, file_ptr_type, + offset, &status, error_code); + +#ifdef HAVE_STATUS_SET_BYTES + if (*error_code == MPI_SUCCESS) { + MPI_Get_elements(&status, MPI_BYTE, &len); + (*request)->nbytes = len; + } +#endif + fd->async_count++; +} + +void ADIOI_GRIDFTP_IreadStrided(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Request *request, int + *error_code) +{ + ADIO_Status status; + int myrank, nprocs; +#ifdef HAVE_STATUS_SET_BYTES + int typesize; +#endif + + *error_code = MPI_SUCCESS; + + *request = ADIOI_Malloc_request(); + (*request)->optype = ADIOI_WRITE; + (*request)->fd = fd; + (*request)->queued = 0; + (*request)->datatype = datatype; + + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_IreadStrided called on %s\n", + myrank, nprocs, fd->filename); + FPRINTF(stdout, "[%d/%d] calling ADIOI_GRIDFTP_ReadStrided\n", + myrank, nprocs); +#endif /* PRINT_ERR_MSG */ + + ADIOI_GRIDFTP_ReadStrided(fd, buf, count, datatype, file_ptr_type, + offset, &status, error_code); + +#ifdef HAVE_STATUS_SET_BYTES + if (*error_code == MPI_SUCCESS) { + MPI_Type_size(datatype, &typesize); + (*request)->nbytes = count * typesize; + } +#endif + fd->async_count++; +} + diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_iwrite.c gridftp/romio/adio/ad_gridftp/ad_gridftp_iwrite.c --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_iwrite.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp_iwrite.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,93 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $Id: ad_gridftp_iwrite.c,v 1.3 2002/10/24 17:01:04 gropp Exp $ + * + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +#include "ad_gridftp.h" +#include "adioi.h" + +/* ADIOI_GRIDFTP_IwriteContig() + * + * Implemented by immediately calling WriteContig() + */ +void ADIOI_GRIDFTP_IwriteContig(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Request *request, int + *error_code) +{ + ADIO_Status status; + int myrank, nprocs, typesize, len; + + *error_code = MPI_SUCCESS; + + *request = ADIOI_Malloc_request(); + (*request)->optype = ADIOI_WRITE; + (*request)->fd = fd; + (*request)->queued = 0; + (*request)->datatype = datatype; + + MPI_Type_size(datatype, &typesize); + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_IwriteContig called on %s\n", + myrank, nprocs, fd->filename); + FPRINTF(stdout, "[%d/%d] calling ADIOI_GRIDFTP_WriteContig\n", + myrank, nprocs); +#endif /* PRINT_ERR_MSG */ + + len = count * typesize; + ADIOI_GRIDFTP_WriteContig(fd, buf, len, MPI_BYTE, file_ptr_type, + offset, &status, error_code); + +#ifdef HAVE_STATUS_SET_BYTES + if (*error_code == MPI_SUCCESS) { + MPI_Get_elements(&status, MPI_BYTE, &len); + (*request)->nbytes = len; + } +#endif + fd->async_count++; +} + +void ADIOI_GRIDFTP_IwriteStrided(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Request *request, int + *error_code) +{ + ADIO_Status status; + int myrank, nprocs; +#ifdef HAVE_STATUS_SET_BYTES + int typesize; +#endif + + *error_code = MPI_SUCCESS; + + *request = ADIOI_Malloc_request(); + (*request)->optype = ADIOI_WRITE; + (*request)->fd = fd; + (*request)->queued = 0; + (*request)->datatype = datatype; + + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_IwriteStrided called on %s\n", + myrank, nprocs, fd->filename); + FPRINTF(stdout, "[%d/%d] calling ADIOI_GRIDFTP_WriteStrided\n", + myrank, nprocs); +#endif /* PRINT_ERR_MSG */ + + ADIOI_GRIDFTP_WriteStrided(fd, buf, count, datatype, file_ptr_type, + offset, &status, error_code); + +#ifdef HAVE_STATUS_SET_BYTES + if (*error_code == MPI_SUCCESS) { + MPI_Type_size(datatype, &typesize); + (*request)->nbytes = count * typesize; + } +#endif + fd->async_count++; +} diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_open.c gridftp/romio/adio/ad_gridftp/ad_gridftp_open.c --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_open.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp_open.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,410 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +#include "ad_gridftp.h" +#include "adioi.h" + +static globus_mutex_t lock; +static globus_cond_t cond; + +static globus_bool_t file_exists,exists_done; +static void exists_cb(void *myargs, globus_ftp_client_handle_t *handle, globus_object_t *error) +{ + if (error) + { + fprintf(stderr, "%s\n", globus_object_printable_to_string(error)); + } + else + { + file_exists=GLOBUS_TRUE; + } + exists_done=GLOBUS_TRUE; +} + +static globus_bool_t touch_ctl_done; +static void touch_ctl_cb(void *myargs, globus_ftp_client_handle_t *handle, globus_object_t *error) +{ + if (error) + { + fprintf(stderr, "%s\n", globus_object_printable_to_string(error)); + } + globus_mutex_lock(&lock); + touch_ctl_done=GLOBUS_TRUE; + globus_cond_signal(&cond); + globus_mutex_unlock(&lock); +} + +static void touch_data_cb(void *myargs, globus_ftp_client_handle_t *handle, globus_object_t *error, + globus_byte_t *buffer, globus_size_t length, globus_off_t offset, + globus_bool_t eof) +{ + if (error) + fprintf(stderr, "%s\n", globus_object_printable_to_string(error)); + globus_ftp_client_register_read(handle,buffer,length,touch_data_cb,myargs); + return; +} + +void ADIOI_GRIDFTP_Open(ADIO_File fd, int *error_code) +{ + char myname[]="ADIOI_GRIDFTP_Open"; + int myrank, nprocs, keyfound; + char hintval[MPI_MAX_INFO_VAL+1]; + globus_ftp_client_handleattr_t hattr; + globus_result_t result; + + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_Open called on %s\n", myrank, + nprocs, fd->filename); +#endif + + /* activate Globus ftp client module -- can be called multiple times, so + it's safest to call once per file/connection */ + globus_module_activate(GLOBUS_FTP_CLIENT_MODULE); + fd->fd_sys = num_gridftp_handles; + /* No shared file pointers for now */ + fd->shared_fp_fname = NULL; + *error_code = MPI_SUCCESS; + + /* Access modes here mean something very different here than they + would on a "real" filesystem... As a result, the amode and hint + processing here is intermingled and a little weird because many + of them have to do with the connection rather than the file itself. + The thing that sucks about this is that read and write ops will + have to check themselves if the file is being accessed rdonly, rdwr, + or wronly. + */ + if ( (result=globus_ftp_client_handleattr_init(&hattr))!=GLOBUS_SUCCESS ) + { + + + globus_err_handler("globus_ftp_client_handleattr_init", + myname,result); + fd->fd_sys = -1; + *error_code = MPIR_ERR_FILE_CORRUPT; + ADIOI_Error(fd,*error_code,myname); + return; + } + if ( (result=globus_ftp_client_operationattr_init(&(oattr[fd->fd_sys])))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_operationattr_init", + myname,result); + fd->fd_sys = -1; + *error_code = MPIR_ERR_FILE_CORRUPT; + ADIOI_Error(fd,*error_code,myname); + return; + } + + + /* Always use connection caching unless told otherwise */ + if ( (result=globus_ftp_client_handleattr_set_cache_all(&hattr,GLOBUS_TRUE))!=GLOBUS_SUCCESS ) + globus_err_handler("globus_ftp_client_handleattr_set_cache_all",myname,result); + + /* Assume that it's safe to cache a file if it's read-only */ + if ( (fd->access_mode&MPI_MODE_RDONLY) && + (result=globus_ftp_client_handleattr_add_cached_url(&hattr,fd->filename))!=GLOBUS_SUCCESS ) + globus_err_handler("globus_ftp_client_handleattr_add_cached_url",myname,result); + + /* Since we're (almost by definition) doing things that FTP S (stream) + control mode can't handle, default to E (extended block) control mode + for gsiftp:// URLs. ftp:// URLs use standard stream control mode + by default. This behavior can be overridden by the ftp_control_mode + hint. */ + + /* + if ( !strncmp(fd->filename,"gsiftp:",7) && + (result=globus_ftp_client_operationattr_set_mode(&(oattr[fd->fd_sys]),GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK))!=GLOBUS_SUCCESS ) + globus_err_handler("globus_ftp_client_operationattr_set_mode",myname,result); + else if ( !strncmp(fd->filename,"ftp:",4) && + (result=globus_ftp_client_operationattr_set_mode(&(oattr[fd->fd_sys]),GLOBUS_FTP_CONTROL_MODE_STREAM))!=GLOBUS_SUCCESS ) + globus_err_handler("globus_ftp_client_operationattr_set_mode",myname,result); + */ + + /* Set append mode if necessary */ + if ( (fd->access_mode&MPI_MODE_APPEND) && + ((result=globus_ftp_client_operationattr_set_append(&(oattr[fd->fd_sys]),GLOBUS_TRUE))!=GLOBUS_SUCCESS) ) + globus_err_handler("globus_ftp_client_operationattr_set_append",myname,result); + + /* Other hint and amode processing that would affect hattr and/or + oattr[] (eg. parallelism, striping, etc.) goes here */ + if ( fd->info!=MPI_INFO_NULL ) + { + MPI_Info_get(fd->info,"ftp_control_mode",MPI_MAX_INFO_VAL,hintval,&keyfound); + if ( keyfound ) + { + if ( ( !strcmp(hintval,"extended") || !strcmp(hintval,"extended_block") ) && + (result=globus_ftp_client_operationattr_set_mode(&(oattr[fd->fd_sys]),GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK))!=GLOBUS_SUCCESS ) + globus_err_handler("globus_ftp_client_operationattr_set_mode",myname,result); + else if ( !strcmp(hintval,"block") && + (result=globus_ftp_client_operationattr_set_mode(&(oattr[fd->fd_sys]),GLOBUS_FTP_CONTROL_MODE_BLOCK))!=GLOBUS_SUCCESS ) + globus_err_handler("globus_ftp_client_operationattr_set_mode",myname,result); + else if ( !strcmp(hintval,"compressed") && + (result=globus_ftp_client_operationattr_set_mode(&(oattr[fd->fd_sys]),GLOBUS_FTP_CONTROL_MODE_COMPRESSED))!=GLOBUS_SUCCESS ) + globus_err_handler("globus_ftp_client_operationattr_set_mode",myname,result); + else if ( !strcmp(hintval,"stream") && + (result=globus_ftp_client_operationattr_set_mode(&(oattr[fd->fd_sys]),GLOBUS_FTP_CONTROL_MODE_STREAM))!=GLOBUS_SUCCESS ) + globus_err_handler("globus_ftp_client_operationattr_set_mode",myname,result); + } + + MPI_Info_get(fd->info,"parallelism",MPI_MAX_INFO_VAL,hintval,&keyfound); + if ( keyfound ) + { + int nftpthreads; + + if ( sscanf(hintval,"%d",&nftpthreads)==1 ) + { + globus_ftp_control_parallelism_t parallelism; + + parallelism.mode = GLOBUS_FTP_CONTROL_PARALLELISM_FIXED; + parallelism.fixed.size = nftpthreads; + if ( (result=globus_ftp_client_operationattr_set_parallelism(&(oattr[fd->fd_sys]), + ¶llelism))!=GLOBUS_SUCCESS ) + globus_err_handler("globus_ftp_client_operationattr_set_parallelism",myname,result); + } + } + + MPI_Info_get(fd->info,"striped_ftp",MPI_MAX_INFO_VAL,hintval,&keyfound); + if ( keyfound ) + { + /* if set to "true" or "enable", set up round-robin block layout */ + if ( !strncmp("true",hintval,4) || !strncmp("TRUE",hintval,4) || + !strncmp("enable",hintval,4) || !strncmp("ENABLE",hintval,4) ) + { + MPI_Info_get(fd->info,"striping_factor",MPI_MAX_INFO_VAL,hintval,&keyfound); + if ( keyfound ) + { + int striping_factor; + + if ( sscanf(hintval,"%d",&striping_factor)==1 ) + { + globus_ftp_control_layout_t layout; + + layout.mode = GLOBUS_FTP_CONTROL_STRIPING_BLOCKED_ROUND_ROBIN; + layout.round_robin.block_size = striping_factor; + if ( (result=globus_ftp_client_operationattr_set_layout(&(oattr[fd->fd_sys]), + &layout))!=GLOBUS_SUCCESS ) + globus_err_handler("globus_ftp_client_operationattr_set_layout", + myname,result); + } + } + } + } + + MPI_Info_get(fd->info,"tcp_buffer",MPI_MAX_INFO_VAL,hintval,&keyfound); + if ( keyfound ) + { + /* set tcp buffer size */ + int buffer_size; + if ( sscanf(hintval,"%d",&buffer_size)==1 ) + { + globus_ftp_control_tcpbuffer_t tcpbuf; + + tcpbuf.mode = GLOBUS_FTP_CONTROL_TCPBUFFER_FIXED; + tcpbuf.fixed.size = buffer_size; + if ( (result=globus_ftp_client_operationattr_set_tcp_buffer(&(oattr[fd->fd_sys]), + &tcpbuf))!=GLOBUS_SUCCESS ) + globus_err_handler("globus_ftp_client_operationattr_set_tcp_buffer",myname,result); + } + } + + MPI_Info_get(fd->info,"transfer_type",MPI_MAX_INFO_VAL,hintval,&keyfound); + if ( keyfound ) + { + globus_ftp_control_type_t filetype; + /* set transfer type (i.e. ASCII or binary) */ + if ( !strcmp("ascii",hintval) || !strcmp("ASCII",hintval) ) + { + filetype=GLOBUS_FTP_CONTROL_TYPE_ASCII; + } + else + { + filetype=GLOBUS_FTP_CONTROL_TYPE_IMAGE; + } + if ( (result=globus_ftp_client_operationattr_set_type(&(oattr[fd->fd_sys]),filetype))!=GLOBUS_SUCCESS ) + globus_err_handler("globus_ftp_client_operationattr_set_type",myname,result); + } + } + else + fprintf(stderr,"no MPI_Info object associated with %s\n",fd->filename); + + /* Create the ftp handle */ + if ( (result=globus_ftp_client_handle_init(&(gridftp_fh[fd->fd_sys]),&hattr))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_handle_init",myname,result); + fd->fd_sys = -1; + *error_code = MPIR_ERR_FILE_CORRUPT; + ADIOI_Error(fd,*error_code,myname); + return; + } + + /* Check for existence of the file */ + globus_mutex_init(&lock, GLOBUS_NULL); + globus_cond_init(&cond, GLOBUS_NULL); + file_exists=GLOBUS_FALSE; + exists_done=GLOBUS_FALSE; + if ( myrank==0 ) + { + if ( (result=globus_ftp_client_exists(&(gridftp_fh[fd->fd_sys]), + fd->filename, + &(oattr[fd->fd_sys]), + exists_cb, + GLOBUS_NULL))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_exists",myname,result); + fd->fd_sys = -1; + *error_code = MPIR_ERR_FILE_CORRUPT; + ADIOI_Error(fd,*error_code,myname); + return; + } + /* wait till the callback completes */ + globus_mutex_lock(&lock); + while ( exists_done!=GLOBUS_TRUE ) + globus_cond_wait(&cond,&lock); + globus_mutex_unlock(&lock); + } + MPI_Barrier(fd->comm); + MPI_Bcast(&file_exists,1,MPI_INT,0,fd->comm); + + /* It turns out that this is handled by MPI_File_open() directly */ + if ( (file_exists!=GLOBUS_TRUE) && (fd->access_mode&MPI_MODE_CREATE) && + !(fd->access_mode&MPI_MODE_EXCL) && !(fd->access_mode&MPI_MODE_RDONLY) ) + { + if ( myrank==0 ) + { + /* if the file doesn't exist, write a single NULL to it */ + globus_byte_t touchbuf=(globus_byte_t)'\0'; + touch_ctl_done=GLOBUS_FALSE; + if ( (result=globus_ftp_client_put(&(gridftp_fh[fd->fd_sys]), + fd->filename, + &(oattr[fd->fd_sys]), + GLOBUS_NULL, + touch_ctl_cb, + GLOBUS_NULL))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_put",myname,result); + fd->fd_sys = -1; + *error_code = MPI_ERR_IO; + ADIOI_Error(fd,*error_code,myname); + return; + } + if ( (result=globus_ftp_client_register_write(&(gridftp_fh[fd->fd_sys]), + (globus_byte_t *)&touchbuf, + 0, + (globus_off_t)0, + GLOBUS_TRUE, + touch_data_cb, + GLOBUS_NULL))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_register_write",myname,result); + fd->fd_sys = -1; + *error_code = MPI_ERR_IO; + ADIOI_Error(fd,*error_code,myname); + return; + } + globus_mutex_lock(&lock); + while ( touch_ctl_done!=GLOBUS_TRUE ) + globus_cond_wait(&cond,&lock); + globus_mutex_unlock(&lock); + } + MPI_Barrier(fd->comm); + } + else if ( (fd->access_mode&MPI_MODE_EXCL) && (file_exists==GLOBUS_TRUE) ) + { + fd->fd_sys = -1; + *error_code = MPI_ERR_FILE_EXISTS; + ADIOI_Error(fd,*error_code,myname); + return; + } + else if ( (fd->access_mode&MPI_MODE_RDONLY) && (file_exists!=GLOBUS_TRUE) ) + { + if ( myrank==0 ) + { + fprintf(stderr,"WARNING: read-only file %s does not exist!\n",fd->filename); + } + } + num_gridftp_handles++; + +#if 0 + /* Debugging info for testing PASV mode behind firewalls */ + if ( myrank==0 ) + { + globus_bool_t striped; + globus_ftp_control_mode_t mode; + globus_ftp_control_type_t filetype; + globus_ftp_control_parallelism_t parallelism; + + fprintf(stderr,"--gridftp details for %s--\n", + fd->filename); + + /* + fprintf(stderr,"Connection caching: "); + globus_ftp_client_handleattr_get_cache_all(&hattr,&cached); + if ( cached==GLOBUS_TRUE ) + fprintf(stderr,"Y\n"); + else + fprintf(stderr,"N\n"); + */ + + fprintf(stderr,"Control mode: "); + globus_ftp_client_operationattr_get_mode(&(oattr[fd->fd_sys]),&mode); + if ( mode==GLOBUS_FTP_CONTROL_MODE_BLOCK ) + fprintf(stderr,"block\n"); + else if ( mode==GLOBUS_FTP_CONTROL_MODE_COMPRESSED ) + fprintf(stderr,"compressed\n"); + else if ( mode==GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK ) + fprintf(stderr,"extended block\n"); + else if ( mode==GLOBUS_FTP_CONTROL_MODE_STREAM ) + fprintf(stderr,"stream\n"); + else + fprintf(stderr,"unknown\n"); + + fprintf(stderr,"File type: "); + globus_ftp_client_operationattr_get_type(&(oattr[fd->fd_sys]),&filetype); + if ( filetype==GLOBUS_FTP_CONTROL_TYPE_ASCII ) + fprintf(stderr,"ASCII\n"); + else if ( filetype==GLOBUS_FTP_CONTROL_TYPE_IMAGE ) + fprintf(stderr,"binary\n"); + else if ( filetype==GLOBUS_FTP_CONTROL_TYPE_EBCDIC ) + fprintf(stderr,"EBCDIC\n"); + else + fprintf(stderr,"unknown\n"); + + fprintf(stderr,"Parallelism: "); + globus_ftp_client_operationattr_get_parallelism(&(oattr[fd->fd_sys]),¶llelism); + if ( parallelism.mode==GLOBUS_FTP_CONTROL_PARALLELISM_NONE ) + fprintf(stderr,"none\n"); + else if ( parallelism.mode==GLOBUS_FTP_CONTROL_PARALLELISM_FIXED ) + fprintf(stderr,"fixed with %d streams\n",parallelism.fixed.size); + else + fprintf(stderr,"unknown\n"); + + fprintf(stderr,"Striping: "); + globus_ftp_client_operationattr_get_striped(&(oattr[fd->fd_sys]),&striped); + if ( striped==GLOBUS_TRUE ) + { + globus_ftp_control_layout_t layout; + + fprintf(stderr,"Y\nLayout: "); + globus_ftp_client_operationattr_get_layout(&(oattr[fd->fd_sys]), + &layout); + if ( layout.mode==GLOBUS_FTP_CONTROL_STRIPING_NONE ) + fprintf(stderr,"none\n"); + else if ( layout.mode==GLOBUS_FTP_CONTROL_STRIPING_PARTITIONED ) + fprintf(stderr,"partitioned, size=%d\n",layout.partitioned.size); + else if ( layout.mode==GLOBUS_FTP_CONTROL_STRIPING_BLOCKED_ROUND_ROBIN ) + fprintf(stderr,"round-robin, block size=%d\n",layout.round_robin.block_size); + else + fprintf(stderr,"unknown\n"); + } + else + fprintf(stderr,"N\n"); + + fflush(stderr); + } +#endif + +} diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_rdcoll.c gridftp/romio/adio/ad_gridftp/ad_gridftp_rdcoll.c --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_rdcoll.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp_rdcoll.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,32 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $Id: ad_gridftp_rdcoll.c,v 1.4 2002/10/24 17:01:05 gropp Exp $ + * + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +#include "ad_gridftp.h" +#include "adioi.h" + +void ADIOI_GRIDFTP_ReadStridedColl(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Status *status, + int *error_code) +{ + int myrank, nprocs; + + *error_code = MPI_SUCCESS; + + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_ReadStridedColl called on %s\n", + myrank, nprocs, fd->filename); + FPRINTF(stdout, "[%d/%d] calling ADIOI_GEN_ReadStridedColl\n", + myrank, nprocs); +#endif /* PRINT_ERR_MSG */ + + ADIOI_GEN_ReadStridedColl(fd, buf, count, datatype, file_ptr_type, + offset, status, error_code); +} diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_read.c gridftp/romio/adio/ad_gridftp/ad_gridftp_read.c --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_read.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp_read.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,487 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $Id: ad_gridftp_read.c,v 1.6 2002/10/24 17:01:05 gropp Exp $ + * + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +#include "ad_gridftp.h" +#include "adioi.h" +#include "adio_extern.h" + +static globus_mutex_t readcontig_ctl_lock; +static globus_cond_t readcontig_ctl_cond; +static globus_bool_t readcontig_ctl_done; +static void readcontig_ctl_cb(void *myargs, globus_ftp_client_handle_t *handle, globus_object_t *error) +{ + if (error) + { + fprintf(stderr, "%s\n", globus_object_printable_to_string(error)); + } + globus_mutex_lock(&readcontig_ctl_lock); + if ( readcontig_ctl_done!=GLOBUS_TRUE ) + readcontig_ctl_done=GLOBUS_TRUE; + globus_cond_signal(&readcontig_ctl_cond); + globus_mutex_unlock(&readcontig_ctl_lock); + return; +} + +static void readcontig_data_cb(void *myargs, globus_ftp_client_handle_t *handle, globus_object_t *error, + globus_byte_t *buffer, globus_size_t length, globus_off_t offset, + globus_bool_t eof) +{ + globus_size_t *bytes_read; + + bytes_read=(globus_size_t *)myargs; + if (error) + { + fprintf(stderr, "%s\n", globus_object_printable_to_string(error)); + } + *bytes_read+=length; + /* I don't understand why the data callback has to keep recalling register_read, + but everything I've done and all the examples I've seen seem to require + that behavior to work... */ + /* + * Using buffer+length seems to work, but is probably not the correct + * solution. A big read of 256kB chunks will have lines like this: + readcontig_data_cb: buffer 0x404e0008 length 0 offset 31719424 eof 1 + readcontig_data_cb: buffer 0x404a0008 length 65536 offset 31981568 eof 0 + readcontig_data_cb: buffer 0x404b0008 length 65536 offset 32047104 eof 0 + readcontig_data_cb: buffer 0x404c0008 length 65536 offset 32112640 eof 0 + readcontig_data_cb: buffer 0x404d0008 length 65536 offset 32178176 eof 0 + */ +#if 0 + fprintf(stderr, "%s: buffer %p length %d offset %Ld eof %d\n", + __func__, buffer, length, offset, eof); +#endif + if ( !eof ) + globus_ftp_client_register_read(handle, + buffer+length, + length, + readcontig_data_cb, + (void *)(bytes_read)); + return; +} + +static globus_mutex_t readdiscontig_ctl_lock; +static globus_cond_t readdiscontig_ctl_cond; +static globus_bool_t readdiscontig_ctl_done; +static void readdiscontig_ctl_cb(void *myargs, globus_ftp_client_handle_t *handle, globus_object_t *error) +{ + if (error) + { + fprintf(stderr, "%s\n", globus_object_printable_to_string(error)); + } + globus_mutex_lock(&readdiscontig_ctl_lock); + if ( readdiscontig_ctl_done!=GLOBUS_TRUE ) + readdiscontig_ctl_done=GLOBUS_TRUE; + globus_cond_signal(&readdiscontig_ctl_cond); + globus_mutex_unlock(&readdiscontig_ctl_lock); + return; +} + +static void readdiscontig_data_cb(void *myargs, globus_ftp_client_handle_t *handle, globus_object_t *error, + globus_byte_t *buffer, globus_size_t length, globus_off_t offset, + globus_bool_t eof) +{ + globus_size_t *bytes_read; + + bytes_read=(globus_size_t *)myargs; + if (error) + { + fprintf(stderr, "%s\n", globus_object_printable_to_string(error)); + } + *bytes_read+=length; + /* I don't understand why the data callback has to keep recalling register_read, + but everything I've done and all the examples I've seen seem to require + that behavior to work... */ + if ( !eof ) + globus_ftp_client_register_read(handle, + buffer, + length, + readdiscontig_data_cb, + (void *)(bytes_read)); + return; +} + +void ADIOI_GRIDFTP_ReadContig(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Status *status, int + *error_code) +{ + char myname[]="ADIOI_GRIDFTP_ReadContig"; + int myrank, nprocs, datatype_size; + globus_size_t len,bytes_read=0; + globus_off_t goff; + globus_result_t result; + + if ( fd->access_mode&MPI_MODE_WRONLY ) + { + *error_code=MPIR_ERR_MODE_WRONLY; + return; + } + + *error_code = MPI_SUCCESS; + + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); + MPI_Type_size(datatype, &datatype_size); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_ReadContig called on %s\n", myrank, + nprocs, fd->filename); +#endif /* PRINT_ERR_MSG */ + +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] reading (buf = 0x%x, loc = %Ld, sz = %Ld)\n", + myrank, nprocs, (int) buf, (long long) offset, + (long long) datatype_size * count); +#endif /* PRINT_ERR_MSG */ + + if (file_ptr_type != ADIO_EXPLICIT_OFFSET) + { + offset = fd->fp_ind; + } + + /* Do the gridftp I/O transfer */ + goff = (globus_off_t)offset; + len = ((globus_size_t)datatype_size)*((globus_size_t)count); + + globus_mutex_init(&readcontig_ctl_lock, GLOBUS_NULL); + globus_cond_init(&readcontig_ctl_cond, GLOBUS_NULL); + readcontig_ctl_done=GLOBUS_FALSE; + if ( (result=globus_ftp_client_partial_get(&(gridftp_fh[fd->fd_sys]), + fd->filename, + &(oattr[fd->fd_sys]), + GLOBUS_NULL, + goff, + goff+(globus_off_t)len, + readcontig_ctl_cb, + GLOBUS_NULL))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_partial_get",myname,result); + *error_code=MPI_ERR_IO; + ADIOI_Error(fd,*error_code,myname); + return; + } + if ( (result=globus_ftp_client_register_read(&(gridftp_fh[fd->fd_sys]), + (globus_byte_t *)buf, + len, + readcontig_data_cb, + (void *)(&bytes_read)))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_register_read",myname,result); + *error_code=MPI_ERR_IO; + ADIOI_Error(fd,*error_code,myname); + return; + } + + + /* The ctl callback won't start till the data callbacks complete, so it's + safe to wait on just the ctl callback */ + globus_mutex_lock(&readcontig_ctl_lock); + while ( readcontig_ctl_done!=GLOBUS_TRUE ) + globus_cond_wait(&readcontig_ctl_cond,&readcontig_ctl_lock); + globus_mutex_unlock(&readcontig_ctl_lock); + + globus_mutex_destroy(&readcontig_ctl_lock); + globus_cond_destroy(&readcontig_ctl_cond); + +#ifdef HAVE_STATUS_SET_BYTES + MPIR_Status_set_bytes(status, datatype, bytes_read); +#endif + if (file_ptr_type != ADIO_EXPLICIT_OFFSET) + { + fd->fp_ind += bytes_read; + fd->fp_sys_posn = fd->fp_ind; +#if 0 + FPRINTF(stdout, "[%d/%d] new file position is %Ld\n", myrank, + nprocs, (long long) fd->fp_ind); +#endif + } + else { + fd->fp_sys_posn = offset + bytes_read; + } +} + +void ADIOI_GRIDFTP_ReadDiscontig(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Status *status, int + *error_code) +{ + char myname[]="ADIOI_GRIDFTP_ReadDiscontig"; + int myrank,nprocs; + /* size and extent of buffer in memory */ + MPI_Aint btype_size,btype_extent; + /* size and extent of file record layout */ + MPI_Aint ftype_size,ftype_extent; + /* size of file elemental type; seeks are done in units of this */ + MPI_Aint etype_size; + MPI_Aint extent; + ADIOI_Flatlist_node *flat_file; + int i,buf_contig,boff,nblks; + globus_off_t start,end,goff; + globus_size_t bytes_read; + globus_result_t result; + globus_byte_t *tmp; + + if ( fd->access_mode&MPI_MODE_WRONLY ) + { + *error_code=MPIR_ERR_MODE_WRONLY; + return; + } + + *error_code=MPI_SUCCESS; + + MPI_Comm_rank(fd->comm,&myrank); + MPI_Comm_size(fd->comm,&nprocs); + + etype_size=fd->etype_size; + MPI_Type_size(fd->filetype,&ftype_size); + MPI_Type_extent(fd->filetype,&ftype_extent); + /* This is arguably unnecessary, as this routine assumes that the + buffer in memory is contiguous */ + MPI_Type_size(datatype,&btype_size); + MPI_Type_extent(datatype,&btype_extent); + ADIOI_Datatype_iscontig(datatype,&buf_contig); + + if ( ( btype_extent!=btype_size ) || ( ! buf_contig ) ) + { + fprintf(stderr,"[%d/%d] %s called with discontigous memory buffer\n", + myrank,nprocs,myname); + fflush(stderr); + *error_code=MPI_ERR_TYPE; + ADIOI_Error(fd,*error_code,myname); + return; + } + /* from here we can assume btype_extent==btype_size */ + + /* Flatten out fd->filetype so we know which blocks to skip */ + ADIOI_Flatten_datatype(fd->filetype); + flat_file = ADIOI_Flatlist; + while (flat_file->type != fd->filetype && flat_file->next!=NULL) + flat_file = flat_file->next; + + /* Figure out how big the area to read is */ + start=(globus_off_t)(offset*etype_size); + goff=start; + boff=0; + extent=0; + nblks=0; + while ( boff < (count*btype_size) ) + { + int blklen=0; + + for (i=0;icount;i++) + { + /* find the length of the next block */ + if ( (boff+flat_file->blocklens[i]) < (count*btype_size) ) + blklen=flat_file->blocklens[i]; + else + blklen=(count*btype_size)-boff; + /* increment buffer size to be used */ + boff+=blklen; + /* compute extent -- the nblks*ftype_extent bit is + there so we remember how many ftypes we've already + been through */ + extent=MAX(extent,nblks*ftype_extent+flat_file->indices[i]+blklen); + if ( boff>=(count*btype_size) ) + break; + } + nblks++; + } + if ( extent < count*btype_size ) + { + fprintf(stderr,"[%d/%d] %s error in computing extent -- extent %d is smaller than total bytes requested %d!\n", + myrank,nprocs,myname,extent,count*btype_size); + fflush(stderr); + *error_code=MPI_ERR_TYPE; + ADIOI_Error(fd,*error_code,myname); + return; + } + end=start+(globus_off_t)extent; + tmp=(globus_byte_t *)malloc((size_t)extent*sizeof(globus_byte_t)); + + /* start up the globus partial read */ + globus_mutex_init(&readdiscontig_ctl_lock, GLOBUS_NULL); + globus_cond_init(&readdiscontig_ctl_cond, GLOBUS_NULL); + readdiscontig_ctl_done=GLOBUS_FALSE; + if ( (result=globus_ftp_client_partial_get(&(gridftp_fh[fd->fd_sys]), + fd->filename, + &(oattr[fd->fd_sys]), + GLOBUS_NULL, + start, + end, + readdiscontig_ctl_cb, + GLOBUS_NULL))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_partial_get",myname,result); + *error_code=MPI_ERR_IO; + ADIOI_Error(fd,*error_code,myname); + return; + } + + /* Do all the actual I/Os */ + /* Since globus_ftp_client_register_read() is brain-dead and doesn't + let you specify an offset, we have to slurp the entire extent into + memory and then parse out the pieces we want... Sucks, doesn't it? + + This should probably be done in chunks (preferably of a size + set using a file hint), but that'll have to come later. + --TB */ + if ( (result=globus_ftp_client_register_read(&(gridftp_fh[fd->fd_sys]), + tmp, + (globus_size_t)extent, + readdiscontig_data_cb, + (void *)(&bytes_read)))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_register_read",myname,result); + *error_code=MPI_ERR_IO; + ADIOI_Error(fd,*error_code,myname); + return; + } + /* The ctl callback won't start till the data callbacks complete, so it's + safe to wait on just the ctl callback */ + globus_mutex_lock(&readdiscontig_ctl_lock); + while ( readdiscontig_ctl_done!=GLOBUS_TRUE ) + globus_cond_wait(&readdiscontig_ctl_cond,&readdiscontig_ctl_lock); + globus_mutex_unlock(&readdiscontig_ctl_lock); + + globus_mutex_destroy(&readdiscontig_ctl_lock); + globus_cond_destroy(&readdiscontig_ctl_cond); + + boff=0; + nblks=0; + goff=0; + while ( boff < (count*btype_size) ) + { + int i,blklen; + + for (i=0;icount;i++) + { + if ( (boff+flat_file->blocklens[i]) < (count*btype_size) ) + blklen=flat_file->blocklens[i]; + else + blklen=(count*btype_size)-boff; + if ( blklen > 0 ) + { + goff=nblks*ftype_extent+flat_file->indices[i]; + memcpy((globus_byte_t *)buf+boff,tmp+goff,(size_t)blklen); + boff+=blklen; + if ( boff>=(count*btype_size) ) + break; + } + } + nblks++; + } + free(tmp); + +#ifdef HAVE_STATUS_SET_BYTES + MPIR_Status_set_bytes(status, datatype, bytes_read); +#endif + if (file_ptr_type != ADIO_EXPLICIT_OFFSET) + { + fd->fp_ind += extent; + fd->fp_sys_posn = fd->fp_ind; +#if 0 + FPRINTF(stdout, "[%d/%d] new file position is %Ld\n", myrank, + nprocs, (long long) fd->fp_ind); +#endif + } + else { + fd->fp_sys_posn = offset + extent; + } +} + +void ADIOI_GRIDFTP_ReadStrided(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Status *status, int + *error_code) +{ + /* + int myrank, nprocs; + + *error_code = MPI_SUCCESS; + + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_ReadStrided called on %s\n", myrank, + nprocs, fd->filename); + FPRINTF(stdout, "[%d/%d] calling ADIOI_GEN_ReadStrided\n", myrank, + nprocs); +#endif + + ADIOI_GEN_ReadStrided(fd, buf, count, datatype, file_ptr_type, offset, + status, error_code); + + */ + + char myname[]="ADIOI_GRIDFTP_ReadStrided"; + int myrank, nprocs; + int i,j; + int buf_contig,file_contig; + MPI_Aint btype_size,bufsize; + globus_off_t start,disp; + globus_size_t bytes_read; + globus_byte_t *intermediate; + + *error_code = MPI_SUCCESS; + + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_ReadStrided called on %s\n", myrank, + nprocs, fd->filename); +#endif /* PRINT_ERR_MSG */ + + MPI_Type_size(datatype,&btype_size); + bufsize=count*btype_size; + ADIOI_Datatype_iscontig(fd->filetype,&file_contig); + ADIOI_Datatype_iscontig(datatype,&buf_contig); + if ( buf_contig && !file_contig ) + { + /* Contiguous in memory, discontig in file */ + ADIOI_GRIDFTP_ReadDiscontig(fd, buf, count, datatype, + file_ptr_type, offset, status, error_code); + } + else if ( !buf_contig && file_contig ) + { + /* Discontiguous in mem, contig in file -- comparatively easy */ + int posn=0; + + /* read contiguous data into intermediate buffer */ + intermediate=(globus_byte_t *)malloc((size_t)bufsize); + ADIOI_GRIDFTP_ReadContig(fd, intermediate, bufsize, MPI_BYTE, + file_ptr_type, offset, status, error_code); + + /* explode contents of intermediate buffer into main buffer */ + MPI_Unpack(intermediate,bufsize,&posn,buf,count,datatype,fd->comm); + + free(intermediate); + } + else if ( !buf_contig && !file_contig ) + { + /* Discontig in both mem and file -- the hardest case */ + int posn=0; + + /* Read discontiguous data into intermediate buffer */ + intermediate=(globus_byte_t *)malloc((size_t)bufsize); + ADIOI_GRIDFTP_ReadDiscontig(fd, intermediate, bufsize, MPI_BYTE, + file_ptr_type, offset, status, error_code); + + /* explode contents of intermediate buffer into main buffer */ + posn=0; + MPI_Unpack(intermediate,bufsize,&posn,buf,count,datatype,fd->comm); + + free(intermediate); + } + else + { + /* Why did you bother calling ReadStrided?!?!?! */ + ADIOI_GRIDFTP_ReadContig(fd, buf, count, datatype, + file_ptr_type, offset, status, error_code); + } + +} + diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_resize.c gridftp/romio/adio/ad_gridftp/ad_gridftp_resize.c --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_resize.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp_resize.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,232 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $Id: ad_gridftp_resize.c,v 1.2 2002/10/24 17:01:05 gropp Exp $ + * + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +#include "ad_gridftp.h" +#include "adioi.h" + +static globus_mutex_t resize_lock; +static globus_cond_t resize_cond; +static globus_bool_t resize_done; +static globus_bool_t resize_success; + +void resize_cb(void *myargs, globus_ftp_client_handle_t *handle, + globus_object_t *error) +{ + if (error) + { + fprintf(stderr, "%s\n", globus_object_printable_to_string(error)); + globus_mutex_lock(&resize_lock); + resize_success=GLOBUS_FALSE; + globus_mutex_unlock(&resize_lock); + } + else + { + globus_mutex_lock(&resize_lock); + resize_success=GLOBUS_TRUE; + globus_mutex_unlock(&resize_lock); + } + globus_mutex_lock(&resize_lock); + resize_done=GLOBUS_TRUE; + globus_cond_signal(&resize_cond); + globus_mutex_unlock(&resize_lock); +} + + +static void resize_wrdata_cb(void *myargs, globus_ftp_client_handle_t *handle, globus_object_t *error, + globus_byte_t *buffer, globus_size_t length, globus_off_t offset, + globus_bool_t eof) +{ + if (error) + fprintf(stderr, "%s\n", globus_object_printable_to_string(error)); + if (!eof) + globus_ftp_client_register_read(handle, + buffer, + length, + resize_wrdata_cb, + myargs); + return; +} + + +void ADIOI_GRIDFTP_Resize(ADIO_File fd, ADIO_Offset size, int *error_code) +{ + int myrank, nprocs; + char myname[]="ADIOI_GRIDFTP_Resize"; + globus_off_t fsize; + globus_result_t result; + + *error_code = MPI_SUCCESS; + + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_Resize called on %s\n", + myrank, nprocs, fd->filename); +#endif /* PRINT_ERR_MSG */ + + /* Sanity check */ + if ( fd->access_mode&MPI_MODE_RDONLY ) + { + fprintf(stderr,"%s: attempt to resize read-only file %s!\n", + myname,fd->filename); + *error_code = MPI_ERR_AMODE; + ADIOI_Error(fd,*error_code,myname); + return; + } + + /* This routine is supposed to do the moral equivalent of truncate(), + but there's not an equivalent operation in the globus_ftp_client API. */ + globus_mutex_init(&resize_lock,GLOBUS_NULL); + globus_cond_init(&resize_cond,GLOBUS_NULL); + resize_done=GLOBUS_FALSE; + if ( (result=globus_ftp_client_size(&(gridftp_fh[fd->fd_sys]), + fd->filename, + &(oattr[fd->fd_sys]), + &(fsize), + resize_cb, + GLOBUS_NULL))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_size",myname,result); + *error_code=MPI_ERR_IO; + ADIOI_Error(fd,*error_code,myname); + return; + } + globus_mutex_lock(&resize_lock); + while ( resize_done!=GLOBUS_TRUE ) + globus_cond_wait(&resize_lock,&resize_cond); + if ( fsize < (globus_off_t)size ) + { + /* The file is smaller than the requested size, so + do a zero-byte write to where the new EOF should be. */ + globus_byte_t touchbuf=(globus_byte_t)'\0'; + resize_done=GLOBUS_FALSE; + if ( (result=globus_ftp_client_partial_put(&(gridftp_fh[fd->fd_sys]), + fd->filename, + &(oattr[fd->fd_sys]), + GLOBUS_NULL, + (globus_off_t)size, + (globus_off_t)size, + resize_cb, + GLOBUS_NULL))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_partial_put",myname,result); + *error_code=MPI_ERR_IO; + ADIOI_Error(fd,*error_code,myname); + return; + } + + if ( (result=globus_ftp_client_register_write(&(gridftp_fh[fd->fd_sys]), + (globus_byte_t *)&touchbuf, + 0, + (globus_off_t)0, + GLOBUS_TRUE, + resize_wrdata_cb, + GLOBUS_NULL))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_register_write",myname,result); + *error_code=MPI_ERR_IO; + ADIOI_Error(fd,*error_code,myname); + return; + } + globus_mutex_lock(&resize_lock); + while ( resize_done!=GLOBUS_TRUE ) + globus_cond_wait(&resize_cond,&resize_lock); + globus_mutex_unlock(&resize_lock); + } + else if ( fsize > (globus_off_t)size ) + { + /* The file is bigger than the requested size, so + we'll abuse globus_ftp_client_third_party_partial_put() + into truncating it for us. */ + char *urlold; + size_t urllen; + + urllen=strlen(fd->filename); + urlold=(char *)malloc(urllen+5); + sprintf(urlold,"%s.old",fd->filename); + resize_done=GLOBUS_FALSE; + resize_success=GLOBUS_FALSE; + if ( (result=globus_ftp_client_move(&(gridftp_fh[fd->fd_sys]), + fd->filename, + urlold, + &(oattr[fd->fd_sys]), + resize_cb, + GLOBUS_NULL))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_move",myname,result); + *error_code=MPI_ERR_IO; + ADIOI_Error(fd,*error_code,myname); + return; + } + globus_mutex_lock(&resize_lock); + while ( resize_done!=GLOBUS_TRUE ) + globus_cond_wait(&resize_cond,&resize_lock); + globus_mutex_unlock(&resize_lock); + if ( resize_success!=GLOBUS_TRUE ) + { + *error_code = MPI_ERR_IO; + return; + } + resize_done=GLOBUS_FALSE; + if ( (result=globus_ftp_client_partial_third_party_transfer(&(gridftp_fh[fd->fd_sys]), + urlold, + &(oattr[fd->fd_sys]), + fd->filename, + &(oattr[fd->fd_sys]), + GLOBUS_NULL, + 0, + (globus_off_t)size, + resize_cb, + GLOBUS_NULL))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_partial_third_party_transfer",myname,result); + *error_code=MPI_ERR_IO; + ADIOI_Error(fd,*error_code,myname); + return; + } + globus_mutex_lock(&resize_lock); + while ( resize_done!=GLOBUS_TRUE ) + globus_cond_wait(&resize_cond,&resize_lock); + globus_mutex_unlock(&resize_lock); + if ( resize_success!=GLOBUS_TRUE ) + { + *error_code = MPI_ERR_IO; + ADIOI_Error(fd,*error_code,myname); + return; + } + resize_done=GLOBUS_FALSE; + if ( (result=globus_ftp_client_delete(&(gridftp_fh[fd->fd_sys]), + urlold, + &(oattr[fd->fd_sys]), + resize_cb, + GLOBUS_NULL))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_delete",myname,result); + *error_code=MPI_ERR_IO; + ADIOI_Error(fd,*error_code,myname); + return; + } + globus_mutex_lock(&resize_lock); + while ( resize_done!=GLOBUS_TRUE ) + globus_cond_wait(&resize_cond,&resize_lock); + globus_mutex_unlock(&resize_lock); + if ( resize_success!=GLOBUS_TRUE ) + { + *error_code = MPI_ERR_IO; + ADIOI_Error(fd,*error_code,myname); + return; + } + } + globus_mutex_destroy(&resize_lock); + globus_cond_destroy(&resize_cond); +} + + + + + diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_seek.c gridftp/romio/adio/ad_gridftp/ad_gridftp_seek.c --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_seek.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp_seek.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,144 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $Id: ad_gridftp_seek.c,v 1.4 2002/10/24 17:01:05 gropp Exp $ + * + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +#include "ad_gridftp.h" +#include "adioi.h" +#include "adio_extern.h" + +globus_mutex_t lock; +globus_cond_t cond; +globus_bool_t seek_size_done; + +void seek_size_cb(void *myargs, globus_ftp_client_handle_t *handle, + globus_object_t *error) +{ + if (error) + { + fprintf(stderr, "%s\n", globus_object_printable_to_string(error)); + } + globus_mutex_lock(&lock); + seek_size_done=GLOBUS_TRUE; + globus_cond_signal(&cond); + globus_mutex_unlock(&lock); +} + +/* ADIOI_GRIDFTP_SeekIndividual() + * + * Implements SEEK_SET only (and doesn't test for whence type); all + * other types of whence must be converted before calling this. + * + * Returns an absolute offset in bytes. The offset passed into the call is in + * terms of the etype relative to the filetype, so some calculations are + * necessary. + */ +ADIO_Offset ADIOI_GRIDFTP_SeekIndividual(ADIO_File fd, ADIO_Offset offset, + int whence, int *error_code) +{ + int myrank, nprocs; + + ADIO_Offset off; + ADIOI_Flatlist_node *flat_file; + int i, n_etypes_in_filetype, n_filetypes, etype_in_filetype; + ADIO_Offset abs_off_in_filetype=0; + int size_in_filetype, sum; + int filetype_size, etype_size, filetype_is_contig; + MPI_Aint filetype_extent; + + char myname[]="ADIOI_GRIDFTP_SeekIndividual"; + + *error_code = MPI_SUCCESS; + + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_SeekIndividual called on %s\n", + myrank, nprocs, fd->filename); +#endif /* PRINT_ERR_MSG */ + + ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig); + etype_size = fd->etype_size; + + if (filetype_is_contig) off = fd->disp + etype_size * offset; + else { + flat_file = ADIOI_Flatlist; + while (flat_file->type != fd->filetype) flat_file = flat_file->next; + + MPI_Type_extent(fd->filetype, &filetype_extent); + MPI_Type_size(fd->filetype, &filetype_size); + if ( ! filetype_size ) { + *error_code = MPI_SUCCESS; + return 0; + } + + n_etypes_in_filetype = filetype_size/etype_size; + n_filetypes = (int) (offset / n_etypes_in_filetype); + etype_in_filetype = (int) (offset % n_etypes_in_filetype); + size_in_filetype = etype_in_filetype * etype_size; + + sum = 0; + for (i=0; icount; i++) { + sum += flat_file->blocklens[i]; + + if (sum > size_in_filetype) { + abs_off_in_filetype = flat_file->indices[i] + + size_in_filetype - (sum - flat_file->blocklens[i]); + break; + } + } + + /* abs. offset in bytes in the file */ + off = (ADIO_Offset) n_filetypes * filetype_extent + + abs_off_in_filetype; + } + + if ( whence==ADIO_SEEK_SET ) + { + fd->fp_ind = fd->disp + off; + fd->fp_sys_posn = fd->disp + off; + } + else if ( whence==ADIO_SEEK_CUR ) + { + fd->fp_ind += off; + fd->fp_sys_posn += off; + } + else if ( whence==ADIO_SEEK_END ) + { + globus_result_t result; + globus_off_t fsize; + + globus_mutex_init(&lock,GLOBUS_NULL); + globus_cond_init(&cond,GLOBUS_NULL); + seek_size_done=GLOBUS_FALSE; + if ( (result=globus_ftp_client_size(&(gridftp_fh[fd->fd_sys]), + fd->filename, + &(oattr[fd->fd_sys]), + &(fsize), + seek_size_cb, + GLOBUS_NULL))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_size",myname,result); + return 0; + } + globus_mutex_lock(&lock); + while ( seek_size_done!=GLOBUS_SUCCESS ) + globus_cond_wait(&lock,&cond); + globus_mutex_unlock(&lock); + globus_mutex_destroy(&lock); + globus_cond_destroy(&cond); + + fd->fp_ind = (ADIO_Offset)fsize + off; + fd->fp_sys_posn = (ADIO_Offset)fsize + off; + } + else + { + fprintf(stderr,"%s: Invalid seek type!\n",myname); + return 0; + } + + return fd->fp_ind; +} diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_setsh.c gridftp/romio/adio/ad_gridftp/ad_gridftp_setsh.c --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_setsh.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp_setsh.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,25 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $Id: ad_gridftp_setsh.c,v 1.2 2002/10/24 17:01:05 gropp Exp $ + * + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +#include "ad_gridftp.h" +#include "adioi.h" + +void ADIOI_GRIDFTP_Set_shared_fp(ADIO_File fd, ADIO_Offset offset, + int *error_code) +{ + int myrank, nprocs; + + *error_code = MPI_SUCCESS; + + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_Set_shared_fp called on %s\n", + myrank, nprocs, fd->filename); +#endif /* PRINT_ERR_MSG */ +} diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_wait.c gridftp/romio/adio/ad_gridftp/ad_gridftp_wait.c --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_wait.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp_wait.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,64 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $Id: ad_gridftp_wait.c,v 1.4 2002/10/24 17:01:05 gropp Exp $ + * + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +#include "ad_gridftp.h" +#include "adioi.h" + +void ADIOI_GRIDFTP_ReadComplete(ADIO_Request *request, ADIO_Status *status, int + *error_code) +{ + int myrank, nprocs; + + *error_code = MPI_SUCCESS; + + if (*request == ADIO_REQUEST_NULL) { + FPRINTF(stdout, "[xx/xx] ADIOI_GRIDFTP_ReadComplete called on ADIO_REQUEST_NULL\n"); + return; + } + + MPI_Comm_size((*request)->fd->comm, &nprocs); + MPI_Comm_rank((*request)->fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_ReadComplete called on %s\n", + myrank, nprocs, (*request)->fd->filename); +#endif /* PRINT_ERR_MSG */ + +#ifdef HAVE_STATUS_SET_BYTES + MPIR_Status_set_bytes(status, (*request)->datatype, (*request)->nbytes); +#endif + (*request)->fd->async_count--; + ADIOI_Free_request((ADIOI_Req_node *) (*request)); + *request = ADIO_REQUEST_NULL; +} + +void ADIOI_GRIDFTP_WriteComplete(ADIO_Request *request, ADIO_Status *status, int + *error_code) +{ + int myrank, nprocs; + + *error_code = MPI_SUCCESS; + + if (*request == ADIO_REQUEST_NULL) { + FPRINTF(stderr, "[?/?] ADIOI_GRIDFTP_WriteComplete called on ADIO_REQUEST_NULL\n"); + return; + } + + MPI_Comm_size((*request)->fd->comm, &nprocs); + MPI_Comm_rank((*request)->fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_WriteComplete called on %s\n", + myrank, nprocs, (*request)->fd->filename); +#endif /* PRINT_ERR_MSG */ + +#ifdef HAVE_STATUS_SET_BYTES + MPIR_Status_set_bytes(status, (*request)->datatype, (*request)->nbytes); +#endif + (*request)->fd->async_count--; + ADIOI_Free_request((ADIOI_Req_node *) (*request)); + *request = ADIO_REQUEST_NULL; +} diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_wrcoll.c gridftp/romio/adio/ad_gridftp/ad_gridftp_wrcoll.c --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_wrcoll.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp_wrcoll.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,32 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $Id: ad_gridftp_wrcoll.c,v 1.4 2002/10/24 17:01:06 gropp Exp $ + * + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +#include "ad_gridftp.h" +#include "adioi.h" + +void ADIOI_GRIDFTP_WriteStridedColl(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Status *status, + int *error_code) +{ + int myrank, nprocs; + + *error_code = MPI_SUCCESS; + + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_WriteStridedColl called on %s\n", + myrank, nprocs, fd->filename); + FPRINTF(stdout, "[%d/%d] calling ADIOI_GEN_WriteStridedColl\n", + myrank, nprocs); +#endif /* PRINT_ERR_MSG */ + + ADIOI_GEN_WriteStridedColl(fd, buf, count, datatype, file_ptr_type, + offset, status, error_code); +} diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_write.c gridftp/romio/adio/ad_gridftp/ad_gridftp_write.c --- mpich-1.2.6/romio/adio/ad_gridftp/ad_gridftp_write.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/ad_gridftp_write.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,501 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $Id: ad_gridftp_write.c,v 1.5 2002/10/24 17:01:06 gropp Exp $ + * + * Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. + * See COPYRIGHT notice in top-level directory. + */ + +#include "ad_gridftp.h" +#include "adioi.h" +#include "adio_extern.h" + +static globus_mutex_t writecontig_ctl_lock; +static globus_cond_t writecontig_ctl_cond; +static globus_bool_t writecontig_ctl_done; +static void writecontig_ctl_cb(void *myargs, globus_ftp_client_handle_t *handle, globus_object_t *error) +{ + if (error) + { + fprintf(stderr, "%s\n", globus_object_printable_to_string(error)); + } + globus_mutex_lock(&writecontig_ctl_lock); + if ( writecontig_ctl_done!=GLOBUS_TRUE ) + writecontig_ctl_done=GLOBUS_TRUE; + globus_cond_signal(&writecontig_ctl_cond); + globus_mutex_unlock(&writecontig_ctl_lock); +#ifdef PRINT_ERR_MSG + fprintf(stderr,"finished with contig write transaction\n"); +#endif /* PRINT_ERR_MSG */ + return; +} + +static void writecontig_data_cb(void *myargs, globus_ftp_client_handle_t *handle, globus_object_t *error, + globus_byte_t *buffer, globus_size_t length, globus_off_t offset, + globus_bool_t eof) +{ + globus_size_t *bytes_written; + + bytes_written=(globus_size_t *)myargs; + if (error) + { + fprintf(stderr, "%s\n", globus_object_printable_to_string(error)); + } + *bytes_written+=length; + /* I don't understand why the data callback has to keep recalling register_write, + but everything I've done and all the examples I've seen seem to require + that behavior to work... */ + if ( !eof ) + { + globus_ftp_client_register_write(handle, + buffer, + length, + offset, + GLOBUS_TRUE, + writecontig_data_cb, + (void *)(bytes_written)); + } +#ifdef PRINT_ERR_MSG + fprintf(stderr,"wrote %Ld bytes...",(long long)length); +#endif /* PRINT_ERR_MSG */ + return; +} + + +static globus_mutex_t writediscontig_ctl_lock; +static globus_cond_t writediscontig_ctl_cond; +static globus_bool_t writediscontig_ctl_done; +static void writediscontig_ctl_cb(void *myargs, globus_ftp_client_handle_t *handle, globus_object_t *error) +{ + if (error) + { + fprintf(stderr, "%s\n", globus_object_printable_to_string(error)); + } + globus_mutex_lock(&writediscontig_ctl_lock); + if ( writediscontig_ctl_done!=GLOBUS_TRUE ) + writediscontig_ctl_done=GLOBUS_TRUE; + globus_cond_signal(&writediscontig_ctl_cond); + globus_mutex_unlock(&writediscontig_ctl_lock); + return; +} + +static void writediscontig_data_cb(void *myargs, globus_ftp_client_handle_t *handle, globus_object_t *error, + globus_byte_t *buffer, globus_size_t length, globus_off_t offset, + globus_bool_t eof) +{ + globus_size_t *bytes_written; + + bytes_written=(globus_size_t *)myargs; + if (error) + { + fprintf(stderr, "%s\n", globus_object_printable_to_string(error)); + } + *bytes_written+=length; + /* I don't understand why the data callback has to keep recalling register_read, + but everything I've done and all the examples I've seen seem to require + that behavior to work... */ + if ( !eof ) + globus_ftp_client_register_write(handle, + buffer, + length, + offset, + eof, + writediscontig_data_cb, + (void *)(bytes_written)); + fprintf(stderr,"wrote %Ld bytes...",(long long)length); + return; +} + + +void ADIOI_GRIDFTP_WriteContig(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Status *status, int + *error_code) +{ + char myname[]="ADIOI_GRIDFTP_WriteContig"; + int myrank, nprocs, datatype_size; + globus_size_t len,bytes_written=0; + globus_off_t goff; + globus_result_t result; + + if ( fd->access_mode&MPI_MODE_RDONLY ) + { + *error_code=MPI_ERR_AMODE; + return; + } + + *error_code = MPI_SUCCESS; + + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); + MPI_Type_size(datatype, &datatype_size); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_WriteContig called on %s\n", myrank, + nprocs, fd->filename); +#endif /* PRINT_ERR_MSG */ + +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] writing (buf = 0x%08x, loc = %Ld, sz = %Ld)\n", + myrank, nprocs, (int) buf, (long long) offset, + (long long) datatype_size * count); +#endif /* PRINT_ERR_MSG */ + + if (file_ptr_type != ADIO_EXPLICIT_OFFSET) + { + offset = fd->fp_ind; + } + + /* Do the gridftp I/O transfer */ + goff = (globus_off_t)offset; + len = ((globus_size_t)datatype_size)*((globus_size_t)count); + + globus_mutex_init(&writecontig_ctl_lock, GLOBUS_NULL); + globus_cond_init(&writecontig_ctl_cond, GLOBUS_NULL); + writecontig_ctl_done=GLOBUS_FALSE; + if ( (result=globus_ftp_client_partial_put(&(gridftp_fh[fd->fd_sys]), + fd->filename, + &(oattr[fd->fd_sys]), + GLOBUS_NULL, + goff, + goff+(globus_off_t)len, + writecontig_ctl_cb, + GLOBUS_NULL))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_partial_put",myname,result); + *error_code=MPI_ERR_IO; + ADIOI_Error(fd,*error_code,myname); + return; + } + if ( (result=globus_ftp_client_register_write(&(gridftp_fh[fd->fd_sys]), + (globus_byte_t *)buf, + len, + goff, + GLOBUS_TRUE, + writecontig_data_cb, + (void *)(&bytes_written)))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_register_write",myname,result); + *error_code=MPI_ERR_IO; + ADIOI_Error(fd,*error_code,myname); + return; + } + + + /* The ctl callback won't start till the data callbacks complete, so it's + safe to wait on just the ctl callback */ + globus_mutex_lock(&writecontig_ctl_lock); + while ( writecontig_ctl_done!=GLOBUS_TRUE ) + globus_cond_wait(&writecontig_ctl_cond,&writecontig_ctl_lock); + globus_mutex_unlock(&writecontig_ctl_lock); + + globus_mutex_destroy(&writecontig_ctl_lock); + globus_cond_destroy(&writecontig_ctl_cond); + +#ifdef HAVE_STATUS_SET_BYTES + MPIR_Status_set_bytes(status, datatype, bytes_written); +#endif + if (file_ptr_type != ADIO_EXPLICIT_OFFSET) + { + offset = fd->fp_ind; + fd->fp_ind += bytes_written; + fd->fp_sys_posn = fd->fp_ind; +#if 0 + FPRINTF(stdout, "[%d/%d] new file position is %Ld\n", myrank, + nprocs, (long long) fd->fp_ind); +#endif + } + else { + fd->fp_sys_posn = offset + bytes_written; + } +} + + +void ADIOI_GRIDFTP_WriteDiscontig(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Status *status, int + *error_code) +{ + char myname[]="ADIOI_GRIDFTP_WriteDiscontig"; + int myrank,nprocs; + MPI_Aint btype_size,btype_extent; + MPI_Aint ftype_size,ftype_extent; + MPI_Aint etype_size; + MPI_Aint extent; + ADIOI_Flatlist_node *flat_file; + int buf_contig,boff,i,nblks; + globus_off_t start,end,goff; + globus_size_t bytes_written; + globus_result_t result; + + MPI_Comm_rank(fd->comm,&myrank); + MPI_Comm_size(fd->comm,&nprocs); + fprintf(stderr,"[%d/%d] Entering %s\n",myrank,nprocs,myname); + fflush(stderr); + etype_size=fd->etype_size; + MPI_Type_size(fd->filetype,&ftype_size); + MPI_Type_extent(fd->filetype,&ftype_extent); + /* This is arguably unnecessary, as this routine assumes that the + buffer in memory is contiguous */ + MPI_Type_size(datatype,&btype_size); + MPI_Type_extent(datatype,&btype_extent); + ADIOI_Datatype_iscontig(datatype,&buf_contig); + + if ( ( btype_extent!=btype_size ) || ( ! buf_contig ) ) + { + fprintf(stderr,"[%d/%d] %s called with discontigous memory buffer\n", + myrank,nprocs,myname); + fflush(stderr); + *error_code=MPI_ERR_TYPE; + ADIOI_Error(fd,*error_code,myname); + return; + } + /* from here we can assume btype_extent==btype_size */ + + /* Flatten out fd->filetype so we know which blocks to skip */ + ADIOI_Flatten_datatype(fd->filetype); + flat_file = ADIOI_Flatlist; + while (flat_file->type != fd->filetype && flat_file->next!=NULL) + flat_file = flat_file->next; + + /* Figure out how big the area to write is */ + /* ASSUMPTION: ftype_size is an integer multiple of btype_size or vice versa. */ + start=(globus_off_t)(offset*etype_size); + goff=start; + boff=0; + extent=0; + nblks=0; + while ( boff < (count*btype_size) ) + { + int blklen; + + for (i=0;icount;i++) + { + if ( (boff+flat_file->blocklens[i]) < (count*btype_size) ) + blklen=flat_file->blocklens[i]; + else + blklen=(count*btype_size)-boff; + boff+=blklen; + extent=MAX(extent,nblks*ftype_extent+flat_file->indices[i]+blklen); + if ( boff>=(count*btype_size) ) + break; + /* + fprintf(stderr,"[%d/%d] %s i=%d nblks=%d blklen=%d extent=%d\n", + myrank,nprocs,myname,i,nblks,blklen,extent);*/ + } + nblks++; + } + if ( extent < count*btype_size ) + { + fprintf(stderr,"[%d/%d] %s error in computing extent -- extent %d is smaller than total bytes requested %d!\n", + myrank,nprocs,myname,extent,count*btype_size); + fflush(stderr); + *error_code=MPI_ERR_TYPE; + ADIOI_Error(fd,*error_code,myname); + return; + } + end=start+(globus_off_t)extent; + fprintf(stderr,"[%d/%d] %s writing %d bytes into extent of %d bytes starting at offset %Ld\n", + myrank,nprocs,myname,count*btype_size,extent,(long long)start); + fflush(stderr); + + /* start up the globus partial write */ + globus_mutex_init(&writediscontig_ctl_lock, GLOBUS_NULL); + globus_cond_init(&writediscontig_ctl_cond, GLOBUS_NULL); + writediscontig_ctl_done=GLOBUS_FALSE; + if ( (result=globus_ftp_client_partial_put(&(gridftp_fh[fd->fd_sys]), + fd->filename, + &(oattr[fd->fd_sys]), + GLOBUS_NULL, + start, + end, + writediscontig_ctl_cb, + GLOBUS_NULL))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_partial_get",myname,result); + *error_code=MPI_ERR_IO; + ADIOI_Error(fd,*error_code,myname); + return; + } + + /* Do all the actual I/Os */ + boff=0; + nblks=0; + while ( boff < (count*btype_size) ) + { + int i,blklen; + + for (i=0;icount;i++) + { + if ( (boff+flat_file->blocklens[i]) < (count*btype_size) ) + blklen=flat_file->blocklens[i]; + else + blklen=(count*btype_size)-boff; + if ( blklen > 0 ) + { + goff=start+nblks*ftype_extent+((globus_off_t)flat_file->indices[i]); + /* + fprintf(stderr,"[%d/%d] %s writing %d bytes from boff=%d at goff=%Ld\n",myrank,nprocs,myname,blklen,boff,goff); + */ + if ( (result=globus_ftp_client_register_write(&(gridftp_fh[fd->fd_sys]), + ((globus_byte_t *)buf)+boff, + (globus_size_t)blklen, + goff, + GLOBUS_TRUE, + writediscontig_data_cb, + (void *)(&bytes_written)))!=GLOBUS_SUCCESS ) + { + globus_err_handler("globus_ftp_client_register_write",myname,result); + *error_code=MPI_ERR_IO; + ADIOI_Error(fd,*error_code,myname); + return; + } + boff+=blklen; + if ( boff>=(count*btype_size) ) + break; + } + } + nblks++; + } + + + /* The ctl callback won't start till the data callbacks complete, so it's + safe to wait on just the ctl callback */ + globus_mutex_lock(&writediscontig_ctl_lock); + while ( writediscontig_ctl_done!=GLOBUS_TRUE ) + globus_cond_wait(&writediscontig_ctl_cond,&writediscontig_ctl_lock); + globus_mutex_unlock(&writediscontig_ctl_lock); + globus_mutex_destroy(&writediscontig_ctl_lock); + globus_cond_destroy(&writediscontig_ctl_cond); + +#ifdef HAVE_STATUS_SET_BYTES + MPIR_Status_set_bytes(status, datatype, bytes_written); +#endif + if (file_ptr_type != ADIO_EXPLICIT_OFFSET) + { + fd->fp_ind += extent; + fd->fp_sys_posn = fd->fp_ind; +#if 0 + FPRINTF(stdout, "[%d/%d] new file position is %Ld\n", myrank, + nprocs, (long long) fd->fp_ind); +#endif + } + else { + fd->fp_sys_posn = offset + extent; + } + fprintf(stderr,"[%d/%d] Exiting %s\n", + myrank,nprocs,myname); + fflush(stderr); +} + + +#define GRIDFTP_USE_GENERIC_STRIDED +void ADIOI_GRIDFTP_WriteStrided(ADIO_File fd, void *buf, int count, + MPI_Datatype datatype, int file_ptr_type, + ADIO_Offset offset, ADIO_Status *status, + int *error_code) +{ +#ifdef GRIDFTP_USE_GENERIC_STRIDED + int myrank, nprocs; + + if ( fd->access_mode&MPI_MODE_RDONLY ) + { + *error_code=MPI_ERR_AMODE; + return; + } + + *error_code = MPI_SUCCESS; + + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_WriteStrided called on %s\n", + myrank, nprocs, fd->filename); + FPRINTF(stdout, "[%d/%d] writing (buf = 0x%08x, loc = %Ld)\n", + myrank, nprocs, (int) buf, (long long) offset); + FPRINTF(stdout, "[%d/%d] calling ADIOI_GEN_WriteStrided\n", + myrank, nprocs); +#endif /* PRINT_ERR_MSG */ + + ADIOI_GEN_WriteStrided(fd, buf, count, datatype, file_ptr_type, offset, + status, error_code); + return; +#else + char myname[]="ADIOI_GRIDFTP_WriteStrided"; + int myrank, nprocs; + int buf_contig,file_contig; + MPI_Aint btype_size,bufsize; + globus_byte_t *intermediate; + + *error_code = MPI_SUCCESS; + + MPI_Comm_size(fd->comm, &nprocs); + MPI_Comm_rank(fd->comm, &myrank); +#ifdef PRINT_ERR_MSG + FPRINTF(stdout, "[%d/%d] ADIOI_GRIDFTP_WriteStrided called on %s\n", myrank, + nprocs, fd->filename); +#endif /* PRINT_ERR_MSG */ + + MPI_Type_size(datatype,&btype_size); + bufsize=count*btype_size; + ADIOI_Datatype_iscontig(fd->filetype,&file_contig); + ADIOI_Datatype_iscontig(datatype,&buf_contig); + if ( buf_contig && !file_contig ) + { + /* Contiguous in memory, discontig in file */ + fprintf(stderr,"[%d/%d] %s called w/ contig mem, discontig file\n", + myrank,nprocs,myname); + fflush(stderr); + + ADIOI_GRIDFTP_WriteDiscontig(fd, buf, count, datatype, + file_ptr_type, offset, status, error_code); + } + else if ( !buf_contig && file_contig ) + { + /* Discontiguous in mem, contig in file -- comparatively easy */ + int posn=0; + + fprintf(stderr,"[%d/%d] %s called w/ discontig mem, contig file\n", + myrank,nprocs,myname); + fflush(stderr); + + + /* squeeze contents of main buffer into intermediate buffer*/ + intermediate=(globus_byte_t *)malloc((size_t)bufsize); + MPI_Pack(buf,count,datatype,intermediate,bufsize,&posn,fd->comm); + + /* write contiguous data from intermediate buffer */ + ADIOI_GRIDFTP_WriteContig(fd, intermediate, bufsize, MPI_BYTE, + file_ptr_type, offset, status, error_code); + + free(intermediate); + } + else if ( !buf_contig && !file_contig ) + { + /* Discontig in both mem and file -- the hardest case */ + int posn=0; + + fprintf(stderr,"[%d/%d] %s called w/ discontig mem, discontig file\n", + myrank,nprocs,myname); + fflush(stderr); + + /* squeeze contents of main buffer into intermediate buffer*/ + intermediate=(globus_byte_t *)malloc((size_t)bufsize); + MPI_Pack(buf,count,datatype,intermediate,bufsize,&posn,fd->comm); + + /* write contiguous data from intermediate buffer */ + ADIOI_GRIDFTP_WriteDiscontig(fd, intermediate, bufsize, MPI_BYTE, + file_ptr_type, offset, status, error_code); + + free(intermediate); + } + else + { + /* Why did you bother calling WriteStrided?!?!?! */ + fprintf(stderr,"[%d/%d] Why the heck did you call %s with contiguous buffer *and* file types?\n", + myrank,nprocs,myname); + ADIOI_GRIDFTP_WriteContig(fd, buf, count, datatype, + file_ptr_type, offset, status, error_code); + } +#endif /* ! GRIDFTP_USE_GENERIC_STRIDED */ +} + diff -ruN mpich-1.2.6/romio/adio/ad_gridftp/globus_routines.c gridftp/romio/adio/ad_gridftp/globus_routines.c --- mpich-1.2.6/romio/adio/ad_gridftp/globus_routines.c 1969-12-31 19:00:00.000000000 -0500 +++ gridftp/romio/adio/ad_gridftp/globus_routines.c 2004-08-24 14:11:52.000000000 -0400 @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include "adio.h" +#include + +/* Here are the canonical definitions of the extern's referenced by + ad_gridftp.h */ +int num_gridftp_handles=0; +#ifndef ADIO_GRIDFTP_HANDLES_MAX +#define ADIO_GRIDFTP_HANDLES_MAX 200 +#endif /* ! ADIO_GRIDFTP_HANDLES_MAX */ +/* having to keep not one but two big global tables sucks... */ +globus_ftp_client_handle_t gridftp_fh[ADIO_GRIDFTP_HANDLES_MAX]; +globus_ftp_client_operationattr_t oattr[ADIO_GRIDFTP_HANDLES_MAX]; + +void globus_err_handler(const char *routine, const char *caller, + globus_result_t result) +{ + int myrank,nprocs; + globus_object_t *err; + + MPI_Comm_rank(MPI_COMM_WORLD,&myrank); + MPI_Comm_size(MPI_COMM_WORLD,&nprocs); + err = globus_error_get(result); + FPRINTF(stderr, "[%d/%d] %s error \"%s\", called from %s\n", + myrank,nprocs,routine,globus_object_printable_to_string(err),caller); +} diff -ruN mpich-1.2.6/romio/adio/common/ad_fstype.c gridftp/romio/adio/common/ad_fstype.c --- mpich-1.2.6/romio/adio/common/ad_fstype.c 2003-09-04 16:24:44.000000000 -0400 +++ gridftp/romio/adio/common/ad_fstype.c 2004-08-24 14:11:52.000000000 -0400 @@ -244,6 +244,10 @@ # else if (fsbuf.f_type == MOUNT_NFS) *fstype = ADIO_NFS; # endif +# ifdef ROMIO_GRIDFTP + else if ( !strncmp("ftp:",filename,4) || !strncmp("gsiftp:",filename,7) ) + *fstype = ADIO_GRIDFTP; +# endif else *fstype = ADIO_UFS; } #elif defined(PARAGON) @@ -359,6 +363,9 @@ { *fstype = ADIO_TESTFS; } + else if (!strncmp(filename, "ftp:", 4) || !strncmp(filename, "gsiftp:", 7)){ + *fstype = ADIO_GRIDFTP; + } else { #ifdef ROMIO_NTFS *fstype = ADIO_NTFS; @@ -407,7 +414,7 @@ *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**iofstype", 0); return; #elif defined(PRINT_ERR_MSG) - FPRINTF(stderr, "ADIO_ResolveFileType: Can't determine the file-system type. Check the filename/path you provided and try again. Otherwise, prefix the filename with a string to indicate the type of file sytem (piofs:, pfs:, nfs:, ufs:, hfs:, xfs:, sfs:, pvfs:).\n"); + FPRINTF(stderr, "ADIO_ResolveFileType: Can't determine the file-system type. Check the filename/path you provided and try again. Otherwise, prefix the filename with a string to indicate the type of file sytem (piofs:, pfs:, nfs:, ufs:, hfs:, xfs:, sfs:, pvfs:, pvfs2:, ftp:, gsiftp:).\n"); MPI_Abort(MPI_COMM_WORLD, 1); #else /* MPICH-1 */ myerrcode = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_FSTYPE, @@ -644,6 +651,21 @@ *ops = &ADIO_TESTFS_operations; #endif } + if (file_system == ADIO_GRIDFTP) { +#ifndef ROMIO_GRIDFTP +# ifdef PRINT_ERR_MSG + FPRINTF(stderr, "ADIO_ResolveFileType: ROMIO has not been configured to use the GridFTP access method\n"); + MPI_Abort(MPI_COMM_WORLD, 1); +# else + myerrcode = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_TESTFS, + myname, (char *) 0, (char *) 0); + *error_code = ADIOI_Error(MPI_FILE_NULL, myerrcode, myname); + return; +# endif +#else + *ops = &ADIO_GRIDFTP_operations; +#endif + } *error_code = MPI_SUCCESS; *fstype = file_system; return; diff -ruN mpich-1.2.6/romio/adio/common/setfn.c gridftp/romio/adio/common/setfn.c --- mpich-1.2.6/romio/adio/common/setfn.c 2003-06-24 18:48:18.000000000 -0400 +++ gridftp/romio/adio/common/setfn.c 2004-08-24 14:11:52.000000000 -0400 @@ -114,6 +114,15 @@ #endif break; + case ADIO_GRIDFTP: +#ifdef ROMIO_GRIDFTP + *(fd->fns) = ADIO_GRIDFTP_operations; +#else + FPRINTF(stderr, "ADIOI_SetFunctions: ROMIO has not been configured to use the GridFTP access method\n"); + MPI_Abort(MPI_COMM_WORLD, 1); +#endif + break; + default: FPRINTF(stderr, "ADIOI_SetFunctions: Unsupported file system type\n"); MPI_Abort(MPI_COMM_WORLD, 1); diff -ruN mpich-1.2.6/romio/adio/include/BaseIOErrMsgs.msg gridftp/romio/adio/include/BaseIOErrMsgs.msg --- mpich-1.2.6/romio/adio/include/BaseIOErrMsgs.msg 2000-01-21 15:55:41.000000000 -0500 +++ gridftp/romio/adio/include/BaseIOErrMsgs.msg 2004-08-24 14:11:52.000000000 -0400 @@ -25,7 +25,7 @@ 32 1 "I/O Error" 32 2 "%s" 1 32 3 "Only an integral number of etypes can be accessed" -32 5 "Can't determine the file-system type. Check the filename/path you provided and try again. Otherwise, prefix the filename with a string to indicate the type of file sytem (piofs:, pfs:, nfs:, ufs:, hfs:, xfs:, sfs:, pvfs:)" +32 5 "Can't determine the file-system type. Check the filename/path you provided and try again. Otherwise, prefix the filename with a string to indicate the type of file system (piofs:, pfs:, nfs:, ufs:, hfs:, xfs:, sfs:, pvfs:, pvfs2:, ftp:, gsiftp:)" 32 7 "ROMIO has not been configured to use the PFS file system" 32 9 "ROMIO has not been configured to use the PIOFS file system" 32 11 "ROMIO has not been configured to use the UFS file system" diff -ruN mpich-1.2.6/romio/adio/include/adio.h gridftp/romio/adio/include/adio.h --- mpich-1.2.6/romio/adio/include/adio.h 2004-06-07 13:59:57.000000000 -0400 +++ gridftp/romio/adio/include/adio.h 2004-08-24 14:11:52.000000000 -0400 @@ -276,6 +276,7 @@ #define ADIO_NTFS 158 /* NTFS for Windows NT */ #define ADIO_TESTFS 159 /* fake file system for testing */ #define ADIO_PVFS2 160 /* PVFS2: 2nd generation PVFS */ +#define ADIO_GRIDFTP 161 /* Globus GridFTP */ #define ADIO_SEEK_SET SEEK_SET #define ADIO_SEEK_CUR SEEK_CUR diff -ruN mpich-1.2.6/romio/adio/include/adioi_errmsg.h gridftp/romio/adio/include/adioi_errmsg.h --- mpich-1.2.6/romio/adio/include/adioi_errmsg.h 2003-05-28 20:02:38.000000000 -0400 +++ gridftp/romio/adio/include/adioi_errmsg.h 2004-08-24 14:11:52.000000000 -0400 @@ -43,7 +43,7 @@ MPI_ERR_IO MPIR_ERR_ETYPE_FRACTIONAL "Only an integral number of etypes can be accessed" - MPIR_ERR_NO_FSTYPE "Can't determine the file-system type. Check the filename/path you provided and try again. Otherwise, prefix the filename with a string to indicate the type of file sytem (piofs:, pfs:, nfs:, ufs:, hfs:, xfs:, sfs:, pvfs:)" + MPIR_ERR_NO_FSTYPE "Can't determine the file-system type. Check the filename/path you provided and try again. Otherwise, prefix the filename with a string to indicate the type of file system (piofs:, pfs:, nfs:, ufs:, hfs:, xfs:, sfs:, pvfs:, pvfs2: ftp:, gsiftp:)" MPIR_ERR_NO_PFS "ROMIO has not been configured to use the PFS file system" MPIR_ERR_NO_PIOFS "ROMIO has not been configured to use the PIOFS file system" MPIR_ERR_NO_UFS "ROMIO has not been configured to use the UFS file system" diff -ruN mpich-1.2.6/romio/adio/include/adioi_fs_proto.h gridftp/romio/adio/include/adioi_fs_proto.h --- mpich-1.2.6/romio/adio/include/adioi_fs_proto.h 2003-06-24 18:48:23.000000000 -0400 +++ gridftp/romio/adio/include/adioi_fs_proto.h 2004-08-24 14:11:52.000000000 -0400 @@ -584,4 +584,9 @@ /* prototypes are in adio/ad_testfs/ad_testfs.h */ #endif +#ifdef ROMIO_GRIDFTP +/* prototypes are in adio/ad_gridftp/ad_gridftp.h */ +extern struct ADIOI_Fns_struct ADIO_GRIDFTP_operations; +#endif + #endif diff -ruN mpich-1.2.6/romio/adio/include/romioconf.h.in gridftp/romio/adio/include/romioconf.h.in --- mpich-1.2.6/romio/adio/include/romioconf.h.in 2004-08-04 12:08:28.000000000 -0400 +++ gridftp/romio/adio/include/romioconf.h.in 2004-08-24 14:11:52.000000000 -0400 @@ -195,6 +195,9 @@ /* Define for PIOFS */ #undef PIOFS +/* Define for Romio with gridftp */ +#undef ROMIO_GRIDFTP + /* Define if mpi_test needed */ #undef NEEDS_MPI_TEST diff -ruN mpich-1.2.6/romio/configure.in gridftp/romio/configure.in --- mpich-1.2.6/romio/configure.in 2004-08-02 09:37:31.000000000 -0400 +++ gridftp/romio/configure.in 2004-08-24 14:11:52.000000000 -0400 @@ -90,7 +90,7 @@ # have_aio=no # -known_filesystems="nfs ufs pfs piofs pvfs pvfs2 testfs xfs hfs sfs" +known_filesystems="nfs ufs pfs piofs pvfs pvfs2 testfs xfs hfs sfs gridftp" known_mpi_impls="mpich_mpi sgi_mpi hp_mpi cray_mpi lam_mpi" # # Defaults @@ -1276,6 +1276,9 @@ ROMIO_LFLAGS="$USER_FFLAGS -bI:/usr/include/piofs/piofs.exp" USER_FFLAGS="$USER_FFLAGS -bI:/usr/include/piofs/piofs.exp" fi +if test -n "$file_system_gridftp"; then + AC_DEFINE(ROMIO_GRIDFTP,1,[Define for Romio with gridftp]) +fi if test -n "$mpi_mpich"; then if test -z "$arch_SX4" ; then MPIOF_H_INCLUDED=1 @@ -1636,6 +1639,7 @@ adio/ad_sfs/Makefile adio/ad_pfs/Makefile \ adio/ad_testfs/Makefile adio/ad_pvfs/Makefile \ adio/ad_pvfs2/Makefile adio/ad_piofs/Makefile \ + adio/ad_gridftp/Makefile \ mpi-io/fortran/Makefile mpi2-other/info/fortran/Makefile \ mpi2-other/array/fortran/Makefile test/fmisc.f \ test/fcoll_test.f test/pfcoll_test.f test/fperf.f ) diff -ruN mpich-1.2.6/romio/mpi-io/close.c gridftp/romio/mpi-io/close.c --- mpich-1.2.6/romio/mpi-io/close.c 2004-04-06 14:46:31.000000000 -0400 +++ gridftp/romio/mpi-io/close.c 2004-08-24 14:11:52.000000000 -0400 @@ -53,7 +53,7 @@ ADIOI_TEST_FILE_HANDLE(*fh, myname); #endif - if (((*fh)->file_system != ADIO_PIOFS) && ((*fh)->file_system != ADIO_PVFS) && ((*fh)->file_system != ADIO_PVFS2)) { + if (((*fh)->file_system != ADIO_PIOFS) && ((*fh)->file_system != ADIO_PVFS) && ((*fh)->file_system != ADIO_PVFS2) && ((*fh)->file_system != ADIO_GRIDFTP)) { ADIOI_Free((*fh)->shared_fp_fname); /* need a barrier because the file containing the shared file pointer is opened with COMM_SELF. We don't want it to be diff -ruN mpich-1.2.6/romio/mpi-io/delete.c gridftp/romio/mpi-io/delete.c --- mpich-1.2.6/romio/mpi-io/delete.c 2004-02-12 01:08:22.000000000 -0500 +++ gridftp/romio/mpi-io/delete.c 2004-08-24 14:11:52.000000000 -0400 @@ -107,12 +107,14 @@ } /* --END ERROR HANDLING-- */ - /* skip prefix on filename if there is one */ + /* skip prefix on filename if there is one and it's not a known URL (eg. ftp:// or gsiftp:// ) */ tmp = strchr(filename, ':'); /* Only skip prefixes greater than length one to allow for windows drive specification (c:\...)*/ /*if (tmp) filename = tmp + 1;*/ - if (tmp > filename + 1) - filename = tmp + 1; + if (!(!strncmp(filename,"ftp:",4) || !strncmp(filename,"gsiftp:",7))) { + if (tmp > filename + 1) + filename = tmp + 1; + } /* call the fs-specific delete function */ (fsops->ADIOI_xxx_Delete)(filename, &error_code); diff -ruN mpich-1.2.6/romio/mpi-io/open.c gridftp/romio/mpi-io/open.c --- mpich-1.2.6/romio/mpi-io/open.c 2004-05-19 19:55:09.000000000 -0400 +++ gridftp/romio/mpi-io/open.c 2004-08-24 14:11:52.000000000 -0400 @@ -213,7 +213,7 @@ * invalid flags through some functional interface rather than having * these tests here. -- Rob, 06/06/2001 */ - if (((file_system == ADIO_PIOFS) || (file_system == ADIO_PVFS) || (file_system == ADIO_PVFS2)) && + if (((file_system == ADIO_PIOFS) || (file_system == ADIO_PVFS) || (file_system == ADIO_PVFS2) || (file_system == ADIO_GRIDFTP)) && (amode & MPI_MODE_SEQUENTIAL)) { #ifdef MPICH2 @@ -221,7 +221,7 @@ "**iosequnsupported", 0); return MPIR_Err_return_file(MPI_FILE_NULL, myname, error_code); #elif defined(PRINT_ERR_MSG) - FPRINTF(stderr, "MPI_File_open: MPI_MODE_SEQUENTIAL not supported on PIOFS and PVFS\n"); + FPRINTF(stderr, "MPI_File_open: MPI_MODE_SEQUENTIAL not supported\n"); MPI_Abort(MPI_COMM_WORLD, 1); #else /* MPICH-1 */ error_code = MPIR_Err_setmsg(MPI_ERR_UNSUPPORTED_OPERATION, @@ -231,12 +231,15 @@ } /* --END ERROR HANDLING-- */ - /* strip off prefix if there is one */ + /* strip off prefix if there is one, and if it's not a URL + (eg. ftp://ftp.foo.edu/bar/baz) handled by GridFTP */ tmp = strchr(filename, ':'); /* Only skip prefixes greater than length one to allow for windows drive specification (c:\...)*/ /*if (tmp) filename = tmp + 1;*/ - if (tmp > filename + 1) - filename = tmp + 1; + if (!(!strncmp(filename,"ftp:",4) || !strncmp(filename,"gsiftp:",7))) { + if (tmp > filename + 1) + filename = tmp + 1; + } /* use default values for disp, etype, filetype */ /* set iomode=M_ASYNC. It is used to implement the Intel PFS interface @@ -250,10 +253,11 @@ /* determine name of file that will hold the shared file pointer */ /* can't support shared file pointers on a file system that doesn't - support file locking, e.g., PIOFS, PVFS, PVFS2 */ + support file locking. */ if ((error_code == MPI_SUCCESS) && ((*fh)->file_system != ADIO_PIOFS) && ((*fh)->file_system != ADIO_PVFS) - && ((*fh)->file_system != ADIO_PVFS2) ){ + && ((*fh)->file_system != ADIO_PVFS2) + && ((*fh)->file_system != ADIO_GRIDFTP) ){ MPI_Comm_rank(dupcomm, &rank); ADIOI_Shfp_fname(*fh, rank);