Error: 'mask' argument of 'count' intrinsic at (1) must be a logical array

171 Views Asked by At

I have recently tried compacting an older version of my program to make it more efficient by using the "count" function. However, when I try to compile the program, I get the error for each count statement:

Error: 'mask' argument of 'count' intrinsic at (1) must be a logical array

How can I fix this? My goal is to count (for 4 columns b c d and e) how many momenta fit into certain ranges, defined by these bins (of which there are 20.) I had received a suggestion from an earlier post to use arrays for the bin counting process, and I thought I had it correct, but I get an error. I will link my previous post here: How to read counts into 1D array?

Here is my current program:

    program mean_analysis
    implicit none
    
    integer i, j, k, N, l
    double precision a, b, c, d, e
    integer binb(1:20),binc(1:20),bind(1:20),bine(1:20)
    real lower(1:20),upper(1:20)

    

    character(100) event
    
    upper(1)=-2.7
    lower(1)=-3
        
    open(unit = 7, file="zpc_initial_momenta.dat")
        do l=2,20
            lower(l)=lower(l-1)+.3
            upper(l)=upper(l-1)+.3  
        end do
        
        do k=1, 10
            read(7,'(A)') event
            do j=1,4000
            read(7,*) a, b, c, d, e
            do i=1,20
        binb(i)=binb(i)+count(b>=lower(i).and. b<upper(i))
        binc(i)=binc(i)+count(c>=lower(i).and. c<upper(i))
        bind(i)=bind(i)+count(d>=lower(i).and. d<upper(i))
        bine(i)=bine(i)+count(e>=lower(i).and. e<upper(i))  
        
        end do
        end do
        end do
                
    close(7)
            
    open(unit = 8, file="outputanalysis.dat")
        Write(8,*) 'The bins in each column are as follows:'
        Write(8,*) 'FIRST COLUMN (MOMENTUM IN X DIRECTION)'
        write(8,*) binb(1:20)
        
    close(8)
    
    end program
            

Do you guys have any suggestions or something that I may have missed?

1

There are 1 best solutions below

3
Vladimir F Героям слава On

Count and similar array functions require an array argument. You have scalars expresions there

 b>=lower(i).and. b<upper(i)

An array would be

 b>=lower.and. b<upper