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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:13:06+00:00 2026-05-27T12:13:06+00:00

I can not call the same subroutine two time using pgf90 fortran complier on

  • 0

I can not call the same subroutine two time using pgf90 fortran complier on Linux environment. To call the subroutine for the 1st time is OK but calling it for the 2nd time, it gives Segmentation fault. Can some one give some suggestion, what is wrong with my code, As simple example is given as

P.S. with gfortran it is OK, even i tried it on the intel visual fortran and it is OK

program main 

use module_Append_1DI

implicit none 

integer, allocatable:: Arr(:)

integer::Brr(2)

Brr=[3, 4]

call Append_1DI(Arr,Brr)

write(*,*)Arr

call Append_1DI(Arr,Brr)

write(*,*)Arr

end program main 

module module_Append_1DI

contains

subroutine Append_1DI(A,B)

implicit none 

!================================================

integer, allocatable, intent(inout)::A(:)

integer, intent(in)::B(:)

integer, allocatable::temp(:)

integer::sizeA,sizeB,sizeN

!================================================

sizeA=size(A); sizeB=size(B); sizeN=sizeA+sizeB

allocate(temp(sizeN)); temp(1:sizeA)=A

call move_alloc(from=temp,to=A)

A(sizeA+1:sizeN)=B

end subroutine Append_1DI

end module module_Append_1DI
  • 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-27T12:13:07+00:00Added an answer on May 27, 2026 at 12:13 pm

    To be honest I’m amazed it works the first time you call it. That’s because A is not then allocated, and you are not allowed to use the size intrinsic on an unallocated allocatable array. In fact if you turn on all the checking flags ifort tells you this

    Wot now? ifort --version
    ifort (IFORT) 12.0.4 20110427
    Copyright (C) 1985-2011 Intel Corporation.  All rights reserved.
    
    Wot now? ifort -check all -g -traceback s.f90
    Wot now? ./a.out
    forrtl: severe (408): fort: (8): Attempt to fetch from allocatable variable A when it is not allocated
    
    Image              PC                Routine            Line        Source             
    a.out              000000000046A3FA  Unknown               Unknown  Unknown
    a.out              0000000000468F75  Unknown               Unknown  Unknown
    a.out              0000000000420B56  Unknown               Unknown  Unknown
    a.out              0000000000404C95  Unknown               Unknown  Unknown
    a.out              00000000004050E9  Unknown               Unknown  Unknown
    a.out              0000000000402ED5  module_append_1di          24  s.f90
    a.out              000000000040385F  MAIN__                     46  s.f90
    a.out              0000000000402B2C  Unknown               Unknown  Unknown
    libc.so.6          00007FB5F826DEFF  Unknown               Unknown  Unknown
    a.out              0000000000402A29  Unknown               Unknown  Unknown
    

    gfortran is less clear, but still tells you something is wrong

    Wot now? gfortran --version
    GNU Fortran (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
    Copyright (C) 2010 Free Software Foundation, Inc.
    
    GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
    You may redistribute copies of GNU Fortran
    under the terms of the GNU General Public License.
    For more information about these matters, see the file named COPYING
    
    Wot now? gfortran -Wall -Wextra -pedantic -fbounds-check -std=f2003 -g -fbacktrace s.f90
    Wot now? ./a.out
    At line 24 of file s.f90
    Fortran runtime error: Array bound mismatch for dimension 1 of array 'temp' (1252015568/139957056323024)
    
    Backtrace for this error:
      + function append_1di (0x400EC7)
        at line 24 of file s.f90
      + in the main program
        at line 48 of file s.f90
      + /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xff) [0x7f4a4a1deeff]
    

    And to pick another random compiler, that from Sun/oracle, again you get the same message

    Wot now? f90 -V
    f90: Sun Fortran 95 8.5 Linux_i386 2010/08/13
    usage: f90 [ options ] files.  Use 'f90 -flags' for details
    Wot now? f90 -C s.f90
    Wot now? ./a.out
    
     ******  FORTRAN RUN-TIME SYSTEM  ******
     Attempting to use an unallocated ALLOCATABLE 'A'
     Location:  line 22 column 16 of 's.f90'
    Aborted
    

    So the problem is the use of A before it is allocated.

    Is the confusion that you think this is a zero size array? Well you need to get that out of your head – an unallocated alloctable array has no defined size at all, which is very different from allocated bu zero size array.

    Ian

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

Sidebar

Related Questions

I'm not sure this is possible, but in ruby, you can dynamically call a
I am using SwingWorkers to make my GUI responsive. But I can not understand
rowanparker https://github.com/rowanparker/kohana-3-paypal I really need this module but I can not use it because
I think this may sound pretty simple, but still I can not get it
I have two tables, both have the same columns. We will call them tilistings
I can not create a directory in russian (UTF-8) using vimscript in WinXP. For
In a iPhone application, I am using two different tableviews in same screen. Now,
I'm using BCB6, but it should be the same as Delphi, if I just
Every time I call this method my NSMutableData is leaking and I cannot figure
One of our developers used this call: TzSpecificLocalTimeToSystemTime() but unfortunately we cannot keep it

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.