!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
!		Intrinsic functions & procedures
!
! written by  Zheng Gengbin    , Yan Mi
!			Peking University , P.R.C
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

module intrinsic_lib

!  in_type indicate that function result use the first argument type
type in_type
integer i
end type

! shape_type indicate that in reshape function  result depend on shape of SHAPE
type shape_type
integer i
end type

! all_type indicate that any type is allowed .


!!!!!!!
interface ABS
	type (in_type) function abs1(a)
		integer a
	end function abs1
	type (in_type) function abs2(a)
		integer a(1:2)
	end function abs2
	type (in_type) function abs3(a)
		integer a(1:2,1:2)
	end function abs3
	type (in_type) function abs4(a)
		integer a(1:2,1:2,1:2)
	end function abs4

  	type (in_type) function abs11(a)
		real a
	end function abs11
  	type (in_type) function abs12(a)
		real a(1:2)
	end function abs12
  	type (in_type) function abs13(a)
		real a(1:2,1:2)
	end function abs13
  	type (in_type) function abs14(a)
		real a(1:2,1:2,1:2)
	end function abs14
  	type (in_type) function abs31(a)
		double precision a
	end function abs31
  	type (in_type) function abs32(a)
		double precision a(1:2)
	end function abs32
  	type (in_type) function abs33(a)
		double precision a(1:2,1:2)
	end function abs33
  	type (in_type) function abs34(a)
		double precision a(1:2,1:2,1:2)
	end function abs34

	real function abs21(a)
		complex a
	end function abs21
	function abs22(a)
		real abs22(1:2)
		complex a(1:2)
	end function abs22
	function abs23(a)
		real abs23(1:2,1:2)
		complex a(1:2,1:2)
	end function abs23
end interface 

interface  all

	logical function all(mask,dim)
		logical mask
		integer ,optional ::dim 
	end function 
end interface

interface achar

	character function achar(i)
 		integer i
	end function
end interface

interface acos
	type (in_type) function acos(x)
 		real x
	end function
end interface

interface adjustr
	type (in_type) function adjustr(string)
		 character string
	end function
end interface

interface adjustl
	type (in_type) function adjustl(string)
		 character string
	end function
end interface

interface  aimag

	real function aimag(z)
		complex z
	end function
end interface

interface AINT
	integer  function aint11(a,kind)
		real a
		integer,optional:: kind
      	end function
	integer  function aint12(a,kind)
		real a(1:2)
		integer,optional:: kind
      	end function
	integer  function aint21(a,kind)
		double precision a
		integer,optional:: kind
      	end function
	integer  function aint22(a,kind)
		double precision a(1:2)
		integer,optional:: kind
      	end function
end interface

interface allocated
	logical  function  allocated(arrray)

	end function
end interface

interface anint
	integer  function  anint(a,kind)
		real a
		integer,optional::kind
	end function
end interface

interface  any
	logical  function  any1(mask,dim)
		logical mask(1:2)
		real ,optional::dim
	end function 
	logical  function  any2(mask,dim)
		logical mask(1:2,1:2)
		real ,optional::dim
	end function 
	logical  function  any3(mask,dim)
		logical mask(1:2,1:2,1:2)
		real ,optional::dim
	end function 
	logical  function  any4(mask,dim)
		logical mask(1:2,1:2,1:2,1:2)
		real ,optional::dim
	end function 
end interface


interface	asin	
	real function asin(x)
		real 	x
	end function 
end interface           


interface  atan
	real function atan(x)
		real x

	end function

end interface


interface associated
        logical function associated1(pointer1,target1)
		type all_type
		integer j
		end type

                type (all_type) ,pointer::  		pointer1
                type (all_type) ,pointer,optional::     target1
        end function
end interface

interface atan2
	real function atan2(y,x)
		real y,x
	end function
end interface

interface bit_size
	integer function bit_size(i)
		integer i
	end function
end interface

interface btest
	logical function btest(i,pos)
		real i,pos
	end function
end interface

interface ceiling
        integer  function ceiling(a)
		real a 
        end function
end interface

interface 	char
        character (len=1) function  char(i,kind)
		integer i
		integer,optional:: kind
        end function
end interface

interface	CMPLX 
!x can be integer ,real,complex; y can be integer ,real.
        complex function  cmplx11(x,y,kind)
		integer x
		integer,optional::y
		integer,optional::kind
        end function

                function  cmplx12(x,y,kind)
		complex cmplx12(1:2)
		integer x(1:2)
		integer,optional::y(1:2)
		integer,optional::kind
        end function

        complex function  cmplx21(x,y,kind)
		real x
		real,optional::y
		integer,optional::kind
        end function

        complex function  cmplx31(x,y,kind)
		complex x
		integer,optional::y
		integer,optional::kind
        end function
end interface

interface  conjg
        complex function conjg(z)
		complex z
        end function
end interface

interface  cos
        real function  cos1(x)
		real x
        end function
        complex function  cos2(x)
                complex x
        end function

end interface

interface cosh
        real function  cosh(x)
		real x
        end function
end interface

interface count
        integer function count1(mask,dim)
		logical mask(1:2)
		integer,optional::dim
        end function
        integer function count2(mask,dim)
		logical mask(1:2,1:2)
		integer,optional::dim
        end function
        integer function count3(mask,dim)
		logical mask(1:2,1:2,1:2)
		integer,optional::dim
        end function
end interface

interface CSHIFT
!array can be any type array
        type (in_type) function  cshift11(array,shift,dim)
		type all_type
		integer j
		end type

		type(all_type) array(1:2)
		integer shift
		integer ,optional::dim
        end function
        type (in_type) function  cshift12(array,shift,dim)
		type all_type
		integer j
		end type

		type(all_type) array(1:2,1:2)
		integer shift
		integer ,optional::dim
        end function
end interface

interface date_and_time
       	subroutine date_and_time(date,time,zone,values)
		character,optional::date,time,zone
		integer,optional:: values
        end subroutine 
end interface

interface dble
        double precision function dble(a)
! a can be integer,real, complex
		integer a
        end function
end interface

interface digits
        integer function digits1(x)
		integer x
        end function
        integer function digits2(x)
                real x
        end function

end interface

interface  dim
        real function dim1(x,y)
		real  x,y
        end function
         integer function dim2(x,y)
                 integer  x,y
        end function

end interface

interface  dot_product
! result and dummy can be 1:2 integer,real, complex,logical
        integer function dot_product1(vector_a,vector_b)
		integer vector_a(1:2),vector_b(1:2)
        end function
        real function dot_product2(vector_a,vector_b)
		real vector_a(1:2),vector_b(1:2)
        end function
        complex function dot_product3(vector_a,vector_b)
		complex vector_a(1:2),vector_b(1:2)
        end function
        logical function dot_product4(vector_a,vector_b)
		logical vector_a(1:2),vector_b(1:2)
        end function
end interface

interface dprod
        double precision function dprod(x,y)
		real x,y
        end function
end interface

interface eoshift
        integer function  eoshift(array,shift,boundary,dim)
! array and result can be any type
		integer array
		integer shift
		integer,optional::boundary
		integer,optional ::dim	
        end function
end interface

interface epsilon
        real function epsilon(x)
		real x
        end function
end interface

interface exp
        type (in_type) function exp1(x)
		real x
        end function
        type (in_type) function exp2(x)
		real x(1:2)
        end function
        type (in_type) function exp3(x)
		real x(1:2,1:2)
        end function
        type (in_type) function exp4(x)
		real x(1:2,1:2,1:2)
        end function

        type (in_type) function exp11(x)
		complex x
        end function
        type (in_type) function exp12(x)
		complex x(1:2)
        end function
        type (in_type) function exp13(x)
		complex x(1:2,1:2)
        end function
        type (in_type) function exp14(x)
		complex x(1:2,1:2,1:2)
        end function

end interface

interface exponent
        integer function exponent(x)
		real x
        end function
end interface


interface floor
	integer function floor(a)
		real a
	end function
end interface


interface fraction
        real function  fraction(x)
		real x
        end function
end interface


interface huge
        real function huge1(x)
		real x
        end function
	integer  function huge2(x)
		integer x
	end function
end interface


interface iachar
        integer function iachar(c)
		character(len=1) c
        end function
end interface


interface  iand
        integer function iand(i,j)
		integer i,j
        end function
end interface


interface ibclr
        integer function ibclr(i,pos)
		integer i,pos
        end function
end interface

interface ibits
        integer function ibits(i,pos,len)
		integer i,pos,len
        end function
end interface

interface ibset
        integer  function ibset(i,pos)
		integer i,pos
        end function
end interface

interface ichar
        integer function ichar(c)
		character(len=1) c
        end function
end interface

interface ieor
        integer function ieor(i,j)
		integer i,j
        end function
end interface

interface index
        integer function index(strng,substring,back)
		character strng,substrng
		logical,optional::  back
        end function
end interface

interface int
        integer function int1(a,kind)
		integer a
		integer,optional:: kind
        end function
	integer function int2(a,kind)
		real a
                integer,optional:: kind
        end function

        integer function int3(a,kind)
		complex a
                integer,optional:: kind
        end function
end interface

interface  ior
        integer function ior(i,j)
		integer i,j
        end function
end interface

interface  ishft
        integer function ishft(i,shift)
		integer i,j
        end function
end interface

interface ishfic
        integer function ishfic(i,shift,size)
		integer i,shift
		integer ,optional:: size
        end function
