diff --git a/src/LIB/SURCOUCHE/src/modd_field.f90 b/src/LIB/SURCOUCHE/src/modd_field.f90 index 7f44477b9df6625d66d51d9c7a3381cc4d481cfb..8d75b37d6786e704c9c5b6b57bb66cd0d69b4551 100644 --- a/src/LIB/SURCOUCHE/src/modd_field.f90 +++ b/src/LIB/SURCOUCHE/src/modd_field.f90 @@ -315,6 +315,7 @@ type(tfieldmetadata) function Fill_tfieldmetadata( cmnhname, cstdname, clongname logical, optional, intent(in) :: ltimedep character(len=:), allocatable :: ymnhname + logical :: gdimlistfilled ! cmnhname if ( Present( cmnhname ) ) then @@ -418,29 +419,44 @@ type(tfieldmetadata) function Fill_tfieldmetadata( cmnhname, cstdname, clongname tpfield%ndimlist(tpfield%ndims+1:) = NMNHDIM_UNUSED else !If ndimlist is not provided, it is possible to fill it if some information is available + gdimlistfilled = .false. if ( Present( cdir ) ) then if ( cdir == 'XY' ) then ! Check also on NGRIDUNKNOWN (this happens if the optional ngrid argument is not provided) if ( tpfield%ndims == 2 .and. tpfield%ngrid /= NGRIDUNKNOWN ) then tpfield%ndimlist(1:2) = NMNHDIM_ARAKAWA(tpfield%ngrid,1:2) + gdimlistfilled = .true. else if ( tpfield%ndims == 3 .and. tpfield%ngrid /= NGRIDUNKNOWN ) then tpfield%ndimlist(1:3) = NMNHDIM_ARAKAWA(tpfield%ngrid,1:3) + gdimlistfilled = .true. else if ( tpfield%ndims == 4 .and. tpfield%ngrid /= NGRIDUNKNOWN ) then tpfield%ndimlist(1:3) = NMNHDIM_ARAKAWA(tpfield%ngrid,1:3) tpfield%ndimlist(4) = NMNHDIM_NOTLISTED - else - call Print_msg( NVERB_DEBUG, 'GEN', 'Fill_tfielddata', 'ndimlist not filled for variable ' // Trim( ymnhname ) ) + gdimlistfilled = .true. + end if + else if ( cdir == 'XX' ) then + if ( tpfield%ndims == 1 .and. tpfield%ngrid /= NGRIDUNKNOWN ) then + tpfield%ndimlist(1) = NMNHDIM_ARAKAWA(tpfield%ngrid,1) + gdimlistfilled = .true. + end if + else if ( cdir == 'YY' ) then + if ( tpfield%ndims == 1 .and. tpfield%ngrid /= NGRIDUNKNOWN ) then + tpfield%ndimlist(1) = NMNHDIM_ARAKAWA(tpfield%ngrid,2) + gdimlistfilled = .true. + end if + else if ( cdir == 'ZZ' ) then + if ( tpfield%ndims == 1 .and. tpfield%ngrid /= NGRIDUNKNOWN ) then + tpfield%ndimlist(1) = NMNHDIM_ARAKAWA(tpfield%ngrid,3) + gdimlistfilled = .true. end if - else - call Print_msg( NVERB_DEBUG, 'GEN', 'Fill_tfielddata', 'ndimlist not filled for variable ' // Trim( ymnhname ) ) end if - else - call Print_msg( NVERB_DEBUG, 'GEN', 'Fill_tfielddata', 'ndimlist not filled for variable ' // Trim( ymnhname ) ) end if + if (.not. gdimlistfilled ) & + call Print_msg( NVERB_DEBUG, 'GEN', 'Fill_tfielddata', 'ndimlist not filled for variable ' // Trim( ymnhname ) ) end if if ( Present( ltimedep ) ) then if ( ltimedep ) then - if ( tpfield%ndims == NMNHMAXDIMS ) & + if ( tpfield%ndims == NMNHMAXDIMS ) & call Print_msg( NVERB_ERROR, 'GEN', 'Fill_tfielddata', & 'ltimedep=T not possible if ndims=NMNHMAXDIMS for variable ' // Trim( ymnhname ) ) !Set this dimension only if ndimlist already filled up or tpfield%ndims = 0