fortran90

Open and read data in one row in fortran 90

牧云@^-^@ 提交于 2020-01-02 05:29:05
问题 I did some dummy code to learn to open and read file. Let's say I have the following test.dat which reads 1 2 3 4 5 6 7 8 9 10 I wrote the following code to open and read the data file subroutine readdata implicit none integer :: j double precision :: test open(unit = 100, file = 'test.dat', status = 'old', action = 'read') do j = 1, 10 read(100,*) test print *, 'N1=', test end do end subroutine The output is shown below, as expected gfortran -g -I/usr/include -o main main.o subroutines.o -L

Fortran 90 - “Segmentation fault - invalid memory reference” with scalable 3D array

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-02 01:17:07
问题 I have compiled a fortran 90 program with gfortran which builds a scalable 3D array in a way I want. Upon running, I get the following error: Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: #0 0x10542ee42 #1 0x10542f60e #2 0x7fff8d7895a9 #3 0x10542575e #4 0x105425975 #5 0x105425d0e Segmentation fault: 11 I believe this is a memory issue with the large 3D array, as it works if I decrease the dimensions, but is there anyway to get around

Python reading unformatted direct access Fortran 90 gives incorrect output

故事扮演 提交于 2020-01-01 16:56:15
问题 Here is how the data is written (its a 2-D matrix of floats. I am not sure the size). open(unit=51,file='rmsd/'//nn_output,form='unformatted',access='direct',status='replace',& recl=Npoints*sizeofreal) !a bunch of code omitted write(51,rec=idx-nstart+1) (real(dist(jdx)),jdx=1,Npoints) Here is how I am trying to read the file, inspired from the answer to these similar questions: 1, 2. f = open(inputfilename,'rb') field = np.fromfile(f,dtype='float64') But the result is not correct. The

Fortran 90/95 library for sparse matrices?

 ̄綄美尐妖づ 提交于 2019-12-31 20:31:51
问题 I am looking for a library for dealing with sparse matrices in fortran 90/95. I only need very basic operations like matrix-vector multiplication. What do you suggest I use? I have searched around and an extension(?) to BLAS called "sparse blas", documented in chapter 3 of the blast technical forum specification: http://www.netlib.org/blas/blast-forum/, seems ideal. According to that document, there should be a fortran 95 interface to the library. However, I haven't been able to find an

Zero indexed array in Fortran? [duplicate]

安稳与你 提交于 2019-12-31 05:25:30
问题 This question already has answers here : Array First Index in Fortran (2 answers) Closed last year . Can someone explain what is zero indexed array in Fortran along with example. I'm not getting any content on that on internet. 回答1: A zero indexed array is an array who's index origin is ZERO . This means that the first element of the array is referenced by index 0 . Fortran arrays defaultly start with index 1 when you declare them INTEGER, DIMENSION(3) :: v Here, the symbol v represents a one

Error in Derived type declaration: Variable at (1) in this context must be constant

孤人 提交于 2019-12-31 02:58:12
问题 I have a derived type declared in a module like this: MODULE dmotifs TYPE :: PRM INTEGER, PRIVATE :: nsp=4,nrx=8,maxprx=4 REAL, PRIVATE :: cref=1e-6,tref=1 REAL, DIMENSION(nrx,maxprx) :: k REAL :: input END TYPE PRM CONTAINS SUBROUTINE unreg(y,param,r,s) TYPE(PRM), INTENT(IN) :: param REAL, DIMENSION(param%nsp), INTENT(IN) :: y INTEGER, DIMENSION(param%nsp,param%nrx), INTENT(OUT) :: s=0 REAL, DIMENSION(param%nrx,1), INTENT(OUT) :: r=0 REAL :: mOut, mCtrl, pOut, pCtrl mOut=y(ind_mOut) mCtrl=y

Fortran 90 difference between compaq visual fortran and gfortran

吃可爱长大的小学妹 提交于 2019-12-30 16:27:12
问题 This may be a specific question, but I think it pertains to how memory is handled with these two compilers (Compaq visual Fortran Optimizing Compiler Version 6.5 and minGW). I am trying to get an idea of best practices with using pointers in Fortran 90 (which I must use). Here is an example code, which should work "out of the box" with one warning from a gfortran compiler: "POINTER valued function appears on RHS of assignment", and no warnings from the other compiler. module vectorField_mod

Writing robust and “modern” Fortran code

梦想与她 提交于 2019-12-29 10:08:48
问题 In some scientific environments, you often cannot go without FORTRAN as most of the developers only know that idiom, and there is lot of legacy code and related experience. And frankly, there are not many other cross-platform options for high performance programming (C++ would do the task, but the syntax, zero-starting arrays, and pointers are not compatible with some people). So, let's assume a new project must use Fortran 90, but I want to build the most modern software architecture out of

Writing robust and “modern” Fortran code

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-29 10:08:23
问题 In some scientific environments, you often cannot go without FORTRAN as most of the developers only know that idiom, and there is lot of legacy code and related experience. And frankly, there are not many other cross-platform options for high performance programming (C++ would do the task, but the syntax, zero-starting arrays, and pointers are not compatible with some people). So, let's assume a new project must use Fortran 90, but I want to build the most modern software architecture out of

How to use gfortran for Fortran 90 with .for file extension?

杀马特。学长 韩版系。学妹 提交于 2019-12-29 09:14:13
问题 After I installed Gfortran in Ubuntu (16.04) is pointing to f95. I see in gfortran manual that -std option can be given for f95 and forward. The default -std option value I see from manual is "gnu". I am not sure of implications of internals of compiling if I use f95 for f90 code. How do I use gfortran for Fortran 90 files with .for extension? I do not want to use Fortran 95 compiler for Fortran 90 code though Fortran 95 might be able to (not sure) compile Fortran 90. 回答1: Fortran 90 is dead.