boolean - Turn off Warning: Extension: Conversion from LOGICAL(4) to INTEGER(4) at (1) for gfortran? -


i intentionally casting array of boolean values integers warning:

warning: extension: conversion logical(4) integer(4) @ (1) 

which don't want. can either

(1) turn off warning in makefile?

or (more favorably)

(2) explicitly make cast in code compiler doesn't need worry?

the code looking this:

a = (b.eq.0) 

where a , b both size (n,1) integer arrays. b filled integers ranging 0 3. need use type of command again later a = (b.eq.1) , need a integer array 1 if , if b requested integer, otherwise should 0. these should act boolean values (1 .true., 0 .false.), going using them in matrix operations , summations converted floating point values (when necessary) division, logical values not optimal in circumstance.

specifically, looking fastest, vectorized version of command. easy write wrapper testing elements, want vectorized operation efficiency.

i compiling gfortran, whatever methods used work in ifort compiling intel compilers down road.

update:

both merge , where work example in question. performance metrics on these , select best vectorization. interested in how work matrices, not arrays, not original question post new 1 unless wants expand answer how might adapted matrices.

i have not found compiler option solve (1).

however, type conversion pretty simple. the documentation gfortran specifies .true. mapped 1, , false 0.

note conversion not specified standard, , different values used other compilers. specifically, should not depend on exact values.

a simple merge trick scalars , arrays:

program test   integer :: int_sca, int_vec(3)   logical :: log_sca, log_vec(3)    log_sca = .true.   log_vec = [ .true., .false., .true. ]    int_sca = merge( 1, 0, log_sca )   int_vec = merge( 1, 0, log_vec )    print *, int_sca   print *, int_vec end program 

to address updated question, trivial merge:

a = merge(1, 0, b == 0) 

this can performed on scalars , arrays of arbitrary dimensions. latter, can vectorized compiler. should consult manual of compiler that, though.

the where statement in casey's answer can extended in same way.


since convert them floats later on, why not assign them floats right away? assuming a real, like:

a = merge(1., 0., b == 0) 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -