Skip to content

Commit

Permalink
Enhancement: WRF CMake Changes (#739)
Browse files Browse the repository at this point in the history
* Renaming .F files to .F90

* Fixing dependency for nudging build

* Moving files from .f90 -> .F90

* Renaming .F to .F90 coupled WRF files

* Renaming .F to .F90 coupled WRF files

* CMake: bringing over some changes from WRF CMake changes. Tabs to spaces and enforcing uniform style guide

* Bringing over a few edits to some CMakeLists.txt files from the WRF PR#2009
  • Loading branch information
scrasmussen authored Sep 26, 2024
1 parent 3dc1b88 commit 7cbd1e4
Show file tree
Hide file tree
Showing 110 changed files with 527 additions and 504 deletions.
256 changes: 128 additions & 128 deletions CMakeLists.txt

Large diffs are not rendered by default.

290 changes: 151 additions & 139 deletions src/CMakeLists.txt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/CPL/NoahMP_cpl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_library(hydro_noahmp_cpl STATIC
module_hrldas_HYDRO.F
hrldas_drv_HYDRO.F
module_hrldas_HYDRO.F
hrldas_drv_HYDRO.F
)

target_link_libraries(hydro_noahmp_cpl PUBLIC hydro_mpp)
Expand Down
6 changes: 3 additions & 3 deletions src/CPL/WRF_cpl/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Makefile
#
.SUFFIXES:
.SUFFIXES: .o .F
.SUFFIXES: .o .F90



Expand All @@ -15,9 +15,9 @@ OBJS = \
wrf_drv_HYDRO.o
all: $(OBJS)

.F.o:
.F90.o:
@echo ""
$(COMPILER90) $(CPPINVOKE) $(CPPFLAGS) -I$(NETCDFINC) -o $(@) $(F90FLAGS) $(MODFLAG) -I$(WRF_ROOT)/frame -I$(WRF_ROOT)/main -I$(WRF_ROOT)/external/esmf_time_f90 $(*).F
$(COMPILER90) $(CPPINVOKE) $(CPPFLAGS) -I$(NETCDFINC) -o $(@) $(F90FLAGS) $(MODFLAG) -I$(WRF_ROOT)/frame -I$(WRF_ROOT)/main -I$(WRF_ROOT)/external/esmf_time_f90 $(*).F90
@echo ""
ar -r ../../lib/libHYDRO.a $(@)

Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions src/Data_Rec/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
add_library(hydro_data_rec STATIC
module_gw_gw2d_data.F
module_rt_inc.F
module_namelist_inc.F
module_RT_data.F
module_namelist.F
module_gw_gw2d_data.F90
module_rt_inc.F90
module_namelist_inc.F90
module_RT_data.F90
module_namelist.F90
)
6 changes: 3 additions & 3 deletions src/Data_Rec/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Makefile
#
.SUFFIXES:
.SUFFIXES: .o .F
.SUFFIXES: .o .F90

include ../macros

Expand All @@ -14,9 +14,9 @@ OBJS = \

all: $(OBJS)

.F.o:
.F90.o:
@echo ""
$(COMPILER90) $(CPPINVOKE) $(CPPFLAGS) -I$(NETCDFINC) -o $(@) $(F90FLAGS) $(LDFLAGS) $(MODFLAG) -I../mod $(*).F
$(COMPILER90) $(CPPINVOKE) $(CPPFLAGS) -I$(NETCDFINC) -o $(@) $(F90FLAGS) $(LDFLAGS) $(MODFLAG) -I../mod $(*).F90
@echo ""
ar -r ../lib/libHYDRO.a $(@)
cp *.mod ../mod
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/Debug_Utilities/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# build the version static library
add_library(hydro_debug_utils STATIC
debug_dump_variable.F
debug_dump_variable.F90
)
12 changes: 6 additions & 6 deletions src/Debug_Utilities/Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Makefile
# Makefile
#
.SUFFIXES:
.SUFFIXES: .o .F
.SUFFIXES: .o .F90

include ../macros

OBJS = \
debug_dump_variable.o
debug_dump_variable.o

all: $(OBJS)
all: $(OBJS)

.F.o:
.F90.o:
@echo ""
$(COMPILER90) $(CPPINVOKE) $(CPPFLAGS) -I$(NETCDFINC) -o $(@) $(F90FLAGS) $(LDFLAGS) $(MODFLAG) -I../mod $(*).F
$(COMPILER90) $(CPPINVOKE) $(CPPFLAGS) -I$(NETCDFINC) -o $(@) $(F90FLAGS) $(LDFLAGS) $(MODFLAG) -I../mod $(*).F90
@echo ""
ar -r ../lib/libHYDRO.a $(@)
cp *.mod ../mod
Expand Down
File renamed without changes.
18 changes: 10 additions & 8 deletions src/HYDRO_drv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# build the version static library
add_library(hydro_driver STATIC
module_HYDRO_drv.F
module_HYDRO_drv.F90
)

target_link_libraries(hydro_driver PUBLIC hydro_mpp)
target_link_libraries(hydro_driver PUBLIC hydro_data_rec)
target_link_libraries(hydro_driver PUBLIC hydro_routing)
target_link_libraries(hydro_driver PUBLIC hydro_debug_utils)
target_link_libraries(hydro_driver PUBLIC
hydro_mpp
hydro_data_rec
hydro_routing
hydro_debug_utils
)

if (WRF_HYDRO_NUDGING STREQUAL "1")
target_link_libraries(hydro_driver PUBLIC hydro_nudging)
endif (WRF_HYDRO_NUDGING STREQUAL "1")
if(WRF_HYDRO_NUDGING STREQUAL "1")
target_link_libraries(hydro_driver PUBLIC hydro_nudging)
endif()
10 changes: 5 additions & 5 deletions src/HYDRO_drv/Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Makefile
# Makefile
#
.SUFFIXES:
.SUFFIXES: .o .F
.SUFFIXES: .o .F90

include ../macros

OBJS = \
module_HYDRO_drv.o
all: $(OBJS)
all: $(OBJS)

.F.o:
.F90.o:
@echo ""
$(COMPILER90) $(CPPINVOKE) $(CPPFLAGS) -o $(@) $(F90FLAGS) $(LDFLAGS) $(MODFLAG) -I$(NETCDFINC) -I../mod $(*).F
$(COMPILER90) $(CPPINVOKE) $(CPPFLAGS) -o $(@) $(F90FLAGS) $(LDFLAGS) $(MODFLAG) -I$(NETCDFINC) -I../mod $(*).F90
@echo ""
ar -r ../lib/libHYDRO.a $(@)
cp *.mod ../mod
Expand Down
File renamed without changes.
8 changes: 6 additions & 2 deletions src/IO/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# build the orchestrator static library
add_library(hydro_netcdf_layer STATIC
netcdf_layer.f90
)
netcdf_layer.F90
)

