From 5b024c05c19e8855b83f7533bbb785bf6efaf7c9 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 31 May 2024 15:50:24 -0700 Subject: [PATCH 01/42] Force fail on genexp in defines --- cmake/c_preproc.cmake | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/cmake/c_preproc.cmake b/cmake/c_preproc.cmake index 14f7fe9295..4de0a1e7a1 100644 --- a/cmake/c_preproc.cmake +++ b/cmake/c_preproc.cmake @@ -111,14 +111,9 @@ macro( wrf_expand_definitions ) set( WRF_EXP_DEFS ) foreach( WRF_EXP_DEF ${WRF_EXP_DEFINITIONS} ) if ( NOT ${WRF_EXP_DEF} MATCHES ".*-D.*" ) - # We have a generator expression, inject the -D correctly - # THIS SHOULD ONLY BE USED FOR CONDITIONALLY APPLIED DEFINITIONS + # We have a generator expression, error! no way we can evaluate this correctly if ( ${WRF_EXP_DEF} MATCHES "^[$]<" ) - # Take advantage of the fact that a define is most likely not an expanded variable (i.e. starts with a-zA-Z, adjust if not) - # preceeded by the defining generator expression syntax $<>:var or ,var - # Yes this is fragile but is probably more robust than the current code if you're relying on this macro :D - string( REGEX REPLACE "(>:|,)([a-zA-Z])" "\\1-D\\2" WRF_EXP_DEF_SANITIZED ${WRF_EXP_DEF} ) - list( APPEND WRF_EXP_DEFS ${WRF_EXP_DEF_SANITIZED} ) + message( FATAL_ERROR "Generator expressions not allowed in preprocessing defines" ) else() list( APPEND WRF_EXP_DEFS -D${WRF_EXP_DEF} ) endif() From 7c6e773bfe104a6e118bac91f3d466040853aa2f Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 31 May 2024 15:51:35 -0700 Subject: [PATCH 02/42] Rewrite the defines to not use genexp --- CMakeLists.txt | 246 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 173 insertions(+), 73 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d1a1297f2f..e719518246 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -619,55 +619,8 @@ add_compile_definitions( DWORDSIZE=${DWORDSIZE} LWORDSIZE=${LWORDSIZE} RWORDSIZE=${RWORDSIZE} - # Only define if set, this is to use #ifdef/#ifndef preprocessors - # in code since cmake cannot handle basically any others :( - # https://gitlab.kitware.com/cmake/cmake/-/issues/17398 - $<$:WRF_CHEM=$> - $<$:BUILD_CHEM=$> - $<$:WRF_CMAQ=$> - $<$,$>:WRF_KPP=$> - $<$:WRF_DFI_RADAR=$> - $<$:WRF_TITAN=$> - $<$:WRF_MARS=$> - $<$:WRF_VENUS=$> - $<$:WRF_HYDRO=$> - - # Because once again we need two defines to control one thing - $<$:WRF_USE_CTSM=$> - $<$>:WRF_USE_CLM> - - # If force classic or no nc-4 support enable classic - $<$,$>>:NETCDF_classic=1> - $<$,$>>:WRFIO_NCD_NO_LARGE_FILE_SUPPORT=1> - # May need a check for WRFIO_ncdpar_LARGE_FILE_SUPPORT - - # Now set the opposite in different defines, because why not :) - $<$>,$>:USE_NETCDF4_FEATURES=1> - $<$>,$>:WRFIO_NCD_LARGE_FILE_SUPPORT=1> - - # Could simplify logic to just check if RPC is available but to be explicit - # Does this actually need to check for EM_CORE (Config.pl:443) - # not enable terran or not rpc_found do - # not ( enable terrain and rpc_found ) - $<$,$>>:LANDREAD_STUB> - $<$:TERRAIN_AND_LANDUSE> - - - $<$:USE_ALLOCATABLES> - $<$:wrfmodel> - $<$:GRIB1> - $<$:INTIO> - $<$:KEEP_INT_AROUND> - $<$:LIMIT_ARGS> - - #!TODO Always defined - fix the ambiguous english in these BUILD_*_FAST defines - BUILD_RRTMG_FAST=$ - BUILD_RRTMK=$ - BUILD_SBM_FAST=$ - SHOW_ALL_VARS_USED=$ - - # Alwasys set - NMM_CORE=$ + + NMM_MAX_DIM=2600 NETCDF @@ -675,33 +628,180 @@ add_compile_definitions( NONSTANDARD_SYSTEM_SUBR EM_CORE=${EM_CORE} - WRFPLUS=$> - DA_CORE=$,$>> - # DFI_RADAR=$ - - # Nesting options - $<$:MOVE_NESTS> - $<$>:VORTEX_CENTER> - - # Configuration checks - $<$>:NO_IEEE_MODULE> - $<$>:NO_ISO_C_SUPPORT> - # If flush fails, check if we can fall back to fflush, and if not no support - $<$>:$,USE_FFLUSH,NO_FLUSH_SUPPORT>> - $<$>:NO_GAMMA_SUPPORT> - - #!TODO Leaving as is in WRF for now but investigate why we don't do this - # https://stackoverflow.com/a/1035713 - # If fseeko64 succeeds, use that, else check if we can fall back to fseeko, and if not just use fseek - $,FSEEKO64_OK,$,FSEEKO_OK,FSEEK_OK>> - - # I don't believe these are used anymore... - # $<$:MPI2_SUPPORT=$> - # $<$:MPI2_THREAD_SUPPORT=$> - ) +# Only define if set, this is to use #ifdef/#ifndef preprocessors +# in code since cmake cannot handle basically any others :( +# https://gitlab.kitware.com/cmake/cmake/-/issues/17398 +if ( ${ENABLE_CHEM} ) + add_compile_definitions( WRF_CHEM=1 ) + if ( ${ENABLE_KPP} ) + add_compile_definitions( WRF_KPP=1 ) + endif() +endif() +if ( ${ENABLE_CHEM} ) + add_compile_definitions( BUILD_CHEM=1 ) +endif() +if ( ${ENABLE_CMAQ} ) + add_compile_definitions( WRF_CMAQ=1 ) +endif() +if ( ${ENABLE_DFI_RADAR} ) + add_compile_definitions( WRF_DFI_RADAR=1 ) +endif() +if ( ${ENABLE_TITAN} ) + add_compile_definitions( WRF_TITAN=1 ) +endif() +if ( ${ENABLE_MARS} ) + add_compile_definitions( WRF_MARS=1 ) +endif() +if ( ${ENABLE_VENUS} ) + add_compile_definitions( WRF_VENUS=1 ) +endif() +if ( ${ENABLE_HYDRO} ) + add_compile_definitions( WRF_HYDRO=1 ) +endif() + +# Because once again we need two defines to control one thing +if ( ${ENABLE_CTSM} ) + add_compile_definitions( WRF_USE_CTSM ) +else() + #!TODO there are some files that rely on this being 1, but that is never set by the legacy make system + add_compile_definitions( WRF_USE_CLM ) +endif() + +# If force classic or no nc-4 support enable classic +if ( ${FORCE_NETCDF_CLASSIC} OR ( NOT ${netCDF_NC4} ) ) + add_compile_definitions( NETCDF_classic=1 ) +endif() +if ( ${WRFIO_NCD_NO_LARGE_FILE_SUPPORT} OR ( NOT ${netCDF_LARGE_FILE_SUPPORT} ) ) + add_compile_definitions( WRFIO_NCD_NO_LARGE_FILE_SUPPORT=1 ) +endif() +# May need a check for WRFIO_ncdpar_LARGE_FILE_SUPPORT + +# Now set the opposite in different defines, because why not :) +if ( ( NOT ${FORCE_NETCDF_CLASSIC} ) AND ${netCDF_NC4} ) + add_compile_definitions( USE_NETCDF4_FEATURES=1 ) +endif() +if ( ( NOT ${WRFIO_NCD_NO_LARGE_FILE_SUPPORT} ) AND ${netCDF_LARGE_FILE_SUPPORT} ) + add_compile_definitions( WRFIO_NCD_LARGE_FILE_SUPPORT=1 ) +endif() + +# Could simplify logic to just check if RPC is available but to be explicit +# Does this actually need to check for EM_CORE (Config.pl:443) +# not enable terran or not rpc_found do +# not ( enable terrain and rpc_found ) +# if ( NOT ( ${ENABLE_TERRAIN} AND ${RPC_FOUND} ) ) # this is wrong, needs fixing +# add_compile_definitions( LANDREAD_STUB ) +# endif() +if ( ${ENABLE_TERRAIN} AND ${MOVE_NESTS} ) + add_compile_definitions( TERRAIN_AND_LANDUSE ) +else () + add_compile_definitions( LANDREAD_STUB ) +endif() + +if ( ${USE_ALLOCATABLES} ) + add_compile_definitions( USE_ALLOCATABLES ) +endif() +if ( ${wrfmodel} ) + add_compile_definitions( wrfmodel ) +endif() +if ( ${GRIB1} ) + add_compile_definitions( GRIB1 ) +endif() +if ( ${INTIO} ) + add_compile_definitions( INTIO ) +endif() +if ( ${KEEP_INT_AROUND} ) + add_compile_definitions( KEEP_INT_AROUND ) +endif() +if ( ${LIMIT_ARGS} ) + add_compile_definitions( LIMIT_ARGS ) +endif() + + +if ( ${BUILD_RRTMG_FAST} ) + add_compile_definitions( BUILD_RRTMG_FAST=1 ) +else() + add_compile_definitions( BUILD_RRTMG_FAST=0 ) +endif() +if ( ${BUILD_RRTMK} ) + add_compile_definitions( BUILD_RRTMK=1 ) +else() + add_compile_definitions( BUILD_RRTMK=0 ) +endif() +if ( ${BUILD_SBM_FAST} ) + add_compile_definitions( BUILD_SBM_FAST=1 ) +else() + add_compile_definitions( BUILD_SBM_FAST=0 ) +endif() +if ( ${SHOW_ALL_VARS_USED} ) + add_compile_definitions( SHOW_ALL_VARS_USED=1 ) +else() + add_compile_definitions( SHOW_ALL_VARS_USED=0 ) +endif() +if ( ${NMM_CORE} ) + add_compile_definitions( NMM_CORE=1 ) +else() + add_compile_definitions( NMM_CORE=0 ) +endif() + +if ( "${WRF_CORE}" STREQUAL "PLUS" ) + add_compile_definitions( WRFPLUS=1 ) +else() + add_compile_definitions( WRFPLUS=0 ) +endif() + +if ( "${WRF_CORE}" STREQUAL "DA_CORE" OR "${WRF_CORE}" STREQUAL "DA_4D_VAR" ) + add_compile_definitions( DA_CORE=1 ) +else() + add_compile_definitions( DA_CORE=0 ) +endif() +# DFI_RADAR=$ + +# Nesting options +if ( ${MOVE_NESTS} ) + add_compile_definitions( MOVE_NESTS ) +endif() +if ( "${WRF_NESTING}" STREQUAL "VORTEX" ) + add_compile_definitions( VORTEX_CENTER ) +endif() + +# Configuration checks +if ( NOT ${Fortran_2003_IEEE} ) + add_compile_definitions( NO_IEEE_MODULE ) +endif() +if ( NOT ${Fortran_2003_ISO_C} ) + add_compile_definitions( NO_ISO_C_SUPPORT ) +endif() +# If flush fails, check if we can fall back to fflush, and if not no support +if ( NOT ${Fortran_2003_FLUSH} ) + if ( "${Fortran_2003_FFLUSH}" ) + add_compile_definitions( USE_FFLUSH ) + else() + add_compile_definitions( NO_FLUSH_SUPPORT ) + endif() +endif() +if ( NOT ${Fortran_2003_GAMMA} ) + add_compile_definitions( NO_GAMMA_SUPPORT ) +endif() + +#!TODO Leaving as is in WRF for now but investigate why we don't do this +# https://stackoverflow.com/a/1035713 +# If fseeko64 succeeds, use that, else check if we can fall back to fseeko, and if not just use fseek +if ( NOT ${FSEEKO64} ) + add_compile_definitions( FSEEKO64_OK ) +elseif( "${FSEEKO}" ) + add_compile_definitions( FSEEKO_OK ) +else() + add_compile_definitions( FSEEK_OK ) +endif() + +# I don't believe these are used anymore... +# $<$:MPI2_SUPPORT=$> +# $<$:MPI2_THREAD_SUPPORT=$> + + # Make core target add_library( ${PROJECT_NAME}_Core From 980aca8bac5cbf50024c2366df9ac0988bd7e7e8 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 24 Apr 2024 16:06:13 -0700 Subject: [PATCH 03/42] Move internal flags and compile definitions to variables rather than applied globablly --- CMakeLists.txt | 288 ++++++++++++++------------- chem/CMakeLists.txt | 15 +- external/CMakeLists.txt | 4 + external/io_adios2/CMakeLists.txt | 3 +- external/io_netcdf/CMakeLists.txt | 3 +- external/io_netcdfpar/CMakeLists.txt | 3 +- external/io_pnetcdf/CMakeLists.txt | 3 +- frame/CMakeLists.txt | 7 +- main/CMakeLists.txt | 3 + phys/CMakeLists.txt | 3 +- tools/CMakeLists.txt | 5 +- 11 files changed, 184 insertions(+), 153 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e719518246..8bdbbdaf32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -322,21 +322,21 @@ if ( ${USE_MPI} ) # It still technically finds MPI but the output is nonintuitive # saying things like hdf5 or pthread find_package( MPI REQUIRED COMPONENTS Fortran C ) - add_compile_definitions( - USE_MPI=1 - DM_PARALLEL - ) + list( APPEND PROJECT_COMPILE_DEFINITIONS + USE_MPI=1 + DM_PARALLEL + ) if ( DEFINED WRF_MPI_Fortran_FLAGS AND NOT "${WRF_MPI_Fortran_FLAGS}" STREQUAL "" ) - add_compile_options( - $<$:${WRF_MPI_Fortran_FLAGS}> - ) + list( APPEND PROJECT_COMPILE_OPTIONS + $<$:${WRF_MPI_Fortran_FLAGS}> + ) endif() if ( DEFINED WRF_MPI_C_FLAGS AND NOT "${WRF_MPI_C_FLAGS}" STREQUAL "" ) - add_compile_options( - $<$:${WRF_MPI_C_FLAGS}> - ) + list( APPEND PROJECT_COMPILE_OPTIONS + $<$:${WRF_MPI_C_FLAGS}> + ) endif() # Check if MPI in all its glory has forced IPO down our throats due to hard-coding the wrapper flags @@ -365,16 +365,19 @@ if ( ${USE_MPI} ) set( USE_RSL_LITE ON ) # We know NONE is the zero index so compare against that elseif( ${CURRENT_NESTING_IDX} GREATER 0 ) - add_compile_definitions( - DM_PARALLEL - STUBMPI - ) + list( APPEND PROJECT_COMPILE_DEFINITIONS + DM_PARALLEL + STUBMPI + ) set( USE_RSL_LITE ON ) endif() if ( ${USE_OPENMP} ) find_package( OpenMP REQUIRED COMPONENTS Fortran C ) - add_compile_definitions( USE_OPENMP=1 SM_PARALLEL ) + list( APPEND PROJECT_COMPILE_DEFINITIONS + USE_OPENMP=1 + SM_PARALLEL + ) endif() if ( ${USE_M4} ) @@ -541,50 +544,50 @@ endif() # This is really ugly but such is the cost of supporting many ways to say the same thing # https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html -add_compile_options( - # Use "" and ; specifically to evaluate correctly - # "$<$:>" #@ Absoft Fortran - # "$<$:>" #@ Analog VisualDSP++ - # "$<$:>" #@ Apple Clang - # "$<$:>" #@ ARM Compiler - # "$<$:>" #@ ARM Compiler based on Clang - # "$<$:>" #@ Bruce C Compiler - # "$<$:>" #@ Concurrent Fortran - # "$<$:>" #@ LLVM Clang - "$<$:-s;integer32;-s;real${RWORDSIZE_B}>" #@ Cray Compiler - # "$<$:>" #@ Embarcadero - "$<$,$>:-fdefault-real-${RWORDSIZE}>" #@ Classic Flang Fortran Compiler - # "$<$:>" #@ LLVM Flang Fortran Compiler - "$<$:-CcdRR${RWORDSIZE}>" #@ Fujitsu HPC compiler (Trad mode) - # "$<$:>" #@ Fujitsu HPC compiler (Clang mode) - "$<$:-r${RWORDSIZE};-i4>" #@ G95 Fortran - "$<$,$>:-fdefault-real-${RWORDSIZE}>" #@ GNU Compiler Collection - # "$<$:>" #@ Green Hills Software - # "$<$:>" #@ Hewlett-Packard Compiler - # "$<$:>" #@ IAR Systems - "$<$:-real-size;${RWORDSIZE_B};-i4>" #@ Intel Classic Compiler - "$<$:-real-size;${RWORDSIZE_B};-i4>" #@ Intel LLVM-Based Compiler - # "$<$:>" #@ MCST Elbrus C/C++/Fortran Compiler - # "$<$:>" #@ Microsoft Visual Studio - "$<$:-r${RWORDSIZE};-i4>" #@ NVIDIA HPC Compiler - # "$<$:>" #@ NVIDIA CUDA Compiler - # "$<$:>" #@ Open Watcom - "$<$:-r${RWORDSIZE};-i4>" #@ The Portland Group - "$<$:-r${RWORDSIZE};-i4>" #@ PathScale - # "$<$:>" #@ Small Device C Compiler - # "$<$:>" #@ Oracle Solaris Studio - # "$<$:>" #@ Tasking Compiler Toolsets - # "$<$:>" #@ Texas Instruments - # "$<$:>" #@ Tiny C Compiler - "$<$:-qrealsize=${RWORDSIZE};-qintsize=4>" #@ IBM XL - # "$<$:>" #@ IBM Clang-based XL - # "$<$:>" #@ IBM LLVM-based Compiler - # Todo find how to handle default selection or add new compiler IDs - # unknown how to add support for sxf90 - - # line lengths - "$<$:-ffree-line-length-none>" #@ GNU Compiler Collection - ) +list( APPEND PROJECT_COMPILE_OPTIONS + # Use "" and ; specifically to evaluate correctly + # "$<$:>" #@ Absoft Fortran + # "$<$:>" #@ Analog VisualDSP++ + # "$<$:>" #@ Apple Clang + # "$<$:>" #@ ARM Compiler + # "$<$:>" #@ ARM Compiler based on Clang + # "$<$:>" #@ Bruce C Compiler + # "$<$:>" #@ Concurrent Fortran + # "$<$:>" #@ LLVM Clang + "$<$:-s;integer32;-s;real${RWORDSIZE_B}>" #@ Cray Compiler + # "$<$:>" #@ Embarcadero + "$<$,$>:-fdefault-real-${RWORDSIZE}>" #@ Classic Flang Fortran Compiler + # "$<$:>" #@ LLVM Flang Fortran Compiler + "$<$:-CcdRR${RWORDSIZE}>" #@ Fujitsu HPC compiler (Trad mode) + # "$<$:>" #@ Fujitsu HPC compiler (Clang mode) + "$<$:-r${RWORDSIZE};-i4>" #@ G95 Fortran + "$<$,$>:-fdefault-real-${RWORDSIZE}>" #@ GNU Compiler Collection + # "$<$:>" #@ Green Hills Software + # "$<$:>" #@ Hewlett-Packard Compiler + # "$<$:>" #@ IAR Systems + "$<$:-real-size;${RWORDSIZE_B};-i4>" #@ Intel Classic Compiler + "$<$:-real-size;${RWORDSIZE_B};-i4>" #@ Intel LLVM-Based Compiler + # "$<$:>" #@ MCST Elbrus C/C++/Fortran Compiler + # "$<$:>" #@ Microsoft Visual Studio + "$<$:-r${RWORDSIZE};-i4>" #@ NVIDIA HPC Compiler + # "$<$:>" #@ NVIDIA CUDA Compiler + # "$<$:>" #@ Open Watcom + "$<$:-r${RWORDSIZE};-i4>" #@ The Portland Group + "$<$:-r${RWORDSIZE};-i4>" #@ PathScale + # "$<$:>" #@ Small Device C Compiler + # "$<$:>" #@ Oracle Solaris Studio + # "$<$:>" #@ Tasking Compiler Toolsets + # "$<$:>" #@ Texas Instruments + # "$<$:>" #@ Tiny C Compiler + "$<$:-qrealsize=${RWORDSIZE};-qintsize=4>" #@ IBM XL + # "$<$:>" #@ IBM Clang-based XL + # "$<$:>" #@ IBM LLVM-based Compiler + # Todo find how to handle default selection or add new compiler IDs + # unknown how to add support for sxf90 + + # line lengths + "$<$:-ffree-line-length-none>" #@ GNU Compiler Collection + ) # https://stackoverflow.com/a/53155812 @@ -593,98 +596,98 @@ add_compile_options( # Whole project flags -add_compile_options( - # $<$:-cpp> - # Use "" and ; specifically to evaluate correctly - "$<$:-diag-disable;6843>" - $<$,$>:-fallow-argument-mismatch> - $<$,$>:-fallow-invalid-boz> - $<$,$>:-ffree-line-length-none> - - # $,$:-diag-disable;6843> - ) +list( APPEND PROJECT_COMPILE_OPTIONS + # $<$:-cpp> + # Use "" and ; specifically to evaluate correctly + "$<$:-diag-disable;6843>" + $<$,$>:-fallow-argument-mismatch> + $<$,$>:-fallow-invalid-boz> + $<$,$>:-ffree-line-length-none> + + # $,$:-diag-disable;6843> + ) if ( ${PROFILE_COMPILATION} ) message( STATUS "Attemping to add compilation profiling..." ) - add_compile_options( - $<$:-ftime-report> - ) + list( APPEND PROJECT_COMPILE_OPTIONS $<$:-ftime-report> ) endif() -add_compile_definitions( - MAX_DOMAINS_F=${MAX_DOMAINS_F} - CONFIG_BUF_LEN=${CONFIG_BUF_LEN} - MAX_HISTORY=${MAX_HISTORY} - IWORDSIZE=${IWORDSIZE} - DWORDSIZE=${DWORDSIZE} - LWORDSIZE=${LWORDSIZE} - RWORDSIZE=${RWORDSIZE} +list( APPEND PROJECT_COMPILE_DEFINITIONS + MAX_DOMAINS_F=${MAX_DOMAINS_F} + CONFIG_BUF_LEN=${CONFIG_BUF_LEN} + MAX_HISTORY=${MAX_HISTORY} + IWORDSIZE=${IWORDSIZE} + DWORDSIZE=${DWORDSIZE} + LWORDSIZE=${LWORDSIZE} + RWORDSIZE=${RWORDSIZE} - NMM_MAX_DIM=2600 - NETCDF + # Alwasys set + NMM_MAX_DIM=2600 + NETCDF + + #!TODO Change this to a confcheck + NONSTANDARD_SYSTEM_SUBR + + EM_CORE=${EM_CORE} - #!TODO Change this to a confcheck - NONSTANDARD_SYSTEM_SUBR - - EM_CORE=${EM_CORE} - ) + ) # Only define if set, this is to use #ifdef/#ifndef preprocessors # in code since cmake cannot handle basically any others :( # https://gitlab.kitware.com/cmake/cmake/-/issues/17398 if ( ${ENABLE_CHEM} ) - add_compile_definitions( WRF_CHEM=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_CHEM=1 ) if ( ${ENABLE_KPP} ) - add_compile_definitions( WRF_KPP=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_KPP=1 ) endif() endif() if ( ${ENABLE_CHEM} ) - add_compile_definitions( BUILD_CHEM=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS BUILD_CHEM=1 ) endif() if ( ${ENABLE_CMAQ} ) - add_compile_definitions( WRF_CMAQ=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_CMAQ=1 ) endif() if ( ${ENABLE_DFI_RADAR} ) - add_compile_definitions( WRF_DFI_RADAR=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_DFI_RADAR=1 ) endif() if ( ${ENABLE_TITAN} ) - add_compile_definitions( WRF_TITAN=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_TITAN=1 ) endif() if ( ${ENABLE_MARS} ) - add_compile_definitions( WRF_MARS=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_MARS=1 ) endif() if ( ${ENABLE_VENUS} ) - add_compile_definitions( WRF_VENUS=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_VENUS=1 ) endif() if ( ${ENABLE_HYDRO} ) - add_compile_definitions( WRF_HYDRO=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_HYDRO=1 ) endif() # Because once again we need two defines to control one thing if ( ${ENABLE_CTSM} ) - add_compile_definitions( WRF_USE_CTSM ) + list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_USE_CTSM ) else() #!TODO there are some files that rely on this being 1, but that is never set by the legacy make system - add_compile_definitions( WRF_USE_CLM ) + list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_USE_CLM ) endif() # If force classic or no nc-4 support enable classic if ( ${FORCE_NETCDF_CLASSIC} OR ( NOT ${netCDF_NC4} ) ) - add_compile_definitions( NETCDF_classic=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS NETCDF_classic=1 ) endif() if ( ${WRFIO_NCD_NO_LARGE_FILE_SUPPORT} OR ( NOT ${netCDF_LARGE_FILE_SUPPORT} ) ) - add_compile_definitions( WRFIO_NCD_NO_LARGE_FILE_SUPPORT=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS WRFIO_NCD_NO_LARGE_FILE_SUPPORT=1 ) endif() # May need a check for WRFIO_ncdpar_LARGE_FILE_SUPPORT # Now set the opposite in different defines, because why not :) if ( ( NOT ${FORCE_NETCDF_CLASSIC} ) AND ${netCDF_NC4} ) - add_compile_definitions( USE_NETCDF4_FEATURES=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS USE_NETCDF4_FEATURES=1 ) endif() if ( ( NOT ${WRFIO_NCD_NO_LARGE_FILE_SUPPORT} ) AND ${netCDF_LARGE_FILE_SUPPORT} ) - add_compile_definitions( WRFIO_NCD_LARGE_FILE_SUPPORT=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS WRFIO_NCD_LARGE_FILE_SUPPORT=1 ) endif() # Could simplify logic to just check if RPC is available but to be explicit @@ -692,109 +695,109 @@ endif() # not enable terran or not rpc_found do # not ( enable terrain and rpc_found ) # if ( NOT ( ${ENABLE_TERRAIN} AND ${RPC_FOUND} ) ) # this is wrong, needs fixing -# add_compile_definitions( LANDREAD_STUB ) +# list( APPEND PROJECT_COMPILE_DEFINITIONS LANDREAD_STUB ) # endif() if ( ${ENABLE_TERRAIN} AND ${MOVE_NESTS} ) - add_compile_definitions( TERRAIN_AND_LANDUSE ) + list( APPEND PROJECT_COMPILE_DEFINITIONS TERRAIN_AND_LANDUSE ) else () - add_compile_definitions( LANDREAD_STUB ) + list( APPEND PROJECT_COMPILE_DEFINITIONS LANDREAD_STUB ) endif() if ( ${USE_ALLOCATABLES} ) - add_compile_definitions( USE_ALLOCATABLES ) + list( APPEND PROJECT_COMPILE_DEFINITIONS USE_ALLOCATABLES ) endif() if ( ${wrfmodel} ) - add_compile_definitions( wrfmodel ) + list( APPEND PROJECT_COMPILE_DEFINITIONS wrfmodel ) endif() if ( ${GRIB1} ) - add_compile_definitions( GRIB1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS GRIB1 ) endif() if ( ${INTIO} ) - add_compile_definitions( INTIO ) + list( APPEND PROJECT_COMPILE_DEFINITIONS INTIO ) endif() if ( ${KEEP_INT_AROUND} ) - add_compile_definitions( KEEP_INT_AROUND ) + list( APPEND PROJECT_COMPILE_DEFINITIONS KEEP_INT_AROUND ) endif() if ( ${LIMIT_ARGS} ) - add_compile_definitions( LIMIT_ARGS ) + list( APPEND PROJECT_COMPILE_DEFINITIONS LIMIT_ARGS ) endif() if ( ${BUILD_RRTMG_FAST} ) - add_compile_definitions( BUILD_RRTMG_FAST=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS BUILD_RRTMG_FAST=1 ) else() - add_compile_definitions( BUILD_RRTMG_FAST=0 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS BUILD_RRTMG_FAST=0 ) endif() if ( ${BUILD_RRTMK} ) - add_compile_definitions( BUILD_RRTMK=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS BUILD_RRTMK=1 ) else() - add_compile_definitions( BUILD_RRTMK=0 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS BUILD_RRTMK=0 ) endif() if ( ${BUILD_SBM_FAST} ) - add_compile_definitions( BUILD_SBM_FAST=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS BUILD_SBM_FAST=1 ) else() - add_compile_definitions( BUILD_SBM_FAST=0 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS BUILD_SBM_FAST=0 ) endif() if ( ${SHOW_ALL_VARS_USED} ) - add_compile_definitions( SHOW_ALL_VARS_USED=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS SHOW_ALL_VARS_USED=1 ) else() - add_compile_definitions( SHOW_ALL_VARS_USED=0 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS SHOW_ALL_VARS_USED=0 ) endif() if ( ${NMM_CORE} ) - add_compile_definitions( NMM_CORE=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS NMM_CORE=1 ) else() - add_compile_definitions( NMM_CORE=0 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS NMM_CORE=0 ) endif() if ( "${WRF_CORE}" STREQUAL "PLUS" ) - add_compile_definitions( WRFPLUS=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS WRFPLUS=1 ) else() - add_compile_definitions( WRFPLUS=0 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS WRFPLUS=0 ) endif() if ( "${WRF_CORE}" STREQUAL "DA_CORE" OR "${WRF_CORE}" STREQUAL "DA_4D_VAR" ) - add_compile_definitions( DA_CORE=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS DA_CORE=1 ) else() - add_compile_definitions( DA_CORE=0 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS DA_CORE=0 ) endif() # DFI_RADAR=$ # Nesting options if ( ${MOVE_NESTS} ) - add_compile_definitions( MOVE_NESTS ) + list( APPEND PROJECT_COMPILE_DEFINITIONS MOVE_NESTS ) endif() if ( "${WRF_NESTING}" STREQUAL "VORTEX" ) - add_compile_definitions( VORTEX_CENTER ) + list( APPEND PROJECT_COMPILE_DEFINITIONS VORTEX_CENTER ) endif() # Configuration checks if ( NOT ${Fortran_2003_IEEE} ) - add_compile_definitions( NO_IEEE_MODULE ) + list( APPEND PROJECT_COMPILE_DEFINITIONS NO_IEEE_MODULE ) endif() if ( NOT ${Fortran_2003_ISO_C} ) - add_compile_definitions( NO_ISO_C_SUPPORT ) + list( APPEND PROJECT_COMPILE_DEFINITIONS NO_ISO_C_SUPPORT ) endif() # If flush fails, check if we can fall back to fflush, and if not no support if ( NOT ${Fortran_2003_FLUSH} ) if ( "${Fortran_2003_FFLUSH}" ) - add_compile_definitions( USE_FFLUSH ) + list( APPEND PROJECT_COMPILE_DEFINITIONS USE_FFLUSH ) else() - add_compile_definitions( NO_FLUSH_SUPPORT ) + list( APPEND PROJECT_COMPILE_DEFINITIONS NO_FLUSH_SUPPORT ) endif() endif() if ( NOT ${Fortran_2003_GAMMA} ) - add_compile_definitions( NO_GAMMA_SUPPORT ) + list( APPEND PROJECT_COMPILE_DEFINITIONS NO_GAMMA_SUPPORT ) endif() #!TODO Leaving as is in WRF for now but investigate why we don't do this # https://stackoverflow.com/a/1035713 # If fseeko64 succeeds, use that, else check if we can fall back to fseeko, and if not just use fseek -if ( NOT ${FSEEKO64} ) - add_compile_definitions( FSEEKO64_OK ) +if ( ${FSEEKO64} ) + list( APPEND PROJECT_COMPILE_DEFINITIONS FSEEKO64_OK ) elseif( "${FSEEKO}" ) - add_compile_definitions( FSEEKO_OK ) + list( APPEND PROJECT_COMPILE_DEFINITIONS FSEEKO_OK ) else() - add_compile_definitions( FSEEK_OK ) + list( APPEND PROJECT_COMPILE_DEFINITIONS FSEEK_OK ) endif() # I don't believe these are used anymore... @@ -808,6 +811,19 @@ add_library( STATIC ) +target_compile_options( + ${PROJECT_NAME}_Core + PRIVATE + ${PROJECT_COMPILE_OPTIONS} + ) + + +target_compile_definitions( + ${PROJECT_NAME}_Core + PRIVATE + ${PROJECT_COMPILE_DEFINITIONS} + ) + # Supplemental to core, or rather should be, some stuff in external is legitimately part of WRF and others # are source code from truly external repositories - albeit old versions add_subdirectory( external ) diff --git a/chem/CMakeLists.txt b/chem/CMakeLists.txt index 9bfbf3d5ac..544b253256 100644 --- a/chem/CMakeLists.txt +++ b/chem/CMakeLists.txt @@ -223,4 +223,17 @@ target_link_libraries( convert_emiss PRIVATE ${PROJECT_NAME}_Core - ) \ No newline at end of file + ) + +target_compile_options( + convert_emiss + PRIVATE + ${PROJECT_COMPILE_OPTIONS} + ) + + +target_compile_definitions( + convert_emiss + PRIVATE + ${PROJECT_COMPILE_DEFINITIONS} + ) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 7036a9debe..e52b1c3fbf 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -20,6 +20,10 @@ # Always build +# Suffice it to say everything under this is WRF-specific while also being external +add_compile_options ( "${PROJECT_COMPILE_OPTIONS}" ) +add_compile_definitions( "${PROJECT_COMPILE_DEFINITIONS}" ) + add_subdirectory( io_int ) add_subdirectory( io_grib1 ) add_subdirectory( io_grib_share ) diff --git a/external/io_adios2/CMakeLists.txt b/external/io_adios2/CMakeLists.txt index dde531a716..2d8efd61e0 100644 --- a/external/io_adios2/CMakeLists.txt +++ b/external/io_adios2/CMakeLists.txt @@ -33,14 +33,13 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} # First preprocess -get_directory_property( DIR_DEFS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS ) get_target_property ( FOLDER_COMPILE_TARGET_INCLUDES ${FOLDER_COMPILE_TARGET} INCLUDE_DIRECTORIES ) wrf_c_preproc_fortran( TARGET_NAME ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ EXTENSION ".f90" INCLUDES ${FOLDER_COMPILE_TARGET_INCLUDES} - DEFINITIONS ${DIR_DEFS} + DEFINITIONS ${PROJECT_COMPILE_DEFINITIONS} SOURCES wrf_io.F90 ) diff --git a/external/io_netcdf/CMakeLists.txt b/external/io_netcdf/CMakeLists.txt index ac93792869..b63a1ae474 100644 --- a/external/io_netcdf/CMakeLists.txt +++ b/external/io_netcdf/CMakeLists.txt @@ -47,14 +47,13 @@ target_include_directories( # First preprocess -get_directory_property( DIR_DEFS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS ) get_target_property ( FOLDER_COMPILE_TARGET_INCLUDES ${FOLDER_COMPILE_TARGET} INCLUDE_DIRECTORIES ) wrf_c_preproc_fortran( TARGET_NAME ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ EXTENSION ".f90" INCLUDES ${FOLDER_COMPILE_TARGET_INCLUDES} - DEFINITIONS ${DIR_DEFS} + DEFINITIONS ${PROJECT_COMPILE_DEFINITIONS} SOURCES wrf_io.F90 ) diff --git a/external/io_netcdfpar/CMakeLists.txt b/external/io_netcdfpar/CMakeLists.txt index 8a0db9b9c9..9536023c58 100644 --- a/external/io_netcdfpar/CMakeLists.txt +++ b/external/io_netcdfpar/CMakeLists.txt @@ -47,14 +47,13 @@ target_include_directories( # First preprocess -get_directory_property( DIR_DEFS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS ) get_target_property ( FOLDER_COMPILE_TARGET_INCLUDES ${FOLDER_COMPILE_TARGET} INCLUDE_DIRECTORIES ) wrf_c_preproc_fortran( TARGET_NAME ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ EXTENSION ".f90" INCLUDES ${FOLDER_COMPILE_TARGET_INCLUDES} - DEFINITIONS ${DIR_DEFS} + DEFINITIONS ${PROJECT_COMPILE_DEFINITIONS} SOURCES wrf_io.F90 ) diff --git a/external/io_pnetcdf/CMakeLists.txt b/external/io_pnetcdf/CMakeLists.txt index 1717f71383..8c7c138233 100644 --- a/external/io_pnetcdf/CMakeLists.txt +++ b/external/io_pnetcdf/CMakeLists.txt @@ -35,14 +35,13 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} # First preprocess -get_directory_property( DIR_DEFS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS ) get_target_property ( FOLDER_COMPILE_TARGET_INCLUDES ${FOLDER_COMPILE_TARGET} INCLUDE_DIRECTORIES ) wrf_c_preproc_fortran( TARGET_NAME ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ EXTENSION ".f90" INCLUDES ${FOLDER_COMPILE_TARGET_INCLUDES} - DEFINITIONS ${DIR_DEFS} + DEFINITIONS ${PROJECT_COMPILE_DEFINITIONS} SOURCES wrf_io.F90 ) diff --git a/frame/CMakeLists.txt b/frame/CMakeLists.txt index 59f8d2551b..c322d84c9a 100644 --- a/frame/CMakeLists.txt +++ b/frame/CMakeLists.txt @@ -14,7 +14,6 @@ set( # Generate all the combinations dynamically, not a fan of this file breakdown ######################################################################################################################## set( nl_dyn_source ) -get_directory_property( DIR_DEFS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS ) foreach( n RANGE 0 7 ) wrf_c_preproc_fortran( @@ -25,7 +24,7 @@ foreach( n RANGE 0 7 ) INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/inc DEPENDENCIES registry_code - DEFINITIONS ${DIR_DEFS} NNN=${n} NL_set_ROUTINES + DEFINITIONS ${PROJECT_COMPILE_DEFINITIONS} NNN=${n} NL_set_ROUTINES SOURCES nl_access_routines.F ) wrf_c_preproc_fortran( @@ -36,7 +35,7 @@ foreach( n RANGE 0 7 ) INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/inc DEPENDENCIES registry_code - DEFINITIONS ${DIR_DEFS} NNN=${n} NL_get_ROUTINES + DEFINITIONS ${PROJECT_COMPILE_DEFINITIONS} NNN=${n} NL_get_ROUTINES SOURCES nl_access_routines.F ) @@ -166,4 +165,4 @@ set_source_files_properties( install( FILES ${WRF_INCLUDE_FILES} DESTINATION include/${FOLDER_COMPILE_TARGET} - ) \ No newline at end of file + ) diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 9a2f69eca6..b0ec69d7f0 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -1,6 +1,9 @@ # WRF CMake Build set( FOLDER_COMPILE_TARGETS ) +add_compile_options ( "${PROJECT_COMPILE_OPTIONS}" ) +add_compile_definitions( "${PROJECT_COMPILE_DEFINITIONS}" ) + # First make true executables if ( ${WRF_CORE} STREQUAL "PLUS" ) add_executable( diff --git a/phys/CMakeLists.txt b/phys/CMakeLists.txt index d7d85e1c12..d3df6a28e0 100644 --- a/phys/CMakeLists.txt +++ b/phys/CMakeLists.txt @@ -5,14 +5,13 @@ # Quickly preprocess some files so that cmake can understand the module dependencies # ######################################################################################################################## -get_directory_property( DIR_DEFS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS ) wrf_c_preproc_fortran( TARGET_NAME module_ra_rrtmg_preproc OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ EXTENSION ".f90" INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} DEPENDENCIES registry_code - DEFINITIONS ${DIR_DEFS} + DEFINITIONS ${PROJECT_COMPILE_DEFINITIONS} SOURCES module_ra_rrtmg_lwk.F module_ra_rrtmg_lwf.F module_ra_rrtmg_swk.F diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 1181ab0af4..a261177f1a 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,4 +1,6 @@ # WRF CMake Build +add_compile_options ( "${PROJECT_COMPILE_OPTIONS}" ) +add_compile_definitions( "${PROJECT_COMPILE_DEFINITIONS}" ) #!TODO ORGANIZE THIS FOLDER set( FOLDER_COMPILE_TARGET registry ) @@ -99,10 +101,9 @@ elseif ( ${WRF_CORE} STREQUAL "DA" OR ${WRF_CORE} STREQUAL "DA_4D_VAR" ) endif() -get_directory_property( DIR_DEFS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS ) wrf_expand_definitions( RESULT_VAR REGISTRY_DEFS - DEFINITIONS ${DIR_DEFS} + DEFINITIONS ${PROJECT_COMPILE_DEFINITIONS} ) # How this is not a bigger thing or not resolved is beyond me From 6b9d27ea71fe9a544d2a2f0136716e78821d1679 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 30 Jul 2024 16:20:31 -0700 Subject: [PATCH 04/42] Make sure hydro gets all the flags similar to original cmake build --- hydro/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hydro/CMakeLists.txt b/hydro/CMakeLists.txt index ee756e71ac..63f6f59bf0 100644 --- a/hydro/CMakeLists.txt +++ b/hydro/CMakeLists.txt @@ -1,4 +1,6 @@ # additions that WRF-Hydro's top CMakeLists.txt handles +add_compile_options( ${PROJECT_COMPILE_OPTIONS} ) +add_compile_definitions( ${PROJECT_COMPILE_DEFINITIONS} ) set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/hydro/mods) add_definitions(-DMPP_LAND) if (WRF_HYDRO_NUDGING STREQUAL "1") From 4dda1098f96384309a466b8d8b376e71d4ea5958 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 31 Jul 2024 17:47:42 -0700 Subject: [PATCH 05/42] Prepare cmake build to not have core selection --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bdbbdaf32..4f42c8f374 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,6 +127,9 @@ set( WRF_CASE_OPTIONS EM_CONVRAD EM_SQUALL2D_X EM_SQUALL2D_Y + + # No case selected, for situations where we are not compiling ARW + NONE ) set( WRF_CASE "" CACHE STRING "WRF_CASE" ) From bee8ddd2075a80305cf1c9e9f6045522307f2cba Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 31 Jul 2024 17:48:44 -0700 Subject: [PATCH 06/42] Make sure appropriate selection of option for non-ARW cores --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f42c8f374..70e1a06f91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -223,6 +223,11 @@ if ( NOT ${WRF_CORE} IN_LIST WRF_CORE_OPTIONS ) message( FATAL_ERROR "WRF Core option not recognized : ${WRF_CORE}" ) endif() +if ( NOT ${WRF_CORE} STREQUAL "ARW" ) + message( STATUS "All non-ARW Cores requires using pointers in grid state struct" ) + set( USE_ALLOCATABLES OFF CACHE BOOL "Required by configuration" FORCE ) +endif() + if ( NOT ${WRF_NESTING} IN_LIST WRF_NESTING_OPTIONS ) message( FATAL_ERROR "WRF Nesting option not recognized : ${WRF_NESTING}" ) endif() From 4e30de19ea998be194979d6ab91ce96b3045a5e3 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 31 Jul 2024 17:49:02 -0700 Subject: [PATCH 07/42] Shortcut selections for other cores --- arch/configure_reader.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/configure_reader.py b/arch/configure_reader.py index fb89bfca80..2668a86f1f 100755 --- a/arch/configure_reader.py +++ b/arch/configure_reader.py @@ -575,8 +575,12 @@ def generateCMakeToolChainFile( cmakeToolChainTemplate, output, stanza, optionsD def projectSpecificOptions( options, stanzaCfg ) : coreOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_CORE_OPTIONS", "WRF_CORE" ) - nestingOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_NESTING_OPTIONS", "WRF_NESTING", 1 ) - caseOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_CASE_OPTIONS", "WRF_CASE" ) + if coreOption == "ARW" : + nestingOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_NESTING_OPTIONS", "WRF_NESTING", 1 ) + caseOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_CASE_OPTIONS", "WRF_CASE" ) + else : + nestingOption = "NONE" + caseOption = "NONE" # These are yes yesValues = [ "yes", "y", "true", "1" ] From 5598e7c314626883567cc9d76215187c0c7225f5 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 31 Jul 2024 17:54:07 -0700 Subject: [PATCH 08/42] Generalize the sanitization logic for stanzas --- arch/configure_reader.py | 52 ++++------------------------------------ 1 file changed, 5 insertions(+), 47 deletions(-) diff --git a/arch/configure_reader.py b/arch/configure_reader.py index 2668a86f1f..98f758e0b8 100755 --- a/arch/configure_reader.py +++ b/arch/configure_reader.py @@ -17,7 +17,8 @@ osAndArchAlt = re.compile( r"^ARCH[ ]+(\w+)[ ]+(\w+)", re.I ) referenceVar = re.compile( r"[$]([(])?(\w+)(?(1)[)])", re.I ) -compileObject = re.compile( r"(\W)-c(\W)" ) +compileObject = re.compile( r"(\W|^)-c(\W|$)" ) +configureRepl = re.compile( r"(\W|^)CONFIGURE_\w+(\W|$)" ) class Stanza(): @@ -160,52 +161,9 @@ def sanitize( self ) : self.dereference( "FCBASEOPTS" ) # Remove rogue compile commands that should *NOT* even be here - keysToSanitize = [ - "ARFLAGS","ARFLAGS", - "CC", - "CFLAGS_LOCAL", - "CFLAGS", - "COMPRESSION_INC", - "COMPRESSION_LIBS", - "CPP", - "CPPFLAGS", - "DM_CC", - "DM_FC", - "ESMF_LDFLAG", - "F77FLAGS", - "FC", - "FCBASEOPTS_NO_G", - "FCBASEOPTS", - "FCOPTIM", - "FCSUFFIX", - "FDEFS", - "FFLAGS", - "FNGFLAGS", - "FORMAT_FIXED", - "FORMAT_FREE", - "LD", - "LDFLAGS_LOCAL", - "LDFLAGS", - "MODULE_SRCH_FLAG", - "RLFLAGS", - "SCC", - "SFC", - "TRADFLAG", - ] - - for keyToSan in keysToSanitize : - if keyToSan in self.kvPairs_ : - self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_COMP_L", "" ) - self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_COMP_I", "" ) - self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_FC", "" ) - self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_CC", "" ) - self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_FDEFS", "" ) - self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_MPI", "" ) - self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_COMPAT_FLAGS", "" ) - self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_CPPFLAGS", "" ) - self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_TRADFLAG", "" ) - - self.kvPairs_[ keyToSan ] = compileObject.sub( r"\1\2", self.kvPairs_[ keyToSan ] ).strip() + for keyToSan in self.kvPairs_.keys() : + self.kvPairs_[ keyToSan ] = configureRepl.sub( r"\1\2", self.kvPairs_[ keyToSan ] ).strip() + self.kvPairs_[ keyToSan ] = compileObject.sub( r"\1\2", self.kvPairs_[ keyToSan ] ).strip() # Now fix certain ones that are mixing programs with flags all mashed into one option From 96930f52e5596256f13ae8bca9b171d453c6877d Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 29 Jul 2024 18:42:50 -0700 Subject: [PATCH 09/42] Create properties for flag and defines organization --- CMakeLists.txt | 25 +++++++ cmake/target_source_properties.cmake | 107 +++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 cmake/target_source_properties.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 70e1a06f91..7321125eb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,12 +26,15 @@ list( APPEND CMAKE_C_PREPROCESSOR_FLAGS -P -nostdinc -traditional ) include( CMakePackageConfigHelpers ) include( CheckIPOSupported ) + +# WRF helper scripts include( c_preproc ) include( m4_preproc ) include( target_copy ) include( confcheck ) include( gitinfo ) include( printOption ) +include( target_source_properties ) include( wrf_case_setup ) include( wrf_get_version ) @@ -311,6 +314,28 @@ if ( ${USE_IPO} ) endif() endif() + +################################################################################ +## +## Create our flags / defines properties and variables to carry our information +## +################################################################################ +define_target_source_properties( + PROPERTIES + FLAGS_OPTIMIZATION # Control of optimization flags + FLAGS_CONFCHECK # Originate from system configuration checks + FLAGS_Fortran_PRECISION # Fortran floating point precision control + FLAGS_Fortran_LINE_LENGTH # Fortran line length for compilers that need it + FLAGS_DIAGNOSTICS # Extra flags for diagnostics + FLAGS_SUPPRESS_ERRORS # EXPLICITLY suppress errors, USE SPARINGLY!!! + FLAGS_SUPPRESS_WARNINGS # Suppress warnings, try to fix before they become errs + FLAGS_STANZA # Any remaining flags imported via stanza + + DEFINE_CONFCHECK # Originate from system configuration checks + DEFINE_OPTIONS # Anything that is derived from options + DEFINE_STANZA # Any remaining defines imported via stanza + ) + ################################################################################ ## ## Now find packages that cross-compilation is potentially handled diff --git a/cmake/target_source_properties.cmake b/cmake/target_source_properties.cmake new file mode 100644 index 0000000000..c6ce9d4d00 --- /dev/null +++ b/cmake/target_source_properties.cmake @@ -0,0 +1,107 @@ +# +# These two functions together allow greater control of propagating flags within +# a target on a per-source basis with the ability to "inherit" those properties +# from the target if not set. This allows a target to defing its own flags, but +# then if a file needs different settings those can be directly overridden without +# relying on compiler-specific flag order precedence. Additionally this allows a +# project to organize grouping of flags within a target +# + + +# +# A simple function to create properties for targets and sources quickly +# +function( define_target_source_properties ) + set( options ) + set( oneValueArgs ) + set( multiValueArgs PROPERTIES ) + + cmake_parse_arguments( + FUNC_PROP + "${options}" "${oneValueArgs}" "${multiValueArgs}" + ${ARGN} + ) + + foreach( PROPERTY ${FUNC_PROP_PROPERTIES} ) + define_property( + SOURCE + PROPERTY ${PROPERTY} + # INHERITED # they will be "inherited" via target to source + ) + + define_property( + TARGET + PROPERTY ${PROPERTY} + # INHERITED # they will be "inherited" via target to source + ) + endforeach() +endfunction() + + +# +# The bulk of the functionality exists in this function. It will loop over each +# provided target, gathering sources and their respective properties listed, using +# the target's property if not defined for this source else nothing, and finally +# applies it to that source. +# +function( apply_target_source_properties ) + set( options ) + set( oneValueArgs AS_PROPERTY ) + set( multiValueArgs TARGETS PROPERTIES ) + + cmake_parse_arguments( + FUNC_PROP + "${options}" "${oneValueArgs}" "${multiValueArgs}" + ${ARGN} + ) + + foreach( TARGET ${FUNC_PROP_TARGETS} ) + # get target sources + get_target_property( TARGET_SOURCES ${TARGET} SOURCES ) + + # get default "inherited" value from target + foreach( PROPERTY ${FUNC_PROP_PROPERTIES} ) + get_target_property( TARGET_PROPERTY_${PROPERTY} ${TARGET} ${PROPERTY} ) + if ( "${TARGET_PROPERTY_${PROPERTY}}" STREQUAL "TARGET_PROPERTY_${PROPERTY}-NOTFOUND" ) + # unset it + set( TARGET_PROPERTY_${PROPERTY} ) + endif() + endforeach() + + foreach( SOURCE ${TARGET_SOURCES} ) + + # We need to accumulate properties since a call to set property will + # override what was there before + set( SOURCE_PROPERTY_ALL ) + + foreach( PROPERTY ${FUNC_PROP_PROPERTIES} ) + # first try source + get_source_file_property( + SOURCE_PROPERTY_${PROPERTY} + ${SOURCE} + TARGET_DIRECTORY ${TARGET} + ${PROPERTY} + ) + if ( "${SOURCE_PROPERTY_${PROPERTY}}" STREQUAL "NOTFOUND" ) + # use target + set( SOURCE_PROPERTY_${PROPERTY} ${TARGET_PROPERTY_${PROPERTY}} ) + endif() + + # Now apply these as prop + if ( NOT "${SOURCE_PROPERTY_${PROPERTY}}" STREQUAL "" ) + list( APPEND SOURCE_PROPERTY_ALL ${SOURCE_PROPERTY_${PROPERTY}} ) + endif() + endforeach() # properties + + # Apply properties to source + if ( NOT "${SOURCE_PROPERTY_ALL}" STREQUAL "" ) + set_source_files_properties( + ${SOURCE} + TARGET_DIRECTORY ${TARGET} + PROPERTIES + ${FUNC_PROP_AS_PROPERTY} ${SOURCE_PROPERTY_ALL} + ) + endif() + endforeach() # sources + endforeach() # targets +endfunction() \ No newline at end of file From 0203d612bdda8e7bdf6378cb44c0cb5373f9ea6a Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 31 Jul 2024 17:35:01 -0700 Subject: [PATCH 10/42] Fine-tuned control of compile flags --- CMakeLists.txt | 340 ++++++++++++++++----------- arch/configure_reader.py | 3 +- cmake/target_source_properties.cmake | 49 +++- cmake/template/arch_config.cmake | 21 +- frame/CMakeLists.txt | 2 +- 5 files changed, 257 insertions(+), 158 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7321125eb1..d5fa55a4a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -322,20 +322,43 @@ endif() ################################################################################ define_target_source_properties( PROPERTIES - FLAGS_OPTIMIZATION # Control of optimization flags - FLAGS_CONFCHECK # Originate from system configuration checks - FLAGS_Fortran_PRECISION # Fortran floating point precision control - FLAGS_Fortran_LINE_LENGTH # Fortran line length for compilers that need it - FLAGS_DIAGNOSTICS # Extra flags for diagnostics - FLAGS_SUPPRESS_ERRORS # EXPLICITLY suppress errors, USE SPARINGLY!!! - FLAGS_SUPPRESS_WARNINGS # Suppress warnings, try to fix before they become errs - FLAGS_STANZA # Any remaining flags imported via stanza + COMPILE_OPTIONS_OPTIMIZATION # Control of optimization flags + COMPILE_OPTIONS_CONFCHECK # Originate from system configuration checks + COMPILE_OPTIONS_OPTIONS # Derived from options + COMPILE_OPTIONS_Fortran_PRECISION # Fortran floating point precision control + COMPILE_OPTIONS_Fortran_LINE_LENGTH # Fortran line length for compilers that need it + COMPILE_OPTIONS_DIAGNOSTICS # Extra flags for diagnostics + COMPILE_OPTIONS_SUPPRESS_ERRORS # EXPLICITLY suppress errors, USE SPARINGLY!!! + COMPILE_OPTIONS_SUPPRESS_WARNINGS # Suppress warnings, try to fix before they become errs + COMPILE_OPTIONS_STANZA # Any remaining flags imported via stanza - DEFINE_CONFCHECK # Originate from system configuration checks - DEFINE_OPTIONS # Anything that is derived from options - DEFINE_STANZA # Any remaining defines imported via stanza + COMPILE_DEFINITIONS_CONFCHECK # Originate from system configuration checks + COMPILE_DEFINITIONS_OPTIONS # Anything that is derived from options + COMPILE_DEFINITIONS_STANZA # Any remaining defines imported via stanza ) +# These will be the cumulative set for quicker reference +set( PROJECT_COMPILE_OPTIONS "" ) +set( PROJECT_COMPILE_DEFINITIONS "" ) + +# Recreate these as project variables so that they may be re-used generically +set( PROJECT_COMPILE_OPTIONS_OPTIMIZATION "" ) +set( PROJECT_COMPILE_OPTIONS_CONFCHECK "" ) +set( PROJECT_COMPILE_OPTIONS_OPTIONS "" ) +set( PROJECT_COMPILE_OPTIONS_Fortran_PRECISION "" ) +set( PROJECT_COMPILE_OPTIONS_Fortran_LINE_LENGTH "" ) +set( PROJECT_COMPILE_OPTIONS_DIAGNOSTICS "" ) +set( PROJECT_COMPILE_OPTIONS_SUPPRESS_ERRORS "" ) +set( PROJECT_COMPILE_OPTIONS_SUPPRESS_WARNINGS "" ) +set( PROJECT_COMPILE_OPTIONS_STANZA "" ) +set( PROJECT_COMPILE_DEFINITIONS_CONFCHECK "" ) +set( PROJECT_COMPILE_DEFINITIONS_OPTIONS "" ) +set( PROJECT_COMPILE_DEFINITIONS_STANZA ${WRF_ARCH_LOCAL} ) + +# Make these imported variables easier to use in genexp +separate_arguments( WRF_FCOPTIM ) +separate_arguments( WRF_FCNOOPT ) + ################################################################################ ## ## Now find packages that cross-compilation is potentially handled @@ -355,19 +378,19 @@ if ( ${USE_MPI} ) # It still technically finds MPI but the output is nonintuitive # saying things like hdf5 or pthread find_package( MPI REQUIRED COMPONENTS Fortran C ) - list( APPEND PROJECT_COMPILE_DEFINITIONS + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS USE_MPI=1 DM_PARALLEL ) if ( DEFINED WRF_MPI_Fortran_FLAGS AND NOT "${WRF_MPI_Fortran_FLAGS}" STREQUAL "" ) - list( APPEND PROJECT_COMPILE_OPTIONS + list( APPEND PROJECT_COMPILE_OPTIONS_OPTIONS $<$:${WRF_MPI_Fortran_FLAGS}> ) endif() if ( DEFINED WRF_MPI_C_FLAGS AND NOT "${WRF_MPI_C_FLAGS}" STREQUAL "" ) - list( APPEND PROJECT_COMPILE_OPTIONS + list( APPEND PROJECT_COMPILE_OPTIONS_OPTIONS $<$:${WRF_MPI_C_FLAGS}> ) endif() @@ -398,7 +421,7 @@ if ( ${USE_MPI} ) set( USE_RSL_LITE ON ) # We know NONE is the zero index so compare against that elseif( ${CURRENT_NESTING_IDX} GREATER 0 ) - list( APPEND PROJECT_COMPILE_DEFINITIONS + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS DM_PARALLEL STUBMPI ) @@ -407,7 +430,7 @@ endif() if ( ${USE_OPENMP} ) find_package( OpenMP REQUIRED COMPONENTS Fortran C ) - list( APPEND PROJECT_COMPILE_DEFINITIONS + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS USE_OPENMP=1 SM_PARALLEL ) @@ -540,44 +563,18 @@ add_subdirectory( confcheck ) ## ################################################################################ -# https://stackoverflow.com/a/47927921 -# Define compile options to be inherited for directories -define_property( - SOURCE - PROPERTY COMPILE_FLAGS - INHERITED - BRIEF_DOCS "brief-doc" - FULL_DOCS "full-doc" - ) - -define_property( - DIRECTORY - PROPERTY COMPILE_FLAGS - INHERITED - BRIEF_DOCS "brief-doc" - FULL_DOCS "full-doc" - ) - # Get current build type flags and put them in there if ( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) - set_directory_properties( - PROPERTIES - COMPILE_FLAGS - $<$:${WRF_FCOPTIM}> - ) + set( PROJECT_COMPILE_OPTIONS_OPTIMIZATION $<$:${WRF_FCOPTIM}> ) # else() # # Assume no optimization -# set_directory_properties( -# PROPERTIES -# COMPILE_FLAGS -# $<$:${WRF_FCNOOPT}> -# ) +# set( PROJECT_COMPILE_OPTIONS_OPTIMIZATION $<$:${WRF_FCNOOPT}> ) endif() # This is really ugly but such is the cost of supporting many ways to say the same thing # https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html -list( APPEND PROJECT_COMPILE_OPTIONS +list( APPEND PROJECT_COMPILE_OPTIONS_Fortran_PRECISION # Use "" and ; specifically to evaluate correctly # "$<$:>" #@ Absoft Fortran # "$<$:>" #@ Analog VisualDSP++ @@ -617,7 +614,9 @@ list( APPEND PROJECT_COMPILE_OPTIONS # "$<$:>" #@ IBM LLVM-based Compiler # Todo find how to handle default selection or add new compiler IDs # unknown how to add support for sxf90 + ) +list( APPEND PROJECT_COMPILE_OPTIONS_Fortran_LINE_LENGTH # line lengths "$<$:-ffree-line-length-none>" #@ GNU Compiler Collection ) @@ -628,24 +627,23 @@ list( APPEND PROJECT_COMPILE_OPTIONS # message( STATUS "Set Fortran_COMPILER_ID to : ${Fortran_COMPILER_ID}" ) -# Whole project flags -list( APPEND PROJECT_COMPILE_OPTIONS - # $<$:-cpp> +list( APPEND PROJECT_COMPILE_OPTIONS_SUPPRESS_WARNINGS # Use "" and ; specifically to evaluate correctly "$<$:-diag-disable;6843>" + ) + +list( APPEND PROJECT_COMPILE_OPTIONS_SUPPRESS_ERRORS $<$,$>:-fallow-argument-mismatch> $<$,$>:-fallow-invalid-boz> $<$,$>:-ffree-line-length-none> - - # $,$:-diag-disable;6843> ) if ( ${PROFILE_COMPILATION} ) message( STATUS "Attemping to add compilation profiling..." ) - list( APPEND PROJECT_COMPILE_OPTIONS $<$:-ftime-report> ) + list( APPEND PROJECT_COMPILE_OPTIONS_DIAGNOSTICS $<$:-ftime-report> ) endif() -list( APPEND PROJECT_COMPILE_DEFINITIONS +list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS MAX_DOMAINS_F=${MAX_DOMAINS_F} CONFIG_BUF_LEN=${CONFIG_BUF_LEN} MAX_HISTORY=${MAX_HISTORY} @@ -671,56 +669,56 @@ list( APPEND PROJECT_COMPILE_DEFINITIONS # in code since cmake cannot handle basically any others :( # https://gitlab.kitware.com/cmake/cmake/-/issues/17398 if ( ${ENABLE_CHEM} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_CHEM=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRF_CHEM=1 ) if ( ${ENABLE_KPP} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_KPP=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRF_KPP=1 ) endif() endif() if ( ${ENABLE_CHEM} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS BUILD_CHEM=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS BUILD_CHEM=1 ) endif() if ( ${ENABLE_CMAQ} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_CMAQ=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRF_CMAQ=1 ) endif() if ( ${ENABLE_DFI_RADAR} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_DFI_RADAR=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRF_DFI_RADAR=1 ) endif() if ( ${ENABLE_TITAN} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_TITAN=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRF_TITAN=1 ) endif() if ( ${ENABLE_MARS} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_MARS=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRF_MARS=1 ) endif() if ( ${ENABLE_VENUS} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_VENUS=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRF_VENUS=1 ) endif() if ( ${ENABLE_HYDRO} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_HYDRO=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRF_HYDRO=1 ) endif() # Because once again we need two defines to control one thing if ( ${ENABLE_CTSM} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_USE_CTSM ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRF_USE_CTSM ) else() #!TODO there are some files that rely on this being 1, but that is never set by the legacy make system - list( APPEND PROJECT_COMPILE_DEFINITIONS WRF_USE_CLM ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRF_USE_CLM ) endif() # If force classic or no nc-4 support enable classic if ( ${FORCE_NETCDF_CLASSIC} OR ( NOT ${netCDF_NC4} ) ) - list( APPEND PROJECT_COMPILE_DEFINITIONS NETCDF_classic=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS NETCDF_classic=1 ) endif() if ( ${WRFIO_NCD_NO_LARGE_FILE_SUPPORT} OR ( NOT ${netCDF_LARGE_FILE_SUPPORT} ) ) - list( APPEND PROJECT_COMPILE_DEFINITIONS WRFIO_NCD_NO_LARGE_FILE_SUPPORT=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRFIO_NCD_NO_LARGE_FILE_SUPPORT=1 ) endif() # May need a check for WRFIO_ncdpar_LARGE_FILE_SUPPORT # Now set the opposite in different defines, because why not :) if ( ( NOT ${FORCE_NETCDF_CLASSIC} ) AND ${netCDF_NC4} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS USE_NETCDF4_FEATURES=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS USE_NETCDF4_FEATURES=1 ) endif() if ( ( NOT ${WRFIO_NCD_NO_LARGE_FILE_SUPPORT} ) AND ${netCDF_LARGE_FILE_SUPPORT} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS WRFIO_NCD_LARGE_FILE_SUPPORT=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRFIO_NCD_LARGE_FILE_SUPPORT=1 ) endif() # Could simplify logic to just check if RPC is available but to be explicit @@ -728,115 +726,139 @@ endif() # not enable terran or not rpc_found do # not ( enable terrain and rpc_found ) # if ( NOT ( ${ENABLE_TERRAIN} AND ${RPC_FOUND} ) ) # this is wrong, needs fixing -# list( APPEND PROJECT_COMPILE_DEFINITIONS LANDREAD_STUB ) +# list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS LANDREAD_STUB ) # endif() if ( ${ENABLE_TERRAIN} AND ${MOVE_NESTS} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS TERRAIN_AND_LANDUSE ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS TERRAIN_AND_LANDUSE ) else () - list( APPEND PROJECT_COMPILE_DEFINITIONS LANDREAD_STUB ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS LANDREAD_STUB ) endif() if ( ${USE_ALLOCATABLES} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS USE_ALLOCATABLES ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS USE_ALLOCATABLES ) endif() if ( ${wrfmodel} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS wrfmodel ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS wrfmodel ) endif() if ( ${GRIB1} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS GRIB1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS GRIB1 ) endif() if ( ${INTIO} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS INTIO ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS INTIO ) endif() if ( ${KEEP_INT_AROUND} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS KEEP_INT_AROUND ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS KEEP_INT_AROUND ) endif() if ( ${LIMIT_ARGS} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS LIMIT_ARGS ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS LIMIT_ARGS ) endif() if ( ${BUILD_RRTMG_FAST} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS BUILD_RRTMG_FAST=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS BUILD_RRTMG_FAST=1 ) else() - list( APPEND PROJECT_COMPILE_DEFINITIONS BUILD_RRTMG_FAST=0 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS BUILD_RRTMG_FAST=0 ) endif() if ( ${BUILD_RRTMK} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS BUILD_RRTMK=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS BUILD_RRTMK=1 ) else() - list( APPEND PROJECT_COMPILE_DEFINITIONS BUILD_RRTMK=0 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS BUILD_RRTMK=0 ) endif() if ( ${BUILD_SBM_FAST} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS BUILD_SBM_FAST=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS BUILD_SBM_FAST=1 ) else() - list( APPEND PROJECT_COMPILE_DEFINITIONS BUILD_SBM_FAST=0 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS BUILD_SBM_FAST=0 ) endif() if ( ${SHOW_ALL_VARS_USED} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS SHOW_ALL_VARS_USED=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS SHOW_ALL_VARS_USED=1 ) else() - list( APPEND PROJECT_COMPILE_DEFINITIONS SHOW_ALL_VARS_USED=0 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS SHOW_ALL_VARS_USED=0 ) endif() if ( ${NMM_CORE} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS NMM_CORE=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS NMM_CORE=1 ) else() - list( APPEND PROJECT_COMPILE_DEFINITIONS NMM_CORE=0 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS NMM_CORE=0 ) endif() if ( "${WRF_CORE}" STREQUAL "PLUS" ) - list( APPEND PROJECT_COMPILE_DEFINITIONS WRFPLUS=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRFPLUS=1 ) else() - list( APPEND PROJECT_COMPILE_DEFINITIONS WRFPLUS=0 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRFPLUS=0 ) endif() if ( "${WRF_CORE}" STREQUAL "DA_CORE" OR "${WRF_CORE}" STREQUAL "DA_4D_VAR" ) - list( APPEND PROJECT_COMPILE_DEFINITIONS DA_CORE=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS DA_CORE=1 ) else() - list( APPEND PROJECT_COMPILE_DEFINITIONS DA_CORE=0 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS DA_CORE=0 ) endif() # DFI_RADAR=$ # Nesting options if ( ${MOVE_NESTS} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS MOVE_NESTS ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS MOVE_NESTS ) endif() if ( "${WRF_NESTING}" STREQUAL "VORTEX" ) - list( APPEND PROJECT_COMPILE_DEFINITIONS VORTEX_CENTER ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS VORTEX_CENTER ) endif() # Configuration checks if ( NOT ${Fortran_2003_IEEE} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS NO_IEEE_MODULE ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_CONFCHECK NO_IEEE_MODULE ) endif() if ( NOT ${Fortran_2003_ISO_C} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS NO_ISO_C_SUPPORT ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_CONFCHECK NO_ISO_C_SUPPORT ) endif() # If flush fails, check if we can fall back to fflush, and if not no support if ( NOT ${Fortran_2003_FLUSH} ) if ( "${Fortran_2003_FFLUSH}" ) - list( APPEND PROJECT_COMPILE_DEFINITIONS USE_FFLUSH ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_CONFCHECK USE_FFLUSH ) else() - list( APPEND PROJECT_COMPILE_DEFINITIONS NO_FLUSH_SUPPORT ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_CONFCHECK NO_FLUSH_SUPPORT ) endif() endif() if ( NOT ${Fortran_2003_GAMMA} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS NO_GAMMA_SUPPORT ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_CONFCHECK NO_GAMMA_SUPPORT ) endif() #!TODO Leaving as is in WRF for now but investigate why we don't do this # https://stackoverflow.com/a/1035713 # If fseeko64 succeeds, use that, else check if we can fall back to fseeko, and if not just use fseek if ( ${FSEEKO64} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS FSEEKO64_OK ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_CONFCHECK FSEEKO64_OK ) elseif( "${FSEEKO}" ) - list( APPEND PROJECT_COMPILE_DEFINITIONS FSEEKO_OK ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_CONFCHECK FSEEKO_OK ) else() - list( APPEND PROJECT_COMPILE_DEFINITIONS FSEEK_OK ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_CONFCHECK FSEEK_OK ) endif() # I don't believe these are used anymore... # $<$:MPI2_SUPPORT=$> # $<$:MPI2_THREAD_SUPPORT=$> +# Accumulate option and definitions +list( APPEND PROJECT_COMPILE_OPTIONS + ${PROJECT_COMPILE_OPTIONS_OPTIMIZATION} + ${PROJECT_COMPILE_OPTIONS_CONFCHECK} + ${PROJECT_COMPILE_OPTIONS_OPTIONS} + ${PROJECT_COMPILE_OPTIONS_Fortran_PRECISION} + ${PROJECT_COMPILE_OPTIONS_Fortran_LINE_LENGTH} + ${PROJECT_COMPILE_OPTIONS_DIAGNOSTICS} + ${PROJECT_COMPILE_OPTIONS_SUPPRESS_ERRORS} + ${PROJECT_COMPILE_OPTIONS_SUPPRESS_WARNINGS} + ${PROJECT_COMPILE_OPTIONS_STANZA} + ) +list( APPEND PROJECT_COMPILE_DEFINITIONS + ${PROJECT_COMPILE_DEFINITIONS_CONFCHECK} + ${PROJECT_COMPILE_DEFINITIONS_OPTIONS} + ${PROJECT_COMPILE_DEFINITIONS_STANZA} + ) + +################################################################################ +## +## DO NOT modify PROJECT_COMPILE_* beyond this point +## +################################################################################ + # Make core target add_library( @@ -844,18 +866,22 @@ add_library( STATIC ) -target_compile_options( - ${PROJECT_NAME}_Core - PRIVATE - ${PROJECT_COMPILE_OPTIONS} - ) - +set_target_properties( + ${PROJECT_NAME}_Core + PROPERTIES + COMPILE_OPTIONS_OPTIMIZATION "${PROJECT_COMPILE_OPTIONS_OPTIMIZATION}" + COMPILE_OPTIONS_CONFCHECK "${PROJECT_COMPILE_OPTIONS_CONFCHECK}" + COMPILE_OPTIONS_OPTIONS "${PROJECT_COMPILE_OPTIONS_OPTIONS}" + COMPILE_OPTIONS_Fortran_PRECISION "${PROJECT_COMPILE_OPTIONS_Fortran_PRECISION}" + COMPILE_OPTIONS_Fortran_LINE_LENGTH "${PROJECT_COMPILE_OPTIONS_Fortran_LINE_LENGTH}" + COMPILE_OPTIONS_DIAGNOSTICS "${PROJECT_COMPILE_OPTIONS_DIAGNOSTICS}" + COMPILE_OPTIONS_SUPPRESS_ERRORS "${PROJECT_COMPILE_OPTIONS_SUPPRESS_ERRORS}" + COMPILE_OPTIONS_SUPPRESS_WARNINGS "${PROJECT_COMPILE_OPTIONS_SUPPRESS_WARNINGS}" + COMPILE_OPTIONS_STANZA "${PROJECT_COMPILE_OPTIONS_STANZA}" + # We do not use compile definitions for CMake's lack of source file accounting + ) -target_compile_definitions( - ${PROJECT_NAME}_Core - PRIVATE - ${PROJECT_COMPILE_DEFINITIONS} - ) +# Do NOT apply these options or defines just yet, allow files to be added and set their own properties # Supplemental to core, or rather should be, some stuff in external is legitimately part of WRF and others # are source code from truly external repositories - albeit old versions @@ -868,6 +894,68 @@ add_dependencies( # So many things depend on this that I'm adding a dep here registry_code ) + +# Add directly to core +add_subdirectory( phys ) +add_subdirectory( share ) +add_subdirectory( frame ) +add_subdirectory( inc ) + +if ( ${WRF_CHEM} ) + add_subdirectory( chem ) +endif() + +if ( ${ENABLE_HYDRO} ) + add_subdirectory( hydro ) +endif() + +add_subdirectory( dyn_em ) + + +add_subdirectory( main ) + +################################################################################ +# Add subdirectory with case info +################################################################################ +if ( ${CURRENT_WRF_CORE_IDX} GREATER_EQUAL ${START_DA_IDX} ) + message( STATUS "DA or PLUS build, WRF_CASE selection ignored" ) +else() + add_subdirectory( test/${WRF_CASE_FOLDER} ) +endif() + + + +################################################################################ +## +## DO NOT add sources beyond this point +## +################################################################################ + +# gather compile info and apply +apply_target_source_properties( + TARGETS ${PROJECT_NAME}_Core + PROPERTIES + COMPILE_OPTIONS_OPTIMIZATION + COMPILE_OPTIONS_CONFCHECK + COMPILE_OPTIONS_OPTIONS + COMPILE_OPTIONS_Fortran_PRECISION + COMPILE_OPTIONS_Fortran_LINE_LENGTH + COMPILE_OPTIONS_DIAGNOSTICS + COMPILE_OPTIONS_SUPPRESS_ERRORS + COMPILE_OPTIONS_SUPPRESS_WARNINGS + COMPILE_OPTIONS_STANZA + AS_PROPERTY COMPILE_OPTIONS + ) + +target_compile_definitions( + ${PROJECT_NAME}_Core + PRIVATE + ${PROJECT_COMPILE_DEFINITIONS_CONFCHECK} + ${PROJECT_COMPILE_DEFINITIONS_OPTIONS} + ${PROJECT_COMPILE_DEFINITIONS_STANZA} + ) + + target_include_directories( ${PROJECT_NAME}_Core PUBLIC @@ -926,34 +1014,6 @@ target_include_directories( ${pnetCDF_INCLUDE_DIRS} ) -# Add directly to core -add_subdirectory( phys ) -add_subdirectory( share ) -add_subdirectory( frame ) -add_subdirectory( inc ) - -if ( ${WRF_CHEM} ) - add_subdirectory( chem ) -endif() - -if ( ${ENABLE_HYDRO} ) - add_subdirectory( hydro ) -endif() - -add_subdirectory( dyn_em ) - - -add_subdirectory( main ) - -################################################################################ -# Add subdirectory with case info -################################################################################ -if ( ${CURRENT_WRF_CORE_IDX} GREATER_EQUAL ${START_DA_IDX} ) - message( STATUS "DA or PLUS build, WRF_CASE selection ignored" ) -else() - add_subdirectory( test/${WRF_CASE_FOLDER} ) -endif() - # Configure core set_target_properties( ${PROJECT_NAME}_Core @@ -964,6 +1024,8 @@ set_target_properties( EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY ) +target_link_options( ${PROJECT_NAME}_Core PRIVATE ${WRF_LINK_FLAGS} ) + # Because of the way netCDF provides its info and the way cmake auto-gens RPATH, we need to help it along target_link_directories( ${PROJECT_NAME}_Core diff --git a/arch/configure_reader.py b/arch/configure_reader.py index 98f758e0b8..c52d776af7 100755 --- a/arch/configure_reader.py +++ b/arch/configure_reader.py @@ -504,6 +504,7 @@ def generateCMakeToolChainFile( cmakeToolChainTemplate, output, stanza, optionsD configStanza = cmakeToolChainTemplateLines.format( ARCH_LOCAL=stanza.kvPairs_["ARCH_LOCAL"], + LDFLAGS_LOCAL=stanza.kvPairs_["LDFLAGS_LOCAL"], BYTESWAPIO=stanza.kvPairs_["BYTESWAPIO"], CFLAGS_LOCAL=stanza.kvPairs_["CFLAGS_LOCAL"], DM_CC=stanza.kvPairs_["DM_CC"], @@ -587,4 +588,4 @@ def projectSpecificOptions( options, stanzaCfg ) : return additionalOptions if __name__ == '__main__' : - main() \ No newline at end of file + main() diff --git a/cmake/target_source_properties.cmake b/cmake/target_source_properties.cmake index c6ce9d4d00..55042a6263 100644 --- a/cmake/target_source_properties.cmake +++ b/cmake/target_source_properties.cmake @@ -6,6 +6,21 @@ # relying on compiler-specific flag order precedence. Additionally this allows a # project to organize grouping of flags within a target # +# Note that for compile defines on source files they are not used in the autogen +# dependency scanning. See : +# https://gitlab.kitware.com/cmake/cmake/-/issues/22519 +# and +# https://gitlab.kitware.com/cmake/cmake/-/blob/master/Source/cmDependsFortran.cxx#L84 +# functions cmDependsFortran::cmDependsFortran() and cmDependsFortran::WriteDependencies() +# +# The solution is to either use Ninja or preprocess the files (what Ninja internally does) +# This is probably the way to go as well since CMake native preprocessor directive +# parsing is... subpar and simplified : +# https://gitlab.kitware.com/cmake/cmake/-/issues/17398 +# +# Alternatively, set critical flags at the target level +# + # @@ -45,7 +60,7 @@ endfunction() # applies it to that source. # function( apply_target_source_properties ) - set( options ) + set( options DISCARD_PREVIOUS DEBUG ) set( oneValueArgs AS_PROPERTY ) set( multiValueArgs TARGETS PROPERTIES ) @@ -89,18 +104,38 @@ function( apply_target_source_properties ) # Now apply these as prop if ( NOT "${SOURCE_PROPERTY_${PROPERTY}}" STREQUAL "" ) + if ( ${FUNC_PROP_DEBUG} ) + message( STATUS "DEBUG : Adding '${SOURCE_PROPERTY_${PROPERTY}}' as SOURCE_PROPERTY_${PROPERTY}") + endif() list( APPEND SOURCE_PROPERTY_ALL ${SOURCE_PROPERTY_${PROPERTY}} ) endif() endforeach() # properties # Apply properties to source if ( NOT "${SOURCE_PROPERTY_ALL}" STREQUAL "" ) - set_source_files_properties( - ${SOURCE} - TARGET_DIRECTORY ${TARGET} - PROPERTIES - ${FUNC_PROP_AS_PROPERTY} ${SOURCE_PROPERTY_ALL} - ) + if ( NOT ${FUNC_PROP_DISCARD_PREVIOUS} ) + # get old value and append + get_source_file_property( + SOURCE_PROPERTY_ORIG + ${SOURCE} + TARGET_DIRECTORY ${TARGET} + ${FUNC_PROP_AS_PROPERTY} + ) + if ( "${SOURCE_PROPERTY_ORIG}" STREQUAL "NOTFOUND" ) + set( SOURCE_PROPERTY_ORIG ) + endif() + endif() + + if ( ${FUNC_PROP_DEBUG} ) + message( STATUS "DEBUG : ${FUNC_PROP_AS_PROPERTY} being set to '${SOURCE_PROPERTY_ORIG} ${SOURCE_PROPERTY_ALL}'") + endif() + + set_source_files_properties( + ${SOURCE} + TARGET_DIRECTORY ${TARGET} + PROPERTIES + ${FUNC_PROP_AS_PROPERTY} "${SOURCE_PROPERTY_ORIG};${SOURCE_PROPERTY_ALL}" + ) endif() endforeach() # sources endforeach() # targets diff --git a/cmake/template/arch_config.cmake b/cmake/template/arch_config.cmake index 42cba60287..0a655a4e32 100644 --- a/cmake/template/arch_config.cmake +++ b/cmake/template/arch_config.cmake @@ -15,15 +15,16 @@ set( CMAKE_Fortran_FLAGS_INIT "{SFC_FLAGS} {FCBASEOPTS} {BYTESWAPIO}" ) set( CMAKE_C_FLAGS_INIT "{SCC_FLAGS} {CFLAGS_LOCAL}" ) # https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS_CONFIG_INIT.html -set( CMAKE_Fortran_FLAGS_DEBUG_INIT "{FCDEBUG}" ) -set( CMAKE_Fortran_FLAGS_RELEASE_INIT "" ) -set( CMAKE_C_FLAGS_DEBUG_INIT "" ) -set( CMAKE_C_FLAGS_RELEASE_INIT "" ) +set( CMAKE_Fortran_FLAGS_Debug_INIT "{FCDEBUG}" ) +set( CMAKE_Fortran_FLAGS_Release_INIT "" ) +set( CMAKE_C_FLAGS_Debug_INIT "" ) +set( CMAKE_C_FLAGS_Release_INIT "" ) # Project specifics now -set( WRF_MPI_Fortran_FLAGS "{DM_FC_FLAGS}" ) -set( WRF_MPI_C_FLAGS "{DM_CC_FLAGS}" ) -set( WRF_ARCH_LOCAL "{ARCH_LOCAL}" ) -set( WRF_M4_FLAGS "{M4_FLAGS}" ) -set( WRF_FCOPTIM "{FCOPTIM}" ) -set( WRF_FCNOOPT "{FCNOOPT}" ) \ No newline at end of file +set( WRF_MPI_Fortran_FLAGS "{DM_FC_FLAGS}" ) +set( WRF_MPI_C_FLAGS "{DM_CC_FLAGS}" ) +set( WRF_ARCH_LOCAL "{ARCH_LOCAL}" ) +set( WRF_M4_FLAGS "{M4_FLAGS}" ) +set( WRF_FCOPTIM "{FCOPTIM}" ) +set( WRF_FCNOOPT "{FCNOOPT}" ) +set( WRF_LINK_FLAGS "{LDFLAGS_LOCAL}" ) diff --git a/frame/CMakeLists.txt b/frame/CMakeLists.txt index c322d84c9a..b923149edf 100644 --- a/frame/CMakeLists.txt +++ b/frame/CMakeLists.txt @@ -158,7 +158,7 @@ target_sources( set_source_files_properties( ${nl_dyn_source} PROPERTIES - COMPILE_FLAGS + COMPILE_OPTIONS_OPTIMIZATION $<$:${WRF_FCNOOPT}> ) From 86c370700dd7a437fd6dabefe24c481825d04f03 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 1 Aug 2024 12:01:57 -0700 Subject: [PATCH 11/42] Don't force specific define able to come from stanza --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d5fa55a4a5..eef1cb7fde 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -658,7 +658,7 @@ list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS NETCDF #!TODO Change this to a confcheck - NONSTANDARD_SYSTEM_SUBR + # NONSTANDARD_SYSTEM_SUBR # For now let this come from stanza EM_CORE=${EM_CORE} From 17694776910fe592d895ab7a647725b5a6e6da44 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 1 Aug 2024 13:16:52 -0700 Subject: [PATCH 12/42] Allow for regular defines to be passed in --- cmake/c_preproc.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/c_preproc.cmake b/cmake/c_preproc.cmake index 4de0a1e7a1..23ee44ddb0 100644 --- a/cmake/c_preproc.cmake +++ b/cmake/c_preproc.cmake @@ -117,6 +117,9 @@ macro( wrf_expand_definitions ) else() list( APPEND WRF_EXP_DEFS -D${WRF_EXP_DEF} ) endif() + else() + # Just add it normally + list( APPEND WRF_EXP_DEFS ${WRF_EXP_DEF} ) endif() endforeach() From 812acda062ce5e6cf480ef70b50295cfe35d3811 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 5 Aug 2024 18:03:59 -0700 Subject: [PATCH 13/42] Reduce configuration check logic by using try_* functions --- cmake/confcheck.cmake | 133 +++++++++++---------------------------- confcheck/CMakeLists.txt | 29 ++++----- 2 files changed, 49 insertions(+), 113 deletions(-) diff --git a/cmake/confcheck.cmake b/cmake/confcheck.cmake index 5db8469519..4c4970bda8 100644 --- a/cmake/confcheck.cmake +++ b/cmake/confcheck.cmake @@ -1,18 +1,18 @@ # WRF Macro for adding configuration checks from source file, default is fortran # https://cmake.org/cmake/help/latest/module/CheckFortranSourceCompiles.html # https://github.com/ufs-community/ufs-weather-model/issues/132 -include( CheckFortranSourceRuns ) -include( CheckFortranSourceCompiles ) -include( CheckCSourceRuns ) -include( CheckCSourceCompiles ) -include( CheckCXXSourceRuns ) -include( CheckCXXSourceCompiles ) +# include( CheckFortranSourceRuns ) +# include( CheckFortranSourceCompiles ) +# include( CheckCSourceRuns ) +# include( CheckCSourceCompiles ) +# include( CheckCXXSourceRuns ) +# include( CheckCXXSourceCompiles ) -macro( wrf_conf_check ) +function( wrf_conf_check ) set( options QUIET RUN REQUIRED ) - set( oneValueArgs RESULT_VAR EXTENSION FAIL_REGEX SOURCE MESSAGE SOURCE_TYPE ) - set( multiValueArgs ADDITIONAL_FLAGS ADDITIONAL_DEFINITIONS ADDITIONAL_INCLUDES ADDITIONAL_LINK_OPTIONS ADDITIONAL_LIBRARIES ) + set( oneValueArgs RESULT_VAR MESSAGE ) + set( multiValueArgs SOURCES OPTIONS ) cmake_parse_arguments( WRF_CFG @@ -20,102 +20,41 @@ macro( wrf_conf_check ) ${ARGN} ) - get_filename_component( WRF_CFG_SOURCE_FILE ${WRF_CFG_SOURCE} REALPATH ) - file( READ ${WRF_CFG_SOURCE_FILE} WRF_CFG_CODE ) - - # Santize for newlines - string( REPLACE "\\n" "\\\\n" WRF_CFG_CODE "${WRF_CFG_CODE}" ) - - if ( NOT DEFINED WRF_CFG_SOURCE_TYPE ) - set( WRF_CFG_SOURCE_TYPE fortran ) - endif() - - if ( DEFINED WRF_CFG_FAIL_REGEX ) - if ( DEFINED WRF_CFG_RUN ) - message( WARNING "wrf_conf_check: FAIL_REGEX ignored when running check" ) - else() - set( WRF_CFG_FAIL_REGEX FAIL_REGEX ${WRF_CFG_FAIL_REGEX} ) - endif() + if ( NOT DEFINED WRF_CFG_BINDIR ) + set( WRF_CFG_BINDIR ${CMAKE_CURRENT_BINARY_DIR}/confcheck/${WRF_CFG_RESULT_VAR}/ ) endif() - if ( DEFINED WRF_CFG_EXTENSION ) - set( WRF_CFG_EXTENSION SRC_EXT ${WRF_CFG_EXTENSION} ) - endif() - - # Additional options - if ( DEFINED WRF_CFG_QUIET AND ${WRF_CFG_QUIET} ) - set( CMAKE_REQUIRED_QUIET ${WRF_CFG_QUIET} ) - endif() + message( STATUS "Performing Check ${WRF_CFG_RESULT_VAR}" ) - if ( DEFINED WRF_CFG_ADDITIONAL_FLAGS ) - set( CMAKE_REQUIRED_FLAGS ${WRF_CFG_ADDITIONAL_FLAGS} ) - endif() - - if ( DEFINED WRF_CFG_ADDITIONAL_DEFINITIONS ) - set( CMAKE_REQUIRED_DEFINITIONS ${WRF_CFG_ADDITIONAL_DEFINITIONS} ) - endif() - - if ( DEFINED WRF_CFG_ADDITIONAL_INCLUDES ) - set( CMAKE_REQUIRED_INCLUDES ${WRF_CFG_ADDITIONAL_INCLUDES} ) - endif() - - if ( DEFINED WRF_CFG_ADDITIONAL_LINK_OPTIONS ) - set( CMAKE_REQUIRED_LINK_OPTIONS ${WRF_CFG_ADDITIONAL_LINK_OPTIONS} ) - endif() - - if ( DEFINED WRF_CFG_ADDITIONAL_LIBRARIES ) - set( CMAKE_REQUIRED_LIBRARIES ${WRF_CFG_ADDITIONAL_LIBRARIES} ) - endif() - - string( TOLOWER "${WRF_CFG_SOURCE_TYPE}" WRF_CFG_SOURCE_TYPE ) if ( DEFINED WRF_CFG_RUN ) - if ( ${WRF_CFG_SOURCE_TYPE} STREQUAL "fortran" ) - check_fortran_source_runs( - "${WRF_CFG_CODE}" - ${WRF_CFG_RESULT_VAR} - ${WRF_CFG_FAIL_REGEX} - ${WRF_CFG_EXTENSION} - ) - elseif ( ${WRF_CFG_SOURCE_TYPE} STREQUAL "c" ) - check_c_source_runs( - "${WRF_CFG_CODE}" - ${WRF_CFG_RESULT_VAR} - ${WRF_CFG_FAIL_REGEX} - ${WRF_CFG_EXTENSION} - ) - elseif ( ${WRF_CFG_SOURCE_TYPE} STREQUAL "cpp" ) - check_cpp_source_runs( - "${WRF_CFG_CODE}" - ${WRF_CFG_RESULT_VAR} - ${WRF_CFG_FAIL_REGEX} - ${WRF_CFG_EXTENSION} - ) + try_run( + ${WRF_CFG_RESULT_VAR} + WRF_CFG_COMPILE_RESULT_VAR + ${WRF_CFG_BINDIR} + ${WRF_CFG_SOURCES} + ${WRF_CFG_OPTIONS} + ) + if ( ${WRF_CFG_COMPILE_RESULT_VAR} ) + # Did it run successfully + if ( ${${WRF_CFG_RESULT_VAR}} EQUAL 0 ) + set( ${WRF_CFG_RESULT_VAR} TRUE ) + endif() + else() + set( ${WRF_CFG_RESULT_VAR} FALSE ) endif() else() - if ( ${WRF_CFG_SOURCE_TYPE} STREQUAL "fortran" ) - check_fortran_source_compiles( - "${WRF_CFG_CODE}" - ${WRF_CFG_RESULT_VAR} - ${WRF_CFG_EXTENSION} - ) - elseif ( ${WRF_CFG_SOURCE_TYPE} STREQUAL "c" ) - check_c_source_compiles( - "${WRF_CFG_CODE}" - ${WRF_CFG_RESULT_VAR} - ${WRF_CFG_EXTENSION} - ) - elseif ( ${WRF_CFG_SOURCE_TYPE} STREQUAL "cpp" ) - check_cpp_source_compiles( - "${WRF_CFG_CODE}" - ${WRF_CFG_RESULT_VAR} - ${WRF_CFG_EXTENSION} - ) - endif() + try_compile( + ${WRF_CFG_RESULT_VAR} + ${WRF_CFG_BINDIR} + SOURCES ${WRF_CFG_SOURCES} + ${WRF_CFG_OPTIONS} + ) endif() # If it failed - note that since this is a run/compile test we expect pass/true # to just proceed as normal, but if failure we should do something about it if ( NOT ( DEFINED ${WRF_CFG_RESULT_VAR} AND "${${WRF_CFG_RESULT_VAR}}" ) ) + message( STATUS "Performing Check ${WRF_CFG_RESULT_VAR} - Failure" ) set( WRF_CFG_MSG_TYPE STATUS ) if ( DEFINED WRF_CFG_REQUIRED AND ${WRF_CFG_REQUIRED} ) set( WRF_CFG_MSG_TYPE FATAL_ERROR ) @@ -126,8 +65,12 @@ macro( wrf_conf_check ) else() message( ${WRF_CFG_MSG_TYPE} "${WRF_CFG_RESULT_VAR} marked as required, check failed" ) endif() + else() + message( STATUS "Performing Check ${WRF_CFG_RESULT_VAR} - Success" ) endif() -endmacro() + set( ${WRF_CFG_RESULT_VAR} ${${WRF_CFG_RESULT_VAR}} PARENT_SCOPE ) + +endfunction() diff --git a/confcheck/CMakeLists.txt b/confcheck/CMakeLists.txt index 152aeeaa3a..c431a5c61c 100644 --- a/confcheck/CMakeLists.txt +++ b/confcheck/CMakeLists.txt @@ -2,24 +2,21 @@ wrf_conf_check( RUN RESULT_VAR Fortran_2003_IEEE - SOURCE ${PROJECT_SOURCE_DIR}/tools/fortran_2003_ieee_test.F - EXTENSION .F + SOURCES ${PROJECT_SOURCE_DIR}/tools/fortran_2003_ieee_test.F MESSAGE "Some IEEE Fortran 2003 features missing, removing usage of these features" ) wrf_conf_check( RUN RESULT_VAR Fortran_2003_ISO_C - SOURCE ${PROJECT_SOURCE_DIR}/tools/fortran_2003_iso_c_test.F - EXTENSION .F + SOURCES ${PROJECT_SOURCE_DIR}/tools/fortran_2003_iso_c_test.F MESSAGE "Some ISO_C Fortran 2003 features missing, removing usage ISO_C and stubbing code dependent on it" ) wrf_conf_check( RUN RESULT_VAR Fortran_2003_FLUSH - SOURCE ${PROJECT_SOURCE_DIR}/tools/fortran_2003_flush_test.F - EXTENSION .F + SOURCES ${PROJECT_SOURCE_DIR}/tools/fortran_2003_flush_test.F MESSAGE "Standard FLUSH routine Fortran 2003 features missing, checking for alternate Fortran_2003_FFLUSH" ) @@ -27,8 +24,7 @@ if ( NOT ${Fortran_2003_FLUSH} ) wrf_conf_check( RUN RESULT_VAR Fortran_2003_FFLUSH - SOURCE ${PROJECT_SOURCE_DIR}/tools/fortran_2003_fflush_test.F - EXTENSION .F + SOURCES ${PROJECT_SOURCE_DIR}/tools/fortran_2003_fflush_test.F MESSAGE "Standard FFLUSH routine Fortran 2003 features missing, no alternate to FLUSH found, feature stubbed out" ) endif() @@ -36,8 +32,7 @@ endif() wrf_conf_check( RUN RESULT_VAR Fortran_2003_GAMMA - SOURCE ${PROJECT_SOURCE_DIR}/tools/fortran_2008_gamma_test.F - EXTENSION .F + SOURCES ${PROJECT_SOURCE_DIR}/tools/fortran_2008_gamma_test.F MESSAGE "Some Fortran 2003 features missing, removing usage gamma function intrinsic and stubbing code dependent on it" ) @@ -45,22 +40,20 @@ wrf_conf_check( wrf_conf_check( RUN - SOURCE_TYPE C RESULT_VAR FSEEKO64 - SOURCE ${PROJECT_SOURCE_DIR}/tools/fseek_test.c - EXTENSION .c - ADDITIONAL_DEFINITIONS -DTEST_FSEEKO64 -DFILE_TO_TEST="${PROJECT_SOURCE_DIR}/CMakeLists.txt" + SOURCES ${PROJECT_SOURCE_DIR}/tools/fseek_test.c + OPTIONS + COMPILE_DEFINITIONS -DTEST_FSEEKO64 -DFILE_TO_TEST="${PROJECT_SOURCE_DIR}/CMakeLists.txt" MESSAGE "fseeko64 not supported, checking alternate fseeko" ) if ( NOT "${FSEEKO64}" ) wrf_conf_check( RUN - SOURCE_TYPE C RESULT_VAR FSEEKO - SOURCE ${PROJECT_SOURCE_DIR}/tools/fseek_test.c - EXTENSION .c - ADDITIONAL_DEFINITIONS -DTEST_FSEEKO -DFILE_TO_TEST="${PROJECT_SOURCE_DIR}/CMakeLists.txt" + SOURCES ${PROJECT_SOURCE_DIR}/tools/fseek_test.c + OPTIONS + COMPILE_DEFINITINOS -DTEST_FSEEKO -DFILE_TO_TEST="${PROJECT_SOURCE_DIR}/CMakeLists.txt" MESSAGE "fseeko not supported, compiling with fseek (caution with large files)" ) endif() From b1a8fa1c7e4ebce74c6136a4435b78343959e4f6 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 5 Aug 2024 18:42:43 -0700 Subject: [PATCH 14/42] Purge underscore defs from stanza reading --- arch/configure_reader.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/configure_reader.py b/arch/configure_reader.py index c52d776af7..a72e4a7cf4 100755 --- a/arch/configure_reader.py +++ b/arch/configure_reader.py @@ -160,11 +160,14 @@ def sanitize( self ) : # # Now deref self.dereference( "FCBASEOPTS" ) + definesToRemove = [ "-DUNDERSCORE", "-DNOUNDERSCORE" ] + # Remove rogue compile commands that should *NOT* even be here for keyToSan in self.kvPairs_.keys() : self.kvPairs_[ keyToSan ] = configureRepl.sub( r"\1\2", self.kvPairs_[ keyToSan ] ).strip() self.kvPairs_[ keyToSan ] = compileObject.sub( r"\1\2", self.kvPairs_[ keyToSan ] ).strip() - + for cppDef in definesToRemove : + self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( cppDef, "" ) # Now fix certain ones that are mixing programs with flags all mashed into one option self.splitIntoFieldAndFlags( "SFC" ) From 41df9586a609cecc69a2783fb8d4d30bcc36592a Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 5 Aug 2024 18:43:13 -0700 Subject: [PATCH 15/42] Fix default try run setting --- cmake/confcheck.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/confcheck.cmake b/cmake/confcheck.cmake index 4c4970bda8..6109729619 100644 --- a/cmake/confcheck.cmake +++ b/cmake/confcheck.cmake @@ -26,7 +26,7 @@ function( wrf_conf_check ) message( STATUS "Performing Check ${WRF_CFG_RESULT_VAR}" ) - if ( DEFINED WRF_CFG_RUN ) + if ( DEFINED WRF_CFG_RUN AND "${WRF_CFG_RUN}" ) try_run( ${WRF_CFG_RESULT_VAR} WRF_CFG_COMPILE_RESULT_VAR From 64a9e2862bab765289ece1c8506f0ac74a626e17 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 5 Aug 2024 18:43:37 -0700 Subject: [PATCH 16/42] Adjust message text for failed checks --- cmake/confcheck.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/confcheck.cmake b/cmake/confcheck.cmake index 6109729619..53453ed6d9 100644 --- a/cmake/confcheck.cmake +++ b/cmake/confcheck.cmake @@ -61,9 +61,9 @@ function( wrf_conf_check ) endif() if ( DEFINED WRF_CFG_MESSAGE ) - message( ${WRF_CFG_MSG_TYPE} "${WRF_CFG_MESSAGE}" ) + message( ${WRF_CFG_MSG_TYPE} " ${WRF_CFG_MESSAGE}" ) else() - message( ${WRF_CFG_MSG_TYPE} "${WRF_CFG_RESULT_VAR} marked as required, check failed" ) + message( ${WRF_CFG_MSG_TYPE} " ${WRF_CFG_RESULT_VAR} check failed" ) endif() else() message( STATUS "Performing Check ${WRF_CFG_RESULT_VAR} - Success" ) From 55656fe0d3d6d0f63203f26e7a8780109e312f68 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 5 Aug 2024 18:44:27 -0700 Subject: [PATCH 17/42] Add underscore check --- confcheck/CMakeLists.txt | 25 +++++++++++++++++++++++++ confcheck/check_underscore.c | 8 ++++++++ confcheck/check_underscore.f90 | 5 +++++ 3 files changed, 38 insertions(+) create mode 100644 confcheck/check_underscore.c create mode 100644 confcheck/check_underscore.f90 diff --git a/confcheck/CMakeLists.txt b/confcheck/CMakeLists.txt index c431a5c61c..932e83bbd9 100644 --- a/confcheck/CMakeLists.txt +++ b/confcheck/CMakeLists.txt @@ -58,6 +58,31 @@ if ( NOT "${FSEEKO64}" ) ) endif() + +# Check if underscores are needing for implicit c-Fortran intrefacing functions that +# don't use ISO C binding to map symbols +wrf_conf_check( + # try_run() with more than one source was introduced in CMake 3.25+ + # so we won't use it here until we see reasonable need to incease the + # version requirements + RESULT_VAR NOUNDERSCORE_SYMBOL + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/check_underscore.c ${CMAKE_CURRENT_SOURCE_DIR}/check_underscore.f90 + OPTIONS + COMPILE_DEFINITIONS -DNOUNDERSCORE + MESSAGE "Implicit symbol usage between C and Fortran are not identical, checking with underscores" + ) +if ( NOT ${NOUNDERSCORE_SYMBOL} ) + # If the above fails we NEED the following to work + wrf_conf_check( + RESULT_VAR UNDERSCORE_SYMBOL + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/check_underscore.c ${CMAKE_CURRENT_SOURCE_DIR}/check_underscore.f90 + OPTIONS + COMPILE_DEFINITIONS -DUNDERSCORE + MESSAGE "Implicit symbol usage between C with underscores and Fortran did not link!" + REQUIRED + ) +endif() + # Unsure if this is even necessary. Defines littered throughout configure.defaults # if ( ${USE_MPI} ) # wrf_conf_check( diff --git a/confcheck/check_underscore.c b/confcheck/check_underscore.c new file mode 100644 index 0000000000..05062e4d08 --- /dev/null +++ b/confcheck/check_underscore.c @@ -0,0 +1,8 @@ +#include +#ifdef UNDERSCORE +# define foo foo_ +#endif +void foo( void ) +{ + printf( "Hello World!\n" ); +} diff --git a/confcheck/check_underscore.f90 b/confcheck/check_underscore.f90 new file mode 100644 index 0000000000..1aad4447ed --- /dev/null +++ b/confcheck/check_underscore.f90 @@ -0,0 +1,5 @@ + +program test + write( *, * ) "Calling foo() from Fortran" + call foo() +end program test From b263d5fb061e3040fffd7bfded2146f6477817a2 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 5 Aug 2024 18:44:47 -0700 Subject: [PATCH 18/42] Incorporate underscore check into definitions --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index eef1cb7fde..6c715010f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -831,6 +831,12 @@ else() list( APPEND PROJECT_COMPILE_DEFINITIONS_CONFCHECK FSEEK_OK ) endif() +if ( ${NOUNDERSCORE_SYMBOL} ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_CONFCHECK NOUNDERSCORE ) +elseif( ${UNDERSCORE_SYMBOL} ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_CONFCHECK UNDERSCORE ) +endif() + # I don't believe these are used anymore... # $<$:MPI2_SUPPORT=$> # $<$:MPI2_THREAD_SUPPORT=$> From 1728a6bf0e87e75e5d67067905e4acdad25bf7de Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 12 Jul 2024 16:38:22 -0700 Subject: [PATCH 19/42] External folder compilation for da build --- var/CMakeLists.txt | 12 + var/external/bufr/CMakeLists.txt | 267 ++++++++++++++++++ var/external/crtm_2.3.0/CMakeLists.txt | 35 +++ var/external/crtm_2.3.0/libsrc/CMakeLists.txt | 202 +++++++++++++ var/external/wavelet/CMakeLists.txt | 65 +++++ 5 files changed, 581 insertions(+) create mode 100644 var/CMakeLists.txt create mode 100644 var/external/bufr/CMakeLists.txt create mode 100644 var/external/crtm_2.3.0/CMakeLists.txt create mode 100644 var/external/crtm_2.3.0/libsrc/CMakeLists.txt create mode 100644 var/external/wavelet/CMakeLists.txt diff --git a/var/CMakeLists.txt b/var/CMakeLists.txt new file mode 100644 index 0000000000..3cb2288cc4 --- /dev/null +++ b/var/CMakeLists.txt @@ -0,0 +1,12 @@ + +if ( ${ENABLE_CRTM} ) + add_subdirectory( external/crtm_2.3.0 ) +endif() + +if ( ${ENABLE_BUFR} ) + add_subdirectory( external/bufr ) +endif() + +if ( ${ENABLE_WAVELET} ) + add_subdirectory( external/wavelet ) +endif() diff --git a/var/external/bufr/CMakeLists.txt b/var/external/bufr/CMakeLists.txt new file mode 100644 index 0000000000..43ef08ad9f --- /dev/null +++ b/var/external/bufr/CMakeLists.txt @@ -0,0 +1,267 @@ +# WRF CMake Build +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME ) + +add_library( + ${FOLDER_COMPILE_TARGET} + STATIC + adn30.f + atrcpt.f + bfrini.f + blocks.f + bort_exit.c + bort.f + bort2.f + bvers.f + cadn30.f + capit.f + ccbfl.c + chekstab.f + chrtrn.f + chrtrna.f + cktaba.f + closbf.f + closmg.f + cmpia.c + cmpmsg.f + cmsgini.f + cnved4.f + cobfl.c + conwin.f + copybf.f + copymg.f + copysb.f + cpbfdx.f + cpdxmm.f + cpymem.f + cpyupd.f + crbmg.c + cread.c + cwbmg.c + datebf.f + datelen.f + digit.f + drfini.f + drstpl.f + dumpbf.f + dxdump.f + dxinit.f + dxmini.f + elemdx.f + errwrt.f + getabdb.f + getbmiss.f + getlens.f + getntbe.f + gets1loc.f + gettagpr.f + gettbh.f + getvalnb.f + getwin.f + i4dy.f + ibfms.f + icbfms.f + ichkstr.f + icmpdx.f + icopysb.f + icvidx.c + idn30.f + idxmsg.f + ifbget.f + ifxy.f + igetdate.f + igetfxy.f + igetntbi.f + igetntbl.f + igetsc.f + igettdi.f + inctab.f + invcon.f + invmrg.f + invtag.f + invwin.f + iok2cpy.f + ipkm.f + ipks.f + ireadmg.f + ireadmm.f + ireadns.f + ireadsb.f + irev.for + ishrdx.f + isize.f + istdesc.f + iupb.f + iupbs01.f + iupbs3.f + iupm.f + iupvs01.f + jstchr.f + jstnum.f + lcmgdf.f + lmsg.f + lstjpb.f + makestab.f + maxout.f + mesgbc.f + mesgbf.f + minimg.f + mrginv.f + msgfull.f + msgini.f + msgupd.f + msgwrt.f + mtinfo.f + mvb.f + nemock.f + nemtab.f + nemtba.f + nemtbax.f + nemtbb.f + nemtbd.f + nenubd.f + nevn.f + newwin.f + nmsub.f + nmwrd.f + numbck.f + nummtb.c + numtab.f + numtbd.f + nvnwin.f + nwords.f + nxtwin.f + openbf.f + openbt.f + openmb.f + openmg.f + pad.f + padmsg.f + parstr.f + parusr.f + parutg.f + pkb.f + pkbs1.f + pkc.f + pkftbv.f + pktdd.f + pkvs01.f + posapx.f + rbytes.c + rcstpl.f + rdbfdx.f + rdcmps.f + rdmemm.f + rdmems.f + rdmgsb.f + rdmsgb.f + rdmsgw.f + rdmtbb.f + rdmtbd.f + rdtree.f + rdusdx.f + readdx.f + readerme.f + readlc.f + readmg.f + readmm.f + readmt.f + readns.f + reads3.f + readsb.f + restd.c + rewnbf.f + rjust.f + rsvfvm.f + rtrcpt.f + seqsdx.f + setblock.f + setbmiss.f + sntbbe.f + sntbde.f + status.f + stbfdx.f + stdmsg.f + stndrd.f + stntbi.f + stntbia.f + strcln.f + strcpt.f + string.f + strnum.f + strsuc.f + stseq.c + tabent.f + tabsub.f + trybump.f + ufbcnt.f + ufbcpy.f + ufbcup.f + ufbdmp.f + ufbevn.f + ufbget.f + ufbin3.f + ufbint.f + ufbinx.f + ufbmem.f + ufbmex.f + ufbmms.f + ufbmns.f + ufbovr.f + ufbpos.f + ufbqcd.f + ufbqcp.f + ufbrep.f + ufbrms.f + ufbrp.f + ufbrw.f + ufbseq.f + ufbsp.f + ufbstp.f + ufbtab.f + ufbtam.f + ufdump.f + upb.f + upbb.f + upc.f + upds3.f + upftbv.f + ups.f + uptdd.f + usrtpl.f + valx.f + wrcmps.f + wrdesc.c + wrdlen.for + wrdxtb.f + writcp.f + writdx.f + writlc.f + writsa.f + writsb.f + wrtree.f + wtstat.f + ) + +set_target_properties( + ${FOLDER_COMPILE_TARGET} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY + Fortran_FORMAT FIXED + ) + +set_source_files_properties( + irev.for + wrdlen.for + TARGET_DIRECTORY ${FOLDER_COMPILE_TARGET} + PROPERTIES + COMPILE_DEFINITIONS ${CMAKE_C_BYTE_ORDER} # Use C byte order to mirror make build + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + EXPORT ${EXPORT_NAME}Targets + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) diff --git a/var/external/crtm_2.3.0/CMakeLists.txt b/var/external/crtm_2.3.0/CMakeLists.txt new file mode 100644 index 0000000000..d8c5169513 --- /dev/null +++ b/var/external/crtm_2.3.0/CMakeLists.txt @@ -0,0 +1,35 @@ +# WRF CMake Build +# get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set( FOLDER_COMPILE_TARGET CRTM ) + +add_library( + ${FOLDER_COMPILE_TARGET} + STATIC + ) + +set_target_properties( + ${FOLDER_COMPILE_TARGET} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY + Fortran_FORMAT FREE + ) + + +# target_link_libraries( ${FOLDER_COMPILE_TARGET} +# PRIVATE +# ${netCDF_LIBRARIES} +# $<$:$> +# $<$:$> +# $ +# ) + +add_subdirectory( libsrc ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + EXPORT ${EXPORT_NAME}Targets + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) diff --git a/var/external/crtm_2.3.0/libsrc/CMakeLists.txt b/var/external/crtm_2.3.0/libsrc/CMakeLists.txt new file mode 100644 index 0000000000..4be7a34b93 --- /dev/null +++ b/var/external/crtm_2.3.0/libsrc/CMakeLists.txt @@ -0,0 +1,202 @@ +target_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ) + + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + # The list of files that need preprocessing + CRTM_Module.fpp + + # The list of regular source files + Type_Kinds.f90 + File_Utility.f90 + Message_Handler.f90 + Date_Utility.f90 + DateTime_Utility.f90 + Timing_Utility.f90 + Compare_Float_Numbers.f90 + Endian_Utility.f90 + Binary_File_Utility.f90 + Sort_Utility.f90 + Search_Utility.f90 + String_Utility.f90 + Fundamental_Constants.f90 + Hyperbolic_Step.f90 + Spectral_Units_Conversion.f90 + UnitTest_Define.f90 + SensorInfo_Parameters.f90 + Subset_Define.f90 + SpcCoeff_Define.f90 + ACCoeff_Define.f90 + NLTECoeff_Define.f90 + SpcCoeff_Binary_IO.f90 + ACCoeff_Binary_IO.f90 + NLTECoeff_Binary_IO.f90 + CloudCoeff_Define.f90 + CloudCoeff_Binary_IO.f90 + AerosolCoeff_Define.f90 + AerosolCoeff_Binary_IO.f90 + CRTM_Options_Define.f90 + CRTM_AOD_Module.f90 + IRwaterCoeff_Define.f90 + SEcategory_Define.f90 + LSEatlas_Define.f90 + MWwaterCoeff_Define.f90 + FitCoeff_Define.f90 + MWwaterLUT_Define.f90 + NESDIS_AMSRE_SICEEM_Module.f90 + NESDIS_AMSRE_SNOWEM_Module.f90 + NESDIS_AMSU_SICEEM_Module.f90 + NESDIS_AMSU_SnowEM_Module.f90 + NESDIS_MHS_SICEEM_Module.f90 + NESDIS_MHS_SnowEM_Module.f90 + NESDIS_LandEM_Module.f90 + NESDIS_SEAICE_PHYEM_MODULE.f90 + NESDIS_SnowEM_Parameters.f90 + NESDIS_SSMI_Module.f90 + NESDIS_SSMI_SIceEM_Module.f90 + NESDIS_SSMI_SnowEM_Module.f90 + NESDIS_SSMIS_SeaIceEM_Module.f90 + NESDIS_SSMIS_SnowEM_Module.f90 + NESDIS_SnowEM_ATMS_Parameters.f90 + NESDIS_ATMS_SnowEM_Module.f90 + NESDIS_ATMS_SeaICE_LIB.f90 + NESDIS_ATMS_SeaICE_Module.f90 + CRTM_Utility.f90 + CRTM_Interpolation.f90 + CRTM_SpcCoeff.f90 + CRTM_TauCoeff.f90 + TauCoeff_Define.f90 + CRTM_AerosolCoeff.f90 + CRTM_CloudCoeff.f90 + CRTM_IRlandCoeff.f90 + CRTM_IRwaterCoeff.f90 + CRTM_IRsnowCoeff.f90 + CRTM_IRiceCoeff.f90 + CRTM_VISlandCoeff.f90 + CRTM_VISwaterCoeff.f90 + CRTM_VISsnowCoeff.f90 + CRTM_VISiceCoeff.f90 + CRTM_MWwaterCoeff.f90 + CRTM_Atmosphere_Define.f90 + CRTM_Cloud_Define.f90 + CRTM_Aerosol_Define.f90 + CRTM_Surface_Define.f90 + CRTM_SensorData_Define.f90 + CRTM_SensorInfo.f90 + CRTM_ChannelInfo_Define.f90 + CRTM_Geometry_Define.f90 + CRTM_GeometryInfo_Define.f90 + CRTM_GeometryInfo.f90 + CRTM_Atmosphere.f90 + iAtm_Define.f90 + CRTM_CloudCover_Define.f90 + CRTM_Model_Profiles.f90 + CRTM_AerosolScatter.f90 + ASvar_Define.f90 + CRTM_CloudScatter.f90 + CSvar_Define.f90 + CRTM_MoleculeScatter.f90 + CRTM_SfcOptics_Define.f90 + CRTM_SfcOptics.f90 + CRTM_IR_Land_SfcOptics.f90 + CRTM_IR_Water_SfcOptics.f90 + CRTM_IR_Snow_SfcOptics.f90 + CRTM_IR_Ice_SfcOptics.f90 + CRTM_MW_Land_SfcOptics.f90 + CRTM_MW_Water_SfcOptics.f90 + CRTM_MW_Snow_SfcOptics.f90 + CRTM_MW_Ice_SfcOptics.f90 + CRTM_VIS_Land_SfcOptics.f90 + CRTM_VIS_Water_SfcOptics.f90 + CRTM_VIS_Snow_SfcOptics.f90 + CRTM_VIS_Ice_SfcOptics.f90 + CRTM_SEcategory.f90 + CRTM_LowFrequency_MWSSEM.f90 + CRTM_Fastem1.f90 + CRTM_FastemX.f90 + Reflection_Correction_Module.f90 + Azimuth_Emissivity_Module.f90 + Azimuth_Emissivity_F6_Module.f90 + Small_Scale_Correction_Module.f90 + Large_Scale_Correction_Module.f90 + Foam_Utility_Module.f90 + Slope_Variance.f90 + Guillou.f90 + Ellison.f90 + Liu.f90 + Fresnel.f90 + CRTM_IRSSEM.f90 + CRTM_AtmOptics.f90 + CRTM_AtmOptics_Define.f90 + AOvar_Define.f90 + CRTM_Planck_Functions.f90 + RTV_Define.f90 + SOI_Module.f90 + ADA_Module.f90 + Emission_Module.f90 + CRTM_RTSolution_Define.f90 + Common_RTSolution.f90 + CRTM_RTSolution.f90 + CRTM_AntennaCorrection.f90 + CRTM_AncillaryInput_Define.f90 + SSU_Input_Define.f90 + Zeeman_Input_Define.f90 + CRTM_Parameters.f90 + CRTM_LifeCycle.f90 + CRTM_Forward_Module.f90 + CRTM_Tangent_Linear_Module.f90 + CRTM_Adjoint_Module.f90 + CRTM_K_Matrix_Module.f90 + CRTM_AtmAbsorption.f90 + CRTM_Predictor.f90 + CRTM_Predictor_Define.f90 + ODAS_AtmAbsorption.f90 + ODAS_Predictor.f90 + ODAS_Predictor_Define.f90 + ODAS_Binary_IO.f90 + ODAS_Define.f90 + ODAS_TauCoeff.f90 + ODPS_AtmAbsorption.f90 + ODPS_Predictor.f90 + ODPS_Predictor_Define.f90 + PAFV_Define.f90 + ODPS_Binary_IO.f90 + ODPS_Define.f90 + ODPS_TauCoeff.f90 + CRTM_GeometryInfo.f90 + ODSSU_AtmAbsorption.f90 + ODSSU_Define.f90 + ODSSU_Binary_IO.f90 + ODSSU_TauCoeff.f90 + Profile_Utility_Parameters.f90 + ODPS_CoordinateMapping.f90 + ODZeeman_TauCoeff.f90 + ODZeeman_AtmAbsorption.f90 + ODZeeman_Predictor.f90 + Zeeman_Utility.f90 + CRTM_NLTECorrection.f90 + NLTE_Parameters.f90 + NLTE_Predictor_Define.f90 + NLTE_Predictor_IO.f90 + ) +if ( ${CMAKE_Fortran_COMPILER_ID} STREQUAL "PGI" ) + set_source_files_properties( + Sort_Utility.f90 + TARGET_DIRECTORY ${FOLDER_COMPILE_TARGET} + PROPERTIES + COMPILE_OPTIONS -tp=px + ) +endif() + +# if ( ${CMAKE_Fortran_COMPILER_ID} STREQUAL "Cray" ) +# set_source_files_properties( +# Sort_Utility.f90 +# TARGET_DIRECTORY ${FOLDER_COMPILE_TARGET} +# PROPERTIES +# COMPILE_FLAGS -01 # TODO - find a better way to control these flags +# ) +# endif() diff --git a/var/external/wavelet/CMakeLists.txt b/var/external/wavelet/CMakeLists.txt new file mode 100644 index 0000000000..46650e0af4 --- /dev/null +++ b/var/external/wavelet/CMakeLists.txt @@ -0,0 +1,65 @@ +# WRF CMake Build +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME ) + +add_library( + ${FOLDER_COMPILE_TARGET} # C library + STATIC + awaprogs/chap05/cd.c + dwtai.c + dwtai_w.c + dwtai2.c + dwtai2_w.c + DWTAPartition.c + idwtai.c + idwtai_w.c + idwtai2.c + idwtai2_w.c + l2norm.c + PrintFilter.c + awaprogs/chap05/qf.c + qf_w.c + qftest.c + qftest_w.c + TestFilter.c + awaprogs/chap09/xp.c + ) + + +add_library( + ${FOLDER_COMPILE_TARGET}f # Fortran library + STATIC + dwta_partition.F90 + print_filter.F90 + test_filter.F90 + ) + + +set_target_properties( + ${FOLDER_COMPILE_TARGET}f + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY + Fortran_FORMAT FIXED + ) + +target_compile_definitions( + ${FOLDER_COMPILE_TARGET} + PRIVATE + UNDERSCORE + ) + +target_include_directories( + ${FOLDER_COMPILE_TARGET} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/awaprogs/chap02 + ${CMAKE_CURRENT_SOURCE_DIR}/awaprogs/chap05 + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} ${FOLDER_COMPILE_TARGET}f + EXPORT ${EXPORT_NAME}Targets + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) From 0c275d8b8301d56322465e3b739cca01eac884ec Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 24 Jul 2024 15:39:59 -0700 Subject: [PATCH 20/42] Add cmake option for crtm, wavelet, and bufr --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c715010f9..c295285832 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -171,6 +171,12 @@ set( INTIO ON CACHE BOOL "INTIO" ) set( KEEP_INT_AROUND ON CACHE BOOL "KEEP_INT_AROUND" ) set( LIMIT_ARGS ON CACHE BOOL "LIMIT_ARGS" ) +# WRF DA +set( ENABLE_CRTM OFF CACHE BOOL "ENABLE_CRTM" ) +set( ENABLE_WAVELET ON CACHE BOOL "ENABLE_WAVELET" ) # todo I think this should always be on +set( ENABLE_BUFR ON CACHE BOOL "ENABLE_BUFR" ) # todo I think the config is defaulting this on + + # Toggles, how do we want to best address these options? Environment vars are not # the best set( WRFIO_NCD_NO_LARGE_FILE_SUPPORT OFF CACHE BOOL "WRFIO_NCD_NO_LARGE_FILE_SUPPORT" ) From bebecac2c8ff1d85ee3c83b42a3dd88a082f810b Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 24 Jul 2024 15:40:46 -0700 Subject: [PATCH 21/42] Add var/ build when core is appropriate --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c295285832..7dfcc8c782 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -924,7 +924,12 @@ endif() add_subdirectory( dyn_em ) -add_subdirectory( main ) +if ( ${WRF_CORE} STREQUAL "DA" OR ${WRF_CORE} STREQUAL "DA_4D_VAR" ) + # We don't create any of the drivers for WRF in DA mode + add_subdirectory( var ) +else() + add_subdirectory( main ) +endif() ################################################################################ # Add subdirectory with case info From 43d1f9012317d973e2546fa34c20c58e1c6acae2 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 24 Jul 2024 15:41:23 -0700 Subject: [PATCH 22/42] Extract rconfig always to satisfy DA registry --- tools/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index a261177f1a..8613a1eb8d 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -122,6 +122,10 @@ add_custom_command( ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/inc COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/frame + # WRF DA shenanigans that date back so far back changing to some better layout may have unintended + # consequences with external workflows. There is no harm in always doing this so that's why this is here + COMMAND + grep "^rconfig" ${PROJECT_SOURCE_DIR}/Registry/Registry.EM_COMMON > ${CMAKE_BINARY_DIR}/Registry/Registry.rconfig 2>&1 COMMAND ${CMAKE_BINARY_DIR}/tools/registry ${REGISTRY_DEFS} -DNEW_BDYS ${REGISTRY_FILE} > ${CMAKE_BINARY_DIR}/registry.log 2>&1 #!TODO Just have the registry code actually check for failure or better yet rewrite the From 4a5ac518301dec30f5f80d8e0ada9abc3aeae8f4 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 24 Jul 2024 15:42:15 -0700 Subject: [PATCH 23/42] Compile var lib --- var/CMakeLists.txt | 198 ++++++++++++++++++++++++++++ var/external/bufr/CMakeLists.txt | 6 + var/external/wavelet/CMakeLists.txt | 14 -- 3 files changed, 204 insertions(+), 14 deletions(-) diff --git a/var/CMakeLists.txt b/var/CMakeLists.txt index 3cb2288cc4..37fa73d06a 100644 --- a/var/CMakeLists.txt +++ b/var/CMakeLists.txt @@ -10,3 +10,201 @@ endif() if ( ${ENABLE_WAVELET} ) add_subdirectory( external/wavelet ) endif() + +wrf_m4_preproc_fortran( + TARGET_NAME da_generic_boilerplate + OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ + EXTENSION ".inc" + SOURCES da/da_par_util/da_generic_boilerplate.m4 + TARGET_SCOPE ${PROJECT_NAME}_Core + FLAGS ${M4_FLAGS} + ) + + +add_dependencies( ${PROJECT_NAME}_Core da_generic_boilerplate ) +target_include_directories( + ${PROJECT_NAME}_Core + PRIVATE + ${CMAKE_CURRENT_BINARY_DIR}/preproc/ + ) + +# To somewhat mirror the DA build (and for "neatness") I won't put cmake files +# in each source folder and instead build at this level + +target_sources( + ${PROJECT_NAME}_Core + PRIVATE + da/da_4dvar/da_4dvar.f90 + da/da_airep/da_airep.f90 + da/da_airsr/da_airsr.f90 + da/da_biascorr_airmass/da_bias_airmass.f90 + da/da_biascorr_airmass/da_bias_scan.f90 + da/da_biascorr_airmass/da_bias_sele.f90 + da/da_biascorr_airmass/da_bias_verif.f90 + da/da_biascorr_airmass/pythag.f90 + da/da_biascorr_airmass/rad_bias.f90 + da/da_biascorr_airmass/regress_one.f90 + da/da_biascorr_airmass/tqli.f90 + da/da_biascorr_airmass/tred2.f90 + da/da_bogus/da_bogus.f90 + da/da_buoy/da_buoy.f90 + da/da_chem_sfc/da_chem_sfc.f90 + da/da_control/da_control.f90 + da/da_define_structures/da_define_structures.f90 + da/da_dynamics/da_dynamics.f90 + da/da_etkf/da_etkf.f90 + da/da_ffts/da_ffts.f90 + da/da_ffts/module_ffts.f90 + da/da_gen_be/da_gen_be.f90 + da/da_geoamv/da_geoamv.f90 + da/da_gpseph/da_gpseph.f90 + da/da_gpspw/da_gpspw.f90 + da/da_gpsref/da_gpsref.f90 + da/da_grid_definitions/da_grid_definitions.f90 + da/da_interpolation/da_interpolation.f90 + da/da_main/da_wrfvar_esmf.f90 + da/da_main/da_wrfvar_esmf_super.f90 + da/da_main/da_wrfvar_io.f90 + da/da_main/da_wrfvar_main.f90 + da/da_main/da_wrfvar_top.f90 + da/da_metar/da_metar.f90 + da/da_minimisation/da_minimisation.f90 + da/da_monitor/da_rad_diags.f90 + da/da_mtgirs/da_mtgirs.f90 + da/da_obs/da_obs.f90 + da/da_obs_io/da_obs_io.f90 + da/da_par_util/da_par_util.f90 + da/da_par_util/da_par_util1.f90 + da/da_physics/da_physics.f90 + da/da_physics/f_qv_from_rh.f90 + da/da_pilot/da_pilot.f90 + da/da_polaramv/da_polaramv.f90 + da/da_profiler/da_profiler.f90 + da/da_pseudo/da_pseudo.f90 + da/da_qscat/da_qscat.f90 + da/da_radar/da_radar.f90 + da/da_radiance/da_crtm.f90 + da/da_radiance/da_radiance.f90 + da/da_radiance/da_radiance1.f90 + da/da_radiance/da_rttov.f90 + da/da_radiance/gsi_constants.f90 + da/da_radiance/gsi_kinds.f90 + da/da_radiance/gsi_thinning.f90 + da/da_radiance/mod_clddet_geoir.f90 + da/da_radiance/module_radiance.f90 + da/da_rain/da_rain.f90 + da/da_recursive_filter/da_mat_cv3.f90 + da/da_recursive_filter/da_recursive_filter.f90 + da/da_recursive_filter/da_rf_cv3.f90 + da/da_recursive_filter/da_rfz_cv3.f90 + da/da_reporting/da_reporting.f90 + da/da_satem/da_satem.f90 + da/da_setup_structures/da_setup_structures.f90 + da/da_ships/da_ships.f90 + da/da_sound/da_sound.f90 + da/da_spectral/da_be_spectral.f90 + da/da_spectral/da_spectral.f90 + da/da_ssmi/da_ssmi.f90 + da/da_ssmi/module_ssmi.f90 + da/da_statistics/da_statistics.f90 + da/da_synop/da_synop.f90 + da/da_tamdar/da_tamdar.f90 + da/da_test/da_test.f90 + da/da_tools/da_rsl_interfaces.f90 + da/da_tools/da_tools_serial.f90 + da/da_tools/da_wrf_interfaces.f90 + da/da_tools/gamma1.f90 + da/da_tools/da_tools.f90 + da/da_tracing/da_tracing.f90 + da/da_transfer_model/da_transfer_model.f90 + da/da_update_bc/da_module_couple_uv.f90 + da/da_update_bc/da_module_couple_uv_ad.f90 + da/da_update_bc/da_netcdf_interface.f90 + da/da_update_bc/da_update_bc.f90 + da/da_update_bc/da_update_bc_ad.f90 + da/da_util/da_advance_time.f90 + da/da_util/da_tune_obs_desroziers.f90 + da/da_util/da_tune_obs_hollingsworth1.f90 + da/da_util/da_tune_obs_hollingsworth2.f90 + da/da_varbc/da_varbc.f90 + da/da_varbc_tamdar/da_varbc_tamdar.f90 + da/da_verif_anal/da_verif_anal.f90 + da/da_verif_anal/da_verif_anal_control.f90 + da/da_verif_grid/da_verif_grid.f90 + da/da_verif_grid/da_verif_grid_control.f90 + da/da_verif_obs/da_verif_obs.f90 + da/da_verif_obs/da_verif_obs_control.f90 + da/da_verif_obs/da_verif_obs_init.f90 + da/da_verif_obs/da_verif_tools.f90 + da/da_vtox_transforms/da_vtox_transforms.f90 + da/da_wavelet/da_wavelet.f90 + da/da_lightning/da_lightning.f90 + + # blas and lapack + external/blas/da_blas.f90 + external/lapack/da_lapack.f90 + ) + + +target_include_directories( + ${PROJECT_NAME}_Core + PRIVATE + da/da_4dvar + da/da_airep + da/da_airsr + da/da_bogus + da/da_buoy + da/da_chem_sfc + da/da_define_structures + da/da_dynamics + da/da_etkf + da/da_ffts + da/da_gen_be + da/da_geoamv + da/da_gpseph + da/da_gpspw + da/da_gpsref + da/da_grid_definitions + da/da_interpolation + da/da_lightning + da/da_main + da/da_metar + da/da_minimisation + da/da_mtgirs + da/da_obs + da/da_obs_io + da/da_par_util + da/da_physics + da/da_pilot + da/da_polaramv + da/da_profiler + da/da_pseudo + da/da_qscat + da/da_radar + da/da_radiance + da/da_rain + da/da_recursive_filter + da/da_reporting + da/da_satem + da/da_setup_structures + da/da_ships + da/da_sound + da/da_spectral + da/da_ssmi + da/da_statistics + da/da_synop + da/da_tamdar + da/da_test + da/da_tools + da/da_tracing + da/da_transfer_model + da/da_update_bc + da/da_varbc + da/da_varbc_tamdar + da/da_vtox_transforms + da/da_wavelet + + # blas and lapack + external/blas + external/lapack + ) diff --git a/var/external/bufr/CMakeLists.txt b/var/external/bufr/CMakeLists.txt index 43ef08ad9f..03f4f89cbe 100644 --- a/var/external/bufr/CMakeLists.txt +++ b/var/external/bufr/CMakeLists.txt @@ -250,6 +250,12 @@ set_target_properties( Fortran_FORMAT FIXED ) +target_compile_definitions( + ${FOLDER_COMPILE_TARGET} + PRIVATE + UNDERSCORE + ) + set_source_files_properties( irev.for wrdlen.for diff --git a/var/external/wavelet/CMakeLists.txt b/var/external/wavelet/CMakeLists.txt index 46650e0af4..e842dfea8a 100644 --- a/var/external/wavelet/CMakeLists.txt +++ b/var/external/wavelet/CMakeLists.txt @@ -34,20 +34,6 @@ add_library( ) -set_target_properties( - ${FOLDER_COMPILE_TARGET}f - PROPERTIES - Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} - EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY - Fortran_FORMAT FIXED - ) - -target_compile_definitions( - ${FOLDER_COMPILE_TARGET} - PRIVATE - UNDERSCORE - ) - target_include_directories( ${FOLDER_COMPILE_TARGET} PRIVATE From 4a54b7ee12231f27d960f77fa568f16a93b5923b Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 29 Jul 2024 17:36:18 -0700 Subject: [PATCH 24/42] Add compile defs for DA options --- CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7dfcc8c782..73b3ead394 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -792,7 +792,17 @@ else() list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRFPLUS=0 ) endif() -if ( "${WRF_CORE}" STREQUAL "DA_CORE" OR "${WRF_CORE}" STREQUAL "DA_4D_VAR" ) +if ( "${WRF_CORE}" STREQUAL "DA" OR "${WRF_CORE}" STREQUAL "DA_4D_VAR" ) + if ( ${ENABLE_WAVELET} ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WAVELET ) + endif() + if ( ${ENABLE_CRTM} ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS CRTM ) + endif() + if ( ${ENABLE_BUFR} ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS BUFR ) + endif() + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS DA_CORE=1 ) else() list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS DA_CORE=0 ) From 1d744a51bee2ad3cc54a2a6c4f2fad8e9974eb6f Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 29 Jul 2024 17:37:23 -0700 Subject: [PATCH 25/42] Remove addition of non-DA folders --- CMakeLists.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 73b3ead394..1bd048e52c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -918,7 +918,6 @@ add_dependencies( ) # Add directly to core -add_subdirectory( phys ) add_subdirectory( share ) add_subdirectory( frame ) add_subdirectory( inc ) @@ -931,13 +930,13 @@ if ( ${ENABLE_HYDRO} ) add_subdirectory( hydro ) endif() -add_subdirectory( dyn_em ) - - if ( ${WRF_CORE} STREQUAL "DA" OR ${WRF_CORE} STREQUAL "DA_4D_VAR" ) # We don't create any of the drivers for WRF in DA mode add_subdirectory( var ) else() + # DA does not use any of this + add_subdirectory( dyn_em ) + add_subdirectory( phys ) add_subdirectory( main ) endif() From b2c10132e595099b111c0bc8fe7711dc5017a2e4 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 29 Jul 2024 17:38:31 -0700 Subject: [PATCH 26/42] Adjust core folders sources for when da core is being built --- frame/CMakeLists.txt | 44 +++++++++++++++----------- share/CMakeLists.txt | 74 ++++++++++++++++++++++++-------------------- 2 files changed, 67 insertions(+), 51 deletions(-) diff --git a/frame/CMakeLists.txt b/frame/CMakeLists.txt index b923149edf..a55d27f56c 100644 --- a/frame/CMakeLists.txt +++ b/frame/CMakeLists.txt @@ -89,11 +89,30 @@ if ( ${USE_RSL_LITE} ) set( MODULE_DM ${PROJECT_SOURCE_DIR}/external/RSL_LITE/module_dm.F ) endif() +set( + NON_DA_SOURCES + module_cpl.F + module_cpl_oasis3.F + clog.c + libmassv.F + + module_clear_halos.F + module_comm_nesting_dm.F + module_integrate.F + module_quilt_outbuf_ops.F + module_sm.F + pack_utils.c + ) + +if ( ${WRF_CORE} STREQUAL "DA" OR ${WRF_CORE} STREQUAL "DA_4D_VAR" ) + set( NON_DA_SOURCES "" ) +endif() + target_sources( ${PROJECT_NAME}_Core PRIVATE ${WRF_INCLUDE_FILES} - + # Common sources used in all cores module_configure.F module_driver_constants.F module_domain_type.F @@ -102,11 +121,7 @@ target_sources( module_wrf_error.F module_machine.F module_timing.F - # module_dm.F ${MODULE_DM} - module_cpl.F - module_cpl_oasis3.F - module_alloc_space_0.F module_alloc_space_1.F @@ -122,36 +137,29 @@ target_sources( ${CMAKE_BINARY_DIR}/frame/module_state_description.F # GENERATED ${nl_dyn_source} # GENERATED - clog.c + collect_on_comm.c hires_timer.c - libmassv.F - module_clear_halos.F + module_comm_dm.F module_comm_dm_0.F module_comm_dm_1.F module_comm_dm_2.F module_comm_dm_3.F module_comm_dm_4.F - module_comm_nesting_dm.F - - - - module_integrate.F - + module_io.F module_io_quilt.F module_nesting.F - module_quilt_outbuf_ops.F - module_sm.F + module_tiles.F - - pack_utils.c wrf_debug.F wrf_num_bytes_between.c wrf_shutdown.F + + ${NON_DA_SOURCES} ) # Disable optimizations on these files always diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index 229efae1e5..8f8bb413ff 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -11,49 +11,66 @@ target_include_directories( # Now define base share # ######################################################################################################################## +set( + NON_DA_SOURCES + module_llxy.F + module_soil_pre.F + module_compute_geop.F + module_chem_share.F + module_check_a_mundo.F + module_HLaw.F + module_ctrans_aqchem.F + module_random.F + module_interp_nmm.F + module_interp_store.F + module_string_tools.F + module_MPP.F + module_optional_input.F + dfi.F + solve_interface.F + mediation_interp_domain.F + mediation_force_domain.F + mediation_feedback_domain.F + wrf_tsin.F + track_driver.F + track_input.F + module_trajectory.F + bobrand.c + wrf_timeseries.F + track_driver.F + wrf_fddaobs_in.F + mediation_nest_move.F + setfeenv.c + ) + +if ( ${WRF_CORE} STREQUAL "DA" OR ${WRF_CORE} STREQUAL "DA_4D_VAR" ) + set( NON_DA_SOURCES "" ) +endif() + target_sources( ${PROJECT_NAME}_Core PRIVATE - + # Common sources used in all cores module_model_constants.F - module_llxy.F - module_soil_pre.F + module_date_time.F module_bc.F module_bc_time_utilities.F module_get_file_names.F - module_compute_geop.F - module_chem_share.F - module_check_a_mundo.F - module_HLaw.F - module_ctrans_aqchem.F - module_random.F - module_interp_nmm.F - module_interp_store.F - module_string_tools.F - module_MPP.F module_io_wrf.F - module_io_domain.F - module_optional_input.F - input_wrf.F output_wrf.F wrf_bdyout.F wrf_bdyin.F - dfi.F + mediation_integrate.F mediation_wrfmain.F - solve_interface.F - mediation_interp_domain.F - mediation_force_domain.F - mediation_feedback_domain.F - start_domain.F init_modules.F set_timekeeping.F @@ -61,17 +78,8 @@ target_sources( sint.F wrf_ext_write_field.F wrf_ext_read_field.F - - wrf_tsin.F landread.c - track_driver.F - track_input.F - module_trajectory.F - bobrand.c - wrf_timeseries.F - track_driver.F - wrf_fddaobs_in.F - mediation_nest_move.F - setfeenv.c + + ${NON_DA_SOURCES} ) From e30952c7c3c3fd0a98a00938426c8bdb3d9e2983 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 29 Jul 2024 17:39:14 -0700 Subject: [PATCH 27/42] Set da sources per da.make --- var/CMakeLists.txt | 48 ++++++++++++---------------------------------- 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/var/CMakeLists.txt b/var/CMakeLists.txt index 37fa73d06a..58d8e25109 100644 --- a/var/CMakeLists.txt +++ b/var/CMakeLists.txt @@ -37,42 +37,34 @@ target_sources( da/da_4dvar/da_4dvar.f90 da/da_airep/da_airep.f90 da/da_airsr/da_airsr.f90 - da/da_biascorr_airmass/da_bias_airmass.f90 - da/da_biascorr_airmass/da_bias_scan.f90 - da/da_biascorr_airmass/da_bias_sele.f90 - da/da_biascorr_airmass/da_bias_verif.f90 - da/da_biascorr_airmass/pythag.f90 - da/da_biascorr_airmass/rad_bias.f90 - da/da_biascorr_airmass/regress_one.f90 - da/da_biascorr_airmass/tqli.f90 - da/da_biascorr_airmass/tred2.f90 da/da_bogus/da_bogus.f90 da/da_buoy/da_buoy.f90 da/da_chem_sfc/da_chem_sfc.f90 + # This is not in the original da lib, but I don't see how that + # isn't correct as many modules in this require it da/da_control/da_control.f90 + + da/da_define_structures/da_define_structures.f90 da/da_dynamics/da_dynamics.f90 - da/da_etkf/da_etkf.f90 da/da_ffts/da_ffts.f90 da/da_ffts/module_ffts.f90 - da/da_gen_be/da_gen_be.f90 da/da_geoamv/da_geoamv.f90 da/da_gpseph/da_gpseph.f90 da/da_gpspw/da_gpspw.f90 da/da_gpsref/da_gpsref.f90 da/da_grid_definitions/da_grid_definitions.f90 da/da_interpolation/da_interpolation.f90 - da/da_main/da_wrfvar_esmf.f90 - da/da_main/da_wrfvar_esmf_super.f90 + da/da_lightning/da_lightning.f90 + da/da_main/copyfile.c da/da_main/da_wrfvar_io.f90 - da/da_main/da_wrfvar_main.f90 da/da_main/da_wrfvar_top.f90 da/da_metar/da_metar.f90 da/da_minimisation/da_minimisation.f90 - da/da_monitor/da_rad_diags.f90 da/da_mtgirs/da_mtgirs.f90 - da/da_obs/da_obs.f90 + da/da_obs_io/da_join_iv_for_multi_inc.c da/da_obs_io/da_obs_io.f90 + da/da_obs/da_obs.f90 da/da_par_util/da_par_util.f90 da/da_par_util/da_par_util1.f90 da/da_physics/da_physics.f90 @@ -83,6 +75,7 @@ target_sources( da/da_pseudo/da_pseudo.f90 da/da_qscat/da_qscat.f90 da/da_radar/da_radar.f90 + da/da_radiance/amsr2time_.c da/da_radiance/da_crtm.f90 da/da_radiance/da_radiance.f90 da/da_radiance/da_radiance1.f90 @@ -102,7 +95,6 @@ target_sources( da/da_setup_structures/da_setup_structures.f90 da/da_ships/da_ships.f90 da/da_sound/da_sound.f90 - da/da_spectral/da_be_spectral.f90 da/da_spectral/da_spectral.f90 da/da_ssmi/da_ssmi.f90 da/da_ssmi/module_ssmi.f90 @@ -112,33 +104,17 @@ target_sources( da/da_test/da_test.f90 da/da_tools/da_rsl_interfaces.f90 da/da_tools/da_tools_serial.f90 + da/da_tools/da_tools.f90 da/da_tools/da_wrf_interfaces.f90 da/da_tools/gamma1.f90 - da/da_tools/da_tools.f90 + da/da_tracing/da_memory.c da/da_tracing/da_tracing.f90 da/da_transfer_model/da_transfer_model.f90 - da/da_update_bc/da_module_couple_uv.f90 - da/da_update_bc/da_module_couple_uv_ad.f90 da/da_update_bc/da_netcdf_interface.f90 - da/da_update_bc/da_update_bc.f90 - da/da_update_bc/da_update_bc_ad.f90 - da/da_util/da_advance_time.f90 - da/da_util/da_tune_obs_desroziers.f90 - da/da_util/da_tune_obs_hollingsworth1.f90 - da/da_util/da_tune_obs_hollingsworth2.f90 - da/da_varbc/da_varbc.f90 da/da_varbc_tamdar/da_varbc_tamdar.f90 - da/da_verif_anal/da_verif_anal.f90 - da/da_verif_anal/da_verif_anal_control.f90 - da/da_verif_grid/da_verif_grid.f90 - da/da_verif_grid/da_verif_grid_control.f90 - da/da_verif_obs/da_verif_obs.f90 - da/da_verif_obs/da_verif_obs_control.f90 - da/da_verif_obs/da_verif_obs_init.f90 - da/da_verif_obs/da_verif_tools.f90 + da/da_varbc/da_varbc.f90 da/da_vtox_transforms/da_vtox_transforms.f90 da/da_wavelet/da_wavelet.f90 - da/da_lightning/da_lightning.f90 # blas and lapack external/blas/da_blas.f90 From c77f9c78dd4cc88a2bb65d4f83a6375c7e3ce7e5 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 2 Aug 2024 13:37:42 -0700 Subject: [PATCH 28/42] Flip crtm default --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1bd048e52c..842afbd377 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,7 +172,7 @@ set( KEEP_INT_AROUND ON CACHE BOOL "KEEP_INT_AROUND" ) set( LIMIT_ARGS ON CACHE BOOL "LIMIT_ARGS" ) # WRF DA -set( ENABLE_CRTM OFF CACHE BOOL "ENABLE_CRTM" ) +set( ENABLE_CRTM ON CACHE BOOL "ENABLE_CRTM" ) # todo this is always set unless env var = 0 in make set( ENABLE_WAVELET ON CACHE BOOL "ENABLE_WAVELET" ) # todo I think this should always be on set( ENABLE_BUFR ON CACHE BOOL "ENABLE_BUFR" ) # todo I think the config is defaulting this on From 176dc426e7f835311fdec30ebc638328236213ad Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 2 Aug 2024 13:37:56 -0700 Subject: [PATCH 29/42] Print DA suboptions --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 842afbd377..fc40a2c1d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -541,6 +541,12 @@ print_option( INTIO 20 ) print_option( KEEP_INT_AROUND 20 ) print_option( LIMIT_ARGS 20 ) + +print_option( ENABLE_CRTM 20 ) +print_option( ENABLE_WAVELET 20 ) +print_option( ENABLE_BUFR 20 ) + + print_option( FORCE_NETCDF_CLASSIC 20 ) print_option( BUILD_RRTMG_FAST 20 ) print_option( BUILD_RRTMK 20 ) From f05dd3306b312a51e143818106c73e114431bb6e Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 2 Aug 2024 13:38:08 -0700 Subject: [PATCH 30/42] DA defines always set --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc40a2c1d8..f5e00db742 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -809,7 +809,7 @@ if ( "${WRF_CORE}" STREQUAL "DA" OR "${WRF_CORE}" STREQUAL "DA_4D_VAR" ) list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS BUFR ) endif() - list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS DA_CORE=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS DA_CORE=1 -DFFTPACK -DNORESHAPE ) else() list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS DA_CORE=0 ) endif() From 8aeb0ff3a13e31d6de432abcbe06381ee6545b27 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 2 Aug 2024 13:38:38 -0700 Subject: [PATCH 31/42] Link var/external libs --- CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5e00db742..7332a63b02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1030,6 +1030,12 @@ target_include_directories( $<$:$> $<$:$> + # DA libs + $<$:$> + $<$:$> + $<$:$> + + PRIVATE ${PROJECT_SOURCE_DIR}/dyn_em @@ -1109,6 +1115,12 @@ target_link_libraries( ${PROJECT_NAME}_Core $ $ + + # DA libs + $ + $ + $ + $ ) ################################################################################ From 380325ed21d53c82583b7c7ba17682176817315d Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 2 Aug 2024 13:39:02 -0700 Subject: [PATCH 32/42] Add more info to debug messages --- cmake/target_source_properties.cmake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmake/target_source_properties.cmake b/cmake/target_source_properties.cmake index 55042a6263..6e5d5d414e 100644 --- a/cmake/target_source_properties.cmake +++ b/cmake/target_source_properties.cmake @@ -99,13 +99,16 @@ function( apply_target_source_properties ) ) if ( "${SOURCE_PROPERTY_${PROPERTY}}" STREQUAL "NOTFOUND" ) # use target + if ( ${FUNC_PROP_DEBUG} ) + message( STATUS "DEBUG [${SOURCE}] : Property ${PROPERTY}' not found, using target value '${TARGET_PROPERTY_${PROPERTY}}'" ) + endif() set( SOURCE_PROPERTY_${PROPERTY} ${TARGET_PROPERTY_${PROPERTY}} ) endif() # Now apply these as prop if ( NOT "${SOURCE_PROPERTY_${PROPERTY}}" STREQUAL "" ) if ( ${FUNC_PROP_DEBUG} ) - message( STATUS "DEBUG : Adding '${SOURCE_PROPERTY_${PROPERTY}}' as SOURCE_PROPERTY_${PROPERTY}") + message( STATUS "DEBUG [${SOURCE}] : Adding '${SOURCE_PROPERTY_${PROPERTY}}' as SOURCE_PROPERTY_${PROPERTY}") endif() list( APPEND SOURCE_PROPERTY_ALL ${SOURCE_PROPERTY_${PROPERTY}} ) endif() @@ -127,7 +130,7 @@ function( apply_target_source_properties ) endif() if ( ${FUNC_PROP_DEBUG} ) - message( STATUS "DEBUG : ${FUNC_PROP_AS_PROPERTY} being set to '${SOURCE_PROPERTY_ORIG} ${SOURCE_PROPERTY_ALL}'") + message( STATUS "DEBUG [${SOURCE}] : ${FUNC_PROP_AS_PROPERTY} being set to '${SOURCE_PROPERTY_ORIG} ${SOURCE_PROPERTY_ALL}'") endif() set_source_files_properties( From f34e19fc552046b9e44387bb4566a9d351cbd45c Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 2 Aug 2024 13:39:35 -0700 Subject: [PATCH 33/42] Disable double precision setting on blas and lapack files --- var/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/var/CMakeLists.txt b/var/CMakeLists.txt index 58d8e25109..3e1efb50c8 100644 --- a/var/CMakeLists.txt +++ b/var/CMakeLists.txt @@ -184,3 +184,13 @@ target_include_directories( external/blas external/lapack ) + +# Disable float to double precision on these files always +set_source_files_properties( + # blas and lapack + external/blas/da_blas.f90 + external/lapack/da_lapack.f90 + TARGET_DIRECTORY ${PROJECT_NAME}_Core + PROPERTIES + COMPILE_OPTIONS_Fortran_PRECISION "" # set to nothing to void + ) From 0ef30601354897d51c50fddbde04fbe7f9f1f33b Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 2 Aug 2024 13:40:09 -0700 Subject: [PATCH 34/42] Adjust flags to var/external libs --- var/external/bufr/CMakeLists.txt | 10 ++++++++++ var/external/crtm_2.3.0/CMakeLists.txt | 13 +++++-------- var/external/wavelet/CMakeLists.txt | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/var/external/bufr/CMakeLists.txt b/var/external/bufr/CMakeLists.txt index 03f4f89cbe..9aeec38482 100644 --- a/var/external/bufr/CMakeLists.txt +++ b/var/external/bufr/CMakeLists.txt @@ -250,6 +250,16 @@ set_target_properties( Fortran_FORMAT FIXED ) + +target_compile_options( + ${FOLDER_COMPILE_TARGET} + PRIVATE + ${PROJECT_COMPILE_OPTIONS_OPTIMIZATION} + ${PROJECT_COMPILE_OPTIONS_Fortran_LINE_LENGTH} + ${PROJECT_COMPILE_OPTIONS_SUPPRESS_WARNINGS} + ${PROJECT_COMPILE_OPTIONS_SUPPRESS_ERRORS} + ) + target_compile_definitions( ${FOLDER_COMPILE_TARGET} PRIVATE diff --git a/var/external/crtm_2.3.0/CMakeLists.txt b/var/external/crtm_2.3.0/CMakeLists.txt index d8c5169513..2c74db7b99 100644 --- a/var/external/crtm_2.3.0/CMakeLists.txt +++ b/var/external/crtm_2.3.0/CMakeLists.txt @@ -15,14 +15,11 @@ set_target_properties( Fortran_FORMAT FREE ) - -# target_link_libraries( ${FOLDER_COMPILE_TARGET} -# PRIVATE -# ${netCDF_LIBRARIES} -# $<$:$> -# $<$:$> -# $ -# ) +target_compile_options( + ${FOLDER_COMPILE_TARGET} + PRIVATE + ${WRF_FCOPTIM} # No other source langauges so this is fine + ) add_subdirectory( libsrc ) diff --git a/var/external/wavelet/CMakeLists.txt b/var/external/wavelet/CMakeLists.txt index e842dfea8a..c240cb016a 100644 --- a/var/external/wavelet/CMakeLists.txt +++ b/var/external/wavelet/CMakeLists.txt @@ -42,6 +42,20 @@ target_include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/awaprogs/chap05 ) +target_compile_definitions( + ${FOLDER_COMPILE_TARGET} + PRIVATE + ${PROJECT_COMPILE_DEFINITIONS} + NOUNDERSCORE + ) +# This is new in the cmake build +target_compile_options( + ${FOLDER_COMPILE_TARGET} + PRIVATE + ${PROJECT_COMPILE_OPTIONS_OPTIMIZATION} + + ) + install( TARGETS ${FOLDER_COMPILE_TARGET} ${FOLDER_COMPILE_TARGET}f EXPORT ${EXPORT_NAME}Targets From f064c03046d627dced60cbc23e36c1166bcdbd9a Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 2 Aug 2024 16:46:36 -0700 Subject: [PATCH 35/42] Remove iargc external using preprocessor directives --- var/da/da_util/da_advance_time.f90 | 2 ++ var/gen_be/gen_be_ep2.f90 | 2 ++ var/gen_be/gen_be_stage0_gsi.f90 | 2 ++ var/gen_be/gen_be_stage0_wrf.f90 | 3 ++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/var/da/da_util/da_advance_time.f90 b/var/da/da_util/da_advance_time.f90 index 71b69c0000..379d93d43f 100644 --- a/var/da/da_util/da_advance_time.f90 +++ b/var/da/da_util/da_advance_time.f90 @@ -31,7 +31,9 @@ program da_advance_time ! integer function iargc() ! end function iargc ! end interface +#ifndef __GFORTRAN__ integer, external :: iargc +#endif integer :: ccyy, mm, dd, hh, nn, ss, dday, dh, dn, ds, gday, gsec diff --git a/var/gen_be/gen_be_ep2.f90 b/var/gen_be/gen_be_ep2.f90 index d9e15238a4..71f56f1db7 100644 --- a/var/gen_be/gen_be_ep2.f90 +++ b/var/gen_be/gen_be_ep2.f90 @@ -32,7 +32,9 @@ program gen_be_ep2 character (len=3) :: ce ! Member index -> character. character (len=filename_len) :: moist_string +#ifndef __GFORTRAN__ integer, external :: iargc +#endif integer :: numarg integer :: ne ! Ensemble size. integer :: i, j, k, member ! Loop counters. diff --git a/var/gen_be/gen_be_stage0_gsi.f90 b/var/gen_be/gen_be_stage0_gsi.f90 index 6ba5f3ee36..cdba2fe4b5 100644 --- a/var/gen_be/gen_be_stage0_gsi.f90 +++ b/var/gen_be/gen_be_stage0_gsi.f90 @@ -34,7 +34,9 @@ program gen_be_stage0_gsi character (len=3) :: cne ! Ensemble size. character (len=3) :: ce ! Member index -> character. +#ifndef __GFORTRAN__ integer, external :: iargc +#endif integer :: numarg integer :: ne ! Ensemble size. integer :: i, j, k, member ! Loop counters. diff --git a/var/gen_be/gen_be_stage0_wrf.f90 b/var/gen_be/gen_be_stage0_wrf.f90 index 616ef6c92e..83ddfc503b 100644 --- a/var/gen_be/gen_be_stage0_wrf.f90 +++ b/var/gen_be/gen_be_stage0_wrf.f90 @@ -39,8 +39,9 @@ program gen_be_stage0_wrf character (len=3) :: ce ! Member index -> character. character (len=3) :: ccv_options ! Control variable input - +#ifndef __GFORTRAN__ integer, external :: iargc +#endif integer :: numarg integer :: ne ! Ensemble size. integer :: cv_options ! Control variable option From 380a7fe80e56b669bb3d0edb13007a87bbbf9d0a Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 2 Aug 2024 16:47:34 -0700 Subject: [PATCH 36/42] DA and gen_be source in respective folders --- var/CMakeLists.txt | 145 ++------------------- var/da/CMakeLists.txt | 263 ++++++++++++++++++++++++++++++++++++++ var/gen_be/CMakeLists.txt | 63 +++++++++ 3 files changed, 334 insertions(+), 137 deletions(-) create mode 100644 var/da/CMakeLists.txt create mode 100644 var/gen_be/CMakeLists.txt diff --git a/var/CMakeLists.txt b/var/CMakeLists.txt index 3e1efb50c8..3a8a0b222d 100644 --- a/var/CMakeLists.txt +++ b/var/CMakeLists.txt @@ -34,152 +34,18 @@ target_include_directories( target_sources( ${PROJECT_NAME}_Core PRIVATE - da/da_4dvar/da_4dvar.f90 - da/da_airep/da_airep.f90 - da/da_airsr/da_airsr.f90 - da/da_bogus/da_bogus.f90 - da/da_buoy/da_buoy.f90 - da/da_chem_sfc/da_chem_sfc.f90 - # This is not in the original da lib, but I don't see how that - # isn't correct as many modules in this require it - da/da_control/da_control.f90 - - - da/da_define_structures/da_define_structures.f90 - da/da_dynamics/da_dynamics.f90 - da/da_ffts/da_ffts.f90 - da/da_ffts/module_ffts.f90 - da/da_geoamv/da_geoamv.f90 - da/da_gpseph/da_gpseph.f90 - da/da_gpspw/da_gpspw.f90 - da/da_gpsref/da_gpsref.f90 - da/da_grid_definitions/da_grid_definitions.f90 - da/da_interpolation/da_interpolation.f90 - da/da_lightning/da_lightning.f90 - da/da_main/copyfile.c - da/da_main/da_wrfvar_io.f90 - da/da_main/da_wrfvar_top.f90 - da/da_metar/da_metar.f90 - da/da_minimisation/da_minimisation.f90 - da/da_mtgirs/da_mtgirs.f90 - da/da_obs_io/da_join_iv_for_multi_inc.c - da/da_obs_io/da_obs_io.f90 - da/da_obs/da_obs.f90 - da/da_par_util/da_par_util.f90 - da/da_par_util/da_par_util1.f90 - da/da_physics/da_physics.f90 - da/da_physics/f_qv_from_rh.f90 - da/da_pilot/da_pilot.f90 - da/da_polaramv/da_polaramv.f90 - da/da_profiler/da_profiler.f90 - da/da_pseudo/da_pseudo.f90 - da/da_qscat/da_qscat.f90 - da/da_radar/da_radar.f90 - da/da_radiance/amsr2time_.c - da/da_radiance/da_crtm.f90 - da/da_radiance/da_radiance.f90 - da/da_radiance/da_radiance1.f90 - da/da_radiance/da_rttov.f90 - da/da_radiance/gsi_constants.f90 - da/da_radiance/gsi_kinds.f90 - da/da_radiance/gsi_thinning.f90 - da/da_radiance/mod_clddet_geoir.f90 - da/da_radiance/module_radiance.f90 - da/da_rain/da_rain.f90 - da/da_recursive_filter/da_mat_cv3.f90 - da/da_recursive_filter/da_recursive_filter.f90 - da/da_recursive_filter/da_rf_cv3.f90 - da/da_recursive_filter/da_rfz_cv3.f90 - da/da_reporting/da_reporting.f90 - da/da_satem/da_satem.f90 - da/da_setup_structures/da_setup_structures.f90 - da/da_ships/da_ships.f90 - da/da_sound/da_sound.f90 - da/da_spectral/da_spectral.f90 - da/da_ssmi/da_ssmi.f90 - da/da_ssmi/module_ssmi.f90 - da/da_statistics/da_statistics.f90 - da/da_synop/da_synop.f90 - da/da_tamdar/da_tamdar.f90 - da/da_test/da_test.f90 - da/da_tools/da_rsl_interfaces.f90 - da/da_tools/da_tools_serial.f90 - da/da_tools/da_tools.f90 - da/da_tools/da_wrf_interfaces.f90 - da/da_tools/gamma1.f90 - da/da_tracing/da_memory.c - da/da_tracing/da_tracing.f90 - da/da_transfer_model/da_transfer_model.f90 - da/da_update_bc/da_netcdf_interface.f90 - da/da_varbc_tamdar/da_varbc_tamdar.f90 - da/da_varbc/da_varbc.f90 - da/da_vtox_transforms/da_vtox_transforms.f90 - da/da_wavelet/da_wavelet.f90 - # blas and lapack external/blas/da_blas.f90 external/lapack/da_lapack.f90 + + # da gen_be aero mod + gen_be/aero_mod.f90 ) target_include_directories( ${PROJECT_NAME}_Core PRIVATE - da/da_4dvar - da/da_airep - da/da_airsr - da/da_bogus - da/da_buoy - da/da_chem_sfc - da/da_define_structures - da/da_dynamics - da/da_etkf - da/da_ffts - da/da_gen_be - da/da_geoamv - da/da_gpseph - da/da_gpspw - da/da_gpsref - da/da_grid_definitions - da/da_interpolation - da/da_lightning - da/da_main - da/da_metar - da/da_minimisation - da/da_mtgirs - da/da_obs - da/da_obs_io - da/da_par_util - da/da_physics - da/da_pilot - da/da_polaramv - da/da_profiler - da/da_pseudo - da/da_qscat - da/da_radar - da/da_radiance - da/da_rain - da/da_recursive_filter - da/da_reporting - da/da_satem - da/da_setup_structures - da/da_ships - da/da_sound - da/da_spectral - da/da_ssmi - da/da_statistics - da/da_synop - da/da_tamdar - da/da_test - da/da_tools - da/da_tracing - da/da_transfer_model - da/da_update_bc - da/da_varbc - da/da_varbc_tamdar - da/da_vtox_transforms - da/da_wavelet - # blas and lapack external/blas external/lapack @@ -194,3 +60,8 @@ set_source_files_properties( PROPERTIES COMPILE_OPTIONS_Fortran_PRECISION "" # set to nothing to void ) + +# Add da/da* and gen_be executables dir +add_subdirectory( da ) +add_subdirectory( gen_be ) + diff --git a/var/da/CMakeLists.txt b/var/da/CMakeLists.txt new file mode 100644 index 0000000000..ed3ebf839e --- /dev/null +++ b/var/da/CMakeLists.txt @@ -0,0 +1,263 @@ + +# To somewhat mirror the DA build (and for "neatness") I won't put cmake files +# in each source folder and instead build at this level + +target_sources( + ${PROJECT_NAME}_Core + PRIVATE + da_4dvar/da_4dvar.f90 + da_airep/da_airep.f90 + da_airsr/da_airsr.f90 + da_bogus/da_bogus.f90 + da_buoy/da_buoy.f90 + da_chem_sfc/da_chem_sfc.f90 + # This is not in the original da lib, but I don't see how that + # isn't correct as many modules in this require it + da_control/da_control.f90 + + + da_define_structures/da_define_structures.f90 + da_dynamics/da_dynamics.f90 + da_ffts/da_ffts.f90 + da_ffts/module_ffts.f90 + da_geoamv/da_geoamv.f90 + da_gpseph/da_gpseph.f90 + da_gpspw/da_gpspw.f90 + da_gpsref/da_gpsref.f90 + da_grid_definitions/da_grid_definitions.f90 + da_interpolation/da_interpolation.f90 + da_lightning/da_lightning.f90 + da_main/copyfile.c + da_main/da_wrfvar_io.f90 + da_main/da_wrfvar_top.f90 + da_metar/da_metar.f90 + da_minimisation/da_minimisation.f90 + da_mtgirs/da_mtgirs.f90 + da_obs_io/da_join_iv_for_multi_inc.c + da_obs_io/da_obs_io.f90 + da_obs/da_obs.f90 + da_par_util/da_par_util.f90 + da_par_util/da_par_util1.f90 + da_physics/da_physics.f90 + da_physics/f_qv_from_rh.f90 + da_pilot/da_pilot.f90 + da_polaramv/da_polaramv.f90 + da_profiler/da_profiler.f90 + da_pseudo/da_pseudo.f90 + da_qscat/da_qscat.f90 + da_radar/da_radar.f90 + da_radiance/amsr2time_.c + da_radiance/da_crtm.f90 + da_radiance/da_radiance.f90 + da_radiance/da_radiance1.f90 + da_radiance/da_rttov.f90 + da_radiance/gsi_constants.f90 + da_radiance/gsi_kinds.f90 + da_radiance/gsi_thinning.f90 + da_radiance/mod_clddet_geoir.f90 + da_radiance/module_radiance.f90 + da_rain/da_rain.f90 + da_recursive_filter/da_mat_cv3.f90 + da_recursive_filter/da_recursive_filter.f90 + da_recursive_filter/da_rf_cv3.f90 + da_recursive_filter/da_rfz_cv3.f90 + da_reporting/da_reporting.f90 + da_satem/da_satem.f90 + da_setup_structures/da_setup_structures.f90 + da_ships/da_ships.f90 + da_sound/da_sound.f90 + da_spectral/da_spectral.f90 + da_ssmi/da_ssmi.f90 + da_ssmi/module_ssmi.f90 + da_statistics/da_statistics.f90 + da_synop/da_synop.f90 + da_tamdar/da_tamdar.f90 + da_test/da_test.f90 + da_tools/da_rsl_interfaces.f90 + da_tools/da_tools_serial.f90 + da_tools/da_tools.f90 + da_tools/da_wrf_interfaces.f90 + da_tools/gamma1.f90 + da_tracing/da_memory.c + da_tracing/da_tracing.f90 + da_transfer_model/da_transfer_model.f90 + da_update_bc/da_netcdf_interface.f90 + da_varbc_tamdar/da_varbc_tamdar.f90 + da_varbc/da_varbc.f90 + da_vtox_transforms/da_vtox_transforms.f90 + da_wavelet/da_wavelet.f90 + # For da_bias_* + da_biascorr_airmass/rad_bias.f90 + + ) + + +target_include_directories( + ${PROJECT_NAME}_Core + PRIVATE + da_4dvar + da_airep + da_airsr + da_bogus + da_buoy + da_chem_sfc + da_define_structures + da_dynamics + da_etkf + da_ffts + da_gen_be + da_geoamv + da_gpseph + da_gpspw + da_gpsref + da_grid_definitions + da_interpolation + da_lightning + da_main + da_metar + da_minimisation + da_mtgirs + da_obs + da_obs_io + da_par_util + da_physics + da_pilot + da_polaramv + da_profiler + da_pseudo + da_qscat + da_radar + da_radiance + da_rain + da_recursive_filter + da_reporting + da_satem + da_setup_structures + da_ships + da_sound + da_spectral + da_ssmi + da_statistics + da_synop + da_tamdar + da_test + da_tools + da_tracing + da_transfer_model + da_update_bc + da_varbc + da_varbc_tamdar + da_vtox_transforms + da_wavelet + ) + +# DA util executables +set( DA_EXECUTABLES ) +add_executable( da_tune_obs_hollingsworth1 da_util/da_tune_obs_hollingsworth1.f90 ) +list( APPEND DA_EXECUTABLES da_tune_obs_hollingsworth1 ) + + +add_executable( da_tune_obs_hollingsworth2 da_util/da_tune_obs_hollingsworth2.f90 ) +list( APPEND DA_EXECUTABLES da_tune_obs_hollingsworth2 ) + + +add_executable( da_tune_obs_desroziers da_util/da_tune_obs_desroziers.f90 ) +list( APPEND DA_EXECUTABLES da_tune_obs_desroziers ) + + +add_executable( da_update_bc + da_update_bc/da_update_bc.f90 + da_update_bc/da_module_couple_uv.f90 + ) +target_include_directories( da_update_bc PRIVATE da_update_bc ) +list( APPEND DA_EXECUTABLES da_update_bc ) + + +add_executable( da_update_bc_ad + da_update_bc/da_update_bc_ad.f90 + da_update_bc/da_module_couple_uv.f90 + da_update_bc/da_module_couple_uv_ad.f90 + ) +target_include_directories( da_update_bc_ad PRIVATE da_update_bc ) +list( APPEND DA_EXECUTABLES da_update_bc_ad ) + + +add_executable( da_advance_time da_util/da_advance_time.f90 ) +list( APPEND DA_EXECUTABLES da_advance_time ) + + +add_executable( da_verif_obs + da_verif_obs/da_verif_obs.f90 + da_verif_obs/da_verif_obs_control.f90 + da_verif_obs/da_verif_obs_init.f90 + da_verif_obs/da_verif_tools.f90 + ) +list( APPEND DA_EXECUTABLES da_verif_obs ) + + + +add_executable( da_verif_grid + da_verif_grid/da_verif_grid.f90 + da_verif_grid/da_verif_grid_control.f90 + ) +list( APPEND DA_EXECUTABLES da_verif_grid ) + + + +add_executable( da_bias_airmass + da_biascorr_airmass/da_bias_airmass.f90 + da_biascorr_airmass/pythag.f90 + da_biascorr_airmass/tqli.f90 + da_biascorr_airmass/tred2.f90 + da_biascorr_airmass/regress_one.f90 + ) +list( APPEND DA_EXECUTABLES da_bias_airmass ) + + + +add_executable( da_bias_sele da_biascorr_airmass/da_bias_sele.f90 ) +list( APPEND DA_EXECUTABLES da_bias_sele ) + + +add_executable( da_bias_scan da_biascorr_airmass/da_bias_scan.f90 ) +list( APPEND DA_EXECUTABLES da_bias_scan ) + + +add_executable( da_bias_verif da_biascorr_airmass/da_bias_verif.f90 ) +list( APPEND DA_EXECUTABLES da_bias_verif ) + + +add_executable( da_rad_diags da_monitor/da_rad_diags.f90 ) +list( APPEND DA_EXECUTABLES da_rad_diags ) + +# Now finally da_wrfvar +add_executable( da_wrfvar da_main/da_wrfvar_main.f90 ) +list( APPEND DA_EXECUTABLES da_wrfvar ) + +foreach( DA_EXEC ${DA_EXECUTABLES} ) + target_link_libraries( + ${DA_EXEC} + PRIVATE + ${PROJECT_NAME}_Core + $<$:$> + $<$:$> + ) + target_link_options ( ${DA_EXEC} PRIVATE ${WRF_LINK_FLAGS} ) + target_compile_definitions( ${DA_EXEC} PRIVATE ${PROJECT_COMPILE_DEFINITIONS} ) + target_compile_options ( ${DA_EXEC} PRIVATE ${PROJECT_COMPILE_OPTIONS} ) + +endforeach() + +install( + TARGETS ${DA_EXECUTABLES} + EXPORT ${EXPORT_NAME}Targets + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) + +wrf_setup_targets( + TARGETS ${DA_EXECUTABLES} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/run + USE_SYMLINKS + ) diff --git a/var/gen_be/CMakeLists.txt b/var/gen_be/CMakeLists.txt new file mode 100644 index 0000000000..d232f06170 --- /dev/null +++ b/var/gen_be/CMakeLists.txt @@ -0,0 +1,63 @@ +set( + GEN_BE_EXECUTABLES + gen_be_stage0_wrf + gen_be_stage0_gsi + gen_be_ep1 + gen_be_ep2 + gen_be_stage1 + gen_be_vertloc + gen_be_addmean + gen_be_stage1_gsi + gen_be_stage1_1dvar + gen_be_stage2 + gen_be_stage2_gsi + gen_mbe_stage2 + gen_be_stage2_1dvar + gen_be_stage2a + gen_be_stage3 + gen_be_stage4_global + gen_be_stage4_regional + gen_be_cov2d + gen_be_cov3d + gen_be_cov3d3d_bin3d_contrib + gen_be_cov3d3d_contrib + gen_be_cov2d3d_contrib + gen_be_cov3d2d_contrib + gen_be_diags + gen_be_diags_read + gen_be_hist + gen_be_ensrf + gen_be_etkf + gen_be_ensmean + ) + +foreach( GEN_BE ${GEN_BE_EXECUTABLES} ) + add_executable( ${GEN_BE} ${GEN_BE}.f90 ) + target_link_libraries( + ${GEN_BE} + PRIVATE + ${PROJECT_NAME}_Core + $<$:$> + $<$:$> + ) + target_link_options ( ${GEN_BE} PRIVATE ${WRF_LINK_FLAGS} ) + target_compile_definitions( ${GEN_BE} PRIVATE ${PROJECT_COMPILE_DEFINITIONS} ) + target_compile_options ( ${GEN_BE} PRIVATE ${PROJECT_COMPILE_OPTIONS} ) + +endforeach() + + +install( + TARGETS ${GEN_BE_EXECUTABLES} + EXPORT ${EXPORT_NAME}Targets + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) + +wrf_setup_targets( + TARGETS ${GEN_BE_EXECUTABLES} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/run + USE_SYMLINKS + ) + From 9ddaf993b4b54a334566ee7f260514533a66f256 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 5 Aug 2024 14:21:24 -0700 Subject: [PATCH 37/42] Actually these do go into da --- frame/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frame/CMakeLists.txt b/frame/CMakeLists.txt index a55d27f56c..abbf74b5b8 100644 --- a/frame/CMakeLists.txt +++ b/frame/CMakeLists.txt @@ -99,9 +99,7 @@ set( module_clear_halos.F module_comm_nesting_dm.F module_integrate.F - module_quilt_outbuf_ops.F module_sm.F - pack_utils.c ) if ( ${WRF_CORE} STREQUAL "DA" OR ${WRF_CORE} STREQUAL "DA_4D_VAR" ) @@ -159,6 +157,9 @@ target_sources( wrf_num_bytes_between.c wrf_shutdown.F + pack_utils.c + module_quilt_outbuf_ops.F + ${NON_DA_SOURCES} ) From 72d10d5b3e8badd5ef082915c5132de607f3603c Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 5 Aug 2024 14:22:04 -0700 Subject: [PATCH 38/42] Missing sources from DA folder compiltation --- var/da/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/var/da/CMakeLists.txt b/var/da/CMakeLists.txt index ed3ebf839e..c0f601574e 100644 --- a/var/da/CMakeLists.txt +++ b/var/da/CMakeLists.txt @@ -67,6 +67,7 @@ target_sources( da_ships/da_ships.f90 da_sound/da_sound.f90 da_spectral/da_spectral.f90 + da_spectral/da_be_spectral.f90 da_ssmi/da_ssmi.f90 da_ssmi/module_ssmi.f90 da_statistics/da_statistics.f90 @@ -89,6 +90,10 @@ target_sources( # For da_bias_* da_biascorr_airmass/rad_bias.f90 + # for gen_be + da_gen_be/da_gen_be.f90 + da_etkf/da_etkf.f90 + ) From 95440c1d8ed7df80aed3cef488ada5c13f5e9f16 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 5 Aug 2024 14:22:34 -0700 Subject: [PATCH 39/42] Wavelet compilation kinda working --- var/external/wavelet/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/var/external/wavelet/CMakeLists.txt b/var/external/wavelet/CMakeLists.txt index c240cb016a..bb7be2fe33 100644 --- a/var/external/wavelet/CMakeLists.txt +++ b/var/external/wavelet/CMakeLists.txt @@ -42,12 +42,12 @@ target_include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/awaprogs/chap05 ) -target_compile_definitions( - ${FOLDER_COMPILE_TARGET} - PRIVATE - ${PROJECT_COMPILE_DEFINITIONS} - NOUNDERSCORE - ) +# target_compile_definitions( +# ${FOLDER_COMPILE_TARGET} +# PRIVATE +# ${PROJECT_COMPILE_DEFINITIONS} +# NOUNDERSCORE +# ) # This is new in the cmake build target_compile_options( ${FOLDER_COMPILE_TARGET} From edc554c5499cc9e51cc1974948204512027fd4f8 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 5 Aug 2024 14:23:04 -0700 Subject: [PATCH 40/42] Make sure dest exists before install commands --- cmake/wrf_case_setup.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/wrf_case_setup.cmake b/cmake/wrf_case_setup.cmake index 4e65dc0a72..0c09ec8cd4 100644 --- a/cmake/wrf_case_setup.cmake +++ b/cmake/wrf_case_setup.cmake @@ -15,6 +15,10 @@ macro( wrf_setup_targets ) set( WRF_SETUP_CMD create_symlink ) endif() + if ( NOT EXISTS ${WRF_SETUP_DEST_PATH} ) + file( MAKE_DIRECTORY ${WRF_SETUP_DEST_PATH} ) + endif() + foreach ( WRF_SETUP_TARGET ${WRF_SETUP_TARGETS} ) From fbd93c04dd80713b694ed304f72d80f21e2d2d2e Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 5 Aug 2024 18:57:01 -0700 Subject: [PATCH 41/42] Let underscore def come from confcheck --- var/external/wavelet/CMakeLists.txt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/var/external/wavelet/CMakeLists.txt b/var/external/wavelet/CMakeLists.txt index bb7be2fe33..62a88d9076 100644 --- a/var/external/wavelet/CMakeLists.txt +++ b/var/external/wavelet/CMakeLists.txt @@ -42,20 +42,19 @@ target_include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/awaprogs/chap05 ) -# target_compile_definitions( -# ${FOLDER_COMPILE_TARGET} -# PRIVATE -# ${PROJECT_COMPILE_DEFINITIONS} -# NOUNDERSCORE -# ) # This is new in the cmake build target_compile_options( ${FOLDER_COMPILE_TARGET} PRIVATE ${PROJECT_COMPILE_OPTIONS_OPTIMIZATION} - ) +target_compile_definitions( + ${FOLDER_COMPILE_TARGET} + PRIVATE + ${PROJECT_COMPILE_DEFINITIONS_CONFCHECK} + ) + install( TARGETS ${FOLDER_COMPILE_TARGET} ${FOLDER_COMPILE_TARGET}f EXPORT ${EXPORT_NAME}Targets From 11ee92fb72eaade74c07d36a49d3d9aae28b4dd3 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 5 Aug 2024 19:25:23 -0700 Subject: [PATCH 42/42] Place module files in separate locations for da execs --- var/da/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/var/da/CMakeLists.txt b/var/da/CMakeLists.txt index c0f601574e..cf714ca3e7 100644 --- a/var/da/CMakeLists.txt +++ b/var/da/CMakeLists.txt @@ -251,6 +251,13 @@ foreach( DA_EXEC ${DA_EXECUTABLES} ) target_compile_definitions( ${DA_EXEC} PRIVATE ${PROJECT_COMPILE_DEFINITIONS} ) target_compile_options ( ${DA_EXEC} PRIVATE ${PROJECT_COMPILE_OPTIONS} ) + set_target_properties( + ${DA_EXEC} + PROPERTIES + # Just dump everything in here + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/modules/${DA_EXEC}/ + ) + endforeach() install(