Esmvaltool: NCL interface scripts fail sometimes

Created on 4 Dec 2018  路  9Comments  路  Source: ESMValGroup/ESMValTool

I have the following NCL script:

load "interface_scripts/interface.ncl"                                                                                                                                                                                                                             

enter_msg(DIAG_SCRIPT, "")

; import datasets
; write data
outvar = ...

netcdf_outfile = ncdf_write(outvar, outvar@ncdf)

The function ncdf_write fails with the error

fatal:Undefined identifier: (att2var) is undefined, can't continue
fatal:["Execute.c":8637]:Execute: Error occurred at or near line 503 in file ./interface_scripts/auxiliary.ncl

fatal:["Execute.c":8637]:Execute: Error occurred at or near line 94 in file /mnt/lustre01/pf/b/b309141/ESMValTool/esmvaltool/diag_scripts/austral_jet/mmstf.ncl

The example diagnostic runs fine. The reason for this is that att2var appears after ncdf_write in the code, therefore ncdf_write does apparently not know about it. It can be fixed by loading interface_scripts/interface.ncl twice:

load "interface_scripts/interface.ncl" 
load "interface_scripts/interface.ncl"                                                                                                                                                                                                                                   

This is done indirectly for many other diagnostics, so most of the time it's not a problem. Is there a more elegant solution than loading the interface scripts twice? Also, it's not really user friendly for NCL beginners (like me :grimacing:)

bug

All 9 comments

You can try moving att2var before ncdf_write in auxiliary.ncl.

I thought about that, too, but I think there are a lot more of these potential errors hidden in this file...

Indeed auxiliary.ncl contains a lot of outdated code, which I was planning to clean up at some point.
I would suggest to try swapping the order, and if that solves your problem open a PR.
I will have a closer look when cleaning up.

Ok! :+1:

Did it work?

Sorry, I forgot to check this. I'll try it as soon as my job script has finished and I can switch to the respective branch.

Unfortunately, this doesn't work. The functions att2var and ncdf_define depend on each other, so there's no way to fix this be re-ordering stuff. For now I can definitely live with the workaround, so this issue is not urgent.

@schlunma #1045 should solve your issue, can you check again?

Yes, that particular case (ncdf_write) works 馃憤

Was this page helpful?
0 / 5 - 0 ratings