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

  • Home
  • SEARCH
  • 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 1041355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:20:25+00:00 2026-05-16T15:20:25+00:00

I am linking some fortran code (f90) from matlab using mex and I am

  • 0

I am linking some fortran code (f90) from matlab using mex and I am having matlab freeze occasionally.

In the past, I had freezing happening due to mismatch between data types (say integer*4 vs integer*8).

The code I am linking has many implicitly defined variables, so I am wondering if there is a hidden data type conflict that only occurs occasionally.

To rule out data type mismatch as the cause of the freeze, I would like to have the compiler requiring all variables to be explicitly declared.

Questions:

  1. How do I get gfortran to require all variables to be explicitly declared at compile time? Failing that, is there any way to at least get warnings?

  2. Is a “real” data type interpreted by gfortran as a specific kind in all architectures? If so, which one is it (real*4, real*8, …)?

  3. Is there anyway to force gfortran to interpret the “real” data type as a specific kind, say “real*4”?

  4. Any ideas on what makes the fortran code to freeze when called from a mex compiled routine in matlab (other than data type mismatches)?

Thanks for any help.

Until I figure this out I will be going through many lines of codes trying to list all implicitly defined variables.
Needless to say, I will be tremendously grateful to anyone who frees me from such a boring task…

Best,

G.

  • 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-16T15:20:25+00:00Added an answer on May 16, 2026 at 3:20 pm
    1. You can require all variables to be explicitly declared by adding implicit none.
    2. I believe the default “real” data type is a real*4.
    3. You can use a command-line flag -fdefault-real-8 to force all variables declared as real to be interpreted as a real*8

    Note (for writing more code, not necessarily trying to solve the current bug):
    If you’re using Fortran 90 code, you can use real(kind=4) or real(kind=8) with gfortran rather than the real*4 or real*8 syntaxes. I’ve moved away from setting the real or integer size using command-line flags and instead use an integer, parameter :: REAL_SIZE variable to hold the appropriate number (I typically go for 4 or 8 because all the compilers I use support them, but if you want to be very portable you should use the selected_real_kind routine)

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

Sidebar

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.