fortran90

Fortran90 derived types with mpi, alignment issue?

人盡茶涼 提交于 2019-12-24 12:07:47
问题 I got problem with the following basic code: program foo use mpi implicit none type bartype real(8) :: x integer :: i end type bartype integer :: mpi_bar_type integer :: & count=2, & blocklengths(2)=(/1,1/), & types(2)=(/mpi_double_precision, & mpi_integer/) integer(kind=mpi_address_kind) :: displs(2) type(bartype) :: bar, bararray(4) integer :: rank, ierr, i, test(4), addr0 call mpi_init(ierr) call mpi_comm_rank(mpi_comm_world, rank, ierr) call mpi_get_address(bar, addr0) call mpi_get

MPI send derived data type with pointer in Fortran 90

放肆的年华 提交于 2019-12-24 07:45:41
问题 I would like to send a user defined data type as: TYPE CELL INTEGER :: NUM TYPE(CELL), POINTER :: NEXT => NULL() END TYPE CELL TYPE CELLLIST INTEGER :: NBCELL TYPE(CELL), POINTER :: BEGIN => NULL() END TYPE CELLLIST and the variable to be sent by MPI is defined as: TYPE(CELLLIST) :: _CELLLIST In this variable, _CELLIST%NBCELL denotes the length of the list, and a pointer of type CELL points to the head of the list. I'd like to use MPI_send and MPI_recv to transfer the cell list via MPI. How

Variable format statement when porting from Intel to GNU gfortran

半城伤御伤魂 提交于 2019-12-24 00:39:18
问题 Suppose I'm trying to write out a CSV file header that looks like this: STRING1 2001, 2002, 2003, 2004, And some variable-format Fortran90 code that does this is INTEGER X<Y X=2001 Y=2004 WRITE(6,'(A,(999(5X,I4,",")))') ' STRING1',(y,y=X,Y) The "999" repeats the (5X,I4,",") format structure as many times as it needs to (up to 999 times, at least) to complete. Assume X and Y are subject to change and therefore the number of loop iterations may also change. But if I want the header to look like

No lifting of scalar arguments to arrays in Fortran

强颜欢笑 提交于 2019-12-23 20:24:36
问题 Why is it that Fortran will promote a scalar expression to an array, in an expression , but not as an argument to a procedure? In particular, why did the standards body make this design decision? Is it solely because of ambiguity, should the procedure be overloaded? Could an error message in that situation be an alternative approach? For example, In the code below, the last statement, x = foo(7) , produces the GFortran error: Error: Rank mismatch in argument 'a' at (1) (1 and 0) . module m

Can I use emacs f90-mode with fixed format?

前提是你 提交于 2019-12-23 20:15:38
问题 I'm updating some fortran 77 code to use fortran 90 constructs and emacs is my editor of choice. Currently, the source is in fixed format and that isn't going to change any time soon (due to external constraints). The two emacs major modes that I can choose from are fortran-mode which only highlights the syntax for fortran 77 constructs (It doesn't understand module or contains , etc. as keywords which I find pretty annoying, but it does understand fixed format -- correctly indenting the code

When do Fortran module allocatable arrays go out of scope when loaded as a shared library?

早过忘川 提交于 2019-12-23 18:46:02
问题 I am calling a fortran subroutine from R as part of a more complex optimization problem. Currently, the subroutine is self-contained -- with an input of current parameter values and an output of function evaluation and gradient terms. I now wish to initialize an allocatable array as a shared module variable (prior to the optimization) that will be used (but not modified) by the subroutine during optimization. In this context, when would the shared allocatable array go out of scope or be

Fortran: add column to file (i.e. skip a varying amount of horizontal spaces)

丶灬走出姿态 提交于 2019-12-23 18:14:40
问题 I'm a bloody beginner to Fortran (f90) and some apparently easy problems turn out to cause severe headaches...Thanks for helping me with this one: My code runs through a loop, processes data and writes them into a file. I'd like to have those data written in columns of the same file until the looping is finished. OPEN (unit=11,file=filename // '.csv') WRITE(11,'(i4,A1,f10.6)') NUM4 , tab, NUMfloat10_6 CLOSE(11) This code works fine for the saving of a single dataset. "tab" is defined as char

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

Write dynamical arrays in Fortran 90 [duplicate]

寵の児 提交于 2019-12-23 12:56:21
问题 This question already has answers here : Format string for output dependent on a variable (4 answers) Dynamic output format setting (2 answers) Closed 2 years ago . I have arrays with dynamical dimension ( dimx , dim ) and I need a way to write such arrays in a file through the Write instruction, the problem is that until now I haven't been able to produce such files in a automatic way, I mean until now I have to change the dimension of the array in the Write instruction by hand and I need a

End of record error in file opening

浪尽此生 提交于 2019-12-23 04:24:08
问题 I am currently writing a code to simulate particle collisions. I am trying to open as much files as there are particles (N) and then put the data for positions and velocities in each of these files for each step of the time integration (using Euler's method, but that is not relevant). For that, I tried using a do loop so it will open all the files I need - then I put all the data in them with a different do loop later - and then close them all. I first tried just doing a do loop to open the