diff --git a/source/Lazarus-GUI/UEELSBoson.pas b/source/Lazarus-GUI/UEELSBoson.pas
index 7d5b64da2339f2ef937d9e47c2ea31414685cfd4..234ef3003419f4fabe37e14a13dfe25f7c029c75 100644
--- a/source/Lazarus-GUI/UEELSBoson.pas
+++ b/source/Lazarus-GUI/UEELSBoson.pas
@@ -12,6 +12,7 @@ type
 // Fortran equivalents
   Finteger = int32;
   Fdouble  = double;
+  Flogical  = boolean;
   Fosc_array = array[1..3] of Fdouble;
 
 var
@@ -40,6 +41,7 @@ var
   Control: string;
   Mode:    string;
   Wn_Array: array of Fdouble;
+  Debug: Flogical;
   F_Array:  array of Fdouble;
 // for Boson
   TargetTemperature: Fdouble;
@@ -71,6 +73,7 @@ procedure doeels(var e0: Fdouble;
                  var contrl: string;
                  var mode:   string;
                  var wn_array: array of Fdouble;
+                 var debug: Flogical;
                  var f_array:  array of Fdouble;
                  var size_wn_array: Finteger);
   cdecl; external name 'doeels_';
diff --git a/source/Lazarus-GUI/UMainForm.pas b/source/Lazarus-GUI/UMainForm.pas
index 7cb8873edd117680f5830b3c5ea57d33cf5d381e..827972cd6afea7a526f1893ca66991d8411acb79 100644
--- a/source/Lazarus-GUI/UMainForm.pas
+++ b/source/Lazarus-GUI/UMainForm.pas
@@ -599,7 +599,7 @@ begin
          IntervalWMin, IntervalWMax, IntervalWDelta, Comment1, Comment1_length,
          NumberOfLayers, NumberOfEpsilons, NumberOfPeriodic, LayerName, LayerName_length,
          Thickness, Epsilon, NumberOfOscillators, Oscillator, Oscillator_length,
-         Control, Mode, Wn_Array, F_Array, IntervalNW);
+         Control, Mode, Wn_Array, Debug, F_Array, IntervalNW);
 
   doboson(TargetTemperature, InstrumentalWidth, GaussianFraction, Asymmetry, EMin, EMax,
           IntervalWMin, IntervalWMax, IntervalNW, F_Array, xout, yout, nout);
@@ -653,6 +653,7 @@ begin
   IntervalNW := 1 + round((IntervalWMax - IntervalWMin) / IntervalWDelta);
   setlength(Wn_Array, IntervalNW);
   setlength(F_Array, IntervalNW);
+  Debug := false;
   Control := ' ';
   Mode := ' ';
 
diff --git a/source/f90/INSTALL b/source/f90/INSTALL
index 627fc19559282f4271795e775d40e4b2cac9b277..6f9f3fd23d29fd49932ebcfc61b551bcc29928ba 100644
--- a/source/f90/INSTALL
+++ b/source/f90/INSTALL
@@ -26,7 +26,7 @@ Example:
 
 >>> import doeels
 >>> print(doeels.doeels.__doc__)
-doeels(e0,theta,phia,phib,wmin,wmax,dw,comment,layers,neps,nper,name,thick,epsinf,nos,osc,contrl,mode,wn_array,f_array,[comment_size,name_size,osc_size,wn_array_size])
+doeels(e0,theta,phia,phib,wmin,wmax,dw,comment,layers,neps,nper,name,thick,epsinf,nos,osc,contrl,mode,wn_array,debug,f_array,[comment_size,name_size,osc_size,wn_array_size])
 
 Wrapper for ``doeels``.
 
diff --git a/source/f90/doeels.f90 b/source/f90/doeels.f90
index 533d1bd197ec62bfe7291ffe00e0ae33282a8d53..40f39fbba59deac03e751bfa7514a68897e15831 100644
--- a/source/f90/doeels.f90
+++ b/source/f90/doeels.f90
@@ -2,7 +2,7 @@ module mod_doeels
 contains
 subroutine doeels (e0, theta, phia, phib, wmin, wmax, dw, comment, comment_size,   &
               layers, neps, nper, name, name_size, thick, epsinf, nos, osc, osc_size,&
-              contrl, mode, wn_array, f_array, wn_array_size)
+              contrl, mode, wn_array, debug, f_array, wn_array_size)
 
 ! ******************************************************************
 ! *                                                                *
