# Netcdf error in cluster

**URL:** <https://forum.croco-ocean.org/t/netcdf-error-in-cluster/731>\
**Category:** ze miscellaneous\
**Created:** [June 14, 2024, 7:05am UTC](https://forum.croco-ocean.org/t/netcdf-error-in-cluster/731 "2024-06-14T07:05:51Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![febin](https://forum.croco-ocean.org/letter_avatar_proxy/v4/letter/f/eada6e/32.png) [@febin](https://forum.croco-ocean.org/u/febin)\
**Post date:** [June 14, 2024, 7:05am UTC](https://forum.croco-ocean.org/t/netcdf-error-in-cluster/731/1 "2024-06-14T07:05:51Z")

</div>

NF\_FREAD ERROR: nf\_get\_vara netCDF error code = -57 mynode = 2

GET\_GRID - error while reading variable: h  
in grid netCDF file: CROCO\_FILES/croco\_grd.nc

Spherical grid detected.

NF\_FREAD ERROR: nf\_get\_vara netCDF error code = -57 mynode = 0

GET\_GRID - error while reading variable: h  
in grid netCDF file: CROCO\_FILES/croco\_grd.nc

MAIN - number of records written into history file(s): 0  
number of records written into restart file(s): 0  
number of records written into averages file(s): 0

ERROR: Abnormal termination: netCDF INPUT

any idea what this error is?

---

<div class="post-metadata">

**Author:** ![jcollin](https://forum.croco-ocean.org/letter_avatar_proxy/v4/letter/j/67e7ee/32.png) [@jcollin](https://forum.croco-ocean.org/u/jcollin)\
**Post date:** [June 21, 2024, 7:41am UTC](https://forum.croco-ocean.org/t/netcdf-error-in-cluster/731/2 "2024-06-21T07:41:34Z")

</div>

Hi @febin,

It sounds like you have no bathymetry defined within your croco\_grd.nc file. You probably missed a step when building it. The error code `-57` can mean that there is an issue with variable dimension too.

- check dimensions

```Bash
ncdump -h CROCO_FILES/croco_grd.nc

```

- check values

```Bash
 ncdump -v "h" CROCO_FILES/croco_grd.nc

```

- Also `mynode=2` may suggest that you are using CROCO in parallel. If you defined PARALLEL\_FILES cpp key you have to split your files using `partit`

`./partit np_xi np_eta croco_grd.nc`

same for any other file required at start like croco\_ini.nc

I hope this helps,  
Jeremy

---

<div class="post-metadata">

**Author:** ![ctroupin1](https://forum.croco-ocean.org/user_avatar/forum.croco-ocean.org/ctroupin1/32/778_2.png) [@ctroupin1](https://forum.croco-ocean.org/u/ctroupin1)\
**Post date:** [February 2, 2026, 8:50pm UTC](https://forum.croco-ocean.org/t/netcdf-error-in-cluster/731/3 "2026-02-02T20:50:45Z")

</div>

Hello,

I found this thread while searching for the error message.  
I’m getting the same error, sometimes the error\_code is -40, sometimes -57

```bash
 ...
 NUMBER OF THREADS: 1 BLOCKING: 1 x 1.

 NF_FREAD ERROR: nf_get_vara netCDF error code = -40 mynode = 127

 GET_GRID - error while reading variable: h
            in grid netCDF file: CROCO_FILES/run_nea/croco_grd_nea.nc

 NF_FREAD ERROR: nf_get_vara netCDF error code = -40 mynode = 126

 GET_GRID - error while reading variable: h
            in grid netCDF file: CROCO_FILES/run_nea/croco_grd_nea.nc

 Spherical grid detected.

 NF_FREAD ERROR: nf_get_vara netCDF error code = -57 mynode = 0

 GET_GRID - error while reading variable: h
            in grid netCDF file: CROCO_FILES/run_nea/croco_grd_nea.nc
 ...

```

I confirm that

1. the variable `h`is present in the grid file `croco_grd_nea.nc`.
2. we don’t use parallel\_files:

```auto
# ifdef MPI
# undef PARALLEL_FILES
# undef NC4PAR
# undef MPI_NOLAND
# undef MPI_TIME
# endif

```

The code was run with `MPI` and the error only appears for certain combinations of the parameters `NP_XI` and `NP_ETA`.

For instance:

- `NP_XI=1, NP_ETA=64` fails (with the error messages above)
- `NP_XI=2, NP_ETA=32` works.

---

<div class="post-metadata">

**Author:** ![lcbernardo](https://forum.croco-ocean.org/letter_avatar_proxy/v4/letter/l/8e7dd6/32.png) [@lcbernardo](https://forum.croco-ocean.org/u/lcbernardo)\
**Post date:** [February 3, 2026, 2:30am UTC](https://forum.croco-ocean.org/t/netcdf-error-in-cluster/731/4 "2026-02-03T02:30:58Z")

</div>

Hi,

I rarely these kinds of combinations for NP\_XI and NP\_ETA. What are your grid dimensions?

---

<div class="post-metadata">

**Author:** ![ctroupin1](https://forum.croco-ocean.org/user_avatar/forum.croco-ocean.org/ctroupin1/32/778_2.png) [@ctroupin1](https://forum.croco-ocean.org/u/ctroupin1)\
**Post date:** [February 3, 2026, 9:15am UTC](https://forum.croco-ocean.org/t/netcdf-error-in-cluster/731/5 "2026-02-03T09:15:55Z")

</div>

Hello,

I agree, those combinations are not usual, yet my point here is to show that the error mentioned by [febin](https://forum.croco-ocean.org/u/febin) can have its origin in the tiling.

My grid in this test was: 884 X 800.

Thanks

---

<div class="post-metadata">

**Author:** ![slegac](https://forum.croco-ocean.org/user_avatar/forum.croco-ocean.org/slegac/32/267_2.png) [@slegac](https://forum.croco-ocean.org/u/slegac)\
**Post date:** [February 3, 2026, 10:28am UTC](https://forum.croco-ocean.org/t/netcdf-error-in-cluster/731/6 "2026-02-03T10:28:49Z")

</div>

Hello,

The splitting 1x64 with your grid give really small mpi domain \<15 points… I suggest to not use this splitting. The 2x32 is better.

But beside that, it seems your grid file does not match the compiled grid dimensions.

Can you precise which version of CROCO you are using ?  
And can you attached your param.h, cppdefs.h and the results of ncdump -h on your grid file please ?

---

<div class="post-metadata">

**Author:** ![ctroupin1](https://forum.croco-ocean.org/user_avatar/forum.croco-ocean.org/ctroupin1/32/778_2.png) [@ctroupin1](https://forum.croco-ocean.org/u/ctroupin1)\
**Post date:** [February 3, 2026, 10:33am UTC](https://forum.croco-ocean.org/t/netcdf-error-in-cluster/731/7 "2026-02-03T10:33:48Z")

</div>

Yes you’re right, **1 X 64** is not the best, I was testing different combinations to see which one was the fastest.

I’m using `croco-v2.1.1`.

> [@slegac](#):
>
> But beside that, it seems your grid file does not match the compiled grid dimensions.

This is because the error log I copied was from another experiment, but the same messages appear with the test **1 x 64** (except that `mynode` takes value from 0 to 63).

---

<div class="post-metadata">

**Author:** ![slegac](https://forum.croco-ocean.org/user_avatar/forum.croco-ocean.org/slegac/32/267_2.png) [@slegac](https://forum.croco-ocean.org/u/slegac)\
**Post date:** [February 3, 2026, 10:43am UTC](https://forum.croco-ocean.org/t/netcdf-error-in-cluster/731/8 "2026-02-03T10:43:13Z")

</div>

I think the issue comes from the MPI domain decomposition. With 800 grid points split over 64 MPI subdomains, you end up with about 12–13 points per subdomain. In that case, the last MPI domain can go out of bounds: for example, if 13 points are assigned per domain, then 13×63=819, which already exceeds 800 before reaching the last domain.

As far as I know, CROCO does not explicitly check for this situation in its MPI decomposition, so this kind of configuration can lead to indexing errors.

In this case, the safest solution is to use a decomposition that results in larger subdomains — typically at least 20–30 grid points per MPI domain — which avoids these boundary issues and is generally more robust.

---

<div class="post-metadata">

**Author:** ![ctroupin1](https://forum.croco-ocean.org/user_avatar/forum.croco-ocean.org/ctroupin1/32/778_2.png) [@ctroupin1](https://forum.croco-ocean.org/u/ctroupin1)\
**Post date:** [February 3, 2026, 10:46am UTC](https://forum.croco-ocean.org/t/netcdf-error-in-cluster/731/9 "2026-02-03T10:46:03Z")

</div>

Thanks for the explanation! I was thinking the same

> CROCO does not explicitly check for this situation in its MPI decomposition

Usually I try to have a more regular decomposition (8 X 8) but as I was testing how the code reacted with this type if tiling.

With regards

---

<div class="post-metadata">

**Author:** ![hook-hulk](https://forum.croco-ocean.org/user_avatar/forum.croco-ocean.org/hook-hulk/32/783_2.png) [@hook-hulk](https://forum.croco-ocean.org/u/hook-hulk)\
**Post date:** [February 3, 2026, 11:48am UTC](https://forum.croco-ocean.org/t/netcdf-error-in-cluster/731/10 "2026-02-03T11:48:33Z")

</div>

you are undef PARALLEL\_FILES It’s very good (they have a very critical bug) . but define NC4PAR . its good for mpi job. how many vertical levels you have in. in your system how many cores do you want to use at a time?  
Thank you!

---

<div class="post-metadata">

**Author:** ![ctroupin1](https://forum.croco-ocean.org/user_avatar/forum.croco-ocean.org/ctroupin1/32/778_2.png) [@ctroupin1](https://forum.croco-ocean.org/u/ctroupin1)\
**Post date:** [February 3, 2026, 2:19pm UTC](https://forum.croco-ocean.org/t/netcdf-error-in-cluster/731/11 "2026-02-03T14:19:36Z")

</div>

Thanks for the suggestion, I will check now with `NC4PAR`.

> [@hook-hulk](#):
>
> how many vertical levels you have in

Now 32 levels but that might change soon, I’m just testing.

> [@hook-hulk](#):
>
> in your system how many cores do you want to use at a time?

64 cores; I’ve tried with more but that did not make the simulation faster (I guess because of the MPI tiling).

---

<div class="post-metadata">

**Author:** ![hook-hulk](https://forum.croco-ocean.org/user_avatar/forum.croco-ocean.org/hook-hulk/32/783_2.png) [@hook-hulk](https://forum.croco-ocean.org/u/hook-hulk)\
**Post date:** [February 3, 2026, 3:43pm UTC](https://forum.croco-ocean.org/t/netcdf-error-in-cluster/731/12 "2026-02-03T15:43:54Z")

</div>

Indeed. MPI tiling. (for better mpi you need your region of interest x/y ratio maintain square then decomposition is easy).  
check there is an easy grid there you can choose LLm MMm etc (maybe).  
and your OMP\_NUM\_THREADS is 1 or 2?  
First try :  
export HDF5\_USE\_FILE\_LOCKING=FALSE  
(Disabling locking does **NOT** make parallel I/O safe but try it first)  
during compile the lib use --enable-parallel --enable-shared.  
then test it all ($ make check all)  
then check:  
h5pcc -showconfig | grep -i parallel

which compiler did you use for the compiling model?  
Thank you.

---

<div class="post-metadata">

**Author:** ![ctroupin1](https://forum.croco-ocean.org/user_avatar/forum.croco-ocean.org/ctroupin1/32/778_2.png) [@ctroupin1](https://forum.croco-ocean.org/u/ctroupin1)\
**Post date:** [February 5, 2026, 5:01pm UTC](https://forum.croco-ocean.org/t/netcdf-error-in-cluster/731/13 "2026-02-05T17:01:06Z")

</div>

Thanks for the suggestions, I take note, unfortunately I cannot work anymore on this topic for the moment due to other committments, but I’ll surely try what you indicate and will keep you informed.
