sharc-md / sharc

The SHARC molecular dynamics (MD) program suite is an ab initio MD software package developed to study the excited-state dynamics of molecules.
https://www.sharc-md.org
GNU General Public License v3.0
66 stars 36 forks source link

Error and Warnings when Compiling SHARC and PySHARC #55

Closed eqmao closed 1 year ago

eqmao commented 1 year ago

Hi Dear SHARC Developers,

A while ago I encountered an 'internal compiler error' when trying to compile with GNU compilers so I'm trying to compile with the Intel compilers. The conda packages are installed before compilation.

When compiling sharc/source/misc.f90 and sharc/source/nuclear.f90, ifort is having trouble with the 'rand()' function:

ifort   -O3 -fPIC -g   -c misc.f90
misc.f90(180): error #6404: This name does not have a type, and must have an explicit type.   [RAND]
      seed=int(65536*(rand()-0.5d0))
----------------------^

ifort   -O3 -fPIC -g   -c nuclear.f90
nuclear.f90(929): error #6404: This name does not have a type, and must have an explicit type.   [RAND]
    theta=rand()
----------^
nuclear.f90(932): warning #7319: This argument's data type is incompatible with this intrinsic procedure; procedure assumed EXTERNAL.   [LOG]
    r=sqrt(-2*log(rand())*var)
------------------^
nuclear.f90(932): error #6404: This name does not have a type, and must have an explicit type.   [LOG]
    r=sqrt(-2*log(rand())*var)
--------------^

Replacing the 'rand()' function with the 'random_number()' function seems to fix the problem but I'm not sure if I'm doing the right thing.

When compiling netcdf functionalities I had these warnings, though the compilation managed to proceed:

gcc -fPIC -I.  -I/home/user/software/anaconda3/include -O3 -Wall -c nc_sharc.c
In file included from nc_sharc.h:28,
                 from nc_sharc.c:25:
nc_sharc.c: In function ‘reopen_ncoutputdat’:
nc_sharc.c:141:48: warning: passing argument 3 of ‘nc_inq_dimlen’ makes pointer from integer without a cast [-Wint-conversion]
             nc_inq_dimlen(ncdat->id, unlim_id, nsteps)
                                                ^~~~~~
nc_basic.h:32:18: note: in definition of macro ‘check_nccall’
     if (( iret = ncall)) \
                  ^~~~~
In file included from nc_basic.h:28,
                 from nc_sharc.h:28,
                 from nc_sharc.c:25:

Another similar warning was also poped up for nc_sharc.c:302:52.

When compiling pysharc I had these warnings, though the compilation managed to proceed:

