Re: Function argument



How about something like this (I prefer the Fortran 90/95 facilities,
but this could be done via COMMON blocks too):

module mod_ab
real :: a, b
contains
subroutine setab(anew,bnew)
a = anew
b = bnew
end subroutine

real function f(x)
f = f_enhanced(x,a)
end function
real function g(x)
... similar
end function

end module

That hides the fact that parameters a and b are required for the
actual computation. The subroutine T can be used once you have
set a and b via the extra subroutine setab.

(Instead of simply setting a and b, they can of course be computed at
a convenient moment)

Regards,

Arjen

.



Relevant Pages

  • Help Required: Output error
    ... defines the matrix multiplication operation as a real function, ... latter one defines it as a subroutine. ... IMPLICIT NONE ... end function inv ...
    (comp.lang.fortran)
  • Unresolved Text Symbol
    ... My fortran 90 program has a real function and a subroutine contained in ... The subroutine, which is called in the main program, ... which the compiler is supposed to link during compilation. ... The real function is called pla, and the compiler says that pla is an ...
    (comp.lang.fortran)
  • Re: error with trapzd(numerical recipe)
    ... i use the same subroutine to find the answer of double integral. ... implicit none ... real function func ...
    (comp.lang.fortran)
  • Re: Porting HP C from Alpha to Itanium - __DIVG_C
    ... John Reagan wrote: ... but not if it was passed as a subroutine argument. ... arguments are only byte aligned if you are packing your COMMON blocks. ...
    (comp.os.vms)
  • Re: [g77] Passing parameter statements through common block
    ... I am using the subroutine below in this short demo program below ... >As long as the arrays y and out are the same dimension it works fine. ... common blocks to avoid making errors when reproducing the declarations). ...
    (comp.lang.fortran)