Re: gfortran & directory routines



On Thu, 18 Aug 2011 14:31:15 -0700, Mike Prager
<mprager@xxxxxxxxxxxxxxxxx> wrote:

On Thu, 18 Aug 2011 08:46:05 -0400, nospam@xxxxxxxxxxxxx (Richard
Maine) wrote:

[...]

That seems slightly odd. I can understand requiring declarations of the
function return types (assuming they are indeed functions instead of
subroutines). But it seems odd to require the external declaration. I
might go so far as to say that it sounds like a violation of the
standard. Unless there are both external and intrinsic procedures of the
same name, you should not need an explicit external or intrinsic
declaration. Declaring it the wrong way can hurt (i.e. declaring it as
an external when the compiler has it as an intrinsic), but omitting the
intrnsic and external declarations should be fine unless you are doing
some of the slightly rare things where they happen to be required
(notably, passing them as actual arguments).

Don't blame the compiler. It has the functions in a supplied library,
and with "implicit none", it required me to declare the return types.
I added the "external" designator on my own.

Well, maybe I spoke too soon. Compilation fails without the external
attribute. The declaration is in the top level of a module. The
functions are used in various contained module procedures.

Some of the code looks like this:

module fileutils
use strutils, only : strtrans
implicit none
integer, external :: getcwd, chdir

contains
!---------------------------------------------------------------------------------------------
subroutine fullpathMM(filename_in, fullname, ierror)
! Given a file name, returns the full path with all
! path separators converted to "/"
implicit none
character(len=*), intent(IN) :: filename_in
character(len=*), intent(OUT) :: fullname
character(len=512) :: filename, curdir, filedir
integer, intent(OUT) :: ierror
integer :: dummy, i
logical :: file_exists

.



Relevant Pages

  • Re: decimal to binary
    ... CHARACTER*137438953472 declaration as required by a solution I suggested ... it seems that Fortran is also overly restricted in its string lengths. ... A program requiring more doesn't conform to the standard. ...
    (comp.lang.fortran)
  • Re: Passing module procedures to external procedures -- type issues
    ... explicit declaration for a subroutine. ... I cannot agree that "no declaration...is also explicit declaration". ... That also has nothing in particular to do with subroutines; ... wording of the standard. ...
    (comp.lang.fortran)
  • Re: First attempt at writing simple Module
    ... I'm trying to factor out the declaration and setting of a bunch of variables ... that a suite of programs will need, as well as defining some subroutines ... Package manage to become visible to main (although that's exactly what I ... sub import { ...
    (perl.beginners)
  • declaring module functions in the module itself
    ... I have a module which contains several subroutines and a function. ... declaration of the function. ... When I try to compile, intel fortran complains that the type ... My compromise is to get rid of the declaration of the function at the ...
    (comp.lang.fortran)