Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Output from Array

FloBa
Novice
609 Views

Dear community,

 

I have a multi-dimensional array containing information about when a certain receiver gets a signal from a dedicated transmitter. The array has the following structure:

 

signalarray(Transmitter No. ; Receiver No. ; Timestamp)  

 

For any transmitter there can be several different receivers getting a signal at different timestamps. 

What I want to achieve is using the array data and write an output file with a structure like this: 

 

Transmitter 1

Timestamp           Receiver which gets a signal

2                              1 3 5

3                              1 3

5                              1 2 3 4 5

8                              5

 

Transmitter 2

Timestamp           Receiver which gets a signal

6                              1 5

13                            1 

24                            1 2 5

...

and so on.

 

I have all the information stored in the array, however no idea how to transfer it to the output file. 

I am pretty new to FORTRAN and programming itself, so I would highly appreciate any support :). 

 

Thanks in advance,

Florian

 

Labels (1)
0 Kudos
4 Replies
Ron_Green
Moderator
590 Views

not enough information on the datatype(s) of the array.  can you share your code?

0 Kudos
FloBa
Novice
576 Views

Hello Ron,

 

the array contains only Integer numbers. Here is it's definition :

 

INTEGER, ALLOCATABLE :: signalarray( : , : , 1:1000)     ! 1st dimension:   Transmitter ID No. [-]
                                                                                                 ! 2nd dimension:  Receiver ID No.      [-]
                                                                                                 ! 3rd dimension:  Timestamp         [s]

 

The first two dimension will be allocated after reading an input file with the definition and amount of transmitters and receivers.

 

The code itself computes a link budget between each transmitter and receiver for every simulation timestep. If the power is greater than the sensitivity of the receiver for a simulation step, the respective timestamp is stored in the signalarray.  

 

I think to post the whole code is not useful, because it contains a lot of subroutines etc.

 

I hope this helps, let me know if you need more detailed information to provide any advice. 

 

Thanks,

Florian

 

0 Kudos
jimdempseyatthecove
Black Belt
564 Views

Your first post shows two things of interest:

1) Timestamps are not a contiguous set of numbers. (sequence is broken)

2) For any given timestamp, not all receivers are present

 

Because of this, your array will be sparsely filled.

 

It would make more sense to create a user defined type such as:

type TypeLogInfo
	integer(2) :: TransmiterNumber, ReceiverNumber ! Or integer(1), or integer(2)
	integer(4) :: Timestamp ! Or integer(1), integer(2), integer(8)
end TypeLogInfo

And create an array of these user defined types:

Type(TypeLogInfo), allocatable :: signalarray(:)	! allocate appropriately
integer :: maxLogInfos	! you determine this
integer :: nLogEntries
...
allocate(signalarray(maxLogInfos))	! you setup maxLogInfos)
do i=1,maxLogInfos
	signalarray(i)%TransmitterNumber = -1	! invalid transmitter numger
	signalarray(i)%ReceiverNumber = -1	! invalid receiver numger
	signalarray(i)%Timestamp = -1		! invalid transmitter time stamp
end do
nLogEntries= 0	! pre-incre
... ! you fill in the signal array

After the array is filled to nLogEntries (you can reallocate the array if dataset larger than first estimate), the data would presumably be in timestamp incrementing order.

To printout, you would make number of transmitter numbers of passes on the signal array, filtering the receivers for the selected transmitter number. If the receiver numbers for a given transmitter and timestep are in ascending order, then you can print/write these out on the same line. If they are known not to be in ascending order, then as you can use a truth table (array) as to if the receiver was seen on the selected transmitter and timestamp. When timestamp changes, you then write out the receiver numbers with .true. in the truth table.

 

Jim Dempsey 

0 Kudos
Steve_Lionel
Black Belt
563 Views

To add to what Jim said, you can use the ADVANCE='NO' option on a WRITE to output individual values without advancing to a new record. 

0 Kudos
Reply