diff --git a/src/LIB/SURCOUCHE/src/modd_field.f90 b/src/LIB/SURCOUCHE/src/modd_field.f90 index 8d75b37d6786e704c9c5b6b57bb66cd0d69b4551..2f07d1009190e6994646c4d0a7123bdbfc55e06d 100644 --- a/src/LIB/SURCOUCHE/src/modd_field.f90 +++ b/src/LIB/SURCOUCHE/src/modd_field.f90 @@ -103,6 +103,7 @@ integer, parameter :: NMNHDIM_LASTDIM_DIACHRO = 43 ! Index of the last defi ! because they are allocated in separated structures (1 for each box instead of being in the global dimension list) integer, parameter :: NMNHDIM_BOX_FIRST_ENTRY = 44 +! Important note: keep the order of these coordinates similar to that of the main dimensions (NMNHDIM_NI...) integer, parameter :: NMNHDIM_BOX_NI = NMNHDIM_BOX_FIRST_ENTRY integer, parameter :: NMNHDIM_BOX_NJ = 45 integer, parameter :: NMNHDIM_BOX_NI_U = 46 diff --git a/src/LIB/SURCOUCHE/src/mode_io_field_write.f90 b/src/LIB/SURCOUCHE/src/mode_io_field_write.f90 index d07caaa75b91210e5835da8f4be22ae796ecbfe9..9024c3c182009a4037b585479310001d3fb3e805 100644 --- a/src/LIB/SURCOUCHE/src/mode_io_field_write.f90 +++ b/src/LIB/SURCOUCHE/src/mode_io_field_write.f90 @@ -3524,7 +3524,7 @@ end subroutine IO_Ndimlist_reduce END SUBROUTINE IO_Field_write_byfield_lb - SUBROUTINE IO_Field_write_box_byfield_N1( TPFILE, TPFIELD, HBUDGET, KFIELD, KXOBOX, KXEBOX, KRESP, koffset ) + SUBROUTINE IO_Field_write_box_byfield_N1( TPFILE, TPFIELD, HBUDGET, KFIELD, KXOBOX, KXEBOX, KRESP, koffset, kboxid ) ! USE MODD_IO, ONLY: GSMONOPROC, ISP ! @@ -3541,6 +3541,7 @@ end subroutine IO_Ndimlist_reduce INTEGER, INTENT(IN) :: KXEBOX ! Global coordinates of the box INTEGER, OPTIONAL, INTENT(OUT) :: KRESP ! return-code integer, dimension(2), optional, intent(in) :: koffset + integer, optional, intent(in) :: kboxid ! Box number (ie for subdomain in output file) ! !* 0.2 Declarations of local variables ! @@ -3582,7 +3583,7 @@ end subroutine IO_Ndimlist_reduce if ( gnc4 ) call IO_Field_partial_write_nc4( tpfile, tpfield, IFIELDP, koffset, iresp_nc4 ) else if ( glfi ) call IO_Field_write_lfi( tpfile, tpfield, IFIELDP, iresp_lfi ) - if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, IFIELDP, iresp_nc4 ) + if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, IFIELDP, iresp_nc4, kboxid = kboxid ) end if ELSE ! multiprocesses execution IF (ISP == TPFILE%NMASTER_RANK) THEN @@ -3609,7 +3610,7 @@ end subroutine IO_Ndimlist_reduce if ( gnc4 ) call IO_Field_partial_write_nc4( tpfile, tpfield, IFIELDP, koffset, iresp_nc4 ) else if ( glfi ) call IO_Field_write_lfi( tpfile, tpfield, IFIELDP, iresp_lfi ) - if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, IFIELDP, iresp_nc4 ) + if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, IFIELDP, iresp_nc4, kboxid = kboxid ) end if END IF END IF ! multiprocesses execution @@ -3622,7 +3623,8 @@ end subroutine IO_Ndimlist_reduce END SUBROUTINE IO_Field_write_box_byfield_N1 - SUBROUTINE IO_Field_write_box_byfield_N2( TPFILE, TPFIELD, HBUDGET, KFIELD, KXOBOX, KXEBOX, KYOBOX, KYEBOX, KRESP, koffset ) + SUBROUTINE IO_Field_write_box_byfield_N2( TPFILE, TPFIELD, HBUDGET, KFIELD, KXOBOX, KXEBOX, KYOBOX, KYEBOX, KRESP, & + koffset, kboxid ) ! USE MODD_IO, ONLY: GSMONOPROC, ISP ! @@ -3641,6 +3643,7 @@ end subroutine IO_Ndimlist_reduce INTEGER, INTENT(IN) :: KYEBOX ! INTEGER, OPTIONAL, INTENT(OUT) :: KRESP ! return-code integer, dimension(2), optional, intent(in) :: koffset + integer, optional, intent(in) :: kboxid ! Box number (ie for subdomain in output file) ! !* 0.2 Declarations of local variables ! @@ -3682,7 +3685,7 @@ end subroutine IO_Ndimlist_reduce if ( gnc4 ) call IO_Field_partial_write_nc4( tpfile, tpfield, IFIELDP, koffset, iresp_nc4 ) else if ( glfi ) call IO_Field_write_lfi( tpfile, tpfield, IFIELDP, iresp_lfi ) - if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, IFIELDP, iresp_nc4 ) + if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, IFIELDP, iresp_nc4, kboxid = kboxid ) end if ELSE ! multiprocesses execution IF (ISP == TPFILE%NMASTER_RANK) THEN @@ -3703,7 +3706,7 @@ end subroutine IO_Ndimlist_reduce if ( gnc4 ) call IO_Field_partial_write_nc4( tpfile, tpfield, IFIELDP, koffset, iresp_nc4 ) else if ( glfi ) call IO_Field_write_lfi( tpfile, tpfield, IFIELDP, iresp_lfi ) - if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, IFIELDP, iresp_nc4 ) + if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, IFIELDP, iresp_nc4, kboxid = kboxid ) end if END IF END IF ! multiprocesses execution @@ -3717,7 +3720,7 @@ end subroutine IO_Ndimlist_reduce SUBROUTINE IO_Field_write_box_byfield_N3( TPFILE, TPFIELD, HBUDGET, KFIELD, KXOBOX, KXEBOX, KYOBOX, KYEBOX, & - KZOBOX, KZEBOX, KRESP, koffset ) + KZOBOX, KZEBOX, KRESP, koffset, kboxid ) ! USE MODD_IO, ONLY: GSMONOPROC, ISP ! @@ -3738,6 +3741,7 @@ end subroutine IO_Ndimlist_reduce INTEGER, OPTIONAL, INTENT(IN) :: KZEBOX ! INTEGER, OPTIONAL, INTENT(OUT) :: KRESP ! return-code integer, dimension(3), optional, intent(in) :: koffset + integer, optional, intent(in) :: kboxid ! Box number (ie for subdomain in output file) ! !* 0.2 Declarations of local variables ! @@ -3792,7 +3796,7 @@ end subroutine IO_Ndimlist_reduce if ( gnc4 ) call IO_Field_partial_write_nc4( tpfile, tpfield, IFIELDP, koffset, iresp_nc4 ) else if ( glfi ) call IO_Field_write_lfi( tpfile, tpfield, IFIELDP, iresp_lfi ) - if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, IFIELDP, iresp_nc4 ) + if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, IFIELDP, iresp_nc4, kboxid = kboxid ) end if ELSE ! multiprocesses execution IF (ISP == TPFILE%NMASTER_RANK) THEN @@ -3813,7 +3817,7 @@ end subroutine IO_Ndimlist_reduce if ( gnc4 ) call IO_Field_partial_write_nc4( tpfile, tpfield, IFIELDP, koffset, iresp_nc4 ) else if ( glfi ) call IO_Field_write_lfi( tpfile, tpfield, IFIELDP, iresp_lfi ) - if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, IFIELDP, iresp_nc4 ) + if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, IFIELDP, iresp_nc4, kboxid = kboxid ) end if END IF END IF ! multiprocesses execution @@ -3826,7 +3830,7 @@ end subroutine IO_Ndimlist_reduce END SUBROUTINE IO_Field_write_box_byfield_N3 - SUBROUTINE IO_Field_write_box_byfield_X1( TPFILE, TPFIELD, HBUDGET, PFIELD, KXOBOX, KXEBOX, KRESP, koffset ) + SUBROUTINE IO_Field_write_box_byfield_X1( TPFILE, TPFIELD, HBUDGET, PFIELD, KXOBOX, KXEBOX, KRESP, koffset, kboxid ) ! USE MODD_IO, ONLY: GSMONOPROC, ISP ! @@ -3843,6 +3847,7 @@ end subroutine IO_Ndimlist_reduce INTEGER, INTENT(IN) :: KXEBOX ! Global coordinates of the box INTEGER, OPTIONAL, INTENT(OUT) :: KRESP ! return-code integer, dimension(2), optional, intent(in) :: koffset + integer, optional, intent(in) :: kboxid ! Box number (ie for subdomain in output file) ! !* 0.2 Declarations of local variables ! @@ -3884,7 +3889,7 @@ end subroutine IO_Ndimlist_reduce if ( gnc4 ) call IO_Field_partial_write_nc4( tpfile, tpfield, zfieldp, koffset, iresp_nc4 ) else if ( glfi ) call IO_Field_write_lfi( tpfile, tpfield, zfieldp, iresp_lfi ) - if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, zfieldp, iresp_nc4 ) + if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, zfieldp, iresp_nc4, kboxid = kboxid ) end if ELSE ! multiprocesses execution IF (ISP == TPFILE%NMASTER_RANK) THEN @@ -3911,7 +3916,7 @@ end subroutine IO_Ndimlist_reduce if ( gnc4 ) call IO_Field_partial_write_nc4( tpfile, tpfield, zfieldp, koffset, iresp_nc4 ) else if ( glfi ) call IO_Field_write_lfi( tpfile, tpfield, zfieldp, iresp_lfi ) - if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, zfieldp, iresp_nc4 ) + if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, zfieldp, iresp_nc4, kboxid = kboxid ) end if END IF END IF ! multiprocesses execution @@ -3924,7 +3929,8 @@ end subroutine IO_Ndimlist_reduce END SUBROUTINE IO_Field_write_box_byfield_X1 - SUBROUTINE IO_Field_write_box_byfield_X2( TPFILE, TPFIELD, HBUDGET, PFIELD, KXOBOX, KXEBOX, KYOBOX, KYEBOX, KRESP, koffset ) + SUBROUTINE IO_Field_write_box_byfield_X2( TPFILE, TPFIELD, HBUDGET, PFIELD, KXOBOX, KXEBOX, KYOBOX, KYEBOX, & + KRESP, koffset, kboxid ) ! USE MODD_IO, ONLY: GSMONOPROC, ISP ! @@ -3943,6 +3949,7 @@ end subroutine IO_Ndimlist_reduce INTEGER, INTENT(IN) :: KYEBOX ! INTEGER, OPTIONAL, INTENT(OUT) :: KRESP ! return-code integer, dimension(2), optional, intent(in) :: koffset + integer, optional, intent(in) :: kboxid ! Box number (ie for subdomain in output file) ! !* 0.2 Declarations of local variables ! @@ -3984,7 +3991,7 @@ end subroutine IO_Ndimlist_reduce if ( gnc4 ) call IO_Field_partial_write_nc4( tpfile, tpfield, zfieldp, koffset, iresp_nc4 ) else if ( glfi ) call IO_Field_write_lfi( tpfile, tpfield, zfieldp, iresp_lfi ) - if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, zfieldp, iresp_nc4 ) + if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, zfieldp, iresp_nc4, kboxid = kboxid ) end if ELSE ! multiprocesses execution IF (ISP == TPFILE%NMASTER_RANK) THEN @@ -4005,7 +4012,7 @@ end subroutine IO_Ndimlist_reduce if ( gnc4 ) call IO_Field_partial_write_nc4( tpfile, tpfield, zfieldp, koffset, iresp_nc4 ) else if ( glfi ) call IO_Field_write_lfi( tpfile, tpfield, zfieldp, iresp_lfi ) - if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, zfieldp, iresp_nc4 ) + if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, zfieldp, iresp_nc4, kboxid = kboxid ) end if END IF END IF ! multiprocesses execution @@ -4019,7 +4026,7 @@ end subroutine IO_Ndimlist_reduce SUBROUTINE IO_Field_write_box_byfield_X3( TPFILE, TPFIELD, HBUDGET, PFIELD, KXOBOX, KXEBOX, KYOBOX, KYEBOX, & - KZOBOX, KZEBOX, KRESP, koffset ) + KZOBOX, KZEBOX, KRESP, koffset, kboxid ) ! USE MODD_IO, ONLY: GSMONOPROC, ISP ! @@ -4040,6 +4047,7 @@ end subroutine IO_Ndimlist_reduce INTEGER, OPTIONAL, INTENT(IN) :: KZEBOX ! INTEGER, OPTIONAL, INTENT(OUT) :: KRESP ! return-code integer, dimension(3), optional, intent(in) :: koffset + integer, optional, intent(in) :: kboxid ! Box number (ie for subdomain in output file) ! !* 0.2 Declarations of local variables ! @@ -4094,7 +4102,7 @@ end subroutine IO_Ndimlist_reduce if ( gnc4 ) call IO_Field_partial_write_nc4( tpfile, tpfield, zfieldp, koffset, iresp_nc4 ) else if ( glfi ) call IO_Field_write_lfi( tpfile, tpfield, zfieldp, iresp_lfi ) - if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, zfieldp, iresp_nc4 ) + if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, zfieldp, iresp_nc4, kboxid = kboxid ) end if ELSE ! multiprocesses execution IF (ISP == TPFILE%NMASTER_RANK) THEN @@ -4115,7 +4123,7 @@ end subroutine IO_Ndimlist_reduce if ( gnc4 ) call IO_Field_partial_write_nc4( tpfile, tpfield, zfieldp, koffset, iresp_nc4 ) else if ( glfi ) call IO_Field_write_lfi( tpfile, tpfield, zfieldp, iresp_lfi ) - if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, zfieldp, iresp_nc4 ) + if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, zfieldp, iresp_nc4, kboxid = kboxid ) end if END IF END IF ! multiprocesses execution @@ -4129,7 +4137,7 @@ end subroutine IO_Ndimlist_reduce SUBROUTINE IO_Field_write_box_byfield_X4( TPFILE, TPFIELD, HBUDGET, PFIELD, KXOBOX, KXEBOX, KYOBOX, KYEBOX, & - KZOBOX, KZEBOX, KRESP, koffset ) + KZOBOX, KZEBOX, KRESP, koffset, kboxid ) ! USE MODD_IO, ONLY: GSMONOPROC, ISP ! @@ -4150,6 +4158,7 @@ end subroutine IO_Ndimlist_reduce INTEGER, OPTIONAL, INTENT(IN) :: KZEBOX ! INTEGER, OPTIONAL, INTENT(OUT) :: KRESP ! return-code integer, dimension(4), optional, intent(in) :: koffset + integer, optional, intent(in) :: kboxid ! Box number (ie for subdomain in output file) ! !* 0.2 Declarations of local variables ! @@ -4204,7 +4213,7 @@ end subroutine IO_Ndimlist_reduce if ( gnc4 ) call IO_Field_partial_write_nc4( tpfile, tpfield, zfieldp, koffset, iresp_nc4 ) else if ( glfi ) call IO_Field_write_lfi( tpfile, tpfield, zfieldp, iresp_lfi ) - if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, zfieldp, iresp_nc4 ) + if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, zfieldp, iresp_nc4, kboxid = kboxid ) end if ELSE ! multiprocesses execution IF (ISP == TPFILE%NMASTER_RANK) THEN @@ -4225,7 +4234,7 @@ end subroutine IO_Ndimlist_reduce if ( gnc4 ) call IO_Field_partial_write_nc4( tpfile, tpfield, zfieldp, koffset, iresp_nc4 ) else if ( glfi ) call IO_Field_write_lfi( tpfile, tpfield, zfieldp, iresp_lfi ) - if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, zfieldp, iresp_nc4 ) + if ( gnc4 ) call IO_Field_write_nc4( tpfile, tpfield, zfieldp, iresp_nc4, kboxid = kboxid ) end if END IF END IF ! multiprocesses execution @@ -4238,7 +4247,7 @@ end subroutine IO_Ndimlist_reduce END SUBROUTINE IO_Field_write_box_byfield_X4 - SUBROUTINE IO_Field_write_box_byfield_X5(TPFILE,TPFIELD,HBUDGET,PFIELD,KXOBOX,KXEBOX,KYOBOX,KYEBOX,KRESP) + SUBROUTINE IO_Field_write_box_byfield_X5( TPFILE, TPFIELD, HBUDGET, PFIELD, KXOBOX, KXEBOX, KYOBOX, KYEBOX, KRESP, kboxid ) ! USE MODD_IO, ONLY: GSMONOPROC, ISP ! @@ -4256,6 +4265,7 @@ end subroutine IO_Ndimlist_reduce INTEGER, INTENT(IN) :: KYOBOX ! INTEGER, INTENT(IN) :: KYEBOX ! INTEGER,OPTIONAL, INTENT(OUT):: KRESP ! return-code + integer, optional, intent(in) :: kboxid ! Box number (ie for subdomain in output file) ! !* 0.2 Declarations of local variables ! @@ -4287,7 +4297,7 @@ end subroutine IO_Ndimlist_reduce ZFIELDP=>PFIELD END IF IF (GLFI) CALL IO_Field_write_lfi(TPFILE,TPFIELD,ZFIELDP,iresp_lfi) - IF (GNC4) CALL IO_Field_write_nc4(TPFILE,TPFIELD,ZFIELDP,iresp_nc4) + IF (GNC4) CALL IO_Field_write_nc4(TPFILE,TPFIELD,ZFIELDP,iresp_nc4, kboxid = kboxid ) ELSE ! multiprocesses execution IF (ISP == TPFILE%NMASTER_RANK) THEN ! Allocate the box @@ -4304,7 +4314,7 @@ end subroutine IO_Ndimlist_reduce ! IF (ISP == TPFILE%NMASTER_RANK) THEN IF (GLFI) CALL IO_Field_write_lfi(TPFILE,TPFIELD,ZFIELDP,iresp_lfi) - IF (GNC4) CALL IO_Field_write_nc4(TPFILE,TPFIELD,ZFIELDP,iresp_nc4) + IF (GNC4) CALL IO_Field_write_nc4(TPFILE,TPFIELD,ZFIELDP,iresp_nc4, kboxid = kboxid ) END IF END IF ! multiprocesses execution END IF @@ -4338,7 +4348,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)), TOUT_BOXES(0) ) + CALL IO_Fieldlist_1field_write( TPOUTPUT, IMI, TFIELDLIST(NOUT_FIELDLIST(JI)), 0, TOUT_BOXES(0) ) END DO END IF @@ -4364,12 +4374,12 @@ IF ( NOUT_NBOXES > 0 ) THEN ! Write fields common to all boxes DO JI = 1, SIZE( NOUT_FIELDLIST ) - CALL IO_Fieldlist_1field_write( TZOUTPUT, IMI, TFIELDLIST(NOUT_FIELDLIST(JI)), TOUT_BOXES(JBOX) ) + CALL IO_Fieldlist_1field_write( TZOUTPUT, IMI, TFIELDLIST(NOUT_FIELDLIST(JI)), JBOX, TOUT_BOXES(JBOX) ) END DO ! Write box-specific fields DO JI = 1, SIZE( TOUT_BOXES(JBOX)%NFIELDLIST_SUPP ) - CALL IO_Fieldlist_1field_write( TZOUTPUT, IMI, TFIELDLIST(TOUT_BOXES(JBOX)%NFIELDLIST_SUPP(JI)), TOUT_BOXES(JBOX) ) + CALL IO_Fieldlist_1field_write( TZOUTPUT, IMI, TFIELDLIST(TOUT_BOXES(JBOX)%NFIELDLIST_SUPP(JI)), JBOX, TOUT_BOXES(JBOX) ) END DO ! Restore the root group (not really necessary but cleaner) @@ -4380,7 +4390,7 @@ END IF END SUBROUTINE IO_Fieldlist_write -SUBROUTINE IO_Fieldlist_1field_write( TPOUTPUT, KMI, TPFIELD, TPBOX ) +SUBROUTINE IO_Fieldlist_1field_write( TPOUTPUT, KMI, TPFIELD, KBOXID, TPBOX ) USE MODD_FIELD, ONLY: TFIELDDATA, TFIELDMETADATA USE MODD_OUT_n, ONLY: CMAINDOMAINNAME, TOUTBOXMETADATA @@ -4388,6 +4398,7 @@ USE MODD_OUT_n, ONLY: CMAINDOMAINNAME, TOUTBOXMETADATA TYPE(TFILEDATA), INTENT(IN) :: TPOUTPUT !Output file INTEGER, INTENT(IN) :: KMI TYPE(TFIELDDATA), INTENT(IN) :: TPFIELD +INTEGER, INTENT(IN) :: KBOXID TYPE(TOUTBOXMETADATA), INTENT(IN) :: TPBOX INTEGER :: IIINF, IJINF, IKINF @@ -4547,7 +4558,8 @@ NDIMS: SELECT CASE (TPFIELD%NDIMS) IF ( TPFIELD%CDIR /= 'XX' .AND. TPFIELD%CDIR /= 'YY' .AND. TPFIELD%CDIR /= 'ZZ' ) THEN CALL IO_Field_write(TPOUTPUT,TPFIELD,TPFIELD%TFIELD_X1D(KMI)%DATA) ELSE - CALL IO_Field_write_BOX( TPOUTPUT, TZFIELDMD, 'OTHER', TPFIELD%TFIELD_X1D(KMI)%DATA, KXOBOX = IIINF, KXEBOX = IISUP ) + CALL IO_Field_write_BOX( TPOUTPUT, TZFIELDMD, 'OTHER', TPFIELD%TFIELD_X1D(KMI)%DATA, & + KXOBOX = IIINF, KXEBOX = IISUP, KBOXID = KBOXID ) END IF ELSE call Print_msg( NVERB_ERROR, 'IO', 'IO_Fieldlist_1field_write', trim(tpfield%cmnhname)// & @@ -4569,7 +4581,8 @@ NDIMS: SELECT CASE (TPFIELD%NDIMS) IF ( TPFIELD%CDIR /= 'XX' .AND. TPFIELD%CDIR /= 'YY' .AND. TPFIELD%CDIR /= 'ZZ' ) THEN CALL IO_Field_write(TPOUTPUT,TPFIELD,TPFIELD%TFIELD_N1D(KMI)%DATA) ELSE - CALL IO_Field_write_BOX( TPOUTPUT, TZFIELDMD, 'OTHER', TPFIELD%TFIELD_N1D(KMI)%DATA, KXOBOX = IIINF, KXEBOX = IISUP ) + CALL IO_Field_write_BOX( TPOUTPUT, TZFIELDMD, 'OTHER', TPFIELD%TFIELD_N1D(KMI)%DATA, & + KXOBOX = IIINF, KXEBOX = IISUP, KBOXID = KBOXID ) END IF ELSE call Print_msg( NVERB_ERROR, 'IO', 'IO_Fieldlist_1field_write', trim(tpfield%cmnhname)// & @@ -4670,7 +4683,8 @@ NDIMS: SELECT CASE (TPFIELD%NDIMS) ELSE CALL IO_Field_write_BOX( TPOUTPUT, TZFIELDMD, 'OTHER', TPFIELD%TFIELD_X2D(KMI)%DATA, & KXOBOX = IIINF, KXEBOX = IISUP, & - KYOBOX = IJINF, KYEBOX = IJSUP ) + KYOBOX = IJINF, KYEBOX = IJSUP, & + KBOXID = KBOXID ) END IF ELSE call Print_msg( NVERB_ERROR, 'IO', 'IO_Fieldlist_1field_write', trim(tpfield%cmnhname)// & @@ -4694,7 +4708,8 @@ NDIMS: SELECT CASE (TPFIELD%NDIMS) ELSE CALL IO_Field_write_BOX( TPOUTPUT, TZFIELDMD, 'OTHER', TPFIELD%TFIELD_N2D(KMI)%DATA, & KXOBOX = IIINF, KXEBOX = IISUP, & - KYOBOX = IJINF, KYEBOX = IJSUP ) + KYOBOX = IJINF, KYEBOX = IJSUP, & + KBOXID = KBOXID ) END IF ELSE call Print_msg( NVERB_ERROR, 'IO', 'IO_Fieldlist_1field_write', trim(tpfield%cmnhname)// & @@ -4738,7 +4753,8 @@ NDIMS: SELECT CASE (TPFIELD%NDIMS) CALL IO_Field_write_BOX( TPOUTPUT, TZFIELDMD, 'OTHER', TPFIELD%TFIELD_X3D(KMI)%DATA, & KXOBOX = IIINF, KXEBOX = IISUP, & KYOBOX = IJINF, KYEBOX = IJSUP, & - KZOBOX = IKINF, KZEBOX = IKSUP ) + KZOBOX = IKINF, KZEBOX = IKSUP, & + KBOXID = KBOXID ) END IF ELSE call Print_msg( NVERB_ERROR, 'IO', 'IO_Fieldlist_1field_write', trim(tpfield%cmnhname)// & @@ -4764,7 +4780,8 @@ NDIMS: SELECT CASE (TPFIELD%NDIMS) CALL IO_Field_write_BOX( TPOUTPUT, TZFIELDMD, 'OTHER', TPFIELD%TFIELD_N3D(KMI)%DATA, & KXOBOX = IIINF, KXEBOX = IISUP, & KYOBOX = IJINF, KYEBOX = IJSUP, & - KZOBOX = IKINF, KZEBOX = IKSUP ) + KZOBOX = IKINF, KZEBOX = IKSUP, & + KBOXID = KBOXID ) END IF ELSE call Print_msg( NVERB_ERROR, 'IO', 'IO_Fieldlist_1field_write', trim(tpfield%cmnhname)// & @@ -4809,7 +4826,8 @@ NDIMS: SELECT CASE (TPFIELD%NDIMS) CALL IO_Field_write_BOX( TPOUTPUT, TZFIELDMD, 'OTHER', TPFIELD%TFIELD_X4D(KMI)%DATA, & KXOBOX = IIINF, KXEBOX = IISUP, & KYOBOX = IJINF, KYEBOX = IJSUP, & - KZOBOX = IKINF, KZEBOX = IKSUP ) + KZOBOX = IKINF, KZEBOX = IKSUP, & + KBOXID = KBOXID ) END IF ELSE call Print_msg( NVERB_ERROR, 'IO', 'IO_Fieldlist_1field_write', trim(tpfield%cmnhname)// & diff --git a/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 b/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 index 5b22ae9af91e3ce07e70eb963b51d8a2bd023c45..3dc4cc7bdba3e4eb9994b2171b7e94057931a093 100644 --- a/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 +++ b/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 @@ -182,11 +182,11 @@ end if end subroutine IO_Field_header_split_write_nc4 -SUBROUTINE IO_Field_attr_write_nc4(TPFILE,TPFIELD,KVARID,OEXISTED,KSHAPE,HCALENDAR,OISCOORD) +SUBROUTINE IO_Field_attr_write_nc4( TPFILE, TPFIELD, KVARID, OEXISTED, KSHAPE, HCALENDAR, OISCOORD, KBOXID ) ! USE MODD_CONF, ONLY: CPROGRAM, LCARTESIAN USE MODD_CONF_n, ONLY: CSTORAGE_TYPE -use modd_field, only: NMNHDIM_ARAKAWA, TYPEINT, TYPEREAL +use modd_field, only: NMNHDIM_ARAKAWA, NMNHDIM_BOX_FIRST_ENTRY, NMNHDIM_NI, TYPEINT, TYPEREAL ! TYPE(TFILEDATA), INTENT(IN) :: TPFILE CLASS(TFIELDMETADATA), INTENT(IN) :: TPFIELD @@ -195,11 +195,15 @@ LOGICAL, INTENT(IN) :: OEXISTED !True if va INTEGER(KIND=CDFINT), DIMENSION(:), OPTIONAL, INTENT(IN) :: KSHAPE CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: HCALENDAR LOGICAL, OPTIONAL, INTENT(IN) :: OISCOORD ! Is a coordinate variable (->do not write coordinates attribute) +INTEGER, OPTIONAL, INTENT(IN) :: KBOXID ! CHARACTER(LEN=:), ALLOCATABLE :: YCOORDS INTEGER(KIND=CDFINT) :: INCID INTEGER(KIND=CDFINT) :: istatus +INTEGER :: iboxid ! Number of the box (set to 0 if main domain or no box) +INTEGER :: ishift LOGICAL :: GISCOORD +LOGICAL :: GCOORDPRINT ! CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_Field_attr_write_nc4','called for field '//TRIM(TPFIELD%CMNHNAME)) ! @@ -216,7 +220,13 @@ IF (PRESENT(OISCOORD)) THEN ELSE GISCOORD = .FALSE. END IF -! + +IF ( PRESENT( KBOXID ) ) THEN + iboxid = KBOXID +ELSE + iboxid = 0 +END IF + INCID = TPFILE%NNCID ! ! Standard_name attribute definition (CF convention) @@ -279,8 +289,17 @@ IF (.NOT.GISCOORD) THEN !1D: no direct correspondance with latitude(_x)/longitude(_x) 2D variables => nothing to do IF (.NOT.LCARTESIAN .AND. TPFIELD%NDIMS>1 .AND. TPFIELD%NGRID/=0) THEN IF (TPFIELD%CDIR=='XY') THEN - if ( kshape(1) == tpfile%tncdims%tdims( NMNHDIM_ARAKAWA(tpfield%ngrid,1) )%nlen & - .and. kshape(2) == tpfile%tncdims%tdims( NMNHDIM_ARAKAWA(tpfield%ngrid,2) )%nlen ) then + if ( iboxid == 0 ) then + ! Main domain (or no box) + gcoordprint = kshape(1) == tpfile%tncdims%tdims( NMNHDIM_ARAKAWA(tpfield%ngrid,1) )%nlen & + .and. kshape(2) == tpfile%tncdims%tdims( NMNHDIM_ARAKAWA(tpfield%ngrid,2) )%nlen + else + ! Box (subdomain) + ishift = NMNHDIM_BOX_FIRST_ENTRY - NMNHDIM_NI + gcoordprint = kshape(1) == tpfile%tboxncdims(kboxid)%tdims( NMNHDIM_ARAKAWA(tpfield%ngrid,1) + ishift )%nlen & + .and. kshape(2) == tpfile%tboxncdims(kboxid)%tdims( NMNHDIM_ARAKAWA(tpfield%ngrid,2) + ishift )%nlen + end if + if ( gcoordprint ) then SELECT CASE(TPFIELD%NGRID) CASE (0) !Not on Arakawa grid !Nothing to do @@ -304,9 +323,11 @@ IF (.NOT.GISCOORD) THEN CALL PRINT_MSG(NVERB_ERROR,'IO','IO_Field_attr_write_nc4','invalid NGRID for variable '//TRIM(TPFIELD%CMNHNAME)) END SELECT ! - istatus = NF90_PUT_ATT(INCID, KVARID,'coordinates',YCOORDS) - IF (istatus /= NF90_NOERR) CALL IO_Err_handle_nc4(istatus,'IO_Field_attr_write_nc4','NF90_PUT_ATT','coordinates') - DEALLOCATE(YCOORDS) + if ( allocated( ycoords ) ) then + istatus = NF90_PUT_ATT(INCID, KVARID,'coordinates',YCOORDS) + IF (istatus /= NF90_NOERR) CALL IO_Err_handle_nc4(istatus,'IO_Field_attr_write_nc4','NF90_PUT_ATT','coordinates') + DEALLOCATE(YCOORDS) + end if ELSE CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_Field_attr_write_nc4','coordinates not implemented for variable ' & //TRIM(TPFIELD%CMNHNAME)) @@ -378,7 +399,7 @@ ENDIF END SUBROUTINE IO_Field_attr_write_nc4 -subroutine IO_Field_create_nc4( tpfile, tpfield, kshape, hcalendar, oiscoord, kvarid, oisempty ) +subroutine IO_Field_create_nc4( tpfile, tpfield, kshape, hcalendar, oiscoord, kboxid, kvarid, oisempty ) use modd_field, only: NMNHDIM_TIME, TYPECHAR, TYPEDATE, TYPEINT, TYPELOG, TYPEREAL, TYPEUNDEF use modd_precision, only: MNHINT_NF90, MNHREAL_NF90 @@ -388,6 +409,7 @@ class(tfieldmetadata), intent(in) :: tpfield integer, dimension(:), intent(in), optional :: kshape character(len=*), intent(in), optional :: hcalendar logical, intent(in), optional :: oiscoord ! Is a coordinate variable (->do not write coordinates attribute) +integer, intent(in), optional :: kboxid integer(kind=CDFINT), intent(out), optional :: kvarid logical, intent(out), optional :: oisempty @@ -532,7 +554,8 @@ else end if ! Write metadata -call IO_Field_attr_write_nc4( tpfile, tpfield, ivarid, gexisted, kshape = ishape, hcalendar = hcalendar, oiscoord = oiscoord ) +call IO_Field_attr_write_nc4( tpfile, tpfield, ivarid, gexisted, kshape = ishape, hcalendar = hcalendar, & + oiscoord = oiscoord, kboxid = kboxid ) if ( Present( kvarid ) ) kvarid = ivarid @@ -562,12 +585,13 @@ IF (istatus /= NF90_NOERR) CALL IO_Err_handle_nc4(istatus,'IO_Field_write_nc4_X0 END SUBROUTINE IO_Field_write_nc4_X0 -SUBROUTINE IO_Field_write_nc4_X1(TPFILE,TPFIELD,PFIELD,KRESP) +SUBROUTINE IO_Field_write_nc4_X1(TPFILE,TPFIELD,PFIELD,KRESP,KBOXID) ! TYPE(TFILEDATA),TARGET,INTENT(IN) :: TPFILE CLASS(TFIELDMETADATA), INTENT(IN) :: TPFIELD REAL,DIMENSION(:), INTENT(IN) :: PFIELD ! array containing the data field INTEGER, INTENT(OUT):: KRESP +INTEGER,OPTIONAL, INTENT(IN) :: KBOXID ! Box number (ie for subdomain in output file) ! INTEGER(KIND=CDFINT) :: istatus INTEGER(KIND=CDFINT) :: IVARID @@ -577,7 +601,7 @@ CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_Field_write_nc4_X1',TRIM(TPFILE%CNAME)//': w ! KRESP = 0 ! -call IO_Field_create_nc4( tpfile, tpfield, kshape = Shape( pfield ), kvarid = ivarid, oisempty = gisempty ) +call IO_Field_create_nc4( tpfile, tpfield, kshape = Shape( pfield ), kboxid = kboxid, kvarid = ivarid, oisempty = gisempty ) ! Write the data if ( .not. gisempty ) then @@ -588,7 +612,7 @@ end if END SUBROUTINE IO_Field_write_nc4_X1 -SUBROUTINE IO_Field_write_nc4_X2(TPFILE,TPFIELD,PFIELD,KRESP,KVERTLEVEL,KZFILE,OISCOORD) +SUBROUTINE IO_Field_write_nc4_X2(TPFILE,TPFIELD,PFIELD,KRESP,KVERTLEVEL,KZFILE,OISCOORD,KBOXID) ! TYPE(TFILEDATA), INTENT(IN) :: TPFILE CLASS(TFIELDMETADATA), INTENT(IN) :: TPFIELD @@ -597,6 +621,7 @@ INTEGER, INTENT(OUT):: KRESP INTEGER,OPTIONAL, INTENT(IN) :: KVERTLEVEL ! Number of the vertical level (needed for Z-level split files) INTEGER,OPTIONAL, INTENT(IN) :: KZFILE ! Number of the Z-level split file LOGICAL,OPTIONAL, INTENT(IN) :: OISCOORD ! Is a coordinate variable (->do not write coordinates attribute) +INTEGER,OPTIONAL, INTENT(IN) :: KBOXID ! Box number (ie for subdomain in output file) ! CHARACTER(LEN=4) :: YSUFFIX INTEGER(KIND=CDFINT) :: istatus @@ -611,7 +636,8 @@ call IO_Select_split_file( tpfile, tpfield, tzfile, tzfield, kvertlevel, kzfile ! CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_Field_write_nc4_X2',TRIM(TZFILE%CNAME)//': writing '//TRIM(TZFIELD%CMNHNAME)) ! -call IO_Field_create_nc4( tzfile, tzfield, kshape = Shape( pfield ), oiscoord = oiscoord, kvarid = ivarid, oisempty = gisempty ) +call IO_Field_create_nc4( tzfile, tzfield, kshape = Shape( pfield ), oiscoord = oiscoord, kboxid = kboxid, & + kvarid = ivarid, oisempty = gisempty ) ! Write the data if ( .not. gisempty ) then @@ -624,12 +650,13 @@ if ( Present( kvertlevel ) ) deallocate( tzfield ) END SUBROUTINE IO_Field_write_nc4_X2 -SUBROUTINE IO_Field_write_nc4_X3(TPFILE,TPFIELD,PFIELD,KRESP) +SUBROUTINE IO_Field_write_nc4_X3(TPFILE,TPFIELD,PFIELD,KRESP,KBOXID) ! TYPE(TFILEDATA), INTENT(IN) :: TPFILE CLASS(TFIELDMETADATA), INTENT(IN) :: TPFIELD REAL,DIMENSION(:,:,:), INTENT(IN) :: PFIELD ! array containing the data field INTEGER, INTENT(OUT):: KRESP +INTEGER, OPTIONAL, INTENT(IN) :: KBOXID ! Box number (ie for subdomain in output file) ! INTEGER(KIND=CDFINT) :: istatus INTEGER(KIND=CDFINT) :: IVARID @@ -639,7 +666,7 @@ CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_Field_write_nc4_X3',TRIM(TPFILE%CNAME)//': w ! KRESP = 0 ! -call IO_Field_create_nc4( tpfile, tpfield, kshape = Shape( pfield ), kvarid = ivarid, oisempty = gisempty ) +call IO_Field_create_nc4( tpfile, tpfield, kshape = Shape( pfield ), kboxid = kboxid, kvarid = ivarid, oisempty = gisempty ) ! Write the data if ( .not. gisempty ) then @@ -650,12 +677,13 @@ end if END SUBROUTINE IO_Field_write_nc4_X3 -SUBROUTINE IO_Field_write_nc4_X4(TPFILE,TPFIELD,PFIELD,KRESP) +SUBROUTINE IO_Field_write_nc4_X4(TPFILE,TPFIELD,PFIELD,KRESP,KBOXID) ! TYPE(TFILEDATA), INTENT(IN) :: TPFILE CLASS(TFIELDMETADATA), INTENT(IN) :: TPFIELD REAL,DIMENSION(:,:,:,:), INTENT(IN) :: PFIELD ! array containing the data field INTEGER, INTENT(OUT):: KRESP +INTEGER, OPTIONAL, INTENT(IN) :: KBOXID ! Box number (ie for subdomain in output file) ! INTEGER(KIND=CDFINT) :: istatus INTEGER(KIND=CDFINT) :: IVARID @@ -665,7 +693,7 @@ CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_Field_write_nc4_X4',TRIM(TPFILE%CNAME)//': w ! KRESP = 0 ! -call IO_Field_create_nc4( tpfile, tpfield, kshape = Shape( pfield ), kvarid = ivarid, oisempty = gisempty ) +call IO_Field_create_nc4( tpfile, tpfield, kshape = Shape( pfield ), kboxid = kboxid, kvarid = ivarid, oisempty = gisempty ) ! Write the data if ( .not. gisempty ) then @@ -676,12 +704,13 @@ end if END SUBROUTINE IO_Field_write_nc4_X4 -SUBROUTINE IO_Field_write_nc4_X5(TPFILE,TPFIELD,PFIELD,KRESP) +SUBROUTINE IO_Field_write_nc4_X5(TPFILE,TPFIELD,PFIELD,KRESP,KBOXID) ! TYPE(TFILEDATA), INTENT(IN) :: TPFILE CLASS(TFIELDMETADATA), INTENT(IN) :: TPFIELD REAL,DIMENSION(:,:,:,:,:), INTENT(IN) :: PFIELD ! array containing the data field INTEGER, INTENT(OUT):: KRESP +INTEGER, OPTIONAL, INTENT(IN) :: KBOXID ! Box number (ie for subdomain in output file) ! INTEGER(KIND=CDFINT) :: istatus INTEGER(KIND=CDFINT) :: IVARID @@ -691,7 +720,7 @@ CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_Field_write_nc4_X5',TRIM(TPFILE%CNAME)//': w ! KRESP = 0 ! -call IO_Field_create_nc4( tpfile, tpfield, kshape = Shape( pfield ), kvarid = ivarid, oisempty = gisempty ) +call IO_Field_create_nc4( tpfile, tpfield, kshape = Shape( pfield ), kboxid = kboxid, kvarid = ivarid, oisempty = gisempty ) ! Write the data if ( .not. gisempty ) then @@ -780,7 +809,7 @@ end if END SUBROUTINE IO_Field_write_nc4_N0 -SUBROUTINE IO_Field_write_nc4_N1(TPFILE,TPFIELD,KFIELD,KRESP) +SUBROUTINE IO_Field_write_nc4_N1(TPFILE,TPFIELD,KFIELD,KRESP,KBOXID) ! #if 0 USE MODD_IO, ONLY: LPACK, L2D @@ -793,6 +822,7 @@ TYPE(TFILEDATA), INTENT(IN) :: TPFILE CLASS(TFIELDMETADATA), INTENT(IN) :: TPFIELD INTEGER, DIMENSION(:), INTENT(IN) :: KFIELD INTEGER, INTENT(OUT):: KRESP +INTEGER, OPTIONAL, INTENT(IN) :: KBOXID ! Box number (ie for subdomain in output file) ! INTEGER(KIND=CDFINT) :: istatus INTEGER(KIND=CDFINT) :: IVARID @@ -802,7 +832,7 @@ CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_Field_write_nc4_N1',TRIM(TPFILE%CNAME)//': w ! KRESP = 0 ! -call IO_Field_create_nc4( tpfile, tpfield, kshape = Shape( kfield ), kvarid = ivarid, oisempty = gisempty ) +call IO_Field_create_nc4( tpfile, tpfield, kshape = Shape( kfield ), kboxid = kboxid, kvarid = ivarid, oisempty = gisempty ) ! Write the data if ( .not. gisempty ) then @@ -813,12 +843,13 @@ end if END SUBROUTINE IO_Field_write_nc4_N1 -SUBROUTINE IO_Field_write_nc4_N2(TPFILE,TPFIELD,KFIELD,KRESP) +SUBROUTINE IO_Field_write_nc4_N2(TPFILE,TPFIELD,KFIELD,KRESP,KBOXID) ! TYPE(TFILEDATA),TARGET,INTENT(IN) :: TPFILE CLASS(TFIELDMETADATA), INTENT(IN) :: TPFIELD INTEGER,DIMENSION(:,:),INTENT(IN) :: KFIELD ! array containing the data field INTEGER, INTENT(OUT):: KRESP +INTEGER, OPTIONAL, INTENT(IN) :: KBOXID ! Box number (ie for subdomain in output file) ! INTEGER(KIND=CDFINT) :: istatus INTEGER(KIND=CDFINT) :: IVARID @@ -828,7 +859,7 @@ CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_Field_write_nc4_N2',TRIM(TPFILE%CNAME)//': w ! KRESP = 0 ! -call IO_Field_create_nc4( tpfile, tpfield, kshape = Shape( kfield ), kvarid = ivarid, oisempty = gisempty ) +call IO_Field_create_nc4( tpfile, tpfield, kshape = Shape( kfield ), kboxid = kboxid, kvarid = ivarid, oisempty = gisempty ) ! Write the data if ( .not. gisempty ) then @@ -839,12 +870,13 @@ end if END SUBROUTINE IO_Field_write_nc4_N2 -SUBROUTINE IO_Field_write_nc4_N3(TPFILE,TPFIELD,KFIELD,KRESP) +SUBROUTINE IO_Field_write_nc4_N3(TPFILE,TPFIELD,KFIELD,KRESP,KBOXID) ! TYPE(TFILEDATA),TARGET, INTENT(IN) :: TPFILE CLASS(TFIELDMETADATA), INTENT(IN) :: TPFIELD INTEGER,DIMENSION(:,:,:),INTENT(IN) :: KFIELD ! array containing the data field INTEGER, INTENT(OUT):: KRESP +INTEGER, OPTIONAL, INTENT(IN) :: KBOXID ! Box number (ie for subdomain in output file) ! INTEGER(KIND=CDFINT) :: istatus INTEGER(KIND=CDFINT) :: IVARID @@ -854,7 +886,7 @@ CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_Field_write_nc4_N3',TRIM(TPFILE%CNAME)//': w ! KRESP = 0 ! -call IO_Field_create_nc4( tpfile, tpfield, kshape = Shape( kfield ), kvarid = ivarid, oisempty = gisempty ) +call IO_Field_create_nc4( tpfile, tpfield, kshape = Shape( kfield ), kboxid = kboxid, kvarid = ivarid, oisempty = gisempty ) ! Write the data if ( .not. gisempty ) then