Passing an string through WRAPIT

From: Andrea Hahmann <hahmann_at_nyahnyahspammersnyahnyah>
Date: Thu, 17 Nov 2005 13:32:10 -0700 (MST)

Hi!

I am trying to use an external Fortran 90 routine to read in an ASCII
table of mixed integers, strings and floats. One of the columns of the
table is a string. I am not sure how this array of strings should be
defined in the f90, the wrapper, and the ncl script.

(There was a similar question in the ncl-talk list on Mon Aug 01 2005, but
I could not find an answer...)

Thank you!
Andrea

Here are the separate pieces of my code:

--------------------------------------------------
Data to read:

   20040812 00 LGAK 37.89 23.74 2.00 24.88 25.25
   20040812 00 LGAM 37.94 23.71 9.00 24.54 26.50
   20040812 00 LGDE 38.12 23.78 274.00 21.78 18.75
   20040812 00 LGEK 37.97 23.72 74.00 24.30 24.00
   20040812 00 LGGU 37.99 23.78 162.00 22.46 21.75
   20040812 00 LGKT 38.14 23.95 212.00 21.39 21.75

--------------------------------------------------
F90 code:

subroutine readtable(FileName,nobs,station,lat,lon,tmodel,tobs)
   implicit none
   integer, intent(in) :: nobs
   character(*), intent(in) :: FileName
   character*4, intent(out) :: station(nobs)
   real, intent(out) :: lat(nobs),lon(nobs)
   real, intent(out) :: tmodel(nobs),tobs(nobs)
   real :: aux
   integer :: i,dd,hh

   open(10,file=trim(Filename),status="old")
   read(10,*)
   do i=1,nobs
      read(10,100) dd,hh,station(i),lat(i),lon(i), &
           aux,tmodel(i),tobs(i)
   end do
100 format(2x,i8,2x,i2.2,2x,a4,2x,5f8.2)

end subroutine readtable

--------------------------------------------------
wrapper:

C NCLFORTSTART
       subroutine readtable(FileName,nobs,station,lat,lon,tmodel,tobs)
       real lat,lon,tmodel,tobs
       integer nobs
       dimension lat(nobs),lon(nobs),tmodel(nobs),tobs(nobs)
       character*4 station
       dimension station(nobs)
       character*(*) FileName
C NCLEND

--------------------------------------------------
NCL script:

external EX01 "./ReadTable.so"

begin
   FileName = "verif_stats2.out"
   nobs = 10
   lat = new(nobs,"float")
   lon = new(nobs,"float")
   tmodel = new(nobs,"float")
   tobs = new(nobs,"float")
   station = new(4,"character")

   EX01::readtable(FileName,nobs,station,lat,lon,tmodel,tobs)
end

--------------------------------------------------
And finally here is the
error message:

fatal:Argument type mismatch on argument (2) of (readtable) can not coerce
fatal:Execute: Error occurred at or near line 15 in file ReadTable.ncl

----------------------------------------------------------------
Andrea N. Hahmann, Ph.D.
Research Applications Laboratory
Natl. Center for Atmospheric Research Phone: 1-303-497-8383
PO BOX 3000 Fax: 1-303-497-8401
Boulder, CO 80301 hahmann_at_ucar.edu
----------------------------------------------------------------

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Nov 17 2005 - 13:32:10 MST

This archive was generated by hypermail 2.2.0 : Thu Nov 17 2005 - 19:15:29 MST