target_link_libraries(hydro_netcdf_layer
MPI::MPI_Fortran
)
8 changes: 4 additions & 4 deletions src/IO/Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Makefile
# Makefile
#
.SUFFIXES:
.SUFFIXES: .o .f90
.SUFFIXES: .o .F90

include ../macros

OBJS = \
netcdf_layer.o
all: $(OBJS)

.f90.o:
.F90.o:
@echo ""
# $(CPP) $(CPPFLAGS) -I$(NETCDFINC) $(*).F > $(*).f
# $(COMPILER90) -o $(@) $(F90FLAGS) $(MODFLAG) -I../mod $(*).f
$(COMPILER90) -o $(@) $(F90FLAGS) $(LDFLAGS) $(MODFLAG) -I$(NETCDFINC) -I../mod $(*).f90
$(COMPILER90) -o $(@) $(F90FLAGS) $(LDFLAGS) $(MODFLAG) -I$(NETCDFINC) -I../mod $(*).F90
# $(RMD) $(*).f
@echo ""
ar -r ../lib/libHYDRO.a $(@)
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/Land_models/Noah/Noah/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_library(noah STATIC
module_sf_urban.F
module_sf_noahlsm.F
module_sf_urban.F
module_sf_noahlsm.F
)
10 changes: 5 additions & 5 deletions src/Land_models/Noah/Utility_routines/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
add_library(noah_util STATIC
kwm_string_utilities.F
module_date_utilities.F
module_model_constants.F
module_Noahlsm_utility.F
module_sfcdif_wrf.F
kwm_string_utilities.F
module_date_utilities.F
module_model_constants.F
module_Noahlsm_utility.F
module_sfcdif_wrf.F
)
8 changes: 4 additions & 4 deletions src/Land_models/NoahMP/Utility_routines/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
add_library(noahmp_util STATIC
kwm_string_utilities.F
module_date_utilities.F
module_model_constants.F
module_wrf_utilities.F
kwm_string_utilities.F
module_date_utilities.F
module_model_constants.F
module_wrf_utilities.F
)

