Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 662673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:24:16+00:00 2026-05-13T23:24:16+00:00

In my Fortran code I made the following call to the dnrm2 routine: d

  • 0

In my Fortran code I made the following call to the dnrm2 routine:

d = dnrm2(n, ax, 1)

Just a simple call that would return me a double precision result.

The question is, should I declare the function at the start of my script? I found that if I don’t declare it, when I compile the code in 32 bit Windows, then the result is correct.

But if I compile the code in 64 bit Windows, then the result isn’t be correct.

Why is this so? Must an external routine always be declared in Fortran?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:24:16+00:00Added an answer on May 13, 2026 at 11:24 pm

    If you don’t correctly describe your subprograms (subroutines and functions) to a calling program, the compiler may not correctly call them. Fortran compiles each unit separately, so the compiler doesn’t “know”, by default, about the characteristics of other subprograms. There are several ways that you can describe/declare a subprogram in Fortran 90/95/2003.

    The easiest and best method is to place your subprograms into a module and then “use” that module in the calling program. This automatically makes the interface known to the compiler and will enable the compiler to check the consistency of actual arguments (in the call) and dummy arguments in the subprogram. It will also make known the return type of a function. The various subprograms in a module have their interfaces known to each other.

    You can also write an “interface” containing a subprogram declaration that matches the declarations of the actual subprogram. (This method can be very similar to the style of including header files in C.) This method is more work and prone to error because you have to manually maintain consistency between the actual subprogram and interface whenever changes are made. The interface method is useful when you don’t have the code to the subprogram or the subprogram is written in a language other than Fortran.

    Or you can simply declare a function name to specify the type-return of the function, but this won’t give you any checking of the arguments. In my opinion this method is weaker since having the compiler check argument consistency eliminates a major class of programming mistakes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing code that will call a C function from Fortran using Fortran's C
I would like to compile fortran code on mac such that it does not
I'm working with Fortran code that has to work with various Fortran compilers (and
I have the following FORTRAN code which I need to convert to C or
I am trying to call out to a legacy dll compiled from FORTRAN code.
I'm working with a legacy + academic + numerical fortran-77 code that requires g77
I would have dared say that the numeric values computed by Fortran and C++
My boss just asked me to integrate his bosses old Fortran code into a
I have a library that contains a significant amount of fortran code in it,
The following Fortran Code: module Mod implicit none TYPE derivedtype procedure(procInterface),POINTER,PASS::f END TYPE derivedtype

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.