gms-bbg / gamess-issues

GAMESS issue tracking
7 stars 1 forks source link

Compiling GAMESS in Windows with Intel Compilers, with LibXC plugin #43

Open shoubhikraj opened 3 years ago

shoubhikraj commented 3 years ago

I have already mentioned some fixes to get the default GAMESS build working on Windows with Intel compilers in #42 . This is a way of running the LibXC interface to GAMESS on windows.

For compiling LibXC:

  1. Install CMake for Windows. Then download the compressed archive for LibXC. The current GAMESS version as of now supports libxc v5.0.0, other versions will cause compilation failure. Decompress the archive in any location on the computer (for example, G:\libxc)
  2. Run the "setvars.bat" script file for Intel oneAPI compilers to get the command line for building. Then add the location of the CMake binary to the PATH. By default the cmake binary (cmake.exe) is in C:\Program Files\CMake\bin. So in the command line, run set PATH="C:\Program Files\CMake\bin\";%PATH%
  3. In the LibXc folder, open the "CMakeLists.txt" file, and edit around line 26. Change
    option_with_flags(ENABLE_XHOST "Enable processor-specific optimization" ON
    "-xHost" "-march=native")

    to this:

    option_with_flags(ENABLE_XHOST "Enable processor-specific optimization" ON
    "-QxHost")
  4. Then in the command line change directory to G:\libxc (or wherever the libxc files are), and run the following commands:
    set FC=ifort
    set CC=icl
    set CXX=icl
    cmake -S. -B./build -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DENABLE_FORTRAN=ON -DBUILD_TESTING=OFF -DBUILD_FPIC=ON -DCMAKE_BUILD_SHARED_LIBS=OFF
    cd build
    nmake

    This will compile LibXC, and it will take some time. After compilation is finished, there should be "xc.lib", "xcf90.lib", and "xc_f90_lib_m.mod" in the build directory. Create a new directory gamess/libxc/ (where the gamess source files are) and then paste these files in the gamess/libxc folder.

  5. When running ./config in GAMESS, choose Yes when the prompt about libxc comes up.
  6. Then run compall and lked as usual. Some modifications need to be made in comp and lked scripts: In lked (line 1221) change it to set LIBXC_FLAGS="C:/cygwin64$GMS_PATH/libxc/xcf90.lib C:/cygwin64$GMS_PATH/libxc/xc.lib" This is so that the libxc libraries are linked with gamess. In comp (line 2788) change it to set EXTRAOPT='-fpp -IC:\cygwin64\gamess\libxc' This is so that the .mod file is accessible to the compiler when compiling the GAMESS libxc interface files.
  7. The linking should run successfully to generate the gamess executable. However, the files "libifcoremd.dll" and "libmmd.dll" has to be in the same directory as the executable. These files are usually present in "C:\Program Files (x86)\Intel\oneAPI\compiler\latest\windows\redist\intel64_win\compiler".

After this the GAMESS-LibXC interface should hopefully run without any issue. I have only tested it with rdft-APF-gradient.inp and rdft-He-unnamed-gradient.inp test files.

Now that Intel compilers are free, this should make compiling easier on Windows systems.

The modified comp, and lked scripts are attached: comp.txt lked.txt

foxtran commented 3 years ago

Thank you for this instruction.

option_with_flags(ENABLE_XHOST "Enable processor-specific optimization" ON "-QxHost")

Please, provide this change to LibXC (https://gitlab.com/libxc/libxc) as an improvement for Win10 support, but do not remove other options.

What was the reason not to use ${GMS_PATH}/tools/libxc/download-libxc.csh?

One place, which should be changed, is adding -G"NMake Makefiles" to CMake command in Makefile.in, but I don't have Win10 to test it. Can you try it, please?

saromleang commented 3 years ago

I can work on integrating these changes for your libxc repo and testing on Windows 10.

foxtran commented 3 years ago

@saromleang, I'll be glad for your help! If you fork the libxc-5.1.0 branch, it will be better than pushing to the libxc-5.1.0 branch directly. Later, I'll rebase your changes.

shoubhikraj commented 3 years ago

@FulgurIgor

I didn't use the download-libxc.csh script because the curl command does not work from cygwin on Windows for some reason.

foxtran commented 3 years ago

Ok. Which command for downloading is available on Windows?

shoubhikraj commented 3 years ago

@FulgurIgor

Hi, I have managed to make the download-libxc.csh script work on Cygwin.

The argument --ssl-no-revoke just needs to be added to the curl command:

curl https://gitlab.com/libxc/libxc/-/archive/5.0.0/libxc-5.0.0.tar.gz -o ${GMS_PATH}/libxc/libxc-5.0.0.tar.gz --ssl-no-revoke

Turns out the curl command wasn't working due to some kind of certificate problem.

foxtran commented 3 years ago

The --ssl-no-revoke flag is available only on Windows :-| Was it be the problem with your computer or is it a general problem with Windows?

shoubhikraj commented 3 years ago

@FulgurIgor I am not sure if it's a problem with only my computer. I don't have access to other windows computers right now so I can't check.

The --insecure flag will disable all types of certificate checking all together, and it works on both Windows and Linux as far as I can tell. But it will greatly reduce security as well.

Would it be acceptable to make a separate script for windows, perhaps a native windows batch script?

shoubhikraj commented 3 years ago

Another solution might be to use:

source ../install.info

if ($GMS_TARGET == win64) then
  curl https://gitlab.com/libxc/libxc/-/archive/5.0.0/libxc-5.0.0.tar.gz -o ${GMS_PATH}/libxc/libxc-5.0.0.tar.gz --ssl-no-revoke
else
  curl https://gitlab.com/libxc/libxc/-/archive/5.0.0/libxc-5.0.0.tar.gz -o ${GMS_PATH}/libxc/libxc-5.0.0.tar.gz
foxtran commented 3 years ago

@ShoubhikRaj, why do you add -QxHost, but not /QxHost? According to https://software.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/code-generation-options/xhost-qxhost.html, /QxHost should be.

saromleang commented 3 years ago

@ShoubhikRaj, why do you add -QxHost, but not /QxHost? According to https://software.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/code-generation-options/xhost-qxhost.html, /QxHost should be.

it depends where you are compiling. if you are compiling from windows command prompt you use '/'. if you are compiling within cygwin you can use either '-' or '/'.

cygwin provides access to csh/tcsh/bash however, there is no access for shells or any linux commands via the command prompt.

shoubhikraj commented 3 years ago

I have tested both '-' and '/' for arguments, and Intel compilers accept both everywhere, even when compiling from windows command prompt i.e. -QxHost will work outside cygwin too.