fortran

Passed array with more elements that expected in subroutine

痞子三分冷 提交于 2021-02-08 05:17:46
问题 I have a subroutine in a shared library: SUBROUTINE DLLSUBR(ARR) IMPLICIT NONE INTEGER, PARAMETER :: N = 2 REAL ARR(0:N) arr(0) = 0 arr(1) = 1 arr(2) = 2 END And let's assume I will call it from executable by: REAL ARR(0:3) CALL DLLSUBR(ARR) Note: The code happily compiles and runs (DLLSUBR is inside a module) without any warning or error in Debug + /check:all option switched on. Could this lead to memory corruption or some weird behaviour? Where I can find info about passing array with

Passed array with more elements that expected in subroutine

无人久伴 提交于 2021-02-08 05:14:30
问题 I have a subroutine in a shared library: SUBROUTINE DLLSUBR(ARR) IMPLICIT NONE INTEGER, PARAMETER :: N = 2 REAL ARR(0:N) arr(0) = 0 arr(1) = 1 arr(2) = 2 END And let's assume I will call it from executable by: REAL ARR(0:3) CALL DLLSUBR(ARR) Note: The code happily compiles and runs (DLLSUBR is inside a module) without any warning or error in Debug + /check:all option switched on. Could this lead to memory corruption or some weird behaviour? Where I can find info about passing array with

Passed array with more elements that expected in subroutine

喜欢而已 提交于 2021-02-08 05:14:21
问题 I have a subroutine in a shared library: SUBROUTINE DLLSUBR(ARR) IMPLICIT NONE INTEGER, PARAMETER :: N = 2 REAL ARR(0:N) arr(0) = 0 arr(1) = 1 arr(2) = 2 END And let's assume I will call it from executable by: REAL ARR(0:3) CALL DLLSUBR(ARR) Note: The code happily compiles and runs (DLLSUBR is inside a module) without any warning or error in Debug + /check:all option switched on. Could this lead to memory corruption or some weird behaviour? Where I can find info about passing array with

Fortran: passing arbitrary “structures” to a module subroutine

﹥>﹥吖頭↗ 提交于 2021-02-08 04:41:40
问题 I'm trying to write a general use subroutine for minimization. As I want to have a general purpose subroutine, the objective functions can have different parameters, not just in names, but in dimensions too. So I need a way to pass that parameter structure (I'm using the word structure because my idea is to use something like a structure type variable in Matlab). I managed to use the derived data type, which worked just fine, but the problem arises when I have two different objective

Fortran: passing arbitrary “structures” to a module subroutine

眉间皱痕 提交于 2021-02-08 04:41:05
问题 I'm trying to write a general use subroutine for minimization. As I want to have a general purpose subroutine, the objective functions can have different parameters, not just in names, but in dimensions too. So I need a way to pass that parameter structure (I'm using the word structure because my idea is to use something like a structure type variable in Matlab). I managed to use the derived data type, which worked just fine, but the problem arises when I have two different objective

Using parallel NetCDF to save a distributed 3D complex array

北城余情 提交于 2021-02-08 03:46:28
问题 I have an MPI-based program written in Fortran which produces a 3D array of complex data at each node (sections of a 2D time-series). I would like to use parallel I/O to write these arrays to a single file which can be relatively easily opened in python for further analysis/visualization. Ideally I would like the solution to be memory efficient (i.e. avoid the creation of intermediate temporary arrays). Using NetCDF, I have managed to adapt a subroutine which achieves this for a 3D array of

Numerical equivalent of TRUE is -1?

一曲冷凌霜 提交于 2021-02-08 03:41:37
问题 I am using Intel Fortran in Visual Studio 2012 to compile a Fortran code. When I try to use logical operators I have noticed that a standalone logical expression results in T or F as expected. However, if I need the numerical T or F (0 or 1), I get a -1 when logical result is T. For example: integer*4 a a = 1 logicval = (node(5,L).gt.0) numval = 1*(node(5,L).gt.0) write(*,*) logicval, numval would output T, -1 Is there a way in which I can redefine numerical values assigned to T & F? 回答1: Yes

Using MPI-IO to write Fortran-formatted files

我与影子孤独终老i 提交于 2021-02-08 03:21:14
问题 I am trying to save a solution using the OVERFLOW-PLOT3D q-file format (defined here: http://overflow.larc.nasa.gov/files/2014/06/Appendix_A.pdf). For a single grid, it is basically, READ(1) NGRID READ(1) JD,KD,LD,NQ,NQC READ(1) REFMACH,ALPHA,REY,TIME,GAMINF,BETA,TINF, & IGAM,HTINF,HT1,HT2,RGAS1,RGAS2, & FSMACH,TVREF,DTVREF READ(1) ((((Q(J,K,L,N),J=1,JD),K=1,KD),L=1,LD),N=1,NQ) All of the variables are double precision numbers, excepts for NGRID, JD, KD, LD, NQ, NQC and IGAM which are

Using MPI-IO to write Fortran-formatted files

僤鯓⒐⒋嵵緔 提交于 2021-02-08 03:21:01
问题 I am trying to save a solution using the OVERFLOW-PLOT3D q-file format (defined here: http://overflow.larc.nasa.gov/files/2014/06/Appendix_A.pdf). For a single grid, it is basically, READ(1) NGRID READ(1) JD,KD,LD,NQ,NQC READ(1) REFMACH,ALPHA,REY,TIME,GAMINF,BETA,TINF, & IGAM,HTINF,HT1,HT2,RGAS1,RGAS2, & FSMACH,TVREF,DTVREF READ(1) ((((Q(J,K,L,N),J=1,JD),K=1,KD),L=1,LD),N=1,NQ) All of the variables are double precision numbers, excepts for NGRID, JD, KD, LD, NQ, NQC and IGAM which are

checking for self-assignment in fortran overloaded assignment

倾然丶 夕夏残阳落幕 提交于 2021-02-07 21:11:20
问题 I am trying to implement a polynomial class with fortran 2003, with overloaded arithmetic operations and assignments. The derived type maintains allocatable list of term definitions and coefficients, like this type polynomial private type(monomial),dimension(:),allocatable :: term double precision,dimension(:),allocatable :: coef integer :: nterms=0 contains ... end type polynomial interface assignment(=) module procedure :: polynomial_assignment end interface ... contains elemental