# Error code -57 without parallelisation

**URL:** <https://forum.croco-ocean.org/t/error-code-57-without-parallelisation/7301>\
**Category:** compilation-installation\
**Created:** [March 28, 2025, 1:50pm UTC](https://forum.croco-ocean.org/t/error-code-57-without-parallelisation/7301 "2025-03-28T13:50:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tronka](https://forum.croco-ocean.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@Tronka](https://forum.croco-ocean.org/u/Tronka)\
**Post date:** [March 28, 2025, 1:50pm UTC](https://forum.croco-ocean.org/t/error-code-57-without-parallelisation/7301/1 "2025-03-28T13:50:39Z")

</div>

Hi,  
I am a new user trying to find my way around croco.  
I followed the documentation and got to a stage where I was ready to compile and run the model. However, on model run(./croco croco.in) I get -  
NF\_FREAD ERROR: nf\_get\_vara netCDF error code = -57  
GET\_GRID - error while reading variable : h in grid netCDF file: CROCO\_FILES/croco.grd.  
With a search on the forum I came across  
[previous similar post](https://forum.croco-ocean.org/t/netcdf-error-in-cluster/731), however that was related to MPI/ domain decomposition.  
The tutorial pages also mentions this in connection with MPI/ domain decomposition. I am however (not actively to my knowledge) setting up a parallel run. The console output also says Number of threads: 1 blocking 1 x1. So I doubt this is domain decomp related(however, please correct me if I am wrong).  
I am trying to run the tutorial case BENGUELA LR. I have not made any major changes to the setup except for the following:

1. the .m files in the tools folder do not execute on octave without changing over the commands (netcdf → netcdf.create etc.)
2. add\_topo has indices (j,i) which differs from the indexing in the topo file (returns an index out of bounds error). So, I have switched that to (i,j).  
eg. %topo=cat(2,-topo\_data(j,i1),topo); (original)  
topo=cat(2,-topo\_data(i1,j),topo); (modified)  
In the end h=interp2(y,x,topo,lat,lon,‘cubic’);  
Alternatively h=interp2(x,y,topo’,lon,lat,‘cubic’);

ncdump shows tha the grid file has the variable h. the dimensions are as defined (eta\_rho, xi\_rho) and the values are also printed out fine through ncdump.

So I am at a loss as to what could be causing the problem. Anyone has any hints?

---

<div class="post-metadata">

**Author:** ![popoli](https://forum.croco-ocean.org/letter_avatar_proxy/v4/letter/p/f07891/32.png) [@popoli](https://forum.croco-ocean.org/u/popoli)\
**Post date:** [April 1, 2025, 8:35am UTC](https://forum.croco-ocean.org/t/error-code-57-without-parallelisation/7301/2 "2025-04-01T08:35:48Z")

</div>

need your cppdefs and param.h files

---

<div class="post-metadata">

**Author:** ![Tronka](https://forum.croco-ocean.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@Tronka](https://forum.croco-ocean.org/u/Tronka)\
**Post date:** [April 3, 2025, 9:48am UTC](https://forum.croco-ocean.org/t/error-code-57-without-parallelisation/7301/3 "2025-04-03T09:48:26Z")

</div>

Thanks for the offer! I see that Octave reads and writes the variables in the reverse order. Looked at the ncdump of the grd file for Benguela and compared it to the grd I generate and the eta and xi dimensions are switched. Doing a switch in the pre proc files. Hopefully this solves the problem.

---

<div class="post-metadata">

**Author:** ![Tronka](https://forum.croco-ocean.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@Tronka](https://forum.croco-ocean.org/u/Tronka)\
**Post date:** [April 4, 2025, 7:30am UTC](https://forum.croco-ocean.org/t/error-code-57-without-parallelisation/7301/4 "2025-04-04T07:30:58Z")

</div>

Just wanted to report back that the problem is resolved with respect to that error code. The model starts working, but I get a  
Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation.

I make no chnages to the param and cppdefs from the downloaded files, other than write in my path.  
Seems like a problem with the initialisation?  
The same compilation of crocos works just fine with the input files (.grd, blk, br,bryZ, ini) that I downloaded from the website for the benguela case. So this has to do with the preproc would be my guess.

 ![run_errfpe](https://forum.croco-ocean.org/uploads/default/original/1X/4208cd4076900ca36ae815899fff9a907c028164.png)

---

<div class="post-metadata">

**Author:** ![Tronka](https://forum.croco-ocean.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@Tronka](https://forum.croco-ocean.org/u/Tronka)\
**Post date:** [April 8, 2025, 7:39am UTC](https://forum.croco-ocean.org/t/error-code-57-without-parallelisation/7301/5 "2025-04-08T07:39:30Z")

</div>

Comparing the contents of the generated croco files with the examples files available in the tutorial, I see that the only difference I get in the variables is that the files I generate have time stored as float64, whereas the tutorial input files have timedelta64. Octave doesnt generate this format. However also wondering if this is actually the cause?

---

<div class="post-metadata">

**Author:** ![Tronka](https://forum.croco-ocean.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@Tronka](https://forum.croco-ocean.org/u/Tronka)\
**Post date:** [April 8, 2025, 11:07am UTC](https://forum.croco-ocean.org/t/error-code-57-without-parallelisation/7301/6 "2025-04-08T11:07:17Z")

</div>

Looks like there is a difference between “double” and “NC\_DOUBLE”. Defining the variable NC\_DOUBLE sorts this problem.

However the flosting point error I get from bulk.f remains

---

<div class="post-metadata">

**Author:** ![Tronka](https://forum.croco-ocean.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@Tronka](https://forum.croco-ocean.org/u/Tronka)\
**Post date:** [April 11, 2025, 9:04am UTC](https://forum.croco-ocean.org/t/error-code-57-without-parallelisation/7301/7 "2025-04-11T09:04:22Z")

</div>

I have now solved the problem I faced. thought I would just document my progress here for anyone who faces a similar problem in the future. Summarizing:

1. .m files that ship with the download in croco\_tools have netcdf call that Octave (also matlab) doesn’t consider correct syntax ([as in my post here](https://forum.croco-ocean.org/t/netcdf-calls-in-croco-tools-files/7312)). They need to be switched to the syntax in the documentation: netcdf.create, netcdf.open, netcdf.putVar etc.
2. Octave (here I haven’t tried Matlab) reads and writes the variables in the reverse order of appearance. For example:

> nc=netcdf.open(grdname,“NC\_NOWRITE”);  
> id\_lonr=netcdf.inqVarID(nc, “lon\_rho”);  
> nclonr = netcdf.getVar(nc, id\_lonr);

returns an array of size(xi\_rho, eta\_rho) even though it is stored as (eta\_rho, xi\_rho) in the netdcf file. SO , a reversal.

1. The writing is also reversed. For example:

> var\_u\_s = netcdf.defVar(nc, “u\_south”, ‘NC\_DOUBLE’, [dim\_xi\_u dim\_s\_rho dim\_v3dt]);

is the declaration to create a variable with dimensions [dim\_v3dt, s\_rho, xi\_u].  
And entering values into it also has to be performed in the same order (Reverse of what the downloaded files have)

1. Specifically to Benguela: The external data files do not have Attributes add offset and scale factor and the code defaults it to NaN if the value is not found. This returns an NaN array.  
Additionally, a missing\_value attribute is declared (say -1e9) but the data contains other garbage values for example -5e04. This needs to be cleaned up.

Once these steps are carried out, the case works. I am still a little confused/surprised as to this not being a topics discussed/ pointed out previously on the forum and makes me wonder if I am doing something very seriously wrong.

PS. I drew these conclusions after comparing the preproc files I generated with the preproc files available for download for the benguela case. Thanks to the developers for having those available 🙂

I hope this will help someone, or I get feedback on something I am doing seriously wrong 😃
