Re: error message "WRAPIT.c:151: error: redefinition of â"

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon Nov 18 2013 - 18:02:30 MST

The name of the subroutine called by NCL is 'ann_harm'
not 'ann_cycle'. The file 'ann_cycle.so' contains the executable.

Change
     MAC::ann_cycle(nhar,var,nmd,pcpSlow,low,nmon,ndims,ilen)
to
     MAC::ann_harm(nhar,var,nmd,pcpSlow,low,nmon,ndims,ilen)

On 11/18/13 5:36 PM, Yi-Chih Huang wrote:
> Dennis,
>
> I deleted MAC.stub. But the error "procedure ann_cycle is not defined
> in package MAC" remained when I executed "ncl MAC.ncl". Is it another
> error in MAC.ncl?
>
> Thanks much,
>
> Yi-Chih
>
> #####
> yhuang@arc-env:/fs3/yhuang/scripts$ WRAPIT ann_cycle.f
>
> WRAPIT Version: 120209
> COMPILING ann_cycle.f
> LINKING
> END WRAPIT
>
> yhuang@arc-env:/fs3/yhuang/scripts$ ls -l ann_cycle.so
> -rwxr-xr-x 1 yhuang yhuang 12848 2013-11-19 09:34 ann_cycle.so
> yhuang@arc-env:/fs3/yhuang/scripts$ ncl MAC.ncl
> Copyright (C) 1995-2013 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 6.1.2
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> fatal:syntax error: procedure ann_cycle is not defined in package MAC
>
> fatal:error at line 52 in file MAC.ncl
>
> fatal:Syntax Error in block, block not executed
> fatal:error at line 77 in file MAC.ncl
>
> #####
> load "$SysE/lib/ncl/helper_libs.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> external MAC "./ann_cycle.so"
>
> begin
> latS = -30.0
> latN = 30.0
> lonE = 30.0
> lonW = 180.0
>
> yrStrt = 1979
> yrLast = 2009
> nyr= yrLast -yrStrt +1
> nmo= 12
>
> in = addfile("/fs3/yhuang/precip.mon.mean.nc","r") ; 197901-201306
> YMDHMS = cd_calendar(in->time, 0) ; all times index for desired time
> iYear = ind(YMDHMS(:,0).ge.yrStrt .and. YMDHMS(:,0).le.yrLast)
>
> precip = in->precip(iYear,{latS:latN},{lonE:lonW})
> ds= dimsizes(precip)
> precy = new((/nyr,nmo,ds(1),ds(2)/),float)
> pcp = new((/nyr*nmo,ds(1),ds(2)/),float)
>
> do ny= 0,nyr-1
> iYr = ind(YMDHMS(:,0).eq.yrStng(ny))
> preci = in->precip(iYr,{latS:latN},{lonE:lonW})
> precy(ny,:,:,:) = preci
> end do
>
> pcpClm= dim_avg_n_Wrap( precy, (/0,1/) )
>
> i= 0
> do iz= 0,ds(2)-1
> do im= 0,ds(1)-1
> do nm= 0,nmo-1
> do ny= 0,nyr-1
> pcp(i)= precy(ny,nm,im,iz)
> i= i+1
> end do
> end do
> end do
> end do
>
> nhar= 3
> var= pcp
> nmd= nyr*nmo*ds(1)*ds(2)
> nmon= 12
> ndims= ds(1)
> ilen= ds(2)
> MAC::ann_cycle(nhar,var,nmd,pcpSlow,low,nmon,ndims,ilen)
>
> pcpFast = pcpClm - pcpSlow
> copy_VarCoords(pcpClm,pcpFast)
>
> wks= gsn_open_wks("X11","MAC")
> gsn_define_colormap(wks,"BlueRed")
>
> res = True
> res@gsnAddCyclic = False
> res@mpMinLatF = -30
> res@mpMaxLatF = 30
> res@mpMinLonF = 30
> res@mpMaxLonF = 160
>
> res@cnFillOn = True
> res@cnLinesOn = False ; turn off the contour
> lines
> res@cnLineLabelsOn = False
> res@cnSpanFillPalette = True
>
> res@gsnSpreadColors = True ; use full colormap
> res@gsnSpreadColorStart = 10 ; for BlueRed
> res@gsnSpreadColorEnd = 250 ; for BlueRed
>
> plot = gsn_csm_contour_map(wks,iav,res)
> end
>
>
>
> On Mon, Nov 18, 2013 at 11:28 PM, Dennis Shea <shea@ucar.edu> wrote:
>
>> A 'stub' file is usually used when accessing an f90 subroutine.
>> WRAPIT 'understands' (parses) only f77 syntax. Hence, a stub file
>> which uses f77 syntax is is introduced as a mechanism
>> to communicate the arguments.
>>
>> When you used both the MAC.stub and ann_cycle.f
>> codes, you duplicated the interface.
>>
>> %> WRAPIT MAC.stub ann_cycle.f
>>
>> Delete the MAC.stub and just use:
>>
>> %> WRAPIT ann_cycle.f
>>
>>
>>
>>
>>
>> On 11/17/13 6:37 PM, Yi-Chih Huang wrote:
>>
>>> C NCLFORTSTART
>>> subroutine ann_harm(nhar,var,nmd,sst,low,nmon,ndims,ilen)
>>> real var(nmd)
>>> real sst(ndims,ilen), low(ndims,ilen)
>>> real a(nhar), b(nhar), rcas(nhar,ilen), rsyn(nhar,ilen)
>>> C NCLEND
>>> c program harfil
>>> c constructs the annual cycle of the data
>>> c based on the required number of harmonics
>>> c
>>> c Function Parameter reference
>>> c nhar = integer; number of harmonics to remove
>>> c var = float ; reduced one dimensional input data array
>>> c ; we estimate the seasonal cycle from
>>> c ; this data
>>> c ; the input data contains ilen months of
>>> c ; data; each of the ilen units could contain
>>> c ; a multi-dimensional array representing
>>> c ; n-dimensional data
>>> c ; to make this routine more general, the n-dimensional
>>> c ; data is flattened out into a 1-D array
>>> c ; and written out sequentially
>>> c ; for an example see
>>> c sst = float ; two dimensional output array, time is the first
>>> dimension
>>> c ; a collapsed version of the spatial dimensions form the
>>> c ; second dimension
>>> c!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>>> c Read the data into array SST
>>>
>>> do mon=1,ilen
>>> do i = 1,ndims
>>> sst(i,mon)=0.0
>>> low(i,mon)=0.0
>>> end do
>>> end do
>>>
>>> k=0
>>> pi=3.1415
>>> print *, pi
>>>
>>> do mon=1,nmon
>>> do i=1,ndims
>>> k=k+1
>>> sst(i,mon)=var(k)
>>> enddo
>>> end do
>>> c!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>>>
>>> c Calculate the shapes of sine and cos waves at the different
>>> c harmonic frequencies
>>>
>>> do mon = 1, ilen
>>> do L = 1,nhar
>>> rcas(L,mon) = cos((2*pi*L/ilen)*mon)
>>> rsyn(L,mon) = sin((2*pi*L/ilen)*mon)
>>> enddo
>>> enddo
>>>
>>>
>>> do i = 1,ndims
>>> do L = 1,nhar
>>> a(L) = 0.0
>>> b(L) = 0.0
>>> c Calculate the Lth harmonic component
>>> do mon = 1,ilen
>>> a(L) = a(L) + sst(i,mon)*rcas(L,mon)
>>> b(L) = b(L) + sst(i,mon)*rsyn(L,mon)
>>> enddo
>>> a(L) = a(L) * 2 / float(ilen)
>>> b(L) = b(L) * 2 / float(ilen)
>>> enddo
>>>
>>> c Now reconstruct the time-series with a specified no of harmonics
>>> c This reconstructs the seasonal cycle
>>>
>>> do mon = 1,ilen
>>> do L = 1,nhar
>>> low(i,mon) = low(i,mon)
>>> & + a(L) * rcas(L,mon)
>>> & + b(L) * rsyn(L,mon)
>>>
>>> end do
>>> end do
>>>
>>> end do
>>>
>>> k=0
>>> do mon=1,nmon
>>> do i = 1,ndims
>>> k=k+1
>>> c ann_cycle(k)=low(i,mon)
>>> c var(k)=sst(i,mon)
>>> var(k)=low(i,mon)
>>> end do
>>> end do
>>>
>>> 1000 continue
>>> return
>>> end
>>>
>>
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Nov 18 18:02:35 2013

This archive was generated by hypermail 2.1.8 : Fri Nov 22 2013 - 09:36:32 MST