diff --git a/src/LIB/SURCOUCHE/src/mode_io_field_write.f90 b/src/LIB/SURCOUCHE/src/mode_io_field_write.f90 index 357aa7998fb18fcb70750c2930c76532b644d997..4e3a02ea91c4dbaa22f7b0692f50111c012f474c 100644 --- a/src/LIB/SURCOUCHE/src/mode_io_field_write.f90 +++ b/src/LIB/SURCOUCHE/src/mode_io_field_write.f90 @@ -3917,7 +3917,7 @@ IMI = GET_CURRENT_MODEL_INDEX() ! IF ( LOUT_BIGBOX_WRITE ) THEN DO JI = 1, SIZE( NOUT_FIELDLIST ) - CALL IO_Fieldlist_1field_write( TPOUTPUT, IMI, TFIELDLIST(NOUT_FIELDLIST(JI)) ) + CALL IO_Fieldlist_1field_write( TPOUTPUT, IMI, TFIELDLIST(NOUT_FIELDLIST(JI)), TOUT_BOXES(0) ) END DO END IF @@ -3964,7 +3964,7 @@ SUBROUTINE IO_Fieldlist_1field_write( TPOUTPUT, KMI, TPFIELD, TPBOX ) USE MODD_FIELD, ONLY: NMNHDIM_BOX_NI, NMNHDIM_BOX_NJ, NMNHDIM_BOX_NI_U, NMNHDIM_BOX_NJ_U, NMNHDIM_BOX_NI_V, & NMNHDIM_BOX_NJ_V, NMNHDIM_BOX_LEVEL, NMNHDIM_BOX_LEVEL_W, NMNHDIM_NOTLISTED, & TFIELDDATA, TFIELDMETADATA -USE MODD_OUT_n, ONLY: TOUTBOXMETADATA +USE MODD_OUT_n, ONLY: CMAINDOMAINNAME, TOUTBOXMETADATA USE MODD_PARAMETERS, ONLY: JPHEXT, JPVEXT TYPE(TFILEDATA), INTENT(IN) :: TPOUTPUT !Output file @@ -3975,7 +3975,7 @@ TYPE(TOUTBOXMETADATA), OPTIONAL, INTENT(IN) :: TPBOX TYPE(TFIELDMETADATA) :: TZFIELDMD IF ( PRESENT(TPBOX) ) THEN - IF ( TPFIELD%NDIMS /= 3 .AND. TPFIELD%NTYPE /= TYPEREAL ) THEN + IF ( TPBOX%CNAME /= CMAINDOMAINNAME .AND. TPFIELD%NDIMS /= 3 .AND. TPFIELD%NTYPE /= TYPEREAL ) THEN CALL Print_msg( NVERB_ERROR, 'IO', 'IO_Fieldlist_1field_write', 'TPBOX optional dummy argument not allowed for field ' & // TRIM(TPFIELD%CMNHNAME) ) RETURN @@ -4259,28 +4259,31 @@ NDIMS: SELECT CASE (TPFIELD%NDIMS) TZFIELDMD = TFIELDMETADATA( TPFIELD ) !Copy only metadata (TZFIELD is of TYPE(TFIELDMETADATA)) IF ( TZFIELDMD%CDIR /= 'XY' ) & CALL Print_msg( NVERB_ERROR, 'IO', 'IO_Fieldlist_1field_write', trim(tpfield%cmnhname)//': must have CDIR="XY"' ) - SELECT CASE ( TZFIELDMD%NGRID ) - CASE( 1, 4 ) - TZFIELDMD%NDIMLIST(1) = NMNHDIM_BOX_NI - CASE( 2 ) - TZFIELDMD%NDIMLIST(1) = NMNHDIM_BOX_NI_U - CASE( 3 ) - TZFIELDMD%NDIMLIST(1) = NMNHDIM_BOX_NI_V - END SELECT - SELECT CASE ( TZFIELDMD%NGRID ) - CASE( 1, 4 ) - TZFIELDMD%NDIMLIST(2) = NMNHDIM_BOX_NJ - CASE( 2 ) - TZFIELDMD%NDIMLIST(2) = NMNHDIM_BOX_NJ_U - CASE( 3 ) - TZFIELDMD%NDIMLIST(2) = NMNHDIM_BOX_NJ_V - END SELECT - SELECT CASE ( TZFIELDMD%NGRID ) - CASE( 1, 2, 3 ) - TZFIELDMD%NDIMLIST(3) = NMNHDIM_BOX_LEVEL - CASE( 4 ) - TZFIELDMD%NDIMLIST(3) = NMNHDIM_BOX_LEVEL_W - END SELECT + ! Modify ndimlist except for main domain + IF ( TPBOX%CNAME /= CMAINDOMAINNAME ) THEN + SELECT CASE ( TZFIELDMD%NGRID ) + CASE( 1, 4 ) + TZFIELDMD%NDIMLIST(1) = NMNHDIM_BOX_NI + CASE( 2 ) + TZFIELDMD%NDIMLIST(1) = NMNHDIM_BOX_NI_U + CASE( 3 ) + TZFIELDMD%NDIMLIST(1) = NMNHDIM_BOX_NI_V + END SELECT + SELECT CASE ( TZFIELDMD%NGRID ) + CASE( 1, 4 ) + TZFIELDMD%NDIMLIST(2) = NMNHDIM_BOX_NJ + CASE( 2 ) + TZFIELDMD%NDIMLIST(2) = NMNHDIM_BOX_NJ_U + CASE( 3 ) + TZFIELDMD%NDIMLIST(2) = NMNHDIM_BOX_NJ_V + END SELECT + SELECT CASE ( TZFIELDMD%NGRID ) + CASE( 1, 2, 3 ) + TZFIELDMD%NDIMLIST(3) = NMNHDIM_BOX_LEVEL + CASE( 4 ) + TZFIELDMD%NDIMLIST(3) = NMNHDIM_BOX_LEVEL_W + END SELECT + END IF CALL IO_Field_write_BOX( TPOUTPUT, TZFIELDMD, 'OTHER', TPFIELD%TFIELD_X3D(KMI)%DATA, & KXOBOX = JPHEXT + TPBOX%NIINF, KXEBOX = JPHEXT + TPBOX%NISUP, & KYOBOX = JPHEXT + TPBOX%NJINF, KYEBOX = JPHEXT + TPBOX%NJSUP, & diff --git a/src/LIB/SURCOUCHE/src/mode_io_manage_struct.f90 b/src/LIB/SURCOUCHE/src/mode_io_manage_struct.f90 index 8f5182b6b3c21b11b420d23cc2f501655894364e..db27db09df8777dca66abea1a9dde35c2b25cbd3 100644 --- a/src/LIB/SURCOUCHE/src/mode_io_manage_struct.f90 +++ b/src/LIB/SURCOUCHE/src/mode_io_manage_struct.f90 @@ -792,6 +792,7 @@ SUBROUTINE IO_BOX_PREPARE( KMI ) !######################################################################### USE MODD_DIM_n, ONLY: NIMAX_ll, NJMAX_ll, NKMAX + USE MODD_OUT_n, ONLY: CMAINDOMAINNAME INTEGER, INTENT(IN) :: KMI @@ -806,8 +807,34 @@ SUBROUTINE IO_BOX_PREPARE( KMI ) OUT_MODEL(IMI)%LOUT_BIGBOX_WRITE = LOUT_MAINDOMAIN_WRITE(IMI) OUT_MODEL(IMI)%NOUT_NBOXES = NOUT_BOXES(IMI) - ALLOCATE( OUT_MODEL(IMI)%TOUT_BOXES(NOUT_BOXES(IMI)) ) + + ! Allocate boxes + IF ( OUT_MODEL(IMI)%LOUT_BIGBOX_WRITE ) THEN + ! Allocate also a special box for the main domain (box number 0) + ! This is useful to store its boundaries (ie used if we remove unphysical boundaries or top absorbing layer) + ALLOCATE( OUT_MODEL(IMI)%TOUT_BOXES(0:NOUT_BOXES(IMI)) ) + ELSE + ALLOCATE( OUT_MODEL(IMI)%TOUT_BOXES(NOUT_BOXES(IMI)) ) + END IF + TOUT_BOXES => OUT_MODEL(IMI)%TOUT_BOXES + + ! Treat special box for main domain + IF ( OUT_MODEL(IMI)%LOUT_BIGBOX_WRITE ) THEN + TOUT_BOXES(0)%CNAME = CMAINDOMAINNAME + + ALLOCATE( TOUT_BOXES(0)%NFIELDLIST_SUPP(0) ) + + ! Set boundaries in physical domain coordinates, but must cover all the domain with non-physical values + TOUT_BOXES(0)%NIINF = 1 - JPHEXT + TOUT_BOXES(0)%NISUP = NIMAX_ll + JPHEXT + TOUT_BOXES(0)%NJINF = 1 - JPHEXT + TOUT_BOXES(0)%NJSUP = NJMAX_ll + JPHEXT + TOUT_BOXES(0)%NKINF = 1 - JPVEXT + TOUT_BOXES(0)%NKSUP = NKMAX + JPVEXT + END IF + + ! Treat boxes DO JI = 1, OUT_MODEL(IMI)%NOUT_NBOXES IF ( LEN_TRIM(COUT_BOX_NAME(IMI,JI)) > 0 ) THEN TOUT_BOXES(JI)%CNAME = COUT_BOX_NAME(IMI,JI) diff --git a/src/MNH/modd_outn.f90 b/src/MNH/modd_outn.f90 index b52bdc2667017665e6b76d8c15c6a9a783113174..862faa7dcbfed8dc1e0f44f0a03dbab3b1842de0 100644 --- a/src/MNH/modd_outn.f90 +++ b/src/MNH/modd_outn.f90 @@ -46,6 +46,8 @@ IMPLICIT NONE SAVE +CHARACTER(LEN=NMNHNAMELGTMAX), PARAMETER :: CMAINDOMAINNAME = 'MAINDOMAIN' + TYPE TOUTBOXMETADATA CHARACTER(LEN=NMNHNAMELGTMAX):: CNAME = '' ! Name of the box INTEGER, DIMENSION(:), ALLOCATABLE :: NFIELDLIST_SUPP ! Lists of fields to write (added to the NOUT_FIELDLIST)