Error after assigning one instance of a derived type to another instance (Coarray Fortran)

33 Views Asked by At

My problem could not be reproduced with simple code. So let me post an overview of the problem, and let's see if this generates a solution or a hint.

I have a complex derived type (say, emulator_sp) that has several components including an allocatable coarray component. I have two instances of the type, I1 and I2. First, I initialize I1, including allocating its coarray component:

call init_emulator_sp(I1)

and then do some other stuff with I1

call do_other_things(I1, ...)

This works without a problem. However, if I now assign I2 to I1, this breaks:

call init_emulator_sp(I1)
I2=I1

check that all components of I2 and I1 are the same on each image

call do_other_things(I2, ...)

The error pops up: forrtl: severe (772): Image number 17 is not a valid image number; valid numbers are 1 to 16

Note that the program works on 16 images, and I1 is defined on 16 images.

Compiler information: ifort (IFORT) 19.0.3.199 20190206 Copyright (C) 1985-2019 Intel Corporation. All rights reserved.

Again, I apologize for not posting a simpler isolated code, since I could not reproduce this error on a simpler example. Nonetheless, does anyone have any pointers?

P. S. This is the type definition, if this helps at all:

type emulator_sp
     real, allocatable                        :: pars(:,:,:,:)[:]
     character(128), dimension(3), private    :: state_var_names 
     character(128), dimension(5), private    :: forc_var_names 
     logical                                  optimized
     integer, dimension(2)                    :: train_yrs
     character(10)                            :: parnames(15)
     character(128)                           :: parunits(15)
  end type emulator_sp
0

There are 0 best solutions below