end interface

!! x can be any intrinsic type
interface kind
        integer function kind1(x)
	double precision x
        end function

        integer function kind2(x)
	integer x
        end function

        integer function kind3(x)
	real x
        end function

        integer function kind4(x)
	character x
        end function

        integer function kind5(x)
	logical x
        end function

        integer function kind6(x)
	complex x
        end function

end interface

interface LBOUND
		!!! array must be an ARRAY
        integer function lbound1(array,dim)
		type all_type
		integer j
		end type

		type (all_type)  :: array(1:2)
		integer ,optional:: dim
        end function
        integer function lbound2(array,dim)
		type all_type
		integer j
		end type

		type (all_type)  :: array(1:2,1:2)
		integer ,optional:: dim
        end function
end interface

interface len
	integer function len(string)
		character string
	end function
end interface


interface len_trim
        integer function len_trim(string)
		character string
        end function
end interface


interface lge
        logical function lge(string_a,string_b)
		character string_a,string_b
        end function
end interface


interface lgt
        logical function lgt(string_a,string_b)
		character string_a,string_b
        end function
end interface


interface lle
        logical function  lle(string_a,string_b)
                character string_a,string_b
        end function
end interface


interface llt
        logical function llt(string_a,string_b)
                character string_a,string_b
        end function
end interface


interface LOG
        type(in_type) function log11(x)
		real x
        end function
        type(in_type) function log12(x)
		real x(1:2)
        end function
        type(in_type) function log13(x)
		real x(1:2,1:2)
        end function
        type(in_type) function log21(x)
		complex x
        end function
        type(in_type) function log22(x)
		complex x(1:2)
        end function
        type(in_type) function log21(x)
		complex x(1:2,1:2)
        end function
        type(in_type) function log31(x)
		double precision x
        end function
        type(in_type) function log32(x)
		double precision x(1:2)
        end function
        type(in_type) function log33(x)
		double precision x(1:2,1:2)
        end function

end interface


interface lolg10
        real function log10(x)
		real x
        end function
end interface



!interface  logical
!        logical function logical(l,kind)
!		logical l
!		integer,optional::kind
!        end function
!end interface



interface matmul
        logical function matmul1(matrix_a,matrix_b)
		logical matrix_a,matrix_b
        end function
	real function matmul2(matrix_a,matrix_b)
		real matrix_a,matrix_b
	end function
	integer function matmul3(matrix_a,matrix_b)
 		integer matrix_a,matrix_b
       end function
	complex function matmul4(matrix_a,matrix_b)
		complex matrix_a,matrix_b
        end function

end interface



interface MAX
        real function max1(a1,a2,a3)
		real a1,a2
		real ,optional:: a3
        end function
        real function max2(a1,a2,a3)
		real a1(1:2),a2(1:2)
		real ,optional:: a3(1:2)
        end function
        real function max3(a1,a2,a3)
		real a1(1:2,1:2),a2(1:2,1:2)
		real ,optional:: a3(1:2,1:2)
        end function

        real function max31(a1,a2,a3)
		double precision a1,a2
		real ,optional:: a3
        end function
        real function max32(a1,a2,a3)
		double precision a1(1:2),a2(1:2)
		real ,optional:: a3(1:2)
        end function
        real function max33(a1,a2,a3)
		double precision a1(1:2,1:2),a2(1:2,1:2)
		real ,optional:: a3(1:2,1:2)
        end function

	integer function max11(a1,a2,a3)
		integer a1,a2
		integer ,optional:: a3
	end function
	integer function max12(a1,a2,a3)
		integer a1(1:2),a2(1:2)
		integer ,optional:: a3(1:2)
	end function
	integer function max13(a1,a2,a3)
		integer a1(1:2,1:2),a2(1:2,1:2)
		integer ,optional:: a3(1:2,1:2)
	end function
end interface



interface maxexpopnent
        integer  function maxexpopnent(x)
		real x
        end function
end interface

interface maxloc
	integer function maxloc1(array,mask)
		real array(1:2)
		logical,optional::mask
	end function
	integer function maxloc2(array,mask)
		real array(1:2,1:2)
		logical,optional::mask
	end function
	integer function maxloc11(array,mask)
		 integer  array(1:2)
                logical,optional::mask
	 end function
	integer function maxloc12(array,mask)
		 integer  array(1:2,1:2)
                logical,optional::mask
	 end function

end interface


interface  maxval
        integer function maxval1(array,dim,mask)
		integer array(1:2)
		integer,optional:: dim
		logical,optional::mask(1:2)
        end function
        integer function maxval2(array,dim,mask)
		integer array(1:2,1:2)
		integer,optional:: dim
		logical,optional::mask(1:2,1:2)
        end function
        integer function maxval3(array,dim,mask)
		integer array(1:2,1:2,1:2)
		integer,optional:: dim
		logical,optional::mask(1:2,1:2,1:2)
        end function
        real  function maxval10(array,dim,mask)
                real  array(1:2)
                integer,optional:: dim
                logical,optional::mask(1:2)
        end function
        real  function maxval11(array,dim,mask)
                real  array(1:2,1:2)
                integer,optional:: dim
                logical,optional::mask(1:2,1:2)
        end function
        real  function maxval12(array,dim,mask)
                real  array(1:2,1:2,1:2)
                integer,optional:: dim
                logical,optional::mask(1:2,1:2,1:2)
        end function
end interface


interface merge
        type (in_type) function  merge1(tsource,fsource,mask)
		type all_type
		integer j
		end type

		type (all_type) tsource,fsource
		logical mask
        end function
        type (in_type) function  merge2(tsource,fsource,mask)
		type all_type
		integer j
		end type

		type (all_type) tsource,fsource
		logical mask(1:2)
        end function
        type (in_type) function  merge3(tsource,fsource,mask)
		type all_type
		integer j
		end type

		type (all_type) tsource,fsource
		logical mask(1:2,1:2)
        end function
end interface


interface min
        real function min1(a1,a2,a3)
		real a1,a2
		real ,optional::a3
        end function
        real function min2(a1,a2,a3)
		real a1(1:2),a2(1:2)
		real ,optional::a3(1:2)
        end function
        real function min3(a1,a2,a3)
		real a1(1:2,1:2),a2(1:2,1:2)
		real ,optional::a3(1:2,1:2)
        end function
	integer function min11(a1,a2,a3)
		integer a1,a2
		integer,optional::a3
	end function
	integer function min12(a1,a2,a3)
		integer a1(1:2),a2(1:2)
		integer,optional::a3(1:2)
	end function
	integer function min13(a1,a2,a3)
		integer a1(1:2,1:2),a2(1:2,1:2)
		integer,optional::a3(1:2,1:2)
	end function
end interface


interface mixexponent
        integer function mixexponent(x)
		real x
        end function
end interface


!  replaced in HPF part
!interface minloc
!        function minloc1(array,mask)
!		integer minloc1(1:2)
!		integer array(1:2)
!		logical,optional::mask(1:2)
!        end function
!        function minloc2(array,mask)
!		integer minloc2(1:2)
!		integer array(1:2,1:2)
!		logical,optional::mask(1:2,1:2)
!        end function
!	function minloc11(array,mask)
!		integer minloc11(1:2)
!		real  array(1:2)
!                logical,optional::mask(1:2)
!        end function
!	function minloc12(array,mask)
!		integer minloc12(1:2)
!		real  array(1:2,1:2)
!                logical,optional::mask(1:2,1:2)
!        end function
!	function minloc13(array,mask)
!		integer minloc13(1:2)
!		real  array(1:2,1:2,1:2)
!                logical,optional::mask(1:2,1:2,1:2)
!        end function
!end interface


interface minval
        integer function minval1(array,dim,mask)
		integer array(1:2)
		integer,optional::dim
		logical,optional::mask(1:2)
        end function
        integer function minval2(array,dim,mask)
		integer array(1:2,1:2)
		integer,optional::dim
		logical,optional::mask(1:2,1:2)
        end function
        integer function minval3(array,dim,mask)
		integer array(1:2,1:2,1:2)
		integer,optional::dim
		logical,optional::mask(1:2,1:2,1:2)
        end function
	real function minval11(array,dim,mask)
		real array(1:2)
                integer,optional::dim
                logical,optional::mask(1:2)
        end function
	real function minval12(array,dim,mask)
		real array(1:2,1:2)
                integer,optional::dim
                logical,optional::mask(1:2,1:2)
        end function
	real function minval13(array,dim,mask)
		real array(1:2,1:2,1:2)
                integer,optional::dim
                logical,optional::mask(1:2,1:2,1:2)
        end function
end interface


interface mod
        integer function mod1(a,p)
		integer a,p
        end function
	real function mod2(a,p)
		real a,p
	 end function
end interface


!interface module
!         integer function module1(a,p)
!                integer a,p
!        end function
!	real function module2(a,p)
!		 real a,p
!         end function
!end interface


interface mvbits
        subroutine mvbits(from,frompos,len,to,topos)
		integer,intent(IN):: from,frompos,len,topos
		integer ,intent(INOUT):: to
        end subroutine
end interface


interface nearest
        real function nearest(x,s)
		real x,s
        end function
end interface



