fortran90

Installing gfortran in Cygwin

淺唱寂寞╮ 提交于 2021-01-21 10:44:05
问题 I am trying to compile a modelling program in Cygwin using either a gfortran or g95 compiler. I have installed both compilers, but when I go to configure the program, it checks for the compilers and does not find then ( error : Fortran compiler cannot create executables) . I am new to Cygwin-- I suspect it is something with how/where I installed the compilers...Any ideas? Thank you, L. 回答1: This problem is common for beginners with autotools. It can be: missing libraries; this can be missing

Better way to mask a Fortran array?

别来无恙 提交于 2020-12-29 14:14:05
问题 I am wanting to mask a Fortran array. Here's the way I am currently doing it... where (my_array <=15.0) mask_array = 1 elsewhere mask_array = 0 end where So then I get my masked array with: masked = my_array * mask_array Is there a more concise way to do this? 回答1: Use the MERGE intrinsic function: masked = my_array * merge(1,0,my_array<=15.0) 回答2: Or, sticking with where , masked = 0 where (my_array <=15.0) masked = my_array I expect that there are differences, in speed and memory

Repeatedly used 2D array in a Fortran 90 subroutine

徘徊边缘 提交于 2020-07-23 06:33:24
问题 I have a Fortran 90 program that is of the structure shown below. The step compute the 2D array myMatrix(1:N,1:N) in the subroutinne A is expensive. It depends only on the global variable N and it needs to be computed only once; the "other steps" in the subroutine will not change the value of myMatrix. Currently, myMatrix will be calculated whenever the subroutine is called. Is there a way to write the program in a way that the 2D array myMatrix is calculated only once? module constants

Repeatedly used 2D array in a Fortran 90 subroutine

安稳与你 提交于 2020-07-23 06:31:30
问题 I have a Fortran 90 program that is of the structure shown below. The step compute the 2D array myMatrix(1:N,1:N) in the subroutinne A is expensive. It depends only on the global variable N and it needs to be computed only once; the "other steps" in the subroutine will not change the value of myMatrix. Currently, myMatrix will be calculated whenever the subroutine is called. Is there a way to write the program in a way that the 2D array myMatrix is calculated only once? module constants

Repeatedly used 2D array in a Fortran 90 subroutine

馋奶兔 提交于 2020-07-16 06:43:42
问题 I have a Fortran 90 program that is of the structure shown below. The step compute the 2D array myMatrix(1:N,1:N) in the subroutinne A is expensive. It depends only on the global variable N and it needs to be computed only once; the "other steps" in the subroutine will not change the value of myMatrix. Currently, myMatrix will be calculated whenever the subroutine is called. Is there a way to write the program in a way that the 2D array myMatrix is calculated only once? module constants

Passing parameter as parameter in Fortran-90?

前提是你 提交于 2020-05-29 06:55:06
问题 Suppose I have a subroutine: subroutine foo(x, Nx) implicit none integer, intent(IN) :: x integer, intent(IN) :: Nx select case(x) case (1) write(*,*) "Minimum value" case (Nx) write(*,*) "Maximum value" case default write(*,*) "Somewhere in-between" end select end subroutine foo Suppose my driver looks like this: program main implicit none interface subroutine foo(x,Nx) integer, intent(IN) :: x integer, intent(IN) :: Nx end subroutine foo end interface integer, parameter :: Nx = 100 integer

The name of a subroutine can be a variable in Fortran? [duplicate]

瘦欲@ 提交于 2020-04-06 01:54:45
问题 This question already has answers here : How to alias a function name in Fortran (2 answers) Closed 4 years ago . I was wondering if there is something similar to this in Fortran. Of course this example does not compile but I think you can get the idea. program test character(1):: sub sub='A' call sub sub='B' call sub end program subroutine A print*,'OK! A' end subroutine A subroutine B print*,'OK! B' end subroutine B 回答1: You cannot accomplish this by setting a character variable, but you