Ok the problem seems solved by adding just the terms "ALLOCATE(W(NPOIN),STAT=ERR)".
The simulations I run seem now to take into account the effect of CN. In particular I modify the code in the following way:
!
CALL BIEF_ALLVEC(1,CN,'CN ',IELM1,1,2,MESH)
ALLOCATE(W(NPOIN),STAT=ERR)
NAME='CN '
CALL FIND_IN_SEL(CN,NAME,T2D_FILES(1)%LU,
& T2D_FILES(1)%FMT ,W,OK)
DEALLOCATE(W)
!
! RAIN-EVAPORATION
!
IF(RAIN) THEN
RAIN_MPS=RAIN_MMPD/86400000.D0
SURDT=1.D0/DT
IF(BANDEC) THEN
! EVAPORATION (TENTATIVELY...) LIMITED BY AVAILABLE WATER
DO I=1,NPOIN
IF(CN%R(I).EQ.40) THEN
RAIN_MPS=-0.0000195833
PLUIE%R(I)=MAX(RAIN_MPS,-MAX(HN%R(I),0.D0)*SURDT)
ELSE IF(CN%R(I).EQ.50) THEN
RAIN_MPS=-0.0000142778
PLUIE%R(I)=MAX(RAIN_MPS,-MAX(HN%R(I),0.D0)*SURDT)
ELSE IF(CN%R(I).EQ.60) THEN
RAIN_MPS=-0.0000123056
PLUIE%R(I)=MAX(RAIN_MPS,-MAX(HN%R(I),0.D0)*SURDT)
ELSE IF(CN%R(I).EQ.65) THEN
RAIN_MPS=-0.0000116111
PLUIE%R(I)=MAX(RAIN_MPS,-MAX(HN%R(I),0.D0)*SURDT)
ELSE IF(CN%R(I).EQ.70) THEN
RAIN_MPS=-0.0000107778
PLUIE%R(I)=MAX(RAIN_MPS,-MAX(HN%R(I),0.D0)*SURDT)
ELSE IF(CN%R(I).EQ.75) THEN
RAIN_MPS=-0.0000096389
PLUIE%R(I)=MAX(RAIN_MPS,-MAX(HN%R(I),0.D0)*SURDT)
ELSE IF(CN%R(I).EQ.95) THEN
RAIN_MPS=-0.0000018889
PLUIE%R(I)=MAX(RAIN_MPS,-MAX(HN%R(I),0.D0)*SURDT)
ELSE IF(CN%R(I).EQ.99) THEN
RAIN_MPS=-0.0000001667
PLUIE%R(I)=MAX(RAIN_MPS,-MAX(HN%R(I),0.D0)*SURDT)
ELSE
RAIN_MPS=-0.0000001667
PLUIE%R(I)=MAX(RAIN_MPS,-MAX(HN%R(I),0.D0)*SURDT)
ENDIF
ENDDO
ELSE
CALL OS('X=C ',X=PLUIE,C=RAIN_MPS)
ENDIF
ENDIF
My aim is to assign an infiltration value to each pixel accoriding to the soil type.
The value I set as RIAN_MPS is the one I found in literature corresponding to a saturated soil (it changes according to CN).
I attach the modified subroutine just in case someone wants to have a look at it.
Suggestions and comments are always appreciated.
Daniele