Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all 5691 articles
Browse latest View live

Interesting Observation

$
0
0

So I am sitting in a small Italian Village, as Oddball said in "Kelly's Heroes" soaking up the rays man.  

The rays yesterday were 42 and AC here is an American Dream. 

So the students I work with are pushing to some interesting areas in signal analysis for structural vibrations. Unlike most people who publish made up signals, white noise Gaussian -- 2 Hz and 200 seconds with flat Spectral Density, we deal with reality , 1/f squared signals, noisy and Brown noise base that are 800000 points long and contaminated with everyone who walks or drives a bus or a small truck.

Unfortunately the "best" code to use is the Intel IPP for what I want to do , but I am not going into C++, so I will make do with FORTRAN and MKL.  

So I was playing with the correlation function and the data supplied by Intel. They give an X sample that is 8 long and  y that is 10 offset. 

 DATA x/1,2,3,4,5,6,7,8/
      DATA y/11,12,13,14,15,16,17,18/
      DATA y1/1,2,3,4,5,6,7,8/
      DATA z/0,0,0,0,0,0,0,0,0,0,0,0,0,0/
      DATA e/88,173,254,330,400,463,518,564,448,343,250,170,104,53/
      DATA xshape/k/, yshape/k/, zshape/k2/

So if I run the sample the output is e.  But if I run the sample x and y1 the output is functionally related to Y through a polynomial. 

 

 


Trouble having an Intel Fortran program call C++ functions

$
0
0

I am trying to link a very simple C++ function to a very simple Intel Visual Fortran program.

Fortran program looks like this (In a file called VFTestBed.f90):

 program VFTestBed

 integer pInteger

 pInteger = 11

 call SimpleTest1( pInteger )

 end program

Fortran interface block looks like this (in a file called interfaces.f90):

MODULE INTERFACES

interface

subroutine SimpleTest1( pInteger)

!DEC$ATTRIBUTES DECORATE, ALIAS: "SimpleTest1"

integer pInteger

end subroutine SimpleTest1

end interface

END MODULE

C++ function looks like this (in a file called cppresponder.cpp):

#include <windows.h>
#include <sstream>

void SimpleTest1(int pInteger);

void SimpleTest1(  int pInteger)

{

      std::string pString = "";
      std::string pTitle = "";

      std::string pName = "SimpleTest1\0";

   pString = "Integer was entered.";
   pTitle = "In Routine: " + pName;

   MessageBoxA(NULL, pString.c_str(), pTitle.c_str(), MB_OK |    MB_ICONINFORMATION);

}        

I have researched this problem on Google and tried many dozens of permutations and combinations of various settings, declares, decorations, etc. all to no avail. Indeed, many of the posts were long and quite convoluted and often didn't seem to come to a successful conclusion.

Among other things I have tried:

  1. making the C++ code a .LIB
  2. making the C++ code a .DLL
  3. using various forms of !DEC$ATTRIBUTES DECORATE, ALIAS: "SimpleTest1"
  4. using BIND(C, ...)
  5. using plain aliases
  6. using decorated aliases
  7. used DUMPBIN to see the symbols in the .DLL
  8. using the preamble extern "C"
  9. compiling as C code (disables all the C++ constructs)

and a whole lot of other things. I've tried all the things that supposedly worked for other posters with absolutely no luck.

No matter what I do, I get a linker error message LNK2019 about an unresolved external symbol _SIMPLETEST1 referenced in function _MAIN__

As per the Intel site, I have added in CppResponder.DLL just like adding in a source file.

If it matters, I am using Visual Studio Enterprise 2017 and Intel Parallel Studio XE 2016 Update 4 composer Edition for Windows, all running on a 64 bit Windows 8.1 machine.

