Skip to content

[BUG/ISSUE] Wrong placement of YIN argument in subroutine Update_Rconst #119

@yantosca

Description

@yantosca

In the dev branch, when we create the *Rates.F90 file, the YIN argument definition statements in routine Update_Rconst are placed before the INLINED_RCONST statement. If a USE statement is included in the INLINED_RCONST section, then this will generate code such as this:

SUBROUTINE Update_RCONST ( YIN )

! YIN - Optional input concentrations of variable species
  REAL(kind=dp), OPTIONAL :: YIN(NVAR)

! Y - Concentrations of species (local)
  REAL(kind=dp) :: Y(NSPEC)

! Ensure local Y array is filled with variable and constant concentrations
  Y(1:NSPEC) = C(1:NSPEC)

! Update local Y array if variable concentrations are provided
  if (present(YIN)) Y(1:NVAR) = YIN(1:NVAR)


! Begin INLINED RCONST


  ! Inline an include file containing rate law definitions, which
  ! will be inserted directly into subroutine Update_Rconst().
  ! This is necessary as a workaround for KPP not being able to
  ! include very large files ( > 200000 chars) directly.
  !  -- Bob Yantosca (11 Jun 2021)
  USE fullchem_RateLawFuncs

! End INLINED RCONST

This will generate an error such as:

gfortran -cpp -O   -c gckpp_Precision.F90
gfortran -cpp -O   -c gckpp_Parameters.F90
gfortran -cpp -O   -c gckpp_Global.F90
gfortran -cpp -O   -c gckpp_JacobianSP.F90
gfortran -cpp -O   -c gckpp_Jacobian.F90
gfortran -cpp -O   -c gckpp_Function.F90
gfortran -cpp -O   -c rateLawUtilFuncs.F90
gfortran -cpp -O   -c fullchem_RateLawFuncs.F90
gfortran -cpp -O   -c gckpp_Rates.F90
gckpp_Rates.F90:439:27:

  439 |   USE fullchem_RateLawFuncs
      |                           1
Error: Unexpected USE statement at (1)
make: *** [Makefile:163: gckpp_Rates.o] Error 1
Failed to build the 'kpp_executable.exe' file!  Aborting...

This is because the USE statement must come before any variable declarations or executable statements.

The fix is simple, to place the INLINED_RCONST section first before adding the YIN variable declarations. I can push a fix.

Currently this only affects code in the dev branch but not in main.

Tagging @jimmielin @RolfSander

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingbuildRelated to makefiles and/or compilationcode / structuralRelated to structural source code updates

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions