Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Fortran code to Fortran 90 #74

Merged
merged 1 commit into from
Sep 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions deps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,24 +127,24 @@ endif(UNIX)

add_dependencies(dist version)

add_library(juliampi SHARED test_mpi.f)
add_library(juliampi SHARED test_mpi.f90)

if(MPI_Fortran_LINK_FLAGS)
set_target_properties(juliampi PROPERTIES LINK_FLAGS ${MPI_Fortran_LINK_FLAGS})
endif(MPI_Fortran_LINK_FLAGS)

target_link_libraries(juliampi ${MPI_Fortran_LIBRARIES})

add_executable(make_f2c make_f2c.c)
add_dependencies(make_f2c version)
add_executable(gen_functions gen_functions.c)
add_dependencies(gen_functions version)

add_executable(make_f_const make_f_const.f)
add_executable(gen_constants gen_constants.f90)

file(WRITE ${CMAKE_BINARY_DIR}/mpi.cmake "
execute_process(COMMAND ${CMAKE_BINARY_DIR}/make_f2c OUTPUT_VARIABLE FTWOC)
execute_process(COMMAND ${CMAKE_BINARY_DIR}/make_f_const OUTPUT_VARIABLE FCONS)
execute_process(COMMAND ${CMAKE_BINARY_DIR}/gen_functions OUTPUT_VARIABLE FTWOC)
execute_process(COMMAND ${CMAKE_BINARY_DIR}/gen_constants OUTPUT_VARIABLE FCONS)
file(READ \${SRC} MPI)
file(WRITE \${DST} \"const libmpi = Libdl.dlopen(\\\"${CMAKE_LIB_INSTALL_PREFIX}/libjuliampi\\\",Libdl.RTLD_LAZY|Libdl.RTLD_DEEPBIND|Libdl.RTLD_GLOBAL)\n\")
file(WRITE \${DST} \"const libmpi = Libdl.dlopen(\\\"${CMAKE_LIB_INSTALL_PREFIX}/libjuliampi\\\", Libdl.RTLD_LAZY|Libdl.RTLD_DEEPBIND|Libdl.RTLD_GLOBAL)\n\")
file(APPEND \${DST} \"\n\")
file(APPEND \${DST} \${FTWOC})
file(APPEND \${DST} \"\n\")
Expand All @@ -158,7 +158,7 @@ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/compile-time.jl
-DLIB=${CMAKE_LIB_INSTALL_PREFIX}/libmpi
-DDST=${CMAKE_BINARY_DIR}/compile-time.jl
-P ${CMAKE_BINARY_DIR}/mpi.cmake
DEPENDS make_f2c make_f_const ${CMAKE_SOURCE_DIR}/../src/mpi-base.jl ${CMAKE_BINARY_DIR}/mpi.cmake)
DEPENDS gen_functions gen_constants ${CMAKE_SOURCE_DIR}/../src/mpi-base.jl ${CMAKE_BINARY_DIR}/mpi.cmake)
add_custom_target(mpijl DEPENDS ${CMAKE_BINARY_DIR}/compile-time.jl)
add_dependencies(juliampi mpijl)

Expand All @@ -168,7 +168,7 @@ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/mpi-build.jl
-DLIB=${CMAKE_LIB_INSTALL_PREFIX}/libmpi
-DDST=${CMAKE_BINARY_DIR}/mpi-build.jl
-P ${CMAKE_BINARY_DIR}/mpi.cmake
DEPENDS make_f2c make_f_const ${CMAKE_SOURCE_DIR}/../src/mpi-base.jl ${CMAKE_BINARY_DIR}/mpi.cmake)
DEPENDS gen_functions gen_constants ${CMAKE_SOURCE_DIR}/../src/mpi-base.jl ${CMAKE_BINARY_DIR}/mpi.cmake)
add_custom_target(mpijl-build DEPENDS ${CMAKE_BINARY_DIR}/mpi-build.jl)
add_dependencies(juliampi mpijl-build)

Expand Down
66 changes: 66 additions & 0 deletions deps/gen_constants.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
program gen_constants
implicit none
include 'mpif.h'

call output("MPI_BYTE ", MPI_BYTE)
! Older versions of OpenMPI (such as those used by default by
! Travis) do not define MPI_WCHAR and the MPI_*INT*_T types for
! Fortran. We thus don't require them (yet).
! call output("MPI_WCHAR ", MPI_WCHAR)
! call output("MPI_INT8_T ", MPI_INT8_T)
! call output("MPI_UINT8_T ", MPI_UINT8_T)
! call output("MPI_INT16_T ", MPI_INT16_T)
! call output("MPI_UINT16_T ", MPI_UINT16_T)
! call output("MPI_INT32_T ", MPI_INT32_T)
! call output("MPI_UINT32_T ", MPI_UINT32_T)
! call output("MPI_INT64_T ", MPI_INT64_T)
! call output("MPI_UINT64_T ", MPI_UINT64_T)
call output("MPI_INTEGER1 ", MPI_INTEGER1)
call output("MPI_INTEGER2 ", MPI_INTEGER2)
call output("MPI_INTEGER4 ", MPI_INTEGER4)
call output("MPI_INTEGER8 ", MPI_INTEGER8)
call output("MPI_REAL4 ", MPI_REAL4)
call output("MPI_REAL8 ", MPI_REAL8)
call output("MPI_COMPLEX8 ", MPI_COMPLEX8)
call output("MPI_COMPLEX16 ", MPI_COMPLEX16)

call output("MPI_COMM_NULL ", MPI_COMM_NULL)
call output("MPI_COMM_SELF ", MPI_COMM_SELF)
call output("MPI_COMM_WORLD ", MPI_COMM_WORLD)

call output("MPI_OP_NULL ", MPI_OP_NULL)
call output("MPI_BAND ", MPI_BAND)
call output("MPI_BOR ", MPI_BOR)
call output("MPI_BXOR ", MPI_BXOR)
call output("MPI_LAND ", MPI_LAND)
call output("MPI_LOR ", MPI_LOR)
call output("MPI_LXOR ", MPI_LXOR)
call output("MPI_MAX ", MPI_MAX)
call output("MPI_MAXLOC ", MPI_MAXLOC)
call output("MPI_MIN ", MPI_MIN)
call output("MPI_MINLOC ", MPI_MINLOC)
call output("MPI_PROD ", MPI_PROD)
call output("MPI_REPLACE ", MPI_REPLACE)
call output("MPI_SUM ", MPI_SUM)

call output("MPI_REQUEST_NULL ", MPI_REQUEST_NULL)

call output("MPI_STATUS_SIZE ", MPI_STATUS_SIZE)
call output("MPI_ERROR ", MPI_ERROR)
call output("MPI_SOURCE ", MPI_SOURCE)
call output("MPI_TAG ", MPI_TAG)

call output("MPI_ANY_SOURCE ", MPI_ANY_SOURCE)
call output("MPI_ANY_TAG ", MPI_ANY_TAG)
call output("MPI_TAG_UB ", MPI_TAG_UB)
call output("MPI_UNDEFINED ", MPI_UNDEFINED)

contains

subroutine output(name, value)
character*(*) name
integer value
print '("const ",a," = Cint(",i0,")")', name, value
end subroutine output

end program gen_constants
2 changes: 1 addition & 1 deletion deps/make_f2c.c → deps/gen_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define STRING1(s) #s
#define STRING(s) STRING1(s)

int main (int argc, char *argv[])
int main(int argc, char *argv[])
{
printf("const WRAPPER_VERSION = \"%s\"\n", VERSION);
printf("const MPI_ABORT = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_ABORT));
Expand Down
63 changes: 0 additions & 63 deletions deps/make_f_const.f

This file was deleted.

6 changes: 0 additions & 6 deletions deps/test_mpi.f

This file was deleted.

6 changes: 6 additions & 0 deletions deps/test_mpi.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
subroutine juliampi_empty
implicit none
integer ierr
call mpi_init(ierr)
call mpi_finalize(ierr)
end subroutine juliampi_empty