# "W\_HADV\_TVD" compilation problem

**URL:** <https://forum.croco-ocean.org/t/w-hadv-tvd-compilation-problem/699>\
**Category:** compilation-installation\
**Created:** [May 10, 2024, 8:07am UTC](https://forum.croco-ocean.org/t/w-hadv-tvd-compilation-problem/699 "2024-05-10T08:07:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chinchi](https://forum.croco-ocean.org/letter_avatar_proxy/v4/letter/c/a88e4f/32.png) [@chinchi](https://forum.croco-ocean.org/u/chinchi)\
**Post date:** [May 10, 2024, 8:07am UTC](https://forum.croco-ocean.org/t/w-hadv-tvd-compilation-problem/699/1 "2024-05-10T08:07:25Z")

</div>

When cpp defines W\_HADV\_TVD and W\_VADV\_TVD, compilation fails in v2.0.0.  
But it can be compiled successfully in v1.3.1.  
How can I modify to compile successfully? Thank you.

ps:ubuntu 20.04+gfortran

The compilation error message is as follows:  
#---------------------------------------------------------------------------------  
mpif90 -c -O2 -mcmodel=medium -fdefault-real-8 -fdefault-double-8 -std=legacy -I/usr/include step3d\_fast\_.f -o step3d\_fast.o  
step3d\_fast\_.f:1374:24:

1371 | do k=1,N  
| 2  
…  
1374 | dZdxq\_u(i,j,k)=(z\_r(i,j,k)-z\_r(i-1,j,k))  
| 1  
Warning: Array reference at (1) out of bounds (40 \> 2) in loop beginning at (2)  
step3d\_fast\_.f:1390:53:

1386 | do k=1,N-1  
| 2  
…  
1390 | & \*(dZdxq\_u(i,j,k)+  
| 1  
Warning: Array reference at (1) out of bounds (39 \> 2) in loop beginning at (2)  
step3d\_fast\_.f:1391:53:

1386 | do k=1,N-1  
| 2  
…  
1391 | & dZdxq\_u(i,j,k+1))  
| 1  
Warning: Array reference at (1) out of bounds (40 \> 2) in loop beginning at (2)  
step3d\_fast\_.f:1424:24:

1421 | do k=1,N  
| 2  
…  
1424 | dZdyq\_v(i,j,k)=(z\_r(i,j,k)-z\_r(i,j-1,k))  
| 1  
Warning: Array reference at (1) out of bounds (40 \> 2) in loop beginning at (2)  
step3d\_fast\_.f:1440:47:

1436 | do k=1,N-1  
| 2  
…  
1440 | & \*(dZdyq\_v(i,j,k)+  
| 1  
Warning: Array reference at (1) out of bounds (39 \> 2) in loop beginning at (2)  
step3d\_fast\_.f:1441:47:

1436 | do k=1,N-1  
| 2  
…  
1441 | & dZdyq\_v(i,j,k+1))  
| 1  
Warning: Array reference at (1) out of bounds (40 \> 2) in loop beginning at (2)  
cpp -traditional -DLinux -P -I/usr/include -ICROCOFILES/AGRIF\_INC step3d\_w.F \> step3d\_w\_.f1  
python3 ./change\_loops.py step3d\_w\_.f1 step3d\_w\_.tmp  
cat step3d\_w\_.tmp | ./mpc \> step3d\_w\_.f && \rm step3d\_w\_.tmp  
mpif90 -c -O2 -mcmodel=medium -fdefault-real-8 -fdefault-double-8 -std=legacy -I/usr/include step3d\_w\_.f -o step3d\_w.o  
cpp -traditional -DLinux -P -I/usr/include -ICROCOFILES/AGRIF\_INC rhs3d\_w\_nh.F \> rhs3d\_w\_nh\_.f1  
python3 ./change\_loops.py rhs3d\_w\_nh\_.f1 rhs3d\_w\_nh\_.tmp  
cat rhs3d\_w\_nh\_.tmp | ./mpc \> rhs3d\_w\_nh\_.f && \rm rhs3d\_w\_nh\_.tmp  
mpif90 -c -O2 -mcmodel=medium -fdefault-real-8 -fdefault-double-8 -std=legacy -I/usr/include rhs3d\_w\_nh\_.f -o rhs3d\_w\_nh.o  
rhs3d\_w\_nh\_.f:626:15:

626 | WFx(i,j)=0.5D0\*( wz(i,j,k,nrhs)+wz(i-1,j,k,nrhs)  
| 1  
Error: Rank mismatch in array reference at (1) (2/3)  
rhs3d\_w\_nh\_.f:651:30:

651 | Cr=limiter2(cu,WFx(i,j),cff1,rrm,rr,rrp)  
| 1  
Error: Rank mismatch in array reference at (1) (2/3)  
rhs3d\_w\_nh\_.f:652:15:

652 | WFx(i,j) = (1-Cr)_cff1 + Cr_ WFx(i,j)  
| 1  
Error: Rank mismatch in array reference at (1) (2/3)  
rhs3d\_w\_nh\_.f:652:44:

652 | WFx(i,j) = (1-Cr)_cff1 + Cr_ WFx(i,j)  
| 1  
Error: Rank mismatch in array reference at (1) (2/3)  
rhs3d\_w\_nh\_.f:673:30:

673 | Cr=limiter2(cu,WFx(i,j),cff1,rrm,rr,rrp)  
| 1  
Error: Rank mismatch in array reference at (1) (2/3)  
rhs3d\_w\_nh\_.f:674:15:

674 | WFx(i,j) = (1-Cr)_cff1 + Cr_ WFx(i,j)  
| 1  
Error: Rank mismatch in array reference at (1) (2/3)  
rhs3d\_w\_nh\_.f:674:44:

674 | WFx(i,j) = (1-Cr)_cff1 + Cr_ WFx(i,j)  
| 1  
Error: Rank mismatch in array reference at (1) (2/3)  
rhs3d\_w\_nh\_.f:696:30:

696 | Cr=limiter2(cu,WFx(i,j),cff1,rrm,rr,rrp)  
| 1  
Error: Rank mismatch in array reference at (1) (2/3)  
rhs3d\_w\_nh\_.f:697:15:

697 | WFx(i,j) = (1-Cr)_cff1 + Cr_ WFx(i,j)  
| 1  
Error: Rank mismatch in array reference at (1) (2/3)  
rhs3d\_w\_nh\_.f:697:44:

697 | WFx(i,j) = (1-Cr)_cff1 + Cr_ WFx(i,j)  
| 1  
Error: Rank mismatch in array reference at (1) (2/3)  
rhs3d\_w\_nh\_.f:701:15:

701 | WFe(i,j)=0.5D0\*( Wz(i,j,k,nrhs)+Wz(i,j-1,k,nrhs)  
| 1  
Error: Rank mismatch in array reference at (1) (2/3)  
rhs3d\_w\_nh\_.f:726:30:

726 | Cr=limiter2(cu,WFe(i,j),cff1,rrm,rr,rrp)  
| 1  
Error: Rank mismatch in array reference at (1) (2/3)  
rhs3d\_w\_nh\_.f:727:15:

727 | WFe(i,j) = (1-Cr)_cff1 + Cr_ WFe(i,j)  
| 1  
Error: Rank mismatch in array reference at (1) (2/3)  
rhs3d\_w\_nh\_.f:727:45:

727 | WFe(i,j) = (1-Cr)_cff1 + Cr_ WFe(i,j)  
| 1  
Error: Rank mismatch in array reference at (1) (2/3)  
rhs3d\_w\_nh\_.f:750:30:

750 | Cr=limiter2(cu,WFe(i,j),cff1,rrm,rr,rrp)  
| 1  
Error: Rank mismatch in array reference at (1) (2/3)  
rhs3d\_w\_nh\_.f:751:15:

751 | WFe(i,j) = (1-Cr)_cff1 + Cr_ WFe(i,j)  
| 1  
Error: Rank mismatch in array reference at (1) (2/3)  
rhs3d\_w\_nh\_.f:751:45:

751 | WFe(i,j) = (1-Cr)_cff1 + Cr_ WFe(i,j)  
| 1  
Error: Rank mismatch in array reference at (1) (2/3)  
make: \*\*\* [Makedefs:15: rhs3d\_w\_nh.o] Error 1  
#---------------------------------------------------------------------------------

#Using W\_HADV\_WENO5 and W\_VADV\_WENO5 instead of W\_HADV\_TVD and W\_VADV\_TVD can result in successful compilation in v1.3.1 and v2.0.0.

---

<div class="post-metadata">

**Author:** ![hqcmax](https://forum.croco-ocean.org/user_avatar/forum.croco-ocean.org/hqcmax/32/760_2.png) [@hqcmax](https://forum.croco-ocean.org/u/hqcmax)\
**Post date:** [January 8, 2026, 2:10pm UTC](https://forum.croco-ocean.org/t/w-hadv-tvd-compilation-problem/699/2 "2026-01-08T14:10:38Z")

</div>

Excuse me, have you solved this problem now? I also encountered the same issue when compiling NBQ. Thank you.

---

<div class="post-metadata">

**Author:** ![oartal1](https://forum.croco-ocean.org/user_avatar/forum.croco-ocean.org/oartal1/32/441_2.png) [@oartal1](https://forum.croco-ocean.org/u/oartal1)\
**Post date:** [August 27, 2026, 3:58pm UTC](https://forum.croco-ocean.org/t/w-hadv-tvd-compilation-problem/699/3 "2026-08-27T15:58:39Z")

</div>

Hello everyone.

I know this thread is old, but I ran into the same problem when trying to compile NBC and thought I’d share the solution that worked for me, in case it helps someone else. In cppdefs.h (version 2.0.1, and I think also in 2.0.0) there is this block:

/\* Non-hydrostatic options \*/

# ifdef NBQ

# define W\_HADV\_TVD

# define W\_VADV\_TVD

#endif

The NBQ/LES tutorial recommends schemes that preserve monotonicity for this type of execution. Therefore, changing to WENO5 should be appropriate and also allows the code to compile correctly (at least for me). So, changing this block to:

# ifdef NBQ

# define W\_HADV\_WENO5

# define W\_VADV\_WENO5

#endif

compiles correctly. I hope this helps the community, for now.
