option to disregard array dimension mismatch

279 views
Skip to first unread message

Tatsuhiko Ogawa

unread,
Aug 26, 2012, 11:48:16 PM8/26/12
to gg...@googlegroups.com
Dear g95 experts,

I am searching a g95 option to disregard type mismatches during compilation.

e.g.
/common/aaa/ a,b,c/
a = 1
b = 2
c = 10
d = a(1) + a(3)

This source cause type mismatch of variable "a" (array or scalar). But by disregarding type mismatch, d = 11 because 10 is assigned to a(3).

intel fortran has such a option "/check: bound". What is the counterpart of this option in g95?

Many thanks in advance.

Regards,
Ogawa

jfh

unread,
Aug 29, 2012, 9:21:18 PM8/29/12
to gg...@googlegroups.com
Your program wouldn't compile for me even when I corrected the other error in its common statement and added a print statement (to see what it would do at run time if it ever got that far) and an end statement. Also my version of Intel Fortran has a differently worded syntax for checking bounds. Hence my results:

 miro[~]$ cat badrank.f90
common/aaa/ a,b,c                                                           
a = 1                                                                          
b = 2                                                                          
c = 10                                                                         
d = a(1) + a(3)                                                                
print *,d                                                                      
end            
miro[~]$ ifort -check nobounds badrank.f90
badrank.f90(5): error #6416: This COMMON scalar or array is invalid in this context.   [A]

d = a(1) + a(3)                                                                
----^
compilation aborted for badrank.f90 (code 1)
miro[~]$

Also, you had a rank mismatch not a type mismatch. "Type" in this context is real, integer or complex. (Other possibilities exist but not in this program.) Remember that programs like yours that violate the (appropriate version of the) Fortran standard but still run may do ANYTHING at run-time. I would suggest fixing your program rather than hoping that you can make one compiler permit a non-standard program that you say Intel Fortran aka ifort permits but I found that it didn't. However my version of that has no "/check: bound" option. I used -check nobound above but I got the same results with -check bound. (I use ifort in a Linux system. You didn't say what operating system you used.)

Reply all
Reply to author
Forward
0 new messages