Chemical reaction rates error (usr_rates and usr_rates_des)

Hi everyone,

This is my former question (Can’t open included file ‘usrnlst.inc’ when building solver). However, I meet new errors about the defination for chemical reaction rates. I have read 4.13.3. Reaction Examples in MFiX User Manual but still having the following errors. I am not sure how to solve these problems.

Biomass_13.mfx (21.3 KB)
usr_rates.f (2.3 KB)
usr_rates_des.f (3.3 KB)

species.inc:11:32:

   INTEGER, PARAMETER :: Char = 2
                            1

Error: Cannot change attributes of USE-associated symbol at (1)
CMakeFiles\udfs.dir\build.make:78: recipe for target ‘CMakeFiles/udfs.dir/D_/7_Simulation_cases/Biomass_13/usr_rates.f.obj’ failed
mingw32-make.exe[2]: *** [CMakeFiles/udfs.dir/D_/7_Simulation_cases/Biomass_13/usr_rates.f.obj] Error 1
mingw32-make.exe[2]: *** Waiting for unfinished jobs…
species.inc:11:32:

   INTEGER, PARAMETER :: Char = 2
                            1

Error: Cannot change attributes of USE-associated symbol at (1)
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:80:44:

   ReactantMassFraction = DES_X_s(NP,CHAR)
                                        1

Error: Function ‘char’ requires an argument list at (1)
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:62:25:

      DES_RATES(Drying) = 5.13d6*exp(-8.79d7/(8314.d0*Tp))*MW_s(1,MOISTURE)
                     1

Error: Symbol ‘drying’ at (1) has no IMPLICIT type
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:53:33:

   Tp = min(MAX_TEMP, DES_T_S(NP))
                             1

Warning: Legacy Extension: REAL array index at (1)
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:54:29:

   Tg = min(MAX_TEMP, T_g(IJK))
                         1

Warning: Legacy Extension: REAL array index at (1)
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:60:38:

   ReactantMassFraction  = DES_X_s(NP,MOISTURE)
                                  1

Warning: Legacy Extension: REAL array index at (1)
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:71:37:

   ReactantMassFraction = DES_X_s(NP,VOLATILE)
                                 1

Warning: Legacy Extension: REAL array index at (1)
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:77:41:

   IF(nRR >= Pyrolysis) ReactionRates(IJK,Pyrolysis) = RATES(Pyrolysis)
                                     1

Warning: Legacy Extension: REAL array index at (1)
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:77:58:

   IF(nRR >= Pyrolysis) ReactionRates(IJK,Pyrolysis) = RATES(Pyrolysis)
                                                      1

Error: Function ‘rates’ at (1) has no IMPLICIT type
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:81:61:

   IF((ReactantMassFraction .GT. residuleMass) .AND. (X_g(IJK, CO2) .NE. 0)) THEN
                                                         1

Warning: Legacy Extension: REAL array index at (1)
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:84:38:

      pco2 = P_g*MW_MIX_g(IJK)*X_g(IJK, CO2)/MW_g(CO2)
                                  1

Warning: Legacy Extension: REAL array index at (1)
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:84:29:

      pco2 = P_g*MW_MIX_g(IJK)*X_g(IJK, CO2)/MW_g(CO2)
                         1

Warning: Legacy Extension: REAL array index at (1)
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:84:9:

      pco2 = P_g*MW_MIX_g(IJK)*X_g(IJK, CO2)/MW_g(CO2)
     1

Error: Incompatible ranks 0 and 1 in assignment at (1)
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:89:34:

   IF(nRR >= R1) ReactionRates(IJK,R1) = RATES(R1)
                              1

Warning: Legacy Extension: REAL array index at (1)
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:89:44:

   IF(nRR >= R1) ReactionRates(IJK,R1) = RATES(R1)
                                        1

Error: Function ‘rates’ at (1) has no IMPLICIT type
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:91:61:

   IF((ReactantMassFraction .GT. residuleMass) .AND. (X_g(IJK, H2O) .NE. 0)) THEN
                                                         1