Assuming that Intel Fortran can indeed call a C++ function (I'm assuming it can) then I must be missing a switch or setting somewhere. I've set up both the Fortran and C++ projects with the defaults that Visual Studio provided. Both projects were setup as Release | x86.

Surely, this really can't be that hard of a thing to do. I've spent about 12 hours on this and have nothing to show for it. I have decades of experience with Fortran but am fairly new to C++.

Has anyone done this before and would be willing to walk me through how you did it?

Thanks in advance,

Bob Kiser

A question about comments

$
0
0

Old F77 code often has a great number of otherwise blank lines with 'C' in column 1, for spacing code.  I've even seen more recent code with '!' instead of 'C'.  This has always baffled me - why not just a blank line?  Is there a historic reason why this was needed?

VS2017+IVF2017+Windows10enterprise, VS integration failed

$
0
0

Install VS2017+IVF2017 on some PCs. Most are successful installed except one PC.

I uninstall/reinstall VS/IVF times, each time the installation is completed but VS integration does not effective. Fortran entries cannot be found in VS environment.

I found the difference is that the OS is Win10 enterprise and others are window10 professional. If I change the OS to win10 pro, everythings is OK.

I don't know if it is universal since I have only one case. Just for reference.

Using intel MKL vector math function for multi-dimensional array

$
0
0

Suppose both `a` and `b` are 1-dimensional array with size n, then we can use `vdexp(n, a, b)` to compute the b = exp(a) with MKL function `vdexp`.

When `a` is a two dimensional array with size n1*n2, which is the efficient way to use `vdexp`, a loop over columns or reshape `a` to a one-dimensional array?

 

Suppress warning 402

$
0
0

forrtl: warning (402): In call to WRITEINTEGER an array temporary was created for blablablabla

I get a crapton of these warnings everytime I compile&run my program. I've seen some suggestions in https://groups.google.com/forum/#!topic/comp.lang.fortran/euk_DCVHK_M and https://stackoverflow.com/questions/27751905/warning-message-402-an-arra... to use -check:noarg_temp_created to suppress the warning:

Ok, I am cool with suppressing the warning, but where do I place the check:noarg_temp_created if I'm using Visual Studio 2010?

PARAMETER of Defined Type

$
0
0

Hi,
Please see the following program
 

      MODULE TEST_CONSTRUCTOR
      IMPLICIT NONE
      TYPE :: ABC
        PRIVATE
        INTEGER :: I = 0
        REAL :: R = 0.0
        CONTAINS
        PROCEDURE, PUBLIC :: PRINTME
      END TYPE ABC
      !
      INTERFACE ABC
        MODULE PROCEDURE INIT_ABC
      END INTERFACE
      !
      TYPE (ABC), PARAMETER :: P = ABC(3, 4.0)
      PRIVATE
      PUBLIC :: ABC, P
      !
      CONTAINS
      !
      FUNCTION INIT_ABC(I, R) RESULT(RESULTAT)
        IMPLICIT NONE
        INTEGER, INTENT(IN) :: I
        REAL, INTENT(IN) :: R
        TYPE (ABC) :: RESULTAT
        RESULTAT % I = I
        RESULTAT % R = R
      END FUNCTION INIT_ABC
      !
      SUBROUTINE PRINTME(X)
        IMPLICIT NONE
        CLASS(ABC), INTENT(IN) :: X
        WRITE(6,10) X % I, X % R
   10   FORMAT(/,1X,"I = ",I5,5X,"R = ",ES15.6)
      END SUBROUTINE PRINTME
      !
      END MODULE TEST_CONSTRUCTOR
      !
      PROGRAM TEST_CONSTRUCTOR_PGM
      USE, NON_INTRINSIC :: TEST_CONSTRUCTOR
      IMPLICIT NONE
  !    TYPE (ABC) :: A = ABC(3, 4.0) ! Uncomment this line and I get a compilation error when INTERFACE ABC is defined.
      !
      ! Does this mean that it is impossible to have a statement like that shown below if ABC has private components?
      !
  !    TYPE (ABC), PARAMETER :: Y = ABC(1, 1.0)
      !
      TYPE (ABC) :: A
      TYPE (ABC) :: B
      B = ABC(5, 12.0)
      CALL A % PRINTME()
      CALL B % PRINTME()
      CALL P % PRINTME()
      END PROGRAM TEST_CONSTRUCTOR_PGM

The line TYPE(ABC) :: A = ABC(3, 4.0) isn't allowed because of private components.
So what do I do if I want to have a PARAMETER of derived type defined in a program, assuming I don't have access to the module?

Regards,
Svein-Atle Engeseth

 

A reference to path//myDLL.dll could not be added.please make sure that the file is accessible,and that is a valid assembly or

$
0
0

In vs2015 in visual Fortran compiler in I created console application also.so in library I have a DLL file with my project file name myDLL.dll
I created a c# web application,when I want to add myDLL file to references I got this error in reference manager:

A reference to path//myDLL.dll could not be added.please make sure that the file is accessible,and that is a valid assembly or COM component.

Which project type knows my dll?.is there any error in compile of my dll?therefore what should I do?

Best regards


Intel Fortran Compiler

$
0
0

Hello,

I had few questions about purchasing a new Intel Fortran Compiler license. Since we are an in Institute in TU Munich we want to buy academic license. I have few questions regarding:

  1. What ‘Priority Support Renewal (SSR)’ and ‘Product with priority support’ mean?
  2. License Renewal Type: Post-Expiry and Pre-expiry meaning?
  3. Are we eligible for an academic floating license with 2 or 3 seats?

I would further like to discuss about pricing and validity of licenses etc. Can anyone please clarify this.

Thanks and hope to hear soon from you.

Regards,

Swami

ICE with 17.4 and OO feature test

$
0
0

Hi all,

I played around with OO features to get familiar with it and stumbled over an ICE with PSXE 2017 update 4 (cp. attached build log).

1>------ Build started: Project: OO_Test_polymorph, Configuration: Debug x64 ------
1>Compiling with Intel(R) Visual Fortran Compiler 17.0.4.210 [Intel(R) 64]...
1>mod_fruit.f90
1>fortcom: Fatal: There has been an internal compiler error (C0000005).
1>compilation aborted for D:\02_Fortran\99_test\OO_Test_polymorph\mod_fruit.f90 (code 1)
1>smod_fruit.f90
1>OO_Test_polymorph.f90.

My test code is based on the example from Mark Leair 'Object-Oriented Programming in Fortran 2003 Part 2: Data Polymorphism' (https://gist.github.com/n-s-k/de4af7ce6cc8f2c85e4b33cedb51fd88), but I had to rework it, because of the license terms in the example header. The ICE does not occur in the original code from link above, but on a modified version of it.

Here it is:

submodule (mod_fruit) smod_fruit
  implicit none

  contains

  module subroutine initialize(fruit, color, filled, weight, price, diameter, misc)
    ! initialize shape objects
    class(fruit_t) :: fruit
    integer :: color
    logical :: filled
    integer :: weight
    integer :: price
    integer, optional :: diameter
    integer, optional :: misc

    fruit%color  = color
    fruit%filled = filled
    fruit%weight = weight
    fruit%price  = price

    select type (fruit)
    type is (fruit_t)
          ! no further initialization required
    class is (apple)
        ! rectangle or square specific initializations
        if (present(diameter))  then
           fruit%diameter = diameter
        else
           fruit%diameter = 0
        endif
        if (present(misc)) then
            fruit%misc = misc
        else
            fruit%misc = 0
        endif
    class default
      ! give error for unexpected/unsupported type
         stop 'initialize: unexpected type for sh object!'
    end select

    return

  end subroutine initialize


  !module function constructor(color, filled, weight, price)
  !      implicit none
  !      type(fruit_t) :: constructor
  !      integer :: color
  !      logical :: filled
  !      integer :: weight
  !      integer :: price
  !      call constructor%initialize(color, filled, weight, price)
  !      return
  !end function constructor


end submodule
module mod_fruit

  implicit none

  private

  type, public ::  fruit_t
      private
      integer :: color
      logical :: filled
      integer :: weight
      integer :: price
  contains
      private
      procedure :: initialize
  end type fruit_t

  type, extends(fruit_t), public :: apple
      private
      integer :: diameter
      integer :: misc
  end type apple

  type, extends(apple), public :: pi
  end type pi


  public :: constructor

  interface
    module subroutine initialize(fruit, color, filled, weight, price, diameter, misc)
          implicit none
          class(fruit_t) :: fruit
          integer :: color
          logical :: filled
          integer :: weight
          integer :: price
          integer, optional :: diameter
          integer, optional :: misc
    end subroutine
  end interface

  ! this version works fine
  !interface
  !  module function constructor(color, filled, weight, price)
  !      implicit none
  !      type(fruit_t) :: constructor
  !      integer :: color
  !      logical :: filled
  !      integer :: weight
  !      integer :: price
  !  end function constructor
  !end interface

  contains

  ! this version throws an ICE 'fortcom: Fatal: There has been an internal compiler error (C0000005).'
  function constructor(color, filled, weight, price)
        implicit none
        type(fruit_t) :: constructor
        integer :: color
        logical :: filled
        integer :: weight
        integer :: price
        call constructor%initialize(color, filled, weight, price)
        return
  end function constructor

end module
program OO_Test_polymorph
  use mod_fruit
  implicit none

  ! Variables
  type(fruit_t) :: my_fruit

  my_fruit = constructor(color=1,filled=.true.,weight=3, price=4)

end program OO_Test_polymorph

If the function 'constructor' is contained in the module mod_fruit, the ICE occurs. If only the interface is present and the function is placed in the submodule smod_fruit, the program runs fine. Is it forbidden to name a function constructor? What is wrong here.

Best regards, Johannes

AttachmentSize
Downloadtext/plainBuildLog.htm_.txt4.07 KB

FORM TEAM Fortran 2015

$
0
0

Steve,

I've read both ISO-IECJTC1-SC22-WG5_N2137_CD_revision_of_Fortran_standard_Cohen.pdf and ISO-IECJTC1-SC22-WG5_N2127_The_new_features_of_Fortran_2015_Reid.pdf and still do not completely understand the new Fortran 2015 statement FORM TEAM. Could you explain this in a manner such that someone .NOT. on the WG5 standards committee can understand.

My misunderstandings:

A thread, on some process in a 1 to N process application belongs to a team, the initial team has a team number of -1. From Reid:

The form team statement takes the general form
form team ( team-number, team-variable[, form-team-list] )
where team-number is a scalar integer expression whose value must be positive and team-variable
is a scalar variable of type team type whose values on all the images of a child team will be
defined with information about that child team. All the images of the current team that have
the same team-number value will be in the same child team. This value is the team number
for the child team and is used to identify it in statements executed in an image of another child
of the same parent. The team numbers of all the images of the initial team are always -1.

1) My interpretation is team-number is a new team number that is unique and global to all teams as oppose to an arbitrary number relative to the team forming the new team. Is this correct? Or are the new team numbers relative to the instantiating team context.

The form team statement is an image control statement. The same statement must be executed
by all active images of the current team and they synchronize.

2) My assumption is the synchronization point is at the FORM TEAM statement where all team members of the current team must reach in order to be synchronized. Statement execution following the FORM TEAM is ambiguous.

