Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

RAN function not working

nitin_amt
Beginner
1,003 Views

Ran function is not working with "Intel Fortran Compiler Integration for Microsoft Visual Studio 2008, 10.1.3440.2008, Copyright (C) 2002-2008 Intel Corporation"

The code not working is below with line numbers at the start of each line. At line 6 when I call RAN(IFF), the value of IFF is still the same after line 6 is excuted. I would expect the value of IFF change after line 6. But this is not the case. Please help with the issue. Thanks in advance.

1. program

seven_11
2. USE IFPORT, ONLY: SRAND,RAN, RAND
3. integer*4 IFF
4. real*4 RAN2
5. DATA IFF /3333337/
6. RAN2=RAN(IFF)
7. IFF = 357
8. RAN2=RAN(IFF)
9. end program seven_11

0 Kudos
8 Replies
Steven_L_Intel1
Employee
1,003 Views

Curious. I can reproduce this. I suggest using the standard intrinsic RANDOM_NUMBER instead, I'll report this to the developers.

0 Kudos
Brian_Francis
Beginner
1,003 Views
I think it is working fine. The first call to RAN should use a large negative number as a seed for best results, but the important point to remember is that given the same seed value, the "random" results will be identical from one run to the next (handy for debugging). For a truly random result, try using an integer seed deived from the date and time.
Brian.

0 Kudos
Brian_Francis
Beginner
1,003 Views
Replace "negative" with "odd" in my reply above. Next time I'll read the docs first and post second.

0 Kudos
Steve_Nuchia
New Contributor I
1,003 Views
The doc give a specific example using 3. It doesn't work in 10.1.019.

0 Kudos
Brian_Francis
Beginner
1,003 Views
The doc give a specific example using 3. It doesn't work in 10.1.019.

I've tried the following with 10.1.021 and get results as advertised...

[cpp]program main
integer seed/3/ write (*,*) ran(seed)
write (*,*) ran(seed)
end[/cpp]

...which outputs...

[cpp]4.8220158E-05
0.3321905[/cpp]

Brian.

0 Kudos
Kevin_D_Intel
Employee
1,003 Views
I found that with IVF 10.x, the USE IFPORT interferes with RAN which the original sample program included.

If Brians program is modified slightly as shown:

[cpp]program main
use ifport
integer iseed /3/   
write (*,*) ran(iseed)
write (*,*) ran(iseed)
end[/cpp]

Then it prints:

6.7433808E-05

6.7433808E-05

If line 2 is removed, then it prints:

4.8220158E-05

0.3321905

I reported this to the Fortran Front-end team and will follow-up when I know more. (Internal ref. CQ- 50312)

0 Kudos
Steve_Nuchia
New Contributor I
1,003 Views
My bad: the using statement was something I put in there to get it compiling during the initial porting pass, long before we could actually run anything.
"It seemed like the thing to do at the time."

0 Kudos
Kevin_D_Intel
Employee
1,003 Views

This issue is fixed in the latest IVF 11.0 update, 11.0.072 (Windows).
0 Kudos
Reply