Skip to content

Commit 5094e98

Browse files
uturuncogluUfuk Turuncoglujkbk2004BrianCurtis-NOAA
authored
Bring external land component support to UFS (ufs-community#1443)
* update components and add external land component support * use cubed_sphere_grid as output grid * point updated CMEPS fork * switch to another fix for inconsistent land sea mask issue * make grid file configurable for external land Co-authored-by: Ufuk Turuncoglu <ufuk.turuncoglu@noaa.gov> Co-authored-by: JONG KIM <jong.kim@noaa.gov> Co-authored-by: Brian Curtis <brian.curtis@noaa.gov>
1 parent 5ac19d4 commit 5094e98

30 files changed

+5617
-3911
lines changed

.gitmodules

+4
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@
4242
path = AQM
4343
url = https://github.com/NOAA-EMC/AQM
4444
branch = develop
45+
[submodule "NOAHMP"]
46+
path = NOAHMP-interface/noahmp
47+
url = https://github.com/NOAA-EMC/noahmp
48+
branch = develop

CMakeLists.txt

+16-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules/Modules)
1616
###############################################################################
1717

1818
# Valid applications and choices
19-
list(APPEND VALID_APPS ATM ATMAERO ATMAQ ATMW S2S S2SA S2SW S2SWA HAFS HAFSW HAFS-ALL NG-GODAS)
19+
list(APPEND VALID_APPS ATM ATMAERO ATMAQ ATMW ATML LND S2S S2SA S2SW S2SWA S2SWAL HAFS HAFSW HAFS-ALL NG-GODAS)
2020
set(APP NONE CACHE BOOL "Application Name")
2121
if(NOT (APP IN_LIST VALID_APPS))
2222
message(FATAL_ERROR "${APP} is not a valid application.\nValid Applications are: ${VALID_APPS}")
@@ -33,6 +33,7 @@ set(WW3 OFF CACHE BOOL "Enable WW3")
3333
set(STOCH_PHYS OFF CACHE BOOL "Enable Stochastic Physics")
3434
set(CMEPS OFF CACHE BOOL "Enable CMEPS")
3535
set(CDEPS OFF CACHE BOOL "Enable CDEPS")
36+
set(NOAHMP OFF CACHE BOOL "Enable NOAHMP")
3637

3738
# Configure selected application specific components
3839
message("")
@@ -50,6 +51,7 @@ message("WW3 .............. ${WW3}")
5051
message("STOCH_PHYS ....... ${STOCH_PHYS}")
5152
message("CDEPS ............ ${CDEPS}")
5253
message("CMEPS ............ ${CMEPS}")
54+
message("NOAHMP ........... ${NOAHMP}")
5355

5456
###############################################################################
5557
### Build Options
@@ -211,6 +213,13 @@ if(CDEPS)
211213
add_subdirectory(CDEPS-interface)
212214
endif()
213215

216+
###############################################################################
217+
### Land Components [NOAHMP]
218+
###############################################################################
219+
if(NOAHMP)
220+
add_subdirectory(NOAHMP-interface)
221+
endif()
222+
214223
###############################################################################
215224
### UFS Library
216225
###############################################################################
@@ -283,6 +292,12 @@ if(CDEPS)
283292
target_link_libraries(ufs PUBLIC cdeps::cdeps)
284293
endif()
285294

295+
if(NOAHMP)
296+
add_dependencies(ufs noahmp)
297+
list(APPEND _ufs_defs_private FRONT_NOAHMP=lnd_comp_nuopc)
298+
list(APPEND _ufs_libs_public noahmp)
299+
endif()
300+
286301
target_compile_definitions(ufs PRIVATE "${_ufs_defs_private}")
287302
target_link_libraries(ufs PUBLIC "${_ufs_libs_public}")
288303