a) A new team is constructed that is (presumably) a subset of the existing team, what happens with the team members of the existing team that are not specified for the (or one of the) new team(s)?
.OR.
b) Does FORM TEAM behave somewhat like a N-way fork where portions of the existing team are distributed in a (specified) manner to each of the newly generated teams (an example was given of EVEN_ODD). IOW all former (existing) team members go somewhere.

Jim Dempsey

 

How to compile and link a many source file program efficiently from the command line

$
0
0

Hi,

I have a program consisting of a number of hundreds of subroutines residing in the same folder. How do I write the ifort command to compile and link these subroutines?  I guess a batchfile will be needed if all subroutines have to be listed. If so, can I retrieve the subroutines names from VS, which I have used until now?

Best regards

Anders S

Problems when passing derived types to subroutine

$
0
0

Hello,

i'm running in some trouble when trying to pass some derived types to subroutines for their allocation:

here some small example i created to explaining my problem:

the module containing the derived type:

module type
  implicit none
  private
  public :: mt, rk, ik, ck

  integer, parameter :: digits = 8
  integer, parameter :: decades = 9
  integer, parameter :: rk = selected_real_kind(digits)
  integer, parameter :: ik = selected_int_kind(decades)
  integer, parameter :: ck = selected_char_kind('default')

  type set
    character(kind=ck,len=80) :: name
    integer(ik), allocatable :: members(:)
  end type set

  type mytype
    type(set), allocatable :: nset(:)
  end type mytype
  type(mytype) :: mt
