fortran90

MPI struct datatype with an array

℡╲_俬逩灬. 提交于 2019-12-25 07:52:51
问题 I would like to easily send an someObject in one MPI_SEND/RECV call in mpi. type someObject integer :: foo real :: bar,baz double precision :: a,b,c double precision, dimension(someParam) :: x, y end type someObject I started using a MPI_TYPE_STRUCT, but then realized the sizes of the arrays x and y are dependent upon someParam. I initially thought of nesting a MPI_TYPE_CONTIGUOUS in the struct to represent the arrays, but cannot seem to get this to work. If this is even possible? ! Setup

Openmp array reductions with Fortran

↘锁芯ラ 提交于 2019-12-25 03:46:12
问题 I'm trying to parallelize a code I've written. I'm having problems performing reducitons on arrays. It all seems to work fine for smallish arrays, however when the array size goes above a certain point I either get a stack overflow error or a crash. I've tried to increased the stack size using the /F at compile time, I'm using ifort on windows, I've also tried passing set KMP_STACKSIZE=xxx the intel specific stacksize decleration. This sometimes helps and allows the code to progress further

Find input file size in Fortran 90

有些话、适合烂在心里 提交于 2019-12-25 02:24:35
问题 I'm trying to create a progress indicator based on the total file size vs. file size read so far. I am working with a binary file. open(unit=unitvector, file=vectorname, status='old',form='unformatted') do while (ios.eq.0) read(unitvector,end=888,err=888, iostat=ios) KX, KY, KZ, KNAME, NV, NE, WEIGHT nkcount=nkcount+1 call progress(FILE SIZE, PROGRESS SIZE) allocate( Vector(3,NV) ) read(unitvector) (Vector(1,I),Vector(2,I),Vector(3,I),I=1,NV) . . . end do To compile i use: ifort -warn all

OpenMP and array summation with Fortran 90

三世轮回 提交于 2019-12-25 00:56:42
问题 I'm trying to to compute pressure tensor of a crystal structure. To do so, I have to go throught all pair of particle like in the simplify code below do i=1, atom_number ! sum over atoms i type1 = ATOMS(i) do nj=POINT(i), POINT(i+1)-1 ! sum over atoms j of i's atoms list j = LIST(nj) type2 = ATOMS(j) call get_ff_param(type1,type2,Aab,Bab,Cab,Dab) call distance_sqr2(i,j,r,VECT_R) call gettensor_rij(i,j,T) r = sqrt(r) if (r<coub_cutoff) then local_sum_real(id+1) = local_sum_real(id+1) + ( erfc

Fortran pointer functions: why does this code's behavior depend on the order of function calls?

陌路散爱 提交于 2019-12-24 17:17:08
问题 Context The toy Fortran code posted below calls two pointer functions. That is, both functions return a pointer. In fact, they're both array pointers. They both attempt to do the same thing, which is to return an integer array pointer referencing an integer array having three elements, 1, 2, and 3. The first function uses the pointer assignment operator (=>) to point the function pointer to an allocatable array that holds the data. The second function allocates a block of dynamic memory

How to avoid global variables in Fortran 90 or higher?

有些话、适合烂在心里 提交于 2019-12-24 15:48:38
问题 I have a fortran library to which I must pass a function with a very specific format. The library then is doing some operation on my function. The function is written by a user (like me) and the library is given for granted. Unfortunately to compute my function I need some values (some of them could be initialized once and for all in the main) and I would like to avoid the use of common or save . I read I could use a singleton pattern but I am not very expert in template and on top of that

Private, Save attributes for variables in Fortran 90 modules

混江龙づ霸主 提交于 2019-12-24 15:38:36
问题 I am trying to add access restrictions to some of the variables (using private attribute) in a module but I need to use those variables in subsequent invocations of routines within that module: module MyMod private integer,allocatable :: A(:) public :: init,calc contains subroutine init() ! allocating and initializing A end subroutine init subroutine calc() ! Using A end subroutine end module Questions: Is this true that the private variable will not be in the scope of the program which use s

direct indexing on function return value in fortran

☆樱花仙子☆ 提交于 2019-12-24 15:25:51
问题 Is there posibility to use indexing directly on a function's return value? Something like this: readStr()(2:5) where readStr() is a function which returns a character string. In many other languages it is quite possible, but what about Fortran? The syntax in my example of course does not compile. Is there any other syntax to be used? 回答1: No, that is not possible in Fortran. You could, however, alter your function to take an additional index array that determines which elements are returned.

Paralelize mixed f77 f90 Fortran code?

∥☆過路亽.° 提交于 2019-12-24 13:58:34
问题 I have a code written mostly in f77 however there are also routines written with the f90 syntax. I've been reading how to use openMP for each case, but now I have the doubt how should I do it if I have both syntax in the same code? More specifically should I use use omp_lib or include 'omp_lib.h' but in the same .f file I have both sintaxys. what if I use both? I am compiling with gfortran 4.8.4. If I use let's say use omp_lib (meaning f90 syntax) Then I have to use the correspondent syntax !

Call Matlab from Intel Fortran (Linux)

霸气de小男生 提交于 2019-12-24 12:45:21
问题 I am trying to integrate a Matlab program I wrote into some Fortran code. I tried to follow the example Mathworks provides. But I can't get it to compile because I can't find the header files it requests. Does anyone know of an example of someone getting it to work on Linux using an Intel compiler. I think that might be part of the problem because Matlab only supports GNU Fortran on Linux. And I realize this is a simple question, I just don't understand how to do anything in compiling more