diff --git a/src/LIB/SURCOUCHE/src/fmreadwrit.f90 b/src/LIB/SURCOUCHE/src/fmreadwrit.f90 index 8093e10a1cab9f067b5f466fb410e957f1f003f1..b0d3cc7e40622390228fa1760d313099ad00c597 100644 --- a/src/LIB/SURCOUCHE/src/fmreadwrit.f90 +++ b/src/LIB/SURCOUCHE/src/fmreadwrit.f90 @@ -637,9 +637,12 @@ CHARACTER(LEN=12) :: YVAL_FILE, YVAL_MEM CHARACTER(LEN=JPXKRK) :: YCOMMENT CHARACTER(LEN=12) :: YRESP CHARACTER(LEN=LEN_HREC) :: YRECFM +LOGICAL :: GOLDMNH !if old version of MesoNH (<5.4, old files without complete and correct metadata) ! OGOOD = .TRUE. ! +GOLDMNH = TPFILE%NMNHVERSION(1)<5 .OR. (TPFILE%NMNHVERSION(1)==5 .AND. TPFILE%NMNHVERSION(2)<4) +! YRECFM=TRIM(TPFIELD%CMNHNAME) IF( LEN_TRIM(TPFIELD%CMNHNAME) > LEN(YRECFM) ) & CALL PRINT_MSG(NVERB_WARNING,'IO','IO_READ_CHECK_FIELD_LFI','field name was truncated to '& @@ -704,15 +707,17 @@ IF(TPFIELD%NGRID==NGRIDUNKNOWN) TPFIELD%NGRID=KWORK(1) IF (KWORK(1)/=TPFIELD%NGRID) THEN WRITE(YVAL_FILE,'(I12)') KWORK(1) WRITE(YVAL_MEM, '(I12)') TPFIELD%NGRID - IF (TPFIELD%NDIMS==0) THEN + IF (TPFIELD%NDIMS==0 .OR. GOLDMNH) THEN IERRLEVEL = NVERB_WARNING ELSE IERRLEVEL = NVERB_ERROR END IF CALL PRINT_MSG(IERRLEVEL,'IO','IO_READ_CHECK_FIELD_LFI','expected GRID value ('//TRIM(ADJUSTL(YVAL_MEM))// & ') is different than found in file ('//TRIM(ADJUSTL(YVAL_FILE))//') for variable '//TRIM(TPFIELD%CMNHNAME)) - TPFIELD%NGRID = KWORK(1) - KRESP = -111 !Used later to broadcast modified metadata + IF(.NOT.GOLDMNH) THEN !Do not modify probably incorrect grid number (to prevent problems later with other correct files) + TPFIELD%NGRID = KWORK(1) + KRESP = -111 !Used later to broadcast modified metadata + END IF ELSE CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_READ_CHECK_FIELD_LFI','expected GRID found in file for field ' & //TRIM(TPFIELD%CMNHNAME)) diff --git a/src/LIB/SURCOUCHE/src/mode_netcdf.f90 b/src/LIB/SURCOUCHE/src/mode_netcdf.f90 index 0c7480e63875a13a7cc6604cc36dc75e7795c10d..bde8bc8cfe8776ad6a56ae2c9176f4d0f3b169cd 100644 --- a/src/LIB/SURCOUCHE/src/mode_netcdf.f90 +++ b/src/LIB/SURCOUCHE/src/mode_netcdf.f90 @@ -2532,18 +2532,28 @@ INTEGER(KIND=IDCDF_KIND), INTENT(IN) :: KVARID INTEGER, INTENT(OUT) :: KRESP ! return-code CHARACTER(LEN=*),OPTIONAL,INTENT(IN) :: HCALENDAR ! +INTEGER :: IERRLEVEL INTEGER :: ILEN INTEGER :: IGRID INTEGER(KIND=IDCDF_KIND) :: INCID INTEGER(KIND=IDCDF_KIND) :: STATUS CHARACTER(LEN=12) :: YVAL_FILE, YVAL_MEM CHARACTER(LEN=:),ALLOCATABLE :: YVALUE +LOGICAL :: GOLDMNH !if old version of MesoNH (<5.4, old files without complete and correct metadata) ! CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_READ_CHECK_FIELD_ATTR_NC4',TRIM(TPFILE%CNAME)//': called for field '//TRIM(TPFIELD%CMNHNAME)) ! KRESP = 0 INCID = TPFILE%NNCID ! +GOLDMNH = TPFILE%NMNHVERSION(1)<5 .OR. (TPFILE%NMNHVERSION(1)==5 .AND. TPFILE%NMNHVERSION(2)<4) +! +IF (GOLDMNH) THEN !Set a lower level of error if file comes from an old MesoNH version + IERRLEVEL = NVERB_WARNING +ELSE + IERRLEVEL = NVERB_ERROR +END IF +! ! GRID ! STATUS = NF90_GET_ATT(INCID,KVARID,'grid',IGRID) @@ -2552,11 +2562,13 @@ IF (STATUS == NF90_NOERR) THEN IF (IGRID/=TPFIELD%NGRID) THEN WRITE(YVAL_FILE,'(I12)') IGRID WRITE(YVAL_MEM, '(I12)') TPFIELD%NGRID - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_READ_CHECK_FIELD_ATTR_NC4',TRIM(TPFILE%CNAME)// & + CALL PRINT_MSG(IERRLEVEL,'IO','IO_READ_CHECK_FIELD_ATTR_NC4',TRIM(TPFILE%CNAME)// & ': expected GRID value ('//TRIM(ADJUSTL(YVAL_MEM))// & ') is different than found in file ('//TRIM(ADJUSTL(YVAL_FILE))//') for variable '//TRIM(TPFIELD%CMNHNAME)) - TPFIELD%NGRID = IGRID - KRESP = -111 !Used later to broadcast modified metadata + IF (.NOT.GOLDMNH) THEN !Do not modify probably incorrect grid number (to prevent problems later with other correct files) + TPFIELD%NGRID = IGRID + KRESP = -111 !Used later to broadcast modified metadata + END IF ELSE CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_READ_CHECK_FIELD_ATTR_NC4',TRIM(TPFILE%CNAME)// & ': expected GRID found in file for field '//TRIM(TPFIELD%CMNHNAME)) @@ -2566,7 +2578,7 @@ ELSE !no GRID CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_READ_CHECK_FIELD_ATTR_NC4',TRIM(TPFILE%CNAME)// & ': no GRID (as expected) in file for field '//TRIM(TPFIELD%CMNHNAME)) ELSE - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_READ_CHECK_FIELD_ATTR_NC4',TRIM(TPFILE%CNAME)// & + CALL PRINT_MSG(IERRLEVEL,'IO','IO_READ_CHECK_FIELD_ATTR_NC4',TRIM(TPFILE%CNAME)// & ': expected GRID but not found in file for field '//TRIM(TPFIELD%CMNHNAME)) END IF ENDIF