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

Why is the "ALL_CINT_FORTRAN_" macro commented out for the autogenerated code? #14

Open
MarcusTL12 opened this issue May 11, 2022 · 3 comments

Comments

@MarcusTL12
Copy link

I see they are not commented out in libcint. Is it safe to just uncomment them in the gen-code.cl script? If not, what is the reason for the reduced compatibility between qcint vs libcint?

@MarcusTL12
Copy link
Author

Update:
Naively uncommenting in the generation script does not work. This gives a bunch of compilation errors where functions are called with the wrong number of arguments.

It does however work to write short wrapper function manually in C that is doing essentially what the macro should be doing. Here I tested with some gradient 2-electron integrals that were not directly callable from fortran, and they work nicely with optimizer.

#include "cint.h"

int int2e_ip1_sph(double *buf, int *dims, int *shls, int *atm, int natm, int *bas,
              int nbas, double *env, CINTOpt *opt, double *cache);

void int2e_ip1_optimizer(CINTOpt **opt, int *atm, int natm, int *bas, int nbas,
                     double *env);

int int_wrapper_(double *buf, int *shls, int *atm, int *natm, int *bas,
                 int *nbas, double *env, void **opt) {
    return int2e_ip1_sph(buf, NULL, shls, atm, *natm, bas, *nbas, env,
                     *(CINTOpt **)(opt), NULL);
}

void opt_wrapper_(void **opt, int *atm, int *natm, int *bas, int *nbas,
                  double *env) {
    int2e_ip1_optimizer((CINTOpt **)opt, atm, *natm, bas, *nbas, env);
}

void del_opt_wrapper_(void **opt) { CINTdel_optimizer((CINTOpt **)opt); }

So there is seemingly no inherent problem to call from Fortran, just the macro not working. Would it take a lot of work to fix the macro?

@MarcusTL12
Copy link
Author

Update 2:

So after comparing the gen-code.cl scripts from libcint and qcint, I noticed that in libcint the call of the macro looks like

"ALL_CINT_FORTRAN_(~a)~%"

while in qcint it looks like

"ALL_CINT_FORTRAN_(c~a)~%"

This prepending of a c to the name seems like an error as it then tries to generate functions with names "ccint2e_...". Removing this seemes to have fixed the problem.

@MarcusTL12
Copy link
Author

Created a pull request (#15) with a possible fix.

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

1 participant