fortran90

Calling a subroutine multiple times with different function as argument each time

会有一股神秘感。 提交于 2020-01-06 20:08:10
问题 I'm enough of a novice to not know the terminology, so I can't search the Web for the answer to this. More than once, in programming, I've wanted to do something like this. A and B are subroutines, c and d are functions. A and B each call a function multiple times inside them. call A(c(x)) call A(d(x)) call B(c(x)) call B(d(x)) This structure doesn't work. I'm told that Fortran doesn't support aliasing of functions, at least in this context. (Most search results involving "aliasing" refer to

CMake collect and process all source files in top directory

被刻印的时光 ゝ 提交于 2020-01-06 20:00:04
问题 I am trying to collect and process all source files in the top directory, to deal with the fact that variables are not passed to sub directories. I have cobbled together the following CMakeLists.txt files: cmake_minimum_required(VERSION 2.8) project(main) enable_language(Fortran) enable_testing() set (CMAKE_Fortran_COMPILER ifort) set (CMAKE_Fortran_FLAGS " -g -C -fixed") set (CMAKE_Fortran95_FLAGS " -openmp ") # function to collect all the sources from sub-directories # into a single list

CMake collect and process all source files in top directory

孤街浪徒 提交于 2020-01-06 19:58:22
问题 I am trying to collect and process all source files in the top directory, to deal with the fact that variables are not passed to sub directories. I have cobbled together the following CMakeLists.txt files: cmake_minimum_required(VERSION 2.8) project(main) enable_language(Fortran) enable_testing() set (CMAKE_Fortran_COMPILER ifort) set (CMAKE_Fortran_FLAGS " -g -C -fixed") set (CMAKE_Fortran95_FLAGS " -openmp ") # function to collect all the sources from sub-directories # into a single list

MPI convention for index of rows and columns

一曲冷凌霜 提交于 2020-01-06 07:14:00
问题 I am using MPI for solving PDE. For this, I breakdown the 2D domain into different cells (size of each of these cells is " xcell,ycell " with xcell = size_x_domain/(number of X subdomains) and ycell = size_y_domain/(number of Y subdomains) . So, I am running the code with number of processes = (number of X subdomains)*(number of Y subdomains) The gain relatively to sequential version is that I communicate between each process representing the sub-domains. Here a figure illustrating my

Sparse Storage in Fortran: Only Reading and Writing

孤人 提交于 2020-01-06 06:02:48
问题 I have an array with multiple dimensions (the goal is to allow for about 100) and each dimension has a size of about 2^10 and I only need to store in it about 1000 double precision coefficients. I don't need to do any operation with this array aside from reading and writing into it. The code is written in Fortran 90. I assume that if I a library like one of the ones mentioned in this answer I would be able to store the do this, but would this be optimized for the simple reading and writing

Convert FORTRAN DEC UNION/MAP extensions to anything else

陌路散爱 提交于 2020-01-05 05:28:07
问题 Edit: Gfortran 6 now supports these extensions :) I have some old f77 code that extensively uses UNIONs and MAPs. I need to compile this using gfortran, which does not support these extensions. I have figured out how to convert all non-supported extensions except for these and I am at a loss. I have had several thoughts on possible approaches, but haven't been able to successfully implement anything. I need for the existing UDTs to be accessed in the same way that they currently are; I can

Different syntaxes to declare arrays: with and without the dimension statement [duplicate]

亡梦爱人 提交于 2020-01-04 10:05:11
问题 This question already has answers here : Array declaration in Fortran (2 answers) Closed last year . I'm using gfortran version 7.2.0. I'm quite new to Fortran. I know there are different versions of Fortran. In the code below, I'm declaring arrays (or actually tensors) using different syntaxes program arrays implicit none integer :: m(3, 4) integer, dimension(3, 4) :: n print *, "m = ", m print *, "n = ", n end program arrays In one case, I'm using the dimension statement, in the other I am

Smart printing of integers in fortran90

你说的曾经没有我的故事 提交于 2020-01-03 11:25:12
问题 I'm learning Fortran90 after a brief introduction to Fortran77 a few years ago. When printing integers in Fortran, you must specify how many spaces you want to reserve for printing the integer. Consider this program... implicit none integer :: i i = 123 write(*, '(A, I3, A)') "'", i, "'" !3 spaces for output = no padding write(*, '(A, I5, A)') "'", i, "'" !5 is too many, so output is padded write(*, '(A, I2, A)') "'", i, "'" !2 is too few, so output is jibberish write(*, '(A, I:, A)') "'", i,

Smart printing of integers in fortran90

戏子无情 提交于 2020-01-03 11:25:07
问题 I'm learning Fortran90 after a brief introduction to Fortran77 a few years ago. When printing integers in Fortran, you must specify how many spaces you want to reserve for printing the integer. Consider this program... implicit none integer :: i i = 123 write(*, '(A, I3, A)') "'", i, "'" !3 spaces for output = no padding write(*, '(A, I5, A)') "'", i, "'" !5 is too many, so output is padded write(*, '(A, I2, A)') "'", i, "'" !2 is too few, so output is jibberish write(*, '(A, I:, A)') "'", i,

passing assumed-shape arrays in two levels of subroutines (Fortran 90)

為{幸葍}努か 提交于 2020-01-02 05:39:07
问题 I have had problems calling successive subroutines with assumed-shape arrays in Fortran 90. More specifically, I call two levels of subroutines, passing an assumed-shape array as a parameter, but in the end the array is lost. To demonstrate it, one can follow the code below. program main INTERFACE subroutine sub1(x) real, dimension(:):: x real C end subroutine sub1 subroutine sub2(x) real, dimension(:):: x real C end subroutine sub2 END INTERFACE real, dimension(:), allocatable:: x allocate(x