From 757a1aadbe305aaf2a94464f5df800acd42f4f07 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 5 Mar 2024 16:05:17 -0700 Subject: [PATCH 01/23] CMake files for initial chem and chem+kpp builds --- CMakeLists.txt | 9 +- chem/CMakeLists.txt | 71 +++++---- chem/KPP/kpp/kpp-2.1/CMakeLists.txt | 44 ++++++ chem/KPP/util/wkc/CMakeLists.txt | 221 ++++++++++++++++++++++++++++ 4 files changed, 319 insertions(+), 26 deletions(-) create mode 100644 chem/KPP/kpp/kpp-2.1/CMakeLists.txt create mode 100644 chem/KPP/util/wkc/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cd0264b72..0f20d044ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required( VERSION 3.20 ) cmake_policy( SET CMP0118 NEW ) +cmake_policy( SET CMP0098 NEW ) enable_language( C ) enable_language( CXX ) @@ -254,6 +255,7 @@ endif() if ( ${ENABLE_KPP} AND NOT ${ENABLE_CHEM} ) message( WARNING "ENABLE_KPP requires ENABLE_CHEM but is not set, ignoring" ) + set( ENABLE_KPP OFF CACHE BOOL "Force ignore by configuration" FORCE ) endif() @@ -472,6 +474,11 @@ if ( ${ENABLE_CTSM} ) # find_package( CTSM REQUIRED ) endif() +if ( ${ENABLE_KPP} ) + find_package( BISON REQUIRED ) + find_package( FLEX REQUIRED ) +endif() + # Will need our own finder # find_package( GPFS REQUIRED ) @@ -914,7 +921,7 @@ add_subdirectory( share ) add_subdirectory( frame ) add_subdirectory( inc ) -if ( ${WRF_CHEM} ) +if ( ${ENABLE_CHEM} ) add_subdirectory( chem ) endif() diff --git a/chem/CMakeLists.txt b/chem/CMakeLists.txt index 544b253256..2515c0a3f6 100644 --- a/chem/CMakeLists.txt +++ b/chem/CMakeLists.txt @@ -4,6 +4,10 @@ target_include_directories( PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ) +add_subdirectory( KPP/kpp/kpp-2.1 ) +add_subdirectory( KPP/util/wkc ) + +set( KPP_SOURCES KPP/module_wkppc_constants.F ) ######################################################################################################################## # @@ -13,6 +17,7 @@ target_include_directories( target_sources( ${PROJECT_NAME}_Core PRIVATE + ${KPP_SOURCES} module_data_isrpia_data.F module_data_ISRPIA.F module_data_isrpia_asrc.F @@ -209,31 +214,47 @@ target_sources( aerosol_driver.F ) -######################################################################################################################## -# -# convert_emiss executable -# -######################################################################################################################## -add_executable( - convert_emiss - convert_emiss.F - ) - -target_link_libraries( - convert_emiss - PRIVATE - ${PROJECT_NAME}_Core - ) +#!TODO: I'm not entirely sure when this exec is supposed to be generated or if it +# is exclusive to the real test case +# ######################################################################################################################## +# # +# # convert_emiss executable +# # +# ######################################################################################################################## +# set( CONVERT_EMISS_TARGET convert_emiss ) +# add_executable( +# ${CONVERT_EMISS_TARGET} +# convert_emiss.F +# ) -target_compile_options( - convert_emiss - PRIVATE - ${PROJECT_COMPILE_OPTIONS} - ) +# target_link_libraries( +# ${CONVERT_EMISS_TARGET} +# PRIVATE +# ${PROJECT_NAME}_Core +# ) +# set_target_properties( +# ${CONVERT_EMISS_TARGET} +# PROPERTIES +# # Just dump everything in here +# Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/modules/${CONVERT_EMISS_TARGET}/ +# Fortran_FORMAT FREE +# ) +# target_compile_options( +# convert_emiss +# PRIVATE +# ${PROJECT_COMPILE_OPTIONS} +# ) -target_compile_definitions( - convert_emiss - PRIVATE - ${PROJECT_COMPILE_DEFINITIONS} - ) +# target_compile_definitions( +# convert_emiss +# PRIVATE +# ${PROJECT_COMPILE_DEFINITIONS} +# ) +# install( +# TARGETS ${CONVERT_EMISS_TARGET} +# EXPORT ${EXPORT_NAME}Targets +# RUNTIME DESTINATION bin/ +# ARCHIVE DESTINATION lib/ +# LIBRARY DESTINATION lib/ +# ) diff --git a/chem/KPP/kpp/kpp-2.1/CMakeLists.txt b/chem/KPP/kpp/kpp-2.1/CMakeLists.txt new file mode 100644 index 0000000000..914eb3a192 --- /dev/null +++ b/chem/KPP/kpp/kpp-2.1/CMakeLists.txt @@ -0,0 +1,44 @@ +# Port of cflags.guess logic +# If the compiler starts with "cc" +if ( ${CMAKE_C_COMPILER} MATCHES "(/|\\\\)cc[A-Za-z0-9_]*$" ) + if ( ${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" ) + message( FATAL_ERROR "KPP must be compiled with gcc on SunOS machines" ) + endif() + + set( + KPP_CC_FLAGS + "$<$,$>:-Aa;-D_HPUX_SOURCE>" #@ Hewlett Packard Unix + "$<$,$>:-Aa>" #@ IBM Unix operating system + ) +endif() + + +FLEX_TARGET( + kpp_lex + scan.l + ${CMAKE_CURRENT_BINARY_DIR}/preproc/lex.yy.c + ) + +BISON_TARGET( + kpp_tab + scan.y + ${CMAKE_CURRENT_BINARY_DIR}/preproc/y.tab.c + ) + +add_executable( + kpp + ${FLEX_kpp_lex_OUTPUTS} + ${BISON_kpp_tab_OUTPUTS} + scanner.c + scanutil.c + kpp.c + gen.c + code.c + code_c.c + code_f77.c + code_f90.c + code_matlab.c + debug.c + ) + +target_link_libraries( kpp PRIVATE ${FLEX_LIBRARIES} ) \ No newline at end of file diff --git a/chem/KPP/util/wkc/CMakeLists.txt b/chem/KPP/util/wkc/CMakeLists.txt new file mode 100644 index 0000000000..894433c640 --- /dev/null +++ b/chem/KPP/util/wkc/CMakeLists.txt @@ -0,0 +1,221 @@ + + +set( FOLDER_COMPILE_TARGET registry_kpp ) + +add_executable( + ${FOLDER_COMPILE_TARGET} + ) + +set( GEN_COMMS ${PROJECT_SOURCE_DIR}/tools/gen_comms.stub ) +# 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 +# Apparently chem-kpp does not use the rsl_lite comms, but I'm leaving the logic +# here just in case it needs to change +set_source_files_properties( + ${GEN_COMMS} + TARGET_DIRECTORY ${FOLDER_COMPILE_TARGET} + PROPERTIES + LANGUAGE C + ) +# endif() + +target_sources( + ${FOLDER_COMPILE_TARGET} + PRIVATE + registry_kpp.c + ${PROJECT_SOURCE_DIR}/tools/my_strtok.c + ${PROJECT_SOURCE_DIR}/tools/reg_parse.c + ${PROJECT_SOURCE_DIR}/tools/data.c + ${PROJECT_SOURCE_DIR}/tools/type.c + ${PROJECT_SOURCE_DIR}/tools/misc.c + ${PROJECT_SOURCE_DIR}/tools/sym.c + ${PROJECT_SOURCE_DIR}/tools/symtab_gen.c + + gen_kpp.c + get_wrf_chem_specs.c + gen_kpp_mech_dr.c + gen_kpp_interface.c + get_kpp_chem_specs.c + compare_kpp_to_species.c + get_wrf_radicals.c + get_wrf_jvals.c + gen_kpp_utils.c + gen_kpp_interf_utils.c + gen_kpp_args_to_Update_Rconst.c + kpp_data.c + list_kpp_generated.c + + ${GEN_COMMS} + + # gen_defs.c + # gen_allocs.c + # gen_mod_state_descr.c + # gen_scalar_indices.c + # gen_args.c + # gen_config.c + # gen_irr_diag.c + # gen_model_data_ord.c + # gen_interp.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_include_directories( ${FOLDER_COMPILE_TARGET} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR}/tools + ) + +# Make sure we don't do any weird in-place modification of files +target_compile_definitions( ${FOLDER_COMPILE_TARGET} PRIVATE NO_MODIFY_MAKEFILE ) + +# Should this be installed? Consider also removing regular registry from install... +# install( +# TARGETS ${FOLDER_COMPILE_TARGET} +# RUNTIME DESTINATION bin/ +# ARCHIVE DESTINATION lib/ +# LIBRARY DESTINATION lib/ +# ) + + +# Quickly add tuv_kpp exec as well and generate tuv photolysis inc file +add_executable( tuv_kpp tuv_kpp.c ) + + +for all kpp_mech dirs + + # util/create_inc_files model + for u l b a ibu ib ia e as thing + if kpp_mechd_${thing}_${model}.inc not exist + create + if extra_args_to_update_rconst_${model}.inc not exist + create + if extra_args_update_rconst_${model}.inc not exist + create + if extra_decls_update_rconst_${model}.inc not exist + create + + # run kpp model, generates .F files - KPP_HOME must be set by this point + # often set to chem/KPP/kpp/kpp-2.1 in case you didn't know it was KPP + kpp ${model}.kpp + ${model}_Integrator.f90 + ${model}_Parameters.f90 + ${model}_Precision.f90 + ${model}_JacobianSP.f90 + ${model}_Jacobian.f90 + ${model}_Update_Rconst.f90 + + + if tuv.jmap + gen first once + gen ${model} + + # write_decom ${model} chem_dir + find in ${model}_Integrator.f90 if decomp && call + make + + +if tuv.jmap used + gen last once + +"gather" KPP/inc/*.inc files (known) + + +# Now do coupler + + + + +add_custom_command( + OUTPUT + ${CMAKE_BINARY_DIR}/inc/tuv2wrf_jvals.inc + ${CMAKE_BINARY_DIR}/inc/tuvdef_jvals.inc + WORKING_DIRECTORY + ${CMAKE_BINARY_DIR} + # Replicate what exists in project directory for registry + COMMAND + ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/inc + COMMAND + ${CMAKE_BINARY_DIR}/tools/registry ${REGISTRY_DEFS} -DNEW_BDYS ${REGISTRY_FILE} > ${CMAKE_BINARY_DIR}/registry.log 2>&1 + #!TODO Just have the registry code actually check for failure or better yet rewrite the + # 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 + ) + + + + + + + + + +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 +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_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 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 + ${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 + ) + + + + From 47a922dfac6a1a7b139222c010514782eb6f9e11 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 5 Mar 2024 16:06:47 -0700 Subject: [PATCH 02/23] Rewrite of tuv_kpp directory finding --- chem/KPP/compile_wkc | 6 +++--- chem/KPP/util/wkc/tuv_kpp.c | 17 +++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/chem/KPP/compile_wkc b/chem/KPP/compile_wkc index 1d0cdc190c..0695e772d3 100755 --- a/chem/KPP/compile_wkc +++ b/chem/KPP/compile_wkc @@ -118,10 +118,10 @@ echo $kdir # generate tuv photolysis inc files if( -e $model.tuv.jmap ) then if( $found == 0 ) then - $WKC_HOME/util/wkc/tuv_kpp FIRST + $WKC_HOME/util/wkc/tuv_kpp FIRST ../../inc/ set found = 1 endif - $WKC_HOME/util/wkc/tuv_kpp $model + $WKC_HOME/util/wkc/tuv_kpp $model ../../../../inc/ endif if ( `echo $WRFC_ROOT | awk '{print ( length ( $1 ) > 40 ) }' `) then @@ -139,7 +139,7 @@ end # finish tuv photolysis inc files if( $found == 1 ) then - $WKC_HOME/util/wkc/tuv_kpp LAST + $WKC_HOME/util/wkc/tuv_kpp LAST ../../inc/ endif echo "=========================================================" diff --git a/chem/KPP/util/wkc/tuv_kpp.c b/chem/KPP/util/wkc/tuv_kpp.c index cd878c5df3..d3e9890ce1 100644 --- a/chem/KPP/util/wkc/tuv_kpp.c +++ b/chem/KPP/util/wkc/tuv_kpp.c @@ -46,21 +46,22 @@ int main( int argc, char *argv[], char *env[] ) { argv++; strcpy( mech,*argv ); + argv++; + strcpy( dir,*argv ); + fprintf(stderr,"tuv_kpp: Argument = %s\n",mech); // open and write inc files + strcpy( fname_inc, dir ); + strcat( fname_inc, "tuv2wrf_jvals.inc" ); - if( !strcmp(mech,"LAST") ) - strcpy(fname_inc,"../../inc/tuv2wrf_jvals.inc"); - else - strcpy(fname_inc,"../../../../inc/tuv2wrf_jvals.inc"); if( (fp_set = fopen( fname_inc,"a" )) == NULL ) { fprintf(stderr,"Can not open %s\n",fname_inc ); return(-1); } - if( !strcmp(mech,"LAST") ) - strcpy(fname_inc,"../../inc/tuvdef_jvals.inc"); - else - strcpy(fname_inc,"../../../../inc/tuvdef_jvals.inc"); + + strcpy( fname_inc, dir ); + strcat( fname_inc, "tuvdef_jvals.inc" ); + if( (fp_def = fopen( fname_inc,"a" )) == NULL ) { fprintf(stderr,"Can not open %s\n",fname_inc ); return(-1); From b23cbec820bac0152d7a115328e73bd17abc9375 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 5 Mar 2024 16:07:42 -0700 Subject: [PATCH 03/23] Try to get rid of in situ rewriting files --- chem/KPP/util/wkc/gen_kpp.c | 8 +++--- chem/KPP/util/wkc/list_kpp_generated.c | 37 ++++++++++++++++++++++++++ chem/KPP/util/wkc/protos_kpp.h | 5 +++- 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 chem/KPP/util/wkc/list_kpp_generated.c diff --git a/chem/KPP/util/wkc/gen_kpp.c b/chem/KPP/util/wkc/gen_kpp.c index 63dcd2f853..01b6a317af 100644 --- a/chem/KPP/util/wkc/gen_kpp.c +++ b/chem/KPP/util/wkc/gen_kpp.c @@ -225,12 +225,14 @@ gen_kpp ( char * inc_dirname, char * kpp_dirname ) check_all ( kpp_dirname ); - +#ifdef NO_MODIFY_MAKEFILE + // Write the kpp generated modules to a file + list_kpp_generated( ); +#else /* add the kpp generated modules to the Makefile in the chem directory */ if ( DEBUGR == 1 ) printf("next: change_chem_Makefile \n"); change_chem_Makefile ( ); - - +#endif /* write the mechanism driver */ diff --git a/chem/KPP/util/wkc/list_kpp_generated.c b/chem/KPP/util/wkc/list_kpp_generated.c new file mode 100644 index 0000000000..838947b1e4 --- /dev/null +++ b/chem/KPP/util/wkc/list_kpp_generated.c @@ -0,0 +1,37 @@ +#include + + +#include "protos.h" +#include "protos_kpp.h" +#include "kpp_data.h" + + + +void +list_kpp_generated( ) +{ + knode_t * p1, * p2, * pm1; + FILE *output; + char *output_filename = "kpp_sources.txt"; + char kname[NAMELEN]; + + output = fopen( output_filename, "W" ); + + for ( p1 = KPP_packs ; p1 != NULL ; p1 = p1->next ) + { + p2 = p1->assoc_wrf_pack; + if ( p2 ) + { + strcpy( kname, p1->name ); + fprintf( output, "module_kpp_%s_Integr.o \\\n", kname ); + fprintf( output, "module_kpp_%s_Precision.o \\\n", kname ); + fprintf( output, "module_kpp_%s_Parameters.o \\\n", kname ); + fprintf( output, "module_kpp_%s_Jacobian.o \\\n", kname ); + fprintf( output, "module_kpp_%s_JacobianSP.o \\\n", kname ); + fprintf( output, "module_kpp_%s_Update_Rconst.o \\\n", kname ); + fprintf( output, "module_kpp_%s_interface.o \\\n", kname ); + } + } + + fclose( output ); +} diff --git a/chem/KPP/util/wkc/protos_kpp.h b/chem/KPP/util/wkc/protos_kpp.h index e1f6c41b65..58c3f2a64f 100644 --- a/chem/KPP/util/wkc/protos_kpp.h +++ b/chem/KPP/util/wkc/protos_kpp.h @@ -18,8 +18,11 @@ int compare_kpp_to_species ( char * kpp_dirname) ; int run_kpp( char * dirname , char * kpp_version ); +#ifdef NO_MODIFY_MAKEFILE +void list_kpp_generated( ); +#else void change_chem_Makefile( ); - +#endif void gen_kpp_mechanism_driver ( ); void gen_kpp_call_to_mech_dr ( ); From 392cba7816fceb5c5422498711fc95a3784f7490 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 5 Mar 2024 16:08:28 -0700 Subject: [PATCH 04/23] Break up ifdefs for cmake to properly generate dependencies --- chem/chem_driver.F | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/chem/chem_driver.F b/chem/chem_driver.F index 8650b9444a..485574ffe6 100755 --- a/chem/chem_driver.F +++ b/chem/chem_driver.F @@ -43,11 +43,12 @@ subroutine chem_driver ( grid , config_flags & USE module_wetdep_ls, only:wetdep_ls USE module_uoc_dustwd ! Claudia, 3 April 2014 [mklose 03082015] USE module_input_chem_data, only: last_chem_time, & + mozcart_lbc_set, & + bdy_chem_value_top_pv, & + PVS #if (defined(CHEM_DBG_I) && defined(CHEM_DBG_J) && defined(CHEM_DBG_K)) - chem_dbg, & + USE module_input_chem_data, only: chem_dbg #endif - mozcart_lbc_set, & - bdy_chem_value_top_pv,PVS USE module_chem_share, only: get_last_gas USE module_upper_bc_driver, only: upper_bc_driver USE module_tropopause, only: tropopause_driver From 553be7eefbd3b8077f660e0e16400761d2df09ef Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Tue, 5 Mar 2024 16:08:56 -0700 Subject: [PATCH 05/23] Fix highly irregular indentation so edits are much easier --- chem/KPP/util/write_decomp/integr_edit.c | 110 ++++++++++------------- 1 file changed, 47 insertions(+), 63 deletions(-) diff --git a/chem/KPP/util/write_decomp/integr_edit.c b/chem/KPP/util/write_decomp/integr_edit.c index 82faae53c4..e2f04640dd 100644 --- a/chem/KPP/util/write_decomp/integr_edit.c +++ b/chem/KPP/util/write_decomp/integr_edit.c @@ -28,96 +28,80 @@ main( int argc, char *argv[] ) argv++ ; if ( *argv ) - { - strcpy( mechname, *argv ); - } + { + strcpy( mechname, *argv ); + } else - { - printf("ERROR: USAGE: integr_edit mech_name\n"); - exit(11); - } + { + printf("ERROR: USAGE: integr_edit mech_name\n"); + exit(11); + } - sprintf ( intfname, "module_kpp_%s_Integr.F", mechname); - sprintf ( incfname, "decomp_%s.inc", mechname); - sprintf ( tfname, "%s_new", intfname ); + sprintf( intfname, "module_kpp_%s_Integr.F", mechname ); + sprintf( incfname, "decomp_%s.inc", mechname ); + sprintf( tfname, "%s_new", intfname ); - sprintf( cp_command,"cp %s %s",tfname, intfname); + sprintf( cp_command,"cp %s %s",tfname, intfname ); - intf = fopen( intfname , "r" ); - incf = fopen( incfname , "r" ); - ofile = fopen( tfname , "w" ); + intf = fopen( intfname, "r" ); + incf = fopen( incfname, "r" ); + ofile = fopen( tfname, "w" ); - sprintf ( callln , " CALL %s_KppDecomp\0", mechname ); - sprintf ( endln , "END MODULE"); - - /* loop over lines in Integr file */ - while ( fgets ( inln , 4096 , intf ) != NULL ){ - - copyit=1; - - - /* replace call to decomp routine */ - - if ( !strncmp (inln, callln, strlen(callln)-1) ) { - - printf(" integr_edit: replacing %s \n", inln); - - fprintf(ofile, "!!! use direct adressing in decomp \n"); - fprintf(ofile, "!!! %s", inln); - fprintf(ofile, "CALL decomp_%s ( A, ising )\n", mechname ); - - - add_sub=1; - copyit=0; - } + sprintf( callln, " CALL %s_KppDecomp\0", mechname ); + sprintf( endln, "END MODULE" ); + /* loop over lines in Integr file */ + while ( fgets( inln , 4096 , intf ) != NULL ) { - /* add decomp routine w. direct referncing */ + copyit = 1; - if ( !strncmp (inln, endln, strlen(endln)-1) ) { - if ( add_sub ){ - printf(" %s ", inln ); - while ( fgets ( incln , 4096 , incf ) != NULL ){ + /* replace call to decomp routine */ + if ( !strncmp( inln, callln, strlen( callln ) - 1 ) ) { - fprintf(ofile, "%s", incln); + printf(" integr_edit: replacing %s \n", inln); + fprintf(ofile, "!!! use direct adressing in decomp \n"); + fprintf(ofile, "!!! %s", inln); + fprintf(ofile, "CALL decomp_%s ( A, ising )\n", mechname ); - } - - fprintf(ofile, " \n\n\n"); - } - } - - - - - /* copy line from original file */ - if ( copyit ) { - - fprintf(ofile, "%s", inln); + add_sub = 1; + copyit = 0; + } - } + /* add decomp routine w. direct referncing */ + if ( !strncmp (inln, endln, strlen(endln)-1) ) { - } + if ( add_sub ) { + printf(" %s ", inln ); + while ( fgets ( incln , 4096 , incf ) != NULL ) { + fprintf( ofile, "%s", incln ); + } + fprintf(ofile, " \n\n\n"); + } + } - if ( ! add_sub ) { - printf(" integr_edit: Kept previous version. \n "); - } + /* copy line from original file */ + if ( copyit ) { + fprintf( ofile, "%s", inln ); + } + } + if ( ! add_sub ) { + printf( " integr_edit: Kept previous version. \n " ); + } fclose( intf ); fclose( incf ); fclose( ofile ); - - system(cp_command); + system(cp_command); exit (0); } From 40917bfd93a23bcbe532395c94ea3a9604451cca Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 6 Mar 2024 17:18:54 -0700 Subject: [PATCH 06/23] Adjust arguments to allow for finer control of read/write files --- chem/KPP/util/write_decomp/CMakeLists.txt | 2 ++ chem/KPP/util/write_decomp/Makefile | 2 +- chem/KPP/util/write_decomp/integr_edit.c | 25 ++++++++++++----------- 3 files changed, 16 insertions(+), 13 deletions(-) create mode 100644 chem/KPP/util/write_decomp/CMakeLists.txt diff --git a/chem/KPP/util/write_decomp/CMakeLists.txt b/chem/KPP/util/write_decomp/CMakeLists.txt new file mode 100644 index 0000000000..3259150cef --- /dev/null +++ b/chem/KPP/util/write_decomp/CMakeLists.txt @@ -0,0 +1,2 @@ +# Compile once and only ONCE +add_executable( integration_edit integr_edit.c ) diff --git a/chem/KPP/util/write_decomp/Makefile b/chem/KPP/util/write_decomp/Makefile index 7be276bf72..f8f1ebbe6d 100644 --- a/chem/KPP/util/write_decomp/Makefile +++ b/chem/KPP/util/write_decomp/Makefile @@ -28,7 +28,7 @@ all: $(MAKE) comp ./write_decomp.exe $(MAKE) integr_edit - ./integr_edit.exe $(MECH) + ./integr_edit.exe $(MECH) module_kpp_$(MECH)_Integr.F decomp_$(MODEL).inc $(MODEL)_new $(MAKE) clean diff --git a/chem/KPP/util/write_decomp/integr_edit.c b/chem/KPP/util/write_decomp/integr_edit.c index e2f04640dd..dee009dce4 100644 --- a/chem/KPP/util/write_decomp/integr_edit.c +++ b/chem/KPP/util/write_decomp/integr_edit.c @@ -25,23 +25,22 @@ main( int argc, char *argv[] ) FILE * ofile; - argv++ ; - - if ( *argv ) - { - strcpy( mechname, *argv ); - } - else + + if ( argc != 5 ) { - printf("ERROR: USAGE: integr_edit mech_name\n"); + printf("ERROR: USAGE: integr_edit mech_name integrator_file decomp_inc_file output_file\n"); exit(11); } - sprintf( intfname, "module_kpp_%s_Integr.F", mechname ); - sprintf( incfname, "decomp_%s.inc", mechname ); - sprintf( tfname, "%s_new", intfname ); + argv++ ; + strcpy( mechname, *argv ); - + argv++; + strcpy( intfname, *argv ); + argv++; + strcpy( incfname, *argv ); + argv++; + strcpy( tfname, *argv ); sprintf( cp_command,"cp %s %s",tfname, intfname ); @@ -101,7 +100,9 @@ main( int argc, char *argv[] ) fclose( incf ); fclose( ofile ); +#ifndef NO_COPY system(cp_command); +#endif exit (0); } From 8bcc973ecd6deb7bb4f43c67e32b29fa1dec3c06 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 6 Mar 2024 17:19:51 -0700 Subject: [PATCH 07/23] Set open mode so no need to manually remove or track file --- chem/KPP/util/wkc/tuv_kpp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/chem/KPP/util/wkc/tuv_kpp.c b/chem/KPP/util/wkc/tuv_kpp.c index d3e9890ce1..aeb9d4d7e4 100644 --- a/chem/KPP/util/wkc/tuv_kpp.c +++ b/chem/KPP/util/wkc/tuv_kpp.c @@ -31,6 +31,7 @@ int main( int argc, char *argv[], char *env[] ) { char squezzed[NAMELEN]; char *wrf_jname, *cwrk, *tuv_jspec, *token; char *tuv_jname; + char openMode = "a"; FILE * fp_in, *fp_set, *fp_def; wrf_node *Wrf_node; wrf_node *Wrf_HEAD; @@ -54,7 +55,11 @@ int main( int argc, char *argv[], char *env[] ) { strcpy( fname_inc, dir ); strcat( fname_inc, "tuv2wrf_jvals.inc" ); - if( (fp_set = fopen( fname_inc,"a" )) == NULL ) { + if( !strcmp(mech,"FIRST") ) { + openMode = "w"; + } + + if( (fp_set = fopen( fname_inc, openMode )) == NULL ) { fprintf(stderr,"Can not open %s\n",fname_inc ); return(-1); } @@ -62,7 +67,7 @@ int main( int argc, char *argv[], char *env[] ) { strcpy( fname_inc, dir ); strcat( fname_inc, "tuvdef_jvals.inc" ); - if( (fp_def = fopen( fname_inc,"a" )) == NULL ) { + if( (fp_def = fopen( fname_inc, openMode )) == NULL ) { fprintf(stderr,"Can not open %s\n",fname_inc ); return(-1); } From c7f0dc4f94ce4ade220217cd5157e57f7a62a959 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 6 Mar 2024 17:20:48 -0700 Subject: [PATCH 08/23] Disable registry_kpp for now --- chem/KPP/util/wkc/CMakeLists.txt | 193 ++++++++++++------------------- 1 file changed, 72 insertions(+), 121 deletions(-) diff --git a/chem/KPP/util/wkc/CMakeLists.txt b/chem/KPP/util/wkc/CMakeLists.txt index 894433c640..0425f402fa 100644 --- a/chem/KPP/util/wkc/CMakeLists.txt +++ b/chem/KPP/util/wkc/CMakeLists.txt @@ -91,130 +91,81 @@ target_compile_definitions( ${FOLDER_COMPILE_TARGET} PRIVATE NO_MODIFY_MAKEFILE # ) -# Quickly add tuv_kpp exec as well and generate tuv photolysis inc file +# Quickly add tuv_kpp exec as well add_executable( tuv_kpp tuv_kpp.c ) -for all kpp_mech dirs - - # util/create_inc_files model - for u l b a ibu ib ia e as thing - if kpp_mechd_${thing}_${model}.inc not exist - create - if extra_args_to_update_rconst_${model}.inc not exist - create - if extra_args_update_rconst_${model}.inc not exist - create - if extra_decls_update_rconst_${model}.inc not exist - create - - # run kpp model, generates .F files - KPP_HOME must be set by this point - # often set to chem/KPP/kpp/kpp-2.1 in case you didn't know it was KPP - kpp ${model}.kpp - ${model}_Integrator.f90 - ${model}_Parameters.f90 - ${model}_Precision.f90 - ${model}_JacobianSP.f90 - ${model}_Jacobian.f90 - ${model}_Update_Rconst.f90 - - - if tuv.jmap - gen first once - gen ${model} - - # write_decom ${model} chem_dir - find in ${model}_Integrator.f90 if decomp && call - make - - -if tuv.jmap used - gen last once - -"gather" KPP/inc/*.inc files (known) - - -# Now do coupler - - - - -add_custom_command( - OUTPUT - ${CMAKE_BINARY_DIR}/inc/tuv2wrf_jvals.inc - ${CMAKE_BINARY_DIR}/inc/tuvdef_jvals.inc - WORKING_DIRECTORY - ${CMAKE_BINARY_DIR} - # Replicate what exists in project directory for registry - COMMAND - ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/inc - COMMAND - ${CMAKE_BINARY_DIR}/tools/registry ${REGISTRY_DEFS} -DNEW_BDYS ${REGISTRY_FILE} > ${CMAKE_BINARY_DIR}/registry.log 2>&1 - #!TODO Just have the registry code actually check for failure or better yet rewrite the - # 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 - ) - - - - - - - - - -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 -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_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 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 - ${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 - ) +# add_custom_command( +# OUTPUT +# ${CMAKE_BINARY_DIR}/inc/tuv2wrf_jvals.inc +# ${CMAKE_BINARY_DIR}/inc/tuvdef_jvals.inc +# WORKING_DIRECTORY +# ${CMAKE_BINARY_DIR} +# # Replicate what exists in project directory for registry +# COMMAND +# ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/inc +# COMMAND +# ${CMAKE_BINARY_DIR}/tools/registry ${REGISTRY_DEFS} -DNEW_BDYS ${REGISTRY_FILE} > ${CMAKE_BINARY_DIR}/registry.log 2>&1 +# #!TODO Just have the registry code actually check for failure or better yet rewrite the +# # 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 +# ) + + + + +# 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 +# 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_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 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 +# ${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 +# ) From e6d5c600e56cacb09e0859cc92f8c56dc72a67b5 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 6 Mar 2024 17:21:20 -0700 Subject: [PATCH 09/23] Prepend sources with src/ --- chem/KPP/kpp/kpp-2.1/CMakeLists.txt | 37 +++++++++++++++++------------ 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/chem/KPP/kpp/kpp-2.1/CMakeLists.txt b/chem/KPP/kpp/kpp-2.1/CMakeLists.txt index 914eb3a192..03bceb9e95 100644 --- a/chem/KPP/kpp/kpp-2.1/CMakeLists.txt +++ b/chem/KPP/kpp/kpp-2.1/CMakeLists.txt @@ -15,30 +15,37 @@ endif() FLEX_TARGET( kpp_lex - scan.l - ${CMAKE_CURRENT_BINARY_DIR}/preproc/lex.yy.c + src/scan.l + ${CMAKE_CURRENT_BINARY_DIR}/lex.yy.c ) BISON_TARGET( kpp_tab - scan.y - ${CMAKE_CURRENT_BINARY_DIR}/preproc/y.tab.c + src/scan.y + ${CMAKE_CURRENT_BINARY_DIR}/y.tab.c ) add_executable( kpp ${FLEX_kpp_lex_OUTPUTS} ${BISON_kpp_tab_OUTPUTS} - scanner.c - scanutil.c - kpp.c - gen.c - code.c - code_c.c - code_f77.c - code_f90.c - code_matlab.c - debug.c + src/scanner.c + src/scanutil.c + src/kpp.c + src/gen.c + src/code.c + src/code_c.c + src/code_f77.c + src/code_f90.c + src/code_matlab.c + src/debug.c ) -target_link_libraries( kpp PRIVATE ${FLEX_LIBRARIES} ) \ No newline at end of file +target_compile_definitions( kpp PRIVATE SED_DELIMITER="@" ) +target_include_directories( + kpp + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${CMAKE_CURRENT_BINARY_DIR} + ) +target_link_libraries( kpp PRIVATE ${FLEX_LIBRARIES} ) From fe8455b1705ac8c9a2606fd270918d53b640fd65 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 6 Mar 2024 17:22:23 -0700 Subject: [PATCH 10/23] Simplify include to just KPP, we know it is KPP no need to specify thrice --- chem/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/chem/CMakeLists.txt b/chem/CMakeLists.txt index 2515c0a3f6..74d185ff83 100644 --- a/chem/CMakeLists.txt +++ b/chem/CMakeLists.txt @@ -4,8 +4,7 @@ target_include_directories( PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ) -add_subdirectory( KPP/kpp/kpp-2.1 ) -add_subdirectory( KPP/util/wkc ) +add_subdirectory( KPP ) set( KPP_SOURCES KPP/module_wkppc_constants.F ) From 5930afa59b84f0e45d976a02ac0f8ea52beabb7f Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 6 Mar 2024 17:23:28 -0700 Subject: [PATCH 11/23] Processing kpp gen files and tuv --- CMakeLists.txt | 7 ++ chem/KPP/CMakeLists.txt | 227 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 234 insertions(+) create mode 100644 chem/KPP/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f20d044ae..270d723c59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -214,6 +214,13 @@ set( DWORDSIZE 8 ) set( LWORDSIZE 4 ) +# To limit the KPP generation to not consume copious amounts of RAM +if ( NOT DEFINED MAX_KPP_GEN_THREADS ) + # 1 thread takes about 4.75 GB + set( MAX_KPP_GEN_THREADS 4 ) +endif() + + ######################## ################################################################################ diff --git a/chem/KPP/CMakeLists.txt b/chem/KPP/CMakeLists.txt new file mode 100644 index 0000000000..d4870696c8 --- /dev/null +++ b/chem/KPP/CMakeLists.txt @@ -0,0 +1,227 @@ + +add_subdirectory( kpp/kpp-2.1 ) +add_subdirectory( util/wkc ) +add_subdirectory( util/write_decomp ) +set( + MECHANISMS + cb05_sorg_aq + cb05_sorg_vbs_aq + cbm4 + cbmz_bb + cbmz_mosaic + crimech + cri_mosaic_4bin_aq + cri_mosaic_8bin_aq + gocartracm + mozart + mozart_mosaic_4bin + mozart_mosaic_4bin_aq + mozcart + nmhc9 + racm + racm_esrlsorg + racm_esrlsorg_aqchem + racm_mim + racmpm + racm_soa_vbs + racm_soa_vbs_aqchem + racm_soa_vbs_het + racmsorg + racmsorg_aqchem + radm2 + radm2sorg + saprc99 + saprc99_mosaic_4bin_vbs2 + saprc99_mosaic_8bin_vbs2_aq + t1_mozcart + ) + +message( STATUS "[KPP] Adding generation for mechanisms" ) + +# Some helper vars for grouping the kpp gen and tuv inc +set( KPP_GEN_GROUPS ) +set( KPP_CURRENT_GEN_GROUP 0 ) +set( KPP_SOURCES ) + +set( TUV_PHOTOLYSIS_GEN FALSE ) +set( TUV_PHOTOLYSIS_CMD ) +set( TUV_PHOTOLYSIS_OUT ) + +foreach ( MECH ${MECHANISMS} ) + # Is this even necessary? + # # util/create_inc_files model + # for u l b a ibu ib ia e as thing + # if kpp_mechd_${thing}_${model}.inc not exist + # create + # if extra_args_to_update_rconst_${model}.inc not exist + # create + # if extra_args_update_rconst_${model}.inc not exist + # create + # if extra_decls_update_rconst_${model}.inc not exist + # create + + # run kpp model, generates .F files - KPP_HOME must be set by this point + # often set to chem/KPP/kpp/kpp-2.1 in case you didn't know it was KPP + set( KPP_HOME ${CMAKE_CURRENT_SOURCE_DIR}/kpp/kpp-2.1 ) + + # I'm using the configure-time dir creation to simplify custom target/command usage + set( KPP_WORKING_DIR ${CMAKE_CURRENT_BINARY_DIR}/${MECH}/kpp/) + file( COPY ${CMAKE_CURRENT_SOURCE_DIR}/mechanisms/${MECH}/ DESTINATION ${KPP_WORKING_DIR} ) + set( + ${MECH}_KPP_SOURCES + ${MECH}_Integrator.f90 + ${MECH}_Parameters.f90 + ${MECH}_Precision.f90 + ${MECH}_JacobianSP.f90 + ${MECH}_Jacobian.f90 + ${MECH}_Update_Rconst.f90 + ) + + add_custom_command( + OUTPUT + ${${MECH}_KPP_SOURCES} + COMMAND ${CMAKE_COMMAND} -E env KPP_HOME=${KPP_HOME} $ ${MECH}.kpp > ${CMAKE_BINARY_DIR}/kpp_${MECH}.log 2>&1 + WORKING_DIRECTORY ${KPP_WORKING_DIR} + DEPENDS kpp + ) + add_custom_target( + ${MECH}_kpp + COMMENT "[KPP] Generating kpp files for ${MECH}" + DEPENDS + ${${MECH}_KPP_SOURCES} + ) + set_source_files_properties( + ${${MECH}_KPP_SOURCES} + DIRECTORY ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} + TARGET_DIRECTORY ${PROJECT_NAME}_Core + PROPERTIES + GENERATED ON + ) + add_dependencies( ${PROJECT_NAME}_Core ${MECH}_kpp ) + target_sources( ${PROJECT_NAME}_Core PRIVATE ${${MECH}_KPP_SOURCES} ) + + ###################################################################################################################### + ## + ## Special KPP generation logic to streamline parallel building without crashing + ## + # Assign target to a group to serialize based on maximum threads allowed as + # this consumes a ton of RAM + list( LENGTH KPP_GEN_GROUPS KPP_GEN_GROUPS_LEN ) + if ( ${KPP_GEN_GROUPS_LEN} GREATER ${KPP_CURRENT_GEN_GROUP} ) + list( GET KPP_GEN_GROUPS ${KPP_CURRENT_GEN_GROUP} KPP_PREVIOUS_GROUP_TARGET ) + endif() + + # This is the start point, add it into the list + list( INSERT KPP_GEN_GROUPS ${KPP_CURRENT_GEN_GROUP} ${MECH}_kpp ) + MATH( EXPR KPP_NEXT_IDX "${KPP_CURRENT_GEN_GROUP} + 1" ) + + if ( DEFINED KPP_PREVIOUS_GROUP_TARGET ) + # Add as a dependency + add_dependencies( ${KPP_PREVIOUS_GROUP_TARGET} ${MECH}_kpp ) + # Replace current listing - currently next index is actually pointing to old + list( REMOVE_AT KPP_GEN_GROUPS ${KPP_NEXT_IDX} ) + endif() + + # Now we have min( MAX_KPP_GEN_THREADS, KPP_CURRENT_GEN_GROUP ) in list, loop modulus to go back to zero + MATH( EXPR KPP_CURRENT_GEN_GROUP "${KPP_NEXT_IDX} % ${MAX_KPP_GEN_THREADS}" ) + ## + ## end grouping logic + ## + ###################################################################################################################### + + + # generate tuv photolysis inc file + if ( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/mechanisms/${MECH}/${MECH}.tuv.jmap ) + if ( NOT ${TUV_PHOTOLYSIS_GEN} ) + set( TUV_PHOTOLYSIS_GEN TRUE ) + endif() + + list( + APPEND TUV_PHOTOLYSIS_CMD + COMMAND ${CMAKE_COMMAND} -E chdir ${KPP_WORKING_DIR} $ ${MECH} ${CMAKE_CURRENT_BINARY_DIR}/inc/ >> ${CMAKE_BINARY_DIR}/tuv_photolysis_inc.log 2>&1 + COMMAND ${CMAKE_COMMAND} -E touch tuv_photolysis_${MECH} + ) + list( + APPEND TUV_PHOTOLYSIS_OUT + tuv_photolysis_${MECH} + ) + endif() + + # # write_decom ${model} chem_dir + # add_custom_command( + # OUTPUT + # ${KPP_WORKING_DIR}/${MECH}_decomp_check + # COMMAND ${CMAKE_COMMAND} -E + # COMMAND ${CMAKE_COMMAND} -E ${KPP_WORKING_DIR}/${MECH}_decomp_check + # WORKING_DIRECTORY ${KPP_WORKING_DIR} + # DEPENDS ${MECH}_kpp + # ) + # add_custom_target( + # ${MECH}_kpp + # COMMENT "[KPP] Checking for decomposition rewrite in ${MECH}_Integrator.f90" + # DEPENDS + # ${KPP_WORKING_DIR}/${MECH}_decomp_check + # ) + # set_source_files_properties( + # ${KPP_WORKING_DIR}/${MECH}_Integrator-decomp.f90 + # DIRECTORY ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} + # TARGET_DIRECTORY ${PROJECT_NAME}_Core + # PROPERTIES + # GENERATED ON + # ) + + # As far as I can tell the decomp is not used + # find in ${model}_Integrator.f90 if decomp && call + + # gen use inc statements to decomp_uses.inc: + # ${model}_Parameters + # ${model}_JacobianSP + # compile write_decomp : + # write_decomp.F + # ${model}_Parameters.f90 + # ${model}_Precision.f90 + # ${model}_JacobianSP.f90 + # gen mech.tmp in same directory run with ${model} as sole string + # run write_decomp outputs decomp_${model}.inc + + # # compile integr_edit.exe (already done above) + # run integr_edit ${model} ${model}_Integrator.f90 decomp_${model}.inc new_output + # take new output as ${model}_Integrator.f90 stand-in now + + + +endforeach() + +if ( ${TUV_PHOTOLYSIS_GEN} ) + add_custom_command( + OUTPUT + tuv_photolysis_start + ${TUV_PHOTOLYSIS_OUT} + tuv_photolysis_stop + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/inc/ + COMMAND $ FIRST ${CMAKE_CURRENT_BINARY_DIR}/inc/ > ${CMAKE_BINARY_DIR}/tuv_photolysis_inc.log 2>&1 + COMMAND ${CMAKE_COMMAND} -E touch tuv_photolysis_start + ${TUV_PHOTOLYSIS_CMD} + COMMAND $ LAST ${CMAKE_CURRENT_BINARY_DIR}/inc/ >> ${CMAKE_BINARY_DIR}/tuv_photolysis_inc.log 2>&1 + COMMAND ${CMAKE_COMMAND} -E touch tuv_photolysis_stop + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS tuv_kpp + ) + add_custom_target( + tuv_photolysis_inc # Naming this something different just to identify this is a target + COMMENT "[KPP] Generating tuv_photolysis include file" + DEPENDS + tuv_photolysis_start + ${TUV_PHOTOLYSIS_OUT} + tuv_photolysis_stop + ) + add_dependencies( ${PROJECT_NAME}_Core tuv_photolysis_inc ) +endif() + +# "gather" KPP/inc/*.inc files (known) + + +# # Now do coupler +# registry stuff + + From fa7925de52636ab0d7b0fd1cae0142ad3c79b5a6 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 6 Mar 2024 17:27:06 -0700 Subject: [PATCH 12/23] Remove any need for in situ source generation listing --- chem/KPP/util/wkc/CMakeLists.txt | 1 - chem/KPP/util/wkc/gen_kpp.c | 5 +--- chem/KPP/util/wkc/list_kpp_generated.c | 37 -------------------------- chem/KPP/util/wkc/protos_kpp.h | 4 +-- 4 files changed, 2 insertions(+), 45 deletions(-) delete mode 100644 chem/KPP/util/wkc/list_kpp_generated.c diff --git a/chem/KPP/util/wkc/CMakeLists.txt b/chem/KPP/util/wkc/CMakeLists.txt index 0425f402fa..8e0aaf011e 100644 --- a/chem/KPP/util/wkc/CMakeLists.txt +++ b/chem/KPP/util/wkc/CMakeLists.txt @@ -46,7 +46,6 @@ target_sources( gen_kpp_interf_utils.c gen_kpp_args_to_Update_Rconst.c kpp_data.c - list_kpp_generated.c ${GEN_COMMS} diff --git a/chem/KPP/util/wkc/gen_kpp.c b/chem/KPP/util/wkc/gen_kpp.c index 01b6a317af..ef1df7f110 100644 --- a/chem/KPP/util/wkc/gen_kpp.c +++ b/chem/KPP/util/wkc/gen_kpp.c @@ -225,10 +225,7 @@ gen_kpp ( char * inc_dirname, char * kpp_dirname ) check_all ( kpp_dirname ); -#ifdef NO_MODIFY_MAKEFILE - // Write the kpp generated modules to a file - list_kpp_generated( ); -#else +#ifndef NO_MODIFY_MAKEFILE /* add the kpp generated modules to the Makefile in the chem directory */ if ( DEBUGR == 1 ) printf("next: change_chem_Makefile \n"); change_chem_Makefile ( ); diff --git a/chem/KPP/util/wkc/list_kpp_generated.c b/chem/KPP/util/wkc/list_kpp_generated.c deleted file mode 100644 index 838947b1e4..0000000000 --- a/chem/KPP/util/wkc/list_kpp_generated.c +++ /dev/null @@ -1,37 +0,0 @@ -#include - - -#include "protos.h" -#include "protos_kpp.h" -#include "kpp_data.h" - - - -void -list_kpp_generated( ) -{ - knode_t * p1, * p2, * pm1; - FILE *output; - char *output_filename = "kpp_sources.txt"; - char kname[NAMELEN]; - - output = fopen( output_filename, "W" ); - - for ( p1 = KPP_packs ; p1 != NULL ; p1 = p1->next ) - { - p2 = p1->assoc_wrf_pack; - if ( p2 ) - { - strcpy( kname, p1->name ); - fprintf( output, "module_kpp_%s_Integr.o \\\n", kname ); - fprintf( output, "module_kpp_%s_Precision.o \\\n", kname ); - fprintf( output, "module_kpp_%s_Parameters.o \\\n", kname ); - fprintf( output, "module_kpp_%s_Jacobian.o \\\n", kname ); - fprintf( output, "module_kpp_%s_JacobianSP.o \\\n", kname ); - fprintf( output, "module_kpp_%s_Update_Rconst.o \\\n", kname ); - fprintf( output, "module_kpp_%s_interface.o \\\n", kname ); - } - } - - fclose( output ); -} diff --git a/chem/KPP/util/wkc/protos_kpp.h b/chem/KPP/util/wkc/protos_kpp.h index 58c3f2a64f..8254a017d9 100644 --- a/chem/KPP/util/wkc/protos_kpp.h +++ b/chem/KPP/util/wkc/protos_kpp.h @@ -18,9 +18,7 @@ int compare_kpp_to_species ( char * kpp_dirname) ; int run_kpp( char * dirname , char * kpp_version ); -#ifdef NO_MODIFY_MAKEFILE -void list_kpp_generated( ); -#else +#ifndef NO_MODIFY_MAKEFILE void change_chem_Makefile( ); #endif From 96041a85cf9c082d35a4af432959933c819aee37 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 6 Mar 2024 17:46:44 -0700 Subject: [PATCH 13/23] Fix open mode char assign --- chem/KPP/util/wkc/tuv_kpp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chem/KPP/util/wkc/tuv_kpp.c b/chem/KPP/util/wkc/tuv_kpp.c index aeb9d4d7e4..32b5de6ddc 100644 --- a/chem/KPP/util/wkc/tuv_kpp.c +++ b/chem/KPP/util/wkc/tuv_kpp.c @@ -31,7 +31,7 @@ int main( int argc, char *argv[], char *env[] ) { char squezzed[NAMELEN]; char *wrf_jname, *cwrk, *tuv_jspec, *token; char *tuv_jname; - char openMode = "a"; + char openMode[1] = "a"; FILE * fp_in, *fp_set, *fp_def; wrf_node *Wrf_node; wrf_node *Wrf_HEAD; @@ -56,7 +56,7 @@ int main( int argc, char *argv[], char *env[] ) { strcat( fname_inc, "tuv2wrf_jvals.inc" ); if( !strcmp(mech,"FIRST") ) { - openMode = "w"; + strcpy( openMode, "w" ); } if( (fp_set = fopen( fname_inc, openMode )) == NULL ) { From 7610ad954d00761ab71f78754ee11d2b2d7e0bfc Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 7 Mar 2024 15:04:49 -0700 Subject: [PATCH 14/23] Don't use env vars in registry gen, use defines passed in --- tools/data.h | 2 ++ tools/registry.c | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/data.h b/tools/data.h index 081ece8616..c6171e4c22 100644 --- a/tools/data.h +++ b/tools/data.h @@ -103,6 +103,8 @@ EXTERN char sw_commpath[NAMELEN] ; EXTERN int sw_new_bdys ; /* 20070207 JM support decomposed boundary arrays */ EXTERN int sw_unidir_shift_halo ; /* 20100210 JM assume that halo to shift is same in both directions and only gen one of them */ EXTERN int sw_new_with_old_bdys ; /* 20070207 JM for debugging interim phase, new comms w/ old data structs */ +EXTERN int sw_chem ; +EXTERN int sw_kpp ; EXTERN node_t * Type ; EXTERN node_t * Dim ; diff --git a/tools/registry.c b/tools/registry.c index b2dd0a5f6a..c98d87e193 100644 --- a/tools/registry.c +++ b/tools/registry.c @@ -54,6 +54,8 @@ main( int argc, char *argv[], char *env[] ) other data streams are written to file per process */ sw_new_bdys = 0 ; sw_unidir_shift_halo = 0 ; + sw_chem = 0; + sw_kpp = 0; strcpy( fname_in , "" ) ; @@ -127,6 +129,12 @@ main( int argc, char *argv[], char *env[] ) fprintf(stderr,"Usage: %s [-DDEREF_KLUDGE] [-DDM_PARALLEL] [-DDISTRIB_IO_LAYER] [-DDM_SERIAL_IN_ONLY] [-DD3VAR_IRY_KLUDGE] registryfile\n",thisprog) ; exit(1) ; } + if (!strcmp(*argv,"-DWRF_CHEM=1")) { + sw_chem = 1 ; + } + if (!strcmp(*argv,"-DWRF_KPP=1")) { + sw_kpp = 1 ; + } } else /* consider it an input file */ { @@ -144,10 +152,8 @@ main( int argc, char *argv[], char *env[] ) // possible IRR diagnostcis? // do_irr_diag = 0; - env_val = getenv( "WRF_CHEM" ); - if( env_val != NULL && !strncmp( env_val, "1", 1 ) ) { - env_val = getenv( "WRF_KPP" ); - if( env_val != NULL && !strncmp( env_val, "1", 1 ) ) do_irr_diag = 1; + if( sw_chem == 1 ) { + if( sw_kpp == 1 ) do_irr_diag = 1; } if( do_irr_diag ) { if( access( fname_in,F_OK ) ) { From 3a6d8e63f11f9e07340924a61da2e3ecfb40727c Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 7 Mar 2024 15:06:11 -0700 Subject: [PATCH 15/23] Final set of sources and run registry_kpp --- chem/CMakeLists.txt | 2 - chem/KPP/CMakeLists.txt | 158 ++++++++++++++++++------------- chem/KPP/util/wkc/CMakeLists.txt | 154 ++++++++++++------------------ tools/CMakeLists.txt | 3 + 4 files changed, 156 insertions(+), 161 deletions(-) diff --git a/chem/CMakeLists.txt b/chem/CMakeLists.txt index 74d185ff83..0d59560649 100644 --- a/chem/CMakeLists.txt +++ b/chem/CMakeLists.txt @@ -6,8 +6,6 @@ target_include_directories( ) add_subdirectory( KPP ) -set( KPP_SOURCES KPP/module_wkppc_constants.F ) - ######################################################################################################################## # # Now add sources diff --git a/chem/KPP/CMakeLists.txt b/chem/KPP/CMakeLists.txt index d4870696c8..2d33bc4054 100644 --- a/chem/KPP/CMakeLists.txt +++ b/chem/KPP/CMakeLists.txt @@ -1,7 +1,8 @@ -add_subdirectory( kpp/kpp-2.1 ) -add_subdirectory( util/wkc ) -add_subdirectory( util/write_decomp ) +message( STATUS "[KPP] Starting preprocessing preparation..." ) +list(APPEND CMAKE_MESSAGE_INDENT " ") + +# These names will also be used by the registry_kpp set( MECHANISMS cb05_sorg_aq @@ -36,6 +37,31 @@ set( t1_mozcart ) +add_subdirectory( kpp/kpp-2.1 ) +add_subdirectory( util/wkc ) +add_subdirectory( util/write_decomp ) + + +target_sources( + ${PROJECT_NAME}_Core + PRIVATE + module_wkppc_constants.F + ) + +target_include_directories( + ${PROJECT_NAME}_Core + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/inc + ) + +set( GEN_MECHD_INC u l b a ibu ib ia e ) +set( + GEN_RCONST_INC + extra_args_to_update_rconst + extra_args_update_rconst + extra_decls_update_rconst + ) + message( STATUS "[KPP] Adding generation for mechanisms" ) # Some helper vars for grouping the kpp gen and tuv inc @@ -48,39 +74,66 @@ set( TUV_PHOTOLYSIS_CMD ) set( TUV_PHOTOLYSIS_OUT ) foreach ( MECH ${MECHANISMS} ) - # Is this even necessary? - # # util/create_inc_files model - # for u l b a ibu ib ia e as thing - # if kpp_mechd_${thing}_${model}.inc not exist - # create - # if extra_args_to_update_rconst_${model}.inc not exist - # create - # if extra_args_update_rconst_${model}.inc not exist - # create - # if extra_decls_update_rconst_${model}.inc not exist - # create - - # run kpp model, generates .F files - KPP_HOME must be set by this point + + ###################################################################################################################### + ## + ## Generate any "missing" includes that are just empty + ## + if ( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc/${MECH} ) + file( COPY ${CMAKE_CURRENT_SOURCE_DIR}/inc/${MECH}/ DESTINATION ${CMAKE_BINARY_DIR}/inc ) + endif() + + foreach ( MECHD_INAME ${GEN_MECHD_INC} ) + set( GEN_MECHD_INC_FILENAME kpp_mechd_${MECHD_INAME}_${MECH}.inc ) + if ( NOT EXISTS ${CMAKE_BINARY_DIR}/inc/${GEN_MECHD_INC_FILENAME} ) + message( STATUS "[KPP] Touching empty include ${GEN_MECHD_INC_FILENAME}" ) + file( TOUCH ${CMAKE_BINARY_DIR}/inc/${GEN_MECHD_INC_FILENAME} ) + endif() + endforeach() + + foreach ( RCONST_INAME ${GEN_RCONST_INC} ) + set( GEN_RCONST_INC_FILENAME ${RCONST_INAME}_${MECH}.inc ) + if ( NOT EXISTS ${CMAKE_BINARY_DIR}/inc/${GEN_RCONST_INC_FILENAME} ) + message( STATUS "[KPP] Touching empty include ${GEN_RCONST_INC_FILENAME}" ) + file( TOUCH ${CMAKE_BINARY_DIR}/inc/${GEN_RCONST_INC_FILENAME} ) + endif() + endforeach() + ## + ## + ## + ###################################################################################################################### + + ###################################################################################################################### + ## + ## run kpp model, generates .F files + ## + # KPP_HOME must be set by this point # often set to chem/KPP/kpp/kpp-2.1 in case you didn't know it was KPP set( KPP_HOME ${CMAKE_CURRENT_SOURCE_DIR}/kpp/kpp-2.1 ) # I'm using the configure-time dir creation to simplify custom target/command usage - set( KPP_WORKING_DIR ${CMAKE_CURRENT_BINARY_DIR}/${MECH}/kpp/) + set( KPP_WORKING_DIR ${CMAKE_CURRENT_BINARY_DIR}/mechanisms/${MECH} ) file( COPY ${CMAKE_CURRENT_SOURCE_DIR}/mechanisms/${MECH}/ DESTINATION ${KPP_WORKING_DIR} ) set( ${MECH}_KPP_SOURCES - ${MECH}_Integrator.f90 - ${MECH}_Parameters.f90 - ${MECH}_Precision.f90 - ${MECH}_JacobianSP.f90 - ${MECH}_Jacobian.f90 - ${MECH}_Update_Rconst.f90 + ${KPP_WORKING_DIR}/${MECH}_Integrator.f90 + ${KPP_WORKING_DIR}/${MECH}_Parameters.f90 + ${KPP_WORKING_DIR}/${MECH}_Precision.f90 + ${KPP_WORKING_DIR}/${MECH}_JacobianSP.f90 + ${KPP_WORKING_DIR}/${MECH}_Jacobian.f90 + ${KPP_WORKING_DIR}/${MECH}_Update_Rconst.f90 ) add_custom_command( OUTPUT ${${MECH}_KPP_SOURCES} COMMAND ${CMAKE_COMMAND} -E env KPP_HOME=${KPP_HOME} $ ${MECH}.kpp > ${CMAKE_BINARY_DIR}/kpp_${MECH}.log 2>&1 + COMMAND ${CMAKE_COMMAND} -E compare_files ${KPP_WORKING_DIR}/${MECH}_Integrator.f90 ${KPP_WORKING_DIR}/${MECH}_Integrator.f90 + COMMAND ${CMAKE_COMMAND} -E compare_files ${KPP_WORKING_DIR}/${MECH}_Parameters.f90 ${KPP_WORKING_DIR}/${MECH}_Parameters.f90 + COMMAND ${CMAKE_COMMAND} -E compare_files ${KPP_WORKING_DIR}/${MECH}_Precision.f90 ${KPP_WORKING_DIR}/${MECH}_Precision.f90 + COMMAND ${CMAKE_COMMAND} -E compare_files ${KPP_WORKING_DIR}/${MECH}_JacobianSP.f90 ${KPP_WORKING_DIR}/${MECH}_JacobianSP.f90 + COMMAND ${CMAKE_COMMAND} -E compare_files ${KPP_WORKING_DIR}/${MECH}_Jacobian.f90 ${KPP_WORKING_DIR}/${MECH}_Jacobian.f90 + COMMAND ${CMAKE_COMMAND} -E compare_files ${KPP_WORKING_DIR}/${MECH}_Update_Rconst.f90 ${KPP_WORKING_DIR}/${MECH}_Update_Rconst.f90 WORKING_DIRECTORY ${KPP_WORKING_DIR} DEPENDS kpp ) @@ -90,15 +143,13 @@ foreach ( MECH ${MECHANISMS} ) DEPENDS ${${MECH}_KPP_SOURCES} ) - set_source_files_properties( - ${${MECH}_KPP_SOURCES} - DIRECTORY ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} - TARGET_DIRECTORY ${PROJECT_NAME}_Core - PROPERTIES - GENERATED ON - ) + add_dependencies( ${PROJECT_NAME}_Core ${MECH}_kpp ) target_sources( ${PROJECT_NAME}_Core PRIVATE ${${MECH}_KPP_SOURCES} ) + ## + ## + ## + ###################################################################################################################### ###################################################################################################################### ## @@ -138,7 +189,7 @@ foreach ( MECH ${MECHANISMS} ) list( APPEND TUV_PHOTOLYSIS_CMD - COMMAND ${CMAKE_COMMAND} -E chdir ${KPP_WORKING_DIR} $ ${MECH} ${CMAKE_CURRENT_BINARY_DIR}/inc/ >> ${CMAKE_BINARY_DIR}/tuv_photolysis_inc.log 2>&1 + COMMAND ${CMAKE_COMMAND} -E chdir ${KPP_WORKING_DIR} $ ${MECH} ${CMAKE_BINARY_DIR}/inc/ >> ${CMAKE_BINARY_DIR}/tuv_photolysis_inc.log 2>&1 COMMAND ${CMAKE_COMMAND} -E touch tuv_photolysis_${MECH} ) list( @@ -146,30 +197,6 @@ foreach ( MECH ${MECHANISMS} ) tuv_photolysis_${MECH} ) endif() - - # # write_decom ${model} chem_dir - # add_custom_command( - # OUTPUT - # ${KPP_WORKING_DIR}/${MECH}_decomp_check - # COMMAND ${CMAKE_COMMAND} -E - # COMMAND ${CMAKE_COMMAND} -E ${KPP_WORKING_DIR}/${MECH}_decomp_check - # WORKING_DIRECTORY ${KPP_WORKING_DIR} - # DEPENDS ${MECH}_kpp - # ) - # add_custom_target( - # ${MECH}_kpp - # COMMENT "[KPP] Checking for decomposition rewrite in ${MECH}_Integrator.f90" - # DEPENDS - # ${KPP_WORKING_DIR}/${MECH}_decomp_check - # ) - # set_source_files_properties( - # ${KPP_WORKING_DIR}/${MECH}_Integrator-decomp.f90 - # DIRECTORY ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} - # TARGET_DIRECTORY ${PROJECT_NAME}_Core - # PROPERTIES - # GENERATED ON - # ) - # As far as I can tell the decomp is not used # find in ${model}_Integrator.f90 if decomp && call @@ -192,19 +219,24 @@ foreach ( MECH ${MECHANISMS} ) endforeach() +# Group our aggregated tuv commands if it was specified if ( ${TUV_PHOTOLYSIS_GEN} ) add_custom_command( OUTPUT + # Note: I am not setting output as + # inc/tuv2wrf_jvals.inc + # inc/tuvdef_jvals.inc + # Because I want each step to succeed and not just the start or stop tuv_photolysis_start ${TUV_PHOTOLYSIS_OUT} tuv_photolysis_stop - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/inc/ - COMMAND $ FIRST ${CMAKE_CURRENT_BINARY_DIR}/inc/ > ${CMAKE_BINARY_DIR}/tuv_photolysis_inc.log 2>&1 + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/inc/ + COMMAND $ FIRST ${CMAKE_BINARY_DIR}/inc/ > ${CMAKE_BINARY_DIR}/tuv_photolysis_inc.log 2>&1 COMMAND ${CMAKE_COMMAND} -E touch tuv_photolysis_start ${TUV_PHOTOLYSIS_CMD} - COMMAND $ LAST ${CMAKE_CURRENT_BINARY_DIR}/inc/ >> ${CMAKE_BINARY_DIR}/tuv_photolysis_inc.log 2>&1 + COMMAND $ LAST ${CMAKE_BINARY_DIR}/inc/ >> ${CMAKE_BINARY_DIR}/tuv_photolysis_inc.log 2>&1 COMMAND ${CMAKE_COMMAND} -E touch tuv_photolysis_stop - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} DEPENDS tuv_kpp ) add_custom_target( @@ -218,10 +250,4 @@ if ( ${TUV_PHOTOLYSIS_GEN} ) add_dependencies( ${PROJECT_NAME}_Core tuv_photolysis_inc ) endif() -# "gather" KPP/inc/*.inc files (known) - - -# # Now do coupler -# registry stuff - - +list(POP_BACK CMAKE_MESSAGE_INDENT) diff --git a/chem/KPP/util/wkc/CMakeLists.txt b/chem/KPP/util/wkc/CMakeLists.txt index 8e0aaf011e..949c07c1f8 100644 --- a/chem/KPP/util/wkc/CMakeLists.txt +++ b/chem/KPP/util/wkc/CMakeLists.txt @@ -48,30 +48,9 @@ target_sources( kpp_data.c ${GEN_COMMS} - - # gen_defs.c - # gen_allocs.c - # gen_mod_state_descr.c - # gen_scalar_indices.c - # gen_args.c - # gen_config.c - # gen_irr_diag.c - # gen_model_data_ord.c - # gen_interp.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_include_directories( ${FOLDER_COMPILE_TARGET} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} @@ -94,78 +73,67 @@ target_compile_definitions( ${FOLDER_COMPILE_TARGET} PRIVATE NO_MODIFY_MAKEFILE add_executable( tuv_kpp tuv_kpp.c ) -# add_custom_command( -# OUTPUT -# ${CMAKE_BINARY_DIR}/inc/tuv2wrf_jvals.inc -# ${CMAKE_BINARY_DIR}/inc/tuvdef_jvals.inc -# WORKING_DIRECTORY -# ${CMAKE_BINARY_DIR} -# # Replicate what exists in project directory for registry -# COMMAND -# ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/inc -# COMMAND -# ${CMAKE_BINARY_DIR}/tools/registry ${REGISTRY_DEFS} -DNEW_BDYS ${REGISTRY_FILE} > ${CMAKE_BINARY_DIR}/registry.log 2>&1 -# #!TODO Just have the registry code actually check for failure or better yet rewrite the -# # 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 -# ) - - - - -# 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 -# 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_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 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 -# ${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 -# ) - +# Do registry_kpp generation of sources and include files +set( KPP_INTERFACE_SOURCES ) +set( KPP_INTERFACE_SOURCES_CMD_CHECK ) +foreach( MECH ${MECHANISMS} ) + set( KPP_INTERFACE_SOURCE ${CMAKE_BINARY_DIR}/chem/module_kpp_${MECH}_interface.F ) + list( APPEND KPP_INTERFACE_SOURCES ${KPP_INTERFACE_SOURCE} ) + list( + APPEND KPP_INTERFACE_SOURCES_CMD_CHECK + COMMAND ${CMAKE_COMMAND} -E compare_files ${KPP_INTERFACE_SOURCE} ${KPP_INTERFACE_SOURCE} + ) + +endforeach() + + +get_directory_property( DIR_DEFS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS ) +wrf_expand_definitions( + RESULT_VAR REGISTRY_DEFS + DEFINITIONS ${DIR_DEFS} + ) + +add_custom_command( + OUTPUT + gen_${FOLDER_COMPILE_TARGET} + ${CMAKE_BINARY_DIR}/chem/kpp_mechanism_driver.F + ${KPP_INTERFACE_SOURCES} + 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_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/frame + COMMAND + $ ${REGISTRY_DEFS} ${REGISTRY_FILE} > ${CMAKE_BINARY_DIR}/${FOLDER_COMPILE_TARGET}.log 2>&1 + ${KPP_INTERFACE_SOURCES_CMD_CHECK} + COMMAND + ${CMAKE_COMMAND} -E compare_files ${CMAKE_BINARY_DIR}/chem/kpp_mechanism_driver.F ${CMAKE_BINARY_DIR}/chem/kpp_mechanism_driver.F + COMMAND + ${CMAKE_COMMAND} -E touch gen_${FOLDER_COMPILE_TARGET} + DEPENDS + ${FOLDER_COMPILE_TARGET} + ) + + + +add_custom_target( + registry_kpp_code + DEPENDS + ${KPP_INTERFACE_SOURCES} + ${CMAKE_BINARY_DIR}/chem/kpp_mechanism_driver.F + gen_${FOLDER_COMPILE_TARGET} + ) +add_dependencies( ${PROJECT_NAME}_Core registry_kpp_code ) +target_sources( + ${PROJECT_NAME}_Core + PRIVATE + ${KPP_INTERFACE_SOURCES} + ${CMAKE_BINARY_DIR}/chem/kpp_mechanism_driver.F + ) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 7f07eb2539..0795b35acc 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -119,6 +119,9 @@ foreach( n RANGE 0 31 ) ) endforeach() +# Make sure this exists at the top level - I'm avoiding using cache variables deliberately +set( REGISTRY_FILE ${REGISTRY_FILE} PARENT_SCOPE ) + wrf_expand_definitions( RESULT_VAR REGISTRY_DEFS DEFINITIONS ${PROJECT_COMPILE_DEFINITIONS} From ba755557f8c0effd1558278f82a2cd02dcd5d707 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 11 Mar 2024 12:14:38 -0700 Subject: [PATCH 16/23] Remove unused KPP_SOURCES var --- chem/CMakeLists.txt | 1 - chem/KPP/CMakeLists.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/chem/CMakeLists.txt b/chem/CMakeLists.txt index 0d59560649..cf0e1ee1e0 100644 --- a/chem/CMakeLists.txt +++ b/chem/CMakeLists.txt @@ -14,7 +14,6 @@ add_subdirectory( KPP ) target_sources( ${PROJECT_NAME}_Core PRIVATE - ${KPP_SOURCES} module_data_isrpia_data.F module_data_ISRPIA.F module_data_isrpia_asrc.F diff --git a/chem/KPP/CMakeLists.txt b/chem/KPP/CMakeLists.txt index 2d33bc4054..85f56dd749 100644 --- a/chem/KPP/CMakeLists.txt +++ b/chem/KPP/CMakeLists.txt @@ -67,7 +67,6 @@ message( STATUS "[KPP] Adding generation for mechanisms" ) # Some helper vars for grouping the kpp gen and tuv inc set( KPP_GEN_GROUPS ) set( KPP_CURRENT_GEN_GROUP 0 ) -set( KPP_SOURCES ) set( TUV_PHOTOLYSIS_GEN FALSE ) set( TUV_PHOTOLYSIS_CMD ) From 5c1cb94acf770b74fde1af753156c8fbbf4888c2 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 11 Mar 2024 13:47:11 -0700 Subject: [PATCH 17/23] Adjust defines and registry check to only look for defs not defs with value This now mirrors the make build and allows the make build to supply the WRF_CHEM and WRF_KPP option via defines/command line similar to the make build. Likewise, while there are files that use or or any variation of this, these were never being used by the make build. This may be a bug, but the priority of the cmake build is to acheive parity with the make build in compile flags and overall effect. --- CMakeLists.txt | 4 ++-- tools/registry.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 270d723c59..467f17a8e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -693,9 +693,9 @@ list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS # in code since cmake cannot handle basically any others :( # https://gitlab.kitware.com/cmake/cmake/-/issues/17398 if ( ${ENABLE_CHEM} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRF_CHEM=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRF_CHEM ) if ( ${ENABLE_KPP} ) - list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRF_KPP=1 ) + list( APPEND PROJECT_COMPILE_DEFINITIONS_OPTIONS WRF_KPP ) endif() endif() if ( ${ENABLE_CHEM} ) diff --git a/tools/registry.c b/tools/registry.c index c98d87e193..7919492cf9 100644 --- a/tools/registry.c +++ b/tools/registry.c @@ -129,10 +129,10 @@ main( int argc, char *argv[], char *env[] ) fprintf(stderr,"Usage: %s [-DDEREF_KLUDGE] [-DDM_PARALLEL] [-DDISTRIB_IO_LAYER] [-DDM_SERIAL_IN_ONLY] [-DD3VAR_IRY_KLUDGE] registryfile\n",thisprog) ; exit(1) ; } - if (!strcmp(*argv,"-DWRF_CHEM=1")) { + if (!strcmp(*argv,"-DWRF_CHEM")) { sw_chem = 1 ; } - if (!strcmp(*argv,"-DWRF_KPP=1")) { + if (!strcmp(*argv,"-DWRF_KPP")) { sw_kpp = 1 ; } } From a5d93351f17d29cb52db7746635dce2592842163 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 11 Mar 2024 15:07:33 -0700 Subject: [PATCH 18/23] Add decomp rewrite as apparently it is used --- chem/KPP/CMakeLists.txt | 88 ++++++++++++++++++----- chem/KPP/util/write_decomp/CMakeLists.txt | 1 + 2 files changed, 70 insertions(+), 19 deletions(-) diff --git a/chem/KPP/CMakeLists.txt b/chem/KPP/CMakeLists.txt index 85f56dd749..91e65723f7 100644 --- a/chem/KPP/CMakeLists.txt +++ b/chem/KPP/CMakeLists.txt @@ -115,17 +115,21 @@ foreach ( MECH ${MECHANISMS} ) file( COPY ${CMAKE_CURRENT_SOURCE_DIR}/mechanisms/${MECH}/ DESTINATION ${KPP_WORKING_DIR} ) set( ${MECH}_KPP_SOURCES - ${KPP_WORKING_DIR}/${MECH}_Integrator.f90 ${KPP_WORKING_DIR}/${MECH}_Parameters.f90 ${KPP_WORKING_DIR}/${MECH}_Precision.f90 ${KPP_WORKING_DIR}/${MECH}_JacobianSP.f90 ${KPP_WORKING_DIR}/${MECH}_Jacobian.f90 ${KPP_WORKING_DIR}/${MECH}_Update_Rconst.f90 ) + set( + ${MECH}_KPP_SOURCES_INTEGRATOR + ${KPP_WORKING_DIR}/${MECH}_Integrator.f90 + ) add_custom_command( OUTPUT ${${MECH}_KPP_SOURCES} + ${${MECH}_KPP_SOURCES_INTEGRATOR} COMMAND ${CMAKE_COMMAND} -E env KPP_HOME=${KPP_HOME} $ ${MECH}.kpp > ${CMAKE_BINARY_DIR}/kpp_${MECH}.log 2>&1 COMMAND ${CMAKE_COMMAND} -E compare_files ${KPP_WORKING_DIR}/${MECH}_Integrator.f90 ${KPP_WORKING_DIR}/${MECH}_Integrator.f90 COMMAND ${CMAKE_COMMAND} -E compare_files ${KPP_WORKING_DIR}/${MECH}_Parameters.f90 ${KPP_WORKING_DIR}/${MECH}_Parameters.f90 @@ -141,6 +145,7 @@ foreach ( MECH ${MECHANISMS} ) COMMENT "[KPP] Generating kpp files for ${MECH}" DEPENDS ${${MECH}_KPP_SOURCES} + ${${MECH}_KPP_SOURCES_INTEGRATOR} ) add_dependencies( ${PROJECT_NAME}_Core ${MECH}_kpp ) @@ -196,25 +201,70 @@ foreach ( MECH ${MECHANISMS} ) tuv_photolysis_${MECH} ) endif() - # As far as I can tell the decomp is not used - # find in ${model}_Integrator.f90 if decomp && call - - # gen use inc statements to decomp_uses.inc: - # ${model}_Parameters - # ${model}_JacobianSP - # compile write_decomp : - # write_decomp.F - # ${model}_Parameters.f90 - # ${model}_Precision.f90 - # ${model}_JacobianSP.f90 - # gen mech.tmp in same directory run with ${model} as sole string - # run write_decomp outputs decomp_${model}.inc - - # # compile integr_edit.exe (already done above) - # run integr_edit ${model} ${model}_Integrator.f90 decomp_${model}.inc new_output - # take new output as ${model}_Integrator.f90 stand-in now - + + ###################################################################################################################### + ## + ## Integrator decomp rewrite + ## + # Do decomp for all - easier to manually specify rather than greps + file( + WRITE ${KPP_WORKING_DIR}/decomp_uses.inc + "USE ${MECH}_Parameters\nUSE ${MECH}_JacobianSP\n" + ) + file( + WRITE ${KPP_WORKING_DIR}/mech.tmp + "${MECH}\n" + ) + add_executable( + write_decomp_${MECH} + util/write_decomp/write_decomp.F + ${KPP_WORKING_DIR}/${MECH}_Parameters.f90 + ${KPP_WORKING_DIR}/${MECH}_Precision.f90 + ${KPP_WORKING_DIR}/${MECH}_JacobianSP.f90 + ) + target_include_directories( write_decomp_${MECH} PRIVATE ${KPP_WORKING_DIR} ) + set_target_properties( + write_decomp_${MECH} + PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/decomp/${MECH}/ + Fortran_FORMAT FREE + ) + add_dependencies( write_decomp_${MECH} ${MECH}_kpp ) + + + # Now that write_decomp is generated for this kpp mechanism, process it + add_custom_command( + OUTPUT + ${KPP_WORKING_DIR}/${MECH}_Integrator_decomp.f90 + ${KPP_WORKING_DIR}/decomp_${MECH}.inc + # ${CMAKE_COMMAND} -E chdir ${KPP_WORKING_DIR} + COMMAND $ > ${CMAKE_BINARY_DIR}/kpp_write_decomp_${MECH}.log 2>&1 + COMMAND ${CMAKE_COMMAND} -E compare_files ${KPP_WORKING_DIR}/decomp_${MECH}.inc ${KPP_WORKING_DIR}/decomp_${MECH}.inc + + COMMAND $ + ${MECH} ${MECH}_Integrator.f90 + decomp_${MECH}.inc + ${MECH}_Integrator_decomp.f90 > ${CMAKE_BINARY_DIR}/kpp_integrator_edit_${MECH}.log 2>&1 + COMMAND ${CMAKE_COMMAND} -E compare_files ${KPP_WORKING_DIR}/${MECH}_Integrator_decomp.f90 ${KPP_WORKING_DIR}/${MECH}_Integrator_decomp.f90 + + WORKING_DIRECTORY ${KPP_WORKING_DIR} + DEPENDS kpp + ) + add_custom_target( + ${MECH}_integrator_decomp + COMMENT "[KPP] Post-processing integrator decomposition for ${MECH}_Integrator.f90" + DEPENDS + ${KPP_WORKING_DIR}/${MECH}_Integrator_decomp.f90 + ${KPP_WORKING_DIR}/decomp_${MECH}.inc + ) + + add_dependencies( ${PROJECT_NAME}_Core ${MECH}_integrator_decomp ) + target_sources( ${PROJECT_NAME}_Core PRIVATE ${KPP_WORKING_DIR}/${MECH}_Integrator_decomp.f90 ) + ## + ## + ## + ###################################################################################################################### endforeach() diff --git a/chem/KPP/util/write_decomp/CMakeLists.txt b/chem/KPP/util/write_decomp/CMakeLists.txt index 3259150cef..f80de45d35 100644 --- a/chem/KPP/util/write_decomp/CMakeLists.txt +++ b/chem/KPP/util/write_decomp/CMakeLists.txt @@ -1,2 +1,3 @@ # Compile once and only ONCE add_executable( integration_edit integr_edit.c ) +target_compile_definitions( integration_edit PRIVATE -DNO_COPY ) From e496bfd51241ae2b70fbe7d49779f8705dff7090 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 15 Mar 2024 10:47:29 -0700 Subject: [PATCH 19/23] Only build KPP if requested --- chem/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chem/CMakeLists.txt b/chem/CMakeLists.txt index cf0e1ee1e0..c9c6cc659f 100644 --- a/chem/CMakeLists.txt +++ b/chem/CMakeLists.txt @@ -4,7 +4,9 @@ target_include_directories( PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ) -add_subdirectory( KPP ) +if ( ${ENABLE_KPP} ) + add_subdirectory( KPP ) +endif() ######################################################################################################################## # From 48e37afdaf164dab9447e61044b47cd664f6354d Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 25 Jul 2024 15:30:39 -0700 Subject: [PATCH 20/23] Reduce kpp gen threads to a more conservative value --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 467f17a8e8..3063f99880 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,7 +217,7 @@ set( LWORDSIZE 4 ) # To limit the KPP generation to not consume copious amounts of RAM if ( NOT DEFINED MAX_KPP_GEN_THREADS ) # 1 thread takes about 4.75 GB - set( MAX_KPP_GEN_THREADS 4 ) + set( MAX_KPP_GEN_THREADS 2 ) endif() From 8b1e232e0e1beae753f03bee523d9a347d09e120 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 1 Aug 2024 14:18:50 -0700 Subject: [PATCH 21/23] Add extra safety check since FindFLEX is insufficient --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3063f99880..ef0d1bf250 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -484,6 +484,14 @@ endif() if ( ${ENABLE_KPP} ) find_package( BISON REQUIRED ) find_package( FLEX REQUIRED ) + if ( ${FLEX_FOUND} AND "${FLEX_LIBRARIES}" STREQUAL "FL_LIBRARY-NOTFOUND" ) + message( FATAL_ERROR + "Flex executable found, but libraries were not. Please provide a searchable path for both " + "\n" + "Refer to https://cmake.org/cmake/help/latest/command/find_package.html for more info " + "on providing a suitable path" + ) + endif() endif() # Will need our own finder From 4d44806a1624ba6dddfba2aad5fc8202666a0496 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 1 Aug 2024 17:27:46 -0700 Subject: [PATCH 22/23] Remove old workaround never used --- chem/KPP/kpp/kpp-2.1/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/chem/KPP/kpp/kpp-2.1/CMakeLists.txt b/chem/KPP/kpp/kpp-2.1/CMakeLists.txt index 03bceb9e95..47f85af88f 100644 --- a/chem/KPP/kpp/kpp-2.1/CMakeLists.txt +++ b/chem/KPP/kpp/kpp-2.1/CMakeLists.txt @@ -41,7 +41,6 @@ add_executable( src/debug.c ) -target_compile_definitions( kpp PRIVATE SED_DELIMITER="@" ) target_include_directories( kpp PRIVATE From 80b44a853d66dae789e41e6f02d1a1933c0cce46 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 1 Aug 2024 17:28:41 -0700 Subject: [PATCH 23/23] Ensure lower compilation targets get all flags --- chem/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/chem/CMakeLists.txt b/chem/CMakeLists.txt index c9c6cc659f..8c329a1397 100644 --- a/chem/CMakeLists.txt +++ b/chem/CMakeLists.txt @@ -5,6 +5,8 @@ target_include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) if ( ${ENABLE_KPP} ) + add_compile_options ( "${PROJECT_COMPILE_OPTIONS}" ) + add_compile_definitions( "${PROJECT_COMPILE_DEFINITIONS}" ) add_subdirectory( KPP ) endif()