fortran90

MPI_Send/ Recv communicator datatype error

一世执手 提交于 2019-12-11 06:58:10
问题 I have the following basic MPI program written in Fortran 90: program sendRecv include 'mpif.h' !MPI Variables integer ierr, numProcs, procID !My variables integer dat, datRec !Init MPI call MPI_INIT ( ierr ) !Get number of processes/ cores requested call MPI_COMM_SIZE (MPI_COMM_WORLD, numProcs, ierr) !Get rank of process call MPI_COMM_RANK (MPI_COMM_WORLD, procID, ierr) if (procID .eq. 0) then dat=4 !Send num to process 1 call MPI_SEND (dat, 1, MPI_INT, 1, 0, MPI_COMM_WORLD, ierr) else if

Dynamic array rank

谁都会走 提交于 2019-12-11 06:05:18
问题 I have a few array variables in a module that are dynamic, and later allocated in one of two subroutines outside of the module. However, in one subroutine I want the array to be 1D, in the other subroutine I want it to be 2D. In principle I would want something like this in the module, but I don't believe this is possible in the declaration area?: if (option1) then real (kind=8), allocatable :: arr1(:) else real (kind=8), allocatable :: arr1(:,:) endif Is there a way in the allocatable

Reference passing is changing the values of a matrix

给你一囗甜甜゛ 提交于 2019-12-11 04:54:07
问题 I'm trying to make a code in Fortran90 (compiling with ifort) in which I multiply two matrices. I'm writing code for this because one of the matrices is sparse, so you can do the multiplication without allocating memory for the whole matrix. I have two subroutines. The first one, multiplies the sparse matrix ( k in diagonal, and l at both sides of the diagonal) and a vector ( b ). The result is passed to the main function trough pointer r . I chose using subroutines and no functions because

Fortran performance when passing array slices as arguments

点点圈 提交于 2019-12-11 04:35:06
问题 I like fortran's array-slicing notation ( array(1:n) ), but I wonder whether I take a performance hit if I use them when it's not necessary. Consider, for example, this simple quicksort code (It works, but obviously it's not taking care to pick a good pivot): recursive subroutine quicksort(array, size) real, dimension(:), intent(inout) :: array integer, intent(in) :: size integer :: p if (size > 1) then p = partition(array, size, 1) call quicksort(array(1:p-1), p-1) call quicksort(array(p+1

Creating an overloaded function to be used in message logging

和自甴很熟 提交于 2019-12-11 03:53:35
问题 I am trying to create an overloaded function num2str(x) which will take integer or real values as input and return a string value. My purpose of doing this is to use it when writing log file. Based on suggestions given in my previous post (creating log file) I have created a subroutine message(msglevel, string) which I am using to write my log file. Now I can only send a string to this function and I am trying to make it easy to create a string using num2str(x) . Could someone explain me

Fortran90 Array read blank values as null

时光毁灭记忆、已成空白 提交于 2019-12-11 03:08:25
问题 I'm reading data fram a external text file (30 Rows, 7 Columns), each row is seperated with a ",". I have missing values represented as ",,". When i read data into a two dimensional array the missing value is replaced with 0.00, but i have a 0.00 value in the data too. When i am computing average the count (number of items (n)) showd be count - (number of missing values). How can i pick the missing values dynamically. Thanks Sri DATA 337.60,220.40,0.00,0.00,200.42,216.61,261.04 323.00,249.20

Makefile - compiling back and forth

心已入冬 提交于 2019-12-11 03:07:51
问题 Following is the directory structure of my project: expt-main --------- Makefile_main / \ subdir-1 subdir-2 -------- -------- Makefile_1 Makefile_2 mod_codeA.f90 mod_code1.f90 mod_codeB.f90 mod_code2.f90 mod_codeC.f90 mod_code3.f90 Makefile_main: export SHELL = /bin/sh F90 = mpxlf95 SRCDIRS = $(subdir-1) $(subdir-2) all: @for DIR in ${SRCDIRS} ; do \ back=`pwd`; \ cd $$DIR ;\ $(MAKE) ; status=$$? ; \ if [ $$status != 0 ] ; then \ echo "Exit status fro make was $$status" ; exit $$status ; \ fi

Fortran: pipe to program

北战南征 提交于 2019-12-11 01:28:10
问题 Is there any possibility to launch an external program from Fortran and write something to this programs standard input? I know e.g. of gfortran's SYSTEM but there is no such option. 回答1: Firstly, if you're using a relatively recent compiler you should be able to use execute_command_line (part of the f2008 spec) instead of system (compiler extension). This launches a command using the C library's system call which uses the sh shell on nix and cmd.exe on Windows (see here). As such you can use

OpenMP for dependent variables

你说的曾经没有我的故事 提交于 2019-12-11 00:30:17
问题 This is the first time I am using OpenMP, and I apply it for Fortran. I happened to have a problem adjusting the loop where there is a variable that requires update from its previous value. I tried using PRIVATE clause but the result is far from those resulted by serial computation (without OpenMP). I looked somewhere in OpenMP website and I found one solution using !$OMP PARALLEL DO ORDERED which finally works (produce the same result with the serial one). But it seems that by using this,

Vim syntax highlighting for multiline fortran openmp directives

时光毁灭记忆、已成空白 提交于 2019-12-10 22:20:57
问题 I'm using modern fortran for doing parallel programming. I'm using vim and it's been really annoying me that the fortran.vim syntax files don't seem to handle compiler directives like !$omp or !dir$. These just get rendered as comments in vim so they don't stand out. In c/c++ these compiler directives are done using #pragma's so everything stands out like it were preprocessor code rather than comment code. So I want similar treatment in my fortran syntax. Here's an example of a multiline