end module type

and the module containing the subroutines:

module allocating_sub
  use type, only : ik, rk, ck
  implicit none
  private
  public :: allocating

  interface allocating
    module procedure allocating_real_1d, allocating_int_1d, allocating_char_1d
  end interface

contains

  subroutine allocating_real_1d(vec,length)
    implicit none
    real(rk), allocatable, intent(inout) :: vec(:)
    integer(ik), intent(in) :: length

    if(allocated(vec)) deallocate(vec)
    allocate(vec(length))
  end subroutine allocating_real_1d

  subroutine allocating_int_1d(vec,length)
    implicit none
    integer(ik), allocatable, intent(inout) :: vec(:)
    integer(ik), intent(in) :: length

    if(allocated(vec)) deallocate(vec)
    allocate(vec(length))
  end subroutine allocating_int_1d

  subroutine allocating_char_1d(vec,length)
    implicit none
    character(*), allocatable, intent(inout) :: vec(:)
    integer(ik), intent(in) :: length

    if(allocated(vec)) deallocate(vec)
    allocate(vec(length))
  end subroutine allocating_char_1d

end module allocating_sub

and finaly the main part:

program test
  use type, only : ik, rk, ck, mt
  use allocating_sub
  implicit none

  integer(ik), parameter :: nnsets = 4

  call allocating (mt%nsets(:),nnsets)
