X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a8789d26b134d65148058b8ec759127e97055b67..01a65e5b91b500b3659a5c52cc386bbecc77f608:/src/smpi/smpi_f77.c diff --git a/src/smpi/smpi_f77.c b/src/smpi/smpi_f77.c index a74500b8d6..95c40d7209 100644 --- a/src/smpi/smpi_f77.c +++ b/src/smpi/smpi_f77.c @@ -1,8 +1,8 @@ -/* Copyright (c) 2010. The SimGrid Team. +/* Copyright (c) 2010-2014. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it - * under the terms of the license (GNU LGPL) which comes with this package. */ + * under the terms of the license (GNU LGPL) which comes with this package. */ #include #include @@ -20,13 +20,27 @@ static xbt_dict_t datatype_lookup = NULL; static xbt_dict_t op_lookup = NULL; static int running_processes = 0; - - -/* Convert between Fortran and C MPI_BOTTOM */ -#define F2C_BOTTOM(addr) ((addr!=MPI_IN_PLACE && *(int*)addr == MPI_FORTRAN_BOTTOM) ? MPI_BOTTOM : (addr)) -#define F2C_IN_PLACE(addr) ((addr!=MPI_BOTTOM &&*(int*)addr == MPI_FORTRAN_IN_PLACE) ? MPI_IN_PLACE : (addr)) -#define F2C_STATUS_IGNORE(addr) ((*(int*)addr == MPI_FORTRAN_STATUS_IGNORE) ? MPI_STATUS_IGNORE : (addr)) -#define F2C_STATUSES_IGNORE(addr) ((*(int*)addr == MPI_FORTRAN_STATUSES_IGNORE) ? MPI_STATUSES_IGNORE : (addr)) +/* Bindings for MPI special values */ +union u_smpi_common { + struct s_smpi_common { + integer _MPI_IN_PLACE; + integer _MPI_BOTTOM; + integer _MPI_STATUS_IGNORE; + integer _MPI_STATUSES_IGNORE; + } *f77; /* with f2c, remains NULL with gfortran */ + struct s_smpi_common f90; /* with gfortran */ +} smpi_ = { NULL }; + +/* Convert between Fortran and C */ +#define F2C_ADDR(addr, val) \ + (((void *)(addr) == (void *)(smpi_.f77 \ + ? &smpi_.f77[smpi_current_rank]._ ## val \ + : &smpi_.f90._ ## val)) \ + ? (val) : (void *)(addr)) +#define F2C_BOTTOM(addr) F2C_ADDR(addr, MPI_BOTTOM) +#define F2C_IN_PLACE(addr) F2C_ADDR(addr, MPI_IN_PLACE) +#define F2C_STATUS_IGNORE(addr) F2C_ADDR(addr, MPI_STATUS_IGNORE) +#define F2C_STATUSES_IGNORE(addr) F2C_ADDR(addr, MPI_STATUSES_IGNORE) #define KEY_SIZE (sizeof(int) * 2 + 1) @@ -213,13 +227,10 @@ void mpi_finalize_(int* ierr) { running_processes--; if(running_processes==0){ xbt_dict_free(&op_lookup); - op_lookup = NULL; xbt_dict_free(&datatype_lookup); - datatype_lookup = NULL; xbt_dict_free(&request_lookup); - request_lookup = NULL; + xbt_dict_free(&group_lookup); xbt_dict_free(&comm_lookup); - comm_lookup = NULL; } }