1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-12-22 20:36:01 +01:00

auto-generation of providers

This commit is contained in:
Anthony Scemama 2022-07-11 13:42:39 +02:00
parent 9d64ff74e1
commit 2aa904bed9
4 changed files with 169 additions and 110 deletions

View File

@ -3014,7 +3014,7 @@ qmckl_get_ao_basis_ao_vgl (qmckl_context context,
qmckl_exit_code rc; qmckl_exit_code rc;
rc = qmckl_provide_ao_vgl(context); rc = qmckl_provide_ao_basis_ao_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
qmckl_context_struct* const ctx = (qmckl_context_struct*) context; qmckl_context_struct* const ctx = (qmckl_context_struct*) context;
@ -3090,7 +3090,7 @@ qmckl_get_ao_basis_ao_vgl_inplace (qmckl_context context,
ctx->ao_basis.ao_vgl = ao_vgl; ctx->ao_basis.ao_vgl = ao_vgl;
rc = qmckl_provide_ao_vgl(context); rc = qmckl_provide_ao_basis_ao_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
ctx->ao_basis.ao_vgl = old_array; ctx->ao_basis.ao_vgl = old_array;
@ -6938,18 +6938,26 @@ qmckl_compute_ao_vgl_hpc_gaussian (
**** Provide :noexport: **** Provide :noexport:
#+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none #+CALL: write_provider_header( group="ao_basis", data="ao_vgl" )
qmckl_exit_code qmckl_provide_ao_vgl(qmckl_context context);
#+RESULTS:
#+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :export none
qmckl_exit_code qmckl_provide_ao_basis_ao_vgl(qmckl_context context);
#+end_src #+end_src
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none #+CALL: write_provider_pre( group="ao_basis", data="ao_vgl", dimension="ctx->ao_basis.ao_num * 5 * ctx->point.num")
qmckl_exit_code qmckl_provide_ao_vgl(qmckl_context context)
#+RESULTS:
#+begin_src c :comments org :tangle (eval c) :noweb yes :export none
qmckl_exit_code qmckl_provide_ao_basis_ao_vgl(qmckl_context context)
{ {
qmckl_exit_code rc;
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
return qmckl_failwith( context, return qmckl_failwith( context,
QMCKL_INVALID_CONTEXT, QMCKL_INVALID_CONTEXT,
"qmckl_provide_ao_vgl", "qmckl_provide_ao_basis_ao_vgl",
NULL); NULL);
} }
@ -6959,24 +6967,20 @@ qmckl_exit_code qmckl_provide_ao_vgl(qmckl_context context)
if (!ctx->ao_basis.provided) { if (!ctx->ao_basis.provided) {
return qmckl_failwith( context, return qmckl_failwith( context,
QMCKL_NOT_PROVIDED, QMCKL_NOT_PROVIDED,
"qmckl_ao_vgl", "qmckl_provide_ao_basis_ao_vgl",
NULL); NULL);
} }
/* Compute if necessary */ /* Compute if necessary */
if (ctx->point.date > ctx->ao_basis.ao_vgl_date) { if (ctx->point.date > ctx->ao_basis.ao_vgl_date) {
qmckl_exit_code rc; if (ctx->point.alloc_date > ctx->ao_basis.ao_vgl_date) {
if (ctx->ao_basis.ao_vgl != NULL) {
/* Provide required data */ rc = qmckl_free(context, ctx->ao_basis.ao_vgl);
#ifdef HAVE_HPC assert (rc == QMCKL_SUCCESS);
ctx->ao_basis.ao_vgl = NULL;
#else }
rc = qmckl_provide_ao_basis_shell_vgl(context);
if (rc != QMCKL_SUCCESS) {
return qmckl_failwith( context, rc, "qmckl_provide_ao_basis_shell_vgl", NULL);
} }
#endif
/* Allocate array */ /* Allocate array */
if (ctx->ao_basis.ao_vgl == NULL) { if (ctx->ao_basis.ao_vgl == NULL) {
@ -6993,6 +6997,10 @@ qmckl_exit_code qmckl_provide_ao_vgl(qmckl_context context)
} }
ctx->ao_basis.ao_vgl = ao_vgl; ctx->ao_basis.ao_vgl = ao_vgl;
} }
#+end_src
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
#ifdef HAVE_HPC #ifdef HAVE_HPC
if (ctx->ao_basis.type == 'G') { if (ctx->ao_basis.type == 'G') {
rc = qmckl_compute_ao_vgl_hpc_gaussian(context, rc = qmckl_compute_ao_vgl_hpc_gaussian(context,
@ -7069,6 +7077,13 @@ qmckl_exit_code qmckl_provide_ao_vgl(qmckl_context context)
ctx->ao_basis.ao_vgl); ctx->ao_basis.ao_vgl);
,*/ ,*/
} else { } else {
/* Provide required data */
rc = qmckl_provide_ao_basis_shell_vgl(context);
if (rc != QMCKL_SUCCESS) {
return qmckl_failwith( context, rc, "qmckl_provide_ao_basis_shell_vgl", NULL);
}
rc = qmckl_compute_ao_vgl_doc(context, rc = qmckl_compute_ao_vgl_doc(context,
ctx->ao_basis.ao_num, ctx->ao_basis.ao_num,
ctx->ao_basis.shell_num, ctx->ao_basis.shell_num,
@ -7086,6 +7101,11 @@ qmckl_exit_code qmckl_provide_ao_vgl(qmckl_context context)
ctx->ao_basis.ao_vgl); ctx->ao_basis.ao_vgl);
} }
#else #else
rc = qmckl_provide_ao_basis_shell_vgl(context);
if (rc != QMCKL_SUCCESS) {
return qmckl_failwith( context, rc, "qmckl_provide_ao_basis_shell_vgl", NULL);
}
rc = qmckl_compute_ao_vgl_doc(context, rc = qmckl_compute_ao_vgl_doc(context,
ctx->ao_basis.ao_num, ctx->ao_basis.ao_num,
ctx->ao_basis.shell_num, ctx->ao_basis.shell_num,
@ -7102,6 +7122,12 @@ qmckl_exit_code qmckl_provide_ao_vgl(qmckl_context context)
ctx->ao_basis.shell_vgl, ctx->ao_basis.shell_vgl,
ctx->ao_basis.ao_vgl); ctx->ao_basis.ao_vgl);
#endif #endif
#+end_src
#+CALL: write_provider_post( group="ao_basis", data="ao_vgl" )
#+RESULTS:
#+begin_src c :comments org :tangle (eval c) :noweb yes :export none
if (rc != QMCKL_SUCCESS) { if (rc != QMCKL_SUCCESS) {
return rc; return rc;
} }

View File

@ -587,10 +587,10 @@ qmckl_exit_code qmckl_get_det_vgl_alpha(qmckl_context context, double * const de
qmckl_exit_code rc; qmckl_exit_code rc;
rc = qmckl_provide_ao_vgl(context); rc = qmckl_provide_ao_basis_ao_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_mo_vgl(context); rc = qmckl_provide_mo_basis_mo_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_det_vgl_alpha(context); rc = qmckl_provide_det_vgl_alpha(context);
@ -614,10 +614,10 @@ qmckl_exit_code qmckl_get_det_vgl_beta(qmckl_context context, double * const det
qmckl_exit_code rc; qmckl_exit_code rc;
rc = qmckl_provide_ao_vgl(context); rc = qmckl_provide_ao_basis_ao_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_mo_vgl(context); rc = qmckl_provide_mo_basis_mo_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_det_vgl_beta(context); rc = qmckl_provide_det_vgl_beta(context);
@ -679,7 +679,7 @@ qmckl_exit_code qmckl_provide_det_vgl_alpha(qmckl_context context) {
"qmckl_mo_basis", "qmckl_mo_basis",
NULL); NULL);
} }
rc = qmckl_provide_mo_vgl(context); rc = qmckl_provide_mo_basis_mo_vgl(context);
if (rc != QMCKL_SUCCESS) { if (rc != QMCKL_SUCCESS) {
return qmckl_failwith( context, return qmckl_failwith( context,
QMCKL_NOT_PROVIDED, QMCKL_NOT_PROVIDED,
@ -1326,10 +1326,10 @@ qmckl_exit_code qmckl_get_det_inv_matrix_alpha(qmckl_context context, double * c
qmckl_exit_code rc; qmckl_exit_code rc;
rc = qmckl_provide_ao_vgl(context); rc = qmckl_provide_ao_basis_ao_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_mo_vgl(context); rc = qmckl_provide_mo_basis_mo_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_det_vgl_alpha(context); rc = qmckl_provide_det_vgl_alpha(context);
@ -1355,10 +1355,10 @@ qmckl_exit_code qmckl_get_det_inv_matrix_beta(qmckl_context context, double * co
qmckl_exit_code rc; qmckl_exit_code rc;
rc = qmckl_provide_ao_vgl(context); rc = qmckl_provide_ao_basis_ao_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_mo_vgl(context); rc = qmckl_provide_mo_basis_mo_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_det_vgl_beta(context); rc = qmckl_provide_det_vgl_beta(context);
@ -1384,10 +1384,10 @@ qmckl_exit_code qmckl_get_det_adj_matrix_alpha(qmckl_context context, double * c
qmckl_exit_code rc; qmckl_exit_code rc;
rc = qmckl_provide_ao_vgl(context); rc = qmckl_provide_ao_basis_ao_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_mo_vgl(context); rc = qmckl_provide_mo_basis_mo_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_det_vgl_alpha(context); rc = qmckl_provide_det_vgl_alpha(context);
@ -1413,10 +1413,10 @@ qmckl_exit_code qmckl_get_det_adj_matrix_beta(qmckl_context context, double * co
qmckl_exit_code rc; qmckl_exit_code rc;
rc = qmckl_provide_ao_vgl(context); rc = qmckl_provide_ao_basis_ao_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_mo_vgl(context); rc = qmckl_provide_mo_basis_mo_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_det_vgl_beta(context); rc = qmckl_provide_det_vgl_beta(context);
@ -1442,10 +1442,10 @@ qmckl_exit_code qmckl_get_det_alpha(qmckl_context context, double * const det_va
qmckl_exit_code rc; qmckl_exit_code rc;
rc = qmckl_provide_ao_vgl(context); rc = qmckl_provide_ao_basis_ao_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_mo_vgl(context); rc = qmckl_provide_mo_basis_mo_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_det_vgl_alpha(context); rc = qmckl_provide_det_vgl_alpha(context);
@ -1471,10 +1471,10 @@ qmckl_exit_code qmckl_get_det_beta(qmckl_context context, double * const det_val
qmckl_exit_code rc; qmckl_exit_code rc;
rc = qmckl_provide_ao_vgl(context); rc = qmckl_provide_ao_basis_ao_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_mo_vgl(context); rc = qmckl_provide_mo_basis_mo_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_det_vgl_beta(context); rc = qmckl_provide_det_vgl_beta(context);

View File

@ -217,10 +217,10 @@ qmckl_exit_code qmckl_get_kinetic_energy(qmckl_context context, double * const k
if(!qmckl_nucleus_provided(context)) return QMCKL_NOT_PROVIDED; if(!qmckl_nucleus_provided(context)) return QMCKL_NOT_PROVIDED;
rc = qmckl_provide_ao_vgl(context); rc = qmckl_provide_ao_basis_ao_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_mo_vgl(context); rc = qmckl_provide_mo_basis_mo_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_kinetic_energy(context); rc = qmckl_provide_kinetic_energy(context);
@ -781,10 +781,10 @@ qmckl_exit_code qmckl_get_potential_energy(qmckl_context context, double * const
if(!qmckl_nucleus_provided(context)) return QMCKL_NOT_PROVIDED; if(!qmckl_nucleus_provided(context)) return QMCKL_NOT_PROVIDED;
rc = qmckl_provide_ao_vgl(context); rc = qmckl_provide_ao_basis_ao_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_mo_vgl(context); rc = qmckl_provide_mo_basis_mo_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_potential_energy(context); rc = qmckl_provide_potential_energy(context);
@ -1065,10 +1065,10 @@ qmckl_exit_code qmckl_get_local_energy(qmckl_context context, double * const loc
if(!qmckl_nucleus_provided(context)) return QMCKL_NOT_PROVIDED; if(!qmckl_nucleus_provided(context)) return QMCKL_NOT_PROVIDED;
rc = qmckl_provide_ao_vgl(context); rc = qmckl_provide_ao_basis_ao_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_mo_vgl(context); rc = qmckl_provide_mo_basis_mo_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_local_energy(context); rc = qmckl_provide_local_energy(context);
@ -1327,10 +1327,10 @@ qmckl_exit_code qmckl_get_drift_vector(qmckl_context context, double * const dri
if(!qmckl_nucleus_provided(context)) return QMCKL_NOT_PROVIDED; if(!qmckl_nucleus_provided(context)) return QMCKL_NOT_PROVIDED;
rc = qmckl_provide_ao_vgl(context); rc = qmckl_provide_ao_basis_ao_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_mo_vgl(context); rc = qmckl_provide_mo_basis_mo_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_drift_vector(context); rc = qmckl_provide_drift_vector(context);

View File

@ -457,10 +457,7 @@ qmckl_get_mo_basis_mo_value(qmckl_context context,
qmckl_exit_code rc; qmckl_exit_code rc;
rc = qmckl_provide_ao_basis_ao_value(context); rc = qmckl_provide_mo_basis_mo_value(context);
if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_mo_value(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
qmckl_context_struct* const ctx = (qmckl_context_struct*) context; qmckl_context_struct* const ctx = (qmckl_context_struct*) context;
@ -537,7 +534,7 @@ qmckl_get_mo_basis_mo_value_inplace (qmckl_context context,
ctx->mo_basis.mo_value = mo_value; ctx->mo_basis.mo_value = mo_value;
rc = qmckl_provide_mo_value(context); rc = qmckl_provide_mo_basis_mo_value(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
ctx->mo_basis.mo_value = old_array; ctx->mo_basis.mo_value = old_array;
@ -562,52 +559,55 @@ qmckl_get_mo_basis_mo_value_inplace (qmckl_context context,
*** Provide *** Provide
#+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none #+CALL: write_provider_header( group="mo_basis", data="mo_value" )
qmckl_exit_code qmckl_provide_mo_value(qmckl_context context);
#+RESULTS:
#+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :export none
qmckl_exit_code qmckl_provide_mo_basis_mo_value(qmckl_context context);
#+end_src #+end_src
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none #+CALL: write_provider_pre( group="mo_basis", data="mo_value", dimension="ctx->mo_basis.mo_num * ctx->point.num")
qmckl_exit_code qmckl_provide_mo_value(qmckl_context context)
#+RESULTS:
#+begin_src c :comments org :tangle (eval c) :noweb yes :export none
qmckl_exit_code qmckl_provide_mo_basis_mo_value(qmckl_context context)
{ {
qmckl_exit_code rc; qmckl_exit_code rc;
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
return QMCKL_NULL_CONTEXT; return qmckl_failwith( context,
QMCKL_INVALID_CONTEXT,
"qmckl_provide_mo_basis_mo_value",
NULL);
} }
qmckl_context_struct* const ctx = (qmckl_context_struct*) context; qmckl_context_struct* const ctx = (qmckl_context_struct*) context;
assert (ctx != NULL); assert (ctx != NULL);
if (!ctx->ao_basis.provided) {
return qmckl_failwith( context,
QMCKL_NOT_PROVIDED,
"qmckl_ao_basis",
NULL);
}
rc = qmckl_provide_ao_basis_ao_value(context);
if (rc != QMCKL_SUCCESS) {
return qmckl_failwith( context,
QMCKL_NOT_PROVIDED,
"qmckl_ao_value",
NULL);
}
if (!ctx->mo_basis.provided) { if (!ctx->mo_basis.provided) {
return qmckl_failwith( context, return qmckl_failwith( context,
QMCKL_NOT_PROVIDED, QMCKL_NOT_PROVIDED,
"qmckl_mo_basis", "qmckl_provide_mo_basis_mo_value",
NULL); NULL);
} }
/* Compute if necessary */ /* Compute if necessary */
if (ctx->point.date > ctx->mo_basis.mo_value_date) { if (ctx->point.date > ctx->mo_basis.mo_value_date) {
if (ctx->point.alloc_date > ctx->mo_basis.mo_value_date) {
if (ctx->mo_basis.mo_value != NULL) {
rc = qmckl_free(context, ctx->mo_basis.mo_value);
assert (rc == QMCKL_SUCCESS);
ctx->mo_basis.mo_value = NULL;
}
}
/* Allocate array */ /* Allocate array */
if (ctx->mo_basis.mo_value == NULL) { if (ctx->mo_basis.mo_value == NULL) {
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
mem_info.size = ctx->point.num * ctx->mo_basis.mo_num * sizeof(double); mem_info.size = ctx->mo_basis.mo_num * ctx->point.num * sizeof(double);
double* mo_value = (double*) qmckl_malloc(context, mem_info); double* mo_value = (double*) qmckl_malloc(context, mem_info);
if (mo_value == NULL) { if (mo_value == NULL) {
@ -619,6 +619,17 @@ qmckl_exit_code qmckl_provide_mo_value(qmckl_context context)
ctx->mo_basis.mo_value = mo_value; ctx->mo_basis.mo_value = mo_value;
} }
#+end_src
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
rc = qmckl_provide_ao_basis_ao_value(context);
if (rc != QMCKL_SUCCESS) {
return qmckl_failwith( context,
QMCKL_NOT_PROVIDED,
"qmckl_ao_value",
NULL);
}
if (ctx->mo_basis.mo_vgl_date == ctx->point.date) { if (ctx->mo_basis.mo_vgl_date == ctx->point.date) {
// mo_vgl has been computed at this step: Just copy the data. // mo_vgl has been computed at this step: Just copy the data.
@ -643,12 +654,17 @@ qmckl_exit_code qmckl_provide_mo_value(qmckl_context context)
ctx->ao_basis.ao_value, ctx->ao_basis.ao_value,
ctx->mo_basis.mo_value); ctx->mo_basis.mo_value);
}
#+end_src
#+CALL: write_provider_post( group="mo_basis", data="mo_value" )
#+RESULTS:
#+begin_src c :comments org :tangle (eval c) :noweb yes :export none
if (rc != QMCKL_SUCCESS) { if (rc != QMCKL_SUCCESS) {
return rc; return rc;
} }
}
ctx->mo_basis.mo_value_date = ctx->date; ctx->mo_basis.mo_value_date = ctx->date;
} }
@ -914,10 +930,7 @@ qmckl_get_mo_basis_mo_vgl(qmckl_context context,
qmckl_exit_code rc; qmckl_exit_code rc;
rc = qmckl_provide_ao_vgl(context); rc = qmckl_provide_mo_basis_mo_vgl(context);
if (rc != QMCKL_SUCCESS) return rc;
rc = qmckl_provide_mo_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
qmckl_context_struct* const ctx = (qmckl_context_struct*) context; qmckl_context_struct* const ctx = (qmckl_context_struct*) context;
@ -994,7 +1007,7 @@ qmckl_get_mo_basis_mo_vgl_inplace (qmckl_context context,
ctx->mo_basis.mo_vgl = mo_vgl; ctx->mo_basis.mo_vgl = mo_vgl;
rc = qmckl_provide_mo_vgl(context); rc = qmckl_provide_mo_basis_mo_vgl(context);
if (rc != QMCKL_SUCCESS) return rc; if (rc != QMCKL_SUCCESS) return rc;
ctx->mo_basis.mo_vgl = old_array; ctx->mo_basis.mo_vgl = old_array;
@ -1019,52 +1032,55 @@ qmckl_get_mo_basis_mo_vgl_inplace (qmckl_context context,
*** Provide *** Provide
#+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none #+CALL: write_provider_header( group="mo_basis", data="mo_vgl" )
qmckl_exit_code qmckl_provide_mo_vgl(qmckl_context context);
#+RESULTS:
#+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :export none
qmckl_exit_code qmckl_provide_mo_basis_mo_vgl(qmckl_context context);
#+end_src #+end_src
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none #+CALL: write_provider_pre( group="mo_basis", data="mo_vgl", dimension="5 * ctx->mo_basis.mo_num * ctx->point.num")
qmckl_exit_code qmckl_provide_mo_vgl(qmckl_context context)
#+RESULTS:
#+begin_src c :comments org :tangle (eval c) :noweb yes :export none
qmckl_exit_code qmckl_provide_mo_basis_mo_vgl(qmckl_context context)
{ {
qmckl_exit_code rc; qmckl_exit_code rc;
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
return QMCKL_NULL_CONTEXT; return qmckl_failwith( context,
QMCKL_INVALID_CONTEXT,
"qmckl_provide_mo_basis_mo_vgl",
NULL);
} }
qmckl_context_struct* const ctx = (qmckl_context_struct*) context; qmckl_context_struct* const ctx = (qmckl_context_struct*) context;
assert (ctx != NULL); assert (ctx != NULL);
if (!ctx->ao_basis.provided) {
return qmckl_failwith( context,
QMCKL_NOT_PROVIDED,
"qmckl_ao_basis",
NULL);
}
rc = qmckl_provide_ao_vgl(context);
if (rc != QMCKL_SUCCESS) {
return qmckl_failwith( context,
QMCKL_NOT_PROVIDED,
"qmckl_ao_basis",
NULL);
}
if (!ctx->mo_basis.provided) { if (!ctx->mo_basis.provided) {
return qmckl_failwith( context, return qmckl_failwith( context,
QMCKL_NOT_PROVIDED, QMCKL_NOT_PROVIDED,
"qmckl_mo_basis", "qmckl_provide_mo_basis_mo_vgl",
NULL); NULL);
} }
/* Compute if necessary */ /* Compute if necessary */
if (ctx->point.date > ctx->mo_basis.mo_vgl_date) { if (ctx->point.date > ctx->mo_basis.mo_vgl_date) {
if (ctx->point.alloc_date > ctx->mo_basis.mo_vgl_date) {
if (ctx->mo_basis.mo_vgl != NULL) {
rc = qmckl_free(context, ctx->mo_basis.mo_vgl);
assert (rc == QMCKL_SUCCESS);
ctx->mo_basis.mo_vgl = NULL;
}
}
/* Allocate array */ /* Allocate array */
if (ctx->mo_basis.mo_vgl == NULL) { if (ctx->mo_basis.mo_vgl == NULL) {
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
mem_info.size = 5 * ctx->point.num * ctx->mo_basis.mo_num * sizeof(double); mem_info.size = 5 * ctx->mo_basis.mo_num * ctx->point.num * sizeof(double);
double* mo_vgl = (double*) qmckl_malloc(context, mem_info); double* mo_vgl = (double*) qmckl_malloc(context, mem_info);
if (mo_vgl == NULL) { if (mo_vgl == NULL) {
@ -1076,6 +1092,17 @@ qmckl_exit_code qmckl_provide_mo_vgl(qmckl_context context)
ctx->mo_basis.mo_vgl = mo_vgl; ctx->mo_basis.mo_vgl = mo_vgl;
} }
#+end_src
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
rc = qmckl_provide_ao_basis_ao_vgl(context);
if (rc != QMCKL_SUCCESS) {
return qmckl_failwith( context,
QMCKL_NOT_PROVIDED,
"qmckl_ao_basis",
NULL);
}
rc = qmckl_compute_mo_basis_mo_vgl(context, rc = qmckl_compute_mo_basis_mo_vgl(context,
ctx->ao_basis.ao_num, ctx->ao_basis.ao_num,
ctx->mo_basis.mo_num, ctx->mo_basis.mo_num,
@ -1083,6 +1110,12 @@ qmckl_exit_code qmckl_provide_mo_vgl(qmckl_context context)
ctx->mo_basis.coefficient_t, ctx->mo_basis.coefficient_t,
ctx->ao_basis.ao_vgl, ctx->ao_basis.ao_vgl,
ctx->mo_basis.mo_vgl); ctx->mo_basis.mo_vgl);
#+end_src
#+CALL: write_provider_post( group="mo_basis", data="mo_vgl" )
#+RESULTS:
#+begin_src c :comments org :tangle (eval c) :noweb yes :export none
if (rc != QMCKL_SUCCESS) { if (rc != QMCKL_SUCCESS) {
return rc; return rc;
} }