#!/bin/bash
#===============================================================================
#
# cg_set_proc.sh
#
#-------------------------------------------------------------------------------
#
# Copyright (C) 2012 Hinnerk Stueben
#
# This file is part of BQCD -- Berlin Quantum ChromoDynamics program
#
# BQCD is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BQCD is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with BQCD.  If not, see <http://www.gnu.org/licenses/>.
#
#-------------------------------------------------------------------------------

cat << 'EOF'
subroutine cg_set_proc(p, s)

  use module_cg_procs, exclude => cg_set_proc ! avoid name clash
  implicit none
  procedure(), pointer, intent(out) :: p
  character(*), intent(in) :: s

  select case (trim(s))
EOF

awk -v dquote='"' '
$1 == "procedure()" && $2 == "::" { print "  case (" dquote $3 dquote "); p => " $3 }
' module_cg_procs.f90

cat << 'EOF'
  case default; call die("cg_set_proc(): " // trim(s) // ": unknown procedure")
  end select
end 
EOF


#===============================================================================
