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

Add yac interface to couple to ICON #683

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ project(FESOM2.0)
set(BUILD_SHARED_LIBS ON CACHE BOOL "Default to using shared libs")
set(TOPLEVEL_DIR ${CMAKE_CURRENT_LIST_DIR})
set(FESOM_COUPLED OFF CACHE BOOL "compile fesom standalone or with oasis support (i.e. coupled)")
set(USE_YAC OFF CACHE BOOL "compile fesom with yac")
set(OIFS_COUPLED OFF CACHE BOOL "compile fesom coupled to OpenIFS. (Also needs FESOM_COUPLED to work)")
set(CRAY OFF CACHE BOOL "compile with cray ftn")
set(USE_ICEPACK OFF CACHE BOOL "compile fesom with the Iceapck modules for sea ice column physics.")
Expand Down
19 changes: 19 additions & 0 deletions cmake/FindYAC.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
IF( DEFINED ENV{yac_DIR} )
SET( yac_DIR "$ENV{yac_DIR}" )
ENDIF()

set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${yac_DIR}/lib/pkgconfig:${yac_DIR}/src/pkgconfig")

find_package(PkgConfig QUIET)
PKG_CHECK_MODULES(PC_yac yac)

find_path(YAC_Fortran_INCLUDE_DIRECTORIES mo_yac_finterface.mod HINTS ${PC_yac_INCLUDE_DIRS} ${yac_DIR}/src/mci)

find_library(YAC_LIBRARY yac HINTS ${PC_yac_LINK_LIBRARIES} ${yac_DIR}/src)
#find_library(YAC_CLAPACK_LIBRARY yac_clapack HINTS ${PC_yac_LINK_LIBRARIES} ${yac_DIR}/clapack)
#find_library(YAC_MTIME_LIBRARY yac_mtime HINTS ${PC_yac_LINK_LIBRARIES} ${yac_DIR}/mtime)

#list(REMOVE_ITEM PC_yac_LINK_LIBRARIES yac yac_clapack yac_mtime)

#message(FATAL_ERROR "${PC_yac_LDFLAGS}")
set(YAC_Fortran_LIBRARIES "-L${yac_DIR}/src" ${PC_yac_LDFLAGS})
7 changes: 7 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ endif()
if(${ASYNC_ICEBERGS})
target_compile_definitions(${PROJECT_NAME} PRIVATE __async_icebergs)
endif()

if(${USE_YAC})
include(${CMAKE_CURRENT_LIST_DIR}/../cmake/FindYAC.cmake)
target_compile_definitions(${PROJECT_NAME} PRIVATE __yac __coupled)
endif()

