From 8f5bc5370f68f2ca10fa6a2fc5ecba03dfb4cc95 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 4 May 2023 11:38:33 -0600 Subject: [PATCH 001/180] Modifying #ifdef structure for cmake syntax --- external/atm_ocn/cmpcomm.F | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/atm_ocn/cmpcomm.F b/external/atm_ocn/cmpcomm.F index a78e285337..89cd554e1c 100644 --- a/external/atm_ocn/cmpcomm.F +++ b/external/atm_ocn/cmpcomm.F @@ -1,4 +1,4 @@ -#if defined( DM_PARALLEL ) +#ifdef DM_PARALLEL MODULE CMP_COMM implicit none From 4cee02d51c569d4267ad564f014cf0a926d6e472 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 4 May 2023 11:39:04 -0600 Subject: [PATCH 002/180] Modifying #ifdef structure for cmake syntax --- frame/module_configure.F | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frame/module_configure.F b/frame/module_configure.F index 4e0ae808c3..8554a7d92a 100644 --- a/frame/module_configure.F +++ b/frame/module_configure.F @@ -15,7 +15,8 @@ SUBROUTINE init_module_scalar_tables END SUBROUTINE init_module_scalar_tables END MODULE module_scalar_tables -#if( WRF_CHEM == 1 && WRF_KPP == 1 ) +#ifdef WRF_CHEM +#ifdef WRF_KPP MODULE module_irr_diag INTEGER, parameter :: max_eqn = 1200 @@ -45,6 +46,7 @@ END SUBROUTINE init_module_irr_diag END MODULE module_irr_diag #endif +#endif MODULE module_configure From ae7e64715ca70808298a22482c64ace5d9cb82fa Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 4 May 2023 11:40:50 -0600 Subject: [PATCH 003/180] Ignoring _build directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index eca261d36e..c47fe3e850 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ configure.wrf* *.backup *.f90 +_build/ \ No newline at end of file From a7ce2821c1aa746cbb1595a9f119cd88ddcefaba Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 4 May 2023 11:41:27 -0600 Subject: [PATCH 004/180] Adding some helper cmake modules --- cmake/modules/FindnetCDF.cmake | 55 ++++++++++++++++++ cmake/preproc.cmake | 101 +++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 cmake/modules/FindnetCDF.cmake create mode 100644 cmake/preproc.cmake diff --git a/cmake/modules/FindnetCDF.cmake b/cmake/modules/FindnetCDF.cmake new file mode 100644 index 0000000000..02fae6f443 --- /dev/null +++ b/cmake/modules/FindnetCDF.cmake @@ -0,0 +1,55 @@ +# Find netcdf +# Eventually replace with netCDF's actual config if using that +# Once found this file will define: +# netCDF_FOUND - System has netcdf +# netCDF_INCLUDE_DIRS - The netcdf include directories +# netCDF_LIBRARIES - The libraries needed to use netcdf +# netCDF_DEFINITIONS - Compiler switches required for using netcdf + +# list( REMOVE_ITEM CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} ) +# find_package( netCDF ) +# list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} ) + +# Use nc-config +execute_process( COMMAND nc-config --includedir OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_INCLUDE_DIR ) +execute_process( COMMAND nc-config --libs OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_CLIBS ) +execute_process( COMMAND nc-config --cxx4libs OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_CXXLIBS ) +execute_process( COMMAND nc-config --flibs OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_FLIBS ) +execute_process( COMMAND nc-config --version OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_VERSION_RAW ) +execute_process( COMMAND nc-config --has-nc4 OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_NC4_YES ) +execute_process( COMMAND nc-config --has-pnetcdf OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_PNETCDF_YES ) + +# Sanitize version +string( REPLACE " " ";" netCDF_VERSION_LIST ${netCDF_VERSION_RAW} ) +list( GET netCDF_VERSION_LIST -1 netCDF_VERSION ) + +# Convert yes/no to 0/1 bool +set( netCDF_NC4 $ ) +set( netCDF_PNETCDF $ ) + + +find_package( PkgConfig ) +set( netCDF_DEFINITIONS ) + + + +include(FindPackageHandleStandardArgs) + +# handle the QUIETLY and REQUIRED arguments and set netCDF_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args( netCDF DEFAULT_MSG + netCDF_INCLUDE_DIR + netCDF_CLIBS + netCDF_CXXLIBS + netCDF_FLIBS + netCDF_VERSION + ) + +mark_as_advanced( netCDF_INCLUDE_DIR netCDF_CLIBS netCDF_CXXLIBS netCDF_FLIBS ) + +set( netCDF_LIBRARIES + $<$:${netCDF_CLIBS}> + $<$:${netCDF_CXXLIBS}> + $<$:${netCDF_FLIBS}> + ) +set( netCDF_INCLUDE_DIRS ${netCDF_INCLUDE_DIR} ) diff --git a/cmake/preproc.cmake b/cmake/preproc.cmake new file mode 100644 index 0000000000..2510f59175 --- /dev/null +++ b/cmake/preproc.cmake @@ -0,0 +1,101 @@ +# WRF Macro for preprocessing F files that are just... bad ifdef usage to say the least +macro( wrf_preproc_fortran ) + + set( options ) + set( oneValueArgs TARGET_NAME SUFFIX PREFIX EXTENSION OUTPUT_DIR ) + set( multiValueArgs DEPENDENCIES INCLUDE_DIRECTORIES SOURCES DEFINITIONS GENERATED_SCOPE ) + + cmake_parse_arguments( + WRF_PP_F + "${options}" "${oneValueArgs}" "${multiValueArgs}" + ${ARGN} + ) + #!TODO Verify -o/-I/-E/-D are all compiler independent flags + + # Santitize input + if ( DEFINED WRF_PP_F_GENERATED_SCOPE ) + set( WRF_PP_F_TARGET_DIRECTORY TARGET_DIRECTORY ${WRF_PP_F_GENERATED_SCOPE} ) + endif() + + set( WRF_PP_F_INCLUDES ) + foreach( WRF_PP_F_INC ${WRF_PP_F_INCLUDE_DIRECTORIES} ) + list( APPEND WRF_PP_F_INCLUDES -I${WRF_PP_F_INC} ) + endforeach() + + set( WRF_PP_F_DEFS ) + foreach( WRF_PP_F_DEF ${WRF_PP_F_DEFINITIONS} ) + if ( NOT ${WRF_PP_F_DEF} MATCHES ".*-D.*" ) + # We have a generator expression, inject the -D correctly + if ( ${WRF_PP_F_DEF} MATCHES "^[$]<" ) + # Take advantage of the fact that the first time a generator expression ends to finally + # name the define it has the first ">:" then unexpanded characters (hopefully) + # 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_PP_F_DEF_SANITIZED ${WRF_PP_F_DEF} ) + list( APPEND WRF_PP_F_DEFS ${WRF_PP_F_DEF_SANITIZED} ) + else() + list( APPEND WRF_PP_F_DEFS -D${WRF_PP_F_DEF} ) + endif() + endif() + + endforeach() + + + # Generate compile command and file outputs + set( WRF_PP_F_OUTPUT ) + set( WRF_PP_F_COMMANDS ) + foreach( WRF_PP_F_SOURCE_FILE ${WRF_PP_F_SOURCES} ) + if ( ${WRF_PP_F_EXTENSION} MATCHES "^[.][a-z0-9]+$" ) + string( REGEX REPLACE "[.].*$" "${WRF_PP_F_EXTENSION}" WRF_PP_F_OUTPUT_FILE ${WRF_PP_F_SOURCE_FILE} ) + else() + # Default extension + string( REGEX REPLACE "[.].*$" ".i" WRF_PP_F_OUTPUT_FILE ${WRF_PP_F_SOURCE_FILE} ) + endif() + + set( WRF_PP_F_OUTPUT_FILE ${WRF_PP_F_OUTPUT_DIR}/${WRF_PP_F_PREFIX}${WRF_PP_F_OUTPUT_FILE}${WRF_PP_F_SUFFIX} ) + get_filename_component( WRF_PP_F_INPUT_SOURCE ${WRF_PP_F_SOURCE_FILE} REALPATH ) + + list( + APPEND WRF_PP_F_COMMANDS + COMMAND ${CMAKE_Fortran_COMPILER} -E ${WRF_PP_F_INPUT_SOURCE} ${WRF_PP_F_DEFS} ${WRF_PP_F_INCLUDES} > ${WRF_PP_F_OUTPUT_FILE} + # Force check that they were made + COMMAND ${CMAKE_COMMAND} -E compare_files ${WRF_PP_F_OUTPUT_FILE} ${WRF_PP_F_OUTPUT_FILE} + ) + list( + APPEND WRF_PP_F_OUTPUT + ${WRF_PP_F_OUTPUT_FILE} + ) + + # # Tell all targets that eventually use this file that it is generated - this is useful if this macro is used in a + # # different directory than where the target dependency is set + # # Thanks to https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-add-a-dependency-to-a-source-file-which-is-generated-in-a-subdirectory + # # and https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/ + # # It keeps getting better lol + # # https://gitlab.kitware.com/cmake/cmake/-/issues/18399 + # # We could use cmake 3.20+ and CMP0118, but this allows usage from 3.18.6+ + # TL;DR - This doesn't work despite all documentation stating otherwise, need to use CMP0118 + # set_source_files_properties( + # ${WRF_PP_F_OUTPUT_FILE} + # ${WRF_PP_F_TARGET_DIRECTORY} + # PROPERTIES + # GENERATED TRUE + # ) + + message( STATUS "File ${WRF_PP_F_SOURCE_FILE} will be preprocessed into ${WRF_PP_F_OUTPUT_FILE}" ) + + endforeach() + + # Preprocess sources into a custom target + add_custom_command( + OUTPUT ${WRF_PP_F_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E make_directory ${WRF_PP_F_OUTPUT_DIR} + ${WRF_PP_F_COMMANDS} + COMMENT "Preprocessing ${WRF_PP_F_TARGET_NAME}" + DEPENDS ${WRF_PP_F_DEPENDENCIES} + ) + + add_custom_target( + ${WRF_PP_F_TARGET_NAME} + DEPENDS ${WRF_PP_F_OUTPUT} + ) + +endmacro() \ No newline at end of file From 2dd8305d5dd142d43dda97ee57e0e068a376ce1e Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 4 May 2023 11:42:10 -0600 Subject: [PATCH 005/180] Fairly confident this was a bug --- tools/gen_allocs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/gen_allocs.c b/tools/gen_allocs.c index c7e7953257..abafbcb893 100644 --- a/tools/gen_allocs.c +++ b/tools/gen_allocs.c @@ -659,7 +659,7 @@ gen_dealloc2 ( FILE * fp , char * structname , node_t * node ) fprintf(fp, " DEALLOCATE(%s%s,STAT=ierr)\n if (ierr.ne.0) then\n CALL wrf_error_fatal ( &\n'frame/module_domain.f: Failed to deallocate %s%s. ')\n endif\n", structname, fname, structname, fname ) ; -#ifdef USE_ALLOCATABLES +#ifndef USE_ALLOCATABLES fprintf(fp, " NULLIFY(%s%s)\n",structname, fname ) ; #endif From a254e827fbf37e66e37a6766f4ddf227975dabf5 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 4 May 2023 11:42:41 -0600 Subject: [PATCH 006/180] Adding nonzero macro check for function returns rather than failing silently --- tools/registry.c | 75 +++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/tools/registry.c b/tools/registry.c index 79f7983ed7..937cef5a18 100644 --- a/tools/registry.c +++ b/tools/registry.c @@ -18,6 +18,9 @@ #include "data.h" #include "sym.h" +// Helper macro to actually do return checks +#define NON_ZERO_RETURN( A ) { int result = A; if ( result != 0 ) { printf( "Error in %s, non-zero return expected", #A ); exit(result); } } + /* SamT: bug fix: main returns int */ int main( int argc, char *argv[], char *env[] ) @@ -132,11 +135,11 @@ main( int argc, char *argv[], char *env[] ) argv++ ; } - gen_io_boilerplate() ; /* 20091213 jm. Generate the io_boilerplate_temporary.inc file */ + NON_ZERO_RETURN( gen_io_boilerplate() ); /* 20091213 jm. Generate the io_boilerplate_temporary.inc file */ - init_parser() ; - init_type_table() ; - init_dim_table() ; + NON_ZERO_RETURN( init_parser() ); + NON_ZERO_RETURN( init_type_table() ); + NON_ZERO_RETURN( init_dim_table() ); // // possible IRR diagnostcis? // @@ -230,45 +233,45 @@ main( int argc, char *argv[], char *env[] ) } - reg_parse(fp_tmp) ; + NON_ZERO_RETURN( reg_parse(fp_tmp) ); fclose(fp_tmp) ; - check_dimspecs() ; + NON_ZERO_RETURN( check_dimspecs() ); - gen_state_struct( "inc" ) ; - gen_state_subtypes( "inc" ) ; - gen_alloc( "inc" ) ; + NON_ZERO_RETURN( gen_state_struct( "inc" ) ); + NON_ZERO_RETURN( gen_state_subtypes( "inc" ) ); + NON_ZERO_RETURN( gen_alloc( "inc" ) ); /* gen_alloc_count( "inc" ) ; */ - gen_dealloc( "inc" ) ; - gen_scalar_indices( "inc" ) ; - gen_module_state_description( "frame" ) ; - gen_actual_args( "inc" ) ; - gen_actual_args_new( "inc" ) ; - gen_dummy_args( "inc" ) ; - gen_dummy_args_new( "inc" ) ; - gen_dummy_decls( "inc" ) ; - gen_dummy_decls_new( "inc" ) ; - gen_i1_decls( "inc" ) ; - gen_namelist_statements("inc") ; - gen_namelist_defines ( "inc", 0 ) ; /* without dimension statements */ - gen_namelist_defines ( "inc", 1 ) ; /* with dimension statements */ - gen_namelist_defaults ( "inc" ) ; - gen_namelist_script ( "inc" ) ; - gen_get_nl_config( "inc" ) ; - gen_config_assigns( "inc" ) ; - gen_config_reads( "inc" ) ; - gen_wrf_io( "inc" ) ; - gen_model_data_ord( "inc" ) ; - gen_nest_interp( "inc" ) ; - gen_nest_v_interp( "inc") ; /*KAL added this for vertical interpolation*/ - gen_scalar_derefs( "inc" ) ; - gen_streams("inc") ; + NON_ZERO_RETURN( gen_dealloc( "inc" ) ) ; + NON_ZERO_RETURN( gen_scalar_indices( "inc" ) ) ; + NON_ZERO_RETURN( gen_module_state_description( "frame" ) ) ; + NON_ZERO_RETURN( gen_actual_args( "inc" ) ) ; + NON_ZERO_RETURN( gen_actual_args_new( "inc" ) ) ; + NON_ZERO_RETURN( gen_dummy_args( "inc" ) ) ; + NON_ZERO_RETURN( gen_dummy_args_new( "inc" ) ) ; + NON_ZERO_RETURN( gen_dummy_decls( "inc" ) ) ; + NON_ZERO_RETURN( gen_dummy_decls_new( "inc" ) ) ; + NON_ZERO_RETURN( gen_i1_decls( "inc" ) ) ; + NON_ZERO_RETURN( gen_namelist_statements("inc") ; ) + NON_ZERO_RETURN( gen_namelist_defines ( "inc", 0 ) ) ; /* without dimension statements */ + NON_ZERO_RETURN( gen_namelist_defines ( "inc", 1 ) ) ; /* with dimension statements */ + NON_ZERO_RETURN( gen_namelist_defaults ( "inc" ) ) ; + NON_ZERO_RETURN( gen_namelist_script ( "inc" ) ) ; + NON_ZERO_RETURN( gen_get_nl_config( "inc" ) ) ; + NON_ZERO_RETURN( gen_config_assigns( "inc" ) ) ; + NON_ZERO_RETURN( gen_config_reads( "inc" ) ) ; + NON_ZERO_RETURN( gen_wrf_io( "inc" ) ) ; + NON_ZERO_RETURN( gen_model_data_ord( "inc" ) ) ; + NON_ZERO_RETURN( gen_nest_interp( "inc" ) ) ; + NON_ZERO_RETURN( gen_nest_v_interp( "inc") ; ) /*KAL added this for vertical interpolation*/ + NON_ZERO_RETURN( gen_scalar_derefs( "inc" ) ) ; + NON_ZERO_RETURN( gen_streams("inc") ; ) /* this has to happen after gen_nest_interp, which adds halos to the AST */ - gen_comms( "inc" ) ; /* this is either package supplied (by copying a */ - /* gen_comms.c file into this directory) or a */ - /* stubs routine. */ + NON_ZERO_RETURN( gen_comms( "inc" ) ); /* this is either package supplied (by copying a */ + /* gen_comms.c file into this directory) or a */ + /* stubs routine. */ cleanup: #ifdef _WIN32 From ed596dd2d3ca539e42fe3230ba9d19b488b1887a Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 4 May 2023 11:48:50 -0600 Subject: [PATCH 007/180] Current state of cmake build --- CMakeLists.txt | 297 +++++++++++++++ external/CMakeLists.txt | 29 ++ external/RSL_LITE/CMakeLists.txt | 49 +++ external/atm_ocn/CMakeLists.txt | 45 +++ external/esmf_time_f90/CMakeLists.txt | 60 +++ external/fftpack/fftpack5/CMakeLists.txt | 58 +++ external/io_adios2/CMakeLists.txt | 50 +++ external/io_esmf/CMakeLists.txt | 48 +++ external/io_grib1/CMakeLists.txt | 54 +++ external/io_grib1/MEL_grib1/CMakeLists.txt | 76 ++++ external/io_grib1/WGRIB/CMakeLists.txt | 77 ++++ external/io_grib1/grib1_util/CMakeLists.txt | 44 +++ external/io_grib2/CMakeLists.txt | 0 external/io_grib2/bacio-1.3/CMakeLists.txt | 41 ++ external/io_grib2/g2lib/CMakeLists.txt | 0 external/io_grib2/g2lib/utest/CMakeLists.txt | 0 external/io_grib_share/CMakeLists.txt | 45 +++ external/io_int/CMakeLists.txt | 0 external/io_netcdf/CMakeLists.txt | 0 external/io_netcdfpar/CMakeLists.txt | 0 external/io_phdf5/CMakeLists.txt | 0 external/io_pio/CMakeLists.txt | 0 external/io_pnetcdf/CMakeLists.txt | 0 external/ioapi_share/CMakeLists.txt | 0 frame/CMakeLists.txt | 278 ++++++++++++++ frame/module_dm.F | 376 +++++++++++++++++++ frame/nl_get_0_routines.F | 1 - frame/nl_get_1_routines.F | 1 - frame/nl_get_2_routines.F | 1 - frame/nl_get_3_routines.F | 1 - frame/nl_get_4_routines.F | 1 - frame/nl_get_5_routines.F | 1 - frame/nl_get_6_routines.F | 1 - frame/nl_get_7_routines.F | 1 - frame/nl_set_0_routines.F | 1 - frame/nl_set_1_routines.F | 1 - frame/nl_set_2_routines.F | 1 - frame/nl_set_3_routines.F | 1 - frame/nl_set_4_routines.F | 1 - frame/nl_set_5_routines.F | 1 - frame/nl_set_6_routines.F | 1 - frame/nl_set_7_routines.F | 1 - phys/CMakeLists.txt | 311 +++++++++++++++ share/CMakeLists.txt | 206 ++++++++++ tools/CMakeLists.txt | 129 +++++++ tools/CodeBase/CMakeLists.txt | 0 tools/gen_comms.c | 15 + 47 files changed, 2288 insertions(+), 16 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 external/CMakeLists.txt create mode 100644 external/RSL_LITE/CMakeLists.txt create mode 100644 external/atm_ocn/CMakeLists.txt create mode 100644 external/esmf_time_f90/CMakeLists.txt create mode 100644 external/fftpack/fftpack5/CMakeLists.txt create mode 100644 external/io_adios2/CMakeLists.txt create mode 100644 external/io_esmf/CMakeLists.txt create mode 100644 external/io_grib1/CMakeLists.txt create mode 100644 external/io_grib1/MEL_grib1/CMakeLists.txt create mode 100644 external/io_grib1/WGRIB/CMakeLists.txt create mode 100644 external/io_grib1/grib1_util/CMakeLists.txt create mode 100644 external/io_grib2/CMakeLists.txt create mode 100644 external/io_grib2/bacio-1.3/CMakeLists.txt create mode 100644 external/io_grib2/g2lib/CMakeLists.txt create mode 100644 external/io_grib2/g2lib/utest/CMakeLists.txt create mode 100644 external/io_grib_share/CMakeLists.txt create mode 100644 external/io_int/CMakeLists.txt create mode 100644 external/io_netcdf/CMakeLists.txt create mode 100644 external/io_netcdfpar/CMakeLists.txt create mode 100644 external/io_phdf5/CMakeLists.txt create mode 100644 external/io_pio/CMakeLists.txt create mode 100644 external/io_pnetcdf/CMakeLists.txt create mode 100644 external/ioapi_share/CMakeLists.txt create mode 100644 frame/CMakeLists.txt create mode 100644 frame/module_dm.F delete mode 100644 frame/nl_get_0_routines.F delete mode 100644 frame/nl_get_1_routines.F delete mode 100644 frame/nl_get_2_routines.F delete mode 100644 frame/nl_get_3_routines.F delete mode 100644 frame/nl_get_4_routines.F delete mode 100644 frame/nl_get_5_routines.F delete mode 100644 frame/nl_get_6_routines.F delete mode 100644 frame/nl_get_7_routines.F delete mode 100644 frame/nl_set_0_routines.F delete mode 100644 frame/nl_set_1_routines.F delete mode 100644 frame/nl_set_2_routines.F delete mode 100644 frame/nl_set_3_routines.F delete mode 100644 frame/nl_set_4_routines.F delete mode 100644 frame/nl_set_5_routines.F delete mode 100644 frame/nl_set_6_routines.F delete mode 100644 frame/nl_set_7_routines.F create mode 100644 phys/CMakeLists.txt create mode 100644 share/CMakeLists.txt create mode 100644 tools/CMakeLists.txt create mode 100644 tools/CodeBase/CMakeLists.txt create mode 100644 tools/gen_comms.c diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000..c75216b78d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,297 @@ +cmake_minimum_required( VERSION 3.20 ) +cmake_policy( SET CMP0118 NEW ) + +enable_language( C ) +enable_language( CXX ) +enable_language( Fortran ) + +project( WRF ) + +# list( APPEND CMAKE_MODULE_PATH ) +list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/ ${PROJECT_SOURCE_DIR}/cmake/modules ) + +# TODO rename to something better +include( preproc ) + + +################################################################################ +## +## Options that can be user configured +## +################################################################################ +set( CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/runTemp ) + +set( OPTIMIZATION_LEVEL "" ) +set( WRF_OS "" ) +set( WRF_MACH "" ) + +# Mode configuration +# DO NOT USE OPTION - IT DOES NOT WORK AS ANTICIPATED EVEN WHEN CLEARING CACHE - YOU HAVE BEEN WARNED +set( ENABLE_CHEM OFF CACHE BOOL "ENABLE_CHEM" ) +set( ENABLE_CMAQ OFF CACHE BOOL "ENABLE_CMAQ" ) +set( ENABLE_KPP OFF CACHE BOOL "ENABLE_KPP" ) +set( ENABLE_DFI_RADAR OFF CACHE BOOL "ENABLE_DFI_RADAR" ) +set( ENABLE_TITAN OFF CACHE BOOL "ENABLE_TITAN" ) +set( ENABLE_MARS OFF CACHE BOOL "ENABLE_MARS" ) +set( ENABLE_VENUS OFF CACHE BOOL "ENABLE_VENUS" ) +set( ENABLE_VENUS OFF CACHE BOOL "ENABLE_VENUS" ) +set( ENABLE_TERRAIN OFF CACHE BOOL "ENABLE_TERRAIN" ) + +# What do these defines even do if they are always on???? +set( USE_ALLOCATABLES ON CACHE BOOL "USE_ALLOCATABLES" ) +set( wrfmodel ON CACHE BOOL "wrfmodel" ) +set( GRIB1 ON CACHE BOOL "GRIB1" ) +set( INTIO ON CACHE BOOL "INTIO" ) +set( KEEP_INT_AROUND ON CACHE BOOL "KEEP_INT_AROUND" ) +set( LIMIT_ARGS ON CACHE BOOL "LIMIT_ARGS" ) + +set( BUILD_RRTMG_FAST OFF CACHE BOOL "BUILD_RRTMG_FAST" ) +set( BUILD_RRTMK OFF CACHE BOOL "BUILD_RRTMK" ) +set( BUILD_SBM_FAST ON CACHE BOOL "BUILD_SBM_FAST" ) +set( SHOW_ALL_VARS_USED OFF CACHE BOOL "SHOW_ALL_VARS_USED" ) +# Not cached, cannot be changed, do not touch +set( NMM_CORE OFF ) + +# WRF Core selection +set( WRF_CORE_OPTIONS + # Options listed here + ARW + COAMPS # Not sure how this is used + CONVERT # This exists in compile but not configure + DA + DA_4D_VAR + PLUS + ) + +# Set default WRF_CORE +set( WRF_CORE "" CACHE STRING "WRF_CORE" ) +list( GET WRF_CORE_OPTIONS 0 WRF_CORE ) + + + +option( USE_DOUBLE OFF ) # I believe this is the r8/real8 promotion +option( USE_MPI OFF ) +option( USE_OPENMP OFF ) + +# From arch/preamble +#### Single location for defining total number of domains. You need +#### at least 1 + 2*(number of total nests). For example, 1 coarse +#### grid + three fine grids = 1 + 2(3) = 7, so MAX_DOMAINS=7. +set( MAX_DOMAINS_F 21 ) + + +#### DM buffer length for the configuration flags. + +set( CONFIG_BUF_LEN 65536 ) + +#### Size of bitmasks (in 4byte integers) of stream masks for WRF I/O + +set( MAX_HISTORY 25 ) + +set( IWORDSIZE 4 ) +set( DWORDSIZE 8 ) +set( LWORDSIZE 4 ) +if ( USE_DOUBLE ) + set( RWORDSIZE 8 ) +else() + set( RWORDSIZE 4 ) +endif() + +######################## + +################################################################################ +## +## Load alternate OS/architecture to be compiled for if cross-compiling +## +################################################################################ +if ( ${WRF_OS} ) + # Need a good way of condensing this down + set( WRF_ARCH_FILE ${WRF_OS} ) + + set( CMAKE_TOOLCHAIN_FILE "" ) +endif() + + +# Check WRF options +if ( NOT ${WRF_CORE} IN_LIST WRF_CORE_OPTIONS ) + message( FATAL_ERROR "WRF Core option not recognized : ${WRF_CORE}" ) +endif() + +set( EM_CORE 1 ) +# Far easier to write this one as normal logic rather than generator expression +if( ${WRF_CORE} STREQUAL "CONVERT" OR ${WRF_CORE} STREQUAL "COAMPS" ) + set( EM_CORE 0 ) +endif() + +################################################################################ +## +## Now find packages that cross-compilation is potentially handled +## +################################################################################ +# Provided by cmake natively +find_package( ZLIB REQUIRED ) +find_package( CURL REQUIRED ) + +# HDF5 has some funky weirdness between versions where the casing has changed +find_package( HDF5 REQUIRED ) + +# Will need our own finder +# find_package( GPFS REQUIRED ) + +# Included is a lightweight finder, but we really should switch to using UniData's netCDF cmake config +find_package( netCDF REQUIRED ) + +# Make use of version checking here and not in find_package for previous versions that did not use cmake +if ( NOT netCDF_VERSION GREATER_EQUAL "4.1.3" ) + message( FATAL "Please make sure NETCDF version is 4.1.3 or later. " ) + +endif() + +if ( USE_MPI ) + find_package( MPI REQUIRED COMPONENTS Fortran ) + add_compile_definitions( USE_MPI=1 DM_PARALLEL=1 ) +endif() + +if ( USE_OPENMP ) + find_package( OpenMP REQUIRED COMPONENTS Fortran ) +endif() + +################################################################################ +## +## Adjust flags based on compiler and linker used +## +################################################################################ +# https://stackoverflow.com/a/53155812 +set( Fortran_COMPILER_ID ${CMAKE_Fortran_COMPILER_ID} ) +message( STATUS "Set Fortran_COMPILER_ID to : ${Fortran_COMPILER_ID}" ) + + +# Whole project flags +add_compile_options( + $<$:-cpp> + # Use "" and ; specifically to evaluate correctly + "$<$:-diag-disable;6843>" + + # $,$:-diag-disable;6843> + ) + +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} + # 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=$> + $<$:WRF_CMAQ=$> + $<$:WRF_KPP=$> + $<$:WRF_DFI_RADAR=$> + $<$:WRF_TITAN=$> + $<$:WRF_MARS=$> + $<$:WRF_VENUS=$> + + # Does this actually need to check for EM_CORE (Config.pl:443) + $<$>:LANDREAD_STUB=$>> + + + $<$: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=$ + EM_CORE=${EM_CORE} + WRFPLUS=$> + DA_CORE=$,$>> + # DFI_RADAR=$ + + ) + + +# add_custom_command( OUTPUT NONE_ENABLE_CHEM COMMAND ${CMAKE_COMMAND} -E echo "ENABLE_CHEM => $<$:WRF_CHEM=$> " ) +# add_custom_command( OUTPUT NONE_ENABLE_CMAQ COMMAND ${CMAKE_COMMAND} -E echo "ENABLE_CMAQ => $<$:WRF_CMAQ=$> " ) +# add_custom_command( OUTPUT NONE_ENABLE_KPP COMMAND ${CMAKE_COMMAND} -E echo "ENABLE_KPP => $<$:WRF_KPP=$> " ) +# add_custom_command( OUTPUT NONE_ENABLE_DFI_RADAR COMMAND ${CMAKE_COMMAND} -E echo "ENABLE_DFI_RADAR => $<$:WRF_DFI_RADAR=$> " ) +# add_custom_command( OUTPUT NONE_ENABLE_TITAN COMMAND ${CMAKE_COMMAND} -E echo "ENABLE_TITAN => $<$:WRF_TITAN=$> " ) +# add_custom_command( OUTPUT NONE_ENABLE_MARS COMMAND ${CMAKE_COMMAND} -E echo "ENABLE_MARS => $<$:WRF_MARS=$> " ) +# add_custom_command( OUTPUT NONE_ENABLE_VENUS COMMAND ${CMAKE_COMMAND} -E echo "ENABLE_VENUS => $<$:WRF_VENUS=$> " ) + +#!TODO Investigate if this is better than setting -cpp +set( CMAKE_Fortran_PREPROCESS ON ) + + +# Make core target +add_library( + ${PROJECT_NAME}_Core + STATIC + ) + +# Supplemental to core +add_subdirectory( external ) +add_subdirectory( tools ) + + +add_dependencies( + ${PROJECT_NAME}_Core + # So many things depend on this that I'm adding a dep here + registry_code + ) +target_include_directories( + ${PROJECT_NAME}_Core + PRIVATE + ${PROJECT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR}/inc + ${PROJECT_SOURCE_DIR}/dyn_em + ${PROJECT_SOURCE_DIR}/frame + + # externals + ${PROJECT_SOURCE_DIR}/external/io_grib_share + ${PROJECT_SOURCE_DIR}/external/io_netcdf + ${PROJECT_SOURCE_DIR}/external/io_int + ${PROJECT_SOURCE_DIR}/external/ioapi_share + $ + $ + + + ${CMAKE_BINARY_DIR}/inc + ${CMAKE_BINARY_DIR}/frame + ) + +# Add directly to core +add_subdirectory( phys ) +add_subdirectory( share ) +add_subdirectory( frame ) + +# Configure core +set_target_properties( + ${PROJECT_NAME}_Core + PROPERTIES + # Just dump everything in here + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/modules/ + Fortran_FORMAT FREE + ) + +target_link_libraries( ${PROJECT_NAME}_Core + PRIVATE + ${netCDF_LIBRARIES} + $<$:$> + $<$:$> + esmf_time_f90 + ) + +# target_include_directories( +# ${PROJECT_NAME}_Core +# PRIVATE + +# ) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt new file mode 100644 index 0000000000..0c9801e87b --- /dev/null +++ b/external/CMakeLists.txt @@ -0,0 +1,29 @@ +# WRF CMake Build +if ( AMT_OCN ) + # I have no clue how this gets used + add_subdirectory( atm_ocn ) +endif() + +if ( ADIOS2 ) + add_subdirectory( io_adios2 ) +endif() + +if ( ESMF ) + add_subdirectory( io_esmf ) +endif() + +add_subdirectory( esmf_time_f90 ) +add_subdirectory( io_pnetcdf ) +add_subdirectory( io_pio ) +add_subdirectory( io_int ) +add_subdirectory( io_netcdf ) +add_subdirectory( io_netcdfpar ) +add_subdirectory( io_phdf5 ) +add_subdirectory( io_grib1 ) +add_subdirectory( io_grib_share ) +add_subdirectory( io_grib2 ) + +add_subdirectory( ioapi_share ) +add_subdirectory( RSL_LITE ) +add_subdirectory( fftpack/fftpack5 ) + diff --git a/external/RSL_LITE/CMakeLists.txt b/external/RSL_LITE/CMakeLists.txt new file mode 100644 index 0000000000..0c3effc036 --- /dev/null +++ b/external/RSL_LITE/CMakeLists.txt @@ -0,0 +1,49 @@ +# WRF CMake Build + +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +add_library( + ${FOLDER_COMPILE_TARGET} + STATIC + ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + c_code.c + buf_for_proc.c + rsl_malloc.c + rsl_bcast.c + task_for_point.c + period.c + swap.c + cycle.c + f_pack.F90 + f_xpose.F90 + ) + +set_target_properties( + ${FOLDER_COMPILE_TARGET} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + ) + + +target_link_libraries( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_LIBRARIES} + $<$:$> + $<$:$> + ) + +target_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_INCLUDE_DIRS} + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) diff --git a/external/atm_ocn/CMakeLists.txt b/external/atm_ocn/CMakeLists.txt new file mode 100644 index 0000000000..3756c80111 --- /dev/null +++ b/external/atm_ocn/CMakeLists.txt @@ -0,0 +1,45 @@ +# WRF CMake Build + +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +add_library( + ${FOLDER_COMPILE_TARGET} + STATIC + ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + atm_comm.F + atm_tiles.F + cmpcomm.F + mpi_more.F + module_PATCH_QUILT.F + ) + +set_target_properties( + ${FOLDER_COMPILE_TARGET} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + Fortran_FORMAT FIXED + ) + + +target_link_libraries( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_LIBRARIES} + $<$:$> + $<$:$> + ) + +target_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_INCLUDE_DIRS} + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) diff --git a/external/esmf_time_f90/CMakeLists.txt b/external/esmf_time_f90/CMakeLists.txt new file mode 100644 index 0000000000..324c40e9bb --- /dev/null +++ b/external/esmf_time_f90/CMakeLists.txt @@ -0,0 +1,60 @@ +# WRF CMake Build +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +add_library( + ${FOLDER_COMPILE_TARGET} + STATIC + ) +# Test1_ESMF +# Test1_WRFU +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + ESMF_Alarm.F90 + ESMF_BaseTime.F90 + ESMF_Clock.F90 + ESMF_Time.F90 + Meat.F90 + ESMF_Base.F90 + ESMF_Calendar.F90 + ESMF_Fraction.F90 + ESMF_TimeInterval.F90 + ESMF_Stubs.F90 + ESMF_Mod.F90 + module_symbols_util.F90 + module_utility.F90 + ESMF_AlarmClock.F90 + ) + +# target_compile_options( +# ${FOLDER_COMPILE_TARGET} +# PRIVATE +# # Specific flags for this target +# ) + +set_target_properties( + ${FOLDER_COMPILE_TARGET} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + ) + + +target_link_libraries( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_LIBRARIES} + $<$:$> + $<$:$> + ) + +target_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_INCLUDE_DIRS} + ${CMAKE_CURRENT_LIST_DIR} + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) diff --git a/external/fftpack/fftpack5/CMakeLists.txt b/external/fftpack/fftpack5/CMakeLists.txt new file mode 100644 index 0000000000..4980398d07 --- /dev/null +++ b/external/fftpack/fftpack5/CMakeLists.txt @@ -0,0 +1,58 @@ +# WRF CMake Build + +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +add_library( + ${FOLDER_COMPILE_TARGET} + STATIC + ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + c1f2kb.F cfft1b.F cmf3kf.F cosqb1.F costmi.F dcosq1f.F dfftb1.F mradb2.F mrfti1.F r1fgkf.F rfft2i.F sinqmi.F z1f2kf.F zfft1f.F zmf4kb.F + c1f2kf.F cfft1f.F cmf4kb.F cosqf1.F d1f2kb.F dcosq1i.F dfftf1.F mradb3.F msntb1.F r4_factor.F rfftb1.F sint1b.F z1f3kb.F zfft1i.F zmf4kf.F + c1f3kb.F cfft1i.F cmf4kf.F cosqmb.F d1f2kf.F dcosqb1.F dffti1.F mradb4.F msntf1.F r4_mcfti1.F rfftf1.F sint1f.F z1f3kf.F zfft2b.F zmf5kb.F + c1f3kf.F cfft2b.F cmf5kb.F cosqmf.F d1f3kb.F dcosqf1.F dsint1b.F mradb5.F r1f2kb.F r4_tables.F rffti1.F sint1i.F z1f4kb.F zfft2f.F zmf5kf.F + c1f4kb.F cfft2f.F cmf5kf.F cosqmi.F d1f3kf.F dcost1b.F dsint1f.F mradbg.F r1f2kf.F r8_factor.F rfftmb.F sintb1.F z1f4kf.F zfft2i.F zmfgkb.F + c1f4kf.F cfft2i.F cmfgkb.F cost1b.F d1f4kb.F dcost1f.F dsint1i.F mradf2.F r1f3kb.F r8_mcfti1.F rfftmf.F sintf1.F z1f5kb.F zfftmb.F zmfgkf.F + c1f5kb.F cfftmb.F cmfgkf.F cost1f.F d1f4kf.F dcost1i.F dsintb1.F mradf3.F r1f3kf.F r8_tables.F rfftmi.F sintmb.F z1f5kf.F zfftmf.F zmfm1b.F + c1f5kf.F cfftmf.F cmfm1b.F cost1i.F d1f5kb.F dcostb1.F dsintf1.F mradf4.F r1f4kb.F rfft1b.F sinq1b.F sintmf.F z1fgkb.F zfftmi.F zmfm1f.F + c1fgkb.F cfftmi.F cmfm1f.F costb1.F d1f5kf.F dcostf1.F mcsqb1.F mradf5.F r1f4kf.F rfft1f.F sinq1f.F sintmi.F z1fgkf.F zmf2kb.F + c1fgkf.F cmf2kb.F cosq1b.F costf1.F d1fgkb.F dfft1b.F mcsqf1.F mradfg.F r1f5kb.F rfft1i.F sinq1i.F xercon.F z1fm1b.F zmf2kf.F + c1fm1b.F cmf2kf.F cosq1f.F costmb.F d1fgkf.F dfft1f.F mcstb1.F mrftb1.F r1f5kf.F rfft2b.F sinqmb.F xerfft.F z1fm1f.F zmf3kb.F + c1fm1f.F cmf3kb.F cosq1i.F costmf.F dcosq1b.F dfft1i.F mcstf1.F mrftf1.F r1fgkb.F rfft2f.F sinqmf.F z1f2kb.F zfft1b.F zmf3kf.F + ) + +set_target_properties( + ${FOLDER_COMPILE_TARGET} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + Fortran_FORMAT FREE + ) + +# target_compile_options( ${FOLDER_COMPILE_TARGET} +# PRIVATE +# # -cpp +# # $<$:-fcheck=all> +# # $<$:-check all> +# ) + +target_link_libraries( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_LIBRARIES} + $<$:$> + $<$:$> + ) + +target_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_INCLUDE_DIRS} + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) diff --git a/external/io_adios2/CMakeLists.txt b/external/io_adios2/CMakeLists.txt new file mode 100644 index 0000000000..780d1316cb --- /dev/null +++ b/external/io_adios2/CMakeLists.txt @@ -0,0 +1,50 @@ +# WRF CMake Build + +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +add_library( + ${FOLDER_COMPILE_TARGET} + STATIC + ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + wrf_io.F90 + field_routines.F90 + ext_adios2_get_dom_ti.code + ext_adios2_get_var_td.code + ext_adios2_get_var_ti.code + ext_adios2_put_dom_ti.code + ext_adios2_put_var_td.code + ext_adios2_put_var_ti.code + transpose.code + ) + +set_target_properties( + ${FOLDER_COMPILE_TARGET} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + ) + + +target_link_libraries( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_LIBRARIES} + $<$:$> + $<$:$> + ) + +target_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) diff --git a/external/io_esmf/CMakeLists.txt b/external/io_esmf/CMakeLists.txt new file mode 100644 index 0000000000..1b90ad29b6 --- /dev/null +++ b/external/io_esmf/CMakeLists.txt @@ -0,0 +1,48 @@ +# WRF CMake Build + +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +add_library( + ${FOLDER_COMPILE_TARGET} + STATIC + ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + module_symbols_util.F90 + module_esmf_extensions.F90 + module_utility.F90 + io_esmf.F90 + ext_esmf_open_for_read.F90 + ext_esmf_open_for_write.F90 + ext_esmf_read_field.F90 + ext_esmf_write_field.F90 + ) + +set_target_properties( + ${FOLDER_COMPILE_TARGET} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + ) + + +target_link_libraries( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_LIBRARIES} + $<$:$> + $<$:$> + ) + +target_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) diff --git a/external/io_grib1/CMakeLists.txt b/external/io_grib1/CMakeLists.txt new file mode 100644 index 0000000000..d1bd0fde64 --- /dev/null +++ b/external/io_grib1/CMakeLists.txt @@ -0,0 +1,54 @@ +# WRF CMake Build + +add_subdirectory( MEL_grib1 ) +add_subdirectory( grib1_util ) +add_subdirectory( WGRIB ) + +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +add_library( + ${FOLDER_COMPILE_TARGET} + STATIC + ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + grib1_routines.c + gribmap.c + io_grib1.F + trim.c + ) + +set_target_properties( + ${FOLDER_COMPILE_TARGET} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + Fortran_FORMAT FREE + ) + + +target_link_libraries( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_LIBRARIES} + $<$:$> + $<$:$> + ) + +target_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} + #!TODO Fix duplicates of wrf_[io|status]_flags.h + # ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share + ${CMAKE_CURRENT_SOURCE_DIR}/../io_grib_share + ${CMAKE_CURRENT_SOURCE_DIR}/grib1_util + ${CMAKE_CURRENT_SOURCE_DIR}/MEL_grib1 + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) diff --git a/external/io_grib1/MEL_grib1/CMakeLists.txt b/external/io_grib1/MEL_grib1/CMakeLists.txt new file mode 100644 index 0000000000..4d28866ee4 --- /dev/null +++ b/external/io_grib1/MEL_grib1/CMakeLists.txt @@ -0,0 +1,76 @@ +# WRF CMake Build + +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +add_library( + ${FOLDER_COMPILE_TARGET} + STATIC + ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + FTP_getfile.c + apply_bitmap.c + display_gribhdr.c + gbyte.c + grib_dec.c + grib_enc.c + grib_seek.c + gribgetbds.c + gribgetbms.c + gribgetgds.c + gribgetpds.c + gribhdr2file.c + gribputbds.c + gribputgds.c + gribputpds.c + hdr_print.c + init_dec_struct.c + init_enc_struct.c + init_gribhdr.c + init_struct.c + ld_dec_lookup.c + ld_enc_input.c + ld_enc_lookup.c + ld_grib_origctrs.c + make_default_grbfn.c + make_grib_log.c + map_lvl.c + map_parm.c + pack_spatial.c + prt_inp_struct.c + upd_child_errmsg.c + prt_badmsg.c + swap.c + grib_uthin.c + set_bytes.c + ) + +set_target_properties( + ${FOLDER_COMPILE_TARGET} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + ) + + +target_link_libraries( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_LIBRARIES} + $<$:$> + $<$:$> + ) + +target_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../../ioapi_share + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) diff --git a/external/io_grib1/WGRIB/CMakeLists.txt b/external/io_grib1/WGRIB/CMakeLists.txt new file mode 100644 index 0000000000..31aea35d67 --- /dev/null +++ b/external/io_grib1/WGRIB/CMakeLists.txt @@ -0,0 +1,77 @@ +# WRF CMake Build + +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +add_library( + ${FOLDER_COMPILE_TARGET} + STATIC + ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + # wgrib_main.c # Driver + seekgrib.c + ibm2flt.c + readgrib.c + intpower.c + cnames.c + BDSunpk.c + flt2ieee.c + wrtieee.c + levels.c + PDStimes.c + missing.c + nceptable_reanal.c + nceptable_opn.c + ensemble.c + ombtable.c + ec_ext.c + gribtable.c + gds_grid.c + PDS_date.c + ectable_128.c + ectable_129.c + ectable_130.c + ectable_131.c + ectable_140.c + ectable_150.c + ectable_151.c + ectable_160.c + ectable_170.c + ectable_180.c + nceptab_129.c + dwdtable_002.c + dwdtable_201.c + dwdtable_202.c + dwdtable_203.c + cptectable_254.c + nceptab_130.c + nceptab_131.c + ) + +set_target_properties( + ${FOLDER_COMPILE_TARGET} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + ) + + +target_link_libraries( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_LIBRARIES} + $<$:$> + $<$:$> + ) + +target_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_INCLUDE_DIRS} + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) diff --git a/external/io_grib1/grib1_util/CMakeLists.txt b/external/io_grib1/grib1_util/CMakeLists.txt new file mode 100644 index 0000000000..bda28c07e2 --- /dev/null +++ b/external/io_grib1/grib1_util/CMakeLists.txt @@ -0,0 +1,44 @@ +# WRF CMake Build + +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +add_library( + ${FOLDER_COMPILE_TARGET} + STATIC + ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + alloc_2d.c + read_grib.c + write_grib.c + ) + +set_target_properties( + ${FOLDER_COMPILE_TARGET} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + ) + + +target_link_libraries( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_LIBRARIES} + $<$:$> + $<$:$> + ) + +target_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../MEL_grib1 + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) diff --git a/external/io_grib2/CMakeLists.txt b/external/io_grib2/CMakeLists.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/external/io_grib2/bacio-1.3/CMakeLists.txt b/external/io_grib2/bacio-1.3/CMakeLists.txt new file mode 100644 index 0000000000..d10f368663 --- /dev/null +++ b/external/io_grib2/bacio-1.3/CMakeLists.txt @@ -0,0 +1,41 @@ +# WRF CMake Build + +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +add_library( + ${FOLDER_COMPILE_TARGET} + STATIC + ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + bacio.v1.3.c + baciof.F + ) + +set_target_properties( + ${FOLDER_COMPILE_TARGET} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + ) + + +target_link_libraries( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_LIBRARIES} + $<$:$> + $<$:$> + ) + +target_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_INCLUDE_DIRS} + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) diff --git a/external/io_grib2/g2lib/CMakeLists.txt b/external/io_grib2/g2lib/CMakeLists.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/external/io_grib2/g2lib/utest/CMakeLists.txt b/external/io_grib2/g2lib/utest/CMakeLists.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/external/io_grib_share/CMakeLists.txt b/external/io_grib_share/CMakeLists.txt new file mode 100644 index 0000000000..18b5c4f8d2 --- /dev/null +++ b/external/io_grib_share/CMakeLists.txt @@ -0,0 +1,45 @@ +# WRF CMake Build + +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +add_library( + ${FOLDER_COMPILE_TARGET} + STATIC + ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + io_grib_share.F + get_region_center.c + gridnav.c + open_file.c + ) + +set_target_properties( + ${FOLDER_COMPILE_TARGET} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + Fortran_FORMAT FREE + ) + + +target_link_libraries( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_LIBRARIES} + $<$:$> + $<$:$> + ) + +target_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) \ No newline at end of file diff --git a/external/io_int/CMakeLists.txt b/external/io_int/CMakeLists.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/external/io_netcdf/CMakeLists.txt b/external/io_netcdf/CMakeLists.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/external/io_netcdfpar/CMakeLists.txt b/external/io_netcdfpar/CMakeLists.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/external/io_phdf5/CMakeLists.txt b/external/io_phdf5/CMakeLists.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/external/io_pio/CMakeLists.txt b/external/io_pio/CMakeLists.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/external/io_pnetcdf/CMakeLists.txt b/external/io_pnetcdf/CMakeLists.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/external/ioapi_share/CMakeLists.txt b/external/ioapi_share/CMakeLists.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frame/CMakeLists.txt b/frame/CMakeLists.txt new file mode 100644 index 0000000000..a1db9c0710 --- /dev/null +++ b/frame/CMakeLists.txt @@ -0,0 +1,278 @@ +# WRF CMake Build + +# get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) +# add_library( +# ${FOLDER_COMPILE_TARGET} +# STATIC +# ) + +# ######################################################################################################################## +# # +# # Extra object archive to set up dependencies +# # +# ######################################################################################################################## +# add_library( +# ${FOLDER_COMPILE_TARGET}_deps +# OBJECT +# module_configure.F +# module_driver_constants.F +# module_domain_type.F +# module_domain.F +# module_streams.F +# module_wrf_error.F +# module_machine.F +# module_timing.F +# module_dm.F +# module_cpl.F +# module_cpl_oasis3.F + + +# module_alloc_space_0.F +# module_alloc_space_1.F +# module_alloc_space_2.F +# module_alloc_space_3.F +# module_alloc_space_4.F +# module_alloc_space_5.F +# module_alloc_space_6.F +# module_alloc_space_7.F +# module_alloc_space_8.F +# module_alloc_space_9.F + +# ${CMAKE_BINARY_DIR}/frame/module_state_description.F # GENERATED +# ) + +# add_dependencies( ${FOLDER_COMPILE_TARGET}_deps share_model_constants registry_code ) + + +# Tell CMake to chill, we'll generate those files shortly +# Thanks to https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-add-a-dependency-to-a-source-file-which-is-generated-in-a-subdirectory +# and https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/ +set_source_files_properties( + ${CMAKE_BINARY_DIR}/frame/module_state_description.F + PROPERTIES + GENERATED TRUE + ) + +# set_target_properties( +# ${FOLDER_COMPILE_TARGET}_deps +# PROPERTIES +# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} +# Fortran_FORMAT FREE +# ) + +# target_include_directories( ${FOLDER_COMPILE_TARGET}_deps +# PRIVATE +# ${CMAKE_CURRENT_SOURCE_DIR} +# ${PROJECT_SOURCE_DIR}/inc +# # Compiled sources +# $ +# $ +# # Generated sources +# ${CMAKE_BINARY_DIR}/frame +# ${CMAKE_BINARY_DIR}/inc +# ) +# target_link_libraries( +# ${FOLDER_COMPILE_TARGET}_deps +# PRIVATE +# esmf_time_f90 +# ) + + + +# ######################################################################################################################## +# # Extra stuff for things that depend on registry code +# # https://stackoverflow.com/a/50640971 +# # Generate all the combinations dynamically, not a fan of this file breakdown +# ######################################################################################################################## +# foreach( n RANGE 0 7 ) + +# add_library( nl_set_${n} OBJECT nl_access_routines.F ) +# add_library( nl_get_${n} OBJECT nl_access_routines.F ) + + +# # Wait for registry code +# add_dependencies( nl_set_${n} registry_code ${FOLDER_COMPILE_TARGET}_deps ) +# add_dependencies( nl_get_${n} registry_code ${FOLDER_COMPILE_TARGET}_deps ) + +# target_compile_definitions( nl_set_${n} PRIVATE -DNNN=${n} -DNL_set_ROUTINES ) +# target_compile_definitions( nl_get_${n} PRIVATE -DNNN=${n} -DNL_get_ROUTINES ) + +# set_target_properties( +# nl_set_${n} +# nl_get_${n} +# PROPERTIES +# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} +# Fortran_FORMAT FREE +# ) + +# target_include_directories( nl_set_${n} +# PRIVATE +# ${CMAKE_CURRENT_SOURCE_DIR} +# # Generated sources +# ${CMAKE_BINARY_DIR}/inc +# ) +# target_include_directories( nl_get_${n} +# PRIVATE +# ${CMAKE_CURRENT_SOURCE_DIR} +# # Generated sources +# ${CMAKE_BINARY_DIR}/inc +# ) + +# target_link_libraries( +# ${FOLDER_COMPILE_TARGET} +# PRIVATE +# nl_set_${n} +# nl_get_${n} +# ) + +# endforeach() + +######################################################################################################################## +# Extra stuff for things that depend on registry code +# https://stackoverflow.com/a/50640971 +# 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_preproc_fortran( + TARGET_NAME nl_set_${n} + GENERATED_SCOPE ${PROJECT_NAME}_Core + OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ + EXTENSION ".i" + PREFIX "nl_set_${n}_" + INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_BINARY_DIR}/inc + DEPENDENCIES registry_code + DEFINITIONS ${DIR_DEFS} NNN=${n} NL_set_ROUTINES + SOURCES nl_access_routines.F + ) + wrf_preproc_fortran( + TARGET_NAME nl_get_${n} + GENERATED_SCOPE ${PROJECT_NAME}_Core + OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ + EXTENSION ".i" + PREFIX "nl_get_${n}_" + INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_BINARY_DIR}/inc + DEPENDENCIES registry_code + DEFINITIONS ${DIR_DEFS} NNN=${n} NL_get_ROUTINES + SOURCES nl_access_routines.F + ) + + list( + APPEND + nl_dyn_source + ${CMAKE_CURRENT_BINARY_DIR}/preproc/nl_set_${n}_nl_access_routines.i + ${CMAKE_CURRENT_BINARY_DIR}/preproc/nl_get_${n}_nl_access_routines.i + ) + +endforeach() + + +######################################################################################################################## +# +# Now define base framework +# +######################################################################################################################## +target_sources( + # ${FOLDER_COMPILE_TARGET} + ${PROJECT_NAME}_Core + PRIVATE + module_configure.F + module_driver_constants.F + module_domain_type.F + module_domain.F + module_streams.F + module_wrf_error.F + module_machine.F + module_timing.F + module_dm.F + module_cpl.F + module_cpl_oasis3.F + + + module_alloc_space_0.F + module_alloc_space_1.F + module_alloc_space_2.F + module_alloc_space_3.F + module_alloc_space_4.F + module_alloc_space_5.F + module_alloc_space_6.F + module_alloc_space_7.F + module_alloc_space_8.F + module_alloc_space_9.F + + ${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_internal_header_util.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 + ) + +# set_target_properties( +# ${FOLDER_COMPILE_TARGET} +# PROPERTIES +# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} +# Fortran_FORMAT FREE +# ) + + +# target_link_libraries( ${FOLDER_COMPILE_TARGET} +# PRIVATE +# ${FOLDER_COMPILE_TARGET}_deps +# ${netCDF_LIBRARIES} +# $<$:$> +# $<$:$> +# ) + +target_include_directories( #${FOLDER_COMPILE_TARGET} + ${PROJECT_NAME}_Core + PRIVATE + # ${netCDF_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} + # $ + # $ + # # Generated sources + # ${CMAKE_BINARY_DIR}/frame + # ${CMAKE_BINARY_DIR}/inc + ) + +# Depend on other generated files and libs, this should be one of the last things made apparently +# add_dependencies( ${FOLDER_COMPILE_TARGET} ${FOLDER_COMPILE_TARGET}_deps registry_code share ) + +# install( +# TARGETS ${FOLDER_COMPILE_TARGET} +# RUNTIME DESTINATION bin/ +# ARCHIVE DESTINATION lib/ +# LIBRARY DESTINATION lib/ +# ) diff --git a/frame/module_dm.F b/frame/module_dm.F new file mode 100644 index 0000000000..d9f0aafff6 --- /dev/null +++ b/frame/module_dm.F @@ -0,0 +1,376 @@ +!WRF:PACKAGE:NODM +! +MODULE module_dm + USE module_driver_constants + + LOGICAL intercomm_active( max_domains ), domain_active_this_task( max_domains ) + + CONTAINS + SUBROUTINE init_module_dm + intercomm_active = .TRUE. + domain_active_this_task = .TRUE. + END SUBROUTINE init_module_dm + + REAL FUNCTION wrf_dm_max_real ( inval ) + IMPLICIT NONE + REAL inval + wrf_dm_max_real = inval + END FUNCTION wrf_dm_max_real + + REAL FUNCTION wrf_dm_min_real ( inval ) + IMPLICIT NONE + REAL inval + wrf_dm_min_real = inval + END FUNCTION wrf_dm_min_real + + SUBROUTINE wrf_dm_min_reals ( inval, retval, n ) + IMPLICIT NONE + INTEGER, INTENT(IN) :: n + REAL, INTENT(IN) :: inval(:) + REAL, INTENT(OUT) :: retval(:) + retval(:) = inval(:) + END SUBROUTINE wrf_dm_min_reals + + REAL FUNCTION wrf_dm_sum_real ( inval ) + IMPLICIT NONE + REAL inval + wrf_dm_sum_real = inval + END FUNCTION wrf_dm_sum_real + + SUBROUTINE wrf_dm_sum_reals ( inval, retval ) + IMPLICIT NONE + REAL, INTENT(IN) :: inval(:) + REAL, INTENT(OUT) :: retval(:) + retval(:) = inval(:) + END SUBROUTINE wrf_dm_sum_reals + + INTEGER FUNCTION wrf_dm_sum_integer ( inval ) + IMPLICIT NONE + INTEGER inval + wrf_dm_sum_integer = inval + END FUNCTION wrf_dm_sum_integer + + SUBROUTINE wrf_dm_sum_integers ( inval, retval ) + IMPLICIT NONE + INTEGER, INTENT(IN) :: inval(:) + INTEGER, INTENT(OUT) :: retval(:) + retval(:) = inval(:) + END SUBROUTINE wrf_dm_sum_integers + + INTEGER FUNCTION wrf_dm_bxor_integer ( inval ) + IMPLICIT NONE + INTEGER inval + wrf_dm_bxor_integer = inval + END FUNCTION wrf_dm_bxor_integer + + SUBROUTINE wrf_dm_maxval ( val, idex, jdex ) + IMPLICIT NONE + REAL val + INTEGER idex, jdex + RETURN + END SUBROUTINE wrf_dm_maxval + + SUBROUTINE wrf_dm_minval ( val, idex, jdex ) + IMPLICIT NONE + REAL val + INTEGER idex, jdex + RETURN + END SUBROUTINE wrf_dm_minval + + SUBROUTINE wrf_dm_maxtile_real ( val , tile) + IMPLICIT NONE + REAL val + INTEGER tile + END SUBROUTINE wrf_dm_maxtile_real + + SUBROUTINE wrf_dm_mintile_double ( val , tile) + IMPLICIT NONE + DOUBLE PRECISION val + INTEGER tile + END SUBROUTINE wrf_dm_mintile_double + + SUBROUTINE wrf_dm_tile_val_int ( val , tile) + IMPLICIT NONE + INTEGER val + INTEGER tile + END SUBROUTINE wrf_dm_tile_val_int + +! stub + SUBROUTINE wrf_dm_move_nest ( parent, nest, dx, dy ) + USE module_domain + TYPE (domain), INTENT(INOUT) :: parent, nest + INTEGER, INTENT(IN) :: dx,dy + RETURN + END SUBROUTINE wrf_dm_move_nest + +END MODULE module_dm + +!========================================================================= + +! These are stub functions that do the right thing (usually nothing) +! in case DM_PARALLEL is not compiled for. +! This file, src/module_dm_stubs.F is copied to src/module_dm.F when +! the code is built. +! If, on the other hand, a DM package is specified, the module_dm.F +! provided with that package (e.g. RSL) is copied from /external/RSL/module_dm.F +! into src/module_dm.F. +! It is important to recognize this, because changes directly to src/module_dm.F +! will be lost! + +LOGICAL FUNCTION wrf_dm_on_monitor() + wrf_dm_on_monitor = .true. +END FUNCTION wrf_dm_on_monitor + +INTEGER FUNCTION wrf_dm_monitor_rank() + wrf_dm_monitor_rank = 0 +END FUNCTION wrf_dm_monitor_rank + +SUBROUTINE wrf_get_myproc( myproc ) + IMPLICIT NONE + INTEGER myproc + myproc = 0 + RETURN +END SUBROUTINE wrf_get_myproc + +SUBROUTINE wrf_get_nproc( nprocs ) + IMPLICIT NONE + INTEGER nprocs + nprocs = 1 + RETURN +END SUBROUTINE wrf_get_nproc + +SUBROUTINE wrf_get_nprocx( nprocs ) + IMPLICIT NONE + INTEGER nprocs + nprocs = 1 + RETURN +END SUBROUTINE wrf_get_nprocx + +SUBROUTINE wrf_get_nprocy( nprocs ) + IMPLICIT NONE + INTEGER nprocs + nprocs = 1 + RETURN +END SUBROUTINE wrf_get_nprocy + +SUBROUTINE wrf_dm_bcast_string ( buf , size ) + IMPLICIT NONE + INTEGER size + INTEGER BUF(*) + RETURN +END SUBROUTINE wrf_dm_bcast_string + +SUBROUTINE wrf_dm_bcast_bytes ( buf , size ) + IMPLICIT NONE + INTEGER size + INTEGER BUF(*) + RETURN +END SUBROUTINE wrf_dm_bcast_bytes + +SUBROUTINE wrf_dm_bcast_integer( BUF, N1 ) + IMPLICIT NONE + INTEGER n1 + INTEGER buf(*) + RETURN +END SUBROUTINE wrf_dm_bcast_integer + +SUBROUTINE wrf_dm_bcast_real( BUF, N1 ) + IMPLICIT NONE + INTEGER n1 + REAL buf(*) + RETURN +END SUBROUTINE wrf_dm_bcast_real + +SUBROUTINE wrf_dm_bcast_logical( BUF, N1 ) + IMPLICIT NONE + INTEGER n1 + LOGICAL buf(*) + RETURN +END SUBROUTINE wrf_dm_bcast_logical + +SUBROUTINE wrf_dm_halo ( domdesc , comms , stencil_id ) + IMPLICIT NONE + INTEGER domdesc , comms(*) , stencil_id + RETURN +END SUBROUTINE wrf_dm_halo + +SUBROUTINE wrf_dm_boundary ( domdesc , comms , period_id , & + periodic_x , periodic_y ) + IMPLICIT NONE + INTEGER domdesc , comms(*) , period_id + LOGICAL , INTENT(IN) :: periodic_x, periodic_y + RETURN +END SUBROUTINE wrf_dm_boundary + +SUBROUTINE wrf_dm_xpose_z2x ( domdesc , comms , xpose_id ) + IMPLICIT NONE + INTEGER domdesc , comms(*), xpose_id + RETURN +END SUBROUTINE wrf_dm_xpose_z2x +SUBROUTINE wrf_dm_xpose_x2y ( domdesc , comms , xpose_id ) + IMPLICIT NONE + INTEGER domdesc , comms(*), xpose_id + RETURN +END SUBROUTINE wrf_dm_xpose_x2y +SUBROUTINE wrf_dm_xpose_y2z ( domdesc , comms , xpose_id ) + IMPLICIT NONE + INTEGER domdesc , comms(*), xpose_id + RETURN +END SUBROUTINE wrf_dm_xpose_y2z + +SUBROUTINE wrf_dm_define_comms ( grid ) + USE module_domain + IMPLICIT NONE + TYPE(domain) , INTENT (INOUT) :: grid + RETURN +END SUBROUTINE wrf_dm_define_comms + +SUBROUTINE wrf_get_dm_communicator ( communicator ) + IMPLICIT NONE + INTEGER , INTENT(OUT) :: communicator + communicator = 0 + RETURN +END SUBROUTINE wrf_get_dm_communicator + +SUBROUTINE wrf_get_dm_iocommunicator ( iocommunicator ) + IMPLICIT NONE + INTEGER , INTENT(OUT) :: iocommunicator + iocommunicator = 0 + RETURN +END SUBROUTINE wrf_get_dm_iocommunicator + +SUBROUTINE wrf_dm_shutdown + RETURN +END SUBROUTINE wrf_dm_shutdown +SUBROUTINE wrf_abort + STOP 'wrf_abort' +END SUBROUTINE wrf_abort + +SUBROUTINE wrf_patch_to_global_real (buf,globbuf,domdesc,ndim,& + ids,ide,jds,jde,kds,kde,& + ims,ime,jms,jme,kms,kme,& + ips,ipe,jps,jpe,kps,kpe ) + IMPLICIT NONE + INTEGER ids,ide,jds,jde,kds,kde,& + ims,ime,jms,jme,kms,kme,& + ips,ipe,jps,jpe,kps,kpe + INTEGER fid,domdesc,ndim,glen(3),llen(3) + REAL globbuf(*) + REAL buf(*) + RETURN +END SUBROUTINE wrf_patch_to_global_real + +SUBROUTINE wrf_global_to_patch_real (globbuf,buf,domdesc,ndim,& + ids,ide,jds,jde,kds,kde,& + ims,ime,jms,jme,kms,kme,& + ips,ipe,jps,jpe,kps,kpe ) + IMPLICIT NONE + INTEGER ids,ide,jds,jde,kds,kde,& + ims,ime,jms,jme,kms,kme,& + ips,ipe,jps,jpe,kps,kpe + INTEGER fid,domdesc,ndim,glen(3),llen(3) + REAL globbuf(*) + REAL buf(*) + RETURN +END SUBROUTINE wrf_global_to_patch_real + + +SUBROUTINE wrf_patch_to_global_double (buf,globbuf,domdesc,ndim,& + ids,ide,jds,jde,kds,kde,& + ims,ime,jms,jme,kms,kme,& + ips,ipe,jps,jpe,kps,kpe ) + IMPLICIT NONE + INTEGER ids,ide,jds,jde,kds,kde,& + ims,ime,jms,jme,kms,kme,& + ips,ipe,jps,jpe,kps,kpe + INTEGER fid,domdesc,ndim,glen(3),llen(3) + DOUBLE PRECISION globbuf(*) + DOUBLE PRECISION buf(*) + RETURN +END SUBROUTINE wrf_patch_to_global_double + +SUBROUTINE wrf_global_to_patch_double (globbuf,buf,domdesc,ndim,& + ids,ide,jds,jde,kds,kde,& + ims,ime,jms,jme,kms,kme,& + ips,ipe,jps,jpe,kps,kpe ) + IMPLICIT NONE + INTEGER ids,ide,jds,jde,kds,kde,& + ims,ime,jms,jme,kms,kme,& + ips,ipe,jps,jpe,kps,kpe + INTEGER fid,domdesc,ndim,glen(3),llen(3) + DOUBLE PRECISION globbuf(*) + DOUBLE PRECISION buf(*) + RETURN +END SUBROUTINE wrf_global_to_patch_double + +SUBROUTINE wrf_patch_to_global_integer (buf,globbuf,domdesc,ndim,& + ids,ide,jds,jde,kds,kde,& + ims,ime,jms,jme,kms,kme,& + ips,ipe,jps,jpe,kps,kpe ) + IMPLICIT NONE + INTEGER ids,ide,jds,jde,kds,kde,& + ims,ime,jms,jme,kms,kme,& + ips,ipe,jps,jpe,kps,kpe + INTEGER fid,domdesc,ndim,glen(3),llen(3) + INTEGER globbuf(*) + INTEGER buf(*) + RETURN +END SUBROUTINE wrf_patch_to_global_integer + +SUBROUTINE wrf_global_to_patch_integer (globbuf,buf,domdesc,ndim,& + ids,ide,jds,jde,kds,kde,& + ims,ime,jms,jme,kms,kme,& + ips,ipe,jps,jpe,kps,kpe ) + IMPLICIT NONE + INTEGER ids,ide,jds,jde,kds,kde,& + ims,ime,jms,jme,kms,kme,& + ips,ipe,jps,jpe,kps,kpe + INTEGER fid,domdesc,ndim,glen(3),llen(3) + INTEGER globbuf(*) + INTEGER buf(*) + RETURN +END SUBROUTINE wrf_global_to_patch_integer + +SUBROUTINE wrf_patch_to_global_logical (buf,globbuf,domdesc,ndim,& + ids,ide,jds,jde,kds,kde,& + ims,ime,jms,jme,kms,kme,& + ips,ipe,jps,jpe,kps,kpe ) + IMPLICIT NONE + INTEGER ids,ide,jds,jde,kds,kde,& + ims,ime,jms,jme,kms,kme,& + ips,ipe,jps,jpe,kps,kpe + INTEGER fid,domdesc,ndim,glen(3),llen(3) + LOGICAL globbuf(*) + LOGICAL buf(*) + RETURN +END SUBROUTINE wrf_patch_to_global_logical + +SUBROUTINE wrf_global_to_patch_LOGICAL (globbuf,buf,domdesc,ndim,& + ids,ide,jds,jde,kds,kde,& + ims,ime,jms,jme,kms,kme,& + ips,ipe,jps,jpe,kps,kpe ) + IMPLICIT NONE + INTEGER ids,ide,jds,jde,kds,kde,& + ims,ime,jms,jme,kms,kme,& + ips,ipe,jps,jpe,kps,kpe + INTEGER fid,domdesc,ndim,glen(3),llen(3) + LOGICAL globbuf(*) + LOGICAL buf(*) + RETURN +END SUBROUTINE wrf_global_to_patch_LOGICAL + + SUBROUTINE push_communicators_for_domain( id ) + IMPLICIT NONE + INTEGER, OPTIONAL, INTENT(IN) :: id ! if specified also does an instate for grid id + END SUBROUTINE push_communicators_for_domain + SUBROUTINE pop_communicators_for_domain + END SUBROUTINE pop_communicators_for_domain + SUBROUTINE instate_communicators_for_domain( id ) + IMPLICIT NONE + INTEGER, INTENT(IN) :: id + END SUBROUTINE instate_communicators_for_domain + SUBROUTINE store_communicators_for_domain( id ) + IMPLICIT NONE + INTEGER, INTENT(IN) :: id + END SUBROUTINE store_communicators_for_domain + diff --git a/frame/nl_get_0_routines.F b/frame/nl_get_0_routines.F deleted file mode 100644 index b24d607eb0..0000000000 --- a/frame/nl_get_0_routines.F +++ /dev/null @@ -1 +0,0 @@ -dummy; make needs this to be happy diff --git a/frame/nl_get_1_routines.F b/frame/nl_get_1_routines.F deleted file mode 100644 index b24d607eb0..0000000000 --- a/frame/nl_get_1_routines.F +++ /dev/null @@ -1 +0,0 @@ -dummy; make needs this to be happy diff --git a/frame/nl_get_2_routines.F b/frame/nl_get_2_routines.F deleted file mode 100644 index b24d607eb0..0000000000 --- a/frame/nl_get_2_routines.F +++ /dev/null @@ -1 +0,0 @@ -dummy; make needs this to be happy diff --git a/frame/nl_get_3_routines.F b/frame/nl_get_3_routines.F deleted file mode 100644 index b24d607eb0..0000000000 --- a/frame/nl_get_3_routines.F +++ /dev/null @@ -1 +0,0 @@ -dummy; make needs this to be happy diff --git a/frame/nl_get_4_routines.F b/frame/nl_get_4_routines.F deleted file mode 100644 index b24d607eb0..0000000000 --- a/frame/nl_get_4_routines.F +++ /dev/null @@ -1 +0,0 @@ -dummy; make needs this to be happy diff --git a/frame/nl_get_5_routines.F b/frame/nl_get_5_routines.F deleted file mode 100644 index b24d607eb0..0000000000 --- a/frame/nl_get_5_routines.F +++ /dev/null @@ -1 +0,0 @@ -dummy; make needs this to be happy diff --git a/frame/nl_get_6_routines.F b/frame/nl_get_6_routines.F deleted file mode 100644 index b24d607eb0..0000000000 --- a/frame/nl_get_6_routines.F +++ /dev/null @@ -1 +0,0 @@ -dummy; make needs this to be happy diff --git a/frame/nl_get_7_routines.F b/frame/nl_get_7_routines.F deleted file mode 100644 index b24d607eb0..0000000000 --- a/frame/nl_get_7_routines.F +++ /dev/null @@ -1 +0,0 @@ -dummy; make needs this to be happy diff --git a/frame/nl_set_0_routines.F b/frame/nl_set_0_routines.F deleted file mode 100644 index b24d607eb0..0000000000 --- a/frame/nl_set_0_routines.F +++ /dev/null @@ -1 +0,0 @@ -dummy; make needs this to be happy diff --git a/frame/nl_set_1_routines.F b/frame/nl_set_1_routines.F deleted file mode 100644 index b24d607eb0..0000000000 --- a/frame/nl_set_1_routines.F +++ /dev/null @@ -1 +0,0 @@ -dummy; make needs this to be happy diff --git a/frame/nl_set_2_routines.F b/frame/nl_set_2_routines.F deleted file mode 100644 index b24d607eb0..0000000000 --- a/frame/nl_set_2_routines.F +++ /dev/null @@ -1 +0,0 @@ -dummy; make needs this to be happy diff --git a/frame/nl_set_3_routines.F b/frame/nl_set_3_routines.F deleted file mode 100644 index b24d607eb0..0000000000 --- a/frame/nl_set_3_routines.F +++ /dev/null @@ -1 +0,0 @@ -dummy; make needs this to be happy diff --git a/frame/nl_set_4_routines.F b/frame/nl_set_4_routines.F deleted file mode 100644 index b24d607eb0..0000000000 --- a/frame/nl_set_4_routines.F +++ /dev/null @@ -1 +0,0 @@ -dummy; make needs this to be happy diff --git a/frame/nl_set_5_routines.F b/frame/nl_set_5_routines.F deleted file mode 100644 index b24d607eb0..0000000000 --- a/frame/nl_set_5_routines.F +++ /dev/null @@ -1 +0,0 @@ -dummy; make needs this to be happy diff --git a/frame/nl_set_6_routines.F b/frame/nl_set_6_routines.F deleted file mode 100644 index b24d607eb0..0000000000 --- a/frame/nl_set_6_routines.F +++ /dev/null @@ -1 +0,0 @@ -dummy; make needs this to be happy diff --git a/frame/nl_set_7_routines.F b/frame/nl_set_7_routines.F deleted file mode 100644 index b24d607eb0..0000000000 --- a/frame/nl_set_7_routines.F +++ /dev/null @@ -1 +0,0 @@ -dummy; make needs this to be happy diff --git a/phys/CMakeLists.txt b/phys/CMakeLists.txt new file mode 100644 index 0000000000..1f8afc9829 --- /dev/null +++ b/phys/CMakeLists.txt @@ -0,0 +1,311 @@ +# WRF CMake Build + +# get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME ) + + +######################################################################################################################## +# +# Quickly preprocess some files so that cmake can understand the module dependencies +# +######################################################################################################################## +get_directory_property( DIR_DEFS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS ) +wrf_preproc_fortran( + TARGET_NAME module_ra_rrtmg_lwk_preproc + GENERATED_SCOPE ${PROJECT_NAME}_Core + OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ + EXTENSION ".i" + INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} + # $ + # $ + # $ + DEPENDENCIES registry_code + DEFINITIONS ${DIR_DEFS} + SOURCES module_ra_rrtmg_lwk.F + module_ra_rrtmg_swk.F + module_sf_clm.F + ) + +add_dependencies( ${PROJECT_NAME}_Core module_ra_rrtmg_lwk_preproc ) +# set_source_files_properties( +# ${CMAKE_CURRENT_BINARY_DIR}/preproc/module_ra_rrtmg_lwk.i +# PROPERTIES +# GENERATED TRUE +# ) + + +# add_library( +# ${FOLDER_COMPILE_TARGET} +# STATIC +# ) + +target_sources( + # ${FOLDER_COMPILE_TARGET} + ${PROJECT_NAME}_Core + PRIVATE + complex_number_module.F + module_bep_bem_helper.F + module_bl_acm.F + module_bl_boulac.F + module_bl_camuwpbl_driver.F + module_bl_eepsilon.F + module_bl_fogdes.F + module_bl_gbmpbl.F + module_bl_gfs.F + module_bl_gfsedmf.F + module_bl_gwdo.F + module_bl_gwdo_gsl.F + module_bl_keps.F + module_bl_mfshconvpbl.F + module_bl_mrf.F + module_bl_myjpbl.F + module_bl_myjurb.F + module_bl_mynn.F + module_bl_mynn_common.F + module_bl_mynn_wrapper.F + module_bl_qnsepbl.F + module_bl_shinhong.F + module_bl_temf.F + module_bl_ysu.F + module_cam_bl_diffusion_solver.F + module_cam_bl_eddy_diff.F + module_cam_cldwat.F + module_cam_constituents.F + module_cam_error_function.F + module_cam_esinti.F + module_cam_gffgch.F + module_cam_infnan.F + module_cam_molec_diff.F + module_cam_mp_cldwat2m_micro.F + module_cam_mp_conv_water.F + module_cam_mp_microp_aero.F + module_cam_mp_modal_aero_initialize_data_phys.F + module_cam_mp_ndrop.F + module_cam_mp_qneg3.F + module_cam_mp_radconstants.F + module_cam_physconst.F + module_cam_shr_const_mod.F + module_cam_shr_kind_mod.F + module_cam_support.F + module_cam_trb_mtn_stress.F + module_cam_upper_bc.F + module_cam_wv_saturation.F + module_checkerror.F + module_cu_bmj.F + module_cu_camzm.F + module_cu_camzm_driver.F + module_cu_g3.F + module_cu_gd.F + module_cu_gf_ctrans.F + module_cu_gf_deep.F + module_cu_gf_sh.F + module_cu_gf_wrfdrv.F + module_cu_kf.F + module_cu_kfcup.F + module_cu_kfeta.F + module_cu_ksas.F + module_cu_mskf.F + module_cu_nsas.F + module_cu_ntiedtke.F + module_cu_osas.F + module_cu_sas.F + module_cu_scalesas.F + module_cu_tiedtke.F + module_cumulus_driver.F + module_data_cam_mam_aero.F + module_data_cam_mam_asect.F + module_data_gocart_dust.F + module_diag_afwa.F + module_diag_cl.F + module_diag_functions.F + module_diag_hailcast.F + module_diag_misc.F + module_diag_nwp.F + module_diag_pld.F + module_diag_rasm.F + module_diag_solar.F + module_diag_trad_fields.F + module_diag_zld.F + module_diagnostics_driver.F + module_dust_emis.F + module_fdda_psufddagd.F + module_fdda_spnudging.F + module_fddagd_driver.F + module_fddaobs_driver.F + module_fddaobs_rtfdda.F + module_fire_emis.F + module_firebrand_spotting.F + module_firebrand_spotting_mpi.F + module_fr_fire_atm.F + module_fr_fire_core.F + module_fr_fire_driver.F + module_fr_fire_driver_wrf.F + module_fr_fire_model.F + module_fr_fire_phys.F + module_fr_fire_util.F + module_gfs_funcphys.F + module_gfs_machine.F + module_gfs_physcons.F + module_gocart_coupling.F + module_irrigation.F + module_lightning_driver.F + module_ltng_cpmpr92z.F + module_ltng_crmpr92.F + module_ltng_iccg.F + module_ltng_lpi.F + module_madwrf.F + module_microphysics_driver.F + module_microphysics_zero_out.F + module_mixactivate.F + module_mp_cammgmp_driver.F + module_mp_etanew.F + module_mp_fast_sbm.F + module_mp_fer_hires.F + module_mp_full_sbm.F + module_mp_gsfcgce.F + module_mp_gsfcgce_4ice_nuwrf.F + module_mp_jensen_ishmael.F + module_mp_kessler.F + module_mp_lin.F + module_mp_milbrandt2mom.F + module_mp_morr_two_moment.F + module_mp_morr_two_moment_aero.F + module_mp_nssl_2mom.F + module_mp_ntu.F + module_mp_p3.F + module_mp_radar.F + module_mp_SBM_polar_radar.F + module_mp_sbu_ylin.F + module_mp_thompson.F + module_mp_wdm5.F + module_mp_wdm6.F + module_mp_wdm7.F + module_mp_wsm3.F + module_mp_wsm5.F + module_mp_wsm6.F + module_mp_wsm6r.F + module_mp_wsm7.F + module_pbl_driver.F + module_physics_addtendc.F + module_physics_init.F + module_progtm.F + module_ra_aerosol.F + module_ra_cam.F + module_ra_cam_support.F + module_ra_clWRF_support.F + module_ra_eclipse.F + module_ra_effective_radius.F + module_ra_farms.F + module_ra_flg.F + module_ra_gfdleta.F + module_ra_goddard.F + module_ra_gsfcsw.F + module_ra_hs.F + module_ra_rrtm.F + module_ra_rrtmg_aero_optical_util_cmaq.F + module_ra_rrtmg_lw.F + module_ra_rrtmg_lwf.F + # module_ra_rrtmg_lwk.F + ${CMAKE_CURRENT_BINARY_DIR}/preproc/module_ra_rrtmg_lwk.i + module_ra_rrtmg_sw.F + module_ra_rrtmg_swf.F + # module_ra_rrtmg_swk.F + ${CMAKE_CURRENT_BINARY_DIR}/preproc/module_ra_rrtmg_swk.i + + module_ra_sw.F + module_radiation_driver.F + module_sf_3dpwp.F + module_sf_bem.F + module_sf_bep.F + module_sf_bep_bem.F + # module_sf_clm.F + ${CMAKE_CURRENT_BINARY_DIR}/preproc/module_sf_clm.i + module_sf_ctsm.F + module_sf_exchcoef.F + module_sf_fogdes.F + module_sf_gecros.F + module_sf_gfdl.F + module_sf_gfs.F + module_sf_idealscmsfclay.F + module_sf_lake.F + module_sf_myjsfc.F + module_sf_mynn.F + module_sf_noah_seaice.F + module_sf_noah_seaice_drv.F + module_sf_noahdrv.F + module_sf_noahlsm.F + module_sf_noahlsm_glacial_only.F + # NoahMP Code + noahmp/drivers/wrf/module_sf_noahmpdrv.F + noahmp/src/module_sf_noahmp_glacier.F + noahmp/src/module_sf_noahmp_groundwater.F + noahmp/src/module_sf_noahmplsm.F + + module_sf_ocean_driver.F + module_sf_oml.F + module_sf_pxlsm.F + module_sf_pxlsm_data.F + module_sf_pxsfclay.F + module_sf_qnsesfc.F + module_sf_ruclsm.F + module_sf_scmflux.F + module_sf_scmskintemp.F + module_sf_sfcdiags.F + module_sf_sfcdiags_ruclsm.F + module_sf_sfclay.F + module_sf_sfclayrev.F + module_sf_slab.F + module_sf_ssib.F + module_sf_sstskin.F + module_sf_temfsfclay.F + module_sf_tmnupdate.F + module_sf_urban.F + module_shallowcu_driver.F + module_shcu_camuwshcu.F + module_shcu_camuwshcu_driver.F + module_shcu_deng.F + module_shcu_grims.F + module_shcu_nscv.F + module_surface_driver.F + module_wind_fitch.F + ) + +# set_target_properties( +# ${FOLDER_COMPILE_TARGET} +# PROPERTIES +# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} +# Fortran_FORMAT FREE +# ) + + +# target_link_libraries( ${FOLDER_COMPILE_TARGET} +# PRIVATE +# ${netCDF_LIBRARIES} +# $<$:$> +# $<$:$> +# ) + +target_include_directories( #${FOLDER_COMPILE_TARGET} + ${PROJECT_NAME}_Core + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + # $ + # $ + # $ + + #!TODO Fix duplicates of wrf_[io|status]_flags.h + # ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share + # ${CMAKE_CURRENT_SOURCE_DIR}/../io_grib_share + # ${CMAKE_CURRENT_SOURCE_DIR}/grib1_util + # ${CMAKE_CURRENT_SOURCE_DIR}/MEL_grib1 + ) + +# # Depend on framework, why? I don't know, this is a mess +# add_dependencies( ${FOLDER_COMPILE_TARGET} frame_deps share_deps module_ra_rrtmg_lwk_preproc ) + + +# install( +# TARGETS ${FOLDER_COMPILE_TARGET} +# RUNTIME DESTINATION bin/ +# ARCHIVE DESTINATION lib/ +# LIBRARY DESTINATION lib/ +# ) diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt new file mode 100644 index 0000000000..159047aabf --- /dev/null +++ b/share/CMakeLists.txt @@ -0,0 +1,206 @@ +# WRF CMake Build + +# # get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# # add_library( +# # ${FOLDER_COMPILE_TARGET} +# # STATIC +# # ) +# ######################################################################################################################## +# # +# # Consider only making one library rather than forcing all these target dependencies - it would simplify a ton +# # but for now trying to recreate WRF building as a one-to-one replica +# # +# ######################################################################################################################## +# add_library( +# ${FOLDER_COMPILE_TARGET}_model_constants +# OBJECT +# module_model_constants.F +# # module_llxy.F +# # module_soil_pre.F +# # module_date_time.F +# # module_bc.F + +# ) + +# add_dependencies( ${FOLDER_COMPILE_TARGET}_model_constants frame_deps ) + + +# set_target_properties( +# ${FOLDER_COMPILE_TARGET}_model_constants +# PROPERTIES +# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} +# Fortran_FORMAT FREE +# ) + +# target_include_directories( ${FOLDER_COMPILE_TARGET}_model_constants +# PRIVATE +# ${CMAKE_CURRENT_SOURCE_DIR} +# # Compiled sources +# $ +# $ +# ) + +# ######################################################################################################################## +# # +# # Extra object archive to set up dependencies +# # +# ######################################################################################################################## +# add_library( +# ${FOLDER_COMPILE_TARGET}_deps +# OBJECT +# module_model_constants.F +# module_llxy.F +# module_soil_pre.F +# module_date_time.F +# module_bc.F + +# ) + +# add_dependencies( ${FOLDER_COMPILE_TARGET}_deps frame_deps ) + + +# set_target_properties( +# ${FOLDER_COMPILE_TARGET}_deps +# PROPERTIES +# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} +# Fortran_FORMAT FREE +# ) + +target_include_directories( #${FOLDER_COMPILE_TARGET}_deps + ${PROJECT_NAME}_Core + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + # ${PROJECT_SOURCE_DIR}/inc + # Compiled sources + # $ + # $ + # # Generated sources + # ${CMAKE_BINARY_DIR}/frame + # ${CMAKE_BINARY_DIR}/inc + ) +# target_link_libraries( +# ${FOLDER_COMPILE_TARGET}_deps +# PRIVATE +# esmf_time_f90 +# ) + + + +######################################################################################################################## +# +# Now define base share +# +######################################################################################################################## +target_sources( + # ${FOLDER_COMPILE_TARGET} + ${PROJECT_NAME}_Core + PRIVATE + + 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 + interp_fcn.F + 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 + ) + +# set_target_properties( +# ${FOLDER_COMPILE_TARGET} +# PROPERTIES +# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} +# Fortran_FORMAT FREE +# ) + + +# target_link_libraries( ${FOLDER_COMPILE_TARGET} +# PRIVATE +# ${FOLDER_COMPILE_TARGET}_deps +# ${FOLDER_COMPILE_TARGET}_model_constants +# ${netCDF_LIBRARIES} +# $<$:$> +# $<$:$> +# ) + +# target_include_directories( ${FOLDER_COMPILE_TARGET} +# PRIVATE +# # ${netCDF_INCLUDE_DIRS} +# ${CMAKE_CURRENT_SOURCE_DIR} +# $ +# $ + +# #!TODO Fix duplicates of wrf_[io|status]_flags.h +# # ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share +# # ${CMAKE_CURRENT_SOURCE_DIR}/../io_grib_share +# # ${CMAKE_CURRENT_SOURCE_DIR}/grib1_util +# # ${CMAKE_CURRENT_SOURCE_DIR}/MEL_grib1 +# ) + +# # Depend on framework, why? I don't know, this is a mess +# add_dependencies( +# ${FOLDER_COMPILE_TARGET} +# ${FOLDER_COMPILE_TARGET}_deps +# ${FOLDER_COMPILE_TARGET}_model_constants +# frame_deps +# phys +# ) + +# install( +# TARGETS ${FOLDER_COMPILE_TARGET} +# RUNTIME DESTINATION bin/ +# ARCHIVE DESTINATION lib/ +# LIBRARY DESTINATION lib/ +# ) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt new file mode 100644 index 0000000000..9dc561125e --- /dev/null +++ b/tools/CMakeLists.txt @@ -0,0 +1,129 @@ +# WRF CMake Build + +#!TODO ORGANIZE THIS FOLDER +set( FOLDER_COMPILE_TARGET registry ) +# get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +add_executable( + ${FOLDER_COMPILE_TARGET} + ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + registry.c + my_strtok.c + reg_parse.c + data.c + type.c + misc.c + gen_defs.c + gen_allocs.c + gen_mod_state_descr.c + gen_scalar_indices.c + gen_args.c + gen_config.c + sym.c + symtab_gen.c + gen_irr_diag.c + gen_model_data_ord.c + gen_interp.c + gen_comms.c + gen_scalar_derefs.c + set_dim_strs.c + gen_wrf_io.c + gen_streams.c + ) + +# set_target_properties( +# ${FOLDER_COMPILE_TARGET} +# PROPERTIES +# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} +# Fortran_FORMAT FREE +# ) + +target_link_libraries( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_LIBRARIES} + $<$:$> + $<$:$> + ) + +target_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) + +# Extra stuff for weird registry stuff +set( REGISTRY_FILE "NO_REGISTRY_FILE_SET" ) +if ( ${WRF_CORE} STREQUAL "ARW" ) + + if ( ${ENABLE_CHEM} ) + set( REGISTRY_FILE ${PROJECT_SOURCE_DIR}/Registry/Registry.EM_CHEM ) + + # This check does nothing + # elseif ( ${WRF_DFI_RADAR} ) + # set( REGISTRY_FILE ${PROJECT_SOURCE_DIR}/Registry/Registry.EM ) + + else() + set( REGISTRY_FILE ${PROJECT_SOURCE_DIR}/Registry/Registry.EM ) + + endif() + +elseif ( ${WRF_CORE} STREQUAL "PLUS" ) + set( REGISTRY_FILE ${PROJECT_SOURCE_DIR}/Registry/Registry.tladj ) + +elseif ( ${WRF_CORE} STREQUAL "CONVERT" ) + set( REGISTRY_FILE ${PROJECT_SOURCE_DIR}/Registry/Registry.CONVERT ) + +elseif ( ${WRF_CORE} STREQUAL "DA" OR ${WRF_CORE} STREQUAL "DA_4D_VAR" ) + if ( ${WRF_CHEM} ) + set( REGISTRY_FILE ${PROJECT_SOURCE_DIR}/Registry/Registry.wrfchemvar ) + else() + set( REGISTRY_FILE ${PROJECT_SOURCE_DIR}/Registry/Registry.wrfvar ) + endif() + +endif() + +# How this is not a bigger thing or not resolved is beyond me +# https://gitlab.kitware.com/cmake/cmake/-/issues/18005 +# Also the suggestion does not work +add_custom_command( + OUTPUT + ${CMAKE_BINARY_DIR}/inc/nl_config.inc + ${CMAKE_BINARY_DIR}/frame/module_state_description.F + WORKING_DIRECTORY + ${CMAKE_BINARY_DIR} + # Replicate what exists in project directory for registry + COMMAND + ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/Registry + COMMAND + ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/inc + COMMAND + ${CMAKE_BINARY_DIR}/tools/registry + -DEM_CORE=1 -DNMM_CORE=0 -DNMM_MAX_DIM=2600 -DDA_CORE=0 -DWRFPLUS=0 -DIWORDSIZE=4 -DDWORDSIZE=8 -DRWORDSIZE=4 -DLWORDSIZE=4 -DNONSTANDARD_SYSTEM_SUBR -DWRF_USE_CLM -DUSE_NETCDF4_FEATURES -DWRFIO_NCD_LARGE_FILE_SUPPORT -DDM_PARALLEL -DNETCDF -DLANDREAD_STUB=1 -DUSE_ALLOCATABLES -Dwrfmodel -DGRIB1 -DINTIO -DKEEP_INT_AROUND -DLIMIT_ARGS -DBUILD_RRTMG_FAST=0 -DBUILD_RRTMK=0 -DBUILD_SBM_FAST=1 -DSHOW_ALL_VARS_USED=0 -DCONFIG_BUF_LEN=65536 -DMAX_DOMAINS_F=21 -DMAX_HISTORY=25 -DNMM_NEST=0 -DNEW_BDYS ${REGISTRY_FILE} &> ${CMAKE_BINARY_DIR}/registry.log + #!TODO Just have the registry code actually check for failure or better yet rewrite the + # registry code to not be so obfuscating + COMMAND + ${CMAKE_COMMAND} -E compare_files ${CMAKE_BINARY_DIR}/inc/nl_config.inc ${CMAKE_BINARY_DIR}/inc/nl_config.inc + DEPENDS + ${FOLDER_COMPILE_TARGET} + ) + + + +add_custom_target( + registry_code + DEPENDS + ${CMAKE_BINARY_DIR}/inc/nl_config.inc + ${CMAKE_BINARY_DIR}/frame/module_state_description.F + ) + diff --git a/tools/CodeBase/CMakeLists.txt b/tools/CodeBase/CMakeLists.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/gen_comms.c b/tools/gen_comms.c new file mode 100644 index 0000000000..b079afe8d5 --- /dev/null +++ b/tools/gen_comms.c @@ -0,0 +1,15 @@ +#include +#include + +#include "protos.h" +#include "registry.h" +#include "data.h" + +int +gen_comms ( char * dirname ) +{ + if ( sw_dm_parallel ) + fprintf(stderr,"WARNING: stub version of gen_comms is linked in with registry program.\n") ; + + return(0) ; +} From 5977e85e733b121eaeacca2b68fca23b5cf95d4d Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 8 May 2023 19:01:06 -0600 Subject: [PATCH 008/180] Rename to reflect c preprocessing --- cmake/{preproc.cmake => c_preproc.cmake} | 35 +++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) rename cmake/{preproc.cmake => c_preproc.cmake} (76%) diff --git a/cmake/preproc.cmake b/cmake/c_preproc.cmake similarity index 76% rename from cmake/preproc.cmake rename to cmake/c_preproc.cmake index 2510f59175..b7671195ca 100644 --- a/cmake/preproc.cmake +++ b/cmake/c_preproc.cmake @@ -1,25 +1,25 @@ -# WRF Macro for preprocessing F files that are just... bad ifdef usage to say the least -macro( wrf_preproc_fortran ) +# WRF Macro for C preprocessing F files that are just... bad ifdef usage to say the least +macro( wrf_c_preproc_fortran ) set( options ) set( oneValueArgs TARGET_NAME SUFFIX PREFIX EXTENSION OUTPUT_DIR ) - set( multiValueArgs DEPENDENCIES INCLUDE_DIRECTORIES SOURCES DEFINITIONS GENERATED_SCOPE ) + set( multiValueArgs DEPENDENCIES INCLUDES SOURCES DEFINITIONS ) cmake_parse_arguments( WRF_PP_F "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) - #!TODO Verify -o/-I/-E/-D are all compiler independent flags + #!TODO Verify -o/-I/-E/-D/-free are all compiler independent flags - # Santitize input - if ( DEFINED WRF_PP_F_GENERATED_SCOPE ) - set( WRF_PP_F_TARGET_DIRECTORY TARGET_DIRECTORY ${WRF_PP_F_GENERATED_SCOPE} ) - endif() + # # Santitize input + # if ( DEFINED WRF_PP_F_GENERATED_SCOPE ) + # set( WRF_PP_F_TARGET_DIRECTORY TARGET_DIRECTORY ${WRF_PP_F_GENERATED_SCOPE} ) + # endif() - set( WRF_PP_F_INCLUDES ) - foreach( WRF_PP_F_INC ${WRF_PP_F_INCLUDE_DIRECTORIES} ) - list( APPEND WRF_PP_F_INCLUDES -I${WRF_PP_F_INC} ) + set( WRF_PP_F_INCLUDES_FLAGS ) + foreach( WRF_PP_F_INC ${WRF_PP_F_INCLUDES} ) + list( APPEND WRF_PP_F_INCLUDES_FLAGS -I${WRF_PP_F_INC} ) endforeach() set( WRF_PP_F_DEFS ) @@ -44,19 +44,21 @@ macro( wrf_preproc_fortran ) set( WRF_PP_F_OUTPUT ) set( WRF_PP_F_COMMANDS ) foreach( WRF_PP_F_SOURCE_FILE ${WRF_PP_F_SOURCES} ) + get_filename_component( WRF_PP_F_INPUT_SOURCE ${WRF_PP_F_SOURCE_FILE} REALPATH ) + get_filename_component( WRF_PP_F_INPUT_SOURCE_FILE_ONLY ${WRF_PP_F_SOURCE_FILE} NAME ) + if ( ${WRF_PP_F_EXTENSION} MATCHES "^[.][a-z0-9]+$" ) - string( REGEX REPLACE "[.].*$" "${WRF_PP_F_EXTENSION}" WRF_PP_F_OUTPUT_FILE ${WRF_PP_F_SOURCE_FILE} ) + string( REGEX REPLACE "[.].*$" "${WRF_PP_F_EXTENSION}" WRF_PP_F_OUTPUT_FILE ${WRF_PP_F_INPUT_SOURCE_FILE_ONLY} ) else() # Default extension - string( REGEX REPLACE "[.].*$" ".i" WRF_PP_F_OUTPUT_FILE ${WRF_PP_F_SOURCE_FILE} ) + string( REGEX REPLACE "[.].*$" ".i" WRF_PP_F_OUTPUT_FILE ${WRF_PP_F_INPUT_SOURCE_FILE_ONLY} ) endif() set( WRF_PP_F_OUTPUT_FILE ${WRF_PP_F_OUTPUT_DIR}/${WRF_PP_F_PREFIX}${WRF_PP_F_OUTPUT_FILE}${WRF_PP_F_SUFFIX} ) - get_filename_component( WRF_PP_F_INPUT_SOURCE ${WRF_PP_F_SOURCE_FILE} REALPATH ) list( APPEND WRF_PP_F_COMMANDS - COMMAND ${CMAKE_Fortran_COMPILER} -E ${WRF_PP_F_INPUT_SOURCE} ${WRF_PP_F_DEFS} ${WRF_PP_F_INCLUDES} > ${WRF_PP_F_OUTPUT_FILE} + COMMAND ${CMAKE_Fortran_COMPILER} -E ${WRF_PP_F_INPUT_SOURCE} -free ${WRF_PP_F_DEFS} ${WRF_PP_F_INCLUDES_FLAGS} > ${WRF_PP_F_OUTPUT_FILE} # Force check that they were made COMMAND ${CMAKE_COMMAND} -E compare_files ${WRF_PP_F_OUTPUT_FILE} ${WRF_PP_F_OUTPUT_FILE} ) @@ -80,7 +82,7 @@ macro( wrf_preproc_fortran ) # GENERATED TRUE # ) - message( STATUS "File ${WRF_PP_F_SOURCE_FILE} will be preprocessed into ${WRF_PP_F_OUTPUT_FILE}" ) + # message( STATUS "File ${WRF_PP_F_SOURCE_FILE} will be preprocessed into ${WRF_PP_F_OUTPUT_FILE}" ) endforeach() @@ -95,6 +97,7 @@ macro( wrf_preproc_fortran ) add_custom_target( ${WRF_PP_F_TARGET_NAME} + COMMENT "Building ${WRF_PP_F_TARGET_NAME}" DEPENDS ${WRF_PP_F_OUTPUT} ) From 2fed9116fc031e64bf0735949778199d5573d834 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 8 May 2023 19:01:59 -0600 Subject: [PATCH 009/180] Making registry work in out of source build --- tools/CMakeLists.txt | 2 ++ tools/gen_streams.c | 4 +++- tools/reg_parse.c | 15 +++++++++++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 9dc561125e..97de1176bd 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -107,6 +107,8 @@ add_custom_command( ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/Registry COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/inc + COMMAND + ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/frame COMMAND ${CMAKE_BINARY_DIR}/tools/registry -DEM_CORE=1 -DNMM_CORE=0 -DNMM_MAX_DIM=2600 -DDA_CORE=0 -DWRFPLUS=0 -DIWORDSIZE=4 -DDWORDSIZE=8 -DRWORDSIZE=4 -DLWORDSIZE=4 -DNONSTANDARD_SYSTEM_SUBR -DWRF_USE_CLM -DUSE_NETCDF4_FEATURES -DWRFIO_NCD_LARGE_FILE_SUPPORT -DDM_PARALLEL -DNETCDF -DLANDREAD_STUB=1 -DUSE_ALLOCATABLES -Dwrfmodel -DGRIB1 -DINTIO -DKEEP_INT_AROUND -DLIMIT_ARGS -DBUILD_RRTMG_FAST=0 -DBUILD_RRTMK=0 -DBUILD_SBM_FAST=1 -DSHOW_ALL_VARS_USED=0 -DCONFIG_BUF_LEN=65536 -DMAX_DOMAINS_F=21 -DMAX_HISTORY=25 -DNMM_NEST=0 -DNEW_BDYS ${REGISTRY_FILE} &> ${CMAKE_BINARY_DIR}/registry.log diff --git a/tools/gen_streams.c b/tools/gen_streams.c index f93cf3989d..e6cbda002d 100644 --- a/tools/gen_streams.c +++ b/tools/gen_streams.c @@ -607,12 +607,14 @@ gen_med_find_esmf_coupling ( FILE *fp ) for each stream. This file is then included by the registry.io_boilerplate file when the registry actually runs. As with the other mods above, this allows a variable, compile-time number of io streams. Note that this one is self contained and dirname is hard-coded. + AI: In an effort to delineate true source files from autogen stuff this is now not going into hard-coded + Registry so that we can use ./ as an alternate include location */ int gen_io_boilerplate () { FILE * fp ; - char * dirname = "Registry" ; + char * dirname = "./" ; char fname[NAMELEN] ; char * fn ; char * aux , *streamtype , streamno[5] ; diff --git a/tools/reg_parse.c b/tools/reg_parse.c index 01176c0ea4..5321b58402 100644 --- a/tools/reg_parse.c +++ b/tools/reg_parse.c @@ -116,21 +116,28 @@ pre_parse( char * dir, FILE * infile, FILE * outfile ) for ( p = inln ; ( *p == ' ' || *p == ' ' ) && *p != '\0' ; p++ ) ; if ( !strncmp( p , "include", 7 ) && ! ( ifdef_stack_ptr >= 0 && ! ifdef_stack[ifdef_stack_ptr] ) ) { FILE *include_fp ; + char include_file_name_dir[128] ; char include_file_name[128] ; p += 7 ; for ( ; ( *p == ' ' || *p == ' ' ) && *p != '\0' ; p++ ) ; if ( strlen( p ) > 127 ) { fprintf(stderr,"Registry warning: invalid include file name: %s\n", p ) ; } else { - sprintf( include_file_name , "%s/%s", dir , p ) ; + + sprintf( include_file_name, "%s", p ) ; if ( (p=index(include_file_name,'\n')) != NULL ) *p = '\0' ; + sprintf( include_file_name_dir, "%s/%s", dir , include_file_name ) ; + fprintf(stderr,"opening %s\n",include_file_name) ; - if (( include_fp = fopen( include_file_name , "r" )) != NULL ) { + if ( ( ( include_fp = fopen( include_file_name, "r" ) ) != NULL ) || // Use short circuit logic here to try both sequentially + ( ( include_fp = fopen( include_file_name_dir, "r" ) ) != NULL ) ) + { fprintf(stderr,"including %s\n",include_file_name ) ; pre_parse( dir , include_fp , outfile ) ; fclose( include_fp ) ; - } else { - fprintf(stderr,"Registry warning: cannot open %s. Ignoring.\n", include_file_name ) ; + } + else { + fprintf(stderr,"Registry warning: cannot open %s. Tried %s and %s Ignoring.\n", include_file_name, include_file_name, include_file_name_dir ) ; } } } From f8f35b3dbaba7ec0e9739eff4e3b762c9afdfc37 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:32:39 -0600 Subject: [PATCH 010/180] Splitting out helper macro for definition expansion --- cmake/c_preproc.cmake | 67 +++++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/cmake/c_preproc.cmake b/cmake/c_preproc.cmake index b7671195ca..e8eb03c7bf 100644 --- a/cmake/c_preproc.cmake +++ b/cmake/c_preproc.cmake @@ -22,22 +22,26 @@ macro( wrf_c_preproc_fortran ) list( APPEND WRF_PP_F_INCLUDES_FLAGS -I${WRF_PP_F_INC} ) endforeach() - set( WRF_PP_F_DEFS ) - foreach( WRF_PP_F_DEF ${WRF_PP_F_DEFINITIONS} ) - if ( NOT ${WRF_PP_F_DEF} MATCHES ".*-D.*" ) - # We have a generator expression, inject the -D correctly - if ( ${WRF_PP_F_DEF} MATCHES "^[$]<" ) - # Take advantage of the fact that the first time a generator expression ends to finally - # name the define it has the first ">:" then unexpanded characters (hopefully) - # 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_PP_F_DEF_SANITIZED ${WRF_PP_F_DEF} ) - list( APPEND WRF_PP_F_DEFS ${WRF_PP_F_DEF_SANITIZED} ) - else() - list( APPEND WRF_PP_F_DEFS -D${WRF_PP_F_DEF} ) - endif() - endif() + wrf_expand_definitions( + RESULT_VAR WRF_PP_F_DEFS + DEFINITIONS ${WRF_PP_F_DEFINITIONS} + ) + # set( WRF_PP_F_DEFS ) + # foreach( WRF_PP_F_DEF ${WRF_PP_F_DEFINITIONS} ) + # if ( NOT ${WRF_PP_F_DEF} MATCHES ".*-D.*" ) + # # We have a generator expression, inject the -D correctly + # if ( ${WRF_PP_F_DEF} MATCHES "^[$]<" ) + # # Take advantage of the fact that the first time a generator expression ends to finally + # # name the define it has the first ">:" then unexpanded characters (hopefully) + # # 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_PP_F_DEF_SANITIZED ${WRF_PP_F_DEF} ) + # list( APPEND WRF_PP_F_DEFS ${WRF_PP_F_DEF_SANITIZED} ) + # else() + # list( APPEND WRF_PP_F_DEFS -D${WRF_PP_F_DEF} ) + # endif() + # endif() - endforeach() + # endforeach() # Generate compile command and file outputs @@ -101,4 +105,37 @@ macro( wrf_c_preproc_fortran ) DEPENDS ${WRF_PP_F_OUTPUT} ) +endmacro() + +# Helper macro to take current defintions and santize them with -D, compatible with generator expressions +# for use when definitions are needed at generation time for custom commands +macro( wrf_expand_definitions ) + set( options ) + set( oneValueArgs RESULT_VAR ) + set( multiValueArgs DEFINITIONS ) + + cmake_parse_arguments( + WRF_EXP + "${options}" "${oneValueArgs}" "${multiValueArgs}" + ${ARGN} + ) + + 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 + if ( ${WRF_EXP_DEF} MATCHES "^[$]<" ) + # Take advantage of the fact that the first time a generator expression ends to finally + # name the define it has the first ">:" then unexpanded characters (hopefully) + # 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} ) + else() + list( APPEND WRF_EXP_DEFS -D${WRF_EXP_DEF} ) + endif() + endif() + + endforeach() + + set( ${WRF_EXP_RESULT_VAR} ${WRF_EXP_DEFS} ) endmacro() \ No newline at end of file From b62817bd3b7079d7183927c6a329fe150c06956f Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:33:59 -0600 Subject: [PATCH 011/180] Simplifying #if[n]defs --- dyn_em/module_advect_em.F | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dyn_em/module_advect_em.F b/dyn_em/module_advect_em.F index ff03d1a695..2913ac5a9c 100644 --- a/dyn_em/module_advect_em.F +++ b/dyn_em/module_advect_em.F @@ -1,7 +1,7 @@ !WRF:MODEL_LAYER:DYNAMICS ! -#if ( defined(ADVECT_KERNEL) ) +#ifdef ADVECT_KERNEL ! cpp -traditional-cpp -P -DADVECT_KERNEL module_advect_em.F > advection_kernel.f90 ! gfortran -ffree-form -ffree-line-length-none advection_kernel.f90 ! ./a.out @@ -111,7 +111,7 @@ SUBROUTINE column (loop , data_list, its,ite) END SUBROUTINE column !---------------------------------------------------------------- -#elif ( ! defined(ADVECT_KERNEL) ) +#else MODULE module_advect_em @@ -4357,7 +4357,7 @@ SUBROUTINE advect_scalar ( field, field_old, tendency, & ENDIF vert_order_test END SUBROUTINE advect_scalar -#if ( ! defined(ADVECT_KERNEL) ) +#ifndef ADVECT_KERNEL !--------------------------------------------------------------------------------- @@ -10543,7 +10543,7 @@ END SUBROUTINE advect_scalar_mono !----------------------------------------------------------- -#if ( defined(ADVECT_KERNEL) ) +#ifdef ADVECT_KERNEL END MODULE advection_kernel !================================================================ @@ -10851,7 +10851,7 @@ PROGRAM feeder END PROGRAM feeder #endif -#if ( !defined(ADVECT_KERNEL) ) +#ifndef ADVECT_KERNEL !--------------------------------------------------------------------------------- From 4fa4b994ea11990e375fb802cbe0f2352a56d7b0 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:34:34 -0600 Subject: [PATCH 012/180] Adding missing & --- dyn_em/module_first_rk_step_part1.F | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dyn_em/module_first_rk_step_part1.F b/dyn_em/module_first_rk_step_part1.F index 527eb72a62..0ade285dff 100644 --- a/dyn_em/module_first_rk_step_part1.F +++ b/dyn_em/module_first_rk_step_part1.F @@ -925,7 +925,7 @@ SUBROUTINE first_rk_step_part1 ( grid , config_flags & & ,iopt_crop=config_flags%opt_crop, iopt_irr=config_flags%opt_irr & & ,iopt_irrm=config_flags%opt_irrm & & ,iopt_infdv=config_flags%opt_infdv,iopt_tdrn=config_flags%opt_tdrn & - & ,soiltstep=config_flags%soiltstep + & ,soiltstep=config_flags%soiltstep & & , isnowxy=grid%isnowxy , tvxy=grid%tvxy , tgxy=grid%tgxy & & ,canicexy=grid%canicexy ,canliqxy=grid%canliqxy, eahxy=grid%eahxy & & , tahxy=grid%tahxy , cmxy=grid%cmxy , chxy=grid%chxy & From 713cc585ebdb3dd236d79b6e86801750bc52a161 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:36:24 -0600 Subject: [PATCH 013/180] Making registry runner take known defs --- tools/CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 97de1176bd..11ce867b3e 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -93,6 +93,12 @@ 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} + ) + # How this is not a bigger thing or not resolved is beyond me # https://gitlab.kitware.com/cmake/cmake/-/issues/18005 # Also the suggestion does not work @@ -110,8 +116,9 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/frame COMMAND - ${CMAKE_BINARY_DIR}/tools/registry - -DEM_CORE=1 -DNMM_CORE=0 -DNMM_MAX_DIM=2600 -DDA_CORE=0 -DWRFPLUS=0 -DIWORDSIZE=4 -DDWORDSIZE=8 -DRWORDSIZE=4 -DLWORDSIZE=4 -DNONSTANDARD_SYSTEM_SUBR -DWRF_USE_CLM -DUSE_NETCDF4_FEATURES -DWRFIO_NCD_LARGE_FILE_SUPPORT -DDM_PARALLEL -DNETCDF -DLANDREAD_STUB=1 -DUSE_ALLOCATABLES -Dwrfmodel -DGRIB1 -DINTIO -DKEEP_INT_AROUND -DLIMIT_ARGS -DBUILD_RRTMG_FAST=0 -DBUILD_RRTMK=0 -DBUILD_SBM_FAST=1 -DSHOW_ALL_VARS_USED=0 -DCONFIG_BUF_LEN=65536 -DMAX_DOMAINS_F=21 -DMAX_HISTORY=25 -DNMM_NEST=0 -DNEW_BDYS ${REGISTRY_FILE} &> ${CMAKE_BINARY_DIR}/registry.log + ${CMAKE_BINARY_DIR}/tools/registry ${REGISTRY_DEFS} -DNEW_BDYS ${REGISTRY_FILE} &> ${CMAKE_BINARY_DIR}/registry.log + # -DNONSTANDARD_SYSTEM_SUBR -DWRF_USE_CLM -DUSE_NETCDF4_FEATURES -DWRFIO_NCD_LARGE_FILE_SUPPORT -DDM_PARALLEL -DNETCDF -DLANDREAD_STUB=1 -DUSE_ALLOCATABLES -Dwrfmodel -DGRIB1 -DINTIO -DKEEP_INT_AROUND -DLIMIT_ARGS -DBUILD_RRTMG_FAST=0 -DBUILD_RRTMK=0 -DBUILD_SBM_FAST=1 -DSHOW_ALL_VARS_USED=0 -DCONFIG_BUF_LEN=65536 -DMAX_DOMAINS_F=21 -DMAX_HISTORY=25 -DNMM_NEST=0 -DNEW_BDYS ${REGISTRY_FILE} &> ${CMAKE_BINARY_DIR}/registry.log + #!TODO Just have the registry code actually check for failure or better yet rewrite the # registry code to not be so obfuscating COMMAND From 29df3b5a901add1089227712a41deed2b08d8d29 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:37:21 -0600 Subject: [PATCH 014/180] Adding folders to build --- chem/CMakeLists.txt | 226 ++++++++++++++++++++++++++++++++++++++++++ dyn_em/CMakeLists.txt | 45 +++++++++ 2 files changed, 271 insertions(+) create mode 100644 chem/CMakeLists.txt create mode 100644 dyn_em/CMakeLists.txt diff --git a/chem/CMakeLists.txt b/chem/CMakeLists.txt new file mode 100644 index 0000000000..9bfbf3d5ac --- /dev/null +++ b/chem/CMakeLists.txt @@ -0,0 +1,226 @@ +# WRF CMake Build +target_include_directories( + ${PROJECT_NAME}_Core + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ) + +######################################################################################################################## +# +# Now add sources +# +######################################################################################################################## +target_sources( + ${PROJECT_NAME}_Core + PRIVATE + module_data_isrpia_data.F + module_data_ISRPIA.F + module_data_isrpia_asrc.F + module_data_isrpia_solut.F + module_data_isrpia_kmc198.F + module_data_isrpia_kmc223.F + module_data_isrpia_kmc248.F + module_data_isrpia_kmc273.F + module_data_isrpia_kmc298.F + module_data_isrpia_kmc323.F + module_data_isrpia_expnc.F + module_data_isrpia_caseg.F + module_data_isrpia_casej.F + isofwd.F + isorev.F + isocom.F + moduleHETDATA.F + moduleHETAERO.F + moduleAERODATA.F + aerorate_so2.F + module_aer_opt_out.F + module_add_emiss_burn.F + module_add_emis_cptec.F + module_bioemi_beis314.F + module_chem_utilities.F + module_cmu_dvode_solver.F + module_data_cbmz.F + module_data_cmu_bulkaqchem.F + module_data_gocartchem.F + module_data_gocart_seas.F + module_data_mosaic_kind.F + module_data_mosaic_constants.F + module_data_mosaic_aero.F + module_data_mosaic_main.F + module_data_mosaic_asect.F + module_data_mosaic_asecthp.F + module_data_mosaic_boxmod.F + module_data_mosaic_other.F + module_data_mosaic_therm.F + module_data_radm2.F + module_data_rrtmgaeropt.F + module_data_megan2.F + module_data_soa_vbs.F + module_data_soa_vbs_het.F + module_data_sorgam.F + module_data_sorgam_vbs.F + module_ftuv_subs.F + module_ghg_fluxes.F + module_gocart_drydep.F + module_gocart_settling.F + module_gocart_so2so4.F + module_input_tracer_data.F + module_interpolate.F + module_mosaic_csuesat.F + module_mozcart_wetscav.F + module_peg_util.F + module_tropopause.F + module_upper_bc_driver.F + module_vertmx_wrf.F + module_wave_data.F + module_wetdep_ls.F + module_zero_plumegen_coms.F + module_vash_settling.F + module_chem_plumerise_scalar.F + module_dep_simple.F + module_gocart_dmsemis.F + module_gocart_aerosols.F + module_gocart_dust.F + module_gocart_dust_afwa.F + module_gocart_seasalt.F + module_uoc_dust.F + module_qf03.F + module_soilpsd.F + module_dust_load.F + module_uoc_dustwd.F + module_data_uoc_wd.F + module_mosaic_addemiss.F + module_mosaic_initmixrats.F + module_mosaic_support.F + module_mosaic_init_aerpar.F + module_mosaic_ext.F + module_mosaic_astem.F + module_mosaic_lsode.F + module_mosaic_box_aerchem.F + module_mosaic_aerchem_intr.F + module_mosaic_coag1d.F + module_mosaic_coag3d.F + module_mosaic_movesect1d.F + module_mosaic_movesect3d.F + module_mosaic_newnucb.F + module_mosaic_sect_intr.F + module_mosaic_aerdynam_intr.F + module_mosaic_movesect.F + module_mosaic_newnuc.F + module_mosaic_soa_vbs.F + module_cbmz_lsodes_solver.F + module_cbmz_rodas3_solver.F + module_cmu_bulkaqchem.F + module_data_mgn2mech.F + module_ftuv_driver.F + module_fastj_data.F + module_fastj_mie.F + module_input_chem_data.F + module_mosaic_coag.F + module_mosaic_gly.F + module_mosaic_wetscav.F + module_mosaic_therm.F + module_phot_mad.F + params.mod.F #!TODO Rename this please + numer.F + rdxs.F + rxn.F + params_mod.F + module_phot_tuv.F + module_subs_tuv.F + rtrans.F + la_srb.F + module_radm.F + module_sorgam_aqchem.F + module_sorgam_vbs_aqchem.F + module_aerosols_soa_vbs.F + module_aerosols_soa_vbs_het.F + module_aerosols_sorgam.F + module_aerosols_sorgam_vbs.F + module_bioemi_megan2.F + module_bioemi_simple.F + module_cbm4_initmixrats.F + module_cb05_initmixrats.F + module_cb05_vbs_initmixrats.F + module_cbmz.F + module_cbmz_initmixrats.F + module_cbmz_rodas_prep.F + module_ctrans_grell.F + module_gocart_chem.F + module_input_tracer.F + module_lightning_nox_driver.F + module_lightning_nox_ott.F + module_lightning_nox_decaria.F + module_mixactivate_wrappers.F + module_mosaic_init_aerpar.F + module_mosaic2_driver.F + module_mosaic_sumpm.F + module_mosaic_driver.F + module_optical_averaging.F + module_plumerise1.F + module_mosaic_drydep.F + module_wetscav_driver.F + module_prep_wetscav_sorgam.F + module_input_chem_bioemiss.F + module_input_dust_errosion.F + module_input_gocart_dms.F + module_cbmz_addemiss.F + module_cbm4_addemiss.F + module_cb05_addemiss.F + module_emissions_anthropogenics.F + module_aer_drydep.F + module_cam_mam_calcsize.F + module_cam_mam_dust_sediment.F + module_cam_mam_drydep.F + module_cam_mam_init.F + module_cam_mam_initaerodata.F + module_cam_mam_initmixrats.F + module_cam_mam_rename.F + module_cam_mam_wateruptake.F + module_cam_mam_gasaerexch.F + module_cam_mam_coag.F + module_cam_mam_newnuc.F + module_cam_mam_aerchem_driver.F + module_cam_mam_addemiss.F + module_cam_mam_wetscav.F + module_cam_mam_mz_aerosols_intr.F + module_cam_mam_wetdep.F + module_cam_mam_cloudchem.F + module_cam_mam_setsox.F + module_cam_mam_mo_chem_utls.F + module_mosaic_cloudchem.F + module_sorgam_cloudchem.F + module_sorgam_vbs_cloudchem.F + module_cam_mam_gas_wetdep_driver.F + module_cam_mam_mo_sethet.F + module_phot_fastj.F + module_chem_cup.F + module_isocom.F + module_isofwd.F + module_isorev.F + chemics_init.F + chem_driver.F + cloudchem_driver.F + photolysis_driver.F + optical_driver.F + mechanism_driver.F + emissions_driver.F + dry_dep_driver.F + aerosol_driver.F + ) + +######################################################################################################################## +# +# convert_emiss executable +# +######################################################################################################################## +add_executable( + convert_emiss + convert_emiss.F + ) + +target_link_libraries( + convert_emiss + PRIVATE + ${PROJECT_NAME}_Core + ) \ No newline at end of file diff --git a/dyn_em/CMakeLists.txt b/dyn_em/CMakeLists.txt new file mode 100644 index 0000000000..bff8b38e5d --- /dev/null +++ b/dyn_em/CMakeLists.txt @@ -0,0 +1,45 @@ +# WRF CMake Build +target_include_directories( + ${PROJECT_NAME}_Core + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ) + +######################################################################################################################## +# +# Now add sources +# +######################################################################################################################## +target_sources( + ${PROJECT_NAME}_Core + PRIVATE + module_advect_em.F + module_ieva_em.F + module_diffusion_em.F + module_small_step_em.F + module_big_step_utilities_em.F + module_em.F + module_solvedebug_em.F + module_bc_em.F + module_init_utilities.F + module_wps_io_arw.F + module_damping_em.F + module_polarfft.F + module_force_scm.F + module_first_rk_step_part1.F + module_first_rk_step_part2.F + module_avgflx_em.F + module_sfs_nba.F + module_convtrans_prep.F + module_sfs_driver.F + module_stoch.F + module_after_all_rk_steps.F + init_modules_em.F + solve_em.F + start_em.F + shift_domain_em.F + couple_or_uncouple_em.F + nest_init_utils.F + adapt_timestep_em.F + interp_domain_em.F + ) From 7ecc386ea6438cc679ee3400e10096bdc08e22b0 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:40:14 -0600 Subject: [PATCH 015/180] Preprocessing into f90 --- phys/CMakeLists.txt | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/phys/CMakeLists.txt b/phys/CMakeLists.txt index 1f8afc9829..7713f324f6 100644 --- a/phys/CMakeLists.txt +++ b/phys/CMakeLists.txt @@ -9,21 +9,22 @@ # ######################################################################################################################## get_directory_property( DIR_DEFS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS ) -wrf_preproc_fortran( - TARGET_NAME module_ra_rrtmg_lwk_preproc - GENERATED_SCOPE ${PROJECT_NAME}_Core - OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ - EXTENSION ".i" - INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} - # $ - # $ - # $ - DEPENDENCIES registry_code - DEFINITIONS ${DIR_DEFS} - SOURCES module_ra_rrtmg_lwk.F - module_ra_rrtmg_swk.F - module_sf_clm.F - ) +wrf_c_preproc_fortran( + TARGET_NAME module_ra_rrtmg_lwk_preproc + OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ + EXTENSION ".f90" + INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} + # $ + # $ + # $ + DEPENDENCIES registry_code + DEFINITIONS ${DIR_DEFS} + SOURCES module_ra_rrtmg_lwk.F + module_ra_rrtmg_lwf.F + module_ra_rrtmg_swk.F + module_ra_rrtmg_swf.F + module_sf_clm.F + ) add_dependencies( ${PROJECT_NAME}_Core module_ra_rrtmg_lwk_preproc ) # set_source_files_properties( @@ -203,13 +204,15 @@ target_sources( module_ra_rrtm.F module_ra_rrtmg_aero_optical_util_cmaq.F module_ra_rrtmg_lw.F - module_ra_rrtmg_lwf.F + # module_ra_rrtmg_lwf.F + ${CMAKE_CURRENT_BINARY_DIR}/preproc/module_ra_rrtmg_lwf.f90 # module_ra_rrtmg_lwk.F - ${CMAKE_CURRENT_BINARY_DIR}/preproc/module_ra_rrtmg_lwk.i + ${CMAKE_CURRENT_BINARY_DIR}/preproc/module_ra_rrtmg_lwk.f90 module_ra_rrtmg_sw.F - module_ra_rrtmg_swf.F + # module_ra_rrtmg_swf.F + ${CMAKE_CURRENT_BINARY_DIR}/preproc/module_ra_rrtmg_swf.f90 # module_ra_rrtmg_swk.F - ${CMAKE_CURRENT_BINARY_DIR}/preproc/module_ra_rrtmg_swk.i + ${CMAKE_CURRENT_BINARY_DIR}/preproc/module_ra_rrtmg_swk.f90 module_ra_sw.F module_radiation_driver.F @@ -218,7 +221,7 @@ target_sources( module_sf_bep.F module_sf_bep_bem.F # module_sf_clm.F - ${CMAKE_CURRENT_BINARY_DIR}/preproc/module_sf_clm.i + ${CMAKE_CURRENT_BINARY_DIR}/preproc/module_sf_clm.f90 module_sf_ctsm.F module_sf_exchcoef.F module_sf_fogdes.F From 65e54fa822bf6495efad7dc3cc330bf50a37bd51 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:40:59 -0600 Subject: [PATCH 016/180] Various helper or missing modules --- cmake/confcheck.cmake | 130 +++++++++++++++++++++++++++++++++ cmake/m4_preproc.cmake | 78 ++++++++++++++++++++ cmake/modules/FindJasper.cmake | 59 +++++++++++++++ cmake/modules/FindRPC.cmake | 59 +++++++++++++++ cmake/target_copy.cmake | 75 +++++++++++++++++++ 5 files changed, 401 insertions(+) create mode 100644 cmake/confcheck.cmake create mode 100644 cmake/m4_preproc.cmake create mode 100644 cmake/modules/FindJasper.cmake create mode 100644 cmake/modules/FindRPC.cmake create mode 100644 cmake/target_copy.cmake diff --git a/cmake/confcheck.cmake b/cmake/confcheck.cmake new file mode 100644 index 0000000000..0838637ce9 --- /dev/null +++ b/cmake/confcheck.cmake @@ -0,0 +1,130 @@ +# 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 ) + +macro( 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 ) + + cmake_parse_arguments( + WRF_CFG + "${options}" "${oneValueArgs}" "${multiValueArgs}" + ${ARGN} + ) + + get_filename_component( WRF_CFG_SOURCE_FILE ${WRF_CFG_SOURCE} REALPATH ) + file( READ ${WRF_CFG_SOURCE_FILE} 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() + 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() + + 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} + ) + 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() + 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}}" ) ) + set( WRF_CFG_MSG_TYPE STATUS ) + if ( DEFINED WRF_CFG_REQUIRED AND ${WRF_CFG_REQUIRED} ) + set( WRF_CFG_MSG_TYPE FATAL_ERROR ) + endif() + + if ( DEFINED 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" ) + endif() + endif() + +endmacro() + + diff --git a/cmake/m4_preproc.cmake b/cmake/m4_preproc.cmake new file mode 100644 index 0000000000..b75ee49a11 --- /dev/null +++ b/cmake/m4_preproc.cmake @@ -0,0 +1,78 @@ +# WRF Macro for m4 preprocessing F files +macro( wrf_m4_preproc_fortran ) + + set( options ) + set( oneValueArgs TARGET_NAME SUFFIX PREFIX EXTENSION OUTPUT_DIR M4_PROGRAM ) + set( multiValueArgs DEPENDENCIES SOURCES M4_FLAGS ) + + cmake_parse_arguments( + WRF_PP + "${options}" "${oneValueArgs}" "${multiValueArgs}" + ${ARGN} + ) + set( WRF_PP_M4_PROGRAM_TO_USE m4 ) + if ( DEFINED WRF_PP_M4_PROGRAM ) + set( WRF_PP_M4_PROGRAM_TO_USE ${WRF_PP_M4_PROGRAM} ) + endif() + + # Generate compile command and file outputs + set( WRF_PP_OUTPUT ) + set( WRF_PP_COMMANDS ) + foreach( WRF_PP_SOURCE_FILE ${WRF_PP_SOURCES} ) + get_filename_component( WRF_PP_INPUT_SOURCE ${WRF_PP_SOURCE_FILE} REALPATH ) + get_filename_component( WRF_PP_INPUT_SOURCE_FILE_ONLY ${WRF_PP_SOURCE_FILE} NAME ) + + if ( ${WRF_PP_EXTENSION} MATCHES "^[.][a-z0-9]+$" ) + string( REGEX REPLACE "[.].*$" "${WRF_PP_EXTENSION}" WRF_PP_OUTPUT_FILE ${WRF_PP_INPUT_SOURCE_FILE_ONLY} ) + else() + # Default extension + string( REGEX REPLACE "[.].*$" ".i" WRF_PP_OUTPUT_FILE ${WRF_PP_INPUT_SOURCE_FILE_ONLY} ) + endif() + + set( WRF_PP_OUTPUT_FILE ${WRF_PP_OUTPUT_DIR}/${WRF_PP_PREFIX}${WRF_PP_OUTPUT_FILE}${WRF_PP_SUFFIX} ) + + + list( + APPEND WRF_PP_COMMANDS + COMMAND ${WRF_PP_M4_PROGRAM_TO_USE} ${WRF_PP_M4_FLAGS} ${WRF_PP_INPUT_SOURCE} > ${WRF_PP_OUTPUT_FILE} + # Force check that they were made + COMMAND ${CMAKE_COMMAND} -E compare_files ${WRF_PP_OUTPUT_FILE} ${WRF_PP_OUTPUT_FILE} + ) + list( + APPEND WRF_PP_OUTPUT + ${WRF_PP_OUTPUT_FILE} + ) + + # # Tell all targets that eventually use this file that it is generated - this is useful if this macro is used in a + # # different directory than where the target dependency is set + # # Thanks to https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-add-a-dependency-to-a-source-file-which-is-generated-in-a-subdirectory + # # and https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/ + # # It keeps getting better lol + # # https://gitlab.kitware.com/cmake/cmake/-/issues/18399 + # # We could use cmake 3.20+ and CMP0118, but this allows usage from 3.18.6+ + # TL;DR - This doesn't work despite all documentation stating otherwise, need to use CMP0118 + # set_source_files_properties( + # ${WRF_PP_OUTPUT_FILE} + # ${WRF_PP_TARGET_DIRECTORY} + # PROPERTIES + # GENERATED TRUE + # ) + + # message( STATUS "File ${WRF_PP_SOURCE_FILE} will be preprocessed into ${WRF_PP_OUTPUT_FILE}" ) + + endforeach() + + # Preprocess sources into a custom target + add_custom_command( + OUTPUT ${WRF_PP_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E make_directory ${WRF_PP_OUTPUT_DIR} + ${WRF_PP_COMMANDS} + COMMENT "Preprocessing ${WRF_PP_TARGET_NAME}" + DEPENDS ${WRF_PP_DEPENDENCIES} + ) + + add_custom_target( + ${WRF_PP_TARGET_NAME} + DEPENDS ${WRF_PP_OUTPUT} + ) +endmacro() diff --git a/cmake/modules/FindJasper.cmake b/cmake/modules/FindJasper.cmake new file mode 100644 index 0000000000..68daa26f92 --- /dev/null +++ b/cmake/modules/FindJasper.cmake @@ -0,0 +1,59 @@ +# Find Jasper +# Eventually replace with Jasper's actual config if using that +# Once found this file will define: +# Jasper_FOUND - System has Jasper +# Jasper_INCLUDE_DIRS - The Jasper include directories +# Jasper_LIBRARIES - The libraries needed to use Jasper + +find_package( PkgConfig ) +pkg_check_modules( PC_Jasper QUIET Jasper ) +# set(CMAKE_FIND_DEBUG_MODE TRUE) +find_path( + Jasper_INCLUDE_DIR + NAMES jasper/jasper.h # Make it so we go up one dir + # Hints before PATHS + HINTS ENV Jasper_ROOT ENV JASPERINC ENV JASPER_PATH ${Jasper_ROOT} ${JASPERINC} ${JASPER_PATH} + PATHS ${PC_Jasper_INCLUDE_DIRS} + PATH_SUFFIXES Jasper jasper include #include/jasper + ) +find_library( + Jasper_LIBRARY + NAMES jasper + # Hints before PATHS + HINTS ENV Jasper_ROOT ENV JASPERLIB ENV JASPER_PATH ${Jasper_ROOT} ${JASPERLIB} ${JASPER_PATH} + PATHS ${PC_Jasper_LIBRARY_DIRS} + PATH_SUFFIXES lib + ) + +# set(CMAKE_FIND_DEBUG_MODE FALSE) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + Jasper + FOUND_VAR Jasper_FOUND + REQUIRED_VARS + Jasper_LIBRARY + Jasper_INCLUDE_DIR + # VERSION_VAR Jasper_VERSION + ) + +if ( Jasper_FOUND AND NOT TARGET Jasper::Jasper ) + add_library( Jasper::Jasper UNKNOWN IMPORTED ) + set_target_properties( + Jasper::Jasper + PROPERTIES + IMPORTED_LOCATION "${Jasper_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${PC_Jasper_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Jasper_INCLUDE_DIR}" + ) + + # Allow traditional/legacy style usage + set( Jasper_LIBRARIES ${Jasper_LIBRARY} ) + set( Jasper_INCLUDE_DIRS ${Jasper_INCLUDE_DIR} ) + set( Jasper_DEFINITIONS ${PC_Jasper_CFLAGS_OTHER} ) + + mark_as_advanced( + Jasper_INCLUDE_DIR + Jasper_LIBRARY + ) +endif() \ No newline at end of file diff --git a/cmake/modules/FindRPC.cmake b/cmake/modules/FindRPC.cmake new file mode 100644 index 0000000000..fbbbbda36f --- /dev/null +++ b/cmake/modules/FindRPC.cmake @@ -0,0 +1,59 @@ +# Find RPC +# Eventually replace with RPC's actual config if using that +# Once found this file will define: +# RPC_FOUND - System has RPC +# RPC_INCLUDE_DIRS - The RPC include directories +# RPC_LIBRARIES - The libraries needed to use RPC + +find_package( PkgConfig ) +pkg_check_modules( PC_RPC QUIET RPC ) +# set(CMAKE_FIND_DEBUG_MODE TRUE) +find_path( + RPC_INCLUDE_DIR + NAMES rpc/types.h # Make it so we go up one dir + # Hints before PATHS + HINTS ENV RPC_ROOT ENV RPCINC ENV RPC_PATH ${RPC_ROOT} ${RPCINC} ${RPC_PATH} + PATHS ${PC_RPC_INCLUDE_DIRS} + PATH_SUFFIXES tirpc + ) +find_library( + RPC_LIBRARY + NAMES rpc rpcsvc + # Hints before PATHS + HINTS ENV RPC_ROOT ENV RPCLIB ENV RPC_PATH ${RPC_ROOT} ${RPCLIB} ${RPC_PATH} + PATHS ${PC_RPC_LIBRARY_DIRS} + PATH_SUFFIXES lib + ) + +# set(CMAKE_FIND_DEBUG_MODE FALSE) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + RPC + FOUND_VAR RPC_FOUND + REQUIRED_VARS + RPC_LIBRARY + RPC_INCLUDE_DIR + # VERSION_VAR RPC_VERSION + ) + +if ( RPC_FOUND AND NOT TARGET RPC::RPC ) + add_library( RPC::RPC UNKNOWN IMPORTED ) + set_target_properties( + RPC::RPC + PROPERTIES + IMPORTED_LOCATION "${RPC_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${PC_RPC_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${RPC_INCLUDE_DIR}" + ) + + # Allow traditional/legacy style usage + set( RPC_LIBRARIES ${RPC_LIBRARY} ) + set( RPC_INCLUDE_DIRS ${RPC_INCLUDE_DIR} ) + set( RPC_DEFINITIONS ${PC_RPC_CFLAGS_OTHER} ) + + mark_as_advanced( + RPC_INCLUDE_DIR + RPC_LIBRARY + ) +endif() \ No newline at end of file diff --git a/cmake/target_copy.cmake b/cmake/target_copy.cmake new file mode 100644 index 0000000000..429eddc976 --- /dev/null +++ b/cmake/target_copy.cmake @@ -0,0 +1,75 @@ +# WRF Macro for copying files with generated dependency +# https://stackoverflow.com/a/34800230 +macro( wrf_copy_source_files ) + + set( options ) + set( oneValueArgs TARGET_NAME SUFFIX PREFIX EXTENSION OUTPUT_DIR ) + set( multiValueArgs DEPENDENCIES SOURCES ) + + cmake_parse_arguments( + WRF_COPY + "${options}" "${oneValueArgs}" "${multiValueArgs}" + ${ARGN} + ) + + # Generate compile command and file outputs + set( WRF_COPY_OUTPUT ) + set( WRF_COPY_COMMANDS ) + foreach( WRF_COPY_SOURCE_FILE ${WRF_COPY_SOURCES} ) + get_filename_component( WRF_COPY_INPUT_SOURCE ${WRF_COPY_SOURCE_FILE} REALPATH ) + get_filename_component( WRF_COPY_INPUT_SOURCE_FILE_ONLY ${WRF_COPY_SOURCE_FILE} NAME ) + + if ( ${WRF_COPY_EXTENSION} MATCHES "^[.][a-z0-9]+$" ) + string( REGEX REPLACE "[.].*$" "${WRF_COPY_EXTENSION}" WRF_COPY_OUTPUT_FILE ${WRF_COPY_INPUT_SOURCE_FILE_ONLY} ) + else() + # Default to original filename + set( WRF_COPY_OUTPUT_FILE ${WRF_COPY_INPUT_SOURCE_FILE_ONLY} ) + endif() + + set( WRF_COPY_OUTPUT_FILE ${WRF_COPY_OUTPUT_DIR}/${WRF_COPY_PREFIX}${WRF_COPY_OUTPUT_FILE}${WRF_COPY_SUFFIX} ) + + + list( + APPEND WRF_COPY_COMMANDS + COMMAND ${CMAKE_COMMAND} -E copy ${WRF_COPY_INPUT_SOURCE} ${WRF_COPY_OUTPUT_FILE} + # Force check that they were made + COMMAND ${CMAKE_COMMAND} -E compare_files ${WRF_COPY_OUTPUT_FILE} ${WRF_COPY_OUTPUT_FILE} + ) + list( + APPEND WRF_COPY_OUTPUT + ${WRF_COPY_OUTPUT_FILE} + ) + + # # Tell all targets that eventually use this file that it is generated - this is useful if this macro is used in a + # # different directory than where the target dependency is set + # # Thanks to https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-add-a-dependency-to-a-source-file-which-is-generated-in-a-subdirectory + # # and https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/ + # # It keeps getting better lol + # # https://gitlab.kitware.com/cmake/cmake/-/issues/18399 + # # We could use cmake 3.20+ and CMP0118, but this allows usage from 3.18.6+ + # TL;DR - This doesn't work despite all documentation stating otherwise, need to use CMP0118 + # set_source_files_properties( + # ${WRF_COPY_OUTPUT_FILE} + # ${WRF_COPY_TARGET_DIRECTORY} + # PROPERTIES + # GENERATED TRUE + # ) + + message( STATUS "File ${WRF_COPY_SOURCE_FILE} will be copied to ${WRF_COPY_OUTPUT_FILE}" ) + + endforeach() + + # Preprocess sources into a custom target + add_custom_command( + OUTPUT ${WRF_COPY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E make_directory ${WRF_COPY_OUTPUT_DIR} + ${WRF_COPY_COMMANDS} + COMMENT "Preprocessing ${WRF_COPY_TARGET_NAME}" + DEPENDS ${WRF_COPY_DEPENDENCIES} + ) + + add_custom_target( + ${WRF_COPY_TARGET_NAME} + DEPENDS ${WRF_COPY_OUTPUT} + ) +endmacro() From 3bd942cd565bec88715e5773a8cc832fa1e9269b Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:41:43 -0600 Subject: [PATCH 017/180] Runner for configure checks --- confcheck/CMakeLists.txt | 86 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 confcheck/CMakeLists.txt diff --git a/confcheck/CMakeLists.txt b/confcheck/CMakeLists.txt new file mode 100644 index 0000000000..bf204a3947 --- /dev/null +++ b/confcheck/CMakeLists.txt @@ -0,0 +1,86 @@ +# WRF configuration checks +wrf_conf_check( + RUN + RESULT_VAR Fortran_2003_IEEE + SOURCE ${PROJECT_SOURCE_DIR}/tools/fortran_2003_ieee_test.F + EXTENSION .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 + 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 + MESSAGE "Standard FLUSH routine Fortran 2003 features missing, checking for alternate Fortran_2003_FFLUSH" + ) + +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 + MESSAGE "Standard FFLUSH routine Fortran 2003 features missing, no alternate to FLUSH found, feature stubbed out" + ) +endif() + +wrf_conf_check( + RUN + RESULT_VAR Fortran_2003_GAMMA + SOURCE ${PROJECT_SOURCE_DIR}/tools/fortran_2008_gamma_test.F + EXTENSION .F + MESSAGE "Some Fortran 2003 features missing, removing usage gamma function intrinsic and stubbing code dependent on it" + ) + + + +wrf_conf_check( + RUN + SOURCE_TYPE C + RESULT_VAR FSEEKO64 + SOURCE ${PROJECT_SOURCE_DIR}/tools/fseek_test.c + EXTENSION .c + ADDITIONAL_DEFINTIONS -DTEST_FSEEKO64 + 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_DEFINTIONS -DTEST_FSEEKO + MESSAGE "fseeko not supported, compiling with fseek (caution with large files)" + ) +endif() + +if ( ${USE_MPI} ) + wrf_conf_check( + RUN + SOURCE_TYPE C + RESULT_VAR MPI2_SUPPORT + SOURCE ${PROJECT_SOURCE_DIR}/tools/mpi2_test.c + EXTENSION .c + MESSAGE "MPI_Comm_f2c() and MPI_Comm_c2f() not supported" + ) + + wrf_conf_check( + RUN + SOURCE_TYPE C + RESULT_VAR MPI2_THREAD_SUPPORT + SOURCE ${PROJECT_SOURCE_DIR}/tools/mpi2_thread_test.c + EXTENSION .c + MESSAGE "MPI_Init_thread() not supported" + ) +endif() \ No newline at end of file From c2442cf9f5041af28f440e2570f65d010e6a88e8 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:42:31 -0600 Subject: [PATCH 018/180] Noting how it might eventually be done --- external/CMakeLists.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 0c9801e87b..7402f15b7d 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -1,4 +1,23 @@ # WRF CMake Build + +# The way ncep has written these makes this difficult if not impossible to do... +# # External projects, run them inline but make an alias to their target as if +# # we "built" them ourselves - useful to avoid ExternalProject_Add() + find_package() weirdness +# # Newer versions we might need to do that since g2 relies on bacio with find_package() +# add_subdirectory( bacio ) +# add_subdirectory( g2 ) + +# # bacio v2.6.0 +# add_library( bacio::bacio ALIAS bacio ) + +# # g2 v3.1.2 +# if ( ${USE_DOUBLE} ) +# add_library( g2::g2 ALIAS g2_d ) +# else() +# add_library( g2::g2 ALIAS g2_4 ) +# endif() + + if ( AMT_OCN ) # I have no clue how this gets used add_subdirectory( atm_ocn ) From 808b12684449c675b8fdbcb08e65d681c9a5217d Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:45:19 -0600 Subject: [PATCH 019/180] I believe this was a bug, no idea how it was even working before --- external/io_grib2/g2lib/dec_png.c | 2 +- external/io_grib2/g2lib/enc_png.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/external/io_grib2/g2lib/dec_png.c b/external/io_grib2/g2lib/dec_png.c index aa85184b36..a33c0c0ac6 100644 --- a/external/io_grib2/g2lib/dec_png.c +++ b/external/io_grib2/g2lib/dec_png.c @@ -88,7 +88,7 @@ int DEC_PNG(unsigned char *pngbuf,g2int *width,g2int *height,char *cout) /* Set new custom read function */ - png_set_read_fn(png_ptr,(voidp)&read_io_ptr,(png_rw_ptr)user_read_data); + png_set_read_fn(png_ptr,(png_voidp)&read_io_ptr,(png_rw_ptr)user_read_data); /* png_init_io(png_ptr, fptr); */ /* Read and decode PNG stream */ diff --git a/external/io_grib2/g2lib/enc_png.c b/external/io_grib2/g2lib/enc_png.c index 7d2ef1d287..97d0b961a9 100644 --- a/external/io_grib2/g2lib/enc_png.c +++ b/external/io_grib2/g2lib/enc_png.c @@ -88,7 +88,7 @@ int ENC_PNG(char *data,g2int *width,g2int *height,g2int *nbits,char *pngbuf) /* Set new custom write functions */ - png_set_write_fn(png_ptr,(voidp)&write_io_ptr,(png_rw_ptr)user_write_data, + png_set_write_fn(png_ptr,(png_voidp)&write_io_ptr,(png_rw_ptr)user_write_data, (png_flush_ptr)user_flush_data); /* png_init_io(png_ptr, fptr); */ /* png_set_compression_level(png_ptr, Z_BEST_COMPRESSION); */ From 888a68cdd20f45b2ef2d814f7dd170d9ff817bd8 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:47:06 -0600 Subject: [PATCH 020/180] Compiling the rest of grib2 io --- external/io_grib2/CMakeLists.txt | 57 +++++++++++++ external/io_grib2/g2lib/CMakeLists.txt | 107 +++++++++++++++++++++++++ 2 files changed, 164 insertions(+) diff --git a/external/io_grib2/CMakeLists.txt b/external/io_grib2/CMakeLists.txt index e69de29bb2..dc7649ad1a 100644 --- a/external/io_grib2/CMakeLists.txt +++ b/external/io_grib2/CMakeLists.txt @@ -0,0 +1,57 @@ +# WRF CMake Build + +# Eventually switch to ncep tag on github but for now make this 1-to-1 with make-style WRF +add_subdirectory( g2lib ) +add_subdirectory( bacio-1.3 ) + + +# get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# add_library( +# ${FOLDER_COMPILE_TARGET} +# STATIC +# ) + +# target_sources( +# ${FOLDER_COMPILE_TARGET} +# PRIVATE +target_sources( + ${PROJECT_NAME}_Core + PRIVATE + grib2tbls_types.F + io_grib2.F + read_grib2map.F + ) + +# set_target_properties( +# ${FOLDER_COMPILE_TARGET} +# PROPERTIES +# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} +# Fortran_FORMAT FREE +# ) + + +# target_link_libraries( ${FOLDER_COMPILE_TARGET} +# PRIVATE +# ${netCDF_LIBRARIES} +# $<$:$> +# $<$:$> +# g2lib +# bacio-1.3 +# ) + +# target_include_directories( ${FOLDER_COMPILE_TARGET} +# PRIVATE +# ${netCDF_INCLUDE_DIRS} +# ${CMAKE_CURRENT_SOURCE_DIR} +# #!TODO Fix duplicates of wrf_[io|status]_flags.h +# # ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share +# ${CMAKE_CURRENT_SOURCE_DIR}/../io_grib_share +# ) + +# install( +# TARGETS ${FOLDER_COMPILE_TARGET} +# RUNTIME DESTINATION bin/ +# ARCHIVE DESTINATION lib/ +# LIBRARY DESTINATION lib/ +# ) diff --git a/external/io_grib2/g2lib/CMakeLists.txt b/external/io_grib2/g2lib/CMakeLists.txt index e69de29bb2..f69c900cdd 100644 --- a/external/io_grib2/g2lib/CMakeLists.txt +++ b/external/io_grib2/g2lib/CMakeLists.txt @@ -0,0 +1,107 @@ +# WRF CMake Build +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +add_library( + ${FOLDER_COMPILE_TARGET} + STATIC + ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + addfield.F + addgrid.F + addlocal.F + cmplxpack.F + compack.F + comunpack.F + dec_jpeg2000.c + dec_png.c + drstemplates.F + enc_jpeg2000.c + enc_png.c + g2grids.F + gb_info.F + gbytesc.F + gdt2gds.F + getdim.F + getfield.F + getg2i.F + getg2ir.F + getgb2.F + getgb2l.F + getgb2p.F + getgb2r.F + getgb2rp.F + getgb2s.F + getidx.F + getlocal.F + getpoly.F + gettemplates.F + gf_free.F + gf_getfld.F + gf_unpack1.F + gf_unpack2.F + gf_unpack3.F + gf_unpack4.F + gf_unpack5.F + gf_unpack6.F + gf_unpack7.F + gribcreate.F + gribend.F + gribinfo.F + gribmod.F + gridtemplates.F + ixgb2.F + jpcpack.F + jpcunpack.F + misspack.F + mkieee.F + mova2i.c + pack_gp.F + params.F + pdstemplates.F + pngpack.F + pngunpack.F + putgb2.F + rdieee.F + realloc.F + reduce.F + simpack.F + simunpack.F + skgb.F + specpack.F + specunpack.F + ) + +set_target_properties( + ${FOLDER_COMPILE_TARGET} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + # Fortran_FORMAT FREE + ) + + +target_link_libraries( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_LIBRARIES} + $<$:$> + $<$:$> + $ + ) + +target_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} + #!TODO Fix duplicates of wrf_[io|status]_flags.h + # ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share + ${CMAKE_CURRENT_SOURCE_DIR}/../io_grib_share + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) From b8612c66c17995a8e94e92d0d0f1e8a788eb4874 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:49:00 -0600 Subject: [PATCH 021/180] Switching io_int/intio tags to #defines --- external/io_int/io_int.F90 | 116 ++++++++++++++++++----------------- external/io_int/io_int_idx.c | 2 +- inc/intio_tags.h | 68 ++++++++++---------- 3 files changed, 94 insertions(+), 92 deletions(-) diff --git a/external/io_int/io_int.F90 b/external/io_int/io_int.F90 index e57224b51e..ab95b49a45 100644 --- a/external/io_int/io_int.F90 +++ b/external/io_int/io_int.F90 @@ -9,6 +9,8 @@ ! Uses header manipulation routines in module_io_quilt.F ! +#include "intio_tags.h" + MODULE module_ext_internal USE module_internal_header_util @@ -168,7 +170,7 @@ SUBROUTINE ext_int_open_for_write( FileName , Comm_compute, Comm_io, SysDepInfo, DataHandle , Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + CHARACTER*(*) :: FileName INTEGER , INTENT(IN) :: Comm_compute , Comm_io CHARACTER*(*) :: SysDepInfo @@ -187,7 +189,7 @@ SUBROUTINE ext_int_open_for_write_begin( FileName , Comm_compute, Comm_io, SysDe DataHandle , Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + #include "wrf_io_flags.h" CHARACTER*(*) :: FileName INTEGER , INTENT(IN) :: Comm_compute , Comm_io @@ -221,7 +223,7 @@ END SUBROUTINE ext_int_open_for_write_begin SUBROUTINE ext_int_open_for_write_commit( DataHandle , Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + #include "wrf_io_flags.h" INTEGER , INTENT(IN ) :: DataHandle INTEGER , INTENT(OUT) :: Status @@ -362,7 +364,7 @@ SUBROUTINE ext_int_ioexit( Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(OUT) :: Status INTEGER :: DataHandle INTEGER i,ierr @@ -375,7 +377,7 @@ END SUBROUTINE ext_int_ioexit SUBROUTINE ext_int_get_next_time ( DataHandle, DateStr, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: DateStr INTEGER , INTENT(OUT) :: Status @@ -417,7 +419,7 @@ SUBROUTINE ext_int_get_next_time ( DataHandle, DateStr, Status ) READ( unit=DataHandle, iostat=istat ) hdrbuf ! this is okay as long as no other record type has data that follows IF ( istat .EQ. 0 ) THEN code = hdrbuf(2) - IF ( code .EQ. int_field ) THEN + IF ( code .EQ. INT_FIELD ) THEN CALL int_get_write_field_header ( hdrbuf, hdrbufsize, inttypesize, typesize, & locDataHandle , locDateStr , locVarName , Field , locFieldType , locComm , locIOComm, & locDomainDesc , locMemoryOrder , locStagger , locDimNames , & @@ -433,7 +435,7 @@ SUBROUTINE ext_int_get_next_time ( DataHandle, DateStr, Status ) ELSE READ( unit=DataHandle, iostat=istat ) ENDIF - ELSE IF ( code .EQ. int_dom_td_char ) THEN + ELSE IF ( code .EQ. INT_DOM_TD_CHAR ) THEN CALL int_get_td_header_char( hdrbuf, hdrbufsize, itypesize, & locDataHandle, locDateStr, locElement, locData, loccode ) IF ( TRIM(locDateStr) .NE. TRIM(CurrentDateInFile(DataHandle) ) ) THEN ! control break, return this date @@ -460,13 +462,13 @@ END SUBROUTINE ext_int_get_next_time SUBROUTINE ext_int_set_time ( DataHandle, DateStr, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: DateStr INTEGER , INTENT(OUT) :: Status CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & - DataHandle, "TIMESTAMP", "", TRIM(DateStr), int_set_time ) + DataHandle, "TIMESTAMP", "", TRIM(DateStr), INT_SET_TIME ) WRITE( unit=DataHandle ) hdrbuf Status = 0 RETURN @@ -477,7 +479,7 @@ SUBROUTINE ext_int_get_var_info ( DataHandle , VarName , NDim , MemoryOrder , St DomainStart , DomainEnd , WrfType, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + integer ,intent(in) :: DataHandle character*(*) ,intent(in) :: VarName integer ,intent(out) :: NDim @@ -519,7 +521,7 @@ SUBROUTINE ext_int_get_var_info ( DataHandle , VarName , NDim , MemoryOrder , St READ( unit=DataHandle, iostat=istat ) hdrbuf ! this is okay as long as no other record type has data that follows IF ( istat .EQ. 0 ) THEN code = hdrbuf(2) - IF ( code .EQ. int_field ) THEN + IF ( code .EQ. INT_FIELD ) THEN CALL int_get_write_field_header ( hdrbuf, hdrbufsize, inttypesize, typesize, & locDataHandle , locDateStr , locVarName , Field , locFieldType , locComm , locIOComm, & locDomainDesc , MemoryOrder , locStagger , locDimNames , & @@ -561,7 +563,7 @@ END SUBROUTINE ext_int_get_var_info SUBROUTINE ext_int_get_next_var ( DataHandle, VarName, Status ) USE module_ext_internal IMPLICIT NONE - include 'intio_tags.h' + include 'wrf_status_codes.h' INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: VarName @@ -606,20 +608,20 @@ SUBROUTINE ext_int_get_next_var ( DataHandle, VarName, Status ) IF ( istat .EQ. 0 ) THEN code = hdrbuf(2) #if 1 - IF ( code .EQ. int_dom_ti_char ) THEN + IF ( code .EQ. INT_DOM_TI_CHAR ) THEN CALL int_get_ti_header_char( hdrbuf, hdrbufsize, itypesize, & locDataHandle, locElement, dumstr, strData, loccode ) ENDIF - IF ( code .EQ. int_dom_ti_integer ) THEN + IF ( code .EQ. INT_DOM_TI_INTEGER ) THEN CALL int_get_ti_header( hdrbuf, hdrbufsize, itypesize, rtypesize, & locDataHandle, locElement, iData, loccount, code ) ENDIF - IF ( code .EQ. int_dom_ti_real ) THEN + IF ( code .EQ. INT_DOM_TI_REAL ) THEN CALL int_get_ti_header( hdrbuf, hdrbufsize, itypesize, rtypesize, & locDataHandle, locElement, rData, loccount, code ) ENDIF #endif - IF ( code .EQ. int_field ) THEN + IF ( code .EQ. INT_FIELD ) THEN CALL int_get_write_field_header ( hdrbuf, hdrbufsize, inttypesize, typesize, & locDataHandle , locDateStr , locVarName , Field , locFieldType , locComm , locIOComm, & locDomainDesc , locMemoryOrder , locStagger , locDimNames , & @@ -660,7 +662,7 @@ END SUBROUTINE ext_int_get_next_var SUBROUTINE ext_int_get_dom_ti_real ( DataHandle,Element, Data, Count, Outcount, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element REAL , INTENT(OUT) :: Data(*) @@ -681,7 +683,7 @@ SUBROUTINE ext_int_get_dom_ti_real ( DataHandle,Element, Data, Count, Outcount READ( unit=DataHandle , iostat = istat ) hdrbuf IF ( istat .EQ. 0 ) THEN code = hdrbuf(2) - IF ( code .EQ. int_dom_ti_real ) THEN + IF ( code .EQ. INT_DOM_TI_REAL ) THEN CALL int_get_ti_header( hdrbuf, hdrbufsize, itypesize, rtypesize, & locDataHandle, locElement, Data, loccount, code ) IF ( TRIM(locElement) .EQ. TRIM(Element) ) THEN @@ -690,11 +692,11 @@ SUBROUTINE ext_int_get_dom_ti_real ( DataHandle,Element, Data, Count, Outcount ENDIF keepgoing = .false. ; Status = 0 ENDIF - ELSE IF ( .NOT. ( code .EQ. int_dom_ti_integer .OR. code .EQ. int_dom_ti_logical .OR. & - code .EQ. int_dom_ti_char .OR. code .EQ. int_dom_ti_double .OR. & - code .EQ. int_dom_td_integer .OR. code .EQ. int_dom_td_logical .OR. & - code .EQ. int_dom_td_char .OR. code .EQ. int_dom_td_double .OR. & - code .EQ. int_dom_td_real ) ) THEN + ELSE IF ( .NOT. ( code .EQ. INT_DOM_TI_INTEGER .OR. code .EQ. INT_DOM_TI_LOGICAL .OR. & + code .EQ. INT_DOM_TI_CHAR .OR. code .EQ. INT_DOM_TI_DOUBLE .OR. & + code .EQ. INT_DOM_TD_INTEGER .OR. code .EQ. INT_DOM_TD_LOGICAL .OR. & + code .EQ. INT_DOM_TD_CHAR .OR. code .EQ. INT_DOM_TD_DOUBLE .OR. & + code .EQ. INT_DOM_TD_REAL ) ) THEN BACKSPACE ( unit=DataHandle ) keepgoing = .false. ; Status = 2 ENDIF @@ -712,7 +714,7 @@ END SUBROUTINE ext_int_get_dom_ti_real SUBROUTINE ext_int_put_dom_ti_real ( DataHandle,Element, Data, Count, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element REAL , INTENT(IN) :: Data(*) @@ -726,7 +728,7 @@ SUBROUTINE ext_int_put_dom_ti_real ( DataHandle,Element, Data, Count, Status ! Do nothing unless it is time to write time-independent domain metadata. IF ( int_ok_to_put_dom_ti( DataHandle ) ) THEN CALL int_gen_ti_header( hdrbuf, hdrbufsize, itypesize, rtypesize, & - DataHandle, Element, Data, Count, int_dom_ti_real ) + DataHandle, Element, Data, Count, INT_DOM_TI_REAL ) WRITE( unit=DataHandle ) hdrbuf ENDIF ENDIF @@ -772,7 +774,7 @@ END SUBROUTINE ext_int_put_dom_ti_double SUBROUTINE ext_int_get_dom_ti_integer ( DataHandle,Element, Data, Count, Outcount, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element integer , INTENT(OUT) :: Data(*) @@ -793,7 +795,7 @@ SUBROUTINE ext_int_get_dom_ti_integer ( DataHandle,Element, Data, Count, Outco READ( unit=DataHandle , iostat = istat ) hdrbuf IF ( istat .EQ. 0 ) THEN code = hdrbuf(2) - IF ( code .EQ. int_dom_ti_integer ) THEN + IF ( code .EQ. INT_DOM_TI_INTEGER ) THEN CALL int_get_ti_header( hdrbuf, hdrbufsize, itypesize, rtypesize, & locDataHandle, locElement, Data, loccount, code ) IF ( TRIM(locElement) .EQ. TRIM(Element) ) THEN @@ -803,11 +805,11 @@ SUBROUTINE ext_int_get_dom_ti_integer ( DataHandle,Element, Data, Count, Outco keepgoing = .false. ; Status = 0 ENDIF - ELSE IF ( .NOT. ( code .EQ. int_dom_ti_real .OR. code .EQ. int_dom_ti_logical .OR. & - code .EQ. int_dom_ti_char .OR. code .EQ. int_dom_ti_double .OR. & - code .EQ. int_dom_td_real .OR. code .EQ. int_dom_td_logical .OR. & - code .EQ. int_dom_td_char .OR. code .EQ. int_dom_td_double .OR. & - code .EQ. int_dom_td_integer ) ) THEN + ELSE IF ( .NOT. ( code .EQ. INT_DOM_TI_REAL .OR. code .EQ. INT_DOM_TI_LOGICAL .OR. & + code .EQ. INT_DOM_TI_CHAR .OR. code .EQ. INT_DOM_TI_DOUBLE .OR. & + code .EQ. INT_DOM_TD_REAL .OR. code .EQ. INT_DOM_TD_LOGICAL .OR. & + code .EQ. INT_DOM_TD_CHAR .OR. code .EQ. INT_DOM_TD_DOUBLE .OR. & + code .EQ. INT_DOM_TD_INTEGER ) ) THEN BACKSPACE ( unit=DataHandle ) keepgoing = .false. ; Status = 1 ENDIF @@ -825,7 +827,7 @@ END SUBROUTINE ext_int_get_dom_ti_integer SUBROUTINE ext_int_put_dom_ti_integer ( DataHandle,Element, Data, Count, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element INTEGER , INTENT(IN) :: Data(*) @@ -838,7 +840,7 @@ SUBROUTINE ext_int_put_dom_ti_integer ( DataHandle,Element, Data, Count, Stat ! Do nothing unless it is time to write time-independent domain metadata. IF ( int_ok_to_put_dom_ti( DataHandle ) ) THEN CALL int_gen_ti_header( hdrbuf, hdrbufsize, itypesize, itypesize, & - DataHandle, Element, Data, Count, int_dom_ti_integer ) + DataHandle, Element, Data, Count, INT_DOM_TI_INTEGER ) WRITE( unit=DataHandle ) hdrbuf ENDIF ENDIF @@ -884,7 +886,7 @@ END SUBROUTINE ext_int_put_dom_ti_logical SUBROUTINE ext_int_get_dom_ti_char ( DataHandle,Element, Data, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element CHARACTER*(*) :: Data @@ -905,17 +907,17 @@ SUBROUTINE ext_int_get_dom_ti_char ( DataHandle,Element, Data, Status ) IF ( istat .EQ. 0 ) THEN code = hdrbuf(2) - IF ( code .EQ. int_dom_ti_char ) THEN + IF ( code .EQ. INT_DOM_TI_CHAR ) THEN CALL int_get_ti_header_char( hdrbuf, hdrbufsize, itypesize, & locDataHandle, locElement, dumstr, Data, code ) IF ( TRIM(locElement) .EQ. TRIM(Element) ) THEN keepgoing = .false. ; Status = 0 ENDIF - ELSE IF ( .NOT. ( code .EQ. int_dom_ti_real .OR. code .EQ. int_dom_ti_logical .OR. & - code .EQ. int_dom_ti_integer .OR. code .EQ. int_dom_ti_double .OR. & - code .EQ. int_dom_td_real .OR. code .EQ. int_dom_td_logical .OR. & - code .EQ. int_dom_td_integer .OR. code .EQ. int_dom_td_double .OR. & - code .EQ. int_dom_td_char ) ) THEN + ELSE IF ( .NOT. ( code .EQ. INT_DOM_TI_REAL .OR. code .EQ. INT_DOM_TI_LOGICAL .OR. & + code .EQ. INT_DOM_TI_INTEGER .OR. code .EQ. INT_DOM_TI_DOUBLE .OR. & + code .EQ. INT_DOM_TD_REAL .OR. code .EQ. INT_DOM_TD_LOGICAL .OR. & + code .EQ. INT_DOM_TD_INTEGER .OR. code .EQ. INT_DOM_TD_DOUBLE .OR. & + code .EQ. INT_DOM_TD_CHAR ) ) THEN BACKSPACE ( unit=DataHandle ) keepgoing = .false. ; Status = 1 ENDIF @@ -933,7 +935,7 @@ END SUBROUTINE ext_int_get_dom_ti_char SUBROUTINE ext_int_put_dom_ti_char ( DataHandle, Element, Data, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element CHARACTER*(*) :: Data @@ -947,7 +949,7 @@ SUBROUTINE ext_int_put_dom_ti_char ( DataHandle, Element, Data, Status ) ! Do nothing unless it is time to write time-independent domain metadata. IF ( int_ok_to_put_dom_ti( DataHandle ) ) THEN CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & - DataHandle, Element, "", Data, int_dom_ti_char ) + DataHandle, Element, "", Data, INT_DOM_TI_CHAR ) WRITE( unit=DataHandle ) hdrbuf ENDIF ENDIF @@ -1062,7 +1064,7 @@ END SUBROUTINE ext_int_put_dom_td_logical SUBROUTINE ext_int_get_dom_td_char ( DataHandle,Element, DateStr, Data, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element CHARACTER*(*) :: Data, DateStr @@ -1080,7 +1082,7 @@ SUBROUTINE ext_int_get_dom_td_char ( DataHandle,Element, DateStr, Data, Status IF ( istat .EQ. 0 ) THEN code = hdrbuf(2) - IF ( code .EQ. int_dom_td_char ) THEN + IF ( code .EQ. INT_DOM_TD_CHAR ) THEN CALL int_get_td_header_char( hdrbuf, hdrbufsize, itypesize, & locDataHandle, locDateStr, locElement, Data, code ) IF ( TRIM(locElement) .EQ. TRIM(Element) ) THEN @@ -1103,7 +1105,7 @@ END SUBROUTINE ext_int_get_dom_td_char SUBROUTINE ext_int_put_dom_td_char ( DataHandle,Element, DateStr, Data, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element CHARACTER*(*) :: Data, DateStr @@ -1114,7 +1116,7 @@ SUBROUTINE ext_int_put_dom_td_char ( DataHandle,Element, DateStr, Data, Status IF ( int_valid_handle ( Datahandle ) ) THEN IF ( int_handle_in_use( DataHandle ) ) THEN CALL int_gen_td_header_char( hdrbuf, hdrbufsize, itypesize, & - DataHandle, DateStr, Element, Data, int_dom_td_char ) + DataHandle, DateStr, Element, Data, INT_DOM_TD_CHAR ) WRITE( unit=DataHandle ) hdrbuf ENDIF ENDIF @@ -1178,7 +1180,7 @@ END SUBROUTINE ext_int_put_var_ti_double SUBROUTINE ext_int_get_var_ti_integer ( DataHandle,Element, Varname, Data, Count, Outcount, Status ) USE module_ext_internal IMPLICIT NONE -#include "intio_tags.h" + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element CHARACTER*(*) :: VarName @@ -1192,7 +1194,7 @@ SUBROUTINE ext_int_get_var_ti_integer ( DataHandle,Element, Varname, Data, Coun IF ( int_handle_in_use( DataHandle ) ) THEN READ( unit=DataHandle ) hdrbuf code=hdrbuf(2) - IF ( code .NE. int_var_ti_integer ) THEN + IF ( code .NE. INT_VAR_TI_INTEGER ) THEN BACKSPACE ( unit=DataHandle ) write(*,*) 'unexpected code=',code,' in ext_int_get_var_ti_integer' Status = 1 @@ -1219,7 +1221,7 @@ SUBROUTINE ext_int_put_var_ti_integer ( DataHandle,Element, Varname, Data, Coun USE module_ext_internal USE module_internal_header_util, only: int_gen_ti_header_integer_varna IMPLICIT NONE -#include "intio_tags.h" + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element CHARACTER*(*) :: VarName @@ -1230,7 +1232,7 @@ SUBROUTINE ext_int_put_var_ti_integer ( DataHandle,Element, Varname, Data, Coun IF ( int_handle_in_use( DataHandle ) ) THEN CALL int_gen_ti_header_integer_varna( hdrbuf, hdrbufsize, itypesize,4, & DataHandle, TRIM(Element), TRIM(VarName), Data, Count, & - int_var_ti_integer ) + INT_VAR_TI_INTEGER ) WRITE( unit=DataHandle ) hdrbuf ENDIF ENDIF @@ -1267,7 +1269,7 @@ END SUBROUTINE ext_int_put_var_ti_logical SUBROUTINE ext_int_get_var_ti_char ( DataHandle,Element, Varname, Data, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element CHARACTER*(*) :: VarName @@ -1279,7 +1281,7 @@ SUBROUTINE ext_int_get_var_ti_char ( DataHandle,Element, Varname, Data, Status IF ( int_handle_in_use( DataHandle ) ) THEN READ( unit=DataHandle ) hdrbuf code=hdrbuf(2) - IF ( code .NE. int_var_ti_char ) THEN + IF ( code .NE. INT_VAR_TI_CHAR ) THEN BACKSPACE ( unit=DataHandle ) Status = 1 return @@ -1302,7 +1304,7 @@ END SUBROUTINE ext_int_get_var_ti_char SUBROUTINE ext_int_put_var_ti_char ( DataHandle,Element, Varname, Data, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element CHARACTER*(*) :: VarName @@ -1313,7 +1315,7 @@ SUBROUTINE ext_int_put_var_ti_char ( DataHandle,Element, Varname, Data, Status IF ( int_valid_handle (DataHandle) ) THEN IF ( int_handle_in_use( DataHandle ) ) THEN CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & - DataHandle, TRIM(Element), TRIM(VarName), TRIM(Data), int_var_ti_char ) + DataHandle, TRIM(Element), TRIM(VarName), TRIM(Data), INT_VAR_TI_CHAR ) WRITE( unit=DataHandle ) hdrbuf ENDIF ENDIF @@ -1465,7 +1467,7 @@ SUBROUTINE ext_int_read_field ( DataHandle , DateStr , VarName , Field , FieldTy USE module_ext_internal IMPLICIT NONE #include "wrf_io_flags.h" - include 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: DateStr CHARACTER*(*) :: VarName @@ -1519,7 +1521,7 @@ SUBROUTINE ext_int_read_field ( DataHandle , DateStr , VarName , Field , FieldTy READ( unit=DataHandle, iostat=istat ) hdrbuf ! this is okay as long as no other record type has data that follows IF ( istat .EQ. 0 ) THEN code = hdrbuf(2) - IF ( code .EQ. int_field ) THEN + IF ( code .EQ. INT_FIELD ) THEN CALL int_get_write_field_header ( hdrbuf, hdrbufsize, inttypesize, typesize, & locDataHandle , locDateStr , locVarName , Field , locFieldType , locComm , locIOComm, & locDomainDesc , locMemoryOrder , locStagger , locDimNames , & diff --git a/external/io_int/io_int_idx.c b/external/io_int/io_int_idx.c index 8f812dd356..772263359e 100644 --- a/external/io_int/io_int_idx.c +++ b/external/io_int/io_int_idx.c @@ -19,7 +19,7 @@ #include #include "io_int_idx.h" -#include "io_int_idx_tags.h" +#include "intio_tags.h" /* Static/Private functions within this file */ diff --git a/inc/intio_tags.h b/inc/intio_tags.h index 3808968cf5..daa130ef5f 100644 --- a/inc/intio_tags.h +++ b/inc/intio_tags.h @@ -1,34 +1,34 @@ - INTEGER, PARAMETER :: int_ioexit = 10 - INTEGER, PARAMETER :: int_open_for_write_begin = 20 - INTEGER, PARAMETER :: int_open_for_write_commit = 30 - INTEGER, PARAMETER :: int_open_for_read = 40 - INTEGER, PARAMETER :: int_inquire_opened = 60 - INTEGER, PARAMETER :: int_inquire_filename = 70 - INTEGER, PARAMETER :: int_iosync = 80 - INTEGER, PARAMETER :: int_ioclose = 90 - INTEGER, PARAMETER :: int_next_time = 100 - INTEGER, PARAMETER :: int_set_time = 110 - INTEGER, PARAMETER :: int_next_var = 120 - INTEGER, PARAMETER :: int_dom_ti_real = 140 - INTEGER, PARAMETER :: int_dom_ti_double = 160 - INTEGER, PARAMETER :: int_dom_ti_integer = 180 - INTEGER, PARAMETER :: int_dom_ti_logical = 200 - INTEGER, PARAMETER :: int_dom_ti_char = 220 - INTEGER, PARAMETER :: int_dom_td_real = 240 - INTEGER, PARAMETER :: int_dom_td_double = 260 - INTEGER, PARAMETER :: int_dom_td_integer = 280 - INTEGER, PARAMETER :: int_dom_td_logical = 300 - INTEGER, PARAMETER :: int_dom_td_char = 320 - INTEGER, PARAMETER :: int_var_ti_real = 340 - INTEGER, PARAMETER :: int_var_ti_double = 360 - INTEGER, PARAMETER :: int_var_ti_integer = 380 - INTEGER, PARAMETER :: int_var_ti_logical = 400 - INTEGER, PARAMETER :: int_var_ti_char = 420 - INTEGER, PARAMETER :: int_var_td_real = 440 - INTEGER, PARAMETER :: int_var_td_double = 460 - INTEGER, PARAMETER :: int_var_td_integer = 480 - INTEGER, PARAMETER :: int_var_td_logical = 500 - INTEGER, PARAMETER :: int_var_td_char = 520 - INTEGER, PARAMETER :: int_field = 530 - INTEGER, PARAMETER :: int_var_info = 540 - INTEGER, PARAMETER :: int_noop = 550 +#define INT_IOEXIT 10 +#define INT_OPEN_FOR_WRITE_BEGIN 20 +#define INT_OPEN_FOR_WRITE_COMMIT 30 +#define INT_OPEN_FOR_READ 40 +#define INT_INQUIRE_OPENED 60 +#define INT_INQUIRE_FILENAME 70 +#define INT_IOSYNC 80 +#define INT_IOCLOSE 90 +#define INT_NEXT_TIME 100 +#define INT_SET_TIME 110 +#define INT_NEXT_VAR 120 +#define INT_DOM_TI_REAL 140 +#define INT_DOM_TI_DOUBLE 160 +#define INT_DOM_TI_INTEGER 180 +#define INT_DOM_TI_LOGICAL 200 +#define INT_DOM_TI_CHAR 220 +#define INT_DOM_TD_REAL 240 +#define INT_DOM_TD_DOUBLE 260 +#define INT_DOM_TD_INTEGER 280 +#define INT_DOM_TD_LOGICAL 300 +#define INT_DOM_TD_CHAR 320 +#define INT_VAR_TI_REAL 340 +#define INT_VAR_TI_DOUBLE 360 +#define INT_VAR_TI_INTEGER 380 +#define INT_VAR_TI_LOGICAL 400 +#define INT_VAR_TI_CHAR 420 +#define INT_VAR_TD_REAL 440 +#define INT_VAR_TD_DOUBLE 460 +#define INT_VAR_TD_INTEGER 480 +#define INT_VAR_TD_LOGICAL 500 +#define INT_VAR_TD_CHAR 520 +#define INT_FIELD 530 +#define INT_VAR_INFO 540 +#define INT_NOOP 550 From 3c755bd723d4b9902399e0523f97ec65f1a2ce91 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:50:50 -0600 Subject: [PATCH 022/180] Adjusting for new ioint tags --- frame/module_internal_header_util.F | 42 +++---- frame/module_io_quilt_old.F | 182 ++++++++++++++-------------- 2 files changed, 112 insertions(+), 112 deletions(-) diff --git a/frame/module_internal_header_util.F b/frame/module_internal_header_util.F index bfff25916a..35ad9d92b6 100644 --- a/frame/module_internal_header_util.F +++ b/frame/module_internal_header_util.F @@ -110,7 +110,7 @@ SUBROUTINE int_gen_write_field_header ( hdrbuf, hdrbufsize, itypesize, ftypesize ! hdrbufsize: Size of this data header in bytes. ! headerTag: "Header tag" that tells the I/O quilt servers what kind of ! header this is. For a "write field" header it must be set to -! int_field. See file intio_tags.h for a complete list of +! INT_FIELD. See file intio_tags.h for a complete list of ! these tags. ! ftypesize: Size of field data type in bytes. ! DataHandle: Descriptor for an open data set. @@ -145,7 +145,7 @@ SUBROUTINE int_gen_write_field_header ( hdrbuf, hdrbufsize, itypesize, ftypesize hdrbuf(1) = 0 ! deferred -- this will be length of header - hdrbuf(2) = int_field + hdrbuf(2) = INT_FIELD hdrbuf(3) = ftypesize i = 4 @@ -215,8 +215,8 @@ SUBROUTINE int_get_write_field_header ( hdrbuf, hdrbufsize, itypesize, ftypesize INTEGER i, n hdrbufsize = hdrbuf(1) - IF ( hdrbuf(2) .NE. int_field ) THEN - write(mess,*)'int_get_write_field_header: hdrbuf(2) ne int_field ',hdrbuf(2),int_field + IF ( hdrbuf(2) .NE. INT_FIELD ) THEN + write(mess,*)'int_get_write_field_header: hdrbuf(2) ne INT_FIELD ',hdrbuf(2),INT_FIELD CALL wrf_error_fatal ( mess ) ENDIF ftypesize = hdrbuf(3) @@ -269,7 +269,7 @@ SUBROUTINE int_gen_ofr_header( hdrbuf, hdrbufsize, itypesize, & ! hdrbufsize: Size of this data header in bytes. ! headerTag: "Header tag" that tells the I/O quilt servers what kind of ! header this is. For an "open for read" header it must be set to -! int_open_for_read. See file intio_tags.h for a complete list of +! INT_OPEN_FOR_READ. See file intio_tags.h for a complete list of ! these tags. ! DataHandle: Descriptor for an open data set. ! FileName: File name. @@ -292,7 +292,7 @@ SUBROUTINE int_gen_ofr_header( hdrbuf, hdrbufsize, itypesize, & INTEGER i, n, i1 ! hdrbuf(1) = 0 !deferred - hdrbuf(2) = int_open_for_read + hdrbuf(2) = INT_OPEN_FOR_READ i = 3 hdrbuf(i) = DataHandle ; i = i+1 @@ -324,8 +324,8 @@ SUBROUTINE int_get_ofr_header( hdrbuf, hdrbufsize, itypesize, & INTEGER i, n ! hdrbufsize = hdrbuf(1) -! IF ( hdrbuf(2) .NE. int_open_for_read ) THEN -! CALL wrf_error_fatal ( "int_get_ofr_header: hdrbuf ne int_open_for_read") +! IF ( hdrbuf(2) .NE. INT_OPEN_FOR_READ ) THEN +! CALL wrf_error_fatal ( "int_get_ofr_header: hdrbuf ne INT_OPEN_FOR_READ") ! ENDIF i = 3 DataHandle = hdrbuf(i) ; i = i+1 @@ -356,7 +356,7 @@ SUBROUTINE int_gen_ofwb_header( hdrbuf, hdrbufsize, itypesize, & ! hdrbufsize: Size of this data header in bytes. ! headerTag: "Header tag" that tells the I/O quilt servers what kind of ! header this is. For an "open for write begin" header it must be set to -! int_open_for_write_begin. See file intio_tags.h for a complete list of +! INT_OPEN_FOR_WRITE_BEGIN. See file intio_tags.h for a complete list of ! these tags. ! DataHandle: Descriptor for an open data set. ! io_form: I/O format for this file (netCDF, etc.). @@ -381,7 +381,7 @@ SUBROUTINE int_gen_ofwb_header( hdrbuf, hdrbufsize, itypesize, & INTEGER i, n, j ! hdrbuf(1) = 0 !deferred - hdrbuf(2) = int_open_for_write_begin + hdrbuf(2) = INT_OPEN_FOR_WRITE_BEGIN i = 3 hdrbuf(i) = DataHandle ; i = i+1 hdrbuf(i) = io_form ; i = i+1 @@ -420,8 +420,8 @@ SUBROUTINE int_get_ofwb_header( hdrbuf, hdrbufsize, itypesize, & ! hdrbufsize = hdrbuf(1) !write(0,*)' int_get_ofwb_header next rec start ',hdrbuf(hdrbufsize+1) -! IF ( hdrbuf(2) .NE. int_open_for_write_begin ) THEN -! CALL wrf_error_fatal ( "int_get_ofwb_header: hdrbuf ne int_open_for_write_begin") +! IF ( hdrbuf(2) .NE. INT_OPEN_FOR_WRITE_BEGIN ) THEN +! CALL wrf_error_fatal ( "int_get_ofwb_header: hdrbuf ne INT_OPEN_FOR_WRITE_BEGIN") ! ENDIF i = 3 DataHandle = hdrbuf(i) ; i = i+1 @@ -529,7 +529,7 @@ SUBROUTINE int_gen_ti_header_integer( hdrbuf, hdrbufsize, itypesize, typesize, & ! hdrbufsize: Size of this data header in bytes. ! headerTag: "Header tag" that tells the I/O quilt servers what kind of ! header this is. For an "time-independent integer" header it must be -! set to int_dom_ti_integer. See file intio_tags.h for a complete +! set to INT_DOM_TI_INTEGER. See file intio_tags.h for a complete ! list of these tags. ! DataHandle: Descriptor for an open data set. ! typesize: Size in bytes of each element of Data. @@ -584,7 +584,7 @@ SUBROUTINE int_gen_ti_header_integer_varna( hdrbuf, hdrbufsize, itypesize, types ! hdrbufsize: Size of this data header in bytes. ! headerTag: "Header tag" that tells the I/O quilt servers what kind of ! header this is. For an "time-independent integer" header it must be -! set to int_dom_ti_integer. See file intio_tags.h for a complete +! set to INT_DOM_TI_INTEGER. See file intio_tags.h for a complete ! list of these tags. ! DataHandle: Descriptor for an open data set. ! typesize: Size in bytes of each element of Data. @@ -761,7 +761,7 @@ SUBROUTINE int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & ! hdrbufsize: Size of this data header in bytes. ! headerTag: "Header tag" that tells the I/O quilt servers what kind of ! header this is. For an "time-independent string" header it must be -! set to int_dom_ti_char. See file intio_tags.h for a complete +! set to INT_DOM_TI_CHAR. See file intio_tags.h for a complete ! list of these tags. ! DataHandle: Descriptor for an open data set. ! typesize: 1 (size in bytes of a single CHARACTER). @@ -852,7 +852,7 @@ SUBROUTINE int_gen_td_header_char( hdrbuf, hdrbufsize, itypesize, & ! hdrbufsize: Size of this data header in bytes. ! headerTag: "Header tag" that tells the I/O quilt servers what kind of ! header this is. For an "time-dependent string" header it must be -! set to int_dom_td_char. See file intio_tags.h for a complete +! set to INT_DOM_TD_CHAR. See file intio_tags.h for a complete ! list of these tags. ! DataHandle: Descriptor for an open data set. ! typesize: 1 (size in bytes of a single CHARACTER). @@ -937,7 +937,7 @@ SUBROUTINE int_gen_td_header_integer( hdrbuf, hdrbufsize, itypesize, typesize, & ! hdrbufsize: Size of this data header in bytes. ! headerTag: "Header tag" that tells the I/O quilt servers what kind of ! header this is. For an "time-dependent integer" header it must be -! set to int_dom_td_integer. See file intio_tags.h for a complete +! set to INT_DOM_TD_INTEGER. See file intio_tags.h for a complete ! list of these tags. ! DataHandle: Descriptor for an open data set. ! typesize: 1 (size in bytes of a single CHARACTER). @@ -1074,7 +1074,7 @@ SUBROUTINE int_gen_noop_header ( hdrbuf, hdrbufsize, itypesize ) ! hdrbufsize: Size of this data header in bytes. ! headerTag: "Header tag" that tells the I/O quilt servers what kind of ! header this is. For an "no-operation" header it must be -! set to int_noop. See file intio_tags.h for a complete +! set to INT_NOOP. See file intio_tags.h for a complete ! list of these tags. ! ! @@ -1087,7 +1087,7 @@ SUBROUTINE int_gen_noop_header ( hdrbuf, hdrbufsize, itypesize ) INTEGER i ! hdrbuf(1) = 0 !deferred - hdrbuf(2) = int_noop + hdrbuf(2) = INT_NOOP i = 3 hdrbufsize = (i-1) * itypesize ! return the number in bytes hdrbuf(1) = hdrbufsize @@ -1110,8 +1110,8 @@ SUBROUTINE int_get_noop_header( hdrbuf, hdrbufsize, itypesize ) INTEGER i ! hdrbufsize = hdrbuf(1) - IF ( hdrbuf(2) .NE. int_noop ) THEN - CALL wrf_error_fatal ( "int_get_noop_header: hdrbuf ne int_noop") + IF ( hdrbuf(2) .NE. INT_NOOP ) THEN + CALL wrf_error_fatal ( "int_get_noop_header: hdrbuf ne INT_NOOP") ENDIF i = 3 RETURN diff --git a/frame/module_io_quilt_old.F b/frame/module_io_quilt_old.F index e46d8b1095..69e443a69b 100644 --- a/frame/module_io_quilt_old.F +++ b/frame/module_io_quilt_old.F @@ -743,7 +743,7 @@ SUBROUTINE quilt ALLOCATE( obuf( 4096 ) ) ! DataHandle is provided as second element of reduced CALL int_gen_handle_header( obuf, obufsize, itypesize, & - reduced(2) , int_ioclose ) + reduced(2) , INT_IOCLOSE ) if(poll_servers) then ! Once we're done closing, we need to tell the master @@ -775,7 +775,7 @@ SUBROUTINE quilt DO WHILE ( icurs .lt. obufsize ) ! { hdr_tag = get_hdr_tag( obuf ( icurs / itypesize ) ) SELECT CASE ( hdr_tag ) - CASE ( int_field ) + CASE ( INT_FIELD ) CALL int_get_write_field_header ( obuf(icurs/itypesize), hdrbufsize, itypesize, ftypesize, & DataHandle , DateStr , VarName , Dummy , FieldType , Comm , IOComm, & DomainDesc , MemoryOrder , Stagger , DimNames , & @@ -806,7 +806,7 @@ SUBROUTINE quilt call add_to_bufsize_for_field( VarName, chunksize ) icurs = icurs + chunksize ENDIF - CASE ( int_open_for_write_commit ) ! only one per group of tasks + CASE ( INT_OPEN_FOR_WRITE_COMMIT ) ! only one per group of tasks hdrbufsize = obuf(icurs/itypesize) IF (num_commit_messages.EQ.0) THEN call add_to_bufsize_for_field( 'COMMIT', hdrbufsize ) @@ -851,14 +851,14 @@ SUBROUTINE quilt ! call to collect_on_comm: 1 bona fide output record from server task ! 0 and noops from the rest. - IF ((hdr_tag.EQ.int_noop.AND.mytask_local.NE.0.AND.num_noops.LE.0) & - .OR.hdr_tag.NE.int_noop) THEN + IF ((hdr_tag.EQ.INT_NOOP.AND.mytask_local.NE.0.AND.num_noops.LE.0) & + .OR.hdr_tag.NE.INT_NOOP) THEN write(VarName,'(I5.5)')vid !write(0,*) 'X-2', hdrbufsize, get_hdr_tag( obuf ( icurs / itypesize ) ) , get_hdr_rec_size( obuf ( icurs / itypesize ) ), TRIM(VarName) call add_to_bufsize_for_field( VarName, hdrbufsize ) vid = vid+1 ENDIF - IF ( hdr_tag .EQ. int_noop ) num_noops = num_noops + 1 + IF ( hdr_tag .EQ. INT_NOOP ) num_noops = num_noops + 1 icurs = icurs + hdrbufsize END SELECT ENDDO ! } @@ -874,7 +874,7 @@ SUBROUTINE quilt !write(0,*) 'A icurs ', icurs, ' obufsize ', obufsize hdr_tag = get_hdr_tag( obuf ( icurs / itypesize ) ) SELECT CASE ( hdr_tag ) - CASE ( int_field ) + CASE ( INT_FIELD ) CALL int_get_write_field_header ( obuf(icurs/itypesize), hdrbufsize, itypesize, ftypesize, & DataHandle , DateStr , VarName , Dummy , FieldType , Comm , IOComm, & DomainDesc , MemoryOrder , Stagger , DimNames , & @@ -902,7 +902,7 @@ SUBROUTINE quilt call store_piece_of_field( obuf(icurs/itypesize), VarName, chunksize ) icurs = icurs + chunksize ENDIF - CASE ( int_open_for_write_commit ) ! only one per group of tasks + CASE ( INT_OPEN_FOR_WRITE_COMMIT ) ! only one per group of tasks hdrbufsize = obuf(icurs/itypesize) IF (num_commit_messages.EQ.0) THEN call store_piece_of_field( obuf(icurs/itypesize), 'COMMIT', hdrbufsize ) @@ -911,14 +911,14 @@ SUBROUTINE quilt icurs = icurs + hdrbufsize CASE DEFAULT hdrbufsize = obuf(icurs/itypesize) - IF ((hdr_tag.EQ.int_noop.AND.mytask_local.NE.0.AND.num_noops.LE.0) & - .OR.hdr_tag.NE.int_noop) THEN + IF ((hdr_tag.EQ.INT_NOOP.AND.mytask_local.NE.0.AND.num_noops.LE.0) & + .OR.hdr_tag.NE.INT_NOOP) THEN write(VarName,'(I5.5)')vid !write(0,*) 'A-2b', hdrbufsize, get_hdr_tag( obuf ( icurs / itypesize ) ) , get_hdr_rec_size( obuf ( icurs / itypesize ) ), TRIM(VarName) call store_piece_of_field( obuf(icurs/itypesize), VarName, hdrbufsize ) vid = vid+1 ENDIF - IF ( hdr_tag .EQ. int_noop ) num_noops = num_noops + 1 + IF ( hdr_tag .EQ. INT_NOOP ) num_noops = num_noops + 1 icurs = icurs + hdrbufsize END SELECT ENDDO !} @@ -981,12 +981,12 @@ SUBROUTINE quilt ! actually quite easy. "Noop" requests exist to help avoid race conditions. ! In some cases, only one compute task will everything about a request so ! other compute tasks send "noop" requests. - CASE ( int_noop ) + CASE ( INT_NOOP ) CALL int_get_noop_header( bigbuf(icurs/itypesize), hdrbufsize, itypesize ) icurs = icurs + hdrbufsize ! The I/O server "root" handles the "put_dom_td_real" request. - CASE ( int_dom_td_real ) + CASE ( INT_DOM_TD_REAL ) CALL mpi_type_size( MPI_REAL, ftypesize, ierr ) ALLOCATE( RData( bigbuf(icurs/itypesize + 4 ) ) ) ! 5 is the count of data items for this record ; defined in collect_on_comm.c CALL int_get_td_header( bigbuf(icurs/itypesize:), hdrbufsize, itypesize, ftypesize, & @@ -1020,8 +1020,8 @@ SUBROUTINE quilt DEALLOCATE( RData ) ! The I/O server "root" handles the "put_dom_ti_real" request. - CASE ( int_dom_ti_real ) -!write(0,*)' int_dom_ti_real ' + CASE ( INT_DOM_TI_REAL ) +!write(0,*)' INT_DOM_TI_REAL ' CALL mpi_type_size( MPI_REAL, ftypesize, ierr ) ALLOCATE( RData( bigbuf(icurs/itypesize + 4 ) ) ) ! 5 is the count of data items for this record ; defined in collect_on_comm.c CALL int_get_ti_header( bigbuf(icurs/itypesize:), hdrbufsize, itypesize, ftypesize, & @@ -1057,8 +1057,8 @@ SUBROUTINE quilt DEALLOCATE( RData ) ! The I/O server "root" handles the "put_dom_td_integer" request. - CASE ( int_dom_td_integer ) -!write(0,*)' int_dom_td_integer ' + CASE ( INT_DOM_TD_INTEGER ) +!write(0,*)' INT_DOM_TD_INTEGER ' CALL mpi_type_size( MPI_INTEGER, ftypesize, ierr ) ALLOCATE( IData( bigbuf(icurs/itypesize + 4 ) ) ) ! 5 is the count of data items for this record ; defined in collect_on_comm.c CALL int_get_td_header( bigbuf(icurs/itypesize:), hdrbufsize, itypesize, ftypesize, & @@ -1093,8 +1093,8 @@ SUBROUTINE quilt DEALLOCATE( IData ) ! The I/O server "root" handles the "put_dom_ti_integer" request. - CASE ( int_dom_ti_integer ) -!write(0,*)' int_dom_ti_integer ' + CASE ( INT_DOM_TI_INTEGER ) +!write(0,*)' INT_DOM_TI_INTEGER ' CALL mpi_type_size( MPI_INTEGER, ftypesize, ierr ) ALLOCATE( IData( bigbuf(icurs/itypesize + 4 ) ) ) ! 5 is the count of data items for this record ; defined in collect_on_comm.c @@ -1131,8 +1131,8 @@ SUBROUTINE quilt DEALLOCATE( IData) ! The I/O server "root" handles the "set_time" request. - CASE ( int_set_time ) -!write(0,*)' int_set_time ' + CASE ( INT_SET_TIME ) +!write(0,*)' INT_SET_TIME ' CALL int_get_ti_header_char( bigbuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle, Element, VarName, CData, code ) SELECT CASE (use_package(io_form(DataHandle))) @@ -1147,7 +1147,7 @@ SUBROUTINE quilt icurs = icurs + hdrbufsize ! The I/O server "root" handles the "put_dom_ti_char" request. - CASE ( int_dom_ti_char ) + CASE ( INT_DOM_TI_CHAR ) !write(0,*)' before int_get_ti_header_char ' CALL int_get_ti_header_char( bigbuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle, Element, VarName, CData, code ) @@ -1181,8 +1181,8 @@ SUBROUTINE quilt icurs = icurs + hdrbufsize ! The I/O server "root" handles the "put_var_ti_char" request. - CASE ( int_var_ti_char ) -!write(0,*)' int_var_ti_char ' + CASE ( INT_VAR_TI_CHAR ) +!write(0,*)' INT_VAR_TI_CHAR ' CALL int_get_ti_header_char( bigbuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle, Element, VarName, CData, code ) @@ -1213,12 +1213,12 @@ SUBROUTINE quilt icurs = icurs + hdrbufsize - CASE ( int_ioexit ) + CASE ( INT_IOEXIT ) ! ioexit is now handled by sending negative message length to server CALL wrf_error_fatal( & - "quilt: should have handled int_ioexit already") + "quilt: should have handled INT_IOEXIT already") ! The I/O server "root" handles the "ioclose" request. - CASE ( int_ioclose ) + CASE ( INT_IOCLOSE ) CALL int_get_handle_header( bigbuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle , code ) icurs = icurs + hdrbufsize @@ -1281,17 +1281,17 @@ SUBROUTINE quilt ENDIF ! The I/O server "root" handles the "open_for_write_begin" request. - CASE ( int_open_for_write_begin ) + CASE ( INT_OPEN_FOR_WRITE_BEGIN ) CALL int_get_ofwb_header( bigbuf(icurs/itypesize), hdrbufsize, itypesize, & FileName,SysDepInfo,io_form_arg,DataHandle ) -!write(0,*)' int_open_for_write_begin itypesize ',itypesize,' itypesize ',itypesize -!write(0,*)' int_open_for_write_begin icurs ', icurs, hdrbufsize -!JMDEBUGwrite(0,*)' int_open_for_write_begin FileName ',TRIM(FileName) , ' DataHandle ', DataHandle -!write(0,*)' int_open_for_write_begin SysDepInfo ',TRIM(SysDepInfo) +!write(0,*)' INT_OPEN_FOR_WRITE_BEGIN itypesize ',itypesize,' itypesize ',itypesize +!write(0,*)' INT_OPEN_FOR_WRITE_BEGIN icurs ', icurs, hdrbufsize +!JMDEBUGwrite(0,*)' INT_OPEN_FOR_WRITE_BEGIN FileName ',TRIM(FileName) , ' DataHandle ', DataHandle +!write(0,*)' INT_OPEN_FOR_WRITE_BEGIN SysDepInfo ',TRIM(SysDepInfo) icurs = icurs + hdrbufsize -!write(0,*)' int_open_for_write_begin new icurs,tag,size ', icurs, get_hdr_tag( bigbuf(icurs/itypesize) ),get_hdr_rec_size( bigbuf(icurs/itypesize) ) +!write(0,*)' INT_OPEN_FOR_WRITE_BEGIN new icurs,tag,size ', icurs, get_hdr_tag( bigbuf(icurs/itypesize) ),get_hdr_rec_size( bigbuf(icurs/itypesize) ) io_form(DataHandle) = io_form_arg @@ -1327,14 +1327,14 @@ SUBROUTINE quilt ! In this case, the "okay_to_commit" is simply set to .true. so "write_field" ! requests will initiate writes to disk. Actual commit will be done after ! all requests in this batch have been handled. - CASE ( int_open_for_write_commit ) + CASE ( INT_OPEN_FOR_WRITE_COMMIT ) CALL int_get_handle_header( bigbuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle , code ) icurs = icurs + hdrbufsize okay_to_commit(DataHandle) = .true. -! The I/O server "root" handles the "write_field" (int_field) request. +! The I/O server "root" handles the "write_field" (INT_FIELD) request. ! If okay_to_write(DataHandle) is .true. then the patch in the ! header (bigbuf) is written to a globally-sized internal output buffer via ! the call to store_patch_in_outbuf(). Note that this is where the actual @@ -1342,9 +1342,9 @@ SUBROUTINE quilt ! okay_to_write(DataHandle) is .false. then external I/O package interfaces ! are called to write metadata for I/O formats that support native metadata. ! -! NOTE that the I/O server "root" will only see write_field (int_field) +! NOTE that the I/O server "root" will only see write_field (INT_FIELD) ! requests AFTER an "iosync" request. - CASE ( int_field ) + CASE ( INT_FIELD ) CALL mpi_type_size( MPI_INTEGER, ftypesize, ierr ) CALL int_get_write_field_header ( bigbuf(icurs/itypesize), hdrbufsize, itypesize, ftypesize, & DataHandle , DateStr , VarName , Dummy , FieldType , Comm , IOComm, & @@ -1352,7 +1352,7 @@ SUBROUTINE quilt DomainStart , DomainEnd , & MemoryStart , MemoryEnd , & PatchStart , PatchEnd ) -!write(0,*)' int_field ',TRIM(VarName),DataHandle,okay_to_write(DataHandle) +!write(0,*)' INT_FIELD ',TRIM(VarName),DataHandle,okay_to_write(DataHandle) icurs = icurs + hdrbufsize IF ( okay_to_write(DataHandle) ) THEN @@ -1418,7 +1418,7 @@ SUBROUTINE quilt Status = 0 END SELECT ENDIF - CASE ( int_iosync ) + CASE ( INT_IOSYNC ) CALL int_get_handle_header( bigbuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle , code ) icurs = icurs + hdrbufsize @@ -1436,7 +1436,7 @@ SUBROUTINE quilt ! (via a call to store_patch_in_outbuf()) then call write_outbuf() to write ! them to disk now. ! NOTE that the I/O server "root" will only have called -! store_patch_in_outbuf() when handling write_field (int_field) +! store_patch_in_outbuf() when handling write_field (INT_FIELD) ! commands which only arrive AFTER an "iosync" command. ! CALL start_timing CALL write_outbuf ( handle(DataHandle), use_package(io_form(DataHandle))) @@ -1745,7 +1745,7 @@ SUBROUTINE quilt_pnc ALLOCATE( obuf( 4096 ) ) ! DataHandle is provided as second element of reduced CALL int_gen_handle_header( obuf, obufsize, itypesize, & - reduced(2) , int_ioclose ) + reduced(2) , INT_IOCLOSE ) ENDIF !write(0,*)'calling init_store_piece_of_field' @@ -1772,7 +1772,7 @@ SUBROUTINE quilt_pnc DO WHILE ( icurs .lt. obufsize ) ! { hdr_tag = get_hdr_tag( obuf ( icurs / itypesize ) ) SELECT CASE ( hdr_tag ) - CASE ( int_field ) + CASE ( INT_FIELD ) CALL int_get_write_field_header ( obuf(icurs/itypesize), hdrbufsize, itypesize, ftypesize, & DataHandle , DateStr , VarName , Dummy , FieldType , Comm , IOComm, & DomainDesc , MemoryOrder , Stagger , DimNames , & @@ -1803,7 +1803,7 @@ SUBROUTINE quilt_pnc call add_to_bufsize_for_field( VarName, chunksize ) icurs = icurs + chunksize ENDIF - CASE ( int_open_for_write_commit ) ! only one per group of tasks + CASE ( INT_OPEN_FOR_WRITE_COMMIT ) ! only one per group of tasks hdrbufsize = obuf(icurs/itypesize) IF (num_commit_messages.EQ.0) THEN call add_to_bufsize_for_field( 'COMMIT', hdrbufsize ) @@ -1841,13 +1841,13 @@ SUBROUTINE quilt_pnc ! 5. Logic below does not allow any noop records through since each IO ! server task now receives a valid record (from the 'compute-group master' ! when doing replicated output - IF (hdr_tag.NE.int_noop) THEN + IF (hdr_tag.NE.INT_NOOP) THEN write(VarName,'(I5.5)')vid !write(0,*) 'X-2', hdrbufsize, get_hdr_tag( obuf ( icurs / itypesize ) ) , get_hdr_rec_size( obuf ( icurs / itypesize ) ), TRIM(VarName) call add_to_bufsize_for_field( VarName, hdrbufsize ) vid = vid+1 ENDIF - IF ( hdr_tag .EQ. int_noop ) num_noops = num_noops + 1 + IF ( hdr_tag .EQ. INT_NOOP ) num_noops = num_noops + 1 icurs = icurs + hdrbufsize END SELECT @@ -1864,7 +1864,7 @@ SUBROUTINE quilt_pnc !write(0,*) 'A icurs ', icurs, ' obufsize ', obufsize hdr_tag = get_hdr_tag( obuf ( icurs / itypesize ) ) SELECT CASE ( hdr_tag ) - CASE ( int_field ) + CASE ( INT_FIELD ) CALL int_get_write_field_header ( obuf(icurs/itypesize), hdrbufsize, itypesize, ftypesize, & DataHandle , DateStr , VarName , Dummy , FieldType , Comm , IOComm, & DomainDesc , MemoryOrder , Stagger , DimNames , & @@ -1892,7 +1892,7 @@ SUBROUTINE quilt_pnc icurs = icurs + chunksize !write(0,*) 'A-1a',TRIM(VarName),' icurs ',icurs,PatchStart(1:3),PatchEnd(1:3) ENDIF - CASE ( int_open_for_write_commit ) ! only one per group of tasks + CASE ( INT_OPEN_FOR_WRITE_COMMIT ) ! only one per group of tasks hdrbufsize = obuf(icurs/itypesize) IF (num_commit_messages.EQ.0) THEN call store_piece_of_field( obuf(icurs/itypesize), 'COMMIT', hdrbufsize ) @@ -1901,14 +1901,14 @@ SUBROUTINE quilt_pnc icurs = icurs + hdrbufsize CASE DEFAULT hdrbufsize = obuf(icurs/itypesize) - IF (hdr_tag.NE.int_noop) THEN + IF (hdr_tag.NE.INT_NOOP) THEN write(VarName,'(I5.5)')vid !write(0,*) 'A-2b', hdrbufsize, get_hdr_tag( obuf ( icurs / itypesize ) ) , get_hdr_rec_size( obuf ( icurs / itypesize ) ), TRIM(VarName) call store_piece_of_field( obuf(icurs/itypesize), VarName, hdrbufsize ) vid = vid+1 ENDIF - IF ( hdr_tag .EQ. int_noop ) num_noops = num_noops + 1 + IF ( hdr_tag .EQ. INT_NOOP ) num_noops = num_noops + 1 icurs = icurs + hdrbufsize END SELECT ENDDO !} while(icurs < obufsize) @@ -1942,13 +1942,13 @@ SUBROUTINE quilt_pnc SELECT CASE ( get_hdr_tag( obuf(icurs/itypesize) ) ) ! The I/O server handles the "noop" (do nothing) request. This is ! actually quite easy. "Noop" requests exist to help avoid race conditions. - CASE ( int_noop ) + CASE ( INT_NOOP ) CALL int_get_noop_header( obuf(icurs/itypesize), & hdrbufsize, itypesize ) icurs = icurs + hdrbufsize ! The I/O server "root" handles the "put_dom_td_real" request. - CASE ( int_dom_td_real ) + CASE ( INT_DOM_TD_REAL ) CALL mpi_type_size( MPI_REAL, ftypesize, ierr ) ALLOCATE( RData( obuf(icurs/itypesize + 4 ) ) ) ! 5 is the count of data items for this record ; defined in collect_on_comm.c CALL int_get_td_header( obuf(icurs/itypesize:), hdrbufsize, itypesize, ftypesize, & @@ -1986,7 +1986,7 @@ SUBROUTINE quilt_pnc DEALLOCATE( RData ) ! Every I/O server handles the "put_dom_ti_real" request. - CASE ( int_dom_ti_real ) + CASE ( INT_DOM_TI_REAL ) CALL mpi_type_size( MPI_REAL, ftypesize, ierr ) ALLOCATE( RData( obuf(icurs/itypesize + 4 ) ) ) ! 5 is the count of data items for this record ; defined in collect_on_comm.c @@ -2026,7 +2026,7 @@ SUBROUTINE quilt_pnc DEALLOCATE( RData ) ! Every I/O server handles the "put_dom_td_integer" request. - CASE ( int_dom_td_integer ) + CASE ( INT_DOM_TD_INTEGER ) CALL mpi_type_size( MPI_INTEGER, ftypesize, ierr ) ALLOCATE( IData( obuf(icurs/itypesize + 4 ) ) ) ! 5 is the count of data items for this record ; defined in collect_on_comm.c @@ -2066,7 +2066,7 @@ SUBROUTINE quilt_pnc DEALLOCATE( IData ) ! Every I/O server handles the "put_dom_ti_integer" request. - CASE ( int_dom_ti_integer ) + CASE ( INT_DOM_TI_INTEGER ) CALL mpi_type_size( MPI_INTEGER, ftypesize, ierr ) ALLOCATE( IData( obuf(icurs/itypesize + 4 ) ) ) ! 5 is the count of data items for this record ; defined in collect_on_comm.c @@ -2106,7 +2106,7 @@ SUBROUTINE quilt_pnc DEALLOCATE( IData) ! Every I/O server handles the "set_time" request. - CASE ( int_set_time ) + CASE ( INT_SET_TIME ) CALL int_get_ti_header_char( obuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle, Element, VarName, CData, code ) @@ -2122,7 +2122,7 @@ SUBROUTINE quilt_pnc icurs = icurs + hdrbufsize ! Every I/O server handles the "put_dom_ti_char" request. - CASE ( int_dom_ti_char ) + CASE ( INT_DOM_TI_CHAR ) CALL int_get_ti_header_char( obuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle, Element, VarName, CData, code ) @@ -2159,7 +2159,7 @@ SUBROUTINE quilt_pnc icurs = icurs + hdrbufsize ! Every I/O server handles the "put_var_ti_char" request. - CASE ( int_var_ti_char ) + CASE ( INT_VAR_TI_CHAR ) CALL int_get_ti_header_char( obuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle, Element, VarName, CData, code ) @@ -2195,12 +2195,12 @@ SUBROUTINE quilt_pnc icurs = icurs + hdrbufsize - CASE ( int_ioexit ) + CASE ( INT_IOEXIT ) ! ioexit is now handled by sending negative message length to server CALL wrf_error_fatal( & - "quilt: should have handled int_ioexit already") + "quilt: should have handled INT_IOEXIT already") ! Every I/O server handles the "ioclose" request. - CASE ( int_ioclose ) + CASE ( INT_IOCLOSE ) CALL int_get_handle_header( obuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle , code ) icurs = icurs + hdrbufsize @@ -2256,17 +2256,17 @@ SUBROUTINE quilt_pnc ENDIF ! Every I/O server handles the "open_for_write_begin" request. - CASE ( int_open_for_write_begin ) + CASE ( INT_OPEN_FOR_WRITE_BEGIN ) CALL int_get_ofwb_header( obuf(icurs/itypesize), hdrbufsize, itypesize, & FileName,SysDepInfo,io_form_arg,DataHandle ) -!write(0,*)' int_open_for_write_begin itypesize ',itypesize,' itypesize ',itypesize -!write(0,*)' int_open_for_write_begin icurs ', icurs, hdrbufsize -!JMDEBUGwrite(0,*)' int_open_for_write_begin FileName ',TRIM(FileName) , ' DataHandle ', DataHandle -!write(0,*)' int_open_for_write_begin SysDepInfo ',TRIM(SysDepInfo) +!write(0,*)' INT_OPEN_FOR_WRITE_BEGIN itypesize ',itypesize,' itypesize ',itypesize +!write(0,*)' INT_OPEN_FOR_WRITE_BEGIN icurs ', icurs, hdrbufsize +!JMDEBUGwrite(0,*)' INT_OPEN_FOR_WRITE_BEGIN FileName ',TRIM(FileName) , ' DataHandle ', DataHandle +!write(0,*)' INT_OPEN_FOR_WRITE_BEGIN SysDepInfo ',TRIM(SysDepInfo) icurs = icurs + hdrbufsize -!write(0,*)' int_open_for_write_begin new icurs,tag,size ', icurs, get_hdr_tag( bigbuf(icurs/itypesize) ),get_hdr_rec_size( bigbuf(icurs/itypesize) ) +!write(0,*)' INT_OPEN_FOR_WRITE_BEGIN new icurs,tag,size ', icurs, get_hdr_tag( bigbuf(icurs/itypesize) ),get_hdr_rec_size( bigbuf(icurs/itypesize) ) io_form(DataHandle) = io_form_arg @@ -2304,25 +2304,25 @@ SUBROUTINE quilt_pnc ! Every I/O server handles the "open_for_write_commit" request. ! In this case, the "okay_to_commit" is simply set to .true. so "write_field" -! (int_field) requests will initiate writes to disk. Actual commit will be done after +! (INT_FIELD) requests will initiate writes to disk. Actual commit will be done after ! all requests in this batch have been handled. - CASE ( int_open_for_write_commit ) + CASE ( INT_OPEN_FOR_WRITE_COMMIT ) CALL int_get_handle_header( obuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle , code ) icurs = icurs + hdrbufsize okay_to_commit(DataHandle) = .true. -! Every I/O server handles the "write_field" (int_field) request. +! Every I/O server handles the "write_field" (INT_FIELD) request. ! If okay_to_write(DataHandle) is .true. then the patch in the ! header (bigbuf) is written to disk using pNetCDF. Note that this is where the actual ! "quilting" (reassembly of patches onto a full-size domain) is done. If ! okay_to_write(DataHandle) is .false. then external I/O package interfaces ! are called to write metadata for I/O formats that support native metadata. ! -! NOTE that the I/O servers will only see write_field (int_field) +! NOTE that the I/O servers will only see write_field (INT_FIELD) ! requests AFTER an "iosync" request. - CASE ( int_field ) + CASE ( INT_FIELD ) CALL mpi_type_size( MPI_INTEGER, ftypesize, ierr ) CALL int_get_write_field_header ( obuf(icurs/itypesize), hdrbufsize, itypesize, ftypesize, & DataHandle , DateStr , VarName , Dummy , FieldType , Comm , IOComm, & @@ -2330,7 +2330,7 @@ SUBROUTINE quilt_pnc DomainStart , DomainEnd , & MemoryStart , MemoryEnd , & PatchStart , PatchEnd ) -!write(0,*)' int_field ',TRIM(VarName),DataHandle,okay_to_write(DataHandle) +!write(0,*)' INT_FIELD ',TRIM(VarName),DataHandle,okay_to_write(DataHandle) icurs = icurs + hdrbufsize IF ( okay_to_write(DataHandle) ) THEN @@ -2445,7 +2445,7 @@ SUBROUTINE quilt_pnc Status = 0 END SELECT ENDIF - CASE ( int_iosync ) + CASE ( INT_IOSYNC ) CALL int_get_handle_header( obuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle , code ) icurs = icurs + hdrbufsize @@ -2465,7 +2465,7 @@ SUBROUTINE quilt_pnc ! (via a call to store_patch_in_outbuf_pnc()) then call write_outbuf_pnc() ! to write them to disk now. ! NOTE that the I/O server will only have called -! store_patch_in_outbuf() when handling write_field (int_field) +! store_patch_in_outbuf() when handling write_field (INT_FIELD) ! commands which only arrive AFTER an "iosync" command. ! CALL start_timing #ifdef PNETCDF_QUILT @@ -3088,7 +3088,7 @@ SUBROUTINE wrf_quilt_open_for_write_commit( DataHandle , Status ) !ARP parallel IO IF(compute_group_master(1)) THEN CALL int_gen_handle_header( hdrbuf, hdrbufsize, itypesize, & - DataHandle, int_open_for_write_commit ) + DataHandle, INT_OPEN_FOR_WRITE_COMMIT ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) END IF @@ -3096,7 +3096,7 @@ SUBROUTINE wrf_quilt_open_for_write_commit( DataHandle , Status ) IF ( wrf_dm_on_monitor() ) THEN CALL int_gen_handle_header( hdrbuf, hdrbufsize, itypesize, & - DataHandle, int_open_for_write_commit ) + DataHandle, INT_OPEN_FOR_WRITE_COMMIT ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -3336,14 +3336,14 @@ SUBROUTINE wrf_quilt_ioclose ( DataHandle, Status ) #ifdef PNETCDF_QUILT IF ( compute_group_master(1) )THEN CALL int_gen_handle_header( hdrbuf, hdrbufsize, itypesize, & - DataHandle, int_ioclose ) + DataHandle, INT_IOCLOSE ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF #else IF ( wrf_dm_on_monitor() ) THEN CALL int_gen_handle_header( hdrbuf, hdrbufsize, itypesize, & - DataHandle , int_ioclose ) + DataHandle , INT_IOCLOSE ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -3420,7 +3420,7 @@ SUBROUTINE wrf_quilt_ioexit( Status ) !ARP Send the ioexit message just once to each IOServer when using parallel IO IF( compute_group_master(1) ) THEN CALL int_gen_handle_header( hdrbuf, hdrbufsize, itypesize, & - DataHandle, int_ioexit ) + DataHandle, INT_IOEXIT ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) END IF @@ -3428,7 +3428,7 @@ SUBROUTINE wrf_quilt_ioexit( Status ) IF ( wrf_dm_on_monitor() ) THEN CALL int_gen_handle_header( hdrbuf, hdrbufsize, itypesize, & - DataHandle , int_ioexit ) ! Handle is dummy + DataHandle , INT_IOEXIT ) ! Handle is dummy ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -3532,14 +3532,14 @@ SUBROUTINE wrf_quilt_set_time ( DataHandle, Data, Status ) ! can't tell that's what they are on the IO servers themselves - therefore use ! the compute_group_master process. CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & - DataHandle, "TIMESTAMP", "", Data, int_set_time ) + DataHandle, "TIMESTAMP", "", Data, INT_SET_TIME ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) END IF #else IF ( wrf_dm_on_monitor() ) THEN CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & - DataHandle, "TIMESTAMP", "", Data, int_set_time ) + DataHandle, "TIMESTAMP", "", Data, INT_SET_TIME ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -3648,14 +3648,14 @@ SUBROUTINE wrf_quilt_put_dom_ti_real ( DataHandle,Element, Data, Count, Statu #ifdef PNETCDF_QUILT IF ( compute_group_master(1) ) THEN CALL int_gen_ti_header( hdrbuf, hdrbufsize, itypesize, typesize, & - DataHandle, locElement, Data, Count, int_dom_ti_real ) + DataHandle, locElement, Data, Count, INT_DOM_TI_REAL ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF #else IF ( wrf_dm_on_monitor() ) THEN CALL int_gen_ti_header( hdrbuf, hdrbufsize, itypesize, typesize, & - DataHandle, locElement, Data, Count, int_dom_ti_real ) + DataHandle, locElement, Data, Count, INT_DOM_TI_REAL ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -3806,7 +3806,7 @@ SUBROUTINE wrf_quilt_put_dom_ti_integer ( DataHandle,Element, Data, Count, St IF ( compute_group_master(1) )THEN CALL int_gen_ti_header( hdrbuf, hdrbufsize, itypesize, typesize, & DataHandle, locElement, Data, Count, & - int_dom_ti_integer ) + INT_DOM_TI_INTEGER ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -3814,7 +3814,7 @@ SUBROUTINE wrf_quilt_put_dom_ti_integer ( DataHandle,Element, Data, Count, St IF ( wrf_dm_on_monitor() ) THEN CALL int_gen_ti_header( hdrbuf, hdrbufsize, itypesize, typesize, & DataHandle, locElement, Data, Count, & - int_dom_ti_integer ) + INT_DOM_TI_INTEGER ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -3966,14 +3966,14 @@ SUBROUTINE wrf_quilt_put_dom_ti_char ( DataHandle, Element, Data, Status ) IF(compute_group_master(1))THEN CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & DataHandle, Element, "", Data, & - int_dom_ti_char ) + INT_DOM_TI_CHAR ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) END IF #else IF ( wrf_dm_on_monitor() ) THEN CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & - DataHandle, Element, "", Data, int_dom_ti_char ) + DataHandle, Element, "", Data, INT_DOM_TI_CHAR ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -4510,7 +4510,7 @@ SUBROUTINE wrf_quilt_put_var_ti_char ( DataHandle,Element, Varname, Data, Stat IF ( compute_group_master(1) ) THEN CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & DataHandle, TRIM(Element), & - TRIM(VarName), TRIM(Data), int_var_ti_char ) + TRIM(VarName), TRIM(Data), INT_VAR_TI_CHAR ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -4518,7 +4518,7 @@ SUBROUTINE wrf_quilt_put_var_ti_char ( DataHandle,Element, Varname, Data, Stat IF ( wrf_dm_on_monitor() ) THEN CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & DataHandle, TRIM(Element), & - TRIM(VarName), TRIM(Data), int_var_ti_char ) + TRIM(VarName), TRIM(Data), INT_VAR_TI_CHAR ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -4852,7 +4852,7 @@ SUBROUTINE wrf_quilt_write_field ( DataHandle , DateStr , VarName , Field , Fiel ! During a "real" write, this routine begins by allocating ! int_local_output_buffer if it has not already been allocated. Sizes ! accumulated during "training" are used to determine how big -! int_local_output_buffer must be. This routine then stores "int_field" +! int_local_output_buffer must be. This routine then stores "INT_FIELD" ! headers and associated field data in int_local_output_buffer. The contents ! of int_local_output_buffer are actually sent to the I/O quilt server in ! routine wrf_quilt_iosync(). This scheme allows output of multiple variables From bd029aec020ebf4ad628ab3add0ddbc261ecee8a Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:51:05 -0600 Subject: [PATCH 023/180] Compiling io_int --- external/io_int/CMakeLists.txt | 51 ++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/external/io_int/CMakeLists.txt b/external/io_int/CMakeLists.txt index e69de29bb2..652e95ff55 100644 --- a/external/io_int/CMakeLists.txt +++ b/external/io_int/CMakeLists.txt @@ -0,0 +1,51 @@ +# WRF CMake Build +# get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# add_library( +# ${FOLDER_COMPILE_TARGET} +# STATIC +# ) + +# target_sources( +# ${FOLDER_COMPILE_TARGET} +# PRIVATE +target_sources( + ${PROJECT_NAME}_Core + PRIVATE + io_int.F90 + io_int_idx.c + module_io_int_idx.F90 + module_io_int_read.F90 + ) + +# set_target_properties( +# ${FOLDER_COMPILE_TARGET} +# PROPERTIES +# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} +# Fortran_FORMAT FREE +# ) + + +# target_link_libraries( ${FOLDER_COMPILE_TARGET} +# PRIVATE +# ${netCDF_LIBRARIES} +# $<$:$> +# $<$:$> +# ) + +# target_include_directories( ${FOLDER_COMPILE_TARGET} +# PRIVATE +# ${netCDF_INCLUDE_DIRS} +# ${CMAKE_CURRENT_SOURCE_DIR} +# #!TODO Fix duplicates of wrf_[io|status]_flags.h +# # ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share +# ${CMAKE_CURRENT_SOURCE_DIR}/../io_grib_share +# ${CMAKE_CURRENT_SOURCE_DIR}/../../inc +# ) + +# install( +# TARGETS ${FOLDER_COMPILE_TARGET} +# RUNTIME DESTINATION bin/ +# ARCHIVE DESTINATION lib/ +# LIBRARY DESTINATION lib/ +# ) From 60b47ea7b5746f373ee14bbb27f9eb66f7005df3 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:51:46 -0600 Subject: [PATCH 024/180] No longer needed with set policy, might need to reinstate for older versions of cmake if even possible --- frame/CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/frame/CMakeLists.txt b/frame/CMakeLists.txt index a1db9c0710..1cea61b826 100644 --- a/frame/CMakeLists.txt +++ b/frame/CMakeLists.txt @@ -44,14 +44,14 @@ # add_dependencies( ${FOLDER_COMPILE_TARGET}_deps share_model_constants registry_code ) -# Tell CMake to chill, we'll generate those files shortly -# Thanks to https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-add-a-dependency-to-a-source-file-which-is-generated-in-a-subdirectory -# and https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/ -set_source_files_properties( - ${CMAKE_BINARY_DIR}/frame/module_state_description.F - PROPERTIES - GENERATED TRUE - ) +# # Tell CMake to chill, we'll generate those files shortly +# # Thanks to https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-add-a-dependency-to-a-source-file-which-is-generated-in-a-subdirectory +# # and https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/ +# set_source_files_properties( +# ${CMAKE_BINARY_DIR}/frame/module_state_description.F +# PROPERTIES +# GENERATED TRUE +# ) # set_target_properties( # ${FOLDER_COMPILE_TARGET}_deps From f4c77a6a2862fc3c8750be4fec96e26a1b827d58 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:52:31 -0600 Subject: [PATCH 025/180] Outputting nl_* routines as f90, and processing md_calls with m4 --- frame/CMakeLists.txt | 79 +++++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 27 deletions(-) diff --git a/frame/CMakeLists.txt b/frame/CMakeLists.txt index 1cea61b826..affccb12a5 100644 --- a/frame/CMakeLists.txt +++ b/frame/CMakeLists.txt @@ -136,41 +136,66 @@ set( nl_dyn_source ) get_directory_property( DIR_DEFS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS ) foreach( n RANGE 0 7 ) - wrf_preproc_fortran( - TARGET_NAME nl_set_${n} - GENERATED_SCOPE ${PROJECT_NAME}_Core - OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ - EXTENSION ".i" - PREFIX "nl_set_${n}_" - INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_BINARY_DIR}/inc - DEPENDENCIES registry_code - DEFINITIONS ${DIR_DEFS} NNN=${n} NL_set_ROUTINES - SOURCES nl_access_routines.F - ) - wrf_preproc_fortran( - TARGET_NAME nl_get_${n} - GENERATED_SCOPE ${PROJECT_NAME}_Core - OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ - EXTENSION ".i" - PREFIX "nl_get_${n}_" - INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_BINARY_DIR}/inc - DEPENDENCIES registry_code - DEFINITIONS ${DIR_DEFS} NNN=${n} NL_get_ROUTINES - SOURCES nl_access_routines.F - ) + wrf_c_preproc_fortran( + TARGET_NAME nl_set_${n} + OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ + EXTENSION ".f90" + PREFIX "nl_set_${n}_" + INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_BINARY_DIR}/inc + DEPENDENCIES registry_code + DEFINITIONS ${DIR_DEFS} NNN=${n} NL_set_ROUTINES + SOURCES nl_access_routines.F + ) + wrf_c_preproc_fortran( + TARGET_NAME nl_get_${n} + OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ + EXTENSION ".f90" + PREFIX "nl_get_${n}_" + INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_BINARY_DIR}/inc + DEPENDENCIES registry_code + DEFINITIONS ${DIR_DEFS} NNN=${n} NL_get_ROUTINES + SOURCES nl_access_routines.F + ) + + add_dependencies( ${PROJECT_NAME}_Core nl_get_${n} nl_set_${n} ) list( APPEND nl_dyn_source - ${CMAKE_CURRENT_BINARY_DIR}/preproc/nl_set_${n}_nl_access_routines.i - ${CMAKE_CURRENT_BINARY_DIR}/preproc/nl_get_${n}_nl_access_routines.i + ${CMAKE_CURRENT_BINARY_DIR}/preproc/nl_set_${n}_nl_access_routines.f90 + ${CMAKE_CURRENT_BINARY_DIR}/preproc/nl_get_${n}_nl_access_routines.f90 ) endforeach() - +if ( ${USE_M4} ) + wrf_m4_preproc_fortran( + TARGET_NAME md_calls + OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ + EXTENSION ".inc" + SOURCES md_calls.m4 + ) + +else() + # Copy from arch quickly + # Normally I would say we just add it as source but it is an include file and I don't want to potentially + # pollute the include chain by adding in arch/ *and* I want to maintain the order of operations + # for target dependencies + wrf_copy_source_files( + TARGET_NAME md_calls + OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ + SOURCES ${PROJECT_SOURCE_DIR}/arch/md_calls.inc + ) +endif() + +add_dependencies( ${PROJECT_NAME}_Core md_calls ) +target_include_directories( + ${PROJECT_NAME}_Core + PRIVATE + ${CMAKE_CURRENT_BINARY_DIR}/preproc/ + ) ######################################################################################################################## # # Now define base framework From 326b79901f5f41335010195c59dca529e182c41f Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:53:22 -0600 Subject: [PATCH 026/180] Adding many missing defines, linking and option selections --- CMakeLists.txt | 127 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 117 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c75216b78d..2ab87a9ae1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,11 @@ project( WRF ) # list( APPEND CMAKE_MODULE_PATH ) list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/ ${PROJECT_SOURCE_DIR}/cmake/modules ) -# TODO rename to something better -include( preproc ) +include( c_preproc ) +include( m4_preproc ) +include( target_copy ) +include( confcheck ) + ################################################################################ @@ -44,13 +47,18 @@ set( GRIB1 ON CACHE BOOL "GRIB1" ) set( INTIO ON CACHE BOOL "INTIO" ) set( KEEP_INT_AROUND ON CACHE BOOL "KEEP_INT_AROUND" ) set( LIMIT_ARGS ON CACHE BOOL "LIMIT_ARGS" ) +set( WRFIO_NCD_NO_LARGE_FILE_SUPPORT OFF CACHE BOOL "WRFIO_NCD_NO_LARGE_FILE_SUPPORT" ) set( BUILD_RRTMG_FAST OFF CACHE BOOL "BUILD_RRTMG_FAST" ) set( BUILD_RRTMK OFF CACHE BOOL "BUILD_RRTMK" ) set( BUILD_SBM_FAST ON CACHE BOOL "BUILD_SBM_FAST" ) set( SHOW_ALL_VARS_USED OFF CACHE BOOL "SHOW_ALL_VARS_USED" ) + # Not cached, cannot be changed, do not touch +set( USE_M4 ON ) +# Same thing -what do these defines even do if they are always on???? set( NMM_CORE OFF ) +set( NETCDF ON ) # WRF Core selection set( WRF_CORE_OPTIONS @@ -123,11 +131,30 @@ if( ${WRF_CORE} STREQUAL "CONVERT" OR ${WRF_CORE} STREQUAL "COAMPS" ) set( EM_CORE 0 ) endif() +if ( ${ENABLE_KPP} AND NOT ${ENABLE_CHEM} ) + message( WARNING "ENABLE_KPP requires ENABLE_CHEM but is not set, ignoring" ) +endif() + +################################################################################ +## +## Configuration checks for features & intrinsices +## +################################################################################ +add_subdirectory( confcheck ) + ################################################################################ ## ## Now find packages that cross-compilation is potentially handled ## ################################################################################ +if ( ${USE_M4} ) + find_program( + M4_PROGRAM + m4 + REQUIRED + ) +endif() + # Provided by cmake natively find_package( ZLIB REQUIRED ) find_package( CURL REQUIRED ) @@ -135,6 +162,12 @@ find_package( CURL REQUIRED ) # HDF5 has some funky weirdness between versions where the casing has changed find_package( HDF5 REQUIRED ) +find_package( Jasper REQUIRED ) + +if ( ${ENABLE_TERRAIN} ) + find_package( RPC ) +endif() + # Will need our own finder # find_package( GPFS REQUIRED ) @@ -148,12 +181,13 @@ if ( NOT netCDF_VERSION GREATER_EQUAL "4.1.3" ) endif() if ( USE_MPI ) - find_package( MPI REQUIRED COMPONENTS Fortran ) + find_package( MPI REQUIRED COMPONENTS Fortran C ) add_compile_definitions( USE_MPI=1 DM_PARALLEL=1 ) endif() if ( USE_OPENMP ) - find_package( OpenMP REQUIRED COMPONENTS Fortran ) + find_package( OpenMP REQUIRED COMPONENTS Fortran C ) + add_compile_definitions( USE_OPENMP=1 SM_PARALLEL=1 ) endif() ################################################################################ @@ -163,7 +197,7 @@ endif() ################################################################################ # https://stackoverflow.com/a/53155812 set( Fortran_COMPILER_ID ${CMAKE_Fortran_COMPILER_ID} ) -message( STATUS "Set Fortran_COMPILER_ID to : ${Fortran_COMPILER_ID}" ) +# message( STATUS "Set Fortran_COMPILER_ID to : ${Fortran_COMPILER_ID}" ) # Whole project flags @@ -187,15 +221,28 @@ add_compile_definitions( # 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_KPP=$> $<$:WRF_DFI_RADAR=$> $<$:WRF_TITAN=$> $<$:WRF_MARS=$> $<$:WRF_VENUS=$> + $<$:NETCDF_classic=$> + $<$:WRFIO_NCD_NO_LARGE_FILE_SUPPORT=$> + # TODO Figure out how these should be set + # DUSE_NETCDF4_FEATURES -DWRFIO_NCD_LARGE_FILE_SUPPORT + + $<$:MPI2_SUPPORT=$> + $<$:MPI2_THREAD_SUPPORT=$> + + # 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) - $<$>:LANDREAD_STUB=$>> + # not enable terran or not rpc_found do + # not ( enable terrain and rpc_found ) + $<$,$>>:LANDREAD_STUB> + $<$:TERRAIN_AND_LANDUSE> $<$:USE_ALLOCATABLES> @@ -204,17 +251,38 @@ add_compile_definitions( $<$: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=$ + NETCDF + + EM_CORE=${EM_CORE} WRFPLUS=$> DA_CORE=$,$>> # DFI_RADAR=$ + + # 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>> + + + MPI2_SUPPORT + MPI2_THREAD_SUPPORT ) @@ -237,7 +305,8 @@ add_library( STATIC ) -# Supplemental to core +# 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 ) add_subdirectory( tools ) @@ -246,6 +315,26 @@ add_dependencies( ${PROJECT_NAME}_Core # So many things depend on this that I'm adding a dep here registry_code + # "External" io libs + esmf_time_f90 + + # io_pio + + # io_netcdf + # io_netcdfpar + # io_pnetcdf + # io_phdf5 + io_grib1 + io_grib_share + g2lib + bacio-1.3 + + RSL_LITE + fftpack5 + # add_dependencies() does not support generator expressions + # $ + # $ + # $ ) target_include_directories( ${PROJECT_NAME}_Core @@ -253,15 +342,19 @@ target_include_directories( ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/inc ${PROJECT_SOURCE_DIR}/dyn_em - ${PROJECT_SOURCE_DIR}/frame + # ${PROJECT_SOURCE_DIR}/frame # externals ${PROJECT_SOURCE_DIR}/external/io_grib_share ${PROJECT_SOURCE_DIR}/external/io_netcdf ${PROJECT_SOURCE_DIR}/external/io_int + ${PROJECT_SOURCE_DIR}/external/grib2 ${PROJECT_SOURCE_DIR}/external/ioapi_share + $ $ + $ + $ ${CMAKE_BINARY_DIR}/inc @@ -273,6 +366,12 @@ add_subdirectory( phys ) add_subdirectory( share ) add_subdirectory( frame ) +if ( ${WRF_CHEM} ) + add_subdirectory( chem ) +endif() + +add_subdirectory( dyn_em ) + # Configure core set_target_properties( ${PROJECT_NAME}_Core @@ -288,7 +387,15 @@ target_link_libraries( ${PROJECT_NAME}_Core $<$:$> $<$:$> esmf_time_f90 - ) + g2lib + bacio-1.3 + + # This will add in target dependencies if they exist + $ + $ + $ + $ + ) # target_include_directories( # ${PROJECT_NAME}_Core From 8ebc808bb807bfefa10edcfaf0bac32c830f7f29 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 17:32:21 -0600 Subject: [PATCH 027/180] Adjusting regex to handle generator expressions better --- cmake/c_preproc.cmake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmake/c_preproc.cmake b/cmake/c_preproc.cmake index e8eb03c7bf..471c9bce10 100644 --- a/cmake/c_preproc.cmake +++ b/cmake/c_preproc.cmake @@ -124,11 +124,12 @@ macro( wrf_expand_definitions ) 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 if ( ${WRF_EXP_DEF} MATCHES "^[$]<" ) - # Take advantage of the fact that the first time a generator expression ends to finally - # name the define it has the first ">:" then unexpanded characters (hopefully) + # 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} ) + 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} ) else() list( APPEND WRF_EXP_DEFS -D${WRF_EXP_DEF} ) From e99b7e7e3fb5fc8d66d30b301f1f8c6cdf11e935 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 17:32:54 -0600 Subject: [PATCH 028/180] Output options selected --- cmake/printOption.cmake | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 cmake/printOption.cmake diff --git a/cmake/printOption.cmake b/cmake/printOption.cmake new file mode 100644 index 0000000000..f00d893e9a --- /dev/null +++ b/cmake/printOption.cmake @@ -0,0 +1,54 @@ +# https://stackoverflow.com/a/19578320 +# Some color defintions +if ( NOT "${PRINT_OPTION_SUPPRESS_COLOR}" ) + if ( NOT WIN32 ) + string( ASCII 27 ESC ) + set( COLOR_RESET "${ESC}[m" ) + set( COLOR_BOLD "${ESC}[1m" ) + set( RED "${ESC}[31m" ) + set( GREEN "${ESC}[32m" ) + set( YELLOW "${ESC}[33m" ) + set( BLUE "${ESC}[34m" ) + set( MAGENTA "${ESC}[35m" ) + set( CYAN "${ESC}[36m" ) + set( WHITE "${ESC}[37m" ) + set( BOLD_RED "${ESC}[1;31m" ) + set( BOLD_GREEN "${ESC}[1;32m" ) + set( BOLD_YELLOW "${ESC}[1;33m" ) + set( BOLD_BLUE "${ESC}[1;34m" ) + set( BOLD_MAGENTA "${ESC}[1;35m" ) + set( BOLD_CYAN "${ESC}[1;36m" ) + set( BOLD_WHITE "${ESC}[1;37m" ) + endif() +endif() + +function( print_option ) + set( OPTION ${ARGV0} ) + set( JUSTIFY ${ARGV1} ) + + if ( ${ARGC} GREATER_EQUAL 3 ) + set( ALT_COLOR ${ARGV2} ) + endif() + + if ( DEFINED ALT_COLOR ) + set( OPT_COLOR ${ALT_COLOR} ) + else() + set( OPT_COLOR ${RED} ) + if ( ${${OPTION}} ) + set( OPT_COLOR ${GREEN} ) + endif() + endif() + + set( OPTION_STR "${OPTION}" ) + string( LENGTH ${OPTION_STR} OPTION_STR_LEN ) + math( EXPR N_JUSTIFY "${JUSTIFY} - ${OPTION_STR_LEN}" ) + + if ( ${N_JUSTIFY} LESS 1 ) + set( N_JUSTIFY 1 ) + endif() + + string( REPEAT " " ${N_JUSTIFY} JUSTIFY_WHITESPACE ) + + message( STATUS "${OPTION_STR}${JUSTIFY_WHITESPACE} : ${OPT_COLOR}${${OPTION}}${COLOR_RESET}" ) + +endfunction() \ No newline at end of file From 7373479744952cf8962a9a758e2b7eac20bad209 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 17:33:28 -0600 Subject: [PATCH 029/180] Closing the gap in differences between make and cmake builds --- CMakeLists.txt | 115 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 93 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ab87a9ae1..855c12a02d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ include( c_preproc ) include( m4_preproc ) include( target_copy ) include( confcheck ) - +include( printOption ) ################################################################################ @@ -28,8 +28,42 @@ set( OPTIMIZATION_LEVEL "" ) set( WRF_OS "" ) set( WRF_MACH "" ) -# Mode configuration # DO NOT USE OPTION - IT DOES NOT WORK AS ANTICIPATED EVEN WHEN CLEARING CACHE - YOU HAVE BEEN WARNED +# Mode configuration +# WRF Core selection +set( WRF_CORE_OPTIONS + # Options listed here + ARW + COAMPS # Not sure how this is used + CONVERT # This exists in compile but not configure + DA + DA_4D_VAR + PLUS + ) + +# Set default WRF_CORE +set( WRF_CORE "" CACHE STRING "WRF_CORE" ) +list( GET WRF_CORE_OPTIONS 0 WRF_CORE ) + +# WRF Nesting selection +set( WRF_NESTING_OPTIONS + # Options listed here + NONE + BASIC #TODO Figure out what exactly this does aside from potentially stub things Config.pl:890 + MOVES + VORTEX + ) + +# Set default WRF_NESTING +set( WRF_NESTING "" CACHE STRING "WRF_NESTING" ) +list( GET WRF_NESTING_OPTIONS 0 WRF_NESTING ) + + +set( USE_DOUBLE OFF CACHE BOOL "USE_DOUBLE" ) # I believe this is the r8/real8 promotion +set( USE_MPI OFF CACHE BOOL "USE_MPI" ) +set( USE_OPENMP OFF CACHE BOOL "USE_OPENMP" ) + + set( ENABLE_CHEM OFF CACHE BOOL "ENABLE_CHEM" ) set( ENABLE_CMAQ OFF CACHE BOOL "ENABLE_CMAQ" ) set( ENABLE_KPP OFF CACHE BOOL "ENABLE_KPP" ) @@ -39,6 +73,7 @@ set( ENABLE_MARS OFF CACHE BOOL "ENABLE_MARS" ) set( ENABLE_VENUS OFF CACHE BOOL "ENABLE_VENUS" ) set( ENABLE_VENUS OFF CACHE BOOL "ENABLE_VENUS" ) set( ENABLE_TERRAIN OFF CACHE BOOL "ENABLE_TERRAIN" ) +set( ENABLE_CLM OFF CACHE BOOL "ENABLE_CLM" ) # What do these defines even do if they are always on???? set( USE_ALLOCATABLES ON CACHE BOOL "USE_ALLOCATABLES" ) @@ -54,32 +89,14 @@ set( BUILD_RRTMK OFF CACHE BOOL "BUILD_RRTMK" ) set( BUILD_SBM_FAST ON CACHE BOOL "BUILD_SBM_FAST" ) set( SHOW_ALL_VARS_USED OFF CACHE BOOL "SHOW_ALL_VARS_USED" ) + + # Not cached, cannot be changed, do not touch set( USE_M4 ON ) # Same thing -what do these defines even do if they are always on???? set( NMM_CORE OFF ) set( NETCDF ON ) -# WRF Core selection -set( WRF_CORE_OPTIONS - # Options listed here - ARW - COAMPS # Not sure how this is used - CONVERT # This exists in compile but not configure - DA - DA_4D_VAR - PLUS - ) - -# Set default WRF_CORE -set( WRF_CORE "" CACHE STRING "WRF_CORE" ) -list( GET WRF_CORE_OPTIONS 0 WRF_CORE ) - - - -option( USE_DOUBLE OFF ) # I believe this is the r8/real8 promotion -option( USE_MPI OFF ) -option( USE_OPENMP OFF ) # From arch/preamble #### Single location for defining total number of domains. You need @@ -131,10 +148,51 @@ if( ${WRF_CORE} STREQUAL "CONVERT" OR ${WRF_CORE} STREQUAL "COAMPS" ) set( EM_CORE 0 ) endif() +set( MOVE_NESTS 0 ) +# Far easier to write this one as normal logic rather than generator expression +if( ${WRF_NESTING} STREQUAL "MOVES" OR ${WRF_NESTING} STREQUAL "VORTEX" ) + set( MOVE_NESTS 1 ) +endif() + if ( ${ENABLE_KPP} AND NOT ${ENABLE_CHEM} ) message( WARNING "ENABLE_KPP requires ENABLE_CHEM but is not set, ignoring" ) endif() + + +print_option( WRF_CORE 20 ${BOLD_CYAN} ) +print_option( WRF_NESTING 20 ${BOLD_CYAN} ) + +print_option( USE_DOUBLE 20 ) +print_option( USE_MPI 20 ) +print_option( USE_OPENMP 20 ) + + +print_option( ENABLE_CHEM 20 ) +print_option( ENABLE_CMAQ 20 ) +print_option( ENABLE_KPP 20 ) +print_option( ENABLE_DFI_RADAR 20 ) +print_option( ENABLE_TITAN 20 ) +print_option( ENABLE_MARS 20 ) +print_option( ENABLE_VENUS 20 ) +print_option( ENABLE_VENUS 20 ) +print_option( ENABLE_TERRAIN 20 ) +print_option( ENABLE_CLM 20 ) + +print_option( USE_ALLOCATABLES 20 ) +print_option( wrfmodel 20 ) +print_option( GRIB1 20 ) +print_option( INTIO 20 ) +print_option( KEEP_INT_AROUND 20 ) +print_option( LIMIT_ARGS 20 ) + +print_option( BUILD_RRTMG_FAST 20 ) +print_option( BUILD_RRTMK 20 ) +print_option( BUILD_SBM_FAST 20 ) +print_option( SHOW_ALL_VARS_USED 20 ) + +print_option( WRFIO_NCD_NO_LARGE_FILE_SUPPORT 36 ) + ################################################################################ ## ## Configuration checks for features & intrinsices @@ -168,6 +226,11 @@ if ( ${ENABLE_TERRAIN} ) find_package( RPC ) endif() +if ( ${ENABLE_CLM} ) + # Will need our own finder + # find_package( CLM REQUIRED ) +endif() + # Will need our own finder # find_package( GPFS REQUIRED ) @@ -228,6 +291,7 @@ add_compile_definitions( $<$:WRF_TITAN=$> $<$:WRF_MARS=$> $<$:WRF_VENUS=$> + $<$:WRF_USE_CLM=$> $<$:NETCDF_classic=$> $<$:WRFIO_NCD_NO_LARGE_FILE_SUPPORT=$> @@ -260,14 +324,21 @@ add_compile_definitions( # Alwasys set NMM_CORE=$ + NMM_MAX_DIM=2600 NETCDF + #!TODO Change this to a confcheck + 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> From cd18dcf94d0c64c06961e5dc3c8a112914ed4ed6 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 17 May 2023 16:51:30 -0600 Subject: [PATCH 030/180] Removing redundant files --- external/io_grib1/wrf_status_codes.h | 133 -------------------- external/io_grib_share/wrf_io_flags.h | 16 --- external/io_grib_share/wrf_status_codes.h | 142 ---------------------- 3 files changed, 291 deletions(-) delete mode 100644 external/io_grib1/wrf_status_codes.h delete mode 100644 external/io_grib_share/wrf_io_flags.h delete mode 100644 external/io_grib_share/wrf_status_codes.h diff --git a/external/io_grib1/wrf_status_codes.h b/external/io_grib1/wrf_status_codes.h deleted file mode 100644 index 059d9ea719..0000000000 --- a/external/io_grib1/wrf_status_codes.h +++ /dev/null @@ -1,133 +0,0 @@ - -!WRF Error and Warning messages (1-999) -!All i/o package-specific status codes you may want to add must be handled by your package (see below) -! WRF handles these and netCDF messages only - integer, parameter :: WRF_NO_ERR = 0 !no error - integer, parameter :: WRF_WARN_FILE_NF = -1 !file not found, or incomplete - integer, parameter :: WRF_WARN_MD_NF = -2 !metadata not found - integer, parameter :: WRF_WARN_TIME_NF = -3 !timestamp not found - integer, parameter :: WRF_WARN_TIME_EOF = -4 !no more timestamps - integer, parameter :: WRF_WARN_VAR_NF = -5 !variable not found - integer, parameter :: WRF_WARN_VAR_EOF = -6 !no more variables for the current time - integer, parameter :: WRF_WARN_TOO_MANY_FILES = -7 !too many open files - integer, parameter :: WRF_WARN_TYPE_MISMATCH = -8 !data type mismatch - integer, parameter :: WRF_WARN_WRITE_RONLY_FILE = -9 !attempt to write readonly file - integer, parameter :: WRF_WARN_READ_WONLY_FILE = -10 !attempt to read writeonly file - integer, parameter :: WRF_WARN_FILE_NOT_OPENED = -11 !attempt to access unopened file - integer, parameter :: WRF_WARN_2DRYRUNS_1VARIABLE = -12 !attempt to do 2 trainings for 1 variable - integer, parameter :: WRF_WARN_READ_PAST_EOF = -13 !attempt to read past EOF - integer, parameter :: WRF_WARN_BAD_DATA_HANDLE = -14 !bad data handle - integer, parameter :: WRF_WARN_WRTLEN_NE_DRRUNLEN = -15 !write length not equal to training length - integer, parameter :: WRF_WARN_TOO_MANY_DIMS = -16 !more dimensions requested than training - integer, parameter :: WRF_WARN_COUNT_TOO_LONG = -17 !attempt to read more data than exists - integer, parameter :: WRF_WARN_DIMENSION_ERROR = -18 !input dimension inconsistent - integer, parameter :: WRF_WARN_BAD_MEMORYORDER = -19 !input MemoryOrder not recognized - integer, parameter :: WRF_WARN_DIMNAME_REDEFINED = -20 !a dimension name with 2 different lengths - integer, parameter :: WRF_WARN_CHARSTR_GT_LENDATA = -21 !string longer than provided storage - integer, parameter :: WRF_WARN_NOTSUPPORTED = -22 !function not supportable - integer, parameter :: WRF_WARN_NOOP = -23 !package implements this routine as NOOP - -!Fatal errors - integer, parameter :: WRF_ERR_FATAL_ALLOCATION_ERROR = -100 !allocation error - integer, parameter :: WRF_ERR_FATAL_DEALLOCATION_ERR = -101 !dealloc error - integer, parameter :: WRF_ERR_FATAL_BAD_FILE_STATUS = -102 !bad file status - - -!Package specific errors (1000+) -!Netcdf status codes -!WRF will accept status codes of 1000+, but it is up to the package to handle -! and return the status to the user. - - integer, parameter :: WRF_ERR_FATAL_BAD_VARIABLE_DIM = -1004 - integer, parameter :: WRF_ERR_FATAL_MDVAR_DIM_NOT_1D = -1005 - integer, parameter :: WRF_ERR_FATAL_TOO_MANY_TIMES = -1006 - integer, parameter :: WRF_WARN_BAD_DATA_TYPE = -1007 !this code not in either spec? - integer, parameter :: WRF_WARN_FILE_NOT_COMMITTED = -1008 !this code not in either spec? - integer, parameter :: WRF_WARN_FILE_OPEN_FOR_READ = -1009 - integer, parameter :: WRF_IO_NOT_INITIALIZED = -1010 - integer, parameter :: WRF_WARN_MD_AFTER_OPEN = -1011 - integer, parameter :: WRF_WARN_TOO_MANY_VARIABLES = -1012 - integer, parameter :: WRF_WARN_DRYRUN_CLOSE = -1013 - integer, parameter :: WRF_WARN_DATESTR_BAD_LENGTH = -1014 - integer, parameter :: WRF_WARN_ZERO_LENGTH_READ = -1015 - integer, parameter :: WRF_WARN_DATA_TYPE_NOT_FOUND = -1016 - integer, parameter :: WRF_WARN_DATESTR_ERROR = -1017 - integer, parameter :: WRF_WARN_DRYRUN_READ = -1018 - integer, parameter :: WRF_WARN_ZERO_LENGTH_GET = -1019 - integer, parameter :: WRF_WARN_ZERO_LENGTH_PUT = -1020 - integer, parameter :: WRF_WARN_NETCDF = -1021 - integer, parameter :: WRF_WARN_LENGTH_LESS_THAN_1 = -1022 - integer, parameter :: WRF_WARN_MORE_DATA_IN_FILE = -1023 - integer, parameter :: WRF_WARN_DATE_LT_LAST_DATE = -1024 - -! For HDF5 only - integer, parameter :: WRF_HDF5_ERR_FILE = -200 - integer, parameter :: WRF_HDF5_ERR_MD = -201 - integer, parameter :: WRF_HDF5_ERR_TIME = -202 - integer, parameter :: WRF_HDF5_ERR_TIME_EOF = -203 - integer, parameter :: WRF_HDF5_ERR_MORE_DATA_IN_FILE = -204 - integer, parameter :: WRF_HDF5_ERR_DATE_LT_LAST_DATE = -205 - integer, parameter :: WRF_HDF5_ERR_TOO_MANY_FILES = -206 - integer, parameter :: WRF_HDF5_ERR_TYPE_MISMATCH = -207 - integer, parameter :: WRF_HDF5_ERR_LENGTH_LESS_THAN_1 = -208 - integer, parameter :: WRF_HDF5_ERR_WRITE_RONLY_FILE = -209 - integer, parameter :: WRF_HDF5_ERR_READ_WONLY_FILE = -210 - integer, parameter :: WRF_HDF5_ERR_FILE_NOT_OPENED = -211 - integer, parameter :: WRF_HDF5_ERR_DATESTR_ERROR = -212 - integer, parameter :: WRF_HDF5_ERR_DRYRUN_READ = -213 - integer, parameter :: WRF_HDF5_ERR_ZERO_LENGTH_GET = -214 - integer, parameter :: WRF_HDF5_ERR_ZERO_LENGTH_PUT = -215 - integer, parameter :: WRF_HDF5_ERR_2DRYRUNS_1VARIABLE = -216 - integer, parameter :: WRF_HDF5_ERR_DATA_TYPE_NOTFOUND = -217 - integer, parameter :: WRF_HDF5_ERR_READ_PAST_EOF = -218 - integer, parameter :: WRF_HDF5_ERR_BAD_DATA_HANDLE = -219 - integer, parameter :: WRF_HDF5_ERR_WRTLEN_NE_DRRUNLEN = -220 - integer, parameter :: WRF_HDF5_ERR_DRYRUN_CLOSE = -221 - integer, parameter :: WRF_HDF5_ERR_DATESTR_BAD_LENGTH = -222 - integer, parameter :: WRF_HDF5_ERR_ZERO_LENGTH_READ = -223 - integer, parameter :: WRF_HDF5_ERR_TOO_MANY_DIMS = -224 - integer, parameter :: WRF_HDF5_ERR_TOO_MANY_VARIABLES = -225 - integer, parameter :: WRF_HDF5_ERR_COUNT_TOO_LONG = -226 - integer, parameter :: WRF_HDF5_ERR_DIMENSION_ERROR = -227 - integer, parameter :: WRF_HDF5_ERR_BAD_MEMORYORDER = -228 - integer, parameter :: WRF_HDF5_ERR_DIMNAME_REDEFINED = -229 - integer, parameter :: WRF_HDF5_ERR_MD_AFTER_OPEN = -230 - integer, parameter :: WRF_HDF5_ERR_CHARSTR_GT_LENDATA = -231 - integer, parameter :: WRF_HDF5_ERR_BAD_DATA_TYPE = -232 - integer, parameter :: WRF_HDF5_ERR_FILE_NOT_COMMITTED = -233 - - integer, parameter :: WRF_HDF5_ERR_ALLOCATION = -2001 - integer, parameter :: WRF_HDF5_ERR_DEALLOCATION = -2002 - integer, parameter :: WRF_HDF5_ERR_BAD_FILE_STATUS = -2003 - integer, parameter :: WRF_HDF5_ERR_BAD_VARIABLE_DIM = -2004 - integer, parameter :: WRF_HDF5_ERR_MDVAR_DIM_NOT_1D = -2005 - integer, parameter :: WRF_HDF5_ERR_TOO_MANY_TIMES = -2006 - integer, parameter :: WRF_HDF5_ERR_DATA_ID_NOTFOUND = -2007 - - integer, parameter :: WRF_HDF5_ERR_DATASPACE = -300 - integer, parameter :: WRF_HDF5_ERR_DATATYPE = -301 - integer, parameter :: WRF_HDF5_ERR_PROPERTY_LIST = -302 - - integer, parameter :: WRF_HDF5_ERR_DATASET_CREATE = -303 - integer, parameter :: WRF_HDF5_ERR_DATASET_READ = -304 - integer, parameter :: WRF_HDF5_ERR_DATASET_WRITE = -305 - integer, parameter :: WRF_HDF5_ERR_DATASET_OPEN = -306 - integer, parameter :: WRF_HDF5_ERR_DATASET_GENERAL = -307 - integer, parameter :: WRF_HDF5_ERR_GROUP = -308 - - integer, parameter :: WRF_HDF5_ERR_FILE_OPEN = -309 - integer, parameter :: WRF_HDF5_ERR_FILE_CREATE = -310 - integer, parameter :: WRF_HDF5_ERR_DATASET_CLOSE = -311 - integer, parameter :: WRF_HDF5_ERR_FILE_CLOSE = -312 - integer, parameter :: WRF_HDF5_ERR_CLOSE_GENERAL = -313 - - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_CREATE = -314 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_READ = -315 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_WRITE = -316 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_OPEN = -317 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_GENERAL = -318 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_CLOSE = -319 - - integer, parameter :: WRF_HDF5_ERR_OTHERS = -320 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_OTHERS = -321 - diff --git a/external/io_grib_share/wrf_io_flags.h b/external/io_grib_share/wrf_io_flags.h deleted file mode 100644 index 708939f914..0000000000 --- a/external/io_grib_share/wrf_io_flags.h +++ /dev/null @@ -1,16 +0,0 @@ - integer, parameter :: WRF_FILE_NOT_OPENED = 100 - integer, parameter :: WRF_FILE_OPENED_NOT_COMMITTED = 101 - integer, parameter :: WRF_FILE_OPENED_FOR_WRITE = 102 - integer, parameter :: WRF_FILE_OPENED_FOR_READ = 103 - integer, parameter :: WRF_REAL = 104 - integer, parameter :: WRF_DOUBLE = 105 -#ifdef PROMOTE_FLOAT - integer, parameter :: WRF_FLOAT=WRF_DOUBLE -#else - integer, parameter :: WRF_FLOAT=WRF_REAL -#endif - integer, parameter :: WRF_INTEGER = 106 - integer, parameter :: WRF_LOGICAL = 107 - integer, parameter :: WRF_COMPLEX = 108 - integer, parameter :: WRF_DOUBLE_COMPLEX = 109 - integer, parameter :: WRF_FILE_OPENED_FOR_UPDATE = 110 diff --git a/external/io_grib_share/wrf_status_codes.h b/external/io_grib_share/wrf_status_codes.h deleted file mode 100644 index 008ac5ce76..0000000000 --- a/external/io_grib_share/wrf_status_codes.h +++ /dev/null @@ -1,142 +0,0 @@ - -!WRF Error and Warning messages (1-999) -!All i/o package-specific status codes you may want to add must be handled by your package (see below) -! WRF handles these and netCDF messages only - integer, parameter :: WRF_NO_ERR = 0 !no error - integer, parameter :: WRF_WARN_FILE_NF = -1 !file not found, or incomplete - integer, parameter :: WRF_WARN_MD_NF = -2 !metadata not found - integer, parameter :: WRF_WARN_TIME_NF = -3 !timestamp not found - integer, parameter :: WRF_WARN_TIME_EOF = -4 !no more timestamps - integer, parameter :: WRF_WARN_VAR_NF = -5 !variable not found - integer, parameter :: WRF_WARN_VAR_EOF = -6 !no more variables for the current time - integer, parameter :: WRF_WARN_TOO_MANY_FILES = -7 !too many open files - integer, parameter :: WRF_WARN_TYPE_MISMATCH = -8 !data type mismatch - integer, parameter :: WRF_WARN_WRITE_RONLY_FILE = -9 !attempt to write readonly file - integer, parameter :: WRF_WARN_READ_WONLY_FILE = -10 !attempt to read writeonly file - integer, parameter :: WRF_WARN_FILE_NOT_OPENED = -11 !attempt to access unopened file - integer, parameter :: WRF_WARN_2DRYRUNS_1VARIABLE = -12 !attempt to do 2 trainings for 1 variable - integer, parameter :: WRF_WARN_READ_PAST_EOF = -13 !attempt to read past EOF - integer, parameter :: WRF_WARN_BAD_DATA_HANDLE = -14 !bad data handle - integer, parameter :: WRF_WARN_WRTLEN_NE_DRRUNLEN = -15 !write length not equal to training length - integer, parameter :: WRF_WARN_TOO_MANY_DIMS = -16 !more dimensions requested than training - integer, parameter :: WRF_WARN_COUNT_TOO_LONG = -17 !attempt to read more data than exists - integer, parameter :: WRF_WARN_DIMENSION_ERROR = -18 !input dimension inconsistent - integer, parameter :: WRF_WARN_BAD_MEMORYORDER = -19 !input MemoryOrder not recognized - integer, parameter :: WRF_WARN_DIMNAME_REDEFINED = -20 !a dimension name with 2 different lengths - integer, parameter :: WRF_WARN_CHARSTR_GT_LENDATA = -21 !string longer than provided storage - integer, parameter :: WRF_WARN_NOTSUPPORTED = -22 !function not supportable - integer, parameter :: WRF_WARN_NOOP = -23 !package implements this routine as NOOP - -!Fatal errors - integer, parameter :: WRF_ERR_FATAL_ALLOCATION_ERROR = -100 !allocation error - integer, parameter :: WRF_ERR_FATAL_DEALLOCATION_ERR = -101 !dealloc error - integer, parameter :: WRF_ERR_FATAL_BAD_FILE_STATUS = -102 !bad file status - - -!Package specific errors (1000+) -!Netcdf status codes -!WRF will accept status codes of 1000+, but it is up to the package to handle -! and return the status to the user. - - integer, parameter :: WRF_ERR_FATAL_BAD_VARIABLE_DIM = -1004 - integer, parameter :: WRF_ERR_FATAL_MDVAR_DIM_NOT_1D = -1005 - integer, parameter :: WRF_ERR_FATAL_TOO_MANY_TIMES = -1006 - integer, parameter :: WRF_WARN_BAD_DATA_TYPE = -1007 !this code not in either spec? - integer, parameter :: WRF_WARN_FILE_NOT_COMMITTED = -1008 !this code not in either spec? - integer, parameter :: WRF_WARN_FILE_OPEN_FOR_READ = -1009 - integer, parameter :: WRF_IO_NOT_INITIALIZED = -1010 - integer, parameter :: WRF_WARN_MD_AFTER_OPEN = -1011 - integer, parameter :: WRF_WARN_TOO_MANY_VARIABLES = -1012 - integer, parameter :: WRF_WARN_DRYRUN_CLOSE = -1013 - integer, parameter :: WRF_WARN_DATESTR_BAD_LENGTH = -1014 - integer, parameter :: WRF_WARN_ZERO_LENGTH_READ = -1015 - integer, parameter :: WRF_WARN_DATA_TYPE_NOT_FOUND = -1016 - integer, parameter :: WRF_WARN_DATESTR_ERROR = -1017 - integer, parameter :: WRF_WARN_DRYRUN_READ = -1018 - integer, parameter :: WRF_WARN_ZERO_LENGTH_GET = -1019 - integer, parameter :: WRF_WARN_ZERO_LENGTH_PUT = -1020 - integer, parameter :: WRF_WARN_NETCDF = -1021 - integer, parameter :: WRF_WARN_LENGTH_LESS_THAN_1 = -1022 - integer, parameter :: WRF_WARN_MORE_DATA_IN_FILE = -1023 - integer, parameter :: WRF_WARN_DATE_LT_LAST_DATE = -1024 - -! For HDF5 only - integer, parameter :: WRF_HDF5_ERR_FILE = -200 - integer, parameter :: WRF_HDF5_ERR_MD = -201 - integer, parameter :: WRF_HDF5_ERR_TIME = -202 - integer, parameter :: WRF_HDF5_ERR_TIME_EOF = -203 - integer, parameter :: WRF_HDF5_ERR_MORE_DATA_IN_FILE = -204 - integer, parameter :: WRF_HDF5_ERR_DATE_LT_LAST_DATE = -205 - integer, parameter :: WRF_HDF5_ERR_TOO_MANY_FILES = -206 - integer, parameter :: WRF_HDF5_ERR_TYPE_MISMATCH = -207 - integer, parameter :: WRF_HDF5_ERR_LENGTH_LESS_THAN_1 = -208 - integer, parameter :: WRF_HDF5_ERR_WRITE_RONLY_FILE = -209 - integer, parameter :: WRF_HDF5_ERR_READ_WONLY_FILE = -210 - integer, parameter :: WRF_HDF5_ERR_FILE_NOT_OPENED = -211 - integer, parameter :: WRF_HDF5_ERR_DATESTR_ERROR = -212 - integer, parameter :: WRF_HDF5_ERR_DRYRUN_READ = -213 - integer, parameter :: WRF_HDF5_ERR_ZERO_LENGTH_GET = -214 - integer, parameter :: WRF_HDF5_ERR_ZERO_LENGTH_PUT = -215 - integer, parameter :: WRF_HDF5_ERR_2DRYRUNS_1VARIABLE = -216 - integer, parameter :: WRF_HDF5_ERR_DATA_TYPE_NOTFOUND = -217 - integer, parameter :: WRF_HDF5_ERR_READ_PAST_EOF = -218 - integer, parameter :: WRF_HDF5_ERR_BAD_DATA_HANDLE = -219 - integer, parameter :: WRF_HDF5_ERR_WRTLEN_NE_DRRUNLEN = -220 - integer, parameter :: WRF_HDF5_ERR_DRYRUN_CLOSE = -221 - integer, parameter :: WRF_HDF5_ERR_DATESTR_BAD_LENGTH = -222 - integer, parameter :: WRF_HDF5_ERR_ZERO_LENGTH_READ = -223 - integer, parameter :: WRF_HDF5_ERR_TOO_MANY_DIMS = -224 - integer, parameter :: WRF_HDF5_ERR_TOO_MANY_VARIABLES = -225 - integer, parameter :: WRF_HDF5_ERR_COUNT_TOO_LONG = -226 - integer, parameter :: WRF_HDF5_ERR_DIMENSION_ERROR = -227 - integer, parameter :: WRF_HDF5_ERR_BAD_MEMORYORDER = -228 - integer, parameter :: WRF_HDF5_ERR_DIMNAME_REDEFINED = -229 - integer, parameter :: WRF_HDF5_ERR_MD_AFTER_OPEN = -230 - integer, parameter :: WRF_HDF5_ERR_CHARSTR_GT_LENDATA = -231 - integer, parameter :: WRF_HDF5_ERR_BAD_DATA_TYPE = -232 - integer, parameter :: WRF_HDF5_ERR_FILE_NOT_COMMITTED = -233 - - integer, parameter :: WRF_HDF5_ERR_ALLOCATION = -2001 - integer, parameter :: WRF_HDF5_ERR_DEALLOCATION = -2002 - integer, parameter :: WRF_HDF5_ERR_BAD_FILE_STATUS = -2003 - integer, parameter :: WRF_HDF5_ERR_BAD_VARIABLE_DIM = -2004 - integer, parameter :: WRF_HDF5_ERR_MDVAR_DIM_NOT_1D = -2005 - integer, parameter :: WRF_HDF5_ERR_TOO_MANY_TIMES = -2006 - integer, parameter :: WRF_HDF5_ERR_DATA_ID_NOTFOUND = -2007 - - integer, parameter :: WRF_HDF5_ERR_DATASPACE = -300 - integer, parameter :: WRF_HDF5_ERR_DATATYPE = -301 - integer, parameter :: WRF_HDF5_ERR_PROPERTY_LIST = -302 - - integer, parameter :: WRF_HDF5_ERR_DATASET_CREATE = -303 - integer, parameter :: WRF_HDF5_ERR_DATASET_READ = -304 - integer, parameter :: WRF_HDF5_ERR_DATASET_WRITE = -305 - integer, parameter :: WRF_HDF5_ERR_DATASET_OPEN = -306 - integer, parameter :: WRF_HDF5_ERR_DATASET_GENERAL = -307 - integer, parameter :: WRF_HDF5_ERR_GROUP = -308 - - integer, parameter :: WRF_HDF5_ERR_FILE_OPEN = -309 - integer, parameter :: WRF_HDF5_ERR_FILE_CREATE = -310 - integer, parameter :: WRF_HDF5_ERR_DATASET_CLOSE = -311 - integer, parameter :: WRF_HDF5_ERR_FILE_CLOSE = -312 - integer, parameter :: WRF_HDF5_ERR_CLOSE_GENERAL = -313 - - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_CREATE = -314 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_READ = -315 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_WRITE = -316 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_OPEN = -317 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_GENERAL = -318 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_CLOSE = -319 - - integer, parameter :: WRF_HDF5_ERR_OTHERS = -320 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_OTHERS = -321 - - integer, parameter :: WRF_GRIB2_ERR_GRIBCREATE = -401 - integer, parameter :: WRF_GRIB2_ERR_ADDLOCAL = -402 - integer, parameter :: WRF_GRIB2_ERR_ADDGRIB = -403 - integer, parameter :: WRF_GRIB2_ERR_ADDFIELD = -404 - integer, parameter :: WRF_GRIB2_ERR_GRIBEND = -405 - integer, parameter :: WRF_GRIB2_ERR_WRITE = -406 - integer, parameter :: WRF_GRIB2_ERR_GRIB2MAP = -407 - integer, parameter :: WRF_GRIB2_ERR_GETGB2 = -408 - integer, parameter :: WRF_GRIB2_ERR_READ = -409 From 23b5f9be200554b857bfbb8997ff890541cdad79 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 17 May 2023 16:52:07 -0600 Subject: [PATCH 031/180] Updating [p]netCDF find capabilities --- cmake/modules/FindnetCDF.cmake | 61 +++++++++++++++---------- cmake/modules/FindpnetCDF.cmake | 80 +++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 24 deletions(-) create mode 100644 cmake/modules/FindpnetCDF.cmake diff --git a/cmake/modules/FindnetCDF.cmake b/cmake/modules/FindnetCDF.cmake index 02fae6f443..c9892e98bc 100644 --- a/cmake/modules/FindnetCDF.cmake +++ b/cmake/modules/FindnetCDF.cmake @@ -11,45 +11,58 @@ # list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} ) # Use nc-config -execute_process( COMMAND nc-config --includedir OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_INCLUDE_DIR ) -execute_process( COMMAND nc-config --libs OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_CLIBS ) -execute_process( COMMAND nc-config --cxx4libs OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_CXXLIBS ) -execute_process( COMMAND nc-config --flibs OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_FLIBS ) -execute_process( COMMAND nc-config --version OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_VERSION_RAW ) -execute_process( COMMAND nc-config --has-nc4 OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_NC4_YES ) -execute_process( COMMAND nc-config --has-pnetcdf OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_PNETCDF_YES ) +find_program( + NETCDF_PROGRAM + nc-config + QUIET + ) -# Sanitize version -string( REPLACE " " ";" netCDF_VERSION_LIST ${netCDF_VERSION_RAW} ) -list( GET netCDF_VERSION_LIST -1 netCDF_VERSION ) +message( STATUS "NETCDF_PROGRAM : ${NETCDF_PROGRAM}" ) +if ( ${NETCDF_PROGRAM} MATCHES "-NOTFOUND$" ) + message( STATUS "No nc-config found" ) +else() -# Convert yes/no to 0/1 bool -set( netCDF_NC4 $ ) -set( netCDF_PNETCDF $ ) + execute_process( COMMAND ${NETCDF_PROGRAM} --includedir OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_INCLUDE_DIR ) + execute_process( COMMAND ${NETCDF_PROGRAM} --libs OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_CLIBS ) + execute_process( COMMAND ${NETCDF_PROGRAM} --cxx4libs OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_CXXLIBS ) + execute_process( COMMAND ${NETCDF_PROGRAM} --flibs OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_FLIBS ) + execute_process( COMMAND ${NETCDF_PROGRAM} --version OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_VERSION_RAW ) + execute_process( COMMAND ${NETCDF_PROGRAM} --has-nc4 OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_NC4_YES ) + execute_process( COMMAND ${NETCDF_PROGRAM} --has-pnetcdf OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_PNETCDF_YES ) + execute_process( COMMAND ${NETCDF_PROGRAM} --has-parallel OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_PARALLEL_YES ) -find_package( PkgConfig ) -set( netCDF_DEFINITIONS ) + # Sanitize version + string( REPLACE " " ";" netCDF_VERSION_LIST ${netCDF_VERSION_RAW} ) + list( GET netCDF_VERSION_LIST -1 netCDF_VERSION ) + + # Convert to YES/NO - Note cannot be generator expression if you want to use it during configuration time + string( TOUPPER ${netCDF_NC4_YES} netCDF_NC4 ) + string( TOUPPER ${netCDF_PNETCDF_YES} netCDF_PNETCDF ) + string( TOUPPER ${netCDF_PARALLEL_YES} netCDF_PARALLEL ) + set( netCDF_DEFINITIONS ) + set( netCDF_LIBRARIES + $<$:${netCDF_CLIBS}> + $<$:${netCDF_CXXLIBS}> + $<$:${netCDF_FLIBS}> + ) + set( netCDF_INCLUDE_DIRS ${netCDF_INCLUDE_DIR} ) +endif() + +find_package( PkgConfig ) include(FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set netCDF_FOUND to TRUE # if all listed variables are TRUE find_package_handle_standard_args( netCDF DEFAULT_MSG - netCDF_INCLUDE_DIR + netCDF_INCLUDE_DIRS netCDF_CLIBS netCDF_CXXLIBS netCDF_FLIBS netCDF_VERSION ) -mark_as_advanced( netCDF_INCLUDE_DIR netCDF_CLIBS netCDF_CXXLIBS netCDF_FLIBS ) - -set( netCDF_LIBRARIES - $<$:${netCDF_CLIBS}> - $<$:${netCDF_CXXLIBS}> - $<$:${netCDF_FLIBS}> - ) -set( netCDF_INCLUDE_DIRS ${netCDF_INCLUDE_DIR} ) +mark_as_advanced( netCDF_CLIBS netCDF_CXXLIBS netCDF_FLIBS ) \ No newline at end of file diff --git a/cmake/modules/FindpnetCDF.cmake b/cmake/modules/FindpnetCDF.cmake new file mode 100644 index 0000000000..64604f1c45 --- /dev/null +++ b/cmake/modules/FindpnetCDF.cmake @@ -0,0 +1,80 @@ +# Find pnetcdf +# Eventually replace with pnetCDF's actual config if using that +# Once found this file will define: +# pnetCDF_FOUND - System has pnetcdf +# pnetCDF_INCLUDE_DIRS - The pnetcdf include directories +# pnetCDF_LIBRARIES - The libraries needed to use pnetcdf +# pnetCDF_DEFINITIONS - Compiler switches required for using pnetcdf + +# list( REMOVE_ITEM CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} ) +# find_package( pnetCDF ) +# list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} ) + +# Use pnetcdf-config +find_program( + PNETCDF_PROGRAM + pnetcdf-config + QUIET + ) + +if ( ${PNETCDF_PROGRAM} MATCHES "-NOTFOUND$" ) + message( STATUS "No pnetcdf-config found : ${PNETCDF_PROGRAM}" ) +else() + + execute_process( COMMAND ${PNETCDF_PROGRAM} --includedir OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE pnetCDF_INCLUDE_DIR ) + execute_process( COMMAND ${PNETCDF_PROGRAM} --libdir OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE pnetCDF_LIBRARY_DIR ) + execute_process( COMMAND ${PNETCDF_PROGRAM} --version OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE pnetCDF_VERSION_RAW ) + execute_process( COMMAND ${PNETCDF_PROGRAM} --netcdf4 OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE pnetCDF_NC4_ENABLED ) + + execute_process( COMMAND ${PNETCDF_PROGRAM} --has-c++ OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE pnetCDF_CXX_YES ) + execute_process( COMMAND ${PNETCDF_PROGRAM} --has-fortran OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE pnetCDF_FORTRAN_YES ) + + + + # Sanitize version + string( REPLACE " " ";" pnetCDF_VERSION_LIST ${pnetCDF_VERSION_RAW} ) + list( GET pnetCDF_VERSION_LIST -1 pnetCDF_VERSION ) + + # Note that pnetCDF has decided to change things up and use "disabled" instead of "yes/no" + string( TOLOWER ${pnetCDF_NC4_ENABLED} pnetCDF_NC4_ENABLED ) + if ( ${pnetCDF_NC4_ENABLED} STREQUAL "enabled" ) + set( pnetCDF_NC4 "YES" ) + else() + set( pnetCDF_NC4 "NO" ) + endif() + + string( TOUPPER ${pnetCDF_CXX_YES} pnetCDF_CXX ) + string( TOUPPER ${pnetCDF_FORTRAN_YES} pnetCDF_FORTRAN ) + + + set( pnetCDF_DEFINITIONS ) + + # Find libraries + find_library( + pnetCDF_LIBRARY + NAMES pnetcdf + # Hints before PATHS + HINTS ${pnetCDF_LIBRARY_DIR} + NO_DEFAULT_PATH + ) + + + set( pnetCDF_LIBRARIES + $<$:${pnetCDF_LIBRARY}> + $<$:$:${pnetCDF_LIBRARY}> + $<$:$:${pnetCDF_LIBRARY}> + ) + set( pnetCDF_INCLUDE_DIRS ${pnetCDF_INCLUDE_DIR} ) +endif() +find_package( PkgConfig ) +include(FindPackageHandleStandardArgs) + +# handle the QUIETLY and REQUIRED arguments and set pnetCDF_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args( pnetCDF DEFAULT_MSG + pnetCDF_INCLUDE_DIRS + pnetCDF_LIBRARIES + pnetCDF_VERSION + ) + +# mark_as_advanced( pnetCDF_CLIBS pnetCDF_CXXLIBS pnetCDF_FLIBS ) \ No newline at end of file From b452ed5c614121b3be6ce6f03879c9f213dc455a Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 17 May 2023 16:52:38 -0600 Subject: [PATCH 032/180] Adding main to compilation --- main/CMakeLists.txt | 99 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 main/CMakeLists.txt diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt new file mode 100644 index 0000000000..0e11c35ad3 --- /dev/null +++ b/main/CMakeLists.txt @@ -0,0 +1,99 @@ +# WRF CMake Build +set( FOLDER_COMPILE_TARGETS ) + +# First make true executables +if ( ${WRF_CORE} STREQUAL "ARW" ) + add_executable( + wrf + wrf.F + module_wrf_top.F + ) + list( APPEND FOLDER_COMPILE_TARGETS wrf ) + +elseif ( ${WRF_CORE} STREQUAL "WRFPLUS" ) + add_executable( + wrfplus + wrf.F + module_wrf_top.F + ) + list( APPEND FOLDER_COMPILE_TARGETS wrfplus ) + +# #!TODO When does this get activated? +# elseif() +# add_executable( +# wrf_SST_ESMF +# wrf_ESMFMod.F +# wrf_SST_ESMF.F +# module_wrf_top.F +# ) +# list( APPEND FOLDER_COMPILE_TARGETS em_wrf_SST_ESMF ) +endif() + +# Use case info from higher CMakeLists.txt +set( MODULE_FILE ${PROJECT_SOURCE_DIR}/dyn_em/module_initialize_${WRF_CASE_MODULE}.F ) + +if ( ${WRF_CASE} STREQUAL "EM_REAL" ) + add_executable( + ndown + ndown_em.F + ${MODULE_FILE} + ) + add_executable( + tc + tc_em.F + ${MODULE_FILE} + ) + add_executable( + real + real_em.F + ${MODULE_FILE} + ) + list( APPEND FOLDER_COMPILE_TARGETS ndown tc real ) + +elseif( NOT ${WRF_GENERAL_IDEAL_CASE} ) # Not general ideal and not real + # All others are variants of ideal + add_executable( + ideal + ideal_em.F + ${MODULE_FILE} + ) + list( APPEND FOLDER_COMPILE_TARGETS ideal ) +else() + # greater than or equal to general ideal case + add_executable( + ideal + ideal_em.F + ${PROJECT_SOURCE_DIR}/dyn_em/module_initialize_ideal.F + ) + list( APPEND FOLDER_COMPILE_TARGETS ideal ) +endif() + + +foreach ( TARGET ${FOLDER_COMPILE_TARGETS} ) + set_target_properties( + ${TARGET} + PROPERTIES + # Just dump everything in here + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/modules/ + Fortran_FORMAT FREE + ) + target_link_libraries( + ${TARGET} + PRIVATE + ${PROJECT_NAME}_Core + ) + target_include_directories( + ${TARGET} + PRIVATE + ${PROJECT_SOURCE_DIR}/inc + ${PROJECT_BINARY_DIR}/inc + ) +endforeach() + + +install( + TARGETS ${FOLDER_COMPILE_TARGETS} + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) From 34c5e44a59b51c2a47303f81566b2ad986763986 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 17 May 2023 16:53:50 -0600 Subject: [PATCH 033/180] New cmake modules to help ease building --- cmake/gitinfo.cmake | 41 ++++++++++++++ cmake/template/commit_decl.cmake | 1 + cmake/wrf_case_setup.cmake | 94 ++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 cmake/gitinfo.cmake create mode 100644 cmake/template/commit_decl.cmake create mode 100644 cmake/wrf_case_setup.cmake diff --git a/cmake/gitinfo.cmake b/cmake/gitinfo.cmake new file mode 100644 index 0000000000..0262961c18 --- /dev/null +++ b/cmake/gitinfo.cmake @@ -0,0 +1,41 @@ +# WRF Macro to identify the commit where the compiled code came from +macro( wrf_git_commit ) + + set( options ) + set( oneValueArgs WORKING_DIRECTORY RESULT_VAR ) + set( multiValueArgs ) + + cmake_parse_arguments( + WRF_GIT_COMMIT + "${options}" "${oneValueArgs}" "${multiValueArgs}" + ${ARGN} + ) + + + message( STATUS "Retrieving git information..." ) + execute_process( + OUTPUT_VARIABLE WRF_GIT_COMMIT_SHA + COMMAND git describe --dirty --long --always --abbrev=40 + WORKING_DIRECTORY ${WRF_GIT_COMMIT_WORKING_DIRECTORY} + RESULT_VARIABLE WRF_GIT_COMMIT_NO_GIT_REPO + # ECHO_OUTPUT_VARIABLE + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + execute_process( + OUTPUT_VARIABLE WRF_GIT_COMMIT_DIFF + COMMAND git diff --shortstat + WORKING_DIRECTORY ${WRF_GIT_COMMIT_WORKING_DIRECTORY} + # ECHO_OUTPUT_VARIABLE + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + if ( ${WRF_GIT_COMMIT_NO_GIT_REPO} GREATER 0 ) + set( ${WRF_GIT_COMMIT_RESULT_VAR} "No git found or not a git repository, git commit version not available.") + message( STATUS "git info : Unable to get info" ) + else() + set( ${WRF_GIT_COMMIT_RESULT_VAR} "git info : ${WRF_GIT_COMMIT_SHA} ${WRF_GIT_COMMIT_DIFF}" ) + message( STATUS "git SHA : ${WRF_GIT_COMMIT_SHA}" ) + message( STATUS "git diff : ${WRF_GIT_COMMIT_DIFF}" ) + endif() + +endmacro() \ No newline at end of file diff --git a/cmake/template/commit_decl.cmake b/cmake/template/commit_decl.cmake new file mode 100644 index 0000000000..bcc368835b --- /dev/null +++ b/cmake/template/commit_decl.cmake @@ -0,0 +1 @@ + CHARACTER (LEN=*), PARAMETER :: commit_version = '@GIT_VERSION@' \ No newline at end of file diff --git a/cmake/wrf_case_setup.cmake b/cmake/wrf_case_setup.cmake new file mode 100644 index 0000000000..2e1fc5914c --- /dev/null +++ b/cmake/wrf_case_setup.cmake @@ -0,0 +1,94 @@ +# WRF Macro for adding target symlinks to be run after internal install() code +macro( wrf_link_targets ) + + set( options ) + set( oneValueArgs SYM_PATH OLD_BASE_PATH ) + set( multiValueArgs TARGETS ) + + cmake_parse_arguments( + WRF_LINK + "${options}" "${oneValueArgs}" "${multiValueArgs}" + ${ARGN} + ) + + + foreach ( WRF_LINK_TARGET ${WRF_LINK_TARGETS} ) + + # Generate install code for each target + # https://stackoverflow.com/a/56528615 + #!TODO Do we *need* the rm for symlinks beforehand? + # get_filename_component( WRF_LINK_FILE_ONLY $ NAME + + install( + CODE " + message( STATUS \"Creating symlinks for $\" ) + execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink ${WRF_LINK_OLD_BASE_PATH}/$ ${WRF_LINK_SYM_PATH}/$ ) + " + ) + + endforeach() + +endmacro() + +# WRF Macro for adding file symlinks to be run after internal install() code +macro( wrf_link_files ) + + set( options ) + set( oneValueArgs SYM_PATH ) + set( multiValueArgs FILES ) + + cmake_parse_arguments( + WRF_LINK + "${options}" "${oneValueArgs}" "${multiValueArgs}" + ${ARGN} + ) + + foreach ( WRF_LINK_FILE ${WRF_LINK_FILES} ) + + # Generate install code for each file, this could be done in a simpler manner + # with regular commands but to preserve order of operations it will be done via install( CODE ... ) + # https://stackoverflow.com/a/56528615 + get_filename_component( WRF_LINK_FULL_FILE ${WRF_LINK_FILE} REALPATH ) + get_filename_component( WRF_LINK_FILE_ONLY ${WRF_LINK_FILE} NAME ) + install( + CODE " + message( STATUS \"Creating symlinks for ${WRF_LINK_FILE_ONLY}\" ) + execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink ${WRF_LINK_FULL_FILE} ${WRF_LINK_SYM_PATH}/${WRF_LINK_FILE_ONLY} ) + " + ) + + endforeach() + +endmacro() + +# WRF Macro for adding file symlink to be run after internal install() code +macro( wrf_link_file_new_name ) + + set( options ) + set( oneValueArgs SYM_PATH FILE NEW_NAME ) + set( multiValueArgs ) + + cmake_parse_arguments( + WRF_LINK + "${options}" "${oneValueArgs}" "${multiValueArgs}" + ${ARGN} + ) + + foreach ( WRF_LINK_FILE ${WRF_LINK_FILES} ) + + # Generate install code for each file, this could be done in a simpler manner + # with regular commands but to preserve order of operations it will be done via install( CODE ... ) + # https://stackoverflow.com/a/56528615 + get_filename_component( WRF_LINK_FULL_FILE ${WRF_LINK_FILE} REALPATH ) + get_filename_component( WRF_LINK_FILE_ONLY ${WRF_LINK_FILE} NAME ) + install( + CODE " + message( STATUS \"Creating symlinks for ${WRF_LINK_FILE_ONLY}\" ) + execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink ${WRF_LINK_FULL_FILE} ${WRF_LINK_SYM_PATH}/${WRF_LINK_FILE_ONLY} ) + " + ) + + endforeach() + +endmacro() + From c4e92b99adfc9d9ad8a53c36b7013fbe37a5b4c3 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 17 May 2023 16:54:12 -0600 Subject: [PATCH 034/180] Script to facilitate cleaning cmake build --- cleanCMake.sh | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 cleanCMake.sh diff --git a/cleanCMake.sh b/cleanCMake.sh new file mode 100755 index 0000000000..3dfcf29ca8 --- /dev/null +++ b/cleanCMake.sh @@ -0,0 +1,69 @@ +#!/bin/bash +BUILD_DIR=_build +INSTALL_DIR=runTemp +TEST_DIR=test/ + +function help() +{ + echo "./cleanCMake.sh [options]" + echo " -c Basic cmake clean functionality [cmake --build ${BUILD_DIR} -j 1 --target clean]" + echo " -i Remove cmake binary installs [xargs rm < ${BUILD_DIR}/install_manifest.txt]" + echo " -l Remove symlinks (WRF) [ find ${TEST_DIR} -type l -exec rm {} \; ]" + echo " -f Remove build & install folders (WRF) [ rm ${BUILD_DIR} -r; rm ${INSTALL_DIR}/ -r ]" + echo " -a Remove all (WRF), equivalent to -f -l (more specifically -b -i -l -f)" +} + +CLEAN_BASIC_BUILD=FALSE +CLEAN_BASIC_INSTALL=FALSE +CLEAN_LINKS=FALSE +CLEAN_FOLDERS=FALSE +CLEAN_ALL=FALSE + +while getopts "hcilfa" opt; do + case ${opt} in + c) + CLEAN_BASIC_BUILD=TRUE + ;; + i) + CLEAN_BASIC_INSTALL=TRUE + ;; + l) + CLEAN_LINKS=TRUE + ;; + f) + CLEAN_FOLDERS=TRUE + ;; + a) + CLEAN_ALL=TRUE + ;; + h) help; exit 0 ;; + *) help; exit 1 ;; + :) help; exit 1 ;; + \?) help; exit 1 ;; + esac +done + +if [[ $OPTIND -eq 1 ]]; then + # Do basic clean I guess + CLEAN_BASIC_BUILD=TRUE +fi + +if [[ "${CLEAN_BASIC_BUILD}" == "TRUE" || "${CLEAN_ALL}" == "TRUE" ]]; then + echo "Doing cmake make clean" + cmake --build ${BUILD_DIR} -j 1 --target clean +fi + +if [[ "${CLEAN_BASIC_INSTALL}" == "TRUE" || "${CLEAN_ALL}" == "TRUE" ]]; then + echo "Removing binary installs" + xargs rm < ${BUILD_DIR}/install_manifest.txt +fi + +if [[ "${CLEAN_LINKS}" == "TRUE" || "${CLEAN_ALL}" == "TRUE" ]]; then + echo "Removing all symlinks in ${TEST_DIR}" + find ${TEST_DIR} -type l -exec rm {} \; +fi + +if [[ "${CLEAN_FOLDERS}" == "TRUE" || "${CLEAN_ALL}" == "TRUE" ]]; then + echo "Deleting ${BUILD_DIR} & ${INSTALL_DIR}/" + rm ${BUILD_DIR} -r; rm ${INSTALL_DIR}/ -r +fi \ No newline at end of file From a81ae42a9ad00c52ee79d8b7f16f80e81efc7e33 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 17 May 2023 16:54:55 -0600 Subject: [PATCH 035/180] Removing dead comments --- frame/CMakeLists.txt | 162 +------------------------------------------ share/CMakeLists.txt | 131 +--------------------------------- 2 files changed, 2 insertions(+), 291 deletions(-) diff --git a/frame/CMakeLists.txt b/frame/CMakeLists.txt index affccb12a5..546058d86a 100644 --- a/frame/CMakeLists.txt +++ b/frame/CMakeLists.txt @@ -1,132 +1,5 @@ # WRF CMake Build -# get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) -# add_library( -# ${FOLDER_COMPILE_TARGET} -# STATIC -# ) - -# ######################################################################################################################## -# # -# # Extra object archive to set up dependencies -# # -# ######################################################################################################################## -# add_library( -# ${FOLDER_COMPILE_TARGET}_deps -# OBJECT -# module_configure.F -# module_driver_constants.F -# module_domain_type.F -# module_domain.F -# module_streams.F -# module_wrf_error.F -# module_machine.F -# module_timing.F -# module_dm.F -# module_cpl.F -# module_cpl_oasis3.F - - -# module_alloc_space_0.F -# module_alloc_space_1.F -# module_alloc_space_2.F -# module_alloc_space_3.F -# module_alloc_space_4.F -# module_alloc_space_5.F -# module_alloc_space_6.F -# module_alloc_space_7.F -# module_alloc_space_8.F -# module_alloc_space_9.F - -# ${CMAKE_BINARY_DIR}/frame/module_state_description.F # GENERATED -# ) - -# add_dependencies( ${FOLDER_COMPILE_TARGET}_deps share_model_constants registry_code ) - - -# # Tell CMake to chill, we'll generate those files shortly -# # Thanks to https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-add-a-dependency-to-a-source-file-which-is-generated-in-a-subdirectory -# # and https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/ -# set_source_files_properties( -# ${CMAKE_BINARY_DIR}/frame/module_state_description.F -# PROPERTIES -# GENERATED TRUE -# ) - -# set_target_properties( -# ${FOLDER_COMPILE_TARGET}_deps -# PROPERTIES -# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} -# Fortran_FORMAT FREE -# ) - -# target_include_directories( ${FOLDER_COMPILE_TARGET}_deps -# PRIVATE -# ${CMAKE_CURRENT_SOURCE_DIR} -# ${PROJECT_SOURCE_DIR}/inc -# # Compiled sources -# $ -# $ -# # Generated sources -# ${CMAKE_BINARY_DIR}/frame -# ${CMAKE_BINARY_DIR}/inc -# ) -# target_link_libraries( -# ${FOLDER_COMPILE_TARGET}_deps -# PRIVATE -# esmf_time_f90 -# ) - - - -# ######################################################################################################################## -# # Extra stuff for things that depend on registry code -# # https://stackoverflow.com/a/50640971 -# # Generate all the combinations dynamically, not a fan of this file breakdown -# ######################################################################################################################## -# foreach( n RANGE 0 7 ) - -# add_library( nl_set_${n} OBJECT nl_access_routines.F ) -# add_library( nl_get_${n} OBJECT nl_access_routines.F ) - - -# # Wait for registry code -# add_dependencies( nl_set_${n} registry_code ${FOLDER_COMPILE_TARGET}_deps ) -# add_dependencies( nl_get_${n} registry_code ${FOLDER_COMPILE_TARGET}_deps ) - -# target_compile_definitions( nl_set_${n} PRIVATE -DNNN=${n} -DNL_set_ROUTINES ) -# target_compile_definitions( nl_get_${n} PRIVATE -DNNN=${n} -DNL_get_ROUTINES ) - -# set_target_properties( -# nl_set_${n} -# nl_get_${n} -# PROPERTIES -# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} -# Fortran_FORMAT FREE -# ) - -# target_include_directories( nl_set_${n} -# PRIVATE -# ${CMAKE_CURRENT_SOURCE_DIR} -# # Generated sources -# ${CMAKE_BINARY_DIR}/inc -# ) -# target_include_directories( nl_get_${n} -# PRIVATE -# ${CMAKE_CURRENT_SOURCE_DIR} -# # Generated sources -# ${CMAKE_BINARY_DIR}/inc -# ) - -# target_link_libraries( -# ${FOLDER_COMPILE_TARGET} -# PRIVATE -# nl_set_${n} -# nl_get_${n} -# ) - -# endforeach() - ######################################################################################################################## # Extra stuff for things that depend on registry code # https://stackoverflow.com/a/50640971 @@ -202,7 +75,6 @@ target_include_directories( # ######################################################################################################################## target_sources( - # ${FOLDER_COMPILE_TARGET} ${PROJECT_NAME}_Core PRIVATE module_configure.F @@ -264,40 +136,8 @@ target_sources( wrf_shutdown.F ) -# set_target_properties( -# ${FOLDER_COMPILE_TARGET} -# PROPERTIES -# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} -# Fortran_FORMAT FREE -# ) - - -# target_link_libraries( ${FOLDER_COMPILE_TARGET} -# PRIVATE -# ${FOLDER_COMPILE_TARGET}_deps -# ${netCDF_LIBRARIES} -# $<$:$> -# $<$:$> -# ) - -target_include_directories( #${FOLDER_COMPILE_TARGET} +target_include_directories( ${PROJECT_NAME}_Core PRIVATE - # ${netCDF_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} - # $ - # $ - # # Generated sources - # ${CMAKE_BINARY_DIR}/frame - # ${CMAKE_BINARY_DIR}/inc ) - -# Depend on other generated files and libs, this should be one of the last things made apparently -# add_dependencies( ${FOLDER_COMPILE_TARGET} ${FOLDER_COMPILE_TARGET}_deps registry_code share ) - -# install( -# TARGETS ${FOLDER_COMPILE_TARGET} -# RUNTIME DESTINATION bin/ -# ARCHIVE DESTINATION lib/ -# LIBRARY DESTINATION lib/ -# ) diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index 159047aabf..229efae1e5 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -1,91 +1,10 @@ # WRF CMake Build -# # get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) - -# # add_library( -# # ${FOLDER_COMPILE_TARGET} -# # STATIC -# # ) -# ######################################################################################################################## -# # -# # Consider only making one library rather than forcing all these target dependencies - it would simplify a ton -# # but for now trying to recreate WRF building as a one-to-one replica -# # -# ######################################################################################################################## -# add_library( -# ${FOLDER_COMPILE_TARGET}_model_constants -# OBJECT -# module_model_constants.F -# # module_llxy.F -# # module_soil_pre.F -# # module_date_time.F -# # module_bc.F - -# ) - -# add_dependencies( ${FOLDER_COMPILE_TARGET}_model_constants frame_deps ) - - -# set_target_properties( -# ${FOLDER_COMPILE_TARGET}_model_constants -# PROPERTIES -# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} -# Fortran_FORMAT FREE -# ) - -# target_include_directories( ${FOLDER_COMPILE_TARGET}_model_constants -# PRIVATE -# ${CMAKE_CURRENT_SOURCE_DIR} -# # Compiled sources -# $ -# $ -# ) - -# ######################################################################################################################## -# # -# # Extra object archive to set up dependencies -# # -# ######################################################################################################################## -# add_library( -# ${FOLDER_COMPILE_TARGET}_deps -# OBJECT -# module_model_constants.F -# module_llxy.F -# module_soil_pre.F -# module_date_time.F -# module_bc.F - -# ) - -# add_dependencies( ${FOLDER_COMPILE_TARGET}_deps frame_deps ) - - -# set_target_properties( -# ${FOLDER_COMPILE_TARGET}_deps -# PROPERTIES -# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} -# Fortran_FORMAT FREE -# ) - -target_include_directories( #${FOLDER_COMPILE_TARGET}_deps +target_include_directories( ${PROJECT_NAME}_Core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - # ${PROJECT_SOURCE_DIR}/inc - # Compiled sources - # $ - # $ - # # Generated sources - # ${CMAKE_BINARY_DIR}/frame - # ${CMAKE_BINARY_DIR}/inc ) -# target_link_libraries( -# ${FOLDER_COMPILE_TARGET}_deps -# PRIVATE -# esmf_time_f90 -# ) - - ######################################################################################################################## # @@ -93,7 +12,6 @@ target_include_directories( #${FOLDER_COMPILE_TARGET}_deps # ######################################################################################################################## target_sources( - # ${FOLDER_COMPILE_TARGET} ${PROJECT_NAME}_Core PRIVATE @@ -157,50 +75,3 @@ target_sources( mediation_nest_move.F setfeenv.c ) - -# set_target_properties( -# ${FOLDER_COMPILE_TARGET} -# PROPERTIES -# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} -# Fortran_FORMAT FREE -# ) - - -# target_link_libraries( ${FOLDER_COMPILE_TARGET} -# PRIVATE -# ${FOLDER_COMPILE_TARGET}_deps -# ${FOLDER_COMPILE_TARGET}_model_constants -# ${netCDF_LIBRARIES} -# $<$:$> -# $<$:$> -# ) - -# target_include_directories( ${FOLDER_COMPILE_TARGET} -# PRIVATE -# # ${netCDF_INCLUDE_DIRS} -# ${CMAKE_CURRENT_SOURCE_DIR} -# $ -# $ - -# #!TODO Fix duplicates of wrf_[io|status]_flags.h -# # ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share -# # ${CMAKE_CURRENT_SOURCE_DIR}/../io_grib_share -# # ${CMAKE_CURRENT_SOURCE_DIR}/grib1_util -# # ${CMAKE_CURRENT_SOURCE_DIR}/MEL_grib1 -# ) - -# # Depend on framework, why? I don't know, this is a mess -# add_dependencies( -# ${FOLDER_COMPILE_TARGET} -# ${FOLDER_COMPILE_TARGET}_deps -# ${FOLDER_COMPILE_TARGET}_model_constants -# frame_deps -# phys -# ) - -# install( -# TARGETS ${FOLDER_COMPILE_TARGET} -# RUNTIME DESTINATION bin/ -# ARCHIVE DESTINATION lib/ -# LIBRARY DESTINATION lib/ -# ) From b2ce01522592321fc9536349d1df3d5d97f166ed Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 17 May 2023 16:55:53 -0600 Subject: [PATCH 036/180] Reworking external/ build --- external/CMakeLists.txt | 55 +++++++++++++++++---- external/io_grib1/CMakeLists.txt | 3 +- external/io_grib_share/CMakeLists.txt | 1 + external/io_netcdf/CMakeLists.txt | 65 +++++++++++++++++++++++++ external/io_netcdf/wrf_io.F90 | 4 +- external/io_netcdfpar/CMakeLists.txt | 62 +++++++++++++++++++++++ external/io_netcdfpar/wrf_io.F90 | 4 +- external/io_pio/CMakeLists.txt | 47 ++++++++++++++++++ external/io_pnetcdf/CMakeLists.txt | 62 +++++++++++++++++++++++ external/ioapi_share/wrf_status_codes.h | 9 ++++ 10 files changed, 296 insertions(+), 16 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 7402f15b7d..0d4bbc86f2 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -18,31 +18,66 @@ # endif() +# Always build + +add_subdirectory( io_int ) +add_subdirectory( io_grib1 ) +add_subdirectory( io_grib_share ) +add_subdirectory( ioapi_share ) +add_subdirectory( fftpack/fftpack5 ) + if ( AMT_OCN ) # I have no clue how this gets used + message( STATUS "Adding [atm_ocn] to configuration" ) add_subdirectory( atm_ocn ) endif() if ( ADIOS2 ) + message( STATUS "Adding [io_adios2] to configuration" ) add_subdirectory( io_adios2 ) endif() if ( ESMF ) + message( STATUS "Adding [io_esmf] to configuration" ) add_subdirectory( io_esmf ) endif() +#!TODO Is this always needed add_subdirectory( esmf_time_f90 ) -add_subdirectory( io_pnetcdf ) -add_subdirectory( io_pio ) -add_subdirectory( io_int ) + +# netCDF +#!TODO I believe this is always required from configure:651 add_subdirectory( io_netcdf ) -add_subdirectory( io_netcdfpar ) -add_subdirectory( io_phdf5 ) -add_subdirectory( io_grib1 ) -add_subdirectory( io_grib_share ) -add_subdirectory( io_grib2 ) +#!TODO We should collapse all these files into #ifdefs even if they are compiled +# multiple times with different defs for the same configuration +if ( ${netCDF_PARALLEL} ) + message( STATUS "Adding [io_netcdfpar] to configuration" ) + add_subdirectory( io_netcdfpar ) +endif() + +if ( ${pnetCDF_FOUND} ) + message( STATUS "Adding [io_pnetcdf] to configuration" ) + add_subdirectory( io_pnetcdf ) +endif() + +if ( ${PIO_FOUND} ) + message( STATUS "Adding [io_pio] to configuration" ) + add_subdirectory( io_pio ) +endif() + +# https://cmake.org/cmake/help/latest/module/FindHDF5.html +if ( ${HDF5_IS_PARALLEL} ) + message( STATUS "Adding [io_phdf5] to configuration" ) + add_subdirectory( io_phdf5 ) +endif() + + +if ( ${Jasper_FOUND} ) + message( STATUS "Adding [io_grib2] to configuration" ) + add_subdirectory( io_grib2 ) +endif() + -add_subdirectory( ioapi_share ) add_subdirectory( RSL_LITE ) -add_subdirectory( fftpack/fftpack5 ) + diff --git a/external/io_grib1/CMakeLists.txt b/external/io_grib1/CMakeLists.txt index d1bd0fde64..0fb77efdba 100644 --- a/external/io_grib1/CMakeLists.txt +++ b/external/io_grib1/CMakeLists.txt @@ -39,8 +39,7 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} PRIVATE ${netCDF_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} - #!TODO Fix duplicates of wrf_[io|status]_flags.h - # ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share + ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share ${CMAKE_CURRENT_SOURCE_DIR}/../io_grib_share ${CMAKE_CURRENT_SOURCE_DIR}/grib1_util ${CMAKE_CURRENT_SOURCE_DIR}/MEL_grib1 diff --git a/external/io_grib_share/CMakeLists.txt b/external/io_grib_share/CMakeLists.txt index 18b5c4f8d2..5381b8e35f 100644 --- a/external/io_grib_share/CMakeLists.txt +++ b/external/io_grib_share/CMakeLists.txt @@ -35,6 +35,7 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} PRIVATE ${netCDF_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share ) install( diff --git a/external/io_netcdf/CMakeLists.txt b/external/io_netcdf/CMakeLists.txt index e69de29bb2..cf7f74e5fe 100644 --- a/external/io_netcdf/CMakeLists.txt +++ b/external/io_netcdf/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} + STATIC + ) + +# set( +# SOURCE_CODE +# #!TODO Change the file extension on these, maybe... +# # ext_ncd_get_dom_ti.code +# # ext_ncd_get_var_td.code +# # ext_ncd_get_var_ti.code +# # ext_ncd_put_dom_ti.code +# # ext_ncd_put_var_td.code +# # ext_ncd_put_var_ti.code +# # transpose.code + +# ) + +# set_source_files_properties( +# ${SOURCE_CODE} +# PROPERTIES +# LANGUAGE Fortran +# ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + field_routines.F90 + module_wrfsi_static.F90 + wrf_io.F90 + ) + + +set_target_properties( + ${FOLDER_COMPILE_TARGET} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + ) + + +target_link_libraries( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_LIBRARIES} + $<$:$> + $<$:$> + ) + +target_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share + ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) diff --git a/external/io_netcdf/wrf_io.F90 b/external/io_netcdf/wrf_io.F90 index ec2162d2d5..e29c8b4271 100644 --- a/external/io_netcdf/wrf_io.F90 +++ b/external/io_netcdf/wrf_io.F90 @@ -755,7 +755,7 @@ subroutine Transpose(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) -!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') @@ -941,7 +941,7 @@ subroutine TransposeToR4(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) -!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') diff --git a/external/io_netcdfpar/CMakeLists.txt b/external/io_netcdfpar/CMakeLists.txt index e69de29bb2..6424556f08 100644 --- a/external/io_netcdfpar/CMakeLists.txt +++ b/external/io_netcdfpar/CMakeLists.txt @@ -0,0 +1,62 @@ +# WRF CMake Build + +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +add_library( + ${FOLDER_COMPILE_TARGET} + STATIC + ) + +# set( +# SOURCE_CODE +# # ext_ncdpar_get_dom_ti.code +# # ext_ncdpar_get_var_td.code +# # ext_ncdpar_get_var_ti.code +# # ext_ncdpar_put_dom_ti.code +# # ext_ncdpar_put_var_td.code +# # ext_ncdpar_put_var_ti.code +# # transpose.code +# ) + +# set_source_files_properties( +# ${SOURCE_CODE} +# PROPERTIES +# LANGUAGE Fortran +# ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + field_routines.F90 + module_wrfsi_static.F90 + wrf_io.F90 + ) + + +set_target_properties( + ${FOLDER_COMPILE_TARGET} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + ) + + +target_link_libraries( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_LIBRARIES} + $<$:$> + $<$:$> + ) + +target_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) diff --git a/external/io_netcdfpar/wrf_io.F90 b/external/io_netcdfpar/wrf_io.F90 index a76ec5d82d..60b6dff094 100644 --- a/external/io_netcdfpar/wrf_io.F90 +++ b/external/io_netcdfpar/wrf_io.F90 @@ -768,7 +768,7 @@ subroutine Transpose(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) -!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') @@ -954,7 +954,7 @@ subroutine TransposeToR4a(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) -!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') diff --git a/external/io_pio/CMakeLists.txt b/external/io_pio/CMakeLists.txt index e69de29bb2..380c7c646e 100644 --- a/external/io_pio/CMakeLists.txt +++ b/external/io_pio/CMakeLists.txt @@ -0,0 +1,47 @@ +# WRF CMake Build + +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +add_library( + ${FOLDER_COMPILE_TARGET} + STATIC + ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + wrf_data_pio.F90 + pio_routines.F90 + wrf_io.F90 + field_routines.F90 + read_bdy_routines.F90 + module_wrfsi_static.F90 + ) + + +set_target_properties( + ${FOLDER_COMPILE_TARGET} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + ) + + +target_link_libraries( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_LIBRARIES} + $<$:$> + $<$:$> + ) + +target_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) diff --git a/external/io_pnetcdf/CMakeLists.txt b/external/io_pnetcdf/CMakeLists.txt index e69de29bb2..400ff3bf1d 100644 --- a/external/io_pnetcdf/CMakeLists.txt +++ b/external/io_pnetcdf/CMakeLists.txt @@ -0,0 +1,62 @@ +# WRF CMake Build + +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +add_library( + ${FOLDER_COMPILE_TARGET} + STATIC + ) + +# set( +# SOURCE_CODE +# # ext_pcd_get_dom_ti.code +# # ext_pcd_get_var_td.code +# # ext_pcd_get_var_ti.code +# # ext_pcd_put_dom_ti.code +# # ext_pcd_put_var_td.code +# # ext_pcd_put_var_ti.code +# # transpose.code +# ) + +# set_source_files_properties( +# ${SOURCE_CODE} +# PROPERTIES +# LANGUAGE Fortran +# ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + field_routines.F90 + module_wrfsi_static.F90 + wrf_io.F90 + ) + + +set_target_properties( + ${FOLDER_COMPILE_TARGET} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + ) + + +target_link_libraries( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_LIBRARIES} + $<$:$> + $<$:$> + ) + +target_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${netCDF_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share + ) + +install( + TARGETS ${FOLDER_COMPILE_TARGET} + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) diff --git a/external/ioapi_share/wrf_status_codes.h b/external/ioapi_share/wrf_status_codes.h index 98484da413..8dfb44b53e 100644 --- a/external/ioapi_share/wrf_status_codes.h +++ b/external/ioapi_share/wrf_status_codes.h @@ -132,3 +132,12 @@ integer, parameter :: WRF_HDF5_ERR_OTHERS = -320 integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_OTHERS = -321 + integer, parameter :: WRF_GRIB2_ERR_GRIBCREATE = -401 + integer, parameter :: WRF_GRIB2_ERR_ADDLOCAL = -402 + integer, parameter :: WRF_GRIB2_ERR_ADDGRIB = -403 + integer, parameter :: WRF_GRIB2_ERR_ADDFIELD = -404 + integer, parameter :: WRF_GRIB2_ERR_GRIBEND = -405 + integer, parameter :: WRF_GRIB2_ERR_WRITE = -406 + integer, parameter :: WRF_GRIB2_ERR_GRIB2MAP = -407 + integer, parameter :: WRF_GRIB2_ERR_GETGB2 = -408 + integer, parameter :: WRF_GRIB2_ERR_READ = -409 From a70da4c22913a61ffbddc48fa3636f2d8317a7db Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 17 May 2023 16:56:23 -0600 Subject: [PATCH 037/180] Fully compiling --- CMakeLists.txt | 251 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 176 insertions(+), 75 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 855c12a02d..d202489ca9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,8 +14,22 @@ include( c_preproc ) include( m4_preproc ) include( target_copy ) include( confcheck ) +include( gitinfo ) include( printOption ) +include( wrf_case_setup ) +# First grab git info +wrf_git_commit( + RESULT_VAR GIT_VERSION + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + ) + +# Configure file for usage +configure_file( + ${PROJECT_SOURCE_DIR}/cmake/template/commit_decl.cmake + ${PROJECT_BINARY_DIR}/inc/commit_decl + @ONLY + ) ################################################################################ ## @@ -24,19 +38,22 @@ include( printOption ) ################################################################################ set( CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/runTemp ) +# Mode configuration + set( OPTIMIZATION_LEVEL "" ) set( WRF_OS "" ) set( WRF_MACH "" ) -# DO NOT USE OPTION - IT DOES NOT WORK AS ANTICIPATED EVEN WHEN CLEARING CACHE - YOU HAVE BEEN WARNED -# Mode configuration -# WRF Core selection + +################################################################################ +## WRF Core selection +################################################################################ set( WRF_CORE_OPTIONS # Options listed here ARW COAMPS # Not sure how this is used CONVERT # This exists in compile but not configure - DA + DA # Var directory DA_4D_VAR PLUS ) @@ -45,7 +62,9 @@ set( WRF_CORE_OPTIONS set( WRF_CORE "" CACHE STRING "WRF_CORE" ) list( GET WRF_CORE_OPTIONS 0 WRF_CORE ) -# WRF Nesting selection +################################################################################ +## WRF Nesting selection +################################################################################ set( WRF_NESTING_OPTIONS # Options listed here NONE @@ -59,6 +78,38 @@ set( WRF_NESTING "" CACHE STRING "WRF_NESTING" ) list( GET WRF_NESTING_OPTIONS 0 WRF_NESTING ) +################################################################################ +## WRF Case selection +##!TODO Maybe one day make it so this doesn't need to be a selection and all are +## always built? +################################################################################ +set( WRF_CASE_OPTIONS + # Options listed here + EM_REAL # make this the default + # EM_IDEAL # Technically doable but does anyone build this? It is not a target option in make + EM_FIRE + EM_SCM_XY + EM_TROPICAL_CYCLONE + EM_HELDSUAREZ + + # These are sub-categories of ideal - Keep these lower in the list + EM_B_WAVE # Keep this one here as it is used to check index + EM_GRAV2D_X + EM_HILL2D_X + EM_LES + EM_QUARTER_SS + EM_SEABREEZE2D_X + EM_CONVRAD + EM_SQUALL2D_X + EM_SQUALL2D_Y + ) + +# Set default WRF_CASE +set( WRF_CASE "" CACHE STRING "WRF_CASE" ) +list( GET WRF_CASE_OPTIONS 0 WRF_CASE ) + + +# DO NOT USE OPTION - IT DOES NOT WORK AS ANTICIPATED EVEN WHEN CLEARING CACHE - YOU HAVE BEEN WARNED set( USE_DOUBLE OFF CACHE BOOL "USE_DOUBLE" ) # I believe this is the r8/real8 promotion set( USE_MPI OFF CACHE BOOL "USE_MPI" ) set( USE_OPENMP OFF CACHE BOOL "USE_OPENMP" ) @@ -84,13 +135,14 @@ set( KEEP_INT_AROUND ON CACHE BOOL "KEEP_INT_AROUND" ) set( LIMIT_ARGS ON CACHE BOOL "LIMIT_ARGS" ) set( WRFIO_NCD_NO_LARGE_FILE_SUPPORT OFF CACHE BOOL "WRFIO_NCD_NO_LARGE_FILE_SUPPORT" ) -set( BUILD_RRTMG_FAST OFF CACHE BOOL "BUILD_RRTMG_FAST" ) -set( BUILD_RRTMK OFF CACHE BOOL "BUILD_RRTMK" ) -set( BUILD_SBM_FAST ON CACHE BOOL "BUILD_SBM_FAST" ) -set( SHOW_ALL_VARS_USED OFF CACHE BOOL "SHOW_ALL_VARS_USED" ) - +set( FORCE_NETCDF_CLASSIC OFF CACHE BOOL "FORCE_NETCDF_CLASSIC" ) +set( BUILD_RRTMG_FAST OFF CACHE BOOL "BUILD_RRTMG_FAST" ) +set( BUILD_RRTMK OFF CACHE BOOL "BUILD_RRTMK" ) +set( BUILD_SBM_FAST ON CACHE BOOL "BUILD_SBM_FAST" ) +set( SHOW_ALL_VARS_USED OFF CACHE BOOL "SHOW_ALL_VARS_USED" ) +# TODO investigate if this needs set # Not cached, cannot be changed, do not touch set( USE_M4 ON ) # Same thing -what do these defines even do if they are always on???? @@ -142,6 +194,16 @@ if ( NOT ${WRF_CORE} IN_LIST WRF_CORE_OPTIONS ) message( FATAL_ERROR "WRF Core option not recognized : ${WRF_CORE}" ) endif() +if ( NOT ${WRF_NESTING} IN_LIST WRF_NESTING_OPTIONS ) + message( FATAL_ERROR "WRF Nesting option not recognized : ${WRF_NESTING}" ) +endif() + +if ( NOT ${WRF_CASE} IN_LIST WRF_CASE_OPTIONS ) + message( FATAL_ERROR "WRF Case option not recognized : ${WRF_CASE}" ) +endif() + + +# Handle selection set( EM_CORE 1 ) # Far easier to write this one as normal logic rather than generator expression if( ${WRF_CORE} STREQUAL "CONVERT" OR ${WRF_CORE} STREQUAL "COAMPS" ) @@ -159,9 +221,24 @@ if ( ${ENABLE_KPP} AND NOT ${ENABLE_CHEM} ) endif() +# Additional information on the type of case we are compiling +string( TOLOWER ${WRF_CASE} WRF_CASE_FOLDER ) +string( REPLACE "em_" "" WRF_CASE_MODULE ${WRF_CASE_FOLDER} ) + +# Find if it is a specialized ideal case or general +list( FIND WRF_CASE_OPTIONS EM_B_WAVE START_GENERAL_IDEAL_CASE_IDX ) +list( FIND WRF_CASE_OPTIONS ${WRF_CASE} CURRENT_CASE_IDX ) +set( WRF_GENERAL_IDEAL_CASE TRUE ) +if ( ${CURRENT_CASE_IDX} LESS ${START_GENERAL_IDEAL_CASE_IDX} ) + set( WRF_GENERAL_IDEAL_CASE FALSE ) +endif() + + print_option( WRF_CORE 20 ${BOLD_CYAN} ) print_option( WRF_NESTING 20 ${BOLD_CYAN} ) +print_option( WRF_CASE 20 ${BOLD_CYAN} ) + print_option( USE_DOUBLE 20 ) print_option( USE_MPI 20 ) @@ -186,10 +263,11 @@ print_option( INTIO 20 ) print_option( KEEP_INT_AROUND 20 ) print_option( LIMIT_ARGS 20 ) -print_option( BUILD_RRTMG_FAST 20 ) -print_option( BUILD_RRTMK 20 ) -print_option( BUILD_SBM_FAST 20 ) -print_option( SHOW_ALL_VARS_USED 20 ) +print_option( FORCE_NETCDF_CLASSIC 20 ) +print_option( BUILD_RRTMG_FAST 20 ) +print_option( BUILD_RRTMK 20 ) +print_option( BUILD_SBM_FAST 20 ) +print_option( SHOW_ALL_VARS_USED 20 ) print_option( WRFIO_NCD_NO_LARGE_FILE_SUPPORT 36 ) @@ -218,10 +296,15 @@ find_package( ZLIB REQUIRED ) find_package( CURL REQUIRED ) # HDF5 has some funky weirdness between versions where the casing has changed -find_package( HDF5 REQUIRED ) +# Optional +find_package( HDF5 QUIET ) +# Required for WPS find_package( Jasper REQUIRED ) +# Optional +find_package( PIO QUIET ) + if ( ${ENABLE_TERRAIN} ) find_package( RPC ) endif() @@ -240,9 +323,10 @@ find_package( netCDF REQUIRED ) # Make use of version checking here and not in find_package for previous versions that did not use cmake if ( NOT netCDF_VERSION GREATER_EQUAL "4.1.3" ) message( FATAL "Please make sure NETCDF version is 4.1.3 or later. " ) - endif() +find_package( pnetCDF QUIET ) + if ( USE_MPI ) find_package( MPI REQUIRED COMPONENTS Fortran C ) add_compile_definitions( USE_MPI=1 DM_PARALLEL=1 ) @@ -253,6 +337,7 @@ if ( USE_OPENMP ) add_compile_definitions( USE_OPENMP=1 SM_PARALLEL=1 ) endif() + ################################################################################ ## ## Adjust flags based on compiler and linker used @@ -265,7 +350,7 @@ set( Fortran_COMPILER_ID ${CMAKE_Fortran_COMPILER_ID} ) # Whole project flags add_compile_options( - $<$:-cpp> + # $<$:-cpp> # Use "" and ; specifically to evaluate correctly "$<$:-diag-disable;6843>" @@ -293,7 +378,8 @@ add_compile_definitions( $<$:WRF_VENUS=$> $<$:WRF_USE_CLM=$> - $<$:NETCDF_classic=$> + # If force classic or no nc-4 support enable classic + $<$,$>>:NETCDF_classic=1> $<$:WRFIO_NCD_NO_LARGE_FILE_SUPPORT=$> # TODO Figure out how these should be set # DUSE_NETCDF4_FEATURES -DWRFIO_NCD_LARGE_FILE_SUPPORT @@ -336,7 +422,7 @@ add_compile_definitions( # DFI_RADAR=$ # Nesting options - $<$:MOVE_NESTS> + $<$:MOVE_NESTS> $<$>:VORTEX_CENTER> # Configuration checks @@ -350,21 +436,9 @@ add_compile_definitions( # 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>> - - - MPI2_SUPPORT - MPI2_THREAD_SUPPORT - - ) + ) -# add_custom_command( OUTPUT NONE_ENABLE_CHEM COMMAND ${CMAKE_COMMAND} -E echo "ENABLE_CHEM => $<$:WRF_CHEM=$> " ) -# add_custom_command( OUTPUT NONE_ENABLE_CMAQ COMMAND ${CMAKE_COMMAND} -E echo "ENABLE_CMAQ => $<$:WRF_CMAQ=$> " ) -# add_custom_command( OUTPUT NONE_ENABLE_KPP COMMAND ${CMAKE_COMMAND} -E echo "ENABLE_KPP => $<$:WRF_KPP=$> " ) -# add_custom_command( OUTPUT NONE_ENABLE_DFI_RADAR COMMAND ${CMAKE_COMMAND} -E echo "ENABLE_DFI_RADAR => $<$:WRF_DFI_RADAR=$> " ) -# add_custom_command( OUTPUT NONE_ENABLE_TITAN COMMAND ${CMAKE_COMMAND} -E echo "ENABLE_TITAN => $<$:WRF_TITAN=$> " ) -# add_custom_command( OUTPUT NONE_ENABLE_MARS COMMAND ${CMAKE_COMMAND} -E echo "ENABLE_MARS => $<$:WRF_MARS=$> " ) -# add_custom_command( OUTPUT NONE_ENABLE_VENUS COMMAND ${CMAKE_COMMAND} -E echo "ENABLE_VENUS => $<$:WRF_VENUS=$> " ) #!TODO Investigate if this is better than setting -cpp set( CMAKE_Fortran_PREPROCESS ON ) @@ -381,55 +455,53 @@ add_library( add_subdirectory( external ) add_subdirectory( tools ) - +# add_dependencies() does not support generator expressions so whatever we can defer to linking please do so add_dependencies( ${PROJECT_NAME}_Core # So many things depend on this that I'm adding a dep here registry_code - # "External" io libs - esmf_time_f90 - - # io_pio - - # io_netcdf - # io_netcdfpar - # io_pnetcdf - # io_phdf5 - io_grib1 - io_grib_share - g2lib - bacio-1.3 - - RSL_LITE - fftpack5 - # add_dependencies() does not support generator expressions - # $ - # $ - # $ ) target_include_directories( ${PROJECT_NAME}_Core - PRIVATE + PUBLIC + # List module directories first so the compiler does not get confused + # about things "not being compiled yet" - yes, yes it is compiled + $ + $ + $ + $ + $ + $ + $ + + ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/inc + ${PROJECT_SOURCE_DIR}/frame + ${PROJECT_SOURCE_DIR}/external/ioapi_share + + ${CMAKE_BINARY_DIR}/inc + ${CMAKE_BINARY_DIR}/frame + + PRIVATE + # May or may not exist + $<$:$> + $<$:$> + $<$:$> + $<$:$> + $<$:$> + $<$:$> + $<$:$> + $<$:$> + $<$:$> + ${PROJECT_SOURCE_DIR}/dyn_em - # ${PROJECT_SOURCE_DIR}/frame # externals + ${PROJECT_SOURCE_DIR}/external/esmf_time_f90 ${PROJECT_SOURCE_DIR}/external/io_grib_share ${PROJECT_SOURCE_DIR}/external/io_netcdf ${PROJECT_SOURCE_DIR}/external/io_int - ${PROJECT_SOURCE_DIR}/external/grib2 - ${PROJECT_SOURCE_DIR}/external/ioapi_share - - $ - $ - $ - $ - - - ${CMAKE_BINARY_DIR}/inc - ${CMAKE_BINARY_DIR}/frame ) # Add directly to core @@ -443,6 +515,14 @@ endif() add_subdirectory( dyn_em ) + +add_subdirectory( main ) + +################################################################################ +# Add subdirectory with case info +############################################################################### +add_subdirectory( test/${WRF_CASE_FOLDER} ) + # Configure core set_target_properties( ${PROJECT_NAME}_Core @@ -457,19 +537,40 @@ target_link_libraries( ${PROJECT_NAME}_Core ${netCDF_LIBRARIES} $<$:$> $<$:$> - esmf_time_f90 - g2lib - bacio-1.3 # This will add in target dependencies if they exist + $ + + # "External" io libs + esmf_time_f90 + + io_grib1 + grib1_util + MEL_grib1 + WGRIB + + io_grib_share + fftpack5 + $ $ $ - $ + $ + io_netcdf + $ + $ + $ + + $ + $ + + RSL_LITE ) -# target_include_directories( -# ${PROJECT_NAME}_Core -# PRIVATE - -# ) + +install( + TARGETS ${PROJECT_NAME}_Core + RUNTIME DESTINATION bin/ + ARCHIVE DESTINATION lib/ + LIBRARY DESTINATION lib/ + ) From 06b3d22e32dfb65195573f48067f3408491c87ae Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 17 May 2023 16:58:04 -0600 Subject: [PATCH 038/180] Adding install rules for em_real --- test/em_real/CMakeLists.txt | 88 +++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 test/em_real/CMakeLists.txt diff --git a/test/em_real/CMakeLists.txt b/test/em_real/CMakeLists.txt new file mode 100644 index 0000000000..612d71c6f5 --- /dev/null +++ b/test/em_real/CMakeLists.txt @@ -0,0 +1,88 @@ +# These are just rules for this case, could be named CMakeLists.txt or something +# like install_rules.cmake, whatever you want really +wrf_link_targets( + TARGETS real tc ndown wrf + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + OLD_BASE_PATH ${CMAKE_INSTALL_PREFIX}/bin + ) + +wrf_link_files( + FILES + ${PROJECT_SOURCE_DIR}/run/README.namelist + ${PROJECT_SOURCE_DIR}/run/README.physics_files + ${PROJECT_SOURCE_DIR}/run/README.physics_files + + ${PROJECT_SOURCE_DIR}/run/ETAMPNEW_DATA + ${PROJECT_SOURCE_DIR}/run/ETAMPNEW_DATA.expanded_rain + ${PROJECT_SOURCE_DIR}/run/RRTM_DATA + ${PROJECT_SOURCE_DIR}/run/RRTMG_LW_DATA + ${PROJECT_SOURCE_DIR}/run/RRTMG_SW_DATA + ${PROJECT_SOURCE_DIR}/run/CAM_ABS_DATA + ${PROJECT_SOURCE_DIR}/run/CAM_AEROPT_DATA + ${PROJECT_SOURCE_DIR}/run/CAMtr_volume_mixing_ratio.RCP4.5 + ${PROJECT_SOURCE_DIR}/run/CAMtr_volume_mixing_ratio.RCP6 + ${PROJECT_SOURCE_DIR}/run/CAMtr_volume_mixing_ratio.RCP8.5 + ${PROJECT_SOURCE_DIR}/run/CAMtr_volume_mixing_ratio.A1B + ${PROJECT_SOURCE_DIR}/run/CAMtr_volume_mixing_ratio.A2 + ${PROJECT_SOURCE_DIR}/run/CAMtr_volume_mixing_ratio.SSP119 + ${PROJECT_SOURCE_DIR}/run/CAMtr_volume_mixing_ratio.SSP126 + ${PROJECT_SOURCE_DIR}/run/CAMtr_volume_mixing_ratio.SSP245 + #!TODO Why does this have an alt name? + # ${PROJECT_SOURCE_DIR}/run/CAMtr_volume_mixing_ratio.SSP245 # Has alt name, why? + ${PROJECT_SOURCE_DIR}/run/CAMtr_volume_mixing_ratio.SSP370 + ${PROJECT_SOURCE_DIR}/run/CAMtr_volume_mixing_ratio.SSP585 + ${PROJECT_SOURCE_DIR}/run/CLM_ALB_ICE_DFS_DATA + ${PROJECT_SOURCE_DIR}/run/CLM_ALB_ICE_DRC_DATA + ${PROJECT_SOURCE_DIR}/run/CLM_ASM_ICE_DFS_DATA + ${PROJECT_SOURCE_DIR}/run/CLM_ASM_ICE_DRC_DATA + ${PROJECT_SOURCE_DIR}/run/CLM_DRDSDT0_DATA + ${PROJECT_SOURCE_DIR}/run/CLM_EXT_ICE_DFS_DATA + ${PROJECT_SOURCE_DIR}/run/CLM_EXT_ICE_DRC_DATA + ${PROJECT_SOURCE_DIR}/run/CLM_KAPPA_DATA + ${PROJECT_SOURCE_DIR}/run/CLM_TAU_DATA + ${PROJECT_SOURCE_DIR}/run/ozone.formatted + ${PROJECT_SOURCE_DIR}/run/ozone_lat.formatted + ${PROJECT_SOURCE_DIR}/run/ozone_plev.formatted + ${PROJECT_SOURCE_DIR}/run/aerosol.formatted + ${PROJECT_SOURCE_DIR}/run/aerosol_lat.formatted + ${PROJECT_SOURCE_DIR}/run/aerosol_lon.formatted + ${PROJECT_SOURCE_DIR}/run/aerosol_plev.formatted + ${PROJECT_SOURCE_DIR}/run/eclipse_besselian_elements.dat + ${PROJECT_SOURCE_DIR}/run/capacity.asc + ${PROJECT_SOURCE_DIR}/run/coeff_p.asc + ${PROJECT_SOURCE_DIR}/run/coeff_q.asc + ${PROJECT_SOURCE_DIR}/run/constants.asc + ${PROJECT_SOURCE_DIR}/run/masses.asc + ${PROJECT_SOURCE_DIR}/run/termvels.asc + ${PROJECT_SOURCE_DIR}/run/kernels.asc_s_0_03_0_9 + ${PROJECT_SOURCE_DIR}/run/kernels_z.asc + ${PROJECT_SOURCE_DIR}/run/bulkdens.asc_s_0_03_0_9 + ${PROJECT_SOURCE_DIR}/run/bulkradii.asc_s_0_03_0_9 + ${PROJECT_SOURCE_DIR}/run/CCN_ACTIVATE.BIN + ${PROJECT_SOURCE_DIR}/run/p3_lookupTable_1.dat-5.3-2momI + ${PROJECT_SOURCE_DIR}/run/p3_lookupTable_1.dat-3momI_v5.1.7 + ${PROJECT_SOURCE_DIR}/run/p3_lookupTable_2.dat-2momI_v5.2.3 + ${PROJECT_SOURCE_DIR}/run/HLC.TBL + ${PROJECT_SOURCE_DIR}/run/wind-turbine-1.tbl + ${PROJECT_SOURCE_DIR}/run/ishmael-gamma-tab.bin + ${PROJECT_SOURCE_DIR}/run/ishmael-qi-qc.bin + ${PROJECT_SOURCE_DIR}/run/ishmael-qi-qr.bin + ${PROJECT_SOURCE_DIR}/run/BROADBAND_CLOUD_GODDARD.bin + ${PROJECT_SOURCE_DIR}/run/STOCHPERT.TBL + + ${PROJECT_SOURCE_DIR}/run/GENPARM.TBL + ${PROJECT_SOURCE_DIR}/run/LANDUSE.TBL + ${PROJECT_SOURCE_DIR}/run/SOILPARM.TBL + ${PROJECT_SOURCE_DIR}/run/URBPARM.TBL + ${PROJECT_SOURCE_DIR}/run/URBPARM_LCZ.TBL + ${PROJECT_SOURCE_DIR}/run/VEGPARM.TBL + ${PROJECT_SOURCE_DIR}/run/MPTABLE.TBL # Missing? + ${PROJECT_SOURCE_DIR}/run/tr49t67 + ${PROJECT_SOURCE_DIR}/run/tr49t85 + ${PROJECT_SOURCE_DIR}/run/tr67t85 + ${PROJECT_SOURCE_DIR}/run/gribmap.txt + ${PROJECT_SOURCE_DIR}/run/grib2map.tbl + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) + +#!TODO Add alternate double stuff \ No newline at end of file From 09ee8e9214c50a58bc105b4579f8d90c70c7b943 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 23 May 2023 12:45:51 -0600 Subject: [PATCH 039/180] Adding runtime generated files to ignore list --- .gitignore | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c47fe3e850..26a74951f6 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,17 @@ configure.wrf* *.backup *.f90 -_build/ \ No newline at end of file +_build/ +# New (and old) things we should ignore +wrf_config.cmake +*.nc +rsl.out.* +rsl.error.* +ndown +real +tc +ideal +wrf +wrfbdy_d* +wrfinput_d* +wrfout_d* \ No newline at end of file From e923a6378c2b8545f73e6b772277da5db2834425 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 23 May 2023 12:50:47 -0600 Subject: [PATCH 040/180] Adding libdir and prefix to created variables --- cmake/modules/FindnetCDF.cmake | 5 ++++- cmake/modules/FindpnetCDF.cmake | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmake/modules/FindnetCDF.cmake b/cmake/modules/FindnetCDF.cmake index c9892e98bc..078e1c793d 100644 --- a/cmake/modules/FindnetCDF.cmake +++ b/cmake/modules/FindnetCDF.cmake @@ -23,6 +23,8 @@ if ( ${NETCDF_PROGRAM} MATCHES "-NOTFOUND$" ) else() execute_process( COMMAND ${NETCDF_PROGRAM} --includedir OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_INCLUDE_DIR ) + execute_process( COMMAND ${NETCDF_PROGRAM} --libdir OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_LIBRARY_DIR ) + execute_process( COMMAND ${NETCDF_PROGRAM} --prefix OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_PREFIX ) execute_process( COMMAND ${NETCDF_PROGRAM} --libs OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_CLIBS ) execute_process( COMMAND ${NETCDF_PROGRAM} --cxx4libs OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_CXXLIBS ) execute_process( COMMAND ${NETCDF_PROGRAM} --flibs OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_FLIBS ) @@ -59,10 +61,11 @@ include(FindPackageHandleStandardArgs) # if all listed variables are TRUE find_package_handle_standard_args( netCDF DEFAULT_MSG netCDF_INCLUDE_DIRS + netCDF_LIBRARY_DIR netCDF_CLIBS netCDF_CXXLIBS netCDF_FLIBS netCDF_VERSION ) -mark_as_advanced( netCDF_CLIBS netCDF_CXXLIBS netCDF_FLIBS ) \ No newline at end of file +mark_as_advanced( netCDF_CLIBS netCDF_CXXLIBS netCDF_FLIBS netCDF_PREFIX netCDF_LIBRARY_DIR ) \ No newline at end of file diff --git a/cmake/modules/FindpnetCDF.cmake b/cmake/modules/FindpnetCDF.cmake index 64604f1c45..fbf1745a6b 100644 --- a/cmake/modules/FindpnetCDF.cmake +++ b/cmake/modules/FindpnetCDF.cmake @@ -22,7 +22,8 @@ if ( ${PNETCDF_PROGRAM} MATCHES "-NOTFOUND$" ) else() execute_process( COMMAND ${PNETCDF_PROGRAM} --includedir OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE pnetCDF_INCLUDE_DIR ) - execute_process( COMMAND ${PNETCDF_PROGRAM} --libdir OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE pnetCDF_LIBRARY_DIR ) + execute_process( COMMAND ${PNETCDF_PROGRAM} --libdir OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE pnetCDF_LIBRARY_DIR ) + execute_process( COMMAND ${PNETCDF_PROGRAM} --prefix OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE pnetCDF_PREFIX ) execute_process( COMMAND ${PNETCDF_PROGRAM} --version OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE pnetCDF_VERSION_RAW ) execute_process( COMMAND ${PNETCDF_PROGRAM} --netcdf4 OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE pnetCDF_NC4_ENABLED ) From 0971f3cd7a945489a906e41e10ea329ebb7b097b Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 23 May 2023 12:51:25 -0600 Subject: [PATCH 041/180] Building pnetcdf io lib and re-enabling macro --- external/io_pnetcdf/CMakeLists.txt | 2 ++ external/io_pnetcdf/wrf_io.F90 | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/external/io_pnetcdf/CMakeLists.txt b/external/io_pnetcdf/CMakeLists.txt index 400ff3bf1d..b12e73cd9e 100644 --- a/external/io_pnetcdf/CMakeLists.txt +++ b/external/io_pnetcdf/CMakeLists.txt @@ -43,6 +43,7 @@ set_target_properties( target_link_libraries( ${FOLDER_COMPILE_TARGET} PRIVATE ${netCDF_LIBRARIES} + ${pnetCDF_LIBRARIES} $<$:$> $<$:$> ) @@ -50,6 +51,7 @@ target_link_libraries( ${FOLDER_COMPILE_TARGET} target_include_directories( ${FOLDER_COMPILE_TARGET} PRIVATE ${netCDF_INCLUDE_DIRS} + ${pnetCDF_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share ) diff --git a/external/io_pnetcdf/wrf_io.F90 b/external/io_pnetcdf/wrf_io.F90 index 18f6ac078a..f6e382d93b 100644 --- a/external/io_pnetcdf/wrf_io.F90 +++ b/external/io_pnetcdf/wrf_io.F90 @@ -741,7 +741,7 @@ subroutine Transpose(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) -!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') From dcbda568fc2195b61a605ec61e5d9e14db2ae98a Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 23 May 2023 12:52:46 -0600 Subject: [PATCH 042/180] Adding in source file swap for MPI comms using RSL LITE --- frame/CMakeLists.txt | 8 +++++++- tools/CMakeLists.txt | 16 +++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/frame/CMakeLists.txt b/frame/CMakeLists.txt index 546058d86a..44d69e4491 100644 --- a/frame/CMakeLists.txt +++ b/frame/CMakeLists.txt @@ -74,6 +74,11 @@ target_include_directories( # Now define base framework # ######################################################################################################################## +set( MODULE_DM module_dm.F ) +if ( ${USE_MPI} ) + set( MODULE_DM ${PROJECT_SOURCE_DIR}/external/RSL_LITE/module_dm.F ) +endif() + target_sources( ${PROJECT_NAME}_Core PRIVATE @@ -85,7 +90,8 @@ target_sources( module_wrf_error.F module_machine.F module_timing.F - module_dm.F + # module_dm.F + ${MODULE_DM} module_cpl.F module_cpl_oasis3.F diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 11ce867b3e..1b6eeb37ad 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -8,6 +8,11 @@ add_executable( ${FOLDER_COMPILE_TARGET} ) +set( GEN_COMMS gen_comms.c ) +if ( ${USE_MPI} ) + set( GEN_COMMS ${PROJECT_SOURCE_DIR}/external/RSL_LITE/gen_comms.c ) +endif() + target_sources( ${FOLDER_COMPILE_TARGET} PRIVATE @@ -28,7 +33,8 @@ target_sources( gen_irr_diag.c gen_model_data_ord.c gen_interp.c - gen_comms.c + # gen_comms.c + ${GEN_COMMS} gen_scalar_derefs.c set_dim_strs.c gen_wrf_io.c @@ -42,16 +48,8 @@ target_sources( # Fortran_FORMAT FREE # ) -target_link_libraries( ${FOLDER_COMPILE_TARGET} - PRIVATE - ${netCDF_LIBRARIES} - $<$:$> - $<$:$> - ) - target_include_directories( ${FOLDER_COMPILE_TARGET} PRIVATE - ${netCDF_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} ) From 074f514778204d2f4b4253c8590ca50408b7e6a9 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 23 May 2023 12:53:45 -0600 Subject: [PATCH 043/180] Compilation scheme using arch/configure.defaults now working --- CMakeLists.txt | 110 +++++++++--- arch/configure_reader.py | 292 +++++++++++++++++++++++++++++++ cmake/template/arch_config.cmake | 21 +++ compile_new | 5 + configure_new | 10 ++ 5 files changed, 417 insertions(+), 21 deletions(-) create mode 100755 arch/configure_reader.py create mode 100644 cmake/template/arch_config.cmake create mode 100755 compile_new create mode 100755 configure_new diff --git a/CMakeLists.txt b/CMakeLists.txt index d202489ca9..e4f8e6104d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,9 +7,18 @@ enable_language( Fortran ) project( WRF ) +if ( DEFINED CMAKE_TOOLCHAIN_FILE ) + set( WRF_CONFIG ${CMAKE_TOOLCHAIN_FILE} ) + message( STATUS "Loading configuration file..." ) + include( ${WRF_CONFIG} ) +endif() + # list( APPEND CMAKE_MODULE_PATH ) list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/ ${PROJECT_SOURCE_DIR}/cmake/modules ) +# Use link paths as rpaths +set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE ) + include( c_preproc ) include( m4_preproc ) include( target_copy ) @@ -234,6 +243,10 @@ if ( ${CURRENT_CASE_IDX} LESS ${START_GENERAL_IDEAL_CASE_IDX} ) endif() +if ( DEFINED CMAKE_TOOLCHAIN_FILE ) + print_option( WRF_CONFIG 20 ${BOLD_CYAN} ) +endif() + print_option( WRF_CORE 20 ${BOLD_CYAN} ) print_option( WRF_NESTING 20 ${BOLD_CYAN} ) @@ -271,18 +284,60 @@ print_option( SHOW_ALL_VARS_USED 20 ) print_option( WRFIO_NCD_NO_LARGE_FILE_SUPPORT 36 ) -################################################################################ -## -## Configuration checks for features & intrinsices -## -################################################################################ -add_subdirectory( confcheck ) - ################################################################################ ## ## Now find packages that cross-compilation is potentially handled ## ################################################################################ +if ( ${USE_MPI} ) + # message( STATUS "[BEFORE] MPI_C_COMPILER : ${MPI_C_COMPILER}") + # message( STATUS "[BEFORE] MPI_Fortran_COMPILER : ${MPI_Fortran_COMPILER}") + # message( STATUS "[BEFORE] MPI_LIBRARIES : ${MPI_LIBRARIES}") + # message( STATUS "[BEFORE] MPI_LIBRARY : ${MPI_LIBRARY}") + # message( STATUS "[BEFORE] MPI_EXTRA_LIBRARY : ${MPI_EXTRA_LIBRARY}") + # message( STATUS "[BEFORE] MPI_COMPILE_FLAGS : ${MPI_COMPILE_FLAGS}") + # message( STATUS "[BEFORE] MPI_INCLUDE_PATH : ${MPI_INCLUDE_PATH}") + # message( STATUS "[BEFORE] MPI_LINK_FLAGS : ${MPI_LINK_FLAGS}") + # message( STATUS "[BEFORE] MPI_LIBRARIES : ${MPI_LIBRARIES}") + # set( CMAKE_FIND_DEBUG_MODE TRUE ) + # Through ***MUCH*** debugging, if utilizing MPI__COMPILER + # https://cmake.org/cmake/help/latest/module/FindMPI.html#variables-for-locating-mpi + # the find logic makes a mess of things by utilizing -show[me] + # Which may or may not get polluted by the environment + find_package( MPI REQUIRED COMPONENTS Fortran C ) + add_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}> + ) + endif() + + if ( DEFINED WRF_MPI_C_FLAGS AND NOT "${WRF_MPI_C_FLAGS}" STREQUAL "" ) + add_compile_options( + $<$,${WRF_MPI_C_FLAGS}> + ) + endif() + # set( CMAKE_FIND_DEBUG_MODE FALSE ) + # message( STATUS "[AFTER] MPI_C_COMPILER : ${MPI_C_COMPILER}") + # message( STATUS "[AFTER] MPI_Fortran_COMPILER : ${MPI_Fortran_COMPILER}") + # message( STATUS "[AFTER] MPI_LIBRARIES : ${MPI_LIBRARIES}") + # message( STATUS "[AFTER] MPI_LIBRARY : ${MPI_LIBRARY}") + # message( STATUS "[AFTER] MPI_EXTRA_LIBRARY : ${MPI_EXTRA_LIBRARY}") + # message( STATUS "[AFTER] MPI_COMPILE_FLAGS : ${MPI_COMPILE_FLAGS}") + # message( STATUS "[AFTER] MPI_INCLUDE_PATH : ${MPI_INCLUDE_PATH}") + # message( STATUS "[AFTER] MPI_LINK_FLAGS : ${MPI_LINK_FLAGS}") + # message( STATUS "[AFTER] MPI_LIBRARIES : ${MPI_LIBRARIES}") +endif() + +if ( ${USE_OPENMP} ) + find_package( OpenMP REQUIRED COMPONENTS Fortran C ) + add_compile_definitions( USE_OPENMP=1 SM_PARALLEL ) +endif() + if ( ${USE_M4} ) find_program( M4_PROGRAM @@ -291,9 +346,7 @@ if ( ${USE_M4} ) ) endif() -# Provided by cmake natively -find_package( ZLIB REQUIRED ) -find_package( CURL REQUIRED ) + # HDF5 has some funky weirdness between versions where the casing has changed # Optional @@ -327,16 +380,17 @@ endif() find_package( pnetCDF QUIET ) -if ( USE_MPI ) - find_package( MPI REQUIRED COMPONENTS Fortran C ) - add_compile_definitions( USE_MPI=1 DM_PARALLEL=1 ) -endif() - -if ( USE_OPENMP ) - find_package( OpenMP REQUIRED COMPONENTS Fortran C ) - add_compile_definitions( USE_OPENMP=1 SM_PARALLEL=1 ) -endif() +# Attempt to find zlib packaged with netcdf first +set( ZLIB_ROOT ${netCDF_PREFIX} ) +find_package( ZLIB REQUIRED ) +find_package( CURL REQUIRED ) +################################################################################ +## +## Configuration checks for features & intrinsices +## +################################################################################ +add_subdirectory( confcheck ) ################################################################################ ## @@ -502,6 +556,10 @@ target_include_directories( ${PROJECT_SOURCE_DIR}/external/io_grib_share ${PROJECT_SOURCE_DIR}/external/io_netcdf ${PROJECT_SOURCE_DIR}/external/io_int + + # Found Packages not handled throough :: imported target + ${netCDF_INCLUDE_DIRS} + ${pnetCDF_INCLUDE_DIRS} ) # Add directly to core @@ -529,17 +587,27 @@ set_target_properties( PROPERTIES # Just dump everything in here Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/modules/ - Fortran_FORMAT FREE + Fortran_FORMAT FREE + # INSTALL_RPATH ${netCDF_LIBRARY_DIR} + # ${pnetCDF_LIBRARY_DIR} + # ${} ) - +message( STATUS "pnetCDF_LIBRARIES ${pnetCDF_LIBRARIES}") target_link_libraries( ${PROJECT_NAME}_Core PRIVATE ${netCDF_LIBRARIES} + ${pnetCDF_LIBRARIES} $<$:$> + MPI::MPI_Fortran $<$:$> # This will add in target dependencies if they exist $ + $ + $ + $ + $ + # "External" io libs esmf_time_f90 diff --git a/arch/configure_reader.py b/arch/configure_reader.py new file mode 100755 index 0000000000..8deae9b567 --- /dev/null +++ b/arch/configure_reader.py @@ -0,0 +1,292 @@ +#!/usr/bin/env python3 + +import sys +import re +import inspect +import platform + +archBlock = re.compile( r"(?:#[ ]*)(ARCH(?:.*\n)*?)(?:#{5,})", re.I ) +kvPair = re.compile( r"^(\w+)(?:[ \t]*=[ \t]*)(.*?)$", re.I | re.M ) +# Make this gnarly and complicated since configure.defaults has no standard formatting +# v start v OS V typical v MACOS +osAndArch = re.compile( r"^ARCH[ ]+(\w+)[ ]+((?:\w+.*?),|(?:[(].*?[)]))", re.I ) +# Just grab the first two words, thats what you get +osAndArchAlt = re.compile( r"^ARCH[ ]+(\w+)[ ]+(\w+)", re.I ) + +referenceVar = re.compile( r"[$][(](\w+)[)]", re.I ) + +class Stanza(): + + def __init__( self, lines ) : + self.lines_ = lines + self.os_ = None + self.archs_ = [] + self.kvPairs_ = {} + + def parse( self ) : + # First get os & archs + osarchMatch = osAndArch.match( self.lines_ ) + + if osarchMatch is None : + osarchMatch = osAndArchAlt.match( self.lines_ ) + if osarchMatch is None : + print( "Could not find OS and architecture info in " + self.lines_.partition("\n")[0] ) + + self.os_ = osarchMatch.group(1) + self.archs_ = osarchMatch.group(2).strip(",").split( " " ) + + for kvPairMatch in kvPair.finditer( self.lines_ ) : + self.kvPairs_[ kvPairMatch.group(1) ] = kvPairMatch.group(2) + self.removeComments( kvPairMatch.group(1) ) + + # Now sanitize + self.sanitize() + + def dereference( self, field, fatal=False ) : + if field in self.kvPairs_ : + prevField = self.kvPairs_[field] + + for refVarIter in referenceVar.finditer( prevField ) : + if refVarIter is not None : + # Grab group 1 and check that it is in our kv pairs + refVar = refVarIter.group(1) + if refVar not in self.kvPairs_ : + if fatal : + print( "Could not rereference : " + refVar ) + exit(1) + else: + continue + + # Recursively deref + self.dereference( refVar, fatal ) + + # Replace in original + self.kvPairs_[field] = self.kvPairs_[field].replace( + "$({var})".format( var=refVar ), + self.kvPairs_[refVar] + ) + + def removeReferences( self, field, specifics=[] ) : + if field in self.kvPairs_ : + if specifics : + for specific in specifics : + self.kvPairs_[ field ] = self.kvPairs_[ field ].replace( + "$({var})".format( var=specific ), + "" + ) + else : + self.kvPairs_[ field ] = referenceVar.sub( "", self.kvPairs_[ field ] ) + + + def removeComments( self, field ) : + if field in self.kvPairs_ : + self.kvPairs_[ field ] = self.kvPairs_[ field ].split( "#", 1 )[0] + + def splitIntoFieldAndFlags( self, field ) : + # Fix flags being mixed with programs + if field in self.kvPairs_ : + fieldValue = self.kvPairs_[ field ] + + self.kvPairs_[field] = fieldValue.partition(" ")[0] + self.kvPairs_[field + "_FLAGS"] = fieldValue.partition(" ")[1] + + def sanitize( self ) : + # Fix problematic variables + self.dereference( "DM_FC" ) + self.dereference( "DM_CC" ) + self.removeReferences( "FCBASEOPTS_NO_G" ) + # Get rid of all these mixed up flags, these are handled by cmake natively or + # just in the wrong place + self.removeReferences( "FCBASEOPTS", [ "FCDEBUG", "FORMAT_FREE", "BYTESWAPIO", ] ) + # Now deref + self.dereference( "FCBASEOPTS" ) + + # Now fix certain ones that are mixing programs with flags all mashed into one option + self.splitIntoFieldAndFlags( "DM_FC" ) + self.splitIntoFieldAndFlags( "DM_CC" ) + self.splitIntoFieldAndFlags( "M4" ) + + # Now deref all the rest + for key in self.kvPairs_ : + self.dereference( key ) + # And for final measure strip + self.kvPairs_[ key ] = self.kvPairs_[ key ].strip() + + def __str__( self ): + # base = """OS {os:<8} ARCHITECTURES {archs:<20} + # >> SFC = {SFC:<12} + # >> SCC = {SCC:<12} + # >> CCOMP = {CCOMP:<12} + # >> DM_FC = {DM_FC:<12} + # >> DM_CC = {DM_CC:<12} + # """ + base = """{rec} {os:<10} {SFC:<11} / {SCC:<11} / {CCOMP:<11} / {DM_FC:<11} / {DM_CC:<11}""" + text = inspect.cleandoc( base ).format( + os=str(self.os_), + rec=( "!!" if platform.system().lower() != self.os_.lower() else "Ok" ), + # archs=str(self.archs_), + SFC=str( self.kvPairs_["SFC"].partition(" ")[0] ), + SCC=str( self.kvPairs_["SCC"].partition(" ")[0] ), + CCOMP=str( self.kvPairs_["CCOMP"].partition(" ")[0] ), + DM_FC=str( self.kvPairs_["DM_FC"].partition(" ")[0] ), + DM_CC=str( self.kvPairs_["DM_CC"].partition(" ")[0] ) + ) + # text += "\n" + "\n".join( [ "{key:<18} = {value}".format( key=key, value=value) for key, value in self.kvPairs_.items() ] ) + return text + + @staticmethod + def findFirstDifference( rhStanza, lhStanza, maxLength=32 ) : + diff = False + value = "" + valuesToCheck = [ + "ARCH_LOCAL", + "BYTESWAPIO", + "CFLAGS_LOCAL", + "DM_CC", + "DM_FC", + "DM_FC_FLAGS", + "DM_CC_FLAGS", + "FCBASEOPTS", + "FCDEBUG", + "FCNOOPT", + "FCOPTIM", + "M4_FLAGS", + "SCC", + "SFC" + ] + for rhKey, rhValue in rhStanza.kvPairs_.items() : + if rhKey in valuesToCheck and rhKey in lhStanza.kvPairs_ : + # Qualifies for difference + if rhValue != lhStanza.kvPairs_[rhKey] : + diff = True + value = "{key:<12} = {value}".format( key=rhKey, value=lhStanza.kvPairs_[rhKey] ) + + # Truncate + value = ( value[:maxLength] + "..." ) if len( value ) > maxLength else value + + return diff, value + + +def getStringOptionSelection( topLevelCmake, searchString ) : + topLevelCmakeFP = open( topLevelCmake, "r" ) + topLevelCmakeLines = topLevelCmakeFP.read() + topLevelCmakeFP.close() + + stringOptionsMatch = re.search( + r"set\s*[(]\s*" + searchString + r"\s*(.*?)[)]", + topLevelCmakeLines, + re.I | re.S | re.M + ) + if stringOptionsMatch is None : + print( "Syntax error in parsing " + searchString + " from " + topLevelCmake ) + exit(1) + + options = [ option.split( "#", 1 )[0].strip() for option in stringOptionsMatch.group(1).split( "\n" ) ] + # Weed out empties + options = [ option for option in options if option ] + + optionsFmt = ", ".join( [ "{idx} : {opt}".format( idx=options.index( opt ), opt=opt ) for opt in options ] ) + selection = int( input( "Select string options [0-{max}] ({opts}) : ".format( max=len(options)-1, opts=optionsFmt ) ) ) + + if selection < 0 or selection > len(options) : + print( "Invalid option selection for " + searchString + "!" ) + exit(1) + + return options[selection] + +def generateCMakeToolChainFile( cmakeToolChainTemplate, output, stanza, optionsDict={} ) : + cmakeToolChainTemplateFP = open( cmakeToolChainTemplate, "r" ) + cmakeToolChainTemplateLines = cmakeToolChainTemplateFP.read() + cmakeToolChainTemplateFP.close() + + configStanza = cmakeToolChainTemplateLines.format( + ARCH_LOCAL=stanza.kvPairs_["ARCH_LOCAL"], + BYTESWAPIO=stanza.kvPairs_["BYTESWAPIO"], + CFLAGS_LOCAL=stanza.kvPairs_["CFLAGS_LOCAL"], + DM_CC=stanza.kvPairs_["DM_CC"], + DM_FC=stanza.kvPairs_["DM_FC"], + DM_FC_FLAGS=stanza.kvPairs_["DM_FC_FLAGS"], + DM_CC_FLAGS=stanza.kvPairs_["DM_CC_FLAGS"], + FCBASEOPTS=stanza.kvPairs_["FCBASEOPTS"], + FCDEBUG=stanza.kvPairs_["FCDEBUG"], + FCNOOPT=stanza.kvPairs_["FCNOOPT"], + FCOPTIM=stanza.kvPairs_["FCOPTIM"], + M4_FLAGS=stanza.kvPairs_["M4_FLAGS"], + SCC=stanza.kvPairs_["SCC"], + SFC=stanza.kvPairs_["SFC"] + ) + + # Extra stufff not from stanza but options + fmtOption = "set( {opt:<32} {value:<12} CACHE STRING \"Set by configuration\" FORCE )" + configStanza += "\n" + "\n".join( [ fmtOption.format( opt=key, value=value ) for key, value in optionsDict.items() ] ) + + outputFP = open( output, "w" ) + outputFP.write( configStanza ) + outputFP.close() + +def main() : + configFile = sys.argv[1] + cmakeTemplateFile = sys.argv[2] + cmakeConfigFile = sys.argv[3] + cmakeFile = sys.argv[4] + + coreOption = getStringOptionSelection( cmakeFile, "WRF_CORE_OPTIONS" ) + nestingOption = getStringOptionSelection( cmakeFile, "WRF_NESTING_OPTIONS" ) + caseOption = getStringOptionSelection( cmakeFile, "WRF_CASE_OPTIONS" ) + + # These are yes + yesValues = [ "yes", "y", "true", "1" ] + + #!TODO Expand this for all wrf options + useMPI = input( "[DM] Use MPI? [Y/n] : " ).lower() in yesValues + useOpenMP = input( "[SM] Use OpenMP? [Y/n] : " ).lower() in yesValues + + + fp = open( configFile, 'r' ) + lines = fp.read() + fp.close() + + # Now grab the blocks and parse + stanzas = [] + uniqueConfigs = {} + stanzaIdx = 0 + for stanzaBlock in archBlock.finditer( lines ) : + stanza = Stanza( stanzaBlock.group(1) ) + stanza.parse() + + stanzas.append( stanza ) + stanzaConfig = str( stanza ) + stanzaId = "{idx:<3} ".format( idx=stanzaIdx ) + if stanzaConfig not in uniqueConfigs : + uniqueConfigs[ stanzaConfig ] = { "stanza" : stanza, "idx" : stanzaIdx } + print( stanzaId + stanzaConfig + "[first entry]" ) + else : + diff, value = Stanza.findFirstDifference( uniqueConfigs[ stanzaConfig ]["stanza"], stanza ) + if diff : + print( stanzaId + stanzaConfig + "@{idx} diff => {value}".format( idx=uniqueConfigs[ stanzaConfig ][ "idx" ], value=value ) ) + else : + print( stanzaId + stanzaConfig + "[no difference]" ) + stanzaIdx += 1 + + print( "!! - Not recommended for your system" ) + + idxSelection = int( input( "Select configuration [0-{stop}] (note !!) : ".format( stop=( stanzaIdx-1) ) ) ) + if idxSelection < 0 or idxSelection > stanzaIdx - 1 : + print( "Invalid configuration selection!" ) + exit(1) + + additionalOptions = { + "WRF_CORE" : coreOption, + "WRF_NESTING" : nestingOption, + "WRF_CASE" : caseOption, + "USE_MPI" : "ON" if useMPI else "OFF", + "USE_OPENMP" : "ON" if useMPI else "OFF" + } + generateCMakeToolChainFile( cmakeTemplateFile, cmakeConfigFile, stanzas[idxSelection], additionalOptions ) + + + + +if __name__ == '__main__' : + main() + diff --git a/cmake/template/arch_config.cmake b/cmake/template/arch_config.cmake new file mode 100644 index 0000000000..ee7e800aa7 --- /dev/null +++ b/cmake/template/arch_config.cmake @@ -0,0 +1,21 @@ +# https://cmake.org/cmake/help/latest/module/FindMPI.html#variables-for-locating-mpi +set( MPI_Fortran_COMPILER "{DM_FC}" ) +set( MPI_C_COMPILER "{DM_CC}" ) + +set( CMAKE_Fortran_COMPILER "{SFC}" ) +set( CMAKE_C_COMPILER "{SCC}" ) + +set( CMAKE_Fortran_FLAGS "{FCBASEOPTS} {BYTESWAPIO}" ) +set( CMAKE_C_FLAGS "{CFLAGS_LOCAL}" ) + +set( CMAKE_Fortran_FLAGS_DEBUG "{FCDEBUG}" ) + +set( CMAKE_Fortran_FLAGS_RELEASE "{FCOPTIM}" ) + +# 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 diff --git a/compile_new b/compile_new new file mode 100755 index 0000000000..758e4a8081 --- /dev/null +++ b/compile_new @@ -0,0 +1,5 @@ +#!/bin/bash +# Meant to be run at the top level + +# Now run cmake +cmake --build _build --target install $* \ No newline at end of file diff --git a/configure_new b/configure_new new file mode 100755 index 0000000000..abff460f77 --- /dev/null +++ b/configure_new @@ -0,0 +1,10 @@ +#!/bin/bash +# Meant to be run at the top level +./arch/configure_reader.py \ + arch/configure.defaults \ + cmake/template/arch_config.cmake \ + wrf_config.cmake \ + CMakeLists.txt + +# Now run cmake +cmake -S . -B _build -DCMAKE_INSTALL_PREFIX=$PWD -DCMAKE_TOOLCHAIN_FILE=$PWD/wrf_config.cmake \ No newline at end of file From 577bddb3a54a6f9b7f398beb859511335e0726d2 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 24 May 2023 13:11:26 -0600 Subject: [PATCH 044/180] Fixing syntax for generator expression --- cmake/modules/FindpnetCDF.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/modules/FindpnetCDF.cmake b/cmake/modules/FindpnetCDF.cmake index fbf1745a6b..6e3a0833f2 100644 --- a/cmake/modules/FindpnetCDF.cmake +++ b/cmake/modules/FindpnetCDF.cmake @@ -62,8 +62,8 @@ else() set( pnetCDF_LIBRARIES $<$:${pnetCDF_LIBRARY}> - $<$:$:${pnetCDF_LIBRARY}> - $<$:$:${pnetCDF_LIBRARY}> + $<$:$<$:${pnetCDF_LIBRARY}>> + $<$:$<$:${pnetCDF_LIBRARY}>> ) set( pnetCDF_INCLUDE_DIRS ${pnetCDF_INCLUDE_DIR} ) endif() From 33c7e80ce7d4b6ac08d29e1b739fa48445899f16 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 24 May 2023 13:11:55 -0600 Subject: [PATCH 045/180] Removing lingering unprotected link library --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4f8e6104d..f73b09b827 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -598,7 +598,6 @@ target_link_libraries( ${PROJECT_NAME}_Core ${netCDF_LIBRARIES} ${pnetCDF_LIBRARIES} $<$:$> - MPI::MPI_Fortran $<$:$> # This will add in target dependencies if they exist From 9c0979e168d974a7eda916f613f304b514b91645 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 24 May 2023 14:12:21 -0600 Subject: [PATCH 046/180] Cleaning up --- CMakeLists.txt | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f73b09b827..957b1c5259 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -290,20 +290,12 @@ print_option( WRFIO_NCD_NO_LARGE_FILE_SUPPORT 36 ) ## ################################################################################ if ( ${USE_MPI} ) - # message( STATUS "[BEFORE] MPI_C_COMPILER : ${MPI_C_COMPILER}") - # message( STATUS "[BEFORE] MPI_Fortran_COMPILER : ${MPI_Fortran_COMPILER}") - # message( STATUS "[BEFORE] MPI_LIBRARIES : ${MPI_LIBRARIES}") - # message( STATUS "[BEFORE] MPI_LIBRARY : ${MPI_LIBRARY}") - # message( STATUS "[BEFORE] MPI_EXTRA_LIBRARY : ${MPI_EXTRA_LIBRARY}") - # message( STATUS "[BEFORE] MPI_COMPILE_FLAGS : ${MPI_COMPILE_FLAGS}") - # message( STATUS "[BEFORE] MPI_INCLUDE_PATH : ${MPI_INCLUDE_PATH}") - # message( STATUS "[BEFORE] MPI_LINK_FLAGS : ${MPI_LINK_FLAGS}") - # message( STATUS "[BEFORE] MPI_LIBRARIES : ${MPI_LIBRARIES}") - # set( CMAKE_FIND_DEBUG_MODE TRUE ) # Through ***MUCH*** debugging, if utilizing MPI__COMPILER # https://cmake.org/cmake/help/latest/module/FindMPI.html#variables-for-locating-mpi # the find logic makes a mess of things by utilizing -show[me] # Which may or may not get polluted by the environment + # 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 @@ -321,16 +313,6 @@ if ( ${USE_MPI} ) $<$,${WRF_MPI_C_FLAGS}> ) endif() - # set( CMAKE_FIND_DEBUG_MODE FALSE ) - # message( STATUS "[AFTER] MPI_C_COMPILER : ${MPI_C_COMPILER}") - # message( STATUS "[AFTER] MPI_Fortran_COMPILER : ${MPI_Fortran_COMPILER}") - # message( STATUS "[AFTER] MPI_LIBRARIES : ${MPI_LIBRARIES}") - # message( STATUS "[AFTER] MPI_LIBRARY : ${MPI_LIBRARY}") - # message( STATUS "[AFTER] MPI_EXTRA_LIBRARY : ${MPI_EXTRA_LIBRARY}") - # message( STATUS "[AFTER] MPI_COMPILE_FLAGS : ${MPI_COMPILE_FLAGS}") - # message( STATUS "[AFTER] MPI_INCLUDE_PATH : ${MPI_INCLUDE_PATH}") - # message( STATUS "[AFTER] MPI_LINK_FLAGS : ${MPI_LINK_FLAGS}") - # message( STATUS "[AFTER] MPI_LIBRARIES : ${MPI_LIBRARIES}") endif() if ( ${USE_OPENMP} ) @@ -557,7 +539,7 @@ target_include_directories( ${PROJECT_SOURCE_DIR}/external/io_netcdf ${PROJECT_SOURCE_DIR}/external/io_int - # Found Packages not handled throough :: imported target + # Found Packages not handled through :: imported target ${netCDF_INCLUDE_DIRS} ${pnetCDF_INCLUDE_DIRS} ) From c59908caaa66eba461c7cf1838a5a9e51b08c4f4 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 24 May 2023 15:56:24 -0600 Subject: [PATCH 047/180] Adding double fp64 link data --- test/em_real/CMakeLists.txt | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/test/em_real/CMakeLists.txt b/test/em_real/CMakeLists.txt index 612d71c6f5..00ec19b73c 100644 --- a/test/em_real/CMakeLists.txt +++ b/test/em_real/CMakeLists.txt @@ -85,4 +85,32 @@ wrf_link_files( SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} ) -#!TODO Add alternate double stuff \ No newline at end of file +wrf_link_file_new_name( + FILE ${PROJECT_SOURCE_DIR}/run/CAMtr_volume_mixing_ratio.SSP245 + NEW_NAME ${CMAKE_CURRENT_SOURCE_DIR}/CAMtr_volume_mixing_ratio + ) + + +if ( ${USE_DOUBLE} ) + + wrf_link_file_new_name( + FILE ${PROJECT_SOURCE_DIR}/run/ETAMPNEW_DATA_DBL + NEW_NAME ${CMAKE_CURRENT_SOURCE_DIR}/ETAMPNEW_DATA + ) + wrf_link_file_new_name( + FILE ${PROJECT_SOURCE_DIR}/run/ETAMPNEW_DATA.expanded_rain_DBL + NEW_NAME ${CMAKE_CURRENT_SOURCE_DIR}/ETAMPNEW_DATA.expanded_rain + ) + wrf_link_file_new_name( + FILE ${PROJECT_SOURCE_DIR}/run/RRTM_DATA_DBL + NEW_NAME ${CMAKE_CURRENT_SOURCE_DIR}/RRTM_DATA + ) + wrf_link_file_new_name( + FILE ${PROJECT_SOURCE_DIR}/run/RRTMG_LW_DATA_DBL + NEW_NAME ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG_LW_DATA + ) + wrf_link_file_new_name( + FILE ${PROJECT_SOURCE_DIR}/run/RRTMG_SW_DATA_DBL + NEW_NAME ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG_SW_DATA + ) +endif() From 588fa408a85d678efe2b9d4b8c579129991d609c Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 24 May 2023 17:21:00 -0600 Subject: [PATCH 048/180] Symlinks for all test cases except for esmf coupling --- test/em_b_wave/CMakeLists.txt | 11 +++++++++++ test/em_convrad/CMakeLists.txt | 18 ++++++++++++++++++ test/em_fire/CMakeLists.txt | 11 +++++++++++ test/em_grav2d_x/CMakeLists.txt | 11 +++++++++++ test/em_heldsuarez/CMakeLists.txt | 11 +++++++++++ test/em_hill2d_x/CMakeLists.txt | 11 +++++++++++ test/em_les/CMakeLists.txt | 11 +++++++++++ test/em_quarter_ss/CMakeLists.txt | 22 ++++++++++++++++++++++ test/em_scm_xy/CMakeLists.txt | 17 +++++++++++++++++ test/em_seabreeze2d_x/CMakeLists.txt | 14 ++++++++++++++ test/em_squall2d_x/CMakeLists.txt | 11 +++++++++++ test/em_squall2d_y/CMakeLists.txt | 11 +++++++++++ test/em_tropical_cyclone/CMakeLists.txt | 13 +++++++++++++ 13 files changed, 172 insertions(+) create mode 100644 test/em_b_wave/CMakeLists.txt create mode 100644 test/em_convrad/CMakeLists.txt create mode 100644 test/em_fire/CMakeLists.txt create mode 100644 test/em_grav2d_x/CMakeLists.txt create mode 100644 test/em_heldsuarez/CMakeLists.txt create mode 100644 test/em_hill2d_x/CMakeLists.txt create mode 100644 test/em_les/CMakeLists.txt create mode 100644 test/em_quarter_ss/CMakeLists.txt create mode 100644 test/em_scm_xy/CMakeLists.txt create mode 100644 test/em_seabreeze2d_x/CMakeLists.txt create mode 100644 test/em_squall2d_x/CMakeLists.txt create mode 100644 test/em_squall2d_y/CMakeLists.txt create mode 100644 test/em_tropical_cyclone/CMakeLists.txt diff --git a/test/em_b_wave/CMakeLists.txt b/test/em_b_wave/CMakeLists.txt new file mode 100644 index 0000000000..fa465239fb --- /dev/null +++ b/test/em_b_wave/CMakeLists.txt @@ -0,0 +1,11 @@ +# These are just rules for this case, could be named CMakeLists.txt or something +# like install_rules.cmake, whatever you want really +wrf_link_targets( + TARGETS ideal wrf + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) + +wrf_link_files( + FILES ${PROJECT_SOURCE_DIR}/run/README.namelist + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) \ No newline at end of file diff --git a/test/em_convrad/CMakeLists.txt b/test/em_convrad/CMakeLists.txt new file mode 100644 index 0000000000..b9b76908d2 --- /dev/null +++ b/test/em_convrad/CMakeLists.txt @@ -0,0 +1,18 @@ +# These are just rules for this case, could be named CMakeLists.txt or something +# like install_rules.cmake, whatever you want really +wrf_link_targets( + TARGETS ideal wrf + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) + +wrf_link_files( + FILES + ${PROJECT_SOURCE_DIR}/run/README.namelist + ${PROJECT_SOURCE_DIR}/run/LANDUSE.TBL + ${PROJECT_SOURCE_DIR}/run/RRTMG_LW_DATA + ${PROJECT_SOURCE_DIR}/run/RRTMG_SW_DATA + ${PROJECT_SOURCE_DIR}/run/ozone.formatted + ${PROJECT_SOURCE_DIR}/run/ozone_lat.formatted + ${PROJECT_SOURCE_DIR}/run/ozone_plev.formatted + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) \ No newline at end of file diff --git a/test/em_fire/CMakeLists.txt b/test/em_fire/CMakeLists.txt new file mode 100644 index 0000000000..fa465239fb --- /dev/null +++ b/test/em_fire/CMakeLists.txt @@ -0,0 +1,11 @@ +# These are just rules for this case, could be named CMakeLists.txt or something +# like install_rules.cmake, whatever you want really +wrf_link_targets( + TARGETS ideal wrf + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) + +wrf_link_files( + FILES ${PROJECT_SOURCE_DIR}/run/README.namelist + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) \ No newline at end of file diff --git a/test/em_grav2d_x/CMakeLists.txt b/test/em_grav2d_x/CMakeLists.txt new file mode 100644 index 0000000000..fa465239fb --- /dev/null +++ b/test/em_grav2d_x/CMakeLists.txt @@ -0,0 +1,11 @@ +# These are just rules for this case, could be named CMakeLists.txt or something +# like install_rules.cmake, whatever you want really +wrf_link_targets( + TARGETS ideal wrf + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) + +wrf_link_files( + FILES ${PROJECT_SOURCE_DIR}/run/README.namelist + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) \ No newline at end of file diff --git a/test/em_heldsuarez/CMakeLists.txt b/test/em_heldsuarez/CMakeLists.txt new file mode 100644 index 0000000000..fa465239fb --- /dev/null +++ b/test/em_heldsuarez/CMakeLists.txt @@ -0,0 +1,11 @@ +# These are just rules for this case, could be named CMakeLists.txt or something +# like install_rules.cmake, whatever you want really +wrf_link_targets( + TARGETS ideal wrf + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) + +wrf_link_files( + FILES ${PROJECT_SOURCE_DIR}/run/README.namelist + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) \ No newline at end of file diff --git a/test/em_hill2d_x/CMakeLists.txt b/test/em_hill2d_x/CMakeLists.txt new file mode 100644 index 0000000000..fa465239fb --- /dev/null +++ b/test/em_hill2d_x/CMakeLists.txt @@ -0,0 +1,11 @@ +# These are just rules for this case, could be named CMakeLists.txt or something +# like install_rules.cmake, whatever you want really +wrf_link_targets( + TARGETS ideal wrf + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) + +wrf_link_files( + FILES ${PROJECT_SOURCE_DIR}/run/README.namelist + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) \ No newline at end of file diff --git a/test/em_les/CMakeLists.txt b/test/em_les/CMakeLists.txt new file mode 100644 index 0000000000..fa465239fb --- /dev/null +++ b/test/em_les/CMakeLists.txt @@ -0,0 +1,11 @@ +# These are just rules for this case, could be named CMakeLists.txt or something +# like install_rules.cmake, whatever you want really +wrf_link_targets( + TARGETS ideal wrf + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) + +wrf_link_files( + FILES ${PROJECT_SOURCE_DIR}/run/README.namelist + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) \ No newline at end of file diff --git a/test/em_quarter_ss/CMakeLists.txt b/test/em_quarter_ss/CMakeLists.txt new file mode 100644 index 0000000000..60a6732c6b --- /dev/null +++ b/test/em_quarter_ss/CMakeLists.txt @@ -0,0 +1,22 @@ +# These are just rules for this case, could be named CMakeLists.txt or something +# like install_rules.cmake, whatever you want really +wrf_link_targets( + TARGETS ideal wrf + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) + +wrf_link_files( + FILES + ${PROJECT_SOURCE_DIR}/run/README.namelist + ${PROJECT_SOURCE_DIR}/run/bulkdens.asc_s_0_03_0_9 + ${PROJECT_SOURCE_DIR}/run/bulkradii.asc_s_0_03_0_9 + ${PROJECT_SOURCE_DIR}/run/capacity.asc + ${PROJECT_SOURCE_DIR}/run/coeff_p.asc + ${PROJECT_SOURCE_DIR}/run/coeff_q.asc + ${PROJECT_SOURCE_DIR}/run/constants.asc + ${PROJECT_SOURCE_DIR}/run/kernels.asc_s_0_03_0_9 + ${PROJECT_SOURCE_DIR}/run/kernels_z.asc + ${PROJECT_SOURCE_DIR}/run/masses.asc + ${PROJECT_SOURCE_DIR}/run/termvels.asc + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) \ No newline at end of file diff --git a/test/em_scm_xy/CMakeLists.txt b/test/em_scm_xy/CMakeLists.txt new file mode 100644 index 0000000000..bc2826b2de --- /dev/null +++ b/test/em_scm_xy/CMakeLists.txt @@ -0,0 +1,17 @@ +# These are just rules for this case, could be named CMakeLists.txt or something +# like install_rules.cmake, whatever you want really +wrf_link_targets( + TARGETS ideal wrf + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) + +wrf_link_files( + FILES + ${PROJECT_SOURCE_DIR}/run/README.namelist + ${PROJECT_SOURCE_DIR}/run/GENPARM.TBL + ${PROJECT_SOURCE_DIR}/run/LANDUSE.TBL + ${PROJECT_SOURCE_DIR}/run/SOILPARM.TBL + ${PROJECT_SOURCE_DIR}/run/VEGPARM.TBL + ${PROJECT_SOURCE_DIR}/run/RRTM_DATA + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) \ No newline at end of file diff --git a/test/em_seabreeze2d_x/CMakeLists.txt b/test/em_seabreeze2d_x/CMakeLists.txt new file mode 100644 index 0000000000..58a03a97a0 --- /dev/null +++ b/test/em_seabreeze2d_x/CMakeLists.txt @@ -0,0 +1,14 @@ +# These are just rules for this case, could be named CMakeLists.txt or something +# like install_rules.cmake, whatever you want really +wrf_link_targets( + TARGETS ideal wrf + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) + +wrf_link_files( + FILES + ${PROJECT_SOURCE_DIR}/run/README.namelist + ${PROJECT_SOURCE_DIR}/run/LANDUSE.TBL + ${PROJECT_SOURCE_DIR}/run/RRTM_DATA + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) \ No newline at end of file diff --git a/test/em_squall2d_x/CMakeLists.txt b/test/em_squall2d_x/CMakeLists.txt new file mode 100644 index 0000000000..fa465239fb --- /dev/null +++ b/test/em_squall2d_x/CMakeLists.txt @@ -0,0 +1,11 @@ +# These are just rules for this case, could be named CMakeLists.txt or something +# like install_rules.cmake, whatever you want really +wrf_link_targets( + TARGETS ideal wrf + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) + +wrf_link_files( + FILES ${PROJECT_SOURCE_DIR}/run/README.namelist + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) \ No newline at end of file diff --git a/test/em_squall2d_y/CMakeLists.txt b/test/em_squall2d_y/CMakeLists.txt new file mode 100644 index 0000000000..fa465239fb --- /dev/null +++ b/test/em_squall2d_y/CMakeLists.txt @@ -0,0 +1,11 @@ +# These are just rules for this case, could be named CMakeLists.txt or something +# like install_rules.cmake, whatever you want really +wrf_link_targets( + TARGETS ideal wrf + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) + +wrf_link_files( + FILES ${PROJECT_SOURCE_DIR}/run/README.namelist + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) \ No newline at end of file diff --git a/test/em_tropical_cyclone/CMakeLists.txt b/test/em_tropical_cyclone/CMakeLists.txt new file mode 100644 index 0000000000..0c385179d4 --- /dev/null +++ b/test/em_tropical_cyclone/CMakeLists.txt @@ -0,0 +1,13 @@ +# These are just rules for this case, could be named CMakeLists.txt or something +# like install_rules.cmake, whatever you want really +wrf_link_targets( + TARGETS ideal wrf + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) + +wrf_link_files( + FILES + ${PROJECT_SOURCE_DIR}/run/README.namelist + ${PROJECT_SOURCE_DIR}/run/LANDUSE.TBL + SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + ) \ No newline at end of file From a271b3f3be9010de2cd6b0531833d8cc5bce542a Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 12 Jun 2023 16:39:01 -0600 Subject: [PATCH 049/180] Adding cmake package config template --- cmake/template/WRFConfig.cmake.in | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 cmake/template/WRFConfig.cmake.in diff --git a/cmake/template/WRFConfig.cmake.in b/cmake/template/WRFConfig.cmake.in new file mode 100644 index 0000000000..d17eef1bd7 --- /dev/null +++ b/cmake/template/WRFConfig.cmake.in @@ -0,0 +1,46 @@ +# WRF CMake Package + +@PACKAGE_INIT@ + +include( "${CMAKE_CURRENT_LIST_DIR}/@EXPORT_NAME@Targets.cmake" ) + +set( WRF_VERSION @PROJECT_VERSION@ ) + +# Options WRF was built with +set( WRF_WRF_CORE @WRF_CORE@ ) +set( WRF_WRF_NESTING @WRF_NESTING@ ) +set( WRF_WRF_CASE @WRF_CASE@ ) + +set( WRF_USE_DOUBLE @USE_DOUBLE@ ) +set( WRF_USE_MPI @USE_MPI@ ) +set( WRF_USE_OPENMP @USE_OPENMP@ ) +set( WRF_ENABLE_CHEM @ENABLE_CHEM@ ) +set( WRF_ENABLE_CMAQ @ENABLE_CMAQ@ ) +set( WRF_ENABLE_KPP @ENABLE_KPP@ ) +set( WRF_ENABLE_DFI_RADAR @ENABLE_DFI_RADAR@ ) +set( WRF_ENABLE_TITAN @ENABLE_TITAN@ ) +set( WRF_ENABLE_MARS @ENABLE_MARS@ ) +set( WRF_ENABLE_VENUS @ENABLE_VENUS@ ) +set( WRF_ENABLE_VENUS @ENABLE_VENUS@ ) +set( WRF_ENABLE_TERRAIN @ENABLE_TERRAIN@ ) +set( WRF_ENABLE_CLM @ENABLE_CLM@ ) +set( WRF_USE_ALLOCATABLES @USE_ALLOCATABLES@ ) +set( WRF_wrfmodel @wrfmodel@ ) +set( WRF_GRIB1 @GRIB1@ ) +set( WRF_INTIO @INTIO@ ) +set( WRF_KEEP_INT_AROUND @KEEP_INT_AROUND@ ) +set( WRF_LIMIT_ARGS @LIMIT_ARGS@ ) +set( WRF_FORCE_NETCDF_CLASSIC @FORCE_NETCDF_CLASSIC@ ) +set( WRF_BUILD_RRTMG_FAST @BUILD_RRTMG_FAST@ ) +set( WRF_BUILD_RRTMK @BUILD_RRTMK@ ) +set( WRF_BUILD_SBM_FAST @BUILD_SBM_FAST@ ) +set( WRF_SHOW_ALL_VARS_USED @SHOW_ALL_VARS_USED@ ) +set( WRF_WRFIO_NCD_NO_LARGE_FILE_SUPPORT @WRFIO_NCD_NO_LARGE_FILE_SUPPORT@ ) + + +find_package( netCDF REQUIRED ) +# Attempt to find zlib packaged with netcdf first +set( ZLIB_ROOT ${netCDF_PREFIX} ) +find_package( ZLIB REQUIRED ) + +check_required_components( "@EXPORT_NAME@" ) \ No newline at end of file From b5b0c8c9293add5b2346b3215a898f0beb61b7e9 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 12 Jun 2023 16:39:32 -0600 Subject: [PATCH 050/180] Grabbing version from README --- cmake/wrf_get_version.cmake | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 cmake/wrf_get_version.cmake diff --git a/cmake/wrf_get_version.cmake b/cmake/wrf_get_version.cmake new file mode 100644 index 0000000000..668c9d6941 --- /dev/null +++ b/cmake/wrf_get_version.cmake @@ -0,0 +1,11 @@ +# WRF Macro for getting version, this *should* be replaced with a better versioning scheme +macro( wrf_get_version WRF_VERSION_FILE ) + file( STRINGS ${WRF_VERSION_FILE} WRF_VERSION_FILE_OUTPUT ) + + list( POP_FRONT WRF_VERSION_FILE_OUTPUT FIRST_LINE ) + string( REPLACE " " ";" FIRST_LINE_LIST ${FIRST_LINE} ) + list( GET FIRST_LINE_LIST -1 WRF_VERSION ) + + set( PROJECT_VERSION ${WRF_VERSION} ) + message( STATUS "Setting project version to ${PROJECT_VERSION}" ) +endmacro() From 6859ab3eef150938440f5db87e3ecd273df8b680 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 12 Jun 2023 16:39:57 -0600 Subject: [PATCH 051/180] Better message output --- cmake/modules/FindnetCDF.cmake | 2 +- cmake/modules/FindpnetCDF.cmake | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/modules/FindnetCDF.cmake b/cmake/modules/FindnetCDF.cmake index 078e1c793d..f9051f0792 100644 --- a/cmake/modules/FindnetCDF.cmake +++ b/cmake/modules/FindnetCDF.cmake @@ -17,10 +17,10 @@ find_program( QUIET ) -message( STATUS "NETCDF_PROGRAM : ${NETCDF_PROGRAM}" ) if ( ${NETCDF_PROGRAM} MATCHES "-NOTFOUND$" ) message( STATUS "No nc-config found" ) else() + message( STATUS "Found NETCDF_PROGRAM : ${NETCDF_PROGRAM}" ) execute_process( COMMAND ${NETCDF_PROGRAM} --includedir OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_INCLUDE_DIR ) execute_process( COMMAND ${NETCDF_PROGRAM} --libdir OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_LIBRARY_DIR ) diff --git a/cmake/modules/FindpnetCDF.cmake b/cmake/modules/FindpnetCDF.cmake index 6e3a0833f2..3db3c9dedf 100644 --- a/cmake/modules/FindpnetCDF.cmake +++ b/cmake/modules/FindpnetCDF.cmake @@ -20,6 +20,7 @@ find_program( if ( ${PNETCDF_PROGRAM} MATCHES "-NOTFOUND$" ) message( STATUS "No pnetcdf-config found : ${PNETCDF_PROGRAM}" ) else() + message( STATUS "Found PNETCDF_PROGRAM : ${PNETCDF_PROGRAM}" ) execute_process( COMMAND ${PNETCDF_PROGRAM} --includedir OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE pnetCDF_INCLUDE_DIR ) execute_process( COMMAND ${PNETCDF_PROGRAM} --libdir OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE pnetCDF_LIBRARY_DIR ) From be1f37d11767f81809b02f0bfbf97eaa96b90440 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 12 Jun 2023 16:40:41 -0600 Subject: [PATCH 052/180] Fixing link installs --- cmake/wrf_case_setup.cmake | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/cmake/wrf_case_setup.cmake b/cmake/wrf_case_setup.cmake index 2e1fc5914c..3f2910a7cf 100644 --- a/cmake/wrf_case_setup.cmake +++ b/cmake/wrf_case_setup.cmake @@ -24,6 +24,7 @@ macro( wrf_link_targets ) message( STATUS \"Creating symlinks for $\" ) execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink ${WRF_LINK_OLD_BASE_PATH}/$ ${WRF_LINK_SYM_PATH}/$ ) " + COMPONENT links ) endforeach() @@ -44,17 +45,20 @@ macro( wrf_link_files ) ) foreach ( WRF_LINK_FILE ${WRF_LINK_FILES} ) - + # Generate install code for each file, this could be done in a simpler manner # with regular commands but to preserve order of operations it will be done via install( CODE ... ) # https://stackoverflow.com/a/56528615 get_filename_component( WRF_LINK_FULL_FILE ${WRF_LINK_FILE} REALPATH ) get_filename_component( WRF_LINK_FILE_ONLY ${WRF_LINK_FILE} NAME ) + # Left here for debug purposes, may want to turn this into a trace-level debug msg + # message( "Generating install commands for ${WRF_LINK_FILE_ONLY} into ${WRF_LINK_SYM_PATH}" ) install( CODE " message( STATUS \"Creating symlinks for ${WRF_LINK_FILE_ONLY}\" ) execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink ${WRF_LINK_FULL_FILE} ${WRF_LINK_SYM_PATH}/${WRF_LINK_FILE_ONLY} ) " + COMPONENT links ) endforeach() @@ -74,21 +78,23 @@ macro( wrf_link_file_new_name ) ${ARGN} ) - foreach ( WRF_LINK_FILE ${WRF_LINK_FILES} ) - - # Generate install code for each file, this could be done in a simpler manner - # with regular commands but to preserve order of operations it will be done via install( CODE ... ) - # https://stackoverflow.com/a/56528615 - get_filename_component( WRF_LINK_FULL_FILE ${WRF_LINK_FILE} REALPATH ) - get_filename_component( WRF_LINK_FILE_ONLY ${WRF_LINK_FILE} NAME ) - install( - CODE " - message( STATUS \"Creating symlinks for ${WRF_LINK_FILE_ONLY}\" ) - execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink ${WRF_LINK_FULL_FILE} ${WRF_LINK_SYM_PATH}/${WRF_LINK_FILE_ONLY} ) - " - ) - - endforeach() + + # Generate install code for each file, this could be done in a simpler manner + # with regular commands but to preserve order of operations it will be done via install( CODE ... ) + # https://stackoverflow.com/a/56528615 + get_filename_component( WRF_LINK_FULL_FILE ${WRF_LINK_FILE} REALPATH ) + get_filename_component( WRF_LINK_FILE_ONLY ${WRF_LINK_FILE} NAME ) + get_filename_component( WRF_LINK_NEW_NAME_FULL_FILE ${WRF_LINK_NEW_NAME} REALPATH ) + get_filename_component( WRF_LINK_NEW_NAME_FILE_ONLY ${WRF_LINK_NEW_NAME} NAME ) + # Left here for debug purposes, may want to turn this into a trace-level debug msg + # message( "Generating install commands for ${WRF_LINK_FILE_ONLY} to ${WRF_LINK_NEW_NAME_FILE_ONLY}" ) + install( + CODE " + message( STATUS \"Creating symlinks for ${WRF_LINK_FILE_ONLY} (rename ${WRF_LINK_NEW_NAME_FILE_ONLY})\" ) + execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink ${WRF_LINK_FULL_FILE} ${WRF_LINK_NEW_NAME_FULL_FILE} ) + " + COMPONENT links + ) endmacro() From 7401b9626fe414f5af303d1bcd69f84469ac8ccb Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 12 Jun 2023 16:42:12 -0600 Subject: [PATCH 053/180] Adding externals to export targets --- external/RSL_LITE/CMakeLists.txt | 1 + external/atm_ocn/CMakeLists.txt | 1 + external/esmf_time_f90/CMakeLists.txt | 1 + external/fftpack/fftpack5/CMakeLists.txt | 8 +--- external/io_adios2/CMakeLists.txt | 1 + external/io_esmf/CMakeLists.txt | 1 + external/io_grib1/CMakeLists.txt | 1 + external/io_grib1/MEL_grib1/CMakeLists.txt | 1 + external/io_grib1/WGRIB/CMakeLists.txt | 1 + external/io_grib1/grib1_util/CMakeLists.txt | 1 + external/io_grib2/CMakeLists.txt | 44 --------------------- external/io_grib2/bacio-1.3/CMakeLists.txt | 1 + external/io_grib2/g2lib/CMakeLists.txt | 1 + external/io_grib_share/CMakeLists.txt | 1 + external/io_netcdf/CMakeLists.txt | 1 + external/io_netcdfpar/CMakeLists.txt | 1 + external/io_pio/CMakeLists.txt | 1 + external/io_pnetcdf/CMakeLists.txt | 1 + external/ioapi_share/CMakeLists.txt | 11 ++++++ 19 files changed, 28 insertions(+), 51 deletions(-) diff --git a/external/RSL_LITE/CMakeLists.txt b/external/RSL_LITE/CMakeLists.txt index 0c3effc036..27382f77a8 100644 --- a/external/RSL_LITE/CMakeLists.txt +++ b/external/RSL_LITE/CMakeLists.txt @@ -43,6 +43,7 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} install( TARGETS ${FOLDER_COMPILE_TARGET} + EXPORT ${EXPORT_NAME}Targets RUNTIME DESTINATION bin/ ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ diff --git a/external/atm_ocn/CMakeLists.txt b/external/atm_ocn/CMakeLists.txt index 3756c80111..5f89ce0b03 100644 --- a/external/atm_ocn/CMakeLists.txt +++ b/external/atm_ocn/CMakeLists.txt @@ -39,6 +39,7 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} install( TARGETS ${FOLDER_COMPILE_TARGET} + EXPORT ${EXPORT_NAME}Targets RUNTIME DESTINATION bin/ ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ diff --git a/external/esmf_time_f90/CMakeLists.txt b/external/esmf_time_f90/CMakeLists.txt index 324c40e9bb..d0718a22a8 100644 --- a/external/esmf_time_f90/CMakeLists.txt +++ b/external/esmf_time_f90/CMakeLists.txt @@ -54,6 +54,7 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} install( TARGETS ${FOLDER_COMPILE_TARGET} + EXPORT ${EXPORT_NAME}Targets RUNTIME DESTINATION bin/ ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ diff --git a/external/fftpack/fftpack5/CMakeLists.txt b/external/fftpack/fftpack5/CMakeLists.txt index 4980398d07..9e75543fd5 100644 --- a/external/fftpack/fftpack5/CMakeLists.txt +++ b/external/fftpack/fftpack5/CMakeLists.txt @@ -31,13 +31,6 @@ set_target_properties( Fortran_FORMAT FREE ) -# target_compile_options( ${FOLDER_COMPILE_TARGET} -# PRIVATE -# # -cpp -# # $<$:-fcheck=all> -# # $<$:-check all> -# ) - target_link_libraries( ${FOLDER_COMPILE_TARGET} PRIVATE ${netCDF_LIBRARIES} @@ -52,6 +45,7 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} install( TARGETS ${FOLDER_COMPILE_TARGET} + EXPORT ${EXPORT_NAME}Targets RUNTIME DESTINATION bin/ ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ diff --git a/external/io_adios2/CMakeLists.txt b/external/io_adios2/CMakeLists.txt index 780d1316cb..e72016c8da 100644 --- a/external/io_adios2/CMakeLists.txt +++ b/external/io_adios2/CMakeLists.txt @@ -44,6 +44,7 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} install( TARGETS ${FOLDER_COMPILE_TARGET} + EXPORT ${EXPORT_NAME}Targets RUNTIME DESTINATION bin/ ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ diff --git a/external/io_esmf/CMakeLists.txt b/external/io_esmf/CMakeLists.txt index 1b90ad29b6..8b6ce33b0d 100644 --- a/external/io_esmf/CMakeLists.txt +++ b/external/io_esmf/CMakeLists.txt @@ -42,6 +42,7 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} install( TARGETS ${FOLDER_COMPILE_TARGET} + EXPORT ${EXPORT_NAME}Targets RUNTIME DESTINATION bin/ ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ diff --git a/external/io_grib1/CMakeLists.txt b/external/io_grib1/CMakeLists.txt index 0fb77efdba..bd59b40a7a 100644 --- a/external/io_grib1/CMakeLists.txt +++ b/external/io_grib1/CMakeLists.txt @@ -47,6 +47,7 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} install( TARGETS ${FOLDER_COMPILE_TARGET} + EXPORT ${EXPORT_NAME}Targets RUNTIME DESTINATION bin/ ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ diff --git a/external/io_grib1/MEL_grib1/CMakeLists.txt b/external/io_grib1/MEL_grib1/CMakeLists.txt index 4d28866ee4..99e2c323cc 100644 --- a/external/io_grib1/MEL_grib1/CMakeLists.txt +++ b/external/io_grib1/MEL_grib1/CMakeLists.txt @@ -70,6 +70,7 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} install( TARGETS ${FOLDER_COMPILE_TARGET} + EXPORT ${EXPORT_NAME}Targets RUNTIME DESTINATION bin/ ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ diff --git a/external/io_grib1/WGRIB/CMakeLists.txt b/external/io_grib1/WGRIB/CMakeLists.txt index 31aea35d67..5d99e01f88 100644 --- a/external/io_grib1/WGRIB/CMakeLists.txt +++ b/external/io_grib1/WGRIB/CMakeLists.txt @@ -71,6 +71,7 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} install( TARGETS ${FOLDER_COMPILE_TARGET} + EXPORT ${EXPORT_NAME}Targets RUNTIME DESTINATION bin/ ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ diff --git a/external/io_grib1/grib1_util/CMakeLists.txt b/external/io_grib1/grib1_util/CMakeLists.txt index bda28c07e2..d3ccae3f73 100644 --- a/external/io_grib1/grib1_util/CMakeLists.txt +++ b/external/io_grib1/grib1_util/CMakeLists.txt @@ -38,6 +38,7 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} install( TARGETS ${FOLDER_COMPILE_TARGET} + EXPORT ${EXPORT_NAME}Targets RUNTIME DESTINATION bin/ ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ diff --git a/external/io_grib2/CMakeLists.txt b/external/io_grib2/CMakeLists.txt index dc7649ad1a..2a85c86094 100644 --- a/external/io_grib2/CMakeLists.txt +++ b/external/io_grib2/CMakeLists.txt @@ -4,17 +4,6 @@ add_subdirectory( g2lib ) add_subdirectory( bacio-1.3 ) - -# get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) - -# add_library( -# ${FOLDER_COMPILE_TARGET} -# STATIC -# ) - -# target_sources( -# ${FOLDER_COMPILE_TARGET} -# PRIVATE target_sources( ${PROJECT_NAME}_Core PRIVATE @@ -22,36 +11,3 @@ target_sources( io_grib2.F read_grib2map.F ) - -# set_target_properties( -# ${FOLDER_COMPILE_TARGET} -# PROPERTIES -# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} -# Fortran_FORMAT FREE -# ) - - -# target_link_libraries( ${FOLDER_COMPILE_TARGET} -# PRIVATE -# ${netCDF_LIBRARIES} -# $<$:$> -# $<$:$> -# g2lib -# bacio-1.3 -# ) - -# target_include_directories( ${FOLDER_COMPILE_TARGET} -# PRIVATE -# ${netCDF_INCLUDE_DIRS} -# ${CMAKE_CURRENT_SOURCE_DIR} -# #!TODO Fix duplicates of wrf_[io|status]_flags.h -# # ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share -# ${CMAKE_CURRENT_SOURCE_DIR}/../io_grib_share -# ) - -# install( -# TARGETS ${FOLDER_COMPILE_TARGET} -# RUNTIME DESTINATION bin/ -# ARCHIVE DESTINATION lib/ -# LIBRARY DESTINATION lib/ -# ) diff --git a/external/io_grib2/bacio-1.3/CMakeLists.txt b/external/io_grib2/bacio-1.3/CMakeLists.txt index d10f368663..0915a4ffab 100644 --- a/external/io_grib2/bacio-1.3/CMakeLists.txt +++ b/external/io_grib2/bacio-1.3/CMakeLists.txt @@ -35,6 +35,7 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} install( TARGETS ${FOLDER_COMPILE_TARGET} + EXPORT ${EXPORT_NAME}Targets RUNTIME DESTINATION bin/ ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ diff --git a/external/io_grib2/g2lib/CMakeLists.txt b/external/io_grib2/g2lib/CMakeLists.txt index f69c900cdd..d05515e93c 100644 --- a/external/io_grib2/g2lib/CMakeLists.txt +++ b/external/io_grib2/g2lib/CMakeLists.txt @@ -101,6 +101,7 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} install( TARGETS ${FOLDER_COMPILE_TARGET} + EXPORT ${EXPORT_NAME}Targets RUNTIME DESTINATION bin/ ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ diff --git a/external/io_grib_share/CMakeLists.txt b/external/io_grib_share/CMakeLists.txt index 5381b8e35f..06109be2a3 100644 --- a/external/io_grib_share/CMakeLists.txt +++ b/external/io_grib_share/CMakeLists.txt @@ -40,6 +40,7 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} install( TARGETS ${FOLDER_COMPILE_TARGET} + EXPORT ${EXPORT_NAME}Targets RUNTIME DESTINATION bin/ ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ diff --git a/external/io_netcdf/CMakeLists.txt b/external/io_netcdf/CMakeLists.txt index cf7f74e5fe..11fce945b0 100644 --- a/external/io_netcdf/CMakeLists.txt +++ b/external/io_netcdf/CMakeLists.txt @@ -59,6 +59,7 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} install( TARGETS ${FOLDER_COMPILE_TARGET} + EXPORT ${EXPORT_NAME}Targets RUNTIME DESTINATION bin/ ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ diff --git a/external/io_netcdfpar/CMakeLists.txt b/external/io_netcdfpar/CMakeLists.txt index 6424556f08..e284478feb 100644 --- a/external/io_netcdfpar/CMakeLists.txt +++ b/external/io_netcdfpar/CMakeLists.txt @@ -56,6 +56,7 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} install( TARGETS ${FOLDER_COMPILE_TARGET} + EXPORT ${EXPORT_NAME}Targets RUNTIME DESTINATION bin/ ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ diff --git a/external/io_pio/CMakeLists.txt b/external/io_pio/CMakeLists.txt index 380c7c646e..04e38b4445 100644 --- a/external/io_pio/CMakeLists.txt +++ b/external/io_pio/CMakeLists.txt @@ -41,6 +41,7 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} install( TARGETS ${FOLDER_COMPILE_TARGET} + EXPORT ${EXPORT_NAME}Targets RUNTIME DESTINATION bin/ ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ diff --git a/external/io_pnetcdf/CMakeLists.txt b/external/io_pnetcdf/CMakeLists.txt index b12e73cd9e..09b6b01616 100644 --- a/external/io_pnetcdf/CMakeLists.txt +++ b/external/io_pnetcdf/CMakeLists.txt @@ -58,6 +58,7 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} install( TARGETS ${FOLDER_COMPILE_TARGET} + EXPORT ${EXPORT_NAME}Targets RUNTIME DESTINATION bin/ ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ diff --git a/external/ioapi_share/CMakeLists.txt b/external/ioapi_share/CMakeLists.txt index e69de29bb2..ddd37ecae2 100644 --- a/external/ioapi_share/CMakeLists.txt +++ b/external/ioapi_share/CMakeLists.txt @@ -0,0 +1,11 @@ +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set( + WRF_INCLUDE_FILES + wrf_io_flags.h + wrf_status_codes.h + ) + +install( + FILES ${WRF_INCLUDE_FILES} + DESTINATION include/external/${FOLDER_COMPILE_TARGET} + ) \ No newline at end of file From b4cc8e5de53c43de9945b07a513dee90a06a879b Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 12 Jun 2023 16:43:09 -0600 Subject: [PATCH 054/180] Clean up and setting install files --- frame/CMakeLists.txt | 21 +++++++++++----- phys/CMakeLists.txt | 60 +++----------------------------------------- 2 files changed, 19 insertions(+), 62 deletions(-) diff --git a/frame/CMakeLists.txt b/frame/CMakeLists.txt index 44d69e4491..0608ec41fe 100644 --- a/frame/CMakeLists.txt +++ b/frame/CMakeLists.txt @@ -1,5 +1,13 @@ # WRF CMake Build +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set( + WRF_INCLUDE_FILES + module_internal_header_util.F + ${CMAKE_BINARY_DIR}/frame/module_state_description.F + ) + + ######################################################################################################################## # Extra stuff for things that depend on registry code # https://stackoverflow.com/a/50640971 @@ -82,6 +90,8 @@ endif() target_sources( ${PROJECT_NAME}_Core PRIVATE + ${WRF_INCLUDE_FILES} + module_configure.F module_driver_constants.F module_domain_type.F @@ -127,7 +137,7 @@ target_sources( module_integrate.F - module_internal_header_util.F + module_io.F module_io_quilt.F @@ -142,8 +152,7 @@ target_sources( wrf_shutdown.F ) -target_include_directories( - ${PROJECT_NAME}_Core - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ) +install( + FILES ${WRF_INCLUDE_FILES} + DESTINATION include/${FOLDER_COMPILE_TARGET} + ) \ No newline at end of file diff --git a/phys/CMakeLists.txt b/phys/CMakeLists.txt index 7713f324f6..28d80960fb 100644 --- a/phys/CMakeLists.txt +++ b/phys/CMakeLists.txt @@ -1,8 +1,5 @@ # WRF CMake Build -# get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME ) - - ######################################################################################################################## # # Quickly preprocess some files so that cmake can understand the module dependencies @@ -10,13 +7,10 @@ ######################################################################################################################## get_directory_property( DIR_DEFS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS ) wrf_c_preproc_fortran( - TARGET_NAME module_ra_rrtmg_lwk_preproc + 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} SOURCES module_ra_rrtmg_lwk.F @@ -26,21 +20,9 @@ wrf_c_preproc_fortran( module_sf_clm.F ) -add_dependencies( ${PROJECT_NAME}_Core module_ra_rrtmg_lwk_preproc ) -# set_source_files_properties( -# ${CMAKE_CURRENT_BINARY_DIR}/preproc/module_ra_rrtmg_lwk.i -# PROPERTIES -# GENERATED TRUE -# ) - - -# add_library( -# ${FOLDER_COMPILE_TARGET} -# STATIC -# ) +add_dependencies( ${PROJECT_NAME}_Core module_ra_rrtmg_preproc ) target_sources( - # ${FOLDER_COMPILE_TARGET} ${PROJECT_NAME}_Core PRIVATE complex_number_module.F @@ -272,43 +254,9 @@ target_sources( module_wind_fitch.F ) -# set_target_properties( -# ${FOLDER_COMPILE_TARGET} -# PROPERTIES -# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} -# Fortran_FORMAT FREE -# ) - -# target_link_libraries( ${FOLDER_COMPILE_TARGET} -# PRIVATE -# ${netCDF_LIBRARIES} -# $<$:$> -# $<$:$> -# ) - -target_include_directories( #${FOLDER_COMPILE_TARGET} +target_include_directories( ${PROJECT_NAME}_Core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - # $ - # $ - # $ - - #!TODO Fix duplicates of wrf_[io|status]_flags.h - # ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share - # ${CMAKE_CURRENT_SOURCE_DIR}/../io_grib_share - # ${CMAKE_CURRENT_SOURCE_DIR}/grib1_util - # ${CMAKE_CURRENT_SOURCE_DIR}/MEL_grib1 - ) - -# # Depend on framework, why? I don't know, this is a mess -# add_dependencies( ${FOLDER_COMPILE_TARGET} frame_deps share_deps module_ra_rrtmg_lwk_preproc ) - - -# install( -# TARGETS ${FOLDER_COMPILE_TARGET} -# RUNTIME DESTINATION bin/ -# ARCHIVE DESTINATION lib/ -# LIBRARY DESTINATION lib/ -# ) + ) \ No newline at end of file From c4cc7a656f0126cd2d9a44b0ee391ce6e24763dc Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 12 Jun 2023 16:43:31 -0600 Subject: [PATCH 055/180] Clean up --- tools/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 1b6eeb37ad..375bab59cf 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -2,7 +2,6 @@ #!TODO ORGANIZE THIS FOLDER set( FOLDER_COMPILE_TARGET registry ) -# get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) add_executable( ${FOLDER_COMPILE_TARGET} @@ -115,8 +114,6 @@ add_custom_command( ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/frame COMMAND ${CMAKE_BINARY_DIR}/tools/registry ${REGISTRY_DEFS} -DNEW_BDYS ${REGISTRY_FILE} &> ${CMAKE_BINARY_DIR}/registry.log - # -DNONSTANDARD_SYSTEM_SUBR -DWRF_USE_CLM -DUSE_NETCDF4_FEATURES -DWRFIO_NCD_LARGE_FILE_SUPPORT -DDM_PARALLEL -DNETCDF -DLANDREAD_STUB=1 -DUSE_ALLOCATABLES -Dwrfmodel -DGRIB1 -DINTIO -DKEEP_INT_AROUND -DLIMIT_ARGS -DBUILD_RRTMG_FAST=0 -DBUILD_RRTMK=0 -DBUILD_SBM_FAST=1 -DSHOW_ALL_VARS_USED=0 -DCONFIG_BUF_LEN=65536 -DMAX_DOMAINS_F=21 -DMAX_HISTORY=25 -DNMM_NEST=0 -DNEW_BDYS ${REGISTRY_FILE} &> ${CMAKE_BINARY_DIR}/registry.log - #!TODO Just have the registry code actually check for failure or better yet rewrite the # registry code to not be so obfuscating COMMAND From d0d4963037f9ef16433fc360d66924a3326afc4d Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 12 Jun 2023 16:44:19 -0600 Subject: [PATCH 056/180] Setting up export namespace and cmake package --- CMakeLists.txt | 63 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 55 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 957b1c5259..4d9f44e48b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ enable_language( CXX ) enable_language( Fortran ) project( WRF ) +set( EXPORT_NAME ${PROJECT_NAME} ) if ( DEFINED CMAKE_TOOLCHAIN_FILE ) set( WRF_CONFIG ${CMAKE_TOOLCHAIN_FILE} ) @@ -19,6 +20,7 @@ list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/ ${PROJECT_SOURCE_DIR # Use link paths as rpaths set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE ) +include( CMakePackageConfigHelpers ) include( c_preproc ) include( m4_preproc ) include( target_copy ) @@ -26,6 +28,7 @@ include( confcheck ) include( gitinfo ) include( printOption ) include( wrf_case_setup ) +include( wrf_get_version ) # First grab git info wrf_git_commit( @@ -40,6 +43,9 @@ configure_file( @ONLY ) +# Grab version info +wrf_get_version( ${PROJECT_SOURCE_DIR}/README ) + ################################################################################ ## ## Options that can be user configured @@ -502,6 +508,7 @@ target_include_directories( PUBLIC # List module directories first so the compiler does not get confused # about things "not being compiled yet" - yes, yes it is compiled + # These are already set up to be @ install location $ $ $ @@ -511,13 +518,20 @@ target_include_directories( $ - ${PROJECT_SOURCE_DIR} - ${PROJECT_SOURCE_DIR}/inc - ${PROJECT_SOURCE_DIR}/frame - ${PROJECT_SOURCE_DIR}/external/ioapi_share + $ + $ + $ + $ + + $ + $ - ${CMAKE_BINARY_DIR}/inc - ${CMAKE_BINARY_DIR}/frame + # For install interface includes, i.e. when used by external tools + # such as WPS + # $ + $ + $ + $ PRIVATE # May or may not exist @@ -574,7 +588,7 @@ set_target_properties( # ${pnetCDF_LIBRARY_DIR} # ${} ) -message( STATUS "pnetCDF_LIBRARIES ${pnetCDF_LIBRARIES}") + target_link_libraries( ${PROJECT_NAME}_Core PRIVATE ${netCDF_LIBRARIES} @@ -616,10 +630,43 @@ target_link_libraries( ${PROJECT_NAME}_Core RSL_LITE ) - +################################################################################ +## +## Install and export +## +################################################################################ install( TARGETS ${PROJECT_NAME}_Core + EXPORT ${EXPORT_NAME}Targets RUNTIME DESTINATION bin/ ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ ) + +# Install to namespace +install( + EXPORT ${EXPORT_NAME}Targets + DESTINATION lib/cmake/ + FILE ${EXPORT_NAME}Targets.cmake + NAMESPACE ${EXPORT_NAME}:: + ) + +configure_package_config_file( + ${PROJECT_SOURCE_DIR}/cmake/template/${EXPORT_NAME}Config.cmake.in + ${CMAKE_BINARY_DIR}/${EXPORT_NAME}Config.cmake + INSTALL_DESTINATION lib/cmake + ) + +write_basic_package_version_file( + ${CMAKE_BINARY_DIR}/${EXPORT_NAME}ConfigVersion.cmake + VERSION ${PROJECT_VERSION} + #!TODO Check if this is the type of versioning support we want to use + COMPATIBILITY SameMinorVersion + ) + +install( + FILES + ${CMAKE_BINARY_DIR}/${EXPORT_NAME}Config.cmake + ${CMAKE_BINARY_DIR}/${EXPORT_NAME}ConfigVersion.cmake + DESTINATION lib/cmake + ) \ No newline at end of file From b32d0e4150709c67c82be7b87fa8ce117efde5a7 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 23 Jun 2023 20:05:16 -0600 Subject: [PATCH 057/180] Fixing indentation --- frame/CMakeLists.txt | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/frame/CMakeLists.txt b/frame/CMakeLists.txt index 0608ec41fe..a315494a99 100644 --- a/frame/CMakeLists.txt +++ b/frame/CMakeLists.txt @@ -28,17 +28,17 @@ foreach( n RANGE 0 7 ) DEFINITIONS ${DIR_DEFS} NNN=${n} NL_set_ROUTINES SOURCES nl_access_routines.F ) - wrf_c_preproc_fortran( - TARGET_NAME nl_get_${n} - OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ - EXTENSION ".f90" - PREFIX "nl_get_${n}_" - INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_BINARY_DIR}/inc - DEPENDENCIES registry_code - DEFINITIONS ${DIR_DEFS} NNN=${n} NL_get_ROUTINES - SOURCES nl_access_routines.F - ) + wrf_c_preproc_fortran( + TARGET_NAME nl_get_${n} + OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ + EXTENSION ".f90" + PREFIX "nl_get_${n}_" + INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_BINARY_DIR}/inc + DEPENDENCIES registry_code + DEFINITIONS ${DIR_DEFS} NNN=${n} NL_get_ROUTINES + SOURCES nl_access_routines.F + ) add_dependencies( ${PROJECT_NAME}_Core nl_get_${n} nl_set_${n} ) From a1c598b1362e5d85c22f6b05f1b2a94511729444 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 23 Jun 2023 20:06:25 -0600 Subject: [PATCH 058/180] Cleaning up cmake modules --- cmake/c_preproc.cmake | 17 ----------------- cmake/template/WRFConfig.cmake.in | 2 +- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/cmake/c_preproc.cmake b/cmake/c_preproc.cmake index 471c9bce10..31f1c7fa6d 100644 --- a/cmake/c_preproc.cmake +++ b/cmake/c_preproc.cmake @@ -26,23 +26,6 @@ macro( wrf_c_preproc_fortran ) RESULT_VAR WRF_PP_F_DEFS DEFINITIONS ${WRF_PP_F_DEFINITIONS} ) - # set( WRF_PP_F_DEFS ) - # foreach( WRF_PP_F_DEF ${WRF_PP_F_DEFINITIONS} ) - # if ( NOT ${WRF_PP_F_DEF} MATCHES ".*-D.*" ) - # # We have a generator expression, inject the -D correctly - # if ( ${WRF_PP_F_DEF} MATCHES "^[$]<" ) - # # Take advantage of the fact that the first time a generator expression ends to finally - # # name the define it has the first ">:" then unexpanded characters (hopefully) - # # 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_PP_F_DEF_SANITIZED ${WRF_PP_F_DEF} ) - # list( APPEND WRF_PP_F_DEFS ${WRF_PP_F_DEF_SANITIZED} ) - # else() - # list( APPEND WRF_PP_F_DEFS -D${WRF_PP_F_DEF} ) - # endif() - # endif() - - # endforeach() - # Generate compile command and file outputs set( WRF_PP_F_OUTPUT ) diff --git a/cmake/template/WRFConfig.cmake.in b/cmake/template/WRFConfig.cmake.in index d17eef1bd7..b14902b53f 100644 --- a/cmake/template/WRFConfig.cmake.in +++ b/cmake/template/WRFConfig.cmake.in @@ -43,4 +43,4 @@ find_package( netCDF REQUIRED ) set( ZLIB_ROOT ${netCDF_PREFIX} ) find_package( ZLIB REQUIRED ) -check_required_components( "@EXPORT_NAME@" ) \ No newline at end of file +check_required_components( "@EXPORT_NAME@_Core" ) \ No newline at end of file From 91b28cdadf24f30fa05fc039596a3a35750c908d Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 23 Jun 2023 20:07:16 -0600 Subject: [PATCH 059/180] Adding key sanitization and option string output --- arch/configure_reader.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/arch/configure_reader.py b/arch/configure_reader.py index 8deae9b567..c09a4fb4bc 100755 --- a/arch/configure_reader.py +++ b/arch/configure_reader.py @@ -106,6 +106,29 @@ def sanitize( self ) : self.splitIntoFieldAndFlags( "DM_CC" ) self.splitIntoFieldAndFlags( "M4" ) + # Remove rogue compile commands that should *NOT* even be here + keysToSanitize = [ + "ARFLAGS", + "CFLAGS_LOCAL", + "CPP", + "ESMF_LDFLAG", + "LDFLAGS_LOCAL", + "MODULE_SRCH_FLAG", + "RLFLAGS", + "TRADFLAG", + "FCBASEOPTS", + "FCBASEOPTS_NO_G", + "FCOPTIM", + "FORMAT_FIXED", + "FORMAT_FREE" + ] + + for keyToSan in keysToSanitize : + if keyToSan in self.kvPairs_ : + self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "-c", "" ) + + + # Now deref all the rest for key in self.kvPairs_ : self.dereference( key ) @@ -186,7 +209,7 @@ def getStringOptionSelection( topLevelCmake, searchString ) : options = [ option for option in options if option ] optionsFmt = ", ".join( [ "{idx} : {opt}".format( idx=options.index( opt ), opt=opt ) for opt in options ] ) - selection = int( input( "Select string options [0-{max}] ({opts}) : ".format( max=len(options)-1, opts=optionsFmt ) ) ) + selection = int( input( "Select option from {optionsStr} [0-{max}] ({opts}) : ".format( optionsStr=searchString, max=len(options)-1, opts=optionsFmt ) ) ) if selection < 0 or selection > len(options) : print( "Invalid option selection for " + searchString + "!" ) @@ -279,8 +302,8 @@ def main() : "WRF_CORE" : coreOption, "WRF_NESTING" : nestingOption, "WRF_CASE" : caseOption, - "USE_MPI" : "ON" if useMPI else "OFF", - "USE_OPENMP" : "ON" if useMPI else "OFF" + "USE_MPI" : "ON" if useMPI else "OFF", + "USE_OPENMP" : "ON" if useOpenMP else "OFF" } generateCMakeToolChainFile( cmakeTemplateFile, cmakeConfigFile, stanzas[idxSelection], additionalOptions ) From c66b531655fe4662eb925ea345d9672feab87d38 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 23 Jun 2023 20:08:21 -0600 Subject: [PATCH 060/180] Reinstating old c preproc then m4 processing since gfortran is unable to --- external/io_adios2/CMakeLists.txt | 48 +++++++++++++++------ external/io_adios2/wrf_io.F90 | 6 +-- external/io_netcdf/CMakeLists.txt | 62 +++++++++++++++------------ external/io_netcdf/wrf_io.F90 | 8 ++-- external/io_netcdfpar/CMakeLists.txt | 63 +++++++++++++++------------ external/io_netcdfpar/wrf_io.F90 | 8 ++-- external/io_pnetcdf/CMakeLists.txt | 64 ++++++++++++++++------------ external/io_pnetcdf/wrf_io.F90 | 4 +- 8 files changed, 154 insertions(+), 109 deletions(-) diff --git a/external/io_adios2/CMakeLists.txt b/external/io_adios2/CMakeLists.txt index e72016c8da..0cc7a5e86b 100644 --- a/external/io_adios2/CMakeLists.txt +++ b/external/io_adios2/CMakeLists.txt @@ -7,20 +7,7 @@ add_library( STATIC ) -target_sources( - ${FOLDER_COMPILE_TARGET} - PRIVATE - wrf_io.F90 - field_routines.F90 - ext_adios2_get_dom_ti.code - ext_adios2_get_var_td.code - ext_adios2_get_var_ti.code - ext_adios2_put_dom_ti.code - ext_adios2_put_var_td.code - ext_adios2_put_var_ti.code - transpose.code - ) - +# Do this first to simplify steps later set_target_properties( ${FOLDER_COMPILE_TARGET} PROPERTIES @@ -40,8 +27,41 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} ${netCDF_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share + ${CMAKE_INSTALL_PREFIX}/${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} + SOURCES wrf_io.F90 + ) + +# Now M4 preprocess +wrf_m4_preproc_fortran( + TARGET_NAME ${FOLDER_COMPILE_TARGET}_m4_preproc_wrf_io + OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ + PREFIX "m4_preproc_" + EXTENSION ".f90" + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/preproc/wrf_io.f90 + DEPENDENCIES ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io + ) + +add_dependencies( ${FOLDER_COMPILE_TARGET} ${FOLDER_COMPILE_TARGET}_m4_preproc_wrf_io ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + ${CMAKE_CURRENT_BINARY_DIR}/preproc/m4_preproc_wrf_io.f90 + field_routines.F90 + ) + install( TARGETS ${FOLDER_COMPILE_TARGET} EXPORT ${EXPORT_NAME}Targets diff --git a/external/io_adios2/wrf_io.F90 b/external/io_adios2/wrf_io.F90 index 99e9bfe2e0..b9bfe696d8 100644 --- a/external/io_adios2/wrf_io.F90 +++ b/external/io_adios2/wrf_io.F90 @@ -702,9 +702,9 @@ subroutine Transpose(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) - - !#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) - ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) +! Cannot use following define due to gfortran cpp traditional mode concatenation limitations +!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') #undef DFIELD #define DFIELD XField(1:di,XDEX(i,k,j)) diff --git a/external/io_netcdf/CMakeLists.txt b/external/io_netcdf/CMakeLists.txt index 11fce945b0..236c2001d4 100644 --- a/external/io_netcdf/CMakeLists.txt +++ b/external/io_netcdf/CMakeLists.txt @@ -7,34 +7,7 @@ add_library( STATIC ) -# set( -# SOURCE_CODE -# #!TODO Change the file extension on these, maybe... -# # ext_ncd_get_dom_ti.code -# # ext_ncd_get_var_td.code -# # ext_ncd_get_var_ti.code -# # ext_ncd_put_dom_ti.code -# # ext_ncd_put_var_td.code -# # ext_ncd_put_var_ti.code -# # transpose.code - -# ) - -# set_source_files_properties( -# ${SOURCE_CODE} -# PROPERTIES -# LANGUAGE Fortran -# ) - -target_sources( - ${FOLDER_COMPILE_TARGET} - PRIVATE - field_routines.F90 - module_wrfsi_static.F90 - wrf_io.F90 - ) - - +# Do this first to simplify steps later set_target_properties( ${FOLDER_COMPILE_TARGET} PROPERTIES @@ -57,6 +30,39 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} ${CMAKE_INSTALL_PREFIX}/${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} + SOURCES wrf_io.F90 + ) + +# Now M4 preprocess +wrf_m4_preproc_fortran( + TARGET_NAME ${FOLDER_COMPILE_TARGET}_m4_preproc_wrf_io + OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ + PREFIX "m4_preproc_" + EXTENSION ".f90" + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/preproc/wrf_io.f90 + DEPENDENCIES ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io + ) + +add_dependencies( ${FOLDER_COMPILE_TARGET} ${FOLDER_COMPILE_TARGET}_m4_preproc_wrf_io ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + ${CMAKE_CURRENT_BINARY_DIR}/preproc/m4_preproc_wrf_io.f90 + module_wrfsi_static.F90 + field_routines.F90 + ) + install( TARGETS ${FOLDER_COMPILE_TARGET} EXPORT ${EXPORT_NAME}Targets diff --git a/external/io_netcdf/wrf_io.F90 b/external/io_netcdf/wrf_io.F90 index e29c8b4271..8863e4e29f 100644 --- a/external/io_netcdf/wrf_io.F90 +++ b/external/io_netcdf/wrf_io.F90 @@ -754,8 +754,8 @@ subroutine Transpose(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) - -#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +! Cannot use following define due to gfortran cpp traditional mode concatenation limitations +!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') @@ -940,8 +940,8 @@ subroutine TransposeToR4(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) - -#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +! Cannot use following define due to gfortran cpp traditional mode concatenation limitations +!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') diff --git a/external/io_netcdfpar/CMakeLists.txt b/external/io_netcdfpar/CMakeLists.txt index e284478feb..236c2001d4 100644 --- a/external/io_netcdfpar/CMakeLists.txt +++ b/external/io_netcdfpar/CMakeLists.txt @@ -7,32 +7,7 @@ add_library( STATIC ) -# set( -# SOURCE_CODE -# # ext_ncdpar_get_dom_ti.code -# # ext_ncdpar_get_var_td.code -# # ext_ncdpar_get_var_ti.code -# # ext_ncdpar_put_dom_ti.code -# # ext_ncdpar_put_var_td.code -# # ext_ncdpar_put_var_ti.code -# # transpose.code -# ) - -# set_source_files_properties( -# ${SOURCE_CODE} -# PROPERTIES -# LANGUAGE Fortran -# ) - -target_sources( - ${FOLDER_COMPILE_TARGET} - PRIVATE - field_routines.F90 - module_wrfsi_static.F90 - wrf_io.F90 - ) - - +# Do this first to simplify steps later set_target_properties( ${FOLDER_COMPILE_TARGET} PROPERTIES @@ -51,9 +26,43 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} PRIVATE ${netCDF_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share + ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share + ${CMAKE_INSTALL_PREFIX}/${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} + SOURCES wrf_io.F90 + ) + +# Now M4 preprocess +wrf_m4_preproc_fortran( + TARGET_NAME ${FOLDER_COMPILE_TARGET}_m4_preproc_wrf_io + OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ + PREFIX "m4_preproc_" + EXTENSION ".f90" + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/preproc/wrf_io.f90 + DEPENDENCIES ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io + ) + +add_dependencies( ${FOLDER_COMPILE_TARGET} ${FOLDER_COMPILE_TARGET}_m4_preproc_wrf_io ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + ${CMAKE_CURRENT_BINARY_DIR}/preproc/m4_preproc_wrf_io.f90 + module_wrfsi_static.F90 + field_routines.F90 + ) + install( TARGETS ${FOLDER_COMPILE_TARGET} EXPORT ${EXPORT_NAME}Targets diff --git a/external/io_netcdfpar/wrf_io.F90 b/external/io_netcdfpar/wrf_io.F90 index 60b6dff094..86e25dd2cb 100644 --- a/external/io_netcdfpar/wrf_io.F90 +++ b/external/io_netcdfpar/wrf_io.F90 @@ -767,8 +767,8 @@ subroutine Transpose(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) - -#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +! Cannot use following define due to gfortran cpp traditional mode concatenation limitations +!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') @@ -953,8 +953,8 @@ subroutine TransposeToR4a(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) - -#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +! Cannot use following define due to gfortran cpp traditional mode concatenation limitations +!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') diff --git a/external/io_pnetcdf/CMakeLists.txt b/external/io_pnetcdf/CMakeLists.txt index 09b6b01616..600746a37c 100644 --- a/external/io_pnetcdf/CMakeLists.txt +++ b/external/io_pnetcdf/CMakeLists.txt @@ -7,32 +7,7 @@ add_library( STATIC ) -# set( -# SOURCE_CODE -# # ext_pcd_get_dom_ti.code -# # ext_pcd_get_var_td.code -# # ext_pcd_get_var_ti.code -# # ext_pcd_put_dom_ti.code -# # ext_pcd_put_var_td.code -# # ext_pcd_put_var_ti.code -# # transpose.code -# ) - -# set_source_files_properties( -# ${SOURCE_CODE} -# PROPERTIES -# LANGUAGE Fortran -# ) - -target_sources( - ${FOLDER_COMPILE_TARGET} - PRIVATE - field_routines.F90 - module_wrfsi_static.F90 - wrf_io.F90 - ) - - +# Do this first to simplify steps later set_target_properties( ${FOLDER_COMPILE_TARGET} PROPERTIES @@ -53,9 +28,43 @@ target_include_directories( ${FOLDER_COMPILE_TARGET} ${netCDF_INCLUDE_DIRS} ${pnetCDF_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share + ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share + ${CMAKE_INSTALL_PREFIX}/${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} + SOURCES wrf_io.F90 + ) + +# Now M4 preprocess +wrf_m4_preproc_fortran( + TARGET_NAME ${FOLDER_COMPILE_TARGET}_m4_preproc_wrf_io + OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ + PREFIX "m4_preproc_" + EXTENSION ".f90" + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/preproc/wrf_io.f90 + DEPENDENCIES ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io + ) + +add_dependencies( ${FOLDER_COMPILE_TARGET} ${FOLDER_COMPILE_TARGET}_m4_preproc_wrf_io ) + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + ${CMAKE_CURRENT_BINARY_DIR}/preproc/m4_preproc_wrf_io.f90 + module_wrfsi_static.F90 + field_routines.F90 + ) + install( TARGETS ${FOLDER_COMPILE_TARGET} EXPORT ${EXPORT_NAME}Targets @@ -63,3 +72,4 @@ install( ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ ) + diff --git a/external/io_pnetcdf/wrf_io.F90 b/external/io_pnetcdf/wrf_io.F90 index f6e382d93b..9d9c3733b4 100644 --- a/external/io_pnetcdf/wrf_io.F90 +++ b/external/io_pnetcdf/wrf_io.F90 @@ -740,8 +740,8 @@ subroutine Transpose(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) - -#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +! Cannot use following define due to gfortran cpp traditional mode concatenation limitations +!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') From c95e94d4fd8bc7b4c5ac91588a476160d08799b0 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 23 Jun 2023 20:09:21 -0600 Subject: [PATCH 061/180] Make Jasper optional for grib2 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d9f44e48b..50a36044ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -340,8 +340,8 @@ endif() # Optional find_package( HDF5 QUIET ) -# Required for WPS -find_package( Jasper REQUIRED ) +# Optional for grib2 +find_package( Jasper QUIET ) # Optional find_package( PIO QUIET ) From f2ede498c7741a5bf90908e2bf61d27f556a5be6 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 23 Jun 2023 20:09:49 -0600 Subject: [PATCH 062/180] Add flags specific for GNU builds --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 50a36044ff..690de7b313 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -395,6 +395,9 @@ 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> ) From be71c8efd53d1d76a1214f6076d7ed9fcc49d9db Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 23 Jun 2023 20:09:59 -0600 Subject: [PATCH 063/180] Adding share files --- CMakeLists.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 690de7b313..cb19f5fec2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -672,4 +672,24 @@ install( ${CMAKE_BINARY_DIR}/${EXPORT_NAME}Config.cmake ${CMAKE_BINARY_DIR}/${EXPORT_NAME}ConfigVersion.cmake DESTINATION lib/cmake + ) + +# Install some helper files for anyone using this build as part of their code +install( + DIRECTORY + # Trailing / is important + ${PROJECT_SOURCE_DIR}/cmake/modules/ + COMPONENT helpers + DESTINATION share + FILES_MATCHING + PATTERN "*.cmake" + ) +install( + FILES + ${PROJECT_SOURCE_DIR}/cmake/confcheck.cmake + ${PROJECT_SOURCE_DIR}/cmake/gitinfo.cmake + ${PROJECT_SOURCE_DIR}/cmake/printOption.cmake + ${PROJECT_SOURCE_DIR}/cmake/wrf_get_version.cmake + COMPONENT helpers + DESTINATION share ) \ No newline at end of file From 5c3a283a758ddc7203298ed3a3c55b383026b7ec Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 28 Jun 2023 17:50:56 -0600 Subject: [PATCH 064/180] Removing double WRF --- cmake/template/WRFConfig.cmake.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/template/WRFConfig.cmake.in b/cmake/template/WRFConfig.cmake.in index b14902b53f..9f6778f8fc 100644 --- a/cmake/template/WRFConfig.cmake.in +++ b/cmake/template/WRFConfig.cmake.in @@ -7,9 +7,9 @@ include( "${CMAKE_CURRENT_LIST_DIR}/@EXPORT_NAME@Targets.cmake" ) set( WRF_VERSION @PROJECT_VERSION@ ) # Options WRF was built with -set( WRF_WRF_CORE @WRF_CORE@ ) -set( WRF_WRF_NESTING @WRF_NESTING@ ) -set( WRF_WRF_CASE @WRF_CASE@ ) +set( WRF_CORE @WRF_CORE@ ) +set( WRF_NESTING @WRF_NESTING@ ) +set( WRF_CASE @WRF_CASE@ ) set( WRF_USE_DOUBLE @USE_DOUBLE@ ) set( WRF_USE_MPI @USE_MPI@ ) From 472246e9af764fb31414050283156e37de27f2e1 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 28 Jun 2023 17:51:24 -0600 Subject: [PATCH 065/180] Switching to official toolchain *_INIT options --- cmake/template/arch_config.cmake | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cmake/template/arch_config.cmake b/cmake/template/arch_config.cmake index ee7e800aa7..c22b45a869 100644 --- a/cmake/template/arch_config.cmake +++ b/cmake/template/arch_config.cmake @@ -5,12 +5,11 @@ set( MPI_C_COMPILER "{DM_CC}" ) set( CMAKE_Fortran_COMPILER "{SFC}" ) set( CMAKE_C_COMPILER "{SCC}" ) -set( CMAKE_Fortran_FLAGS "{FCBASEOPTS} {BYTESWAPIO}" ) -set( CMAKE_C_FLAGS "{CFLAGS_LOCAL}" ) +set( CMAKE_Fortran_FLAGS_INIT "{FCBASEOPTS} {BYTESWAPIO}" ) +set( CMAKE_C_FLAGS_INIT "{CFLAGS_LOCAL}" ) -set( CMAKE_Fortran_FLAGS_DEBUG "{FCDEBUG}" ) - -set( CMAKE_Fortran_FLAGS_RELEASE "{FCOPTIM}" ) +set( CMAKE_Fortran_FLAGS_DEBUG_INIT "{FCDEBUG}" ) +set( CMAKE_Fortran_FLAGS_RELEASE_INIT "{FCOPTIM}" ) # Project specifics now set( WRF_MPI_Fortran_FLAGS "{DM_FC_FLAGS}" ) From 5cbdbcebc2b238b2617350c8f457bcdacd78a0c9 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 28 Jun 2023 17:53:07 -0600 Subject: [PATCH 066/180] Minor fixes to build commands --- CMakeLists.txt | 25 ++++++++++++++++--------- configure_new | 2 +- external/io_grib1/CMakeLists.txt | 4 ++-- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb19f5fec2..a85b6838be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,8 @@ set( EXPORT_NAME ${PROJECT_NAME} ) if ( DEFINED CMAKE_TOOLCHAIN_FILE ) set( WRF_CONFIG ${CMAKE_TOOLCHAIN_FILE} ) - message( STATUS "Loading configuration file..." ) - include( ${WRF_CONFIG} ) + # message( STATUS "Loading configuration file... : ${WRF_CONFIG}" ) + # include( ${WRF_CONFIG} ) endif() # list( APPEND CMAKE_MODULE_PATH ) @@ -19,6 +19,7 @@ list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/ ${PROJECT_SOURCE_DIR # Use link paths as rpaths set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE ) +set( CMAKE_Fortran_PREPROCESS ON ) include( CMakePackageConfigHelpers ) include( c_preproc ) @@ -51,7 +52,7 @@ wrf_get_version( ${PROJECT_SOURCE_DIR}/README ) ## Options that can be user configured ## ################################################################################ -set( CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/runTemp ) +# set( CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/ ) # Mode configuration @@ -165,6 +166,10 @@ set( NMM_CORE OFF ) set( NETCDF ON ) +# Special internal flag for profiling compilation +set( PROFILE_COMPILATION OFF ) + + # From arch/preamble #### Single location for defining total number of domains. You need #### at least 1 + 2*(number of total nests). For example, 1 coarse @@ -310,13 +315,13 @@ if ( ${USE_MPI} ) if ( DEFINED WRF_MPI_Fortran_FLAGS AND NOT "${WRF_MPI_Fortran_FLAGS}" STREQUAL "" ) add_compile_options( - $<$,${WRF_MPI_Fortran_FLAGS}> + $<$:${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}> + $<$:${WRF_MPI_C_FLAGS}> ) endif() endif() @@ -402,6 +407,12 @@ add_compile_options( # $,$:-diag-disable;6843> ) +if ( ${PROFILE_COMPILATION} ) + add_compile_options( + $<$:-ftime-report> + ) +endif() + add_compile_definitions( MAX_DOMAINS_F=${MAX_DOMAINS_F} CONFIG_BUF_LEN=${CONFIG_BUF_LEN} @@ -485,10 +496,6 @@ add_compile_definitions( ) -#!TODO Investigate if this is better than setting -cpp -set( CMAKE_Fortran_PREPROCESS ON ) - - # Make core target add_library( ${PROJECT_NAME}_Core diff --git a/configure_new b/configure_new index abff460f77..34ef5602d3 100755 --- a/configure_new +++ b/configure_new @@ -7,4 +7,4 @@ CMakeLists.txt # Now run cmake -cmake -S . -B _build -DCMAKE_INSTALL_PREFIX=$PWD -DCMAKE_TOOLCHAIN_FILE=$PWD/wrf_config.cmake \ No newline at end of file +cmake -S . -B _build -DCMAKE_INSTALL_PREFIX=$PWD/runTemp -DCMAKE_TOOLCHAIN_FILE=$PWD/wrf_config.cmake \ No newline at end of file diff --git a/external/io_grib1/CMakeLists.txt b/external/io_grib1/CMakeLists.txt index bd59b40a7a..83025c0f19 100644 --- a/external/io_grib1/CMakeLists.txt +++ b/external/io_grib1/CMakeLists.txt @@ -4,7 +4,7 @@ add_subdirectory( MEL_grib1 ) add_subdirectory( grib1_util ) add_subdirectory( WGRIB ) -get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME ) add_library( ${FOLDER_COMPILE_TARGET} @@ -24,7 +24,7 @@ set_target_properties( ${FOLDER_COMPILE_TARGET} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} - Fortran_FORMAT FREE + Fortran_FORMAT FREE ) From 505d53b4aad62fc863620a5e4176905b83b7d64b Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 28 Jun 2023 17:53:44 -0600 Subject: [PATCH 067/180] This probably follows original cmake finding order but to be safe reorder to deprioritize env vars --- cmake/modules/FindJasper.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/modules/FindJasper.cmake b/cmake/modules/FindJasper.cmake index 68daa26f92..3b9bc6210c 100644 --- a/cmake/modules/FindJasper.cmake +++ b/cmake/modules/FindJasper.cmake @@ -12,7 +12,7 @@ find_path( Jasper_INCLUDE_DIR NAMES jasper/jasper.h # Make it so we go up one dir # Hints before PATHS - HINTS ENV Jasper_ROOT ENV JASPERINC ENV JASPER_PATH ${Jasper_ROOT} ${JASPERINC} ${JASPER_PATH} + HINTS ${Jasper_ROOT} ${JASPERINC} ${JASPER_PATH} ENV Jasper_ROOT ENV JASPERINC ENV JASPER_PATH PATHS ${PC_Jasper_INCLUDE_DIRS} PATH_SUFFIXES Jasper jasper include #include/jasper ) @@ -20,7 +20,7 @@ find_library( Jasper_LIBRARY NAMES jasper # Hints before PATHS - HINTS ENV Jasper_ROOT ENV JASPERLIB ENV JASPER_PATH ${Jasper_ROOT} ${JASPERLIB} ${JASPER_PATH} + HINTS ${Jasper_ROOT} ${JASPERLIB} ${JASPER_PATH} ENV Jasper_ROOT ENV JASPERLIB ENV JASPER_PATH PATHS ${PC_Jasper_LIBRARY_DIRS} PATH_SUFFIXES lib ) From 05ec5e8acd0b9af8a3fd00ef116e9259897e1091 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 29 Jun 2023 17:18:37 -0600 Subject: [PATCH 068/180] Fixing symlink creation for second passes --- cmake/wrf_case_setup.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/wrf_case_setup.cmake b/cmake/wrf_case_setup.cmake index 3f2910a7cf..e1460af588 100644 --- a/cmake/wrf_case_setup.cmake +++ b/cmake/wrf_case_setup.cmake @@ -49,7 +49,7 @@ macro( wrf_link_files ) # Generate install code for each file, this could be done in a simpler manner # with regular commands but to preserve order of operations it will be done via install( CODE ... ) # https://stackoverflow.com/a/56528615 - get_filename_component( WRF_LINK_FULL_FILE ${WRF_LINK_FILE} REALPATH ) + get_filename_component( WRF_LINK_FULL_FILE ${WRF_LINK_FILE} ABSOLUTE ) get_filename_component( WRF_LINK_FILE_ONLY ${WRF_LINK_FILE} NAME ) # Left here for debug purposes, may want to turn this into a trace-level debug msg # message( "Generating install commands for ${WRF_LINK_FILE_ONLY} into ${WRF_LINK_SYM_PATH}" ) @@ -82,15 +82,15 @@ macro( wrf_link_file_new_name ) # Generate install code for each file, this could be done in a simpler manner # with regular commands but to preserve order of operations it will be done via install( CODE ... ) # https://stackoverflow.com/a/56528615 - get_filename_component( WRF_LINK_FULL_FILE ${WRF_LINK_FILE} REALPATH ) + get_filename_component( WRF_LINK_FULL_FILE ${WRF_LINK_FILE} ABSOLUTE ) get_filename_component( WRF_LINK_FILE_ONLY ${WRF_LINK_FILE} NAME ) - get_filename_component( WRF_LINK_NEW_NAME_FULL_FILE ${WRF_LINK_NEW_NAME} REALPATH ) + get_filename_component( WRF_LINK_NEW_NAME_FULL_FILE ${WRF_LINK_NEW_NAME} ABSOLUTE ) get_filename_component( WRF_LINK_NEW_NAME_FILE_ONLY ${WRF_LINK_NEW_NAME} NAME ) # Left here for debug purposes, may want to turn this into a trace-level debug msg # message( "Generating install commands for ${WRF_LINK_FILE_ONLY} to ${WRF_LINK_NEW_NAME_FILE_ONLY}" ) install( CODE " - message( STATUS \"Creating symlinks for ${WRF_LINK_FILE_ONLY} (rename ${WRF_LINK_NEW_NAME_FILE_ONLY})\" ) + message( STATUS \"Creating symlinks for ${WRF_LINK_FILE} (rename ${WRF_LINK_NEW_NAME})\" ) execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink ${WRF_LINK_FULL_FILE} ${WRF_LINK_NEW_NAME_FULL_FILE} ) " COMPONENT links From 33f5c30f19bb259db26b3067681d07e6c856778b Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 29 Jun 2023 17:19:02 -0600 Subject: [PATCH 069/180] Final touches to linking and include files --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a85b6838be..02284faaa5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -521,6 +521,7 @@ target_include_directories( # These are already set up to be @ install location $ $ + $ $ $ $ @@ -572,6 +573,7 @@ target_include_directories( add_subdirectory( phys ) add_subdirectory( share ) add_subdirectory( frame ) +add_subdirectory( inc ) if ( ${WRF_CHEM} ) add_subdirectory( chem ) From 16091766e6f65f77d7d1b79113af84a5ecd8b683 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 30 Jun 2023 15:31:24 -0600 Subject: [PATCH 070/180] Adding base includes to install --- inc/CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 inc/CMakeLists.txt diff --git a/inc/CMakeLists.txt b/inc/CMakeLists.txt new file mode 100644 index 0000000000..afae9a9632 --- /dev/null +++ b/inc/CMakeLists.txt @@ -0,0 +1,13 @@ +get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set( + WRF_INCLUDE_FILES + intio_tags.h + streams.h + version_decl + ${PROJECT_BINARY_DIR}/inc/commit_decl + ) + +install( + FILES ${WRF_INCLUDE_FILES} + DESTINATION include/inc/${FOLDER_COMPILE_TARGET} + ) \ No newline at end of file From d74021dacf8d6726d222934c0cf86e70231b5a28 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 30 Jun 2023 15:32:25 -0600 Subject: [PATCH 071/180] Setting message out to smaller names --- cmake/wrf_case_setup.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/wrf_case_setup.cmake b/cmake/wrf_case_setup.cmake index e1460af588..838e180df5 100644 --- a/cmake/wrf_case_setup.cmake +++ b/cmake/wrf_case_setup.cmake @@ -90,7 +90,7 @@ macro( wrf_link_file_new_name ) # message( "Generating install commands for ${WRF_LINK_FILE_ONLY} to ${WRF_LINK_NEW_NAME_FILE_ONLY}" ) install( CODE " - message( STATUS \"Creating symlinks for ${WRF_LINK_FILE} (rename ${WRF_LINK_NEW_NAME})\" ) + message( STATUS \"Creating symlinks for ${WRF_LINK_FILE_ONLY} (rename ${WRF_LINK_NEW_NAME_FILE_ONLY})\" ) execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink ${WRF_LINK_FULL_FILE} ${WRF_LINK_NEW_NAME_FULL_FILE} ) " COMPONENT links From 5eab6f12e2c9bc0cceef86e1694a862f6459ed7f Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 30 Jun 2023 15:32:44 -0600 Subject: [PATCH 072/180] Removing old prefix --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 02284faaa5..9d6785d078 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,8 +52,6 @@ wrf_get_version( ${PROJECT_SOURCE_DIR}/README ) ## Options that can be user configured ## ################################################################################ -# set( CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/ ) - # Mode configuration set( OPTIMIZATION_LEVEL "" ) From 52e8d4ce735c98eb584c67e678a9f5f15a9dbfcb Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 3 Jul 2023 13:14:24 -0600 Subject: [PATCH 073/180] Resurrecting nl_set/get routines to maintain old makefile system --- frame/nl_get_0_routines.F | 1 + frame/nl_get_1_routines.F | 1 + frame/nl_get_2_routines.F | 1 + frame/nl_get_3_routines.F | 1 + frame/nl_get_4_routines.F | 1 + frame/nl_get_5_routines.F | 1 + frame/nl_get_6_routines.F | 1 + frame/nl_get_7_routines.F | 1 + frame/nl_set_0_routines.F | 1 + frame/nl_set_1_routines.F | 1 + frame/nl_set_2_routines.F | 1 + frame/nl_set_3_routines.F | 1 + frame/nl_set_4_routines.F | 1 + frame/nl_set_5_routines.F | 1 + frame/nl_set_6_routines.F | 1 + frame/nl_set_7_routines.F | 1 + 16 files changed, 16 insertions(+) create mode 100644 frame/nl_get_0_routines.F create mode 100644 frame/nl_get_1_routines.F create mode 100644 frame/nl_get_2_routines.F create mode 100644 frame/nl_get_3_routines.F create mode 100644 frame/nl_get_4_routines.F create mode 100644 frame/nl_get_5_routines.F create mode 100644 frame/nl_get_6_routines.F create mode 100644 frame/nl_get_7_routines.F create mode 100644 frame/nl_set_0_routines.F create mode 100644 frame/nl_set_1_routines.F create mode 100644 frame/nl_set_2_routines.F create mode 100644 frame/nl_set_3_routines.F create mode 100644 frame/nl_set_4_routines.F create mode 100644 frame/nl_set_5_routines.F create mode 100644 frame/nl_set_6_routines.F create mode 100644 frame/nl_set_7_routines.F diff --git a/frame/nl_get_0_routines.F b/frame/nl_get_0_routines.F new file mode 100644 index 0000000000..b24d607eb0 --- /dev/null +++ b/frame/nl_get_0_routines.F @@ -0,0 +1 @@ +dummy; make needs this to be happy diff --git a/frame/nl_get_1_routines.F b/frame/nl_get_1_routines.F new file mode 100644 index 0000000000..b24d607eb0 --- /dev/null +++ b/frame/nl_get_1_routines.F @@ -0,0 +1 @@ +dummy; make needs this to be happy diff --git a/frame/nl_get_2_routines.F b/frame/nl_get_2_routines.F new file mode 100644 index 0000000000..b24d607eb0 --- /dev/null +++ b/frame/nl_get_2_routines.F @@ -0,0 +1 @@ +dummy; make needs this to be happy diff --git a/frame/nl_get_3_routines.F b/frame/nl_get_3_routines.F new file mode 100644 index 0000000000..b24d607eb0 --- /dev/null +++ b/frame/nl_get_3_routines.F @@ -0,0 +1 @@ +dummy; make needs this to be happy diff --git a/frame/nl_get_4_routines.F b/frame/nl_get_4_routines.F new file mode 100644 index 0000000000..b24d607eb0 --- /dev/null +++ b/frame/nl_get_4_routines.F @@ -0,0 +1 @@ +dummy; make needs this to be happy diff --git a/frame/nl_get_5_routines.F b/frame/nl_get_5_routines.F new file mode 100644 index 0000000000..b24d607eb0 --- /dev/null +++ b/frame/nl_get_5_routines.F @@ -0,0 +1 @@ +dummy; make needs this to be happy diff --git a/frame/nl_get_6_routines.F b/frame/nl_get_6_routines.F new file mode 100644 index 0000000000..b24d607eb0 --- /dev/null +++ b/frame/nl_get_6_routines.F @@ -0,0 +1 @@ +dummy; make needs this to be happy diff --git a/frame/nl_get_7_routines.F b/frame/nl_get_7_routines.F new file mode 100644 index 0000000000..b24d607eb0 --- /dev/null +++ b/frame/nl_get_7_routines.F @@ -0,0 +1 @@ +dummy; make needs this to be happy diff --git a/frame/nl_set_0_routines.F b/frame/nl_set_0_routines.F new file mode 100644 index 0000000000..b24d607eb0 --- /dev/null +++ b/frame/nl_set_0_routines.F @@ -0,0 +1 @@ +dummy; make needs this to be happy diff --git a/frame/nl_set_1_routines.F b/frame/nl_set_1_routines.F new file mode 100644 index 0000000000..b24d607eb0 --- /dev/null +++ b/frame/nl_set_1_routines.F @@ -0,0 +1 @@ +dummy; make needs this to be happy diff --git a/frame/nl_set_2_routines.F b/frame/nl_set_2_routines.F new file mode 100644 index 0000000000..b24d607eb0 --- /dev/null +++ b/frame/nl_set_2_routines.F @@ -0,0 +1 @@ +dummy; make needs this to be happy diff --git a/frame/nl_set_3_routines.F b/frame/nl_set_3_routines.F new file mode 100644 index 0000000000..b24d607eb0 --- /dev/null +++ b/frame/nl_set_3_routines.F @@ -0,0 +1 @@ +dummy; make needs this to be happy diff --git a/frame/nl_set_4_routines.F b/frame/nl_set_4_routines.F new file mode 100644 index 0000000000..b24d607eb0 --- /dev/null +++ b/frame/nl_set_4_routines.F @@ -0,0 +1 @@ +dummy; make needs this to be happy diff --git a/frame/nl_set_5_routines.F b/frame/nl_set_5_routines.F new file mode 100644 index 0000000000..b24d607eb0 --- /dev/null +++ b/frame/nl_set_5_routines.F @@ -0,0 +1 @@ +dummy; make needs this to be happy diff --git a/frame/nl_set_6_routines.F b/frame/nl_set_6_routines.F new file mode 100644 index 0000000000..b24d607eb0 --- /dev/null +++ b/frame/nl_set_6_routines.F @@ -0,0 +1 @@ +dummy; make needs this to be happy diff --git a/frame/nl_set_7_routines.F b/frame/nl_set_7_routines.F new file mode 100644 index 0000000000..b24d607eb0 --- /dev/null +++ b/frame/nl_set_7_routines.F @@ -0,0 +1 @@ +dummy; make needs this to be happy From db73d7f72757ab6b5d169339c069b8b9ca7f7f35 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 5 Jul 2023 18:23:04 -0600 Subject: [PATCH 074/180] Removing these to reinstate the old stubs to support makefile build --- frame/module_dm.F | 376 ---------------------------------------------- tools/gen_comms.c | 15 -- 2 files changed, 391 deletions(-) delete mode 100644 frame/module_dm.F delete mode 100644 tools/gen_comms.c diff --git a/frame/module_dm.F b/frame/module_dm.F deleted file mode 100644 index d9f0aafff6..0000000000 --- a/frame/module_dm.F +++ /dev/null @@ -1,376 +0,0 @@ -!WRF:PACKAGE:NODM -! -MODULE module_dm - USE module_driver_constants - - LOGICAL intercomm_active( max_domains ), domain_active_this_task( max_domains ) - - CONTAINS - SUBROUTINE init_module_dm - intercomm_active = .TRUE. - domain_active_this_task = .TRUE. - END SUBROUTINE init_module_dm - - REAL FUNCTION wrf_dm_max_real ( inval ) - IMPLICIT NONE - REAL inval - wrf_dm_max_real = inval - END FUNCTION wrf_dm_max_real - - REAL FUNCTION wrf_dm_min_real ( inval ) - IMPLICIT NONE - REAL inval - wrf_dm_min_real = inval - END FUNCTION wrf_dm_min_real - - SUBROUTINE wrf_dm_min_reals ( inval, retval, n ) - IMPLICIT NONE - INTEGER, INTENT(IN) :: n - REAL, INTENT(IN) :: inval(:) - REAL, INTENT(OUT) :: retval(:) - retval(:) = inval(:) - END SUBROUTINE wrf_dm_min_reals - - REAL FUNCTION wrf_dm_sum_real ( inval ) - IMPLICIT NONE - REAL inval - wrf_dm_sum_real = inval - END FUNCTION wrf_dm_sum_real - - SUBROUTINE wrf_dm_sum_reals ( inval, retval ) - IMPLICIT NONE - REAL, INTENT(IN) :: inval(:) - REAL, INTENT(OUT) :: retval(:) - retval(:) = inval(:) - END SUBROUTINE wrf_dm_sum_reals - - INTEGER FUNCTION wrf_dm_sum_integer ( inval ) - IMPLICIT NONE - INTEGER inval - wrf_dm_sum_integer = inval - END FUNCTION wrf_dm_sum_integer - - SUBROUTINE wrf_dm_sum_integers ( inval, retval ) - IMPLICIT NONE - INTEGER, INTENT(IN) :: inval(:) - INTEGER, INTENT(OUT) :: retval(:) - retval(:) = inval(:) - END SUBROUTINE wrf_dm_sum_integers - - INTEGER FUNCTION wrf_dm_bxor_integer ( inval ) - IMPLICIT NONE - INTEGER inval - wrf_dm_bxor_integer = inval - END FUNCTION wrf_dm_bxor_integer - - SUBROUTINE wrf_dm_maxval ( val, idex, jdex ) - IMPLICIT NONE - REAL val - INTEGER idex, jdex - RETURN - END SUBROUTINE wrf_dm_maxval - - SUBROUTINE wrf_dm_minval ( val, idex, jdex ) - IMPLICIT NONE - REAL val - INTEGER idex, jdex - RETURN - END SUBROUTINE wrf_dm_minval - - SUBROUTINE wrf_dm_maxtile_real ( val , tile) - IMPLICIT NONE - REAL val - INTEGER tile - END SUBROUTINE wrf_dm_maxtile_real - - SUBROUTINE wrf_dm_mintile_double ( val , tile) - IMPLICIT NONE - DOUBLE PRECISION val - INTEGER tile - END SUBROUTINE wrf_dm_mintile_double - - SUBROUTINE wrf_dm_tile_val_int ( val , tile) - IMPLICIT NONE - INTEGER val - INTEGER tile - END SUBROUTINE wrf_dm_tile_val_int - -! stub - SUBROUTINE wrf_dm_move_nest ( parent, nest, dx, dy ) - USE module_domain - TYPE (domain), INTENT(INOUT) :: parent, nest - INTEGER, INTENT(IN) :: dx,dy - RETURN - END SUBROUTINE wrf_dm_move_nest - -END MODULE module_dm - -!========================================================================= - -! These are stub functions that do the right thing (usually nothing) -! in case DM_PARALLEL is not compiled for. -! This file, src/module_dm_stubs.F is copied to src/module_dm.F when -! the code is built. -! If, on the other hand, a DM package is specified, the module_dm.F -! provided with that package (e.g. RSL) is copied from /external/RSL/module_dm.F -! into src/module_dm.F. -! It is important to recognize this, because changes directly to src/module_dm.F -! will be lost! - -LOGICAL FUNCTION wrf_dm_on_monitor() - wrf_dm_on_monitor = .true. -END FUNCTION wrf_dm_on_monitor - -INTEGER FUNCTION wrf_dm_monitor_rank() - wrf_dm_monitor_rank = 0 -END FUNCTION wrf_dm_monitor_rank - -SUBROUTINE wrf_get_myproc( myproc ) - IMPLICIT NONE - INTEGER myproc - myproc = 0 - RETURN -END SUBROUTINE wrf_get_myproc - -SUBROUTINE wrf_get_nproc( nprocs ) - IMPLICIT NONE - INTEGER nprocs - nprocs = 1 - RETURN -END SUBROUTINE wrf_get_nproc - -SUBROUTINE wrf_get_nprocx( nprocs ) - IMPLICIT NONE - INTEGER nprocs - nprocs = 1 - RETURN -END SUBROUTINE wrf_get_nprocx - -SUBROUTINE wrf_get_nprocy( nprocs ) - IMPLICIT NONE - INTEGER nprocs - nprocs = 1 - RETURN -END SUBROUTINE wrf_get_nprocy - -SUBROUTINE wrf_dm_bcast_string ( buf , size ) - IMPLICIT NONE - INTEGER size - INTEGER BUF(*) - RETURN -END SUBROUTINE wrf_dm_bcast_string - -SUBROUTINE wrf_dm_bcast_bytes ( buf , size ) - IMPLICIT NONE - INTEGER size - INTEGER BUF(*) - RETURN -END SUBROUTINE wrf_dm_bcast_bytes - -SUBROUTINE wrf_dm_bcast_integer( BUF, N1 ) - IMPLICIT NONE - INTEGER n1 - INTEGER buf(*) - RETURN -END SUBROUTINE wrf_dm_bcast_integer - -SUBROUTINE wrf_dm_bcast_real( BUF, N1 ) - IMPLICIT NONE - INTEGER n1 - REAL buf(*) - RETURN -END SUBROUTINE wrf_dm_bcast_real - -SUBROUTINE wrf_dm_bcast_logical( BUF, N1 ) - IMPLICIT NONE - INTEGER n1 - LOGICAL buf(*) - RETURN -END SUBROUTINE wrf_dm_bcast_logical - -SUBROUTINE wrf_dm_halo ( domdesc , comms , stencil_id ) - IMPLICIT NONE - INTEGER domdesc , comms(*) , stencil_id - RETURN -END SUBROUTINE wrf_dm_halo - -SUBROUTINE wrf_dm_boundary ( domdesc , comms , period_id , & - periodic_x , periodic_y ) - IMPLICIT NONE - INTEGER domdesc , comms(*) , period_id - LOGICAL , INTENT(IN) :: periodic_x, periodic_y - RETURN -END SUBROUTINE wrf_dm_boundary - -SUBROUTINE wrf_dm_xpose_z2x ( domdesc , comms , xpose_id ) - IMPLICIT NONE - INTEGER domdesc , comms(*), xpose_id - RETURN -END SUBROUTINE wrf_dm_xpose_z2x -SUBROUTINE wrf_dm_xpose_x2y ( domdesc , comms , xpose_id ) - IMPLICIT NONE - INTEGER domdesc , comms(*), xpose_id - RETURN -END SUBROUTINE wrf_dm_xpose_x2y -SUBROUTINE wrf_dm_xpose_y2z ( domdesc , comms , xpose_id ) - IMPLICIT NONE - INTEGER domdesc , comms(*), xpose_id - RETURN -END SUBROUTINE wrf_dm_xpose_y2z - -SUBROUTINE wrf_dm_define_comms ( grid ) - USE module_domain - IMPLICIT NONE - TYPE(domain) , INTENT (INOUT) :: grid - RETURN -END SUBROUTINE wrf_dm_define_comms - -SUBROUTINE wrf_get_dm_communicator ( communicator ) - IMPLICIT NONE - INTEGER , INTENT(OUT) :: communicator - communicator = 0 - RETURN -END SUBROUTINE wrf_get_dm_communicator - -SUBROUTINE wrf_get_dm_iocommunicator ( iocommunicator ) - IMPLICIT NONE - INTEGER , INTENT(OUT) :: iocommunicator - iocommunicator = 0 - RETURN -END SUBROUTINE wrf_get_dm_iocommunicator - -SUBROUTINE wrf_dm_shutdown - RETURN -END SUBROUTINE wrf_dm_shutdown -SUBROUTINE wrf_abort - STOP 'wrf_abort' -END SUBROUTINE wrf_abort - -SUBROUTINE wrf_patch_to_global_real (buf,globbuf,domdesc,ndim,& - ids,ide,jds,jde,kds,kde,& - ims,ime,jms,jme,kms,kme,& - ips,ipe,jps,jpe,kps,kpe ) - IMPLICIT NONE - INTEGER ids,ide,jds,jde,kds,kde,& - ims,ime,jms,jme,kms,kme,& - ips,ipe,jps,jpe,kps,kpe - INTEGER fid,domdesc,ndim,glen(3),llen(3) - REAL globbuf(*) - REAL buf(*) - RETURN -END SUBROUTINE wrf_patch_to_global_real - -SUBROUTINE wrf_global_to_patch_real (globbuf,buf,domdesc,ndim,& - ids,ide,jds,jde,kds,kde,& - ims,ime,jms,jme,kms,kme,& - ips,ipe,jps,jpe,kps,kpe ) - IMPLICIT NONE - INTEGER ids,ide,jds,jde,kds,kde,& - ims,ime,jms,jme,kms,kme,& - ips,ipe,jps,jpe,kps,kpe - INTEGER fid,domdesc,ndim,glen(3),llen(3) - REAL globbuf(*) - REAL buf(*) - RETURN -END SUBROUTINE wrf_global_to_patch_real - - -SUBROUTINE wrf_patch_to_global_double (buf,globbuf,domdesc,ndim,& - ids,ide,jds,jde,kds,kde,& - ims,ime,jms,jme,kms,kme,& - ips,ipe,jps,jpe,kps,kpe ) - IMPLICIT NONE - INTEGER ids,ide,jds,jde,kds,kde,& - ims,ime,jms,jme,kms,kme,& - ips,ipe,jps,jpe,kps,kpe - INTEGER fid,domdesc,ndim,glen(3),llen(3) - DOUBLE PRECISION globbuf(*) - DOUBLE PRECISION buf(*) - RETURN -END SUBROUTINE wrf_patch_to_global_double - -SUBROUTINE wrf_global_to_patch_double (globbuf,buf,domdesc,ndim,& - ids,ide,jds,jde,kds,kde,& - ims,ime,jms,jme,kms,kme,& - ips,ipe,jps,jpe,kps,kpe ) - IMPLICIT NONE - INTEGER ids,ide,jds,jde,kds,kde,& - ims,ime,jms,jme,kms,kme,& - ips,ipe,jps,jpe,kps,kpe - INTEGER fid,domdesc,ndim,glen(3),llen(3) - DOUBLE PRECISION globbuf(*) - DOUBLE PRECISION buf(*) - RETURN -END SUBROUTINE wrf_global_to_patch_double - -SUBROUTINE wrf_patch_to_global_integer (buf,globbuf,domdesc,ndim,& - ids,ide,jds,jde,kds,kde,& - ims,ime,jms,jme,kms,kme,& - ips,ipe,jps,jpe,kps,kpe ) - IMPLICIT NONE - INTEGER ids,ide,jds,jde,kds,kde,& - ims,ime,jms,jme,kms,kme,& - ips,ipe,jps,jpe,kps,kpe - INTEGER fid,domdesc,ndim,glen(3),llen(3) - INTEGER globbuf(*) - INTEGER buf(*) - RETURN -END SUBROUTINE wrf_patch_to_global_integer - -SUBROUTINE wrf_global_to_patch_integer (globbuf,buf,domdesc,ndim,& - ids,ide,jds,jde,kds,kde,& - ims,ime,jms,jme,kms,kme,& - ips,ipe,jps,jpe,kps,kpe ) - IMPLICIT NONE - INTEGER ids,ide,jds,jde,kds,kde,& - ims,ime,jms,jme,kms,kme,& - ips,ipe,jps,jpe,kps,kpe - INTEGER fid,domdesc,ndim,glen(3),llen(3) - INTEGER globbuf(*) - INTEGER buf(*) - RETURN -END SUBROUTINE wrf_global_to_patch_integer - -SUBROUTINE wrf_patch_to_global_logical (buf,globbuf,domdesc,ndim,& - ids,ide,jds,jde,kds,kde,& - ims,ime,jms,jme,kms,kme,& - ips,ipe,jps,jpe,kps,kpe ) - IMPLICIT NONE - INTEGER ids,ide,jds,jde,kds,kde,& - ims,ime,jms,jme,kms,kme,& - ips,ipe,jps,jpe,kps,kpe - INTEGER fid,domdesc,ndim,glen(3),llen(3) - LOGICAL globbuf(*) - LOGICAL buf(*) - RETURN -END SUBROUTINE wrf_patch_to_global_logical - -SUBROUTINE wrf_global_to_patch_LOGICAL (globbuf,buf,domdesc,ndim,& - ids,ide,jds,jde,kds,kde,& - ims,ime,jms,jme,kms,kme,& - ips,ipe,jps,jpe,kps,kpe ) - IMPLICIT NONE - INTEGER ids,ide,jds,jde,kds,kde,& - ims,ime,jms,jme,kms,kme,& - ips,ipe,jps,jpe,kps,kpe - INTEGER fid,domdesc,ndim,glen(3),llen(3) - LOGICAL globbuf(*) - LOGICAL buf(*) - RETURN -END SUBROUTINE wrf_global_to_patch_LOGICAL - - SUBROUTINE push_communicators_for_domain( id ) - IMPLICIT NONE - INTEGER, OPTIONAL, INTENT(IN) :: id ! if specified also does an instate for grid id - END SUBROUTINE push_communicators_for_domain - SUBROUTINE pop_communicators_for_domain - END SUBROUTINE pop_communicators_for_domain - SUBROUTINE instate_communicators_for_domain( id ) - IMPLICIT NONE - INTEGER, INTENT(IN) :: id - END SUBROUTINE instate_communicators_for_domain - SUBROUTINE store_communicators_for_domain( id ) - IMPLICIT NONE - INTEGER, INTENT(IN) :: id - END SUBROUTINE store_communicators_for_domain - diff --git a/tools/gen_comms.c b/tools/gen_comms.c deleted file mode 100644 index b079afe8d5..0000000000 --- a/tools/gen_comms.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include - -#include "protos.h" -#include "registry.h" -#include "data.h" - -int -gen_comms ( char * dirname ) -{ - if ( sw_dm_parallel ) - fprintf(stderr,"WARNING: stub version of gen_comms is linked in with registry program.\n") ; - - return(0) ; -} From cad26c6f02c1de0f31e79882d3724eedb05db41e Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 5 Jul 2023 18:24:30 -0600 Subject: [PATCH 075/180] Adjusting include paths for removal of redundant code --- external/io_grib1/Makefile | 2 +- external/io_grib_share/Makefile | 6 +++--- external/io_int/makefile | 5 +---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/external/io_grib1/Makefile b/external/io_grib1/Makefile index 6afcf4d760..a222b2dbfe 100644 --- a/external/io_grib1/Makefile +++ b/external/io_grib1/Makefile @@ -10,7 +10,7 @@ # # Specity location for Makefiles that are included. # -INCLUDEDIRS = -I. -I./MEL_grib1 -Igrib1_util -I../io_grib_share -I../ +INCLUDEDIRS = -I. -I./MEL_grib1 -Igrib1_util -I../io_grib_share -I../ -I../ioapi_share BUILD_DIR = $(IO_GRIB_SHARE_DIR)../io_grib_share/build # # Specify directory that output library is to be put in. diff --git a/external/io_grib_share/Makefile b/external/io_grib_share/Makefile index 41d3c96659..5e3a59db55 100644 --- a/external/io_grib_share/Makefile +++ b/external/io_grib_share/Makefile @@ -22,9 +22,9 @@ LIB_DEST = . # CXX_INCLUDES is for C++ files # C_INCLUDES is for C files # -C_INCLUDES = -I. -CXX_INCLUDES = -I. -F_INCLUDES = -I. +C_INCLUDES = -I. -I../ioapi_share +CXX_INCLUDES = -I. -I../ioapi_share +F_INCLUDES = -I. -I../ioapi_share AR = ar ARFLAGS = cruv diff --git a/external/io_int/makefile b/external/io_int/makefile index 3033670e32..7bc484968e 100644 --- a/external/io_int/makefile +++ b/external/io_int/makefile @@ -32,11 +32,8 @@ io_int.f: io_int.F90 module_internal_header_util.o io_int.o: io_int.f ../../inc/intio_tags.h $(FC) $(FCFLAGS) -I../../inc -I../ioapi_share -o $@ -c $*.f -io_int_idx_tags.h: ../../inc/intio_tags.h - awk '{print "#define", toupper($$4), $$6}' < ../../inc/intio_tags.h > $@ - io_int_idx.o: io_int_idx.c io_int_idx.h io_int_idx_tags.h - $(CC) -o $@ -c $(CFLAGS_LOCAL) $*.c + $(CC) -I../../inc -o $@ -c $(CFLAGS_LOCAL) $*.c module_io_int_idx.o: module_io_int_idx.f $(FC) $(FCFLAGS) -o $@ -c $*.f From cb108d878839b5f486c938359496918bf2e7e132 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 5 Jul 2023 18:24:52 -0600 Subject: [PATCH 076/180] Using original stub file names --- frame/CMakeLists.txt | 2 +- tools/CMakeLists.txt | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/frame/CMakeLists.txt b/frame/CMakeLists.txt index a315494a99..f4dd49e63f 100644 --- a/frame/CMakeLists.txt +++ b/frame/CMakeLists.txt @@ -82,7 +82,7 @@ target_include_directories( # Now define base framework # ######################################################################################################################## -set( MODULE_DM module_dm.F ) +set( MODULE_DM module_dm_stubs.F ) if ( ${USE_MPI} ) set( MODULE_DM ${PROJECT_SOURCE_DIR}/external/RSL_LITE/module_dm.F ) endif() diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 375bab59cf..3b0226a835 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -7,9 +7,17 @@ add_executable( ${FOLDER_COMPILE_TARGET} ) -set( GEN_COMMS gen_comms.c ) +set( GEN_COMMS gen_comms.stub ) if ( ${USE_MPI} ) set( GEN_COMMS ${PROJECT_SOURCE_DIR}/external/RSL_LITE/gen_comms.c ) +else() + # Account for the weird makefile nonsense of copying things around + set_source_files_properties( + gen_comms.stub + TARGET_DIRECTORY ${FOLDER_COMPILE_TARGET} + PROPERTIES + LANGUAGE C + ) endif() target_sources( From 73bc589b13b5567dad7a2e5786c249ddd0bcad94 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 6 Jul 2023 15:07:07 -0600 Subject: [PATCH 077/180] Adding check for large file support --- cmake/modules/FindnetCDF.cmake | 9 +++++++++ cmake/modules/FindpnetCDF.cmake | 10 +++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/cmake/modules/FindnetCDF.cmake b/cmake/modules/FindnetCDF.cmake index f9051f0792..dbc3f92746 100644 --- a/cmake/modules/FindnetCDF.cmake +++ b/cmake/modules/FindnetCDF.cmake @@ -33,6 +33,15 @@ else() execute_process( COMMAND ${NETCDF_PROGRAM} --has-pnetcdf OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_PNETCDF_YES ) execute_process( COMMAND ${NETCDF_PROGRAM} --has-parallel OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_PARALLEL_YES ) + # check for large file support + find_file( netCDF_INCLUDE_FILE netcdf.inc ${netCDF_INCLUDE_DIR} ) + file( READ ${netCDF_INCLUDE_FILE} netCDF_INCLUDE_FILE_STR ) + string( FIND "${netCDF_INCLUDE_FILE_STR}" "nf_format_64bit" netCDF_LARGE_FILE_SUPPORT_FOUND ) + if ( ${netCDF_SUPPORT_LARGE_FILE_FOUND} EQUAL -1 ) + set( netCDF_LARGE_FILE_SUPPORT "NO" ) + else() + set( netCDF_LARGE_FILE_SUPPORT "YES" ) + endif() # Sanitize version string( REPLACE " " ";" netCDF_VERSION_LIST ${netCDF_VERSION_RAW} ) diff --git a/cmake/modules/FindpnetCDF.cmake b/cmake/modules/FindpnetCDF.cmake index 3db3c9dedf..7ba3bcb0d0 100644 --- a/cmake/modules/FindpnetCDF.cmake +++ b/cmake/modules/FindpnetCDF.cmake @@ -31,7 +31,15 @@ else() execute_process( COMMAND ${PNETCDF_PROGRAM} --has-c++ OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE pnetCDF_CXX_YES ) execute_process( COMMAND ${PNETCDF_PROGRAM} --has-fortran OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE pnetCDF_FORTRAN_YES ) - + # check for large file support + find_file( pnetCDF_INCLUDE_FILE pnetcdf.inc ${pnetCDF_INCLUDE_DIR} ) + file( READ ${pnetCDF_INCLUDE_FILE} pnetCDF_INCLUDE_FILE_STR ) + string( FIND "${pnetCDF_INCLUDE_FILE_STR}" "nf_format_64bit" pnetCDF_LARGE_FILE_SUPPORT_FOUND ) + if ( ${pnetCDF_SUPPORT_LARGE_FILE_FOUND} EQUAL -1 ) + set( pnetCDF_LARGE_FILE_SUPPORT "NO" ) + else() + set( pnetCDF_LARGE_FILE_SUPPORT "YES" ) + endif() # Sanitize version string( REPLACE " " ";" pnetCDF_VERSION_LIST ${pnetCDF_VERSION_RAW} ) From cf4ecaa464137392338bc1c00c80375f14b73663 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 6 Jul 2023 15:08:18 -0600 Subject: [PATCH 078/180] Typo in adding definitions --- confcheck/CMakeLists.txt | 61 ++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/confcheck/CMakeLists.txt b/confcheck/CMakeLists.txt index bf204a3947..2f896dc8b7 100644 --- a/confcheck/CMakeLists.txt +++ b/confcheck/CMakeLists.txt @@ -45,42 +45,43 @@ wrf_conf_check( wrf_conf_check( RUN - SOURCE_TYPE C - RESULT_VAR FSEEKO64 - SOURCE ${PROJECT_SOURCE_DIR}/tools/fseek_test.c - EXTENSION .c - ADDITIONAL_DEFINTIONS -DTEST_FSEEKO64 - MESSAGE "fseeko64 not supported, checking alternate fseeko" + SOURCE_TYPE C + RESULT_VAR FSEEKO64 + SOURCE ${PROJECT_SOURCE_DIR}/tools/fseek_test.c + EXTENSION .c + ADDITIONAL_DEFINITIONS -DTEST_FSEEKO64 + 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_DEFINTIONS -DTEST_FSEEKO - MESSAGE "fseeko not supported, compiling with fseek (caution with large files)" + SOURCE_TYPE C + RESULT_VAR FSEEKO + SOURCE ${PROJECT_SOURCE_DIR}/tools/fseek_test.c + EXTENSION .c + ADDITIONAL_DEFINITIONS -DTEST_FSEEKO + MESSAGE "fseeko not supported, compiling with fseek (caution with large files)" ) endif() -if ( ${USE_MPI} ) - wrf_conf_check( - RUN - SOURCE_TYPE C - RESULT_VAR MPI2_SUPPORT - SOURCE ${PROJECT_SOURCE_DIR}/tools/mpi2_test.c - EXTENSION .c - MESSAGE "MPI_Comm_f2c() and MPI_Comm_c2f() not supported" - ) +# Unsure if this is even necessary. Defines littered throughout configure.defaults +# if ( ${USE_MPI} ) +# wrf_conf_check( +# RUN +# SOURCE_TYPE C +# RESULT_VAR MPI2_SUPPORT +# SOURCE ${PROJECT_SOURCE_DIR}/tools/mpi2_test.c +# EXTENSION .c +# MESSAGE "MPI_Comm_f2c() and MPI_Comm_c2f() not supported" +# ) - wrf_conf_check( - RUN - SOURCE_TYPE C - RESULT_VAR MPI2_THREAD_SUPPORT - SOURCE ${PROJECT_SOURCE_DIR}/tools/mpi2_thread_test.c - EXTENSION .c - MESSAGE "MPI_Init_thread() not supported" - ) -endif() \ No newline at end of file +# wrf_conf_check( +# RUN +# SOURCE_TYPE C +# RESULT_VAR MPI2_THREAD_SUPPORT +# SOURCE ${PROJECT_SOURCE_DIR}/tools/mpi2_thread_test.c +# EXTENSION .c +# MESSAGE "MPI_Init_thread() not supported" +# ) +# endif() \ No newline at end of file From ad0620d9c61bc3ba19761e79b3eaa193a7aa6370 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 6 Jul 2023 15:09:48 -0600 Subject: [PATCH 079/180] Sanitizing in situ code compile/run checks --- cmake/confcheck.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/confcheck.cmake b/cmake/confcheck.cmake index 0838637ce9..5db8469519 100644 --- a/cmake/confcheck.cmake +++ b/cmake/confcheck.cmake @@ -23,6 +23,9 @@ macro( wrf_conf_check ) 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() From 8dedc4717c1fa032ec847f8809e776fead68ba53 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 6 Jul 2023 15:10:30 -0600 Subject: [PATCH 080/180] Adding proper logic for large file support and nc4 features --- CMakeLists.txt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d6785d078..816e786e23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,8 +147,10 @@ set( GRIB1 ON CACHE BOOL "GRIB1" ) set( INTIO ON CACHE BOOL "INTIO" ) set( KEEP_INT_AROUND ON CACHE BOOL "KEEP_INT_AROUND" ) set( LIMIT_ARGS ON CACHE BOOL "LIMIT_ARGS" ) -set( WRFIO_NCD_NO_LARGE_FILE_SUPPORT OFF CACHE BOOL "WRFIO_NCD_NO_LARGE_FILE_SUPPORT" ) +# 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" ) set( FORCE_NETCDF_CLASSIC OFF CACHE BOOL "FORCE_NETCDF_CLASSIC" ) set( BUILD_RRTMG_FAST OFF CACHE BOOL "BUILD_RRTMG_FAST" ) set( BUILD_RRTMK OFF CACHE BOOL "BUILD_RRTMK" ) @@ -251,6 +253,10 @@ if ( ${CURRENT_CASE_IDX} LESS ${START_GENERAL_IDEAL_CASE_IDX} ) set( WRF_GENERAL_IDEAL_CASE FALSE ) endif() +if ( NOT ${WRFIO_NCD_NO_LARGE_FILE_SUPPORT} ) + message( STATUS "netCDF large file support not suppressed, if available it will be used" ) +endif() + if ( DEFINED CMAKE_TOOLCHAIN_FILE ) print_option( WRF_CONFIG 20 ${BOLD_CYAN} ) @@ -434,12 +440,12 @@ add_compile_definitions( # If force classic or no nc-4 support enable classic $<$,$>>:NETCDF_classic=1> - $<$:WRFIO_NCD_NO_LARGE_FILE_SUPPORT=$> - # TODO Figure out how these should be set - # DUSE_NETCDF4_FEATURES -DWRFIO_NCD_LARGE_FILE_SUPPORT + $<$,$>>:WRFIO_NCD_NO_LARGE_FILE_SUPPORT=1> + # May need a check for WRFIO_ncdpar_LARGE_FILE_SUPPORT - $<$:MPI2_SUPPORT=$> - $<$:MPI2_THREAD_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) From 22fe732a198e407faba22dd5f1a3f93a65fb138f Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 6 Jul 2023 15:11:42 -0600 Subject: [PATCH 081/180] Removing or commenting obsolete code --- CMakeLists.txt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 816e786e23..f738371378 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -198,16 +198,9 @@ endif() ################################################################################ ## -## Load alternate OS/architecture to be compiled for if cross-compiling +## Load options selected and any ancillary logic ## ################################################################################ -if ( ${WRF_OS} ) - # Need a good way of condensing this down - set( WRF_ARCH_FILE ${WRF_OS} ) - - set( CMAKE_TOOLCHAIN_FILE "" ) -endif() - # Check WRF options if ( NOT ${WRF_CORE} IN_LIST WRF_CORE_OPTIONS ) @@ -497,6 +490,10 @@ add_compile_definitions( # 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=$> + ) From 633c6c7683a41380f9dfc495f2fc4cea9531455b Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 6 Jul 2023 15:32:59 -0600 Subject: [PATCH 082/180] Fixing variable typo --- cmake/modules/FindnetCDF.cmake | 2 +- cmake/modules/FindpnetCDF.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/modules/FindnetCDF.cmake b/cmake/modules/FindnetCDF.cmake index dbc3f92746..da0faec44a 100644 --- a/cmake/modules/FindnetCDF.cmake +++ b/cmake/modules/FindnetCDF.cmake @@ -37,7 +37,7 @@ else() find_file( netCDF_INCLUDE_FILE netcdf.inc ${netCDF_INCLUDE_DIR} ) file( READ ${netCDF_INCLUDE_FILE} netCDF_INCLUDE_FILE_STR ) string( FIND "${netCDF_INCLUDE_FILE_STR}" "nf_format_64bit" netCDF_LARGE_FILE_SUPPORT_FOUND ) - if ( ${netCDF_SUPPORT_LARGE_FILE_FOUND} EQUAL -1 ) + if ( ${netCDF_LARGE_FILE_SUPPORT_FOUND} EQUAL -1 ) set( netCDF_LARGE_FILE_SUPPORT "NO" ) else() set( netCDF_LARGE_FILE_SUPPORT "YES" ) diff --git a/cmake/modules/FindpnetCDF.cmake b/cmake/modules/FindpnetCDF.cmake index 7ba3bcb0d0..3606b94ba2 100644 --- a/cmake/modules/FindpnetCDF.cmake +++ b/cmake/modules/FindpnetCDF.cmake @@ -35,7 +35,7 @@ else() find_file( pnetCDF_INCLUDE_FILE pnetcdf.inc ${pnetCDF_INCLUDE_DIR} ) file( READ ${pnetCDF_INCLUDE_FILE} pnetCDF_INCLUDE_FILE_STR ) string( FIND "${pnetCDF_INCLUDE_FILE_STR}" "nf_format_64bit" pnetCDF_LARGE_FILE_SUPPORT_FOUND ) - if ( ${pnetCDF_SUPPORT_LARGE_FILE_FOUND} EQUAL -1 ) + if ( ${pnetCDF_LARGE_FILE_SUPPORT_FOUND} EQUAL -1 ) set( pnetCDF_LARGE_FILE_SUPPORT "NO" ) else() set( pnetCDF_LARGE_FILE_SUPPORT "YES" ) From 1907754944e574cc9d3a673635c048088cc93711 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 7 Jul 2023 17:17:43 -0600 Subject: [PATCH 083/180] Exporting module directory and adding that to include path for WRF_Core --- CMakeLists.txt | 6 +++--- external/RSL_LITE/CMakeLists.txt | 1 + external/atm_ocn/CMakeLists.txt | 1 + external/esmf_time_f90/CMakeLists.txt | 1 + external/fftpack/fftpack5/CMakeLists.txt | 1 + external/io_adios2/CMakeLists.txt | 1 + external/io_esmf/CMakeLists.txt | 1 + external/io_grib1/CMakeLists.txt | 1 + external/io_grib1/MEL_grib1/CMakeLists.txt | 1 + external/io_grib1/WGRIB/CMakeLists.txt | 1 + external/io_grib1/grib1_util/CMakeLists.txt | 1 + external/io_grib2/bacio-1.3/CMakeLists.txt | 1 + external/io_grib2/g2lib/CMakeLists.txt | 1 + external/io_grib_share/CMakeLists.txt | 1 + external/io_netcdf/CMakeLists.txt | 1 + external/io_netcdfpar/CMakeLists.txt | 1 + external/io_pio/CMakeLists.txt | 1 + external/io_pnetcdf/CMakeLists.txt | 1 + 18 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f738371378..172e33f96f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -529,6 +529,8 @@ target_include_directories( $ $ + $ + $ $ @@ -597,9 +599,7 @@ set_target_properties( # Just dump everything in here Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/modules/ Fortran_FORMAT FREE - # INSTALL_RPATH ${netCDF_LIBRARY_DIR} - # ${pnetCDF_LIBRARY_DIR} - # ${} + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY ) target_link_libraries( ${PROJECT_NAME}_Core diff --git a/external/RSL_LITE/CMakeLists.txt b/external/RSL_LITE/CMakeLists.txt index 27382f77a8..5f38783343 100644 --- a/external/RSL_LITE/CMakeLists.txt +++ b/external/RSL_LITE/CMakeLists.txt @@ -26,6 +26,7 @@ set_target_properties( ${FOLDER_COMPILE_TARGET} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY ) diff --git a/external/atm_ocn/CMakeLists.txt b/external/atm_ocn/CMakeLists.txt index 5f89ce0b03..2fe79f79d3 100644 --- a/external/atm_ocn/CMakeLists.txt +++ b/external/atm_ocn/CMakeLists.txt @@ -22,6 +22,7 @@ set_target_properties( PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} Fortran_FORMAT FIXED + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY ) diff --git a/external/esmf_time_f90/CMakeLists.txt b/external/esmf_time_f90/CMakeLists.txt index d0718a22a8..3bba5fdd69 100644 --- a/external/esmf_time_f90/CMakeLists.txt +++ b/external/esmf_time_f90/CMakeLists.txt @@ -36,6 +36,7 @@ set_target_properties( ${FOLDER_COMPILE_TARGET} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY ) diff --git a/external/fftpack/fftpack5/CMakeLists.txt b/external/fftpack/fftpack5/CMakeLists.txt index 9e75543fd5..1ae8c648de 100644 --- a/external/fftpack/fftpack5/CMakeLists.txt +++ b/external/fftpack/fftpack5/CMakeLists.txt @@ -29,6 +29,7 @@ set_target_properties( PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} Fortran_FORMAT FREE + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY ) target_link_libraries( ${FOLDER_COMPILE_TARGET} diff --git a/external/io_adios2/CMakeLists.txt b/external/io_adios2/CMakeLists.txt index 0cc7a5e86b..19af28fa39 100644 --- a/external/io_adios2/CMakeLists.txt +++ b/external/io_adios2/CMakeLists.txt @@ -12,6 +12,7 @@ set_target_properties( ${FOLDER_COMPILE_TARGET} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY ) diff --git a/external/io_esmf/CMakeLists.txt b/external/io_esmf/CMakeLists.txt index 8b6ce33b0d..522e20bc00 100644 --- a/external/io_esmf/CMakeLists.txt +++ b/external/io_esmf/CMakeLists.txt @@ -24,6 +24,7 @@ set_target_properties( ${FOLDER_COMPILE_TARGET} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY ) diff --git a/external/io_grib1/CMakeLists.txt b/external/io_grib1/CMakeLists.txt index 83025c0f19..c21a07be84 100644 --- a/external/io_grib1/CMakeLists.txt +++ b/external/io_grib1/CMakeLists.txt @@ -25,6 +25,7 @@ set_target_properties( PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} Fortran_FORMAT FREE + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY ) diff --git a/external/io_grib1/MEL_grib1/CMakeLists.txt b/external/io_grib1/MEL_grib1/CMakeLists.txt index 99e2c323cc..e71916daea 100644 --- a/external/io_grib1/MEL_grib1/CMakeLists.txt +++ b/external/io_grib1/MEL_grib1/CMakeLists.txt @@ -51,6 +51,7 @@ set_target_properties( ${FOLDER_COMPILE_TARGET} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY ) diff --git a/external/io_grib1/WGRIB/CMakeLists.txt b/external/io_grib1/WGRIB/CMakeLists.txt index 5d99e01f88..9003a6c8b3 100644 --- a/external/io_grib1/WGRIB/CMakeLists.txt +++ b/external/io_grib1/WGRIB/CMakeLists.txt @@ -54,6 +54,7 @@ set_target_properties( ${FOLDER_COMPILE_TARGET} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY ) diff --git a/external/io_grib1/grib1_util/CMakeLists.txt b/external/io_grib1/grib1_util/CMakeLists.txt index d3ccae3f73..ad995d3c03 100644 --- a/external/io_grib1/grib1_util/CMakeLists.txt +++ b/external/io_grib1/grib1_util/CMakeLists.txt @@ -19,6 +19,7 @@ set_target_properties( ${FOLDER_COMPILE_TARGET} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY ) diff --git a/external/io_grib2/bacio-1.3/CMakeLists.txt b/external/io_grib2/bacio-1.3/CMakeLists.txt index 0915a4ffab..450cb510ed 100644 --- a/external/io_grib2/bacio-1.3/CMakeLists.txt +++ b/external/io_grib2/bacio-1.3/CMakeLists.txt @@ -18,6 +18,7 @@ set_target_properties( ${FOLDER_COMPILE_TARGET} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY ) diff --git a/external/io_grib2/g2lib/CMakeLists.txt b/external/io_grib2/g2lib/CMakeLists.txt index d05515e93c..70246d4d16 100644 --- a/external/io_grib2/g2lib/CMakeLists.txt +++ b/external/io_grib2/g2lib/CMakeLists.txt @@ -78,6 +78,7 @@ set_target_properties( ${FOLDER_COMPILE_TARGET} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY # Fortran_FORMAT FREE ) diff --git a/external/io_grib_share/CMakeLists.txt b/external/io_grib_share/CMakeLists.txt index 06109be2a3..f62d453e8b 100644 --- a/external/io_grib_share/CMakeLists.txt +++ b/external/io_grib_share/CMakeLists.txt @@ -21,6 +21,7 @@ set_target_properties( PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} Fortran_FORMAT FREE + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY ) diff --git a/external/io_netcdf/CMakeLists.txt b/external/io_netcdf/CMakeLists.txt index 236c2001d4..6a86c29f9c 100644 --- a/external/io_netcdf/CMakeLists.txt +++ b/external/io_netcdf/CMakeLists.txt @@ -12,6 +12,7 @@ set_target_properties( ${FOLDER_COMPILE_TARGET} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY ) diff --git a/external/io_netcdfpar/CMakeLists.txt b/external/io_netcdfpar/CMakeLists.txt index 236c2001d4..6a86c29f9c 100644 --- a/external/io_netcdfpar/CMakeLists.txt +++ b/external/io_netcdfpar/CMakeLists.txt @@ -12,6 +12,7 @@ set_target_properties( ${FOLDER_COMPILE_TARGET} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY ) diff --git a/external/io_pio/CMakeLists.txt b/external/io_pio/CMakeLists.txt index 04e38b4445..130b8921d3 100644 --- a/external/io_pio/CMakeLists.txt +++ b/external/io_pio/CMakeLists.txt @@ -23,6 +23,7 @@ set_target_properties( ${FOLDER_COMPILE_TARGET} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY ) diff --git a/external/io_pnetcdf/CMakeLists.txt b/external/io_pnetcdf/CMakeLists.txt index 600746a37c..64a01b9b31 100644 --- a/external/io_pnetcdf/CMakeLists.txt +++ b/external/io_pnetcdf/CMakeLists.txt @@ -12,6 +12,7 @@ set_target_properties( ${FOLDER_COMPILE_TARGET} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} + EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY ) From eaa9f4d6c70e80c5add0fc804a7d40415078d18b Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 7 Jul 2023 17:47:49 -0600 Subject: [PATCH 084/180] Don't make cxx lib required for netcdf --- cmake/modules/FindnetCDF.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/FindnetCDF.cmake b/cmake/modules/FindnetCDF.cmake index da0faec44a..6768e2aaec 100644 --- a/cmake/modules/FindnetCDF.cmake +++ b/cmake/modules/FindnetCDF.cmake @@ -72,7 +72,7 @@ find_package_handle_standard_args( netCDF DEFAULT_MSG netCDF_INCLUDE_DIRS netCDF_LIBRARY_DIR netCDF_CLIBS - netCDF_CXXLIBS + # netCDF_CXXLIBS netCDF_FLIBS netCDF_VERSION ) From 8849b86c24b9a067257e3e33e97814373d0666bd Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 7 Jul 2023 17:52:36 -0600 Subject: [PATCH 085/180] Don't use RSL_LITE if no MPI --- external/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 0d4bbc86f2..cbf5c70463 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -77,7 +77,8 @@ if ( ${Jasper_FOUND} ) add_subdirectory( io_grib2 ) endif() - -add_subdirectory( RSL_LITE ) +if ( ${USE_MPI} ) + add_subdirectory( RSL_LITE ) +endif() From 478cea3b2ea97619ba5f316b3e0e0492b5044caa Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 7 Jul 2023 18:13:51 -0600 Subject: [PATCH 086/180] Using a more shell-agnostic redirection --- tools/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 3b0226a835..46909f59dc 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -121,7 +121,7 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/frame COMMAND - ${CMAKE_BINARY_DIR}/tools/registry ${REGISTRY_DEFS} -DNEW_BDYS ${REGISTRY_FILE} &> ${CMAKE_BINARY_DIR}/registry.log + ${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 # registry code to not be so obfuscating COMMAND From f5617fb98c67123ecf659bd17dde029dabc83af8 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 7 Jul 2023 18:18:37 -0600 Subject: [PATCH 087/180] Only linking to RSL_LITE if available --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 172e33f96f..14fb55f5a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -640,7 +640,7 @@ target_link_libraries( ${PROJECT_NAME}_Core $ $ - RSL_LITE + $ ) ################################################################################ From 0c03b4343d404e254ff8504846a7fd32d32df6a2 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 7 Jul 2023 18:26:05 -0600 Subject: [PATCH 088/180] Using a separate module folder for each exec to not conflict on parallel builds --- main/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 0e11c35ad3..0d4ef1124f 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -74,7 +74,7 @@ foreach ( TARGET ${FOLDER_COMPILE_TARGETS} ) ${TARGET} PROPERTIES # Just dump everything in here - Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/modules/ + Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/modules/${TARGET}/ Fortran_FORMAT FREE ) target_link_libraries( @@ -87,6 +87,7 @@ foreach ( TARGET ${FOLDER_COMPILE_TARGETS} ) PRIVATE ${PROJECT_SOURCE_DIR}/inc ${PROJECT_BINARY_DIR}/inc + $ ) endforeach() From 1f0aa9f97ebebd0e8b456b5f2ede3a91e8a73e25 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 10 Jul 2023 14:21:17 -0600 Subject: [PATCH 089/180] Adding correct settings for nesting without MPI enabled --- CMakeLists.txt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 14fb55f5a9..437f34ec71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,7 @@ list( GET WRF_CORE_OPTIONS 0 WRF_CORE ) set( WRF_NESTING_OPTIONS # Options listed here NONE - BASIC #TODO Figure out what exactly this does aside from potentially stub things Config.pl:890 + BASIC MOVES VORTEX ) @@ -251,6 +251,13 @@ if ( NOT ${WRFIO_NCD_NO_LARGE_FILE_SUPPORT} ) endif() +################################################################################ +## +## Print out final set of options to be used +## DO NOT MODIFY OPTIONS BEYOND THIS POINT +## +################################################################################ + if ( DEFINED CMAKE_TOOLCHAIN_FILE ) print_option( WRF_CONFIG 20 ${BOLD_CYAN} ) endif() @@ -297,6 +304,10 @@ print_option( WRFIO_NCD_NO_LARGE_FILE_SUPPORT 36 ) ## Now find packages that cross-compilation is potentially handled ## ################################################################################ +# If nesting is enabled, DM_PARALLEL must be set, but if this is a non-MPI compilation +# we must stub its usage +list( FIND WRF_NESTING_OPTIONS ${WRF_NESTING} CURRENT_NESTING_IDX ) + if ( ${USE_MPI} ) # Through ***MUCH*** debugging, if utilizing MPI__COMPILER # https://cmake.org/cmake/help/latest/module/FindMPI.html#variables-for-locating-mpi @@ -321,6 +332,12 @@ if ( ${USE_MPI} ) $<$:${WRF_MPI_C_FLAGS}> ) endif() +# We know NONE is the zero index so compare against that +elseif( ${CURRENT_NESTING_IDX} GREATER 0 ) + add_compile_definitions( + DM_PARALLEL + STUBMPI + ) endif() if ( ${USE_OPENMP} ) From a893f5246fbd60c6557a36f8d9a059f712697085 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 12 Jul 2023 16:01:13 -0600 Subject: [PATCH 090/180] Accounting for config-set variables --- CMakeLists.txt | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 437f34ec71..e4ea688b37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,9 +72,11 @@ set( WRF_CORE_OPTIONS PLUS ) -# Set default WRF_CORE set( WRF_CORE "" CACHE STRING "WRF_CORE" ) -list( GET WRF_CORE_OPTIONS 0 WRF_CORE ) +if ( ${WRF_CORE} STREQUAL "" ) + # Set default WRF_CORE + list( GET WRF_CORE_OPTIONS 0 WRF_CORE ) +endif() ################################################################################ ## WRF Nesting selection @@ -87,10 +89,11 @@ set( WRF_NESTING_OPTIONS VORTEX ) -# Set default WRF_NESTING set( WRF_NESTING "" CACHE STRING "WRF_NESTING" ) -list( GET WRF_NESTING_OPTIONS 0 WRF_NESTING ) - +if ( ${WRF_NESTING} STREQUAL "" ) + # Set default WRF_NESTING + list( GET WRF_NESTING_OPTIONS 0 WRF_NESTING ) +endif() ################################################################################ ## WRF Case selection @@ -118,13 +121,15 @@ set( WRF_CASE_OPTIONS EM_SQUALL2D_Y ) -# Set default WRF_CASE set( WRF_CASE "" CACHE STRING "WRF_CASE" ) -list( GET WRF_CASE_OPTIONS 0 WRF_CASE ) - +if ( ${WRF_CASE} STREQUAL "" ) + # Set default WRF_CASE + list( GET WRF_CASE_OPTIONS 0 WRF_CASE ) +endif() # DO NOT USE OPTION - IT DOES NOT WORK AS ANTICIPATED EVEN WHEN CLEARING CACHE - YOU HAVE BEEN WARNED -set( USE_DOUBLE OFF CACHE BOOL "USE_DOUBLE" ) # I believe this is the r8/real8 promotion +# If you add anything here, the description should be the name itself - this helps the configuration script +set( USE_DOUBLE OFF CACHE BOOL "USE_DOUBLE" ) set( USE_MPI OFF CACHE BOOL "USE_MPI" ) set( USE_OPENMP OFF CACHE BOOL "USE_OPENMP" ) From 9a89eeb8bbcd24a435fdae6c749a163a7780d595 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 12 Jul 2023 16:05:22 -0600 Subject: [PATCH 091/180] Allow selection of suboptions procedurally --- arch/configure_reader.py | 53 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/arch/configure_reader.py b/arch/configure_reader.py index c09a4fb4bc..376f450b34 100755 --- a/arch/configure_reader.py +++ b/arch/configure_reader.py @@ -217,6 +217,49 @@ def getStringOptionSelection( topLevelCmake, searchString ) : return options[selection] +def getSubOptions( topLevelCmake, ignoreOptions ) : + topLevelCmakeFP = open( topLevelCmake, "r" ) + topLevelCmakeLines = topLevelCmakeFP.read() + topLevelCmakeFP.close() + + stringOptionsMatch = re.finditer( + r"set\s*[(]\s*(\w+)\s*(ON|OFF)\s*CACHE\s*BOOL\s*\"(.*?)\"\s*[)]", + topLevelCmakeLines, + re.I | re.M + ) + # Remove commented ones and ones that don't follow pattern set( ON|OFF CACHE BOOL "" ) + options = [ [ option.group( 1 ), option.group( 2 ) ] for option in stringOptionsMatch if option.group( 1 ) == option.group( 3 ) and option.group(0).split( "#", 1 )[0].strip() ] + + # Remove ignore options + options = [ option for option in options if option[0] not in ignoreOptions ] + subOptions = {} + + if options : + subOptionQuit = False + optionToggleIdx = -1 + + # Print menu + optionStr = "{idx:<3} {option:<24} : {value:<5}" + print( optionStr.format( idx="ID", option="Option", value="Default" ) ) + for opt in options : + print( optionStr.format( idx=options.index(opt), option=opt[0], value=opt[1] ) ) + + print( "Enter ID to toggle option on or off, q to quit : " ) + # Loop until q, toggle from default not current value + while not subOptionQuit : + optionToggleIdx = input() + try: + optionToggleIdx = int( optionToggleIdx ) + if optionToggleIdx < 0 or optionToggleIdx >= len( options ) : + print( "Not a valid index" ) + else: + subOptions[ options[optionToggleIdx][0] ] = "ON" if not ( options[optionToggleIdx][1] == "ON" ) else "OFF" + print( "Set {option} to {value}".format( option=options[optionToggleIdx][0], value=subOptions[ options[optionToggleIdx][0] ] ) ) + except ValueError as err : + subOptionQuit = optionToggleIdx.lower() == "q" + + return subOptions + def generateCMakeToolChainFile( cmakeToolChainTemplate, output, stanza, optionsDict={} ) : cmakeToolChainTemplateFP = open( cmakeToolChainTemplate, "r" ) cmakeToolChainTemplateLines = cmakeToolChainTemplateFP.read() @@ -264,6 +307,13 @@ def main() : useMPI = input( "[DM] Use MPI? [Y/n] : " ).lower() in yesValues useOpenMP = input( "[SM] Use OpenMP? [Y/n] : " ).lower() in yesValues + alreadyAsked = [ "USE_MPI", "USE_OPENMP" ] + + doSuboptionMenu = input( "Configure additional options? [Y/n] : " ).lower() in yesValues + subOptions = {} + if doSuboptionMenu : + subOptions = getSubOptions( cmakeFile, alreadyAsked ) + fp = open( configFile, 'r' ) lines = fp.read() @@ -303,8 +353,9 @@ def main() : "WRF_NESTING" : nestingOption, "WRF_CASE" : caseOption, "USE_MPI" : "ON" if useMPI else "OFF", - "USE_OPENMP" : "ON" if useOpenMP else "OFF" + "USE_OPENMP" : "ON" if useOpenMP else "OFF", } + additionalOptions.update( subOptions ) generateCMakeToolChainFile( cmakeTemplateFile, cmakeConfigFile, stanzas[idxSelection], additionalOptions ) From 38dde8d7a4b62faac64c0a98a38efd4af181af9d Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 12 Jul 2023 16:05:54 -0600 Subject: [PATCH 092/180] Proper creation of WRF target --- main/CMakeLists.txt | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 0d4ef1124f..84886c0894 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -2,22 +2,21 @@ set( FOLDER_COMPILE_TARGETS ) # First make true executables -if ( ${WRF_CORE} STREQUAL "ARW" ) - add_executable( - wrf - wrf.F - module_wrf_top.F - ) - list( APPEND FOLDER_COMPILE_TARGETS wrf ) - -elseif ( ${WRF_CORE} STREQUAL "WRFPLUS" ) +if ( ${WRF_CORE} STREQUAL "PLUS" ) add_executable( wrfplus wrf.F module_wrf_top.F ) list( APPEND FOLDER_COMPILE_TARGETS wrfplus ) - +else() + # I believe this is always made if not WRF PLUS or ESMF + add_executable( + wrf + wrf.F + module_wrf_top.F + ) + list( APPEND FOLDER_COMPILE_TARGETS wrf ) # #!TODO When does this get activated? # elseif() # add_executable( From 42ff2baf0c06ba46133c3dcf772021ac9137f7ad Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 12 Jul 2023 16:06:53 -0600 Subject: [PATCH 093/180] Logic and fixes to allow for double precision compilation --- CMakeLists.txt | 84 +++++++++++++++++++++++++++++--- phys/module_mp_SBM_polar_radar.F | 5 ++ phys/module_mp_fast_sbm.F | 14 ++++++ 3 files changed, 96 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4ea688b37..3077ad4539 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -193,11 +193,7 @@ set( MAX_HISTORY 25 ) set( IWORDSIZE 4 ) set( DWORDSIZE 8 ) set( LWORDSIZE 4 ) -if ( USE_DOUBLE ) - set( RWORDSIZE 8 ) -else() - set( RWORDSIZE 4 ) -endif() + ######################## @@ -256,6 +252,76 @@ if ( NOT ${WRFIO_NCD_NO_LARGE_FILE_SUPPORT} ) endif() +# Handle double promotion - doing this here instead of from config.cmake toolchain +# file since the double promotion logic is a nightmare +list( FIND WRF_CORE_OPTIONS ${WRF_CORE} CURRENT_WRF_CORE_IDX ) +list( FIND WRF_CORE_OPTIONS "DA" START_DA_IDX ) +# DA + WRF PLUS cores require double precision +if ( ${CURRENT_WRF_CORE_IDX} GREATER_EQUAL ${START_DA_IDX} AND NOT ${USE_DOUBLE} ) + # if ( # Apparently set regardless of compiler + # ${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU" OR + # ${CMAKE_Fortran_COMPILER_ID} STREQUAL "Fujitsu" ) + message( STATUS "DA and PLUS Core builds require double precision" ) + set( USE_DOUBLE ON CACHE BOOL "Required by configuration" FORCE ) + # endif() +endif() + +if ( ${USE_DOUBLE} ) + set( RWORDSIZE 8 ) + if ( ${BUILD_SBM_FAST} ) + set( BUILD_SBM_FAST OFF CACHE BOOL "Required by configuration" FORCE ) + message( STATUS "BUILD_SBM_FAST does not support double, turning off" ) + endif() +else() + set( RWORDSIZE 4 ) +endif() + +math( EXPR RWORDSIZE_B "8 * ${RWORDSIZE}" ) + +# 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 + ) + ################################################################################ ## ## Print out final set of options to be used @@ -611,8 +677,12 @@ add_subdirectory( main ) ################################################################################ # Add subdirectory with case info -############################################################################### -add_subdirectory( test/${WRF_CASE_FOLDER} ) +################################################################################ +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( diff --git a/phys/module_mp_SBM_polar_radar.F b/phys/module_mp_SBM_polar_radar.F index 4f94129271..a6ba4e4cc1 100644 --- a/phys/module_mp_SBM_polar_radar.F +++ b/phys/module_mp_SBM_polar_radar.F @@ -6,6 +6,11 @@ SUBROUTINE SBM_polar_radar dummy = 1 END SUBROUTINE SBM_polar_radar END MODULE module_mp_SBM_polar_radar + +! Stub module +module scatt_tables +end module scatt_tables + #else !****************** module scatt_tables diff --git a/phys/module_mp_fast_sbm.F b/phys/module_mp_fast_sbm.F index 184a9220ea..757f05db8c 100644 --- a/phys/module_mp_fast_sbm.F +++ b/phys/module_mp_fast_sbm.F @@ -6,6 +6,20 @@ SUBROUTINE SBM_fast dummy = 1 END SUBROUTINE SBM_fast END MODULE module_mp_fast_sbm + +! Stub modules +module module_mp_SBM_BreakUp +end module module_mp_SBM_BreakUp + +module module_mp_SBM_Collision +end module module_mp_SBM_Collision + +module module_mp_SBM_Auxiliary +end module module_mp_SBM_Auxiliary + +module module_mp_SBM_Nucleation +end module module_mp_SBM_Nucleation + #else ! +-----------------------------------------------------------------------------+ ! +-----------------------------------------------------------------------------+ From 2d1cefa1ef5a287bed87ceeb2beb0f4f1edca3d6 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 14 Jul 2023 16:39:03 -0600 Subject: [PATCH 094/180] Rolling back to older cmake process to allow version checking to work --- cleanCMake.sh | 5 +++-- compile_new | 5 +++-- configure_new | 7 +++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cleanCMake.sh b/cleanCMake.sh index 3dfcf29ca8..52d21eab46 100755 --- a/cleanCMake.sh +++ b/cleanCMake.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh BUILD_DIR=_build INSTALL_DIR=runTemp TEST_DIR=test/ @@ -50,7 +50,8 @@ fi if [[ "${CLEAN_BASIC_BUILD}" == "TRUE" || "${CLEAN_ALL}" == "TRUE" ]]; then echo "Doing cmake make clean" - cmake --build ${BUILD_DIR} -j 1 --target clean + OLD_DIR=$PWD + cd ${BUILD_DIR} && make -j 1 clean && cd $OLD_DIR fi if [[ "${CLEAN_BASIC_INSTALL}" == "TRUE" || "${CLEAN_ALL}" == "TRUE" ]]; then diff --git a/compile_new b/compile_new index 758e4a8081..121f83537e 100755 --- a/compile_new +++ b/compile_new @@ -1,5 +1,6 @@ -#!/bin/bash +#!/bin/sh # Meant to be run at the top level # Now run cmake -cmake --build _build --target install $* \ No newline at end of file +cd _build && make install $* +# cmake --build _build --target install $* \ No newline at end of file diff --git a/configure_new b/configure_new index 34ef5602d3..afd1d6b8c9 100755 --- a/configure_new +++ b/configure_new @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Meant to be run at the top level ./arch/configure_reader.py \ arch/configure.defaults \ @@ -7,4 +7,7 @@ CMakeLists.txt # Now run cmake -cmake -S . -B _build -DCMAKE_INSTALL_PREFIX=$PWD/runTemp -DCMAKE_TOOLCHAIN_FILE=$PWD/wrf_config.cmake \ No newline at end of file +mkdir -p _build/ +cd _build +cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/../runTemp -DCMAKE_TOOLCHAIN_FILE=$PWD/../wrf_config.cmake +# cmake -S . -B _build \ No newline at end of file From 4aea7ee00ade10a1d43097c60defbb21ed938dae Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 14 Jul 2023 16:52:34 -0600 Subject: [PATCH 095/180] Version check for GNU flags --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3077ad4539..193a80e8e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -485,9 +485,9 @@ add_compile_options( # $<$:-cpp> # Use "" and ; specifically to evaluate correctly "$<$:-diag-disable;6843>" - $<$:-fallow-argument-mismatch> - $<$:-fallow-invalid-boz> - $<$:-ffree-line-length-none> + $<$,$>:-fallow-argument-mismatch> + $<$,$>:-fallow-invalid-boz> + $<$,$>:-ffree-line-length-none> # $,$:-diag-disable;6843> ) From 091b2fe4622278b622af6336c70164ce7c79139c Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 4 May 2023 11:38:33 -0600 Subject: [PATCH 096/180] Modifying #ifdef structure for cmake syntax --- external/atm_ocn/cmpcomm.F | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/atm_ocn/cmpcomm.F b/external/atm_ocn/cmpcomm.F index a78e285337..89cd554e1c 100644 --- a/external/atm_ocn/cmpcomm.F +++ b/external/atm_ocn/cmpcomm.F @@ -1,4 +1,4 @@ -#if defined( DM_PARALLEL ) +#ifdef DM_PARALLEL MODULE CMP_COMM implicit none From 82ed6c100d9bf927e8bb8c11fe5708efe83d0038 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 4 May 2023 11:39:04 -0600 Subject: [PATCH 097/180] Modifying #ifdef structure for cmake syntax --- frame/module_configure.F | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frame/module_configure.F b/frame/module_configure.F index 4e0ae808c3..8554a7d92a 100644 --- a/frame/module_configure.F +++ b/frame/module_configure.F @@ -15,7 +15,8 @@ SUBROUTINE init_module_scalar_tables END SUBROUTINE init_module_scalar_tables END MODULE module_scalar_tables -#if( WRF_CHEM == 1 && WRF_KPP == 1 ) +#ifdef WRF_CHEM +#ifdef WRF_KPP MODULE module_irr_diag INTEGER, parameter :: max_eqn = 1200 @@ -45,6 +46,7 @@ END SUBROUTINE init_module_irr_diag END MODULE module_irr_diag #endif +#endif MODULE module_configure From 8f252f86bdf2b4f04a608272b99b89931018d9ea Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 4 May 2023 11:40:50 -0600 Subject: [PATCH 098/180] Ignoring _build directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index eca261d36e..c47fe3e850 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ configure.wrf* *.backup *.f90 +_build/ \ No newline at end of file From a6676c49f71694e3546d3cd6178e623ce883273e Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 4 May 2023 11:42:10 -0600 Subject: [PATCH 099/180] Fairly confident this was a bug --- tools/gen_allocs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/gen_allocs.c b/tools/gen_allocs.c index c7e7953257..abafbcb893 100644 --- a/tools/gen_allocs.c +++ b/tools/gen_allocs.c @@ -659,7 +659,7 @@ gen_dealloc2 ( FILE * fp , char * structname , node_t * node ) fprintf(fp, " DEALLOCATE(%s%s,STAT=ierr)\n if (ierr.ne.0) then\n CALL wrf_error_fatal ( &\n'frame/module_domain.f: Failed to deallocate %s%s. ')\n endif\n", structname, fname, structname, fname ) ; -#ifdef USE_ALLOCATABLES +#ifndef USE_ALLOCATABLES fprintf(fp, " NULLIFY(%s%s)\n",structname, fname ) ; #endif From 6497be377297af1992ff918ed88968bc2c1926c1 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 4 May 2023 11:42:41 -0600 Subject: [PATCH 100/180] Adding nonzero macro check for function returns rather than failing silently --- tools/registry.c | 75 +++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/tools/registry.c b/tools/registry.c index 79f7983ed7..937cef5a18 100644 --- a/tools/registry.c +++ b/tools/registry.c @@ -18,6 +18,9 @@ #include "data.h" #include "sym.h" +// Helper macro to actually do return checks +#define NON_ZERO_RETURN( A ) { int result = A; if ( result != 0 ) { printf( "Error in %s, non-zero return expected", #A ); exit(result); } } + /* SamT: bug fix: main returns int */ int main( int argc, char *argv[], char *env[] ) @@ -132,11 +135,11 @@ main( int argc, char *argv[], char *env[] ) argv++ ; } - gen_io_boilerplate() ; /* 20091213 jm. Generate the io_boilerplate_temporary.inc file */ + NON_ZERO_RETURN( gen_io_boilerplate() ); /* 20091213 jm. Generate the io_boilerplate_temporary.inc file */ - init_parser() ; - init_type_table() ; - init_dim_table() ; + NON_ZERO_RETURN( init_parser() ); + NON_ZERO_RETURN( init_type_table() ); + NON_ZERO_RETURN( init_dim_table() ); // // possible IRR diagnostcis? // @@ -230,45 +233,45 @@ main( int argc, char *argv[], char *env[] ) } - reg_parse(fp_tmp) ; + NON_ZERO_RETURN( reg_parse(fp_tmp) ); fclose(fp_tmp) ; - check_dimspecs() ; + NON_ZERO_RETURN( check_dimspecs() ); - gen_state_struct( "inc" ) ; - gen_state_subtypes( "inc" ) ; - gen_alloc( "inc" ) ; + NON_ZERO_RETURN( gen_state_struct( "inc" ) ); + NON_ZERO_RETURN( gen_state_subtypes( "inc" ) ); + NON_ZERO_RETURN( gen_alloc( "inc" ) ); /* gen_alloc_count( "inc" ) ; */ - gen_dealloc( "inc" ) ; - gen_scalar_indices( "inc" ) ; - gen_module_state_description( "frame" ) ; - gen_actual_args( "inc" ) ; - gen_actual_args_new( "inc" ) ; - gen_dummy_args( "inc" ) ; - gen_dummy_args_new( "inc" ) ; - gen_dummy_decls( "inc" ) ; - gen_dummy_decls_new( "inc" ) ; - gen_i1_decls( "inc" ) ; - gen_namelist_statements("inc") ; - gen_namelist_defines ( "inc", 0 ) ; /* without dimension statements */ - gen_namelist_defines ( "inc", 1 ) ; /* with dimension statements */ - gen_namelist_defaults ( "inc" ) ; - gen_namelist_script ( "inc" ) ; - gen_get_nl_config( "inc" ) ; - gen_config_assigns( "inc" ) ; - gen_config_reads( "inc" ) ; - gen_wrf_io( "inc" ) ; - gen_model_data_ord( "inc" ) ; - gen_nest_interp( "inc" ) ; - gen_nest_v_interp( "inc") ; /*KAL added this for vertical interpolation*/ - gen_scalar_derefs( "inc" ) ; - gen_streams("inc") ; + NON_ZERO_RETURN( gen_dealloc( "inc" ) ) ; + NON_ZERO_RETURN( gen_scalar_indices( "inc" ) ) ; + NON_ZERO_RETURN( gen_module_state_description( "frame" ) ) ; + NON_ZERO_RETURN( gen_actual_args( "inc" ) ) ; + NON_ZERO_RETURN( gen_actual_args_new( "inc" ) ) ; + NON_ZERO_RETURN( gen_dummy_args( "inc" ) ) ; + NON_ZERO_RETURN( gen_dummy_args_new( "inc" ) ) ; + NON_ZERO_RETURN( gen_dummy_decls( "inc" ) ) ; + NON_ZERO_RETURN( gen_dummy_decls_new( "inc" ) ) ; + NON_ZERO_RETURN( gen_i1_decls( "inc" ) ) ; + NON_ZERO_RETURN( gen_namelist_statements("inc") ; ) + NON_ZERO_RETURN( gen_namelist_defines ( "inc", 0 ) ) ; /* without dimension statements */ + NON_ZERO_RETURN( gen_namelist_defines ( "inc", 1 ) ) ; /* with dimension statements */ + NON_ZERO_RETURN( gen_namelist_defaults ( "inc" ) ) ; + NON_ZERO_RETURN( gen_namelist_script ( "inc" ) ) ; + NON_ZERO_RETURN( gen_get_nl_config( "inc" ) ) ; + NON_ZERO_RETURN( gen_config_assigns( "inc" ) ) ; + NON_ZERO_RETURN( gen_config_reads( "inc" ) ) ; + NON_ZERO_RETURN( gen_wrf_io( "inc" ) ) ; + NON_ZERO_RETURN( gen_model_data_ord( "inc" ) ) ; + NON_ZERO_RETURN( gen_nest_interp( "inc" ) ) ; + NON_ZERO_RETURN( gen_nest_v_interp( "inc") ; ) /*KAL added this for vertical interpolation*/ + NON_ZERO_RETURN( gen_scalar_derefs( "inc" ) ) ; + NON_ZERO_RETURN( gen_streams("inc") ; ) /* this has to happen after gen_nest_interp, which adds halos to the AST */ - gen_comms( "inc" ) ; /* this is either package supplied (by copying a */ - /* gen_comms.c file into this directory) or a */ - /* stubs routine. */ + NON_ZERO_RETURN( gen_comms( "inc" ) ); /* this is either package supplied (by copying a */ + /* gen_comms.c file into this directory) or a */ + /* stubs routine. */ cleanup: #ifdef _WIN32 From 3998795bb38a2e15f470f72f8a565df45e9f5960 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 8 May 2023 19:01:59 -0600 Subject: [PATCH 101/180] Making registry work in out of source build --- tools/gen_streams.c | 4 +++- tools/reg_parse.c | 15 +++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/tools/gen_streams.c b/tools/gen_streams.c index f93cf3989d..e6cbda002d 100644 --- a/tools/gen_streams.c +++ b/tools/gen_streams.c @@ -607,12 +607,14 @@ gen_med_find_esmf_coupling ( FILE *fp ) for each stream. This file is then included by the registry.io_boilerplate file when the registry actually runs. As with the other mods above, this allows a variable, compile-time number of io streams. Note that this one is self contained and dirname is hard-coded. + AI: In an effort to delineate true source files from autogen stuff this is now not going into hard-coded + Registry so that we can use ./ as an alternate include location */ int gen_io_boilerplate () { FILE * fp ; - char * dirname = "Registry" ; + char * dirname = "./" ; char fname[NAMELEN] ; char * fn ; char * aux , *streamtype , streamno[5] ; diff --git a/tools/reg_parse.c b/tools/reg_parse.c index 01176c0ea4..5321b58402 100644 --- a/tools/reg_parse.c +++ b/tools/reg_parse.c @@ -116,21 +116,28 @@ pre_parse( char * dir, FILE * infile, FILE * outfile ) for ( p = inln ; ( *p == ' ' || *p == ' ' ) && *p != '\0' ; p++ ) ; if ( !strncmp( p , "include", 7 ) && ! ( ifdef_stack_ptr >= 0 && ! ifdef_stack[ifdef_stack_ptr] ) ) { FILE *include_fp ; + char include_file_name_dir[128] ; char include_file_name[128] ; p += 7 ; for ( ; ( *p == ' ' || *p == ' ' ) && *p != '\0' ; p++ ) ; if ( strlen( p ) > 127 ) { fprintf(stderr,"Registry warning: invalid include file name: %s\n", p ) ; } else { - sprintf( include_file_name , "%s/%s", dir , p ) ; + + sprintf( include_file_name, "%s", p ) ; if ( (p=index(include_file_name,'\n')) != NULL ) *p = '\0' ; + sprintf( include_file_name_dir, "%s/%s", dir , include_file_name ) ; + fprintf(stderr,"opening %s\n",include_file_name) ; - if (( include_fp = fopen( include_file_name , "r" )) != NULL ) { + if ( ( ( include_fp = fopen( include_file_name, "r" ) ) != NULL ) || // Use short circuit logic here to try both sequentially + ( ( include_fp = fopen( include_file_name_dir, "r" ) ) != NULL ) ) + { fprintf(stderr,"including %s\n",include_file_name ) ; pre_parse( dir , include_fp , outfile ) ; fclose( include_fp ) ; - } else { - fprintf(stderr,"Registry warning: cannot open %s. Ignoring.\n", include_file_name ) ; + } + else { + fprintf(stderr,"Registry warning: cannot open %s. Tried %s and %s Ignoring.\n", include_file_name, include_file_name, include_file_name_dir ) ; } } } From 3eb5cb6d3317a40d37e6265e3ddb6f00df57e3f3 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:33:59 -0600 Subject: [PATCH 102/180] Simplifying #if[n]defs --- dyn_em/module_advect_em.F | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dyn_em/module_advect_em.F b/dyn_em/module_advect_em.F index ff03d1a695..2913ac5a9c 100644 --- a/dyn_em/module_advect_em.F +++ b/dyn_em/module_advect_em.F @@ -1,7 +1,7 @@ !WRF:MODEL_LAYER:DYNAMICS ! -#if ( defined(ADVECT_KERNEL) ) +#ifdef ADVECT_KERNEL ! cpp -traditional-cpp -P -DADVECT_KERNEL module_advect_em.F > advection_kernel.f90 ! gfortran -ffree-form -ffree-line-length-none advection_kernel.f90 ! ./a.out @@ -111,7 +111,7 @@ SUBROUTINE column (loop , data_list, its,ite) END SUBROUTINE column !---------------------------------------------------------------- -#elif ( ! defined(ADVECT_KERNEL) ) +#else MODULE module_advect_em @@ -4357,7 +4357,7 @@ SUBROUTINE advect_scalar ( field, field_old, tendency, & ENDIF vert_order_test END SUBROUTINE advect_scalar -#if ( ! defined(ADVECT_KERNEL) ) +#ifndef ADVECT_KERNEL !--------------------------------------------------------------------------------- @@ -10543,7 +10543,7 @@ END SUBROUTINE advect_scalar_mono !----------------------------------------------------------- -#if ( defined(ADVECT_KERNEL) ) +#ifdef ADVECT_KERNEL END MODULE advection_kernel !================================================================ @@ -10851,7 +10851,7 @@ PROGRAM feeder END PROGRAM feeder #endif -#if ( !defined(ADVECT_KERNEL) ) +#ifndef ADVECT_KERNEL !--------------------------------------------------------------------------------- From af7f3a4f4ac600e3fc5c80781a3a5c450cd87b00 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:34:34 -0600 Subject: [PATCH 103/180] Adding missing & --- dyn_em/module_first_rk_step_part1.F | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dyn_em/module_first_rk_step_part1.F b/dyn_em/module_first_rk_step_part1.F index f5eb26734d..157f260be8 100644 --- a/dyn_em/module_first_rk_step_part1.F +++ b/dyn_em/module_first_rk_step_part1.F @@ -925,7 +925,7 @@ SUBROUTINE first_rk_step_part1 ( grid , config_flags & & ,iopt_crop=config_flags%opt_crop, iopt_irr=config_flags%opt_irr & & ,iopt_irrm=config_flags%opt_irrm & & ,iopt_infdv=config_flags%opt_infdv,iopt_tdrn=config_flags%opt_tdrn & - & ,soiltstep=config_flags%soiltstep + & ,soiltstep=config_flags%soiltstep & & , isnowxy=grid%isnowxy , tvxy=grid%tvxy , tgxy=grid%tgxy & & ,canicexy=grid%canicexy ,canliqxy=grid%canliqxy, eahxy=grid%eahxy & & , tahxy=grid%tahxy , cmxy=grid%cmxy , chxy=grid%chxy & From f2b882a23087cc0a8f481c4e17c4d2581e7c7219 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:45:19 -0600 Subject: [PATCH 104/180] I believe this was a bug, no idea how it was even working before --- external/io_grib2/g2lib/dec_png.c | 2 +- external/io_grib2/g2lib/enc_png.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/external/io_grib2/g2lib/dec_png.c b/external/io_grib2/g2lib/dec_png.c index aa85184b36..a33c0c0ac6 100644 --- a/external/io_grib2/g2lib/dec_png.c +++ b/external/io_grib2/g2lib/dec_png.c @@ -88,7 +88,7 @@ int DEC_PNG(unsigned char *pngbuf,g2int *width,g2int *height,char *cout) /* Set new custom read function */ - png_set_read_fn(png_ptr,(voidp)&read_io_ptr,(png_rw_ptr)user_read_data); + png_set_read_fn(png_ptr,(png_voidp)&read_io_ptr,(png_rw_ptr)user_read_data); /* png_init_io(png_ptr, fptr); */ /* Read and decode PNG stream */ diff --git a/external/io_grib2/g2lib/enc_png.c b/external/io_grib2/g2lib/enc_png.c index 7d2ef1d287..97d0b961a9 100644 --- a/external/io_grib2/g2lib/enc_png.c +++ b/external/io_grib2/g2lib/enc_png.c @@ -88,7 +88,7 @@ int ENC_PNG(char *data,g2int *width,g2int *height,g2int *nbits,char *pngbuf) /* Set new custom write functions */ - png_set_write_fn(png_ptr,(voidp)&write_io_ptr,(png_rw_ptr)user_write_data, + png_set_write_fn(png_ptr,(png_voidp)&write_io_ptr,(png_rw_ptr)user_write_data, (png_flush_ptr)user_flush_data); /* png_init_io(png_ptr, fptr); */ /* png_set_compression_level(png_ptr, Z_BEST_COMPRESSION); */ From d541360fec9fd499ad4b2f58e5b3cf772daa8396 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:49:00 -0600 Subject: [PATCH 105/180] Switching io_int/intio tags to #defines --- external/io_int/io_int.F90 | 116 ++++++++++++++++++----------------- external/io_int/io_int_idx.c | 2 +- inc/intio_tags.h | 68 ++++++++++---------- 3 files changed, 94 insertions(+), 92 deletions(-) diff --git a/external/io_int/io_int.F90 b/external/io_int/io_int.F90 index e57224b51e..ab95b49a45 100644 --- a/external/io_int/io_int.F90 +++ b/external/io_int/io_int.F90 @@ -9,6 +9,8 @@ ! Uses header manipulation routines in module_io_quilt.F ! +#include "intio_tags.h" + MODULE module_ext_internal USE module_internal_header_util @@ -168,7 +170,7 @@ SUBROUTINE ext_int_open_for_write( FileName , Comm_compute, Comm_io, SysDepInfo, DataHandle , Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + CHARACTER*(*) :: FileName INTEGER , INTENT(IN) :: Comm_compute , Comm_io CHARACTER*(*) :: SysDepInfo @@ -187,7 +189,7 @@ SUBROUTINE ext_int_open_for_write_begin( FileName , Comm_compute, Comm_io, SysDe DataHandle , Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + #include "wrf_io_flags.h" CHARACTER*(*) :: FileName INTEGER , INTENT(IN) :: Comm_compute , Comm_io @@ -221,7 +223,7 @@ END SUBROUTINE ext_int_open_for_write_begin SUBROUTINE ext_int_open_for_write_commit( DataHandle , Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + #include "wrf_io_flags.h" INTEGER , INTENT(IN ) :: DataHandle INTEGER , INTENT(OUT) :: Status @@ -362,7 +364,7 @@ SUBROUTINE ext_int_ioexit( Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(OUT) :: Status INTEGER :: DataHandle INTEGER i,ierr @@ -375,7 +377,7 @@ END SUBROUTINE ext_int_ioexit SUBROUTINE ext_int_get_next_time ( DataHandle, DateStr, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: DateStr INTEGER , INTENT(OUT) :: Status @@ -417,7 +419,7 @@ SUBROUTINE ext_int_get_next_time ( DataHandle, DateStr, Status ) READ( unit=DataHandle, iostat=istat ) hdrbuf ! this is okay as long as no other record type has data that follows IF ( istat .EQ. 0 ) THEN code = hdrbuf(2) - IF ( code .EQ. int_field ) THEN + IF ( code .EQ. INT_FIELD ) THEN CALL int_get_write_field_header ( hdrbuf, hdrbufsize, inttypesize, typesize, & locDataHandle , locDateStr , locVarName , Field , locFieldType , locComm , locIOComm, & locDomainDesc , locMemoryOrder , locStagger , locDimNames , & @@ -433,7 +435,7 @@ SUBROUTINE ext_int_get_next_time ( DataHandle, DateStr, Status ) ELSE READ( unit=DataHandle, iostat=istat ) ENDIF - ELSE IF ( code .EQ. int_dom_td_char ) THEN + ELSE IF ( code .EQ. INT_DOM_TD_CHAR ) THEN CALL int_get_td_header_char( hdrbuf, hdrbufsize, itypesize, & locDataHandle, locDateStr, locElement, locData, loccode ) IF ( TRIM(locDateStr) .NE. TRIM(CurrentDateInFile(DataHandle) ) ) THEN ! control break, return this date @@ -460,13 +462,13 @@ END SUBROUTINE ext_int_get_next_time SUBROUTINE ext_int_set_time ( DataHandle, DateStr, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: DateStr INTEGER , INTENT(OUT) :: Status CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & - DataHandle, "TIMESTAMP", "", TRIM(DateStr), int_set_time ) + DataHandle, "TIMESTAMP", "", TRIM(DateStr), INT_SET_TIME ) WRITE( unit=DataHandle ) hdrbuf Status = 0 RETURN @@ -477,7 +479,7 @@ SUBROUTINE ext_int_get_var_info ( DataHandle , VarName , NDim , MemoryOrder , St DomainStart , DomainEnd , WrfType, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + integer ,intent(in) :: DataHandle character*(*) ,intent(in) :: VarName integer ,intent(out) :: NDim @@ -519,7 +521,7 @@ SUBROUTINE ext_int_get_var_info ( DataHandle , VarName , NDim , MemoryOrder , St READ( unit=DataHandle, iostat=istat ) hdrbuf ! this is okay as long as no other record type has data that follows IF ( istat .EQ. 0 ) THEN code = hdrbuf(2) - IF ( code .EQ. int_field ) THEN + IF ( code .EQ. INT_FIELD ) THEN CALL int_get_write_field_header ( hdrbuf, hdrbufsize, inttypesize, typesize, & locDataHandle , locDateStr , locVarName , Field , locFieldType , locComm , locIOComm, & locDomainDesc , MemoryOrder , locStagger , locDimNames , & @@ -561,7 +563,7 @@ END SUBROUTINE ext_int_get_var_info SUBROUTINE ext_int_get_next_var ( DataHandle, VarName, Status ) USE module_ext_internal IMPLICIT NONE - include 'intio_tags.h' + include 'wrf_status_codes.h' INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: VarName @@ -606,20 +608,20 @@ SUBROUTINE ext_int_get_next_var ( DataHandle, VarName, Status ) IF ( istat .EQ. 0 ) THEN code = hdrbuf(2) #if 1 - IF ( code .EQ. int_dom_ti_char ) THEN + IF ( code .EQ. INT_DOM_TI_CHAR ) THEN CALL int_get_ti_header_char( hdrbuf, hdrbufsize, itypesize, & locDataHandle, locElement, dumstr, strData, loccode ) ENDIF - IF ( code .EQ. int_dom_ti_integer ) THEN + IF ( code .EQ. INT_DOM_TI_INTEGER ) THEN CALL int_get_ti_header( hdrbuf, hdrbufsize, itypesize, rtypesize, & locDataHandle, locElement, iData, loccount, code ) ENDIF - IF ( code .EQ. int_dom_ti_real ) THEN + IF ( code .EQ. INT_DOM_TI_REAL ) THEN CALL int_get_ti_header( hdrbuf, hdrbufsize, itypesize, rtypesize, & locDataHandle, locElement, rData, loccount, code ) ENDIF #endif - IF ( code .EQ. int_field ) THEN + IF ( code .EQ. INT_FIELD ) THEN CALL int_get_write_field_header ( hdrbuf, hdrbufsize, inttypesize, typesize, & locDataHandle , locDateStr , locVarName , Field , locFieldType , locComm , locIOComm, & locDomainDesc , locMemoryOrder , locStagger , locDimNames , & @@ -660,7 +662,7 @@ END SUBROUTINE ext_int_get_next_var SUBROUTINE ext_int_get_dom_ti_real ( DataHandle,Element, Data, Count, Outcount, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element REAL , INTENT(OUT) :: Data(*) @@ -681,7 +683,7 @@ SUBROUTINE ext_int_get_dom_ti_real ( DataHandle,Element, Data, Count, Outcount READ( unit=DataHandle , iostat = istat ) hdrbuf IF ( istat .EQ. 0 ) THEN code = hdrbuf(2) - IF ( code .EQ. int_dom_ti_real ) THEN + IF ( code .EQ. INT_DOM_TI_REAL ) THEN CALL int_get_ti_header( hdrbuf, hdrbufsize, itypesize, rtypesize, & locDataHandle, locElement, Data, loccount, code ) IF ( TRIM(locElement) .EQ. TRIM(Element) ) THEN @@ -690,11 +692,11 @@ SUBROUTINE ext_int_get_dom_ti_real ( DataHandle,Element, Data, Count, Outcount ENDIF keepgoing = .false. ; Status = 0 ENDIF - ELSE IF ( .NOT. ( code .EQ. int_dom_ti_integer .OR. code .EQ. int_dom_ti_logical .OR. & - code .EQ. int_dom_ti_char .OR. code .EQ. int_dom_ti_double .OR. & - code .EQ. int_dom_td_integer .OR. code .EQ. int_dom_td_logical .OR. & - code .EQ. int_dom_td_char .OR. code .EQ. int_dom_td_double .OR. & - code .EQ. int_dom_td_real ) ) THEN + ELSE IF ( .NOT. ( code .EQ. INT_DOM_TI_INTEGER .OR. code .EQ. INT_DOM_TI_LOGICAL .OR. & + code .EQ. INT_DOM_TI_CHAR .OR. code .EQ. INT_DOM_TI_DOUBLE .OR. & + code .EQ. INT_DOM_TD_INTEGER .OR. code .EQ. INT_DOM_TD_LOGICAL .OR. & + code .EQ. INT_DOM_TD_CHAR .OR. code .EQ. INT_DOM_TD_DOUBLE .OR. & + code .EQ. INT_DOM_TD_REAL ) ) THEN BACKSPACE ( unit=DataHandle ) keepgoing = .false. ; Status = 2 ENDIF @@ -712,7 +714,7 @@ END SUBROUTINE ext_int_get_dom_ti_real SUBROUTINE ext_int_put_dom_ti_real ( DataHandle,Element, Data, Count, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element REAL , INTENT(IN) :: Data(*) @@ -726,7 +728,7 @@ SUBROUTINE ext_int_put_dom_ti_real ( DataHandle,Element, Data, Count, Status ! Do nothing unless it is time to write time-independent domain metadata. IF ( int_ok_to_put_dom_ti( DataHandle ) ) THEN CALL int_gen_ti_header( hdrbuf, hdrbufsize, itypesize, rtypesize, & - DataHandle, Element, Data, Count, int_dom_ti_real ) + DataHandle, Element, Data, Count, INT_DOM_TI_REAL ) WRITE( unit=DataHandle ) hdrbuf ENDIF ENDIF @@ -772,7 +774,7 @@ END SUBROUTINE ext_int_put_dom_ti_double SUBROUTINE ext_int_get_dom_ti_integer ( DataHandle,Element, Data, Count, Outcount, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element integer , INTENT(OUT) :: Data(*) @@ -793,7 +795,7 @@ SUBROUTINE ext_int_get_dom_ti_integer ( DataHandle,Element, Data, Count, Outco READ( unit=DataHandle , iostat = istat ) hdrbuf IF ( istat .EQ. 0 ) THEN code = hdrbuf(2) - IF ( code .EQ. int_dom_ti_integer ) THEN + IF ( code .EQ. INT_DOM_TI_INTEGER ) THEN CALL int_get_ti_header( hdrbuf, hdrbufsize, itypesize, rtypesize, & locDataHandle, locElement, Data, loccount, code ) IF ( TRIM(locElement) .EQ. TRIM(Element) ) THEN @@ -803,11 +805,11 @@ SUBROUTINE ext_int_get_dom_ti_integer ( DataHandle,Element, Data, Count, Outco keepgoing = .false. ; Status = 0 ENDIF - ELSE IF ( .NOT. ( code .EQ. int_dom_ti_real .OR. code .EQ. int_dom_ti_logical .OR. & - code .EQ. int_dom_ti_char .OR. code .EQ. int_dom_ti_double .OR. & - code .EQ. int_dom_td_real .OR. code .EQ. int_dom_td_logical .OR. & - code .EQ. int_dom_td_char .OR. code .EQ. int_dom_td_double .OR. & - code .EQ. int_dom_td_integer ) ) THEN + ELSE IF ( .NOT. ( code .EQ. INT_DOM_TI_REAL .OR. code .EQ. INT_DOM_TI_LOGICAL .OR. & + code .EQ. INT_DOM_TI_CHAR .OR. code .EQ. INT_DOM_TI_DOUBLE .OR. & + code .EQ. INT_DOM_TD_REAL .OR. code .EQ. INT_DOM_TD_LOGICAL .OR. & + code .EQ. INT_DOM_TD_CHAR .OR. code .EQ. INT_DOM_TD_DOUBLE .OR. & + code .EQ. INT_DOM_TD_INTEGER ) ) THEN BACKSPACE ( unit=DataHandle ) keepgoing = .false. ; Status = 1 ENDIF @@ -825,7 +827,7 @@ END SUBROUTINE ext_int_get_dom_ti_integer SUBROUTINE ext_int_put_dom_ti_integer ( DataHandle,Element, Data, Count, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element INTEGER , INTENT(IN) :: Data(*) @@ -838,7 +840,7 @@ SUBROUTINE ext_int_put_dom_ti_integer ( DataHandle,Element, Data, Count, Stat ! Do nothing unless it is time to write time-independent domain metadata. IF ( int_ok_to_put_dom_ti( DataHandle ) ) THEN CALL int_gen_ti_header( hdrbuf, hdrbufsize, itypesize, itypesize, & - DataHandle, Element, Data, Count, int_dom_ti_integer ) + DataHandle, Element, Data, Count, INT_DOM_TI_INTEGER ) WRITE( unit=DataHandle ) hdrbuf ENDIF ENDIF @@ -884,7 +886,7 @@ END SUBROUTINE ext_int_put_dom_ti_logical SUBROUTINE ext_int_get_dom_ti_char ( DataHandle,Element, Data, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element CHARACTER*(*) :: Data @@ -905,17 +907,17 @@ SUBROUTINE ext_int_get_dom_ti_char ( DataHandle,Element, Data, Status ) IF ( istat .EQ. 0 ) THEN code = hdrbuf(2) - IF ( code .EQ. int_dom_ti_char ) THEN + IF ( code .EQ. INT_DOM_TI_CHAR ) THEN CALL int_get_ti_header_char( hdrbuf, hdrbufsize, itypesize, & locDataHandle, locElement, dumstr, Data, code ) IF ( TRIM(locElement) .EQ. TRIM(Element) ) THEN keepgoing = .false. ; Status = 0 ENDIF - ELSE IF ( .NOT. ( code .EQ. int_dom_ti_real .OR. code .EQ. int_dom_ti_logical .OR. & - code .EQ. int_dom_ti_integer .OR. code .EQ. int_dom_ti_double .OR. & - code .EQ. int_dom_td_real .OR. code .EQ. int_dom_td_logical .OR. & - code .EQ. int_dom_td_integer .OR. code .EQ. int_dom_td_double .OR. & - code .EQ. int_dom_td_char ) ) THEN + ELSE IF ( .NOT. ( code .EQ. INT_DOM_TI_REAL .OR. code .EQ. INT_DOM_TI_LOGICAL .OR. & + code .EQ. INT_DOM_TI_INTEGER .OR. code .EQ. INT_DOM_TI_DOUBLE .OR. & + code .EQ. INT_DOM_TD_REAL .OR. code .EQ. INT_DOM_TD_LOGICAL .OR. & + code .EQ. INT_DOM_TD_INTEGER .OR. code .EQ. INT_DOM_TD_DOUBLE .OR. & + code .EQ. INT_DOM_TD_CHAR ) ) THEN BACKSPACE ( unit=DataHandle ) keepgoing = .false. ; Status = 1 ENDIF @@ -933,7 +935,7 @@ END SUBROUTINE ext_int_get_dom_ti_char SUBROUTINE ext_int_put_dom_ti_char ( DataHandle, Element, Data, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element CHARACTER*(*) :: Data @@ -947,7 +949,7 @@ SUBROUTINE ext_int_put_dom_ti_char ( DataHandle, Element, Data, Status ) ! Do nothing unless it is time to write time-independent domain metadata. IF ( int_ok_to_put_dom_ti( DataHandle ) ) THEN CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & - DataHandle, Element, "", Data, int_dom_ti_char ) + DataHandle, Element, "", Data, INT_DOM_TI_CHAR ) WRITE( unit=DataHandle ) hdrbuf ENDIF ENDIF @@ -1062,7 +1064,7 @@ END SUBROUTINE ext_int_put_dom_td_logical SUBROUTINE ext_int_get_dom_td_char ( DataHandle,Element, DateStr, Data, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element CHARACTER*(*) :: Data, DateStr @@ -1080,7 +1082,7 @@ SUBROUTINE ext_int_get_dom_td_char ( DataHandle,Element, DateStr, Data, Status IF ( istat .EQ. 0 ) THEN code = hdrbuf(2) - IF ( code .EQ. int_dom_td_char ) THEN + IF ( code .EQ. INT_DOM_TD_CHAR ) THEN CALL int_get_td_header_char( hdrbuf, hdrbufsize, itypesize, & locDataHandle, locDateStr, locElement, Data, code ) IF ( TRIM(locElement) .EQ. TRIM(Element) ) THEN @@ -1103,7 +1105,7 @@ END SUBROUTINE ext_int_get_dom_td_char SUBROUTINE ext_int_put_dom_td_char ( DataHandle,Element, DateStr, Data, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element CHARACTER*(*) :: Data, DateStr @@ -1114,7 +1116,7 @@ SUBROUTINE ext_int_put_dom_td_char ( DataHandle,Element, DateStr, Data, Status IF ( int_valid_handle ( Datahandle ) ) THEN IF ( int_handle_in_use( DataHandle ) ) THEN CALL int_gen_td_header_char( hdrbuf, hdrbufsize, itypesize, & - DataHandle, DateStr, Element, Data, int_dom_td_char ) + DataHandle, DateStr, Element, Data, INT_DOM_TD_CHAR ) WRITE( unit=DataHandle ) hdrbuf ENDIF ENDIF @@ -1178,7 +1180,7 @@ END SUBROUTINE ext_int_put_var_ti_double SUBROUTINE ext_int_get_var_ti_integer ( DataHandle,Element, Varname, Data, Count, Outcount, Status ) USE module_ext_internal IMPLICIT NONE -#include "intio_tags.h" + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element CHARACTER*(*) :: VarName @@ -1192,7 +1194,7 @@ SUBROUTINE ext_int_get_var_ti_integer ( DataHandle,Element, Varname, Data, Coun IF ( int_handle_in_use( DataHandle ) ) THEN READ( unit=DataHandle ) hdrbuf code=hdrbuf(2) - IF ( code .NE. int_var_ti_integer ) THEN + IF ( code .NE. INT_VAR_TI_INTEGER ) THEN BACKSPACE ( unit=DataHandle ) write(*,*) 'unexpected code=',code,' in ext_int_get_var_ti_integer' Status = 1 @@ -1219,7 +1221,7 @@ SUBROUTINE ext_int_put_var_ti_integer ( DataHandle,Element, Varname, Data, Coun USE module_ext_internal USE module_internal_header_util, only: int_gen_ti_header_integer_varna IMPLICIT NONE -#include "intio_tags.h" + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element CHARACTER*(*) :: VarName @@ -1230,7 +1232,7 @@ SUBROUTINE ext_int_put_var_ti_integer ( DataHandle,Element, Varname, Data, Coun IF ( int_handle_in_use( DataHandle ) ) THEN CALL int_gen_ti_header_integer_varna( hdrbuf, hdrbufsize, itypesize,4, & DataHandle, TRIM(Element), TRIM(VarName), Data, Count, & - int_var_ti_integer ) + INT_VAR_TI_INTEGER ) WRITE( unit=DataHandle ) hdrbuf ENDIF ENDIF @@ -1267,7 +1269,7 @@ END SUBROUTINE ext_int_put_var_ti_logical SUBROUTINE ext_int_get_var_ti_char ( DataHandle,Element, Varname, Data, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element CHARACTER*(*) :: VarName @@ -1279,7 +1281,7 @@ SUBROUTINE ext_int_get_var_ti_char ( DataHandle,Element, Varname, Data, Status IF ( int_handle_in_use( DataHandle ) ) THEN READ( unit=DataHandle ) hdrbuf code=hdrbuf(2) - IF ( code .NE. int_var_ti_char ) THEN + IF ( code .NE. INT_VAR_TI_CHAR ) THEN BACKSPACE ( unit=DataHandle ) Status = 1 return @@ -1302,7 +1304,7 @@ END SUBROUTINE ext_int_get_var_ti_char SUBROUTINE ext_int_put_var_ti_char ( DataHandle,Element, Varname, Data, Status ) USE module_ext_internal IMPLICIT NONE - INCLUDE 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: Element CHARACTER*(*) :: VarName @@ -1313,7 +1315,7 @@ SUBROUTINE ext_int_put_var_ti_char ( DataHandle,Element, Varname, Data, Status IF ( int_valid_handle (DataHandle) ) THEN IF ( int_handle_in_use( DataHandle ) ) THEN CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & - DataHandle, TRIM(Element), TRIM(VarName), TRIM(Data), int_var_ti_char ) + DataHandle, TRIM(Element), TRIM(VarName), TRIM(Data), INT_VAR_TI_CHAR ) WRITE( unit=DataHandle ) hdrbuf ENDIF ENDIF @@ -1465,7 +1467,7 @@ SUBROUTINE ext_int_read_field ( DataHandle , DateStr , VarName , Field , FieldTy USE module_ext_internal IMPLICIT NONE #include "wrf_io_flags.h" - include 'intio_tags.h' + INTEGER , INTENT(IN) :: DataHandle CHARACTER*(*) :: DateStr CHARACTER*(*) :: VarName @@ -1519,7 +1521,7 @@ SUBROUTINE ext_int_read_field ( DataHandle , DateStr , VarName , Field , FieldTy READ( unit=DataHandle, iostat=istat ) hdrbuf ! this is okay as long as no other record type has data that follows IF ( istat .EQ. 0 ) THEN code = hdrbuf(2) - IF ( code .EQ. int_field ) THEN + IF ( code .EQ. INT_FIELD ) THEN CALL int_get_write_field_header ( hdrbuf, hdrbufsize, inttypesize, typesize, & locDataHandle , locDateStr , locVarName , Field , locFieldType , locComm , locIOComm, & locDomainDesc , locMemoryOrder , locStagger , locDimNames , & diff --git a/external/io_int/io_int_idx.c b/external/io_int/io_int_idx.c index 8f812dd356..772263359e 100644 --- a/external/io_int/io_int_idx.c +++ b/external/io_int/io_int_idx.c @@ -19,7 +19,7 @@ #include #include "io_int_idx.h" -#include "io_int_idx_tags.h" +#include "intio_tags.h" /* Static/Private functions within this file */ diff --git a/inc/intio_tags.h b/inc/intio_tags.h index 3808968cf5..daa130ef5f 100644 --- a/inc/intio_tags.h +++ b/inc/intio_tags.h @@ -1,34 +1,34 @@ - INTEGER, PARAMETER :: int_ioexit = 10 - INTEGER, PARAMETER :: int_open_for_write_begin = 20 - INTEGER, PARAMETER :: int_open_for_write_commit = 30 - INTEGER, PARAMETER :: int_open_for_read = 40 - INTEGER, PARAMETER :: int_inquire_opened = 60 - INTEGER, PARAMETER :: int_inquire_filename = 70 - INTEGER, PARAMETER :: int_iosync = 80 - INTEGER, PARAMETER :: int_ioclose = 90 - INTEGER, PARAMETER :: int_next_time = 100 - INTEGER, PARAMETER :: int_set_time = 110 - INTEGER, PARAMETER :: int_next_var = 120 - INTEGER, PARAMETER :: int_dom_ti_real = 140 - INTEGER, PARAMETER :: int_dom_ti_double = 160 - INTEGER, PARAMETER :: int_dom_ti_integer = 180 - INTEGER, PARAMETER :: int_dom_ti_logical = 200 - INTEGER, PARAMETER :: int_dom_ti_char = 220 - INTEGER, PARAMETER :: int_dom_td_real = 240 - INTEGER, PARAMETER :: int_dom_td_double = 260 - INTEGER, PARAMETER :: int_dom_td_integer = 280 - INTEGER, PARAMETER :: int_dom_td_logical = 300 - INTEGER, PARAMETER :: int_dom_td_char = 320 - INTEGER, PARAMETER :: int_var_ti_real = 340 - INTEGER, PARAMETER :: int_var_ti_double = 360 - INTEGER, PARAMETER :: int_var_ti_integer = 380 - INTEGER, PARAMETER :: int_var_ti_logical = 400 - INTEGER, PARAMETER :: int_var_ti_char = 420 - INTEGER, PARAMETER :: int_var_td_real = 440 - INTEGER, PARAMETER :: int_var_td_double = 460 - INTEGER, PARAMETER :: int_var_td_integer = 480 - INTEGER, PARAMETER :: int_var_td_logical = 500 - INTEGER, PARAMETER :: int_var_td_char = 520 - INTEGER, PARAMETER :: int_field = 530 - INTEGER, PARAMETER :: int_var_info = 540 - INTEGER, PARAMETER :: int_noop = 550 +#define INT_IOEXIT 10 +#define INT_OPEN_FOR_WRITE_BEGIN 20 +#define INT_OPEN_FOR_WRITE_COMMIT 30 +#define INT_OPEN_FOR_READ 40 +#define INT_INQUIRE_OPENED 60 +#define INT_INQUIRE_FILENAME 70 +#define INT_IOSYNC 80 +#define INT_IOCLOSE 90 +#define INT_NEXT_TIME 100 +#define INT_SET_TIME 110 +#define INT_NEXT_VAR 120 +#define INT_DOM_TI_REAL 140 +#define INT_DOM_TI_DOUBLE 160 +#define INT_DOM_TI_INTEGER 180 +#define INT_DOM_TI_LOGICAL 200 +#define INT_DOM_TI_CHAR 220 +#define INT_DOM_TD_REAL 240 +#define INT_DOM_TD_DOUBLE 260 +#define INT_DOM_TD_INTEGER 280 +#define INT_DOM_TD_LOGICAL 300 +#define INT_DOM_TD_CHAR 320 +#define INT_VAR_TI_REAL 340 +#define INT_VAR_TI_DOUBLE 360 +#define INT_VAR_TI_INTEGER 380 +#define INT_VAR_TI_LOGICAL 400 +#define INT_VAR_TI_CHAR 420 +#define INT_VAR_TD_REAL 440 +#define INT_VAR_TD_DOUBLE 460 +#define INT_VAR_TD_INTEGER 480 +#define INT_VAR_TD_LOGICAL 500 +#define INT_VAR_TD_CHAR 520 +#define INT_FIELD 530 +#define INT_VAR_INFO 540 +#define INT_NOOP 550 From db27276c275ac77448f5093a157735c974821faf Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 10 May 2023 11:50:50 -0600 Subject: [PATCH 106/180] Adjusting for new ioint tags --- frame/module_internal_header_util.F | 42 +++---- frame/module_io_quilt_old.F | 182 ++++++++++++++-------------- 2 files changed, 112 insertions(+), 112 deletions(-) diff --git a/frame/module_internal_header_util.F b/frame/module_internal_header_util.F index bfff25916a..35ad9d92b6 100644 --- a/frame/module_internal_header_util.F +++ b/frame/module_internal_header_util.F @@ -110,7 +110,7 @@ SUBROUTINE int_gen_write_field_header ( hdrbuf, hdrbufsize, itypesize, ftypesize ! hdrbufsize: Size of this data header in bytes. ! headerTag: "Header tag" that tells the I/O quilt servers what kind of ! header this is. For a "write field" header it must be set to -! int_field. See file intio_tags.h for a complete list of +! INT_FIELD. See file intio_tags.h for a complete list of ! these tags. ! ftypesize: Size of field data type in bytes. ! DataHandle: Descriptor for an open data set. @@ -145,7 +145,7 @@ SUBROUTINE int_gen_write_field_header ( hdrbuf, hdrbufsize, itypesize, ftypesize hdrbuf(1) = 0 ! deferred -- this will be length of header - hdrbuf(2) = int_field + hdrbuf(2) = INT_FIELD hdrbuf(3) = ftypesize i = 4 @@ -215,8 +215,8 @@ SUBROUTINE int_get_write_field_header ( hdrbuf, hdrbufsize, itypesize, ftypesize INTEGER i, n hdrbufsize = hdrbuf(1) - IF ( hdrbuf(2) .NE. int_field ) THEN - write(mess,*)'int_get_write_field_header: hdrbuf(2) ne int_field ',hdrbuf(2),int_field + IF ( hdrbuf(2) .NE. INT_FIELD ) THEN + write(mess,*)'int_get_write_field_header: hdrbuf(2) ne INT_FIELD ',hdrbuf(2),INT_FIELD CALL wrf_error_fatal ( mess ) ENDIF ftypesize = hdrbuf(3) @@ -269,7 +269,7 @@ SUBROUTINE int_gen_ofr_header( hdrbuf, hdrbufsize, itypesize, & ! hdrbufsize: Size of this data header in bytes. ! headerTag: "Header tag" that tells the I/O quilt servers what kind of ! header this is. For an "open for read" header it must be set to -! int_open_for_read. See file intio_tags.h for a complete list of +! INT_OPEN_FOR_READ. See file intio_tags.h for a complete list of ! these tags. ! DataHandle: Descriptor for an open data set. ! FileName: File name. @@ -292,7 +292,7 @@ SUBROUTINE int_gen_ofr_header( hdrbuf, hdrbufsize, itypesize, & INTEGER i, n, i1 ! hdrbuf(1) = 0 !deferred - hdrbuf(2) = int_open_for_read + hdrbuf(2) = INT_OPEN_FOR_READ i = 3 hdrbuf(i) = DataHandle ; i = i+1 @@ -324,8 +324,8 @@ SUBROUTINE int_get_ofr_header( hdrbuf, hdrbufsize, itypesize, & INTEGER i, n ! hdrbufsize = hdrbuf(1) -! IF ( hdrbuf(2) .NE. int_open_for_read ) THEN -! CALL wrf_error_fatal ( "int_get_ofr_header: hdrbuf ne int_open_for_read") +! IF ( hdrbuf(2) .NE. INT_OPEN_FOR_READ ) THEN +! CALL wrf_error_fatal ( "int_get_ofr_header: hdrbuf ne INT_OPEN_FOR_READ") ! ENDIF i = 3 DataHandle = hdrbuf(i) ; i = i+1 @@ -356,7 +356,7 @@ SUBROUTINE int_gen_ofwb_header( hdrbuf, hdrbufsize, itypesize, & ! hdrbufsize: Size of this data header in bytes. ! headerTag: "Header tag" that tells the I/O quilt servers what kind of ! header this is. For an "open for write begin" header it must be set to -! int_open_for_write_begin. See file intio_tags.h for a complete list of +! INT_OPEN_FOR_WRITE_BEGIN. See file intio_tags.h for a complete list of ! these tags. ! DataHandle: Descriptor for an open data set. ! io_form: I/O format for this file (netCDF, etc.). @@ -381,7 +381,7 @@ SUBROUTINE int_gen_ofwb_header( hdrbuf, hdrbufsize, itypesize, & INTEGER i, n, j ! hdrbuf(1) = 0 !deferred - hdrbuf(2) = int_open_for_write_begin + hdrbuf(2) = INT_OPEN_FOR_WRITE_BEGIN i = 3 hdrbuf(i) = DataHandle ; i = i+1 hdrbuf(i) = io_form ; i = i+1 @@ -420,8 +420,8 @@ SUBROUTINE int_get_ofwb_header( hdrbuf, hdrbufsize, itypesize, & ! hdrbufsize = hdrbuf(1) !write(0,*)' int_get_ofwb_header next rec start ',hdrbuf(hdrbufsize+1) -! IF ( hdrbuf(2) .NE. int_open_for_write_begin ) THEN -! CALL wrf_error_fatal ( "int_get_ofwb_header: hdrbuf ne int_open_for_write_begin") +! IF ( hdrbuf(2) .NE. INT_OPEN_FOR_WRITE_BEGIN ) THEN +! CALL wrf_error_fatal ( "int_get_ofwb_header: hdrbuf ne INT_OPEN_FOR_WRITE_BEGIN") ! ENDIF i = 3 DataHandle = hdrbuf(i) ; i = i+1 @@ -529,7 +529,7 @@ SUBROUTINE int_gen_ti_header_integer( hdrbuf, hdrbufsize, itypesize, typesize, & ! hdrbufsize: Size of this data header in bytes. ! headerTag: "Header tag" that tells the I/O quilt servers what kind of ! header this is. For an "time-independent integer" header it must be -! set to int_dom_ti_integer. See file intio_tags.h for a complete +! set to INT_DOM_TI_INTEGER. See file intio_tags.h for a complete ! list of these tags. ! DataHandle: Descriptor for an open data set. ! typesize: Size in bytes of each element of Data. @@ -584,7 +584,7 @@ SUBROUTINE int_gen_ti_header_integer_varna( hdrbuf, hdrbufsize, itypesize, types ! hdrbufsize: Size of this data header in bytes. ! headerTag: "Header tag" that tells the I/O quilt servers what kind of ! header this is. For an "time-independent integer" header it must be -! set to int_dom_ti_integer. See file intio_tags.h for a complete +! set to INT_DOM_TI_INTEGER. See file intio_tags.h for a complete ! list of these tags. ! DataHandle: Descriptor for an open data set. ! typesize: Size in bytes of each element of Data. @@ -761,7 +761,7 @@ SUBROUTINE int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & ! hdrbufsize: Size of this data header in bytes. ! headerTag: "Header tag" that tells the I/O quilt servers what kind of ! header this is. For an "time-independent string" header it must be -! set to int_dom_ti_char. See file intio_tags.h for a complete +! set to INT_DOM_TI_CHAR. See file intio_tags.h for a complete ! list of these tags. ! DataHandle: Descriptor for an open data set. ! typesize: 1 (size in bytes of a single CHARACTER). @@ -852,7 +852,7 @@ SUBROUTINE int_gen_td_header_char( hdrbuf, hdrbufsize, itypesize, & ! hdrbufsize: Size of this data header in bytes. ! headerTag: "Header tag" that tells the I/O quilt servers what kind of ! header this is. For an "time-dependent string" header it must be -! set to int_dom_td_char. See file intio_tags.h for a complete +! set to INT_DOM_TD_CHAR. See file intio_tags.h for a complete ! list of these tags. ! DataHandle: Descriptor for an open data set. ! typesize: 1 (size in bytes of a single CHARACTER). @@ -937,7 +937,7 @@ SUBROUTINE int_gen_td_header_integer( hdrbuf, hdrbufsize, itypesize, typesize, & ! hdrbufsize: Size of this data header in bytes. ! headerTag: "Header tag" that tells the I/O quilt servers what kind of ! header this is. For an "time-dependent integer" header it must be -! set to int_dom_td_integer. See file intio_tags.h for a complete +! set to INT_DOM_TD_INTEGER. See file intio_tags.h for a complete ! list of these tags. ! DataHandle: Descriptor for an open data set. ! typesize: 1 (size in bytes of a single CHARACTER). @@ -1074,7 +1074,7 @@ SUBROUTINE int_gen_noop_header ( hdrbuf, hdrbufsize, itypesize ) ! hdrbufsize: Size of this data header in bytes. ! headerTag: "Header tag" that tells the I/O quilt servers what kind of ! header this is. For an "no-operation" header it must be -! set to int_noop. See file intio_tags.h for a complete +! set to INT_NOOP. See file intio_tags.h for a complete ! list of these tags. ! ! @@ -1087,7 +1087,7 @@ SUBROUTINE int_gen_noop_header ( hdrbuf, hdrbufsize, itypesize ) INTEGER i ! hdrbuf(1) = 0 !deferred - hdrbuf(2) = int_noop + hdrbuf(2) = INT_NOOP i = 3 hdrbufsize = (i-1) * itypesize ! return the number in bytes hdrbuf(1) = hdrbufsize @@ -1110,8 +1110,8 @@ SUBROUTINE int_get_noop_header( hdrbuf, hdrbufsize, itypesize ) INTEGER i ! hdrbufsize = hdrbuf(1) - IF ( hdrbuf(2) .NE. int_noop ) THEN - CALL wrf_error_fatal ( "int_get_noop_header: hdrbuf ne int_noop") + IF ( hdrbuf(2) .NE. INT_NOOP ) THEN + CALL wrf_error_fatal ( "int_get_noop_header: hdrbuf ne INT_NOOP") ENDIF i = 3 RETURN diff --git a/frame/module_io_quilt_old.F b/frame/module_io_quilt_old.F index e46d8b1095..69e443a69b 100644 --- a/frame/module_io_quilt_old.F +++ b/frame/module_io_quilt_old.F @@ -743,7 +743,7 @@ SUBROUTINE quilt ALLOCATE( obuf( 4096 ) ) ! DataHandle is provided as second element of reduced CALL int_gen_handle_header( obuf, obufsize, itypesize, & - reduced(2) , int_ioclose ) + reduced(2) , INT_IOCLOSE ) if(poll_servers) then ! Once we're done closing, we need to tell the master @@ -775,7 +775,7 @@ SUBROUTINE quilt DO WHILE ( icurs .lt. obufsize ) ! { hdr_tag = get_hdr_tag( obuf ( icurs / itypesize ) ) SELECT CASE ( hdr_tag ) - CASE ( int_field ) + CASE ( INT_FIELD ) CALL int_get_write_field_header ( obuf(icurs/itypesize), hdrbufsize, itypesize, ftypesize, & DataHandle , DateStr , VarName , Dummy , FieldType , Comm , IOComm, & DomainDesc , MemoryOrder , Stagger , DimNames , & @@ -806,7 +806,7 @@ SUBROUTINE quilt call add_to_bufsize_for_field( VarName, chunksize ) icurs = icurs + chunksize ENDIF - CASE ( int_open_for_write_commit ) ! only one per group of tasks + CASE ( INT_OPEN_FOR_WRITE_COMMIT ) ! only one per group of tasks hdrbufsize = obuf(icurs/itypesize) IF (num_commit_messages.EQ.0) THEN call add_to_bufsize_for_field( 'COMMIT', hdrbufsize ) @@ -851,14 +851,14 @@ SUBROUTINE quilt ! call to collect_on_comm: 1 bona fide output record from server task ! 0 and noops from the rest. - IF ((hdr_tag.EQ.int_noop.AND.mytask_local.NE.0.AND.num_noops.LE.0) & - .OR.hdr_tag.NE.int_noop) THEN + IF ((hdr_tag.EQ.INT_NOOP.AND.mytask_local.NE.0.AND.num_noops.LE.0) & + .OR.hdr_tag.NE.INT_NOOP) THEN write(VarName,'(I5.5)')vid !write(0,*) 'X-2', hdrbufsize, get_hdr_tag( obuf ( icurs / itypesize ) ) , get_hdr_rec_size( obuf ( icurs / itypesize ) ), TRIM(VarName) call add_to_bufsize_for_field( VarName, hdrbufsize ) vid = vid+1 ENDIF - IF ( hdr_tag .EQ. int_noop ) num_noops = num_noops + 1 + IF ( hdr_tag .EQ. INT_NOOP ) num_noops = num_noops + 1 icurs = icurs + hdrbufsize END SELECT ENDDO ! } @@ -874,7 +874,7 @@ SUBROUTINE quilt !write(0,*) 'A icurs ', icurs, ' obufsize ', obufsize hdr_tag = get_hdr_tag( obuf ( icurs / itypesize ) ) SELECT CASE ( hdr_tag ) - CASE ( int_field ) + CASE ( INT_FIELD ) CALL int_get_write_field_header ( obuf(icurs/itypesize), hdrbufsize, itypesize, ftypesize, & DataHandle , DateStr , VarName , Dummy , FieldType , Comm , IOComm, & DomainDesc , MemoryOrder , Stagger , DimNames , & @@ -902,7 +902,7 @@ SUBROUTINE quilt call store_piece_of_field( obuf(icurs/itypesize), VarName, chunksize ) icurs = icurs + chunksize ENDIF - CASE ( int_open_for_write_commit ) ! only one per group of tasks + CASE ( INT_OPEN_FOR_WRITE_COMMIT ) ! only one per group of tasks hdrbufsize = obuf(icurs/itypesize) IF (num_commit_messages.EQ.0) THEN call store_piece_of_field( obuf(icurs/itypesize), 'COMMIT', hdrbufsize ) @@ -911,14 +911,14 @@ SUBROUTINE quilt icurs = icurs + hdrbufsize CASE DEFAULT hdrbufsize = obuf(icurs/itypesize) - IF ((hdr_tag.EQ.int_noop.AND.mytask_local.NE.0.AND.num_noops.LE.0) & - .OR.hdr_tag.NE.int_noop) THEN + IF ((hdr_tag.EQ.INT_NOOP.AND.mytask_local.NE.0.AND.num_noops.LE.0) & + .OR.hdr_tag.NE.INT_NOOP) THEN write(VarName,'(I5.5)')vid !write(0,*) 'A-2b', hdrbufsize, get_hdr_tag( obuf ( icurs / itypesize ) ) , get_hdr_rec_size( obuf ( icurs / itypesize ) ), TRIM(VarName) call store_piece_of_field( obuf(icurs/itypesize), VarName, hdrbufsize ) vid = vid+1 ENDIF - IF ( hdr_tag .EQ. int_noop ) num_noops = num_noops + 1 + IF ( hdr_tag .EQ. INT_NOOP ) num_noops = num_noops + 1 icurs = icurs + hdrbufsize END SELECT ENDDO !} @@ -981,12 +981,12 @@ SUBROUTINE quilt ! actually quite easy. "Noop" requests exist to help avoid race conditions. ! In some cases, only one compute task will everything about a request so ! other compute tasks send "noop" requests. - CASE ( int_noop ) + CASE ( INT_NOOP ) CALL int_get_noop_header( bigbuf(icurs/itypesize), hdrbufsize, itypesize ) icurs = icurs + hdrbufsize ! The I/O server "root" handles the "put_dom_td_real" request. - CASE ( int_dom_td_real ) + CASE ( INT_DOM_TD_REAL ) CALL mpi_type_size( MPI_REAL, ftypesize, ierr ) ALLOCATE( RData( bigbuf(icurs/itypesize + 4 ) ) ) ! 5 is the count of data items for this record ; defined in collect_on_comm.c CALL int_get_td_header( bigbuf(icurs/itypesize:), hdrbufsize, itypesize, ftypesize, & @@ -1020,8 +1020,8 @@ SUBROUTINE quilt DEALLOCATE( RData ) ! The I/O server "root" handles the "put_dom_ti_real" request. - CASE ( int_dom_ti_real ) -!write(0,*)' int_dom_ti_real ' + CASE ( INT_DOM_TI_REAL ) +!write(0,*)' INT_DOM_TI_REAL ' CALL mpi_type_size( MPI_REAL, ftypesize, ierr ) ALLOCATE( RData( bigbuf(icurs/itypesize + 4 ) ) ) ! 5 is the count of data items for this record ; defined in collect_on_comm.c CALL int_get_ti_header( bigbuf(icurs/itypesize:), hdrbufsize, itypesize, ftypesize, & @@ -1057,8 +1057,8 @@ SUBROUTINE quilt DEALLOCATE( RData ) ! The I/O server "root" handles the "put_dom_td_integer" request. - CASE ( int_dom_td_integer ) -!write(0,*)' int_dom_td_integer ' + CASE ( INT_DOM_TD_INTEGER ) +!write(0,*)' INT_DOM_TD_INTEGER ' CALL mpi_type_size( MPI_INTEGER, ftypesize, ierr ) ALLOCATE( IData( bigbuf(icurs/itypesize + 4 ) ) ) ! 5 is the count of data items for this record ; defined in collect_on_comm.c CALL int_get_td_header( bigbuf(icurs/itypesize:), hdrbufsize, itypesize, ftypesize, & @@ -1093,8 +1093,8 @@ SUBROUTINE quilt DEALLOCATE( IData ) ! The I/O server "root" handles the "put_dom_ti_integer" request. - CASE ( int_dom_ti_integer ) -!write(0,*)' int_dom_ti_integer ' + CASE ( INT_DOM_TI_INTEGER ) +!write(0,*)' INT_DOM_TI_INTEGER ' CALL mpi_type_size( MPI_INTEGER, ftypesize, ierr ) ALLOCATE( IData( bigbuf(icurs/itypesize + 4 ) ) ) ! 5 is the count of data items for this record ; defined in collect_on_comm.c @@ -1131,8 +1131,8 @@ SUBROUTINE quilt DEALLOCATE( IData) ! The I/O server "root" handles the "set_time" request. - CASE ( int_set_time ) -!write(0,*)' int_set_time ' + CASE ( INT_SET_TIME ) +!write(0,*)' INT_SET_TIME ' CALL int_get_ti_header_char( bigbuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle, Element, VarName, CData, code ) SELECT CASE (use_package(io_form(DataHandle))) @@ -1147,7 +1147,7 @@ SUBROUTINE quilt icurs = icurs + hdrbufsize ! The I/O server "root" handles the "put_dom_ti_char" request. - CASE ( int_dom_ti_char ) + CASE ( INT_DOM_TI_CHAR ) !write(0,*)' before int_get_ti_header_char ' CALL int_get_ti_header_char( bigbuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle, Element, VarName, CData, code ) @@ -1181,8 +1181,8 @@ SUBROUTINE quilt icurs = icurs + hdrbufsize ! The I/O server "root" handles the "put_var_ti_char" request. - CASE ( int_var_ti_char ) -!write(0,*)' int_var_ti_char ' + CASE ( INT_VAR_TI_CHAR ) +!write(0,*)' INT_VAR_TI_CHAR ' CALL int_get_ti_header_char( bigbuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle, Element, VarName, CData, code ) @@ -1213,12 +1213,12 @@ SUBROUTINE quilt icurs = icurs + hdrbufsize - CASE ( int_ioexit ) + CASE ( INT_IOEXIT ) ! ioexit is now handled by sending negative message length to server CALL wrf_error_fatal( & - "quilt: should have handled int_ioexit already") + "quilt: should have handled INT_IOEXIT already") ! The I/O server "root" handles the "ioclose" request. - CASE ( int_ioclose ) + CASE ( INT_IOCLOSE ) CALL int_get_handle_header( bigbuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle , code ) icurs = icurs + hdrbufsize @@ -1281,17 +1281,17 @@ SUBROUTINE quilt ENDIF ! The I/O server "root" handles the "open_for_write_begin" request. - CASE ( int_open_for_write_begin ) + CASE ( INT_OPEN_FOR_WRITE_BEGIN ) CALL int_get_ofwb_header( bigbuf(icurs/itypesize), hdrbufsize, itypesize, & FileName,SysDepInfo,io_form_arg,DataHandle ) -!write(0,*)' int_open_for_write_begin itypesize ',itypesize,' itypesize ',itypesize -!write(0,*)' int_open_for_write_begin icurs ', icurs, hdrbufsize -!JMDEBUGwrite(0,*)' int_open_for_write_begin FileName ',TRIM(FileName) , ' DataHandle ', DataHandle -!write(0,*)' int_open_for_write_begin SysDepInfo ',TRIM(SysDepInfo) +!write(0,*)' INT_OPEN_FOR_WRITE_BEGIN itypesize ',itypesize,' itypesize ',itypesize +!write(0,*)' INT_OPEN_FOR_WRITE_BEGIN icurs ', icurs, hdrbufsize +!JMDEBUGwrite(0,*)' INT_OPEN_FOR_WRITE_BEGIN FileName ',TRIM(FileName) , ' DataHandle ', DataHandle +!write(0,*)' INT_OPEN_FOR_WRITE_BEGIN SysDepInfo ',TRIM(SysDepInfo) icurs = icurs + hdrbufsize -!write(0,*)' int_open_for_write_begin new icurs,tag,size ', icurs, get_hdr_tag( bigbuf(icurs/itypesize) ),get_hdr_rec_size( bigbuf(icurs/itypesize) ) +!write(0,*)' INT_OPEN_FOR_WRITE_BEGIN new icurs,tag,size ', icurs, get_hdr_tag( bigbuf(icurs/itypesize) ),get_hdr_rec_size( bigbuf(icurs/itypesize) ) io_form(DataHandle) = io_form_arg @@ -1327,14 +1327,14 @@ SUBROUTINE quilt ! In this case, the "okay_to_commit" is simply set to .true. so "write_field" ! requests will initiate writes to disk. Actual commit will be done after ! all requests in this batch have been handled. - CASE ( int_open_for_write_commit ) + CASE ( INT_OPEN_FOR_WRITE_COMMIT ) CALL int_get_handle_header( bigbuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle , code ) icurs = icurs + hdrbufsize okay_to_commit(DataHandle) = .true. -! The I/O server "root" handles the "write_field" (int_field) request. +! The I/O server "root" handles the "write_field" (INT_FIELD) request. ! If okay_to_write(DataHandle) is .true. then the patch in the ! header (bigbuf) is written to a globally-sized internal output buffer via ! the call to store_patch_in_outbuf(). Note that this is where the actual @@ -1342,9 +1342,9 @@ SUBROUTINE quilt ! okay_to_write(DataHandle) is .false. then external I/O package interfaces ! are called to write metadata for I/O formats that support native metadata. ! -! NOTE that the I/O server "root" will only see write_field (int_field) +! NOTE that the I/O server "root" will only see write_field (INT_FIELD) ! requests AFTER an "iosync" request. - CASE ( int_field ) + CASE ( INT_FIELD ) CALL mpi_type_size( MPI_INTEGER, ftypesize, ierr ) CALL int_get_write_field_header ( bigbuf(icurs/itypesize), hdrbufsize, itypesize, ftypesize, & DataHandle , DateStr , VarName , Dummy , FieldType , Comm , IOComm, & @@ -1352,7 +1352,7 @@ SUBROUTINE quilt DomainStart , DomainEnd , & MemoryStart , MemoryEnd , & PatchStart , PatchEnd ) -!write(0,*)' int_field ',TRIM(VarName),DataHandle,okay_to_write(DataHandle) +!write(0,*)' INT_FIELD ',TRIM(VarName),DataHandle,okay_to_write(DataHandle) icurs = icurs + hdrbufsize IF ( okay_to_write(DataHandle) ) THEN @@ -1418,7 +1418,7 @@ SUBROUTINE quilt Status = 0 END SELECT ENDIF - CASE ( int_iosync ) + CASE ( INT_IOSYNC ) CALL int_get_handle_header( bigbuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle , code ) icurs = icurs + hdrbufsize @@ -1436,7 +1436,7 @@ SUBROUTINE quilt ! (via a call to store_patch_in_outbuf()) then call write_outbuf() to write ! them to disk now. ! NOTE that the I/O server "root" will only have called -! store_patch_in_outbuf() when handling write_field (int_field) +! store_patch_in_outbuf() when handling write_field (INT_FIELD) ! commands which only arrive AFTER an "iosync" command. ! CALL start_timing CALL write_outbuf ( handle(DataHandle), use_package(io_form(DataHandle))) @@ -1745,7 +1745,7 @@ SUBROUTINE quilt_pnc ALLOCATE( obuf( 4096 ) ) ! DataHandle is provided as second element of reduced CALL int_gen_handle_header( obuf, obufsize, itypesize, & - reduced(2) , int_ioclose ) + reduced(2) , INT_IOCLOSE ) ENDIF !write(0,*)'calling init_store_piece_of_field' @@ -1772,7 +1772,7 @@ SUBROUTINE quilt_pnc DO WHILE ( icurs .lt. obufsize ) ! { hdr_tag = get_hdr_tag( obuf ( icurs / itypesize ) ) SELECT CASE ( hdr_tag ) - CASE ( int_field ) + CASE ( INT_FIELD ) CALL int_get_write_field_header ( obuf(icurs/itypesize), hdrbufsize, itypesize, ftypesize, & DataHandle , DateStr , VarName , Dummy , FieldType , Comm , IOComm, & DomainDesc , MemoryOrder , Stagger , DimNames , & @@ -1803,7 +1803,7 @@ SUBROUTINE quilt_pnc call add_to_bufsize_for_field( VarName, chunksize ) icurs = icurs + chunksize ENDIF - CASE ( int_open_for_write_commit ) ! only one per group of tasks + CASE ( INT_OPEN_FOR_WRITE_COMMIT ) ! only one per group of tasks hdrbufsize = obuf(icurs/itypesize) IF (num_commit_messages.EQ.0) THEN call add_to_bufsize_for_field( 'COMMIT', hdrbufsize ) @@ -1841,13 +1841,13 @@ SUBROUTINE quilt_pnc ! 5. Logic below does not allow any noop records through since each IO ! server task now receives a valid record (from the 'compute-group master' ! when doing replicated output - IF (hdr_tag.NE.int_noop) THEN + IF (hdr_tag.NE.INT_NOOP) THEN write(VarName,'(I5.5)')vid !write(0,*) 'X-2', hdrbufsize, get_hdr_tag( obuf ( icurs / itypesize ) ) , get_hdr_rec_size( obuf ( icurs / itypesize ) ), TRIM(VarName) call add_to_bufsize_for_field( VarName, hdrbufsize ) vid = vid+1 ENDIF - IF ( hdr_tag .EQ. int_noop ) num_noops = num_noops + 1 + IF ( hdr_tag .EQ. INT_NOOP ) num_noops = num_noops + 1 icurs = icurs + hdrbufsize END SELECT @@ -1864,7 +1864,7 @@ SUBROUTINE quilt_pnc !write(0,*) 'A icurs ', icurs, ' obufsize ', obufsize hdr_tag = get_hdr_tag( obuf ( icurs / itypesize ) ) SELECT CASE ( hdr_tag ) - CASE ( int_field ) + CASE ( INT_FIELD ) CALL int_get_write_field_header ( obuf(icurs/itypesize), hdrbufsize, itypesize, ftypesize, & DataHandle , DateStr , VarName , Dummy , FieldType , Comm , IOComm, & DomainDesc , MemoryOrder , Stagger , DimNames , & @@ -1892,7 +1892,7 @@ SUBROUTINE quilt_pnc icurs = icurs + chunksize !write(0,*) 'A-1a',TRIM(VarName),' icurs ',icurs,PatchStart(1:3),PatchEnd(1:3) ENDIF - CASE ( int_open_for_write_commit ) ! only one per group of tasks + CASE ( INT_OPEN_FOR_WRITE_COMMIT ) ! only one per group of tasks hdrbufsize = obuf(icurs/itypesize) IF (num_commit_messages.EQ.0) THEN call store_piece_of_field( obuf(icurs/itypesize), 'COMMIT', hdrbufsize ) @@ -1901,14 +1901,14 @@ SUBROUTINE quilt_pnc icurs = icurs + hdrbufsize CASE DEFAULT hdrbufsize = obuf(icurs/itypesize) - IF (hdr_tag.NE.int_noop) THEN + IF (hdr_tag.NE.INT_NOOP) THEN write(VarName,'(I5.5)')vid !write(0,*) 'A-2b', hdrbufsize, get_hdr_tag( obuf ( icurs / itypesize ) ) , get_hdr_rec_size( obuf ( icurs / itypesize ) ), TRIM(VarName) call store_piece_of_field( obuf(icurs/itypesize), VarName, hdrbufsize ) vid = vid+1 ENDIF - IF ( hdr_tag .EQ. int_noop ) num_noops = num_noops + 1 + IF ( hdr_tag .EQ. INT_NOOP ) num_noops = num_noops + 1 icurs = icurs + hdrbufsize END SELECT ENDDO !} while(icurs < obufsize) @@ -1942,13 +1942,13 @@ SUBROUTINE quilt_pnc SELECT CASE ( get_hdr_tag( obuf(icurs/itypesize) ) ) ! The I/O server handles the "noop" (do nothing) request. This is ! actually quite easy. "Noop" requests exist to help avoid race conditions. - CASE ( int_noop ) + CASE ( INT_NOOP ) CALL int_get_noop_header( obuf(icurs/itypesize), & hdrbufsize, itypesize ) icurs = icurs + hdrbufsize ! The I/O server "root" handles the "put_dom_td_real" request. - CASE ( int_dom_td_real ) + CASE ( INT_DOM_TD_REAL ) CALL mpi_type_size( MPI_REAL, ftypesize, ierr ) ALLOCATE( RData( obuf(icurs/itypesize + 4 ) ) ) ! 5 is the count of data items for this record ; defined in collect_on_comm.c CALL int_get_td_header( obuf(icurs/itypesize:), hdrbufsize, itypesize, ftypesize, & @@ -1986,7 +1986,7 @@ SUBROUTINE quilt_pnc DEALLOCATE( RData ) ! Every I/O server handles the "put_dom_ti_real" request. - CASE ( int_dom_ti_real ) + CASE ( INT_DOM_TI_REAL ) CALL mpi_type_size( MPI_REAL, ftypesize, ierr ) ALLOCATE( RData( obuf(icurs/itypesize + 4 ) ) ) ! 5 is the count of data items for this record ; defined in collect_on_comm.c @@ -2026,7 +2026,7 @@ SUBROUTINE quilt_pnc DEALLOCATE( RData ) ! Every I/O server handles the "put_dom_td_integer" request. - CASE ( int_dom_td_integer ) + CASE ( INT_DOM_TD_INTEGER ) CALL mpi_type_size( MPI_INTEGER, ftypesize, ierr ) ALLOCATE( IData( obuf(icurs/itypesize + 4 ) ) ) ! 5 is the count of data items for this record ; defined in collect_on_comm.c @@ -2066,7 +2066,7 @@ SUBROUTINE quilt_pnc DEALLOCATE( IData ) ! Every I/O server handles the "put_dom_ti_integer" request. - CASE ( int_dom_ti_integer ) + CASE ( INT_DOM_TI_INTEGER ) CALL mpi_type_size( MPI_INTEGER, ftypesize, ierr ) ALLOCATE( IData( obuf(icurs/itypesize + 4 ) ) ) ! 5 is the count of data items for this record ; defined in collect_on_comm.c @@ -2106,7 +2106,7 @@ SUBROUTINE quilt_pnc DEALLOCATE( IData) ! Every I/O server handles the "set_time" request. - CASE ( int_set_time ) + CASE ( INT_SET_TIME ) CALL int_get_ti_header_char( obuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle, Element, VarName, CData, code ) @@ -2122,7 +2122,7 @@ SUBROUTINE quilt_pnc icurs = icurs + hdrbufsize ! Every I/O server handles the "put_dom_ti_char" request. - CASE ( int_dom_ti_char ) + CASE ( INT_DOM_TI_CHAR ) CALL int_get_ti_header_char( obuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle, Element, VarName, CData, code ) @@ -2159,7 +2159,7 @@ SUBROUTINE quilt_pnc icurs = icurs + hdrbufsize ! Every I/O server handles the "put_var_ti_char" request. - CASE ( int_var_ti_char ) + CASE ( INT_VAR_TI_CHAR ) CALL int_get_ti_header_char( obuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle, Element, VarName, CData, code ) @@ -2195,12 +2195,12 @@ SUBROUTINE quilt_pnc icurs = icurs + hdrbufsize - CASE ( int_ioexit ) + CASE ( INT_IOEXIT ) ! ioexit is now handled by sending negative message length to server CALL wrf_error_fatal( & - "quilt: should have handled int_ioexit already") + "quilt: should have handled INT_IOEXIT already") ! Every I/O server handles the "ioclose" request. - CASE ( int_ioclose ) + CASE ( INT_IOCLOSE ) CALL int_get_handle_header( obuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle , code ) icurs = icurs + hdrbufsize @@ -2256,17 +2256,17 @@ SUBROUTINE quilt_pnc ENDIF ! Every I/O server handles the "open_for_write_begin" request. - CASE ( int_open_for_write_begin ) + CASE ( INT_OPEN_FOR_WRITE_BEGIN ) CALL int_get_ofwb_header( obuf(icurs/itypesize), hdrbufsize, itypesize, & FileName,SysDepInfo,io_form_arg,DataHandle ) -!write(0,*)' int_open_for_write_begin itypesize ',itypesize,' itypesize ',itypesize -!write(0,*)' int_open_for_write_begin icurs ', icurs, hdrbufsize -!JMDEBUGwrite(0,*)' int_open_for_write_begin FileName ',TRIM(FileName) , ' DataHandle ', DataHandle -!write(0,*)' int_open_for_write_begin SysDepInfo ',TRIM(SysDepInfo) +!write(0,*)' INT_OPEN_FOR_WRITE_BEGIN itypesize ',itypesize,' itypesize ',itypesize +!write(0,*)' INT_OPEN_FOR_WRITE_BEGIN icurs ', icurs, hdrbufsize +!JMDEBUGwrite(0,*)' INT_OPEN_FOR_WRITE_BEGIN FileName ',TRIM(FileName) , ' DataHandle ', DataHandle +!write(0,*)' INT_OPEN_FOR_WRITE_BEGIN SysDepInfo ',TRIM(SysDepInfo) icurs = icurs + hdrbufsize -!write(0,*)' int_open_for_write_begin new icurs,tag,size ', icurs, get_hdr_tag( bigbuf(icurs/itypesize) ),get_hdr_rec_size( bigbuf(icurs/itypesize) ) +!write(0,*)' INT_OPEN_FOR_WRITE_BEGIN new icurs,tag,size ', icurs, get_hdr_tag( bigbuf(icurs/itypesize) ),get_hdr_rec_size( bigbuf(icurs/itypesize) ) io_form(DataHandle) = io_form_arg @@ -2304,25 +2304,25 @@ SUBROUTINE quilt_pnc ! Every I/O server handles the "open_for_write_commit" request. ! In this case, the "okay_to_commit" is simply set to .true. so "write_field" -! (int_field) requests will initiate writes to disk. Actual commit will be done after +! (INT_FIELD) requests will initiate writes to disk. Actual commit will be done after ! all requests in this batch have been handled. - CASE ( int_open_for_write_commit ) + CASE ( INT_OPEN_FOR_WRITE_COMMIT ) CALL int_get_handle_header( obuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle , code ) icurs = icurs + hdrbufsize okay_to_commit(DataHandle) = .true. -! Every I/O server handles the "write_field" (int_field) request. +! Every I/O server handles the "write_field" (INT_FIELD) request. ! If okay_to_write(DataHandle) is .true. then the patch in the ! header (bigbuf) is written to disk using pNetCDF. Note that this is where the actual ! "quilting" (reassembly of patches onto a full-size domain) is done. If ! okay_to_write(DataHandle) is .false. then external I/O package interfaces ! are called to write metadata for I/O formats that support native metadata. ! -! NOTE that the I/O servers will only see write_field (int_field) +! NOTE that the I/O servers will only see write_field (INT_FIELD) ! requests AFTER an "iosync" request. - CASE ( int_field ) + CASE ( INT_FIELD ) CALL mpi_type_size( MPI_INTEGER, ftypesize, ierr ) CALL int_get_write_field_header ( obuf(icurs/itypesize), hdrbufsize, itypesize, ftypesize, & DataHandle , DateStr , VarName , Dummy , FieldType , Comm , IOComm, & @@ -2330,7 +2330,7 @@ SUBROUTINE quilt_pnc DomainStart , DomainEnd , & MemoryStart , MemoryEnd , & PatchStart , PatchEnd ) -!write(0,*)' int_field ',TRIM(VarName),DataHandle,okay_to_write(DataHandle) +!write(0,*)' INT_FIELD ',TRIM(VarName),DataHandle,okay_to_write(DataHandle) icurs = icurs + hdrbufsize IF ( okay_to_write(DataHandle) ) THEN @@ -2445,7 +2445,7 @@ SUBROUTINE quilt_pnc Status = 0 END SELECT ENDIF - CASE ( int_iosync ) + CASE ( INT_IOSYNC ) CALL int_get_handle_header( obuf(icurs/itypesize), hdrbufsize, itypesize, & DataHandle , code ) icurs = icurs + hdrbufsize @@ -2465,7 +2465,7 @@ SUBROUTINE quilt_pnc ! (via a call to store_patch_in_outbuf_pnc()) then call write_outbuf_pnc() ! to write them to disk now. ! NOTE that the I/O server will only have called -! store_patch_in_outbuf() when handling write_field (int_field) +! store_patch_in_outbuf() when handling write_field (INT_FIELD) ! commands which only arrive AFTER an "iosync" command. ! CALL start_timing #ifdef PNETCDF_QUILT @@ -3088,7 +3088,7 @@ SUBROUTINE wrf_quilt_open_for_write_commit( DataHandle , Status ) !ARP parallel IO IF(compute_group_master(1)) THEN CALL int_gen_handle_header( hdrbuf, hdrbufsize, itypesize, & - DataHandle, int_open_for_write_commit ) + DataHandle, INT_OPEN_FOR_WRITE_COMMIT ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) END IF @@ -3096,7 +3096,7 @@ SUBROUTINE wrf_quilt_open_for_write_commit( DataHandle , Status ) IF ( wrf_dm_on_monitor() ) THEN CALL int_gen_handle_header( hdrbuf, hdrbufsize, itypesize, & - DataHandle, int_open_for_write_commit ) + DataHandle, INT_OPEN_FOR_WRITE_COMMIT ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -3336,14 +3336,14 @@ SUBROUTINE wrf_quilt_ioclose ( DataHandle, Status ) #ifdef PNETCDF_QUILT IF ( compute_group_master(1) )THEN CALL int_gen_handle_header( hdrbuf, hdrbufsize, itypesize, & - DataHandle, int_ioclose ) + DataHandle, INT_IOCLOSE ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF #else IF ( wrf_dm_on_monitor() ) THEN CALL int_gen_handle_header( hdrbuf, hdrbufsize, itypesize, & - DataHandle , int_ioclose ) + DataHandle , INT_IOCLOSE ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -3420,7 +3420,7 @@ SUBROUTINE wrf_quilt_ioexit( Status ) !ARP Send the ioexit message just once to each IOServer when using parallel IO IF( compute_group_master(1) ) THEN CALL int_gen_handle_header( hdrbuf, hdrbufsize, itypesize, & - DataHandle, int_ioexit ) + DataHandle, INT_IOEXIT ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) END IF @@ -3428,7 +3428,7 @@ SUBROUTINE wrf_quilt_ioexit( Status ) IF ( wrf_dm_on_monitor() ) THEN CALL int_gen_handle_header( hdrbuf, hdrbufsize, itypesize, & - DataHandle , int_ioexit ) ! Handle is dummy + DataHandle , INT_IOEXIT ) ! Handle is dummy ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -3532,14 +3532,14 @@ SUBROUTINE wrf_quilt_set_time ( DataHandle, Data, Status ) ! can't tell that's what they are on the IO servers themselves - therefore use ! the compute_group_master process. CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & - DataHandle, "TIMESTAMP", "", Data, int_set_time ) + DataHandle, "TIMESTAMP", "", Data, INT_SET_TIME ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) END IF #else IF ( wrf_dm_on_monitor() ) THEN CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & - DataHandle, "TIMESTAMP", "", Data, int_set_time ) + DataHandle, "TIMESTAMP", "", Data, INT_SET_TIME ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -3648,14 +3648,14 @@ SUBROUTINE wrf_quilt_put_dom_ti_real ( DataHandle,Element, Data, Count, Statu #ifdef PNETCDF_QUILT IF ( compute_group_master(1) ) THEN CALL int_gen_ti_header( hdrbuf, hdrbufsize, itypesize, typesize, & - DataHandle, locElement, Data, Count, int_dom_ti_real ) + DataHandle, locElement, Data, Count, INT_DOM_TI_REAL ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF #else IF ( wrf_dm_on_monitor() ) THEN CALL int_gen_ti_header( hdrbuf, hdrbufsize, itypesize, typesize, & - DataHandle, locElement, Data, Count, int_dom_ti_real ) + DataHandle, locElement, Data, Count, INT_DOM_TI_REAL ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -3806,7 +3806,7 @@ SUBROUTINE wrf_quilt_put_dom_ti_integer ( DataHandle,Element, Data, Count, St IF ( compute_group_master(1) )THEN CALL int_gen_ti_header( hdrbuf, hdrbufsize, itypesize, typesize, & DataHandle, locElement, Data, Count, & - int_dom_ti_integer ) + INT_DOM_TI_INTEGER ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -3814,7 +3814,7 @@ SUBROUTINE wrf_quilt_put_dom_ti_integer ( DataHandle,Element, Data, Count, St IF ( wrf_dm_on_monitor() ) THEN CALL int_gen_ti_header( hdrbuf, hdrbufsize, itypesize, typesize, & DataHandle, locElement, Data, Count, & - int_dom_ti_integer ) + INT_DOM_TI_INTEGER ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -3966,14 +3966,14 @@ SUBROUTINE wrf_quilt_put_dom_ti_char ( DataHandle, Element, Data, Status ) IF(compute_group_master(1))THEN CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & DataHandle, Element, "", Data, & - int_dom_ti_char ) + INT_DOM_TI_CHAR ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) END IF #else IF ( wrf_dm_on_monitor() ) THEN CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & - DataHandle, Element, "", Data, int_dom_ti_char ) + DataHandle, Element, "", Data, INT_DOM_TI_CHAR ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -4510,7 +4510,7 @@ SUBROUTINE wrf_quilt_put_var_ti_char ( DataHandle,Element, Varname, Data, Stat IF ( compute_group_master(1) ) THEN CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & DataHandle, TRIM(Element), & - TRIM(VarName), TRIM(Data), int_var_ti_char ) + TRIM(VarName), TRIM(Data), INT_VAR_TI_CHAR ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -4518,7 +4518,7 @@ SUBROUTINE wrf_quilt_put_var_ti_char ( DataHandle,Element, Varname, Data, Stat IF ( wrf_dm_on_monitor() ) THEN CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, & DataHandle, TRIM(Element), & - TRIM(VarName), TRIM(Data), int_var_ti_char ) + TRIM(VarName), TRIM(Data), INT_VAR_TI_CHAR ) ELSE CALL int_gen_noop_header( hdrbuf, hdrbufsize, itypesize ) ENDIF @@ -4852,7 +4852,7 @@ SUBROUTINE wrf_quilt_write_field ( DataHandle , DateStr , VarName , Field , Fiel ! During a "real" write, this routine begins by allocating ! int_local_output_buffer if it has not already been allocated. Sizes ! accumulated during "training" are used to determine how big -! int_local_output_buffer must be. This routine then stores "int_field" +! int_local_output_buffer must be. This routine then stores "INT_FIELD" ! headers and associated field data in int_local_output_buffer. The contents ! of int_local_output_buffer are actually sent to the I/O quilt server in ! routine wrf_quilt_iosync(). This scheme allows output of multiple variables From 5a9d615e3ac57df4ee31db84212d02ad06600c71 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 17 May 2023 16:51:30 -0600 Subject: [PATCH 107/180] Removing redundant files --- external/io_grib1/wrf_status_codes.h | 133 -------------------- external/io_grib_share/wrf_io_flags.h | 16 --- external/io_grib_share/wrf_status_codes.h | 142 ---------------------- 3 files changed, 291 deletions(-) delete mode 100644 external/io_grib1/wrf_status_codes.h delete mode 100644 external/io_grib_share/wrf_io_flags.h delete mode 100644 external/io_grib_share/wrf_status_codes.h diff --git a/external/io_grib1/wrf_status_codes.h b/external/io_grib1/wrf_status_codes.h deleted file mode 100644 index 059d9ea719..0000000000 --- a/external/io_grib1/wrf_status_codes.h +++ /dev/null @@ -1,133 +0,0 @@ - -!WRF Error and Warning messages (1-999) -!All i/o package-specific status codes you may want to add must be handled by your package (see below) -! WRF handles these and netCDF messages only - integer, parameter :: WRF_NO_ERR = 0 !no error - integer, parameter :: WRF_WARN_FILE_NF = -1 !file not found, or incomplete - integer, parameter :: WRF_WARN_MD_NF = -2 !metadata not found - integer, parameter :: WRF_WARN_TIME_NF = -3 !timestamp not found - integer, parameter :: WRF_WARN_TIME_EOF = -4 !no more timestamps - integer, parameter :: WRF_WARN_VAR_NF = -5 !variable not found - integer, parameter :: WRF_WARN_VAR_EOF = -6 !no more variables for the current time - integer, parameter :: WRF_WARN_TOO_MANY_FILES = -7 !too many open files - integer, parameter :: WRF_WARN_TYPE_MISMATCH = -8 !data type mismatch - integer, parameter :: WRF_WARN_WRITE_RONLY_FILE = -9 !attempt to write readonly file - integer, parameter :: WRF_WARN_READ_WONLY_FILE = -10 !attempt to read writeonly file - integer, parameter :: WRF_WARN_FILE_NOT_OPENED = -11 !attempt to access unopened file - integer, parameter :: WRF_WARN_2DRYRUNS_1VARIABLE = -12 !attempt to do 2 trainings for 1 variable - integer, parameter :: WRF_WARN_READ_PAST_EOF = -13 !attempt to read past EOF - integer, parameter :: WRF_WARN_BAD_DATA_HANDLE = -14 !bad data handle - integer, parameter :: WRF_WARN_WRTLEN_NE_DRRUNLEN = -15 !write length not equal to training length - integer, parameter :: WRF_WARN_TOO_MANY_DIMS = -16 !more dimensions requested than training - integer, parameter :: WRF_WARN_COUNT_TOO_LONG = -17 !attempt to read more data than exists - integer, parameter :: WRF_WARN_DIMENSION_ERROR = -18 !input dimension inconsistent - integer, parameter :: WRF_WARN_BAD_MEMORYORDER = -19 !input MemoryOrder not recognized - integer, parameter :: WRF_WARN_DIMNAME_REDEFINED = -20 !a dimension name with 2 different lengths - integer, parameter :: WRF_WARN_CHARSTR_GT_LENDATA = -21 !string longer than provided storage - integer, parameter :: WRF_WARN_NOTSUPPORTED = -22 !function not supportable - integer, parameter :: WRF_WARN_NOOP = -23 !package implements this routine as NOOP - -!Fatal errors - integer, parameter :: WRF_ERR_FATAL_ALLOCATION_ERROR = -100 !allocation error - integer, parameter :: WRF_ERR_FATAL_DEALLOCATION_ERR = -101 !dealloc error - integer, parameter :: WRF_ERR_FATAL_BAD_FILE_STATUS = -102 !bad file status - - -!Package specific errors (1000+) -!Netcdf status codes -!WRF will accept status codes of 1000+, but it is up to the package to handle -! and return the status to the user. - - integer, parameter :: WRF_ERR_FATAL_BAD_VARIABLE_DIM = -1004 - integer, parameter :: WRF_ERR_FATAL_MDVAR_DIM_NOT_1D = -1005 - integer, parameter :: WRF_ERR_FATAL_TOO_MANY_TIMES = -1006 - integer, parameter :: WRF_WARN_BAD_DATA_TYPE = -1007 !this code not in either spec? - integer, parameter :: WRF_WARN_FILE_NOT_COMMITTED = -1008 !this code not in either spec? - integer, parameter :: WRF_WARN_FILE_OPEN_FOR_READ = -1009 - integer, parameter :: WRF_IO_NOT_INITIALIZED = -1010 - integer, parameter :: WRF_WARN_MD_AFTER_OPEN = -1011 - integer, parameter :: WRF_WARN_TOO_MANY_VARIABLES = -1012 - integer, parameter :: WRF_WARN_DRYRUN_CLOSE = -1013 - integer, parameter :: WRF_WARN_DATESTR_BAD_LENGTH = -1014 - integer, parameter :: WRF_WARN_ZERO_LENGTH_READ = -1015 - integer, parameter :: WRF_WARN_DATA_TYPE_NOT_FOUND = -1016 - integer, parameter :: WRF_WARN_DATESTR_ERROR = -1017 - integer, parameter :: WRF_WARN_DRYRUN_READ = -1018 - integer, parameter :: WRF_WARN_ZERO_LENGTH_GET = -1019 - integer, parameter :: WRF_WARN_ZERO_LENGTH_PUT = -1020 - integer, parameter :: WRF_WARN_NETCDF = -1021 - integer, parameter :: WRF_WARN_LENGTH_LESS_THAN_1 = -1022 - integer, parameter :: WRF_WARN_MORE_DATA_IN_FILE = -1023 - integer, parameter :: WRF_WARN_DATE_LT_LAST_DATE = -1024 - -! For HDF5 only - integer, parameter :: WRF_HDF5_ERR_FILE = -200 - integer, parameter :: WRF_HDF5_ERR_MD = -201 - integer, parameter :: WRF_HDF5_ERR_TIME = -202 - integer, parameter :: WRF_HDF5_ERR_TIME_EOF = -203 - integer, parameter :: WRF_HDF5_ERR_MORE_DATA_IN_FILE = -204 - integer, parameter :: WRF_HDF5_ERR_DATE_LT_LAST_DATE = -205 - integer, parameter :: WRF_HDF5_ERR_TOO_MANY_FILES = -206 - integer, parameter :: WRF_HDF5_ERR_TYPE_MISMATCH = -207 - integer, parameter :: WRF_HDF5_ERR_LENGTH_LESS_THAN_1 = -208 - integer, parameter :: WRF_HDF5_ERR_WRITE_RONLY_FILE = -209 - integer, parameter :: WRF_HDF5_ERR_READ_WONLY_FILE = -210 - integer, parameter :: WRF_HDF5_ERR_FILE_NOT_OPENED = -211 - integer, parameter :: WRF_HDF5_ERR_DATESTR_ERROR = -212 - integer, parameter :: WRF_HDF5_ERR_DRYRUN_READ = -213 - integer, parameter :: WRF_HDF5_ERR_ZERO_LENGTH_GET = -214 - integer, parameter :: WRF_HDF5_ERR_ZERO_LENGTH_PUT = -215 - integer, parameter :: WRF_HDF5_ERR_2DRYRUNS_1VARIABLE = -216 - integer, parameter :: WRF_HDF5_ERR_DATA_TYPE_NOTFOUND = -217 - integer, parameter :: WRF_HDF5_ERR_READ_PAST_EOF = -218 - integer, parameter :: WRF_HDF5_ERR_BAD_DATA_HANDLE = -219 - integer, parameter :: WRF_HDF5_ERR_WRTLEN_NE_DRRUNLEN = -220 - integer, parameter :: WRF_HDF5_ERR_DRYRUN_CLOSE = -221 - integer, parameter :: WRF_HDF5_ERR_DATESTR_BAD_LENGTH = -222 - integer, parameter :: WRF_HDF5_ERR_ZERO_LENGTH_READ = -223 - integer, parameter :: WRF_HDF5_ERR_TOO_MANY_DIMS = -224 - integer, parameter :: WRF_HDF5_ERR_TOO_MANY_VARIABLES = -225 - integer, parameter :: WRF_HDF5_ERR_COUNT_TOO_LONG = -226 - integer, parameter :: WRF_HDF5_ERR_DIMENSION_ERROR = -227 - integer, parameter :: WRF_HDF5_ERR_BAD_MEMORYORDER = -228 - integer, parameter :: WRF_HDF5_ERR_DIMNAME_REDEFINED = -229 - integer, parameter :: WRF_HDF5_ERR_MD_AFTER_OPEN = -230 - integer, parameter :: WRF_HDF5_ERR_CHARSTR_GT_LENDATA = -231 - integer, parameter :: WRF_HDF5_ERR_BAD_DATA_TYPE = -232 - integer, parameter :: WRF_HDF5_ERR_FILE_NOT_COMMITTED = -233 - - integer, parameter :: WRF_HDF5_ERR_ALLOCATION = -2001 - integer, parameter :: WRF_HDF5_ERR_DEALLOCATION = -2002 - integer, parameter :: WRF_HDF5_ERR_BAD_FILE_STATUS = -2003 - integer, parameter :: WRF_HDF5_ERR_BAD_VARIABLE_DIM = -2004 - integer, parameter :: WRF_HDF5_ERR_MDVAR_DIM_NOT_1D = -2005 - integer, parameter :: WRF_HDF5_ERR_TOO_MANY_TIMES = -2006 - integer, parameter :: WRF_HDF5_ERR_DATA_ID_NOTFOUND = -2007 - - integer, parameter :: WRF_HDF5_ERR_DATASPACE = -300 - integer, parameter :: WRF_HDF5_ERR_DATATYPE = -301 - integer, parameter :: WRF_HDF5_ERR_PROPERTY_LIST = -302 - - integer, parameter :: WRF_HDF5_ERR_DATASET_CREATE = -303 - integer, parameter :: WRF_HDF5_ERR_DATASET_READ = -304 - integer, parameter :: WRF_HDF5_ERR_DATASET_WRITE = -305 - integer, parameter :: WRF_HDF5_ERR_DATASET_OPEN = -306 - integer, parameter :: WRF_HDF5_ERR_DATASET_GENERAL = -307 - integer, parameter :: WRF_HDF5_ERR_GROUP = -308 - - integer, parameter :: WRF_HDF5_ERR_FILE_OPEN = -309 - integer, parameter :: WRF_HDF5_ERR_FILE_CREATE = -310 - integer, parameter :: WRF_HDF5_ERR_DATASET_CLOSE = -311 - integer, parameter :: WRF_HDF5_ERR_FILE_CLOSE = -312 - integer, parameter :: WRF_HDF5_ERR_CLOSE_GENERAL = -313 - - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_CREATE = -314 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_READ = -315 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_WRITE = -316 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_OPEN = -317 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_GENERAL = -318 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_CLOSE = -319 - - integer, parameter :: WRF_HDF5_ERR_OTHERS = -320 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_OTHERS = -321 - diff --git a/external/io_grib_share/wrf_io_flags.h b/external/io_grib_share/wrf_io_flags.h deleted file mode 100644 index 708939f914..0000000000 --- a/external/io_grib_share/wrf_io_flags.h +++ /dev/null @@ -1,16 +0,0 @@ - integer, parameter :: WRF_FILE_NOT_OPENED = 100 - integer, parameter :: WRF_FILE_OPENED_NOT_COMMITTED = 101 - integer, parameter :: WRF_FILE_OPENED_FOR_WRITE = 102 - integer, parameter :: WRF_FILE_OPENED_FOR_READ = 103 - integer, parameter :: WRF_REAL = 104 - integer, parameter :: WRF_DOUBLE = 105 -#ifdef PROMOTE_FLOAT - integer, parameter :: WRF_FLOAT=WRF_DOUBLE -#else - integer, parameter :: WRF_FLOAT=WRF_REAL -#endif - integer, parameter :: WRF_INTEGER = 106 - integer, parameter :: WRF_LOGICAL = 107 - integer, parameter :: WRF_COMPLEX = 108 - integer, parameter :: WRF_DOUBLE_COMPLEX = 109 - integer, parameter :: WRF_FILE_OPENED_FOR_UPDATE = 110 diff --git a/external/io_grib_share/wrf_status_codes.h b/external/io_grib_share/wrf_status_codes.h deleted file mode 100644 index 008ac5ce76..0000000000 --- a/external/io_grib_share/wrf_status_codes.h +++ /dev/null @@ -1,142 +0,0 @@ - -!WRF Error and Warning messages (1-999) -!All i/o package-specific status codes you may want to add must be handled by your package (see below) -! WRF handles these and netCDF messages only - integer, parameter :: WRF_NO_ERR = 0 !no error - integer, parameter :: WRF_WARN_FILE_NF = -1 !file not found, or incomplete - integer, parameter :: WRF_WARN_MD_NF = -2 !metadata not found - integer, parameter :: WRF_WARN_TIME_NF = -3 !timestamp not found - integer, parameter :: WRF_WARN_TIME_EOF = -4 !no more timestamps - integer, parameter :: WRF_WARN_VAR_NF = -5 !variable not found - integer, parameter :: WRF_WARN_VAR_EOF = -6 !no more variables for the current time - integer, parameter :: WRF_WARN_TOO_MANY_FILES = -7 !too many open files - integer, parameter :: WRF_WARN_TYPE_MISMATCH = -8 !data type mismatch - integer, parameter :: WRF_WARN_WRITE_RONLY_FILE = -9 !attempt to write readonly file - integer, parameter :: WRF_WARN_READ_WONLY_FILE = -10 !attempt to read writeonly file - integer, parameter :: WRF_WARN_FILE_NOT_OPENED = -11 !attempt to access unopened file - integer, parameter :: WRF_WARN_2DRYRUNS_1VARIABLE = -12 !attempt to do 2 trainings for 1 variable - integer, parameter :: WRF_WARN_READ_PAST_EOF = -13 !attempt to read past EOF - integer, parameter :: WRF_WARN_BAD_DATA_HANDLE = -14 !bad data handle - integer, parameter :: WRF_WARN_WRTLEN_NE_DRRUNLEN = -15 !write length not equal to training length - integer, parameter :: WRF_WARN_TOO_MANY_DIMS = -16 !more dimensions requested than training - integer, parameter :: WRF_WARN_COUNT_TOO_LONG = -17 !attempt to read more data than exists - integer, parameter :: WRF_WARN_DIMENSION_ERROR = -18 !input dimension inconsistent - integer, parameter :: WRF_WARN_BAD_MEMORYORDER = -19 !input MemoryOrder not recognized - integer, parameter :: WRF_WARN_DIMNAME_REDEFINED = -20 !a dimension name with 2 different lengths - integer, parameter :: WRF_WARN_CHARSTR_GT_LENDATA = -21 !string longer than provided storage - integer, parameter :: WRF_WARN_NOTSUPPORTED = -22 !function not supportable - integer, parameter :: WRF_WARN_NOOP = -23 !package implements this routine as NOOP - -!Fatal errors - integer, parameter :: WRF_ERR_FATAL_ALLOCATION_ERROR = -100 !allocation error - integer, parameter :: WRF_ERR_FATAL_DEALLOCATION_ERR = -101 !dealloc error - integer, parameter :: WRF_ERR_FATAL_BAD_FILE_STATUS = -102 !bad file status - - -!Package specific errors (1000+) -!Netcdf status codes -!WRF will accept status codes of 1000+, but it is up to the package to handle -! and return the status to the user. - - integer, parameter :: WRF_ERR_FATAL_BAD_VARIABLE_DIM = -1004 - integer, parameter :: WRF_ERR_FATAL_MDVAR_DIM_NOT_1D = -1005 - integer, parameter :: WRF_ERR_FATAL_TOO_MANY_TIMES = -1006 - integer, parameter :: WRF_WARN_BAD_DATA_TYPE = -1007 !this code not in either spec? - integer, parameter :: WRF_WARN_FILE_NOT_COMMITTED = -1008 !this code not in either spec? - integer, parameter :: WRF_WARN_FILE_OPEN_FOR_READ = -1009 - integer, parameter :: WRF_IO_NOT_INITIALIZED = -1010 - integer, parameter :: WRF_WARN_MD_AFTER_OPEN = -1011 - integer, parameter :: WRF_WARN_TOO_MANY_VARIABLES = -1012 - integer, parameter :: WRF_WARN_DRYRUN_CLOSE = -1013 - integer, parameter :: WRF_WARN_DATESTR_BAD_LENGTH = -1014 - integer, parameter :: WRF_WARN_ZERO_LENGTH_READ = -1015 - integer, parameter :: WRF_WARN_DATA_TYPE_NOT_FOUND = -1016 - integer, parameter :: WRF_WARN_DATESTR_ERROR = -1017 - integer, parameter :: WRF_WARN_DRYRUN_READ = -1018 - integer, parameter :: WRF_WARN_ZERO_LENGTH_GET = -1019 - integer, parameter :: WRF_WARN_ZERO_LENGTH_PUT = -1020 - integer, parameter :: WRF_WARN_NETCDF = -1021 - integer, parameter :: WRF_WARN_LENGTH_LESS_THAN_1 = -1022 - integer, parameter :: WRF_WARN_MORE_DATA_IN_FILE = -1023 - integer, parameter :: WRF_WARN_DATE_LT_LAST_DATE = -1024 - -! For HDF5 only - integer, parameter :: WRF_HDF5_ERR_FILE = -200 - integer, parameter :: WRF_HDF5_ERR_MD = -201 - integer, parameter :: WRF_HDF5_ERR_TIME = -202 - integer, parameter :: WRF_HDF5_ERR_TIME_EOF = -203 - integer, parameter :: WRF_HDF5_ERR_MORE_DATA_IN_FILE = -204 - integer, parameter :: WRF_HDF5_ERR_DATE_LT_LAST_DATE = -205 - integer, parameter :: WRF_HDF5_ERR_TOO_MANY_FILES = -206 - integer, parameter :: WRF_HDF5_ERR_TYPE_MISMATCH = -207 - integer, parameter :: WRF_HDF5_ERR_LENGTH_LESS_THAN_1 = -208 - integer, parameter :: WRF_HDF5_ERR_WRITE_RONLY_FILE = -209 - integer, parameter :: WRF_HDF5_ERR_READ_WONLY_FILE = -210 - integer, parameter :: WRF_HDF5_ERR_FILE_NOT_OPENED = -211 - integer, parameter :: WRF_HDF5_ERR_DATESTR_ERROR = -212 - integer, parameter :: WRF_HDF5_ERR_DRYRUN_READ = -213 - integer, parameter :: WRF_HDF5_ERR_ZERO_LENGTH_GET = -214 - integer, parameter :: WRF_HDF5_ERR_ZERO_LENGTH_PUT = -215 - integer, parameter :: WRF_HDF5_ERR_2DRYRUNS_1VARIABLE = -216 - integer, parameter :: WRF_HDF5_ERR_DATA_TYPE_NOTFOUND = -217 - integer, parameter :: WRF_HDF5_ERR_READ_PAST_EOF = -218 - integer, parameter :: WRF_HDF5_ERR_BAD_DATA_HANDLE = -219 - integer, parameter :: WRF_HDF5_ERR_WRTLEN_NE_DRRUNLEN = -220 - integer, parameter :: WRF_HDF5_ERR_DRYRUN_CLOSE = -221 - integer, parameter :: WRF_HDF5_ERR_DATESTR_BAD_LENGTH = -222 - integer, parameter :: WRF_HDF5_ERR_ZERO_LENGTH_READ = -223 - integer, parameter :: WRF_HDF5_ERR_TOO_MANY_DIMS = -224 - integer, parameter :: WRF_HDF5_ERR_TOO_MANY_VARIABLES = -225 - integer, parameter :: WRF_HDF5_ERR_COUNT_TOO_LONG = -226 - integer, parameter :: WRF_HDF5_ERR_DIMENSION_ERROR = -227 - integer, parameter :: WRF_HDF5_ERR_BAD_MEMORYORDER = -228 - integer, parameter :: WRF_HDF5_ERR_DIMNAME_REDEFINED = -229 - integer, parameter :: WRF_HDF5_ERR_MD_AFTER_OPEN = -230 - integer, parameter :: WRF_HDF5_ERR_CHARSTR_GT_LENDATA = -231 - integer, parameter :: WRF_HDF5_ERR_BAD_DATA_TYPE = -232 - integer, parameter :: WRF_HDF5_ERR_FILE_NOT_COMMITTED = -233 - - integer, parameter :: WRF_HDF5_ERR_ALLOCATION = -2001 - integer, parameter :: WRF_HDF5_ERR_DEALLOCATION = -2002 - integer, parameter :: WRF_HDF5_ERR_BAD_FILE_STATUS = -2003 - integer, parameter :: WRF_HDF5_ERR_BAD_VARIABLE_DIM = -2004 - integer, parameter :: WRF_HDF5_ERR_MDVAR_DIM_NOT_1D = -2005 - integer, parameter :: WRF_HDF5_ERR_TOO_MANY_TIMES = -2006 - integer, parameter :: WRF_HDF5_ERR_DATA_ID_NOTFOUND = -2007 - - integer, parameter :: WRF_HDF5_ERR_DATASPACE = -300 - integer, parameter :: WRF_HDF5_ERR_DATATYPE = -301 - integer, parameter :: WRF_HDF5_ERR_PROPERTY_LIST = -302 - - integer, parameter :: WRF_HDF5_ERR_DATASET_CREATE = -303 - integer, parameter :: WRF_HDF5_ERR_DATASET_READ = -304 - integer, parameter :: WRF_HDF5_ERR_DATASET_WRITE = -305 - integer, parameter :: WRF_HDF5_ERR_DATASET_OPEN = -306 - integer, parameter :: WRF_HDF5_ERR_DATASET_GENERAL = -307 - integer, parameter :: WRF_HDF5_ERR_GROUP = -308 - - integer, parameter :: WRF_HDF5_ERR_FILE_OPEN = -309 - integer, parameter :: WRF_HDF5_ERR_FILE_CREATE = -310 - integer, parameter :: WRF_HDF5_ERR_DATASET_CLOSE = -311 - integer, parameter :: WRF_HDF5_ERR_FILE_CLOSE = -312 - integer, parameter :: WRF_HDF5_ERR_CLOSE_GENERAL = -313 - - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_CREATE = -314 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_READ = -315 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_WRITE = -316 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_OPEN = -317 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_GENERAL = -318 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_CLOSE = -319 - - integer, parameter :: WRF_HDF5_ERR_OTHERS = -320 - integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_OTHERS = -321 - - integer, parameter :: WRF_GRIB2_ERR_GRIBCREATE = -401 - integer, parameter :: WRF_GRIB2_ERR_ADDLOCAL = -402 - integer, parameter :: WRF_GRIB2_ERR_ADDGRIB = -403 - integer, parameter :: WRF_GRIB2_ERR_ADDFIELD = -404 - integer, parameter :: WRF_GRIB2_ERR_GRIBEND = -405 - integer, parameter :: WRF_GRIB2_ERR_WRITE = -406 - integer, parameter :: WRF_GRIB2_ERR_GRIB2MAP = -407 - integer, parameter :: WRF_GRIB2_ERR_GETGB2 = -408 - integer, parameter :: WRF_GRIB2_ERR_READ = -409 From 051e2290dcd0a8a2872c0328b7e2a6006cb94c7d Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 17 May 2023 16:55:53 -0600 Subject: [PATCH 108/180] Reworking external/ build --- external/io_netcdf/wrf_io.F90 | 4 ++-- external/io_netcdfpar/wrf_io.F90 | 4 ++-- external/ioapi_share/wrf_status_codes.h | 9 +++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/external/io_netcdf/wrf_io.F90 b/external/io_netcdf/wrf_io.F90 index ec2162d2d5..e29c8b4271 100644 --- a/external/io_netcdf/wrf_io.F90 +++ b/external/io_netcdf/wrf_io.F90 @@ -755,7 +755,7 @@ subroutine Transpose(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) -!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') @@ -941,7 +941,7 @@ subroutine TransposeToR4(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) -!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') diff --git a/external/io_netcdfpar/wrf_io.F90 b/external/io_netcdfpar/wrf_io.F90 index a76ec5d82d..60b6dff094 100644 --- a/external/io_netcdfpar/wrf_io.F90 +++ b/external/io_netcdfpar/wrf_io.F90 @@ -768,7 +768,7 @@ subroutine Transpose(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) -!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') @@ -954,7 +954,7 @@ subroutine TransposeToR4a(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) -!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') diff --git a/external/ioapi_share/wrf_status_codes.h b/external/ioapi_share/wrf_status_codes.h index 98484da413..8dfb44b53e 100644 --- a/external/ioapi_share/wrf_status_codes.h +++ b/external/ioapi_share/wrf_status_codes.h @@ -132,3 +132,12 @@ integer, parameter :: WRF_HDF5_ERR_OTHERS = -320 integer, parameter :: WRF_HDF5_ERR_ATTRIBUTE_OTHERS = -321 + integer, parameter :: WRF_GRIB2_ERR_GRIBCREATE = -401 + integer, parameter :: WRF_GRIB2_ERR_ADDLOCAL = -402 + integer, parameter :: WRF_GRIB2_ERR_ADDGRIB = -403 + integer, parameter :: WRF_GRIB2_ERR_ADDFIELD = -404 + integer, parameter :: WRF_GRIB2_ERR_GRIBEND = -405 + integer, parameter :: WRF_GRIB2_ERR_WRITE = -406 + integer, parameter :: WRF_GRIB2_ERR_GRIB2MAP = -407 + integer, parameter :: WRF_GRIB2_ERR_GETGB2 = -408 + integer, parameter :: WRF_GRIB2_ERR_READ = -409 From 96c9353c13615fda0c6db6d317ca2fe579e80dc3 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 23 May 2023 12:45:51 -0600 Subject: [PATCH 109/180] Adding runtime generated files to ignore list --- .gitignore | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c47fe3e850..26a74951f6 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,17 @@ configure.wrf* *.backup *.f90 -_build/ \ No newline at end of file +_build/ +# New (and old) things we should ignore +wrf_config.cmake +*.nc +rsl.out.* +rsl.error.* +ndown +real +tc +ideal +wrf +wrfbdy_d* +wrfinput_d* +wrfout_d* \ No newline at end of file From 553945592ec3197bfcd986556f815b77e14afa61 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 23 May 2023 12:51:25 -0600 Subject: [PATCH 110/180] Building pnetcdf io lib and re-enabling macro --- external/io_pnetcdf/wrf_io.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/io_pnetcdf/wrf_io.F90 b/external/io_pnetcdf/wrf_io.F90 index 18f6ac078a..f6e382d93b 100644 --- a/external/io_pnetcdf/wrf_io.F90 +++ b/external/io_pnetcdf/wrf_io.F90 @@ -741,7 +741,7 @@ subroutine Transpose(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) -!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') From 7ff2f7e4136fd159c7ee8d7f882f5a80b8f0ff01 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 23 Jun 2023 20:08:21 -0600 Subject: [PATCH 111/180] Reinstating old c preproc then m4 processing since gfortran is unable to --- external/io_adios2/wrf_io.F90 | 6 +++--- external/io_netcdf/wrf_io.F90 | 8 ++++---- external/io_netcdfpar/wrf_io.F90 | 8 ++++---- external/io_pnetcdf/wrf_io.F90 | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/external/io_adios2/wrf_io.F90 b/external/io_adios2/wrf_io.F90 index 99e9bfe2e0..b9bfe696d8 100644 --- a/external/io_adios2/wrf_io.F90 +++ b/external/io_adios2/wrf_io.F90 @@ -702,9 +702,9 @@ subroutine Transpose(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) - - !#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) - ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) +! Cannot use following define due to gfortran cpp traditional mode concatenation limitations +!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') #undef DFIELD #define DFIELD XField(1:di,XDEX(i,k,j)) diff --git a/external/io_netcdf/wrf_io.F90 b/external/io_netcdf/wrf_io.F90 index e29c8b4271..8863e4e29f 100644 --- a/external/io_netcdf/wrf_io.F90 +++ b/external/io_netcdf/wrf_io.F90 @@ -754,8 +754,8 @@ subroutine Transpose(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) - -#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +! Cannot use following define due to gfortran cpp traditional mode concatenation limitations +!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') @@ -940,8 +940,8 @@ subroutine TransposeToR4(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) - -#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +! Cannot use following define due to gfortran cpp traditional mode concatenation limitations +!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') diff --git a/external/io_netcdfpar/wrf_io.F90 b/external/io_netcdfpar/wrf_io.F90 index 60b6dff094..86e25dd2cb 100644 --- a/external/io_netcdfpar/wrf_io.F90 +++ b/external/io_netcdfpar/wrf_io.F90 @@ -767,8 +767,8 @@ subroutine Transpose(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) - -#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +! Cannot use following define due to gfortran cpp traditional mode concatenation limitations +!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') @@ -953,8 +953,8 @@ subroutine TransposeToR4a(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) - -#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +! Cannot use following define due to gfortran cpp traditional mode concatenation limitations +!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') diff --git a/external/io_pnetcdf/wrf_io.F90 b/external/io_pnetcdf/wrf_io.F90 index f6e382d93b..9d9c3733b4 100644 --- a/external/io_pnetcdf/wrf_io.F90 +++ b/external/io_pnetcdf/wrf_io.F90 @@ -740,8 +740,8 @@ subroutine Transpose(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 & call LowerCase(MemoryOrder,MemOrd) select case (MemOrd) - -#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) +! Cannot use following define due to gfortran cpp traditional mode concatenation limitations +!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1)) ! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1)))) case ('xzy') From 03966695b394c7858d205ed4c3bfa866464110d2 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 5 Jul 2023 18:24:30 -0600 Subject: [PATCH 112/180] Adjusting include paths for removal of redundant code --- external/io_grib1/Makefile | 2 +- external/io_grib_share/Makefile | 6 +++--- external/io_int/makefile | 5 +---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/external/io_grib1/Makefile b/external/io_grib1/Makefile index 6afcf4d760..a222b2dbfe 100644 --- a/external/io_grib1/Makefile +++ b/external/io_grib1/Makefile @@ -10,7 +10,7 @@ # # Specity location for Makefiles that are included. # -INCLUDEDIRS = -I. -I./MEL_grib1 -Igrib1_util -I../io_grib_share -I../ +INCLUDEDIRS = -I. -I./MEL_grib1 -Igrib1_util -I../io_grib_share -I../ -I../ioapi_share BUILD_DIR = $(IO_GRIB_SHARE_DIR)../io_grib_share/build # # Specify directory that output library is to be put in. diff --git a/external/io_grib_share/Makefile b/external/io_grib_share/Makefile index 41d3c96659..5e3a59db55 100644 --- a/external/io_grib_share/Makefile +++ b/external/io_grib_share/Makefile @@ -22,9 +22,9 @@ LIB_DEST = . # CXX_INCLUDES is for C++ files # C_INCLUDES is for C files # -C_INCLUDES = -I. -CXX_INCLUDES = -I. -F_INCLUDES = -I. +C_INCLUDES = -I. -I../ioapi_share +CXX_INCLUDES = -I. -I../ioapi_share +F_INCLUDES = -I. -I../ioapi_share AR = ar ARFLAGS = cruv diff --git a/external/io_int/makefile b/external/io_int/makefile index 3033670e32..7bc484968e 100644 --- a/external/io_int/makefile +++ b/external/io_int/makefile @@ -32,11 +32,8 @@ io_int.f: io_int.F90 module_internal_header_util.o io_int.o: io_int.f ../../inc/intio_tags.h $(FC) $(FCFLAGS) -I../../inc -I../ioapi_share -o $@ -c $*.f -io_int_idx_tags.h: ../../inc/intio_tags.h - awk '{print "#define", toupper($$4), $$6}' < ../../inc/intio_tags.h > $@ - io_int_idx.o: io_int_idx.c io_int_idx.h io_int_idx_tags.h - $(CC) -o $@ -c $(CFLAGS_LOCAL) $*.c + $(CC) -I../../inc -o $@ -c $(CFLAGS_LOCAL) $*.c module_io_int_idx.o: module_io_int_idx.f $(FC) $(FCFLAGS) -o $@ -c $*.f From 9a7618678e39896c22b7b3ea506cc69bd4646ba3 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 12 Jul 2023 16:06:53 -0600 Subject: [PATCH 113/180] Logic and fixes to allow for double precision compilation --- phys/module_mp_SBM_polar_radar.F | 5 +++++ phys/module_mp_fast_sbm.F | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/phys/module_mp_SBM_polar_radar.F b/phys/module_mp_SBM_polar_radar.F index 4f94129271..a6ba4e4cc1 100644 --- a/phys/module_mp_SBM_polar_radar.F +++ b/phys/module_mp_SBM_polar_radar.F @@ -6,6 +6,11 @@ SUBROUTINE SBM_polar_radar dummy = 1 END SUBROUTINE SBM_polar_radar END MODULE module_mp_SBM_polar_radar + +! Stub module +module scatt_tables +end module scatt_tables + #else !****************** module scatt_tables diff --git a/phys/module_mp_fast_sbm.F b/phys/module_mp_fast_sbm.F index 184a9220ea..757f05db8c 100644 --- a/phys/module_mp_fast_sbm.F +++ b/phys/module_mp_fast_sbm.F @@ -6,6 +6,20 @@ SUBROUTINE SBM_fast dummy = 1 END SUBROUTINE SBM_fast END MODULE module_mp_fast_sbm + +! Stub modules +module module_mp_SBM_BreakUp +end module module_mp_SBM_BreakUp + +module module_mp_SBM_Collision +end module module_mp_SBM_Collision + +module module_mp_SBM_Auxiliary +end module module_mp_SBM_Auxiliary + +module module_mp_SBM_Nucleation +end module module_mp_SBM_Nucleation + #else ! +-----------------------------------------------------------------------------+ ! +-----------------------------------------------------------------------------+ From 5eaa938f5155feb2e2c55e5f4834370441053746 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 17 Jul 2023 15:44:09 -0600 Subject: [PATCH 114/180] Remove all references to idx tags autogen file --- external/io_int/makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/external/io_int/makefile b/external/io_int/makefile index 7bc484968e..e52b7c7bef 100644 --- a/external/io_int/makefile +++ b/external/io_int/makefile @@ -32,7 +32,7 @@ io_int.f: io_int.F90 module_internal_header_util.o io_int.o: io_int.f ../../inc/intio_tags.h $(FC) $(FCFLAGS) -I../../inc -I../ioapi_share -o $@ -c $*.f -io_int_idx.o: io_int_idx.c io_int_idx.h io_int_idx_tags.h +io_int_idx.o: io_int_idx.c io_int_idx.h $(CC) -I../../inc -o $@ -c $(CFLAGS_LOCAL) $*.c module_io_int_idx.o: module_io_int_idx.f @@ -88,5 +88,5 @@ test_io_mpi: test_io_mpi.f90 $(LIB) $(FC) $(FCFLAGS) $(LDFLAGS) -o $@ $@.f90 -L. -lwrfio_int superclean: - @$(RM) *.f *.o *.obj *.i *.mod $(LIB) diffwrf io_int_idx_tags.h \ - test_io_idx test_io_mpi io_int_idx_tags.h + @$(RM) *.f *.o *.obj *.i *.mod $(LIB) diffwrf \ + test_io_idx test_io_mpi From d102f6de85f98c045da0492b5ad92b40e20e4dcd Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 19 Jul 2023 13:37:29 -0600 Subject: [PATCH 115/180] Removing dimspec check since some configurations fail silently --- tools/registry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/registry.c b/tools/registry.c index 937cef5a18..97759b0942 100644 --- a/tools/registry.c +++ b/tools/registry.c @@ -237,7 +237,7 @@ main( int argc, char *argv[], char *env[] ) fclose(fp_tmp) ; - NON_ZERO_RETURN( check_dimspecs() ); + check_dimspecs(); NON_ZERO_RETURN( gen_state_struct( "inc" ) ); NON_ZERO_RETURN( gen_state_subtypes( "inc" ) ); From 5c5a106dc0ce37cedeea4a0c0285477d4407afb1 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 28 Jul 2023 13:52:02 -0600 Subject: [PATCH 116/180] Better logic for presenting configurations --- arch/configure_reader.py | 160 +++++++++++++++++++++---------- cmake/template/arch_config.cmake | 4 +- 2 files changed, 110 insertions(+), 54 deletions(-) diff --git a/arch/configure_reader.py b/arch/configure_reader.py index 376f450b34..a9995c2c0d 100755 --- a/arch/configure_reader.py +++ b/arch/configure_reader.py @@ -4,6 +4,7 @@ import re import inspect import platform +from shutil import which archBlock = re.compile( r"(?:#[ ]*)(ARCH(?:.*\n)*?)(?:#{5,})", re.I ) kvPair = re.compile( r"^(\w+)(?:[ \t]*=[ \t]*)(.*?)$", re.I | re.M ) @@ -13,7 +14,7 @@ # Just grab the first two words, thats what you get osAndArchAlt = re.compile( r"^ARCH[ ]+(\w+)[ ]+(\w+)", re.I ) -referenceVar = re.compile( r"[$][(](\w+)[)]", re.I ) +referenceVar = re.compile( r"[$]([(])?(\w+)(?(1)[)])", re.I ) class Stanza(): @@ -22,6 +23,12 @@ def __init__( self, lines ) : self.os_ = None self.archs_ = [] self.kvPairs_ = {} + self.crossPlatform_ = False + self.skipCrossPlatform_ = True + self.serialOpt_ = False + self.smparOpt_ = False + self.dmparOpt_ = False + self.dmsmOpt_ = False def parse( self ) : # First get os & archs @@ -34,25 +41,41 @@ def parse( self ) : self.os_ = osarchMatch.group(1) self.archs_ = osarchMatch.group(2).strip(",").split( " " ) + + if ( self.os_.lower() != platform.system().lower() or + platform.machine() not in self.archs_ ) : + self.crossPlatform_ = True - for kvPairMatch in kvPair.finditer( self.lines_ ) : - self.kvPairs_[ kvPairMatch.group(1) ] = kvPairMatch.group(2) - self.removeComments( kvPairMatch.group(1) ) - - # Now sanitize - self.sanitize() + if not self.skipCrossPlatform_ or ( self.skipCrossPlatform_ and not self.crossPlatform_ ) : + + # Find OpenMP/MPI compilation options + memOpts = self.lines_.partition("\n")[0].partition( "#" )[-1].split( " " ) + # print( memOpts ) + self.serialOpt_ = "serial" in memOpts + self.smparOpt_ = "smpar" in memOpts + self.dmparOpt_ = "dmpar" in memOpts + self.dmsmOpt_ = "dm+sm" in memOpts + + for kvPairMatch in kvPair.finditer( self.lines_ ) : + self.kvPairs_[ kvPairMatch.group(1) ] = kvPairMatch.group(2) + self.removeComments( kvPairMatch.group(1) ) + + # Now sanitize + self.sanitize() def dereference( self, field, fatal=False ) : + # print( "Dereferencing " + field ) if field in self.kvPairs_ : prevField = self.kvPairs_[field] for refVarIter in referenceVar.finditer( prevField ) : if refVarIter is not None : # Grab group 1 and check that it is in our kv pairs - refVar = refVarIter.group(1) + refVar = refVarIter.group(2) + # print( "Found variable {0} in field {1}".format( refVar, field ) ) if refVar not in self.kvPairs_ : if fatal : - print( "Could not rereference : " + refVar ) + # print( "Could not rereference : " + refVar ) exit(1) else: continue @@ -62,7 +85,7 @@ def dereference( self, field, fatal=False ) : # Replace in original self.kvPairs_[field] = self.kvPairs_[field].replace( - "$({var})".format( var=refVar ), + "{var}".format( var=refVarIter.group(0) ), self.kvPairs_[refVar] ) @@ -102,6 +125,8 @@ def sanitize( self ) : self.dereference( "FCBASEOPTS" ) # Now fix certain ones that are mixing programs with flags all mashed into one option + self.splitIntoFieldAndFlags( "SFC" ) + self.splitIntoFieldAndFlags( "SCC" ) self.splitIntoFieldAndFlags( "DM_FC" ) self.splitIntoFieldAndFlags( "DM_CC" ) self.splitIntoFieldAndFlags( "M4" ) @@ -134,6 +159,12 @@ def sanitize( self ) : self.dereference( key ) # And for final measure strip self.kvPairs_[ key ] = self.kvPairs_[ key ].strip() + + def serialCompilersAvailable( self ) : + return which( self.kvPairs_["SFC"] ) is not None and which( self.kvPairs_["SCC"] ) is not None + + def dmCompilersAvailable( self ) : + return which( self.kvPairs_["DM_FC"] ) is not None and which( self.kvPairs_["DM_CC"] ) is not None def __str__( self ): # base = """OS {os:<8} ARCHITECTURES {archs:<20} @@ -143,16 +174,18 @@ def __str__( self ): # >> DM_FC = {DM_FC:<12} # >> DM_CC = {DM_CC:<12} # """ - base = """{rec} {os:<10} {SFC:<11} / {SCC:<11} / {CCOMP:<11} / {DM_FC:<11} / {DM_CC:<11}""" + base = """ {os:<10} {recSFC} {SFC:<11} / {recSCC} {SCC:<11} / {recDM_FC} {DM_FC:<11} / {recDM_CC} {DM_CC:<11}""" text = inspect.cleandoc( base ).format( os=str(self.os_), - rec=( "!!" if platform.system().lower() != self.os_.lower() else "Ok" ), + recSFC =( "!!" if which( self.kvPairs_["SFC"] ) is None else (" " * 2 ) ), + recSCC =( "!!" if which( self.kvPairs_["SCC"] ) is None else (" " * 2 ) ), + recDM_FC=( "!!" if which( self.kvPairs_["DM_FC"] ) is None else (" " * 2 ) ), + recDM_CC=( "!!" if which( self.kvPairs_["DM_CC"] ) is None else (" " * 2 ) ), # archs=str(self.archs_), - SFC=str( self.kvPairs_["SFC"].partition(" ")[0] ), - SCC=str( self.kvPairs_["SCC"].partition(" ")[0] ), - CCOMP=str( self.kvPairs_["CCOMP"].partition(" ")[0] ), - DM_FC=str( self.kvPairs_["DM_FC"].partition(" ")[0] ), - DM_CC=str( self.kvPairs_["DM_CC"].partition(" ")[0] ) + SFC=str( self.kvPairs_["SFC"] ), + SCC=str( self.kvPairs_["SCC"] ), + DM_FC=str( self.kvPairs_["DM_FC"] ), + DM_CC=str( self.kvPairs_["DM_CC"] ) ) # text += "\n" + "\n".join( [ "{key:<18} = {value}".format( key=key, value=value) for key, value in self.kvPairs_.items() ] ) return text @@ -279,7 +312,9 @@ def generateCMakeToolChainFile( cmakeToolChainTemplate, output, stanza, optionsD FCOPTIM=stanza.kvPairs_["FCOPTIM"], M4_FLAGS=stanza.kvPairs_["M4_FLAGS"], SCC=stanza.kvPairs_["SCC"], - SFC=stanza.kvPairs_["SFC"] + SFC=stanza.kvPairs_["SFC"], + SCC_FLAGS=stanza.kvPairs_["SCC_FLAGS"], + SFC_FLAGS=stanza.kvPairs_["SFC_FLAGS"] ) # Extra stufff not from stanza but options @@ -296,25 +331,6 @@ def main() : cmakeConfigFile = sys.argv[3] cmakeFile = sys.argv[4] - coreOption = getStringOptionSelection( cmakeFile, "WRF_CORE_OPTIONS" ) - nestingOption = getStringOptionSelection( cmakeFile, "WRF_NESTING_OPTIONS" ) - caseOption = getStringOptionSelection( cmakeFile, "WRF_CASE_OPTIONS" ) - - # These are yes - yesValues = [ "yes", "y", "true", "1" ] - - #!TODO Expand this for all wrf options - useMPI = input( "[DM] Use MPI? [Y/n] : " ).lower() in yesValues - useOpenMP = input( "[SM] Use OpenMP? [Y/n] : " ).lower() in yesValues - - alreadyAsked = [ "USE_MPI", "USE_OPENMP" ] - - doSuboptionMenu = input( "Configure additional options? [Y/n] : " ).lower() in yesValues - subOptions = {} - if doSuboptionMenu : - subOptions = getSubOptions( cmakeFile, alreadyAsked ) - - fp = open( configFile, 'r' ) lines = fp.read() fp.close() @@ -327,27 +343,67 @@ def main() : stanza = Stanza( stanzaBlock.group(1) ) stanza.parse() - stanzas.append( stanza ) - stanzaConfig = str( stanza ) - stanzaId = "{idx:<3} ".format( idx=stanzaIdx ) - if stanzaConfig not in uniqueConfigs : - uniqueConfigs[ stanzaConfig ] = { "stanza" : stanza, "idx" : stanzaIdx } - print( stanzaId + stanzaConfig + "[first entry]" ) - else : - diff, value = Stanza.findFirstDifference( uniqueConfigs[ stanzaConfig ]["stanza"], stanza ) - if diff : - print( stanzaId + stanzaConfig + "@{idx} diff => {value}".format( idx=uniqueConfigs[ stanzaConfig ][ "idx" ], value=value ) ) - else : - print( stanzaId + stanzaConfig + "[no difference]" ) - stanzaIdx += 1 + if not stanza.crossPlatform_ and stanza.serialCompilersAvailable() and ( stanza.dmCompilersAvailable() or ( stanza.serialOpt_ or stanza.smparOpt_ ) ) : + stanzas.append( stanza ) + stanzaConfig = str( stanza ) + stanzaId = "{idx:<3} ".format( idx=stanzaIdx ) + if stanzaConfig not in uniqueConfigs : + uniqueConfigs[ stanzaConfig ] = { "stanza" : stanza, "idx" : stanzaIdx } + + print( stanzaId + stanzaConfig + stanza.kvPairs_[ "DESCRIPTION" ] ) + # else : + # diff, value = Stanza.findFirstDifference( uniqueConfigs[ stanzaConfig ]["stanza"], stanza ) + # if diff : + # print( stanzaId + stanzaConfig + "@{idx} diff => {value}".format( idx=uniqueConfigs[ stanzaConfig ][ "idx" ], value=value ) ) + # else : + # print( stanzaId + stanzaConfig + "[no difference]" ) + stanzaIdx += 1 - print( "!! - Not recommended for your system" ) + print( "!! - Compiler not found, some configurations will not work and will be hidden" ) idxSelection = int( input( "Select configuration [0-{stop}] (note !!) : ".format( stop=( stanzaIdx-1) ) ) ) if idxSelection < 0 or idxSelection > stanzaIdx - 1 : print( "Invalid configuration selection!" ) exit(1) + stanzaCfg = stanzas[idxSelection] + coreOption = getStringOptionSelection( cmakeFile, "WRF_CORE_OPTIONS" ) + nestingOption = getStringOptionSelection( cmakeFile, "WRF_NESTING_OPTIONS" ) + caseOption = getStringOptionSelection( cmakeFile, "WRF_CASE_OPTIONS" ) + + # These are yes + yesValues = [ "yes", "y", "true", "1" ] + + ############################################################################## + # Decompose the weird way to write the logic for DM/SM + USE_MPI = False + if ( stanzaCfg.serialOpt_ or stanzaCfg.smparOpt_ ) and ( stanzaCfg.dmparOpt_ or stanzaCfg.dmsmOpt_ ) : + # togglable + # we can safely check this since the user would not have been able to select this stanza if it couldn't be disabled + if stanzaCfg.dmCompilersAvailable() : + useMPI = input( "[DM] Use MPI? [Y/n] : " ).lower() in yesValues + else : + useMPI = False + else: + # User has no choice in the matter + useMPI = ( stanzaCfg.dmparOpt_ or stanzaCfg.dmsmOpt_ ) + + useOpenMP = False + if ( stanzaCfg.serialOpt_ or stanzaCfg.dmparOpt_ ) and ( stanzaCfg.smparOpt_ or stanzaCfg.dmsmOpt_ ): + # togglable + useOpenMP = input( "[SM] Use OpenMP? [Y/n] : " ).lower() in yesValues + else: + # User has no choice in the matter + useOpenMP = ( stanzaCfg.smparOpt_ or stanzaCfg.dmsmOpt_ ) + + ############################################################################## + + alreadyAsked = [ "USE_MPI", "USE_OPENMP" ] + doSuboptionMenu = input( "Configure additional options? [Y/n] : " ).lower() in yesValues + subOptions = {} + if doSuboptionMenu : + subOptions = getSubOptions( cmakeFile, alreadyAsked ) + additionalOptions = { "WRF_CORE" : coreOption, "WRF_NESTING" : nestingOption, @@ -356,7 +412,7 @@ def main() : "USE_OPENMP" : "ON" if useOpenMP else "OFF", } additionalOptions.update( subOptions ) - generateCMakeToolChainFile( cmakeTemplateFile, cmakeConfigFile, stanzas[idxSelection], additionalOptions ) + generateCMakeToolChainFile( cmakeTemplateFile, cmakeConfigFile, stanzaCfg, additionalOptions ) diff --git a/cmake/template/arch_config.cmake b/cmake/template/arch_config.cmake index c22b45a869..6977379aa2 100644 --- a/cmake/template/arch_config.cmake +++ b/cmake/template/arch_config.cmake @@ -5,8 +5,8 @@ set( MPI_C_COMPILER "{DM_CC}" ) set( CMAKE_Fortran_COMPILER "{SFC}" ) set( CMAKE_C_COMPILER "{SCC}" ) -set( CMAKE_Fortran_FLAGS_INIT "{FCBASEOPTS} {BYTESWAPIO}" ) -set( CMAKE_C_FLAGS_INIT "{CFLAGS_LOCAL}" ) +set( CMAKE_Fortran_FLAGS_INIT "{SFC_FLAGS} {FCBASEOPTS} {BYTESWAPIO}" ) +set( CMAKE_C_FLAGS_INIT "{SCC_FLAGS} {CFLAGS_LOCAL}" ) set( CMAKE_Fortran_FLAGS_DEBUG_INIT "{FCDEBUG}" ) set( CMAKE_Fortran_FLAGS_RELEASE_INIT "{FCOPTIM}" ) From e44fab2e90a18d1b14b388af19bbbbe5ca4861c6 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 31 Jul 2023 14:34:29 -0600 Subject: [PATCH 117/180] Making sure to cd back --- cleanCMake.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cleanCMake.sh b/cleanCMake.sh index 52d21eab46..c42fbfc22d 100755 --- a/cleanCMake.sh +++ b/cleanCMake.sh @@ -51,7 +51,7 @@ fi if [[ "${CLEAN_BASIC_BUILD}" == "TRUE" || "${CLEAN_ALL}" == "TRUE" ]]; then echo "Doing cmake make clean" OLD_DIR=$PWD - cd ${BUILD_DIR} && make -j 1 clean && cd $OLD_DIR + cd ${BUILD_DIR} && make -j 1 clean; cd $OLD_DIR fi if [[ "${CLEAN_BASIC_INSTALL}" == "TRUE" || "${CLEAN_ALL}" == "TRUE" ]]; then From 547bac12f3652ec3352c5b8bc05b0fdd8e5e3842 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 31 Jul 2023 14:35:48 -0600 Subject: [PATCH 118/180] Aligning with WPS configure_reader.py --- arch/configure_reader.py | 109 ++++++++++++++++++++++++++++++++------- 1 file changed, 90 insertions(+), 19 deletions(-) diff --git a/arch/configure_reader.py b/arch/configure_reader.py index a9995c2c0d..a65eaea958 100755 --- a/arch/configure_reader.py +++ b/arch/configure_reader.py @@ -15,12 +15,15 @@ osAndArchAlt = re.compile( r"^ARCH[ ]+(\w+)[ ]+(\w+)", re.I ) referenceVar = re.compile( r"[$]([(])?(\w+)(?(1)[)])", re.I ) +compileObject = re.compile( r"(\W)-c(\W)" ) class Stanza(): def __init__( self, lines ) : self.lines_ = lines self.os_ = None + self.arch_ = None + self.osArchLine_ = None self.archs_ = [] self.kvPairs_ = {} self.crossPlatform_ = False @@ -31,13 +34,14 @@ def __init__( self, lines ) : self.dmsmOpt_ = False def parse( self ) : + self.osArchLine_ = self.lines_.partition("\n")[0] # First get os & archs - osarchMatch = osAndArch.match( self.lines_ ) + osarchMatch = osAndArch.match( self.osArchLine_ ) if osarchMatch is None : - osarchMatch = osAndArchAlt.match( self.lines_ ) + osarchMatch = osAndArchAlt.match( self.osArchLine_ ) if osarchMatch is None : - print( "Could not find OS and architecture info in " + self.lines_.partition("\n")[0] ) + print( "Could not find OS and architecture info in " + self.osArchLine_ ) self.os_ = osarchMatch.group(1) self.archs_ = osarchMatch.group(2).strip(",").split( " " ) @@ -45,11 +49,12 @@ def parse( self ) : if ( self.os_.lower() != platform.system().lower() or platform.machine() not in self.archs_ ) : self.crossPlatform_ = True - + + # Allow cross platform or must not be cross platform if not self.skipCrossPlatform_ or ( self.skipCrossPlatform_ and not self.crossPlatform_ ) : # Find OpenMP/MPI compilation options - memOpts = self.lines_.partition("\n")[0].partition( "#" )[-1].split( " " ) + memOpts = self.osArchLine_.partition( "#" )[-1].split( " " ) # print( memOpts ) self.serialOpt_ = "serial" in memOpts self.smparOpt_ = "smpar" in memOpts @@ -63,6 +68,11 @@ def parse( self ) : # Now sanitize self.sanitize() + ###################################################################################################################### + ## + ## search and replace $() and $ instances + ## + ###################################################################################################################### def dereference( self, field, fatal=False ) : # print( "Dereferencing " + field ) if field in self.kvPairs_ : @@ -113,6 +123,11 @@ def splitIntoFieldAndFlags( self, field ) : self.kvPairs_[field] = fieldValue.partition(" ")[0] self.kvPairs_[field + "_FLAGS"] = fieldValue.partition(" ")[1] + ###################################################################################################################### + ## + ## Clean up the stanza so kv pairs can be used as-is + ## + ###################################################################################################################### def sanitize( self ) : # Fix problematic variables self.dereference( "DM_FC" ) @@ -121,7 +136,9 @@ def sanitize( self ) : # Get rid of all these mixed up flags, these are handled by cmake natively or # just in the wrong place self.removeReferences( "FCBASEOPTS", [ "FCDEBUG", "FORMAT_FREE", "BYTESWAPIO", ] ) - # Now deref + self.removeReferences( "FFLAGS", [ "FORMAT_FREE", "FORMAT_FIXED" ] ) + self.removeReferences( "F77FLAGS", [ "FORMAT_FREE", "FORMAT_FIXED" ] ) + # # Now deref self.dereference( "FCBASEOPTS" ) # Now fix certain ones that are mixing programs with flags all mashed into one option @@ -133,39 +150,68 @@ def sanitize( self ) : # Remove rogue compile commands that should *NOT* even be here keysToSanitize = [ - "ARFLAGS", + "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", - "FCBASEOPTS", - "FCBASEOPTS_NO_G", - "FCOPTIM", - "FORMAT_FIXED", - "FORMAT_FREE" ] for keyToSan in keysToSanitize : if keyToSan in self.kvPairs_ : - self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "-c", "" ) - - + 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", "" ) + + compileObject.sub( "\1\2", self.kvPairs_[ keyToSan ] ) + # self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "-c", "" ) # Now deref all the rest for key in self.kvPairs_ : self.dereference( key ) # And for final measure strip self.kvPairs_[ key ] = self.kvPairs_[ key ].strip() - + def serialCompilersAvailable( self ) : return which( self.kvPairs_["SFC"] ) is not None and which( self.kvPairs_["SCC"] ) is not None def dmCompilersAvailable( self ) : return which( self.kvPairs_["DM_FC"] ) is not None and which( self.kvPairs_["DM_CC"] ) is not None + ###################################################################################################################### + ## + ## string representation to view as option + ## + ###################################################################################################################### def __str__( self ): # base = """OS {os:<8} ARCHITECTURES {archs:<20} # >> SFC = {SFC:<12} @@ -190,6 +236,11 @@ def __str__( self ): # text += "\n" + "\n".join( [ "{key:<18} = {value}".format( key=key, value=value) for key, value in self.kvPairs_.items() ] ) return text + ###################################################################################################################### + ## + ## Find first apparent difference between two stanzas + ## + ###################################################################################################################### @staticmethod def findFirstDifference( rhStanza, lhStanza, maxLength=32 ) : diff = False @@ -198,14 +249,16 @@ def findFirstDifference( rhStanza, lhStanza, maxLength=32 ) : "ARCH_LOCAL", "BYTESWAPIO", "CFLAGS_LOCAL", + "CFLAGS", + "DM_CC_FLAGS", "DM_CC", - "DM_FC", "DM_FC_FLAGS", - "DM_CC_FLAGS", + "DM_FC", "FCBASEOPTS", "FCDEBUG", "FCNOOPT", "FCOPTIM", + "FFLAGS", "M4_FLAGS", "SCC", "SFC" @@ -222,7 +275,11 @@ def findFirstDifference( rhStanza, lhStanza, maxLength=32 ) : return diff, value - +######################################################################################################################## +## +## Select enum-like string for string-based cmake options +## +######################################################################################################################## def getStringOptionSelection( topLevelCmake, searchString ) : topLevelCmakeFP = open( topLevelCmake, "r" ) topLevelCmakeLines = topLevelCmakeFP.read() @@ -250,6 +307,11 @@ def getStringOptionSelection( topLevelCmake, searchString ) : return options[selection] +######################################################################################################################## +## +## Aggregate and allow toggle of various suboptions in alternate menu +## +######################################################################################################################## def getSubOptions( topLevelCmake, ignoreOptions ) : topLevelCmakeFP = open( topLevelCmake, "r" ) topLevelCmakeLines = topLevelCmakeFP.read() @@ -293,6 +355,15 @@ def getSubOptions( topLevelCmake, ignoreOptions ) : return subOptions +######################################################################################################################## +######################################################################################################################## +## +## ABOVE THIS BREAK THINGS ARE EXACTLY THE SAME AS WRF/WPS +## BELOW THIS BREAK THINGS DIFFER +## +######################################################################################################################## +######################################################################################################################## + def generateCMakeToolChainFile( cmakeToolChainTemplate, output, stanza, optionsDict={} ) : cmakeToolChainTemplateFP = open( cmakeToolChainTemplate, "r" ) cmakeToolChainTemplateLines = cmakeToolChainTemplateFP.read() From 864b6a9e7220bdb0a146379c00df12cf1b6b3ca2 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 16 Aug 2023 18:26:34 -0600 Subject: [PATCH 119/180] Fix bug where string compare fails when values not defined --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 193a80e8e4..a68a39097f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,7 +73,7 @@ set( WRF_CORE_OPTIONS ) set( WRF_CORE "" CACHE STRING "WRF_CORE" ) -if ( ${WRF_CORE} STREQUAL "" ) +if ( "${WRF_CORE}" STREQUAL "" ) # Set default WRF_CORE list( GET WRF_CORE_OPTIONS 0 WRF_CORE ) endif() @@ -90,7 +90,7 @@ set( WRF_NESTING_OPTIONS ) set( WRF_NESTING "" CACHE STRING "WRF_NESTING" ) -if ( ${WRF_NESTING} STREQUAL "" ) +if ( "${WRF_NESTING}" STREQUAL "" ) # Set default WRF_NESTING list( GET WRF_NESTING_OPTIONS 0 WRF_NESTING ) endif() @@ -122,7 +122,7 @@ set( WRF_CASE_OPTIONS ) set( WRF_CASE "" CACHE STRING "WRF_CASE" ) -if ( ${WRF_CASE} STREQUAL "" ) +if ( "${WRF_CASE}" STREQUAL "" ) # Set default WRF_CASE list( GET WRF_CASE_OPTIONS 0 WRF_CASE ) endif() From 177d95bcfb04c6fe2dfb1d3972bcd312c45d7e97 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 16 Aug 2023 18:27:54 -0600 Subject: [PATCH 120/180] Allow stanza selection and direct option pass-through without user prompt, useful for automation --- arch/configure_reader.py | 212 +++++++++++++++++++++++++++++---------- configure_new | 76 +++++++++++--- 2 files changed, 221 insertions(+), 67 deletions(-) diff --git a/arch/configure_reader.py b/arch/configure_reader.py index a65eaea958..eae281f280 100755 --- a/arch/configure_reader.py +++ b/arch/configure_reader.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import argparse import sys import re import inspect @@ -191,9 +192,9 @@ def sanitize( self ) : 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", "" ) - - compileObject.sub( "\1\2", self.kvPairs_[ keyToSan ] ) - # self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "-c", "" ) + + self.kvPairs_[ keyToSan ] = compileObject.sub( r"\1\2", self.kvPairs_[ keyToSan ] ).strip() + # Now deref all the rest for key in self.kvPairs_ : @@ -275,6 +276,133 @@ def findFirstDifference( rhStanza, lhStanza, maxLength=32 ) : return diff, value +######################################################################################################################## +## +## Option handling +## +######################################################################################################################## +def getOptionsParser() : + parser = argparse.ArgumentParser( ) + + # https://stackoverflow.com/a/24181138 + requiredNamed = parser.add_argument_group( "required named arguments" ) + + requiredNamed.add_argument( + "-c", "--config", + dest="configFile", + help="configure.defaults file holding all stanza configurations", + type=str, + required=True + ) + requiredNamed.add_argument( + "-t", "--template", + dest="cmakeTemplateFile", + help="cmake template file for configuring stanza into cmake syntax", + type=str, + required=True + ) + requiredNamed.add_argument( + "-o", "--output", + dest="outputConfigFile", + help="cmake output toolchain config file for selected stanza", + type=str, + required=True + ) + + parser.add_argument( + "-p", "--preselect", + dest="preselect", + help="Use preselected stanza configuration, if multiple match grabs the first one", + type=str, + default=None + ) + + parser.add_argument( + "-x", "--skipCMakeOptions", + dest="skipCMakeOptions", + help="Skip query of available CMake options", + default=False, + const=True, + action='store_const' + ) + parser.add_argument( + "-s", "--source", + dest="sourceCMakeFile", + help="Required unless -x/--skipCMakeOptions set, project cmake source file used to determine available options", + type=str, + default=None + ) + + return parser + + +class Options(object): + """Empty namespace""" + pass + +######################################################################################################################## +## +## Select stanza to operate on +## +######################################################################################################################## +def selectStanza( options ) : + + fp = open( options.configFile, 'r' ) + lines = fp.read() + fp.close() + + # Now grab the blocks and parse + stanzas = [] + # Gather all stanzas available + for stanzaBlock in archBlock.finditer( lines ) : + stanza = Stanza( stanzaBlock.group(1) ) + stanza.parse() + + if not stanza.crossPlatform_ and stanza.serialCompilersAvailable() and ( stanza.dmCompilersAvailable() or ( stanza.serialOpt_ or stanza.smparOpt_ ) ) : + if "DESCRIPTION" not in stanza.kvPairs_ : + # Of course WPS configure.defaults is different than WRF so descriptions are embedded in the comments + stanza.kvPairs_[ "DESCRIPTION" ] = stanza.osArchLine_.partition( "," )[ -1 ].partition( "#" )[0].strip() + stanzas.append( stanza ) + + idxSelection = 0 + if options.preselect is None : + # Query for selected + stanzaIdx = 0 + uniqueConfigs = {} + for stanza in stanzas : + stanzaConfig = str( stanza ) + stanzaId = "{idx:<3} ".format( idx=stanzaIdx ) + if stanzaConfig not in uniqueConfigs : + uniqueConfigs[ stanzaConfig ] = { "stanza" : stanza, "idx" : stanzaIdx } + + print( stanzaId + stanzaConfig + stanza.kvPairs_[ "DESCRIPTION" ] ) + # else : + # diff, value = Stanza.findFirstDifference( uniqueConfigs[ stanzaConfig ]["stanza"], stanza ) + # if diff : + # print( stanzaId + stanzaConfig + "@{idx} diff => {value}".format( idx=uniqueConfigs[ stanzaConfig ][ "idx" ], value=value ) ) + # else : + # print( stanzaId + stanzaConfig + "[no difference]" ) + stanzaIdx += 1 + print( "!! - Compiler not found, some configurations will not work and will be hidden" ) + idxSelection = int( input( "Select configuration [0-{stop}] (note !!) : ".format( stop=( stanzaIdx-1) ) ) ) + if idxSelection < 0 or idxSelection > stanzaIdx - 1 : + print( "Invalid configuration selection!" ) + exit(1) + else : + for stanza in stanzas : + if options.preselect.lower() in stanza.kvPairs_["DESCRIPTION"].lower() : + print( str( stanza ) + stanza.kvPairs_[ "DESCRIPTION"] ) + break + else : + idxSelection += 1 + if idxSelection == len( stanzas ) : + print( "Error: Stanza configuration with description '{0}' does not exist. Preselect failed.".format( options.preselect ) ) + exit(1) + + stanzaCfg = stanzas[idxSelection] + + return stanzaCfg + ######################################################################################################################## ## ## Select enum-like string for string-based cmake options @@ -355,6 +483,24 @@ def getSubOptions( topLevelCmake, ignoreOptions ) : return subOptions +def main() : + + parser = getOptionsParser() + options = Options() + parser.parse_args( namespace=options ) + + stanzaCfg = selectStanza( options ) + + additionalOptions = {} + if not options.skipCMakeOptions : + if options.sourceCMakeFile is None : + print( "Error: Project source cmake file required for project specific options." ) + exit(1) + else: + additionalOptions = projectSpecificOptions( options, stanzaCfg ) + + generateCMakeToolChainFile( options.cmakeTemplateFile, options.outputConfigFile, stanzaCfg, additionalOptions ) + ######################################################################################################################## ######################################################################################################################## ## @@ -396,51 +542,10 @@ def generateCMakeToolChainFile( cmakeToolChainTemplate, output, stanza, optionsD outputFP.write( configStanza ) outputFP.close() -def main() : - configFile = sys.argv[1] - cmakeTemplateFile = sys.argv[2] - cmakeConfigFile = sys.argv[3] - cmakeFile = sys.argv[4] - - fp = open( configFile, 'r' ) - lines = fp.read() - fp.close() - - # Now grab the blocks and parse - stanzas = [] - uniqueConfigs = {} - stanzaIdx = 0 - for stanzaBlock in archBlock.finditer( lines ) : - stanza = Stanza( stanzaBlock.group(1) ) - stanza.parse() - - if not stanza.crossPlatform_ and stanza.serialCompilersAvailable() and ( stanza.dmCompilersAvailable() or ( stanza.serialOpt_ or stanza.smparOpt_ ) ) : - stanzas.append( stanza ) - stanzaConfig = str( stanza ) - stanzaId = "{idx:<3} ".format( idx=stanzaIdx ) - if stanzaConfig not in uniqueConfigs : - uniqueConfigs[ stanzaConfig ] = { "stanza" : stanza, "idx" : stanzaIdx } - - print( stanzaId + stanzaConfig + stanza.kvPairs_[ "DESCRIPTION" ] ) - # else : - # diff, value = Stanza.findFirstDifference( uniqueConfigs[ stanzaConfig ]["stanza"], stanza ) - # if diff : - # print( stanzaId + stanzaConfig + "@{idx} diff => {value}".format( idx=uniqueConfigs[ stanzaConfig ][ "idx" ], value=value ) ) - # else : - # print( stanzaId + stanzaConfig + "[no difference]" ) - stanzaIdx += 1 - - print( "!! - Compiler not found, some configurations will not work and will be hidden" ) - - idxSelection = int( input( "Select configuration [0-{stop}] (note !!) : ".format( stop=( stanzaIdx-1) ) ) ) - if idxSelection < 0 or idxSelection > stanzaIdx - 1 : - print( "Invalid configuration selection!" ) - exit(1) - - stanzaCfg = stanzas[idxSelection] - coreOption = getStringOptionSelection( cmakeFile, "WRF_CORE_OPTIONS" ) - nestingOption = getStringOptionSelection( cmakeFile, "WRF_NESTING_OPTIONS" ) - caseOption = getStringOptionSelection( cmakeFile, "WRF_CASE_OPTIONS" ) +def projectSpecificOptions( options, stanzaCfg ) : + coreOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_CORE_OPTIONS" ) + nestingOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_NESTING_OPTIONS" ) + caseOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_CASE_OPTIONS" ) # These are yes yesValues = [ "yes", "y", "true", "1" ] @@ -473,7 +578,7 @@ def main() : doSuboptionMenu = input( "Configure additional options? [Y/n] : " ).lower() in yesValues subOptions = {} if doSuboptionMenu : - subOptions = getSubOptions( cmakeFile, alreadyAsked ) + subOptions = getSubOptions( options.sourceCMakeFile, alreadyAsked ) additionalOptions = { "WRF_CORE" : coreOption, @@ -481,13 +586,10 @@ def main() : "WRF_CASE" : caseOption, "USE_MPI" : "ON" if useMPI else "OFF", "USE_OPENMP" : "ON" if useOpenMP else "OFF", - } + } additionalOptions.update( subOptions ) - generateCMakeToolChainFile( cmakeTemplateFile, cmakeConfigFile, stanzaCfg, additionalOptions ) - - + return additionalOptions if __name__ == '__main__' : - main() - + main() \ No newline at end of file diff --git a/configure_new b/configure_new index afd1d6b8c9..b79a69e463 100755 --- a/configure_new +++ b/configure_new @@ -1,13 +1,65 @@ #!/bin/sh -# Meant to be run at the top level -./arch/configure_reader.py \ - arch/configure.defaults \ - cmake/template/arch_config.cmake \ - wrf_config.cmake \ - CMakeLists.txt - -# Now run cmake -mkdir -p _build/ -cd _build -cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/../runTemp -DCMAKE_TOOLCHAIN_FILE=$PWD/../wrf_config.cmake -# cmake -S . -B _build \ No newline at end of file + +function help() +{ + echo "./configure_new [options] [-- ]" + echo " -p Preselect a stanza configuration with matching description" + echo " -x Skip CMake options prompt, meant to be used in conjunction with direct pass-in options" + echo " -- Directly pass CMake options to configuration, equivalent to cmake " + echo " -h Print this message" + +} + +preselect= +skipCMake=false +while getopts p:xh opt; do + case $opt in + p) + preselect=$OPTARG + ;; + x) + skipCMake=true + ;; + h) help; exit 0 ;; + *) help; exit 1 ;; + :) help; exit 1 ;; + \?) help; exit 1 ;; + esac +done + +shift "$((OPTIND - 1))" + +extraOps= +if [ $skipCMake = true ]; then + extraOps="-x" +else + extraOps="-s CMakeLists.txt" +fi + + +if [ ! -z "$preselect" ]; then + echo "Using preselected config ${preselect}" + # Meant to be run at the top level + ./arch/configure_reader.py \ + -c arch/configure.defaults \ + -t cmake/template/arch_config.cmake \ + -o wrf_config.cmake \ + ${extraOps} -p "${preselect}" +else + # Meant to be run at the top level + ./arch/configure_reader.py \ + -c arch/configure.defaults \ + -t cmake/template/arch_config.cmake \ + -o wrf_config.cmake \ + ${extraOps} +fi + +configureStanza=$? + +if [ $configureStanza -eq 0 ]; then + # Now run cmake + mkdir -p _build/ + cd _build + cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/../runTemp -DCMAKE_TOOLCHAIN_FILE=$PWD/../wrf_config.cmake $* + # cmake -S . -B _build +fi \ No newline at end of file From ad11946ae4cf8af9d5e2697217a346a8ba6891d7 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 22 Aug 2023 16:08:54 -0600 Subject: [PATCH 121/180] Changing visibility of linked omp lib as that can cause netcdf linked in to fail --- external/io_netcdf/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/external/io_netcdf/CMakeLists.txt b/external/io_netcdf/CMakeLists.txt index 6a86c29f9c..8fc86002d2 100644 --- a/external/io_netcdf/CMakeLists.txt +++ b/external/io_netcdf/CMakeLists.txt @@ -17,10 +17,11 @@ set_target_properties( target_link_libraries( ${FOLDER_COMPILE_TARGET} + PUBLIC + $<$:$> PRIVATE ${netCDF_LIBRARIES} $<$:$> - $<$:$> ) target_include_directories( ${FOLDER_COMPILE_TARGET} From 7341c8e33ae7d74cd23b1ddf7301636cc1d8b420 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 22 Aug 2023 16:09:19 -0600 Subject: [PATCH 122/180] Print build type --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a68a39097f..a309d83e5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -334,6 +334,7 @@ if ( DEFINED CMAKE_TOOLCHAIN_FILE ) endif() +print_option( CMAKE_BUILD_TYPE 20 ${BOLD_CYAN} ) print_option( WRF_CORE 20 ${BOLD_CYAN} ) print_option( WRF_NESTING 20 ${BOLD_CYAN} ) print_option( WRF_CASE 20 ${BOLD_CYAN} ) From 4d82c75c6598ecd2253089706c772e0a2a6c5a51 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 22 Aug 2023 16:11:58 -0600 Subject: [PATCH 123/180] Setting preproc macros to suppress further automatic processing to avoid bad symbol mapping when using gdb --- cmake/c_preproc.cmake | 18 ++++++++---- cmake/m4_preproc.cmake | 66 ++++++++++++++++++++++++------------------ 2 files changed, 50 insertions(+), 34 deletions(-) diff --git a/cmake/c_preproc.cmake b/cmake/c_preproc.cmake index 31f1c7fa6d..b57c63d7f8 100644 --- a/cmake/c_preproc.cmake +++ b/cmake/c_preproc.cmake @@ -3,7 +3,7 @@ macro( wrf_c_preproc_fortran ) set( options ) set( oneValueArgs TARGET_NAME SUFFIX PREFIX EXTENSION OUTPUT_DIR ) - set( multiValueArgs DEPENDENCIES INCLUDES SOURCES DEFINITIONS ) + set( multiValueArgs DEPENDENCIES INCLUDES SOURCES DEFINITIONS TARGET_SCOPE ) cmake_parse_arguments( WRF_PP_F @@ -12,10 +12,10 @@ macro( wrf_c_preproc_fortran ) ) #!TODO Verify -o/-I/-E/-D/-free are all compiler independent flags - # # Santitize input - # if ( DEFINED WRF_PP_F_GENERATED_SCOPE ) - # set( WRF_PP_F_TARGET_DIRECTORY TARGET_DIRECTORY ${WRF_PP_F_GENERATED_SCOPE} ) - # endif() + # Santitize input + if ( DEFINED WRF_PP_F_TARGET_SCOPE ) + set( WRF_PP_F_TARGET_DIRECTORY TARGET_DIRECTORY ${WRF_PP_F_TARGET_SCOPE} ) + endif() set( WRF_PP_F_INCLUDES_FLAGS ) foreach( WRF_PP_F_INC ${WRF_PP_F_INCLUDES} ) @@ -68,7 +68,13 @@ macro( wrf_c_preproc_fortran ) # PROPERTIES # GENERATED TRUE # ) - + set_source_files_properties( + ${WRF_PP_F_OUTPUT_FILE} + DIRECTORY ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} + ${WRF_PP_F_TARGET_DIRECTORY} + PROPERTIES + Fortran_PREPROCESS OFF + ) # message( STATUS "File ${WRF_PP_F_SOURCE_FILE} will be preprocessed into ${WRF_PP_F_OUTPUT_FILE}" ) endforeach() diff --git a/cmake/m4_preproc.cmake b/cmake/m4_preproc.cmake index b75ee49a11..4158795578 100644 --- a/cmake/m4_preproc.cmake +++ b/cmake/m4_preproc.cmake @@ -3,10 +3,10 @@ macro( wrf_m4_preproc_fortran ) set( options ) set( oneValueArgs TARGET_NAME SUFFIX PREFIX EXTENSION OUTPUT_DIR M4_PROGRAM ) - set( multiValueArgs DEPENDENCIES SOURCES M4_FLAGS ) + set( multiValueArgs DEPENDENCIES SOURCES FLAGS TARGET_SCOPE ) cmake_parse_arguments( - WRF_PP + WRF_PP_M4 "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) @@ -15,32 +15,36 @@ macro( wrf_m4_preproc_fortran ) set( WRF_PP_M4_PROGRAM_TO_USE ${WRF_PP_M4_PROGRAM} ) endif() + # Santitize input + if ( DEFINED WRF_PP_M4_TARGET_SCOPE ) + set( WRF_PP_M4_TARGET_DIRECTORY TARGET_DIRECTORY ${WRF_PP_M4_TARGET_SCOPE} ) + endif() + # Generate compile command and file outputs - set( WRF_PP_OUTPUT ) - set( WRF_PP_COMMANDS ) - foreach( WRF_PP_SOURCE_FILE ${WRF_PP_SOURCES} ) - get_filename_component( WRF_PP_INPUT_SOURCE ${WRF_PP_SOURCE_FILE} REALPATH ) - get_filename_component( WRF_PP_INPUT_SOURCE_FILE_ONLY ${WRF_PP_SOURCE_FILE} NAME ) + set( WRF_PP_M4_OUTPUT ) + set( WRF_PP_M4_COMMANDS ) + foreach( WRF_PP_M4_SOURCE_FILE ${WRF_PP_M4_SOURCES} ) + get_filename_component( WRF_PP_M4_INPUT_SOURCE ${WRF_PP_M4_SOURCE_FILE} REALPATH ) + get_filename_component( WRF_PP_M4_INPUT_SOURCE_FILE_ONLY ${WRF_PP_M4_SOURCE_FILE} NAME ) - if ( ${WRF_PP_EXTENSION} MATCHES "^[.][a-z0-9]+$" ) - string( REGEX REPLACE "[.].*$" "${WRF_PP_EXTENSION}" WRF_PP_OUTPUT_FILE ${WRF_PP_INPUT_SOURCE_FILE_ONLY} ) + if ( ${WRF_PP_M4_EXTENSION} MATCHES "^[.][a-z0-9]+$" ) + string( REGEX REPLACE "[.].*$" "${WRF_PP_M4_EXTENSION}" WRF_PP_M4_OUTPUT_FILE ${WRF_PP_M4_INPUT_SOURCE_FILE_ONLY} ) else() # Default extension - string( REGEX REPLACE "[.].*$" ".i" WRF_PP_OUTPUT_FILE ${WRF_PP_INPUT_SOURCE_FILE_ONLY} ) + string( REGEX REPLACE "[.].*$" ".i" WRF_PP_M4_OUTPUT_FILE ${WRF_PP_M4_INPUT_SOURCE_FILE_ONLY} ) endif() - set( WRF_PP_OUTPUT_FILE ${WRF_PP_OUTPUT_DIR}/${WRF_PP_PREFIX}${WRF_PP_OUTPUT_FILE}${WRF_PP_SUFFIX} ) + set( WRF_PP_M4_OUTPUT_FILE ${WRF_PP_M4_OUTPUT_DIR}/${WRF_PP_M4_PREFIX}${WRF_PP_M4_OUTPUT_FILE}${WRF_PP_M4_SUFFIX} ) - list( - APPEND WRF_PP_COMMANDS - COMMAND ${WRF_PP_M4_PROGRAM_TO_USE} ${WRF_PP_M4_FLAGS} ${WRF_PP_INPUT_SOURCE} > ${WRF_PP_OUTPUT_FILE} + APPEND WRF_PP_M4_COMMANDS + COMMAND ${WRF_PP_M4_PROGRAM_TO_USE} ${WRF_PP_M4_FLAGS} ${WRF_PP_M4_INPUT_SOURCE} > ${WRF_PP_M4_OUTPUT_FILE} # Force check that they were made - COMMAND ${CMAKE_COMMAND} -E compare_files ${WRF_PP_OUTPUT_FILE} ${WRF_PP_OUTPUT_FILE} + COMMAND ${CMAKE_COMMAND} -E compare_files ${WRF_PP_M4_OUTPUT_FILE} ${WRF_PP_M4_OUTPUT_FILE} ) list( - APPEND WRF_PP_OUTPUT - ${WRF_PP_OUTPUT_FILE} + APPEND WRF_PP_M4_OUTPUT + ${WRF_PP_M4_OUTPUT_FILE} ) # # Tell all targets that eventually use this file that it is generated - this is useful if this macro is used in a @@ -52,27 +56,33 @@ macro( wrf_m4_preproc_fortran ) # # We could use cmake 3.20+ and CMP0118, but this allows usage from 3.18.6+ # TL;DR - This doesn't work despite all documentation stating otherwise, need to use CMP0118 # set_source_files_properties( - # ${WRF_PP_OUTPUT_FILE} - # ${WRF_PP_TARGET_DIRECTORY} + # ${WRF_PP_M4_OUTPUT_FILE} + # ${WRF_PP_M4_TARGET_DIRECTORY} # PROPERTIES # GENERATED TRUE # ) - - # message( STATUS "File ${WRF_PP_SOURCE_FILE} will be preprocessed into ${WRF_PP_OUTPUT_FILE}" ) + set_source_files_properties( + ${WRF_PP_M4_OUTPUT_FILE} + DIRECTORY ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} + ${WRF_PP_M4_TARGET_DIRECTORY} + PROPERTIES + Fortran_PREPROCESS OFF + ) + # message( STATUS "File ${WRF_PP_M4_SOURCE_FILE} will be preprocessed into ${WRF_PP_M4_OUTPUT_FILE}" ) endforeach() # Preprocess sources into a custom target add_custom_command( - OUTPUT ${WRF_PP_OUTPUT} - COMMAND ${CMAKE_COMMAND} -E make_directory ${WRF_PP_OUTPUT_DIR} - ${WRF_PP_COMMANDS} - COMMENT "Preprocessing ${WRF_PP_TARGET_NAME}" - DEPENDS ${WRF_PP_DEPENDENCIES} + OUTPUT ${WRF_PP_M4_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E make_directory ${WRF_PP_M4_OUTPUT_DIR} + ${WRF_PP_M4_COMMANDS} + COMMENT "Preprocessing ${WRF_PP_M4_TARGET_NAME}" + DEPENDS ${WRF_PP_M4_DEPENDENCIES} ) add_custom_target( - ${WRF_PP_TARGET_NAME} - DEPENDS ${WRF_PP_OUTPUT} + ${WRF_PP_M4_TARGET_NAME} + DEPENDS ${WRF_PP_M4_OUTPUT} ) endmacro() From 73f71f54a730870f537b5a58d048f08e8e0c4b19 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 22 Aug 2023 16:12:38 -0600 Subject: [PATCH 124/180] Find omp/mpi if finding wrf and was built with said options --- cmake/template/WRFConfig.cmake.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake/template/WRFConfig.cmake.in b/cmake/template/WRFConfig.cmake.in index 9f6778f8fc..f896e0f420 100644 --- a/cmake/template/WRFConfig.cmake.in +++ b/cmake/template/WRFConfig.cmake.in @@ -38,6 +38,14 @@ set( WRF_SHOW_ALL_VARS_USED @SHOW_ALL_VARS_USED@ ) set( WRF_WRFIO_NCD_NO_LARGE_FILE_SUPPORT @WRFIO_NCD_NO_LARGE_FILE_SUPPORT@ ) +if ( ${WRF_USE_MPI} ) + find_package( MPI REQUIRED COMPONENTS Fortran C ) +endif() + +if ( ${WRF_USE_OPENMP} ) + find_package( OpenMP REQUIRED COMPONENTS Fortran C ) +endif() + find_package( netCDF REQUIRED ) # Attempt to find zlib packaged with netcdf first set( ZLIB_ROOT ${netCDF_PREFIX} ) From d453c430e991c187490b4e568142d89240d46605 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 22 Aug 2023 16:40:03 -0600 Subject: [PATCH 125/180] Applying m4 flags --- CMakeLists.txt | 1 + external/io_adios2/CMakeLists.txt | 2 ++ external/io_netcdf/CMakeLists.txt | 2 ++ external/io_netcdfpar/CMakeLists.txt | 2 ++ external/io_pnetcdf/CMakeLists.txt | 2 ++ frame/CMakeLists.txt | 2 ++ 6 files changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a309d83e5f..ff982bcec2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -423,6 +423,7 @@ if ( ${USE_M4} ) m4 REQUIRED ) + set( M4_FLAGS ${WRF_M4_FLAGS} -Uinclude -Uindex -Ulen ) endif() diff --git a/external/io_adios2/CMakeLists.txt b/external/io_adios2/CMakeLists.txt index 19af28fa39..dde531a716 100644 --- a/external/io_adios2/CMakeLists.txt +++ b/external/io_adios2/CMakeLists.txt @@ -52,6 +52,8 @@ wrf_m4_preproc_fortran( EXTENSION ".f90" SOURCES ${CMAKE_CURRENT_BINARY_DIR}/preproc/wrf_io.f90 DEPENDENCIES ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io + TARGET_SCOPE ${FOLDER_COMPILE_TARGET} + FLAGS ${M4_FLAGS} ) add_dependencies( ${FOLDER_COMPILE_TARGET} ${FOLDER_COMPILE_TARGET}_m4_preproc_wrf_io ) diff --git a/external/io_netcdf/CMakeLists.txt b/external/io_netcdf/CMakeLists.txt index 8fc86002d2..d000427d7c 100644 --- a/external/io_netcdf/CMakeLists.txt +++ b/external/io_netcdf/CMakeLists.txt @@ -53,6 +53,8 @@ wrf_m4_preproc_fortran( EXTENSION ".f90" SOURCES ${CMAKE_CURRENT_BINARY_DIR}/preproc/wrf_io.f90 DEPENDENCIES ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io + TARGET_SCOPE ${FOLDER_COMPILE_TARGET} + FLAGS ${M4_FLAGS} ) add_dependencies( ${FOLDER_COMPILE_TARGET} ${FOLDER_COMPILE_TARGET}_m4_preproc_wrf_io ) diff --git a/external/io_netcdfpar/CMakeLists.txt b/external/io_netcdfpar/CMakeLists.txt index 6a86c29f9c..4e68778b06 100644 --- a/external/io_netcdfpar/CMakeLists.txt +++ b/external/io_netcdfpar/CMakeLists.txt @@ -52,6 +52,8 @@ wrf_m4_preproc_fortran( EXTENSION ".f90" SOURCES ${CMAKE_CURRENT_BINARY_DIR}/preproc/wrf_io.f90 DEPENDENCIES ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io + TARGET_SCOPE ${FOLDER_COMPILE_TARGET} + FLAGS ${M4_FLAGS} ) add_dependencies( ${FOLDER_COMPILE_TARGET} ${FOLDER_COMPILE_TARGET}_m4_preproc_wrf_io ) diff --git a/external/io_pnetcdf/CMakeLists.txt b/external/io_pnetcdf/CMakeLists.txt index 64a01b9b31..1717f71383 100644 --- a/external/io_pnetcdf/CMakeLists.txt +++ b/external/io_pnetcdf/CMakeLists.txt @@ -54,6 +54,8 @@ wrf_m4_preproc_fortran( EXTENSION ".f90" SOURCES ${CMAKE_CURRENT_BINARY_DIR}/preproc/wrf_io.f90 DEPENDENCIES ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io + TARGET_SCOPE ${FOLDER_COMPILE_TARGET} + FLAGS ${M4_FLAGS} ) add_dependencies( ${FOLDER_COMPILE_TARGET} ${FOLDER_COMPILE_TARGET}_m4_preproc_wrf_io ) diff --git a/frame/CMakeLists.txt b/frame/CMakeLists.txt index f4dd49e63f..4ae687d39f 100644 --- a/frame/CMakeLists.txt +++ b/frame/CMakeLists.txt @@ -57,6 +57,8 @@ if ( ${USE_M4} ) OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/ EXTENSION ".inc" SOURCES md_calls.m4 + TARGET_SCOPE ${PROJECT_NAME}_Core + FLAGS ${M4_FLAGS} ) else() From 558d9d1348a649b055e94c0669776716a0997554 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 6 Sep 2023 14:23:38 -0600 Subject: [PATCH 126/180] Using cpp instead of fortran compiler for more standardized flag usage --- CMakeLists.txt | 3 ++ arch/configure_reader.py | 62 +++++++++++++++++++++----------- cmake/c_preproc.cmake | 5 ++- cmake/template/arch_config.cmake | 11 +++++- 4 files changed, 57 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff982bcec2..799735673e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,9 @@ list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/ ${PROJECT_SOURCE_DIR set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE ) set( CMAKE_Fortran_PREPROCESS ON ) +# This is always set +list( APPEND CMAKE_C_PREPROCESSOR_FLAGS -P -nostdinc ) + include( CMakePackageConfigHelpers ) include( c_preproc ) include( m4_preproc ) diff --git a/arch/configure_reader.py b/arch/configure_reader.py index eae281f280..9c7b603a25 100755 --- a/arch/configure_reader.py +++ b/arch/configure_reader.py @@ -2,6 +2,7 @@ import argparse import sys +import os import re import inspect import platform @@ -76,29 +77,45 @@ def parse( self ) : ###################################################################################################################### def dereference( self, field, fatal=False ) : # print( "Dereferencing " + field ) + if field in self.kvPairs_ : prevField = self.kvPairs_[field] for refVarIter in referenceVar.finditer( prevField ) : + envSub = None + if refVarIter is not None : # Grab group 1 and check that it is in our kv pairs refVar = refVarIter.group(2) # print( "Found variable {0} in field {1}".format( refVar, field ) ) if refVar not in self.kvPairs_ : - if fatal : - # print( "Could not rereference : " + refVar ) - exit(1) + # Try to use the environment variables + if refVar in os.environ : + envSub = os.environ[ refVar ] else: - continue - - # Recursively deref - self.dereference( refVar, fatal ) + if fatal : + # print( "Could not rereference : " + refVar ) + exit(1) + else: + continue + - # Replace in original - self.kvPairs_[field] = self.kvPairs_[field].replace( - "{var}".format( var=refVarIter.group(0) ), - self.kvPairs_[refVar] - ) + # This is an environment variable + if envSub is not None : + self.kvPairs_[field] = self.kvPairs_[field].replace( + "{var}".format( var=refVarIter.group(0) ), + envSub + ) + # This is a kv pair, recurse + else : + # Recursively deref + self.dereference( refVar, fatal ) + + # Replace in original + self.kvPairs_[field] = self.kvPairs_[field].replace( + "{var}".format( var=refVarIter.group(0) ), + self.kvPairs_[refVar] + ) def removeReferences( self, field, specifics=[] ) : if field in self.kvPairs_ : @@ -142,13 +159,6 @@ def sanitize( self ) : # # Now deref self.dereference( "FCBASEOPTS" ) - # Now fix certain ones that are mixing programs with flags all mashed into one option - self.splitIntoFieldAndFlags( "SFC" ) - self.splitIntoFieldAndFlags( "SCC" ) - self.splitIntoFieldAndFlags( "DM_FC" ) - self.splitIntoFieldAndFlags( "DM_CC" ) - self.splitIntoFieldAndFlags( "M4" ) - # Remove rogue compile commands that should *NOT* even be here keysToSanitize = [ "ARFLAGS","ARFLAGS", @@ -192,10 +202,20 @@ def sanitize( self ) : 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() + # Now fix certain ones that are mixing programs with flags all mashed into one option + self.splitIntoFieldAndFlags( "SFC" ) + self.splitIntoFieldAndFlags( "SCC" ) + self.splitIntoFieldAndFlags( "DM_FC" ) + self.splitIntoFieldAndFlags( "DM_CC" ) + self.splitIntoFieldAndFlags( "CPP" ) + self.splitIntoFieldAndFlags( "M4" ) + # Now deref all the rest for key in self.kvPairs_ : self.dereference( key ) @@ -531,7 +551,9 @@ def generateCMakeToolChainFile( cmakeToolChainTemplate, output, stanza, optionsD SCC=stanza.kvPairs_["SCC"], SFC=stanza.kvPairs_["SFC"], SCC_FLAGS=stanza.kvPairs_["SCC_FLAGS"], - SFC_FLAGS=stanza.kvPairs_["SFC_FLAGS"] + SFC_FLAGS=stanza.kvPairs_["SFC_FLAGS"], + CPP=stanza.kvPairs_["CPP"], + CPP_FLAGS=stanza.kvPairs_["CPP_FLAGS"], ) # Extra stufff not from stanza but options diff --git a/cmake/c_preproc.cmake b/cmake/c_preproc.cmake index b57c63d7f8..14f7fe9295 100644 --- a/cmake/c_preproc.cmake +++ b/cmake/c_preproc.cmake @@ -10,8 +10,7 @@ macro( wrf_c_preproc_fortran ) "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) - #!TODO Verify -o/-I/-E/-D/-free are all compiler independent flags - + # Santitize input if ( DEFINED WRF_PP_F_TARGET_SCOPE ) set( WRF_PP_F_TARGET_DIRECTORY TARGET_DIRECTORY ${WRF_PP_F_TARGET_SCOPE} ) @@ -45,7 +44,7 @@ macro( wrf_c_preproc_fortran ) list( APPEND WRF_PP_F_COMMANDS - COMMAND ${CMAKE_Fortran_COMPILER} -E ${WRF_PP_F_INPUT_SOURCE} -free ${WRF_PP_F_DEFS} ${WRF_PP_F_INCLUDES_FLAGS} > ${WRF_PP_F_OUTPUT_FILE} + COMMAND ${CMAKE_C_PREPROCESSOR} ${CMAKE_C_PREPROCESSOR_FLAGS} ${WRF_PP_F_INPUT_SOURCE} ${WRF_PP_F_DEFS} ${WRF_PP_F_INCLUDES_FLAGS} > ${WRF_PP_F_OUTPUT_FILE} # Force check that they were made COMMAND ${CMAKE_COMMAND} -E compare_files ${WRF_PP_F_OUTPUT_FILE} ${WRF_PP_F_OUTPUT_FILE} ) diff --git a/cmake/template/arch_config.cmake b/cmake/template/arch_config.cmake index 6977379aa2..42cba60287 100644 --- a/cmake/template/arch_config.cmake +++ b/cmake/template/arch_config.cmake @@ -2,14 +2,23 @@ set( MPI_Fortran_COMPILER "{DM_FC}" ) set( MPI_C_COMPILER "{DM_CC}" ) +# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER.html set( CMAKE_Fortran_COMPILER "{SFC}" ) set( CMAKE_C_COMPILER "{SCC}" ) +# Our own addition +set( CMAKE_C_PREPROCESSOR "{CPP}" ) +set( CMAKE_C_PREPROCESSOR_FLAGS {CPP_FLAGS} ) + +# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS_INIT.html 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 "{FCOPTIM}" ) +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}" ) From 8c64748158b8cab3011d4b5e8b44b934d78721a9 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 6 Sep 2023 14:24:38 -0600 Subject: [PATCH 127/180] sh compliant --- cleanCMake.sh | 14 +++++++------- configure_new | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cleanCMake.sh b/cleanCMake.sh index c42fbfc22d..a392d75143 100755 --- a/cleanCMake.sh +++ b/cleanCMake.sh @@ -3,7 +3,7 @@ BUILD_DIR=_build INSTALL_DIR=runTemp TEST_DIR=test/ -function help() +help() { echo "./cleanCMake.sh [options]" echo " -c Basic cmake clean functionality [cmake --build ${BUILD_DIR} -j 1 --target clean]" @@ -43,28 +43,28 @@ while getopts "hcilfa" opt; do esac done -if [[ $OPTIND -eq 1 ]]; then +if [ $OPTIND -eq 1 ]; then # Do basic clean I guess CLEAN_BASIC_BUILD=TRUE fi -if [[ "${CLEAN_BASIC_BUILD}" == "TRUE" || "${CLEAN_ALL}" == "TRUE" ]]; then +if [ "${CLEAN_BASIC_BUILD}" = "TRUE" ] || [ "${CLEAN_ALL}" = "TRUE" ]; then echo "Doing cmake make clean" OLD_DIR=$PWD cd ${BUILD_DIR} && make -j 1 clean; cd $OLD_DIR fi -if [[ "${CLEAN_BASIC_INSTALL}" == "TRUE" || "${CLEAN_ALL}" == "TRUE" ]]; then +if [ "${CLEAN_BASIC_INSTALL}" = "TRUE" ] || [ "${CLEAN_ALL}" = "TRUE" ]; then echo "Removing binary installs" xargs rm < ${BUILD_DIR}/install_manifest.txt fi -if [[ "${CLEAN_LINKS}" == "TRUE" || "${CLEAN_ALL}" == "TRUE" ]]; then +if [ "${CLEAN_LINKS}" = "TRUE" ] || [ "${CLEAN_ALL}" = "TRUE" ]; then echo "Removing all symlinks in ${TEST_DIR}" find ${TEST_DIR} -type l -exec rm {} \; fi -if [[ "${CLEAN_FOLDERS}" == "TRUE" || "${CLEAN_ALL}" == "TRUE" ]]; then +if [ "${CLEAN_FOLDERS}" = "TRUE" ] || [ "${CLEAN_ALL}" = "TRUE" ]; then echo "Deleting ${BUILD_DIR} & ${INSTALL_DIR}/" rm ${BUILD_DIR} -r; rm ${INSTALL_DIR}/ -r -fi \ No newline at end of file +fi diff --git a/configure_new b/configure_new index b79a69e463..213ecc3a43 100755 --- a/configure_new +++ b/configure_new @@ -1,6 +1,6 @@ #!/bin/sh -function help() +help() { echo "./configure_new [options] [-- ]" echo " -p Preselect a stanza configuration with matching description" From bc3a808773794cffa55fc1f6fcc267c0eb40203c Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 6 Sep 2023 14:28:21 -0600 Subject: [PATCH 128/180] Remove non-existent fortran module dirs --- CMakeLists.txt | 3 --- external/io_grib1/MEL_grib1/CMakeLists.txt | 7 ------- external/io_grib1/WGRIB/CMakeLists.txt | 7 ------- external/io_grib1/grib1_util/CMakeLists.txt | 7 ------- 4 files changed, 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 799735673e..8ae882a3f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -616,9 +616,6 @@ target_include_directories( $ $ $ - $ - $ - $ $ $ diff --git a/external/io_grib1/MEL_grib1/CMakeLists.txt b/external/io_grib1/MEL_grib1/CMakeLists.txt index e71916daea..b275211c69 100644 --- a/external/io_grib1/MEL_grib1/CMakeLists.txt +++ b/external/io_grib1/MEL_grib1/CMakeLists.txt @@ -47,13 +47,6 @@ target_sources( set_bytes.c ) -set_target_properties( - ${FOLDER_COMPILE_TARGET} - PROPERTIES - Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} - EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY - ) - target_link_libraries( ${FOLDER_COMPILE_TARGET} PRIVATE diff --git a/external/io_grib1/WGRIB/CMakeLists.txt b/external/io_grib1/WGRIB/CMakeLists.txt index 9003a6c8b3..03f53648ff 100644 --- a/external/io_grib1/WGRIB/CMakeLists.txt +++ b/external/io_grib1/WGRIB/CMakeLists.txt @@ -50,13 +50,6 @@ target_sources( nceptab_131.c ) -set_target_properties( - ${FOLDER_COMPILE_TARGET} - PROPERTIES - Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} - EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY - ) - target_link_libraries( ${FOLDER_COMPILE_TARGET} PRIVATE diff --git a/external/io_grib1/grib1_util/CMakeLists.txt b/external/io_grib1/grib1_util/CMakeLists.txt index ad995d3c03..c480ff8f87 100644 --- a/external/io_grib1/grib1_util/CMakeLists.txt +++ b/external/io_grib1/grib1_util/CMakeLists.txt @@ -15,13 +15,6 @@ target_sources( write_grib.c ) -set_target_properties( - ${FOLDER_COMPILE_TARGET} - PROPERTIES - Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} - EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY - ) - target_link_libraries( ${FOLDER_COMPILE_TARGET} PRIVATE From 50797201b0a33ef29c5a8702cb084425cd4f77cb Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 6 Sep 2023 14:30:29 -0600 Subject: [PATCH 129/180] Fixing fseek tests --- confcheck/CMakeLists.txt | 4 ++-- tools/fseek_test.c | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/confcheck/CMakeLists.txt b/confcheck/CMakeLists.txt index 2f896dc8b7..152aeeaa3a 100644 --- a/confcheck/CMakeLists.txt +++ b/confcheck/CMakeLists.txt @@ -49,7 +49,7 @@ wrf_conf_check( RESULT_VAR FSEEKO64 SOURCE ${PROJECT_SOURCE_DIR}/tools/fseek_test.c EXTENSION .c - ADDITIONAL_DEFINITIONS -DTEST_FSEEKO64 + ADDITIONAL_DEFINITIONS -DTEST_FSEEKO64 -DFILE_TO_TEST="${PROJECT_SOURCE_DIR}/CMakeLists.txt" MESSAGE "fseeko64 not supported, checking alternate fseeko" ) @@ -60,7 +60,7 @@ if ( NOT "${FSEEKO64}" ) RESULT_VAR FSEEKO SOURCE ${PROJECT_SOURCE_DIR}/tools/fseek_test.c EXTENSION .c - ADDITIONAL_DEFINITIONS -DTEST_FSEEKO + ADDITIONAL_DEFINITIONS -DTEST_FSEEKO -DFILE_TO_TEST="${PROJECT_SOURCE_DIR}/CMakeLists.txt" MESSAGE "fseeko not supported, compiling with fseek (caution with large files)" ) endif() diff --git a/tools/fseek_test.c b/tools/fseek_test.c index edd25c6035..c1bee099b5 100644 --- a/tools/fseek_test.c +++ b/tools/fseek_test.c @@ -1,4 +1,7 @@ #define _FILE_OFFSET_BITS 64 +#ifndef FILE_TO_TEST +#define FILE_TO_TEST "Makefile" +#endif #include #include #include @@ -18,7 +21,7 @@ main() int result2 ; #endif fp = NULL ; - fp = fopen( "Makefile" , "r" ) ; + fp = fopen( FILE_TO_TEST , "r" ) ; #ifdef TEST_FSEEKO x = 0xffffffff ; result1 = (sizeof(x) == 8) ; From a4c5ccea7224fcca5bac38f4e87dbe896b90b4fb Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 6 Sep 2023 14:30:47 -0600 Subject: [PATCH 130/180] Fixing bad syntax --- dyn_em/module_big_step_utilities_em.F | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dyn_em/module_big_step_utilities_em.F b/dyn_em/module_big_step_utilities_em.F index 50d7972c62..d8c26e809b 100644 --- a/dyn_em/module_big_step_utilities_em.F +++ b/dyn_em/module_big_step_utilities_em.F @@ -5733,11 +5733,11 @@ SUBROUTINE moist_physics_finish_em( t_new, t_old, t0, mut, & ! 300 ! term 4 ! IF ( ( config_flags%use_theta_m .EQ. 1 ) .AND. (P_Qv .GE. PARAM_FIRST_SCALAR) ) THEN - t_new(i,k,j) = h_diabatic(i,k,j)*(1. + (R_v/R_d)*qv_diabatic(i,k,j)) + \ - mpten*(1. + (R_v/R_d)*qv(i,k,j)) + \ + t_new(i,k,j) = h_diabatic(i,k,j)*(1. + (R_v/R_d)*qv_diabatic(i,k,j)) + & + mpten*(1. + (R_v/R_d)*qv(i,k,j)) + & (R_v/R_d)*qvten*th_phy(i,k,j) - T0 th_phy_m_t0(i,k,j) = (t_new(i,k,j)+T0)/(1.+(R_v/R_d)*qv(i,k,j)) - T0 - h_diabatic(i,k,j) = ( mpten*(1. + (R_v/R_d)*qv(i,k,j)) + \ + h_diabatic(i,k,j) = ( mpten*(1. + (R_v/R_d)*qv(i,k,j)) + & (R_v/R_d)*qvten*th_phy(i,k,j) ) / dt ELSE t_new(i,k,j) = t_new(i,k,j) + mpten From 8e19a345c403212c6c8c847d5d6de2436ba893ca Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 6 Sep 2023 14:33:37 -0600 Subject: [PATCH 131/180] IPO control and per-file optimization set --- CMakeLists.txt | 151 +++++++++++++++++++++++++++++-------------- frame/CMakeLists.txt | 8 +++ main/CMakeLists.txt | 35 +++++++++- 3 files changed, 146 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ae882a3f8..0473a172da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,7 @@ set( CMAKE_Fortran_PREPROCESS ON ) list( APPEND CMAKE_C_PREPROCESSOR_FLAGS -P -nostdinc ) include( CMakePackageConfigHelpers ) +include( CheckIPOSupported ) include( c_preproc ) include( m4_preproc ) include( target_copy ) @@ -34,6 +35,8 @@ include( printOption ) include( wrf_case_setup ) include( wrf_get_version ) +check_ipo_supported( RESULT IPO_SUPPORT ) + # First grab git info wrf_git_commit( RESULT_VAR GIT_VERSION @@ -61,6 +64,7 @@ set( OPTIMIZATION_LEVEL "" ) set( WRF_OS "" ) set( WRF_MACH "" ) +set( CMAKE_BUILD_TYPE Release CACHE STRING "Build Type" ) ################################################################################ ## WRF Core selection @@ -135,6 +139,7 @@ endif() set( USE_DOUBLE OFF CACHE BOOL "USE_DOUBLE" ) set( USE_MPI OFF CACHE BOOL "USE_MPI" ) set( USE_OPENMP OFF CACHE BOOL "USE_OPENMP" ) +set( USE_IPO OFF CACHE BOOL "USE_IPO" ) set( ENABLE_CHEM OFF CACHE BOOL "ENABLE_CHEM" ) @@ -175,7 +180,7 @@ set( NETCDF ON ) # Special internal flag for profiling compilation -set( PROFILE_COMPILATION OFF ) +set( PROFILE_COMPILATION OFF CACHE BOOL "PROFILE_COMPILATION" ) # From arch/preamble @@ -281,49 +286,15 @@ endif() math( EXPR RWORDSIZE_B "8 * ${RWORDSIZE}" ) -# 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 - ) + +# Check if IPO usage +if ( ${USE_IPO} ) + if ( NOT ${IPO_SUPPORT} ) + message( STATUS "IPO/LTO not supported, request ignored" ) + set( USE_IPO OFF CACHE BOOL "Required by configuration" FORCE ) + endif() +endif() +set( CMAKE_INTERPROCEDURAL_OPTIMIZATION ${USE_IPO} ) ################################################################################ ## @@ -336,8 +307,9 @@ if ( DEFINED CMAKE_TOOLCHAIN_FILE ) print_option( WRF_CONFIG 20 ${BOLD_CYAN} ) endif() - print_option( CMAKE_BUILD_TYPE 20 ${BOLD_CYAN} ) + + print_option( WRF_CORE 20 ${BOLD_CYAN} ) print_option( WRF_NESTING 20 ${BOLD_CYAN} ) print_option( WRF_CASE 20 ${BOLD_CYAN} ) @@ -346,7 +318,7 @@ print_option( WRF_CASE 20 ${BOLD_CYAN} ) print_option( USE_DOUBLE 20 ) print_option( USE_MPI 20 ) print_option( USE_OPENMP 20 ) - +print_option( USE_IPO 20 ) print_option( ENABLE_CHEM 20 ) print_option( ENABLE_CMAQ 20 ) @@ -480,8 +452,92 @@ add_subdirectory( confcheck ) ## Adjust flags based on compiler and linker used ## ################################################################################ + +# 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}> + ) +# else() +# # Assume no optimization +# set_directory_properties( +# PROPERTIES +# COMPILE_FLAGS +# $<$:${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 +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 + ) + + # https://stackoverflow.com/a/53155812 -set( Fortran_COMPILER_ID ${CMAKE_Fortran_COMPILER_ID} ) +# set( Fortran_COMPILER_ID ${CMAKE_Fortran_COMPILER_ID} ) # message( STATUS "Set Fortran_COMPILER_ID to : ${Fortran_COMPILER_ID}" ) @@ -498,6 +554,7 @@ add_compile_options( ) if ( ${PROFILE_COMPILATION} ) + message( STATUS "Attemping to add compilation profiling..." ) add_compile_options( $<$:-ftime-report> ) diff --git a/frame/CMakeLists.txt b/frame/CMakeLists.txt index 4ae687d39f..0af7f9bb8a 100644 --- a/frame/CMakeLists.txt +++ b/frame/CMakeLists.txt @@ -154,6 +154,14 @@ target_sources( wrf_shutdown.F ) +# Disable optimizations on these files always +set_source_files_properties( + ${nl_dyn_source} + PROPERTIES + COMPILE_FLAGS + $<$:${WRF_FCNOOPT}> + ) + install( FILES ${WRF_INCLUDE_FILES} DESTINATION include/${FOLDER_COMPILE_TARGET} diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 84886c0894..bb553a7d31 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -76,11 +76,44 @@ foreach ( TARGET ${FOLDER_COMPILE_TARGETS} ) Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/modules/${TARGET}/ Fortran_FORMAT FREE ) - target_link_libraries( + + + if ( ${USE_IPO} ) + set_target_properties( + ${TARGET} + PROPERTIES + INTERPROCEDURAL_OPTIMIZATION TRUE + ) + + if ( ${CMAKE_VERSION} VERSION_LESS 3.24 ) + target_link_libraries( ${TARGET} PRIVATE ${PROJECT_NAME}_Core ) + + # Static libraries with LTO/IPO sometimes don't pull all the correct symbols + set( LINKER_OPTION ${CMAKE_Fortran_LINKER_WRAPPER_FLAG} ) + target_link_options( + ${TARGET} + PRIVATE + ${LINKER_OPTION}--whole-archive $ ${LINKER_OPTION}--no-whole-archive + ) + else() + target_link_libraries( + ${TARGET} + PRIVATE + $ + ) + endif() + else() + target_link_libraries( + ${TARGET} + PRIVATE + ${PROJECT_NAME}_Core + ) + endif() + target_include_directories( ${TARGET} PRIVATE From df258c2dee276d83101f2133ba21a179c8078b0f Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 29 Sep 2023 15:19:13 -0700 Subject: [PATCH 132/180] Wrapping build type in quotes for when not set --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0473a172da..90062e0c18 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,8 +64,10 @@ set( OPTIMIZATION_LEVEL "" ) set( WRF_OS "" ) set( WRF_MACH "" ) -set( CMAKE_BUILD_TYPE Release CACHE STRING "Build Type" ) - +if ( "${CMAKE_BUILD_TYPE}" STREQUAL "" ) + set( CMAKE_BUILD_TYPE Debug ) + message( STATUS "Set default build type to ${CMAKE_BUILD_TYPE}" ) +endif() ################################################################################ ## WRF Core selection ################################################################################ From 2b8dc1b3f9cbdbcac256c77796f6398f34c5ca44 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 29 Sep 2023 15:22:17 -0700 Subject: [PATCH 133/180] Fixing missing symbols due to MPI wrapper forcing IPO usage even when set to OFF --- CMakeLists.txt | 135 ++++++++++++++++++++++++++++++------------------- 1 file changed, 83 insertions(+), 52 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 90062e0c18..de8156aefd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -296,57 +296,6 @@ if ( ${USE_IPO} ) set( USE_IPO OFF CACHE BOOL "Required by configuration" FORCE ) endif() endif() -set( CMAKE_INTERPROCEDURAL_OPTIMIZATION ${USE_IPO} ) - -################################################################################ -## -## Print out final set of options to be used -## DO NOT MODIFY OPTIONS BEYOND THIS POINT -## -################################################################################ - -if ( DEFINED CMAKE_TOOLCHAIN_FILE ) - print_option( WRF_CONFIG 20 ${BOLD_CYAN} ) -endif() - -print_option( CMAKE_BUILD_TYPE 20 ${BOLD_CYAN} ) - - -print_option( WRF_CORE 20 ${BOLD_CYAN} ) -print_option( WRF_NESTING 20 ${BOLD_CYAN} ) -print_option( WRF_CASE 20 ${BOLD_CYAN} ) - - -print_option( USE_DOUBLE 20 ) -print_option( USE_MPI 20 ) -print_option( USE_OPENMP 20 ) -print_option( USE_IPO 20 ) - -print_option( ENABLE_CHEM 20 ) -print_option( ENABLE_CMAQ 20 ) -print_option( ENABLE_KPP 20 ) -print_option( ENABLE_DFI_RADAR 20 ) -print_option( ENABLE_TITAN 20 ) -print_option( ENABLE_MARS 20 ) -print_option( ENABLE_VENUS 20 ) -print_option( ENABLE_VENUS 20 ) -print_option( ENABLE_TERRAIN 20 ) -print_option( ENABLE_CLM 20 ) - -print_option( USE_ALLOCATABLES 20 ) -print_option( wrfmodel 20 ) -print_option( GRIB1 20 ) -print_option( INTIO 20 ) -print_option( KEEP_INT_AROUND 20 ) -print_option( LIMIT_ARGS 20 ) - -print_option( FORCE_NETCDF_CLASSIC 20 ) -print_option( BUILD_RRTMG_FAST 20 ) -print_option( BUILD_RRTMK 20 ) -print_option( BUILD_SBM_FAST 20 ) -print_option( SHOW_ALL_VARS_USED 20 ) - -print_option( WRFIO_NCD_NO_LARGE_FILE_SUPPORT 36 ) ################################################################################ ## @@ -381,6 +330,31 @@ if ( ${USE_MPI} ) $<$:${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 + # https://www.open-mpi.org/faq/?category=mpi-apps#why-no-rpath LOL! + # Quote "The default installation of Open MPI tries very hard to not include any non-essential flags in the wrapper compilers" + # Okay, yea sure. Maybe it's the distro's lib config that does add all the bloatware flags + if ( NOT ${USE_IPO} ) + # get compile info + message( STATUS "Checking if MPI requires IPO" ) + foreach( IPO_FLAG IN LISTS CMAKE_Fortran_COMPILE_OPTIONS_IPO ) + string( FIND "${MPI_Fortran_COMPILE_OPTIONS}" ${IPO_FLAG} MPI_FORCE_IPO ) + # Note we are not using IN_LIST since certain IPO settings might not exactly match (e.g. -flto vs -flto=auto) + if ( NOT ${MPI_FORCE_IPO} EQUAL -1 ) + # An IPO flag was found + if ( ${IPO_SUPPORT} ) + message( STATUS "NOTE: ${MPI_Fortran_COMPILER} requires IPO flags be enabled, forcing USE_IPO=ON" ) + set( USE_IPO ON CACHE BOOL "Required by MPI" FORCE ) + break() + else() + message( FATAL_ERROR "${MPI_Fortran_COMPILER} requires IPO support but selected compiler does not support it, would fail to link" ) + endif() + endif() + endforeach() + endif() + + 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( @@ -442,6 +416,63 @@ set( ZLIB_ROOT ${netCDF_PREFIX} ) find_package( ZLIB REQUIRED ) find_package( CURL REQUIRED ) +################################################################################ +## +## Print out final set of options to be used +## DO NOT MODIFY OPTIONS BEYOND THIS POINT +## +################################################################################ + +if ( DEFINED CMAKE_TOOLCHAIN_FILE ) + print_option( WRF_CONFIG 20 ${BOLD_CYAN} ) +endif() + +print_option( CMAKE_BUILD_TYPE 20 ${BOLD_CYAN} ) + + +print_option( WRF_CORE 20 ${BOLD_CYAN} ) +print_option( WRF_NESTING 20 ${BOLD_CYAN} ) +print_option( WRF_CASE 20 ${BOLD_CYAN} ) + + +print_option( USE_DOUBLE 20 ) +print_option( USE_MPI 20 ) +print_option( USE_OPENMP 20 ) +print_option( USE_IPO 20 ) + +print_option( ENABLE_CHEM 20 ) +print_option( ENABLE_CMAQ 20 ) +print_option( ENABLE_KPP 20 ) +print_option( ENABLE_DFI_RADAR 20 ) +print_option( ENABLE_TITAN 20 ) +print_option( ENABLE_MARS 20 ) +print_option( ENABLE_VENUS 20 ) +print_option( ENABLE_VENUS 20 ) +print_option( ENABLE_TERRAIN 20 ) +print_option( ENABLE_CLM 20 ) + +print_option( USE_ALLOCATABLES 20 ) +print_option( wrfmodel 20 ) +print_option( GRIB1 20 ) +print_option( INTIO 20 ) +print_option( KEEP_INT_AROUND 20 ) +print_option( LIMIT_ARGS 20 ) + +print_option( FORCE_NETCDF_CLASSIC 20 ) +print_option( BUILD_RRTMG_FAST 20 ) +print_option( BUILD_RRTMK 20 ) +print_option( BUILD_SBM_FAST 20 ) +print_option( SHOW_ALL_VARS_USED 20 ) + +print_option( WRFIO_NCD_NO_LARGE_FILE_SUPPORT 36 ) + +################################################################################ +## +## Set any global cmake options decided by particular configuration +## +################################################################################ +set( CMAKE_INTERPROCEDURAL_OPTIMIZATION ${USE_IPO} ) + ################################################################################ ## ## Configuration checks for features & intrinsices @@ -474,7 +505,7 @@ define_property( ) # Get current build type flags and put them in there -if ( ${CMAKE_BUILD_TYPE} STREQUAL "Release" ) +if ( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) set_directory_properties( PROPERTIES COMPILE_FLAGS From 9d473f020b3d1fae28b6bac07edb7eb17b949e8a Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 29 Sep 2023 15:23:23 -0700 Subject: [PATCH 134/180] Finally deducing the true nature of nesting logic requiring stubbed mpi but using rsllite --- CMakeLists.txt | 3 +++ external/CMakeLists.txt | 2 +- frame/CMakeLists.txt | 3 ++- tools/CMakeLists.txt | 3 ++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index de8156aefd..93717d67f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -306,6 +306,8 @@ endif() # we must stub its usage list( FIND WRF_NESTING_OPTIONS ${WRF_NESTING} CURRENT_NESTING_IDX ) +# If MPI or nesting +set( USE_RSL_LITE OFF ) if ( ${USE_MPI} ) # Through ***MUCH*** debugging, if utilizing MPI__COMPILER # https://cmake.org/cmake/help/latest/module/FindMPI.html#variables-for-locating-mpi @@ -361,6 +363,7 @@ elseif( ${CURRENT_NESTING_IDX} GREATER 0 ) DM_PARALLEL STUBMPI ) + set( USE_RSL_LITE ON ) endif() if ( ${USE_OPENMP} ) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index cbf5c70463..8c4596a7eb 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -77,7 +77,7 @@ if ( ${Jasper_FOUND} ) add_subdirectory( io_grib2 ) endif() -if ( ${USE_MPI} ) +if ( ${USE_RSL_LITE} ) add_subdirectory( RSL_LITE ) endif() diff --git a/frame/CMakeLists.txt b/frame/CMakeLists.txt index 0af7f9bb8a..59f8d2551b 100644 --- a/frame/CMakeLists.txt +++ b/frame/CMakeLists.txt @@ -85,7 +85,8 @@ target_include_directories( # ######################################################################################################################## set( MODULE_DM module_dm_stubs.F ) -if ( ${USE_MPI} ) +if ( ${USE_RSL_LITE} ) + message( STATUS "Setting module_dm to RSL_LITE" ) set( MODULE_DM ${PROJECT_SOURCE_DIR}/external/RSL_LITE/module_dm.F ) endif() diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 46909f59dc..1181ab0af4 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -8,7 +8,8 @@ add_executable( ) set( GEN_COMMS gen_comms.stub ) -if ( ${USE_MPI} ) +if ( ${USE_RSL_LITE} ) + message( STATUS "Setting gen_comms to RSL_LITE" ) set( GEN_COMMS ${PROJECT_SOURCE_DIR}/external/RSL_LITE/gen_comms.c ) else() # Account for the weird makefile nonsense of copying things around From 0439324d96157ebfdeebfa9ca6441abc69715842 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 28 Dec 2023 12:11:32 -0700 Subject: [PATCH 135/180] Allow control of build and install directories --- cleanCMake.sh | 70 ++++++++++++++++++++++++++++----------------------- compile_new | 9 +++++-- configure_new | 30 ++++++++++++++++------ 3 files changed, 69 insertions(+), 40 deletions(-) diff --git a/cleanCMake.sh b/cleanCMake.sh index a392d75143..f372dae0ed 100755 --- a/cleanCMake.sh +++ b/cleanCMake.sh @@ -1,40 +1,48 @@ #!/bin/sh -BUILD_DIR=_build -INSTALL_DIR=runTemp -TEST_DIR=test/ +buildDirectory=_build +installDirectory=install help() { echo "./cleanCMake.sh [options]" - echo " -c Basic cmake clean functionality [cmake --build ${BUILD_DIR} -j 1 --target clean]" - echo " -i Remove cmake binary installs [xargs rm < ${BUILD_DIR}/install_manifest.txt]" - echo " -l Remove symlinks (WRF) [ find ${TEST_DIR} -type l -exec rm {} \; ]" - echo " -f Remove build & install folders (WRF) [ rm ${BUILD_DIR} -r; rm ${INSTALL_DIR}/ -r ]" - echo " -a Remove all (WRF), equivalent to -f -l (more specifically -b -i -l -f)" + echo " -c Basic cmake clean functionality [cmake --build ${buildDirectory} -j 1 --target clean]" + echo " -b Remove cmake binary installs [xargs rm < ${buildDirectory}/install_manifest.txt]" + echo " -l Remove symlinks (WRF) [ find ${installDirectory}/test -type l -exec rm {} \; ]" + echo " -f Remove build & install folders (WRF) [ rm ${buildDirectory} -r; rm ${installDirectory}/ -r ]" + echo " -a Remove all (WRF), equivalent to -f -l (more specifically -b -l -f)" + echo "Specific builds/installs" + echo " -d directory Specify operating on particular build directory" + echo " -i directory Specify operating on particular install directory" } -CLEAN_BASIC_BUILD=FALSE -CLEAN_BASIC_INSTALL=FALSE -CLEAN_LINKS=FALSE -CLEAN_FOLDERS=FALSE -CLEAN_ALL=FALSE +cleanBasicBuild=FALSE +cleanBasicInstall=FALSE +cleanLinks=FALSE +cleanFolders=FALSE +cleanAll=FALSE -while getopts "hcilfa" opt; do +while getopts "hcblfad:i:" opt; do case ${opt} in c) - CLEAN_BASIC_BUILD=TRUE + cleanBasicBuild=TRUE ;; - i) - CLEAN_BASIC_INSTALL=TRUE + b) + cleanBasicInstall=TRUE ;; l) - CLEAN_LINKS=TRUE + cleanLinks=TRUE ;; f) - CLEAN_FOLDERS=TRUE + cleanFolders=TRUE ;; a) - CLEAN_ALL=TRUE + cleanAll=TRUE + ;; + d) + buildDirectory=$OPTARG + ;; + i) + installDirectory=$OPTARG ;; h) help; exit 0 ;; *) help; exit 1 ;; @@ -45,26 +53,26 @@ done if [ $OPTIND -eq 1 ]; then # Do basic clean I guess - CLEAN_BASIC_BUILD=TRUE + cleanBasicBuild=TRUE fi -if [ "${CLEAN_BASIC_BUILD}" = "TRUE" ] || [ "${CLEAN_ALL}" = "TRUE" ]; then +if [ "${cleanBasicBuild}" = "TRUE" ] || [ "${cleanAll}" = "TRUE" ]; then echo "Doing cmake make clean" OLD_DIR=$PWD - cd ${BUILD_DIR} && make -j 1 clean; cd $OLD_DIR + cd ${buildDirectory} && make -j 1 clean; cd $OLD_DIR fi -if [ "${CLEAN_BASIC_INSTALL}" = "TRUE" ] || [ "${CLEAN_ALL}" = "TRUE" ]; then +if [ "${cleanBasicInstall}" = "TRUE" ] || [ "${cleanAll}" = "TRUE" ]; then echo "Removing binary installs" - xargs rm < ${BUILD_DIR}/install_manifest.txt + xargs rm < ${buildDirectory}/install_manifest.txt fi -if [ "${CLEAN_LINKS}" = "TRUE" ] || [ "${CLEAN_ALL}" = "TRUE" ]; then - echo "Removing all symlinks in ${TEST_DIR}" - find ${TEST_DIR} -type l -exec rm {} \; +if [ "${cleanLinks}" = "TRUE" ] || [ "${cleanAll}" = "TRUE" ]; then + echo "Removing all symlinks in ${installDirectory}/test" + find ${installDirectory}/test -type l -exec rm {} \; fi -if [ "${CLEAN_FOLDERS}" = "TRUE" ] || [ "${CLEAN_ALL}" = "TRUE" ]; then - echo "Deleting ${BUILD_DIR} & ${INSTALL_DIR}/" - rm ${BUILD_DIR} -r; rm ${INSTALL_DIR}/ -r +if [ "${cleanFolders}" = "TRUE" ] || [ "${cleanAll}" = "TRUE" ]; then + echo "Deleting ${buildDirectory} & ${installDirectory}/" + rm ${buildDirectory} -r; rm ${installDirectory}/ -r fi diff --git a/compile_new b/compile_new index 121f83537e..c9a8f99059 100755 --- a/compile_new +++ b/compile_new @@ -2,5 +2,10 @@ # Meant to be run at the top level # Now run cmake -cd _build && make install $* -# cmake --build _build --target install $* \ No newline at end of file +buildDirectory=$1 +if [ ! -f "$buildDirectory" ]; + buildDirectory=$PWD/install +else + shift +fi +cd $buildDirectory && make install $* \ No newline at end of file diff --git a/configure_new b/configure_new index 213ecc3a43..2fa6dce50e 100755 --- a/configure_new +++ b/configure_new @@ -5,6 +5,8 @@ help() echo "./configure_new [options] [-- ]" echo " -p Preselect a stanza configuration with matching description" echo " -x Skip CMake options prompt, meant to be used in conjunction with direct pass-in options" + echo " -d directory Use as alternate build directory" + echo " -i directory Use as alternate install directory" echo " -- Directly pass CMake options to configuration, equivalent to cmake " echo " -h Print this message" @@ -12,7 +14,7 @@ help() preselect= skipCMake=false -while getopts p:xh opt; do +while getopts p:xd:i:h opt; do case $opt in p) preselect=$OPTARG @@ -20,6 +22,12 @@ while getopts p:xh opt; do x) skipCMake=true ;; + d) + buildDirectory=$OPTARG + ;; + i) + installDirectory=$OPTARG + ;; h) help; exit 0 ;; *) help; exit 1 ;; :) help; exit 1 ;; @@ -36,6 +44,16 @@ else extraOps="-s CMakeLists.txt" fi +if [ -z "$buildDirectory" ]; then + buildDirectory=_build + echo "Using default build directory : $buildDirectory" +fi +if [ -z "$installDirectory" ]; then + installDirectory=$PWD/install + echo "Using default install directory : $installDirectory" +fi + +mkdir -p $buildDirectory if [ ! -z "$preselect" ]; then echo "Using preselected config ${preselect}" @@ -43,14 +61,14 @@ if [ ! -z "$preselect" ]; then ./arch/configure_reader.py \ -c arch/configure.defaults \ -t cmake/template/arch_config.cmake \ - -o wrf_config.cmake \ + -o $buildDirectory/wrf_config.cmake \ ${extraOps} -p "${preselect}" else # Meant to be run at the top level ./arch/configure_reader.py \ -c arch/configure.defaults \ -t cmake/template/arch_config.cmake \ - -o wrf_config.cmake \ + -o $buildDirectory/wrf_config.cmake \ ${extraOps} fi @@ -58,8 +76,6 @@ configureStanza=$? if [ $configureStanza -eq 0 ]; then # Now run cmake - mkdir -p _build/ - cd _build - cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/../runTemp -DCMAKE_TOOLCHAIN_FILE=$PWD/../wrf_config.cmake $* - # cmake -S . -B _build + cd $buildDirectory + cmake .. -DCMAKE_INSTALL_PREFIX=$installDirectory -DCMAKE_TOOLCHAIN_FILE=$buildDirectory/wrf_config.cmake $* fi \ No newline at end of file From 2958e9c1af7d97a386ba3a64e22da619c0a120e4 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 28 Dec 2023 12:12:41 -0700 Subject: [PATCH 136/180] Split netCDF and netCDF-Fortran finding into two separate modules --- cmake/modules/FindnetCDF-Fortran.cmake | 71 ++++++++++++++++++++++++++ cmake/modules/FindnetCDF.cmake | 25 ++++----- 2 files changed, 82 insertions(+), 14 deletions(-) create mode 100644 cmake/modules/FindnetCDF-Fortran.cmake diff --git a/cmake/modules/FindnetCDF-Fortran.cmake b/cmake/modules/FindnetCDF-Fortran.cmake new file mode 100644 index 0000000000..a20f5b1af0 --- /dev/null +++ b/cmake/modules/FindnetCDF-Fortran.cmake @@ -0,0 +1,71 @@ +# Find netcdf +# Eventually replace with netCDF-Fortran's actual config if using that +# Once found this file will define: +# netCDF-Fortran_FOUND - System has netcdf +# netCDF-Fortran_INCLUDE_DIRS - The netcdf include directories +# netCDF-Fortran_LIBRARIES - The libraries needed to use netcdf +# netCDF-Fortran_DEFINITIONS - Compiler switches required for using netcdf + +# list( REMOVE_ITEM CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} ) +# find_package( netCDF-Fortran ) +# list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} ) + +# Use nc-config +find_program( + NETCDF-FORTRAN_PROGRAM + nf-config + QUIET + ) + +if ( ${NETCDF-FORTRAN_PROGRAM} MATCHES "-NOTFOUND$" ) + message( STATUS "No nf-config found" ) +else() + message( STATUS "Found NETCDF-FORTRAN_PROGRAM : ${NETCDF-FORTRAN_PROGRAM}" ) + + execute_process( COMMAND ${NETCDF-FORTRAN_PROGRAM} --includedir OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF-Fortran_INCLUDE_DIR ) + execute_process( COMMAND ${NETCDF-FORTRAN_PROGRAM} --prefix OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF-Fortran_PREFIX ) + execute_process( COMMAND ${NETCDF-FORTRAN_PROGRAM} --flibs OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF-Fortran_FLIBS ) + execute_process( COMMAND ${NETCDF-FORTRAN_PROGRAM} --version OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF-Fortran_VERSION_RAW ) + execute_process( COMMAND ${NETCDF-FORTRAN_PROGRAM} --has-nc4 OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF-Fortran_NC4_YES ) + + # check for large file support + find_file( netCDF-Fortran_INCLUDE_FILE netcdf.inc ${netCDF-Fortran_INCLUDE_DIR} ) + file( READ ${netCDF-Fortran_INCLUDE_FILE} netCDF-Fortran_INCLUDE_FILE_STR ) + string( FIND "${netCDF-Fortran_INCLUDE_FILE_STR}" "nf_format_64bit_data" netCDF-Fortran_LARGE_FILE_SUPPORT_FOUND ) + if ( ${netCDF-Fortran_LARGE_FILE_SUPPORT_FOUND} EQUAL -1 ) + set( netCDF-Fortran_LARGE_FILE_SUPPORT "NO" ) + else() + set( netCDF-Fortran_LARGE_FILE_SUPPORT "YES" ) + endif() + + # Sanitize version + string( REPLACE " " ";" netCDF-Fortran_VERSION_LIST ${netCDF-Fortran_VERSION_RAW} ) + list( GET netCDF-Fortran_VERSION_LIST -1 netCDF-Fortran_VERSION ) + + # Convert to YES/NO - Note cannot be generator expression if you want to use it during configuration time + string( TOUPPER ${netCDF-Fortran_NC4_YES} netCDF-Fortran_NC4 ) + + set( netCDF-Fortran_DEFINITIONS ) + + set( netCDF-Fortran_LIBRARIES + $<$:${netCDF-Fortran_FLIBS}> + ) + + # Because we may need this for in-situ manual preprocessing do not use genex + set( netCDF-Fortran_INCLUDE_DIRS ${netCDF-Fortran_INCLUDE_DIR} ) +endif() + +find_package( PkgConfig ) + +include(FindPackageHandleStandardArgs) + +# handle the QUIETLY and REQUIRED arguments and set netCDF-Fortran_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args( + netCDF-Fortran DEFAULT_MSG + netCDF-Fortran_INCLUDE_DIRS + netCDF-Fortran_FLIBS + netCDF-Fortran_VERSION + ) + +mark_as_advanced( netCDF-Fortran_FLIBS netCDF-Fortran_PREFIX ) \ No newline at end of file diff --git a/cmake/modules/FindnetCDF.cmake b/cmake/modules/FindnetCDF.cmake index 6768e2aaec..90d4dc01da 100644 --- a/cmake/modules/FindnetCDF.cmake +++ b/cmake/modules/FindnetCDF.cmake @@ -26,17 +26,15 @@ else() execute_process( COMMAND ${NETCDF_PROGRAM} --libdir OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_LIBRARY_DIR ) execute_process( COMMAND ${NETCDF_PROGRAM} --prefix OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_PREFIX ) execute_process( COMMAND ${NETCDF_PROGRAM} --libs OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_CLIBS ) - execute_process( COMMAND ${NETCDF_PROGRAM} --cxx4libs OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_CXXLIBS ) - execute_process( COMMAND ${NETCDF_PROGRAM} --flibs OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_FLIBS ) execute_process( COMMAND ${NETCDF_PROGRAM} --version OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_VERSION_RAW ) execute_process( COMMAND ${NETCDF_PROGRAM} --has-nc4 OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_NC4_YES ) execute_process( COMMAND ${NETCDF_PROGRAM} --has-pnetcdf OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_PNETCDF_YES ) execute_process( COMMAND ${NETCDF_PROGRAM} --has-parallel OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE netCDF_PARALLEL_YES ) # check for large file support - find_file( netCDF_INCLUDE_FILE netcdf.inc ${netCDF_INCLUDE_DIR} ) + find_file( netCDF_INCLUDE_FILE netcdf.h ${netCDF_INCLUDE_DIR} ) file( READ ${netCDF_INCLUDE_FILE} netCDF_INCLUDE_FILE_STR ) - string( FIND "${netCDF_INCLUDE_FILE_STR}" "nf_format_64bit" netCDF_LARGE_FILE_SUPPORT_FOUND ) + string( FIND "${netCDF_INCLUDE_FILE_STR}" "NC_FORMAT_64BIT_DATA" netCDF_LARGE_FILE_SUPPORT_FOUND ) if ( ${netCDF_LARGE_FILE_SUPPORT_FOUND} EQUAL -1 ) set( netCDF_LARGE_FILE_SUPPORT "NO" ) else() @@ -55,10 +53,11 @@ else() set( netCDF_DEFINITIONS ) set( netCDF_LIBRARIES - $<$:${netCDF_CLIBS}> - $<$:${netCDF_CXXLIBS}> - $<$:${netCDF_FLIBS}> + # All supported language variants will need this regardless - this may conflict with the RPATH in any + # supplemental packages so be careful to use compatible langauge versions of netCDF + $<$,$>:${netCDF_CLIBS}> ) + # Because we may need this for in-situ manual preprocessing do not use genex set( netCDF_INCLUDE_DIRS ${netCDF_INCLUDE_DIR} ) endif() @@ -69,12 +68,10 @@ include(FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set netCDF_FOUND to TRUE # if all listed variables are TRUE find_package_handle_standard_args( netCDF DEFAULT_MSG - netCDF_INCLUDE_DIRS - netCDF_LIBRARY_DIR - netCDF_CLIBS - # netCDF_CXXLIBS - netCDF_FLIBS - netCDF_VERSION + netCDF_INCLUDE_DIRS + netCDF_LIBRARY_DIR + netCDF_CLIBS + netCDF_VERSION ) -mark_as_advanced( netCDF_CLIBS netCDF_CXXLIBS netCDF_FLIBS netCDF_PREFIX netCDF_LIBRARY_DIR ) \ No newline at end of file +mark_as_advanced( netCDF_CLIBS netCDF_PREFIX netCDF_LIBRARY_DIR ) \ No newline at end of file From 59fad1429559ab62bbfec1404f3bf76c1ad22fac Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 28 Dec 2023 12:14:09 -0700 Subject: [PATCH 137/180] Adjust to split netCDF packages --- CMakeLists.txt | 15 ++++++++++----- external/io_netcdf/CMakeLists.txt | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93717d67f9..1ada7cf3c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -405,11 +405,14 @@ endif() # find_package( GPFS REQUIRED ) # Included is a lightweight finder, but we really should switch to using UniData's netCDF cmake config -find_package( netCDF REQUIRED ) +# The reason these are two separate and not COMPONENTS of one larger package is because that is the way UniData +# has laid out the cmake configs for each respective package +find_package( netCDF REQUIRED ) +find_package( netCDF-Fortran REQUIRED ) # Make use of version checking here and not in find_package for previous versions that did not use cmake -if ( NOT netCDF_VERSION GREATER_EQUAL "4.1.3" ) - message( FATAL "Please make sure NETCDF version is 4.1.3 or later. " ) +if ( ( NOT netCDF_VERSION GREATER_EQUAL "4.1.3" ) OR ( NOT netCDF-Fortran_VERSION GREATER_EQUAL "4.1.3" ) ) + message( FATAL "Please make sure NETCDF versions are 4.1.3 or later. " ) endif() find_package( pnetCDF QUIET ) @@ -752,6 +755,7 @@ target_include_directories( # Found Packages not handled through :: imported target ${netCDF_INCLUDE_DIRS} + ${netCDF-Fortran_INCLUDE_DIRS} ${pnetCDF_INCLUDE_DIRS} ) @@ -790,18 +794,19 @@ set_target_properties( ) target_link_libraries( ${PROJECT_NAME}_Core - PRIVATE + PUBLIC ${netCDF_LIBRARIES} + ${netCDF-Fortran_LIBRARIES} ${pnetCDF_LIBRARIES} $<$:$> $<$:$> - # This will add in target dependencies if they exist $ $ $ $ $ + PRIVATE # "External" io libs diff --git a/external/io_netcdf/CMakeLists.txt b/external/io_netcdf/CMakeLists.txt index d000427d7c..17d419e689 100644 --- a/external/io_netcdf/CMakeLists.txt +++ b/external/io_netcdf/CMakeLists.txt @@ -27,6 +27,7 @@ target_link_libraries( ${FOLDER_COMPILE_TARGET} target_include_directories( ${FOLDER_COMPILE_TARGET} PRIVATE ${netCDF_INCLUDE_DIRS} + ${netCDF-Fortran_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET} From ba79d5f250215fd6dc2861c4b77eeaf000d9bc47 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 2 Jan 2024 12:29:03 -0700 Subject: [PATCH 138/180] Adding library path to package finds to allow rpath automated generation to work --- cmake/modules/FindnetCDF-Fortran.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/modules/FindnetCDF-Fortran.cmake b/cmake/modules/FindnetCDF-Fortran.cmake index a20f5b1af0..baa05fbe9b 100644 --- a/cmake/modules/FindnetCDF-Fortran.cmake +++ b/cmake/modules/FindnetCDF-Fortran.cmake @@ -46,6 +46,7 @@ else() string( TOUPPER ${netCDF-Fortran_NC4_YES} netCDF-Fortran_NC4 ) set( netCDF-Fortran_DEFINITIONS ) + set( netCDF-Fortran_LIBRARY_DIR ${netCDF-Fortran_PREFIX}/lib ) set( netCDF-Fortran_LIBRARIES $<$:${netCDF-Fortran_FLIBS}> @@ -68,4 +69,4 @@ find_package_handle_standard_args( netCDF-Fortran_VERSION ) -mark_as_advanced( netCDF-Fortran_FLIBS netCDF-Fortran_PREFIX ) \ No newline at end of file +mark_as_advanced( netCDF-Fortran_FLIBS netCDF-Fortran_PREFIX netCDF-Fortran_LIBRARY_DIR ) \ No newline at end of file From f65b612c4e7bef4ccd08cb5e1f6d695aa54de204 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 2 Jan 2024 12:30:27 -0700 Subject: [PATCH 139/180] Full support for out-of-source build and installs --- CMakeLists.txt | 9 +++++ cmake/wrf_case_setup.cmake | 80 ++++++++++++++++++++++---------------- compile_new | 5 ++- 3 files changed, 58 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ada7cf3c1..4f3b8c18e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -793,6 +793,15 @@ set_target_properties( EXPORT_PROPERTIES Fortran_MODULE_DIRECTORY ) +# 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 + PUBLIC + ${netCDF_LIBRARY_DIR} + ${netCDF-Fortran_LIBRARY_DIR} + ) + + target_link_libraries( ${PROJECT_NAME}_Core PUBLIC ${netCDF_LIBRARIES} diff --git a/cmake/wrf_case_setup.cmake b/cmake/wrf_case_setup.cmake index 838e180df5..a3bcdcbca7 100644 --- a/cmake/wrf_case_setup.cmake +++ b/cmake/wrf_case_setup.cmake @@ -1,64 +1,72 @@ -# WRF Macro for adding target symlinks to be run after internal install() code -macro( wrf_link_targets ) +# WRF Macro for adding target symlinks/copies to be run after internal install() code +macro( wrf_setup_targets ) - set( options ) - set( oneValueArgs SYM_PATH OLD_BASE_PATH ) + set( options USE_SYMLINKS ) + set( oneValueArgs DEST_PATH OLD_BASE_PATH ) set( multiValueArgs TARGETS ) cmake_parse_arguments( - WRF_LINK + WRF_SETUP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + set( WRF_SETUP_CMD copy_if_different ) + if ( ${WRF_SETUP_USE_SYMLINKS} ) + set( WRF_SETUP_CMD create_symlink ) + endif() - foreach ( WRF_LINK_TARGET ${WRF_LINK_TARGETS} ) + foreach ( WRF_SETUP_TARGET ${WRF_SETUP_TARGETS} ) # Generate install code for each target # https://stackoverflow.com/a/56528615 #!TODO Do we *need* the rm for symlinks beforehand? - # get_filename_component( WRF_LINK_FILE_ONLY $ NAME + # get_filename_component( WRF_SETUP_FILE_ONLY $ NAME install( CODE " - message( STATUS \"Creating symlinks for $\" ) - execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink ${WRF_LINK_OLD_BASE_PATH}/$ ${WRF_LINK_SYM_PATH}/$ ) + message( STATUS \"Setting up $ via ${WRF_SETUP_CMD}\" ) + execute_process( COMMAND ${CMAKE_COMMAND} -E ${WRF_SETUP_CMD} ${WRF_SETUP_OLD_BASE_PATH}/$ ${WRF_SETUP_DEST_PATH}/$ ) " - COMPONENT links + COMPONENT setup ) endforeach() endmacro() -# WRF Macro for adding file symlinks to be run after internal install() code -macro( wrf_link_files ) +# WRF Macro for adding file symlinks/copies to be run after internal install() code +macro( wrf_setup_files ) - set( options ) - set( oneValueArgs SYM_PATH ) + set( options USE_SYMLINKS ) + set( oneValueArgs DEST_PATH ) set( multiValueArgs FILES ) cmake_parse_arguments( - WRF_LINK + WRF_SETUP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + set( WRF_SETUP_CMD copy_if_different ) + if ( ${WRF_SETUP_USE_SYMLINKS} ) + set( WRF_SETUP_CMD create_symlink ) + endif() - foreach ( WRF_LINK_FILE ${WRF_LINK_FILES} ) + foreach ( WRF_SETUP_FILE ${WRF_SETUP_FILES} ) # Generate install code for each file, this could be done in a simpler manner # with regular commands but to preserve order of operations it will be done via install( CODE ... ) # https://stackoverflow.com/a/56528615 - get_filename_component( WRF_LINK_FULL_FILE ${WRF_LINK_FILE} ABSOLUTE ) - get_filename_component( WRF_LINK_FILE_ONLY ${WRF_LINK_FILE} NAME ) + get_filename_component( WRF_SETUP_FULL_FILE ${WRF_SETUP_FILE} ABSOLUTE ) + get_filename_component( WRF_SETUP_FILE_ONLY ${WRF_SETUP_FILE} NAME ) # Left here for debug purposes, may want to turn this into a trace-level debug msg - # message( "Generating install commands for ${WRF_LINK_FILE_ONLY} into ${WRF_LINK_SYM_PATH}" ) + # message( "Generating install commands for ${WRF_SETUP_FILE_ONLY} into ${WRF_SETUP_DEST_PATH}" ) install( CODE " - message( STATUS \"Creating symlinks for ${WRF_LINK_FILE_ONLY}\" ) - execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink ${WRF_LINK_FULL_FILE} ${WRF_LINK_SYM_PATH}/${WRF_LINK_FILE_ONLY} ) + message( STATUS \"Setting up ${WRF_SETUP_FILE_ONLY} via ${WRF_SETUP_CMD}\" ) + execute_process( COMMAND ${CMAKE_COMMAND} -E ${WRF_SETUP_CMD} ${WRF_SETUP_FULL_FILE} ${WRF_SETUP_DEST_PATH}/${WRF_SETUP_FILE_ONLY} ) " - COMPONENT links + COMPONENT setup ) endforeach() @@ -66,34 +74,38 @@ macro( wrf_link_files ) endmacro() # WRF Macro for adding file symlink to be run after internal install() code -macro( wrf_link_file_new_name ) +macro( wrf_setup_file_new_name ) - set( options ) - set( oneValueArgs SYM_PATH FILE NEW_NAME ) + set( options USE_SYMLINKS ) + set( oneValueArgs FILE NEW_NAME ) set( multiValueArgs ) cmake_parse_arguments( - WRF_LINK + WRF_SETUP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + set( WRF_SETUP_CMD copy_if_different ) + if ( ${WRF_SETUP_USE_SYMLINKS} ) + set( WRF_SETUP_CMD create_symlink ) + endif() # Generate install code for each file, this could be done in a simpler manner # with regular commands but to preserve order of operations it will be done via install( CODE ... ) # https://stackoverflow.com/a/56528615 - get_filename_component( WRF_LINK_FULL_FILE ${WRF_LINK_FILE} ABSOLUTE ) - get_filename_component( WRF_LINK_FILE_ONLY ${WRF_LINK_FILE} NAME ) - get_filename_component( WRF_LINK_NEW_NAME_FULL_FILE ${WRF_LINK_NEW_NAME} ABSOLUTE ) - get_filename_component( WRF_LINK_NEW_NAME_FILE_ONLY ${WRF_LINK_NEW_NAME} NAME ) + get_filename_component( WRF_SETUP_FULL_FILE ${WRF_SETUP_FILE} ABSOLUTE ) + get_filename_component( WRF_SETUP_FILE_ONLY ${WRF_SETUP_FILE} NAME ) + get_filename_component( WRF_SETUP_NEW_NAME_FULL_FILE ${WRF_SETUP_NEW_NAME} ABSOLUTE ) + get_filename_component( WRF_SETUP_NEW_NAME_FILE_ONLY ${WRF_SETUP_NEW_NAME} NAME ) # Left here for debug purposes, may want to turn this into a trace-level debug msg - # message( "Generating install commands for ${WRF_LINK_FILE_ONLY} to ${WRF_LINK_NEW_NAME_FILE_ONLY}" ) + # message( "Generating install commands for ${WRF_SETUP_FILE_ONLY} to ${WRF_SETUP_NEW_NAME_FILE_ONLY}" ) install( CODE " - message( STATUS \"Creating symlinks for ${WRF_LINK_FILE_ONLY} (rename ${WRF_LINK_NEW_NAME_FILE_ONLY})\" ) - execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink ${WRF_LINK_FULL_FILE} ${WRF_LINK_NEW_NAME_FULL_FILE} ) + message( STATUS \"Setting up ${WRF_SETUP_FILE_ONLY} (rename ${WRF_SETUP_NEW_NAME_FILE_ONLY}) via ${WRF_SETUP_CMD}\" ) + execute_process( COMMAND ${CMAKE_COMMAND} -E ${WRF_SETUP_CMD} ${WRF_SETUP_FULL_FILE} ${WRF_SETUP_NEW_NAME_FULL_FILE} ) " - COMPONENT links + COMPONENT setup ) endmacro() diff --git a/compile_new b/compile_new index c9a8f99059..0dc9888774 100755 --- a/compile_new +++ b/compile_new @@ -3,8 +3,9 @@ # Now run cmake buildDirectory=$1 -if [ ! -f "$buildDirectory" ]; - buildDirectory=$PWD/install +if [ ! -d "$buildDirectory" ]; then + buildDirectory=$PWD/_build + echo "Using default build directory : ${buildDirectory}" else shift fi From 73e17f23a2c231ac6bea53ccdddc20c63efa969e Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 2 Jan 2024 12:31:06 -0700 Subject: [PATCH 140/180] Setup em_real to do out-of-source install --- test/em_real/CMakeLists.txt | 42 +++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/test/em_real/CMakeLists.txt b/test/em_real/CMakeLists.txt index 00ec19b73c..c4746f8973 100644 --- a/test/em_real/CMakeLists.txt +++ b/test/em_real/CMakeLists.txt @@ -1,12 +1,20 @@ # These are just rules for this case, could be named CMakeLists.txt or something # like install_rules.cmake, whatever you want really -wrf_link_targets( +get_filename_component( FOLDER_DEST ${CMAKE_CURRENT_SOURCE_DIR} NAME ) + +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${CMAKE_INSTALL_PREFIX}/test/ + PATTERN CMakeLists.txt EXCLUDE + PATTERN .gitignore EXCLUDE + ) +wrf_setup_targets( TARGETS real tc ndown wrf - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} OLD_BASE_PATH ${CMAKE_INSTALL_PREFIX}/bin ) -wrf_link_files( +wrf_setup_files( FILES ${PROJECT_SOURCE_DIR}/run/README.namelist ${PROJECT_SOURCE_DIR}/run/README.physics_files @@ -59,6 +67,7 @@ wrf_link_files( ${PROJECT_SOURCE_DIR}/run/bulkdens.asc_s_0_03_0_9 ${PROJECT_SOURCE_DIR}/run/bulkradii.asc_s_0_03_0_9 ${PROJECT_SOURCE_DIR}/run/CCN_ACTIVATE.BIN + # These might be p3_lookupTable_1.dat-v5.4_* ${PROJECT_SOURCE_DIR}/run/p3_lookupTable_1.dat-5.3-2momI ${PROJECT_SOURCE_DIR}/run/p3_lookupTable_1.dat-3momI_v5.1.7 ${PROJECT_SOURCE_DIR}/run/p3_lookupTable_2.dat-2momI_v5.2.3 @@ -82,35 +91,36 @@ wrf_link_files( ${PROJECT_SOURCE_DIR}/run/tr67t85 ${PROJECT_SOURCE_DIR}/run/gribmap.txt ${PROJECT_SOURCE_DIR}/run/grib2map.tbl - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH + ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) -wrf_link_file_new_name( +wrf_setup_file_new_name( FILE ${PROJECT_SOURCE_DIR}/run/CAMtr_volume_mixing_ratio.SSP245 - NEW_NAME ${CMAKE_CURRENT_SOURCE_DIR}/CAMtr_volume_mixing_ratio + NEW_NAME ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST}/CAMtr_volume_mixing_ratio ) if ( ${USE_DOUBLE} ) - wrf_link_file_new_name( + wrf_setup_file_new_name( FILE ${PROJECT_SOURCE_DIR}/run/ETAMPNEW_DATA_DBL - NEW_NAME ${CMAKE_CURRENT_SOURCE_DIR}/ETAMPNEW_DATA + NEW_NAME ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST}/ETAMPNEW_DATA ) - wrf_link_file_new_name( + wrf_setup_file_new_name( FILE ${PROJECT_SOURCE_DIR}/run/ETAMPNEW_DATA.expanded_rain_DBL - NEW_NAME ${CMAKE_CURRENT_SOURCE_DIR}/ETAMPNEW_DATA.expanded_rain + NEW_NAME ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST}/ETAMPNEW_DATA.expanded_rain ) - wrf_link_file_new_name( + wrf_setup_file_new_name( FILE ${PROJECT_SOURCE_DIR}/run/RRTM_DATA_DBL - NEW_NAME ${CMAKE_CURRENT_SOURCE_DIR}/RRTM_DATA + NEW_NAME ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST}/RRTM_DATA ) - wrf_link_file_new_name( + wrf_setup_file_new_name( FILE ${PROJECT_SOURCE_DIR}/run/RRTMG_LW_DATA_DBL - NEW_NAME ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG_LW_DATA + NEW_NAME ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST}/RRTMG_LW_DATA ) - wrf_link_file_new_name( + wrf_setup_file_new_name( FILE ${PROJECT_SOURCE_DIR}/run/RRTMG_SW_DATA_DBL - NEW_NAME ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG_SW_DATA + NEW_NAME ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST}/RRTMG_SW_DATA ) endif() From bcd8bdeb978952bf590aee4e314cf1570170b74d Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 2 Jan 2024 12:47:35 -0700 Subject: [PATCH 141/180] Setup ideal cases to do out-of-source installs --- test/em_b_wave/CMakeLists.txt | 16 ++++++++++++---- test/em_convrad/CMakeLists.txt | 16 ++++++++++++---- test/em_fire/CMakeLists.txt | 16 ++++++++++++---- test/em_grav2d_x/CMakeLists.txt | 16 ++++++++++++---- test/em_heldsuarez/CMakeLists.txt | 16 ++++++++++++---- test/em_hill2d_x/CMakeLists.txt | 16 ++++++++++++---- test/em_les/CMakeLists.txt | 16 ++++++++++++---- test/em_quarter_ss/CMakeLists.txt | 16 ++++++++++++---- test/em_real/CMakeLists.txt | 4 ++-- test/em_scm_xy/CMakeLists.txt | 16 ++++++++++++---- test/em_seabreeze2d_x/CMakeLists.txt | 16 ++++++++++++---- test/em_squall2d_x/CMakeLists.txt | 16 ++++++++++++---- test/em_squall2d_y/CMakeLists.txt | 16 ++++++++++++---- test/em_tropical_cyclone/CMakeLists.txt | 16 ++++++++++++---- 14 files changed, 158 insertions(+), 54 deletions(-) diff --git a/test/em_b_wave/CMakeLists.txt b/test/em_b_wave/CMakeLists.txt index fa465239fb..e11c3c229c 100644 --- a/test/em_b_wave/CMakeLists.txt +++ b/test/em_b_wave/CMakeLists.txt @@ -1,11 +1,19 @@ # These are just rules for this case, could be named CMakeLists.txt or something # like install_rules.cmake, whatever you want really -wrf_link_targets( +get_filename_component( FOLDER_DEST ${CMAKE_CURRENT_SOURCE_DIR} NAME ) + +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${CMAKE_INSTALL_PREFIX}/test/ + PATTERN CMakeLists.txt EXCLUDE + PATTERN .gitignore EXCLUDE + ) +wrf_setup_targets( TARGETS ideal wrf - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) -wrf_link_files( +wrf_setup_files( FILES ${PROJECT_SOURCE_DIR}/run/README.namelist - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) \ No newline at end of file diff --git a/test/em_convrad/CMakeLists.txt b/test/em_convrad/CMakeLists.txt index b9b76908d2..075a4d4245 100644 --- a/test/em_convrad/CMakeLists.txt +++ b/test/em_convrad/CMakeLists.txt @@ -1,11 +1,19 @@ # These are just rules for this case, could be named CMakeLists.txt or something # like install_rules.cmake, whatever you want really -wrf_link_targets( +get_filename_component( FOLDER_DEST ${CMAKE_CURRENT_SOURCE_DIR} NAME ) + +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${CMAKE_INSTALL_PREFIX}/test/ + PATTERN CMakeLists.txt EXCLUDE + PATTERN .gitignore EXCLUDE + ) +wrf_setup_targets( TARGETS ideal wrf - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) -wrf_link_files( +wrf_setup_files( FILES ${PROJECT_SOURCE_DIR}/run/README.namelist ${PROJECT_SOURCE_DIR}/run/LANDUSE.TBL @@ -14,5 +22,5 @@ wrf_link_files( ${PROJECT_SOURCE_DIR}/run/ozone.formatted ${PROJECT_SOURCE_DIR}/run/ozone_lat.formatted ${PROJECT_SOURCE_DIR}/run/ozone_plev.formatted - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) \ No newline at end of file diff --git a/test/em_fire/CMakeLists.txt b/test/em_fire/CMakeLists.txt index fa465239fb..e11c3c229c 100644 --- a/test/em_fire/CMakeLists.txt +++ b/test/em_fire/CMakeLists.txt @@ -1,11 +1,19 @@ # These are just rules for this case, could be named CMakeLists.txt or something # like install_rules.cmake, whatever you want really -wrf_link_targets( +get_filename_component( FOLDER_DEST ${CMAKE_CURRENT_SOURCE_DIR} NAME ) + +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${CMAKE_INSTALL_PREFIX}/test/ + PATTERN CMakeLists.txt EXCLUDE + PATTERN .gitignore EXCLUDE + ) +wrf_setup_targets( TARGETS ideal wrf - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) -wrf_link_files( +wrf_setup_files( FILES ${PROJECT_SOURCE_DIR}/run/README.namelist - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) \ No newline at end of file diff --git a/test/em_grav2d_x/CMakeLists.txt b/test/em_grav2d_x/CMakeLists.txt index fa465239fb..e11c3c229c 100644 --- a/test/em_grav2d_x/CMakeLists.txt +++ b/test/em_grav2d_x/CMakeLists.txt @@ -1,11 +1,19 @@ # These are just rules for this case, could be named CMakeLists.txt or something # like install_rules.cmake, whatever you want really -wrf_link_targets( +get_filename_component( FOLDER_DEST ${CMAKE_CURRENT_SOURCE_DIR} NAME ) + +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${CMAKE_INSTALL_PREFIX}/test/ + PATTERN CMakeLists.txt EXCLUDE + PATTERN .gitignore EXCLUDE + ) +wrf_setup_targets( TARGETS ideal wrf - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) -wrf_link_files( +wrf_setup_files( FILES ${PROJECT_SOURCE_DIR}/run/README.namelist - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) \ No newline at end of file diff --git a/test/em_heldsuarez/CMakeLists.txt b/test/em_heldsuarez/CMakeLists.txt index fa465239fb..e11c3c229c 100644 --- a/test/em_heldsuarez/CMakeLists.txt +++ b/test/em_heldsuarez/CMakeLists.txt @@ -1,11 +1,19 @@ # These are just rules for this case, could be named CMakeLists.txt or something # like install_rules.cmake, whatever you want really -wrf_link_targets( +get_filename_component( FOLDER_DEST ${CMAKE_CURRENT_SOURCE_DIR} NAME ) + +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${CMAKE_INSTALL_PREFIX}/test/ + PATTERN CMakeLists.txt EXCLUDE + PATTERN .gitignore EXCLUDE + ) +wrf_setup_targets( TARGETS ideal wrf - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) -wrf_link_files( +wrf_setup_files( FILES ${PROJECT_SOURCE_DIR}/run/README.namelist - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) \ No newline at end of file diff --git a/test/em_hill2d_x/CMakeLists.txt b/test/em_hill2d_x/CMakeLists.txt index fa465239fb..e11c3c229c 100644 --- a/test/em_hill2d_x/CMakeLists.txt +++ b/test/em_hill2d_x/CMakeLists.txt @@ -1,11 +1,19 @@ # These are just rules for this case, could be named CMakeLists.txt or something # like install_rules.cmake, whatever you want really -wrf_link_targets( +get_filename_component( FOLDER_DEST ${CMAKE_CURRENT_SOURCE_DIR} NAME ) + +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${CMAKE_INSTALL_PREFIX}/test/ + PATTERN CMakeLists.txt EXCLUDE + PATTERN .gitignore EXCLUDE + ) +wrf_setup_targets( TARGETS ideal wrf - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) -wrf_link_files( +wrf_setup_files( FILES ${PROJECT_SOURCE_DIR}/run/README.namelist - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) \ No newline at end of file diff --git a/test/em_les/CMakeLists.txt b/test/em_les/CMakeLists.txt index fa465239fb..e11c3c229c 100644 --- a/test/em_les/CMakeLists.txt +++ b/test/em_les/CMakeLists.txt @@ -1,11 +1,19 @@ # These are just rules for this case, could be named CMakeLists.txt or something # like install_rules.cmake, whatever you want really -wrf_link_targets( +get_filename_component( FOLDER_DEST ${CMAKE_CURRENT_SOURCE_DIR} NAME ) + +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${CMAKE_INSTALL_PREFIX}/test/ + PATTERN CMakeLists.txt EXCLUDE + PATTERN .gitignore EXCLUDE + ) +wrf_setup_targets( TARGETS ideal wrf - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) -wrf_link_files( +wrf_setup_files( FILES ${PROJECT_SOURCE_DIR}/run/README.namelist - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) \ No newline at end of file diff --git a/test/em_quarter_ss/CMakeLists.txt b/test/em_quarter_ss/CMakeLists.txt index 60a6732c6b..c4deda7890 100644 --- a/test/em_quarter_ss/CMakeLists.txt +++ b/test/em_quarter_ss/CMakeLists.txt @@ -1,11 +1,19 @@ # These are just rules for this case, could be named CMakeLists.txt or something # like install_rules.cmake, whatever you want really -wrf_link_targets( +get_filename_component( FOLDER_DEST ${CMAKE_CURRENT_SOURCE_DIR} NAME ) + +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${CMAKE_INSTALL_PREFIX}/test/ + PATTERN CMakeLists.txt EXCLUDE + PATTERN .gitignore EXCLUDE + ) +wrf_setup_targets( TARGETS ideal wrf - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) -wrf_link_files( +wrf_setup_files( FILES ${PROJECT_SOURCE_DIR}/run/README.namelist ${PROJECT_SOURCE_DIR}/run/bulkdens.asc_s_0_03_0_9 @@ -18,5 +26,5 @@ wrf_link_files( ${PROJECT_SOURCE_DIR}/run/kernels_z.asc ${PROJECT_SOURCE_DIR}/run/masses.asc ${PROJECT_SOURCE_DIR}/run/termvels.asc - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) \ No newline at end of file diff --git a/test/em_real/CMakeLists.txt b/test/em_real/CMakeLists.txt index c4746f8973..6b90f6ff37 100644 --- a/test/em_real/CMakeLists.txt +++ b/test/em_real/CMakeLists.txt @@ -1,9 +1,9 @@ # These are just rules for this case, could be named CMakeLists.txt or something # like install_rules.cmake, whatever you want really -get_filename_component( FOLDER_DEST ${CMAKE_CURRENT_SOURCE_DIR} NAME ) +get_filename_component( FOLDER_DEST ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} NAME ) install( - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DIRECTORY ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} DESTINATION ${CMAKE_INSTALL_PREFIX}/test/ PATTERN CMakeLists.txt EXCLUDE PATTERN .gitignore EXCLUDE diff --git a/test/em_scm_xy/CMakeLists.txt b/test/em_scm_xy/CMakeLists.txt index bc2826b2de..960134a9c6 100644 --- a/test/em_scm_xy/CMakeLists.txt +++ b/test/em_scm_xy/CMakeLists.txt @@ -1,11 +1,19 @@ # These are just rules for this case, could be named CMakeLists.txt or something # like install_rules.cmake, whatever you want really -wrf_link_targets( +get_filename_component( FOLDER_DEST ${CMAKE_CURRENT_SOURCE_DIR} NAME ) + +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${CMAKE_INSTALL_PREFIX}/test/ + PATTERN CMakeLists.txt EXCLUDE + PATTERN .gitignore EXCLUDE + ) +wrf_setup_targets( TARGETS ideal wrf - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) -wrf_link_files( +wrf_setup_files( FILES ${PROJECT_SOURCE_DIR}/run/README.namelist ${PROJECT_SOURCE_DIR}/run/GENPARM.TBL @@ -13,5 +21,5 @@ wrf_link_files( ${PROJECT_SOURCE_DIR}/run/SOILPARM.TBL ${PROJECT_SOURCE_DIR}/run/VEGPARM.TBL ${PROJECT_SOURCE_DIR}/run/RRTM_DATA - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) \ No newline at end of file diff --git a/test/em_seabreeze2d_x/CMakeLists.txt b/test/em_seabreeze2d_x/CMakeLists.txt index 58a03a97a0..440ed57794 100644 --- a/test/em_seabreeze2d_x/CMakeLists.txt +++ b/test/em_seabreeze2d_x/CMakeLists.txt @@ -1,14 +1,22 @@ # These are just rules for this case, could be named CMakeLists.txt or something # like install_rules.cmake, whatever you want really -wrf_link_targets( +get_filename_component( FOLDER_DEST ${CMAKE_CURRENT_SOURCE_DIR} NAME ) + +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${CMAKE_INSTALL_PREFIX}/test/ + PATTERN CMakeLists.txt EXCLUDE + PATTERN .gitignore EXCLUDE + ) +wrf_setup_targets( TARGETS ideal wrf - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) -wrf_link_files( +wrf_setup_files( FILES ${PROJECT_SOURCE_DIR}/run/README.namelist ${PROJECT_SOURCE_DIR}/run/LANDUSE.TBL ${PROJECT_SOURCE_DIR}/run/RRTM_DATA - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) \ No newline at end of file diff --git a/test/em_squall2d_x/CMakeLists.txt b/test/em_squall2d_x/CMakeLists.txt index fa465239fb..e11c3c229c 100644 --- a/test/em_squall2d_x/CMakeLists.txt +++ b/test/em_squall2d_x/CMakeLists.txt @@ -1,11 +1,19 @@ # These are just rules for this case, could be named CMakeLists.txt or something # like install_rules.cmake, whatever you want really -wrf_link_targets( +get_filename_component( FOLDER_DEST ${CMAKE_CURRENT_SOURCE_DIR} NAME ) + +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${CMAKE_INSTALL_PREFIX}/test/ + PATTERN CMakeLists.txt EXCLUDE + PATTERN .gitignore EXCLUDE + ) +wrf_setup_targets( TARGETS ideal wrf - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) -wrf_link_files( +wrf_setup_files( FILES ${PROJECT_SOURCE_DIR}/run/README.namelist - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) \ No newline at end of file diff --git a/test/em_squall2d_y/CMakeLists.txt b/test/em_squall2d_y/CMakeLists.txt index fa465239fb..e11c3c229c 100644 --- a/test/em_squall2d_y/CMakeLists.txt +++ b/test/em_squall2d_y/CMakeLists.txt @@ -1,11 +1,19 @@ # These are just rules for this case, could be named CMakeLists.txt or something # like install_rules.cmake, whatever you want really -wrf_link_targets( +get_filename_component( FOLDER_DEST ${CMAKE_CURRENT_SOURCE_DIR} NAME ) + +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${CMAKE_INSTALL_PREFIX}/test/ + PATTERN CMakeLists.txt EXCLUDE + PATTERN .gitignore EXCLUDE + ) +wrf_setup_targets( TARGETS ideal wrf - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) -wrf_link_files( +wrf_setup_files( FILES ${PROJECT_SOURCE_DIR}/run/README.namelist - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) \ No newline at end of file diff --git a/test/em_tropical_cyclone/CMakeLists.txt b/test/em_tropical_cyclone/CMakeLists.txt index 0c385179d4..cc2ccaa8a3 100644 --- a/test/em_tropical_cyclone/CMakeLists.txt +++ b/test/em_tropical_cyclone/CMakeLists.txt @@ -1,13 +1,21 @@ # These are just rules for this case, could be named CMakeLists.txt or something # like install_rules.cmake, whatever you want really -wrf_link_targets( +get_filename_component( FOLDER_DEST ${CMAKE_CURRENT_SOURCE_DIR} NAME ) + +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${CMAKE_INSTALL_PREFIX}/test/ + PATTERN CMakeLists.txt EXCLUDE + PATTERN .gitignore EXCLUDE + ) +wrf_setup_targets( TARGETS ideal wrf - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) -wrf_link_files( +wrf_setup_files( FILES ${PROJECT_SOURCE_DIR}/run/README.namelist ${PROJECT_SOURCE_DIR}/run/LANDUSE.TBL - SYM_PATH ${CMAKE_CURRENT_SOURCE_DIR} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} ) \ No newline at end of file From bf1f5466b0386da098f29d085698296cd821db46 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 2 Jan 2024 13:44:53 -0700 Subject: [PATCH 142/180] First draft of ideal tests for cmake --- .ci/tests/buildCMake.sh | 98 +++++++++ .ci/wrf_em_ideal_tests-cmake.json | 350 ++++++++++++++++++++++++++++++ 2 files changed, 448 insertions(+) create mode 100755 .ci/tests/buildCMake.sh create mode 100644 .ci/wrf_em_ideal_tests-cmake.json diff --git a/.ci/tests/buildCMake.sh b/.ci/tests/buildCMake.sh new file mode 100755 index 0000000000..4f97951cf5 --- /dev/null +++ b/.ci/tests/buildCMake.sh @@ -0,0 +1,98 @@ +#!/bin/sh +help() +{ + echo "./build.sh [workingdir] [options] [-- ]" + echo " [workingdir] First argument must be the working dir to immediate cd to" + echo " -c Configuration build type, piped directly into configure" + echo " -b Build command passed into compile" + echo " -r Clean command passed into cleanCmake" + echo " -e environment variables in comma-delimited list, e.g. var=1,foo,bar=0" + echo " -- Directly pass options to hostenv.sh, equivalent to hostenv.sh " + echo " -h Print this message" + echo "" + echo "If you wish to use an env var in your arg such as '-c \$PRESELECT -e PRESELECT=GNU'," + echo "you will need to do '-c \\\$PRESELECT -e PRESELECT=32' to delay shell expansion" +} + +workingDirectory=$1 +shift +if [ $workingDirectory = "-h" ]; then + help + exit 0 +fi +cd $workingDirectory + +# Get some helper functions +. .ci/env/helpers.sh + +while getopts c:b:r:e:h opt; do + case $opt in + c) + configuration="$OPTARG" + ;; + b) + buildCommand="$OPTARG" + ;; + r) + cleanCommand="$OPTARG" + ;; + e) + envVars="$envVars,$OPTARG" + ;; + h) help; exit 0 ;; + *) help; exit 1 ;; + :) help; exit 1 ;; + \?) help; exit 1 ;; + esac +done + +shift "$((OPTIND - 1))" + +# Everything else goes to our env setup +. .ci/env/hostenv.sh $* + +# Now evaluate env vars in case it pulls from hostenv.sh +if [ ! -z "$envVars" ]; then + setenvStr "$envVars" +fi + +# Re-evaluate input values for delayed expansion +eval "cleanCommand=\"$cleanCommand\"" +eval "configuration=\"$configuration\"" +eval "buildCommand=\"$buildCommand\"" + +echo "./cleanCMake.sh -a $cleanCommand" +./cleanCMake.sh -a $cleanCommand +echo "Clean done" + +echo "./configure_new $configuration" +./configure_new $configuration +echo "Configure done" + +result=$? + +if [ $result -ne 0 ]; then + echo "Failed to configure, command returned non-zero exit status" + exit 1 +fi + +echo "./compile_new $buildCommand" +./compile_new $buildCommand +echo "Compile done" + +result=$? + +if [ $result -ne 0 ]; then + echo "Failed to compile, command returned non-zero exit status" + exit 1 +fi + +# # And a *very* special check because WRF compiles the WRF way and force-ignores all make errors +# # putting the onus on US to check for things +# if [ ! -x $installDirectory/main/wrf ]; then # There's a bunch of other execs but this is the most important and +# # doing more checks to accomodate just reinforces this bad design +# echo "Failed to compile" +# exit 1 +# fi + +echo "TEST $(basename $0) PASS" \ No newline at end of file diff --git a/.ci/wrf_em_ideal_tests-cmake.json b/.ci/wrf_em_ideal_tests-cmake.json new file mode 100644 index 0000000000..399021575c --- /dev/null +++ b/.ci/wrf_em_ideal_tests-cmake.json @@ -0,0 +1,350 @@ +{ + "submit_options" : + { + "timelimit" : "00:20:00", + "working_directory" : "..", + "arguments" : + { + "base_env_numprocs" : [ "-e", "NUM_PROCS=4" ], + "base_env_wkdir" : [ "-e", "WK_DIR=$PWD" ], + + ".*build.*::args_compilecmd" : [ "-c", "-p GNU -d _build_$IDEAL_CASE -i $WK_DIR/install_$IDEAL_CASE -x -- -DWRF_CORE=ARW -DWRF_NESTING=BASIC -DWRF_CASE=$IDEAL_CASE_UPPER $USE_MPI $USE_OPENMP" ], + ".*build.*::args_buildcmd" : [ "-b", "_build_$IDEAL_CASE -j $NUM_PROCS" ], + ".*build.*::args_cleancmd" : [ "-r", "-d _build_$IDEAL_CASE -i $WK_DIR/install_$IDEAL_CASE" ], + + ".*build-omp.*::args_config" : [ "-e", "USE_OPENMP=-DUSE_OPENMP=ON" ], + ".*build-mpi.*::args_config" : [ "-e", "USE_MPI=-DUSE_MPI=ON" ], + + ".*testcase.*::global_env" : [ "-e", "DATA=/path/to/data" ], + ".*testcase.*::args_always" : [ "-c", "$WK_DIR/install_$IDEAL_CASE/test/$IDEAL_CASE", "-b", "ideal", "-d", "$DATA/$IDEAL_CASE" ], + ".*testcase-mpi.*::exec_mpi" : [ "-p", "mpirun -np $NUM_PROCS" ], + ".*testcase-omp.*::env" : [ "-e", "OMP_NUM_THREADS=$NUM_PROCS" ], + + ".*testcase-serial.*::dir" : [ "-f", ".ci/tests/SCRIPTS/Namelists/weekly/$IDEAL_CASE/", "-s", "serial_results" ], + ".*testcase-omp.*::dir" : [ "-f", ".ci/tests/SCRIPTS/Namelists/weekly/$IDEAL_CASE/", "-i", "serial_results" ], + ".*testcase-mpi.*::dir" : [ "-f", ".ci/tests/SCRIPTS/Namelists/weekly/$IDEAL_CASE/", "-i", "serial_results" ] + }, + "polaris" : + { + "submission" : "LOCAL", + "arguments" : + { + "base_env_numprocs" : [ "-e", "NUM_PROCS=2" ], + ".*testcase.*::global_env" : + [ + "-e", "DATA=/mnt/s/github/data/wrf/regtest/Data" + ] + } + }, + "cheyenne" : + { + "submission" : "PBS", + "queue" : "economy", + "resources" : "-l select=1:ncpus=6", + "arguments" : + { + "base_env_numprocs" : [ "-e", "NUM_PROCS=6" ], + ".*testcase.*::global_env" : + [ + "-e", "DATA=/glade/work/aislas/github/data/wrf/regtest/Data/" + ], + "global_modules" : [ "gnu", "netcdf" ], + ".*mpi.*::mpi_module" : [ "openmpi/4.0.3" ] + } + }, + "hsn.de.hpc" : + { + "submission" : "PBS", + "queue" : "main", + "resources" : "-l select=1:ncpus=8 -l job_priority=economy", + "timelimit" : "00:10:00", + "arguments" : + { + "base_env_numprocs" : [ "-e", "NUM_PROCS=8" ], + ".*testcase.*::global_env" : + [ + "-e", "DATA=/glade/work/aislas/github/data/wrf/regtest/Data/" + ], + "global_modules" : [ "gcc", "netcdf" ], + ".*mpi.*::mpi_module" : [ "cray-mpich" ] + } + } + }, + "ideal-tests" : + { + "submit_options" : + { + "arguments" : + { + ".*em_quarter_ss-testcase.*::args_namelist" : + [ + "-n", "namelist.input.02NE,namelist.input.03,namelist.input.03NE" + ], + ".*em_quarter_ss.*::args_idealcase" : + [ + "-e", "IDEAL_CASE=em_quarter_ss" + ] + } + }, + "steps" : + { + "em_quarter_ss.build-serial" : + { + "command" : ".ci/tests/buildCMake.sh" + }, + "em_quarter_ss.testcase-serial" : + { + "submit_options" : { + "cheyenne" : { "resources" : "-l select=1:ncpus=1" }, + "derecho" : { "resources" : "-l select=1:ncpus=1 -l job_priority=economy" } + }, + "command" : ".ci/tests/runNamelists.sh", + "dependencies" : { "em_quarter_ss.build-serial" : "afterok" } + }, + "em_quarter_ss.build-omp" : + { + "command" : ".ci/tests/buildCMake.sh" + }, + "em_quarter_ss.testcase-omp" : + { + "submit_options" : { + "cheyenne" : { "resources" : "-l select=1:ncpus=4:ompthreads=4" }, + "derecho" : { "resources" : "-l select=1:ncpus=8:ompthreads=8 -l job_priority=economy" } + }, + "command" : ".ci/tests/runNamelists.sh", + "dependencies" : { "em_quarter_ss.build-omp" : "afterok", "em_quarter_ss.testcase-serial" : "afterok" } + }, + "em_quarter_ss.build-mpi" : + { + "command" : ".ci/tests/buildCMake.sh" + }, + "em_quarter_ss.testcase-mpi" : + { + "submit_options" : { + "cheyenne" : { "resources" : "-l select=1:ncpus=4:mpiprocs=6" }, + "derecho" : { "resources" : "-l select=1:ncpus=8:mpiprocs=8 -l job_priority=economy" } + }, + "command" : ".ci/tests/runNamelists.sh", + "dependencies" : { "em_quarter_ss.build-mpi" : "afterok", "em_quarter_ss.testcase-serial" : "afterok" } + } + } + }, + "em_quarter_ss_real8" : + { + "submit_options" : + { + "arguments" : + { + ".*build.*::args_configopt" : [ "-o", "-d -r8" ], + ".*testcase.*::args_namelist" : + [ + "-n", "namelist.input.08,namelist.input.09" + ], + ".*::args_idealcase" : + [ + "-e", "IDEAL_CASE=em_quarter_ss" + ] + } + }, + "steps" : + { + "build-serial" : + { + "command" : ".ci/tests/buildCMake.sh" + }, + "testcase-serial" : + { + "submit_options" : { + "cheyenne" : { "resources" : "-l select=1:ncpus=1" }, + "derecho" : { "resources" : "-l select=1:ncpus=1 -l job_priority=economy" } + }, + "command" : ".ci/tests/runNamelists.sh", + "dependencies" : { "build-serial" : "afterok" } + }, + "build-omp" : + { + "command" : ".ci/tests/buildCMake.sh", + "dependencies" : { "testcase-serial" : "afterok" } + }, + "testcase-omp" : + { + "submit_options" : { + "cheyenne" : { "resources" : "-l select=1:ncpus=4:ompthreads=4" }, + "derecho" : { "resources" : "-l select=1:ncpus=8:ompthreads=8 -l job_priority=economy" } + }, + "command" : ".ci/tests/runNamelists.sh", + "dependencies" : { "build-omp" : "afterok" } + }, + "build-mpi" : + { + "command" : ".ci/tests/buildCMake.sh", + "dependencies" : { "testcase-omp" : "afterok" } + }, + "testcase-mpi" : + { + "submit_options" : { + "cheyenne" : { "resources" : "-l select=1:ncpus=4:mpiprocs=6" }, + "derecho" : { "resources" : "-l select=1:ncpus=8:mpiprocs=8 -l job_priority=economy" } + }, + "command" : ".ci/tests/runNamelists.sh", + "dependencies" : { "build-mpi" : "afterok" } + } + } + }, + "em_b_wave" : + { + "submit_options" : + { + "arguments" : + { + ".*testcase.*::args_namelist" : + [ + "-n", "namelist.input.1NE,namelist.input.2,namelist.input.2NE,namelist.input.3" + ], + ".*::args_idealcase" : + [ + "-e", "IDEAL_CASE=em_b_wave" + ] + } + }, + "steps" : + { + "build-serial" : + { + "command" : ".ci/tests/buildCMake.sh" + }, + "testcase-serial" : + { + "submit_options" : { + "cheyenne" : { "resources" : "-l select=1:ncpus=1" }, + "derecho" : { "resources" : "-l select=1:ncpus=1 -l job_priority=economy" } + }, + "command" : ".ci/tests/runNamelists.sh", + "dependencies" : { "build-serial" : "afterok" } + }, + "build-omp" : + { + "command" : ".ci/tests/buildCMake.sh", + "dependencies" : { "testcase-serial" : "afterok" } + }, + "testcase-omp" : + { + "submit_options" : { + "cheyenne" : { "resources" : "-l select=1:ncpus=4:ompthreads=4" }, + "derecho" : { "resources" : "-l select=1:ncpus=8:ompthreads=8 -l job_priority=economy" } + }, + "command" : ".ci/tests/runNamelists.sh", + "dependencies" : { "build-omp" : "afterok" } + }, + "build-mpi" : + { + "command" : ".ci/tests/buildCMake.sh", + "dependencies" : { "testcase-omp" : "afterok" } + }, + "testcase-mpi" : + { + "submit_options" : { + "cheyenne" : { "resources" : "-l select=1:ncpus=4:mpiprocs=6" }, + "derecho" : { "resources" : "-l select=1:ncpus=8:mpiprocs=8 -l job_priority=economy" } + }, + "command" : ".ci/tests/runNamelists.sh", + "dependencies" : { "build-mpi" : "afterok" } + } + } + }, + "em_fire" : + { + "submit_options" : + { + "arguments" : + { + ".*testcase.*::args_namelist" : + [ + "-n", "namelist.input.01" + ], + ".*::args_idealcase" : + [ + "-e", "IDEAL_CASE=em_fire" + ] + } + }, + "steps" : + { + "build-serial" : + { + "command" : ".ci/tests/buildCMake.sh" + }, + "testcase-serial" : + { + "submit_options" : { + "cheyenne" : { "resources" : "-l select=1:ncpus=1" }, + "derecho" : { "resources" : "-l select=1:ncpus=1 -l job_priority=economy" } + }, + "command" : ".ci/tests/runNamelists.sh", + "dependencies" : { "build-serial" : "afterok" } + }, + "build-omp" : + { + "command" : ".ci/tests/buildCMake.sh", + "dependencies" : { "testcase-serial" : "afterok" } + }, + "testcase-omp" : + { + "submit_options" : { + "cheyenne" : { "resources" : "-l select=1:ncpus=4:ompthreads=4" }, + "derecho" : { "resources" : "-l select=1:ncpus=8:ompthreads=8 -l job_priority=economy" } + }, + "command" : ".ci/tests/runNamelists.sh", + "dependencies" : { "build-omp" : "afterok" } + }, + "build-mpi" : + { + "command" : ".ci/tests/buildCMake.sh", + "dependencies" : { "testcase-omp" : "afterok" } + }, + "testcase-mpi" : + { + "submit_options" : { + "cheyenne" : { "resources" : "-l select=1:ncpus=4:mpiprocs=6" }, + "derecho" : { "resources" : "-l select=1:ncpus=8:mpiprocs=8 -l job_priority=economy" } + }, + "command" : ".ci/tests/runNamelists.sh", + "dependencies" : { "build-mpi" : "afterok" } + } + } + }, + "em_hill2d_x" : + { + "submit_options" : + { + "arguments" : + { + ".*build.*::args_nesting" : [ "-n", "0" ], + ".*testcase.*::args_namelist" : + [ + "-n", "namelist.input.01" + ], + ".*::args_idealcase" : + [ + "-e", "IDEAL_CASE=em_hill2d_x" + ] + } + }, + "steps" : + { + "build-serial" : + { + "command" : ".ci/tests/buildCMake.sh" + }, + "testcase-serial" : + { + "submit_options" : { + "cheyenne" : { "resources" : "-l select=1:ncpus=1" }, + "derecho" : { "resources" : "-l select=1:ncpus=1 -l job_priority=economy" } + }, + "command" : ".ci/tests/runNamelists.sh", + "dependencies" : { "build-serial" : "afterok" } + } + } + } +} \ No newline at end of file From 2437541fdf6e14675b1ee45f33dbd51b4a34bea9 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 2 Jan 2024 15:00:54 -0700 Subject: [PATCH 143/180] Compilation of multiple tests at the same time for cmake now works --- .ci/tests/buildCMake.sh | 6 +++--- .ci/wrf_em_ideal_tests-cmake.json | 20 +++++++++++--------- cleanCMake.sh | 8 ++++---- compile_new | 3 ++- configure_new | 3 +++ 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.ci/tests/buildCMake.sh b/.ci/tests/buildCMake.sh index 4f97951cf5..a86dd7b7cd 100755 --- a/.ci/tests/buildCMake.sh +++ b/.ci/tests/buildCMake.sh @@ -67,9 +67,8 @@ echo "Clean done" echo "./configure_new $configuration" ./configure_new $configuration -echo "Configure done" - result=$? +echo "Configure done" if [ $result -ne 0 ]; then echo "Failed to configure, command returned non-zero exit status" @@ -78,9 +77,10 @@ fi echo "./compile_new $buildCommand" ./compile_new $buildCommand +result=$? echo "Compile done" -result=$? + if [ $result -ne 0 ]; then echo "Failed to compile, command returned non-zero exit status" diff --git a/.ci/wrf_em_ideal_tests-cmake.json b/.ci/wrf_em_ideal_tests-cmake.json index 399021575c..24cd181d85 100644 --- a/.ci/wrf_em_ideal_tests-cmake.json +++ b/.ci/wrf_em_ideal_tests-cmake.json @@ -7,16 +7,17 @@ { "base_env_numprocs" : [ "-e", "NUM_PROCS=4" ], "base_env_wkdir" : [ "-e", "WK_DIR=$PWD" ], + "env_dirs" : [ "-e", "BUILD_DIR=_build_$IDEAL_CASE$DM$SM", "-e", "INSTALL_DIR=$WK_DIR/install_$IDEAL_CASE$DM$SM" ], - ".*build.*::args_compilecmd" : [ "-c", "-p GNU -d _build_$IDEAL_CASE -i $WK_DIR/install_$IDEAL_CASE -x -- -DWRF_CORE=ARW -DWRF_NESTING=BASIC -DWRF_CASE=$IDEAL_CASE_UPPER $USE_MPI $USE_OPENMP" ], - ".*build.*::args_buildcmd" : [ "-b", "_build_$IDEAL_CASE -j $NUM_PROCS" ], - ".*build.*::args_cleancmd" : [ "-r", "-d _build_$IDEAL_CASE -i $WK_DIR/install_$IDEAL_CASE" ], + ".*build.*::args_compilecmd" : [ "-c", "-p GNU -d $BUILD_DIR -i $INSTALL_DIR -x -- -DWRF_CORE=ARW -DWRF_NESTING=BASIC -DWRF_CASE=$IDEAL_CASE_UPPER $USE_MPI $USE_OPENMP" ], + ".*build.*::args_buildcmd" : [ "-b", "$BUILD_DIR -j $NUM_PROCS" ], + ".*build.*::args_cleancmd" : [ "-r", "-d $BUILD_DIR -i $INSTALL_DIR" ], - ".*build-omp.*::args_config" : [ "-e", "USE_OPENMP=-DUSE_OPENMP=ON" ], - ".*build-mpi.*::args_config" : [ "-e", "USE_MPI=-DUSE_MPI=ON" ], + ".*build-omp.*::args_config" : [ "-e", "USE_OPENMP=-DUSE_OPENMP=ON", "-e", "SM=_sm" ], + ".*build-mpi.*::args_config" : [ "-e", "USE_MPI=-DUSE_MPI=ON", "-e", "DM=_dm" ], ".*testcase.*::global_env" : [ "-e", "DATA=/path/to/data" ], - ".*testcase.*::args_always" : [ "-c", "$WK_DIR/install_$IDEAL_CASE/test/$IDEAL_CASE", "-b", "ideal", "-d", "$DATA/$IDEAL_CASE" ], + ".*testcase.*::args_always" : [ "-c", "$INSTALL_DIR/test/$IDEAL_CASE", "-b", "ideal", "-d", "$DATA/$IDEAL_CASE" ], ".*testcase-mpi.*::exec_mpi" : [ "-p", "mpirun -np $NUM_PROCS" ], ".*testcase-omp.*::env" : [ "-e", "OMP_NUM_THREADS=$NUM_PROCS" ], @@ -60,12 +61,12 @@ "timelimit" : "00:10:00", "arguments" : { - "base_env_numprocs" : [ "-e", "NUM_PROCS=8" ], + "base_env_numprocs" : [ "-e", "NUM_PROCS=2" ], ".*testcase.*::global_env" : [ "-e", "DATA=/glade/work/aislas/github/data/wrf/regtest/Data/" ], - "global_modules" : [ "gcc", "netcdf" ], + "global_modules" : [ "gcc", "netcdf", "cmake" ], ".*mpi.*::mpi_module" : [ "cray-mpich" ] } } @@ -82,7 +83,8 @@ ], ".*em_quarter_ss.*::args_idealcase" : [ - "-e", "IDEAL_CASE=em_quarter_ss" + "-e", "IDEAL_CASE=em_quarter_ss", + "-e", "IDEAL_CASE_UPPER=EM_QUARTER_SS" ] } }, diff --git a/cleanCMake.sh b/cleanCMake.sh index f372dae0ed..85290c8042 100755 --- a/cleanCMake.sh +++ b/cleanCMake.sh @@ -59,20 +59,20 @@ fi if [ "${cleanBasicBuild}" = "TRUE" ] || [ "${cleanAll}" = "TRUE" ]; then echo "Doing cmake make clean" OLD_DIR=$PWD - cd ${buildDirectory} && make -j 1 clean; cd $OLD_DIR + cd ${buildDirectory} && make -j 1 clean > /dev/null 2>&1; cd $OLD_DIR fi if [ "${cleanBasicInstall}" = "TRUE" ] || [ "${cleanAll}" = "TRUE" ]; then echo "Removing binary installs" - xargs rm < ${buildDirectory}/install_manifest.txt + xargs rm < ${buildDirectory}/install_manifest.txt > /dev/null 2>&1 fi if [ "${cleanLinks}" = "TRUE" ] || [ "${cleanAll}" = "TRUE" ]; then echo "Removing all symlinks in ${installDirectory}/test" - find ${installDirectory}/test -type l -exec rm {} \; + find ${installDirectory}/test -type l -exec rm {} \; > /dev/null 2>&1 fi if [ "${cleanFolders}" = "TRUE" ] || [ "${cleanAll}" = "TRUE" ]; then echo "Deleting ${buildDirectory} & ${installDirectory}/" - rm ${buildDirectory} -r; rm ${installDirectory}/ -r + rm ${buildDirectory} -r; rm ${installDirectory}/ -r > /dev/null 2>&1 fi diff --git a/compile_new b/compile_new index 0dc9888774..721df9d3bf 100755 --- a/compile_new +++ b/compile_new @@ -9,4 +9,5 @@ if [ ! -d "$buildDirectory" ]; then else shift fi -cd $buildDirectory && make install $* \ No newline at end of file +cd $buildDirectory && make install $* +exit $? \ No newline at end of file diff --git a/configure_new b/configure_new index 2fa6dce50e..e9d9900ba1 100755 --- a/configure_new +++ b/configure_new @@ -78,4 +78,7 @@ if [ $configureStanza -eq 0 ]; then # Now run cmake cd $buildDirectory cmake .. -DCMAKE_INSTALL_PREFIX=$installDirectory -DCMAKE_TOOLCHAIN_FILE=$buildDirectory/wrf_config.cmake $* + exit $? +else + exit $configureStanza fi \ No newline at end of file From 95acd4de775883d732022fcb99f3f96b528a524a Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 2 Jan 2024 16:15:28 -0700 Subject: [PATCH 144/180] Fix builds to work correctly when not mpi --- .ci/wrf_em_ideal_tests-cmake.json | 6 ++++-- external/CMakeLists.txt | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.ci/wrf_em_ideal_tests-cmake.json b/.ci/wrf_em_ideal_tests-cmake.json index 24cd181d85..a7376b0b96 100644 --- a/.ci/wrf_em_ideal_tests-cmake.json +++ b/.ci/wrf_em_ideal_tests-cmake.json @@ -13,8 +13,10 @@ ".*build.*::args_buildcmd" : [ "-b", "$BUILD_DIR -j $NUM_PROCS" ], ".*build.*::args_cleancmd" : [ "-r", "-d $BUILD_DIR -i $INSTALL_DIR" ], - ".*build-omp.*::args_config" : [ "-e", "USE_OPENMP=-DUSE_OPENMP=ON", "-e", "SM=_sm" ], - ".*build-mpi.*::args_config" : [ "-e", "USE_MPI=-DUSE_MPI=ON", "-e", "DM=_dm" ], + ".*build-omp.*::args_config" : [ "-e", "USE_OPENMP=-DUSE_OPENMP=ON" ], + ".*omp.*::args_config" : [ "-e", "SM=_sm" ], + ".*build-mpi.*::args_config" : [ "-e", "USE_MPI=-DUSE_MPI=ON" ], + ".*mpi.*::args_config" : [ "-e", "DM=_dm" ], ".*testcase.*::global_env" : [ "-e", "DATA=/path/to/data" ], ".*testcase.*::args_always" : [ "-c", "$INSTALL_DIR/test/$IDEAL_CASE", "-b", "ideal", "-d", "$DATA/$IDEAL_CASE" ], diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 8c4596a7eb..268a2a2b6c 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -50,7 +50,7 @@ add_subdirectory( esmf_time_f90 ) add_subdirectory( io_netcdf ) #!TODO We should collapse all these files into #ifdefs even if they are compiled # multiple times with different defs for the same configuration -if ( ${netCDF_PARALLEL} ) +if ( ${netCDF_PARALLEL} AND ${USE_MPI} ) message( STATUS "Adding [io_netcdfpar] to configuration" ) add_subdirectory( io_netcdfpar ) endif() From 4364f9ac39fa2c609d8b6d56fada68cbff38cbb3 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 8 Jan 2024 19:32:41 +0000 Subject: [PATCH 145/180] Adding version checking to JASPER as selected version is very important --- CMakeLists.txt | 4 ++-- cmake/modules/FindJasper.cmake | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f3b8c18e3..c92de611de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -384,10 +384,10 @@ endif() # HDF5 has some funky weirdness between versions where the casing has changed # Optional -find_package( HDF5 QUIET ) +find_package( HDF5 ) # Optional for grib2 -find_package( Jasper QUIET ) +find_package( Jasper 1.900.1...<1.900.24 ) # Optional find_package( PIO QUIET ) diff --git a/cmake/modules/FindJasper.cmake b/cmake/modules/FindJasper.cmake index 3b9bc6210c..541ecf2147 100644 --- a/cmake/modules/FindJasper.cmake +++ b/cmake/modules/FindJasper.cmake @@ -25,6 +25,11 @@ find_library( PATH_SUFFIXES lib ) +# Ripped from https://github.com/Kitware/CMake/blob/master/Modules/FindJasper.cmake +if( Jasper_INCLUDE_DIR AND EXISTS "${Jasper_INCLUDE_DIR}/jasper/jas_config.h") + file(STRINGS "${Jasper_INCLUDE_DIR}/jasper/jas_config.h" jasper_version_str REGEX "^#define[\t ]+JAS_VERSION[\t ]+\".*\".*") + string(REGEX REPLACE "^#define[\t ]+JAS_VERSION[\t ]+\"([^\"]+)\".*" "\\1" Jasper_VERSION_STRING "${jasper_version_str}") +endif() # set(CMAKE_FIND_DEBUG_MODE FALSE) include(FindPackageHandleStandardArgs) @@ -34,7 +39,8 @@ find_package_handle_standard_args( REQUIRED_VARS Jasper_LIBRARY Jasper_INCLUDE_DIR - # VERSION_VAR Jasper_VERSION + VERSION_VAR Jasper_VERSION_STRING + HANDLE_VERSION_RANGE ) if ( Jasper_FOUND AND NOT TARGET Jasper::Jasper ) From 94ed78cf78f2854a0a6cd1005e2c212e0c14ec29 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 8 Jan 2024 23:19:24 +0000 Subject: [PATCH 146/180] Add stand-in code for native netCDF[-Fortran] cmake builds --- cmake/modules/FindnetCDF-Fortran.cmake | 19 ++++++++++++++++++- cmake/modules/FindnetCDF.cmake | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/cmake/modules/FindnetCDF-Fortran.cmake b/cmake/modules/FindnetCDF-Fortran.cmake index baa05fbe9b..0ead239a57 100644 --- a/cmake/modules/FindnetCDF-Fortran.cmake +++ b/cmake/modules/FindnetCDF-Fortran.cmake @@ -10,7 +10,24 @@ # find_package( netCDF-Fortran ) # list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} ) -# Use nc-config + +# exit early if we don't even need to be here +if ( netCDF-Fortran_FOUND ) + return() +endif() + +############################################################################### +# First try to find using netCDF-Fortran native cmake build +# TODO : Enable this when netCDF-Fortran native cmake build works well as an imported package +# find_package( netCDF-Fortran CONFIG ) +# if ( netCDF-Fortran_FOUND ) +# message( STATUS "Found netCDF-Fortran through native cmake build" ) +# return() +# endif() +############################################################################### + +# else +# Use nf-config find_program( NETCDF-FORTRAN_PROGRAM nf-config diff --git a/cmake/modules/FindnetCDF.cmake b/cmake/modules/FindnetCDF.cmake index 90d4dc01da..518ec95348 100644 --- a/cmake/modules/FindnetCDF.cmake +++ b/cmake/modules/FindnetCDF.cmake @@ -10,6 +10,24 @@ # find_package( netCDF ) # list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} ) +# exit early if we don't even need to be here +if ( netCDF_FOUND ) + return() +endif() + + +############################################################################### +# First try to find using netCDF native cmake build +# TODO : Enable this when netCDF native cmake build works well as an imported package +# find_package( netCDF CONFIG ) +# if ( netCDF_FOUND ) +# message( STATUS "Found netCDF through native cmake build" ) +# return() +# endif() +############################################################################### + + +# else # Use nc-config find_program( NETCDF_PROGRAM From 1003f72b2a37c439069711f5d5a6c02caecbeb65 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 9 Jan 2024 18:50:53 +0000 Subject: [PATCH 147/180] Make optional packages default off and must be requested on --- CMakeLists.txt | 15 ++++++++++++--- external/CMakeLists.txt | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c92de611de..fb363cf976 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,6 +141,9 @@ endif() set( USE_DOUBLE OFF CACHE BOOL "USE_DOUBLE" ) set( USE_MPI OFF CACHE BOOL "USE_MPI" ) set( USE_OPENMP OFF CACHE BOOL "USE_OPENMP" ) +set( USE_HDF5 OFF CACHE BOOL "USE_HDF5" ) +set( USE_JASPER OFF CACHE BOOL "USE_JASPER" ) +set( USE_PIO OFF CACHE BOOL "USE_PIO" ) set( USE_IPO OFF CACHE BOOL "USE_IPO" ) @@ -384,13 +387,19 @@ endif() # HDF5 has some funky weirdness between versions where the casing has changed # Optional -find_package( HDF5 ) +if ( ${USE_HDF5} ) + find_package( HDF5 ) +endif() # Optional for grib2 -find_package( Jasper 1.900.1...<1.900.24 ) +if ( ${USE_JASPER} ) + find_package( Jasper 1.900.1...<1.900.24 ) +endif() # Optional -find_package( PIO QUIET ) +if ( ${USE_PIO} ) + find_package( PIO QUIET ) +endif() if ( ${ENABLE_TERRAIN} ) find_package( RPC ) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 268a2a2b6c..7036a9debe 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -66,6 +66,7 @@ if ( ${PIO_FOUND} ) endif() # https://cmake.org/cmake/help/latest/module/FindHDF5.html +# I don't think this is the correct variable to control this IO capability... if ( ${HDF5_IS_PARALLEL} ) message( STATUS "Adding [io_phdf5] to configuration" ) add_subdirectory( io_phdf5 ) From d91185dbad5976b25f2495440cc7483b693163f9 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 12 Jan 2024 16:34:07 -0700 Subject: [PATCH 148/180] Use installed binary location rather than specifying it manually --- cmake/wrf_case_setup.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/wrf_case_setup.cmake b/cmake/wrf_case_setup.cmake index a3bcdcbca7..9cb2a304b7 100644 --- a/cmake/wrf_case_setup.cmake +++ b/cmake/wrf_case_setup.cmake @@ -2,7 +2,7 @@ macro( wrf_setup_targets ) set( options USE_SYMLINKS ) - set( oneValueArgs DEST_PATH OLD_BASE_PATH ) + set( oneValueArgs DEST_PATH ) set( multiValueArgs TARGETS ) cmake_parse_arguments( @@ -26,7 +26,7 @@ macro( wrf_setup_targets ) install( CODE " message( STATUS \"Setting up $ via ${WRF_SETUP_CMD}\" ) - execute_process( COMMAND ${CMAKE_COMMAND} -E ${WRF_SETUP_CMD} ${WRF_SETUP_OLD_BASE_PATH}/$ ${WRF_SETUP_DEST_PATH}/$ ) + execute_process( COMMAND ${CMAKE_COMMAND} -E ${WRF_SETUP_CMD} $ ${WRF_SETUP_DEST_PATH}/$ ) " COMPONENT setup ) From 54e9e0fccb83233d2f2b7a8f891cfddc273aea7f Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 12 Jan 2024 16:35:38 -0700 Subject: [PATCH 149/180] Fix em_real install path --- test/em_real/CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/em_real/CMakeLists.txt b/test/em_real/CMakeLists.txt index 6b90f6ff37..4117a7f5b3 100644 --- a/test/em_real/CMakeLists.txt +++ b/test/em_real/CMakeLists.txt @@ -3,15 +3,14 @@ get_filename_component( FOLDER_DEST ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} NAME ) install( - DIRECTORY ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} - DESTINATION ${CMAKE_INSTALL_PREFIX}/test/ + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} PATTERN CMakeLists.txt EXCLUDE PATTERN .gitignore EXCLUDE ) wrf_setup_targets( TARGETS real tc ndown wrf DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} - OLD_BASE_PATH ${CMAKE_INSTALL_PREFIX}/bin ) wrf_setup_files( From 7abfaeb0429df753bdf0d96ae99a8cd9f4a0d1c4 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 12 Jan 2024 16:36:16 -0700 Subject: [PATCH 150/180] Fix typo in argpack --- .ci/wrf_em_ideal_tests-cmake.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/wrf_em_ideal_tests-cmake.json b/.ci/wrf_em_ideal_tests-cmake.json index a7376b0b96..304f71f183 100644 --- a/.ci/wrf_em_ideal_tests-cmake.json +++ b/.ci/wrf_em_ideal_tests-cmake.json @@ -79,7 +79,7 @@ { "arguments" : { - ".*em_quarter_ss-testcase.*::args_namelist" : + ".*em_quarter_ss.testcase.*::args_namelist" : [ "-n", "namelist.input.02NE,namelist.input.03,namelist.input.03NE" ], From a7117e1c73805b32784f17908fce0ea7f19eb313 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 15 Jan 2024 13:48:42 -0700 Subject: [PATCH 151/180] Get ideal tests now working within same repo directory simultaneously --- .ci/wrf_em_ideal_tests-cmake.json | 72 ++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 25 deletions(-) diff --git a/.ci/wrf_em_ideal_tests-cmake.json b/.ci/wrf_em_ideal_tests-cmake.json index 304f71f183..80b6593866 100644 --- a/.ci/wrf_em_ideal_tests-cmake.json +++ b/.ci/wrf_em_ideal_tests-cmake.json @@ -5,13 +5,15 @@ "working_directory" : "..", "arguments" : { - "base_env_numprocs" : [ "-e", "NUM_PROCS=4" ], + "base_env_numprocs" : [ "-e", "NUM_PROCS=6" ], "base_env_wkdir" : [ "-e", "WK_DIR=$PWD" ], "env_dirs" : [ "-e", "BUILD_DIR=_build_$IDEAL_CASE$DM$SM", "-e", "INSTALL_DIR=$WK_DIR/install_$IDEAL_CASE$DM$SM" ], - ".*build.*::args_compilecmd" : [ "-c", "-p GNU -d $BUILD_DIR -i $INSTALL_DIR -x -- -DWRF_CORE=ARW -DWRF_NESTING=BASIC -DWRF_CASE=$IDEAL_CASE_UPPER $USE_MPI $USE_OPENMP" ], + ".*build.*::args_compilecmd" : [ "-c", "-p GNU -d $BUILD_DIR -i $INSTALL_DIR -x -- -DWRF_CORE=ARW -DWRF_NESTING=$NESTING -DWRF_CASE=$IDEAL_CASE_UPPER $USE_MPI $USE_OPENMP $USE_DOUBLE" ], ".*build.*::args_buildcmd" : [ "-b", "$BUILD_DIR -j $NUM_PROCS" ], ".*build.*::args_cleancmd" : [ "-r", "-d $BUILD_DIR -i $INSTALL_DIR" ], + ".*build.*::args_nesting" : [ "-e", "NESTING=BASIC" ], + ".*build.*::args_precision" : [ "-e", "USE_DOUBLE=-DUSE_DOUBLE=OFF" ], ".*build-omp.*::args_config" : [ "-e", "USE_OPENMP=-DUSE_OPENMP=ON" ], ".*omp.*::args_config" : [ "-e", "SM=_sm" ], @@ -23,9 +25,9 @@ ".*testcase-mpi.*::exec_mpi" : [ "-p", "mpirun -np $NUM_PROCS" ], ".*testcase-omp.*::env" : [ "-e", "OMP_NUM_THREADS=$NUM_PROCS" ], - ".*testcase-serial.*::dir" : [ "-f", ".ci/tests/SCRIPTS/Namelists/weekly/$IDEAL_CASE/", "-s", "serial_results" ], - ".*testcase-omp.*::dir" : [ "-f", ".ci/tests/SCRIPTS/Namelists/weekly/$IDEAL_CASE/", "-i", "serial_results" ], - ".*testcase-mpi.*::dir" : [ "-f", ".ci/tests/SCRIPTS/Namelists/weekly/$IDEAL_CASE/", "-i", "serial_results" ] + ".*testcase-serial.*::dir" : [ "-f", ".ci/tests/SCRIPTS/Namelists/weekly/$IDEAL_CASE/", "-s", "serial_results/$IDEAL_CASE/" ], + ".*testcase-omp.*::dir" : [ "-f", ".ci/tests/SCRIPTS/Namelists/weekly/$IDEAL_CASE/", "-i", "serial_results/$IDEAL_CASE/" ], + ".*testcase-mpi.*::dir" : [ "-f", ".ci/tests/SCRIPTS/Namelists/weekly/$IDEAL_CASE/", "-i", "serial_results/$IDEAL_CASE/" ] }, "polaris" : { @@ -39,6 +41,18 @@ ] } }, + "mmm-mystic" : + { + "submission" : "LOCAL", + "arguments" : + { + "base_env_numprocs" : [ "-e", "NUM_PROCS=9" ], + ".*testcase.*::global_env" : + [ + "-e", "DATA=$HOME/wrf-model/DATA/namelists/Data/" + ] + } + }, "cheyenne" : { "submission" : "PBS", @@ -63,7 +77,7 @@ "timelimit" : "00:10:00", "arguments" : { - "base_env_numprocs" : [ "-e", "NUM_PROCS=2" ], + "base_env_numprocs" : [ "-e", "NUM_PROCS=16" ], ".*testcase.*::global_env" : [ "-e", "DATA=/glade/work/aislas/github/data/wrf/regtest/Data/" @@ -73,17 +87,17 @@ } } }, - "ideal-tests" : + "em_quarter_ss" : { "submit_options" : { "arguments" : { - ".*em_quarter_ss.testcase.*::args_namelist" : + ".*testcase.*::args_namelist" : [ "-n", "namelist.input.02NE,namelist.input.03,namelist.input.03NE" ], - ".*em_quarter_ss.*::args_idealcase" : + ".*::args_idealcase" : [ "-e", "IDEAL_CASE=em_quarter_ss", "-e", "IDEAL_CASE_UPPER=EM_QUARTER_SS" @@ -92,44 +106,44 @@ }, "steps" : { - "em_quarter_ss.build-serial" : + "build-serial" : { "command" : ".ci/tests/buildCMake.sh" }, - "em_quarter_ss.testcase-serial" : + "testcase-serial" : { "submit_options" : { "cheyenne" : { "resources" : "-l select=1:ncpus=1" }, "derecho" : { "resources" : "-l select=1:ncpus=1 -l job_priority=economy" } }, "command" : ".ci/tests/runNamelists.sh", - "dependencies" : { "em_quarter_ss.build-serial" : "afterok" } + "dependencies" : { "build-serial" : "afterok" } }, - "em_quarter_ss.build-omp" : + "build-omp" : { "command" : ".ci/tests/buildCMake.sh" }, - "em_quarter_ss.testcase-omp" : + "testcase-omp" : { "submit_options" : { "cheyenne" : { "resources" : "-l select=1:ncpus=4:ompthreads=4" }, "derecho" : { "resources" : "-l select=1:ncpus=8:ompthreads=8 -l job_priority=economy" } }, "command" : ".ci/tests/runNamelists.sh", - "dependencies" : { "em_quarter_ss.build-omp" : "afterok", "em_quarter_ss.testcase-serial" : "afterok" } + "dependencies" : { "build-omp" : "afterok", "testcase-serial" : "afterok" } }, - "em_quarter_ss.build-mpi" : + "build-mpi" : { "command" : ".ci/tests/buildCMake.sh" }, - "em_quarter_ss.testcase-mpi" : + "testcase-mpi" : { "submit_options" : { "cheyenne" : { "resources" : "-l select=1:ncpus=4:mpiprocs=6" }, "derecho" : { "resources" : "-l select=1:ncpus=8:mpiprocs=8 -l job_priority=economy" } }, "command" : ".ci/tests/runNamelists.sh", - "dependencies" : { "em_quarter_ss.build-mpi" : "afterok", "em_quarter_ss.testcase-serial" : "afterok" } + "dependencies" : { "build-mpi" : "afterok", "testcase-serial" : "afterok" } } } }, @@ -139,15 +153,20 @@ { "arguments" : { - ".*build.*::args_configopt" : [ "-o", "-d -r8" ], + ".*build.*::args_precision" : [ "-e", "USE_DOUBLE=-DUSE_DOUBLE=ON" ], ".*testcase.*::args_namelist" : [ "-n", "namelist.input.08,namelist.input.09" ], ".*::args_idealcase" : [ - "-e", "IDEAL_CASE=em_quarter_ss" - ] + "-e", "IDEAL_CASE=em_quarter_ss", + "-e", "IDEAL_CASE_UPPER=EM_QUARTER_SS" + ], + "env_dirs" : [ "-e", "BUILD_DIR=_build_$IDEAL_CASE$DM$SM-r8", "-e", "INSTALL_DIR=$WK_DIR/install_$IDEAL_CASE$DM$SM-r8" ], + ".*testcase-serial.*::dir" : [ "-f", ".ci/tests/SCRIPTS/Namelists/weekly/$IDEAL_CASE/", "-s", "serial_results/$IDEAL_CASE/double/" ], + ".*testcase-omp.*::dir" : [ "-f", ".ci/tests/SCRIPTS/Namelists/weekly/$IDEAL_CASE/", "-i", "serial_results/$IDEAL_CASE/double/" ], + ".*testcase-mpi.*::dir" : [ "-f", ".ci/tests/SCRIPTS/Namelists/weekly/$IDEAL_CASE/", "-i", "serial_results/$IDEAL_CASE/double/" ] } }, "steps" : @@ -207,7 +226,8 @@ ], ".*::args_idealcase" : [ - "-e", "IDEAL_CASE=em_b_wave" + "-e", "IDEAL_CASE=em_b_wave", + "-e", "IDEAL_CASE_UPPER=EM_B_WAVE" ] } }, @@ -268,7 +288,8 @@ ], ".*::args_idealcase" : [ - "-e", "IDEAL_CASE=em_fire" + "-e", "IDEAL_CASE=em_fire", + "-e", "IDEAL_CASE_UPPER=EM_FIRE" ] } }, @@ -323,14 +344,15 @@ { "arguments" : { - ".*build.*::args_nesting" : [ "-n", "0" ], + ".*build.*::args_nesting" : [ "-e", "NESTING=NONE" ], ".*testcase.*::args_namelist" : [ "-n", "namelist.input.01" ], ".*::args_idealcase" : [ - "-e", "IDEAL_CASE=em_hill2d_x" + "-e", "IDEAL_CASE=em_hill2d_x", + "-e", "IDEAL_CASE_UPPER=EM_HILL2D_X" ] } }, From 331d416eecd4fa605534fa495772d15b2a141008 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 22 Jan 2024 15:46:34 -0700 Subject: [PATCH 152/180] Adding correct logic for CLM --- CMakeLists.txt | 11 +++++++---- phys/module_sf_clm.F | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb363cf976..8dd807db0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,7 +156,7 @@ set( ENABLE_MARS OFF CACHE BOOL "ENABLE_MARS" ) set( ENABLE_VENUS OFF CACHE BOOL "ENABLE_VENUS" ) set( ENABLE_VENUS OFF CACHE BOOL "ENABLE_VENUS" ) set( ENABLE_TERRAIN OFF CACHE BOOL "ENABLE_TERRAIN" ) -set( ENABLE_CLM OFF CACHE BOOL "ENABLE_CLM" ) +set( ENABLE_CTSM OFF CACHE BOOL "ENABLE_CTSM" ) # What do these defines even do if they are always on???? set( USE_ALLOCATABLES ON CACHE BOOL "USE_ALLOCATABLES" ) @@ -405,9 +405,9 @@ if ( ${ENABLE_TERRAIN} ) find_package( RPC ) endif() -if ( ${ENABLE_CLM} ) +if ( ${ENABLE_CTSM} ) # Will need our own finder - # find_package( CLM REQUIRED ) + # find_package( CTSM REQUIRED ) endif() # Will need our own finder @@ -627,7 +627,10 @@ add_compile_definitions( $<$:WRF_TITAN=$> $<$:WRF_MARS=$> $<$:WRF_VENUS=$> - $<$:WRF_USE_CLM=$> + + # 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> diff --git a/phys/module_sf_clm.F b/phys/module_sf_clm.F index 6d11ac7857..6feda0a955 100644 --- a/phys/module_sf_clm.F +++ b/phys/module_sf_clm.F @@ -60994,7 +60994,7 @@ subroutine clminit(VEGFRA,SNOW,SNOWC,SNOWH,CANWAT,SMSTAV, & ENDDO ENDDO IF ( errflag .EQ. 1 ) THEN - CALL wrf_error_fatal( "CLM: clminit: out of range value "// & + CALL wrf_error_fatal( "CLM: clminit: out of range value ", & "of ISLTYP. Is this field in the input?" ) ENDIF !------------------------------------------------------------------------------ From 4b7924294525a692bf48f9d0e506fa3c441b71fe Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 22 Jan 2024 15:46:46 -0700 Subject: [PATCH 153/180] Using new ccpp kind file --- phys/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/phys/CMakeLists.txt b/phys/CMakeLists.txt index 28d80960fb..ee01faf613 100644 --- a/phys/CMakeLists.txt +++ b/phys/CMakeLists.txt @@ -25,6 +25,7 @@ add_dependencies( ${PROJECT_NAME}_Core module_ra_rrtmg_preproc ) target_sources( ${PROJECT_NAME}_Core PRIVATE + ccpp_kind_types.F complex_number_module.F module_bep_bem_helper.F module_bl_acm.F From 17e8905d2426ab6e32e10ad4b9f8ff73200bc201 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 22 Jan 2024 15:57:41 -0700 Subject: [PATCH 154/180] Revert "Making registry work in out of source build" This reverts commit 278a36481782d417a6f6b0655e8e14f502433677. --- tools/gen_streams.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/gen_streams.c b/tools/gen_streams.c index f68897fba6..ad5251ff4d 100644 --- a/tools/gen_streams.c +++ b/tools/gen_streams.c @@ -609,14 +609,12 @@ gen_med_find_esmf_coupling ( FILE *fp ) for each stream. This file is then included by the registry.io_boilerplate file when the registry actually runs. As with the other mods above, this allows a variable, compile-time number of io streams. Note that this one is self contained and dirname is hard-coded. - AI: In an effort to delineate true source files from autogen stuff this is now not going into hard-coded - Registry so that we can use ./ as an alternate include location */ int gen_io_boilerplate () { FILE * fp ; - char * dirname = "./" ; + char * dirname = "Registry" ; char fname[NAMELEN] ; char * fn ; char * aux , *streamtype , streamno[5] ; From 7743a355854e95cb0754bfaea2e63933b2d55036 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 24 Jan 2024 22:43:06 -0700 Subject: [PATCH 155/180] Removing unofficial tests --- .ci/tests/buildCMake.sh | 98 -------- .ci/wrf_em_ideal_tests-cmake.json | 376 ------------------------------ 2 files changed, 474 deletions(-) delete mode 100755 .ci/tests/buildCMake.sh delete mode 100644 .ci/wrf_em_ideal_tests-cmake.json diff --git a/.ci/tests/buildCMake.sh b/.ci/tests/buildCMake.sh deleted file mode 100755 index a86dd7b7cd..0000000000 --- a/.ci/tests/buildCMake.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/sh -help() -{ - echo "./build.sh [workingdir] [options] [-- ]" - echo " [workingdir] First argument must be the working dir to immediate cd to" - echo " -c Configuration build type, piped directly into configure" - echo " -b Build command passed into compile" - echo " -r Clean command passed into cleanCmake" - echo " -e environment variables in comma-delimited list, e.g. var=1,foo,bar=0" - echo " -- Directly pass options to hostenv.sh, equivalent to hostenv.sh " - echo " -h Print this message" - echo "" - echo "If you wish to use an env var in your arg such as '-c \$PRESELECT -e PRESELECT=GNU'," - echo "you will need to do '-c \\\$PRESELECT -e PRESELECT=32' to delay shell expansion" -} - -workingDirectory=$1 -shift -if [ $workingDirectory = "-h" ]; then - help - exit 0 -fi -cd $workingDirectory - -# Get some helper functions -. .ci/env/helpers.sh - -while getopts c:b:r:e:h opt; do - case $opt in - c) - configuration="$OPTARG" - ;; - b) - buildCommand="$OPTARG" - ;; - r) - cleanCommand="$OPTARG" - ;; - e) - envVars="$envVars,$OPTARG" - ;; - h) help; exit 0 ;; - *) help; exit 1 ;; - :) help; exit 1 ;; - \?) help; exit 1 ;; - esac -done - -shift "$((OPTIND - 1))" - -# Everything else goes to our env setup -. .ci/env/hostenv.sh $* - -# Now evaluate env vars in case it pulls from hostenv.sh -if [ ! -z "$envVars" ]; then - setenvStr "$envVars" -fi - -# Re-evaluate input values for delayed expansion -eval "cleanCommand=\"$cleanCommand\"" -eval "configuration=\"$configuration\"" -eval "buildCommand=\"$buildCommand\"" - -echo "./cleanCMake.sh -a $cleanCommand" -./cleanCMake.sh -a $cleanCommand -echo "Clean done" - -echo "./configure_new $configuration" -./configure_new $configuration -result=$? -echo "Configure done" - -if [ $result -ne 0 ]; then - echo "Failed to configure, command returned non-zero exit status" - exit 1 -fi - -echo "./compile_new $buildCommand" -./compile_new $buildCommand -result=$? -echo "Compile done" - - - -if [ $result -ne 0 ]; then - echo "Failed to compile, command returned non-zero exit status" - exit 1 -fi - -# # And a *very* special check because WRF compiles the WRF way and force-ignores all make errors -# # putting the onus on US to check for things -# if [ ! -x $installDirectory/main/wrf ]; then # There's a bunch of other execs but this is the most important and -# # doing more checks to accomodate just reinforces this bad design -# echo "Failed to compile" -# exit 1 -# fi - -echo "TEST $(basename $0) PASS" \ No newline at end of file diff --git a/.ci/wrf_em_ideal_tests-cmake.json b/.ci/wrf_em_ideal_tests-cmake.json deleted file mode 100644 index 80b6593866..0000000000 --- a/.ci/wrf_em_ideal_tests-cmake.json +++ /dev/null @@ -1,376 +0,0 @@ -{ - "submit_options" : - { - "timelimit" : "00:20:00", - "working_directory" : "..", - "arguments" : - { - "base_env_numprocs" : [ "-e", "NUM_PROCS=6" ], - "base_env_wkdir" : [ "-e", "WK_DIR=$PWD" ], - "env_dirs" : [ "-e", "BUILD_DIR=_build_$IDEAL_CASE$DM$SM", "-e", "INSTALL_DIR=$WK_DIR/install_$IDEAL_CASE$DM$SM" ], - - ".*build.*::args_compilecmd" : [ "-c", "-p GNU -d $BUILD_DIR -i $INSTALL_DIR -x -- -DWRF_CORE=ARW -DWRF_NESTING=$NESTING -DWRF_CASE=$IDEAL_CASE_UPPER $USE_MPI $USE_OPENMP $USE_DOUBLE" ], - ".*build.*::args_buildcmd" : [ "-b", "$BUILD_DIR -j $NUM_PROCS" ], - ".*build.*::args_cleancmd" : [ "-r", "-d $BUILD_DIR -i $INSTALL_DIR" ], - ".*build.*::args_nesting" : [ "-e", "NESTING=BASIC" ], - ".*build.*::args_precision" : [ "-e", "USE_DOUBLE=-DUSE_DOUBLE=OFF" ], - - ".*build-omp.*::args_config" : [ "-e", "USE_OPENMP=-DUSE_OPENMP=ON" ], - ".*omp.*::args_config" : [ "-e", "SM=_sm" ], - ".*build-mpi.*::args_config" : [ "-e", "USE_MPI=-DUSE_MPI=ON" ], - ".*mpi.*::args_config" : [ "-e", "DM=_dm" ], - - ".*testcase.*::global_env" : [ "-e", "DATA=/path/to/data" ], - ".*testcase.*::args_always" : [ "-c", "$INSTALL_DIR/test/$IDEAL_CASE", "-b", "ideal", "-d", "$DATA/$IDEAL_CASE" ], - ".*testcase-mpi.*::exec_mpi" : [ "-p", "mpirun -np $NUM_PROCS" ], - ".*testcase-omp.*::env" : [ "-e", "OMP_NUM_THREADS=$NUM_PROCS" ], - - ".*testcase-serial.*::dir" : [ "-f", ".ci/tests/SCRIPTS/Namelists/weekly/$IDEAL_CASE/", "-s", "serial_results/$IDEAL_CASE/" ], - ".*testcase-omp.*::dir" : [ "-f", ".ci/tests/SCRIPTS/Namelists/weekly/$IDEAL_CASE/", "-i", "serial_results/$IDEAL_CASE/" ], - ".*testcase-mpi.*::dir" : [ "-f", ".ci/tests/SCRIPTS/Namelists/weekly/$IDEAL_CASE/", "-i", "serial_results/$IDEAL_CASE/" ] - }, - "polaris" : - { - "submission" : "LOCAL", - "arguments" : - { - "base_env_numprocs" : [ "-e", "NUM_PROCS=2" ], - ".*testcase.*::global_env" : - [ - "-e", "DATA=/mnt/s/github/data/wrf/regtest/Data" - ] - } - }, - "mmm-mystic" : - { - "submission" : "LOCAL", - "arguments" : - { - "base_env_numprocs" : [ "-e", "NUM_PROCS=9" ], - ".*testcase.*::global_env" : - [ - "-e", "DATA=$HOME/wrf-model/DATA/namelists/Data/" - ] - } - }, - "cheyenne" : - { - "submission" : "PBS", - "queue" : "economy", - "resources" : "-l select=1:ncpus=6", - "arguments" : - { - "base_env_numprocs" : [ "-e", "NUM_PROCS=6" ], - ".*testcase.*::global_env" : - [ - "-e", "DATA=/glade/work/aislas/github/data/wrf/regtest/Data/" - ], - "global_modules" : [ "gnu", "netcdf" ], - ".*mpi.*::mpi_module" : [ "openmpi/4.0.3" ] - } - }, - "hsn.de.hpc" : - { - "submission" : "PBS", - "queue" : "main", - "resources" : "-l select=1:ncpus=8 -l job_priority=economy", - "timelimit" : "00:10:00", - "arguments" : - { - "base_env_numprocs" : [ "-e", "NUM_PROCS=16" ], - ".*testcase.*::global_env" : - [ - "-e", "DATA=/glade/work/aislas/github/data/wrf/regtest/Data/" - ], - "global_modules" : [ "gcc", "netcdf", "cmake" ], - ".*mpi.*::mpi_module" : [ "cray-mpich" ] - } - } - }, - "em_quarter_ss" : - { - "submit_options" : - { - "arguments" : - { - ".*testcase.*::args_namelist" : - [ - "-n", "namelist.input.02NE,namelist.input.03,namelist.input.03NE" - ], - ".*::args_idealcase" : - [ - "-e", "IDEAL_CASE=em_quarter_ss", - "-e", "IDEAL_CASE_UPPER=EM_QUARTER_SS" - ] - } - }, - "steps" : - { - "build-serial" : - { - "command" : ".ci/tests/buildCMake.sh" - }, - "testcase-serial" : - { - "submit_options" : { - "cheyenne" : { "resources" : "-l select=1:ncpus=1" }, - "derecho" : { "resources" : "-l select=1:ncpus=1 -l job_priority=economy" } - }, - "command" : ".ci/tests/runNamelists.sh", - "dependencies" : { "build-serial" : "afterok" } - }, - "build-omp" : - { - "command" : ".ci/tests/buildCMake.sh" - }, - "testcase-omp" : - { - "submit_options" : { - "cheyenne" : { "resources" : "-l select=1:ncpus=4:ompthreads=4" }, - "derecho" : { "resources" : "-l select=1:ncpus=8:ompthreads=8 -l job_priority=economy" } - }, - "command" : ".ci/tests/runNamelists.sh", - "dependencies" : { "build-omp" : "afterok", "testcase-serial" : "afterok" } - }, - "build-mpi" : - { - "command" : ".ci/tests/buildCMake.sh" - }, - "testcase-mpi" : - { - "submit_options" : { - "cheyenne" : { "resources" : "-l select=1:ncpus=4:mpiprocs=6" }, - "derecho" : { "resources" : "-l select=1:ncpus=8:mpiprocs=8 -l job_priority=economy" } - }, - "command" : ".ci/tests/runNamelists.sh", - "dependencies" : { "build-mpi" : "afterok", "testcase-serial" : "afterok" } - } - } - }, - "em_quarter_ss_real8" : - { - "submit_options" : - { - "arguments" : - { - ".*build.*::args_precision" : [ "-e", "USE_DOUBLE=-DUSE_DOUBLE=ON" ], - ".*testcase.*::args_namelist" : - [ - "-n", "namelist.input.08,namelist.input.09" - ], - ".*::args_idealcase" : - [ - "-e", "IDEAL_CASE=em_quarter_ss", - "-e", "IDEAL_CASE_UPPER=EM_QUARTER_SS" - ], - "env_dirs" : [ "-e", "BUILD_DIR=_build_$IDEAL_CASE$DM$SM-r8", "-e", "INSTALL_DIR=$WK_DIR/install_$IDEAL_CASE$DM$SM-r8" ], - ".*testcase-serial.*::dir" : [ "-f", ".ci/tests/SCRIPTS/Namelists/weekly/$IDEAL_CASE/", "-s", "serial_results/$IDEAL_CASE/double/" ], - ".*testcase-omp.*::dir" : [ "-f", ".ci/tests/SCRIPTS/Namelists/weekly/$IDEAL_CASE/", "-i", "serial_results/$IDEAL_CASE/double/" ], - ".*testcase-mpi.*::dir" : [ "-f", ".ci/tests/SCRIPTS/Namelists/weekly/$IDEAL_CASE/", "-i", "serial_results/$IDEAL_CASE/double/" ] - } - }, - "steps" : - { - "build-serial" : - { - "command" : ".ci/tests/buildCMake.sh" - }, - "testcase-serial" : - { - "submit_options" : { - "cheyenne" : { "resources" : "-l select=1:ncpus=1" }, - "derecho" : { "resources" : "-l select=1:ncpus=1 -l job_priority=economy" } - }, - "command" : ".ci/tests/runNamelists.sh", - "dependencies" : { "build-serial" : "afterok" } - }, - "build-omp" : - { - "command" : ".ci/tests/buildCMake.sh", - "dependencies" : { "testcase-serial" : "afterok" } - }, - "testcase-omp" : - { - "submit_options" : { - "cheyenne" : { "resources" : "-l select=1:ncpus=4:ompthreads=4" }, - "derecho" : { "resources" : "-l select=1:ncpus=8:ompthreads=8 -l job_priority=economy" } - }, - "command" : ".ci/tests/runNamelists.sh", - "dependencies" : { "build-omp" : "afterok" } - }, - "build-mpi" : - { - "command" : ".ci/tests/buildCMake.sh", - "dependencies" : { "testcase-omp" : "afterok" } - }, - "testcase-mpi" : - { - "submit_options" : { - "cheyenne" : { "resources" : "-l select=1:ncpus=4:mpiprocs=6" }, - "derecho" : { "resources" : "-l select=1:ncpus=8:mpiprocs=8 -l job_priority=economy" } - }, - "command" : ".ci/tests/runNamelists.sh", - "dependencies" : { "build-mpi" : "afterok" } - } - } - }, - "em_b_wave" : - { - "submit_options" : - { - "arguments" : - { - ".*testcase.*::args_namelist" : - [ - "-n", "namelist.input.1NE,namelist.input.2,namelist.input.2NE,namelist.input.3" - ], - ".*::args_idealcase" : - [ - "-e", "IDEAL_CASE=em_b_wave", - "-e", "IDEAL_CASE_UPPER=EM_B_WAVE" - ] - } - }, - "steps" : - { - "build-serial" : - { - "command" : ".ci/tests/buildCMake.sh" - }, - "testcase-serial" : - { - "submit_options" : { - "cheyenne" : { "resources" : "-l select=1:ncpus=1" }, - "derecho" : { "resources" : "-l select=1:ncpus=1 -l job_priority=economy" } - }, - "command" : ".ci/tests/runNamelists.sh", - "dependencies" : { "build-serial" : "afterok" } - }, - "build-omp" : - { - "command" : ".ci/tests/buildCMake.sh", - "dependencies" : { "testcase-serial" : "afterok" } - }, - "testcase-omp" : - { - "submit_options" : { - "cheyenne" : { "resources" : "-l select=1:ncpus=4:ompthreads=4" }, - "derecho" : { "resources" : "-l select=1:ncpus=8:ompthreads=8 -l job_priority=economy" } - }, - "command" : ".ci/tests/runNamelists.sh", - "dependencies" : { "build-omp" : "afterok" } - }, - "build-mpi" : - { - "command" : ".ci/tests/buildCMake.sh", - "dependencies" : { "testcase-omp" : "afterok" } - }, - "testcase-mpi" : - { - "submit_options" : { - "cheyenne" : { "resources" : "-l select=1:ncpus=4:mpiprocs=6" }, - "derecho" : { "resources" : "-l select=1:ncpus=8:mpiprocs=8 -l job_priority=economy" } - }, - "command" : ".ci/tests/runNamelists.sh", - "dependencies" : { "build-mpi" : "afterok" } - } - } - }, - "em_fire" : - { - "submit_options" : - { - "arguments" : - { - ".*testcase.*::args_namelist" : - [ - "-n", "namelist.input.01" - ], - ".*::args_idealcase" : - [ - "-e", "IDEAL_CASE=em_fire", - "-e", "IDEAL_CASE_UPPER=EM_FIRE" - ] - } - }, - "steps" : - { - "build-serial" : - { - "command" : ".ci/tests/buildCMake.sh" - }, - "testcase-serial" : - { - "submit_options" : { - "cheyenne" : { "resources" : "-l select=1:ncpus=1" }, - "derecho" : { "resources" : "-l select=1:ncpus=1 -l job_priority=economy" } - }, - "command" : ".ci/tests/runNamelists.sh", - "dependencies" : { "build-serial" : "afterok" } - }, - "build-omp" : - { - "command" : ".ci/tests/buildCMake.sh", - "dependencies" : { "testcase-serial" : "afterok" } - }, - "testcase-omp" : - { - "submit_options" : { - "cheyenne" : { "resources" : "-l select=1:ncpus=4:ompthreads=4" }, - "derecho" : { "resources" : "-l select=1:ncpus=8:ompthreads=8 -l job_priority=economy" } - }, - "command" : ".ci/tests/runNamelists.sh", - "dependencies" : { "build-omp" : "afterok" } - }, - "build-mpi" : - { - "command" : ".ci/tests/buildCMake.sh", - "dependencies" : { "testcase-omp" : "afterok" } - }, - "testcase-mpi" : - { - "submit_options" : { - "cheyenne" : { "resources" : "-l select=1:ncpus=4:mpiprocs=6" }, - "derecho" : { "resources" : "-l select=1:ncpus=8:mpiprocs=8 -l job_priority=economy" } - }, - "command" : ".ci/tests/runNamelists.sh", - "dependencies" : { "build-mpi" : "afterok" } - } - } - }, - "em_hill2d_x" : - { - "submit_options" : - { - "arguments" : - { - ".*build.*::args_nesting" : [ "-e", "NESTING=NONE" ], - ".*testcase.*::args_namelist" : - [ - "-n", "namelist.input.01" - ], - ".*::args_idealcase" : - [ - "-e", "IDEAL_CASE=em_hill2d_x", - "-e", "IDEAL_CASE_UPPER=EM_HILL2D_X" - ] - } - }, - "steps" : - { - "build-serial" : - { - "command" : ".ci/tests/buildCMake.sh" - }, - "testcase-serial" : - { - "submit_options" : { - "cheyenne" : { "resources" : "-l select=1:ncpus=1" }, - "derecho" : { "resources" : "-l select=1:ncpus=1 -l job_priority=economy" } - }, - "command" : ".ci/tests/runNamelists.sh", - "dependencies" : { "build-serial" : "afterok" } - } - } - } -} \ No newline at end of file From 8ba0eefae6100b84e28190e760ff5d91aeb80de7 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 24 Jan 2024 22:43:59 -0700 Subject: [PATCH 156/180] Add missing traditional flag to cpp --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8dd807db0d..74ce18784f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE ) set( CMAKE_Fortran_PREPROCESS ON ) # This is always set -list( APPEND CMAKE_C_PREPROCESSOR_FLAGS -P -nostdinc ) +list( APPEND CMAKE_C_PREPROCESSOR_FLAGS -P -nostdinc -traditional ) include( CMakePackageConfigHelpers ) include( CheckIPOSupported ) From 46182a98d5af874e37fd221f05ee55f9d13d7454 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 24 Jan 2024 22:46:39 -0700 Subject: [PATCH 157/180] Revert syntax changes due to traditional flag now in place --- dyn_em/module_big_step_utilities_em.F | 4 ++-- phys/module_sf_clm.F | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dyn_em/module_big_step_utilities_em.F b/dyn_em/module_big_step_utilities_em.F index d8c26e809b..ca845a6efd 100644 --- a/dyn_em/module_big_step_utilities_em.F +++ b/dyn_em/module_big_step_utilities_em.F @@ -5733,8 +5733,8 @@ SUBROUTINE moist_physics_finish_em( t_new, t_old, t0, mut, & ! 300 ! term 4 ! IF ( ( config_flags%use_theta_m .EQ. 1 ) .AND. (P_Qv .GE. PARAM_FIRST_SCALAR) ) THEN - t_new(i,k,j) = h_diabatic(i,k,j)*(1. + (R_v/R_d)*qv_diabatic(i,k,j)) + & - mpten*(1. + (R_v/R_d)*qv(i,k,j)) + & + t_new(i,k,j) = h_diabatic(i,k,j)*(1. + (R_v/R_d)*qv_diabatic(i,k,j)) + \ + mpten*(1. + (R_v/R_d)*qv(i,k,j)) + \ (R_v/R_d)*qvten*th_phy(i,k,j) - T0 th_phy_m_t0(i,k,j) = (t_new(i,k,j)+T0)/(1.+(R_v/R_d)*qv(i,k,j)) - T0 h_diabatic(i,k,j) = ( mpten*(1. + (R_v/R_d)*qv(i,k,j)) + & diff --git a/phys/module_sf_clm.F b/phys/module_sf_clm.F index 6feda0a955..6d11ac7857 100644 --- a/phys/module_sf_clm.F +++ b/phys/module_sf_clm.F @@ -60994,7 +60994,7 @@ subroutine clminit(VEGFRA,SNOW,SNOWC,SNOWH,CANWAT,SMSTAV, & ENDDO ENDDO IF ( errflag .EQ. 1 ) THEN - CALL wrf_error_fatal( "CLM: clminit: out of range value ", & + CALL wrf_error_fatal( "CLM: clminit: out of range value "// & "of ISLTYP. Is this field in the input?" ) ENDIF !------------------------------------------------------------------------------ From 6684d468c0a30fe5048c8d5adb6d1d54d522a6c1 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 24 Jan 2024 22:55:52 -0700 Subject: [PATCH 158/180] Missed one single backslash --- dyn_em/module_big_step_utilities_em.F | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dyn_em/module_big_step_utilities_em.F b/dyn_em/module_big_step_utilities_em.F index ca845a6efd..50d7972c62 100644 --- a/dyn_em/module_big_step_utilities_em.F +++ b/dyn_em/module_big_step_utilities_em.F @@ -5737,7 +5737,7 @@ SUBROUTINE moist_physics_finish_em( t_new, t_old, t0, mut, & mpten*(1. + (R_v/R_d)*qv(i,k,j)) + \ (R_v/R_d)*qvten*th_phy(i,k,j) - T0 th_phy_m_t0(i,k,j) = (t_new(i,k,j)+T0)/(1.+(R_v/R_d)*qv(i,k,j)) - T0 - h_diabatic(i,k,j) = ( mpten*(1. + (R_v/R_d)*qv(i,k,j)) + & + h_diabatic(i,k,j) = ( mpten*(1. + (R_v/R_d)*qv(i,k,j)) + \ (R_v/R_d)*qvten*th_phy(i,k,j) ) / dt ELSE t_new(i,k,j) = t_new(i,k,j) + mpten From 5a91180a71734050885c0ebc5aeb30ac560ddf28 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 31 Jan 2024 12:49:58 -0700 Subject: [PATCH 159/180] Note that -c is the default clean option --- cleanCMake.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cleanCMake.sh b/cleanCMake.sh index 85290c8042..33876a6e8f 100755 --- a/cleanCMake.sh +++ b/cleanCMake.sh @@ -5,7 +5,7 @@ installDirectory=install help() { echo "./cleanCMake.sh [options]" - echo " -c Basic cmake clean functionality [cmake --build ${buildDirectory} -j 1 --target clean]" + echo " -c [Default if no options] Basic cmake clean functionality [cmake --build ${buildDirectory} -j 1 --target clean]" echo " -b Remove cmake binary installs [xargs rm < ${buildDirectory}/install_manifest.txt]" echo " -l Remove symlinks (WRF) [ find ${installDirectory}/test -type l -exec rm {} \; ]" echo " -f Remove build & install folders (WRF) [ rm ${buildDirectory} -r; rm ${installDirectory}/ -r ]" From 4b61b40025e3883b0989e707e94e30e83292ab51 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 31 Jan 2024 12:51:37 -0700 Subject: [PATCH 160/180] Update command descriptions to reflect actual shell command execution --- cleanCMake.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cleanCMake.sh b/cleanCMake.sh index 33876a6e8f..cb95bde3f5 100755 --- a/cleanCMake.sh +++ b/cleanCMake.sh @@ -5,11 +5,11 @@ installDirectory=install help() { echo "./cleanCMake.sh [options]" - echo " -c [Default if no options] Basic cmake clean functionality [cmake --build ${buildDirectory} -j 1 --target clean]" + echo " -c [Default if no options] Basic cmake clean functionality [make -j 1 clean]" echo " -b Remove cmake binary installs [xargs rm < ${buildDirectory}/install_manifest.txt]" echo " -l Remove symlinks (WRF) [ find ${installDirectory}/test -type l -exec rm {} \; ]" echo " -f Remove build & install folders (WRF) [ rm ${buildDirectory} -r; rm ${installDirectory}/ -r ]" - echo " -a Remove all (WRF), equivalent to -f -l (more specifically -b -l -f)" + echo " -a Remove all (WRF), equivalent to -c -b -f (more specifically -c then -b then-f)" echo "Specific builds/installs" echo " -d directory Specify operating on particular build directory" echo " -i directory Specify operating on particular install directory" From 25f71049301158ccf6a1116e1f28e2ec1ceb68e0 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 31 Jan 2024 12:51:55 -0700 Subject: [PATCH 161/180] Remove clean links as no softlinks are created now --- cleanCMake.sh | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/cleanCMake.sh b/cleanCMake.sh index cb95bde3f5..06c3a38a8c 100755 --- a/cleanCMake.sh +++ b/cleanCMake.sh @@ -7,7 +7,6 @@ help() echo "./cleanCMake.sh [options]" echo " -c [Default if no options] Basic cmake clean functionality [make -j 1 clean]" echo " -b Remove cmake binary installs [xargs rm < ${buildDirectory}/install_manifest.txt]" - echo " -l Remove symlinks (WRF) [ find ${installDirectory}/test -type l -exec rm {} \; ]" echo " -f Remove build & install folders (WRF) [ rm ${buildDirectory} -r; rm ${installDirectory}/ -r ]" echo " -a Remove all (WRF), equivalent to -c -b -f (more specifically -c then -b then-f)" echo "Specific builds/installs" @@ -21,7 +20,7 @@ cleanLinks=FALSE cleanFolders=FALSE cleanAll=FALSE -while getopts "hcblfad:i:" opt; do +while getopts "hcbfad:i:" opt; do case ${opt} in c) cleanBasicBuild=TRUE @@ -29,9 +28,6 @@ while getopts "hcblfad:i:" opt; do b) cleanBasicInstall=TRUE ;; - l) - cleanLinks=TRUE - ;; f) cleanFolders=TRUE ;; @@ -67,11 +63,6 @@ if [ "${cleanBasicInstall}" = "TRUE" ] || [ "${cleanAll}" = "TRUE" ]; then xargs rm < ${buildDirectory}/install_manifest.txt > /dev/null 2>&1 fi -if [ "${cleanLinks}" = "TRUE" ] || [ "${cleanAll}" = "TRUE" ]; then - echo "Removing all symlinks in ${installDirectory}/test" - find ${installDirectory}/test -type l -exec rm {} \; > /dev/null 2>&1 -fi - if [ "${cleanFolders}" = "TRUE" ] || [ "${cleanAll}" = "TRUE" ]; then echo "Deleting ${buildDirectory} & ${installDirectory}/" rm ${buildDirectory} -r; rm ${installDirectory}/ -r > /dev/null 2>&1 From ceea17d00db69e4967bdcb6ba75a6eb766571a43 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 31 Jan 2024 12:52:53 -0700 Subject: [PATCH 162/180] Add documentation on new build method --- README | 1 + doc/README.cmake_build | 229 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 230 insertions(+) create mode 100644 doc/README.cmake_build diff --git a/README b/README index 30879e360b..0dc23906b0 100644 --- a/README +++ b/README @@ -29,6 +29,7 @@ This is the main directory for the WRF Version 4 source code release. ====================================== Other README files are located in the WRF/doc directory: +doc/README.cmake_build doc/README.crtm doc/README.CTSM doc/README.cygwin.md diff --git a/doc/README.cmake_build b/doc/README.cmake_build new file mode 100644 index 0000000000..d11c248cf6 --- /dev/null +++ b/doc/README.cmake_build @@ -0,0 +1,229 @@ + +How to compile and run? +----------------------- + +- In WRF directory, type './configure_new' - this will create a + _build/wrf_config.cmake file that has appropriate compile options for the + supported computers. + + Note: !! You must clone all submodules manually and have all code prepared !! + !! to compile. No extra steps are done to download code or sanitize it !! + + Note: WRF requires netCDF library, but this cmake build does not require you + to set any environment variables. For netCDF detection, the configuration + will be detected from the `nc-config` in your path unless using + netCDF_ROOT cmake variable. See more information from cmake on *_ROOT + variables if you do not want to use the netCDF associated with the + `nc-config` in your path + + Follow the prompts to select your configuration. The first will be a general + stanza selection, which will only show configurations for which you have the + supported compilers in your path. Likewise, for partially supported stanzas + a '!!' will appear next to that portion of the stanza denoting that this + portion of the stanza is not supported in your environment and thus will not + be selectable via the interactive dialogs. + + Compared to previous version of `configure` this will look much more sparse + and the numbering will be changed to reflect what is availble. For this + reason it will be best to talk about configuration with their description + or some other unique identifier from now on with this build methodology. + + Other common options previously done during the stanza configuration selection + are now broken out into y/n interactive queries. This includes usage of : + * SM (OpenMP) + * DM (MPI) + + Target selection (case), core, and nesting are all done at the configuration phase. + + Any extra configuration parameters that would normally be done through + environment variables or extra command line options are under the + "Configure additional options?" section + + Advanced features of `./configure_new` are discussed later in this document + +- Type './compile_new [any make options such as `-j 12`]' + If the first argument to compile_new is a directory, it will instead use that + directory as the location for building. If not the default is to build the + configuration placed in _build (the default location for `./configure_new` to + place a configuration) + + +- If sucessful, this will create either `real` or `ideal` and `wrf` executables + in the install location's bin/ directory (for default location this will be + install/bin/) and the appropriate executables will be also copied into + the respective test directoires under the same install directory as + /test/. Likewise, for specific test cases that + have additional or modified inputs, those input files are copied from the + respective source location test/ + + Note: Compared to the older compile script, executables do not have the '.exe' + suffix + +- cd to the appropriate test directory in the installation location to run + ideal/real/wrf. + +- If it is one of the idealized cases (b_wave, hill2d_x, grav2d_x, quarter_ss, + squall2d_x, squall2d_y, em_les or em_heldsuarez), cd the the appropriate directory, type + + ./ideal + + to produce wrfinput_d01 file for wrf model. Then type + + ./wrf + + to run. + +- If it is real-data case (real), place files from WPS (met_em.*) + in the appropriate directory, type + + ./real + + to produce wrfbdy_d01 and wrfinput_d01. Then type + + ./wrf + + to run. + +- If you use mpich, type + + mpirun -np number-of-processors wrf + +- If you want to clean your configuration use `./cleanCMake.sh`, additional + options are available, see `./cleanCMake.sh -h` for more info + + +Advanced Configuration +----------------------- + +- The 'configure_new' script is designed to work out-of-the-box with minimal + guidance, however to take full advantage of the features this system brings + one can use `./configure_new -h` to receive a help message: + ./configure_new [options] [-- ] + -p Preselect a stanza configuration with matching description + -x Skip CMake options prompt, meant to be used in conjunction with direct pass-in options + -d directory Use as alternate build directory + -i directory Use as alternate install directory + -- Directly pass CMake options to configuration, equivalent to cmake + -h Print this message + + The '-p' option allows the preselection of a stanza based on its description + without requiring knowledge about its defined number within your environment. + This does require that the stanza exist within the compatible set that would + be available within your environment. + + The '-x' option allows the interactive dialogs to be suppressed, and + configuration will immediately proceed with whatever options have been set or + passed in. This is meant to be used with the '--' delimeter option + + The '-d' option allows us to specify an alternative build/configuration + directory. As CMake best operates with out-of-source builds, our configuration + and compilation all happen within a different directory than the source. The + default name of this directory is _build/, however for more fine-tuned control + or housing multiple builds from the same source repo at the same time one can + specify a different directory name using this option. It is recommended to use + _build* as the prefix to denote this as an autogenerated directory that can be + safely deleted in its entirety + + The '-i' options allows us to specify an alternative install directory for our + compiled configuration. The default value is $PWD/install. Note that the + default includes '$PWD/' - directory locations provided via this option should + use absolute paths as the compile command is executed inside the build + directory, thus any relative paths would be from that location. The files to + be placed in the install directory follows the same premises as the '-d' + option meaning they are autogenerated or copies of source files. This means + the install directory can be safely deleted in its entirety if this + configuration is no longer desired. This also allows multiple installs of + different compilations to coexist from within the same source repo + + The '--' option is meant to be a delimeter marking all subsequent input to be + fed directly to the CMake command execution. In other words, after this marker + anything that you place afterwards is as if you are directly passing in + command line options to `cmake`. This allows you to more effectively use the + '-x' option to skip interactive dialogs and instead write the value you want + beforehand, though usage of this option is not necessary. The option name and + values for a given option, respectively, are always named the same as the + cmake option so utilizing the same option name and value that appears in + the interactive dialog will work. As an example : + + ./configure_new -p GNU -x -- -DWRF_CORE=ARW -DWRF_NESTING=BASIC -DWRF_CASE=EM_REAL + + Would configure immediately configure for the first GNU stanza, using "ARW" as + the WRF_CORE option, "BASIC" as the WRF_NESTING option, and "EM_REAL" as the + WRF_CASE option. Note that the value used is the actual name of the value, not + the numeric shorthand used during interactive dialog. + + +- The 'compile_new' has a complimentary feature to pair with 'configure_new'. + This feature is specifying an alternate build directory to use as a compile + location. The alternate install directory, if used, does not need to be + specified as that is embedded into the cmake configuration files at configure + time. To use this feature, specify the alternate build directory to use as the + first argument ONLY into the script, like so : + + ./configure_new _buildCustomDirectory -j 12 + + Afterwards, all standard make options apply. If no directory is provided it + will be assumed that you are using the default build directory '_build'. This + should be sufficient for normal usage. + + +- The 'cleanCmake.sh' is a cleaning script to more easily facilitate cleaning + configurations, whether configured, compiled, or installed. To see the full + list of options, use `./cleanCmake.sh -h` to receive a help message: + + ./cleanCMake.sh [options] + -c [Default if no options] Basic cmake clean functionality [make -j 1 clean] + -b Remove cmake binary installs [xargs rm < _build/install_manifest.txt] + -f Remove build & install folders (WRF) [ rm _build -r; rm install/ -r ] + -a Remove all (WRF), equivalent to -c -b -f (more specifically -c then -b then -f)" + Specific builds/installs + -d directory Specify operating on particular build directory + -i directory Specify operating on particular install directory + + Each command tells exactly or the equivalent shell commands that would be + executed, but for clarity they are explained below as well. + + The '-c' option is the default usage if no options were passed in, in other + words `./cleanCmake.sh`. This effectively goes into the build directory and + runs `make -j 1 clean`, removing all binary objects in the build directory. + This does not remove files in the install directory. + + The '-b' option removes the installed files from the install directory + manually. This can be useful for reinstating a faulty or manually disrupted + install without needing to entirely recompile. For example, imagine modifying + the provided 'namelist.input' in the test case folder of the install, but not + recalling what the original values were and where the file originates from. + One could clean only the install and reinstall the exact same compilation with + `./cleanCMake.sh -b && ./compile_new` to reobtain a pristine install. + + The '-f' option removes the build and install directories entirely. This is + quickest way to clean but also lose a configuration. It can be very useful if + you find your configuration not working as expected and need a full reset. + This can often happen with CMake caching, which can be a headache to clear. + + The '-a' option can be seen as an alternative to the '-f' option which + effectively in the end does the same but in a more ordered fashion. This will + perform all the cleaning in a step-by-step process first doing the '-c' option, + then the '-b' option, and finally the '-f'. + + + Additional functionality is provided to compliment the advanced features in + 'configure_new' of '-d'/'-i'. These are mimicked in 'cleanCMake.sh' to have + the same usage and flags, so interchanging then between the commands will work. + The effects of 'cleanCMake.sh' cleaning, based on option, will + correspondingly affect the newly specified directories. For example, if an + alternate build directory is provided, the '-b' option will use that instead: + + ./cleanCMake.sh -b -d _buildCustomDirectory + + One might think we would use the install directory when specifying the '-b' + option, but recall that the install location is embeded into the build + configuration and thus removing the installs that cmake did without entirely + removing the install directory requires going to the build directory. This + can be extremely versatile when installing into common locations where other + projects or installed software coexists within a single base install folder. + + + + + From bac485c915285bc28030e795448f0c570d72e5a3 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 31 Jan 2024 12:54:13 -0700 Subject: [PATCH 163/180] Noting default values more concisely and improving printing of options --- arch/configure_reader.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/arch/configure_reader.py b/arch/configure_reader.py index 9c7b603a25..e95f5edc6b 100755 --- a/arch/configure_reader.py +++ b/arch/configure_reader.py @@ -404,7 +404,8 @@ def selectStanza( options ) : # print( stanzaId + stanzaConfig + "[no difference]" ) stanzaIdx += 1 print( "!! - Compiler not found, some configurations will not work and will be hidden" ) - idxSelection = int( input( "Select configuration [0-{stop}] (note !!) : ".format( stop=( stanzaIdx-1) ) ) ) + stringSelection = input( "Select configuration [0-{stop}] Default [0] (note !!) : ".format( stop=( stanzaIdx-1) ) ) + idxSelection = int( stringSelection if stringSelection.isdigit() else 0 ) if idxSelection < 0 or idxSelection > stanzaIdx - 1 : print( "Invalid configuration selection!" ) exit(1) @@ -428,7 +429,7 @@ def selectStanza( options ) : ## Select enum-like string for string-based cmake options ## ######################################################################################################################## -def getStringOptionSelection( topLevelCmake, searchString ) : +def getStringOptionSelection( topLevelCmake, searchString, destinationOption ) : topLevelCmakeFP = open( topLevelCmake, "r" ) topLevelCmakeLines = topLevelCmakeFP.read() topLevelCmakeFP.close() @@ -446,8 +447,9 @@ def getStringOptionSelection( topLevelCmake, searchString ) : # Weed out empties options = [ option for option in options if option ] - optionsFmt = ", ".join( [ "{idx} : {opt}".format( idx=options.index( opt ), opt=opt ) for opt in options ] ) - selection = int( input( "Select option from {optionsStr} [0-{max}] ({opts}) : ".format( optionsStr=searchString, max=len(options)-1, opts=optionsFmt ) ) ) + optionsFmt = "\n\t" + "\n\t".join( [ "{idx} : {opt}".format( idx=options.index( opt ), opt=opt ) for opt in options ] ) + stringSelection = input( "Select option for {option} from {optionsSource} [0-{max}] {opts} \nDefault [0] : ".format( option=destinationOption, optionsSource=searchString, max=len(options)-1, opts=optionsFmt ) ) + selection = int( stringSelection if stringSelection.isdigit() else 0 ) if selection < 0 or selection > len(options) : print( "Invalid option selection for " + searchString + "!" ) @@ -565,9 +567,9 @@ def generateCMakeToolChainFile( cmakeToolChainTemplate, output, stanza, optionsD outputFP.close() def projectSpecificOptions( options, stanzaCfg ) : - coreOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_CORE_OPTIONS" ) - nestingOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_NESTING_OPTIONS" ) - caseOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_CASE_OPTIONS" ) + coreOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_CORE_OPTIONS", "WRF_CORE" ) + nestingOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_NESTING_OPTIONS", "WRF_NESTING" ) + caseOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_CASE_OPTIONS", "WRF_CASE" ) # These are yes yesValues = [ "yes", "y", "true", "1" ] @@ -579,7 +581,7 @@ def projectSpecificOptions( options, stanzaCfg ) : # togglable # we can safely check this since the user would not have been able to select this stanza if it couldn't be disabled if stanzaCfg.dmCompilersAvailable() : - useMPI = input( "[DM] Use MPI? [Y/n] : " ).lower() in yesValues + useMPI = input( "[DM] Use MPI? Default [N] [y/N] : " ).lower() in yesValues else : useMPI = False else: @@ -589,7 +591,7 @@ def projectSpecificOptions( options, stanzaCfg ) : useOpenMP = False if ( stanzaCfg.serialOpt_ or stanzaCfg.dmparOpt_ ) and ( stanzaCfg.smparOpt_ or stanzaCfg.dmsmOpt_ ): # togglable - useOpenMP = input( "[SM] Use OpenMP? [Y/n] : " ).lower() in yesValues + useOpenMP = input( "[SM] Use OpenMP? Default [N] [y/N] : " ).lower() in yesValues else: # User has no choice in the matter useOpenMP = ( stanzaCfg.smparOpt_ or stanzaCfg.dmsmOpt_ ) @@ -597,7 +599,7 @@ def projectSpecificOptions( options, stanzaCfg ) : ############################################################################## alreadyAsked = [ "USE_MPI", "USE_OPENMP" ] - doSuboptionMenu = input( "Configure additional options? [Y/n] : " ).lower() in yesValues + doSuboptionMenu = input( "Configure additional options? Default [N] [y/N] : " ).lower() in yesValues subOptions = {} if doSuboptionMenu : subOptions = getSubOptions( options.sourceCMakeFile, alreadyAsked ) From 62b0e9371bce9103b1a2ba9b03cd6fb61ee78e88 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 31 Jan 2024 18:00:56 -0700 Subject: [PATCH 164/180] Correctly installing cmake config files so other projects can link against WRF using find_package() --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 74ce18784f..775877b1ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -861,6 +861,7 @@ target_link_libraries( ${PROJECT_NAME}_Core ## Install and export ## ################################################################################ +set( CONFIG_INSTALL_DIRECTORY lib/cmake/${PROJECT_NAME} ) install( TARGETS ${PROJECT_NAME}_Core EXPORT ${EXPORT_NAME}Targets @@ -872,7 +873,7 @@ install( # Install to namespace install( EXPORT ${EXPORT_NAME}Targets - DESTINATION lib/cmake/ + DESTINATION ${CONFIG_INSTALL_DIRECTORY} FILE ${EXPORT_NAME}Targets.cmake NAMESPACE ${EXPORT_NAME}:: ) @@ -880,7 +881,7 @@ install( configure_package_config_file( ${PROJECT_SOURCE_DIR}/cmake/template/${EXPORT_NAME}Config.cmake.in ${CMAKE_BINARY_DIR}/${EXPORT_NAME}Config.cmake - INSTALL_DESTINATION lib/cmake + INSTALL_DESTINATION ${CONFIG_INSTALL_DIRECTORY} ) write_basic_package_version_file( @@ -894,7 +895,7 @@ install( FILES ${CMAKE_BINARY_DIR}/${EXPORT_NAME}Config.cmake ${CMAKE_BINARY_DIR}/${EXPORT_NAME}ConfigVersion.cmake - DESTINATION lib/cmake + DESTINATION ${CONFIG_INSTALL_DIRECTORY} ) # Install some helper files for anyone using this build as part of their code From 67ac1a0ce2a0e6cbd7ff6286caf1027435f18fc2 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 1 Feb 2024 10:46:31 -0700 Subject: [PATCH 165/180] Set default build type to release if not specified --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 775877b1ef..0664246941 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,7 @@ set( WRF_OS "" ) set( WRF_MACH "" ) if ( "${CMAKE_BUILD_TYPE}" STREQUAL "" ) - set( CMAKE_BUILD_TYPE Debug ) + set( CMAKE_BUILD_TYPE Release ) message( STATUS "Set default build type to ${CMAKE_BUILD_TYPE}" ) endif() ################################################################################ From 2c7c39637f05b63cbaa2d05dcf9b014c57d0d90a Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 1 Feb 2024 10:51:14 -0700 Subject: [PATCH 166/180] Set MPI to default on if available --- arch/configure_reader.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/configure_reader.py b/arch/configure_reader.py index e95f5edc6b..b4d0706675 100755 --- a/arch/configure_reader.py +++ b/arch/configure_reader.py @@ -573,6 +573,8 @@ def projectSpecificOptions( options, stanzaCfg ) : # These are yes yesValues = [ "yes", "y", "true", "1" ] + # Acceptable no values + noValues = [ "no", "n", "false", "0" ] ############################################################################## # Decompose the weird way to write the logic for DM/SM @@ -581,7 +583,7 @@ def projectSpecificOptions( options, stanzaCfg ) : # togglable # we can safely check this since the user would not have been able to select this stanza if it couldn't be disabled if stanzaCfg.dmCompilersAvailable() : - useMPI = input( "[DM] Use MPI? Default [N] [y/N] : " ).lower() in yesValues + useMPI = not( input( "[DM] Use MPI? Default [Y] [Y/n] : " ).lower() in noValues ) else : useMPI = False else: From c454589c2be1bc1bc2973493e2f6b9ddd5f73de2 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 1 Feb 2024 10:55:07 -0700 Subject: [PATCH 167/180] Add ability to set default option selection for string options based on index assigned --- arch/configure_reader.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/configure_reader.py b/arch/configure_reader.py index b4d0706675..2803f1fe4b 100755 --- a/arch/configure_reader.py +++ b/arch/configure_reader.py @@ -429,7 +429,7 @@ def selectStanza( options ) : ## Select enum-like string for string-based cmake options ## ######################################################################################################################## -def getStringOptionSelection( topLevelCmake, searchString, destinationOption ) : +def getStringOptionSelection( topLevelCmake, searchString, destinationOption, defaultIndex=0 ) : topLevelCmakeFP = open( topLevelCmake, "r" ) topLevelCmakeLines = topLevelCmakeFP.read() topLevelCmakeFP.close() @@ -448,8 +448,15 @@ def getStringOptionSelection( topLevelCmake, searchString, destinationOption ) : options = [ option for option in options if option ] optionsFmt = "\n\t" + "\n\t".join( [ "{idx} : {opt}".format( idx=options.index( opt ), opt=opt ) for opt in options ] ) - stringSelection = input( "Select option for {option} from {optionsSource} [0-{max}] {opts} \nDefault [0] : ".format( option=destinationOption, optionsSource=searchString, max=len(options)-1, opts=optionsFmt ) ) - selection = int( stringSelection if stringSelection.isdigit() else 0 ) + stringSelection = input( "Select option for {option} from {optionsSource} [0-{max}] {opts} \nDefault [{defIdx}] : ".format( + option=destinationOption, + optionsSource=searchString, + max=len(options)-1, + opts=optionsFmt, + defIdx=defaultIndex + ) + ) + selection = int( stringSelection if stringSelection.isdigit() else defaultIndex ) if selection < 0 or selection > len(options) : print( "Invalid option selection for " + searchString + "!" ) From b09c6c574ad8dc8f4c48cc5235677ae681feae89 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 1 Feb 2024 10:57:29 -0700 Subject: [PATCH 168/180] Set default WRF_NESTING value to 1/BASIC --- arch/configure_reader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/configure_reader.py b/arch/configure_reader.py index 2803f1fe4b..fb89bfca80 100755 --- a/arch/configure_reader.py +++ b/arch/configure_reader.py @@ -575,7 +575,7 @@ 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" ) + nestingOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_NESTING_OPTIONS", "WRF_NESTING", 1 ) caseOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_CASE_OPTIONS", "WRF_CASE" ) # These are yes From b60bd7ed534470f78b3c738cce2ce83c19244317 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 7 Feb 2024 08:59:23 -0700 Subject: [PATCH 169/180] Change Darwin configurations to include architecture before (MACOS) string --- arch/configure.defaults | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/configure.defaults b/arch/configure.defaults index 36ca1b6e00..06d56315d8 100644 --- a/arch/configure.defaults +++ b/arch/configure.defaults @@ -818,7 +818,7 @@ CC_TOOLS = $(SCC) NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin (MACOS) PGI compiler with pgcc #serial smpar dmpar dm+sm +#ARCH Darwin x86_64 aarch64, (MACOS) PGI compiler with pgcc #serial smpar dmpar dm+sm # DESCRIPTION = PGI ($SFC/$SCC) DMPARALLEL = # 1 @@ -862,7 +862,7 @@ CC_TOOLS = cc NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin (MACOS) intel compiler with icc #serial smpar dmpar dm+sm +#ARCH Darwin x86_64 aarch64, (MACOS) intel compiler with icc #serial smpar dmpar dm+sm # DESCRIPTION = INTEL ($SFC/$SCC) DMPARALLEL = # 1 @@ -909,7 +909,7 @@ CC_TOOLS = cc NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin (MACOS) intel compiler with clang EDIT FOR OPENMPI #serial smpar dmpar dm+sm +#ARCH Darwin x86_64 aarch64, (MACOS) intel compiler with clang EDIT FOR OPENMPI #serial smpar dmpar dm+sm # DESCRIPTION = INTEL ($SFC/$SCC) DMPARALLEL = # 1 @@ -955,7 +955,7 @@ CC_TOOLS = cc NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin (MACOS) g95 with gcc #serial dmpar +#ARCH Darwin x86_64 aarch64, (MACOS) g95 with gcc #serial dmpar # DESCRIPTION = GNU ($SFC/$SCC) DMPARALLEL = # 1 @@ -1000,7 +1000,7 @@ CC_TOOLS = $(SCC) NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin (MACOS) gfortran with gcc #serial smpar dmpar dm+sm +#ARCH Darwin x86_64 aarch64, (MACOS) gfortran with gcc #serial smpar dmpar dm+sm # DESCRIPTION = GNU ($SFC/$SCC) DMPARALLEL = # 1 @@ -1045,7 +1045,7 @@ CC_TOOLS = $(SCC) NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin (MACOS) gfortran with clang #serial smpar dmpar dm+sm +#ARCH Darwin x86_64 aarch64, (MACOS) gfortran with clang #serial smpar dmpar dm+sm # DESCRIPTION = GNU ($SFC/clang) DMPARALLEL = # 1 @@ -1090,7 +1090,7 @@ CC_TOOLS = clang NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin (MACOS) xlf #serial dmpar +#ARCH Darwin x86_64 aarch64, (MACOS) xlf #serial dmpar # DESCRIPTION = IBM ($SFC/$SCC) DMPARALLEL = # 1 @@ -1695,7 +1695,7 @@ CC_TOOLS = $(SCC) NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin (MACOS) PGI compiler with pgcc -f90= #serial smpar dmpar dm+sm +#ARCH Darwin x86_64 aarch64, (MACOS) PGI compiler with pgcc -f90= #serial smpar dmpar dm+sm # DESCRIPTION = PGI ($SFC/$SCC): -f90=pgf90 DMPARALLEL = # 1 @@ -1739,7 +1739,7 @@ CC_TOOLS = cc NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin (MACOS) intel compiler with icc #serial smpar dmpar dm+sm +#ARCH Darwin x86_64 aarch64, (MACOS) intel compiler with icc #serial smpar dmpar dm+sm # DESCRIPTION = INTEL ($SFC/$SCC): Open MPI DMPARALLEL = # 1 @@ -1786,7 +1786,7 @@ CC_TOOLS = cc NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin (MACOS) gfortran with gcc openmpi #serial smpar dmpar dm+sm +#ARCH Darwin x86_64 aarch64, (MACOS) gfortran with gcc openmpi #serial smpar dmpar dm+sm # DESCRIPTION = GNU ($SFC/$SCC): Open MPI DMPARALLEL = # 1 From 983f82a9ee602abab66aa93cf620673fcb354f8b Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 8 Feb 2024 16:22:21 -0700 Subject: [PATCH 170/180] Use arm64 as architecture string rather than aarch64 for Darwin --- arch/configure.defaults | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/configure.defaults b/arch/configure.defaults index 06d56315d8..1275f3ce33 100644 --- a/arch/configure.defaults +++ b/arch/configure.defaults @@ -818,7 +818,7 @@ CC_TOOLS = $(SCC) NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin x86_64 aarch64, (MACOS) PGI compiler with pgcc #serial smpar dmpar dm+sm +#ARCH Darwin x86_64 arm64, (MACOS) PGI compiler with pgcc #serial smpar dmpar dm+sm # DESCRIPTION = PGI ($SFC/$SCC) DMPARALLEL = # 1 @@ -862,7 +862,7 @@ CC_TOOLS = cc NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin x86_64 aarch64, (MACOS) intel compiler with icc #serial smpar dmpar dm+sm +#ARCH Darwin x86_64 arm64, (MACOS) intel compiler with icc #serial smpar dmpar dm+sm # DESCRIPTION = INTEL ($SFC/$SCC) DMPARALLEL = # 1 @@ -909,7 +909,7 @@ CC_TOOLS = cc NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin x86_64 aarch64, (MACOS) intel compiler with clang EDIT FOR OPENMPI #serial smpar dmpar dm+sm +#ARCH Darwin x86_64 arm64, (MACOS) intel compiler with clang EDIT FOR OPENMPI #serial smpar dmpar dm+sm # DESCRIPTION = INTEL ($SFC/$SCC) DMPARALLEL = # 1 @@ -955,7 +955,7 @@ CC_TOOLS = cc NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin x86_64 aarch64, (MACOS) g95 with gcc #serial dmpar +#ARCH Darwin x86_64 arm64, (MACOS) g95 with gcc #serial dmpar # DESCRIPTION = GNU ($SFC/$SCC) DMPARALLEL = # 1 @@ -1000,7 +1000,7 @@ CC_TOOLS = $(SCC) NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin x86_64 aarch64, (MACOS) gfortran with gcc #serial smpar dmpar dm+sm +#ARCH Darwin x86_64 arm64, (MACOS) gfortran with gcc #serial smpar dmpar dm+sm # DESCRIPTION = GNU ($SFC/$SCC) DMPARALLEL = # 1 @@ -1045,7 +1045,7 @@ CC_TOOLS = $(SCC) NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin x86_64 aarch64, (MACOS) gfortran with clang #serial smpar dmpar dm+sm +#ARCH Darwin x86_64 arm64, (MACOS) gfortran with clang #serial smpar dmpar dm+sm # DESCRIPTION = GNU ($SFC/clang) DMPARALLEL = # 1 @@ -1090,7 +1090,7 @@ CC_TOOLS = clang NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin x86_64 aarch64, (MACOS) xlf #serial dmpar +#ARCH Darwin x86_64 arm64, (MACOS) xlf #serial dmpar # DESCRIPTION = IBM ($SFC/$SCC) DMPARALLEL = # 1 @@ -1695,7 +1695,7 @@ CC_TOOLS = $(SCC) NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin x86_64 aarch64, (MACOS) PGI compiler with pgcc -f90= #serial smpar dmpar dm+sm +#ARCH Darwin x86_64 arm64, (MACOS) PGI compiler with pgcc -f90= #serial smpar dmpar dm+sm # DESCRIPTION = PGI ($SFC/$SCC): -f90=pgf90 DMPARALLEL = # 1 @@ -1739,7 +1739,7 @@ CC_TOOLS = cc NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin x86_64 aarch64, (MACOS) intel compiler with icc #serial smpar dmpar dm+sm +#ARCH Darwin x86_64 arm64, (MACOS) intel compiler with icc #serial smpar dmpar dm+sm # DESCRIPTION = INTEL ($SFC/$SCC): Open MPI DMPARALLEL = # 1 @@ -1786,7 +1786,7 @@ CC_TOOLS = cc NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD ########################################################### -#ARCH Darwin x86_64 aarch64, (MACOS) gfortran with gcc openmpi #serial smpar dmpar dm+sm +#ARCH Darwin x86_64 arm64, (MACOS) gfortran with gcc openmpi #serial smpar dmpar dm+sm # DESCRIPTION = GNU ($SFC/$SCC): Open MPI DMPARALLEL = # 1 From 8c42ccadefeb918de55c16bdc79373cf5ad604df Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 13 Feb 2024 12:06:22 -0700 Subject: [PATCH 171/180] Add shared physics files to cmake compilation --- phys/CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/phys/CMakeLists.txt b/phys/CMakeLists.txt index ee01faf613..d7d85e1c12 100644 --- a/phys/CMakeLists.txt +++ b/phys/CMakeLists.txt @@ -253,6 +253,17 @@ target_sources( module_shcu_nscv.F module_surface_driver.F module_wind_fitch.F + module_wind_mav.F + + # Shared physics + physics_mmm/bl_gwdo.F90 + physics_mmm/bl_ysu.F90 + physics_mmm/cu_ntiedtke.F90 + physics_mmm/module_libmassv.F90 + physics_mmm/mp_radar.F90 + physics_mmm/mp_wsm6.F90 + physics_mmm/mp_wsm6_effectRad.F90 + physics_mmm/sf_sfclayrev.F90 ) From f7f6fcb905e61bb07cb3812efeca9460aaa0167f Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 13 Feb 2024 12:27:09 -0700 Subject: [PATCH 172/180] Fix install location of tables and data --- test/em_real/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/em_real/CMakeLists.txt b/test/em_real/CMakeLists.txt index 4117a7f5b3..f714d3da73 100644 --- a/test/em_real/CMakeLists.txt +++ b/test/em_real/CMakeLists.txt @@ -1,6 +1,6 @@ # These are just rules for this case, could be named CMakeLists.txt or something # like install_rules.cmake, whatever you want really -get_filename_component( FOLDER_DEST ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} NAME ) +get_filename_component( FOLDER_DEST ${CMAKE_CURRENT_SOURCE_DIR} NAME ) install( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} From b04996b8d5ce40f15dd49ee0e661e336e079de73 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 14 Feb 2024 10:43:25 -0700 Subject: [PATCH 173/180] Set p3 tables to newer correct values --- test/em_real/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/em_real/CMakeLists.txt b/test/em_real/CMakeLists.txt index f714d3da73..5cd6ff52f2 100644 --- a/test/em_real/CMakeLists.txt +++ b/test/em_real/CMakeLists.txt @@ -67,9 +67,9 @@ wrf_setup_files( ${PROJECT_SOURCE_DIR}/run/bulkradii.asc_s_0_03_0_9 ${PROJECT_SOURCE_DIR}/run/CCN_ACTIVATE.BIN # These might be p3_lookupTable_1.dat-v5.4_* - ${PROJECT_SOURCE_DIR}/run/p3_lookupTable_1.dat-5.3-2momI - ${PROJECT_SOURCE_DIR}/run/p3_lookupTable_1.dat-3momI_v5.1.7 - ${PROJECT_SOURCE_DIR}/run/p3_lookupTable_2.dat-2momI_v5.2.3 + ${PROJECT_SOURCE_DIR}/run/p3_lookupTable_1.dat-v5.4_2momI + ${PROJECT_SOURCE_DIR}/run/p3_lookupTable_1.dat-v5.4_3momI + ${PROJECT_SOURCE_DIR}/run/p3_lookupTable_2.dat-v5.3 ${PROJECT_SOURCE_DIR}/run/HLC.TBL ${PROJECT_SOURCE_DIR}/run/wind-turbine-1.tbl ${PROJECT_SOURCE_DIR}/run/ishmael-gamma-tab.bin From 464f539737998077674f70a7d2253367c9a11d76 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 14 Feb 2024 10:44:07 -0700 Subject: [PATCH 174/180] Remove COAMPS option --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0664246941..32a36f6154 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,7 +74,6 @@ endif() set( WRF_CORE_OPTIONS # Options listed here ARW - COAMPS # Not sure how this is used CONVERT # This exists in compile but not configure DA # Var directory DA_4D_VAR From 33fb761351e79e99381a938d973211409a438c7f Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 14 Feb 2024 10:51:08 -0700 Subject: [PATCH 175/180] Set correct location for MPTABLE.TBL --- test/em_real/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/em_real/CMakeLists.txt b/test/em_real/CMakeLists.txt index 5cd6ff52f2..b1d88726b4 100644 --- a/test/em_real/CMakeLists.txt +++ b/test/em_real/CMakeLists.txt @@ -66,7 +66,6 @@ wrf_setup_files( ${PROJECT_SOURCE_DIR}/run/bulkdens.asc_s_0_03_0_9 ${PROJECT_SOURCE_DIR}/run/bulkradii.asc_s_0_03_0_9 ${PROJECT_SOURCE_DIR}/run/CCN_ACTIVATE.BIN - # These might be p3_lookupTable_1.dat-v5.4_* ${PROJECT_SOURCE_DIR}/run/p3_lookupTable_1.dat-v5.4_2momI ${PROJECT_SOURCE_DIR}/run/p3_lookupTable_1.dat-v5.4_3momI ${PROJECT_SOURCE_DIR}/run/p3_lookupTable_2.dat-v5.3 @@ -84,7 +83,7 @@ wrf_setup_files( ${PROJECT_SOURCE_DIR}/run/URBPARM.TBL ${PROJECT_SOURCE_DIR}/run/URBPARM_LCZ.TBL ${PROJECT_SOURCE_DIR}/run/VEGPARM.TBL - ${PROJECT_SOURCE_DIR}/run/MPTABLE.TBL # Missing? + ${PROJECT_SOURCE_DIR}/phys/noahmp/parameters/MPTABLE.TBL ${PROJECT_SOURCE_DIR}/run/tr49t67 ${PROJECT_SOURCE_DIR}/run/tr49t85 ${PROJECT_SOURCE_DIR}/run/tr67t85 From f6da85a6f860576b9cb5529060703fea17739a4e Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 15 Feb 2024 09:50:44 -0700 Subject: [PATCH 176/180] Move install namelist.input files up one to match other installs --- test/em_real/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/em_real/CMakeLists.txt b/test/em_real/CMakeLists.txt index b1d88726b4..493feee90f 100644 --- a/test/em_real/CMakeLists.txt +++ b/test/em_real/CMakeLists.txt @@ -4,7 +4,7 @@ get_filename_component( FOLDER_DEST ${CMAKE_CURRENT_SOURCE_DIR} NAME ) install( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - DESTINATION ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} + DESTINATION ${CMAKE_INSTALL_PREFIX}/test/ PATTERN CMakeLists.txt EXCLUDE PATTERN .gitignore EXCLUDE ) From 759df0346b678e20dc0a50b2e7c04553eae653d6 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 15 Feb 2024 11:15:00 -0700 Subject: [PATCH 177/180] Use install location so links don't rely on build location and add .exe link automatically --- cmake/wrf_case_setup.cmake | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cmake/wrf_case_setup.cmake b/cmake/wrf_case_setup.cmake index 9cb2a304b7..4e65dc0a72 100644 --- a/cmake/wrf_case_setup.cmake +++ b/cmake/wrf_case_setup.cmake @@ -23,10 +23,22 @@ macro( wrf_setup_targets ) #!TODO Do we *need* the rm for symlinks beforehand? # get_filename_component( WRF_SETUP_FILE_ONLY $ NAME + # If we ever wanted to link or copy things other than binaries we could change this + set( WRF_SETUP_INSTALL_LOCATION ${CMAKE_INSTALL_PREFIX}/bin ) + install( CODE " message( STATUS \"Setting up $ via ${WRF_SETUP_CMD}\" ) - execute_process( COMMAND ${CMAKE_COMMAND} -E ${WRF_SETUP_CMD} $ ${WRF_SETUP_DEST_PATH}/$ ) + execute_process( COMMAND ${CMAKE_COMMAND} -E ${WRF_SETUP_CMD} ${WRF_SETUP_INSTALL_LOCATION}/$ ${WRF_SETUP_DEST_PATH}/$ ) + " + COMPONENT setup + ) + + # Add .exe link as well + install( + CODE " + message( STATUS \"Creating symlink for $.exe\" ) + execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink ${WRF_SETUP_DEST_PATH}/$ ${WRF_SETUP_DEST_PATH}/$.exe ) " COMPONENT setup ) From 981aafada5dcc35fd997273d6f10f6ed616ccbb8 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 15 Feb 2024 11:18:14 -0700 Subject: [PATCH 178/180] Switch to symlinks for binaries --- test/em_b_wave/CMakeLists.txt | 1 + test/em_convrad/CMakeLists.txt | 1 + test/em_fire/CMakeLists.txt | 1 + test/em_grav2d_x/CMakeLists.txt | 1 + test/em_heldsuarez/CMakeLists.txt | 1 + test/em_hill2d_x/CMakeLists.txt | 1 + test/em_les/CMakeLists.txt | 1 + test/em_quarter_ss/CMakeLists.txt | 1 + test/em_real/CMakeLists.txt | 1 + test/em_scm_xy/CMakeLists.txt | 1 + test/em_seabreeze2d_x/CMakeLists.txt | 1 + test/em_squall2d_x/CMakeLists.txt | 1 + test/em_squall2d_y/CMakeLists.txt | 1 + test/em_tropical_cyclone/CMakeLists.txt | 1 + 14 files changed, 14 insertions(+) diff --git a/test/em_b_wave/CMakeLists.txt b/test/em_b_wave/CMakeLists.txt index e11c3c229c..1fdecccc5e 100644 --- a/test/em_b_wave/CMakeLists.txt +++ b/test/em_b_wave/CMakeLists.txt @@ -11,6 +11,7 @@ install( wrf_setup_targets( TARGETS ideal wrf DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} + USE_SYMLINKS ) wrf_setup_files( diff --git a/test/em_convrad/CMakeLists.txt b/test/em_convrad/CMakeLists.txt index 075a4d4245..b362766fab 100644 --- a/test/em_convrad/CMakeLists.txt +++ b/test/em_convrad/CMakeLists.txt @@ -11,6 +11,7 @@ install( wrf_setup_targets( TARGETS ideal wrf DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} + USE_SYMLINKS ) wrf_setup_files( diff --git a/test/em_fire/CMakeLists.txt b/test/em_fire/CMakeLists.txt index e11c3c229c..1fdecccc5e 100644 --- a/test/em_fire/CMakeLists.txt +++ b/test/em_fire/CMakeLists.txt @@ -11,6 +11,7 @@ install( wrf_setup_targets( TARGETS ideal wrf DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} + USE_SYMLINKS ) wrf_setup_files( diff --git a/test/em_grav2d_x/CMakeLists.txt b/test/em_grav2d_x/CMakeLists.txt index e11c3c229c..1fdecccc5e 100644 --- a/test/em_grav2d_x/CMakeLists.txt +++ b/test/em_grav2d_x/CMakeLists.txt @@ -11,6 +11,7 @@ install( wrf_setup_targets( TARGETS ideal wrf DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} + USE_SYMLINKS ) wrf_setup_files( diff --git a/test/em_heldsuarez/CMakeLists.txt b/test/em_heldsuarez/CMakeLists.txt index e11c3c229c..1fdecccc5e 100644 --- a/test/em_heldsuarez/CMakeLists.txt +++ b/test/em_heldsuarez/CMakeLists.txt @@ -11,6 +11,7 @@ install( wrf_setup_targets( TARGETS ideal wrf DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} + USE_SYMLINKS ) wrf_setup_files( diff --git a/test/em_hill2d_x/CMakeLists.txt b/test/em_hill2d_x/CMakeLists.txt index e11c3c229c..1fdecccc5e 100644 --- a/test/em_hill2d_x/CMakeLists.txt +++ b/test/em_hill2d_x/CMakeLists.txt @@ -11,6 +11,7 @@ install( wrf_setup_targets( TARGETS ideal wrf DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} + USE_SYMLINKS ) wrf_setup_files( diff --git a/test/em_les/CMakeLists.txt b/test/em_les/CMakeLists.txt index e11c3c229c..1fdecccc5e 100644 --- a/test/em_les/CMakeLists.txt +++ b/test/em_les/CMakeLists.txt @@ -11,6 +11,7 @@ install( wrf_setup_targets( TARGETS ideal wrf DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} + USE_SYMLINKS ) wrf_setup_files( diff --git a/test/em_quarter_ss/CMakeLists.txt b/test/em_quarter_ss/CMakeLists.txt index c4deda7890..54ffc652fc 100644 --- a/test/em_quarter_ss/CMakeLists.txt +++ b/test/em_quarter_ss/CMakeLists.txt @@ -11,6 +11,7 @@ install( wrf_setup_targets( TARGETS ideal wrf DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} + USE_SYMLINKS ) wrf_setup_files( diff --git a/test/em_real/CMakeLists.txt b/test/em_real/CMakeLists.txt index 493feee90f..f4ac4b0fd5 100644 --- a/test/em_real/CMakeLists.txt +++ b/test/em_real/CMakeLists.txt @@ -11,6 +11,7 @@ install( wrf_setup_targets( TARGETS real tc ndown wrf DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} + USE_SYMLINKS ) wrf_setup_files( diff --git a/test/em_scm_xy/CMakeLists.txt b/test/em_scm_xy/CMakeLists.txt index 960134a9c6..fad4a9b122 100644 --- a/test/em_scm_xy/CMakeLists.txt +++ b/test/em_scm_xy/CMakeLists.txt @@ -11,6 +11,7 @@ install( wrf_setup_targets( TARGETS ideal wrf DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} + USE_SYMLINKS ) wrf_setup_files( diff --git a/test/em_seabreeze2d_x/CMakeLists.txt b/test/em_seabreeze2d_x/CMakeLists.txt index 440ed57794..00e2c6c7a7 100644 --- a/test/em_seabreeze2d_x/CMakeLists.txt +++ b/test/em_seabreeze2d_x/CMakeLists.txt @@ -11,6 +11,7 @@ install( wrf_setup_targets( TARGETS ideal wrf DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} + USE_SYMLINKS ) wrf_setup_files( diff --git a/test/em_squall2d_x/CMakeLists.txt b/test/em_squall2d_x/CMakeLists.txt index e11c3c229c..1fdecccc5e 100644 --- a/test/em_squall2d_x/CMakeLists.txt +++ b/test/em_squall2d_x/CMakeLists.txt @@ -11,6 +11,7 @@ install( wrf_setup_targets( TARGETS ideal wrf DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} + USE_SYMLINKS ) wrf_setup_files( diff --git a/test/em_squall2d_y/CMakeLists.txt b/test/em_squall2d_y/CMakeLists.txt index e11c3c229c..1fdecccc5e 100644 --- a/test/em_squall2d_y/CMakeLists.txt +++ b/test/em_squall2d_y/CMakeLists.txt @@ -11,6 +11,7 @@ install( wrf_setup_targets( TARGETS ideal wrf DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} + USE_SYMLINKS ) wrf_setup_files( diff --git a/test/em_tropical_cyclone/CMakeLists.txt b/test/em_tropical_cyclone/CMakeLists.txt index cc2ccaa8a3..f7422e0971 100644 --- a/test/em_tropical_cyclone/CMakeLists.txt +++ b/test/em_tropical_cyclone/CMakeLists.txt @@ -11,6 +11,7 @@ install( wrf_setup_targets( TARGETS ideal wrf DEST_PATH ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST} + USE_SYMLINKS ) wrf_setup_files( From 31e07dba7ab51dacf6aa2373c1e32bd4358c2338 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 15 Feb 2024 11:45:55 -0700 Subject: [PATCH 179/180] Create analogous run/ directory in install/ --- main/CMakeLists.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index bb553a7d31..9a2f69eca6 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -130,3 +130,24 @@ install( ARCHIVE DESTINATION lib/ LIBRARY DESTINATION lib/ ) + +# Install the "run" directory +install( + DIRECTORY ${PROJECT_SOURCE_DIR}/run/ + DESTINATION ${CMAKE_INSTALL_PREFIX}/run + PATTERN CMakeLists.txt EXCLUDE + PATTERN .gitignore EXCLUDE + ) +wrf_setup_targets( + TARGETS ${FOLDER_COMPILE_TARGETS} + DEST_PATH ${CMAKE_INSTALL_PREFIX}/run + USE_SYMLINKS + ) + +# Re-setup this particular file +wrf_setup_files( + FILES + ${PROJECT_SOURCE_DIR}/phys/noahmp/parameters/MPTABLE.TBL + DEST_PATH + ${CMAKE_INSTALL_PREFIX}/run/ + ) From 7895715c0c5c11064df1efcd687692a3e0b6bfae Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 15 Feb 2024 11:46:16 -0700 Subject: [PATCH 180/180] Change install of mixing_ratio to link to better identify where it is coming from --- test/em_real/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/em_real/CMakeLists.txt b/test/em_real/CMakeLists.txt index f4ac4b0fd5..d68270361a 100644 --- a/test/em_real/CMakeLists.txt +++ b/test/em_real/CMakeLists.txt @@ -97,6 +97,7 @@ wrf_setup_files( wrf_setup_file_new_name( FILE ${PROJECT_SOURCE_DIR}/run/CAMtr_volume_mixing_ratio.SSP245 NEW_NAME ${CMAKE_INSTALL_PREFIX}/test/${FOLDER_DEST}/CAMtr_volume_mixing_ratio + USE_SYMLINKS )