end program test

 

when i try to run this i get the following error:

error #6285: There is no matching specific subroutine for this generic subroutine call.   [ALLOCATING]  

Now i am asking myself how to write a subroutine allocating_xx which is able to handle such structures.

 

the following solution works but strongly impairs the readabilty of the main code if large type-structures are used:

if (allocated(mt%nset)) deallocate(mt%nset) ; allocate(mt%nset(nnsets))

 

Best regards,

Jan

 

Integer*8 Arithmetic

$
0
0

I'm using Intel Fortran XE 2013 SP1 to modify an existing Fortran code (under Windows 7).

I'm 'upgrading' some of the INTEGERs to INTEGER*8 (from *4), but I'm then having problems with some of the arithmetic of the *8 integers.

Adding/subtracting the *8 integers all works OK, but when multiplying causes the program to 'fall-over' (I'm running it under Debug).  These particular integers all have fairly small values (<100), so cannot be an overflow problem.  (I'm not mixing *8 with *4).

Could there be a problem with Project Properties - what could be causing this ?

Thanks,

Gerald Reeves.

 

Entry point not found

$
0
0

Hi all,

I have a problem of running an  (  ).exe generated using static lib (.obj) from compiled sources of finite elements software MSC MARC, with adding to these libraries my user subroutines in order to generated new .exe of the code.  I am using VS 2013 community and Intel(R) Visual Fortran Compiler XE 15.0.  the compilation is under the platform 64. There is no errors or warnings. when I run the generated .exe I get this message:

The procedure entry point for_uninit_use_src could not be located in the dynamic link library C:\RUNN\plotv.exe.

after this not found entry, in visual studio output I have:

FTH: (9412): *** Fault tolerant heap shim applied to current process. This is usually due to previous crashes. ***
'plotv.exe' (Win32): Unloaded 'C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32\mpirt\impi.dll'
The thread 0x948 has exited with code 0 (0x0).
The thread 0x3174 has exited with code 0 (0x0).
First-chance exception at 0x00007FFA177A5AA0 (ntdll.dll) in plotv.exe: 0xC0000139: Entry Point Not Found.
The thread 0x32a8 has exited with code -1073741511 (0xc0000139).
The program '[9412] plotv.exe' has exited with code -1073741511 (0xc0000139) 'Entry Point Not Found'.

Thank you for your help.

Marmi

 


Graphic problem in Intel Fortran compiler

