fortran95

Do we still need subroutines? [closed]

▼魔方 西西 提交于 2019-12-04 05:51:43
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 introduce a cascade of differences between the two. One example is the calling semantics: you can call a

Nested derived type with overloaded assignment

Deadly 提交于 2019-12-04 04:43:27
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 explicit assignment between instances of over (by uncommenting the commented code lines). Why? I find it

The mysterious nature of Fortran 90 modules

∥☆過路亽.° 提交于 2019-12-03 12:44:29
Fortran 90 modules are evanescent creatures. I was using a (singular) module for a while with some success (compiling using Intel Visual Fortran and Visual Studio 2010). Then I wrote another module and tried to USE it in another function, before receiving this error: error #7002: Error in opening the compiled module file. Check INCLUDE paths. So I deleted the offending module. But now I receive the same error after when trying to access my original module! How can I locate these mysterious creatures? Why does one module work but not two? I'm assuming that I need to delete and recompile them,

Fortran 90/95 library for sparse matrices?

拜拜、爱过 提交于 2019-12-03 02:06:15
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 actual implementation of this specification anywhere that I was able to download. I am kind of getting the

Reading a character string of unknown length

跟風遠走 提交于 2019-12-02 19:40:06
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(I) = DNA print*, I, Seq(I) X = Len_Trim( Seq(I) ) ! length of individual sequence print*, 'Sequence

fortran 95 rounding up on it's own

房东的猫 提交于 2019-12-02 12:31:33
问题 I decided to learn the fortran95 language (reason why is not important). However being a beginner I ran into a weird problem I really can't explain, therefor I need help. I have the insertion sort algorithm: subroutine insertion_sort_REAL4(array, array_len) implicit none !parameners integer :: array_len real (kind=4), dimension(array_len) :: array !variables integer :: i,key,hole_pos do i = 0,array_len key = array(i) hole_pos = i; do while ((hole_pos > 0.0) .and. (key < array(hole_pos - 1)))

Error: Expected a right parenthesis in expression at (1)

∥☆過路亽.° 提交于 2019-12-02 10:06:41
问题 its showing Expected a right parenthesis in expression, although i have checked it many times do i= 0, m-1 do j= 0, n-1 k1(i,j)=-0.001*(((y(i,j)/dx)*((0.02651995*pho(i+3,j))-(0.18941314*pho(i+2,j))+(0.79926643*pho(i+1,j))-(0.79926643*pho(i-1,j))+(0.18941314*pho(i-2,j))-(0.02651995*pho(i-3,j))))+((x(i,j)/dy)*((0.02651995*pho(i+3,j))-(0.18941314*pho(i+2,j))+(0.79926643*pho(i+1,j))-(0.79926643*pho(i-1,j))+(0.18941314*pho(i-2,j))-(0.02651995*pho(i-3, j))))) enddo enddo 回答1: If your question is

Fortran allocatable array lifetime

前提是你 提交于 2019-12-02 10:02:25
Say I have the below code: program test call foo call foo contains subroutine foo integer(8),dimension(:),allocatable:: var1 allocate(var1(10)) ... return end subroutine foo end will the variable var1 get allocated twice? (I guess YES). If it is allocated for each call, will the memory allocated during the first call becomes free? var1 will (attempt to) be allocated every time the ALLOCATE statement is executed (i.e. every time the foo procedure is called). Under the rules of Fortran 90 (only) the allocation status of foo becomes undefined when the procedure ends. A variable with undefined

Data type mismatch in fortran

孤街浪徒 提交于 2019-12-02 08:57:07
I've written a rudimentary algorithm in Fortran 95 to calculate the gradient of a function (an example of which is prescribed in the code) using central differences augmented with a procedure known as Richardson extrapolation. function f(n,x) ! The scalar multivariable function to be differentiated integer :: n real(kind = kind(1d0)) :: x(n), f f = x(1)**5.d0 + cos(x(2)) + log(x(3)) - sqrt(x(4)) end function f !=====! !=====! !=====! program gradient !==============================================================================! ! Calculates the gradient of the scalar function f at x=0using a

Error: Expected a right parenthesis in expression at (1)

早过忘川 提交于 2019-12-02 06:31:16
its showing Expected a right parenthesis in expression, although i have checked it many times do i= 0, m-1 do j= 0, n-1 k1(i,j)=-0.001*(((y(i,j)/dx)*((0.02651995*pho(i+3,j))-(0.18941314*pho(i+2,j))+(0.79926643*pho(i+1,j))-(0.79926643*pho(i-1,j))+(0.18941314*pho(i-2,j))-(0.02651995*pho(i-3,j))))+((x(i,j)/dy)*((0.02651995*pho(i+3,j))-(0.18941314*pho(i+2,j))+(0.79926643*pho(i+1,j))-(0.79926643*pho(i-1,j))+(0.18941314*pho(i-2,j))-(0.02651995*pho(i-3, j))))) enddo enddo francescalus If your question is "why?", then note that Fortran specifies a maximum line length (if the line consists solely of