Sponsored Content
Top Forums Shell Programming and Scripting Multiple arrays in variable using for loop Post 302975452 by RudiC on Monday 13th of June 2016 12:00:08 PM
Old 06-13-2016
You can't do that. Disregarding your syntax errors, shells - at least the ones I know of - don't provide such "dynamic variable definitions", and neither do they have multi-dimensional arrays.

Try one-dimensional (associative) arrays with an index constructed from two values.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Nested Loop to Echo Multiple Arrays

I have three arrays which hold three elements each. I have a fourth array which contains the names of those three arrays. I'm having difficulty creating a nested loop that can loop through each array and echo their values. script #!/bin/ksh # array of locations (usa, london, australia)... (1 Reply)
Discussion started by: yongho
1 Replies

2. Shell Programming and Scripting

Using arrays outside the loop

set -A town_name india pakistan srilanka india set -A town m=0 n=0 while } ] do t1=`echo ${town_name}` town= $t1 echo ${town} n=$((n+1)) m=$((m+1)) done t2=`echo ${town}` echo $t2 i m trying to get the value of town array outside the loop but i m nt getting it.. Could u plz... (5 Replies)
Discussion started by: priyanka3006
5 Replies

3. Programming

Perl arrays and loop through array

Hi All I need to get <STDIN> from a user. the <STDIN> is a range of number delimited by "," (comma) and can be with range delimited by "-". Example: 1,2,3,4-9,12,15,34-36,70 Now I need to get this from the user and go on each number and "Do something"... but when trying to do this as above... (2 Replies)
Discussion started by: RedGrinGo
2 Replies

4. Shell Programming and Scripting

Iterating through two arrays in a single loop

Hey everyone. Is it possible to use two arrays in a loop? Basically what I am trying to do is iterate through the elements in an array, and, based on a condition, use the current position in the array to point to that index in the array. Here's the loop structure I'm looking for: ... (1 Reply)
Discussion started by: msarro
1 Replies

5. Shell Programming and Scripting

Problem with arrays and loop

