Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

What is the maximum character length allowed?

$
0
0

Hello,


I wrote this simple code (see below) that converts an array of real into a very long string of characters.
I have been running this little code on 2 different machines and I compiled it with the same compler on both machines :


Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.1.106 Build 20131008
Copyright (C) 1985-2013 Intel Corporation.  All rights reserved.


Both machines are equipped with Intel processors,



  1. one with processors like : Intel(R) Xeon(R) CPU E5472  @ 3.00GHz

  2. and the other one with processor like : Intel(R) Xeon(R) CPU E5506  @ 2.13GHz

While on machine 1, the code works fine, on machine 2, I get a "Segmentation fault (core dumped)" message most of the time with n = 2093504.


So, is there a maximum character length allowed that is machine-dependant? How can I know this maximum?


Regards,
F.
 

program test

        implicit none

        integer :: i
        real, allocatable :: cube(:)
        integer :: n, length

        n = 2093503 ! OK
        n = 2093504 ! Segmentation fault
        length = 4*n
        write(*,*) n, length
        if (.not. allocated(cube)) allocate(cube(n))

        do i = 1, n
            call random(cube(i))
        end do

        call sub(cube, n, length)

    end program

    subroutine sub(array, n, length)

        implicit none

        integer :: n, len
        real :: array(n), f
        character(length) :: buf
        character(4) :: c
        integer :: i

        equivalence(f, c)

        write(*,*) n, length
        do i = 1, n
            f = array(i)

            buf(4*(i-1)+1:4*(i-1)+4) = c(1:4)
        end do

    end subroutine sub

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>