diff --git a/src/LIB/SURCOUCHE/src/mode_io_field_write.f90 b/src/LIB/SURCOUCHE/src/mode_io_field_write.f90 index 9024c3c182009a4037b585479310001d3fb3e805..ea5ff4f74f7d7c0afb42ae47599d31f862ba8fac 100644 --- a/src/LIB/SURCOUCHE/src/mode_io_field_write.f90 +++ b/src/LIB/SURCOUCHE/src/mode_io_field_write.f90 @@ -4395,11 +4395,11 @@ SUBROUTINE IO_Fieldlist_1field_write( TPOUTPUT, KMI, TPFIELD, KBOXID, TPBOX ) USE MODD_FIELD, ONLY: TFIELDDATA, TFIELDMETADATA 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 +TYPE(TFILEDATA), INTENT(IN) :: TPOUTPUT !Output file +INTEGER, INTENT(IN) :: KMI +TYPE(TFIELDDATA), INTENT(IN) :: TPFIELD +INTEGER, INTENT(IN) :: KBOXID +TYPE(TOUTBOXMETADATA), INTENT(INOUT) :: TPBOX INTEGER :: IIINF, IJINF, IKINF INTEGER :: IISUP, IJSUP, IKSUP @@ -4662,6 +4662,8 @@ NDIMS: SELECT CASE (TPFIELD%NDIMS) IF ( TPBOX%CNAME /= CMAINDOMAINNAME ) CALL IO_Dim_main_to_box( TZFIELDMD ) CALL IO_Dim_box_bounds( TPBOX, TZFIELDMD, KIINF=IIINF, KISUP=IISUP, KJINF=IJINF, KJSUP=IJSUP ) + + CALL IO_Box_coords_enable( TZFIELDMD, TPBOX ) END IF NTYPE2D: SELECT CASE (TPFIELD%NTYPE) @@ -4731,6 +4733,8 @@ NDIMS: SELECT CASE (TPFIELD%NDIMS) IF ( TPBOX%CNAME /= CMAINDOMAINNAME ) CALL IO_Dim_main_to_box( TZFIELDMD ) CALL IO_Dim_box_bounds( TPBOX, TZFIELDMD, KIINF=IIINF, KISUP=IISUP, KJINF=IJINF, KJSUP=IJSUP, KKINF=IKINF, KKSUP=IKSUP ) + + CALL IO_Box_coords_enable( TZFIELDMD, TPBOX ) END IF NTYPE3D: SELECT CASE (TPFIELD%NTYPE) @@ -4804,6 +4808,8 @@ NDIMS: SELECT CASE (TPFIELD%NDIMS) IF ( TPBOX%CNAME /= CMAINDOMAINNAME ) CALL IO_Dim_main_to_box( TZFIELDMD ) CALL IO_Dim_box_bounds( TPBOX, TZFIELDMD, KIINF=IIINF, KISUP=IISUP, KJINF=IJINF, KJSUP=IJSUP, KKINF=IKINF, KKSUP=IKSUP ) + + CALL IO_Box_coords_enable( TZFIELDMD, TPBOX ) END IF NTYPE4D: SELECT CASE (TPFIELD%NTYPE) @@ -4922,6 +4928,46 @@ END SELECT NDIMS END SUBROUTINE IO_Fieldlist_1field_write +SUBROUTINE IO_Box_coords_enable( TPFIELD, TPBOX ) + ! This subroutine set to true a coordinate as soon as it is used + ! Once it is true, it must not be set again to false (it is to know if the coordinate has been used and has to be written) + USE MODD_FIELD, ONLY: TFIELDMETADATA + USE MODD_OUT_n, ONLY: TOUTBOXMETADATA + + CLASS(TFIELDMETADATA), INTENT(IN) :: TPFIELD + CLASS(TOUTBOXMETADATA), INTENT(INOUT) :: TPBOX + + IF ( TPFIELD%NDIMS < 2 ) RETURN + + SELECT CASE( TPFIELD%NGRID ) + CASE(1) !Mass point + TPBOX%LCOORD_LATM = .TRUE. + TPBOX%LCOORD_LONM = .TRUE. + CASE(2) !u point + TPBOX%LCOORD_LATU = .TRUE. + TPBOX%LCOORD_LONU = .TRUE. + CASE(3) !v point + TPBOX%LCOORD_LATV = .TRUE. + TPBOX%LCOORD_LONV = .TRUE. + CASE(4) !w point + TPBOX%LCOORD_LATM = .TRUE. + TPBOX%LCOORD_LONM = .TRUE. + CASE(5) !xi vorticity point (=f point =uv point) + TPBOX%LCOORD_LATF = .TRUE. + TPBOX%LCOORD_LONF = .TRUE. + CASE(6) !eta vorticity point (=uw point) + TPBOX%LCOORD_LATU = .TRUE. + TPBOX%LCOORD_LONU = .TRUE. + CASE(7) !zeta vorticity point (=vw point) + TPBOX%LCOORD_LATV = .TRUE. + TPBOX%LCOORD_LONV = .TRUE. + CASE(8) !fw point (=uvw point) + TPBOX%LCOORD_LATF = .TRUE. + TPBOX%LCOORD_LONF = .TRUE. + END SELECT +END SUBROUTINE IO_Box_coords_enable + + SUBROUTINE IO_Field_user_write( TPOUTPUT ) ! #if 0 diff --git a/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 b/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 index 9cc90f2f164e70e3ddb79d796de8c82c2fe98024..d5ffe3f5fa309ff87a30041beafefa1a59b2e23d 100644 --- a/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 +++ b/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 @@ -2677,20 +2677,20 @@ subroutine Write_box_coords( kbox, tpbox ) if ( .not. lcartesian ) then ! Mass point - call Write_box_one_coord( tpbox, 'latitude', zlatm_glob ) - call Write_box_one_coord( tpbox, 'longitude', zlonm_glob ) + if ( tpbox%lcoord_latm ) call Write_box_one_coord( tpbox, 'latitude', zlatm_glob ) + if ( tpbox%lcoord_lonm ) call Write_box_one_coord( tpbox, 'longitude', zlonm_glob ) ! u point - call Write_box_one_coord( tpbox, 'latitude_u', zlatu_glob ) - call Write_box_one_coord( tpbox, 'longitude_u', zlonu_glob ) + if ( tpbox%lcoord_latu ) call Write_box_one_coord( tpbox, 'latitude_u', zlatu_glob ) + if ( tpbox%lcoord_lonu ) call Write_box_one_coord( tpbox, 'longitude_u', zlonu_glob ) ! v point - call Write_box_one_coord( tpbox, 'latitude_v', zlatv_glob ) - call Write_box_one_coord( tpbox, 'longitude_v', zlonv_glob ) + if ( tpbox%lcoord_latv ) call Write_box_one_coord( tpbox, 'latitude_v', zlatv_glob ) + if ( tpbox%lcoord_lonv ) call Write_box_one_coord( tpbox, 'longitude_v', zlonv_glob ) ! xi vorticity point (=f point =uv point) - call Write_box_one_coord( tpbox, 'latitude_f', zlatf_glob ) - call Write_box_one_coord( tpbox, 'longitude_f', zlonf_glob ) + if ( tpbox%lcoord_latf ) call Write_box_one_coord( tpbox, 'latitude_f', zlatf_glob ) + if ( tpbox%lcoord_lonf ) call Write_box_one_coord( tpbox, 'longitude_f', zlonf_glob ) end if ! Restore the root HDF group diff --git a/src/MNH/modd_outn.f90 b/src/MNH/modd_outn.f90 index 583da788cc6502e95a282475b8df53a117692bbf..423b60b7cbc6fee847f41434fa5cc7a156bde7c6 100644 --- a/src/MNH/modd_outn.f90 +++ b/src/MNH/modd_outn.f90 @@ -57,6 +57,17 @@ TYPE TOUTBOXMETADATA INTEGER :: NJSUP = NNEGUNDEF INTEGER :: NKINF = NNEGUNDEF INTEGER :: NKSUP = NNEGUNDEF + + ! Variables to decide if some coordinates are used and are to be written + ! Set to true if the coordinate is necessary + LOGICAL :: LCOORD_LATM = .FALSE. ! Latitude at mass points + LOGICAL :: LCOORD_LONM = .FALSE. ! Longitude at mass points + LOGICAL :: LCOORD_LATU = .FALSE. ! Latitude at u points + LOGICAL :: LCOORD_LONU = .FALSE. ! Longitude at u points + LOGICAL :: LCOORD_LATV = .FALSE. ! Latitude at v points + LOGICAL :: LCOORD_LONV = .FALSE. ! Longitude at v points + LOGICAL :: LCOORD_LATF = .FALSE. ! Latitude at f points + LOGICAL :: LCOORD_LONF = .FALSE. ! Longitude at f points END TYPE TOUTBOXMETADATA TYPE OUT_t