In file included from pysharc_src/pysharc.c:338:
pysharc_src/pysharc_QMout.c: In function 'QMout_init':
pysharc_src/pysharc_QMout.c:143:18: warning: passing argument 1 of 'setPointers' from incompatible pointer type [-Wincompatible-pointer-types]
  143 |     setPointers( (double complex **)H_ptr,
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~
      |                  |
      |                  _Complex double **
In file included from include/libsharc.h:25,
                 from pysharc_src/pysharc.c:48:
include/interface.h:60:26: note: expected 'void **' but argument is of type '_Complex double **'
   60 | void setPointers(void ** H, void ** dm,
      |                  ~~~~~~~~^
In file included from pysharc_src/pysharc.c:338:
pysharc_src/pysharc_QMout.c:144:18: warning: passing argument 2 of 'setPointers' from incompatible pointer type [-Wincompatible-pointer-types]
  144 |                  (double complex **)DM_ptr,
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                  |
      |                  _Complex double **
In file included from include/libsharc.h:25,
                 from pysharc_src/pysharc.c:48:
include/interface.h:60:37: note: expected 'void **' but argument is of type '_Complex double **'
   60 | void setPointers(void ** H, void ** dm,
      |                             ~~~~~~~~^~
In file included from pysharc_src/pysharc.c:338:
pysharc_src/pysharc_QMout.c:145:18: warning: passing argument 3 of 'setPointers' from incompatible pointer type [-Wincompatible-pointer-types]
  145 |                  (double complex **)Ov_ptr,
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                  |
      |                  _Complex double **
In file included from include/libsharc.h:25,
                 from pysharc_src/pysharc.c:48:
include/interface.h:61:26: note: expected 'void **' but argument is of type '_Complex double **'
   61 |                  void ** overlap,
      |                  ~~~~~~~~^~~~~~~
In file included from pysharc_src/pysharc.c:338:
pysharc_src/pysharc_QMout.c:146:18: warning: passing argument 4 of 'setPointers' from incompatible pointer type [-Wincompatible-pointer-types]
  146 |                  (double **)G_ptr,
      |                  ^~~~~~~~~~~~~~~~
      |                  |
      |                  double **
In file included from include/libsharc.h:25,
                 from pysharc_src/pysharc.c:48:
include/interface.h:62:26: note: expected 'void **' but argument is of type 'double **'
   62 |                  void ** grad,
      |                  ~~~~~~~~^~~~
In file included from pysharc_src/pysharc.c:338:
pysharc_src/pysharc_QMout.c:147:18: warning: passing argument 5 of 'setPointers' from incompatible pointer type [-Wincompatible-pointer-types]
  147 |                  (double **)NACDR_ptr);
      |                  ^~~~~~~~~~~~~~~~~~~~
      |                  |
      |                  double **
In file included from include/libsharc.h:25,
                 from pysharc_src/pysharc.c:48:
include/interface.h:63:26: note: expected 'void **' but argument is of type 'double **'
   63 |                  void ** nacs
      |                  ~~~~~~~~^~~~
In file included from pysharc_src/pysharc.c:340:
pysharc_src/pysharc_QMin.c: In function 'QMin_new':
pysharc_src/pysharc_QMin.c:55:10: warning: assignment to 'QMin *' from incompatible pointer type 'QMout *' [-Wincompatible-pointer-types]
   55 |     self = (QMout *)type->tp_alloc(type, 0);
      |          ^
pysharc_src/pysharc_QMin.c: In function 'QMin_init':
pysharc_src/pysharc_QMin.c:77:22: warning: passing argument 1 of 'setQMinPointers' from incompatible pointer type [-Wincompatible-pointer-types]
   77 |     setQMinPointers( (double **)Crd_ptr );
      |                      ^~~~~~~~~~~~~~~~~~
      |                      |
      |                      double **
In file included from include/libsharc.h:25,
                 from pysharc_src/pysharc.c:48:
include/interface.h:65:30: note: expected 'void **' but argument is of type 'double **'
   65 | void setQMinPointers(void ** Crd);
      |                      ~~~~~~~~^~~
In file included from pysharc_src/pysharc.c:338:
pysharc_src/pysharc_QMout.c: In function 'QMout_set_nacdr':
pysharc_src/pysharc_QMout.c:512:9: warning: 'state_state_nac' may be used uninitialized in this function [-Wmaybe-uninitialized]
  512 |         free(state_state_nac);
      |         ^~~~~~~~~~~~~~~~~~~~~
pysharc_src/pysharc_QMout.c: In function 'QMout_set_gradient':
pysharc_src/pysharc_QMout.c:304:9: warning: 'state_gradient' may be used uninitialized in this function [-Wmaybe-uninitialized]
  304 |         free(state_gradient);
      |         ^~~~~~~~~~~~~~~~~~~~

I wonder if the warnings were the result of my incorrectly prepared environment or other mistakes and I would greatly appreciate any suggestions from you.

Best Regards,

lukhman9020 commented 1 year ago

Hello eqmao, I faced the same problem when a installed Sharc and I did not get the solution did you get the solution and if you get the solution could you help me, please.

with regards LUKHMAN

markusoppel commented 1 year ago

Hello,

you can safely ignore the warnings. And replacing rand() by random_number() is also ok. The latter is more up to the modern Fortran standard.

Regards, Markus