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

Input data file with columns divided in blocks

$
0
0

Hello all,

I need to read a 62x14 table which is generated by an external program. However the external program splits the table in two parts, showing the first 10 columns and the remaining columns just below the first part. Is it possible to read such table in my Fortran code? What should be done?

 

Thanks,

 

Paulo


System and SystemQQ: what am I doing wrong?

$
0
0

Hi,

I want to do something that is quite simple (I reckon).  I must go up one folder level, chdir to another folder and then delete one existing file in this latter folder.  What I'm doing is the following:

         Logical :: I

         I = SystemQQ('cd ..\Data\')
         I = SystemQQ('del CPG.dat')

However, it seems that not even the first command works, I mean, I cannot go up one level and then into the Data folder.  The command System (by the way, in what it differs from SystemQQ?) doesn't work either.  Same result if I split the first command:

         I = SystemQQ('cd ..')
         I = SystemQQ('cd Dados')
         I = SystemQQ('del CPG.dat')

What am I doing wrong?  My system's specs are appended below.

Thanks a lot for any help.

Fausto

Windows 7

Microsoft Visual Studio 2005
Version 8.0.50727.867  (vsvista.050727-8600)
Microsoft .NET Framework
Version 2.0.50727 SP2

Fortran calling C++ stdcall DLL

$
0
0

Why can I link my Intel Fortran  dll (sum_if.dll)  to my Fortran (sum_test)  but not my C++ one (sum_cpp.dll)?     All are accepted as STDCAL DLLs by other software e.g. Excel VBA (in the attached .zip)

Fortran Linking to sum_if  works with any of:

  1. Linker | Input |  Additional Dependecies= sum_if.lib
  2. Adding.lib to project (e.g. sum_if.lib)
  3. Project Dependencies = sum_if

But for sum_cpp the dll is not found or accepted   i.e.

sum_test.obj : error LNK2019: unresolved external symbol __imp_sum referenced in function _MAIN__

Dependency Walker  shows function=sum on both. So hopefully it is not a "Decoration" issue?

I have attached the VS Community 2013 Solution, as I hope/ expect  the answer is hidden there. 

1. VS 2013 Solution= sumdll  Projects: = Win32

All sharing same ..\Output\Release and Debug directories.  The excel “double check”  lives in Debug. This helps simplify and clarify "finding" the DLL (I wanted to avoid full paths) 

1.1 Sum_if.dll contains:

function sum(a,b)
IMPLICIT NONE
  ! Expose subroutine ExcelDLL to users of this DLL
  !DEC$ATTRIBUTES STDCALL, DLLEXPORT, ALIAS: 'sum'	:: sum
  !DEC$ATTRIBUTES Value :: a,b
  ! Variables
  integer*4 a,b,sum
  ! Body of ExcelDLL
  sum=a+b
end function sum

1.2 Sum_cpp.dll 

//  Sum_cpp.cpp contains:
int _stdcall sum(int x, int y){
	return x+y;
}

// Sum_cpp.def contains:
LIBRARY	"sum_cpp""
	EXPORTS sum @

1.3 Sum_test

   Interface
      function sum(a,b)
        IMPLICIT NONE
        ! Expose subroutine ExcelDLL to users of this DLL
        !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:'sum'	:: sum
        !DEC$ATTRIBUTES Value :: a,b
        ! Variables
        INTEGER*4 a,b,sum
      end function sum
    End Interface

    INTEGER*4  :: a_i4b, b_i4b, c_i4b,d_i4b, I, j
    print *, 'add integers'
    a_i4b=7
    b_i4b=43
    c_i4b=sum(a_i4b,b_i4b)
    write(*,'(I10,A,I10,A,I10)')  a_i4b," + ", b_i4b," = ",c_i4b
    end program vf_dll_test

2. Excel VBA Declares

' all work fine:' C++
Declare Function sumcpp Lib "sum_cpp.dll" Alias "sum" (ByVal i As Long, ByVal j As Long) As Long' Intel Fortran 10.1
Declare Function sumif Lib "sum_if.dll" Alias "sum" (ByVal a As Long, ByVal b As Long) As Long

Peter

 

AttachmentSize
Downloadsumdll.zip8.32 MB

Free Intel Fortran for students is back!

Free Intel Visual Fortran for students!

$
0
0

Intel Fortran is now available under a free, non-commercial license for qualified students on Linux, OS X and WIndows. See https://software.intel.com/en-us/qualify-for-free-software/student for more details.

Note: If you don't already have a supported Microsoft Visuall Studio installed, you'll need to get one first as the student license doesn't include the VS Shell-based IDE. The free Visual Studio 2013 Community Edition will do.

Modules and subroutines

$
0
0

Hello everyone,

I am new to fortran.. I am facing difficulty in calling subroutine and module from main program. When I run the program , its gives error about line 95 d.

sometimes it gives error SALFORD RUN TIME ERROR-STACK OVER FLOW

Please check any mistake in the following code:

Regards,

Ali

  1. Module variables_m

 

  1. integer lon,lonmax,xx,yy     ! longitude
  1. integer lat,latmax     ! latitude
  2. integer yr,yrmax       ! year
  3. integer mon,monmax     ! month
  4. integer num            ! arbitral number
  5. integer i,j,k
  6. parameter (lonmax=320) ! num of grids (longitude)
  7. parameter (latmax=160) ! num of grids (latitude)
  8. parameter (yrmax=101)  ! num of years totally
  9. parameter (monmax=12)  ! num of months per year
  10. real:: idata(lonmax,latmax*monmax*yrmax)
  11. real data(lonmax,latmax,monmax,yrmax)
  1. real, dimension(1:10)::ave
  2. integer count,tt,sy,ey
  3. real:: summ

 

  1. end module variables_m
  1. module readbinaryfile_m
  2. use variables_m
  3. contains
  4. subroutine readbinaryfile()

 

 

 

 

 

  1. open(8,file='monthly_temperature_1900to2000.bin',access='direct',recl=lonmax*1)
  1. do num=1,latmax*monmax*yrmax
  1. do           lon=1,lonmax
  2. read(8,rec=num) idata(lon,num)
  3. end do
  4. enddo    
  5. close(8)
  6. end subroutine readbinaryfile    
  1. end module readbinaryfile_m
  1. module printallvalues_m
  2. use variables_m
  3. use readbinaryfile_m
  1. implicit none
  1. contains
  2. subroutine printallvalues()
  1. integer lon,lonmax,xx,yy     ! longitude
  2. integer lat,latmax     ! latitude
  3. integer yr,yrmax       ! year
  4. integer mon,monmax     ! month
  5. integer num            ! arbitral number
  6. integer i,j,k
  7. parameter (lonmax=320) ! num of grids (longitude)
  8. parameter (latmax=160) ! num of grids (latitude)
  9. parameter (yrmax=101)  ! num of years totally
  10. parameter (monmax=12)  ! num of months per year
  11. real:: idata(lonmax,latmax*monmax*yrmax)
  12. real data(lonmax,latmax,monmax,yrmax)
  1. real, dimension(1:10)::ave
  2. integer count,tt,sy,ey
  3. real:: summ
  1. open(9,file='all_values.csv',status='replace')
  2. num=1
  1. do yr=1,yrmax
  1. do mon=1,monmax
  2. do lat=1,latmax
  3. do lon=1,lonmax
  4. data(lon,lat,mon,yr)=idata(lon,num)
  5. write(9,*) data(lon,lat,mon,yr)
  6. end do
  7. num=num+1
  8. end do
  1. end do
  2. end do
  1. close(9)
  1. end subroutine printallvalues
  1. end module printallvalues_m
  1. module decadalmeantemperature_m
  2. use variables_m
  3. use readbinaryfile_m
  4. use printallvalues_m
  5. implicit none
  6. contains
  1. subroutine decadalmeantemperature()
  1. integer lon,lonmax,xx,yy     ! longitude
  2. integer lat,latmax     ! latitude
  3. integer yr,yrmax       ! year
  4. integer mon,monmax     ! month
  5. integer num            ! arbitral number
  6. integer i,j,k
  7. parameter (lonmax=320) ! num of grids (longitude)
  8. parameter (latmax=160) ! num of grids (latitude)
  9. parameter (yrmax=101)  ! num of years totally
  10. parameter (monmax=12)  ! num of months per year
  11. real:: idata(lonmax,latmax*monmax*yrmax)
  12. real data(lonmax,latmax,monmax,yrmax)
  1. real, dimension(1:10)::ave
  2. integer count,tt,sy,ey
  3. real:: summ
  1. open(10,file='10 Years average.csv',status='replace')
  2. write(10,*) 'Interval',',','Average Decadel Temp'
  1. sy=1
  2. ey=10  
  1. do k=1,10
    1. summ=0.0
    2. count=0
  2. do yr= sy,ey
  1. ave=0.0

.yy=1899+sy

  1. xx=1899+ey
  1. do           mon=1, 12
  2. do           lat=1,160
  3. do           lon=1,320
  4. summ =summ+ data(lon,lat,mon,yr)
  5. count=count+1
  1. end do
  2. end do
  3. end do
  4. end do
  1. sy=ey+1
  1. ey=ey+10
  2. if (ey==100) then
  3. ey=101
  4. end if
    1. ave(k) =summ/count
  5. write(10,*) yy,'-',xx,',', ave(k)
  1. end do
  1. close(10)
  1. end subroutine decadalmeantemperature
  2. end module decadalmeantemperature_m
  1. program envfluidmechanics
  1. use variables_m
  2. use readbinaryfile_m
  3. use printallvalues_m
  1. use decadalmeantemperature_m
  2. call decadalmeantemperature

 

 

  1. end program envfluidmechanics

 

Debugger jumps into memcpy.asm

$
0
0

I am just going through my program in debug mode. Currently I have the problem, that when a value is assigned to a variable, the debugger jumps into  memcpy.asm. I don't want to see this!

I think there's a project property set wrong, but which one?

!OMP SIMD useage

$
0
0

This useful new feature seams only possible on explicit do loops. Why was it not thought to be useful for implicit loops, i.e array assignment ? Is it too hard to implement ?


convert where to if else style code in fortran.

$
0
0

hi below is the code I rewrote(with do loops) and further down(with where statements) is the original code. The code seems to be producing differnt values for WORK arrays over time. How to resolve this issue?? 

do j=1,ny_block
           do i=1,nx_block

           if(LMASK(i,j) .eq. .true. )then

            WORK1(i,j,kk) =  KAPPA_THIC(i,j,kbt,k,bid)  &
                           * SLX(i,j,kk,kbt,k,bid) * dz(k)

            WORK2(i,j,kk) = c2 * dzwr(k) * ( WORK1(i,j,kk)            &
              - KAPPA_THIC(i,j,ktp,k+1,bid) * SLX(i,j,kk,ktp,k+1,bid) &
                                            * dz(k+1) )

            WORK2_NEXT(i,j) = c2 * ( &
              KAPPA_THIC(i,j,ktp,k+1,bid) * SLX(i,j,kk,ktp,k+1,bid) - &
              KAPPA_THIC(i,j,kbt,k+1,bid) * SLX(i,j,kk,kbt,k+1,bid) )

            WORK3(i,j,kk) =  KAPPA_THIC(i,j,kbt,k,bid)  &
                           * SLY(i,j,kk,kbt,k,bid) * dz(k)

            WORK4(i,j,kk) = c2 * dzwr(k) * ( WORK3(i,j,kk)            &
              - KAPPA_THIC(i,j,ktp,k+1,bid) * SLY(i,j,kk,ktp,k+1,bid) &
                                            * dz(k+1) )

            WORK4_NEXT(i,j) = c2 * ( &
              KAPPA_THIC(i,j,ktp,k+1,bid) * SLY(i,j,kk,ktp,k+1,bid) - &
              KAPPA_THIC(i,j,kbt,k+1,bid) * SLY(i,j,kk,kbt,k+1,bid) )

            endif

           enddo
          enddo

         

           where ( LMASK )

            WORK1(:,:,kk) =  KAPPA_THIC(:,:,kbt,k,bid)  &
                           * SLX(:,:,kk,kbt,k,bid) * dz(k)
            WORK2(:,:,kk) = c2 * dzwr(k) * ( WORK1(:,:,kk)            &
              - KAPPA_THIC(:,:,ktp,k+1,bid) * SLX(:,:,kk,ktp,k+1,bid) &
                                            * dz(k+1) )

            WORK2_NEXT = c2 * ( &
              KAPPA_THIC(:,:,ktp,k+1,bid) * SLX(:,:,kk,ktp,k+1,bid) - &
              KAPPA_THIC(:,:,kbt,k+1,bid) * SLX(:,:,kk,kbt,k+1,bid) )

            WORK3(:,:,kk) =  KAPPA_THIC(:,:,kbt,k,bid)  &
                           * SLY(:,:,kk,kbt,k,bid) * dz(k)
            WORK4(:,:,kk) = c2 * dzwr(k) * ( WORK3(:,:,kk)            &
              - KAPPA_THIC(:,:,ktp,k+1,bid) * SLY(:,:,kk,ktp,k+1,bid) &
                                            * dz(k+1) )

            WORK4_NEXT = c2 * ( &
              KAPPA_THIC(:,:,ktp,k+1,bid) * SLY(:,:,kk,ktp,k+1,bid) - &
              KAPPA_THIC(:,:,kbt,k+1,bid) * SLY(:,:,kk,kbt,k+1,bid) )

          endwhere

Are they equivalent??

 

Coz I am having issues of correctness here.

Compiler bug - stream formatted nonadvancing read

$
0
0

Hello,

I'd like to report a possible bug in Fortran Intel Compiler - it seems it doesn't read correctly data in nonadvancing way on a file opened as a formatted stream.

Please consider the attached program. It generates file with lines "This_is_line_no_XXXX" where XXXX is the number of the line. It then reads it back as stream formatted nonadvancing. With the default blocksize, the first problem exhibits at line 780 which is around 16384 bytes which could be the default blocksize, the output is as follows:

[jan@olney npen_build]$ ./test.exe
 Generating file fread_test.txt
 Reading fread_test.txt
OK  Line    1 read   20 >This_is_line_no_0001<
OK  Line    2 read   20 >This_is_line_no_0002<
OK  Line    3 read   20 >This_is_line_no_0003<
...
OK  Line  776 read   20 >This_is_line_no_0776<
OK  Line  777 read   20 >This_is_line_no_0777<
OK  Line  778 read   20 >This_is_line_no_0778<
OK  Line  779 read   20 >This_is_line_no_0779<
ERR Line  780 read   40 >This_is_line_no_0780This_is_line_no_0781<
ERR Line  781 read   20 >This_is_line_no_0782<
ERR Line  782 read   20 >This_is_line_no_0783<

If blocksize=200 as in the attached program, the problem exhibits much more often in all kind of strange ways:

...
OK  Line  145 read   20 >This_is_line_no_0145<
ERR Line  146 read   22 >Thihis_is_line_no_0147<
ERR Line  147 read   20 >This_is_line_no_0148<
...
ERR Line  193 read   20 >This_is_line_no_0194<
ERR Line  194 read   18 >This_is_line_no_01<
ERR Line  195 read   20 >This_is_line_no_0196<
...
ERR Line  241 read   20 >This_is_line_no_0242<
ERR Line  242 read   24 >This_iss_is_line_no_0244<
ERR Line  243 read   20 >This_is_line_no_0245<
...
ERR Line  289 read   20 >This_is_line_no_0291<
ERR Line  290 read   14 >This_is_line92<
ERR Line  291 read   20 >This_is_line_no_0293<
...

The output is generated from ifort (IFORT) 15.0.2 20150121 64-bit on Fedora 21, however, the similar behavior can be reproduced on Windows with Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.4.221 Build 20150407

Regards,

Jan

AttachmentSize
Downloadfread_test_ifort.f901.48 KB

LNK2005 error when compiling for Debug x64 (mixed C++/Fortran)

$
0
0

Hi all, I'm attempting to recompile a mixed C++/Fortran project for a x64 platform / Debug configuration but keep running into a LNK2005 error. The Fortran code is compiled to a static library while the C++ code -- which calls the Fortran code -- is compiled to a dynamic library. The error occurs when I attempt to compile the C++ code:

1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: atanf already defined in MyFortranLibrary.lib(atanf_stub.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: atan2f already defined in MyFortranLibrary.lib(atan2f_stub.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: sqrtf already defined in MyFortranLibrary.lib(sqrtf_stub.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: cosf already defined in MyFortranLibrary.lib(cosf_stub.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: sinf already defined in MyFortranLibrary.lib(sinf_stub.obj)

Here, "MyFortranLibrary.lib" is the compiled Fortran library.

Things I've tried:

  • Added ..\Intel\Composer XE 2013 SP1\compiler\lib\intel64 directory to both projects' library directories
  • Set Runtime Library > Multithread Debug DLL for both projects
  • Cleaned and rebuilt projects

This seems to be the most prevalent solution (at least as far as I know), but doesn't seem to work in my case. I am able to compile for x32/Debug, x32/Release, and x64/Release. Please let me know if I've missed any information that may help diagnose the problem. Thanks!

A bug report

$
0
0

Dear developers,

I would like to report a bug in ifort version 15.0.3 in SUSE Linux Enterprise Server 11.3(x86_64):

---

      program t
      implicit none
      integer, parameter :: o2d(1)=1
      integer            :: nloc(1,1),pauli(1,1),mom(1)
      integer            :: ih,ii
      do ii=1,1
        mom(:)=matmul((/(sum(nloc(ih,o2d(:))),ih=1,1)/),pauli(:,:))
      end do
      end program

--

This source code compiling with the ifort gives a catastrophic error. I somehow avoid this error by separating the problematic sentence(mom...). I hope that this problem will be solved in the future. Thank you very much in advance.

Best regards,

Yoshiro

 

Manifest Tool: Same option settings, different command line

$
0
0

In two projects I have the same property settings of the manifest tool. Nevertheless I get different command lines.
I have thought, the command line is just a summary of the settings. Am I wrong?

How to tame the ancient arrays?

$
0
0

The description of problem: I have a very old subprogram which was written for Microsoft Fortran v.5 (DOS, pre-windows era). There are two arrays in program code. The dimensions, the array specifications are (35,40) and (37,38). The program code was written so that it assumed that all elements of array specification that less than 1 are computed, but their values are equal 0. In Intel Fortran, the elements of array specification that less than 1 are computed with the own values. As result, the two summations give two different results of computing compared MS-Fortran and Intel Fortran. I understand that the modern Fortran operates with elements of array specification that less than 0 and negative ones. And the old code is a heritage of Fortran IV. Thus I have a question: how to lock the individual elements of array which are less than 1 and make all calculations with them are equal 0 in order to revert to the scheme of old Fortran.

Runtime issues in legacy multiple entry subroutines

$
0
0

Hi, I am in evaluation mode of your product on Windows and OS X. I am trying to get some legacy FORTRAN IV code running and I have issues with existing multiple entry point subroutines. Here is a basic sample that has the problem I am having: 
 

       DIMENSION TEST(10),NTEST(5) 
       N=5 
       CALL TESTENTRY(N,TEST,NTEST) 
       A=2. 
       B=3. 
       C=5. 
       I=2 
       CALL ENTRY1(I,A,B,C) 
       END 

       SUBROUTINE TESTENTRY(NENT,TESTENT,NTESTENT) 
       DIMENSION TESTENT(NENT),NTESTENT(NENT+1) 
       RETURN 
       ENTRY ENTRY1(ICOUNT,A,B,C) 
       DO 10 I=1,ICOUNT 
          TESTENT(I) = A*FLOAT(I) 
          NTESTENT(I) = I 
 10   CONTINUE 
       RETURN 
       END

what happens is the program logic expects the arrays to be available under ENTRY1 but they are not available, as indicated in the debugger with a breakpoint set at the first line of the do loop.  It appears the arrays and variables available in the main entry are not available in the second entry, even the integer NENT.   Is there some flag I can set for the compiler to understand this kind of FORTRAN IV style logic?

Thanks


can build a DLL, but cannot run it on another pc

$
0
0

I have built a very simple DLL using Intel fortran.  I can successfully call a routine in it from an Excel visual basic macro on my own computer, but not on another computer.  I get a message about "file not found" and "error 53".

I think the right compiler options are what I'm looking for.  Can anyone tell me what I need to do?

So far I'm doing everything with 32 bit options, and Excel is a 32 bit version.  Once I get this working, I want to get it working for 64 bit Excel.

Thanks,

Brian

 

Is it possible to call C# directly from Fortran?

$
0
0

Hello,

I know its possible to call C# from Fortran via C++. but was wondering do we some direct way to do it with the new intel compiler 2015?

Thanks

Building Linux exectuable

$
0
0

Dear all, 

I hope this is the correct forum to ask this question. I have built my fortran exectuable on Windows 7  using Parallel Studio XE 2011 with VS 2010. 

Now I will need to build a linux exectuable as well.  I was wondering if you could guide me on the easiest way to do this. 

Also is there an equivalent of Visual Studio that can be used in Linux?

I would really appreciate your response. 

Thank you very much in Advance for your help. 

 

Creating .exe file from Fortran

$
0
0

Hi, So I am very new to Fortran and just started working with Microsoft Visual Studio.

I was wondering how it is possible to export the code as .exe so it would be readable by other computers with no compiler .

Thanks, 

Arman 

Polymorphic Pointers

$
0
0

I am trying to use pointers to create links between objects. Using Fortran and here is the code piece:

 module base_pars_module
   type,abstract,public :: base_pars
   end type
 end module
 module test_parameters_module
   use base_pars_module
   type, extends(base_pars) :: test_pars
     contains
     procedure :: whoami
   end type
   contains
   function whoami(this) result(iostat)
     class( test_pars) :: this
     write(*,*) 'i am a derived type child of base_pars'
   end type
 end module
 module base_mask_module
   use base_pars module
     type, abstract , public :: base_mask
     class(base_pars),pointer :: parameters
   end type
end module
module test_mask_module
  use base_mask_module
  implicit none
  type, extends(base_mask) :: test_mask
  end type
end module
program driver
type(test_pars) , target :: par_Test
type(test_mask) :: mask_test
  iostat= par_test%whoami()
  mask_test%parameters=>par_test
  iostat=mask_test%parameters%whoami()
end program

parameters at base_mask_module is a pointer with base_pars class. I would like to use this pointer to refer par_test object which is test_pars type that extends base_pars type. So the pointer and the target has the same class. But when I compile this it gives an error:

 driver.f90:17.37:

iostat=mask_test%parameters%whoami()
                                  1
Error: 'whoami' at (1) is not a member of the 'base_pars' structure

Is it a bug or am i doing something wrong?

Viewing all 3270 articles
Browse latest View live


Latest Images

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