interface nint
        integer function nint1(a,kind)
		real a
		integer,optional::kind
        end function
        integer function nint2(a,kind)
		real a(1:2)
		integer,optional::kind
        end function
        integer function nint3(a,kind)
		real a(1:2,1:2)
		integer,optional::kind
        end function
        integer function nint11(a,kind)
		double precision a
		integer,optional::kind
        end function
        integer function nint12(a,kind)
		double precision a(1:2)
		integer,optional::kind
        end function
        integer function nint13(a,kind)
		double precision a(1:2,1:2)
		integer,optional::kind
        end function
end interface


interface not
        integer function not(i)
		integer i
        end function
end interface


interface pack
        integer function pack1(array,mask,vector)
		!! array and vector can be any type
		logical mask
		integer array
		integer,optional:: vector
        end function
end interface


interface precision
        integer function precision1(x)
		real x
        end function
	integer function precision2(x)
		complex x
	end function
end interface


interface present
	!!! a can be any type
        logical function present1(a)
		type all_type
		integer j
		end type

		type (all_type)  a
        end function
end interface


interface product
        integer function producti1(array,dim,mask)
		integer array
		integer,optional::dim
		logical,optional::mask
        end function
	real function product2(array,dim,mask)
		real array
                integer,optional::dim
                logical,optional::mask
        end function
	complex function product3(array,dim,mask)
		complex array
                integer,optional::dim
                logical,optional::mask
        end function
end interface


interface radix
	integer function radix1(x)
		integer x
	end function
	integer function radix2(x)
		real x
	end function
end interface

interface random_number
 	subroutine random_number1(harvest)
		real,intent(inout):: harvest
	end subroutine       
 	subroutine random_number2(harvest)
		real,intent(inout):: harvest(1:2)
	end subroutine       
 	subroutine random_number3(harvest)
		real,intent(inout):: harvest(1:2,1:2)
	end subroutine       
end interface

interface RANDOM_SEED
	subroutine random_seed(size,put,get)
		integer,optional :: size
		integer,optional :: put(1:2)
		integer,optional :: get(1:2)
	end subroutine
end interface

interface range
        integer function range1(x)
		integer x
        end function
	integer function range2(x)
		real x
        end function
        integer function range3(x)
		complex x
	end function
end interface

interface  real
        real function  real1(a,kind)
		integer a
		integer ,optional::kind
        end function
	real function  real2(a,kind)
		real a
	        integer ,optional::kind
        end function
        real function  real3(a,kind)
		complex a
               integer ,optional::kind
        end function
end interface

interface repeat
        character function repeat(string,ncopies)
		character string
		integer ncopies
        end function
end interface

interface  reshape
			!! source and pad can be any type
        type (shape_type)  function reshape1(source,shape,pad,order)
		type any_type
                integer j
                end type

		type (any_type) 	source(1:2)
		integer 		shape(1:2)
		type (any_type),optional:: pad
		integer,optional::	order
        end function
        type (shape_type)  function reshape2(source,shape,pad,order)
		type any_type
                integer j
                end type

		type (any_type) 	source(1:2,1:2)
		integer 		shape(1:2)
		type (any_type),optional:: pad
		integer,optional::	order
        end function
end interface


interface prspacing
	real function prspacing(x)
		real x
	end function
end interface


interface scale
        real  function scale(x,i)
		real x
		integer i
        end function
end interface


interface scan
         integer function scan(string,set,back)
		character string,set
		logical,optional::back
        end function
end interface


interface select_int_kind
        integer function select_int_kind(r)
		integer r
        end function
end interface

interface selected_int_kind
        integer function select_int_kind(r)
		integer r
        end function
end interface

interface  select_real_kind
        integer function select_real_kind(p,r)
		integer ,optional::p,r
        end function
end interface

interface  selected_real_kind
        integer function select_real_kind(p,r)
		integer ,optional::p,r
        end function
end interface

interface set_exponent
        real function set_exponent(x,i)
		real x
		integer i
        end function
end interface


interface shape
		 !!! source can be any type array
        function  shape1(source)
		integer shape1(1:2)
		integer source(1:2)
        end function
        function  shape2(source)
		integer shape2(1:2)
		integer source(1:2,1:2)
        end function
        function  shape3(source)
		integer shape3(1:2)
		integer source(1:2,1:2,1:2)
        end function

        function  shape11(source)
		integer shape11(1:2)
		real source(1:2)
        end function
        function  shape12(source)
		integer shape12(1:2)
		real source(1:2,1:2)
        end function
        function  shape13(source)
		integer shape13(1:2)
		real source(1:2,1:2,1:2)
        end function
end interface

interface sign
	integer function sign1(a,b)
		integer a,b
	end function
	real function sign2(a,b)
		real  a,b
        end function
end interface


interface sin
        type (in_type) function sin11(x)
		real x
        end function
        type (in_type) function sin12(x)
		real x(1:2)
        end function
        type (in_type) function sin13(x)
		real x(1:2,1:2)
        end function
	type (in_type) function sin21(x)
		complex x
        end function
	type (in_type) function sin22(x)
		complex x(1:2)
        end function
	type (in_type) function sin23(x)
		complex x(1:2,1:2)
        end function
end interface


interface sinh
        real function sinh(x)
		real x
        end function
end interface


interface size
!!! array can be any type array
        integer function size1(array,dim)
		type any_type
		integer j
		end type

		type (any_type)        :: array(1)
		integer,optional::dim
        end function

        integer function size2(array,dim)
		type any_type
		integer j
		end type

		type (any_type)         :: array(1:2,1:2)
		integer,optional::dim
        end function

        integer function size3(array,dim)
		type any_type
		integer j
		end type

		type (any_type)         :: array(1,1,1)
		integer,optional::dim
        end function

        integer function size4(array,dim)
		type any_type
		integer j
		end type

		type (any_type)         :: array(1,1,1,1)
		integer,optional::dim
        end function
end interface


interface spacing
        real function spacing(x)
		real x
        end function
end interface


interface spread
        integer function spread1(source,dim,ncopies)
		integer source  !!source can be any tyep
		integer dim,ncopies
        end function
end interface


interface  SQRT
        type (in_type) function sqrt11(x)
		real x
        end function
        type (in_type) function sqrt12(x)
		real x(1:2)
        end function
        type (in_type) function sqrt13(x)
		real x(1:2,1:2)
        end function
        type (in_type) function sqrt14(x)
		real x(1:2,1:2,1:2)
        end function
        type (in_type) function sqrt11(x)
		double precision x
        end function
        type (in_type) function sqrt12(x)
		double precision x(1:2)
        end function
        type (in_type) function sqrt13(x)
		double precision x(1:2,1:2)
        end function
        type (in_type) function sqrt14(x)
		double precision x(1:2,1:2,1:2)
        end function

	type (in_type) function sqrt31(x)
		complex x
        end function
	type (in_type) function sqrt32(x)
		complex x(1:2)
        end function
	type (in_type) function sqrt33(x)
		complex x(1:2,1:2)
        end function
	type (in_type) function sqrt34(x)
		complex x(1:2,1:2,1:2)
        end function
end interface

interface  SUM
	integer function sum1(array,dim,mask)
		integer array(1:2)
		integer,optional::dim
		logical,optional::mask
	end function
	integer function sum2(array,dim,mask)
		integer array(1:2,1:2)
		integer,optional::dim
		logical,optional::mask
	end function
	integer function sum3(array,dim,mask)
		integer array(1:2,1:2,1:2)
		integer,optional::dim
		logical,optional::mask
	end function

	real function sum11(array,dim,mask)
		real array(1:2)
                integer,optional::dim
                logical,optional::mask
        end function
	real function sum12(array,dim,mask)
		real array(1:2,1:2)
                integer,optional::dim
                logical,optional::mask
        end function
	real function sum13(array,dim,mask)
		real array(1:2,1:2,1:2)
                integer,optional::dim
                logical,optional::mask
        end function
	real function sum14(array,dim,mask)
		real array(1:2,1:2,1:2,1:2)
                integer,optional::dim
                logical,optional::mask
        end function

	complex function sum21(array,dim,mask)
		complex array(1:2)
                integer,optional::dim
                logical,optional::mask
        end function
	complex function sum22(array,dim,mask)
		complex array(1:2,1:2)
                integer,optional::dim
                logical,optional::mask
        end function
	complex function sum23(array,dim,mask)
		complex array(1:2,1:2,1:2)
                integer,optional::dim
                logical,optional::mask
        end function

	real function sum31(array,dim,mask)
		double precision array(1:2)
                integer,optional::dim
                logical,optional::mask
        end function
	real function sum32(array,dim,mask)
		double precision array(1:2,1:2)
                integer,optional::dim
                logical,optional::mask
        end function
	real function sum33(array,dim,mask)
		double precision array(1:2,1:2,1:2)
                integer,optional::dim
                logical,optional::mask
        end function
	real function sum34(array,dim,mask)
		double precision array(1:2,1:2,1:2,1:2)
                integer,optional::dim
                logical,optional::mask
        end function
end interface

interface system_clock
	subroutine system_clock(count,count_rate,count_max)
		integer,optional,intent(out):: count,count_rate,count_max
	end subroutine
end interface

interface tan
        real function tan(x)
		real x
        end function
end interface

interface tanh
        real function tanh(x)
		real x
        end function
end interface

interface tiny
        real function tiny(x)
		real x
        end function
end interface

interface transfer
        integer function transfer1(source,mold,size)
		integer mold ! mold can be any type array
				!source can be any type array
		integer ,optional::size
        end function
end interface

