- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a fortran programme in which I have defined a 2D array. Next I wish to write all the elements of the array using a loop. For that I am using the following code:
program main use, intrinsic:: iso_fortran_env, only: output_unit, input_unit, error_unit implicit none integer :: NY = 5, NX = 4 integer, allocatable, dimension(:, :) :: a_global integer, allocatable, dimension(:) :: a_temp integer :: i, j, me allocate( a_global(NY, NX), source=0 ) do i = 1, NX do j = 1, NY a_global(j, i) = j + ( i - 1 ) * NY end do end do write( output_unit, * ) "a_global in image 1 (printed column-wise) = " do i = 1, NX write( output_unit, * ) a_global(:, i) end do write( output_unit, * ) "" write( output_unit, * ) "a_global in image 1 (printed row-wise) = " do i = 1, NY ! a_temp = a_global(i, :) ! write( output_unit, * ) a_temp write( output_unit, * ) a_global(i, :) end do end program main
I am using intel compiler to compile the program and am using the following syntax to compile:
ifort -check all program.f90
When the executable is run, the first set of write commands prints the array as expected, ie, it prints all the columns of the array in a new line. But, although the second set of write commands throws the following warning before printing a row of the array in each line, it runs successfully.
forrtl: warning (406): fort: (1): In call to I/O Write routine, an array temporary was created for argument #1 Image PC Routine Line Source a.out 0000000000406C86 Unknown Unknown Unknown a.out 0000000000403EE5 Unknown Unknown Unknown a.out 00000000004029DE Unknown Unknown Unknown libc-2.17.so 00007F83EA940495 __libc_start_main Unknown Unknown a.out 00000000004028E9 Unknown Unknown Unknown
Now, I wish to code the same program in parallel and have image 1 define and write the array as above. For this I have the following modification in the code:
program main use, intrinsic:: iso_fortran_env, only: output_unit, input_unit, error_unit implicit none integer :: NY = 5, NX = 4 integer, allocatable, dimension(:, :) :: a_global integer, allocatable, dimension(:) :: a_temp integer :: i, j, me sync all me = this_image() allocate( a_global(NY, NX), source=0 ) if ( me == 1 ) then do i = 1, NX do j = 1, NY a_global(j, i) = j + ( i - 1 ) * NY end do end do write( output_unit, * ) "a_global in image 1 (printed column-wise) = " do i = 1, NX write( output_unit, * ) a_global(:, i) end do write( output_unit, * ) "" write( output_unit, * ) "a_global in image 1 (printed row-wise) = " do i = 1, NY ! a_temp = a_global(i, :) ! write( output_unit, * ) a_temp write( output_unit, * ) a_global(i, :) end do end if end program main
This time I compile the above code using:
ifort -coarray -check all program.f90
Now, when I try to run the program, it throws the same warning. But this time it halts with the following additional error:
application called MPI_Abort(comm=0x84000004, 3) - process 0
I understand that the warning is shown because fortran is trying to print a set of values of the arrays which are not contiguous. But what I do not understand is why the application is aborting when I try to run it in parallel with runtime checks on. Should not it just throw the same warning and end gracefully? What am I missing here?
P.S. I am using CentOS 7 with Intel parallel studio 2017 student edition.
Link Copied

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page