Dear Expert,
I want to build a solver for the gas-solid problem, but the solver is not building, kindly check the bug report to see if it will be a solver.
Cpp_2024-01-06T160000.490444.zip (51.0 KB)
When you have issues building UDF code, click on First error
in the build popup and it will take you to the offending line.
In your case:
/tmp/lungu3_2024-01-06T160000.490444/fortron.f:5:34:
5 | real, dimension(NI, NH1) :: IW = {{-1.5582248, -2.46757, -2.5418835, -2.985875, -2.044306, -3.165086, 2.6962786, 1.570628, 1.9805754, -1.4589518, 2.0126028, -1.7743504, -2.7962937, -1.0229516, -1.4725527, 2.3409698},
| 1
Error: Expected an initialization expression at (1)
The (1)
is marking the exact spot where the error occurs (also note it is on line 5, colum 34).
real, dimension(NI, NH1) :: IW = {{-1.5582248, -2.46757, -2.5418835, -2.985875, -2.044306, -3.165086, 2.6962786, 1.570628, 1.9805754, -1.4589518, 2.0126028, -1.7743504, -2.7962937, -1.0229516, -1.4725527, 2.3409698},
{-0.13974571, 0.51182044, 0.41524053, -0.12704508, 0.24660031, 0.3688965, 2.9667315, -0.4228308, 0.56329006, -0.18212788, 0.3581895, -0.29713887, -0.4854258, -0.15655787, 0.32499683, 0.4348078},
{-0.23623218, -0.04252426, -0.01037833, 0.04741014, -0.17991374, 0.03735462, 3.6345057, -0.5878261, 0.01314784, -0.00473932, -0.00984425, -0.2056783, 0.04235772, 0.23454268, 0.22414905, -0.008082}
};
You can generally Google for the error messages, like "Expected an initialization expression’. In this case, the message is telling you that this is not the correct syntax for initializing an array in Fortran. See for example How to initialize two-dimensional arrays in Fortran - Stack Overflow I also suggest you get a good Fortran book such as Modern Fotran. You also need line continuation character (&
) for multiline statements. Also be sure to understand the difference between column-major (Fotran) and row-major (C) storage formats. Fortran - Reshape Functions
There are several ways to initialize a 2D array, one of them is with reshape
:
real, dimension(NH1,NI) :: IW = reshape ([-1.5582248, -2.46757, -2.5418835, -2.985875, -2.044306, -3.165086, 2.6962786, 1.570628, 1.9805754, -1.4589518, 2.0126028, -1.7743504, -2.7962937, -1.0229516, -1.4725527, 2.3409698, &
-0.13974571, 0.51182044, 0.41524053, -0.12704508, 0.24660031, 0.3688965, 2.9667315, -0.4228308, 0.56329006, -0.18212788, 0.3581895, -0.29713887, -0.4854258, -0.15655787, 0.32499683, 0.4348078, &
-0.23623218, -0.04252426, -0.01037833, 0.04741014, -0.17991374, 0.03735462, 3.6345057, -0.5878261, 0.01314784, -0.00473932, -0.00984425, -0.2056783, 0.04235772, 0.23454268, 0.22414905, -0.008082], &
[NH1,NI]);
This takes care of the first error, the rest are up to you!
Thank you for the help, I reduced my code but still errors, could you change
lungu3_2024-01-12T194105.228778.zip (49.6 KB)
it.
I cannot continue to debug your Fortran code for you. You need to learn how to read and interpret the error messages from the compiler. Just start with the first error and try to fix that.
The first error is:
143 | real, dimension(NI, NH1) :: IW
| 1
Error: Explicit array shape at (1) must be constant of INTEGER type and not UNKNOWN type
The array shape is (NI, NH1)
. But these are both undefined here, because you moved their definitions down into module neuralnetworkmodule
.
Thanks for the information, please send user-defined function manual for Mfix like Fluent.
It will be very helpful for the user so that they can easily understand all these uselfu tool for creating UDF in Mfix.