[ncl-talk] load scripts in multiple NCLfiles program
Dennis Shea
shea at ucar.edu
Fri Nov 28 13:14:30 MST 2014
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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141128/3b21fd0b/attachment.html
More information about the ncl-talk
mailing list