$
0
0

Hi, I'm a student majoring in aerospace engineering in South Korea.

Because of my major, recently I'm studying about fortran and facing many of errors.

My current issue is graphic problems.

I want to draw a 2-D graph with two 1-D array(i.e. X&Y array) data.

So I found a subroutine and below is that.

At first time, there are 4 errors of error code 2019-they are about external symbol- and a fatal error code of 1120.

After a searching for related articles in this forum, I found the way which about project option(?)

 fortran-libraries-runtime library-->quickwin

& linker-system-subsystem-->console

By setting the options like this I finally have no errors and can see a new black window.

But I still have no graph output. I have only a black window.

So, I need some help for solving this problem and  I hope you guys help me to see the graph out.

Thank you.

 

 

      SUBROUTINE grph(X,Y,IMAX,xmin,xmax,ymin,ymax)

C================================================================

        DIMENSION X(1),Y(1)

C

         RTX = 10.0 / (XMAX - XMIN)

         RTY = 10.0 / (YMAX - YMIN)

C

        ICOLG=2

        ICOLP=22

        ICOLN=49

C============================================================

         XO = -XMIN * RTX + 1.5

         YO = -YMIN * RTY - 2.5

C

        CALL PLOTS(0,1,16)

        CALL NEWPEN(0)

C

C --- X-AXIES PLOT

C

DX=(XMAX-XMIN)/10.0

XAX=xmin

   X1 =XO

   Y1 =YO

CALL PLOT(X1,Y1,3)

        DO 35 I=1,10

XAX=XAX+DX

X1 =XO+XAX*RTX

Y1=YO

CALL PLOT(X1,Y1,2)

CALL PLOT(X1,Y1+0.05,2)

CALL PLOT(X1,Y1,2)

35      CONTINUE

C --- Y-AXIES PLOT

C

DY=(YMAX-YMIN)/10.0

YAX=ymin

   X1 =XO

   Y1 =YO

CALL PLOT(X1,Y1,3)

        DO 36 I=1,10

YAX=YAX+DY

X1 =XO

Y1=YO+YAX*RTY

CALL PLOT(X1,Y1,2)

CALL PLOT(X1+0.05,Y1,2)

CALL PLOT(X1,Y1,2)

36      CONTINUE

C

C  PLOT GRAPH

call newpen(icolg)

IF(IMAX.LE.1) RETURN

DO I=2,IMAX

X1 =XO+X(I-1)*RTX

Y1 =YO+Y(I-1)*RTY

CALL PLOT(X1,Y1,3)

X1 =XO+X(I)*RTX

Y1 =YO+Y(I)*RTY

CALL PLOT(X1,Y1,2)

C CALL CIRCLE(X1,Y1,0.05,6)

ENDDO

C--------------------------------------------------------------

 RETURN

        END

C------------------------------------------------------------

C

C---------------------------------------------------------------

SUBROUTINE CIRCLE(XO,YO,R,M)

DTH=6.28385308/FLOAT(M)

THETA=0.0

X1=XO+R

Y1=YO

CALL PLOT(X1,Y1,3)

DO I=1,M

THETA=THETA+DTH

X1=XO+R*COS(THETA)

Y1=YO+R*SIN(THETA)

CALL PLOT(X1,Y1,2)

ENDDO

RETURN

END

 

 

c----------------------------------------------------------------------------------------------

c Initialize the Graphic Mode

c----------------------------------------------------------------------------------------------

SUBROUTINE plots(ii,jj,id)

      USE IFQWIN

      

LOGICAL             modestatus

INTEGER(2)          maxx, maxy

TYPE (windowconfig) myscreen

COMMON              maxx, maxy

 

c  Set highest resolution graphics mode.

if(id.gt.0) then

myscreen.numxpixels=-1

myscreen.numypixels=-1

myscreen.numtextcols=-1

myscreen.numtextrows=-1

myscreen.numcolors=-1

myscreen.fontsize=-1

myscreen.title = ""C ! blank

modestatus=SETWINDOWCONFIG(myscreen)

i=ii;  i=jj

i=i

end if

return

END

