Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yantosca opened this issue Dec 19, 2024 · 2 comments · Fixed by #120
Open

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

yantosca opened this issue Dec 19, 2024 · 2 comments · Fixed by #120
Assignees
Labels
bug Something isn't working build Related to makefiles and/or compilation code / structural Related to structural source code updates
Milestone

Comments

@yantosca
Copy link
Contributor

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

@yantosca yantosca added bug Something isn't working build Related to makefiles and/or compilation code / structural Related to structural source code updates labels Dec 19, 2024
@yantosca yantosca added this to the 3.2.0 milestone Dec 19, 2024
@yantosca yantosca self-assigned this Dec 19, 2024
@yantosca
Copy link
Contributor Author

Note: the ultimate solution would be to create a separate inline for F90 use statements. I will work on this as time allows.

@RolfSander
Copy link
Contributor

I added more consistent comments for the inlined code into the new branch tmp/inline_comments. If you agree, it can be merged into dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working build Related to makefiles and/or compilation code / structural Related to structural source code updates
Projects
None yet
2 participants