if(${OIFS_COUPLED})
target_compile_definitions(${PROJECT_NAME} PRIVATE __oifs)
endif()
Expand Down Expand Up @@ -314,6 +320,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE ${MCT_Fortran_LIBRARIES} ${MPEU_Fo
# OASIS-YAK
target_link_libraries(${PROJECT_NAME} PRIVATE ${YACUTILS_Fortran_LIBRARIES} ${YACCORE_Fortran_LIBRARIES})
target_link_libraries(${PROJECT_NAME} PRIVATE ${YAXT_Fortran_LIBRARIES} ${YAXTC_Fortran_LIBRARIES})
target_link_libraries(${PROJECT_NAME} PRIVATE ${YAC_Fortran_LIBRARIES})

#set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE Fortran)

Expand Down
37 changes: 19 additions & 18 deletions src/MOD_ICE.F90
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ MODULE MOD_ICE
!
!_______________________________________________________________________________
! set work array derived type for ice
#if defined (__oasis) || defined (__ifsinterface)
#if defined (__coupled) || defined (__ifsinterface)
TYPE T_ICE_ATMCOUPL

!___________________________________________________________________________
real(kind=WP), allocatable, dimension(:) :: oce_flx_h, ice_flx_h, tmpoce_flx_h, tmpice_flx_h
#if defined (__oifs) || defined (__ifsinterface)
#if defined (__oifs) || defined (__ifsinterface) || defined(__yac)
!___________________________________________________________________________
real(kind=WP), allocatable, dimension(:) :: ice_alb, enthalpyoffuse, flx_qres, flx_qcon
! !!! DONT FORGET ice_temp rhs_tempdiv rhs_temp is advected for oifs !!! --> becomes additional ice
Expand All @@ -102,7 +102,7 @@ MODULE MOD_ICE
procedure WRITE_T_ICE_ATMCOUPL
procedure READ_T_ICE_ATMCOUPL
END TYPE T_ICE_ATMCOUPL
#endif /* (__oasis) */
#endif /* (__coupled) || __ifsinterface*/

!
!
Expand Down Expand Up @@ -157,12 +157,12 @@ MODULE MOD_ICE

! put thermodynamics arrays
type(t_ice_thermo) :: thermo

#if defined (__oasis) || defined (__ifsinterface)
#if defined (__coupled) || defined (__ifsinterface)
!___________________________________________________________________________
! put ice arrays for coupled model
type(t_ice_atmcoupl) :: atmcoupl
#endif /* (__oasis) */
#endif /* (__coupled) || (__ifsinterface)*/

!___________________________________________________________________________
! set ice model parameters:
Expand Down Expand Up @@ -323,7 +323,7 @@ end subroutine READ_T_ICE_THERMO
!
!_______________________________________________________________________________
! Unformatted writing for T_ICE_ATMCOUPL
#if defined (__oasis) || defined (__ifsinterface)
#if defined (__coupled) || defined (__ifsinterface)
subroutine WRITE_T_ICE_ATMCOUPL(tcoupl, unit)
IMPLICIT NONE
class(T_ICE_ATMCOUPL), intent(in) :: tcoupl
Expand All @@ -338,11 +338,12 @@ subroutine WRITE_T_ICE_ATMCOUPL(tcoupl, unit)
call write_bin_array(tcoupl%ice_alb, unit, iostat, iomsg)
call write_bin_array(tcoupl%enthalpyoffuse, unit, iostat, iomsg)
#endif /* (__oifs) */
end subroutine WRITE_T_ICE_ATMCOUPL
#endif /* (__oasis) */

end subroutine WRITE_T_ICE_ATMCOUPL
#endif /* (__coupled) || (__ifsinterface)*/

! Unformatted reading for T_ICE_ATMCOUPL
#if defined (__oasis) || defined (__ifsinterface)
#if defined (__coupled) || defined (__ifsinterface)
subroutine READ_T_ICE_ATMCOUPL(tcoupl, unit)
IMPLICIT NONE
class(T_ICE_ATMCOUPL), intent(inout) :: tcoupl
Expand All @@ -358,7 +359,7 @@ subroutine READ_T_ICE_ATMCOUPL(tcoupl, unit)
call read_bin_array(tcoupl%enthalpyoffuse, unit, iostat, iomsg)
#endif /* (__oifs) */
end subroutine READ_T_ICE_ATMCOUPL
#endif /* (__oasis) */
#endif /* (__coupled) || (__ifsinterface)*/
!
!
!_______________________________________________________________________________
Expand All @@ -378,9 +379,9 @@ subroutine WRITE_T_ICE(ice, unit, iostat, iomsg)
!___________________________________________________________________________
call ice%thermo%WRITE_T_ICE_THERMO(unit)
call ice%work%WRITE_T_ICE_WORK(unit)
#if defined (__oasis) || defined (__ifsinterface)
#if defined (__coupled) || defined (__ifsinterface)
call ice%atmcoupl%WRITE_T_ICE_ATMCOUPL(unit)
#endif /* (__oasis) */
#endif /* (__coupled) */

!___________________________________________________________________________
write(unit, iostat=iostat, iomsg=iomsg) ice%pstar
Expand Down Expand Up @@ -451,9 +452,9 @@ subroutine READ_T_ICE(ice, unit, iostat, iomsg)
!___________________________________________________________________________
call ice%thermo%READ_T_ICE_THERMO(unit)
call ice%work%READ_T_ICE_WORK(unit)
#if defined (__oasis) || defined (__ifsinterface)
#if defined (__coupled) || defined (__ifsinterface)
call ice%atmcoupl%READ_T_ICE_ATMCOUPL(unit)
#endif /* (__oasis) */
#endif /* (__coupled) */

!___________________________________________________________________________
read(unit, iostat=iostat, iomsg=iomsg) ice%pstar
Expand Down Expand Up @@ -743,8 +744,8 @@ subroutine ice_init(ice, partit, mesh)
ice%thermo%thdgr_old = 0.0_WP

!___________________________________________________________________________
! initialse coupling array of ice derived type
#if defined (__oasis) || defined (__ifsinterface)
! initialse coupling array of ice derived type
#if defined (__coupled) || defined (__ifsinterface)
allocate(ice%atmcoupl%oce_flx_h( node_size))
allocate(ice%atmcoupl%ice_flx_h( node_size))
allocate(ice%atmcoupl%tmpoce_flx_h( node_size))
Expand All @@ -763,7 +764,7 @@ subroutine ice_init(ice, partit, mesh)
ice%atmcoupl%flx_qres = 0.0_WP
ice%atmcoupl%flx_qcon = 0.0_WP
#endif /* (__oifs) */
#endif /* (__oasis) */
#endif /* (__coupled) */

!___________________________________________________________________________
! --> took from oce_mesh.F90 --> subroutine mesh_auxiliary_arrays(partit, mesh)
Expand Down
2 changes: 1 addition & 1 deletion src/MOD_MESH.F90
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ MODULE MOD_MESH
!___Elevation stiffness matrix__________________________________________________
type(sparse_matrix) :: ssh_stiff

!#if defined (__oasis)
!#if defined (__coupled)
real(kind=WP), allocatable, dimension(:) :: lump2d_south
real(kind=WP), allocatable, dimension(:) :: lump2d_north
integer, allocatable, dimension(:) :: ind_south
Expand Down
Loading
Loading