A quick and dirty example for a wrapper would be the following:
program omhulsel
implicit none
print *, 'f(1.,2.,3.) = ', f(1.,2.,3.)
print *, 'g(1.) = ', g(1.)
print *, 'g(1.,2.,3.) = ', g(1.,2.,3.)
print *, 'g(1.) = ', g(1.)
print *, 'g(1.,b=0.) = ', g(1.,b=0.)
contains
real function f(x,y,z)
real :: x, y, z
f = x**2 + y**2 + z**2
end function
real function g(x,a,b)
real :: x
real, optional :: a, b
real :: par_a = 0, par_b = 0
if (present(a)) par_a = a
if (present(b)) par_b = b
g = f(x,par_a,par_b)
end function
end program
The function g
retains its parameters par_a
and par_b
(they get the SAVE
attribute) which can also be modified by passing along optional arguments.