intel-fortran

Intrinsic Assignment and Polymorphism in Fortran 2003

混江龙づ霸主 提交于 2019-12-01 23:39:30
I tried adding a procedure to this module , written by @VladimirF , that implements a generic linked list in Fortran 2003. I wanted to be able to output the contents of the list as an array for convenience, so I added the following procedure to a lists module in a file called lists.f90 : subroutine list_as_array(self, arrayOut) class(list),intent(inout) :: self class(*),dimension(1:self%length),intent(out) :: arrayOut integer :: i type(list_node), pointer :: nodeIter nodeIter = self%first do i = 1,self%length arrayOut(i) = nodeIter%item ! <---ERROR here if (i<self%length) then nodeIter =

Catch integer exceptions in Fortran

徘徊边缘 提交于 2019-12-01 22:03:28
Is there a way to catch integer exceptions with gfortran or ifort like there is for catching floating point exceptions? Consider this simple program to calculate the factorial: program factorial use, intrinsic :: iso_fortran_env implicit none integer(8) :: fac real(REAL64) :: facR integer,parameter :: maxOrder = 30 integer :: i fac = 1 ; facR = 1.e0_REAL64 do i=2,maxOrder fac=fac*i ; facR=facR*real(i,REAL64) write(*,*) i, fac, facR enddo ! i end program At some point there will be an overflow - for integer(8) as shown here, it will occur at around 21. But without the calculation using floats

Fortran 'parameter' type not included in compiled object

∥☆過路亽.° 提交于 2019-12-01 18:42:17
I have a Fortran module that contains some variables that have the attribute parameter and some have the attribute save . The parameter ones are not included in the compiled object, which becomes a problem when trying to assemble a library. For example, consider a file testModule.f90 : module testMOD integer, save :: thisIsSaved = 1 integer, parameter :: thisIsParametered = 2 end module testMOD I compile this with: ifort -c testModule.f90 . When I check what's inside it: >$ nm testModule.o 0000000000000000 T testmod._ 0000000000000000 D testmod_mp_thisissaved_ only the thisIsSaved variable is

Program crash for array copy with ifort

回眸只為那壹抹淺笑 提交于 2019-12-01 17:11:51
This program crashes with Illegal instruction: 4 on MacOSX Lion and ifort (IFORT) 12.1.0 20111011 program foo real, pointer :: a(:,:), b(:,:) allocate(a(5400, 5400)) allocate(b(5400, 3600)) a=1.0 b(:, 1:3600) = a(:, 1:3600) print *, a print *, b deallocate(a) deallocate(b) end program The same program works with gfortran. I don't see any problem. Any ideas ? Unrolling the copy and performing the explicit loop over the columns works in both compilers. Note that with allocatable instead of pointer I have no problems. The behavior is the same if the statement is either inside a module or not. I

Program crash for array copy with ifort

感情迁移 提交于 2019-12-01 16:11:49
问题 This program crashes with Illegal instruction: 4 on MacOSX Lion and ifort (IFORT) 12.1.0 20111011 program foo real, pointer :: a(:,:), b(:,:) allocate(a(5400, 5400)) allocate(b(5400, 3600)) a=1.0 b(:, 1:3600) = a(:, 1:3600) print *, a print *, b deallocate(a) deallocate(b) end program The same program works with gfortran. I don't see any problem. Any ideas ? Unrolling the copy and performing the explicit loop over the columns works in both compilers. Note that with allocatable instead of

Reading bad values from binary file in Fortran with a defined input procedure

谁都会走 提交于 2019-12-01 08:13:45
I'm trying to write a simple code, which takes some objects with the same parental abstract class, stores them into a binary file and reads them back. My code looks like this: module m implicit none type :: container class(a), allocatable :: item end type container type, abstract :: a character(20), public :: obj_type integer, public :: num contains procedure :: write_impl => write_a procedure :: read_impl => read_a generic :: write(unformatted) => write_impl generic :: read(unformatted) => read_impl end type a type, extends(a) :: b integer, public :: num2 contains procedure :: write_impl =>

Intrinsic Assignment and Polymorphism in Fortran 2003

巧了我就是萌 提交于 2019-12-01 07:52:34
问题 I tried adding a procedure to this module, written by @VladimirF, that implements a generic linked list in Fortran 2003. I wanted to be able to output the contents of the list as an array for convenience, so I added the following procedure to a lists module in a file called lists.f90 : subroutine list_as_array(self, arrayOut) class(list),intent(inout) :: self class(*),dimension(1:self%length),intent(out) :: arrayOut integer :: i type(list_node), pointer :: nodeIter nodeIter = self%first do i

Fortran - Return an anonymous function from subroutine

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 06:31:36
I am trying to generalize a function call from a subroutine. So my idea is something like this if (case1) then call MainSubroutine1(myFun) elseif (case2) call MainSubroutine2(myFun) end if do i = 1,4 data = myFun(i) end do I realize this is kind of vague but I am not sure if this is possible. Thank you, John edit 1/31/14 7:57 AM I am sorry for the vague way I phrased this. I was thinking something similar to what @haraldki did but I was hoping that I could define an anonymous function within MainSubroutine1 and MainSubroutine2 and transfer that definition out to the main code. This is because

Fortran dynamic libraries, load at runtime?

穿精又带淫゛_ 提交于 2019-12-01 00:08:15
Is it possible to have a Fortran program load a Fortran library at run time? If so, would it be possible to modify a function and recompile only the library to have the originally-compiled program call the modified function in the library at run time? If anyone can provide a minimal working example of how this could be achieved that would be great. Here are some few links that can be helpfull: This page on rosettacode.org which gives complete example with details and discuss implementation on linux and MACOS This intel forum post where Steve Lionel give some advice on how to do the dynamic

how to write a huge matrix to file row by row (fortran 90)

早过忘川 提交于 2019-11-30 10:54:07
I want to write a matrix with a lot of data to a file row by row. For example, I have a matrix 100*100 and I want to have it in form 100*100 in the file. However, it doesn't work.Following is my code and some description. N and M are integers around some hundreds. RECL is expected length I set the file but here it seems this command does not work. The output is with 198 lines when N is set 99 and M is set 200. Vec is a double precision complex matrix. How could I output the values of Vec keeping its original format N*M? My compile command is "ifort -o out test.f90". open(unit=2, file='graph1