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

Undefined symbol "ycnrm2" #817

Closed
chemsh opened this issue Jul 2, 2023 · 11 comments
Closed

Undefined symbol "ycnrm2" #817

chemsh opened this issue Jul 2, 2023 · 11 comments

Comments

@chemsh
Copy link

chemsh commented Jul 2, 2023

Dear NWChem authors,

we find a minor bug in NWChem 7.2 the hotfix version
https://github.com/nwchemgit/nwchem/archive/refs/heads/hotfix/release-7-2-0.zip

The source file src/gwmol/cs_minres_qlp.F requires BLAS function ycnrm2 which is converted from dznrm2 by the 64to32 configure. However this 32-bit function is not in the folder 64to32blas (if I understand the 64to32 mechanism correctly). It causes a linking issue when NWChem 7.2 is compiled with GNU compilers as a shared library directly-linked against Py-ChemShell. We never had this issue before (of course GW is new in 7.2), nor is it seen when compiling with Intel. Replacing all ycnrm2 with dznrm2 in src/gwmol/cs_minres_qlp.F can eliminate the issue. However, we think it may be a bug? Thank you very much.

Kind regards,

You

@edoapra
Copy link
Collaborator

edoapra commented Jul 3, 2023

@chemsh Did you set the environmental variable GWCMPLX ?

@chemsh
Copy link
Author

chemsh commented Jul 4, 2023

Hi Edo, @edoapra

no, we didn't set the variable GWCMPLX and we didn't know about this variable. Your hint reminds me of checking the preprocessor in gw_cdgw_buildrn_minres.F
#define SOLVER cs_minres_qlp
which defines the function cs_minres_qlp in which ycnrm2 is requested.

However, I just tried forcing not to define the preprocessor by passing in a Fortran compile flag -UGWCMPLX and it doesn't help and "undefined reference to `ycnrm2_'" persisted. It's not surprising because the function is compiled in any case though it's not actually in use (according to my rough grepping).

This ld linking issue is not seen when the standalone executable nwchem is created on the same machine, but only in Py-ChemShell. Many thanks!

Kind regards,

You

@tomkeal
Copy link

tomkeal commented Jul 4, 2023

Hi @edoapra,

Just to add to You's report, we've seen a few more linking errors on the same platform that arise outside of gwmol. These are yopmtr, ystein and ysptrd, all of which are referenced within peigs/src/f77/dspevx2.F. It looks like in v7.0.2 these routines were not converted from "D" to "Y", while in v7.2.0 they are, but then subsequently the "Y" wrappers are not found when linking.

Best wishes,

Tom

@edoapra
Copy link
Collaborator

edoapra commented Jul 4, 2023

Please submit all the detail to reproduce these problems since I am not able to see them otherwise.

@edoapra
Copy link
Collaborator

edoapra commented Jul 4, 2023

For example, the log of the compilation make V=1 in the directory $NWCHEM_TOP/src/gwmol could help.

@edoapra
Copy link
Collaborator

edoapra commented Jul 4, 2023

Have you defined the environment variable CONVERT_ALL by any chance?

CONVERT_ALL should not be defined, but setting CONVERT_ALL might generate the peigs and gwmol failures reported here.

@chemsh
Copy link
Author

chemsh commented Jul 4, 2023

Hi Edo,

thank you for the advice. Unfortunately it's not easy to reproduce the error because it's not seen unless we compile Py-ChemShell with directly linked-in NWChem 7.2 on a specific HPC machine (the UK's ARCHER2) where only GNU and Cray-MPI is available. We did not set CONVERT_ALL, either. Here is the script we used for compiling NWChem static libraries to be used by Py-ChemShell:

#!/bin/bash

module unload epcc-job-env
module restore
module swap PrgEnv-cray PrgEnv-gnu
module load cmake/3.21.3
module load cray-python
module load cray-libsci
module load libfabric
module load tk

njobs=4

export NWCHEM_TOP=/mnt/lustre/a2fs-work3/work/c01/shared/chemshell/21.0/chemsh/interfaces/nwchem/src
export NWCHEM_MODULES=all
export NWCHEM_TARGET=LINUX64

export USE_MPI=yes
export USE_MPIF=yes
export USE_MPIF4=yes
export LIBMPI=" "
export MPI_INCLUDE=/opt/cray/pe/mpich/8.1.23/ofi/GNU/9.1/include
export MPI_LIB=/opt/cray/pe/mpich/8.1.23/ofi/GNU/9.1/lib
export FORCE_MPI_ENV=yes

export USE_OPENMP=yes
export ARMCI_NETWORK=MPI-TS

export SCALAPACK_SIZE=4
export HAVE_SCALAPACK=yes
export SCALAPACK="-L/opt/cray/pe/libsci/22.12.1.1/GNU/9.1/x86_64/lib "
export HAS_BLAS=yes
export BLAS_SIZE=4
export BLASOPT=" "
export LAPACK_LIB=" "
export LAPACK_SIZE=4
export INSTALL_PREFIX=$NWCHEM_TOP

export USE_64TO32=yes

export FC=ftn
export FOPTIONS="-fPIC -fdefault-integer-8"
export COPTIONS=-fPIC

cd $NWCHEM_TOP/src

export USE_SUBGROUPS=1

make -j $njobs nwchem_config &> config.log

make -j $njobs 64_to_32 &> 64_to_32.log

sed -i 's/ycnrm2/dznrm2/g' gwmol/cs_minres_qlp.F
sed -i 's/YOPMTR/DOPMTR/Ig' peigs/src/f77/dspevx2.F
sed -i 's/YSTEIN/DSTEIN/Ig' peigs/src/f77/dspevx2.F
sed -i 's/YSPTRD/DSPTRD/Ig' peigs/src/f77/dspevx2.F

make -j $njobs &> make.log

make install &> install.log

The above reported linking error only happens when ld links against libnwchem.so (a shared lib of ChemShell containing the NWChem static libs) due to gwmol and libga.so (GA as shared library for ChemShell) due to PeiGS (needed by GA). The above pasted Bash script doesn't result in any issue for generating nwchem the executable, even without the sed lines which are used only for preventing the errors when linking against ChemShell.

In any case, we are afraid that the cause is that none of ycnrm2, yopmtr, ystein, or ysptrd has been actually defined in the NWChem package, as we searched in the source files.

Thanks a lot!

edoapra added a commit to edoapra/nwchem that referenced this issue Jul 4, 2023
edoapra added a commit to edoapra/nwchem that referenced this issue Jul 4, 2023
@edoapra
Copy link
Collaborator

edoapra commented Jul 4, 2023

I believe the root cause of the problem is that ChemShell, by linking NWChem as a library, uses objects that NWChem does not link since they are not referenced.
I should have a fix for it some time soon

@edoapra edoapra mentioned this issue Jul 4, 2023
edoapra added a commit that referenced this issue Jul 4, 2023
@edoapra
Copy link
Collaborator

edoapra commented Jul 5, 2023

@tomkeal @chemsh I have pushed to the branch `hotfix/release-7-2-0' a couple of commits to address your failures. The problematic object files are no longer created.
Please let me now if this fixes the ChemShell problem.

@chemsh
Copy link
Author

chemsh commented Jul 5, 2023

Hi Edo, @edoapra

many thanks again for your prompt response! I can confirm that with the latest hotfix release 7.2.0 compiles in Py-ChemShell without any more linking issue. The problem is gone!

Thank you so much! I'm closing the current Issue.

@chemsh chemsh closed this as completed Jul 5, 2023
@tomkeal
Copy link

tomkeal commented Jul 6, 2023

Many thanks for your help @edoapra !

Tom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants