View Issue Details

IDProjectCategoryView StatusLast Update
0002767OpenFOAMContributionpublic2017-11-21 22:00
ReporterPfiffikus Assigned Tohenry  
PrioritylowSeverityfeatureReproducibilityalways
Status closedResolutionno change required 
Summary0002767: prevent contradicting compiler directives for WM_PRECISION_OPTION: wm_sp, wm_dp, or wm_ldp
DescriptionWhat about to detect contradicting compiler directives by
#if (defined WM_SP && (defined WM_DP || defined WM_LDP)) || (defined WM_DP && (defined WM_SP || defined WM_LDP)) || (defined WM_LDP && (defined WM_SP || defined WM_DP))
#error You cannot use more than only one of WM_SP, WM_DP, WM_LDP at the same time!
#endif

#if !(defined WM_SP || defined WM_DP || defined WM_LDP)
#error You must use either WM_SP, WM_DP, or WM_LDP
#endif
Steps To ReproduceTry to link your code, compiled with -DWM_SP, with initially installed sources, compiled with -DWM_LP. It could fail due to unresolved references ...
Additional InformationYes, the prevention is only for safety in case of manual modification of make mechanism.
Tagscompilation, linking

Activities

henry

2017-11-21 14:33

manager   ~0009056

It is not clear where in the code you want this test or why. WM_LDP does not exist in OpenFOAM, did you add it? What does it do?

wyldckat

2017-11-21 21:52

updater   ~0009057

@Henry: After a quick Google search, it looks like "WM_LDP" was implemented in the fork "foam-extend", which refers to "long double precision". I have no idea what good would it do to have that much precision, but I guess it would be for planetary-sized simulations or for atomic/molecular modelling?

As to why people would want to define these options manually? It's a trend that has been showing up on the forums once in a while, people compiling and linking other code directly to OpenFOAM libraries, without relying on OpenFOAM's wmake stack.


@Pfiffikus: The use of those macro checks does not check whether the code was first compiled with another option; for example, if a cluster administrator installs OpenFOAM in a way commonly used on Linux distributions - e.g. having the libraries in "/usr/lib/OpenFOAM", instead of something like "/opt/OpenFOAM/5/platforms/linux64GccDPOpt" - then having these macro checks will not verify which options were originally used for compiling the libraries.

----

On the other hand, checking whether at least "WM_SP" or "WM_DP" is defined, could be useful for those trying to implement their own Makefile implementation... or if someone messes up the settings in the "rules" folder. I guess it would be enough to define this in the main 'Scalar.H' file, for it to always trigger the check when necessary.

henry

2017-11-21 22:00

manager   ~0009058

I don't see the need for this change and the proposal is not compatible with OpenFOAM anyway. I think it would be better to set and check these variable is the build scripts rather than adding this kind of clutter to the code.

Issue History

Date Modified Username Field Change
2017-11-21 14:09 Pfiffikus New Issue
2017-11-21 14:09 Pfiffikus Tag Attached: compilation
2017-11-21 14:09 Pfiffikus Tag Attached: linking
2017-11-21 14:33 henry Note Added: 0009056
2017-11-21 21:52 wyldckat Note Added: 0009057
2017-11-21 22:00 henry Assigned To => henry
2017-11-21 22:00 henry Status new => closed
2017-11-21 22:00 henry Resolution open => no change required
2017-11-21 22:00 henry Note Added: 0009058