@@ -29,6 +29,7 @@ subroutine doeels (e0, theta, phia, phib, wmin, wmax, dw, comment, comment_size,
 ! * contrl:         'image' for image-charge screening             *
 ! * mode:           'kurosawa' for kurosawa model                  *
 ! * wn_array:       frequencies                                    *
+! * debug:          logical                                        *
 ! * f_array:        spectrum                                       *
 ! * wn_array_size:  number of frequencies                          *
 ! *                                                                *
@@ -50,8 +51,9 @@ subroutine doeels (e0, theta, phia, phib, wmin, wmax, dw, comment, comment_size,
   integer, intent(in) :: comment_size, name_size, osc_size, wn_array_size
   integer, intent(in out) :: layers, nper, nos(name_size)
   double precision, intent(in out) :: wn_array(wn_array_size), f_array(wn_array_size)
+  logical, intent(in), optional :: debug
 
-  logical :: rational, user, debug
+  logical :: rational, user
   integer :: i, iw, neps, nofu, nout, nw, lmax
   double precision :: a, acoef, aerr, alpha, argmin, argmax, b, bcoef, beta,  &
       c1, c2, ccoef, cospsi, dlimf, dx, elleps, ener, epsmac, facru, f, f0,   &
@@ -68,7 +70,6 @@ subroutine doeels (e0, theta, phia, phib, wmin, wmax, dw, comment, comment_size,
 
   data aerr / 0.0d0 /, rerr / 1.0d-06 /, f / 0.0d0 /, f1 / 0.0d0 /
 
-  debug = .false.
   if (debug) then
     write (*,*) 'doeels:'
     write (*,*) 'comment: ',  size(comment)
diff --git a/source/f90/eels-boson.f90 b/source/f90/eels-boson.f90
index 2da9ecd928b6850ab8eabe68bb6aec850ebf570e..3c5363abf55e47f04ea15d2a48a15a10a3d8a136 100644
--- a/source/f90/eels-boson.f90
+++ b/source/f90/eels-boson.f90
@@ -145,9 +145,10 @@ program eels_boson
   nw = 1 + int((wmax - wmin) / dw)
   allocate (wn_array(nw), f(nw))
 
+  debug = .false.
   call doeels(e0, theta, phia, phib, wmin, wmax, dw, comment, size(comment),   &
               layers, neps, nper, name, size(name), thick, epsinf, nos, osc, size(osc, 2),&
-              contrl, mode, wn_array, f, size(wn_array))
+              contrl, mode, wn_array, debug, f, size(wn_array))
 
   open(unit = 13, file = bosin_name)
 ! target temperature (Kelvin)
diff --git a/source/f90/eels.f90 b/source/f90/eels.f90
index ae4558041afc0ae827f85c8b8b02667b42dd56bf..85c9105a49514e4f42251b57b4ebd7086283fffc 100644
--- a/source/f90/eels.f90
+++ b/source/f90/eels.f90
@@ -23,6 +23,7 @@ program eels
 
   integer :: old_size_1, old_size_2
   double precision, allocatable :: tmp_osc(:, :)
+  logical :: debug
   integer :: ioStatus
 
 !  integer, parameter :: name_length = 10
@@ -129,9 +130,10 @@ program eels
   nw = 1 + int((wmax - wmin) / dw)
   allocate (wn_array(nw), f(nw))
 
+  debug = .false.
   call doeels(e0, theta, phia, phib, wmin, wmax, dw, comment, size(comment),   &
               layers, neps, nper, name, size(name), thick, epsinf, nos, osc, size(osc, 2),&
-              contrl, mode, wn_array, f, size(wn_array))
+              contrl, mode, wn_array, debug, f, size(wn_array))
 
   open (unit = 12, file = 'eelsou')
   write (12, 207) e0, theta, phia, phib
diff --git a/source/f90/fcat-analysis/eels_all.f90 b/source/f90/fcat-analysis/eels_all.f90
index 99598ed4e5903c15fe19a22420a531a6fa0e1ffe..93742552ea45f68b7077610c31151adf3bf919b5 100644
--- a/source/f90/fcat-analysis/eels_all.f90
+++ b/source/f90/fcat-analysis/eels_all.f90
@@ -23,6 +23,7 @@ program eels
 
   integer :: old_size_1, old_size_2
   double precision, allocatable :: tmp_osc(:, :)
+  logical :: debug
   integer :: ioStatus
 
 !  integer, parameter :: name_length = 10
@@ -129,9 +130,10 @@ program eels
   nw = 1 + int((wmax - wmin) / dw)
   allocate (wn_array(nw), f(nw))
 
+  debug = .false.
   call doeels(e0, theta, phia, phib, wmin, wmax, dw, comment, size(comment),   &
               layers, neps, nper, name, size(name), thick, epsinf, nos, osc, size(osc, 2),&
-              contrl, mode, wn_array, f, size(wn_array))
+              contrl, mode, wn_array, debug, f, size(wn_array))
 
   open (unit = 12, file = 'eelsou')
   write (12, 207) e0, theta, phia, phib, comment(1)
