Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Fortran Manual pg 228

JohnNichols
Colaborador Valioso III
1.970 Vistas
program main
    implicit none

    INTEGER, PARAMETER :: dp = selected_real_kind(15, 307)
    integer,parameter :: k5 = selected_int_kind(5)
    integer,parameter :: k15 = selected_int_kind(15)
    Integer (kind=k5), parameter  :: i5 = 10
    integer(kind=k15) :: i15
    REAL (KIND=dp) :: a(i5)
    REAL (KIND=dp) :: b(i5)
    REAL (KIND=dp) :: c(i5)

    call sub1(a,b,c,size(a),size(a),size(a))

    contains

    
    subroutine sub1(a, b, c, lent, n1, n2)
    use IFCORE, only : for_sfence
    integer(kind=k15) lent, n1, n2, i, j
    REAL (KIND=dp) a(lent), b(lent), c(lent), d(lent)
    !$omp parallel do
    do j = 1, n1
        a(j) = 1.0 *j
        b(j) = 2.0 * j*j
        c(j) = 3.0 *j * j*j
    enddo
    !$omp end parallel do
    call for_sfence()
    !$omp parallel do
    do i = 1, n2
        a(i) = a(i) + b(i) * c(i)
        write(*,*)a(i)
    enddo
    !$omp end parallel do
    end subroutine


    end
program main
    implicit none

    INTEGER, PARAMETER :: dp = selected_real_kind(15, 307)
    integer,parameter :: k5 = selected_int_kind(5)
    integer,parameter :: k15 = selected_int_kind(15)
    Integer (kind=k5), parameter  :: i5 = 10
    integer(kind=k15) :: i15
    REAL (KIND=dp) :: a(i5)
    REAL (KIND=dp) :: b(i5)
    REAL (KIND=dp) :: c(i5)

    call sub1(a,b,c,size(a),size(a),size(a))

    contains

    ! The following USE statement provides Fortran interfaces to Windows routines
    subroutine sub1(a, b, c, lent, n1, n2)
    use IFCORE, only : for_sfence
    integer(kind=k15) lent, n1, n2, i, j
    REAL (KIND=dp) a(lent), b(lent), c(lent), d(lent)
    !$omp parallel do
    do j = 1, n1
        a(j) = 1.0 *j
        b(j) = 2.0 * j*j
        c(j) = 3.0 *j * j*j
    enddo
    !$omp end parallel do
    call for_sfence()
    !$omp parallel do
    do i = 1, n2
        a(i) = a(i) + b(i) * c(i)
        write(*,*)a(i)
    enddo
    !$omp end parallel do
    end subroutine


    end

 

changed len to lent to avoid keyword, added main so it ran, and kind so Steve et al. are pleased. 

made the numbers different to 7 so it looked interesting and not 10 sevens.

11 Respuestas
Barbara_P_Intel
Empleados
1.904 Vistas

@JohnNichols, you posted two examples. Which is the one to use in the Fortran DGR?

JohnNichols
Colaborador Valioso III
1.898 Vistas

Sorry they are identical, the box duplicated itself when I was inserting and I did not realize. First one is ok.  

Next:

On page 85 to 87 of the pdf developer guide, the current one, there are coding mistakes.  However I am a bit stuck on what is the standard template to use to revise the code.  Do I use a blank Windows Desktop template?   

 

Barbara_P_Intel
Empleados
1.890 Vistas

There's at least a comment statement different between the two. That's why I asked.

Re Next: I'm not sure what your question is. Do you want to update more than the Fortran source?

 

JohnNichols
Colaborador Valioso III
1.864 Vistas

My apologies, it is the first one that I recommend. No idea about the second one.  But strange things happen.  

 

The source on page 85 has it appears on first review, two mistakes in coding, but I suspect that me running the code into the standard Fortran console model template I have permanently set up to run examples is the wrong template.  One of the mistakes may be the wrong template, one is not.  I have used quickwin many years ago, but the pdf says Fortran Windows - so I am lost as to the template?  

I do not write Fortran in Windows programs, life is to short for that much misery.  

 

Barbara_P_Intel
Empleados
1.855 Vistas

I'm being a pest. What is the coding error you fixed? It's not leaping out at me. I filed a bug report last fall to change "FTN_SFENCE" to "FOR_SFENCE"; that is fixed in the current DGR.

Windows? I use Linux unless I'm forced to due to an issue only being seen on Windows.



JohnNichols
Colaborador Valioso III
1.846 Vistas

changed len to lent to avoid keyword, added main so it ran, and kind so Steve et al. are pleased. 

made the numbers different to 7 so it looked interesting and not 10 sevens.

Barbara_P_Intel
Empleados
1.817 Vistas

I filed a Feature Request with the docs team, DOC-10934.

I modified the example a bit to remove the warning messages when compiling.



JohnNichols
Colaborador Valioso III
1.811 Vistas

What did your final code look like pls?

This is what teams do, they make things better,  

This new sign in is a pain in the neck.  

Barbara_P_Intel
Empleados
1.810 Vistas

Attached. 

size() returns 32-bit integer. You have larger integers declared in the subroutine. There's a mismatch.

 

Barbara_P_Intel
Empleados
1.646 Vistas

Sorry for the delayed reply. The sample in the DGR (Developer Guide and Reference) is fixed.



JohnNichols
Colaborador Valioso III
1.641 Vistas

@Barbara_P_Intel , thank you for the notification.  You do not need to apologize, the service on this website is superb, it would be nice if Intel ruled the world, but alas it does not.  

Joke:

Two computer scientists went for a job at Intel.  The best person one and the second did not, assuming equal treatment under the scorching sun of the interview room.  The second scientist became an MP in the English parliament and said to Intel, with my second class pass degree I am going to tell you how to run your company in England. 

Only the BBC and the Guardian, both non-profit saw the humour.  

 

Responder