NOAHMP-interface/CMakeLists.txt

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#------------------------------------------------------------------------------
2+
# Add source files
3+
# NUOPC cap
4+
list(APPEND _noahmp_cap_files noahmp/drivers/nuopc/lnd_comp_kind.F90
5+
noahmp/drivers/nuopc/lnd_comp_types.F90
6+
noahmp/drivers/nuopc/lnd_comp_shr.F90
7+
noahmp/drivers/nuopc/lnd_comp_io.F90
8+
noahmp/drivers/nuopc/lnd_comp_domain.F90
9+
noahmp/drivers/nuopc/lnd_comp_import_export.F90
10+
noahmp/drivers/nuopc/lnd_comp_nuopc.F90
11+
noahmp/drivers/nuopc/lnd_comp_driver.F90)
12+
13+
# CCPP interface
14+
list(APPEND _noahmp_ccpp_files noahmp/drivers/ccpp/noahmpdrv.F90
15+
noahmp/drivers/ccpp/sfc_diff.f
16+
noahmp/drivers/ccpp/machine.F
17+
noahmp/drivers/ccpp/noahmp_tables.f90
18+
noahmp/drivers/ccpp/namelist_soilveg.f
19+
noahmp/drivers/ccpp/set_soilveg.f
20+
noahmp/drivers/ccpp/funcphys.f90
21+
noahmp/drivers/ccpp/physcons.F90)
22+
23+
# NoahMP
24+
list(APPEND _noahmp_files noahmp/src/module_sf_noahmplsm.f90
25+
noahmp/src/module_sf_noahmp_glacier.f90)
26+
27+
#------------------------------------------------------------------------------
28+
# Set CCPP flags for C/C++/Fortran preprocessor
29+
add_definitions(-DCCPP)
30+
31+
#------------------------------------------------------------------------------
32+
# Set MPI flags for C/C++/Fortran preprocessor
33+
if(MPI)
34+
add_definitions(-DMPI)
35+
endif()
36+
37+
#------------------------------------------------------------------------------
38+
# Set flag for 32bit dynamics build
39+
if(32BIT)
40+
message(STATUS "Compile CCPP slow physics with 64-bit precision, fast physics with 32-bit precision")
41+
add_definitions(-DOVERLOAD_R4)
42+
if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
43+
set(CMAKE_Fortran_FLAGS_PHYSICS "-real-size 64 -no-prec-div -no-prec-sqrt")
44+
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
45+
set(CMAKE_Fortran_FLAGS_PHYSICS "-fdefault-real-8 -fdefault-double-8")
46+
endif()
47+
set(CMAKE_Fortran_FLAGS_DYNAMICS "")
48+
else()
49+
message(STATUS "Compile CCPP physics with 64-bit precision")
50+
remove_definitions(-DOVERLOAD_R8)
51+
remove_definitions(-DOVERLOAD_R4)
52+
set(CMAKE_Fortran_FLAGS_PHYSICS "")
53+
set(CMAKE_Fortran_FLAGS_DYNAMICS "")
54+
endif()
55+
56+
#------------------------------------------------------------------------------
57+
# Add model-specific flags for C/C++/Fortran preprocessor
58+
add_definitions(-DMOIST_CAPPA -DUSE_COND -DNEMS_GSM)
59+
add_definitions(-DINTERNAL_FILE_NML)
60+
61+
#------------------------------------------------------------------------------
62+
# NOAHMP
63+
add_library(noahmp STATIC ${_noahmp_cap_files} ${_noahmp_ccpp_files} ${_noahmp_files})
64+
set_target_properties(noahmp PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
65+
target_include_directories(noahmp PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
66+
$<INSTALL_INTERFACE:mod>)
67+
target_link_libraries(noahmp PUBLIC esmf fms)
68+
69+
###############################################################################
70+
### Install
71+
###############################################################################
72+
73+
install(
74+
TARGETS noahmp
75+
EXPORT noahmp-config
76+
LIBRARY DESTINATION lib
77+
ARCHIVE DESTINATION lib
78+
COMPONENT Library)
79+
80+
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod DESTINATION ${CMAKE_INSTALL_PREFIX}/NOAHMP)
81+
82+
install(EXPORT noahmp-config
83+
DESTINATION lib/cmake)

NOAHMP-interface/noahmp

Submodule noahmp added at 34a52cc

cmake/configure_apps.cmake

+19-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
###############################################################################
1414
### Configure Application Components
1515
###############################################################################
16-
if(APP MATCHES "^(ATM|ATMW|ATMAQ)$")
16+
if(APP MATCHES "^(ATM|ATMW|ATMAQ|ATML)$")
1717
set(FMS ON CACHE BOOL "Enable FMS" FORCE)
1818
set(FV3 ON CACHE BOOL "Enable FV3" FORCE)
1919
set(STOCH_PHYS ON CACHE BOOL "Enable Stochastic Physics" FORCE)
@@ -23,6 +23,10 @@ if(APP MATCHES "^(ATM|ATMW|ATMAQ)$")
2323
elseif(APP MATCHES "ATMAQ")
2424
set(AQM ON CACHE BOOL "Enable AQM" FORCE)
2525
message("Configuring UFS app in Atmosphere with Air Quality mode")
26+
elseif(APP MATCHES "ATML")
27+
set(CMEPS ON CACHE BOOL "Enable CMEPS" FORCE)
28+
set(NOAHMP ON CACHE BOOL "Enable NOAHMP" FORCE)
29+
message("Configuring UFS app in Atmosphere with Air Quality mode")
2630
else()
2731
message("Configuring UFS app in Atmosphere Only mode")
2832
endif()
@@ -38,25 +42,24 @@ if(APP MATCHES "^(NG-GODAS)$")
3842
message("Configuring UFS app in (CDEPS) Data Atmosphere mode")
3943
endif()
4044