@@ -1082,7 +1084,7 @@ end subroutine seteps
 
 subroutine doeels (e0, theta, phia, phib, wmin, wmax, dw, comment, comment_size,   &
               layers, neps, nper, name, name_size, thick, epsinf, nos, osc, osc_size,&
-              contrl, mode, wn_array, f_array, wn_array_size)
+              contrl, mode, wn_array, debug, f_array, wn_array_size)
 
 ! ******************************************************************
 ! *                                                                *
@@ -1104,8 +1106,9 @@ subroutine doeels (e0, theta, phia, phib, wmin, wmax, dw, comment, comment_size,
   integer, intent(in) :: comment_size, name_size, osc_size, wn_array_size
   integer, intent(in out) :: layers, nper, nos(name_size)
   double precision, intent(in out) :: wn_array(wn_array_size), f_array(wn_array_size)
+  logical, intent(in), optional :: debug
 
-  logical :: rational, user, debug
+  logical :: rational, user
   integer :: i, iw, neps, nofu, nout, nw, lmax
   double precision :: a, acoef, aerr, alpha, argmin, argmax, b, bcoef, beta,  &
       c1, c2, ccoef, cospsi, dlimf, dx, elleps, ener, epsmac, facru, f, f0,   &
@@ -1163,7 +1166,6 @@ subroutine doeels (e0, theta, phia, phib, wmin, wmax, dw, comment, comment_size,
 
   data aerr / 0.0d0 /, rerr / 1.0d-06 /, f / 0.0d0 /, f1 / 0.0d0 /
 
-  debug = .false.
   if (debug) then
     write (*,*) 'doeels:'
     write (*,*) 'comment: ',  size(comment)
diff --git a/source/f90/fcat-analysis/eels_all.f90.fcat-analysis.f90 b/source/f90/fcat-analysis/eels_all.f90.fcat-analysis.f90
index a276938de19adfa09fd96028a42946fd85abc723..4fde64909a708ab4d9dbb823861018f38788b75d 100644
--- a/source/f90/fcat-analysis/eels_all.f90.fcat-analysis.f90
+++ b/source/f90/fcat-analysis/eels_all.f90.fcat-analysis.f90
@@ -23,6 +23,7 @@ program eels
 
   integer :: old_size_1, old_size_2
   double precision, allocatable :: tmp_osc(:, :)
+  logical :: debug
   integer :: ioStatus
 
 !  integer, parameter :: name_length = 10
@@ -129,6 +130,7 @@ program eels
 1   nw = 1 + int((wmax - wmin) / dw)
 1   allocate (wn_array(nw), f(nw))
 
+1   debug = .false.
 1   call doeels(e0, theta, phia, phib, wmin, wmax, dw, comment, size(comment),   &
               layers, neps, nper, name, size(name), thick, epsinf, nos, osc, size(osc, 2),&
               contrl, mode, wn_array, f, size(wn_array))
@@ -1082,7 +1084,7 @@ end subroutine seteps
 
 subroutine doeels (e0, theta, phia, phib, wmin, wmax, dw, comment, comment_size,   &
               layers, neps, nper, name, name_size, thick, epsinf, nos, osc, osc_size,&
-              contrl, mode, wn_array, f_array, wn_array_size)
+              contrl, mode, wn_array, debug, f_array, wn_array_size)
 
 ! ******************************************************************
 ! *                                                                *
@@ -1104,8 +1106,9 @@ subroutine doeels (e0, theta, phia, phib, wmin, wmax, dw, comment, comment_size,
   integer, intent(in) :: comment_size, name_size, osc_size, wn_array_size
   integer, intent(in out) :: layers, nper, nos(name_size)
   double precision, intent(in out) :: wn_array(wn_array_size), f_array(wn_array_size)
+  logical, intent(in), optional :: debug
 
-  logical :: rational, user, debug
+  logical :: rational, user
   integer :: i, iw, neps, nofu, nout, nw, lmax
   double precision :: a, acoef, aerr, alpha, argmin, argmax, b, bcoef, beta,  &
       c1, c2, ccoef, cospsi, dlimf, dx, elleps, ener, epsmac, facru, f, f0,   &
@@ -1163,7 +1166,6 @@ subroutine doeels (e0, theta, phia, phib, wmin, wmax, dw, comment, comment_size,
 
   data aerr / 0.0d0 /, rerr / 1.0d-06 /, f / 0.0d0 /, f1 / 0.0d0 /
 
-1   debug = .false.
 1   if (debug) then
 *>     write (*,*) 'doeels:'
 *>     write (*,*) 'comment: ',  size(comment)
diff --git a/source/f90/fcat-analysis/eels_all.f90.fcat-analysis.txt b/source/f90/fcat-analysis/eels_all.f90.fcat-analysis.txt
index 1feb9ef144e8ade3edd26e3af2c0ba93027be349..dda7d14647efc58b5db57efba229a568d2752cfa 100644
--- a/source/f90/fcat-analysis/eels_all.f90.fcat-analysis.txt
+++ b/source/f90/fcat-analysis/eels_all.f90.fcat-analysis.txt
@@ -23,6 +23,7 @@ program eels
 
   integer :: old_size_1, old_size_2
   double precision, allocatable :: tmp_osc(:, :)
+  logical :: debug
   integer :: ioStatus
 
 !  integer, parameter :: name_length = 10
@@ -129,9 +130,10 @@ program eels
 1   nw = 1 + int((wmax - wmin) / dw)
 1   allocate (wn_array(nw), f(nw))
 
+1   debug = .false.
 1   call doeels(e0, theta, phia, phib, wmin, wmax, dw, comment, size(comment),   &
               layers, neps, nper, name, size(name), thick, epsinf, nos, osc, size(osc, 2),&
-              contrl, mode, wn_array, f, size(wn_array))
+              contrl, mode, wn_array, debug, f, size(wn_array))
 
 1   open (unit = 12, file = 'eelsou')
 1   write (12, 207) e0, theta, phia, phib, comment(1)
@@ -1072,7 +1074,7 @@ subroutine seteps(neps, nos, osc, epsinf, wn, name, eps, layers, mode)
 end subroutine seteps
 subroutine doeels (e0, theta, phia, phib, wmin, wmax, dw, comment, comment_size,   &
               layers, neps, nper, name, name_size, thick, epsinf, nos, osc, osc_size,&
-              contrl, mode, wn_array, f_array, wn_array_size)
+              contrl, mode, wn_array, debug, f_array, wn_array_size)
 
 ! ******************************************************************
 ! *                                                                *
@@ -1094,8 +1096,9 @@ subroutine doeels (e0, theta, phia, phib, wmin, wmax, dw, comment, comment_size,
   integer, intent(in) :: comment_size, name_size, osc_size, wn_array_size
   integer, intent(in out) :: layers, nper, nos(name_size)
   double precision, intent(in out) :: wn_array(wn_array_size), f_array(wn_array_size)
+  logical, intent(in), optional :: debug
 
-  logical :: rational, user, debug
+  logical :: rational, user
   integer :: i, iw, neps, nofu, nout, nw, lmax
   double precision :: a, acoef, aerr, alpha, argmin, argmax, b, bcoef, beta,  &
       c1, c2, ccoef, cospsi, dlimf, dx, elleps, ener, epsmac, facru, f, f0,   &
@@ -1153,7 +1156,6 @@ subroutine doeels (e0, theta, phia, phib, wmin, wmax, dw, comment, comment_size,
 
   data aerr / 0.0d0 /, rerr / 1.0d-06 /, f / 0.0d0 /, f1 / 0.0d0 /
 
-1   debug = .false.
 1   if (debug) then
 *>     write (*,*) 'doeels:'
 *>     write (*,*) 'comment: ',  size(comment)
diff --git a/tests/phintlog/doeels.f90 b/tests/phintlog/doeels.f90
index 2ca42d30e50e5692722b18167e066beb410eff13..366a2ffc92ce1803f7fe0d4b05de4b76d7725f33 100644
--- a/tests/phintlog/doeels.f90
+++ b/tests/phintlog/doeels.f90
@@ -1,6 +1,6 @@
 subroutine doeels (e0, theta, phia, phib, wmin, wmax, dw, comment, comment_size,   &
               layers, neps, nper, name, name_size, thick, epsinf, nos, osc, osc_size,&
-              contrl, mode, wn_array, f_array, wn_array_size)
+              contrl, mode, wn_array, debug, f_array, wn_array_size)
 
 ! ******************************************************************
 ! *                                                                *
@@ -48,8 +48,9 @@ subroutine doeels (e0, theta, phia, phib, wmin, wmax, dw, comment, comment_size,
   integer, intent(in) :: comment_size, name_size, osc_size, wn_array_size
   integer, intent(in out) :: layers, nper, nos(name_size)
   double precision, intent(in out) :: wn_array(wn_array_size), f_array(wn_array_size)
+  logical, intent(in), optional :: debug
 
-  logical :: rational, user, debug
+  logical :: rational, user
   integer :: i, iw, neps, nofu, nout, nw, lmax
   double precision :: a, acoef, aerr, alpha, argmin, argmax, b, bcoef, beta,  &
       c1, c2, ccoef, cospsi, dlimf, dx, elleps, ener, epsmac, facru, f, f0,   &
@@ -66,7 +67,6 @@ subroutine doeels (e0, theta, phia, phib, wmin, wmax, dw, comment, comment_size,
 
   data aerr / 0.0d0 /, rerr / 1.0d-06 /, f / 0.0d0 /, f1 / 0.0d0 /
 
-  debug = .false.
   if (debug) then
     write (*,*) 'doeels:'
     write (*,*) 'comment: ',  size(comment)
diff --git a/tests/phintlog/eels.f90 b/tests/phintlog/eels.f90
index f2a80cf2ed028e7e1c43ac90350f0f4b297a7618..396fde2ceef23df3b5da4c8a8f2c58664b694214 100644
--- a/tests/phintlog/eels.f90
+++ b/tests/phintlog/eels.f90
@@ -23,6 +23,7 @@ program eels
 
   integer :: old_size_1, old_size_2
   double precision, allocatable :: tmp_osc(:, :)
+  logical :: debug
   integer :: ioStatus
 
 !  integer, parameter :: name_length = 10
@@ -132,9 +133,10 @@ program eels
   nw = 1 + int((wmax - wmin) / dw)
   allocate (wn_array(nw), f(nw))
 
+  debug = .false.
   call doeels(e0, theta, phia, phib, wmin, wmax, dw, comment, size(comment),   &
               layers, neps, nper, name, size(name), thick, epsinf, nos, osc, size(osc, 2),&
-              contrl, mode, wn_array, f, size(wn_array))
+              contrl, mode, wn_array, debug, f, size(wn_array))
 
   open (unit = 12, file = 'eelsou')
   write (12, 207) e0, theta, phia, phib