Skip to content

Commit

Permalink
Fail-safe for not available routines.
Browse files Browse the repository at this point in the history
Signed-off-by: MtoLStoN <70513124+MtoLStoN@users.noreply.github.com>
  • Loading branch information
MtoLStoN committed Aug 11, 2023
1 parent 178df50 commit 1873d89
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ target_link_libraries(
"$<$<BOOL:${WITH_OpenMP}>:OpenMP::OpenMP_Fortran>"
"mctc-lib::mctc-lib"
"$<$<BOOL:${WITH_CPCMX}>:cpcmx::cpcmx>"
"tblite::tblite"
"$<$<BOOL:${WITH_TBLITE}>:tblite::tblite>"
)
set_target_properties(
"lib-${PROJECT_NAME}-static"
Expand Down Expand Up @@ -143,7 +143,7 @@ target_link_libraries(
"$<$<BOOL:${WITH_OpenMP}>:OpenMP::OpenMP_Fortran>"
"mctc-lib::mctc-lib"
"$<$<BOOL:${WITH_CPCMX}>:cpcmx::cpcmx>"
"tblite::tblite"
"$<$<BOOL:${WITH_TBLITE}>:tblite::tblite>"
)
set_target_properties(
"lib-${PROJECT_NAME}-shared"
Expand Down
13 changes: 13 additions & 0 deletions src/solv/cpx.F90
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ subroutine setup_cpcmx(self, env, solvent)
!> TODO: SETUP solute directly from TCosmo instead of reading COSMO file
Call read_cosmo('xtb.cosmo',self%solute,'NONE',error)
if (allocated(error)) Call env%error(error%message, source)
#else
Call no_cpcmx_here(env)
#endif
end subroutine setup_cpcmx

Expand Down Expand Up @@ -103,6 +105,8 @@ subroutine calculate_cpcmx(self,env,solvent,energy_gas,probe,T,max_cycle,conv_cr
call self%state_correction(density(solvent),atomicmass(self%solvent%element),T)
call self%cds(probe,solvent)
total_energy= self%dG()+energy_gas
#else
Call no_cpcmx_here(env)
#endif
end subroutine calculate_cpcmx

Expand Down Expand Up @@ -147,4 +151,13 @@ subroutine print_cpcmx(self,verbose)
#endif
end subroutine print_cpcmx


#if ! WITH_CPCMX
subroutine no_cpcmx_here(env)

This comment has been minimized.

Copy link
@Albkat

Albkat Aug 11, 2023

Contributor

This subroutine appears to be redundant. As an alternative, you could simply use the following lines:

call env%error('CPCM-X is not available in this version of xtb.', source)
return

This way, you could directly fall back to the the main from your module.

This comment has been minimized.

Copy link
@MtoLStoN

MtoLStoN Aug 11, 2023

Author Member

Yeah sure - I just liked the idea of defining a subroutine for this as that makes it more future-proof. But of course, this will most likely never be needed.

type(TEnvironment), intent(inout) :: env

call env%error('CPCM-X is not available in this version of xtb.', source)
end subroutine no_cpcmx_here
#endif

end module xtb_solv_cpx

0 comments on commit 1873d89

Please sign in to comment.