Skip to content

Commit

Permalink
Adjust interpv templates for vscode compatibility
Browse files Browse the repository at this point in the history
The mock-template code that uses the C preprocessor to
define multiple versions of Interp/Extrap functions is
incompatible with Fortran linting, crashing the linter
(see fortran-lang/fortls#236)
because it tries to process the Fortran syntax without
invoking the preprocessor.

This code adjusts the templates to hold just the subroutine
body, leaving the `end subroutine` statement for the
enclosing Fortran file.  This change fixes the linter crash,
although it still doesn't properly understand the
subroutines.
  • Loading branch information
Christopher Subich authored and chantal-pic committed Dec 5, 2023
1 parent 616633f commit 71e7810
Show file tree
Hide file tree
Showing 21 changed files with 521 additions and 103 deletions.
50 changes: 50 additions & 0 deletions src/interpv/Extrap1D_Abort.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,81 @@

!version that accepts real(single) arguments, with the extended interface
subroutine Extrap1D_Abort_X &
(numInterpSets, srcNumLevels, destNumLevels, &
src_ijDim, dst_ijDim, &

vLevelSource, stateSource, stateDerivSource, &

posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &

extrapEnableDown, extrapEnableUp, &
extrapGuideDown, extrapGuideUp, &

flux, numExtArraysIn, numExtArraysOut, &
ExtArraysIn, ExtArraysOut &
)
#define real48 single
#include "Extrap1D_Abort_Body.inc"
#undef real48
end subroutine

!version that accepts real(double) arguments, with the extended interface
subroutine Extrap1D_Abort_X8 &
(numInterpSets, srcNumLevels, destNumLevels, &
src_ijDim, dst_ijDim, &

vLevelSource, stateSource, stateDerivSource, &

posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &

extrapEnableDown, extrapEnableUp, &
extrapGuideDown, extrapGuideUp, &

flux, numExtArraysIn, numExtArraysOut, &
ExtArraysIn, ExtArraysOut &
)
#define real48 double
#include "Extrap1D_Abort_Body.inc"
#undef real48
end subroutine




!version that accepts real(single) arguments
subroutine Extrap1D_Abort &
(numInterpSets, srcNumLevels, destNumLevels, &
src_ijDim, dst_ijDim, &

vLevelSource, stateSource, stateDerivSource, &

posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &

extrapEnableDown, extrapEnableUp, &
extrapGuideDown, extrapGuideUp &
)
#define real48 single
#define DestnFunc Extrap1D_Abort_X
#include "Interp1D_PreX_Shell.inc"
#undef DestnFunc
#undef real48
end subroutine

!version that accepts real(double) arguments
subroutine Extrap1D_Abort8 &
(numInterpSets, srcNumLevels, destNumLevels, &
src_ijDim, dst_ijDim, &

vLevelSource, stateSource, stateDerivSource, &

posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &

extrapEnableDown, extrapEnableUp, &
extrapGuideDown, extrapGuideUp &
)
#define real48 double
#define DestnFunc Extrap1D_Abort_X8
#include "Interp1D_PreX_Shell.inc"
#undef DestnFunc
#undef real48
end subroutine
20 changes: 10 additions & 10 deletions src/interpv/Extrap1D_Abort_Body.inc
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
!!!s/r Extrap1D_Abort - Abort if an extrapolation is required
!subroutine Extrap1D_Abort_X &
!subroutine Extrap1D_Abort_X8 &
(numInterpSets, srcNumLevels, destNumLevels, &
src_ijDim, dst_ijDim, &
! (numInterpSets, srcNumLevels, destNumLevels, &
! src_ijDim, dst_ijDim, &

vLevelSource, stateSource, stateDerivSource, &
! vLevelSource, stateSource, stateDerivSource, &

posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &
! posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &

extrapEnableDown, extrapEnableUp, &
extrapGuideDown, extrapGuideUp, &
! extrapEnableDown, extrapEnableUp, &
! extrapGuideDown, extrapGuideUp, &

flux, numExtArraysIn, numExtArraysOut, &
ExtArraysIn, ExtArraysOut &
)
! flux, numExtArraysIn, numExtArraysOut, &
! ExtArraysIn, ExtArraysOut &
! )
! These are dummy arguments for this function: stateDerivSource,
! stateDerivDestn, flux, numExtArraysIn, numExtArraysOut, ExtArraysIn,
! ExtArraysOut
Expand Down Expand Up @@ -93,4 +93,4 @@
!$OMP END parallel do


end subroutine ! Extrap1D_Abort_X
! end subroutine ! Extrap1D_Abort_X
50 changes: 50 additions & 0 deletions src/interpv/Extrap1D_Fixed.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,81 @@

!version that accepts real(single) arguments, with the extended interface
subroutine Extrap1D_Fixed_X &
(numInterpSets, srcNumLevels, destNumLevels, &
src_ijDim, dst_ijDim, &

vLevelSource, stateSource, stateDerivSource, &

posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &

extrapEnableDown, extrapEnableUp, &
extrapGuideDown, extrapGuideUp, &

flux, numExtArraysIn, numExtArraysOut, &
ExtArraysIn, ExtArraysOut &
)
#define real48 single
#include "Extrap1D_Fixed_Body.inc"
#undef real48
end subroutine

!version that accepts real(double) arguments, with the extended interface
subroutine Extrap1D_Fixed_X8 &
(numInterpSets, srcNumLevels, destNumLevels, &
src_ijDim, dst_ijDim, &

vLevelSource, stateSource, stateDerivSource, &

posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &

extrapEnableDown, extrapEnableUp, &
extrapGuideDown, extrapGuideUp, &

flux, numExtArraysIn, numExtArraysOut, &
ExtArraysIn, ExtArraysOut &
)
#define real48 double
#include "Extrap1D_Fixed_Body.inc"
#undef real48
end subroutine




!version that accepts real(single) arguments
subroutine Extrap1D_Fixed &
(numInterpSets, srcNumLevels, destNumLevels, &
src_ijDim, dst_ijDim, &

vLevelSource, stateSource, stateDerivSource, &

posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &

extrapEnableDown, extrapEnableUp, &
extrapGuideDown, extrapGuideUp &
)
#define real48 single
#define DestnFunc Extrap1D_Fixed_X
#include "Interp1D_PreX_Shell.inc"
#undef DestnFunc
#undef real48
end subroutine

!version that accepts real(double) arguments
subroutine Extrap1D_Fixed8 &
(numInterpSets, srcNumLevels, destNumLevels, &
src_ijDim, dst_ijDim, &

vLevelSource, stateSource, stateDerivSource, &

posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &

extrapEnableDown, extrapEnableUp, &
extrapGuideDown, extrapGuideUp &
)
#define real48 double
#define DestnFunc Extrap1D_Fixed_X8
#include "Interp1D_PreX_Shell.inc"
#undef DestnFunc
#undef real48
end subroutine
20 changes: 10 additions & 10 deletions src/interpv/Extrap1D_Fixed_Body.inc
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
!!!s/r Extrap1D_Fixed - Extrapolate, to a fixed (selectable) value
!subroutine Extrap1D_Fixed_X &
!subroutine Extrap1D_Fixed_X8 &
(numInterpSets, srcNumLevels, destNumLevels, &
src_ijDim, dst_ijDim, &
! (numInterpSets, srcNumLevels, destNumLevels, &
! src_ijDim, dst_ijDim, &

vLevelSource, stateSource, stateDerivSource, &
! vLevelSource, stateSource, stateDerivSource, &

posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &
! posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &

extrapEnableDown, extrapEnableUp, &
extrapGuideDown, extrapGuideUp, &
! extrapEnableDown, extrapEnableUp, &
! extrapGuideDown, extrapGuideUp, &

flux, numExtArraysIn, numExtArraysOut, &
ExtArraysIn, ExtArraysOut &
)
! flux, numExtArraysIn, numExtArraysOut, &
! ExtArraysIn, ExtArraysOut &
! )
! These are dummy arguments for this function: stateDerivSource,
! stateDerivDestn, flux, numExtArraysIn, numExtArraysOut, ExtArraysIn,
! ExtArraysOut
Expand Down Expand Up @@ -100,4 +100,4 @@
!$OMP END parallel do


end subroutine ! Extrap1D_Fixed_X
! end subroutine ! Extrap1D_Fixed_X
50 changes: 50 additions & 0 deletions src/interpv/Extrap1D_LapseRate.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,81 @@

!version that accepts real(single) arguments, with the extended interface
subroutine Extrap1D_LapseRate_X &
(numInterpSets, srcNumLevels, destNumLevels, &
src_ijDim, dst_ijDim, &

vLevelSource, stateSource, stateDerivSource, &

posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &

extrapEnableDown, extrapEnableUp, &
extrapGuideDown, extrapGuideUp, &

flux, numExtArraysIn, numExtArraysOut, &
ExtArraysIn, ExtArraysOut &
)
#define real48 single
#include "Extrap1D_LapseRate_Body.inc"
#undef real48
end subroutine

!version that accepts real(double) arguments, with the extended interface
subroutine Extrap1D_LapseRate_X8 &
(numInterpSets, srcNumLevels, destNumLevels, &
src_ijDim, dst_ijDim, &

vLevelSource, stateSource, stateDerivSource, &

posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &

extrapEnableDown, extrapEnableUp, &
extrapGuideDown, extrapGuideUp, &

flux, numExtArraysIn, numExtArraysOut, &
ExtArraysIn, ExtArraysOut &
)
#define real48 double
#include "Extrap1D_LapseRate_Body.inc"
#undef real48
end subroutine




!version that accepts real(single) arguments
subroutine Extrap1D_LapseRate &
(numInterpSets, srcNumLevels, destNumLevels, &
src_ijDim, dst_ijDim, &

vLevelSource, stateSource, stateDerivSource, &

posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &

extrapEnableDown, extrapEnableUp, &
extrapGuideDown, extrapGuideUp &
)
#define real48 single
#define DestnFunc Extrap1D_LapseRate_X
#include "Interp1D_PreX_Shell.inc"
#undef DestnFunc
#undef real48
end subroutine

!version that accepts real(double) arguments
subroutine Extrap1D_LapseRate8 &
(numInterpSets, srcNumLevels, destNumLevels, &
src_ijDim, dst_ijDim, &

vLevelSource, stateSource, stateDerivSource, &

posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &

extrapEnableDown, extrapEnableUp, &
extrapGuideDown, extrapGuideUp &
)
#define real48 double
#define DestnFunc Extrap1D_LapseRate_X8
#include "Interp1D_PreX_Shell.inc"
#undef DestnFunc
#undef real48
end subroutine
20 changes: 10 additions & 10 deletions src/interpv/Extrap1D_LapseRate_Body.inc
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
!!!s/r Extrap1D_LapseRate - Extrapolate, based on lapse rates
!subroutine Extrap1D_LapseRate_X &
!subroutine Extrap1D_LapseRate_X8 &
(numInterpSets, srcNumLevels, destNumLevels, &
src_ijDim, dst_ijDim, &
! (numInterpSets, srcNumLevels, destNumLevels, &
! src_ijDim, dst_ijDim, &

vLevelSource, stateSource, stateDerivSource, &
! vLevelSource, stateSource, stateDerivSource, &

posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &
! posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &

extrapEnableDown, extrapEnableUp, &
extrapGuideDown, extrapGuideUp, &
! extrapEnableDown, extrapEnableUp, &
! extrapGuideDown, extrapGuideUp, &

flux, numExtArraysIn, numExtArraysOut, &
ExtArraysIn, ExtArraysOut &
)
! flux, numExtArraysIn, numExtArraysOut, &
! ExtArraysIn, ExtArraysOut &
! )
! These are dummy arguments for this function: stateDerivSource,
! stateDerivDestn, flux, numExtArraysIn, numExtArraysOut, ExtArraysIn,
! ExtArraysOut
Expand Down Expand Up @@ -118,4 +118,4 @@
!$OMP END parallel do
end subroutine ! Extrap1D_LapseRate_X
! end subroutine ! Extrap1D_LapseRate_X
28 changes: 28 additions & 0 deletions src/interpv/Extrap1D_Surface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,40 @@

!version that accepts real(single) arguments, with the extended interface
subroutine Extrap1D_Surface_X &
(numInterpSets, srcNumLevels, destNumLevels, &
src_ijDim, dst_ijDim, &

vLevelSource, stateSource, stateDerivSource, &

posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &

extrapEnableDown, extrapEnableUp, &
extrapGuideDown, extrapGuideUp, &

flux, numExtArraysIn, numExtArraysOut, &
ExtArraysIn, ExtArraysOut &
)
#define real48 single
#include "Extrap1D_Surface_Body.inc"
#undef real48
end subroutine

!version that accepts real(double) arguments, with the extended interface
subroutine Extrap1D_Surface_X8 &
(numInterpSets, srcNumLevels, destNumLevels, &
src_ijDim, dst_ijDim, &

vLevelSource, stateSource, stateDerivSource, &

posnDestInSrc, vLevelDestn, stateDestn, stateDerivDestn, &

extrapEnableDown, extrapEnableUp, &
extrapGuideDown, extrapGuideUp, &

flux, numExtArraysIn, numExtArraysOut, &
ExtArraysIn, ExtArraysOut &
)
#define real48 double
#include "Extrap1D_Surface_Body.inc"
#undef real48
end subroutine
Loading

0 comments on commit 71e7810

Please sign in to comment.