diff --git a/src/LIB/SURCOUCHE/src/mode_io_tools_nc4.f90 b/src/LIB/SURCOUCHE/src/mode_io_tools_nc4.f90 index 0a7371e745d0a5d24a97015a894df692ef0a681f..1a0eceddb0cd360a7b8ca79424d336af72a032b7 100644 --- a/src/LIB/SURCOUCHE/src/mode_io_tools_nc4.f90 +++ b/src/LIB/SURCOUCHE/src/mode_io_tools_nc4.f90 @@ -255,7 +255,7 @@ USE MODD_CONF_n, ONLY: CSTORAGE_TYPE USE MODD_DIAG_FLAG, ONLY: LTRAJ USE MODD_DIM_n, ONLY: NIMAX_ll, NJMAX_ll, NKMAX use modd_dyn, only: xseglen -use modd_dyn_n, only: dyn_model, nalbot +use modd_dyn_n, only: dyn_model use modd_field, only: NMNHDIM_NI, NMNHDIM_NJ, NMNHDIM_NI_U, NMNHDIM_NJ_U, NMNHDIM_NI_V, NMNHDIM_NJ_V, & NMNHDIM_LEVEL, NMNHDIM_LEVEL_W, NMNHDIM_TIME, & NMNHDIM_ONE, NMNHDIM_NSWB, NMNHDIM_NLWB, NMNHDIM_TRAJ_TIME, NMNHDIM_COMPLEX, & @@ -296,7 +296,7 @@ CHARACTER(LEN=*),OPTIONAL,INTENT(IN) :: HPROGRAM_ORIG !To emulate a file coming CHARACTER(LEN=:),ALLOCATABLE :: YPROGRAM integer :: iavg, iprof, istation integer :: ispectra_ni, ispectra_nj -INTEGER :: IIU_ll, IJU_ll, IKU +INTEGER :: IIU_ll, IJU_ll, IKU, IKU_MAX integer :: jbox CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_Knowndims_set_nc4','called for '//TRIM(TPFILE%CNAME)) @@ -309,12 +309,12 @@ ENDIF IIU_ll = NIMAX_ll + 2*JPHEXT IJU_ll = NJMAX_ll + 2*JPHEXT -IF ( tpfile%ctype == 'MNHOUTPUT' .AND. LOUT_TAL_REMOVE ) THEN - ! Remove the Top Absorbing Layer (if asked) - IKU = NALBOT +IF ( TPFILE%CTYPE == 'MNHOUTPUT' ) THEN + IKU = TOUT_BOXES(0)%NKSUP - TOUT_BOXES(0)%NKINF + 1 ELSE - IKU = NKMAX + 2*JPVEXT + IKU = NKMAX + 2*JPVEXT END IF +IKU_MAX = NKMAX + 2*JPVEXT if ( .not.Associated( tpfile%tncdims ) ) then call Print_msg( NVERB_ERROR, 'IO', 'IO_Knowndims_set_nc4', 'tncdims not associated for ' // Trim( tpfile%cname ) ) @@ -343,7 +343,8 @@ call IO_Add_dim_nc4( tpfile, NMNHDIM_NJ_V, 'nj_v', IJU_ll ) if ( Trim( yprogram ) /= 'PGD' .and. Trim( yprogram ) /= 'NESPGD' .and. Trim( yprogram ) /= 'ZOOMPG' & .and. .not. ( Trim( yprogram ) == 'REAL' .and. cstorage_type == 'SU' ) ) then !condition to detect PREP_SURFEX call IO_Add_dim_nc4( tpfile, NMNHDIM_LEVEL, 'level', IKU ) - call IO_Add_dim_nc4( tpfile, NMNHDIM_LEVEL_W, 'level_w', IKU ) + ! There is one more PHYSICAL vertical layer for w points (but the same number for physical + unphysical borders) + call IO_Add_dim_nc4( tpfile, NMNHDIM_LEVEL_W, 'level_w', MIN( IKU+1, IKU_MAX ) ) if ( tpfile%ctype /= 'MNHDIACHRONIC' ) & call IO_Add_dim_nc4( tpfile, NMNHDIM_TIME, 'time', Int( NF90_UNLIMITED, kind = Kind(1) ) ) end if