target_link_libraries(noahmp_util PUBLIC hydro_mpp)
8 changes: 4 additions & 4 deletions src/Land_models/NoahMP/phys/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
add_subdirectory("surfex")

add_library(noahmp_phys STATIC
module_sf_noahmpdrv.F
module_sf_noahmp_glacier.F
module_sf_noahmp_groundwater.F
module_sf_noahmplsm.F
module_sf_noahmpdrv.F
module_sf_noahmp_glacier.F
module_sf_noahmp_groundwater.F
module_sf_noahmplsm.F
)

target_link_libraries(noahmp_phys snowcro crocus_surfex)
15 changes: 9 additions & 6 deletions src/MPP/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
add_library(hydro_mpp STATIC
CPL_WRF.F
module_mpp_GWBUCKET.F
module_mpp_ReachLS.F
mpp_land.F
hashtable.F
CPL_WRF.F90
module_mpp_GWBUCKET.F90
module_mpp_ReachLS.F90
mpp_land.F90
hashtable.F90
)

target_link_libraries(hydro_mpp ${MPI_Fortran_LIBRARIES})
target_link_libraries(hydro_mpp MPI::MPI_Fortran)
target_include_directories(hydro_mpp PUBLIC
${MPI_Fortran_MODULE_DIR}
)
12 changes: 6 additions & 6 deletions src/MPP/CPL_WRF.F → src/MPP/CPL_WRF.F90
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ subroutine CPL_LAND_INIT(istart,iend,jstart,jend)
dims(0) = 0
dims(1) = 0
do xx=1,total_pe_num
if(node_info(2,xx) .eq. (-1)) then
dims(0) = dims(0)+1
endif
if(node_info(4,xx) .eq. (-1)) then
dims(1) = dims(1)+1
endif
if(node_info(2,xx) .eq. (-1)) then
dims(0) = dims(0)+1
endif
if(node_info(4,xx) .eq. (-1)) then
dims(1) = dims(1)+1
endif
enddo

ndim = 2
Expand Down
28 changes: 14 additions & 14 deletions src/MPP/Makefile
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
# Makefile
# Makefile
#
.SUFFIXES:
.SUFFIXES: .o .F
.SUFFIXES: .o .F90

include ../macros

OBJS = hashtable.o CPL_WRF.o mpp_land.o module_mpp_ReachLS.o module_mpp_GWBUCKET.o

all: $(OBJS)

hashtable.o: hashtable.F
hashtable.o: hashtable.F90
@echo ""
$(RMD) $(*).o $(*).mod $(*).stb *~
$(COMPILER90) $(F90FLAGS) $(LDFLAGS) -c $(*).F
$(COMPILER90) $(F90FLAGS) $(LDFLAGS) -c $(*).F90
cp hashtable.mod ../mod
ar -r ../lib/libHYDRO.a $(@)

mpp_land.o: mpp_land.F
mpp_land.o: mpp_land.F90
@echo ""
$(RMD) $(*).o $(*).mod $(*).stb *~
$(COMPILER90) $(F90FLAGS) $(LDFLAGS) -c $(*).F
$(COMPILER90) $(F90FLAGS) $(LDFLAGS) -c $(*).F90
ar -r ../lib/libHYDRO.a $(@)