! ?????????? maybe have some problem
interface  TRANSPOSE
        integer function transpose1(matrix)
		logical	matrix(:,:) !!! matrix can be ant type and its rank is 2
        end function
        integer function transpose2(matrix)
                 integer	matrix(:,:) !!! matrix can be ant type and its rank is 2
        end function
        integer function transpose3(matrix)
                 real	matrix(:,:) !!! matrix can be ant type and its rank is 2
        end function
        integer function transpose4(matrix)
                 character	matrix(:,:) !!! matrix can be ant type and its rank is 2
        end function
        integer function transpose5(matrix)
                 complex	matrix(:,:) !!! matrix can be ant type and its rank is 2
        end function
! modified by yan mi 1996.10.15
end interface

interface  trim
	character function trim(string)
		character string
	end function
end interface
 
interface  ubound
		! array can  be any tyep
        integer function ubound1(array,dim)
		type any_type
                integer j
                end type

                type (any_type)  :: array(1:2)
		integer,optional::dim
        end function
        integer function ubound2(array,dim)
		type any_type
                integer j
                end type

                type (any_type)  :: array(1:2,1:2)
		integer,optional::dim
        end function
end interface
 
interface  unpack
        integer function unpack1(vector,mask,field)
		integer vector,field  !! vector can be any array
		logical mask
        end function
end interface
 
interface  verify
        integer function verify(string,set,back)
		character string,set
		 logical,optional:: back
        end function
end interface
 

!-----------------------------------------------------------------
!                    HPF intrinsic libaray
! 
!-----------------------------------------------------------------

interface ilen
        type (in_type) function ilen1(i)
             integer i 
        end function  
end interface
!interface maxloc
!        integer function maxloc1(array,dim,mask)
!            integer array(1:2)
!            integer,optional:: dim
!            logical,optional:: mask
!        end function
!        integer function maxloc2(array,dim,mask)
!            integer array(1:2,1:2)
!            integer,optional:: dim
!            logical,optional:: mask
!        end function
!        integer function maxloc3(array,dim,mask)
!            integer array(1:2,1:2,1:2)
!            integer,optional:: dim
!            logical,optional:: mask
!        end function
!        integer function maxloc11(array,dim,mask)
!            real array
!            integer,optional:: dim
!            logical,optional:: mask
!        end function
!        integer function maxloc12(array,dim,mask)
!            real array(1:2)
!            integer,optional:: dim
!            logical,optional:: mask
!        end function
!        integer function maxloc13(array,dim,mask)
!            real array(1:2,1:2)
!            integer,optional:: dim
!            logical,optional:: mask
!        end function
!        integer function maxloc14(array,dim,mask)
!            real array(1:2,1:2,1:2)
!            integer,optional:: dim
!            logical,optional:: mask
!        end function
!        integer function maxloc11(array,dim,mask)      
!            complex array
!            integer,optional:: dim
!            logical,optional:: mask
!        end function
!        integer function maxloc12(array,dim,mask)
!            complex array(1:2)
!            integer,optional:: dim
!            logical,optional:: mask
!        end function
!        integer function maxloc13(array,dim,mask)
!            complex array(1:2,1:2)
!            integer,optional:: dim
!            logical,optional:: mask
!        end function
!        integer function maxloc14(array,dim,mask)
!            complex array(1:2,1:2,1:2)
!            integer,optional:: dim
!            logical,optional:: mask
!        end function
!
!end interface

                

interface minloc
        integer function minloc1(array,dim,mask)
            integer array(1:2)
            integer,optional:: dim
            logical,optional:: mask
        end function
        integer function minloc2(array,dim,mask)
            integer array(1:2,1:2)
            integer,optional:: dim
            logical,optional:: mask
        end function
        integer function minloc3(array,dim,mask)
            integer array(1:2,1:2,1:2)
            integer,optional:: dim
            logical,optional:: mask
        end function
        integer function minloc11(array,dim,mask)
            real array(1:2)
            integer,optional:: dim
            logical,optional:: mask
        end function
        integer function minloc12(array,dim,mask)
            real array(1:2,1:2)
            integer,optional:: dim
            logical,optional:: mask
        end function
        integer function minloc13(array,dim,mask)
            real array(1:2,1:2,1:2)
            integer,optional:: dim
            logical,optional:: mask
        end function
end interface  

interface NUMBER_OF_PROCESSORS
        integer function number_of_processors(dim)
             integer,optional :: dim
        end function  
end  interface

interface processors_shape
        function processors_shape()
	integer processors_shape(1:2)
        end function    
end  interface

interface all_prefix
        logical function all_prefix(mask,dim,segment,exclusive)
              logical mask
              integer,optional::dim
              logical,optional::segment
              logical,optional::exclusive
        end function
end interface
   
interface all_scatter
         logical function all_scatter1(mask,base,indx1)
               logical mask
               logical base
               integer indx1
          end function
          logical function all_scatter2(mask,base,indx1,indx2) 
               logical mask
               logical base
               integer indx1,indx2  
          end function
          logical function all_scatter(mask,base,indx1,indx2,indx3) 
               logical mask
               logical base
               integer indx1,indx2,indx3  
          end function
          logical function all_scatter(mask,base,indx1,indx2,indx3,indx4) 
               logical mask
               logical base
               integer indx1,indx2,indx3,indx4  
          end function
          logical function all_scatter(mask,base,indx1,indx2,indx3,indx4,indx5) 
               logical mask
               logical base
               integer indx1,indx2,indx3,indx4,indx5  
          end function
end interface

interface all_suffix 
          logical function all_suffix(mask,dim,segment,exclusive)
               logical mask
               integer,optional::dim
               logical,optional::segment
               logical,optional::exclusive
          end function  
end interface                            

interface any_prefix
          logical function any_prefix(mask,dim,segment,exclusive)
               logical mask
               integer,optional::dim
               logical,optional::segment
               logical,optional::exclusive
          end function
end interface

interface any_scatter
         logical function any_scatter1(mask,base,indx1)
               logical mask
               logical base
               integer indx1
          end function
          logical function any_scatter2(mask,base,indx1,indx2)
               logical mask
               logical base
               integer indx1,indx2
          end function
          logical function any_scatter(mask,base,indx1,indx2,indx3)
               logical mask
               logical base
               integer indx1,indx2,indx3
          end function
          logical function any_scatter(mask,base,indx1,indx2,indx3,indx4)
               logical mask
               logical base
               integer indx1,indx2,indx3,indx4
          end function
          logical function any_scatter(mask,base,indx1,indx2,indx3,indx4,indx5)
               logical mask
               logical base
               integer indx1,indx2,indx3,indx4,indx5
          end function
end interface

interface any_suffix
          logical function any_suffix(mask,dim,segment,exclusive)
               logical mask
               integer,optional::dim
               logical,optional::segment
               logical,optional::exclusive
          end function
end interface

interface copy_prefix
        type (in_type) function copy_prefix1(array,dim,segment)
                integer array
                integer,optional::dim
                logical,optional::segment                  
        end function
        type (in_type) function copy_prefix2(array,dim,segment) 
                integer array(1:2)
                integer,optional::dim
                logical,optional::segment
        end function 
        type (in_type) function copy_prefix3(array,dim,segment) 
                integer array(1:2,1:2)
                integer,optional::dim
                logical,optional::segment
        end function 
        type (in_type) function copy_prefix4(array,dim,segment)  
                integer array(1:2,1:2,1:2)
                integer,optional::dim
                logical,optional::segment
        end function 
        type (in_type) function copy_prefix21(array,dim,segment)
                real array
                integer,optional::dim
                logical,optional::segment
        end function 
        type (in_type) function copy_prefix22(array,dim,segment)
                real array(1:2)
                integer,optional::dim
                logical,optional::segment
        end function 
        type (in_type) function copy_prefix23(array,dim,segment)
                real array(1:2,1:2)
                integer,optional::dim
                logical,optional::segment
        end function 
        type (in_type) function copy_prefix24(array,dim,segment)
                real array(1:2,1:2,1:2)
                integer,optional::dim
                logical,optional::segment
        end function 
        type (in_type) function copy_prefix31(array,dim,segment)
                complex array
                integer,optional::dim
                logical,optional::segment
        end function 
        type (in_type) function  copy_prefix32(array,dim,segment)
                complex array(1:2)
                integer,optional::dim
                logical,optional::segment
        end function 
        type (in_type) function  copy_prefix33(array,dim,segment)
                complex array(1:2,1:2)
                integer,optional::dim
                logical,optional::segment
        end function 
        type (in_type) function  copy_prefix34(array,dim,segment)
                complex array(1:2,1:2,1:2)
                integer,optional::dim
                logical,optional::segment
        end function 
end interface

