[ncl-talk] load scripts in multiple NCLfiles program
franz
f.trotta at sincem.unibo.it
Wed Dec 3 08:23:42 MST 2014
thanks Dennis for a very clear answer.
I was doing somethig like the following:
load “script_1.ncl”
load “script_2.ncl”
begin ; MAIN
end
I solved the problem changing the order of loading the script_1.ncl
and script_2.ncl
in the main.ncl file because script_1 need function placed in script_2.
thanks
Francesco T.
On 28-11-2014 21:14, Dennis Shea wrote:
> It is likely, you are violating NCL's "scoping" rules which are
> similar to Pascal.
>
> Compiled languages (eg: fortran, C, C++,..) use two steps: (1)
> compiling and (2) linking in the build process. Compiling translates
> codes into 'machine language' and results in independent object codes.
> Linking refers to the creation of a single executable file from
> multiple object files. Hence, the compiled program knows where
> assorted object files are located because of the link process.
>
> NCL is an interpreted language like Matlab, Python. Rather than
> compiled, the codes (scripts) are interpreted. There is no
> conversion to machine code. There is no formal 'link' process.
> Generally, interpreted languages require a library or function be
> 'loaded' (ie, 'defined') prior to use. This is called the 'scope' of
> the code. The 'scope' also applies to variables. An example
>
> load “dummy_1.ncl” ; not aware of constants or codes
> below
>
> GRAVITY = 9.8
>
> RGAS = 204
>
> load “dummy_2.ncl” ; can use GRAVITY, RGAS &
> 'dummy_1.ncl'
>
> REARTH = 6371.009 ; km
>
> load “dummy_3.ncl” ; can use GRAVITY, RGAS, REARTH
>
>
> ; dummy_1,ncl, dummy_2.ncl
>
> begin ; MAIN ; can use GRAVITY,
> RGAS, REARTH
>
>
> ; dummy_1,ncl, dummy_2.ncl, dummy_1.ncl
>
> :
>
> end
> load “dummy_4.ncl” ; can NOT be 'seen' by any of the above code
> so it
> ; can not
> be used
>
> On Fri, Nov 28, 2014 at 8:30 AM, franz <f.trotta at sincem.unibo.it>
> wrote:
>
>> Dear Ncl,
>> I have written a multi file program in NCL,
>> There is a main script ‘main.ncl’ which is a entry
>> point of the code
>> in this file I load external scripts (where there are several
>> utility
>> function/procdure. lets call script1.ncl and script2.ncl )
>>
>> I have a problem when in one of this external script
>> (script1.ncl) I
>> call a procedure
>> which is defined in an other external script (scrip2.ncl)
>>
>> fatal:syntax error: line 196 in file ./script1.ncl before
>> or near n
>>
>> tempe_myOc,saline_myOc,ssh_myOc,glAttr_description)
>>
> --------------------------------------------------------------------------------^
>>
>> fatal:syntax error: possibly an undefined procedure
>>
>> How can I solve this problem?
>>
>> thanks
>> Francesco T.
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk [1]
>
>
>
> Links:
> ------
> [1] http://mailman.ucar.edu/mailman/listinfo/ncl-talk
More information about the ncl-talk
mailing list