Ansys Products

Ansys Products

Discuss installation & licensing of our Ansys Teaching and Research products.

Chemkin user subroutine – compiling issues

    • Javier Rodriguez
      Subscriber

      I'm trying to modify the creslaf user subroutine but when I try to compile the modified version I get the following error:

      Compiling creslaf_user_routines.f
              ifort -nologo -D_AMD64_ -DUSE_XERCES_2_8 -MD  -I. -Ipc -I..\pc -I.. -I..\include\ -I..\user_routines -I..\source\ -I..\source\solvers\ -I..\source\multiPhase -I..\kinetics\API  -I\include -I\include\xercesc -I\source\encryption -threads -O3 -DDLL_EXPORT /assume:noold_maxminloc /Qopenmp /Qmkl:sequential  -fpp  -c -Focreslaf_user_routines.obj creslaf_user_routines.f
      creslaf_user_routines.f(59): error #7002: Error in opening the compiled module file.  Check INCLUDE paths.   [CKUSERROUTINES_INTERFACESMODULE]
            Use CKuserRoutines_InterfacesModule
      ----------^
      creslaf_user_routines.f(145): error #7002: Error in opening the compiled module file.  Check INCLUDE paths.   [CKUSERROUTINES_INTERFACESMODULE]
            Use CKuserRoutines_InterfacesModule
      ----------^
      compilation aborted for creslaf_user_routines.f (code 1)

       

      I'm guessing it's an issue with locating the "CKuserRoutines_InterfacesModule", but I can't locate this component anywhere

    • jcooper
      Ansys Employee

      Hi Javier:

      As far as I know there is no special utility for compilation, so the error may come because you are using compilation steps that may not access the proper Chemkin environment.  There are some .mak files in the Chemkin installation to help with this.

      Below are the steps outlined in the Chemkin Help documentation.  You can test them out by executing each step to see if it works as expected:

       

      The following steps will incorporate a customized rate routine in cklib_user_routines.f, and/or a modified FUNCTION PRQFUN in premix_user_routines.f for the Premixed Laminar Flame Models, by recompiling the modified user routines and updating the object archive library required by the application program:

      1. On Windows systems, set the FLEXLM_ARCH environment variable.

      2. Locate the user routines’ archive library file:

        For Windows/PC, this library is located at \lib\user_routines.lib.

        For UNIX, this library is located at /lib/user_routines.a.

      3. Back up the library file; for example, rename the existing user_routines.lib file (e.g. as installed_user_routines.lib), so that it does not get overwritten.

      4. Using the makefile available in the user_routines directory, the following will compile the changes made to the user routine files and create a new user_routines.lib. The command must be typed in an Intel FORTRAN command window (PC) or in a UNIX shell with the Intel FORTRAN environment, after using the cd command to reach the user_routines directory:

        For Windows/PC, use:

        nmake -i -f user_routines_pc.mak

        For UNIX, use:

        make -i -f user_routines_unix.mak


        Note:  If you copy instead of rename the original library, you will have to also explicitly delete the original file from the lib directory before make will build a new version.


      5. On Windows platforms, set the environment variable FLEXLM_ARCH to: win64.

      6. You must rebuild the target executable's shared-object library, thus linking the updated user routines’ library. The shared-object libraries are located in the bin directory (for example, PC: %CHEMKIN_BIN% ; UNIX: $CHEMKIN_BIN). In this example, you create the shared-object library associated with the PRQFUN routine in Table 2.1: Keyword and FORTRAN Code Relationships, to incorporate the modified routines cited in the previous step:

        For Windows/PC, the shared-object library consists of three files, premixdll.dll, premixdll.exp, and premixdll.lib.

        For UNIX platforms, the corresponding file is libpremix.so (for LINUX).

      7. Back up the shared-object library for the executable that you want to build. For example, rename the existing premixdll.* files (for example, as installed_premixdll.dll), so that they do not get overwritten.


        Note:  If you copy instead of rename the original library, you will have to also explicitly delete the original file from the bin directory before make will build a new version.


      8. Change directories to the drivers_cpp directory:

        For Windows/PC, use:

        cd ..\drivers_cpp

        For UNIX, use:

        cd ../drivers_cpp

      9. For the Reactor Model you are targeting, make a new shared-object library using the makefile located in the drivers_cpp directory:

        For Windows/PC, use:

        nmake -i -f drivers_cpp_pc.mak ..\bin\premixdll.dll

        which also creates a new premixdll.exp and premixdll.lib.

        For UNIX, use:

        make -i -f drivers_cpp_unix.mak ../bin/libpremix.so

      Now you can launch the Ansys Chemkin interface and process your input files as usual with the modified run-time shared-object library for the associated Reactor Models (in this case the Premixed Burner-stabilized Flame and the Premixed Flame-speed Calculator). Remember to restore the backed-up shared-object library when you want to return to the as-installed functionality.

      • Javier Rodriguez
        Subscriber

        If i use the instructions shared I get the following issue:

        C:\Program Files\ANSYS Inc\v232\reaction\chemkinpro.win64\user_routines>nmake -i -f user_routines_pc.mak
         
        Microsoft (R) Program Maintenance Utility Version 14.38.33133.0
        Copyright (C) Microsoft Corporation.  All rights reserved.
         
        NMAKE : fatal error U1073: don't know how to make 'CKuserRoutines_InterfacesModule.obj'
        Stop.
         
        C:\Program Files\ANSYS Inc\v232\reaction\chemkinpro.win64\user_routines>
         
         
        The issue is still due to the CKuserRoutines_InterfacesModule
    • jcooper
      Ansys Employee

      Ah I see ... It looks like an object listed in the .mak file is missing.

       

      There should be a file named as CKuserRoutines_InterfacesModule.f90 in the  folder: C:\Program Files\ANSYS Inc\v232\reaction\chemkinpro.win64\user_routines

      I am following up with Development to see what they suggest.

    • Javier Rodriguez
      Subscriber

      I am missing that file from the user_routines folder. Can this file simply be sent via email or attached here as a link?

    • jcooper
      Ansys Employee

      Hi Javier:

      I am hoping so.  (It is missing from my Chemkin installations as well, so it may have to be created first.)

      Email or FTP will probably be the best way to transfer it - I'll keep you posted.

    • jcooper
      Ansys Employee

      Hi Javier:

      I have the missing file. It is source code, so I won't post it here. If you can send me your email, I will FTP it to you.

      The upcoming Chemkin release (24.1) will have this file included.

      Best Regards,

      Judy

    • Javier Rodriguez
      Subscriber

       

      my email is \\\

       

    • jcooper
      Ansys Employee

      I just sent you the file.  It will come from securetransfer@ansys

       

      Best Regards,

       

      Judy

      • Javier Rodriguez
        Subscriber

        I received the email, thanks

    • Javier Rodriguez
      Subscriber

      I did the above steps for "prqfun" but when running the premixed burner sample I get the following message on chemkin but no output file is generated:

      No projects were open when last session exited.  So, none are reopened now.
      Beginning pre-mixed_burner__burner_stabilized Network Diagram Validation...  
      System connectivity validated.  Updating Open Projects tree.
      Beginning pre-mixed_burner__burner_stabilized Network Diagram Validation...  
      System connectivity validated.  Updating Open Projects tree.
      Create input file C:\Users\main\chemkin\samples2023R2\pre-mixed_burner\burner_stabilized\pre-mixed_burner__burner_stabilized.inp
      Obtained 1 copy of CHEMKIN.
      Licenses will be held until this user interface is closed.
      Start running Pre-Mixed_Burner (C1)......
      Possible runtime error encountered, retrying
      Finish running Pre-Mixed_Burner (C1): failed
      Done running all jobs

    • jcooper
      Ansys Employee

      This means that the run failed.

       

      Your working folder should be full of files:

      Normally, the file that contains the diagnostics for the run has the .out.  Most failures are numerical.  No .out file indicates that the run never started, so there is probably something wrong with the linked material(s).  I would suggest retrying your steps with the unmodifed rate routine to rule out coding error. If there is a .log file in the directory, this may also be helpful.

      • Javier Rodriguez
        Subscriber

        The reactor works fine when I restore the default user routines. But when I follow the exact steps shown above for using user subroutines (without modifying any of the user subroutine .f files) I get the runtime error and no .out file for the reactor (only the gas and gtran output files are generated). I do however have a .bat file that when run results in the issue shown below.

         

    • jcooper
      Ansys Employee

      What is your compiler?  Are you using Intel or something else?  that dll appears to be a component of the Intel compiler.

      Are you using Intel Fortran command prompt or a native command prompt and then setting the environment?

      • Javier Rodriguez
        Subscriber

        I'm using the Intel compiler through the Intel Fortran command prompt

    • jcooper
      Ansys Employee

      What is the path to your compiler?  Is it 32-bit or 64-bit?

       

    • jcooper
      Ansys Employee

      Chemkin was built with Intel Fortran compiler update 5 2019.  It is possible that there is a compiler incompatibility here.  Please make sure you are launching the 64-bit compiler.

       

       

      • Javier Rodriguez
        Subscriber

        Im using the Intel oneAPI command prompt for Intel 64 for Visual Studio 2022, but the OneAPI that I have installed is 2024. Could this 2024 version be the issue?

    • jcooper
      Ansys Employee

      Chemkin was built using Visual Studio 2019 and Intel Fortran compiler update 5 2019 so the Visual Studio version or the compiler versions could be the problem.  We have seen this error in some situations, and according to our Developers, it is still a bit inconsistent.  Some combinations with newer compilers have worked and some not.  We still haven't nailed down the reason.  If you can't get Intel Fortran, you could try downgrading the compiler version to 2021 or lower.

    • jcooper
      Ansys Employee

      Are you on Windows 10 or 11?

       

      • Javier Rodriguez
        Subscriber

        Windows 10

    • jcooper
      Ansys Employee

      Hi Javier:

      I believe we may have found the possible root-cause of this issue: wrong Intel MKL version (as is suggested by the error message)

      [1] Both versions of Chemkin, v232 and v241 use the Intel MKL 2021.3.0
       
      [2] Both versions of Chemkin, v232 and v241 use Visual Studio 2019
       
      [3] The compiler used for v232 is IntelFortran update 5 2019 whereas for v241 it is the oneAPI (Intel Fortran Classic i.e. ifort)
       
      [4] Unfortunately, the default (built-in) versions of MKL (i.e. what one would get when downloading the compiler) are incompatible with Chemkin needs (as mentioned in [1]).
       
      [5] So, I would suggest downloading and installing Intel MKL 2021.3.0. The installation folder should have a directory structure as shown in the screen-shot below:
       
       
      [6] With correct version of MKL installed, you can open the appropriate compiler command prompt (for the versions as mentioned in [3] above) and then set-up the correct MKL version.
      The setting up of MKL is done by typing: Call MKL_Install_DIR\env\vars.bat intel64 vs2019
       
      When set correctly, if one types the following at the command prompt: where mkl_core.1.dll  ---- it would show the install path to MKL.
       
      [7] Now from this command prompt with appropriate compiler and MKL, follow building the user-routine (the static library and the application dll).
       
      With [7], the user-routine would work as expected when running from the GUI.
       
      [8] To run from command prompt:
      (a) Open a native (non-compiler) command prompt.
      (b) Set Chemkin environment by typing: ANSYS_Install_DIR\reaction\chemkinpro.win64\bin\run_chemkinpro_env_setup.bat
       
      And then run the appropriate application program.
       
      Please let me know if this works.
       
      Best Regards,
       
      Judy
      • Javier Rodriguez
        Subscriber

        The issue is I don't have access to the 2021 MKL - I only have the recent 2024 on that comes with the compiler. 

        I do have access to a linux machine that has the 2021 compiler but this also returns an error when making the new shared-object library using the makefile located in the drivers_cpp (error message is "error #10236: File not found: '../lib//libmkl_blas95_lp64.a'")

    • jcooper
      Ansys Employee

      I could not find a way to download the MKL either. Looks like we may have to see if we can supply the MKL version...  I have passed your findings on to our developers

    • jcooper
      Ansys Employee

      You will probably need an active support subscription with Intel to download previous versions. The advice I got from development was to try linking up to the MKL redistributable within the  Chemkin installation.  You can do this using the following steps

      Note that we haven't tried this in-house, and it is not something that we would say we support...
       
      (1) In the Chemkin installation folder (for example, C:\Program Files\ANSYS Inc\v232\reaction\chemkinpro.win64\bin) locate file named: run_chemkinpro_env_setup_part2.bat
      (2) In this file, see line (~ # 33) as: set PATH=%CHEMKIN_BIN%;%TP_DIR%\IntelCompiler\2019.5.281\winx64;%TP_DIR%\IntelMKL\2021.3.0\winx64;%TP_DIR%\zlib\1.2.13\winx64;%PATH%
       
      Notice the reference to MKL as %TP_DIR%\IntelMKL\2021.3.0\winx64   This is coming from the 'third-party' directory that we provide. (This TP_DIR is set at line ~ #26.) The location of MKL for Chemkin v241 would therefore ultimately resolve to C:\Program Files\ANSYS Inc\v241\tp\IntelMKL\2021.3.0\winx64 
       
      (3) Instead of the above, when using the oneAPI compiler you can try: C:\Program Files (x86)\Intel\oneAPI\mkl\2023.1.0\redist\intel64
       
      Save a copy of the _part2.bat file first so that you can revert back to it. Then, edit it and replace the %TP_DIR%\IntelMKL\2021.3.0\winx64 with the new MKL location.
       
      (4) Alternatively, you can just copy and paste all the files from the oneAPI mkl folder into %TP_DIR%\IntelMKL\2021.3.0\winx64

       

    • Javier Rodriguez
      Subscriber

      I copied all my MKL files into %TP_DIR%\IntelMKL\2021.3.0\winx64 and after using the compiler to modify a routine it seems to be working now

      Thanks for the help

       

    • jcooper
      Ansys Employee

      You're very welcome! ????

    • jcooper
      Ansys Employee
      One thing to note: when new MKL files are copied over (or pointed to in the batch file), ONLY the application that was rebuilt will run correctly. ANY applications which were not recompiled will continue to want the previous (as-installed) MKL files. To run those,you will need the older MKL on path. 
    • SAI ROHITH THAVITI
      Subscriber

      Hello,

      Thanks for the detailed discussion on compiling user subroutines. I followed the above procedure by copying the mkl files into the chemkin directory and ran a reactor which is using the premix code. The reactor returns an error but the .out file is generated. The error states:

      PREMIX: Error initializing gas-phase linkfile...C:\Users\asus\chemkin\samples2024R1\pre-mixed_burner\burner_stabilized\pre-mixed_burner__burner_stabilized_gas.asc

      Could anyone tell where am I going wrong?

Viewing 21 reply threads
  • The topic ‘Chemkin user subroutine – compiling issues’ is closed to new replies.