Variables declared in F90 module and C routines
Posted: Fri Apr 13, 2018 9:22 am
Dear CS users and CS team,
I searched for an answer to my problem in the forum and CS docs but I didn't find any, so I post it here.
I try to use some F90 variables (defined in mymodule() in cs_user_modules.f90) in a C routine (cs_user_mesh.c).
These variables are intialized at the beggining of the CS run by the use of cs_user_initialization.f90 routine.
I just declared my variable in cs_user_mesh C routine
and I try to print it with
Compiler complains about a "nested extern declaration of myvar" in cs_user_mesh.c (this could be fair as myvar will be known after linking of objects files) and compilation stops with this message :
This seems to be a linking problem, so it's probably about a missing declaration of mymodule() or a bad declaration of my variable.
Can you help me and indicate how I can properly include my module in the C routine, just like I "use mymodule" in F90 routines?
Thanks for feebacks!
Jeremie
I searched for an answer to my problem in the forum and CS docs but I didn't find any, so I post it here.
I try to use some F90 variables (defined in mymodule() in cs_user_modules.f90) in a C routine (cs_user_mesh.c).
These variables are intialized at the beggining of the CS run by the use of cs_user_initialization.f90 routine.
I just declared my variable in cs_user_mesh C routine
Code: Select all
extern int myvar
Code: Select all
bft_printf("myvar = %6i\n", myvar);
Compiler complains about a "nested extern declaration of myvar" in cs_user_mesh.c (this could be fair as myvar will be known after linking of objects files) and compilation stops with this message :
Code: Select all
cs_user_mesh.c:(.text+0x24) : référence indéfinie vers « myvar»
collect2: error: ld returned 1 exit status
Can you help me and indicate how I can properly include my module in the C routine, just like I "use mymodule" in F90 routines?
Thanks for feebacks!
Jeremie