gfortran

Fortran pointers to structures

萝らか妹 提交于 2019-12-20 02:04:49
问题 I have a problem assigning a pointer to a structure, to a pointer to a structure. I use gfortran 4.6.3, and the name of the file is test_pointer_struct.f08 so I am using the Fortran 2008 standard (as supported by gfortran 4.6.3). Hera comes the code: PROGRAM test_pointer_struct type tSmall integer :: a double precision :: b end type tSmall type tBig integer :: h type(tSmall), pointer :: member_small end type tBig type(tBig) :: var_big type(tSmall), pointer :: var_small(:) ! We get an array of

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

Module or main program array must have constant shape error in Fortran

拥有回忆 提交于 2019-12-19 09:38:55
问题 An integer variable declared in the module is used as a global variable to define the size of related arrays in the program. The size of program varies, so the size of array is a variable but not a parameter. It is determined at the beginning of the program. In the following snippet of code, n is the global size variable. It is declared in the module and defined at the beginning of main function/program. Similar usage of n in the main program and the subroutine contained in the main program

Is there an alternative to GETCWD() in Fortran 2003-2008

此生再无相见时 提交于 2019-12-19 07:09:21
问题 The GNU Extension to the GNU Fortran compiler provides the subroutine GETCWD() that well, gets the current working directory. However, my code has to be portable to the ifort and nagfor compiler as well and I use F2003 features. So, is there an alternative to GETCWD() for F2003 and later? I have the standard here but it's quite sizeable and I've been going through it for a while now and haven't found anything useful... 回答1: You can also use the ISO_C_Binding and call the corresponding C

Fortran runtime warning: temporary array

淺唱寂寞╮ 提交于 2019-12-19 06:00:42
问题 I get the fortran runtime warning "An array temporary was created" when running my code (compiled with gfortran) and I would like to know if there is a better way to solve this warning. My original code is something like this: allocate(flx_est(lsign,3)) allocate(flx_err(lsign,3)) do i=1,lsign call combflx_calc(flx_est(i,:),flx_err(i,:)) enddo Inside the subroutine I define the variables like this: subroutine combflx_calc(flx_est,flx_err) use,intrinsic :: ISO_Fortran_env, only: real64 implicit

Pointers in pure functions

你说的曾经没有我的故事 提交于 2019-12-18 08:32:30
问题 In order to traverse a linked list in Fortran, I use a pointer to the current element that is moved to the next one inside a loop. Trying to apply this inside a pure function that operates on said linked list results in an error. Example: module list implicit none ! Node type n_list integer :: val type(n_list),pointer :: next => NULL() end type ! Linked list type t_list type(n_list),pointer :: head end type contains pure function in_list( list, val ) result(res) implicit none class(t_list)

How do I replace my HPC gfortran with Homebrew gfortran?

纵然是瞬间 提交于 2019-12-18 07:14:36
问题 I currently have Xcode (along with command line tools) and gfrotran from HPC installed on my Yosemite system, and would like to replace HPC's gfortran with Homebrew's (because I'm having trouble building Python packages with the HPC gfortran). What are the steps to accomplish this? I want to be sure that HPC's gfortran is gone (I just want one Fortran) and Apple's tools still work (for Xcode, Swift, OS X and iOS development, etc.) and of course that I have a working version of gfortran that

GFortran and CodeBlocks issue with Modules and Multiple Files

南楼画角 提交于 2019-12-18 07:14:07
问题 I am working with GFortran and CodeBlocks but I'm having an issue about Modules and Multiple files. i keep getting this error: Fatal Error: Can't open module file 'mesh.mod' for reading at (1): No such file or directory For some reason, GFortran is not building the 'mesh.mod' file. This problem does not occur when I put all the code in a single .f90 file. Bellow is an example of code that this error happens. main.f90 MODULE MESH IMPLICIT NONE INTEGER :: IMAX,JMAX,NMAX REAL(8), ALLOCATABLE ::

Function return type mismatch

£可爱£侵袭症+ 提交于 2019-12-18 07:09:04
问题 I'm attempting to recode an old C++ program in Fortran to make use of LAPACK (I'm aware that C++ does have LAPACK++, but I'm having a lot of trouble installing it, so I gave up). I originally didn't have any problems with compilation, but that was when I had all variables declared as REAL . When I started coding the section of the program that required LAPACK, I found that all parameters passed to DSYEV need to be DOUBLE PRECISION . So I tried to change everything to double precision