Re: Something is wrong with integer array in external fortran code

From: 李嘉鹏 <lijpbasin_at_nyahnyahspammersnyahnyah>
Date: Mon May 07 2012 - 19:25:52 MDT

It seems that parameter dat in subroutine print_int is interpreted as type real rather than integer
It might be something related to implicit type in fortran 77, since when I changed the array 'dat' to array 'jat', it works for integer arrays and not for real arrays. To make the case simpler, the fortran 77 source file 'print_array.f' can be used instead of the two-part 'print_array.f90' and 'print_array.stub'

At 2012-05-07 16:27:22,L <dxlds@163.com> wrote:

Hi, Li,
in your stub file:
       integer n
       integer dat
       dimension dat(n)

it seems that the 'dimension' line forces the 'dat' to be a real type
so, I change it into this:
       integer n
       integer dat(n)

and it works fine.

Hope it helps.

Liu

At 2012-05-07 15:17:42,"李嘉鹏" <lijpbasin@126.com> wrote:

Hi, Some integer array argument passing failed in my program. The three small bits of code can reproduce it.

WRAPIT print_array.f90 print_array.stub
ncl my_print.ncl

Gives the following results:

 Copyright (C) 1995-2011 - All Rights Reserved
 University Corporation for Atmospheric Research
 NCAR Command Language Version 6.0.0
 The use of this software is governed by a License Agreement.
 See http://www.ncl.ucar.edu/ for more details.
(0)1
(1)2
(2)3
(3)4
(4)5
warning:Argument 1 of the current function or procedure was coerced to the appropriate type and thus will not change if the function or procedure modifies its value
  1065353216 1073741824 1077936128 1082130432 1084227584
(0) 1
(1) 2
(2) 3
(3) 4
(4) 5
   1.00000000 2.00000000 3.00000000 4.00000000 5.00000000

print_real seems to work while print_int fails, is there something wrong with the fortran code?

$ gfortran -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)

$ uname -a
Linux xxx 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Mon May 7 19:26:09 2012

This archive was generated by hypermail 2.1.8 : Thu May 10 2012 - 16:57:50 MDT