Hello , im sorry for my english . im trying to create a dynamic menu that will display if the interface is ACTIVE OR STOPPED/FAILED for some reason i cant get it to work properly start_interface_func() { i=0 for interface_chk in 11 71 73 72 12 47 48 49 50 20 23 24 25 46 21 22 27 28... (5 Replies)
Discussion started by: visiown
5 Replies

6. Shell Programming and Scripting

Using multiple values for single variable in a loop

Hello Guys, I have a small loop problem as below. I have 3 different values to be used while running the same script - va1="some-value1" va2="some-value2" va3="some-value3" Now I want to use these three variable values to be used for running the same command, like - while... (1 Reply)
Discussion started by: rockf1bull
1 Replies

7. Shell Programming and Scripting

[SOLVED] UNIX FOR loop to read a variable with multiple values

Hi, I have a variable which stores file names as a result of find command. I need to delete all these files one by one, i.e. by a loop. Can anyone tell me how can it be done? The variable f2d has the file names like these abc.txt bcd.txt fff.txt gef.txt Now I have used a loop as... (12 Replies)
Discussion started by: jhilmil
12 Replies

8. Shell Programming and Scripting

Detail on For loop for multiple file input and bash variable usage

Dear mentors, I just need little explanation regarding for loop to give input to awk script for file in `ls *.txt |sort -t"_" -k2n,2`; do awk script $file done which sorts file in order, and will input one after another file in order to awk script suppose if I have to input 2 or... (4 Replies)
Discussion started by: Akshay Hegde
4 Replies

9. Shell Programming and Scripting

Bash for loop with arrays second variable?

I am fairly new to bash and am not sure how to resolve this: I have a series of geographical long/lat points eg. 50/-30 listed on separate lines in a file called junk2. I have input these into an array and am then using that array in a for loop. Towards the end of the loop I create a file called... (4 Replies)
Discussion started by: lily-anne
4 Replies

10. Shell Programming and Scripting

Loop over multiple arrays

Hi All I need really really help with this :- I have two files ( File1 , File 2) both files are output of two different scripts. File1 usually has a list of names ( sometimes 3 names sometimes 5 sometimes more , depends about the output of the script) File2 usually has a list of numbers... (2 Replies)
Discussion started by: samsan
2 Replies
MPI_Type_create_subarray(3OpenMPI)										MPI_Type_create_subarray(3OpenMPI)

NAME
MPI_Type_create_subarray - Creates a data type describing an n-dimensional subarray of an n-dimensional array. SYNTAX
C Syntax #include <mpi.h> int MPI_Type_create_subarray(int ndims, int array_of_sizes[], int array_of_subsizes[], int array_of_starts[], int order, MPI_Datatype oldtype, MPI_Datatype *newtype) Fortran Syntax INCLUDE 'mpif.h' MPI_TYPE_CREATE_SUBARRAY(NDIMS, ARRAY_OF_SIZES, ARRAY_OF_SUBSIZES, ARRAY_OF_STARTS, ORDER, OLDTYPE, NEWTYPE, IERROR) INTEGER NDIMS, ARRAY_OF_SIZES(*), ARRAY_OF_SUBSIZES(*), ARRAY_OF_STARTS(*), ORDER, OLDTYPE, NEWTYPE, IERROR C++ Syntax #include <mpi.h> MPI::Datatype MPI::Datatype::Create_subarray(int ndims, const int array_of_sizes[], const int array_of_subsizes[], const int array_of_starts[], int order) const INPUT PARAMETERS
ndims Number of array dimensions (positive integer). array_of_sizes Number of elements of type oldtype in each dimension of the full array (array of positive integers). array_of_subsizes Number of elements of type oldtype in each dimension of the subarray (array of positive integers). array_of_starts Starting coordinates of the subarray in each dimension (array of nonnegative integers). order Array storage order flag (state). oldtype Array element data type (handle). OUTPUT PARAMETERS
newtype New data type (handle). IERROR Fortran only: Error status (integer). DESCRIPTION
The subarray type constructor creates an MPI data type describing an n-dimensional subarray of an n-dimensional array. The subarray may be situated anywhere within the full array, and may be of any nonzero size up to the size of the larger array as long as it is confined within this array. This type constructor facilitates creating file types to access arrays distributed in blocks among processes to a single file that contains the global array. This type constructor can handle arrays with an arbitrary number of dimensions and works for both C- and Fortran-ordered matrices (that is, row-major or column-major). Note that a C program may use Fortran order and a Fortran program may use C order. The ndims parameter specifies the number of dimensions in the full data array and gives the number of elements in array_of_sizes, array_of_subsizes, and array_of_starts. The number of elements of type oldtype in each dimension of the n-dimensional array and the requested subarray are specified by array_of_sizes and array_of_subsizes, respectively. For any dimension i, it is erroneous to specify array_of_subsizes[i] < 1 or array_of_subsizes[i] > array of sizes[i]. The array_of_starts contains the starting coordinates of each dimension of the subarray. Arrays are assumed to be indexed starting from zero. For any dimension i, it is erroneous to specify array_of_starts[i] < 0 or array_of_starts[i] > (array_of_sizes[i] - array_of_subsizes[i]). The order argument specifies the storage order for the subarray as well as the full array. It must be set to one of the following: - MPI_ORDER_C: The ordering used by C arrays, (that is, row-major order) - MPI_ORDER_FORTRAN: The ordering used by Fortran arrays, (that is, column-major order) A ndims-dimensional subarray (newtype) with no extra padding can be defined by the function Subarray() as follows: newtype = Subarray(ndims, {size , size ,..., size }, 0 1 ndims-1 {subsize , subsize , ..., subsize }, 0 1 ndims-1 {start , start , ..., start }, oldtype) 0 1 bduns-1 Let the typemap of oldtype have the form: {(type , disp ), (type , disp ), ..., (type , disp )} 0 0 1 1 n-1 n-1 where typei is a predefined MPI data type, and let ex be the extent of oldtype. The Subarray() function is defined recursively in three equations on page 72 of the MPI-2 standard. For an example use of MPI_Type_create_subarray in the context of I/O, see Section 9.9.2 of the MPI-2 standard. NOTES
In a Fortran program with arrays indexed starting from 1, if the starting coordinate of a particular dimension of the subarray is n, then the entry in array of starts for that dimension is n-1. ERRORS
Almost all MPI routines return an error value; C routines as the value of the function and Fortran routines in the last argument. C++ func- tions do not return errors. If the default error handler is set to MPI::ERRORS_THROW_EXCEPTIONS, then on error the C++ exception mechanism will be used to throw an MPI:Exception object. Before the error value is returned, the current MPI error handler is called. By default, this error handler aborts the MPI job, except for I/O function errors. The error handler may be changed with MPI_Comm_set_errhandler; the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned. Note that MPI does not guarantee that an MPI program can continue past an error. Open MPI 1.2 September 2006 MPI_Type_create_subarray(3OpenMPI)
All times are GMT -4. The time now is 04:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy