[Tex/LaTex] How to declare global variables for an algorithm

algorithmicalgorithms

I have an algorithm which manipulates some local and global variables.
I don't know the format to declare global variables,
here I declared them in Require before the Procedure, However I think Require is for input parameters

\begin{algorithm}
\caption{An Algorithm}
\begin{algorithmic}
\Require
\State
    \State $A$, Global var1
    \State $B$, global var2
    \State $C$, global var3
\Procedure{Proc}{$input$}
 \State $D$, local var 
\State $A \gets B +D$
 \EndProcedure
\end{algorithmic}
\end{algorithm}

Best Answer

You can define a new block:

\documentclass{article}
\usepackage{algorithm,algpseudocode}

\algdef{SE}[VARIABLES]{Variables}{EndVariables}
   {\algorithmicvariables}
   {\algorithmicend\ \algorithmicvariables}
\algnewcommand{\algorithmicvariables}{\textbf{global variables}}

\begin{document}

\begin{algorithm}
\caption{An Algorithm}
\begin{algorithmic}
\Variables
 \State $A$, Global var1
 \State $B$, global var2
 \State $C$, global var3
\EndVariables
\Procedure{Proc}{$input$}
 \State $D$, local var
\State $A \gets B +D$
 \EndProcedure
\end{algorithmic}
\end{algorithm}

\end{document}

enter image description here