Warning: Legacy Extension: REAL array index at (1)
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:94:38:

      ph2o = P_g*MW_MIX_g(IJK)*X_g(IJK, H2O)/MW_g(H2O)
                                  1

Warning: Legacy Extension: REAL array index at (1)
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:94:29:

      ph2o = P_g*MW_MIX_g(IJK)*X_g(IJK, H2O)/MW_g(H2O)
                         1

Warning: Legacy Extension: REAL array index at (1)
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:94:9:

      ph2o = P_g*MW_MIX_g(IJK)*X_g(IJK, H2O)/MW_g(H2O)
     1

Error: Incompatible ranks 0 and 1 in assignment at (1)
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:99:34:

   IF(nRR >= R2) ReactionRates(IJK,R2) = RATES(R2)
                              1

Warning: Legacy Extension: REAL array index at (1)
D:\7_Simulation_cases\Biomass_13\usr_rates_des.f:99:44:

   IF(nRR >= R2) ReactionRates(IJK,R2) = RATES(R2)
                                        1

Error: Function ‘rates’ at (1) has no IMPLICIT type
mingw32-make.exe[2]: *** [CMakeFiles/udfs.dir/D_/7_Simulation_cases/Biomass_13/usr_rates_des.f.obj] Error 1
CMakeFiles\udfs.dir\build.make:92: recipe for target ‘CMakeFiles/udfs.dir/D_/7_Simulation_cases/Biomass_13/usr_rates_des.f.obj’ failed
CMakeFiles\Makefile2:101: recipe for target ‘CMakeFiles/udfs.dir/all’ failed
Makefile:134: recipe for target ‘all’ failed

                 BUILD FAILED

==========================================================================
mingw32-make.exe[1]: *** [CMakeFiles/udfs.dir/all] Error 2
mingw32-make.exe: *** [all] Error 2

We have a few problems here:

  1. Issues related to the symbol ‘CHAR’ - this causes the first 3 error messages

Note that CHAR is a built-in function in Fortran77:

It looks like the version of GFortran that we use on Windows (5.3.0) does not let you redefine this symbol. When I attempt to build your code on Linux, using GFortran 11, I do not get the errors with CHAR. Unfortunately there is not a newer version of GFortran that is readily available for Windows. The easiest thing to do is probably to rename this species to something else.

  1. You have a typo “drying” (in your .f file) vs “dring” (in the .mfx) - again, GFortran 11 prints a slighly more helpful message than 5.3.0
   62 |          DES_RATES(Drying) = 5.13d6*exp(-8.79d7/(8314.d0*Tp))*MW_s(1,MOISTURE)
      |                         1
Error: Symbol drying at (1) has no IMPLICIT type; did you mean dring?
  1. Array indices declared as DOUBLE PRECISION when they should be INTEGER.
       Tp = min(MAX_TEMP, DES_T_S(NP))
                                  1
Warning: Legacy Extension: REAL array index at (1)

Note this is pointing at NP to tell you there is a problem with it and, indeed in your usr_rates_des.f you have:

      DOUBLE PRECISION, INTENT(IN) :: NP  ! Global index of particle
      DOUBLE PRECISION, INTENT(IN) :: pM  ! Solid phase index of particle NP
      DOUBLE PRECISION, INTENT(IN) :: IJK ! Fluid cell index containing NP

those should all be INTEGER since they are array indices (as the compiler is telling you).

– Charles

Thank you @cgw . I have successfully revised errors in the usr_rates_des.f file and there are some other mistakes in my original usr_rates_des.f file. I also have corrected them according to the prompt. This case seems to run well without SMP; however, the solver stop running just at the beginning of the calculation within the first time step after been built in parallel. How to solve this problem? Thanks.

Biomass_13.mfx (21.7 KB)
usr_rates.f (2.3 KB)
usr_rates_des.f (3.3 KB)

It is recommended to build the solver in debug mode first when writing udf. This will catch most obvious mistakes. Here there is a segfault when initializing DES_RATES because it is not declared properly. Please add the size of the array on line 31 of usr_rates_des.f:

DOUBLE PRECISION, INTENT(OUT) :: DES_RATES(NO_OF_DES_RXNS)  
1 Like

Much thanks @jeff.dietiker