interface copy_scatter
        type (in_type) function copy_scatter1(array,base,indx1,mask)
                 integer array
                 integer base
                 integer indx1
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter2(array,base,indx1,mask)
                 integer array(1:2)
                 integer base(1:2)
                 integer indx1
                 logical,optional::mask
        end function 
        type (in_type) function copy_scatter3(array,base,indx1,mask)
                 integer array(1:2,1:2)
                 integer base(1:2,1:2)
                 integer indx1
                 logical,optional::mask
        end function 
        type (in_type) function copy_scatter4(array,base,indx1,mask)
                 integer array(1:2,1:2,1:2)
                 integer base(1:2,1:2,1:2)
                 integer indx1
                 logical,optional::mask
        end function 
        type (in_type) function copy_scatter21(array,base,indx1,mask)
                 real array
                 real base
                 integer indx1
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter22(array,base,indx1,mask)
                 real array(1:2)
                 real base(1:2)
                 integer indx1
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter23(array,base,indx1,mask)
                 real array(1:2,1:2)
                 real base(1:2,1:2)
                 integer indx1
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter24(array,base,indx1,mask)
                 real array(1:2,1:2,1:2)
                 real  base(1:2,1:2,1:2)
                 integer indx1
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter31(array,base,indx1,mask)
                 complex array
                 complex base
                 integer indx1
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter32(array,base,indx1,mask)
                 complex array(1:2)
                 complex base(1:2)
                 integer indx1
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter33(array,base,indx1,mask)
                 complex array(1:2,1:2)
                 complex base(1:2,1:2)
                 integer indx1
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter34(array,base,indx1,mask)
                 complex array(1:2,1:2,1:2)
                 complex base(1:2,1:2,1:2)
                 integer indx1
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter41(array,base,indx1,indx2,mask)
                 integer array
                 integer base
                 integer indx1,indx2
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter42(array,base,indx1,indx2,mask)
                 integer array(1:2)
                 integer base(1:2)
                 integer indx1,indx2
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter43(array,base,indx1,indx2,mask)
                 integer array(1:2,1:2)
                 integer base(1:2,1:2)
                 integer indx1,indx2
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter44(array,base,indx1,indx2,mask)
                 integer array(1:2,1:2,1:2)
                 integer base(1:2,1:2,1:2)
                 integer indx1,indx2
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter51(array,base,indx1,indx2,mask)
                 real array
                 real base
                 integer indx1,indx2
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter52(array,base,indx1,indx2,mask)
                 real array(1:2)
                 real base(1:2)
                 integer indx1,indx2
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter53(array,base,indx1,indx2,mask)
                 real array(1:2,1:2)
                 real base(1:2,1:2)
                 integer indx1,indx2
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter(array,base,indx1,indx2,mask)
                 real array(1:2,1:2,1:2)
                 real  base(1:2,1:2,1:2)
                 integer indx1,indx2
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter(array,base,indx1,indx2,mask)
                 complex array
                 complex base
                 integer indx1,indx2
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter(array,base,indx1,indx2,mask)
                 complex array(1:2)
                 complex base(1:2)
                 integer indx1,indx2
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter(array,base,indx1,indx2,mask)
                 complex array(1:2,1:2)
                 complex base(1:2,1:2)
                 integer indx1,indx2
                 logical,optional::mask
        end function
        type (in_type) function copy_scatter(array,base,indx1,indx2,mask)
                 complex array(1:2,1:2,1:2)
                 complex base(1:2,1:2,1:2)
                 integer indx1,indx2
                 logical,optional::mask
        end function
end interface

interface copy_suffix
        type (in_type) function copy_suffix1(array,dim,segment)
                integer array
                integer,optional::dim
                logical,optional::segment
        end function
        type (in_type) function copy_suffix2(array,dim,segment)
                integer array(1:2)
                integer,optional::dim
                logical,optional::segment
        end function
        type (in_type) function copy_suffix3(array,dim,segment)
                integer array(1:2,1:2)
                integer,optional::dim
                logical,optional::segment
        end function
        type (in_type) function copy_suffix4(array,dim,segment)
                integer array(1:2,1:2,1:2)
                integer,optional::dim
                logical,optional::segment
        end function
        type (in_type) function copy_suffix21(array,dim,segment)
                real array
                integer,optional::dim
                logical,optional::segment
        end function
        type (in_type) function copy_suffix22(array,dim,segment)
                real array(1:2)
                integer,optional::dim
                logical,optional::segment
        end function
        type (in_type) function copy_suffix23(array,dim,segment)
                real array(1:2,1:2)
                integer,optional::dim
                logical,optional::segment
        end function
        type (in_type) function copy_suffix24(array,dim,segment)
                real array(1:2,1:2,1:2)
                integer,optional::dim
                logical,optional::segment
        end function
        type (in_type) function copy_suffix31(array,dim,segment)
                complex array
                integer,optional::dim
                logical,optional::segment
        end function
        type (in_type) function  copy_suffix32(array,dim,segment)
                complex array(1:2)
                integer,optional::dim
                logical,optional::segment
        end function
        type (in_type) function  copy_suffix33(array,dim,segment)
                complex array(1:2,1:2)
                integer,optional::dim
                logical,optional::segment
        end function
        type (in_type) function  copy_suffix34(array,dim,segment)
                complex array(1:2,1:2,1:2)
                integer,optional::dim
                logical,optional::segment
        end function
end interface

interface count_prefix
          logical function count_prefix(mask,dim,segment,exclusive)
               logical mask
               integer,optional::dim
               logical,optional::segment
               logical,optional::exclusive
          end function
end interface

interface count_scatter
          logical function count_scatter1(mask,base,indx1)
               logical mask
               logical base
               integer indx1
          end function
          logical function count_scatter2(mask,base,indx1,indx2)
               logical mask
               logical base
               integer indx1,indx2
          end function
          logical function count_scatter(mask,base,indx1,indx2,indx3)
               logical mask
               logical base
               integer indx1,indx2,indx3
          end function
          logical function count_scatter(mask,base,indx1,indx2,indx3,indx4)
               logical mask
               logical base
               integer indx1,indx2,indx3,indx4
          end function
          logical function count_scatter(mask,base,indx1,indx2,indx3,indx4,indx5)
               logical mask
               logical base
               integer indx1,indx2,indx3,indx4,indx5
          end function
end interface

interface count_suffix
          logical function count_suffix(mask,dim,segment,exclusive)
               logical mask
               integer,optional::dim
               logical,optional::segment
               logical,optional::exclusive
          end function
end interface

interface grade_down
          integer function grade_down11(array,dim)
                integer array
                integer,optional::dim
          end function
          integer function grade_down12(array,dim) 
                integer array(1:2)
                integer,optional::dim
          end function
          integer function grade_down13(array,dim) 
                integer array(1:2,1:2)
                integer,optional::dim
          end function
          integer function grade_down14(array,dim) 
                integer array(1:2,1:2,1:2)
                integer,optional::dim
          end function
          integer function grade_down21(array,dim) 
                real array
                integer,optional::dim
          end function
          integer function grade_down22(array,dim) 
                real array(1:2)
                integer,optional::dim
          end function
          integer function grade_down23(array,dim) 
                real array(1:2,1:2)
                integer,optional::dim
          end function
          integer function grade_down24(array,dim) 
                real array(1:2,1:2,1:2)
                integer,optional::dim
          end function
          integer function grade_down31(array,dim) 
                character array
                integer,optional::dim
          end function
          integer function grade_down32(array,dim)
                character array(1:2)
                integer,optional::dim
          end function
          integer function grade_down33(array,dim)
                character array(1:2,1:2)
                integer,optional::dim
          end function
          integer function grade_down34(array,dim)
                character array(1:2,1:2,1:2)
                integer,optional::dim
          end function
end interface

interface grade_up
          integer function grade_up11(array,dim)
                integer array
                integer,optional::dim
          end function
          integer function grade_up12(array,dim)
                integer array(1:2)
                integer,optional::dim
          end function
          integer function grade_up13(array,dim)
                integer array(1:2,1:2)
                integer,optional::dim
          end function
          integer function grade_up14(array,dim)
                integer array(1:2,1:2,1:2)
                integer,optional::dim
          end function
          integer function grade_up21(array,dim)
                real array
                integer,optional::dim
          end function
          integer function grade_up22(array,dim)
                real array(1:2)
                integer,optional::dim
          end function
          integer function grade_up23(array,dim)
                real array(1:2,1:2)
                integer,optional::dim
          end function
          integer function grade_up24(array,dim)
                real array(1:2,1:2,1:2)
                integer,optional::dim
          end function
          integer function grade_up31(array,dim)
                character array
                integer,optional::dim
          end function
          integer function grade_up32(array,dim)
                character array(1:2)
                integer,optional::dim
          end function
          integer function grade_up33(array,dim)
                character array(1:2,1:2)
                integer,optional::dim
          end function
          integer function grade_up34(array,dim)
                character array(1:2,1:2,1:2)
                integer,optional::dim
          end function
end interface

