Error: for loop initial declarations are only allowed in C99 mode

hello everyone,
I was building the dmp solver in the centos7 os(vmware workstation) ,and the error came up with:
/home/sc/anaconda3/envs/mfix-22.1/lib/python3.10/site-packages/numpy/f2py/src/fortranobject.c:707:5: error: for loop initial declarations are only allowed in C99 mode
for (int i = 0; i < rank; ++i) {
^
mfix-version 22.1
case:cyclone_flush_bc_3d


Can you tell me what version of mpifort you are using?

@songchao1 what version of mpifort?

sorry cgw,i am not familar with the centos7, and, i tried to find the mpi-version is 1.10.7

image

It looks like you are using a pretty old compiler. What does

mpifort --version

say? Mine says

$  mpifort --version
GNU Fortran (Gentoo 11.2.1_p20220115 p4) 11.2.1 20220115

If you can upgrade the compiler, this would be good. Note that the error message is complaining about code that follows the c99 standard. This is enabled by default for more recent compilers, but you are using some compiler for which c99 is not automatically enabled. If you can’t upgrade the compiler, you can work around the problem by using custom build type and adding -std=c99 to the compiler flags, like this:

shot-2022-07-15_09-54-37

This will cause some warnings since the -std=c99 flag is only valid for C, not Fortran, but these are non-fatal warnings and the compilation should succeed.

I’ll add a proper fix for this in the upcoming 22.2 release. But upgrade your compiler if you can - your jobs will run faster with the newer compilers, which produce better code.

– Charles

ok ,i will try it. thanks a lot!! :grinning: :grinning: