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

Assignment overloading of the form scalar = vector(:)

$
0
0

Hi,

I'm having trouble to define a overloaded assigment using:

  1. a scalar variable on the left-hande side and
  2. a 1d array on the right-hand side.

In other words, I want to do scalar = vector(:).

Is this even allowed ?

Thanks.

! ifort main.f90; ./a.out

Module MyModule
  implicit none
  private
  public        ::      MyType

  Type          ::      MyType
    integer     ::      Var
  contains
    generic     ,public         ::      operator(+)     =>      Addition_0d, Addition_1d
    procedure   ,private        ::      Addition_0d
    procedure   ,private        ::      Addition_1d
    generic     ,private        ::      assignment(=)   =>      Assign_0d, Assign_1d
    procedure   ,private        ::      Assign_0d
    procedure   ,private        ::      Assign_1d
  End Type
  contains

Function Addition_0d( This, That ) result(Res)
  class(MyType)                 ,intent(in)     ::      This
  type(MyType)                  ,intent(in)     ::      That
  type(MyType)                                  ::      Res
  Res%Var       =       This%Var + That%Var
End Function

Function Addition_1d( This, That ) result(Res)
  class(MyType)                 ,intent(in)     ::      This
  type(MyType)  ,dimension(:)   ,intent(in)     ::      That
  type(MyType)                                  ::      Res
  Res%Var       =       This%Var + sum( That%Var )
End Function

Subroutine Assign_0d( lhs, rhs )
  class(MyType)                 ,intent(out)    ::      lhs
  type(MyType)                  ,intent(in)     ::      rhs
  lhs%Var       =       rhs%Var
End Subroutine

Subroutine Assign_1d( lhs, rhs )
  class(MyType)                 ,intent(out)    ::      lhs
  type(MyType)  ,dimension(:)   ,intent(in)     ::      rhs
  lhs%Var       =       sum( rhs%Var )
End Subroutine

End Module

Program Main
  use MyModule  ,only:  MyType
  implicit none

  type(MyType)                  ::      Sca_1, Sca_2, Sca_3
  type(MyType)  ,dimension(3)   ::      Vec_1_2_3

  Sca_1%Var = 1
  Sca_2%Var = 2
  Sca_3%Var = 0

  write(*,"(/,'Test_1)')")
  Sca_3 = Sca_1 + Sca_2
  if ( Sca_3%Var == 3 ) then
    write(*,"('Success: Sca_3%Var = ',g0)") Sca_3%Var
  else
    write(*,"('Failure: Sca_3%Var = ',g0)") Sca_3%Var
  end if

  Sca_3%Var        = 0
  Vec_1_2_3(1)%Var = 1
  Vec_1_2_3(2)%Var = 2
  Vec_1_2_3(3)%Var = 3

  write(*,"(/,'Test_2)')")
  Sca_3 = Sca_1 + Vec_1_2_3
  if ( Sca_3%Var == 7 ) then
    write(*,"('Success: Sca_3%Var = ',g0)") Sca_3%Var
  else
    write(*,"('Failure: Sca_3%Var = ',g0)") Sca_3%Var
  end if

  Sca_3%Var = 0
  write(*,"(/,'Test_3')")
  Sca_3 = Vec_1_2_3                     ! COMPILER_ERROR: error #6366: The shapes of the array expressions do not conform.   [SCA_3]
  if ( Sca_3%Var == 6 ) then
    write(*,"('Success: Sca_3%Var = ',g0)") Sca_3%Var
  else
    write(*,"('Failure: Sca_3%Var = ',g0)") Sca_3%Var
  end if

End Program

 


Difficulty of compiling fortran code while linking with mkl

$
0
0

Hi,

I have been trying to compile my fortran code, where I am using a couple of mkl functions such as dss solver, MKL_DCSRMULTCSR, MKL_DCSRGEMV, etc. Previously I had a similar code, from which I was compiling a dll. I was calling then the created dll from matlab using loadlibrary function. This has worked in the past, because my code did not use any of the mkl functions I mentioned above.

Now when I try the loadlibrary command, it complains that it does not recognize the mkl functions. I have been searching for solutions here in forum, on the web, etc. Unfortunately, all the things I have tried so far failed. This is where I need your help.

So far I have tried two approaches: 