interface hpf_alignment 
          subroutine hpf_alignment1(alignee,lb,ub,stride,axis_map,identity_map,dynamic,ncopies)
                integer alignee
                integer,optional:: lb
                integer,optional:: ub
                integer,optional:: stride
                integer,optional:: axis_map
                logical,optional:: identity_map
                logical,optional:: dynamic
                integer,optional:: ncopies      
          end subroutine
          subroutine hpf_alignment2(alignee,lb,ub,stride,axis_map,identity_map,dynamic,ncopies)
                integer alignee(1:2)
                integer,optional:: lb
                integer,optional:: ub
                integer,optional:: stride
                integer,optional:: axis_map
                logical,optional:: identity_map
                logical,optional:: dynamic
                integer,optional:: ncopies
          end subroutine
          subroutine hpf_alignment3(alignee,lb,ub,stride,axis_map,identity_map,dynamic,ncopies)
                integer alignee(1:2,1:2)
                integer,optional:: lb
                integer,optional:: ub
                integer,optional:: stride
                integer,optional:: axis_map
                logical,optional:: identity_map
                logical,optional:: dynamic
                integer,optional:: ncopies
          end subroutine
          subroutine hpf_alignment4(alignee,lb,ub,stride,axis_map,identity_map,dynamic,ncopies)
                integer alignee(1:2,1:2,1:2)
                integer,optional:: lb
                integer,optional:: ub
                integer,optional:: stride
                integer,optional:: axis_map
                logical,optional:: identity_map
                logical,optional:: dynamic
                integer,optional:: ncopies
          end subroutine
          subroutine hpf_alignment11(alignee,lb,ub,stride,axis_map,identity_map, dynamic,ncopies)
                real alignee
                integer,optional:: lb
                integer,optional:: ub
                integer,optional:: stride
                integer,optional:: axis_map
                logical,optional:: identity_map
                logical,optional:: dynamic
                integer,optional:: ncopies
          end subroutine
          subroutine hpf_alignment12(alignee,lb,ub,stride,axis_map,identity_map, dynamic,ncopies)
                real alignee(1:2)
                integer,optional:: lb
                integer,optional:: ub
                integer,optional:: stride
                integer,optional:: axis_map
                logical,optional:: identity_map
                logical,optional:: dynamic
                integer,optional:: ncopies
          end subroutine
          subroutine hpf_alignment13(alignee,lb,ub,stride,axis_map,identity_map, dynamic,ncopies)
                real alignee(1:2,1:2)
                integer,optional:: lb
                integer,optional:: ub
                integer,optional:: stride
                integer,optional:: axis_map
                logical,optional:: identity_map
                logical,optional:: dynamic
                integer,optional:: ncopies
          end subroutine
          subroutine hpf_alignment14(alignee,lb,ub,stride,axis_map,identity_map, dynamic,ncopies)
                real alignee(1:2,1:2,1:2)
                integer,optional:: lb
                integer,optional:: ub
                integer,optional:: stride
                integer,optional:: axis_map
                logical,optional:: identity_map
                logical,optional:: dynamic
                integer,optional:: ncopies
          end subroutine
          subroutine hpf_alignment21(alignee,lb,ub,stride,axis_map,identity_map, dynamic,ncopies)
                complex alignee
                integer,optional:: lb
                integer,optional:: ub
                integer,optional:: stride
                integer,optional:: axis_map
                logical,optional:: identity_map
                logical,optional:: dynamic
                integer,optional:: ncopies
          end subroutine
          subroutine hpf_alignment22(alignee,lb,ub,stride,axis_map,identity_map, dynamic,ncopies)
                complex alignee(1:2)
                integer,optional:: lb
                integer,optional:: ub
                integer,optional:: stride
                integer,optional:: axis_map
                logical,optional:: identity_map
                logical,optional:: dynamic
                integer,optional:: ncopies
          end subroutine
          subroutine hpf_alignment23(alignee,lb,ub,stride,axis_map,identity_map,dynamic,ncopies)
                complex alignee(1:2,1:2)
                integer,optional:: lb
                integer,optional:: ub
                integer,optional:: stride
                integer,optional:: axis_map
                logical,optional:: identity_map
                logical,optional:: dynamic
                integer,optional:: ncopies
          end subroutine
          subroutine hpf_alignment24(alignee,lb,ub,stride,axis_map,identity_map,dynamic,ncopies)
                complex alignee(1:2,1:2,1:2)
                integer,optional:: lb
                integer,optional:: ub
                integer,optional:: stride
                integer,optional:: axis_map
                logical,optional:: identity_map
                logical,optional:: dynamic
                integer,optional:: ncopies
          end subroutine
end interface

interface hpf_template
          subroutine hpf_template1(alignee,template_rank,lb,ub,stride,axis_type,axis_info,number_aligned,dynamic)
                integer alignee
                integer,optional::template_rank  
                integer,optional:: lb
                integer,optional:: ub
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: number_aligned
                logical,optional:: dynamic
          end subroutine
          subroutine hpf_template2(alignee,template_rank,lb,ub,stride,axis_type,axis_info,number_aligned,dynamic)
                integer alignee(1:2)
                integer,optional::template_rank  
                integer,optional:: lb
                integer,optional:: ub
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: number_aligned
                logical,optional:: dynamic
          end subroutine
          subroutine hpf_template3(alignee,template_rank,lb,ub,stride,axis_type, axis_info,number_aligned,dynamic)
                integer alignee(1:2,1:2)
                integer,optional::template_rank
                integer,optional:: lb
                integer,optional:: ub
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: number_aligned
                logical,optional:: dynamic
          end subroutine
          subroutine hpf_template4(alignee,template_rank,lb,ub,stride,axis_type,axis_info,number_aligned,dynamic)
                integer alignee(1:2,1:2,1:2)
                integer,optional::template_rank
                integer,optional:: lb
                integer,optional:: ub
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: number_aligned
                logical,optional:: dynamic
          end subroutine
          subroutine hpf_templatei21(alignee,template_rank,lb,ub,stride,axis_type, axis_info,number_aligned,dynamic)
                real alignee
                integer,optional::template_rank
                integer,optional:: lb
                integer,optional:: ub
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: number_aligned
                logical,optional:: dynamic
          end subroutine
          subroutine hpf_template22(alignee,template_rank,lb,ub,stride,axis_type, axis_info,number_aligned,dynamic)
                real alignee(1:2)
                integer,optional::template_rank
                integer,optional:: lb
                integer,optional:: ub
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: number_aligned
                logical,optional:: dynamic
          end subroutine
          subroutine hpf_template23(alignee,template_rank,lb,ub,stride,axis_type, axis_info,number_aligned,dynamic)
                real alignee(1:2,1:2)
                integer,optional::template_rank
                integer,optional:: lb
                integer,optional:: ub
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: number_aligned
                logical,optional:: dynamic
          end subroutine
          subroutine hpf_template24(alignee,template_rank,lb,ub,stride,axis_type, axis_info,number_aligned,dynamic)
                real alignee(1:2,1:2,1:2)
                integer,optional::template_rank
                integer,optional:: lb
                integer,optional:: ub
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: number_aligned
                logical,optional:: dynamic
          end subroutine
end interface

interface hpf_distribution
         subroutine hpf_distributioni1(distributee,axis_type, axis_info,processors_rank,processors_shape)
                integer distributee 
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: processors_rank
                integer,optional:: processors_shape(1:2)
          end subroutine
         subroutine hpf_distribution2(distributee,axis_type, axis_info,processors_rank,processors_shape)
                integer distributee(1:2) 
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: processors_rank
                integer,optional:: processors_shape(1:2)
          end subroutine
         subroutine hpf_distribution3(distributee,axis_type, axis_info,processors_rank,processors_shape)
                integer distributee(1:2,1:2) 
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: processors_rank
                integer,optional:: processors_shape(1:2)
          end subroutine
         subroutine hpf_distribution4(distributee,axis_type, axis_info,processors_rank,processors_shape)
                integer distributee(1:2,1:2,1:2) 
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: processors_rank
                integer,optional:: processors_shape(1:2)
          end subroutine
         subroutine hpf_distribution21(distributee,axis_type, axis_info,processors_rank,processors_shape)
                real distributee 
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: processors_rank
                integer,optional:: processors_shape(1:2)
          end subroutine
         subroutine hpf_distribution22(distributee,axis_type, axis_info,processors_rank,processors_shape)
                real  distributee(1:2) 
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: processors_rank
                integer,optional:: processors_shape(1:2)
          end subroutine
         subroutine hpf_distribution23(distributee,axis_type, axis_info,processors_rank,processors_shape)
                real distributee(1:2,1:2) 
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: processors_rank
                integer,optional:: processors_shape(1:2)
          end subroutine
         subroutine hpf_distribution24(distributee,axis_type, axis_info,processors_rank,processors_shape)
                real distributee(1:2,1:2,1:2) 
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: processors_rank
                integer,optional:: processors_shape(1:2)
          end subroutine
         subroutine hpf_distribution31(distributee,axis_type, axis_info,processors_rank,processors_shape)
                complex distributee 
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: processors_rank
                integer,optional:: processors_shape(1:2)
          end subroutine
         subroutine hpf_distribution32(distributee,axis_type, axis_info,processors_rank,processors_shape)
                complex distributee(1:2)
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: processors_rank
                integer,optional:: processors_shape(1:2)
          end subroutine
         subroutine hpf_distribution33(distributee,axis_type, axis_info,processors_rank,processors_shape)
                complex distributee(1:2,1:2)
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: processors_rank
                integer,optional:: processors_shape(1:2)
          end subroutine
         subroutine hpf_distribution34(distributee,axis_type, axis_info,processors_rank,processors_shape)
                complex distributee(1:2,1:2,1:2)
                character,optional:: axis_type
                integer,optional:: axis_info
                integer,optional:: processors_rank
                integer,optional:: processors_shape(1:2)
          end subroutine
end interface

interface iall
          type (in_type) function iall1(array,dim,mask) 
                 integer array(1:2)
                 integer,optional:: dim
                 logical,optional:: mask
          end function 
          type (in_type) function iall2(array,dim,mask) 
                 integer array(1:2,1:2)
                 integer,optional:: dim 
                 logical,optional:: mask 
          end function 
          type (in_type) function iall3(array,dim,mask) 
                 integer array(1:2,1:2,1:2)
                 integer,optional:: dim 
                 logical,optional:: mask 
          end function 
end interface

