Re: Calling Fortran 90 subroutine from NCL complains about array dimensions

From: Ekin Akoglu <ekin_at_nyahnyahspammersnyahnyah>
Date: Wed Jun 25 2014 - 03:24:25 MDT

Dear Dennis,

After failed attempts to upload my data files to FTP due to an error "553
Could not create file.", I fiddled with my "layers.ncl" script more and
resolved the issue. Indeed, the problem was identical to the condition
explained in Example 5 (
https://www.ncl.ucar.edu/Document/Tools/WRAPIT.shtml#Example_5). For
reference, here is how I solved the solution:

I have a 4D array with dimensions as (time, depth, lat, lon). I read these
from netCDf file in NCL and post-process the array with a Fortran 90
subroutine called within an NCL script. However, it gave error as below:


fatal:depth_integrator: dimension size of dimension (2) of NPP must be
equal to the value of z
fatal:["Execute.c":8567]:


The remedy was, when supplying the arguments to the Fortran subroutine
during call within the NCL script, the dimensions of the arrays need to be
reversed. Let's say our array NPP has named dimensions of (time, z, y, x)
as below:

 NPP = new((/time, z, y, x/), "double") ; define 4D array
 data = addfile(filelist(ncfile), "r") ; add file for reading
 NPP = data->NPP ; read data

; while giving the 4D array as an argument to the F90 function call,
reorder named dimensions
EX01::depth_integrator(ntime, nlayer, nlatitude, nlongitude, NPP(x | :, y |
:, z | :, time | :))


That was it. Thank you for your time.

Kind regards,

Ekin

On 25 June 2014 01:48, Dennis Shea <shea@ucar.edu> wrote:

> I think you would have to provide the source data files.
>
> ftp ftp.cgd.ucar.edu
> anonymous
> <use your email address for the password>
> cd incoming
> put ...
> put ...
> .
> .
> .
> quit
>
> Note that for security reasons, you cannot list the contents of this
> directory, and neither can we. We need to know the *exact* names of the
> files in order to retrieve them.
>
> Send email to ncl-talk <ncl-talk@ucar.edu> (you must subscribe
> <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> first) with the
> following information:
>
>
> - The names of the files after you have successfully completed the
> transfer.
> - The version of NCL you are running (ncl -V).
> - The type of system you are on (uname -a).
> - The exact error message you are getting. If there is no error
> message, then a detailed description of the problem.
>
> Thank you for your consideration.
>
>
>
> On Tue, Jun 24, 2014 at 2:23 PM, Ekin Akoglu <ekin@ims.metu.edu.tr> wrote:
>
>> Dear all,
>>
>> I could not figure out why but I couldn't manage to make a Fortran 90
>> subroutine work with a call in an NCL script. WRAPIT compiles and creates
>> the *.so file without problems. But the NCL script gives error on line with
>> the call to the F90 code. The error is:
>>
>> fatal:depth_integrator: dimension size of dimension (2) of
>> layer_thickness must be equal to the value of nlayer
>> fatal:["Execute.c":8567]:Execute: Error occurred at or near line 90 in
>> file layers.ncl
>>
>> I understand that something does not fit when passing between NCL and F90
>> and it is the array dimensioning. However, I couldn't figure out what is
>> wrong.I also examined Example 5 (
>> https://www.ncl.ucar.edu/Document/Tools/WRAPIT.shtml#Example_5) for
>> differences in array dimensions between NCL and Fortran to no avail. I
>> would be glad if you could provide some help. Attached is the NCL script,
>> F90 code and the stub file for your reference.
>>
>> Thank you in advance.
>>
>> Kind regards,
>>
>> Ekin
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>

Received on Wed Jun 25 09:24:32 2014

This archive was generated by hypermail 2.1.8 : Wed Jul 23 2014 - 15:33:46 MDT