Error: Can't convert LOGICAL(4) to INTEGER(4) at (1)

1,081 views
Skip to first unread message

ramkishore singh

unread,
Jul 14, 2015, 7:41:23 AM7/14/15
to gg...@googlegroups.com
Hi,
I am trying to run Trnsysfunctions.f90 file but encountered the error: Can't convert LOGICAL(4) to INTEGER(4) at (1).

Can anybody help me to resolve the issue?

Thanks,
Ramkishore 

ziggy76

unread,
Jul 15, 2015, 5:01:21 AM7/15/15
to gg...@googlegroups.com

HI,
can you give more details ?
Most of the time, this error comes from codes converted from the C language where logical and integers have the same format (0 for false and true for values different from zero)
In fortran integers and boolean are incompatible.
You must do the conversion yourself :
IF( logicalvar ) THEN
   intvar=1
ELSE
   intvar=0
ENDIF

or
IF( intvar>0 ) THEN
   logicalvar= .TRUE.
ELSE
   logicalvar=.FALSE.
ENDIF


Hope it helps,
regards.

ramkishore singh

unread,
Jul 15, 2015, 6:46:07 AM7/15/15
to gg...@googlegroups.com
Thank you very much indeed.
Let me try this and will get back to you.

Kind regards,
Ramkishore

R.K. Singh

unread,
Jul 16, 2015, 6:23:01 AM7/16/15
to meu...@coria.fr, gg...@googlegroups.com
Hi,
Thanks a ton. Your suggestion solved the issue. Now I am having another error: If clause  at (1) requires a scalar logical expression.

Code statement is as follows:

If(getIsVersionSigningTime()) Then
Call SetTypeVersion(17)
Return
      EndIf 


If(getIsVersionSigningTime()) Then
   1
Error: If clause  at (1) requires a scalar logical expression.

May I request you look at the above issue too. 

Thanks and regards,
Ramkishore


--
You received this message because you are subscribed to a topic in the Google Groups "gg95" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gg95/52biafWcjhk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gg95+uns...@googlegroups.com.
To post to this group, send email to gg...@googlegroups.com.
Visit this group at http://groups.google.com/group/gg95.
For more options, visit https://groups.google.com/d/optout.

Siegfried MEUNIER-GUTTIN-CLUZEL

unread,
Jul 16, 2015, 7:30:44 AM7/16/15
to R.K. Singh, gg...@googlegroups.com
Hi,
it's the same problem : I suppose that the function getIsVersionSigningTime() returns a numerical value which is different from zero if the treatment is to be done.
So you can write
If(getIsVersionSigningTime()>0) Then
		Call SetTypeVersion(17)
		Return
EndIf 
Be careful, you must verify what  the fuction returns ...

Regards.

R.K. Singh

unread,
Jul 16, 2015, 7:38:22 AM7/16/15
to Siegfried MEUNIER-GUTTIN-CLUZEL, gg...@googlegroups.com
Hi,
Thank you very much indeed.
I checked it and it works.

Regards,
Ramkishore

jfh

unread,
Aug 17, 2015, 7:08:58 PM8/17/15
to gg95

These can both be simplified to one-liners:

 intvar = merge(1,0,logicalvar)

 logicalvar = (intvar>0)
Reply all
Reply to author
Forward
0 new messages