interface iall_prefix
          type (in_type) function iall_prefix1(array,dim,mask,segment,exclusive)
                 integer array(1:2)     
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive   
          end function 
          type (in_type) function iall_prefix1(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2)     
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)         
                 logical,optional::segment(1:2,1:2) 
                 logical,optional::exclusive   
          end function 
          type (in_type) function iall_prefix1(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2,1:2)     
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)         
                 logical,optional::segment(1:2,1:2,1:2) 
                 logical,optional::exclusive   
          end function 
end interface

interface iall_scatter
          type (in_type) function iall_scatter1(array,base,indx1,mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2)
                logical,optional::mask(1:2) 
          end function
          type (in_type) function iall_scatter2(array,base,indx1,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2)
                logical,optional::mask(1:2,1:2) 
          end function 
          type (in_type) function iall_scatter3(array,base,indx1,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2) 
          end function 
          type (in_type) function iall_scatter21(array,base,indx1,indx2,mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2),indx2(1:2)
                logical,optional::mask(1:2) 
          end function 
          type (in_type) function iall_scatter22(array,base,indx1,indx2,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2),indx2(1:2,1:2)
                logical,optional::mask(1:2,1:2) 
          end function 
          type (in_type) function iall_scatter23(array,base,indx1,indx2,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2),indx2(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2) 
          end function 
          type (in_type) function iall_scatter31(array,base,indx1,indx2,indx3,mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2),indx2(1:2),indx3(1:2)
                logical,optional::mask(1:2) 
          end function 
          type (in_type) function iall_scatter32(array,base,indx1,indx2,indx3,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2),indx2(1:2,1:2),indx3(1:2,1:2)
                logical,optional::mask(1:2,1:2) 
          end function 
          type (in_type) function iall_scatter33(array,base,indx1,indx2,indx3,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2),indx2(1:2,1:2,1:2),indx3(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2) 
          end function 
          type (in_type) function iall_scatter41(array,base,indx1,indx2,indx3,indx4,mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2),indx2(1:2),indx3(1:2),indx4(1:2)
                logical,optional::mask(1:2) 
          end function 
          type (in_type) function iall_scatter42(array,base,indx1,indx2,indx3,indx4 ,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2),indx2(1:2,1:2),indx3(1:2,1:2),indx4(1:2,1:2)
                logical,optional::mask(1:2,1:2) 
          end function 
          type (in_type) function iall_scatter43(array,base,indx1,indx2,indx3,indx4,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2),indx2(1:2,1:2,1:2),indx3(1:2,1:2,1:2),indx4(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2) 
          end function 
end interface

interface iall_suffix
          type (in_type) function iall_suffix1(array,dim,mask,segment,exclusive)
                 integer array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function iall_suffix2(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2) 
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function iall_suffix3(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2,1:2) 
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function

end interface

interface iany
          type (in_type) function iany1(array,dim,mask)
                  integer array(1:2)
                  integer,optional::dim
                  logical,optional::mask(1:2) 
          end function
          type (in_type) function iany2(array,dim,mask)
                  integer array(1:2,1:2)
                  integer,optional::dim
                  logical,optional::mask(1:2,1:2) 
          end function
          type (in_type) function iany3(array,dim,mask)
                  integer array(1:2,1:2,1:2)
                  integer,optional::dim
                  logical,optional::mask(1:2,1:2,1:2) 
          end function
end interface

