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 6656705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:40:34+00:00 2026-05-26T01:40:34+00:00

Here is my minimal example: program test implicit none real :: testfunc write(*,*) Writing

  • 0

Here is my minimal example:

program test    
  implicit none
  real :: testfunc
  write(*,*) "Writing from main"
  write(*,*) testfunc()
end program test

function testfunc() result(y)
  real             :: y
  write(*,*) "Write from function g"
  y=1.0
  return
end function testfunc

When compiling with a simple

gfortran test.f90

or when including a library like Slatec

gfortran test.f90 -lslatec

It works fine.

However, when changing the library to -llapack of -lblas, then the program hangs at runtime
when calling testfunc(). Note that my example code here does not actually use any of these libraries. The last thing i see is “Writing from main”, then nothing happens, and i have to CTRL-C to regain control. When hanging, the process does not appear to be using any CPU cycles.

The strange thing now is that, if i comment out the write statement inside testfunc(), it works all the time.

So my question is really: Can these libraries really prevent me from printing inside my own functions? Why? How?

(I’m actually working on a larger program which needs lapack and blas, so i obviously can’t just stop linking to them.)

  • 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-26T01:40:34+00:00Added an answer on May 26, 2026 at 1:40 am

    As far as I remember, it is not standard conforming to call recursively the WRITE keyword.

    To correct you program, modify slightly your main program

    program test    
      implicit none
      real :: testfunc,result
      write(*,*) "Writing from main"
      result=testfunc()
      write(*,*) result
    end program test
    

    From my point of new, the trouble you met has therefore nothing to do with the used libraries but the symptoms of the mistake may change in that case (from apparently no bug to a crash).

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

Sidebar

Related Questions

I've just typed in an example from K&R... #include <stdio.h> int main (int argc,
I came across some code which kind of puzzled me. Here's a minimal example
Here's a minimal batch file, demo.bat , to illustrate my problem: @ECHO off set
Here is the scenario: I'm writing an app that will watch for any changes
Here's an interesting problem to solve in minimal amounts of code. I expect the
The minimal example of the problem I'm having is reproduced below: #include <set> using
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior

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.