fortran95

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

When does a module go out of scope in Fortran 90/95?

巧了我就是萌 提交于 2019-12-29 01:43:51
问题 My intended use is program main use mod external sub call sub end program main subroutine sub ! code here calls subroutines in mod end subroutine sub Specifically, will module mod be in scope in subroutine sub ? Also, I'd be interested to know more generally when a module is in/out of scope. I'm using gfortran 4.6.1, if it matters. 回答1: It is not in scope of subroutine sub, as sub cannot call routines or use variables from mod, because sub is not part of the program main . They have nothing

Accessing variable in main program from external subroutine

痞子三分冷 提交于 2019-12-24 09:17:50
问题 I'm trying to solve a maximum likelihood problem in Fortran using the NAG optimization library, but I'm running into problems accessing the variables in the main program from the external subroutines funct and hess (see pseudo-code below). What is the best way to pass variables (e.g. b ) from the main program to such routines, given that I cannot pass them directly as arguments (a restriction of the NAG library). I have tried to implement COMMON blocks, but without much succes. MODULE user

User-defined operators in Fortran

假如想象 提交于 2019-12-23 15:26:42
问题 I had a question about the correct way of programming user-defined operators in Fortran. To be more specific, I will provide the example of my problem. I am working on creating a user-defined data type for spherical particles called 'Particle'. I want to define an operator that takes an existing array of Particle objects and adds a new Particle object to it. I was wondering how I would go about defining user defined operators to do such an action. Currently I have, within the type definition

I/O in pure Fortran procedures

萝らか妹 提交于 2019-12-23 08:50:43
问题 I'm trying to incorporate error checking within a pure procedure I am writing. I would like something like: pure real function func1(output_unit,a) implicit none integer :: a, output_unit if (a < 0) then write(output_unit,*) 'Error in function func1: argument must be a nonnegative integer. It is ', a else func1 = a/3 endif return end function func1 However, pure functions are not allowed to have IO statements to external files, so I tried passing a unit number to the function, e.g. output

Linking FORTRAN and C++ objects files

為{幸葍}努か 提交于 2019-12-23 04:14:07
问题 I am going to call a C++ function from FORTRAN, for which I am using ISO_C_Binding module. After compaction of the FORTRAN main file and C++ function with commands gfortran -c mlp8.f90 g++ -c mean_cpp.cc Which will create the objects files but in the linking phase as suggested by some members I am going to use the commands g++ mlp8.o mean_cpp.o -o main –lgfortran I.e. using C++ compiler with linking to FORTRAN libraries but it gives error like /Cygnus/cygwin-b20/H-i586-cygwin32/i586-win32/bin

Fortran: can you explain this formatting string

若如初见. 提交于 2019-12-23 01:25:08
问题 I have a Fortran program which I need to modify, so I'm reading it and trying to understand. Can you please explain what the formatting string in the following statement means: write(*,'(1p,(5x,3(1x,g20.10)))') x(jr,1:ncols) 回答1: http://www.fortran.com/F77_std/rjcnf0001-sh-13.html breifly, you are writing three general (g) format floats per line. Each float has a total field width of 20 characters and 10 places to the right of the decimal. Large magnitude numbers are in exponential form. The

Do we still need subroutines? [closed]

烂漫一生 提交于 2019-12-21 12:29:48
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 9 years ago . In Fortran, a clear difference exists between function and subroutine: functions return one value, subroutines return no value. This

Nested derived type with overloaded assignment

假如想象 提交于 2019-12-21 12:18:21
问题 I have a derived type ( wrapper ) containing an other derived type ( over ). For the latter the assignment operator have been overloaded. As the assignment of derived types happens per default componentwise, I'd expect that assigning two instances of wrapper would invoke the overloaded assignment for over at some point. However, using the program below, it does not seem to be the case. The overloaded assignment is only invoked if I also overload the assignment for wrapper containing an

Reading a character string of unknown length

依然范特西╮ 提交于 2019-12-20 09:43:10
问题 I have been tasked with writing a Fortran 95 program that will read character input from a file, and then (to start with) simply spit it back out again. The tricky part is that these lines of input are of varying length (no maximum length given) and there can be any number of lines within the file. I've used do read( 1, *, iostat = IO ) DNA ! reads to EOF -- GOOD!! if ( IO < 0 ) exit ! if EOF is reached, exit do I = I + 1 NumRec = I ! used later for total no. of records allocate( Seq(I) ) Seq