c---------------------------------------------------------------------------------------------

c  DRAWLINES - This subroutine draws a line and move the pen.

c---------------------------------------------------------------------------------------------

SUBROUTINE plot(x,y,id)

      USE IFQWIN

      

INTEGER(2) status,ix,iy

TYPE (xycoord)  xy

ix=int2(x*100.+.5);   iy=int2(700.-y*100.+.5)

if(id.eq.3) then

CALL MOVETO(ix,iy, xy )

else if (id.eq.2) then

status = LINETO(ix, iy)

endif

return

end

c------------------------------------------------------------------------------------------

c  Set the pen collor

c------------------------------------------------------------------------------------------

SUBROUTINE NEWPEN(ICOLR)

      USE IFQWIN

      

INTEGER(4) oldcolor,COLOR

C

COLR=FLOAT(ICOLR)

IF(colr.EQ.0.) THEN

color=#FFFFFF

ELSE if(colr.ge.1. .and. colr.lt.16.) then

color=#0000FF

COLOR=color+INT4(COLR*4096.)

else if(colr.ge.16. .and. colr.lt.31.) then

color=#00FFFF

COLOR=color-INT4((ICOLR-15.)*16.)

else if(colr.ge.31.  .and. colr.lt.47.) then

color=#00FF00

COLOR=color+INT4((COLR-15.)*4096.*256.)

else if(colr.ge.48.  .and. colr.lt.63.) then

color=#FFFF00

COLOR=color-INT4((COLR-48.)*4096.)

else if(colr.ge.64. ) then

color=#FF0000

COLOR=color-INT4((COLR-48.)*4096.*16.)+INT4((COLR-64.)*17.)

endif

oldcolor = SETCOLORRGB(COLOR)

return 

      END

Redistributable vs Cherry pick runtime DLLs

$
0
0

Given that I will not be doing a static linking, would it be okay to just ship 3 or 4 fortran runtime DLLs along with my installer (for using within the organization)? Or, do I have to ship the fortran runtime redist along with my installer, no matter what.?

Suppress warning 402

$
0
0

forrtl: warning (402): In call to WRITEINTEGER an array temporary was created for blablablabla

I get a crapton of these warnings everytime I compile&run my program. I've seen some suggestions in https://groups.google.com/forum/#!topic/comp.lang.fortran/euk_DCVHK_M and https://stackoverflow.com/questions/27751905/warning-message-402-an-arra... to use -check:noarg_temp_created to suppress the warning:

Ok, I am cool with suppressing the warning, but where do I place the check:noarg_temp_created if I'm using Visual Studio 2010?

PARAMETER of Defined Type

$
0
0

Hi,
Please see the following program
 

      MODULE TEST_CONSTRUCTOR
      IMPLICIT NONE
      TYPE :: ABC
        PRIVATE
        INTEGER :: I = 0
        REAL :: R = 0.0
        CONTAINS
        PROCEDURE, PUBLIC :: PRINTME
      END TYPE ABC
      !
      INTERFACE ABC
        MODULE PROCEDURE INIT_ABC
      END INTERFACE
      !
      TYPE (ABC), PARAMETER :: P = ABC(3, 4.0)
      PRIVATE
      PUBLIC :: ABC, P
      !
      CONTAINS
      !
      FUNCTION INIT_ABC(I, R) RESULT(RESULTAT)
        IMPLICIT NONE
        INTEGER, INTENT(IN) :: I
        REAL, INTENT(IN) :: R
        TYPE (ABC) :: RESULTAT
        RESULTAT % I = I
        RESULTAT % R = R
      END FUNCTION INIT_ABC
      !
      SUBROUTINE PRINTME(X)
        IMPLICIT NONE
        CLASS(ABC), INTENT(IN) :: X
        WRITE(6,10) X % I, X % R
   10   FORMAT(/,1X,"I = ",I5,5X,"R = ",ES15.6)
      END SUBROUTINE PRINTME
      !
      END MODULE TEST_CONSTRUCTOR
      !
      PROGRAM TEST_CONSTRUCTOR_PGM
      USE, NON_INTRINSIC :: TEST_CONSTRUCTOR
      IMPLICIT NONE
  !    TYPE (ABC) :: A = ABC(3, 4.0) ! Uncomment this line and I get a compilation error when INTERFACE ABC is defined.
      !
      ! Does this mean that it is impossible to have a statement like that shown below if ABC has private components?
      !
  !    TYPE (ABC), PARAMETER :: Y = ABC(1, 1.0)
      !
      TYPE (ABC) :: A
      TYPE (ABC) :: B
      B = ABC(5, 12.0)
      CALL A % PRINTME()
      CALL B % PRINTME()
      CALL P % PRINTME()
      END PROGRAM TEST_CONSTRUCTOR_PGM

