Skip to content

Commit

Permalink
separate shared fortran utility module
Browse files Browse the repository at this point in the history
  • Loading branch information
mattldawson committed May 10, 2024
1 parent 4390dfa commit 7b9448d
Show file tree
Hide file tree
Showing 9 changed files with 411 additions and 23 deletions.
14 changes: 6 additions & 8 deletions docker/Dockerfile.fortran-intel
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ RUN apt update \
zlib1g-dev \
&& apt clean

# Build netcdf-fortran
ENV CXX=icpx
ENV CC=icx
ENV FC=ifx
# Set environment variables to install MUSICA using gcc
ENV CXX=g++
ENV CC=gcc
ENV FC=gfortran
ENV FFLAGS="-I/usr/include/"

# Build netcdf-fortran
RUN git clone https://github.com/Unidata/netcdf-fortran.git \
&& cd netcdf-fortran \
&& git checkout v4.6.0 \
Expand All @@ -35,10 +37,6 @@ RUN git clone https://github.com/Unidata/netcdf-fortran.git \
&& make -j 8 \
&& make install

# Set environment variables to install MUSICA using gcc
ENV FC=gfortran
ENV FFLAGS="-I/usr/include/"

# Copy the musica code
COPY . musica

Expand Down
1 change: 1 addition & 0 deletions fortran/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ target_sources(musica-fortran
PRIVATE
micm.F90
tuvx.F90
util.F90
)

# Add flags for gfortran
Expand Down
4 changes: 1 addition & 3 deletions fortran/test/fetch_content_integration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ FetchContent_Declare(musica_fortran
GIT_TAG ${MUSICA_GIT_TAG}
)

set(MUSICA_BUILD_C_CXX_INTERFACE ON)
set(MUSICA_BUILD_C_CXX_INTERFACE OFF)
set(MUSICA_BUILD_FORTRAN_INTERFACE ON)
set(MUSICA_ENABLE_MICM ON)
set(MUSICA_ENABLE_TUVX ON)
set(MUSICA_ENABLE_TESTS OFF)
set(MUSICA_ENABLE_INSTALL OFF)

Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
project(
musica
VERSION ${PROJECT_VERSION}
LANGUAGES C CXX Fortran
LANGUAGES C CXX
)

message (STATUS "CMake build configuration for ${PROJECT_NAME} (${CMAKE_BUILD_TYPE}) ${PROJECT_VERSION}")
Expand Down Expand Up @@ -38,7 +38,6 @@ configure_file(version.c.in ${CMAKE_BINARY_DIR}/version.c @ONLY)
target_sources(musica
PRIVATE
util.cpp
util.F90
component_versions.c
${CMAKE_BINARY_DIR}/version.c
)
Expand Down Expand Up @@ -70,6 +69,8 @@ endif()
####################
# TUVX
if(MUSICA_ENABLE_TUVX)
enable_language(Fortran)

# include the sources directly into musica
target_sources(musica
PRIVATE
Expand Down
11 changes: 5 additions & 6 deletions src/packaging/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ install(
${MUSICA_INSTALL_INCLUDE_DIR}
)

# install fortran mod files
# install fortran source files
install(
DIRECTORY
${MUSICA_MOD_DIR}/
DESTINATION
${MUSICA_INSTALL_INCLUDE_DIR}
FILES_MATCHING PATTERN "*.mod"
FILES
${MUSICA_FORTRAN_SRC_DIR}/util.F90
DESTINATION
${MUSICA_INSTALL_INCLUDE_DIR}/musica/fortran
)

# install MICM
Expand Down
1 change: 1 addition & 0 deletions src/tuvx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ target_sources(musica
PRIVATE
interface.F90
tuvx.cpp
tuvx_util.F90
)
14 changes: 10 additions & 4 deletions src/tuvx/interface.F90
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
module tuvx_interface

use iso_c_binding, only : c_ptr, c_loc, c_int
use tuvx_core, only : core_t
use musica_util, only : to_f_string, string_t_c
use musica_string, only : string_t
use iso_c_binding, only : c_ptr, c_loc, c_int
use tuvx_core, only : core_t
use musica_tuvx_util, only : to_f_string, string_t_c
use musica_string, only : string_t

implicit none

private

contains

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

function internal_create_tuvx(config_path, error_code) bind(C, name="internal_create_tuvx")
type(string_t_c), value, intent(in) :: config_path
integer(kind=c_int), intent(out) :: error_code
Expand All @@ -28,6 +31,7 @@ function internal_create_tuvx(config_path, error_code) bind(C, name="internal_cr

end function internal_create_tuvx

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

subroutine internal_delete_tuvx(tuvx) bind(C, name="internal_delete_tuvx")
use iso_c_binding, only: c_ptr, c_f_pointer
Expand All @@ -40,4 +44,6 @@ subroutine internal_delete_tuvx(tuvx) bind(C, name="internal_delete_tuvx")
end if
end subroutine internal_delete_tuvx

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

end module tuvx_interface
Loading

0 comments on commit 7b9448d

Please sign in to comment.