fortran90

For three digit exponents Fortran drops the 'E' in the output

与世无争的帅哥 提交于 2019-11-30 14:04:46
问题 I'm just coming to Fortran90 from Python and, honestly, the hardest part so far has been getting used to the formatting codes for writing output. I've run across a formatting problem that I can't seem to google or fiddle my way out of, I have searched this site for an answer but didn't find anything helpful. I'm doing a calculation and writing the output to file. I'm formatting the results of the calculation with the following code write(file, ('13ES11.2)') kappa Some of the values are very

How can I make gfortran or ifort tell me when it implicitly promotes a REAL(4) to a REAL(8)?

懵懂的女人 提交于 2019-11-30 09:38:51
问题 I am tasked with changing the precision of parts of an HPC application, bearing in mind that it makes heavy reliance on auto-vectorisation. It is therefore useful for the compiler to inform me when conversions of any type of floating point conversion occurs (as this could have a serious performance impact). The -Wconversion flag sounds like it should suit my needs: -Wconversion Warn about implicit conversions between different types. https://gcc.gnu.org/onlinedocs/gcc-4.1.0/gfortran/Warning

Segfault when calling a function with a constant argument

怎甘沉沦 提交于 2019-11-30 09:37:38
问题 I have written this very simple code in Fortran: program su implicit none real ran3 write(*,*) ran3(0) end program su real*8 function ran3(iseed) implicit none integer iseed iseed=iseed*153941+1 ran3=float(iseed)*2.328+0.5 end function ran3 I have no problem in compiling it but when I execute the code I get this message: Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: #0 0xB76BAC8B #1 0xB76BB2DC #2 0xB77BA3FF #3 0x8048653 in ran3_ #4

For three digit exponents Fortran drops the 'E' in the output

落花浮王杯 提交于 2019-11-30 09:21:00
I'm just coming to Fortran90 from Python and, honestly, the hardest part so far has been getting used to the formatting codes for writing output. I've run across a formatting problem that I can't seem to google or fiddle my way out of, I have searched this site for an answer but didn't find anything helpful. I'm doing a calculation and writing the output to file. I'm formatting the results of the calculation with the following code write(file, ('13ES11.2)') kappa Some of the values are very small so I end up three digit negative values. So something that should look like this, 10e-100 But

How to check if Fortran array contains value?

点点圈 提交于 2019-11-30 07:56:43
I've seen this asked for other languages, but having just found out how nicely Fortran can handle arrays, I thought there might be an easy way to do this without loops. Currently I'm searching over a 3D array looking at 'nearest neighbours' to see if they contain the letter 'n', and whenever it finds this value, I want it to perform some clusterLabel assignment (which isn't relevant for this question) I wanted to use if(lastNeighArray.eq."n") then...<rest of code> but for obvious reasons it doesn't like checking an array against a value. Neither does it like me using lastNeighArray(:) , even

What does => (equals greater than) mean in Fortran?

╄→尐↘猪︶ㄣ 提交于 2019-11-30 07:28:43
问题 I'm looking through some old Fortran 90 code and have come across the => symbol: var => item It looks like it's being used for some sort of assignment. Searching Google for "arrow symbol Fortran" or "equals greater than symbol Fortran" gives me no related material. 回答1: => appears in six contexts as a syntactic element in modern Fortran, many, but not all, related to pointers: pointer assignment ; pointer initialization ; procedure (pointer) declaration ; type-bound procedure declaration ;

how to call a Fortran90 function included in a module in c++ code?

好久不见. 提交于 2019-11-30 07:16:24
问题 I m including a fortran90 program that is not mine in my C++ project . In the first stept I try to call the function by their name_() and i get the error "undefined reference to mp_mpi_cartesian_init_ "by dispalying the symbol of the obj file (using nm) i found that the function are called by their module as module_function_ so i add the module name and i Get the same problem but between fortran obj such as "Constants.f90:(.text+0x36): undefined reference to __powi4i4" here is the c++ code :

Function Returning an array in Fortran

只谈情不闲聊 提交于 2019-11-30 06:41:46
It is my understanding that you can return an array from a function in Fortran, but for some reason my code is only returning the first value in the array I am asking it to return. This is the function: function polynomialMult(npts,x,y) integer npts double precision x(npts), results(npts + 1), y(npts,npts) polynomialMult = x(1:npts) + 1 end function and this is where I'm calling it C(1:numPoints) = polynomialMult(numPoints,x,f) print *, C(1:numPoints)` right now it doesn't do anything useful because I am trying to understand the syntax before I write the logic. I saw some stuff about

Stack overflow in Fortran 90

丶灬走出姿态 提交于 2019-11-30 05:30:26
I have written a fairly large program in Fortran 90. It has been working beautifully for quite a while, but today I tried to step it up a notch and increase the problem size (it is a research non-standard FE-solver, if that helps anyone...) Now I get the "stack overflow" error message and naturally the program terminates without giving me anything useful to work with. The program starts with setting up all relevant arrays and matrices, and after that is done it prints a few lines of stats regarding this to a log-file. Even with my new, larger problem, this works fine (albeit a little slow),

Can GDB be used to print values of allocatable arrays of a derived type in Fortran 90? [duplicate]

只谈情不闲聊 提交于 2019-11-29 20:48:16
问题 This question already has answers here : Fortran print allocatable array in gdb (3 answers) Closed 4 years ago . I have the following data structure in a Fortran90 program: TYPE derivedType CHARACTER(100) :: name = ' ' INTEGER :: type = 0 REAL(KIND(1.0D0)) :: property = 0.0 END TYPE derivedType TYPE (derivedType), ALLOCATABLE, DIMENSION(:) :: arrayOfDerivedTypes When I try to debug and print values in GDB like: (gdb) p arrayOfDerivedTypes(1)%name I get non-sensical values (often strings of