41-
if(APP MATCHES "^(S2S|S2SA|S2SW|S2SWA)$")
45+
if(APP MATCHES "^(S2S|S2SA|S2SW|S2SWA|S2SWAL)$")
4246
set(APP_MSG "Configuring UFS app in S2S")
4347
set(CMEPS ON CACHE BOOL "Enable CMEPS" FORCE)
4448
set(FMS ON CACHE BOOL "Enable FMS" FORCE)
4549
set(FV3 ON CACHE BOOL "Enable FV3" FORCE)
4650
set(MOM6 ON CACHE BOOL "Enable MOM6" FORCE)
4751
set(CICE6 ON CACHE BOOL "Enable CICE6" FORCE)
4852
set(STOCH_PHYS ON CACHE BOOL "Enable Stochastic Physics" FORCE)
49-
if(APP MATCHES "^S2SW")
53+
if(APP MATCHES "^(S2SW|S2SWA|S2SWAL)")
5054
set(WW3 ON CACHE BOOL "Enable WAVEWATCH III" FORCE)
5155
string(CONCAT APP_MSG ${APP_MSG} " with Waves")
5256
endif()
53-
if(APP MATCHES "A$")
57+
if(APP MATCHES "^(S2SA|S2SWA)")
5458
set(UFS_GOCART ON CACHE BOOL "Enable GOCART" FORCE)
55-
if(WW3)
56-
string(CONCAT APP_MSG ${APP_MSG} " and Aerosols")
57-
else()
58-
string(CONCAT APP_MSG ${APP_MSG} " with Aerosols")
59-
endif()
59+
string(CONCAT APP_MSG ${APP_MSG} " with Aerosols")
60+
endif()
61+
if(APP MATCHES "^S2SWAL")
62+
set(NOAHMP ON CACHE BOOL "Enable NOAHMP" FORCE)
6063
endif()
6164
message("${APP_MSG} mode")
6265
endif()
@@ -84,3 +87,10 @@ if(APP MATCHES "^(ATMAERO)$")
8487
set(UFS_GOCART ON CACHE BOOL "Enable GOCART" FORCE)
8588
message("Configuring UFS app in Atmosphere with Aerosols mode")
8689
endif()
90+
91+
if(APP MATCHES "^(LND)$")
92+
set(CMEPS ON CACHE BOOL "Enable CMEPS" FORCE)
93+
set(CDEPS ON CACHE BOOL "Enable CDEPS" FORCE)
94+
set(NOAHMP ON CACHE BOOL "Enable NOAHMP" FORCE)
95+
set(FMS ON CACHE BOOL "Enable FMS" FORCE)
96+
endif()

driver/UFSDriver.F90

+11
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ MODULE UFSDriver
7474
#ifdef FRONT_NOAH
7575
use FRONT_NOAH, only: NOAH_SS => SetServices
7676
#endif
77+
#ifdef FRONT_NOAHMP
78+
use FRONT_NOAHMP, only: NOAHMP_SS => SetServices
79+
#endif
7780
#ifdef FRONT_LIS
7881
use FRONT_LIS, only: LIS_SS => SetServices
7982
#endif
@@ -447,6 +450,14 @@ subroutine SetModelServices(driver, rc)
447450
found_comp = .true.
448451
end if
449452
#endif
453+
#ifdef FRONT_NOAHMP
454+
if (trim(model) == "noahmp") then
455+
call NUOPC_DriverAddComp(driver, trim(prefix), NOAHMP_SS, &
456+
petList=petList, comp=comp, rc=rc)
457+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
458+
found_comp = .true.
459+
end if
460+
#endif
450461
#ifdef FRONT_LIS
451462
if (trim(model) == "lis") then
452463
!TODO: Remove bail code and pass info and SetVM to DriverAddComp

0 commit comments

Comments
 (0)