- I tried to link the mkl libraries while I am compiling the code. For example I have tried commands such as:

ifort -shared -fpic -o Engine.so -O3 -L/usr/local/intel/composer_xe_2013.5.192/mkl/lib/intel64/ -I/usr/local/intel/composer_xe_2013.5.192/mkl/include/ -lmkl_intel_lp64.so -lmkl_sequential -lmkl_core SourceCode/*.f90

Although it does not return any error and creates the Engine.so successfully, when I load it in matlab, it tells me that it cant find "lmkl_intel_lp64.so" library (even if I copy it to the same directory). My question here is: do you think there is something wrong the way I compile it or do I need to define something on matlab side?

- the second thing I tried was just to compile it without linking to mkl libraries as:

ifort -shared -fpic -o Engine.so -O3 SourceCode/*.f90

where included the "mkl_dss.f90" file in my fortran code. This again returns no error and created the dll successfully. And when I load it in matlab, it actually does NOT complain about dss functions (so I assume that I managed to include the dss solver). However it still complains about the remaining two MKL_DCSRMULTCSR, MKL_DCSRGEMV functions. I know that they are part of mkl_spblas however there is no .f90 file for this, but only an .fi file (I think the difference is still not clear to me, i.e. why there is f90 file for dss but an fi file for spblas). As a result, I could not do the same trick for these two functions.

Sorry for the long post, I tried to summarize it as short as possible while describing the important parts.

I would be glad for any suggestions how I could make this thing work 

Thank you very much in advance,

best regards,

Murat

 

 

 

How to Link Against STATIC libc on Ubuntu 13.10

$
0
0

 

I have been able to get digit for digit identical results on Ubuntu 13.10 x64 vs. Windows, if I compile my code like so:



ifort -zero -traceback -static-intel -i8 -O2 -axAVX -ftz -fpe0 -fp-model source -c SOURCEFILE.FOR



A colleague informed me that "-static-intel" does not mean I will get static c libraries linked into my program, so if I distribute the compiled .exe of my program, I may not get identical results on another Linux distribution.



My question is, is there any way to compile against the static version of libc (and any other required libraries?) to ensure that I get digit for digit agreement between different Linux platforms after I redistribute my .exe?

 

external file modified date

$
0
0

There seems to be no simple way of obtaining the modified date of an external file in Fortran. Can anyone help with a few lines of Fortran code to get the information? Preferably, the code is portable across platforms and compilers (I know GFortran has an intrinsic function for this purpose).

How to declare `interface` block for MKL functions?

$
0
0

Hi,

The following code was successfully compiled but returned wrong result:

program main
   use, intrinsic:: iso_fortran_env, only: INPUT_UNIT, OUTPUT_UNIT, ERROR_UNIT

   implicit none

   interface ! returns wrong result
      subroutine sscal(n, alpha, x, incx)
         Integer, intent(in):: n
         Real, intent(in):: alpha
         Real, intent(inout):: x(:)
         Integer, intent(in):: incx
      end subroutine sscal
   end interface
   ! external sscal ! returns expected result

   Real:: xs(2) = [1, 2]

   write(OUTPUT_UNIT, *) xs
   call sscal(2, 3.0, xs, 1)
   write(OUTPUT_UNIT, *) xs

   stop
end program main

 

   1.000000       2.000000
   1.000000       2.000000



If I use `external` statement instead of the `interface` block, it works as expected:

 

   1.000000       2.000000
   3.000000       6.000000



Would you tell me how to make `interface` block version work correctly?

I use `ifort (IFORT) 13.1.0 20130121`.



 

Creating file name strings

$
0
0

Hi All,

I'm trying to create numerous files in a directory with a do loop using the command open. I don't exactly know how I'm supposed to take care of the names of the files. Since I can only type a single string in the file="..." section of the open command

Any help would be highly appreciated

Regards

Debugging in v15 beta

$
0
0

Is this the right place to ask about debugging in the v15 beta product? I've tried premier support but it says the product is no longer supported.

Thanks.

Error installing on Ubuntu

$
0
0

Hello,

I am unable to install Intel Fortran Compiler XE for Intel(R) 64 component on Ubuntu 14.04. It says 'Unsupportted OS' at first. However, if I ignore and continue, select Intel 64 architecture, at Installation stage I get the error:

Installing Intel Fortran Compiler XE for Intel(R) 64 component...

ERROR: Unable to extract data from RPM package. Please check that temporary

directory is not full.



Please help.

Thanks.

Aditya


Memory can not be "Read" Erro

$
0
0

Hi Guys,

I am using FORTRAN as my coding language for ASPEN PLUS. Frequently I come across an error which says :

                     " Instruction at "0x749860b0" refernced at "0x000000000". The memory can not be "read".

Is this error due to system Hardware issues (I have 2 GB RAM)?

Can you please help me to resolve this error.

Thanks 

Rajesh

OpenMP refusing to thread

$
0
0

Steve, Colleagues,

Can anyone suggest why OpenMP would not thread the following (simple) double loop?

CALL OMP_SET_NUM_THREADS(4)
MemForEachStack = 16000000
call kmp_set_stacksize_s(MemForEachStack)
!$omp parallel do default(firstprivate), shared(ReceiverDistribution)
xloop:  &
do i = NumXLimit1,NumXLimit2
	do j=NumYLimit1,NumYLimit2
		ReceiverDistribution(j,i) = sqrt(float(i*j))
	end do
end do xloop
!$OMP end parallel do 

I am experimenting with OpenMP multi-thread in our routines and have managed to multi-thread the smaller one. But I have been unable to multi-thread our largest routine (large for us: ~10,000 lines of code with ~5,000 lines of supporting subroutines). I am attempting to declare a parallel do section involving a set of nested loops. The code involved (~500 lines) within the inner loop is rather elaborate -- with calls to subroutines. I have "use omp_lib" at the start of the routine. I eventually worked through the process of getting the correct list of variables in the shared clause, and got the code to run.  But OpenMP would not multi-thread the outer loop. I get no compiler errors. The code links and runs correctly, but with only one thread. A write of omp_get_thread_num() to the standard output within the loop always shows zero. That is, one thread.

If I turn on the vector optimization report, it shows the 1000's of instances where the code has been successfully vectorized. But I can get no information about (non)threading.

Finally, I commented out ALL the original double loop-code and substituted the simple double-loop listed above. Still no multi-threading. I get no messages from OpenMP, though I have the report level set to 2. (But I don't think that will help, since I think it only reports success, not the reason for failure). The code runs without incident, thought (of course) the results are different since I'm putting nonsense into the array ReceiverDistribution, rather than doing the more elaborate work. 

There is still a lot of code before and after the simple double loop listed above. But I cannot understand how it could be suppressing threading; however complex it is.

I am using compiler release 14.0.3.202.  Worringly, I get exactly the same behavior with beta 15.0.070

David

 

Code Generation for future Intel® MIC Architecture-based Processors

$
0
0

In versions 14.0.1 and later, the Intel® C++ Compiler and the Intel® Fortran Compiler processor-specific options support code generation for Intel® Advanced Vector Extensions 512 (Intel® AVX-512) targeting the next generation of Intel® MIC Architecture-based products, codenamed "Knights Landing".

Code generation targeting this platform can be achieved through the use of the following options:

For additional information how to use these options, please refer to the article Intel® Compiler Options for Intel® SSE and Intel® AVX generation and Processor-specific Optimizations.

 

  • Developers
  • Linux*
  • C/C++
  • Fortran
  • Intermediate
  • Intel® C++ Compiler
  • Intel® Fortran Compiler
  • Intel® Many Integrated Core Architecture
  • Optimization
  • Vectorization
  • URL
  • Compiler Topics
  • Theme Zone: 

    IDZone

    runtime crashes

    $
    0
    0

    I am currently moving a large code base over to the Intel fortran compiler. This task is almost complete, and the code is now executing as expected, however visual studio 2010 keeps crashing while I am debugging. These crashes occur either when stepping into a particular procedure, or when hitting a break point inside of the procedure. I receive the error message: Microsoft visual studio has stopped working. windows is checking for a solution to the problem... The studio then restarts with no explanation as to what caused the crash. Curiously, if I step over these procedures, they run fine and my debug session continues.

    I understand there is not a lot to go on here, but I would appreciate any suggestions

    compiling with -ipo takes too much time

    $
    0
    0

    Dear all,

    I am using the following compile line for my makefile however -ipo options takes far longer than without -ipo, what is the reason of this behavior?

    ifort -ipo -prec-sqrt -prec-div -fp-model source -xHost -traceback -unroll4 -O3 -standard-semantics -assume protect_parens

    Is this behavior normal? I am on a Linux x86-64 environment.

    Best,

    Umut

     

    Invoking Internet Explorer from Fortran - IVF Composer

    $
    0
    0

    In an application I use Internet Explorer to open and display a HTML files.


    The program line below used to work well, both with QVF and with Intel VF version 10.026


    iret = WinExec('C:\Program Files\Internet Explorer\iexplore.exe ' //trim(WORKDIR)//'HTM4621\UMTVA462A.HTML'C,SW_MAXIMIZE)


    When compiling with IVF 2013 I get the following warning:


    Compiling with Intel(R) Visual Fortran Compiler XE 14.0.1.139 [IA-32]...


    Instructions.f90


    C:\IV-Fortran\TVA51-2C -April2014\TVA51-single-clas-2014-2C\Instructions.f90(15): warning #5275: The backslash character and following character is not a valid escape sequence


    When I run the program, the IE starts, but it does not display the HTML file.


    How can this problem be fixed?


     

    AVX instruction using xmm ?

    $
    0
    0
     

    Hi,

    I have a question about AVX instruction. I compiled my code using ifort 13 with -O2 and -xHost. I want to enable 256-bit wide AVX to perform four 64-bit floating point operations per cycle.

    Here is my first code piece:

     623 !DIR$ SIMD
     624         do ii = 1, Nc
     625 ! diagonal components first
     626           StrnRt(ii,1) =   JAC(ii)   * (                &
     627                            MT1(ii,1) * VelGrad1st(ii,1) &
     628                          + MT1(ii,2) * VelGrad1st(ii,3) )
    			...
     640          end do

    The assembly files show that the following instructions were generated for line 627:

    vmulsd    8(%r8,%r14,8), %xmm1, %xmm3                   #627.38
    vmulpd    %xmm6, %xmm5, %xmm11                          #627.38
    vmulpd    %ymm5, %ymm4, %ymm10                          #627.38

    I understand why I got vmulsd. My question is why vmulpd %xmm6, %xmm5, %xmm11 was generated and what does it stand for? I think vmulpd should be an AVX instruction and should use ymm to have 256-bit wide vectorization.

    For the second code piece:

     643 !DIR$ SIMD
     644         do ii = 1, Nc
     645 ! diagonal components first
     646           StrnRt(ii,1) =   JAC(ii)   * (                &
     647                            MT1(ii,1) * VelGrad1st(ii,1) &
     648                          + MT1(ii,2) * VelGrad1st(ii,4) &
     649                          + MT1(ii,3) * VelGrad1st(ii,7) )
     			...
     685         end do

    The assembly files show that the following instructions were generated for line 647:

    vmulsd    (%r12), %xmm4, %xmm6                          #647.38
    vmulpd    %xmm11, %xmm10, %xmm0                         #647.38

    Here again I got vmulpd with xmm. I even did NOT get vmulpd with ymm. I am worrying that this code piece is only performing two 64-bit floating point operations per cycle, rather than four.

    I truly appreciate your help.

    Best regards,

         Wentao


    best ifort equivalent flag to gfortran -O3 -ffast-math?

    $
    0
    0

    Hi to everyone,

    I am parallelizing a MC code written in Fortran using OpenMP. During the development process I used the Parallel Studio Suite with great success (really, I would not be able to do it without the help of the Advisor, Amplifier and Inspector programs... I am not an expert (actually, I am physicist who loves programming, but I have had to do self-training during my career)

    Now I am testing the performance of my program under various OS, compiler and CPU's. Originally, this code was expected to be compiled with gfortran and "-O3 -ffast-math" flags, is there a close equivalent to this configuration for ifort?

    As a first approach I am using ifort with "-O3" and I obtain a ~20% performance gain compared with gfortran, so I would like to check if there are other flags that could improve the performance of my code. Thanks for your help!

    Intel® Composer Release Notes by Version

    $
    0
    0

    Matlab calls IVF dll generated by IDE environment

    $
    0
    0

    Hi
    I have not found detailed steps to build fortran dll from IDE environement and link to Matlab.
    I found that IDE approach to create fortran dll is simpler tha "mex -setup " approach since we need to
    edit *.stp, *.bat files fom /bin & matlab prefdir. We do not have write permission for
    folder anyway!
    Hence I created some sample document to create and run visula studio here:
    I use Vista business SP2, Matlab R2006b, IVF 11.0 & VS 2008.
    =====================================================================
    1. Create Fortran Project from IDE:
    File->New Project->IVF->Library->Dynamic-link Library:
    Project name :

    2. Copy \extern\include\mexversion.rc to the local project dir: TestIVFDLL

    3. Solution explorer->Resource Files->Add existing item->mexversion.rc

    4. Copy sample mexfunction fortran file from >matlabroot>\extern\reffbook\timestwo.F to the local project dir TestIVFDLL

    5. Solution explorer->Source Files->Add existing item->timestwo.F

    6. Solution explorer->Fortran->General->Additional Include Directories:
    \extern\include

    7. Solution explorer->Fortran->Preprocessor: Yes(/fpp)

    8. Solution explorer->Fortran->Diagnostics:
    Generate Interface Blocks: No
    Check Routine Interface : No

    9. Solution explorer->Linker->General->Output Files: .mexw32

    10. Solution explorer->Linker->General->Output FilAdditional Include Directories: \extern\lib\\microsoft
    (Here it is Vista 32-bit platform)

    11. Solution explorer->Linker->Input->additional dependencies : libmx.lib libmex.lib libmat.lib libeng.lib

    12. Solution explorer->Linker->Input->Module definition file:
    "myModule.def"
    For this case:
    %%%%%%%%%%%%%%%%%%%%%%%%%
    LIBRARY TestIVFDLL
    EXPORTS
    MEXFUNCTION
    TIMESTWO
    %%%%%%%%%%%%%%%%%%%%%%%%%

    13. Issue Build command.

    After build, perform the following check:
    =========================================
    1. Go to command prompt; go to project dir & issue DUMPBIN command.
    (If this command does not work, look for "vcvars.bat" and set all MSVS variables.)

    $>DUMPBIN /exports .\Debug\testivfdll.mexw32

    DUMPBIN command results:
    ...
    1 0 00001005 MEXFUNCTION = @ILT+0(_MEXFUNCTION)
    2 1 0000100A TIMESTWO = @ILT+5(_TIMESTWO)
    ...

    Everything is perfect: gateway function (MEXFUNCTION)& our calculation function (TIMESTWO) get exported.

    2. Construct header file for this function:
    From fortran:
    ...
    subroutine timestwo(y, x)
    real*8 x, y
    C
    y = 2.0d0 * x
    return
    end

    Note: The above file is the the same as \extern\examples\refbook\timestwo.F

    The corresponding header required for Matlab:
    void TIMESTWO (double*, double*);
    -----> otherwise Matlab cribs!

    3. Go to Matlab folder and copy the header file & testivfdll.mexw32

    4. Write Matlab dummy file to test this dll
    function dummy()
    %
    % matlab is case-sensitive to dll & header names
    %
    loadlibrary('testivfdll', 'TestIVFDLL.h');

    mlfunc = libfunctions('testivfdll','-full');
    libfunctionsview testivfdll

    aa = 3.0;
    cc = 0.0;
    if libisloaded('testivfdll')
    bb =calllib('testivfdll', 'TIMESTWO', cc,aa)
    end
    unloadlibrary testivfdll
    end

    File I/O Unformatted Stream Vs Binary

    $
    0
    0

    I am not familiar with opening a file with form set to Unformated with Acess set to Stream. Is this identical to opening a file with form set to Binary. If not, since they are record free files would something written with both forms produce the same binary? What would be the pros/cons between them if there is a difference. Right now I am able to postprocess form set to binary with python, but I assume it should work with stream because its equivalent to a C-binary?

     

    Thanks as always.

    Volatile coarrays

    $
    0
    0

    The compiler does not seem to be honouring C560 "The VOLATILE attribute shall not be specified for a coarray that is accessed by use (11.2.2) or host (16.5.1.4) association."  This is the clearest example, but I can't get a message no matter what I do.

    MODULE Wombat

        INTEGER :: x[*]

    END MODULE Wombat

    PROGRAM Main

        Use Wombat

        VOLATILE :: x

        x = 0

    END PROGRAM Main

     

    Viewing all 3270 articles
    Browse latest View live


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