intel-fortran

How to return a value from a Python callback in Fortran using F2Py

爱⌒轻易说出口 提交于 2019-12-24 00:49:47
问题 Consider the following Fortran subroutine, defined in test.f: subroutine test(py_func) use iso_fortran_env, only stdout => output_unit external py_func integer :: a integer :: b a = 12 write(stdout, *) a b = py_func(a) write(stdout, *) b end subroutine Also the following Python code, defined in call_test.py: import test def func(x): return x * 2 test.test(func) Compiled with the following (Intel compiler): python f2py.py -c test.f --fcompiler=intelvem -m test I expect this as output when I

Running Intel Fortran on Sublime Text 3

隐身守侯 提交于 2019-12-23 19:30:41
问题 Sublime Text 3 has a package that links the text editor to Gfortran and it runs without any problems. I would like to know how can I add Intel Fortran as a custom build to Sublime Text 3? From what I understand I need to go on build systems and create a new file with code similar to the one below (this is an example for gfortran). { "cmd": "gfortran ${file} -o ${file_base_name}", "selector": "source.modern-fortran, source.fixedform-fortran", } How could I do this for Intel Fortran? Extra:

forrtl: warning (402): fort: (1)

霸气de小男生 提交于 2019-12-23 11:56:44
问题 i get the following warning at runtime: ... forrtl: warning (402): fort: (1): In call to I/O Write routine, an array temporary was created for argument #2 forrtl: warning (402): fort: (1): In call to I/O Write routine, an array temporary was created for argument #3 forrtl: warning (402): fort: (1): In call to GERADHEIT_LINIAL, an array temporary was created for argument #2 forrtl: warning (402): fort: (1): In call to GERADHEIT_LINIAL, an array temporary was created for argument #3 ... for

Convert logical type to double in Fortran

我的未来我决定 提交于 2019-12-23 09:03:27
问题 I'm looking for a bulletproof way of converting logical type variables to real type that will work in both ifort and gfortran. The following works in ifort, but not in gfortran: logical :: a real :: b a = .true. b = dble(a) The error thrown in gfortran is b = dble(a) 1 Error: 'a' argument of 'dble' intrinsic at (1) must be a numeric type Obviously, .true. should map to 1.d0, and .false. to 0.d0. What's the best way of doing this? 回答1: I am not sure if there is an intrinsic tool that does this

Why aren't my fortran functions exported when using the BIND(C, NAME=“name”) attribute

泪湿孤枕 提交于 2019-12-22 22:52:31
问题 I am used to using the following syntax subroutine CalcA(A,N) !DEC$ ATTRIBUTES DLLEXPORT :: CALCA !DEC$ ATTRIBUTES ALIAS:'CalcA' :: CalcA IMPLICIT NONE ... end subroutine CalcA which produces an exported function in a .dll So now I am trying the new ISO_C_BINDING with the following code subroutine CalcA(A,N) BIND(C, NAME="CalcA") USE, INTRINSIC :: ISO_C_BINDING IMPLICIT NONE ... end subroutine CalcA But the export function is not created So what am I missing here? How is the new iso_c_binding

In Fortran, how do I remove Nth element from an array?

爷,独闯天下 提交于 2019-12-21 21:22:04
问题 Eg I have array (/1,3,4,5,7,9,11/), how do I remove its 3rd element? I couldn't find an array function which does that, nor I find a loop an elegant solution, since I don't know how to append to an array (this means, add an element next to the previous defined element.) I want to remove all even elements from an array... I know there is only one. I can find its index using MINLOC, but I don't know how to remove an element from array. 回答1: Let a = (/1,3,4,5,7,9,11/) then pack(a,mod(a,2)/=0)

Catch integer exceptions in Fortran

▼魔方 西西 提交于 2019-12-19 22:25:11
问题 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

Catch integer exceptions in Fortran

巧了我就是萌 提交于 2019-12-19 22:24:50
问题 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

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

孤人 提交于 2019-12-19 09:29:51
问题 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) =>

why change “complex*16” to “complex(16)” cause the runtime increased unreasonably in fortran?

此生再无相见时 提交于 2019-12-19 04:32:09
问题 This fortran code was originally written in Fortran 77 format(I will show it later). After I got it, I changed it into f90 free format via a converting tool. Using intel fortran compiler ifort , the compiation and running is just as fine as before. Then I want to do more, I want to transform nonstandard,obsolete data type declaration f77 style like: real*8 , complex*16 etc into f90 standard real(8) , complex(16) . But I found an unbelievable thing. I just changed one "complex*16" into