interface iany_prefix
          type (in_type) function iany_prefix1(array,dim,mask,segment,exclusive)
                 integer array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function iany_prefix1(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function 
          type (in_type) function iany_prefix1(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function 
end interface

interface iany_scatter
          type (in_type) function iany_scatter1(array,base,indx1,mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2)
                logical,optional::mask(1:2)
          end function
          type (in_type) function iany_scatter2(array,base,indx1,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2)
                logical,optional::mask(1:2,1:2)
          end function
          type (in_type) function iany_scatter3(array,base,indx1,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2)
          end function
          type (in_type) function iany_scatter21(array,base,indx1,indx2,mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2),indx2(1:2)
                logical,optional::mask(1:2)
          end function
          type (in_type) function iany_scatter22(array,base,indx1,indx2,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2),indx2(1:2,1:2)
                logical,optional::mask(1:2,1:2)
          end function
          type (in_type) function iany_scatter23(array,base,indx1,indx2,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2),indx2(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2)
          end function
          type (in_type) function iany_scatter31(array,base,indx1,indx2,indx3,mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2),indx2(1:2),indx3(1:2)
                logical,optional::mask(1:2)
          end function
          type (in_type) function iany_scatter32(array,base,indx1,indx2,indx3,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2),indx2(1:2,1:2),indx3(1:2,1:2)
                logical,optional::mask(1:2,1:2)
          end function
          type (in_type) function iany_scatter33(array,base,indx1,indx2,indx3,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2),indx2(1:2,1:2,1:2),indx3(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2)
          end function
          type (in_type) function iany_scatter41(array,base,indx1,indx2,indx3,indx4,mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2),indx2(1:2),indx3(1:2),indx4(1:2)
                logical,optional::mask(1:2)
          end function
          type (in_type) function iany_scatter42(array,base,indx1,indx2,indx3,indx4 ,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2),indx2(1:2,1:2),indx3(1:2,1:2),indx4(1:2,1:2)
                logical,optional::mask(1:2,1:2)
          end function
          type (in_type) function iany_scatter43(array,base,indx1,indx2,indx3,indx4,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2),indx2(1:2,1:2,1:2),indx3(1:2,1:2,1:2),indx4(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2)
          end function
end interface
 
interface iany_suffix
          type (in_type) function iany_suffix1(array,dim,mask,segment,exclusive)
                 integer array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function iany_suffix2(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function iany_suffix3(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function
end interface

interface iparity
          type (in_type) function iparity1(array,dim,mask)
                  integer array(1:2)
                  integer,optional::dim
                  logical,optional::mask(1:2)
          end function
          type (in_type) function iparity2(array,dim,mask)
                  integer array(1:2,1:2)
                  integer,optional::dim
                  logical,optional::mask(1:2,1:2)
          end function
          type (in_type) function iparity3(array,dim,mask)
                  integer array(1:2,1:2,1:2)
                  integer,optional::dim
                  logical,optional::mask(1:2,1:2,1:2)
          end function
end interface

interface iparity_prefix
          type (in_type) function iparity_prefix1(array,dim,mask,segment,exclusive)
                 integer array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function iparity_prefix2(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function iparity_prefix3(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function
end interface
interface iparity_scatter
          type (in_type) function iparity_scatter1(array,base,indx1,mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2)
                logical,optional::mask(1:2)
          end function
          type (in_type) function iparity_scatter2(array,base,indx1,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2)
                logical,optional::mask(1:2,1:2)
          end function
          type (in_type) function iparity_scatter3(array,base,indx1,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2)
          end function
          type (in_type) function iparity_scatter21(array,base,indx1,indx2,mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2),indx2(1:2)
                logical,optional::mask(1:2)
          end function
          type (in_type) function iparity_scatter22(array,base,indx1,indx2,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2),indx2(1:2,1:2)
                logical,optional::mask(1:2,1:2)
          end function
          type (in_type) function iparity_scatter23(array,base,indx1,indx2,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2),indx2(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2)
          end function
          type (in_type) function iparity_scatter31(array,base,indx1,indx2,indx3,mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2),indx2(1:2),indx3(1:2)
                logical,optional::mask(1:2)
          end function
          type (in_type) function iparity_scatter32(array,base,indx1,indx2,indx3,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2),indx2(1:2,1:2),indx3(1:2,1:2)
                logical,optional::mask(1:2,1:2)
          end function
          type (in_type) function iparrity_scatter33(array,base,indx1,indx2,indx3,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2),indx2(1:2,1:2,1:2),indx3(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2)
          end function
          type (in_type) function iparity_scatter41(array,base,indx1,indx2,indx3,indx4,mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2),indx2(1:2),indx3(1:2),indx4(1:2)
                logical,optional::mask(1:2)
          end function
          type (in_type) function iparity_scatter42(array,base,indx1,indx2,indx3,indx4 ,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2),indx2(1:2,1:2),indx3(1:2,1:2),indx4(1:2,1:2)
                logical,optional::mask(1:2,1:2)
          end function
          type (in_type) function iparity_scatter43(array,base,indx1,indx2,indx3,indx4,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2),indx2(1:2,1:2,1:2),indx3(1:2,1:2,1:2),indx4(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2)
          end function
end interface

interface iparity_suffix
          type (in_type) function iparity_suffix1(array,dim,mask,segment,exclusive)
                 integer array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function iparity_suffix2(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function iparity_suffix3(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function
end interface

interface leadz
          type (in_type) function leadz(i) 
                  integer i 
          end function
end interface 

interface maxval_prefix
          type (in_type) function maxval_prefix1(array,dim,mask,segment,exclusive)
                 integer array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function maxval_prefix2(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function maxval_prefix3(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function
end interface
interface maxval_scatter
          type (in_type) function maxval_scatter1(array,base,indx1,mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2)
                logical,optional::mask(1:2)
          end function
          type (in_type) function maxval_scatter2(array,base,indx1,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2)
                logical,optional::mask(1:2,1:2)
          end function
          type (in_type) function maxval_scatter3(array,base,indx1,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2)
          end function
          type (in_type) function maxval_scatter21(array,base,indx1,indx2,mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2),indx2(1:2)
                logical,optional::mask(1:2)
          end function
          type (in_type) function maxval_scatter22(array,base,indx1,indx2,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2),indx2(1:2,1:2)
                logical,optional::mask(1:2,1:2)
          end function
          type (in_type) function maxval_scatter23(array,base,indx1,indx2,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2),indx2(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2)
          end function
          type (in_type) function maxval_scatter31(array,base,indx1,indx2,indx3,mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2),indx2(1:2),indx3(1:2)
                logical,optional::mask(1:2)
          end function
          type (in_type) function maxval_scatter32(array,base,indx1,indx2,indx3 ,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2),indx2(1:2,1:2),indx3(1:2,1:2)
                logical,optional::mask(1:2,1:2)
          end function
          type (in_type) function maxval_scatter33(array,base,indx1,indx2,indx3,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2),indx2(1:2,1:2,1:2),indx3(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2)
          end function
          type (in_type) function maxval_scatter41(array,base,indx1,indx2,indx3,indx4,mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2),indx2(1:2),indx3(1:2),indx4(1:2)
                logical,optional::mask(1:2)
          end function
          type (in_type) function maxval_scatter42(array,base,indx1,indx2,indx3,indx4 ,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2),indx2(1:2,1:2),indx3(1:2,1:2),indx4(1:2,1:2)
                logical,optional::mask(1:2,1:2)
          end function
          type (in_type) function maxval_scatter43(array,base,indx1,indx2,indx3,indx4,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2),indx2(1:2,1:2,1:2),indx3(1:2,1:2,1:2),indx4(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2)
          end function
end interface

interface maxval_suffix
          type (in_type) function maxval_suffix1(array,dim,mask,segment,exclusive)
                 integer array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function maxval_suffix2(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function maxval_suffix3(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function
end interface

interface minval_prefix
          type (in_type) function minval_prefix1(array,dim,mask,segment,exclusive)
                 integer array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function minval_prefix2(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function minval_prefix3(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function
end interface
interface minval_scatter
          type (in_type) function minval_scatter1(array,base,indx1,mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2)
                logical,optional::mask(1:2)
          end function
          type (in_type) function minval_scatter2(array,base,indx1,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2)
                logical,optional::mask(1:2,1:2)
          end function
          type (in_type) function minval_scatter3(array,base,indx1,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2)
          end function
          type (in_type) function minval_scatter21(array,base,indx1,indx2,mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2),indx2(1:2)
                logical,optional::mask(1:2)
          end function
          type (in_type) function minval_scatter22(array,base,indx1,indx2,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2),indx2(1:2,1:2)
                logical,optional::mask(1:2,1:2)
          end function
          type (in_type) function minval_scatter23(array,base,indx1,indx2,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2),indx2(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2)
          end function
          type (in_type) function minval_scatter31(array,base,indx1,indx2,indx3, mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2),indx2(1:2),indx3(1:2)
                logical,optional::mask(1:2)
          end function
          type (in_type) function minval_scatter32(array,base,indx1,indx2,indx3 ,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2),indx2(1:2,1:2),indx3(1:2,1:2)
                logical,optional::mask(1:2,1:2)
          end function
          type (in_type) function minval_scatter33(array,base,indx1,indx2,indx3,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2),indx2(1:2,1:2,1:2),indx3(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2)
          end function
          type (in_type) function minval_scatter41(array,base,indx1,indx2,indx3,indx4,mask)
                integer array(1:2)
                integer base(1:2)
                integer indx1(1:2),indx2(1:2),indx3(1:2),indx4(1:2)
                logical,optional::mask(1:2)
          end function
          type (in_type) function minval_scatter42(array,base,indx1,indx2,indx3,indx4 ,mask)
                integer array(1:2,1:2)
                integer base(1:2,1:2)
                integer indx1(1:2,1:2),indx2(1:2,1:2),indx3(1:2,1:2),indx4(1:2,1:2)
                logical,optional::mask(1:2,1:2)
          end function
          type (in_type) function minval_scatter43(array,base,indx1,indx2,indx3,indx4,mask)
                integer array(1:2,1:2,1:2)
                integer base(1:2,1:2,1:2)
                integer indx1(1:2,1:2,1:2),indx2(1:2,1:2,1:2),indx3(1:2,1:2,1:2),indx4(1:2,1:2,1:2)
                logical,optional::mask(1:2,1:2,1:2)
          end function
end interface
interface minval_suffix
          type (in_type) function minval_suffix1(array,dim,mask,segment,exclusive)
                 integer array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function minval_suffix2(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function minval_suffix3(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function
end interface

interface parity
          type (in_type) function parity1(mask,dim)
                  logical mask(1:2)
                  integer,optional::dim              
          end function
          type (in_type) function parity2(mask,dim)
                  logical mask(1:2,1:2)              
                  integer,optional::dim
          end function
          type (in_type) function parity3(mask,dim)
                  logical mask(1:2,1:2,1:2)              
                  integer,optional::dim
          end function
end interface


interface parity_prefix
          type (in_type) function parity_prefix1(mask,dim,segment,exclusive)
                  logical mask(1:2)
                  integer,optional::dim
                  logical,optional::segment(1:2)
                  logical exclusive
          end function
          type (in_type) function parity_prefix2(mask,dim,segment,exclusive)
                  logical mask(1:2,1:2)
                  integer,optional::dim
                  logical,optional::segment(1:2,1:2)
                  logical exclusive
          end function
          type (in_type) function parity_prefix3(mask,dim,segment,exclusive)
                  logical mask(1:2,1:2,1:2)
                  integer,optional::dim
                  logical,optional::segment(1:2,1:2,1:2)
                  logical exclusive
          end function
end interface

interface parity_suffix
          type (in_type) function parity_suffix1(mask,dim,segment,exclusive)
                  logical mask(1:2)
                  integer,optional::dim
                  logical,optional::segment(1:2)
                  logical exclusive
          end function
          type (in_type) function parity_suffix2(mask,dim,segment,exclusive)
                  logical mask(1:2,1:2)
                  integer,optional::dim
                  logical,optional::segment(1:2,1:2)
                  logical exclusive
          end function
          type (in_type) function parity_suffix3(mask,dim,segment,exclusive)
                  logical mask(1:2,1:2,1:2)
                  integer,optional::dim
                  logical,optional::segment(1:2,1:2,1:2)
                  logical exclusive
          end function
end interface

interface popcnt
          type (in_type) function popcnt(i)
                   integer i         
          end function
end interface

interface poppar
          type (in_type) function poppar(i)         
                   integer i
          end function
end interface

interface product_prefix
          type (in_type) function product_prefix1(array,dim,mask,segment,exclusive)
                 integer array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function product_prefix2(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function product_prefix3(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function product_prefix21(array,dim,mask,segment,exclusive)
                 real array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function product_prefix22(array,dim,mask,segment,exclusive)
                 real array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function product_prefix23(array,dim,mask,segment,exclusive)
                 real array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function product_prefix31(array,dim,mask,segment,exclusive)
                 complex array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function product_prefix32(array,dim,mask,segment,exclusive)
                 complex array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function product_prefix33(array,dim,mask,segment,exclusive)
                 complex array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function

end interface

interface product_suffix
          type (in_type) function product_suffix1(array,dim,mask,segment,exclusive)
                 integer array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function product_suffix2(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function product_suffix3(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function product_suffix21(array,dim,mask,segment,exclusive)
                 real array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function product_suffix22(array,dim,mask,segment,exclusive)
                 real array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function product_suffix23(array,dim,mask,segment,exclusive)
                 real array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function product_suffix31(array,dim,mask,segment,exclusive)
                 complex array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function product_suffix32(array,dim,mask,segment,exclusive)
                 complex array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function product_suffix33(array,dim,mask,segment,exclusive)
                 complex array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function

end interface
interface sum_prefix
          type (in_type) function sum_prefix1(array,dim,mask,segment,exclusive)
                 integer array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function sum_prefix2(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function sum_prefix3(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function sum_prefix21(array,dim,mask,segment,exclusive)
                 real array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function sum_prefix22(array,dim,mask,segment,exclusive)
                 real array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function sum_prefix23(array,dim,mask,segment,exclusive)
                 real array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function sum_prefix31(array,dim,mask,segment,exclusive)
                 complex array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function sum_prefix32(array,dim,mask,segment,exclusive)
                 complex array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function sum_prefix33(array,dim,mask,segment,exclusive)
                 complex array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function

end interface

interface sum_suffix
          type (in_type) function sum_suffix1(array,dim,mask,segment,exclusive)
                 integer array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function sum_suffix2(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function sum_suffix3(array,dim,mask,segment,exclusive)
                 integer array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function sum_suffix21(array,dim,mask,segment,exclusive)
                 real array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function sum_suffix22(array,dim,mask,segment,exclusive)
                 real array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function sum_suffix23(array,dim,mask,segment,exclusive)
                 real array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function sum_suffix31(array,dim,mask,segment,exclusive)
                 complex array(1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2)
                 logical,optional::segment(1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function sum_suffix32(array,dim,mask,segment,exclusive)
                 complex array(1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2)
                 logical,optional::segment(1:2,1:2)
                 logical,optional::exclusive
          end function
          type (in_type) function sum_suffix33(array,dim,mask,segment,exclusive)
                 complex array(1:2,1:2,1:2)
                 integer,optional::dim
                 logical,optional::mask(1:2,1:2,1:2)
                 logical,optional::segment(1:2,1:2,1:2)
                 logical,optional::exclusive
          end function

end interface



end module
