fortran95

Is Fortran return statement obsolete?

穿精又带淫゛_ 提交于 2019-12-12 12:08:44
问题 I just want to know if the return statement in Fortran 2008 is obsolete, because it seems to be unnecessary to write it at the end of subroutines and functions. Does it have some other utility? 回答1: No, it is not obsolete. It is used to exit a subroutine and a function. Whenever you want to exit in the middle of a subroutine, you use RETURN . For example, when some error happens or similar. Using RETURN is an alternative to long if conditions like if (no_error) then a lot of code end if You

Autocomplete from directory in Fortran

你。 提交于 2019-12-12 04:49:35
问题 I have a little program written in Fortran which needs to read in a file. The filename is provided by the user during runtime. Now I want to emulate the bash behavior by autocompleting the filename, or cycle through available files by pressing [tab]. Since this will be only an extra bonus, and I don't have much time, I don't want to put a lot of time in such a feature. So is there may be an Ifort feature or such doing this automatically? Thanks. 回答1: I don't know any such feature in libraries

Listing the contents of a directory in Fortran [closed]

只愿长相守 提交于 2019-12-12 03:17:54
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 27 days ago . How do I get the contents of a directory in Fortran 95? 回答1: shure if we have all the files in the 'inFiles' folder, we first find out how many are there and then we read their names into an array, check this out: real :: r integer :: i,reason,NstationFiles,iStation character(LEN

FORTRAN block data seems to not be working

南笙酒味 提交于 2019-12-11 06:36:34
问题 I am working on some legacy code that relies heavily on common blocks which are initialized with BLOCK DATA similar to the code below. BLOCK DATA filename PARAMETER (size=100) CHARACTER*8 somearray(size) COMMON /block1/ somearray DATA(somearray(i), i=100)/ *'string1', 'string2', ... , 'string100'/ END At some point in the program a subroutine uses this common block as shown in the code below. SUBROUTINE SUB(array) IMPLICIT DOUBLE PRECISION (A-H,O-Z) CHARACTER*8 array(*), somearray(100) COMMON

Does the Intel Fortran 95 compiler allow module arrays to be of non-constant size?

六眼飞鱼酱① 提交于 2019-12-10 20:18:45
问题 I have downloaded a Fortran 90/95 adaptive mesh refinment library (Paramesh), and now I'm trying to compile an example program that came with it. In the process I modified the Makefile to use gfortran instead of the Intel Fortran compiler. In the library code, there is a module containing this snippet: module physicaldata ! Many many lines of variable definitions here !.... Public :: nfluxvar Integer,Save :: nfluxvar ! Many many lines of variable definitions here !.... end module physicaldata

Is there ever a reason to write .eqv. .true.?

雨燕双飞 提交于 2019-12-10 17:47:16
问题 In logic, and in *ahem* properly designed programming languages, comparing a boolean to true is always redundant, i.e. a == True should be replaced by simply a . (And similarly, a == False by not a ). Many languages, including C, don't have a proper boolean type so it can make a difference whether you compare with true (e.g. 2 == true yields 0 , which as a boolean represents false, while 2 itself can represent true). Is this also an issue in Fortran, or can I always replace a .eqv. .true. by

How to get the Fortran SUM command result to exceed 2^24 for single precision arrays

こ雲淡風輕ζ 提交于 2019-12-10 15:52:37
问题 To check memory allocations we populate single precision arrays with unit values and interrogate with the SUM and DOT_PRODUCT commands. These intrinsics stop counting after 16777216 (= 2^24). How can we get these commands to count billions of elements? We prefer to avoid DO loops. This is not a problem with higher precision arrays. program allocator use iso_fortran_env implicit NONE integer, parameter :: sp = selected_real_kind ( REAL32 ) integer, parameter :: xlint = selected_int_kind (

The mysterious nature of Fortran 90 modules

与世无争的帅哥 提交于 2019-12-09 10:02:01
问题 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

Fortran Character Input at Undefined Length

大城市里の小女人 提交于 2019-12-08 09:47:51
问题 program Test implicit none character (LEN=100) :: input character (LEN=100) :: output print *,"Please input your message: " read *, input For every character, I encrypt it in Ceaser's Cipher Calculations print *,"This is the output: " write (*,"(2a)") "Message = ", out end program Test This doesn't work entirely. For every character in the input, I convert it using the modulo(iachar()) functions. It works up until the print, I followed the debugging, the encryption is fine. But the issue with

Random array / matrix intitialisation in Fortran

断了今生、忘了曾经 提交于 2019-12-08 01:55:00
问题 Is there a way to initialise a random array without using explicit do-loops? Right now my random matrix initialisation looks like program Main implicit none save integer :: seed, i, j real :: x character(100) :: option real, dimension(10,10) :: matrix if (iargc() > 0) then CALL GETARG(1,option) read(option,*) seed else seed = 1 end if call RANDOM_SEED(seed) do i=1,10 do j=1,10 call RANDOM_NUMBER(x) matrix(i,j) = x end do end do end program But if possible I'd like it to be more along the