The line TYPE(ABC) :: A = ABC(3, 4.0) isn't allowed because of private components.
So what do I do if I want to have a PARAMETER of derived type defined in a program, assuming I don't have access to the module?

Regards,
Svein-Atle Engeseth

 

C# call fortran dll with option argument

$
0
0

I want to use Fortran dll in C#, in  function "wrapper_integrate",  forth argument "intsteps" is an optional argument.  

My fortran code:

module integration
  implicit none
contains
  function Integrate(func, a,b, intsteps) result(integral)
    interface
      real function func(x)
        real, intent(in) :: x
      end function func
    end interface
    real :: integral, a, b
    integer :: intsteps
    intent(in) :: a, b, intsteps
    optional :: intsteps
    real :: x, dx
    integer :: i,n
    integer, parameter :: rk = kind(x)
    n = 1000
    if (present(intsteps)) n = intsteps
    dx = (b-a)/n
    integral = 0.0_rk
    do i = 1,n
      x = a + (1.0_rk * i - 0.5_rk) * dx
      integral = integral + func(x)
    end do
    integral = integral * dx
  end function
end module integration
   function wrapper_integrate(func, a, b, intsteps) result(integral) bind(C, name='wrapper_integrate')
!DEC$ ATTRIBUTES DLLEXPORT :: wrapper_integrate
  use iso_c_binding
  use Integration
  implicit none
  interface
    function func(x) bind(C)
      use, intrinsic :: iso_c_binding
      implicit none
      real(c_float), intent(in) :: x
      real(c_float) :: func
    end function func
  end interface
  real(c_float), intent(in),value :: a,b
  integer(c_int), intent(in), optional :: intsteps
  real(c_float) :: integral
  real :: local_a, local_b
  integer :: local_intsteps
  local_a = a
  local_b = b
  if (present(intsteps)) then
    local_intsteps = intsteps
    integral = Integrate(local_func, a, b, local_intsteps)
  else
    integral = Integrate(local_func, a, b)
  end if
contains
  function local_func(x)
    real, intent(in) :: x
    real :: local_func
    real(c_float) :: local_x
    local_x = x
    local_func = func(local_x)
  end function local_func
end function wrapper_integrate

My C# code in VS2013:

using System;

using System.Runtime.InteropServices;
namespace Console_use_integrate{
    class Program
    {


        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
        public delegate float ActionRefInt(ref float n);

        public ActionRefInt callbackHandler;

        public Program()
        {
            callbackHandler = new ActionRefInt(square);
        }

        public float square(ref float n)
        {
            return n*n;
        }


        static void Main(string[] args)
        {
            Program myProg2 = new Program();

            float a = 1f;
            float b = 3f;
            int step = null;
            float result;
            Console.WriteLine("Interval  from {0} to {1} ", a, b);

            result = integrate_Dll(myProg2.callbackHandler, a,  b,ref step);
            Console.WriteLine("integration result is {0}",result);
            Console.ReadKey();
        }


        [DllImport(@"integrate_Dll.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "wrapper_integrate")]
        public static extern float integrate_Dll([MarshalAs(UnmanagedType.FunctionPtr)] ActionRefInt callBack, float a, float b,ref int c);
    }

    }

Can I pass "null" if I don't want to use argument "step" which is corresponding to optional argument "intsteps" in  Fortran dll? 

 

Thanks!

Viewing all 5691 articles
Browse latest View live


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