Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake error pertaining to kpp_standalone when compiling with MECH=carbon #78

Closed
msulprizio opened this issue Dec 13, 2024 · 2 comments · Fixed by #79
Closed

CMake error pertaining to kpp_standalone when compiling with MECH=carbon #78

msulprizio opened this issue Dec 13, 2024 · 2 comments · Fixed by #79
Assignees
Labels
category: Bug Something isn't working topic: Build Related to CMake and/or the build sequence
Milestone

Comments

@msulprizio
Copy link
Contributor

msulprizio commented Dec 13, 2024

Your name

Melissa Sulprizio

Your affiliation

Harvard

What happened? What did you expect to happen?

Using the latest dev/no-diff-to-benchmark branch, I get the following error when attempting to build GCClassic with the carbon mechanism using the commands cmake ../CodeDir; cmake . -DMECH=carbon -DRUNDIR=..; make -j install:

[msulprizio@holy8a24301 build]$ cmake . -DRUNDIR=.. -DMECH=carbon                                                                                                                                                             
=================================================================                                                                                                                                                             
GCClassic 14.5.0 (superproject wrapper)                                                                                                                                                                                       
Current status: 14.5.0-22-gf866ce2.dirty                                                                                                                                                                                      
=================================================================                                                                                                                                                             
-- Useful CMake variables:                                                                                                                                                                          
  + CMAKE_PREFIX_PATH:    /n/sw/helmod-rocky8/apps/MPI/gcc/12.2.0-fasrc01/openmpi/4.1.4-fa                                                                                                                                    src01/netcdf-c/4.9.2-fasrc01                                                                                                                                                                                
  ...             /n/sw/helmod-rocky8/apps/MPI/gcc/12.2.0-fasrc01/openmpi/4.1.4-fasrc01/ne                                                                                                                                    tcdf-fortran/4.6.0-fasrc02                                                                                                                                                                          
  ...             /n/sw/helmod-rocky8/apps/MPI/gcc/12.2.0-fasrc01/openmpi/4.1.4-fasrc01/ne                                                                                                                                    tcdf-c/4.9.2-fasrc01                                                                                                                                                        
  ...             /n/sw/helmod-rocky8/apps/MPI/gcc/12.2.0-fasrc01/openmpi/4.1.4-fasrc01/ne                                                                                                                                    tcdf-fortran/4.6.0-fasrc02                                                                                                                                                                          
  + CMAKE_BUILD_TYPE:     Release                                                                                                                                                                                             
-- Run directory setup:                                                                                                                                                                 
  + RUNDIR:       /n/home05/msulprizio/RD/TestCarbon/gc_4x5_merra2_carbon                                                                                                                                                     
-- Threading:                                                                                                                                   
  * OMP:          ON  OFF                                                                                                                                                                       
-- General settings:                                                                                                                                                        
  * MECH:         fullchem  carbon  Hg  custom                                                                                                                                                                              
  * USE_REAL8:    ON  OFF                                                                                                                                                                       
  * SANITIZE:     ON  OFF                                                                                                                                                                       
-- Components:                                                                                                                                      
  * TOMAS:        ON  OFF                                                                                                                                                                       
  * TOMAS_BINS:   NA  15  40                                                                                                                                                                                
  * APM:          ON  OFF                                                                                                                                                                       
  * RRTMG:        ON  OFF                                                                                                                                                                       
  * GTMM:         ON  OFF                                                                                                                                                                       
  * HCOSA:        ON  OFF                                                                                                                                                                       
  * LUO_WETDEP:   ON  OFF                                                                                                                                                                       
  * FASTJX:       ON  OFF                                                                                                                                                                       
=================================================================                                                                                                                                                             
HEMCO 3.10.0                                                                                                                                
Current status: 3.10.0-2-gd00af43                                                                                                                                                                                             
=================================================================                                                                                                                                                             
=================================================================                                                                                                                                                             
HETP 1.0                                                                                                                    
=================================================================                                                                                                                                                             
=================================================================                                                                                                                                                             
Cloud-J 8.0.1                                                                                                                                   
Current status: 8.0.1                                                                                                                                                           
=================================================================                                                                                                                                                             
=================================================================                                                                                                                                                             
GEOS-Chem 14.5.0 (science codebase)                                                                                                                                                                                           
Current status: 14.6.0-alpha.0-116-g0fcf8c4af.dirty                                                                                                                                                                           
=================================================================                                                                                                                                                             
Creating /n/home05/msulprizio/RD/TestCarbon/gc_4x5_merra2_carbon/CodeDir/src/GEOS-Chem/Int                                                                                                                                    erfaces/GCClassic/gc_classic_version.H                                                                                                                                                                                        
CMake Error at src/CMakeLists.txt:101 (install):                                                                                                                                                                            
  install TARGETS given target "kpp_standalone" which does not exist.                                                                                                                                                       
                                                                                                                                                                                                                            
                                                                                                                                                                                                                            
