gfortran

Flush-to-zero in gfortran

眉间皱痕 提交于 2019-12-10 13:44:02
问题 Is there a way to force flush-to-zero of underflows in gfortran? I can't believe this is the first time someone has asked this, but I couldn't find anything on it anywhere. Mea culpa if this is a duplicate. 回答1: You can accomplish this with recent versions of gfortran that support the Fortran 2003 IEEE modules. The standard defines two underflow modes -- gradual and abrupt. Abrupt is the one you want which sets underflow to 0 and signals the underflow floating point exception. You can test

Combining F77 and F95 fortran code

ⅰ亾dé卋堺 提交于 2019-12-10 12:16:54
问题 I'm working on some scientific code that is mostly F77 but also some F95. In places, I need to include F77 code into my F95 code. Is there a way to get this code to play nicely within my code by using a particular compiler flag or something? I'm using gfortran and occasionally ifort. It is possible for me to modify the legacy code but I would need to do it in a sensible way to maintain backwards compatibility with other F77 code while also being forwards compatible with F95 code. I get errors

Problems with porting a fortran program from ubuntu to windows

人走茶凉 提交于 2019-12-10 12:11:16
问题 I previously had some troubles updating old code that still needed a not supported compiler and expensive libraries to a version with gfortran in Eclipse on Windows. I let it rest for a while and recently I took a whole other approach, rebuilding the program from scratch, developping on a ubuntu machine, but now I want to bring it back to a windows machine so that my co-workers can contribute on it. The status: Program compiles, runs and gives good results on an ubuntu machine with the GCC

Segmentation fault occurs at top of subroutine when C code calls Fortran subroutine

烂漫一生 提交于 2019-12-10 11:56:46
问题 I have C++ code in file test-Q.cpp that calls a Fortran subroutine in file getqpf.F . In file test-Q.cpp , I've declared the Fortran code as external, and I am calling the function using the getqpf_() name-mangling convention. The gcc and gfortran compilers are being used on GNU/Linux. Here is a snippet from the top of the C++ file: extern "C" { void getqpf_ (double *tri, int nsamp, int lwin, int nfreqfit, double dt, float null, int L2, double df, double *qq, double *pf, double *ampls, double

Errors in linking fortran code that imports a MAT-file [duplicate]

强颜欢笑 提交于 2019-12-10 11:42:21
问题 This question already has an answer here : Reading data from matlab files into C (1 answer) Closed 4 years ago . I have to import a MAT-file in a fortran program. I followed the example file but I am facing some problems while linking. The compilation happens fine. Minimal code: #include "fintrf.h" PROGRAM main USE ssa USE dmotifs USE param IMPLICIT NONE ! MAT-FILE Declarations ! INTEGER matOpen, matGetDir INTEGER matGetVariableInfo INTEGER mp, dir, adir(100), pa INTEGER mxGetM, mxGetN,

How to specify procedures to be executed depending on data type of variable

三世轮回 提交于 2019-12-10 11:27:11
问题 I'm writing a module that access images and reads pixel values. The values in the images are usually of different data types ( integer(2) , integer(4) , ...). Up to now, type image is defined in the following way: type, public :: image logical :: initialized = .false. character(256) :: path = "" ! Path to image integer :: dimensions(3) = -1 ! Dimensions of image integer :: datatype = 0 ! Datatype contains procedure :: initialize procedure :: pxvalues procedure :: getMeta end type image My

Read C++ 'Hello World' from Fortran

二次信任 提交于 2019-12-10 10:25:11
问题 I'm trying to verify a a simple hello world function written in c++ can be called from a FORTRAN script (gfortran 4.9.20. I have little experience with both c++ and FORTRAN so I thought this is were I should start. //code.cpp #include <iostream> extern "C" { void worker(); int main() { worker(); } void worker() { std::cout << "Hello, World!\n"; } } and a header as follows //code.h #include "code.cpp" extern "C" { void worker(); } I was able to call my hello function in c++ with the simple

gfortran is not working on Mac OS X 10.9 (Mavericks)

旧街凉风 提交于 2019-12-10 06:06:23
问题 Recently, I updated my OS X to 10.9 (Mavericks); unfortunately, gfortran stops working although I updated Xcode command line to 5.1.1 for OS X Mavericks. Similar question has been asked sometime ago, here, but I don't think so the issue is sorted out. here is what I did: first I removed the existing gfortran bash-3.2$ sudo rm -r /usr/local/gfortran /usr/local/bin/gfortran Then I downloaded gfortran-4.9-bin.tar, and unzip it and installed successfully bash-3.2$ gunzip gfortran-4.9-bin.tar bash

Does gfortran take advantage of DO CONCURRENT?

空扰寡人 提交于 2019-12-10 03:26:26
问题 I'm currently using gfortran 4.9.2 and I was wondering if the compiler actually know hows to take advantage of the DO CONCURRENT construct (Fortran 2008). I know that the compiler "supports" it, but it is not clear what that entails. For example, if automatic parallelization is turned on (with some number of threads specified), does the compiler know how to parallelize a do concurrent loop? Edit: As mentioned in the comment, this previous question on SO is very similar to mine, but it is from

Removing whitespace in string

。_饼干妹妹 提交于 2019-12-09 19:25:43
问题 I have the following code: program main character (len=15) :: abc = "te st tex t" print *, trim(abc) end program main Which outputs: te st tex t I excepted all the whitespace to be removed but it wasn't. How can I remove all the whitespace from the string? 回答1: Trim will remove spaces only at the edges, not in the middle (this is common behaviour on almost all languages/libraries). If you want to remove all spaces in the string, you will have to create your own function to do this, iterating