Re: How can I simply use (old) routines?



Arno <arnoinperu@xxxxxxxxxxx> wrote:

But the compiler does know what the return value of the function is, as
the function is said to be an integer function:
integer function set_number(i)

So, why do I have to specify that again in main.f90?

No the compiler does not know that *WHEN COMPILING THE MAIN PROGRAM". It
is fundamental to the design external procedures that they can be
compiled separately. Your function could, in principle, be in a separate
file - one that you haven't even written yet when compiling the main
program. So the compiler doesn't get to "look" at the function when
compiling the main. The standard is written from that viewpoint.

Internal and modul functions, introduced in f90, are different. In those
cases, the compiler does know about the function when compiling the
main. If you think that is a better way for things to be, I agree; I
recommend using module or internal procedures instead of external ones
in most cases. But external procedures were the only option before f90,
so if you have old code and don't want to change it, then you have to
play by the rules for external procedures.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.



Relevant Pages

  • Re: Undefined reference error when linking slatec.f90 library
    ... When compiling program prog.f90 calling this lib, I get messages of undefined routines: ... These message don't occur when using the original F77 version which is split into individual files. ... The F77 version fails on some of the test programs with "fatal errors" while the F90 version only produces some minor fails on testing when using optimisation options. ...
    (comp.lang.fortran)
  • Re: Undefined reference error when linking slatec.f90 library
    ... I have found a strange behaviour when binding the F90 version of the ... gfortran -c slatec.f90 ... When compiling program prog.f90 calling this lib, ... into individual files which, possibly, may be a solution (but why does ...
    (comp.lang.fortran)
  • Undefined reference error when linking slatec.f90 library
    ... When compiling program prog.f90 calling this lib, I get messages of undefined routines: ... These message don't occur when using the original F77 version which is split into individual files. ... Since on my system there is no "f90split" utility, I don't see any convenient way to split the files into individual files which, possibly, may be a solution (but why does it matter whether the routines are individual files or a single file?) ... The F77 version fails on some of the test programs with "fatal errors" while the F90 version only produces some minor fails on testing when using optimisation options. ...
    (comp.lang.fortran)
  • Re: Fortran module checking
    ... Modules must be compiled *prior* to compiling the ... there was a missing dependency in the makefile. ... $(F90) -o main main.o modules.o ...
    (comp.lang.fortran)
  • Re: busting sp datatypes
    ... g95 0.91 are stopping the all Fortran version from compiling. ... integer function comparebind ... know if other compilers might add padding. ...
    (comp.lang.fortran)