-- Configuring incomplete, errors occurred!

The issue appears to be in GCClassic/src/CMakeLists.txt at these lines

      # Installation path is a GEOS-Chem run directory,
      # Therefore we will install the executable there.
      install(TARGETS ${EXE_FILE_NAME} RUNTIME DESTINATION ${INSTALL_PATH})
      install(TARGETS ${KPPSA_FILE_NAME} RUNTIME DESTINATION ${INSTALL_PATH})

It appears that the first execution of cmake ../CodeDir adds kpp_standalone to TARGETS using:

#-----------------------------------------------------------------------------
# Define the KPP standalone executable:
# 1. Specify a cache variable with the default target name
# 2. Specify the location of the main program
# 3. Specify libraries that the main program depends on
# 4. Store the binary exectuable file in the bin folder (pre-install)
#
# At present build KPP standalone only for fullchem or custom mechanisms.
#-----------------------------------------------------------------------------
if("${MECH}" STREQUAL fullchem OR "${MECH}" STREQUAL custom)
  set(KPPSA_FILE_NAME kpp_standalone CACHE STRING
    "Default name for the KPP standalone executable file")
  mark_as_advanced(KPPSA_FILE_NAME)

  add_executable(${KPPSA_FILE_NAME}
    GEOS-Chem/KPP/standalone/kpp_standalone.F90
  )
  target_link_libraries(${KPPSA_FILE_NAME}
    PUBLIC
    KPPStandalone
  )
  set_target_properties(${KPPSA_FILE_NAME}
    PROPERTIES
    RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
  )
endif()

However, for the second execution of cmake passing -DMECH=carbon kpp_standalone is not defined and returns the above error.

NOTE: This was not caught by integration tests because they use one cmake command (i.e. cmake [path/to/code] -DMECH=carbon).

What are the steps to reproduce the bug?

To build I used:

$ cmake ../CodeDir
$ cmake . -DMECH=carbon -DRUNDIR=..

Note that if I use a single command for cmake I do not get the error:

$ cmake ../CodeDir -DMECH=carbon -DRUNDIR=..

Please attach any relevant configuration and log files.

No response

What GCClassic version were you using?

dev/no-diff-to-benchmark (14.5.1)

What environment were you running GCClassic on?

Local cluster

What compiler and version were you using?

gcc 12

Will you be addressing this bug yourself?

No

Additional information

While this issue can be avoided using a single cmake command, we should provide a fix for the case of multiple cmake commands. The GEOS-Chem ReadTheDocs does not explicitly tell users to pass all compile options to cmake in a single command.

Tagging @yantosca

@msulprizio msulprizio added the category: Bug Something isn't working label Dec 13, 2024
@msulprizio msulprizio added this to the 14.5.1 milestone Dec 13, 2024
@msulprizio msulprizio assigned msulprizio and yantosca and unassigned msulprizio Dec 13, 2024
@yantosca
Copy link
Contributor

Thanks @msulprizio. I can try to dig into that next week. Sorry about that!! Shouldn't be too hard to fix.

@yantosca yantosca added the topic: Build Related to CMake and/or the build sequence label Dec 16, 2024
yantosca added a commit that referenced this issue Dec 16, 2024
This merge brings PR #79 (Fixed error in CMake logic that
attempted to build the KPP standalone for mechanisms other
than fullchem and custom, by @yantosca) into the GEOS-Chem
"no-diff-to-benchmark" development stream.

This PR fixes a build issue that can occur when the CMake
commands are given separately instead of as a single command.
See issue #78 for details.

Signed-off-by: Bob Yantosca <[email protected]>
@yantosca
Copy link
Contributor

We can close this issue which is now resolved by PR #79.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: Bug Something isn't working topic: Build Related to CMake and/or the build sequence
Projects
None yet
2 participants