CPL_WRF.o: CPL_WRF.F
CPL_WRF.o: CPL_WRF.F90
@echo ""
$(RMD) $(*).o $(*).mod $(*).stb *~
$(COMPILER90) $(CPPINVOKE) $(CPPFLAGS) -I$(NETCDFINC) -o $(@) $(F90FLAGS) $(LDFLAGS) $(MODFLAG) $(*).F
$(COMPILER90) $(F90FLAGS) $(LDFLAGS) -c $(*).F
$(COMPILER90) $(CPPINVOKE) $(CPPFLAGS) -I$(NETCDFINC) -o $(@) $(F90FLAGS) $(LDFLAGS) $(MODFLAG) $(*).F90

$(COMPILER90) $(F90FLAGS) $(LDFLAGS) -c $(*).F90
ar -r ../lib/libHYDRO.a $(@)

module_mpp_ReachLS.o: module_mpp_ReachLS.F
module_mpp_ReachLS.o: module_mpp_ReachLS.F90
@echo ""
$(RMD) $(*).o $(*).mod $(*).stb *~
$(COMPILER90) $(F90FLAGS) $(LDFLAGS) -c $(*).F
$(COMPILER90) $(F90FLAGS) $(LDFLAGS) -c $(*).F90
ar -r ../lib/libHYDRO.a $(@)

module_mpp_GWBUCKET.o: module_mpp_GWBUCKET.F
module_mpp_GWBUCKET.o: module_mpp_GWBUCKET.F90
@echo ""
$(RMD) $(*).o $(*).mod $(*).stb *~
$(COMPILER90) $(F90FLAGS) $(LDFLAGS) -c $(*).F
$(COMPILER90) $(F90FLAGS) $(LDFLAGS) -c $(*).F90
ar -r ../lib/libHYDRO.a $(@)

clean:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 12 additions & 8 deletions src/OrchestratorLayer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# build the orchestrator static library
add_library(hydro_orchestrator STATIC
config.f90
io_manager.f90
orchestrator.f90
)
config.F90
io_manager.F90
orchestrator.F90
)

add_dependencies(hydro_orchestrator hydro_netcdf_layer)
add_dependencies(hydro_orchestrator hydro_utils)
add_dependencies(hydro_orchestrator
hydro_netcdf_layer
hydro_utils
)

target_link_libraries(hydro_orchestrator PUBLIC hydro_netcdf_layer)
target_link_libraries(hydro_orchestrator PUBLIC hydro_utils)
target_link_libraries(hydro_orchestrator PRIVATE
hydro_netcdf_layer
hydro_utils
)
10 changes: 5 additions & 5 deletions src/OrchestratorLayer/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Makefile
# Makefile
#
.SUFFIXES:
.SUFFIXES: .o .f90
.SUFFIXES: .o .F90

include ../macros

Expand All @@ -20,10 +20,10 @@ all: $(OBJS)
# @echo ""
# cp *.mod ../mod

.f90.o:
.F90.o:
@echo "Orchestrator Makefile:"
# $(COMPILER90) -o $(@) $(F90FLAGS) $(MODFLAG) $(*).f
$(COMPILER90) $(CPPINVOKE) -o $(@) $(CPPFLAGS) $(FPPFLAGS) $(F90FLAGS) $(LDFLAGS) $(MODFLAG) -I$(NETCDFINC) $(*).f90
$(COMPILER90) $(CPPINVOKE) -o $(@) $(CPPFLAGS) $(FPPFLAGS) $(F90FLAGS) $(LDFLAGS) $(MODFLAG) -I$(NETCDFINC) $(*).F90
# $(RMD) $(*).f
@echo ""
ar -r ../lib/libHYDRO.a $(@)
Expand All @@ -36,5 +36,5 @@ io_manager.o: ../IO/netcdf_layer.o

orchestrator.o: io_manager.o config.o

clean:
clean:
rm -f *.o *.mod *.stb *~ *.f
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 7cbd1e4

Please sign in to comment.