Gaelle + Didier 3/5/2016 : bug dimensions 2D cases
authorGaelle Tanguy <gaelle.tanguy@meteo.fr>
Tue, 3 May 2016 13:20:06 +0000 (13:20 +0000)
committerPhilippe WAUTELET <philippe.wautelet@aero.obs-mip.fr>
Thu, 19 May 2016 14:44:49 +0000 (16:44 +0200)
src/LIB/SURCOUCHE/src/fmread_ll.f90
src/LIB/SURCOUCHE/src/fmwrit_ll.f90

index b4edb57..e980fb9 100644 (file)
-!MNH_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
-!MNH_LIC This is part of the Meso-NH software governed by the CeCILL-C licence
-!MNH_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt  
-!MNH_LIC for details. version 1.
-!-----------------------------------------------------------------
-!--------------- special set of characters for CVS information
-!-----------------------------------------------------------------
-! $Source$
-! $Name$ 
-! $Revision$ 
-! $Date$
-!-----------------------------------------------------------------
-!-----------------------------------------------------------------
-
-#ifdef MNH_MPI_DOUBLE_PRECISION
-#define MPI_FLOAT MPI_DOUBLE_PRECISION
-#else
-#define MPI_FLOAT MPI_REAL
-#endif
-
-MODULE MODE_FMREAD
-!
-!Correction :
-!  J.Escobar : 22/08/2005 : BUG : manque un "GOTO 1000" si champs
-!              lue non trouvĂ© !!!
-!  J.Escobar : 13/01/2015 : remove comment on BCAST(IRESP in FMREADX2_ll
-!  J.Escobar : 15/09/2015 : WENO5 & JPHEXT <> 1 
-!  D.Gazen   : avril 2016 bug dimensions 2D cases in netcdf
-!
-USE MODD_MPIF
-#if defined(MNH_IOCDF4)
-USE MODE_NETCDF
-#endif
-IMPLICIT NONE 
-
-PRIVATE
-
-INTERFACE FMREAD
-  MODULE PROCEDURE FMREADX0_ll,FMREADX1_ll,FMREADX2_ll,FMREADX3_ll,&
-       & FMREADX4_ll,FMREADX5_ll,FMREADX6_ll,&
-       & FMREADN0_ll,FMREADN1_ll,FMREADN2_ll,&
-       & FMREADL0_ll,FMREADL1_ll,FMREADC0_ll,FMREADT0_ll
-END INTERFACE
-!
-
-PUBLIC FMREAD_LB,FMREAD,FMREADX0_ll,FMREADX1_ll,FMREADX2_ll,FMREADX3_ll,&
-       & FMREADX4_ll,FMREADX5_ll,FMREADX6_ll,&
-       & FMREADN0_ll,FMREADN1_ll,FMREADN2_ll,&
-       & FMREADL0_ll,FMREADL1_ll,FMREADC0_ll,FMREADT0_ll
-
-!INCLUDE 'mpif.h'
-
-CONTAINS 
-SUBROUTINE FM_READ_ERR(HFUNC,HFILEM,HFIPRI,HRECFM,HDIR,KRESP)
-USE MODE_FM, ONLY : FMLOOK_ll
-
-CHARACTER(LEN=*) :: HFUNC 
-CHARACTER(LEN=*) :: HFILEM
-CHARACTER(LEN=*) :: HFIPRI
-CHARACTER(LEN=*) :: HRECFM
-CHARACTER(LEN=*) :: HDIR
-INTEGER          :: KRESP
-
-INTEGER          :: ILUPRI
-INTEGER          :: IRESP
-
-CALL FMLOOK_ll(HFIPRI,HFIPRI,ILUPRI,IRESP)
-WRITE (ILUPRI,*) ' exit from ',HFUNC, ' with RESP:',KRESP
-!STOP "fmread_ll.f90:: FM_READ_ERR"
-
-WRITE (ILUPRI,*) '   | HFILEM = ',HFILEM
-WRITE (ILUPRI,*) '   | HRECFM = ',HRECFM
-WRITE (ILUPRI,*) '   | HDIR  = ',HDIR
-
-END SUBROUTINE FM_READ_ERR
-
-
-SUBROUTINE BCAST_HEADER(TPFD,TPFMH)
-USE MODE_FD_ll, ONLY : FD_ll
-USE MODD_FM
-TYPE(FD_ll),     POINTER    :: TPFD
-TYPE(FMHEADER), INTENT(IN) :: TPFMH
-
-INTEGER :: ierr 
-
-CALL MPI_BCAST(TPFMH%GRID,1,MPI_INTEGER,TPFD%OWNER-1,TPFD%COMM,IERR)
-CALL MPI_BCAST(TPFMH%COMLEN,1,MPI_INTEGER,TPFD%OWNER-1,TPFD%COMM,IERR)
-CALL MPI_BCAST(TPFMH%COMMENT,TPFMH%COMLEN,MPI_CHARACTER,TPFD%OWNER-1,TPFD%COMM,IERR)
-
-END SUBROUTINE BCAST_HEADER
-
-SUBROUTINE FMREADX0_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&
-     KLENCH,HCOMMENT,KRESP)
-USE MODD_IO_ll, ONLY : ISP,GSMONOPROC 
-USE MODD_FM
-USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-!
-!*      0.    DECLARATIONS
-!             ------------
-!
-!
-!*      0.1   Declarations of arguments
-!
-CHARACTER(LEN=*),             INTENT(IN) ::HFILEM ! FM-file name
-CHARACTER(LEN=*),             INTENT(IN) ::HRECFM ! name of the article to read
-CHARACTER(LEN=*),             INTENT(IN) ::HFIPRI ! output file for error messages
-CHARACTER(LEN=*),             INTENT(IN) ::HDIR   ! field form
-REAL,                         INTENT(INOUT)::PFIELD ! array containing the data field 
-INTEGER,                      INTENT(INOUT)::KGRID  ! C-grid indicator (u,v,w,T)
-INTEGER,                      INTENT(INOUT)::KLENCH ! length of comment string
-CHARACTER(LEN=*),             INTENT(INOUT)::HCOMMENT ! comment string
-INTEGER,                      INTENT(INOUT)::KRESP    ! return-code
-!
-!*      0.2   Declarations of local variables
-!
-!----------------------------------------------------------------
-CHARACTER(LEN=JPFINL)        :: YFNLFI
-INTEGER                      :: IERR
-TYPE(FD_ll), POINTER         :: TZFD
-INTEGER                      :: IRESP
-TYPE(FMHEADER)               :: TZFMH
-!
-!*      1.1   THE NAME OF LFIFM
-!
-IRESP = 0
-YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-!------------------------------------------------------------------
-TZFD=>GETFD(YFNLFI)
-IF (ASSOCIATED(TZFD)) THEN
-  IF (GSMONOPROC) THEN ! sequential execution
-    IF (ASSOCIATED(TZFD%CDF)) THEN
-       CALL NCREAD(TZFD%CDF%NCID,HRECFM,PFIELD,TZFMH,IRESP)
-    ELSE
-       CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,1,PFIELD,TZFMH,IRESP)
-    END IF
-    IF (IRESP /= 0) GOTO 1000
-  ELSE ! multiprocessor execution
-    IF (ISP == TZFD%OWNER)  THEN
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,PFIELD,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,1,PFIELD,TZFMH,IRESP)
-      END IF
-    END IF
-    !
-    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-    IF (IRESP /= 0) GOTO 1000
-    !
-    CALL BCAST_HEADER(TZFD,TZFMH)
-    !
-    CALL MPI_BCAST(PFIELD,1,MPI_FLOAT,TZFD%OWNER-1,TZFD%COMM,IERR)
-  END IF
-  KGRID  = TZFMH%GRID
-  KLENCH = TZFMH%COMLEN
-  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)
-ELSE 
-  IRESP = -61
-END IF
-!----------------------------------------------------------------
-1000 CONTINUE
-!! Error handler
-IF (IRESP.NE.0) THEN
-  CALL FM_READ_ERR("FMREADX0_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)
-ENDIF
-KRESP = IRESP
-RETURN
-    
-END SUBROUTINE FMREADX0_ll
-
-SUBROUTINE FMREADX1_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&
-     KLENCH,HCOMMENT,KRESP, KIMAX_ll, KJMAX_ll, TPSPLITTING)
-USE MODD_IO_ll, ONLY : ISP,GSMONOPROC, ISNPROC
-USE MODD_FM
-USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-USE MODE_SCATTER_ll
-USE MODE_ALLOCBUFFER_ll
-USE MODD_STRUCTURE_ll, ONLY : ZONE_ll
-!
-!*      0.    DECLARATIONS
-!             ------------
-!
-!
-!*      0.1   Declarations of arguments
-!
-CHARACTER(LEN=*),        INTENT(IN) ::HFILEM   ! FM-file name
-CHARACTER(LEN=*),        INTENT(IN) ::HRECFM   ! name of the article to read
-CHARACTER(LEN=*),        INTENT(IN) ::HFIPRI   ! output file for error messages
-CHARACTER(LEN=*),        INTENT(IN) ::HDIR     ! Field form
-REAL,DIMENSION(:),TARGET,INTENT(INOUT)::PFIELD   ! array containing the data field 
-INTEGER,                 INTENT(INOUT)::KGRID    ! C-grid indicator (u,v,w,T)
-INTEGER,                 INTENT(INOUT)::KLENCH   ! length of comment string
-CHARACTER(LEN=*),        INTENT(INOUT)::HCOMMENT ! comment string
-INTEGER,                 INTENT(INOUT)::KRESP    ! return-code
-INTEGER, OPTIONAL, INTENT(IN) ::KIMAX_ll
-INTEGER, OPTIONAL, INTENT(IN) ::KJMAX_ll
-TYPE(ZONE_ll), DIMENSION(ISNPROC), OPTIONAL :: TPSPLITTING  ! splitting of the domain
-!
-!*      0.2   Declarations of local variables
-!
-!----------------------------------------------------------------
-CHARACTER(LEN=JPFINL)     :: YFNLFI
-INTEGER                   :: IERR
-TYPE(FD_ll), POINTER      :: TZFD
-INTEGER                   :: IRESP
-REAL,DIMENSION(:),POINTER :: ZFIELDP
-LOGICAL                   :: GALLOC
-TYPE(FMHEADER)            :: TZFMH
-!
-!*      1.1   THE NAME OF LFIFM
-!
-GALLOC = .FALSE.
-IRESP = 0
-YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-!------------------------------------------------------------------
-TZFD=>GETFD(YFNLFI)
-IF (ASSOCIATED(TZFD)) THEN
-  IF (GSMONOPROC) THEN ! sequential execution
-    IF (ASSOCIATED(TZFD%CDF)) THEN
-       CALL NCREAD(TZFD%CDF%NCID,HRECFM,PFIELD,TZFMH,IRESP)
-    ELSE
-       CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-    END IF
-    IF (IRESP /= 0) GOTO 1000
-  ELSE ! multiprocessor execution
-    IF (ISP == TZFD%OWNER)  THEN
-      IF( PRESENT(KIMAX_ll) .AND. PRESENT(KJMAX_ll) ) THEN
-        CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC, KIMAX_ll, KJMAX_ll)
-      ELSE
-        CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)
-      ENDIF
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-              & ,IRESP)
-      END IF
-    ELSE
-      ALLOCATE(ZFIELDP(0))
-      GALLOC = .TRUE.
-    END IF
-      
-    !  
-    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-    IF (IRESP /= 0) GOTO 1000
-    !
-    CALL BCAST_HEADER(TZFD,TZFMH)
-    !
-    IF (HDIR /= 'XX' .AND. HDIR /='YY') THEN
-      ! Broadcast Field
-      CALL MPI_BCAST(PFIELD,SIZE(PFIELD),MPI_FLOAT,TZFD%OWNER-1,TZFD%COMM,IERR)
-    ELSE 
-      !Scatter Field
-      IF( PRESENT(TPSPLITTING) ) THEN
-        CALL SCATTER_XXFIELD(HDIR,ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM,TPSPLITTING)
-      ELSE
-        CALL SCATTER_XXFIELD(HDIR,ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM)
-      ENDIF
-    END IF
-  END IF !(GSMONOPROC)
-  
-  KGRID  = TZFMH%GRID
-  KLENCH = TZFMH%COMLEN
-  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)
-ELSE 
-  IRESP = -61
-END IF
-!----------------------------------------------------------------
-1000 CONTINUE
-!! Error handler
-IF (IRESP.NE.0) THEN
-  CALL FM_READ_ERR("FMREADX1_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)
-ENDIF
-
-IF (GALLOC) DEALLOCATE (ZFIELDP)
-KRESP = IRESP
-RETURN
-!------------------------------------------------------------------
-END SUBROUTINE FMREADX1_ll
-
-SUBROUTINE FMREADX2_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&
-     KLENCH,HCOMMENT,KRESP, KIMAX_ll, KJMAX_ll, TPSPLITTING)
-USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LPACK,L1D,L2D , ISNPROC
-USE MODD_PARAMETERS_ll,ONLY : JPHEXT
-USE MODD_FM
-USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-USE MODE_SCATTER_ll
-USE MODE_ALLOCBUFFER_ll
-!JUANZ
-USE MODD_TIMEZ, ONLY : TIMEZ
-USE MODE_MNH_TIMING, ONLY : SECOND_MNH2
-!JUANZ 
-USE MODD_STRUCTURE_ll, ONLY : ZONE_ll
-#ifdef MNH_GA
-    USE MODE_GA
-#endif
-
-IMPLICIT NONE
-
-CHARACTER(LEN=*),           INTENT(IN) ::HFILEM   ! FM-file name
-CHARACTER(LEN=*),           INTENT(IN) ::HRECFM   ! name of the article to read
-CHARACTER(LEN=*),           INTENT(IN) ::HFIPRI   ! output file for error messages
-CHARACTER(LEN=*),           INTENT(IN) ::HDIR     ! field form
-REAL,DIMENSION(:,:),TARGET, INTENT(INOUT)::PFIELD   ! array containing the data field
-INTEGER,                    INTENT(INOUT)::KGRID    ! C-grid indicator (u,v,w,T)
-INTEGER,                    INTENT(INOUT)::KLENCH   ! length of comment string
-CHARACTER(LEN=*),           INTENT(INOUT)::HCOMMENT ! comment string
-INTEGER,                   INTENT(INOUT)::KRESP     ! return-code
-INTEGER, OPTIONAL, INTENT(IN) ::KIMAX_ll
-INTEGER, OPTIONAL, INTENT(IN) ::KJMAX_ll
-TYPE(ZONE_ll), DIMENSION(ISNPROC), OPTIONAL :: TPSPLITTING  ! splitting of the domain
-!
-!
-!*      0.2   Declarations of local variables
-!
-CHARACTER(LEN=JPFINL)        :: YFNLFI
-INTEGER                      :: IERR
-TYPE(FD_ll), POINTER         :: TZFD
-INTEGER                      :: IRESP
-REAL,DIMENSION(:,:), POINTER :: ZFIELDP
-LOGICAL                      :: GALLOC
-TYPE(FMHEADER)               :: TZFMH
-!JUANZ
-REAL*8,DIMENSION(2) :: T0,T1,T2
-REAL*8,DIMENSION(2) :: T11,T22
-!JUANZ
-#ifdef MNH_GA
-REAL,DIMENSION(:,:),POINTER    :: ZFIELD_GA
-#endif
-!
-!*      1.1   THE NAME OF LFIFM
-!
-CALL SECOND_MNH2(T11)
-GALLOC = .FALSE.
-IRESP = 0
-YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-
-!------------------------------------------------------------------
-
-TZFD=>GETFD(YFNLFI)
-IF (ASSOCIATED(TZFD)) THEN
-  IF (GSMONOPROC) THEN ! sequential execution
-!    IF (LPACK .AND. L1D .AND. HDIR=='XY') THEN 
-    IF (LPACK .AND. L1D .AND. SIZE(PFIELD,1)==2*JPHEXT+1 .AND. SIZE(PFIELD,2)==2*JPHEXT+1) THEN
-      ZFIELDP=>PFIELD(2:2,2:2)
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-      END IF
-      PFIELD(:,:)=SPREAD(SPREAD(PFIELD(2,2),DIM=1,NCOPIES=3),DIM=2,NCOPIES=3)
-!    ELSE IF (LPACK .AND. L2D .AND. HDIR=='XY') THEN
-    ELSE IF (LPACK .AND. L2D .AND. SIZE(PFIELD,2)==2*JPHEXT+1) THEN
-      ZFIELDP=>PFIELD(:,2:2)
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-      END IF
-      PFIELD(:,:)=SPREAD(PFIELD(:,2),DIM=2,NCOPIES=3)
-    ELSE
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,PFIELD,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-      END IF
-    END IF
-    IF (IRESP /= 0) GOTO 1000
-  ELSE ! multiprocessor execution
-     CALL SECOND_MNH2(T0)
-    IF (ISP == TZFD%OWNER)  THEN
-      ! I/O processor case
-      IF( PRESENT(KIMAX_ll) .AND. PRESENT(KJMAX_ll) ) THEN
-        CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC, KIMAX_ll, KJMAX_ll)
-      ELSE
-        CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)
-      ENDIF
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-           & ,IRESP)
-      END IF
-    ELSE
-      ALLOCATE(ZFIELDP(0,0))
-      GALLOC = .TRUE.
-    END IF
-    CALL SECOND_MNH2(T1)
-    TIMEZ%T_READ2D_READ=TIMEZ%T_READ2D_READ + T1 - T0
-    !
-    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-    IF (IRESP /= 0) GOTO 1000
-    !
-    CALL BCAST_HEADER(TZFD,TZFMH)
-    !
-    IF (HDIR == 'XX' .OR. HDIR =='YY') THEN
-      ! XX or YY Scatter Field
-      IF( PRESENT(TPSPLITTING) ) THEN
-        CALL SCATTER_XXFIELD(HDIR,ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM,TPSPLITTING)
-      ELSE
-        CALL SCATTER_XXFIELD(HDIR,ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM)
-      ENDIF
-    ELSE IF (HDIR == 'XY') THEN
-      IF (LPACK .AND. L2D) THEN
-        ! 2D compact case
-      IF( PRESENT(TPSPLITTING) ) THEN
-        CALL SCATTER_XXFIELD('XX',ZFIELDP(:,1),PFIELD(:,2),TZFD%OWNER,TZFD%COMM,TPSPLITTING)
-      ELSE
-        CALL SCATTER_XXFIELD('XX',ZFIELDP(:,1),PFIELD(:,2),TZFD%OWNER,TZFD%COMM)
-      ENDIF
-        PFIELD(:,:) = SPREAD(PFIELD(:,2),DIM=2,NCOPIES=3)
-      ELSE
-#ifdef MNH_GA
-         !
-         ! init/create the ga , dim3 = 1
-         !
-         CALL MNH_INIT_GA(SIZE(PFIELD,1),SIZE(PFIELD,2),1,HRECFM,"READ")
-         IF (ISP == TZFD%OWNER)  THEN
-            !
-            ! put the data in the g_a , this proc get this 1 slide
-            !
-            lo_zplan(JPIZ) = 1
-            hi_zplan(JPIZ) = 1
-            call nga_put(g_a, lo_zplan, hi_zplan,ZFIELDP, ld_zplan)
-         END IF
-         call ga_sync
-         !
-         ! get the columun data in this proc
-         !
-         ! temp buf to avoid problem with none stride PFIELDS buffer  with HALO 
-         ALLOCATE (ZFIELD_GA (SIZE(PFIELD,1),SIZE(PFIELD,2)))
-         call nga_get(g_a, lo_col, hi_col,ZFIELD_GA(1,1) , ld_col)
-         PFIELD = ZFIELD_GA
-         DEALLOCATE(ZFIELD_GA)
-#else
-        ! XY Scatter Field
-        CALL SCATTER_XYFIELD(ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM)
-#endif
-      END IF
-    ELSE
-      CALL MPI_BCAST(PFIELD,SIZE(PFIELD),MPI_FLOAT,TZFD%OWNER-1,TZFD%COMM,IERR)
-    END IF
-    CALL SECOND_MNH2(T2)
-    TIMEZ%T_READ2D_SCAT=TIMEZ%T_READ2D_SCAT + T2 - T1    
-  END IF !(GSMONOPROC)
-  
-  KGRID  = TZFMH%GRID
-  KLENCH = TZFMH%COMLEN
-  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)
-ELSE 
-  IRESP = -61
-END IF
-!----------------------------------------------------------------
-1000 CONTINUE
-!! Error handler
-IF (IRESP.NE.0) THEN
-  CALL FM_READ_ERR("FMREADX2_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)
-ENDIF
-IF (GALLOC) DEALLOCATE (ZFIELDP)
-KRESP = IRESP
-!------------------------------------------------------------------
-
-CALL SECOND_MNH2(T22)
-TIMEZ%T_READ2D_ALL=TIMEZ%T_READ2D_ALL + T22 - T11
-
-END SUBROUTINE FMREADX2_ll
-
-SUBROUTINE FMREADX3_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&
-     KLENCH,HCOMMENT,KRESP)
-USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LPACK,L1D,L2D 
-USE MODD_PARAMETERS_ll,ONLY : JPHEXT
-USE MODD_FM
-USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-USE MODE_SCATTER_ll
-USE MODE_ALLOCBUFFER_ll
-!JUANZ
-USE MODD_IO_ll, ONLY : ISNPROC
-USE MODE_IO_ll, ONLY : io_file,io_rank
-USE MODD_TIMEZ, ONLY : TIMEZ
-USE MODE_MNH_TIMING, ONLY : SECOND_MNH2
-!JUANZ
-#ifdef MNH_GA
-    USE MODE_GA
-#endif
-USE MODD_VAR_ll, ONLY : MNH_STATUSES_IGNORE
-
-IMPLICIT NONE
-
-CHARACTER(LEN=*),             INTENT(IN) ::HFILEM ! FM-file name
-CHARACTER(LEN=*),             INTENT(IN) ::HRECFM ! name of the article to read
-CHARACTER(LEN=*),             INTENT(IN) ::HFIPRI ! output file for error messages
-CHARACTER(LEN=*),             INTENT(IN) ::HDIR   ! field form
-REAL, DIMENSION(:,:,:),TARGET,INTENT(INOUT)::PFIELD ! array containing the data field
-INTEGER,                      INTENT(INOUT)::KGRID  ! C-grid indicator (u,v,w,T)
-INTEGER,                      INTENT(INOUT)::KLENCH ! length of comment string
-CHARACTER(LEN=*),             INTENT(INOUT)::HCOMMENT ! comment string
-INTEGER,                      INTENT(INOUT)::KRESP    ! return-code
-!
-#ifdef MNH_GA
-REAL,DIMENSION(:,:,:),POINTER              :: ZFIELD_GA
-#endif
-!
-!
-!*      0.2   Declarations of local variables
-!
-CHARACTER(LEN=JPFINL)                    :: YFNLFI
-INTEGER                                  :: IERR
-TYPE(FD_ll), POINTER                     :: TZFD
-INTEGER                                  :: IRESP
-REAL,DIMENSION(:,:,:),POINTER            :: ZFIELDP
-LOGICAL                                  :: GALLOC
-TYPE(FMHEADER)                           :: TZFMH
-!JUAN
-INTEGER                                  :: JK,JKK
-CHARACTER(LEN=LEN(HRECFM))               :: YK,YRECZSLIDE
-REAL,DIMENSION(:,:),POINTER              :: ZSLIDE_ll,ZSLIDE
-INTEGER                                  :: IK_FILE,IK_rank,inb_proc_real,JK_MAX
-CHARACTER(len=5)                         :: YK_FILE  
-CHARACTER(len=128)                       :: YFILE_IOZ  
-TYPE(FD_ll), POINTER                     :: TZFD_IOZ 
-INTEGER                                  :: JI,IXO,IXE,IYO,IYE
-REAL,DIMENSION(:,:),POINTER              :: TX2DP
-INTEGER, DIMENSION(MPI_STATUS_SIZE)      :: STATUS
-LOGICAL                                  :: GALLOC_ll
-
-INTEGER,ALLOCATABLE,DIMENSION(:)    :: REQ_TAB
-INTEGER                           :: NB_REQ
-TYPE TX_2DP
-   REAL,DIMENSION(:,:), POINTER    :: X
-END TYPE TX_2DP
-TYPE(TX_2DP),ALLOCATABLE,DIMENSION(:) :: T_TX2DP
-REAL*8,DIMENSION(2) :: T0,T1,T2
-REAL*8,DIMENSION(2) :: T11,T22
-!JUAN
-!
-!*      1.1   THE NAME OF LFIFM
-!
-CALL SECOND_MNH2(T11)
-GALLOC    = .FALSE.
-GALLOC_ll = .FALSE.
-IRESP  = 0
-YFNLFI = TRIM(ADJUSTL(HFILEM))//'.lfi'
-!------------------------------------------------------------------
-TZFD=>GETFD(YFNLFI)
-IF (ASSOCIATED(TZFD)) THEN
-  IF (GSMONOPROC  .AND.  (TZFD%nb_procio.eq.1) ) THEN ! sequential execution
-!    IF (LPACK .AND. L1D .AND. HDIR=='XY') THEN 
-    IF (LPACK .AND. L1D  .AND. SIZE(PFIELD,1)==2*JPHEXT+1 .AND. SIZE(PFIELD,2)==2*JPHEXT+1) THEN
-      ZFIELDP=>PFIELD(2:2,2:2,:)
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-      END IF
-      PFIELD(:,:,:)=SPREAD(SPREAD(PFIELD(2,2,:),DIM=1,NCOPIES=3),DIM=2,NCOPIES=3)
-!    ELSE IF (LPACK .AND. L2D .AND. HDIR=='XY') THEN
-    ELSE IF (LPACK .AND. L2D .AND. SIZE(PFIELD,2)==2*JPHEXT+1) THEN
-      ALLOCATE (ZFIELDP(SIZE(PFIELD,1),1,SIZE(PFIELD,3)))
-      GALLOC = .TRUE.
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-      END IF
-      PFIELD(:,:,:)=SPREAD(ZFIELDP(:,1,:),DIM=2,NCOPIES=3)
-    ELSE
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,PFIELD,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-      END IF
-    END IF
-    IF (IRESP /= 0) GOTO 1000
-  ELSEIF ( (TZFD%nb_procio .eq. 1 ) .OR.  ( HDIR == '--' )  ) THEN ! multiprocessor execution & 1 IO proc 
-  ! read 3D field for graphique
-    IF (ISP == TZFD%OWNER)  THEN
-      CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-           & ,IRESP)
-      END IF
-    ELSE 
-      ALLOCATE(ZFIELDP(0,0,0))
-      GALLOC = .TRUE. 
-    END IF
-    !
-    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-    IF (IRESP /= 0) GOTO 1000
-    !
-    CALL BCAST_HEADER(TZFD,TZFMH)
-    !
-    IF (HDIR == 'XX' .OR. HDIR =='YY') THEN
-      ! XX or YY Scatter Field
-      CALL SCATTER_XXFIELD(HDIR,ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM) 
-    ELSE IF (HDIR == 'XY') THEN
-      IF (LPACK .AND. L2D) THEN
-        ! 2D compact case
-        CALL SCATTER_XXFIELD('XX',ZFIELDP(:,1,:),PFIELD(:,2,:),TZFD%OWNER,TZFD%COMM)
-        PFIELD(:,:,:) = SPREAD(PFIELD(:,2,:),DIM=2,NCOPIES=3)
-      ELSE
-        ! XY Scatter Field
-        CALL SCATTER_XYFIELD(ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM)
-      END IF
-    ELSE
-      ! Broadcast Field
-      CALL MPI_BCAST(PFIELD,SIZE(PFIELD),MPI_FLOAT,TZFD%OWNER-1,TZFD%COMM,IERR)
-    END IF
-  ELSE  ! multiprocessor execution & // IO  
-!
-!JUAN BG Z SLIDE 
-!
-#ifdef MNH_GA
-          !
-          ! init/create the ga
-          !
-          CALL SECOND_MNH2(T0)
-          CALL MNH_INIT_GA(SIZE(PFIELD,1),SIZE(PFIELD,2),SIZE(PFIELD,3),HRECFM,"READ")
-         !
-         ! read the data
-         !
-         ALLOCATE(ZSLIDE_ll(0,0)) ! to avoid bug on test of size
-         GALLOC_ll = .TRUE.
-         DO JKK=1,IKU_ll
-            IK_FILE   =  io_file(JKK,TZFD%nb_procio)
-            write(YK_FILE ,'(".Z",i3.3)') IK_FILE+1
-            YFILE_IOZ =  TRIM(HFILEM)//YK_FILE//".lfi"
-            TZFD_IOZ => GETFD(YFILE_IOZ)
-            !
-            IK_RANK   =  TZFD_IOZ%OWNER
-            !
-            IF (ISP == IK_RANK )  THEN
-               IF ( SIZE(ZSLIDE_ll) .EQ. 0 ) THEN
-                  DEALLOCATE(ZSLIDE_ll)
-                  CALL ALLOCBUFFER_ll(ZSLIDE_ll,ZSLIDE,HDIR,GALLOC_ll)
-               END IF
-               !    
-               CALL SECOND_MNH2(T0)
-               WRITE(YK,'(I4.4)')  JKK
-               YRECZSLIDE = TRIM(HRECFM)//YK
-               IF (ASSOCIATED(TZFD_IOZ%CDF)) THEN
-                  CALL NCREAD(TZFD_IOZ%CDF%NCID,YRECZSLIDE,ZSLIDE_ll,TZFMH,IRESP)
-               ELSE
-                  CALL FM_READ_ll(TZFD_IOZ%FLU,YRECZSLIDE,.TRUE.,SIZE(ZSLIDE_ll),ZSLIDE_ll,TZFMH&
-                       & ,IRESP)
-               END IF
-               CALL SECOND_MNH2(T1)
-               TIMEZ%T_READ3D_READ=TIMEZ%T_READ3D_READ + T1 - T0
-               !
-               ! put the data in the g_a , this proc get this JKK slide
-               !
-               lo_zplan(JPIZ) = JKK
-               hi_zplan(JPIZ) = JKK
-               call nga_put(g_a, lo_zplan, hi_zplan,ZSLIDE_ll, ld_zplan)
-            END IF
-         END DO
-         call ga_sync
-         !
-         ! get the columun data in this proc
-         !
-         ! temp buf to avoid problem with none stride PFIELDS buffer  with HALO 
-         ALLOCATE (ZFIELD_GA (SIZE(PFIELD,1),SIZE(PFIELD,2),SIZE(PFIELD,3)))
-         call nga_get(g_a, lo_col, hi_col,ZFIELD_GA(1,1,1) , ld_col)
-         PFIELD = ZFIELD_GA
-         DEALLOCATE(ZFIELD_GA)
-#else
-     ALLOCATE(ZSLIDE_ll(0,0))
-     GALLOC_ll = .TRUE.
-     inb_proc_real = min(TZFD%nb_procio,ISNPROC)
-     Z_SLIDE: DO JK=1,SIZE(PFIELD,3),inb_proc_real
-        !
-        ! read the data
-        !
-        JK_MAX=min(SIZE(PFIELD,3),JK+inb_proc_real-1)
-        !
-         NB_REQ=0
-         ALLOCATE(REQ_TAB(ISNPROC-1))
-         ALLOCATE(T_TX2DP(ISNPROC-1))        
-        DO JKK=JK,JK_MAX
-           IF (TZFD%NB_PROCIO .GT. 1 ) THEN
-              IK_FILE   =  io_file(JKK,TZFD%nb_procio)
-              write(YK_FILE ,'(".Z",i3.3)') IK_FILE+1
-              YFILE_IOZ =  TRIM(HFILEM)//YK_FILE//".lfi"
-              TZFD_IOZ => GETFD(YFILE_IOZ)
-           ELSE
-              TZFD_IOZ => TZFD
-           ENDIF
-           IK_RANK   =  TZFD_IOZ%OWNER
-           IF (ISP == IK_RANK )  THEN
-              IF ( SIZE(ZSLIDE_ll) .EQ. 0 ) THEN
-                 DEALLOCATE(ZSLIDE_ll)
-                 CALL ALLOCBUFFER_ll(ZSLIDE_ll,ZSLIDE,HDIR,GALLOC_ll)
-              END IF
-              !JUAN
-               CALL SECOND_MNH2(T0)
-              WRITE(YK,'(I4.4)')  JKK
-              YRECZSLIDE = TRIM(HRECFM)//YK
-              IF (ASSOCIATED(TZFD_IOZ%CDF)) THEN
-                 CALL NCREAD(TZFD_IOZ%CDF%NCID,YRECZSLIDE,ZSLIDE_ll,TZFMH,IRESP)
-              ELSE
-                 CALL FM_READ_ll(TZFD_IOZ%FLU,YRECZSLIDE,.TRUE.,SIZE(ZSLIDE_ll),ZSLIDE_ll,TZFMH&
-                   & ,IRESP)
-              END IF
-              !JUANIOZ
-               CALL SECOND_MNH2(T1)
-               TIMEZ%T_READ3D_READ=TIMEZ%T_READ3D_READ + T1 - T0
-              DO JI = 1,ISNPROC
-                 CALL GET_DOMREAD_ll(JI,IXO,IXE,IYO,IYE)
-                 TX2DP=>ZSLIDE_ll(IXO:IXE,IYO:IYE)
-                 IF (ISP /= JI) THEN 
-                     NB_REQ = NB_REQ + 1
-                     ALLOCATE(T_TX2DP(NB_REQ)%X(IXO:IXE,IYO:IYE))
-                     T_TX2DP(NB_REQ)%X=TX2DP
-                     CALL MPI_ISEND(T_TX2DP(NB_REQ)%X,SIZE(TX2DP),MPI_FLOAT,JI-1,199+IK_RANK &
-                          & ,TZFD_IOZ%COMM,REQ_TAB(NB_REQ),IERR)
-                     !CALL MPI_BSEND(TX2DP,SIZE(TX2DP),MPI_FLOAT,JI-1,199+IK_RANK,TZFD_IOZ%COMM,IERR)
-                 ELSE 
-                    PFIELD(:,:,JKK) = TX2DP(:,:)
-                 END IF
-              END DO
-               CALL SECOND_MNH2(T2)
-               TIMEZ%T_READ3D_SEND=TIMEZ%T_READ3D_SEND + T2 - T1
-              !JUANIOZ
-           END IF
-        END DO
-        !
-        ! brodcast the data
-        !
-    IF (HDIR == 'XX' .OR. HDIR =='YY') THEN
-      ! XX or YY Scatter Field
-       STOP " XX ou YY NON PREVU SUR BG POUR LE MOMENT "
-      CALL SCATTER_XXFIELD(HDIR,ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM) 
-    ELSE IF (HDIR == 'XY') THEN
-       IF (LPACK .AND. L2D) THEN
-          ! 2D compact case
-          STOP " L2D NON PREVU SUR BG POUR LE MOMENT "
-          CALL SCATTER_XXFIELD('XX',ZFIELDP(:,1,:),PFIELD(:,2,:),TZFD%OWNER,TZFD%COMM)
-          PFIELD(:,:,:) = SPREAD(PFIELD(:,2,:),DIM=2,NCOPIES=3)
-       ELSE
-          !
-          ! XY Scatter Field
-          !
-               CALL SECOND_MNH2(T0)
-          DO JKK=JK,JK_MAX
-             !
-             ! get the file & rank 
-             !
-             IF (TZFD%NB_PROCIO .GT. 1 ) THEN
-               IK_FILE   =  io_file(JKK,TZFD%nb_procio)
-               write(YK_FILE ,'(".Z",i3.3)') IK_FILE+1
-               YFILE_IOZ =  TRIM(HFILEM)//YK_FILE//".lfi"
-               TZFD_IOZ => GETFD(YFILE_IOZ)
-            ELSE
-               TZFD_IOZ => TZFD
-            END IF
-            !
-            !IK_RANK   =  1 + io_rank(IK_FILE,ISNPROC,TZFD%nb_procio)
-            IK_RANK    =  TZFD_IOZ%OWNER
-            !
-            ZSLIDE => PFIELD(:,:,JKK)
-!JUANIOZ
-            !CALL SCATTER_XYFIELD(ZSLIDE_ll,ZSLIDE,TZFD_IOZ%OWNER,TZFD_IOZ%COMM)
-            IF (ISP .NE. IK_RANK) THEN
-               CALL MPI_RECV(ZSLIDE,SIZE(ZSLIDE),MPI_FLOAT,IK_RANK-1,199+IK_RANK,TZFD_IOZ%COMM&
-                    & ,STATUS,IERR)
-            END IF
-!JUAN IOZ
-         END DO
-               CALL SECOND_MNH2(T1)
-               TIMEZ%T_READ3D_RECV=TIMEZ%T_READ3D_RECV + T1 - T0               
-      END IF
-    ELSE
-      ! Broadcast Field
-       STOP "  Broadcast Field NON PREVU SUR BG POUR LE MOMENT "
-      CALL MPI_BCAST(PFIELD,SIZE(PFIELD),MPI_FLOAT,TZFD%OWNER-1,TZFD%COMM,IERR)
-    END IF
-         CALL SECOND_MNH2(T0) 
-         IF (NB_REQ .GT.0 ) THEN
-            CALL MPI_WAITALL(NB_REQ,REQ_TAB,MNH_STATUSES_IGNORE,IERR)
-            DO JI=1,NB_REQ ;  DEALLOCATE(T_TX2DP(JI)%X) ; ENDDO
-         END IF
-         DEALLOCATE(T_TX2DP)
-         DEALLOCATE(REQ_TAB)
-         CALL SECOND_MNH2(T1) 
-         TIMEZ%T_READ3D_WAIT=TIMEZ%T_READ3D_WAIT + T1 - T0
- END DO Z_SLIDE
- !
- CALL BCAST_HEADER(TZFD,TZFMH)
- !
-#endif
-!JUAN BG Z SLIDE  
-  END IF !(GSMONOPROC) 
-  
-  KGRID    = TZFMH%GRID
-  KLENCH   = TZFMH%COMLEN
-  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)
-ELSE 
-  IRESP = -61          
-END IF
-!----------------------------------------------------------------
-1000 CONTINUE
-!! Error handler
-IF (IRESP.NE.0) THEN
-  CALL FM_READ_ERR("FMREADX3_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)
-ENDIF
-IF (GALLOC) DEALLOCATE (ZFIELDP)
-IF (GALLOC_ll) DEALLOCATE (ZSLIDE_ll)
-!IF (ASSOCIATED(ZSLIDE_ll)) DEALLOCATE (ZSLIDE_ll)
-KRESP = IRESP
-CALL MPI_BARRIER(TZFD%COMM,IERR)
-CALL SECOND_MNH2(T22)
-TIMEZ%T_READ3D_ALL=TIMEZ%T_READ3D_ALL + T22 - T11
-
-!------------------------------------------------------------------
-END SUBROUTINE FMREADX3_ll
-
-SUBROUTINE FMREADX4_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&
-     KLENCH,HCOMMENT,KRESP)
-USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LPACK,L1D,L2D 
-USE MODD_PARAMETERS_ll,ONLY : JPHEXT
-USE MODD_FM
-USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-USE MODE_SCATTER_ll
-USE MODE_ALLOCBUFFER_ll
-
-CHARACTER(LEN=*),              INTENT(IN) ::HFILEM   ! FM-file name
-CHARACTER(LEN=*),              INTENT(IN) ::HRECFM   ! name of the article to read
-CHARACTER(LEN=*),              INTENT(IN) ::HFIPRI   ! output file for error messages
-CHARACTER(LEN=*),              INTENT(IN) ::HDIR     ! field form
-REAL,DIMENSION(:,:,:,:),TARGET,INTENT(INOUT)::PFIELD   ! array containing the data field
-INTEGER,                       INTENT(INOUT)::KGRID    ! C-grid indicator (u,v,w,T)
-INTEGER,                       INTENT(INOUT)::KLENCH   ! length of comment string
-CHARACTER(LEN=*),              INTENT(INOUT)::HCOMMENT ! comment string
-INTEGER,                       INTENT(INOUT)::KRESP  ! return-code if
-!
-!
-!*      0.2   Declarations of local variables
-!
-CHARACTER(LEN=JPFINL)           :: YFNLFI
-INTEGER                         :: IERR
-TYPE(FD_ll), POINTER            :: TZFD
-INTEGER                         :: IRESP
-REAL,DIMENSION(:,:,:,:),POINTER :: ZFIELDP
-LOGICAL                         :: GALLOC
-TYPE(FMHEADER)                  :: TZFMH
-!
-!*      1.1   THE NAME OF LFIFM
-!
-GALLOC = .FALSE.
-IRESP = 0
-YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-!------------------------------------------------------------------
-TZFD=>GETFD(YFNLFI)
-IF (ASSOCIATED(TZFD)) THEN
-  IF (GSMONOPROC) THEN ! sequential execution
-!    IF (LPACK .AND. L1D .AND. HDIR=='XY') THEN 
-    IF (LPACK .AND. L1D .AND. SIZE(PFIELD,1)==2*JPHEXT+1 .AND. SIZE(PFIELD,2)==2*JPHEXT+1) THEN
-      ZFIELDP=>PFIELD(2:2,2:2,:,:)
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-      END IF
-      PFIELD(:,:,:,:)=SPREAD(SPREAD(PFIELD(2,2,:,:),DIM=1,NCOPIES=3),DIM=2,NCOPIES=3)
-!    ELSE IF (LPACK .AND. L2D .AND. HDIR=='XY') THEN
-    ELSE IF (LPACK .AND. L2D .AND. SIZE(PFIELD,2)==2*JPHEXT+1) THEN
-      ZFIELDP=>PFIELD(:,2:2,:,:)
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-      END IF
-      PFIELD(:,:,:,:)=SPREAD(PFIELD(:,2,:,:),DIM=2,NCOPIES=3)
-    ELSE
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,PFIELD,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-      END IF
-    END IF
-    IF (IRESP /= 0) GOTO 1000
-  ELSE
-    IF (ISP == TZFD%OWNER)  THEN
-      CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-           & ,IRESP)
-      END IF
-    ELSE
-      ALLOCATE(ZFIELDP(0,0,0,0))
-      GALLOC = .TRUE.
-    END IF
-    !
-    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-    IF (IRESP /= 0) GOTO 1000
-    !
-    CALL BCAST_HEADER(TZFD,TZFMH)
-    !
-    IF (HDIR == 'XX' .OR. HDIR =='YY') THEN
-      ! XX or YY Scatter Field
-      CALL SCATTER_XXFIELD(HDIR,ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM) 
-    ELSE IF (HDIR == 'XY') THEN
-      IF (LPACK .AND. L2D) THEN
-        ! 2D compact case
-        CALL SCATTER_XXFIELD('XX',ZFIELDP(:,1,:,:),PFIELD(:,2,:,:),TZFD%OWNER,TZFD%COMM)
-        PFIELD(:,:,:,:) = SPREAD(PFIELD(:,2,:,:),DIM=2,NCOPIES=3)
-      ELSE
-        ! XY Scatter Field
-        CALL SCATTER_XYFIELD(ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM)
-      END IF
-    ELSE
-      ! Broadcast Field
-      CALL MPI_BCAST(PFIELD,SIZE(PFIELD),MPI_FLOAT,TZFD%OWNER-1,TZFD%COMM,IERR)
-    END IF
-  END IF
-  KGRID  = TZFMH%GRID
-  KLENCH = TZFMH%COMLEN
-  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)
-ELSE 
-  IRESP = -61
-END IF
-!----------------------------------------------------------------
-1000 CONTINUE
-!! Error handler
-IF (IRESP.NE.0) THEN
-  CALL FM_READ_ERR("FMREADX4_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)
-ENDIF
-
-IF (GALLOC) DEALLOCATE (ZFIELDP)
-KRESP = IRESP
-RETURN
-!------------------------------------------------------------------
-END SUBROUTINE FMREADX4_ll
-
-SUBROUTINE FMREADX5_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&
-     KLENCH,HCOMMENT,KRESP)
-USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LPACK,L1D,L2D 
-USE MODD_PARAMETERS_ll,ONLY : JPHEXT
-USE MODD_FM
-USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-USE MODE_SCATTER_ll
-USE MODE_ALLOCBUFFER_ll
-
-CHARACTER(LEN=*),                INTENT(IN) ::HFILEM ! FM-file name
-CHARACTER(LEN=*),                INTENT(IN) ::HRECFM ! name of the article to read
-CHARACTER(LEN=*),                INTENT(IN) ::HFIPRI ! output file for error messages
-CHARACTER(LEN=*),                INTENT(IN) ::HDIR   ! field form
-REAL,DIMENSION(:,:,:,:,:),TARGET,INTENT(INOUT)::PFIELD ! array containing the data field
-INTEGER,                         INTENT(INOUT)::KGRID  ! C-grid indicator (u,v,w,T)
-INTEGER,                         INTENT(INOUT)::KLENCH ! length of comment string
-CHARACTER(LEN=*),                INTENT(INOUT)::HCOMMENT ! comment string
-INTEGER,                         INTENT(INOUT)::KRESP  ! return-code
-!
-!
-!*      0.2   Declarations of local variables
-!
-CHARACTER(LEN=JPFINL)             :: YFNLFI
-INTEGER                           :: IERR
-TYPE(FD_ll), POINTER              :: TZFD
-INTEGER                           :: IRESP
-REAL,DIMENSION(:,:,:,:,:),POINTER :: ZFIELDP
-LOGICAL                           :: GALLOC
-TYPE(FMHEADER)                    :: TZFMH
-!
-!*      1.1   THE NAME OF LFIFM
-!
-GALLOC = .FALSE.
-IRESP = 0
-YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-!------------------------------------------------------------------
-TZFD=>GETFD(YFNLFI)
-IF (ASSOCIATED(TZFD)) THEN
-  IF (GSMONOPROC) THEN ! sequential execution
-!    IF (LPACK .AND. L1D .AND. HDIR=='XY') THEN 
-    IF (LPACK .AND. L1D .AND. SIZE(PFIELD,1)==2*JPHEXT+1 .AND. SIZE(PFIELD,2)==2*JPHEXT+1) THEN
-      ZFIELDP=>PFIELD(2:2,2:2,:,:,:)
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-      END IF
-      PFIELD(:,:,:,:,:)=SPREAD(SPREAD(PFIELD(2,2,:,:,:),DIM=1,NCOPIES=3),DIM=2,NCOPIES=3)
-!    ELSE IF (LPACK .AND. L2D .AND. HDIR=='XY') THEN
-    ELSE IF (LPACK .AND. L2D .AND. SIZE(PFIELD,2)==2*JPHEXT+1) THEN
-      ZFIELDP=>PFIELD(:,2:2,:,:,:)
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-      END IF
-      PFIELD(:,:,:,:,:)=SPREAD(PFIELD(:,2,:,:,:),DIM=2,NCOPIES=3)
-    ELSE
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,PFIELD,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-      END IF
-    END IF  
-    IF (IRESP /= 0) GOTO 1000
-  ELSE ! multiprocessor execution
-    IF (ISP == TZFD%OWNER)  THEN
-      CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-           & ,IRESP)
-      END IF
-    ELSE
-      ALLOCATE(ZFIELDP(0,0,0,0,0))
-      GALLOC = .TRUE.
-    END IF
-    !
-    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-    IF (IRESP /= 0) GOTO 1000
-    !
-    CALL BCAST_HEADER(TZFD,TZFMH)
-    !
-    IF (HDIR == 'XX' .OR. HDIR =='YY') THEN
-      ! XX or YY Scatter Field
-      CALL SCATTER_XXFIELD(HDIR,ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM) 
-    ELSE IF (HDIR == 'XY') THEN
-      IF (LPACK .AND. L2D) THEN
-        ! 2D compact case
-        CALL SCATTER_XXFIELD('XX',ZFIELDP(:,1,:,:,:),PFIELD(:,2,:,:,:),&
-             & TZFD%OWNER,TZFD%COMM)
-        PFIELD(:,:,:,:,:) = SPREAD(PFIELD(:,2,:,:,:),DIM=2,NCOPIES=3)
-      ELSE
-        ! XY Scatter Field
-        CALL SCATTER_XYFIELD(ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM)
-      END IF
-    ELSE
-      ! Broadcast Field
-      CALL MPI_BCAST(PFIELD,SIZE(PFIELD),MPI_FLOAT,TZFD%OWNER-1,TZFD%COMM,IERR)
-    END IF
-  END IF
-  KGRID  = TZFMH%GRID
-  KLENCH = TZFMH%COMLEN
-  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)
-ELSE 
-  IRESP = -61
-END IF
-!----------------------------------------------------------------
-1000 CONTINUE
-!! Error handler
-IF (IRESP.NE.0) THEN
-  CALL FM_READ_ERR("FMREADX5_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)
-ENDIF
-IF (GALLOC) DEALLOCATE (ZFIELDP)
-KRESP = IRESP
-RETURN
-!------------------------------------------------------------------
-END SUBROUTINE FMREADX5_ll
-
-SUBROUTINE FMREADX6_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&
-     KLENCH,HCOMMENT,KRESP)
-USE MODD_IO_ll, ONLY : ISP,GSMONOPROC 
-USE MODD_FM
-USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-USE MODE_SCATTER_ll
-USE MODE_ALLOCBUFFER_ll
-
-CHARACTER(LEN=*),                  INTENT(IN) ::HFILEM ! FM-file name
-CHARACTER(LEN=*),                  INTENT(IN) ::HRECFM ! name of the article to read
-CHARACTER(LEN=*),                  INTENT(IN) ::HFIPRI ! output file for error messages
-CHARACTER(LEN=*),                  INTENT(IN) ::HDIR   ! field form
-REAL,DIMENSION(:,:,:,:,:,:),TARGET,INTENT(INOUT)::PFIELD ! array containing the data field
-INTEGER,                           INTENT(INOUT)::KGRID  ! C-grid indicator (u,v,w,T)
-INTEGER,                           INTENT(INOUT)::KLENCH ! length of comment string
-CHARACTER(LEN=*),                  INTENT(INOUT)::HCOMMENT ! comment string
-INTEGER,                           INTENT(INOUT)::KRESP  ! return-code
-!
-!
-!*      0.2   Declarations of local variables
-!
-CHARACTER(LEN=JPFINL)               :: YFNLFI
-INTEGER                             :: IERR
-TYPE(FD_ll), POINTER                :: TZFD
-INTEGER                             :: IRESP
-REAL,DIMENSION(:,:,:,:,:,:),POINTER :: ZFIELDP
-LOGICAL                             :: GALLOC
-TYPE(FMHEADER)                      :: TZFMH
-!
-!*      1.1   THE NAME OF LFIFM
-!
-GALLOC = .FALSE.
-IRESP = 0
-YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-!------------------------------------------------------------------
-TZFD=>GETFD(YFNLFI)
-IF (ASSOCIATED(TZFD)) THEN
-  IF (GSMONOPROC) THEN ! sequential execution
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,PFIELD,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-      END IF
-    IF (IRESP /= 0) GOTO 1000
-  ELSE ! multiprocessor execution
-    IF (ISP == TZFD%OWNER)  THEN
-      CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-           & ,IRESP)
-      END IF
-    ELSE
-      ALLOCATE(ZFIELDP(0,0,0,0,0,0))
-      GALLOC = .TRUE.
-    END IF
-    !
-    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-    IF (IRESP /= 0) GOTO 1000
-    !
-    CALL BCAST_HEADER(TZFD,TZFMH)
-    !
-    IF (HDIR == 'XX' .OR. HDIR =='YY') THEN
-      ! XX or YY Scatter Field
-      CALL SCATTER_XXFIELD(HDIR,ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM) 
-    ELSE IF (HDIR == 'XY') THEN
-      ! XY Scatter Field
-      CALL SCATTER_XYFIELD(ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM)
-    ELSE
-      ! Broadcast Field
-      CALL MPI_BCAST(PFIELD,SIZE(PFIELD),MPI_FLOAT,TZFD%OWNER-1,TZFD%COMM,IERR)
-    END IF
-  END IF
-  KGRID  = TZFMH%GRID
-  KLENCH = TZFMH%COMLEN
-  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)
-ELSE 
-  IRESP = -61
-END IF
-!----------------------------------------------------------------
-1000 CONTINUE
-!! Error handler
-IF (IRESP.NE.0) THEN
-  CALL FM_READ_ERR("FMREADX6_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)
-ENDIF
-IF (GALLOC) DEALLOCATE (ZFIELDP)
-KRESP = IRESP
-RETURN
-!------------------------------------------------------------------
-END SUBROUTINE FMREADX6_ll
-
-SUBROUTINE FMREADN0_ll(HFILEM,HRECFM,HFIPRI,HDIR,KFIELD,KGRID,&
-     KLENCH,HCOMMENT,KRESP)
-USE MODD_IO_ll, ONLY : ISP,GSMONOPROC 
-USE MODD_FM
-USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-
-!
-!*      0.    DECLARATIONS
-!             ------------
-!
-!
-!*      0.1   Declarations of arguments
-!
-CHARACTER(LEN=*),          INTENT(IN) ::HFILEM   ! FM-file name
-CHARACTER(LEN=*),          INTENT(IN) ::HRECFM   ! name of the article to read
-CHARACTER(LEN=*),          INTENT(IN) ::HFIPRI   ! output file for error messages
-CHARACTER(LEN=*),          INTENT(IN) ::HDIR     ! Field form
-INTEGER,                   INTENT(INOUT)::KFIELD ! array containing the data field     
-INTEGER,                   INTENT(INOUT)::KGRID    ! C-grid indicator (u,v,w,T)
-INTEGER,                   INTENT(INOUT)::KLENCH   ! length of comment string
-CHARACTER(LEN=*),          INTENT(INOUT)::HCOMMENT ! comment string
-INTEGER,                   INTENT(INOUT)::KRESP    ! return-code
-!
-!*      0.2   Declarations of local variables
-!
-CHARACTER(LEN=JPFINL)        :: YFNLFI
-INTEGER                      :: IERR
-TYPE(FD_ll), POINTER         :: TZFD
-INTEGER                      :: IRESP
-TYPE(FMHEADER)               :: TZFMH
-
-!
-!*      1.1   THE NAME OF LFIFM
-!
-IRESP = 0
-YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-!  
-TZFD=>GETFD(YFNLFI)
-IF (ASSOCIATED(TZFD)) THEN
-  IF (GSMONOPROC) THEN ! sequential execution
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,KFIELD,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,1,KFIELD,TZFMH,IRESP)
-      END IF
-    IF (IRESP /= 0) GOTO 1000
-  ELSE
-    IF (ISP == TZFD%OWNER)  THEN
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,KFIELD,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,1,KFIELD,TZFMH,IRESP)
-      END IF
-    END IF
-    !
-    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-    IF (IRESP /= 0) GOTO 1000
-    !
-    CALL BCAST_HEADER(TZFD,TZFMH)       
-    !
-    CALL MPI_BCAST(KFIELD,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-  END IF
-  KGRID  = TZFMH%GRID
-  KLENCH = TZFMH%COMLEN
-  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)
-ELSE 
-  IRESP = -61
-END IF
-!----------------------------------------------------------------
-1000 CONTINUE
-!! Error handler
-IF (IRESP.NE.0) THEN
-  CALL FM_READ_ERR("FMREADN0_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)
-ENDIF
-KRESP = IRESP
-RETURN
-
-END SUBROUTINE FMREADN0_ll
-
-SUBROUTINE FMREADN1_ll(HFILEM,HRECFM,HFIPRI,HDIR,KFIELD,KGRID,&
-     KLENCH,HCOMMENT,KRESP)
-USE MODD_IO_ll, ONLY : ISP,GSMONOPROC
-USE MODD_FM
-USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-USE MODE_SCATTER_ll
-USE MODE_ALLOCBUFFER_ll
-
-!*      0.    DECLARATIONS
-!             ------------
-!
-!
-!*      0.1   Declarations of arguments
-!
-CHARACTER(LEN=*),           INTENT(IN) ::HFILEM   ! FM-file name
-CHARACTER(LEN=*),           INTENT(IN) ::HRECFM   ! name of the article to read
-CHARACTER(LEN=*),           INTENT(IN) ::HFIPRI   ! output file for error messages
-CHARACTER(LEN=*),           INTENT(IN) ::HDIR     ! Field form
-INTEGER,DIMENSION(:),TARGET,INTENT(INOUT)::KFIELD ! array containing the data field     
-INTEGER,                    INTENT(INOUT)::KGRID    ! C-grid indicator (u,v,w,T)
-INTEGER,                    INTENT(INOUT)::KLENCH   ! length of comment string
-CHARACTER(LEN=*),           INTENT(INOUT)::HCOMMENT ! comment string
-INTEGER,                    INTENT(INOUT)::KRESP    ! return-code
-!
-!*      0.2   Declarations of local variables
-!
-CHARACTER(LEN=JPFINL)            :: YFNLFI
-INTEGER                          :: IERR
-TYPE(FD_ll), POINTER             :: TZFD
-INTEGER                          :: IRESP
-INTEGER,DIMENSION(:),POINTER     :: IFIELDP
-LOGICAL                          :: GALLOC
-TYPE(FMHEADER)                   :: TZFMH
-!
-!*      1.1   THE NAME OF LFIFM
-!
-GALLOC = .FALSE.
-IRESP = 0
-YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-!------------------------------------------------------------------
-TZFD=>GETFD(YFNLFI)
-IF (ASSOCIATED(TZFD)) THEN
-  IF (GSMONOPROC) THEN ! sequential execution
-    IF (ASSOCIATED(TZFD%CDF)) THEN
-       CALL NCREAD(TZFD%CDF%NCID,HRECFM,KFIELD,TZFMH,IRESP)
-    ELSE
-       CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(KFIELD),KFIELD,TZFMH,IRESP)
-    END IF
-    IF (IRESP /= 0) GOTO 1000
-  ELSE
-    IF (ISP == TZFD%OWNER)  THEN
-      CALL ALLOCBUFFER_ll(IFIELDP,KFIELD,HDIR,GALLOC)
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,IFIELDP,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELDP),IFIELDP,TZFMH&
-           & ,IRESP)
-      END IF
-    ELSE
-      ALLOCATE(IFIELDP(0))
-      GALLOC = .TRUE.
-    END IF
-    !
-    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-    IF (IRESP /= 0) GOTO 1000
-    !
-    CALL BCAST_HEADER(TZFD,TZFMH)
-    !
-    IF (HDIR /= 'XX' .AND. HDIR /='YY') THEN
-      ! Broadcast Field
-      CALL MPI_BCAST(KFIELD,SIZE(KFIELD),MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-    ELSE 
-      !Scatter Field
-      CALL SCATTER_XXFIELD(HDIR,IFIELDP,KFIELD,TZFD%OWNER,TZFD%COMM) 
-    END IF
-  END IF
-  KGRID  = TZFMH%GRID
-  KLENCH = TZFMH%COMLEN
-  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)
-ELSE 
-  IRESP = -61
-END IF
-!----------------------------------------------------------------
-1000 CONTINUE
-!! Error handler
-IF (IRESP.NE.0) THEN
-  CALL FM_READ_ERR("FMREADN1_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)
-ENDIF
-IF (GALLOC) DEALLOCATE (IFIELDP)
-KRESP = IRESP
-RETURN
-  
-END SUBROUTINE FMREADN1_ll
-
-SUBROUTINE FMREADN2_ll(HFILEM,HRECFM,HFIPRI,HDIR,KFIELD,KGRID,&
-     KLENCH,HCOMMENT,KRESP)
-USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LPACK,L1D,L2D 
-USE MODD_PARAMETERS_ll,ONLY : JPHEXT
-USE MODD_FM
-USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-USE MODE_SCATTER_ll
-USE MODE_ALLOCBUFFER_ll
-
-CHARACTER(LEN=*),              INTENT(IN) ::HFILEM ! FM-file name
-CHARACTER(LEN=*),              INTENT(IN) ::HRECFM ! name of the article to read
-CHARACTER(LEN=*),              INTENT(IN) ::HFIPRI ! output file for error messages
-CHARACTER(LEN=*),              INTENT(IN) ::HDIR   ! field form
-INTEGER, DIMENSION(:,:),TARGET,INTENT(INOUT)::KFIELD ! array containing the data field
-INTEGER,                       INTENT(INOUT)::KGRID  ! C-grid indicator (u,v,w,T)
-INTEGER,                       INTENT(INOUT)::KLENCH ! length of comment string
-CHARACTER(LEN=*),              INTENT(INOUT)::HCOMMENT ! comment string
-INTEGER,                       INTENT(INOUT)::KRESP  ! return-code
-!
-!
-!*      0.2   Declarations of local variables
-!
-CHARACTER(LEN=JPFINL)          :: YFNLFI
-INTEGER                        :: IERR
-TYPE(FD_ll), POINTER           :: TZFD
-INTEGER                        :: IRESP
-INTEGER,DIMENSION(:,:),POINTER :: IFIELDP
-LOGICAL                        :: GALLOC
-TYPE(FMHEADER)                 :: TZFMH
-!
-!*      1.1   THE NAME OF LFIFM
-!
-GALLOC = .FALSE.
-IRESP = 0
-YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-!------------------------------------------------------------------
-TZFD=>GETFD(YFNLFI)
-IF (ASSOCIATED(TZFD)) THEN
-  IF (GSMONOPROC) THEN ! sequential execution
-!    IF (LPACK .AND. L1D .AND. HDIR=='XY') THEN 
-    IF (LPACK .AND. L1D .AND. SIZE(KFIELD,1)==2*JPHEXT+1 .AND. SIZE(KFIELD,2)==2*JPHEXT+1) THEN
-      IFIELDP=>KFIELD(2:2,2:2)
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,IFIELDP,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELDP),IFIELDP,TZFMH,IRESP)
-      END IF
-      KFIELD(:,:)=SPREAD(SPREAD(KFIELD(2,2),DIM=1,NCOPIES=3),DIM=2,NCOPIES=3)
-!    ELSE IF (LPACK .AND. L2D .AND. HDIR=='XY') THEN
-    ELSE IF (LPACK .AND. L2D .AND. SIZE(KFIELD,2)==2*JPHEXT+1) THEN
-      IFIELDP=>KFIELD(:,2:2)
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,IFIELDP,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELDP),IFIELDP,TZFMH,IRESP)
-      END IF
-      KFIELD(:,:)=SPREAD(KFIELD(:,2),DIM=2,NCOPIES=3)
-    ELSE
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,KFIELD,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(KFIELD),KFIELD,TZFMH,IRESP)
-      END IF
-    END IF
-    IF (IRESP /= 0) GOTO 1000
-  ELSE
-    IF (ISP == TZFD%OWNER)  THEN
-      CALL ALLOCBUFFER_ll(IFIELDP,KFIELD,HDIR,GALLOC)
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,IFIELDP,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELDP),IFIELDP&
-           & ,TZFMH,IRESP)
-      END IF
-    ELSE
-      ALLOCATE(IFIELDP(0,0))
-      GALLOC = .TRUE.
-    END IF
-    !
-    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-    IF (IRESP /= 0) GOTO 1000
-    !
-    CALL BCAST_HEADER(TZFD,TZFMH)
-    !
-    IF (HDIR == 'XX' .OR. HDIR =='YY') THEN
-      ! XX or YY Scatter Field
-      CALL SCATTER_XXFIELD(HDIR,IFIELDP,KFIELD,TZFD%OWNER,TZFD&
-           & %COMM) 
-    ELSE IF (HDIR == 'XY') THEN
-      IF (LPACK .AND. L2D) THEN
-        ! 2D compact case
-        CALL SCATTER_XXFIELD('XX',IFIELDP(:,1),KFIELD(:,2),TZFD%OWNER,TZFD%COMM)
-        KFIELD(:,:) = SPREAD(KFIELD(:,2),DIM=2,NCOPIES=3)
-      ELSE
-        ! XY Scatter Field
-        CALL SCATTER_XYFIELD(IFIELDP,KFIELD,TZFD%OWNER,TZFD%COMM)
-      END IF
-    ELSE
-      ! Broadcast Field
-      IF (ISP == TZFD%OWNER) KFIELD = IFIELDP
-      CALL MPI_BCAST(KFIELD,SIZE(KFIELD),MPI_INTEGER,TZFD%OWNER-1&
-           & ,TZFD%COMM,IERR)
-    END IF
-  END IF
-  KGRID  = TZFMH%GRID
-  KLENCH = TZFMH%COMLEN
-  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)
-ELSE 
-  IRESP = -61
-END IF
-!----------------------------------------------------------------
-1000 CONTINUE
-!! Error handler
-IF (IRESP.NE.0) THEN
-  CALL FM_READ_ERR("FMREADN2_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)
-ENDIF
-!
-IF (GALLOC) DEALLOCATE (IFIELDP)
-KRESP = IRESP
-RETURN
-!------------------------------------------------------------------
-END SUBROUTINE FMREADN2_ll
-
-
-SUBROUTINE FMREADL0_ll(HFILEM,HRECFM,HFIPRI,HDIR,OFIELD,KGRID,&
-     KLENCH,HCOMMENT,KRESP)
-USE MODD_IO_ll, ONLY : ISP,GSMONOPROC 
-USE MODD_FM
-USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-
-!*      0.    DECLARATIONS
-!             ------------
-!
-!
-!*      0.1   Declarations of arguments
-!
-CHARACTER(LEN=*),          INTENT(IN) ::HFILEM ! FM-file name
-CHARACTER(LEN=*),          INTENT(IN) ::HRECFM ! name of the article to read
-CHARACTER(LEN=*),          INTENT(IN) ::HFIPRI ! output file for error messages
-CHARACTER(LEN=*),          INTENT(IN) ::HDIR   ! field form
-LOGICAL,                   INTENT(INOUT)::OFIELD ! array containing the data field
-INTEGER,                   INTENT(INOUT)::KGRID  ! C-grid indicator (u,v,w,T)
-INTEGER,                   INTENT(INOUT)::KLENCH ! length of comment string
-CHARACTER(LEN=*),          INTENT(INOUT)::HCOMMENT ! comment string
-INTEGER,                   INTENT(INOUT)::KRESP    ! return-code
-!
-!*      0.2   Declarations of local variables
-!
-CHARACTER(LEN=JPFINL)        :: YFNLFI
-INTEGER                      :: IERR
-TYPE(FD_ll), POINTER         :: TZFD
-INTEGER                      :: IRESP
-INTEGER                      :: IFIELD
-TYPE(FMHEADER)               :: TZFMH
-
-!
-!*      1.1   THE NAME OF LFIFM
-!
-IRESP = 0
-YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-!------------------------------------------------------------------
-TZFD=>GETFD(YFNLFI)
-IF (ASSOCIATED(TZFD)) THEN
-  IF (GSMONOPROC) THEN ! sequential execution
-    IF (ASSOCIATED(TZFD%CDF)) THEN
-       CALL NCREAD(TZFD%CDF%NCID,HRECFM,IFIELD,TZFMH,IRESP)
-    ELSE
-       CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,1,IFIELD,TZFMH,IRESP)
-    END IF
-    IF (IRESP /= 0) GOTO 1000
-  ELSE
-    IF (ISP == TZFD%OWNER)  THEN
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,IFIELD,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,1,IFIELD,TZFMH,IRESP)
-      END IF
-    END IF
-    !
-    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-    IF (IRESP /= 0) GOTO 1000
-    !
-    CALL BCAST_HEADER(TZFD,TZFMH)
-    !
-    CALL MPI_BCAST(IFIELD,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,&
-         & IERR)
-  END IF
-  IF (IFIELD==1) THEN
-    OFIELD=.TRUE.
-  ELSE
-    OFIELD=.FALSE.
-  END IF
-  KGRID  = TZFMH%GRID
-  KLENCH = TZFMH%COMLEN
-  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)
-ELSE 
-  IRESP = -61
-END IF
-!----------------------------------------------------------------
-1000 CONTINUE
-!! Error handler
-IF (IRESP.NE.0) THEN
-  CALL FM_READ_ERR("FMREADL0_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)
-ENDIF
-KRESP = IRESP
-RETURN
-
-END SUBROUTINE FMREADL0_ll
-
-SUBROUTINE FMREADL1_ll(HFILEM,HRECFM,HFIPRI,HDIR,OFIELD,KGRID,&
-     KLENCH,HCOMMENT,KRESP)
-USE MODD_IO_ll, ONLY : ISP,GSMONOPROC 
-USE MODD_FM
-USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-!
-!*      0.    DECLARATIONS
-!             ------------
-!
-IMPLICIT NONE
-!
-!*      0.1   Declarations of arguments
-!
-CHARACTER(LEN=*),          INTENT(IN) ::HFILEM  ! FM-file name
-CHARACTER(LEN=*),          INTENT(IN) ::HRECFM  ! name of the article to read
-CHARACTER(LEN=*),          INTENT(IN) ::HFIPRI  ! output file for error messages
-CHARACTER(LEN=*),          INTENT(IN) ::HDIR    ! Field form
-LOGICAL, DIMENSION(:),     INTENT(INOUT)::OFIELD  ! array containing the data field
-INTEGER,                   INTENT(INOUT)::KGRID    ! C-grid indicator (u,v,w,T)
-INTEGER,                   INTENT(INOUT)::KLENCH   ! length of comment string
-CHARACTER(LEN=*),          INTENT(INOUT)::HCOMMENT ! comment string
-INTEGER,                   INTENT(INOUT)::KRESP    ! return-code
-!
-!*      0.2   Declarations of local variables
-!
-
-CHARACTER(LEN=JPFINL)            :: YFNLFI
-INTEGER                          :: IERR
-TYPE(FD_ll), POINTER             :: TZFD
-INTEGER                          :: IRESP
-INTEGER, DIMENSION(SIZE(OFIELD)) :: IFIELD
-TYPE(FMHEADER)                   :: TZFMH
-
-!
-!*      1.1   THE NAME OF LFIFM
-!
-IRESP = 0
-YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-!
-TZFD=>GETFD(YFNLFI)
-IF (ASSOCIATED(TZFD)) THEN
-  IF (GSMONOPROC) THEN ! sequential execution
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,IFIELD,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELD),IFIELD,TZFMH&
-         & ,IRESP)
-      END IF
-    IF (IRESP /= 0) GOTO 1000
-  ELSE
-    IF (ISP == TZFD%OWNER)  THEN
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,IFIELD,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELD),IFIELD,TZFMH&
-           & ,IRESP)
-      END IF
-    END IF
-    !
-    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-    IF (IRESP /= 0) GOTO 1000
-    !
-    CALL BCAST_HEADER(TZFD,TZFMH)
-    !
-    CALL MPI_BCAST(IFIELD,SIZE(IFIELD),MPI_INTEGER,TZFD%OWNER-1,TZFD&
-       & %COMM,IERR)
-  END IF
-  WHERE (IFIELD==1)
-    OFIELD=.TRUE.
-  ELSEWHERE
-    OFIELD=.FALSE.
-  END WHERE
-  KGRID  = TZFMH%GRID
-  KLENCH = TZFMH%COMLEN
-  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)
-ELSE 
-  IRESP = -61
-END IF
-!----------------------------------------------------------------
-1000 CONTINUE
-!! Error handler
-IF (IRESP.NE.0) THEN
-  CALL FM_READ_ERR("FMREADL1_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)
-ENDIF
-KRESP = IRESP
-RETURN
-
-END SUBROUTINE FMREADL1_ll
-
-SUBROUTINE FMREADC0_ll(HFILEM,HRECFM,HFIPRI,HDIR,HFIELD,KGRID,&
-     KLENCH,HCOMMENT,KRESP)
-USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIREAD
-USE MODD_FM
-USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-!
-!*      0.    DECLARATIONS
-!             ------------
-!
-!
-!*      0.1   Declarations of arguments
-!
-CHARACTER(LEN=*),          INTENT(IN) ::HFILEM   ! FM-file name
-CHARACTER(LEN=*),          INTENT(IN) ::HRECFM   ! name of the article to read
-CHARACTER(LEN=*),          INTENT(IN) ::HFIPRI   ! output file for error messages
-CHARACTER(LEN=*),          INTENT(IN) ::HDIR     ! Field form
-CHARACTER(LEN=*),          INTENT(INOUT)::HFIELD   ! array containing the data field    
-INTEGER,                   INTENT(INOUT)::KGRID    ! C-grid indicator (u,v,w,T)
-INTEGER,                   INTENT(INOUT)::KLENCH   ! length of comment string
-CHARACTER(LEN=*),          INTENT(INOUT)::HCOMMENT ! comment string
-INTEGER,                   INTENT(INOUT)::KRESP    ! return-code
-!
-!*      0.2   Declarations of local variables
-!
-CHARACTER(LEN=JPFINL)             :: YFNLFI
-INTEGER                           :: IERR
-TYPE(FD_ll), POINTER              :: TZFD
-INTEGER                           :: IRESP
-INTEGER                           :: JLOOP
-INTEGER, DIMENSION(LEN(HFIELD))   :: IFIELD
-CHARACTER(LEN(HFIELD))            :: YFIELD
-INTEGER                           :: ILENG
-TYPE(FMHEADER)                    :: TZFMH
-
-!
-!*      1.1   THE NAME OF LFIFM
-!
-IRESP = 0
-YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-ILENG=LEN(HFIELD)
-!
-TZFD=>GETFD(YFNLFI)
-IF (ASSOCIATED(TZFD)) THEN
-  IF (GSMONOPROC) THEN  ! sequential execution
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,YFIELD,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,ILENG,IFIELD,TZFMH,IRESP)
-      END IF
-    IF (IRESP /= 0) GOTO 1000
-  ELSE ! parallel execution
-    IF (ISP == TZFD%OWNER)  THEN
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,YFIELD,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,ILENG,IFIELD,TZFMH,IRESP)
-      END IF
-    END IF
-    !
-    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-    IF (IRESP /= 0) GOTO 1000
-    !
-    CALL BCAST_HEADER(TZFD,TZFMH)
-    !
-    IF (LIOCDF4 .AND. .NOT. LLFIREAD) THEN
-       ! NetCDF
-       CALL MPI_BCAST(YFIELD,ILENG,MPI_CHARACTER,TZFD%OWNER-1,TZFD%COMM,&
-            &IERR)
-    ELSE 
-       ! LFI
-       CALL MPI_BCAST(IFIELD,ILENG,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,&
-            & IERR)
-    END IF
-  END IF ! parallel execution
-  !
-  IF (LIOCDF4 .AND. .NOT. LLFIREAD) THEN
-     ! NetCDF
-     HFIELD = YFIELD
-  ELSE
-     ! LFI Case
-     DO JLOOP=1,ILENG
-        HFIELD(JLOOP:JLOOP)=ACHAR(IFIELD(JLOOP))
-     END DO
-  END IF
-  KGRID  = TZFMH%GRID
-  KLENCH = TZFMH%COMLEN
-  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)
-ELSE 
-  IRESP = -61
-END IF
-!----------------------------------------------------------------
-1000 CONTINUE
-!! Error handler
-IF (IRESP.NE.0) THEN
-  CALL FM_READ_ERR("FMREADC0_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)
-ENDIF
-KRESP = IRESP
-RETURN
-
-END SUBROUTINE FMREADC0_ll
-
-SUBROUTINE FMREADT0_ll(HFILEM,HRECFM,HFIPRI,HDIR,TFIELD,KGRID,&
-                           KLENCH,HCOMMENT,KRESP)
-!*      0.    DECLARATIONS
-!             ------------
-!
-USE MODD_IO_ll, ONLY : ISP,GSMONOPROC 
-USE MODD_TYPE_DATE
-USE MODD_FM
-USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-!
-!*      0.1   Declarations of arguments
-!
-CHARACTER(LEN=*),          INTENT(IN) ::HFILEM   ! FM-file name
-CHARACTER(LEN=*),          INTENT(IN) ::HRECFM   ! name of the article to read
-CHARACTER(LEN=*),          INTENT(IN) ::HFIPRI   ! output file for error messages
-CHARACTER(LEN=*),          INTENT(IN) ::HDIR     ! Field form
-TYPE (DATE_TIME),          INTENT(INOUT)::TFIELD ! array containing the data field
-INTEGER,                   INTENT(INOUT)::KGRID    ! C-grid indicator (u,v,w,T)
-INTEGER,                   INTENT(INOUT)::KLENCH   ! length of comment string
-CHARACTER(LEN=*),          INTENT(INOUT)::HCOMMENT ! comment string
-INTEGER,                   INTENT(INOUT)::KRESP    ! return-code
-!
-!
-!*      0.2   Declarations of local variables
-!
-!-------------------------------------------------------------------------------
-
-
-CHARACTER(LEN=JPFINL)        :: YFNLFI
-INTEGER                      :: IERR
-TYPE(FD_ll), POINTER         :: TZFD
-INTEGER                      :: IRESP
-INTEGER,DIMENSION(3)         :: ITDATE
-REAL                         :: ZTIME
-TYPE(FMHEADER)               :: TZFMH
-
-!
-!*      1.1   THE NAME OF LFIFM
-!
-IRESP = 0
-
-YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-
-TZFD=>GETFD(YFNLFI)
-IF (ASSOCIATED(TZFD)) THEN
-  IF (GSMONOPROC) THEN ! sequential execution
-    IF (ASSOCIATED(TZFD%CDF)) THEN
-       CALL NCREAD(TZFD%CDF%NCID,TRIM(HRECFM)//'%TDATE',ITDATE,TZFMH,IRESP)
-       CALL NCREAD(TZFD%CDF%NCID,TRIM(HRECFM)//'%TIME',ZTIME,TZFMH,IRESP)
-    ELSE
-       CALL FM_READ_ll(TZFD%FLU,TRIM(HRECFM)//'%TDATE',.FALSE.,3,ITDATE&
-       & ,TZFMH,IRESP)
-       CALL FM_READ_ll(TZFD%FLU,TRIM(HRECFM)//'%TIME',.TRUE.,1,ZTIME&
-       & ,TZFMH,IRESP)
-    END IF
-    IF (IRESP /= 0) GOTO 1000
-  ELSE
-    IF (ISP == TZFD%OWNER)  THEN
-       IF (ASSOCIATED(TZFD%CDF)) THEN
-          CALL NCREAD(TZFD%CDF%NCID,TRIM(HRECFM)//'%TDATE',ITDATE,TZFMH,IRESP)
-          CALL NCREAD(TZFD%CDF%NCID,TRIM(HRECFM)//'%TIME',ZTIME,TZFMH,IRESP)
-       ELSE
-          CALL FM_READ_ll(TZFD%FLU,TRIM(HRECFM)//'%TDATE',.FALSE.,3,ITDATE&
-               & ,TZFMH,IRESP)
-          CALL FM_READ_ll(TZFD%FLU,TRIM(HRECFM)//'%TIME',.TRUE.,1,ZTIME&
-               & ,TZFMH,IRESP)
-
-       END IF
-    END IF
-    !
-    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-    IF (IRESP /= 0) GOTO 1000
-    ! Last header is significant
-    CALL BCAST_HEADER(TZFD,TZFMH)      
-    !
-    CALL MPI_BCAST(ITDATE,3,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-    CALL MPI_BCAST(ZTIME,1,MPI_FLOAT,TZFD%OWNER-1,TZFD%COMM,IERR)
-  END IF
-  TFIELD%TDATE = DATE(ITDATE(1),ITDATE(2),ITDATE(3))
-  TFIELD%TIME = ZTIME
-  KGRID  = TZFMH%GRID
-  KLENCH = TZFMH%COMLEN
-  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)
-ELSE 
-  IRESP = -61
-END IF
-!----------------------------------------------------------------
-1000 CONTINUE
-!! Error handler
-IF (IRESP.NE.0) THEN
-  CALL FM_READ_ERR("FMREADT0_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)
-ENDIF
-KRESP = IRESP
-RETURN
-
-END SUBROUTINE FMREADT0_ll
-
-SUBROUTINE FMREAD_LB(HFILEM,HRECFM,HFIPRI,HLBTYPE,PLB,KRIM,KL3D,&
-     & KGRID,KLENCH,HCOMMENT,KRESP)
-USE MODD_FM
-USE MODD_IO_ll,        ONLY : ISP,ISNPROC,GSMONOPROC,LPACK,L2D 
-USE MODD_PARAMETERS_ll,ONLY : JPHEXT
-USE MODE_DISTRIB_LB
-USE MODE_TOOLS_ll,     ONLY : GET_GLOBALDIMS_ll
-USE MODE_FD_ll,        ONLY : GETFD,JPFINL,FD_LL
-!JUANZ
-USE MODD_TIMEZ, ONLY : TIMEZ
-USE MODE_MNH_TIMING, ONLY : SECOND_MNH2
-!JUANZ
-USE MODD_VAR_ll, ONLY : MNH_STATUSES_IGNORE
-
-CHARACTER(LEN=*),     INTENT(IN) ::HFILEM   ! file name
-CHARACTER(LEN=*),     INTENT(IN) ::HRECFM   ! name of the article to be written
-CHARACTER(LEN=*),     INTENT(IN) ::HFIPRI   ! file for prints
-CHARACTER(LEN=*),     INTENT(IN) ::HLBTYPE  ! 'LBX','LBXU','LBY' or 'LBYV'
-REAL, DIMENSION(:,:,:),TARGET, INTENT(INOUT)::PLB ! array containing the LB field
-INTEGER,              INTENT(IN) :: KRIM  ! size of the LB area
-INTEGER,              INTENT(IN) :: KL3D  ! size of the LB array in FM
-INTEGER,              INTENT(INOUT)::KGRID  ! C-grid indicator (u,v,w,T)
-INTEGER,              INTENT(INOUT)::KLENCH ! length of comment string
-CHARACTER(LEN=*),     INTENT(INOUT)::HCOMMENT ! comment string
-INTEGER,              INTENT(INOUT)::KRESP  ! return-code 
-!
-!*      0.2   Declarations of local variables
-!
-CHARACTER(LEN=JPFINL)        :: YFNLFI
-INTEGER                      :: IERR
-TYPE(FD_ll), POINTER         :: TZFD
-INTEGER                      :: IRESP
-REAL,DIMENSION(:,:,:),ALLOCATABLE,TARGET :: Z3D
-REAL,DIMENSION(:,:,:), POINTER           :: TX3DP
-TYPE(FMHEADER)               :: TZFMH
-INTEGER :: IIMAX_ll,IJMAX_ll
-INTEGER :: IIB,IIE,IJB,IJE
-INTEGER :: JI
-INTEGER, DIMENSION(MPI_STATUS_SIZE) :: STATUS
-INTEGER, ALLOCATABLE,DIMENSION(:,:)   :: STATUSES
-!JUANZIO
-!JUAN INTEGER,SAVE,DIMENSION(100000)    :: REQ_TAB
-INTEGER,ALLOCATABLE,DIMENSION(:)    :: REQ_TAB
-INTEGER                           :: NB_REQ,IKU
-TYPE TX_3DP
-REAL,DIMENSION(:,:,:), POINTER    :: X
-END TYPE
-TYPE(TX_3DP),ALLOCATABLE,DIMENSION(:) :: T_TX3DP
-REAL*8,DIMENSION(2) :: T0,T1,T2,T3
-REAL*8,DIMENSION(2) :: T11,T22
-!JUANZIO
-
-!
-!*      1.1   THE NAME OF LFIFM
-!
-CALL SECOND_MNH2(T11)
-IRESP = 0
-YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-!------------------------------------------------------------------
-TZFD=>GETFD(YFNLFI)
-IF (ASSOCIATED(TZFD)) THEN
-  IF (GSMONOPROC) THEN ! sequential execution
-    IF (HLBTYPE == 'LBX' .OR. HLBTYPE == 'LBXU') THEN 
-      ALLOCATE(Z3D(KL3D,SIZE(PLB,2),SIZE(PLB,3)))
-      Z3D = 0.0
-      IF (LPACK .AND. L2D) THEN
-        TX3DP=>Z3D(:,JPHEXT+1:JPHEXT+1,:)
-        IF (ASSOCIATED(TZFD%CDF)) THEN
-           CALL NCREAD(TZFD%CDF%NCID,HRECFM,TX3DP,TZFMH,IRESP)
-        ELSE
-           CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(TX3DP),TX3DP,TZFMH,IRESP)
-        END IF
-        Z3D(:,:,:) = SPREAD(Z3D(:,JPHEXT+1,:),DIM=2,NCOPIES=2*JPHEXT+1)
-      ELSE
-         IF (ASSOCIATED(TZFD%CDF)) THEN
-            CALL NCREAD(TZFD%CDF%NCID,HRECFM,Z3D,TZFMH,IRESP)
-         ELSE
-            CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(Z3D),Z3D,TZFMH,IRESP)
-         END IF
-      END IF
-      PLB(1:KRIM+JPHEXT,:,:)          = Z3D(1:KRIM+JPHEXT,:,:)
-      PLB(KRIM+JPHEXT+1:2*(KRIM+JPHEXT),:,:) = Z3D(KL3D-KRIM-JPHEXT+1:KL3D,:,:)
-    ELSE !(HLBTYPE == 'LBY' .OR. HLBTYPE == 'LBYV') 
-      ALLOCATE(Z3D(SIZE(PLB,1),KL3D,SIZE(PLB,3)))
-      Z3D = 0.0
-      IF (ASSOCIATED(TZFD%CDF)) THEN
-         CALL NCREAD(TZFD%CDF%NCID,HRECFM,Z3D,TZFMH,IRESP)
-      ELSE
-         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(Z3D),Z3D,TZFMH,IRESP)
-      END IF
-      PLB(:,1:KRIM+JPHEXT,:)          = Z3D(:,1:KRIM+JPHEXT,:)
-      PLB(:,KRIM+JPHEXT+1:2*(KRIM+JPHEXT),:) = Z3D(:,KL3D-KRIM-JPHEXT+1:KL3D,:)
-    END IF
-    IF (IRESP /= 0) GOTO 1000
-  ELSE                 ! multiprocessor execution
-    IF (ISP == TZFD%OWNER)  THEN
-      CALL SECOND_MNH2(T0)
-      CALL GET_GLOBALDIMS_ll(IIMAX_ll,IJMAX_ll)
-      IF (HLBTYPE == 'LBX' .OR. HLBTYPE == 'LBXU') THEN 
-        ALLOCATE(Z3D(KL3D,IJMAX_ll+2*JPHEXT,SIZE(PLB,3)))
-        Z3D = 0.0
-        IF (LPACK .AND. L2D) THEN
-          TX3DP=>Z3D(:,JPHEXT+1:JPHEXT+1,:)
-          IF (ASSOCIATED(TZFD%CDF)) THEN
-             CALL NCREAD(TZFD%CDF%NCID,HRECFM,TX3DP,TZFMH,IRESP)
-          ELSE
-             CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(TX3DP),TX3DP,TZFMH,IRESP)
-          END IF
-          Z3D(:,:,:) = SPREAD(Z3D(:,JPHEXT+1,:),DIM=2,NCOPIES=2*JPHEXT+1)
-        ELSE
-           IF (ASSOCIATED(TZFD%CDF)) THEN
-              CALL NCREAD(TZFD%CDF%NCID,HRECFM,Z3D,TZFMH,IRESP)
-           ELSE
-              CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(Z3D),Z3D,TZFMH,IRESP)
-           END IF
-        END IF
-        ! erase gap in LB field
-        Z3D(KRIM+JPHEXT+1:2*(KRIM+JPHEXT),:,:) = Z3D(KL3D-KRIM-JPHEXT+1:KL3D,:,:)
-      ELSE !(HLBTYPE == 'LBY' .OR. HLBTYPE == 'LBYV') 
-        ALLOCATE(Z3D(IIMAX_ll+2*JPHEXT,KL3D,SIZE(PLB,3)))
-        Z3D = 0.0
-        IF (ASSOCIATED(TZFD%CDF)) THEN
-           CALL NCREAD(TZFD%CDF%NCID,HRECFM,Z3D,TZFMH,IRESP)
-        ELSE
-           CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(Z3D),Z3D,TZFMH,IRESP)
-        END IF
-        ! erase gap in LB field
-        Z3D(:,KRIM+JPHEXT+1:2*(KRIM+JPHEXT),:) = Z3D(:,KL3D-KRIM-JPHEXT+1:KL3D,:)
-      END IF
-      CALL SECOND_MNH2(T1)
-      TIMEZ%T_READLB_READ=TIMEZ%T_READLB_READ + T1 - T0
-    END IF
-    !  
-    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-    IF (IRESP /= 0) GOTO 1000
-    !  
-    CALL BCAST_HEADER(TZFD,TZFMH)
-    ! 
-    NB_REQ=0
-    ALLOCATE(REQ_TAB(ISNPROC-1))
-    !REQ_TAB=MPI_REQUEST_NULL
-    IF (ISP == TZFD%OWNER)  THEN
-       CALL SECOND_MNH2(T1)
-      !ALLOCATE(REQ_TAB(ISNPROC-1))
-      !REQ_TAB=MPI_REQUEST_NULL
-      ALLOCATE(T_TX3DP(ISNPROC-1))
-      IKU = SIZE(Z3D,3)
-      DO JI = 1,ISNPROC
-        CALL GET_DISTRIB_LB(HLBTYPE,JI,'FM','READ',KRIM,IIB,IIE,IJB,IJE)
-        IF (IIB /= 0) THEN
-          TX3DP=>Z3D(IIB:IIE,IJB:IJE,:)
-          IF (ISP /= JI) THEN 
-            NB_REQ = NB_REQ + 1
-            ALLOCATE(T_TX3DP(NB_REQ)%X(IIB:IIE,IJB:IJE,IKU))           
-            T_TX3DP(NB_REQ)%X=Z3D(IIB:IIE,IJB:IJE,:)
-            CALL MPI_ISEND(T_TX3DP(NB_REQ)%X,SIZE(TX3DP),MPI_FLOAT,JI-1,99,TZFD%COMM,REQ_TAB(NB_REQ),IERR)
-            !CALL MPI_BSEND(T_TX3DP(NB_REQ)%X,SIZE(TX3DP),MPI_FLOAT,JI-1,99,TZFD%COMM,IERR)
-          ELSE
-            CALL GET_DISTRIB_LB(HLBTYPE,JI,'LOC','READ',KRIM,IIB,IIE,IJB,IJE)
-            PLB(IIB:IIE,IJB:IJE,:) = TX3DP(:,:,:)
-          END IF
-        END IF
-      END DO
-      CALL SECOND_MNH2(T2)
-      TIMEZ%T_READLB_SEND=TIMEZ%T_READLB_SEND + T2 - T1      
-      IF (NB_REQ .GT.0 ) THEN
-         !ALLOCATE(STATUSES(MPI_STATUS_SIZE,NB_REQ))
-         !CALL MPI_WAITALL(NB_REQ,REQ_TAB,STATUSES,IERR)
-         CALL MPI_WAITALL(NB_REQ,REQ_TAB,MNH_STATUSES_IGNORE,IERR)
-         !DEALLOCATE(STATUSES)
-         DO JI=1,NB_REQ ;  DEALLOCATE(T_TX3DP(JI)%X) ; ENDDO
-      END IF
-      DEALLOCATE(T_TX3DP)
-      !DEALLOCATE(REQ_TAB)
-      CALL SECOND_MNH2(T3)
-      TIMEZ%T_READLB_WAIT=TIMEZ%T_READLB_WAIT + T3 - T2
-    ELSE
-       CALL SECOND_MNH2(T0)
-      !ALLOCATE(REQ_TAB(1))
-      !REQ_TAB=MPI_REQUEST_NULL
-      CALL GET_DISTRIB_LB(HLBTYPE,ISP,'LOC','READ',KRIM,IIB,IIE,IJB,IJE)
-      IF (IIB /= 0) THEN
-        TX3DP=>PLB(IIB:IIE,IJB:IJE,:)
-        CALL MPI_RECV(TX3DP,SIZE(TX3DP),MPI_FLOAT,TZFD%OWNER-1,99,TZFD%COMM,STATUS,IERR)
-        !NB_REQ = NB_REQ + 1
-        !CALL MPI_IRECV(TX3DP,SIZE(TX3DP),MPI_FLOAT,TZFD%OWNER-1,99,TZFD%COMM,REQ_TAB(NB_REQ),IERR)
-        !IF (NB_REQ .GT.0 ) CALL MPI_WAITALL(NB_REQ,REQ_TAB,MNH_STATUSES_IGNORE,IERR)
-      END IF
-      CALL SECOND_MNH2(T1)
-      TIMEZ%T_READLB_RECV=TIMEZ%T_READLB_RECV + T1 - T0 
-    END IF
-    DEALLOCATE(REQ_TAB)
-  END IF !(GSMONOPROC)
-  KGRID  = TZFMH%GRID
-  KLENCH = TZFMH%COMLEN
-  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)
-ELSE 
-  IRESP = -61          
-END IF
-!----------------------------------------------------------------
-1000 CONTINUE
-!! Error handler
-IF (IRESP.NE.0) THEN
-  CALL FM_READ_ERR("FMREAD_LB",HFILEM,HFIPRI,HRECFM,HLBTYPE,IRESP)
-ENDIF
-!
-IF (ALLOCATED(Z3D)) DEALLOCATE (Z3D)
-KRESP = IRESP
-!
-!CALL MPI_BARRIER(TZFD%COMM,IERR)
-CALL SECOND_MNH2(T22)
-TIMEZ%T_READLB_ALL=TIMEZ%T_READLB_ALL + T22 - T11
-END SUBROUTINE FMREAD_LB
-
-END MODULE MODE_FMREAD
-
-
-!
+!MNH_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier\r
+!MNH_LIC This is part of the Meso-NH software governed by the CeCILL-C licence\r
+!MNH_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt  \r
+!MNH_LIC for details. version 1.\r
+!-----------------------------------------------------------------\r
+!--------------- special set of characters for CVS information\r
+!-----------------------------------------------------------------\r
+! $Source$\r
+! $Name$ \r
+! $Revision$ \r
+! $Date$\r
+!-----------------------------------------------------------------\r
+!-----------------------------------------------------------------\r
+\r
+#ifdef MNH_MPI_DOUBLE_PRECISION\r
+#define MPI_FLOAT MPI_DOUBLE_PRECISION\r
+#else\r
+#define MPI_FLOAT MPI_REAL\r
+#endif\r
+\r
+MODULE MODE_FMREAD\r
+!\r
+!Correction :\r
+!  J.Escobar : 22/08/2005 : BUG : manque un "GOTO 1000" si champs\r
+!              lue non trouvĂ© !!!\r
+!  J.Escobar : 13/01/2015 : remove comment on BCAST(IRESP in FMREADX2_ll\r
+!  J.Escobar : 15/09/2015 : WENO5 & JPHEXT <> 1 \r
+!\r
+USE MODD_MPIF\r
+#if defined(MNH_IOCDF4)\r
+USE MODE_NETCDF\r
+#endif\r
+IMPLICIT NONE \r
+\r
+PRIVATE\r
+\r
+INTERFACE FMREAD\r
+  MODULE PROCEDURE FMREADX0_ll,FMREADX1_ll,FMREADX2_ll,FMREADX3_ll,&\r
+       & FMREADX4_ll,FMREADX5_ll,FMREADX6_ll,&\r
+       & FMREADN0_ll,FMREADN1_ll,FMREADN2_ll,&\r
+       & FMREADL0_ll,FMREADL1_ll,FMREADC0_ll,FMREADT0_ll\r
+END INTERFACE\r
+!\r
+\r
+PUBLIC FMREAD_LB,FMREAD,FMREADX0_ll,FMREADX1_ll,FMREADX2_ll,FMREADX3_ll,&\r
+       & FMREADX4_ll,FMREADX5_ll,FMREADX6_ll,&\r
+       & FMREADN0_ll,FMREADN1_ll,FMREADN2_ll,&\r
+       & FMREADL0_ll,FMREADL1_ll,FMREADC0_ll,FMREADT0_ll\r
+\r
+!INCLUDE 'mpif.h'\r
+\r
+CONTAINS \r
+SUBROUTINE FM_READ_ERR(HFUNC,HFILEM,HFIPRI,HRECFM,HDIR,KRESP)\r
+USE MODE_FM, ONLY : FMLOOK_ll\r
+\r
+CHARACTER(LEN=*) :: HFUNC \r
+CHARACTER(LEN=*) :: HFILEM\r
+CHARACTER(LEN=*) :: HFIPRI\r
+CHARACTER(LEN=*) :: HRECFM\r
+CHARACTER(LEN=*) :: HDIR\r
+INTEGER          :: KRESP\r
+\r
+INTEGER          :: ILUPRI\r
+INTEGER          :: IRESP\r
+\r
+CALL FMLOOK_ll(HFIPRI,HFIPRI,ILUPRI,IRESP)\r
+WRITE (ILUPRI,*) ' exit from ',HFUNC, ' with RESP:',KRESP\r
+!STOP "fmread_ll.f90:: FM_READ_ERR"\r
+\r
+WRITE (ILUPRI,*) '   | HFILEM = ',HFILEM\r
+WRITE (ILUPRI,*) '   | HRECFM = ',HRECFM\r
+WRITE (ILUPRI,*) '   | HDIR  = ',HDIR\r
+\r
+END SUBROUTINE FM_READ_ERR\r
+\r
+\r
+SUBROUTINE BCAST_HEADER(TPFD,TPFMH)\r
+USE MODE_FD_ll, ONLY : FD_ll\r
+USE MODD_FM\r
+TYPE(FD_ll),     POINTER    :: TPFD\r
+TYPE(FMHEADER), INTENT(IN) :: TPFMH\r
+\r
+INTEGER :: ierr \r
+\r
+CALL MPI_BCAST(TPFMH%GRID,1,MPI_INTEGER,TPFD%OWNER-1,TPFD%COMM,IERR)\r
+CALL MPI_BCAST(TPFMH%COMLEN,1,MPI_INTEGER,TPFD%OWNER-1,TPFD%COMM,IERR)\r
+CALL MPI_BCAST(TPFMH%COMMENT,TPFMH%COMLEN,MPI_CHARACTER,TPFD%OWNER-1,TPFD%COMM,IERR)\r
+\r
+END SUBROUTINE BCAST_HEADER\r
+\r
+SUBROUTINE FMREADX0_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&\r
+     KLENCH,HCOMMENT,KRESP)\r
+USE MODD_IO_ll, ONLY : ISP,GSMONOPROC \r
+USE MODD_FM\r
+USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL\r
+!\r
+!*      0.    DECLARATIONS\r
+!             ------------\r
+!\r
+!\r
+!*      0.1   Declarations of arguments\r
+!\r
+CHARACTER(LEN=*),             INTENT(IN) ::HFILEM ! FM-file name\r
+CHARACTER(LEN=*),             INTENT(IN) ::HRECFM ! name of the article to read\r
+CHARACTER(LEN=*),             INTENT(IN) ::HFIPRI ! output file for error messages\r
+CHARACTER(LEN=*),             INTENT(IN) ::HDIR   ! field form\r
+REAL,                         INTENT(INOUT)::PFIELD ! array containing the data field \r
+INTEGER,                      INTENT(INOUT)::KGRID  ! C-grid indicator (u,v,w,T)\r
+INTEGER,                      INTENT(INOUT)::KLENCH ! length of comment string\r
+CHARACTER(LEN=*),             INTENT(INOUT)::HCOMMENT ! comment string\r
+INTEGER,                      INTENT(INOUT)::KRESP    ! return-code\r
+!\r
+!*      0.2   Declarations of local variables\r
+!\r
+!----------------------------------------------------------------\r
+CHARACTER(LEN=JPFINL)        :: YFNLFI\r
+INTEGER                      :: IERR\r
+TYPE(FD_ll), POINTER         :: TZFD\r
+INTEGER                      :: IRESP\r
+TYPE(FMHEADER)               :: TZFMH\r
+!\r
+!*      1.1   THE NAME OF LFIFM\r
+!\r
+IRESP = 0\r
+YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'\r
+!------------------------------------------------------------------\r
+TZFD=>GETFD(YFNLFI)\r
+IF (ASSOCIATED(TZFD)) THEN\r
+  IF (GSMONOPROC) THEN ! sequential execution\r
+    IF (ASSOCIATED(TZFD%CDF)) THEN\r
+       CALL NCREAD(TZFD%CDF%NCID,HRECFM,PFIELD,TZFMH,IRESP)\r
+    ELSE\r
+       CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,1,PFIELD,TZFMH,IRESP)\r
+    END IF\r
+    IF (IRESP /= 0) GOTO 1000\r
+  ELSE ! multiprocessor execution\r
+    IF (ISP == TZFD%OWNER)  THEN\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,PFIELD,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,1,PFIELD,TZFMH,IRESP)\r
+      END IF\r
+    END IF\r
+    !\r
+    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    IF (IRESP /= 0) GOTO 1000\r
+    !\r
+    CALL BCAST_HEADER(TZFD,TZFMH)\r
+    !\r
+    CALL MPI_BCAST(PFIELD,1,MPI_FLOAT,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+  END IF\r
+  KGRID  = TZFMH%GRID\r
+  KLENCH = TZFMH%COMLEN\r
+  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)\r
+ELSE \r
+  IRESP = -61\r
+END IF\r
+!----------------------------------------------------------------\r
+1000 CONTINUE\r
+!! Error handler\r
+IF (IRESP.NE.0) THEN\r
+  CALL FM_READ_ERR("FMREADX0_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)\r
+ENDIF\r
+KRESP = IRESP\r
+RETURN\r
+    \r
+END SUBROUTINE FMREADX0_ll\r
+\r
+SUBROUTINE FMREADX1_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&\r
+     KLENCH,HCOMMENT,KRESP, KIMAX_ll, KJMAX_ll, TPSPLITTING)\r
+USE MODD_IO_ll, ONLY : ISP,GSMONOPROC, ISNPROC\r
+USE MODD_FM\r
+USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL\r
+USE MODE_SCATTER_ll\r
+USE MODE_ALLOCBUFFER_ll\r
+USE MODD_STRUCTURE_ll, ONLY : ZONE_ll\r
+!\r
+!*      0.    DECLARATIONS\r
+!             ------------\r
+!\r
+!\r
+!*      0.1   Declarations of arguments\r
+!\r
+CHARACTER(LEN=*),        INTENT(IN) ::HFILEM   ! FM-file name\r
+CHARACTER(LEN=*),        INTENT(IN) ::HRECFM   ! name of the article to read\r
+CHARACTER(LEN=*),        INTENT(IN) ::HFIPRI   ! output file for error messages\r
+CHARACTER(LEN=*),        INTENT(IN) ::HDIR     ! Field form\r
+REAL,DIMENSION(:),TARGET,INTENT(INOUT)::PFIELD   ! array containing the data field \r
+INTEGER,                 INTENT(INOUT)::KGRID    ! C-grid indicator (u,v,w,T)\r
+INTEGER,                 INTENT(INOUT)::KLENCH   ! length of comment string\r
+CHARACTER(LEN=*),        INTENT(INOUT)::HCOMMENT ! comment string\r
+INTEGER,                 INTENT(INOUT)::KRESP    ! return-code\r
+INTEGER, OPTIONAL, INTENT(IN) ::KIMAX_ll\r
+INTEGER, OPTIONAL, INTENT(IN) ::KJMAX_ll\r
+TYPE(ZONE_ll), DIMENSION(ISNPROC), OPTIONAL :: TPSPLITTING  ! splitting of the domain\r
+!\r
+!*      0.2   Declarations of local variables\r
+!\r
+!----------------------------------------------------------------\r
+CHARACTER(LEN=JPFINL)     :: YFNLFI\r
+INTEGER                   :: IERR\r
+TYPE(FD_ll), POINTER      :: TZFD\r
+INTEGER                   :: IRESP\r
+REAL,DIMENSION(:),POINTER :: ZFIELDP\r
+LOGICAL                   :: GALLOC\r
+TYPE(FMHEADER)            :: TZFMH\r
+!\r
+!*      1.1   THE NAME OF LFIFM\r
+!\r
+GALLOC = .FALSE.\r
+IRESP = 0\r
+YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'\r
+!------------------------------------------------------------------\r
+TZFD=>GETFD(YFNLFI)\r
+IF (ASSOCIATED(TZFD)) THEN\r
+  IF (GSMONOPROC) THEN ! sequential execution\r
+    IF (ASSOCIATED(TZFD%CDF)) THEN\r
+       CALL NCREAD(TZFD%CDF%NCID,HRECFM,PFIELD,TZFMH,IRESP)\r
+    ELSE\r
+       CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)\r
+    END IF\r
+    IF (IRESP /= 0) GOTO 1000\r
+  ELSE ! multiprocessor execution\r
+    IF (ISP == TZFD%OWNER)  THEN\r
+      IF( PRESENT(KIMAX_ll) .AND. PRESENT(KJMAX_ll) ) THEN\r
+        CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC, KIMAX_ll, KJMAX_ll)\r
+      ELSE\r
+        CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)\r
+      ENDIF\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&\r
+              & ,IRESP)\r
+      END IF\r
+    ELSE\r
+      ALLOCATE(ZFIELDP(0))\r
+      GALLOC = .TRUE.\r
+    END IF\r
+      \r
+    !  \r
+    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    IF (IRESP /= 0) GOTO 1000\r
+    !\r
+    CALL BCAST_HEADER(TZFD,TZFMH)\r
+    !\r
+    IF (HDIR /= 'XX' .AND. HDIR /='YY') THEN\r
+      ! Broadcast Field\r
+      CALL MPI_BCAST(PFIELD,SIZE(PFIELD),MPI_FLOAT,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    ELSE \r
+      !Scatter Field\r
+      IF( PRESENT(TPSPLITTING) ) THEN\r
+        CALL SCATTER_XXFIELD(HDIR,ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM,TPSPLITTING)\r
+      ELSE\r
+        CALL SCATTER_XXFIELD(HDIR,ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM)\r
+      ENDIF\r
+    END IF\r
+  END IF !(GSMONOPROC)\r
+  \r
+  KGRID  = TZFMH%GRID\r
+  KLENCH = TZFMH%COMLEN\r
+  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)\r
+ELSE \r
+  IRESP = -61\r
+END IF\r
+!----------------------------------------------------------------\r
+1000 CONTINUE\r
+!! Error handler\r
+IF (IRESP.NE.0) THEN\r
+  CALL FM_READ_ERR("FMREADX1_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)\r
+ENDIF\r
+\r
+IF (GALLOC) DEALLOCATE (ZFIELDP)\r
+KRESP = IRESP\r
+RETURN\r
+!------------------------------------------------------------------\r
+END SUBROUTINE FMREADX1_ll\r
+\r
+SUBROUTINE FMREADX2_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&\r
+     KLENCH,HCOMMENT,KRESP, KIMAX_ll, KJMAX_ll, TPSPLITTING)\r
+USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LPACK,L1D,L2D , ISNPROC\r
+USE MODD_PARAMETERS_ll,ONLY : JPHEXT\r
+USE MODD_FM\r
+USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL\r
+USE MODE_SCATTER_ll\r
+USE MODE_ALLOCBUFFER_ll\r
+!JUANZ\r
+USE MODD_TIMEZ, ONLY : TIMEZ\r
+USE MODE_MNH_TIMING, ONLY : SECOND_MNH2\r
+!JUANZ \r
+USE MODD_STRUCTURE_ll, ONLY : ZONE_ll\r
+#ifdef MNH_GA\r
+    USE MODE_GA\r
+#endif\r
+\r
+IMPLICIT NONE\r
+\r
+CHARACTER(LEN=*),           INTENT(IN) ::HFILEM   ! FM-file name\r
+CHARACTER(LEN=*),           INTENT(IN) ::HRECFM   ! name of the article to read\r
+CHARACTER(LEN=*),           INTENT(IN) ::HFIPRI   ! output file for error messages\r
+CHARACTER(LEN=*),           INTENT(IN) ::HDIR     ! field form\r
+REAL,DIMENSION(:,:),TARGET, INTENT(INOUT)::PFIELD   ! array containing the data field\r
+INTEGER,                    INTENT(INOUT)::KGRID    ! C-grid indicator (u,v,w,T)\r
+INTEGER,                    INTENT(INOUT)::KLENCH   ! length of comment string\r
+CHARACTER(LEN=*),           INTENT(INOUT)::HCOMMENT ! comment string\r
+INTEGER,                   INTENT(INOUT)::KRESP     ! return-code\r
+INTEGER, OPTIONAL, INTENT(IN) ::KIMAX_ll\r
+INTEGER, OPTIONAL, INTENT(IN) ::KJMAX_ll\r
+TYPE(ZONE_ll), DIMENSION(ISNPROC), OPTIONAL :: TPSPLITTING  ! splitting of the domain\r
+!\r
+!\r
+!*      0.2   Declarations of local variables\r
+!\r
+CHARACTER(LEN=JPFINL)        :: YFNLFI\r
+\r
+INTEGER                      :: IERR\r
+TYPE(FD_ll), POINTER         :: TZFD\r
+INTEGER                      :: IRESP\r
+REAL,DIMENSION(:,:), POINTER :: ZFIELDP\r
+LOGICAL                      :: GALLOC\r
+TYPE(FMHEADER)               :: TZFMH\r
+!JUANZ\r
+REAL*8,DIMENSION(2) :: T0,T1,T2\r
+REAL*8,DIMENSION(2) :: T11,T22\r
+!JUANZ\r
+#ifdef MNH_GA\r
+REAL,DIMENSION(:,:),POINTER    :: ZFIELD_GA\r
+#endif\r
+INTEGER                      :: IHEXTOT\r
+!\r
+!*      1.1   THE NAME OF LFIFM\r
+!\r
+CALL SECOND_MNH2(T11)\r
+GALLOC = .FALSE.\r
+IRESP = 0\r
+YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'\r
+\r
+!------------------------------------------------------------------\r
+IHEXTOT = 2*JPHEXT+1\r
+TZFD=>GETFD(YFNLFI)\r
+IF (ASSOCIATED(TZFD)) THEN\r
+  IF (GSMONOPROC) THEN ! sequential execution\r
+!    IF (LPACK .AND. L1D .AND. HDIR=='XY') THEN \r
+    IF (LPACK .AND. L1D .AND. SIZE(PFIELD,1)==IHEXTOT .AND. SIZE(PFIELD,2)==IHEXTOT) THEN\r
+      ZFIELDP=>PFIELD(JPHEXT+1:JPHEXT+1,JPHEXT+1:JPHEXT+1)\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)\r
+      END IF\r
+      PFIELD(:,:)=SPREAD(SPREAD(PFIELD(JPHEXT+1,JPHEXT+1),DIM=1,NCOPIES=IHEXTOT),DIM=2,NCOPIES=IHEXTOT)\r
+!    ELSE IF (LPACK .AND. L2D .AND. HDIR=='XY') THEN\r
+    ELSE IF (LPACK .AND. L2D .AND. SIZE(PFIELD,2)==IHEXTOT) THEN\r
+      ZFIELDP=>PFIELD(:,JPHEXT+1:JPHEXT+1)\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)\r
+      END IF\r
+      PFIELD(:,:)=SPREAD(PFIELD(:,JPHEXT+1),DIM=2,NCOPIES=IHEXTOT)\r
+    ELSE\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,PFIELD,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)\r
+      END IF\r
+    END IF\r
+    IF (IRESP /= 0) GOTO 1000\r
+  ELSE ! multiprocessor execution\r
+     CALL SECOND_MNH2(T0)\r
+    IF (ISP == TZFD%OWNER)  THEN\r
+      ! I/O processor case\r
+      IF( PRESENT(KIMAX_ll) .AND. PRESENT(KJMAX_ll) ) THEN\r
+        CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC, KIMAX_ll, KJMAX_ll)\r
+      ELSE\r
+        CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)\r
+      ENDIF\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&\r
+           & ,IRESP)\r
+      END IF\r
+    ELSE\r
+      ALLOCATE(ZFIELDP(0,0))\r
+      GALLOC = .TRUE.\r
+    END IF\r
+    CALL SECOND_MNH2(T1)\r
+    TIMEZ%T_READ2D_READ=TIMEZ%T_READ2D_READ + T1 - T0\r
+    !\r
+    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    IF (IRESP /= 0) GOTO 1000\r
+    !\r
+    CALL BCAST_HEADER(TZFD,TZFMH)\r
+    !\r
+    IF (HDIR == 'XX' .OR. HDIR =='YY') THEN\r
+      ! XX or YY Scatter Field\r
+      IF( PRESENT(TPSPLITTING) ) THEN\r
+        CALL SCATTER_XXFIELD(HDIR,ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM,TPSPLITTING)\r
+      ELSE\r
+        CALL SCATTER_XXFIELD(HDIR,ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM)\r
+      ENDIF\r
+    ELSE IF (HDIR == 'XY') THEN\r
+      IF (LPACK .AND. L2D) THEN\r
+        ! 2D compact case\r
+      IF( PRESENT(TPSPLITTING) ) THEN\r
+        CALL SCATTER_XXFIELD('XX',ZFIELDP(:,1),PFIELD(:,JPHEXT+1),TZFD%OWNER,TZFD%COMM,TPSPLITTING)\r
+      ELSE\r
+        CALL SCATTER_XXFIELD('XX',ZFIELDP(:,1),PFIELD(:,JPHEXT+1),TZFD%OWNER,TZFD%COMM)\r
+      ENDIF\r
+        PFIELD(:,:) = SPREAD(PFIELD(:,JPHEXT+1),DIM=2,NCOPIES=IHEXTOT)\r
+      ELSE\r
+#ifdef MNH_GA\r
+         !\r
+         ! init/create the ga , dim3 = 1\r
+         !\r
+         CALL MNH_INIT_GA(SIZE(PFIELD,1),SIZE(PFIELD,2),1,HRECFM,"READ")\r
+         IF (ISP == TZFD%OWNER)  THEN\r
+            !\r
+            ! put the data in the g_a , this proc get this 1 slide\r
+            !\r
+            lo_zplan(JPIZ) = 1\r
+            hi_zplan(JPIZ) = 1\r
+            call nga_put(g_a, lo_zplan, hi_zplan,ZFIELDP, ld_zplan)\r
+         END IF\r
+         call ga_sync\r
+         !\r
+         ! get the columun data in this proc\r
+         !\r
+         ! temp buf to avoid problem with none stride PFIELDS buffer  with HALO \r
+         ALLOCATE (ZFIELD_GA (SIZE(PFIELD,1),SIZE(PFIELD,2)))\r
+         call nga_get(g_a, lo_col, hi_col,ZFIELD_GA(1,1) , ld_col)\r
+         PFIELD = ZFIELD_GA\r
+         DEALLOCATE(ZFIELD_GA)\r
+#else\r
+        ! XY Scatter Field\r
+        CALL SCATTER_XYFIELD(ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM)\r
+#endif\r
+      END IF\r
+    ELSE\r
+      CALL MPI_BCAST(PFIELD,SIZE(PFIELD),MPI_FLOAT,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    END IF\r
+    CALL SECOND_MNH2(T2)\r
+    TIMEZ%T_READ2D_SCAT=TIMEZ%T_READ2D_SCAT + T2 - T1    \r
+  END IF !(GSMONOPROC)\r
+  \r
+  KGRID  = TZFMH%GRID\r
+  KLENCH = TZFMH%COMLEN\r
+  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)\r
+ELSE \r
+  IRESP = -61\r
+END IF\r
+!----------------------------------------------------------------\r
+1000 CONTINUE\r
+!! Error handler\r
+IF (IRESP.NE.0) THEN\r
+  CALL FM_READ_ERR("FMREADX2_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)\r
+ENDIF\r
+IF (GALLOC) DEALLOCATE (ZFIELDP)\r
+KRESP = IRESP\r
+!------------------------------------------------------------------\r
+\r
+CALL SECOND_MNH2(T22)\r
+TIMEZ%T_READ2D_ALL=TIMEZ%T_READ2D_ALL + T22 - T11\r
+\r
+END SUBROUTINE FMREADX2_ll\r
+\r
+SUBROUTINE FMREADX3_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&\r
+     KLENCH,HCOMMENT,KRESP)\r
+USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LPACK,L1D,L2D \r
+USE MODD_PARAMETERS_ll,ONLY : JPHEXT\r
+USE MODD_FM\r
+USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL\r
+USE MODE_SCATTER_ll\r
+USE MODE_ALLOCBUFFER_ll\r
+!JUANZ\r
+USE MODD_IO_ll, ONLY : ISNPROC\r
+USE MODE_IO_ll, ONLY : io_file,io_rank\r
+USE MODD_TIMEZ, ONLY : TIMEZ\r
+USE MODE_MNH_TIMING, ONLY : SECOND_MNH2\r
+!JUANZ\r
+#ifdef MNH_GA\r
+    USE MODE_GA\r
+#endif\r
+USE MODD_VAR_ll, ONLY : MNH_STATUSES_IGNORE\r
+\r
+IMPLICIT NONE\r
+\r
+CHARACTER(LEN=*),             INTENT(IN) ::HFILEM ! FM-file name\r
+CHARACTER(LEN=*),             INTENT(IN) ::HRECFM ! name of the article to read\r
+CHARACTER(LEN=*),             INTENT(IN) ::HFIPRI ! output file for error messages\r
+CHARACTER(LEN=*),             INTENT(IN) ::HDIR   ! field form\r
+REAL, DIMENSION(:,:,:),TARGET,INTENT(INOUT)::PFIELD ! array containing the data field\r
+INTEGER,                      INTENT(INOUT)::KGRID  ! C-grid indicator (u,v,w,T)\r
+INTEGER,                      INTENT(INOUT)::KLENCH ! length of comment string\r
+CHARACTER(LEN=*),             INTENT(INOUT)::HCOMMENT ! comment string\r
+INTEGER,                      INTENT(INOUT)::KRESP    ! return-code\r
+!\r
+#ifdef MNH_GA\r
+REAL,DIMENSION(:,:,:),POINTER              :: ZFIELD_GA\r
+#endif\r
+!\r
+!\r
+!*      0.2   Declarations of local variables\r
+!\r
+CHARACTER(LEN=JPFINL)                    :: YFNLFI\r
+INTEGER                                  :: IERR\r
+TYPE(FD_ll), POINTER                     :: TZFD\r
+INTEGER                                  :: IRESP\r
+REAL,DIMENSION(:,:,:),POINTER            :: ZFIELDP\r
+LOGICAL                                  :: GALLOC\r
+TYPE(FMHEADER)                           :: TZFMH\r
+!JUAN\r
+INTEGER                                  :: JK,JKK\r
+CHARACTER(LEN=LEN(HRECFM))               :: YK,YRECZSLIDE\r
+REAL,DIMENSION(:,:),POINTER              :: ZSLIDE_ll,ZSLIDE\r
+INTEGER                                  :: IK_FILE,IK_rank,inb_proc_real,JK_MAX\r
+CHARACTER(len=5)                         :: YK_FILE  \r
+CHARACTER(len=128)                       :: YFILE_IOZ  \r
+TYPE(FD_ll), POINTER                     :: TZFD_IOZ \r
+INTEGER                                  :: JI,IXO,IXE,IYO,IYE\r
+REAL,DIMENSION(:,:),POINTER              :: TX2DP\r
+INTEGER, DIMENSION(MPI_STATUS_SIZE)      :: STATUS\r
+LOGICAL                                  :: GALLOC_ll\r
+\r
+INTEGER,ALLOCATABLE,DIMENSION(:)    :: REQ_TAB\r
+INTEGER                           :: NB_REQ\r
+TYPE TX_2DP\r
+   REAL,DIMENSION(:,:), POINTER    :: X\r
+END TYPE TX_2DP\r
+TYPE(TX_2DP),ALLOCATABLE,DIMENSION(:) :: T_TX2DP\r
+REAL*8,DIMENSION(2) :: T0,T1,T2\r
+REAL*8,DIMENSION(2) :: T11,T22\r
+INTEGER             :: IHEXTOT\r
+!JUAN\r
+!\r
+!*      1.1   THE NAME OF LFIFM\r
+!\r
+CALL SECOND_MNH2(T11)\r
+GALLOC    = .FALSE.\r
+GALLOC_ll = .FALSE.\r
+IRESP  = 0\r
+YFNLFI = TRIM(ADJUSTL(HFILEM))//'.lfi'\r
+!------------------------------------------------------------------\r
+IHEXTOT = 2*JPHEXT+1\r
+TZFD=>GETFD(YFNLFI)\r
+IF (ASSOCIATED(TZFD)) THEN\r
+  IF (GSMONOPROC  .AND.  (TZFD%nb_procio.eq.1) ) THEN ! sequential execution\r
+!    IF (LPACK .AND. L1D .AND. HDIR=='XY') THEN \r
+    IF (LPACK .AND. L1D  .AND. SIZE(PFIELD,1)==IHEXTOT .AND. SIZE(PFIELD,2)==IHEXTOT) THEN\r
+      ZFIELDP=>PFIELD(JPHEXT+1:JPHEXT+1,JPHEXT+1:JPHEXT+1,:)\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)\r
+      END IF\r
+      PFIELD(:,:,:)=SPREAD(SPREAD(PFIELD(JPHEXT+1,JPHEXT+1,:),DIM=1,NCOPIES=IHEXTOT),DIM=2,NCOPIES=IHEXTOT)\r
+!    ELSE IF (LPACK .AND. L2D .AND. HDIR=='XY') THEN\r
+    ELSE IF (LPACK .AND. L2D .AND. SIZE(PFIELD,2)==IHEXTOT) THEN\r
+      ALLOCATE (ZFIELDP(SIZE(PFIELD,1),1,SIZE(PFIELD,3)))\r
+      GALLOC = .TRUE.\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)\r
+      END IF\r
+      PFIELD(:,:,:)=SPREAD(ZFIELDP(:,1,:),DIM=2,NCOPIES=IHEXTOT)\r
+    ELSE\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,PFIELD,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)\r
+      END IF\r
+    END IF\r
+    IF (IRESP /= 0) GOTO 1000\r
+  ELSEIF ( (TZFD%nb_procio .eq. 1 ) .OR.  ( HDIR == '--' )  ) THEN ! multiprocessor execution & 1 IO proc \r
+  ! read 3D field for graphique\r
+    IF (ISP == TZFD%OWNER)  THEN\r
+      CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&\r
+           & ,IRESP)\r
+      END IF\r
+    ELSE \r
+      ALLOCATE(ZFIELDP(0,0,0))\r
+      GALLOC = .TRUE. \r
+    END IF\r
+    !\r
+    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    IF (IRESP /= 0) GOTO 1000\r
+    !\r
+    CALL BCAST_HEADER(TZFD,TZFMH)\r
+    !\r
+    IF (HDIR == 'XX' .OR. HDIR =='YY') THEN\r
+      ! XX or YY Scatter Field\r
+      CALL SCATTER_XXFIELD(HDIR,ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM) \r
+    ELSE IF (HDIR == 'XY') THEN\r
+      IF (LPACK .AND. L2D) THEN\r
+        ! 2D compact case\r
+        CALL SCATTER_XXFIELD('XX',ZFIELDP(:,1,:),PFIELD(:,JPHEXT+1,:),TZFD%OWNER,TZFD%COMM)\r
+        PFIELD(:,:,:) = SPREAD(PFIELD(:,JPHEXT+1,:),DIM=2,NCOPIES=IHEXTOT)\r
+      ELSE\r
+        ! XY Scatter Field\r
+        CALL SCATTER_XYFIELD(ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM)\r
+      END IF\r
+    ELSE\r
+      ! Broadcast Field\r
+      CALL MPI_BCAST(PFIELD,SIZE(PFIELD),MPI_FLOAT,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    END IF\r
+  ELSE  ! multiprocessor execution & // IO  \r
+!\r
+!JUAN BG Z SLIDE \r
+!\r
+#ifdef MNH_GA\r
+          !\r
+          ! init/create the ga\r
+          !\r
+          CALL SECOND_MNH2(T0)\r
+          CALL MNH_INIT_GA(SIZE(PFIELD,1),SIZE(PFIELD,2),SIZE(PFIELD,3),HRECFM,"READ")\r
+         !\r
+         ! read the data\r
+         !\r
+         ALLOCATE(ZSLIDE_ll(0,0)) ! to avoid bug on test of size\r
+         GALLOC_ll = .TRUE.\r
+         DO JKK=1,IKU_ll\r
+            IK_FILE   =  io_file(JKK,TZFD%nb_procio)\r
+            write(YK_FILE ,'(".Z",i3.3)') IK_FILE+1\r
+            YFILE_IOZ =  TRIM(HFILEM)//YK_FILE//".lfi"\r
+            TZFD_IOZ => GETFD(YFILE_IOZ)\r
+            !\r
+            IK_RANK   =  TZFD_IOZ%OWNER\r
+            !\r
+            IF (ISP == IK_RANK )  THEN\r
+               IF ( SIZE(ZSLIDE_ll) .EQ. 0 ) THEN\r
+                  DEALLOCATE(ZSLIDE_ll)\r
+                  CALL ALLOCBUFFER_ll(ZSLIDE_ll,ZSLIDE,HDIR,GALLOC_ll)\r
+               END IF\r
+               !    \r
+               CALL SECOND_MNH2(T0)\r
+               WRITE(YK,'(I4.4)')  JKK\r
+               YRECZSLIDE = TRIM(HRECFM)//YK\r
+               IF (ASSOCIATED(TZFD_IOZ%CDF)) THEN\r
+                  CALL NCREAD(TZFD_IOZ%CDF%NCID,YRECZSLIDE,ZSLIDE_ll,TZFMH,IRESP)\r
+               ELSE\r
+                  CALL FM_READ_ll(TZFD_IOZ%FLU,YRECZSLIDE,.TRUE.,SIZE(ZSLIDE_ll),ZSLIDE_ll,TZFMH&\r
+                       & ,IRESP)\r
+               END IF\r
+               CALL SECOND_MNH2(T1)\r
+               TIMEZ%T_READ3D_READ=TIMEZ%T_READ3D_READ + T1 - T0\r
+               !\r
+               ! put the data in the g_a , this proc get this JKK slide\r
+               !\r
+               lo_zplan(JPIZ) = JKK\r
+               hi_zplan(JPIZ) = JKK\r
+               call nga_put(g_a, lo_zplan, hi_zplan,ZSLIDE_ll, ld_zplan)\r
+            END IF\r
+         END DO\r
+         call ga_sync\r
+         !\r
+         ! get the columun data in this proc\r
+         !\r
+         ! temp buf to avoid problem with none stride PFIELDS buffer  with HALO \r
+         ALLOCATE (ZFIELD_GA (SIZE(PFIELD,1),SIZE(PFIELD,2),SIZE(PFIELD,3)))\r
+         call nga_get(g_a, lo_col, hi_col,ZFIELD_GA(1,1,1) , ld_col)\r
+         PFIELD = ZFIELD_GA\r
+         DEALLOCATE(ZFIELD_GA)\r
+#else\r
+     ALLOCATE(ZSLIDE_ll(0,0))\r
+     GALLOC_ll = .TRUE.\r
+     inb_proc_real = min(TZFD%nb_procio,ISNPROC)\r
+     Z_SLIDE: DO JK=1,SIZE(PFIELD,3),inb_proc_real\r
+        !\r
+        ! read the data\r
+        !\r
+        JK_MAX=min(SIZE(PFIELD,3),JK+inb_proc_real-1)\r
+        !\r
+         NB_REQ=0\r
+         ALLOCATE(REQ_TAB(ISNPROC-1))\r
+         ALLOCATE(T_TX2DP(ISNPROC-1))        \r
+        DO JKK=JK,JK_MAX\r
+           IF (TZFD%NB_PROCIO .GT. 1 ) THEN\r
+              IK_FILE   =  io_file(JKK,TZFD%nb_procio)\r
+              write(YK_FILE ,'(".Z",i3.3)') IK_FILE+1\r
+              YFILE_IOZ =  TRIM(HFILEM)//YK_FILE//".lfi"\r
+              TZFD_IOZ => GETFD(YFILE_IOZ)\r
+           ELSE\r
+              TZFD_IOZ => TZFD\r
+           ENDIF\r
+           IK_RANK   =  TZFD_IOZ%OWNER\r
+           IF (ISP == IK_RANK )  THEN\r
+              IF ( SIZE(ZSLIDE_ll) .EQ. 0 ) THEN\r
+                 DEALLOCATE(ZSLIDE_ll)\r
+                 CALL ALLOCBUFFER_ll(ZSLIDE_ll,ZSLIDE,HDIR,GALLOC_ll)\r
+              END IF\r
+              !JUAN\r
+               CALL SECOND_MNH2(T0)\r
+              WRITE(YK,'(I4.4)')  JKK\r
+              YRECZSLIDE = TRIM(HRECFM)//YK\r
+              IF (ASSOCIATED(TZFD_IOZ%CDF)) THEN\r
+                 CALL NCREAD(TZFD_IOZ%CDF%NCID,YRECZSLIDE,ZSLIDE_ll,TZFMH,IRESP)\r
+              ELSE\r
+                 CALL FM_READ_ll(TZFD_IOZ%FLU,YRECZSLIDE,.TRUE.,SIZE(ZSLIDE_ll),ZSLIDE_ll,TZFMH&\r
+                   & ,IRESP)\r
+              END IF\r
+              !JUANIOZ\r
+               CALL SECOND_MNH2(T1)\r
+               TIMEZ%T_READ3D_READ=TIMEZ%T_READ3D_READ + T1 - T0\r
+              DO JI = 1,ISNPROC\r
+                 CALL GET_DOMREAD_ll(JI,IXO,IXE,IYO,IYE)\r
+                 TX2DP=>ZSLIDE_ll(IXO:IXE,IYO:IYE)\r
+                 IF (ISP /= JI) THEN \r
+                     NB_REQ = NB_REQ + 1\r
+                     ALLOCATE(T_TX2DP(NB_REQ)%X(IXO:IXE,IYO:IYE))\r
+                     T_TX2DP(NB_REQ)%X=TX2DP\r
+                     CALL MPI_ISEND(T_TX2DP(NB_REQ)%X,SIZE(TX2DP),MPI_FLOAT,JI-1,199+IK_RANK &\r
+                          & ,TZFD_IOZ%COMM,REQ_TAB(NB_REQ),IERR)\r
+                     !CALL MPI_BSEND(TX2DP,SIZE(TX2DP),MPI_FLOAT,JI-1,199+IK_RANK,TZFD_IOZ%COMM,IERR)\r
+                 ELSE \r
+                    PFIELD(:,:,JKK) = TX2DP(:,:)\r
+                 END IF\r
+              END DO\r
+               CALL SECOND_MNH2(T2)\r
+               TIMEZ%T_READ3D_SEND=TIMEZ%T_READ3D_SEND + T2 - T1\r
+              !JUANIOZ\r
+           END IF\r
+        END DO\r
+        !\r
+        ! brodcast the data\r
+        !\r
+    IF (HDIR == 'XX' .OR. HDIR =='YY') THEN\r
+      ! XX or YY Scatter Field\r
+       STOP " XX ou YY NON PREVU SUR BG POUR LE MOMENT "\r
+      CALL SCATTER_XXFIELD(HDIR,ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM) \r
+    ELSE IF (HDIR == 'XY') THEN\r
+       IF (LPACK .AND. L2D) THEN\r
+          ! 2D compact case\r
+          STOP " L2D NON PREVU SUR BG POUR LE MOMENT "\r
+          CALL SCATTER_XXFIELD('XX',ZFIELDP(:,1,:),PFIELD(:,JPHEXT+1,:),TZFD%OWNER,TZFD%COMM)\r
+          PFIELD(:,:,:) = SPREAD(PFIELD(:,JPHEXT+1,:),DIM=2,NCOPIES=IHEXTOT)\r
+       ELSE\r
+          !\r
+          ! XY Scatter Field\r
+          !\r
+               CALL SECOND_MNH2(T0)\r
+          DO JKK=JK,JK_MAX\r
+             !\r
+             ! get the file & rank \r
+             !\r
+             IF (TZFD%NB_PROCIO .GT. 1 ) THEN\r
+               IK_FILE   =  io_file(JKK,TZFD%nb_procio)\r
+               write(YK_FILE ,'(".Z",i3.3)') IK_FILE+1\r
+               YFILE_IOZ =  TRIM(HFILEM)//YK_FILE//".lfi"\r
+               TZFD_IOZ => GETFD(YFILE_IOZ)\r
+            ELSE\r
+               TZFD_IOZ => TZFD\r
+            END IF\r
+            !\r
+            !IK_RANK   =  1 + io_rank(IK_FILE,ISNPROC,TZFD%nb_procio)\r
+            IK_RANK    =  TZFD_IOZ%OWNER\r
+            !\r
+            ZSLIDE => PFIELD(:,:,JKK)\r
+!JUANIOZ\r
+            !CALL SCATTER_XYFIELD(ZSLIDE_ll,ZSLIDE,TZFD_IOZ%OWNER,TZFD_IOZ%COMM)\r
+            IF (ISP .NE. IK_RANK) THEN\r
+               CALL MPI_RECV(ZSLIDE,SIZE(ZSLIDE),MPI_FLOAT,IK_RANK-1,199+IK_RANK,TZFD_IOZ%COMM&\r
+                    & ,STATUS,IERR)\r
+            END IF\r
+!JUAN IOZ\r
+         END DO\r
+               CALL SECOND_MNH2(T1)\r
+               TIMEZ%T_READ3D_RECV=TIMEZ%T_READ3D_RECV + T1 - T0               \r
+      END IF\r
+    ELSE\r
+      ! Broadcast Field\r
+       STOP "  Broadcast Field NON PREVU SUR BG POUR LE MOMENT "\r
+      CALL MPI_BCAST(PFIELD,SIZE(PFIELD),MPI_FLOAT,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    END IF\r
+         CALL SECOND_MNH2(T0) \r
+         IF (NB_REQ .GT.0 ) THEN\r
+            CALL MPI_WAITALL(NB_REQ,REQ_TAB,MNH_STATUSES_IGNORE,IERR)\r
+            DO JI=1,NB_REQ ;  DEALLOCATE(T_TX2DP(JI)%X) ; ENDDO\r
+         END IF\r
+         DEALLOCATE(T_TX2DP)\r
+         DEALLOCATE(REQ_TAB)\r
+         CALL SECOND_MNH2(T1) \r
+         TIMEZ%T_READ3D_WAIT=TIMEZ%T_READ3D_WAIT + T1 - T0\r
+ END DO Z_SLIDE\r
+ !\r
+ CALL BCAST_HEADER(TZFD,TZFMH)\r
+ !\r
+#endif\r
+!JUAN BG Z SLIDE  \r
+  END IF !(GSMONOPROC) \r
+  \r
+  KGRID    = TZFMH%GRID\r
+  KLENCH   = TZFMH%COMLEN\r
+  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)\r
+ELSE \r
+  IRESP = -61          \r
+END IF\r
+!----------------------------------------------------------------\r
+1000 CONTINUE\r
+!! Error handler\r
+IF (IRESP.NE.0) THEN\r
+  CALL FM_READ_ERR("FMREADX3_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)\r
+ENDIF\r
+IF (GALLOC) DEALLOCATE (ZFIELDP)\r
+IF (GALLOC_ll) DEALLOCATE (ZSLIDE_ll)\r
+!IF (ASSOCIATED(ZSLIDE_ll)) DEALLOCATE (ZSLIDE_ll)\r
+KRESP = IRESP\r
+CALL MPI_BARRIER(TZFD%COMM,IERR)\r
+CALL SECOND_MNH2(T22)\r
+TIMEZ%T_READ3D_ALL=TIMEZ%T_READ3D_ALL + T22 - T11\r
+\r
+!------------------------------------------------------------------\r
+END SUBROUTINE FMREADX3_ll\r
+\r
+SUBROUTINE FMREADX4_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&\r
+     KLENCH,HCOMMENT,KRESP)\r
+USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LPACK,L1D,L2D \r
+USE MODD_PARAMETERS_ll,ONLY : JPHEXT\r
+USE MODD_FM\r
+USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL\r
+USE MODE_SCATTER_ll\r
+USE MODE_ALLOCBUFFER_ll\r
+\r
+CHARACTER(LEN=*),              INTENT(IN) ::HFILEM   ! FM-file name\r
+CHARACTER(LEN=*),              INTENT(IN) ::HRECFM   ! name of the article to read\r
+CHARACTER(LEN=*),              INTENT(IN) ::HFIPRI   ! output file for error messages\r
+CHARACTER(LEN=*),              INTENT(IN) ::HDIR     ! field form\r
+REAL,DIMENSION(:,:,:,:),TARGET,INTENT(INOUT)::PFIELD   ! array containing the data field\r
+INTEGER,                       INTENT(INOUT)::KGRID    ! C-grid indicator (u,v,w,T)\r
+INTEGER,                       INTENT(INOUT)::KLENCH   ! length of comment string\r
+CHARACTER(LEN=*),              INTENT(INOUT)::HCOMMENT ! comment string\r
+INTEGER,                       INTENT(INOUT)::KRESP  ! return-code if\r
+!\r
+!\r
+!*      0.2   Declarations of local variables\r
+!\r
+CHARACTER(LEN=JPFINL)           :: YFNLFI\r
+INTEGER                         :: IERR\r
+TYPE(FD_ll), POINTER            :: TZFD\r
+INTEGER                         :: IRESP\r
+REAL,DIMENSION(:,:,:,:),POINTER :: ZFIELDP\r
+LOGICAL                         :: GALLOC\r
+TYPE(FMHEADER)                  :: TZFMH\r
+INTEGER                         :: IHEXTOT\r
+!\r
+!*      1.1   THE NAME OF LFIFM\r
+!\r
+GALLOC = .FALSE.\r
+IRESP = 0\r
+YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'\r
+!------------------------------------------------------------------\r
+IHEXTOT = 2*JPHEXT+1\r
+TZFD=>GETFD(YFNLFI)\r
+IF (ASSOCIATED(TZFD)) THEN\r
+  IF (GSMONOPROC) THEN ! sequential execution\r
+!    IF (LPACK .AND. L1D .AND. HDIR=='XY') THEN \r
+    IF (LPACK .AND. L1D .AND. SIZE(PFIELD,1)==IHEXTOT .AND. SIZE(PFIELD,2)==IHEXTOT) THEN\r
+      ZFIELDP=>PFIELD(JPHEXT+1:JPHEXT+1,JPHEXT+1:JPHEXT+1,:,:)\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)\r
+      END IF\r
+      PFIELD(:,:,:,:)=SPREAD(SPREAD(PFIELD(JPHEXT+1,JPHEXT+1,:,:),DIM=1,NCOPIES=IHEXTOT),DIM=2,NCOPIES=IHEXTOT)\r
+!    ELSE IF (LPACK .AND. L2D .AND. HDIR=='XY') THEN\r
+    ELSE IF (LPACK .AND. L2D .AND. SIZE(PFIELD,2)==IHEXTOT) THEN\r
+      ZFIELDP=>PFIELD(:,JPHEXT+1:JPHEXT+1,:,:)\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)\r
+      END IF\r
+      PFIELD(:,:,:,:)=SPREAD(PFIELD(:,JPHEXT+1,:,:),DIM=2,NCOPIES=IHEXTOT)\r
+    ELSE\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,PFIELD,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)\r
+      END IF\r
+    END IF\r
+    IF (IRESP /= 0) GOTO 1000\r
+  ELSE\r
+    IF (ISP == TZFD%OWNER)  THEN\r
+      CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&\r
+           & ,IRESP)\r
+      END IF\r
+    ELSE\r
+      ALLOCATE(ZFIELDP(0,0,0,0))\r
+      GALLOC = .TRUE.\r
+    END IF\r
+    !\r
+    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    IF (IRESP /= 0) GOTO 1000\r
+    !\r
+    CALL BCAST_HEADER(TZFD,TZFMH)\r
+    !\r
+    IF (HDIR == 'XX' .OR. HDIR =='YY') THEN\r
+      ! XX or YY Scatter Field\r
+      CALL SCATTER_XXFIELD(HDIR,ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM) \r
+    ELSE IF (HDIR == 'XY') THEN\r
+      IF (LPACK .AND. L2D) THEN\r
+        ! 2D compact case\r
+        CALL SCATTER_XXFIELD('XX',ZFIELDP(:,1,:,:),PFIELD(:,JPHEXT+1,:,:),TZFD%OWNER,TZFD%COMM)\r
+        PFIELD(:,:,:,:) = SPREAD(PFIELD(:,JPHEXT+1,:,:),DIM=2,NCOPIES=IHEXTOT)\r
+      ELSE\r
+        ! XY Scatter Field\r
+        CALL SCATTER_XYFIELD(ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM)\r
+      END IF\r
+    ELSE\r
+      ! Broadcast Field\r
+      CALL MPI_BCAST(PFIELD,SIZE(PFIELD),MPI_FLOAT,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    END IF\r
+  END IF\r
+  KGRID  = TZFMH%GRID\r
+  KLENCH = TZFMH%COMLEN\r
+  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)\r
+ELSE \r
+  IRESP = -61\r
+END IF\r
+!----------------------------------------------------------------\r
+1000 CONTINUE\r
+!! Error handler\r
+IF (IRESP.NE.0) THEN\r
+  CALL FM_READ_ERR("FMREADX4_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)\r
+ENDIF\r
+\r
+IF (GALLOC) DEALLOCATE (ZFIELDP)\r
+KRESP = IRESP\r
+RETURN\r
+!------------------------------------------------------------------\r
+END SUBROUTINE FMREADX4_ll\r
+\r
+SUBROUTINE FMREADX5_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&\r
+     KLENCH,HCOMMENT,KRESP)\r
+USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LPACK,L1D,L2D \r
+USE MODD_PARAMETERS_ll,ONLY : JPHEXT\r
+USE MODD_FM\r
+USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL\r
+USE MODE_SCATTER_ll\r
+USE MODE_ALLOCBUFFER_ll\r
+\r
+CHARACTER(LEN=*),                INTENT(IN) ::HFILEM ! FM-file name\r
+CHARACTER(LEN=*),                INTENT(IN) ::HRECFM ! name of the article to read\r
+CHARACTER(LEN=*),                INTENT(IN) ::HFIPRI ! output file for error messages\r
+CHARACTER(LEN=*),                INTENT(IN) ::HDIR   ! field form\r
+REAL,DIMENSION(:,:,:,:,:),TARGET,INTENT(INOUT)::PFIELD ! array containing the data field\r
+INTEGER,                         INTENT(INOUT)::KGRID  ! C-grid indicator (u,v,w,T)\r
+INTEGER,                         INTENT(INOUT)::KLENCH ! length of comment string\r
+CHARACTER(LEN=*),                INTENT(INOUT)::HCOMMENT ! comment string\r
+INTEGER,                         INTENT(INOUT)::KRESP  ! return-code\r
+!\r
+!\r
+!*      0.2   Declarations of local variables\r
+!\r
+CHARACTER(LEN=JPFINL)             :: YFNLFI\r
+INTEGER                           :: IERR\r
+TYPE(FD_ll), POINTER              :: TZFD\r
+INTEGER                           :: IRESP\r
+REAL,DIMENSION(:,:,:,:,:),POINTER :: ZFIELDP\r
+LOGICAL                           :: GALLOC\r
+TYPE(FMHEADER)                    :: TZFMH\r
+INTEGER                           :: IHEXTOT\r
+!\r
+!*      1.1   THE NAME OF LFIFM\r
+!\r
+GALLOC = .FALSE.\r
+IRESP = 0\r
+YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'\r
+!------------------------------------------------------------------\r
+IHEXTOT = 2*JPHEXT+1\r
+TZFD=>GETFD(YFNLFI)\r
+IF (ASSOCIATED(TZFD)) THEN\r
+  IF (GSMONOPROC) THEN ! sequential execution\r
+!    IF (LPACK .AND. L1D .AND. HDIR=='XY') THEN \r
+    IF (LPACK .AND. L1D .AND. SIZE(PFIELD,1)==IHEXTOT .AND. SIZE(PFIELD,2)==IHEXTOT) THEN\r
+      ZFIELDP=>PFIELD(JPHEXT+1:JPHEXT+1,JPHEXT+1:JPHEXT+1,:,:,:)\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)\r
+      END IF\r
+      PFIELD(:,:,:,:,:)=SPREAD(SPREAD(PFIELD(JPHEXT+1,JPHEXT+1,:,:,:),DIM=1,NCOPIES=IHEXTOT),DIM=2,NCOPIES=IHEXTOT)\r
+!    ELSE IF (LPACK .AND. L2D .AND. HDIR=='XY') THEN\r
+    ELSE IF (LPACK .AND. L2D .AND. SIZE(PFIELD,2)==IHEXTOT) THEN\r
+      ZFIELDP=>PFIELD(:,JPHEXT+1:JPHEXT+1,:,:,:)\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)\r
+      END IF\r
+      PFIELD(:,:,:,:,:)=SPREAD(PFIELD(:,JPHEXT+1,:,:,:),DIM=2,NCOPIES=IHEXTOT)\r
+    ELSE\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,PFIELD,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)\r
+      END IF\r
+    END IF  \r
+    IF (IRESP /= 0) GOTO 1000\r
+  ELSE ! multiprocessor execution\r
+    IF (ISP == TZFD%OWNER)  THEN\r
+      CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&\r
+           & ,IRESP)\r
+      END IF\r
+    ELSE\r
+      ALLOCATE(ZFIELDP(0,0,0,0,0))\r
+      GALLOC = .TRUE.\r
+    END IF\r
+    !\r
+    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    IF (IRESP /= 0) GOTO 1000\r
+    !\r
+    CALL BCAST_HEADER(TZFD,TZFMH)\r
+    !\r
+    IF (HDIR == 'XX' .OR. HDIR =='YY') THEN\r
+      ! XX or YY Scatter Field\r
+      CALL SCATTER_XXFIELD(HDIR,ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM) \r
+    ELSE IF (HDIR == 'XY') THEN\r
+      IF (LPACK .AND. L2D) THEN\r
+        ! 2D compact case\r
+        CALL SCATTER_XXFIELD('XX',ZFIELDP(:,1,:,:,:),PFIELD(:,JPHEXT+1,:,:,:),&\r
+             & TZFD%OWNER,TZFD%COMM)\r
+        PFIELD(:,:,:,:,:) = SPREAD(PFIELD(:,JPHEXT+1,:,:,:),DIM=2,NCOPIES=IHEXTOT)\r
+      ELSE\r
+        ! XY Scatter Field\r
+        CALL SCATTER_XYFIELD(ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM)\r
+      END IF\r
+    ELSE\r
+      ! Broadcast Field\r
+      CALL MPI_BCAST(PFIELD,SIZE(PFIELD),MPI_FLOAT,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    END IF\r
+  END IF\r
+  KGRID  = TZFMH%GRID\r
+  KLENCH = TZFMH%COMLEN\r
+  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)\r
+ELSE \r
+  IRESP = -61\r
+END IF\r
+!----------------------------------------------------------------\r
+1000 CONTINUE\r
+!! Error handler\r
+IF (IRESP.NE.0) THEN\r
+  CALL FM_READ_ERR("FMREADX5_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)\r
+ENDIF\r
+IF (GALLOC) DEALLOCATE (ZFIELDP)\r
+KRESP = IRESP\r
+RETURN\r
+!------------------------------------------------------------------\r
+END SUBROUTINE FMREADX5_ll\r
+\r
+SUBROUTINE FMREADX6_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&\r
+     KLENCH,HCOMMENT,KRESP)\r
+USE MODD_IO_ll, ONLY : ISP,GSMONOPROC \r
+USE MODD_FM\r
+USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL\r
+USE MODE_SCATTER_ll\r
+USE MODE_ALLOCBUFFER_ll\r
+\r
+CHARACTER(LEN=*),                  INTENT(IN) ::HFILEM ! FM-file name\r
+CHARACTER(LEN=*),                  INTENT(IN) ::HRECFM ! name of the article to read\r
+CHARACTER(LEN=*),                  INTENT(IN) ::HFIPRI ! output file for error messages\r
+CHARACTER(LEN=*),                  INTENT(IN) ::HDIR   ! field form\r
+REAL,DIMENSION(:,:,:,:,:,:),TARGET,INTENT(INOUT)::PFIELD ! array containing the data field\r
+INTEGER,                           INTENT(INOUT)::KGRID  ! C-grid indicator (u,v,w,T)\r
+INTEGER,                           INTENT(INOUT)::KLENCH ! length of comment string\r
+CHARACTER(LEN=*),                  INTENT(INOUT)::HCOMMENT ! comment string\r
+INTEGER,                           INTENT(INOUT)::KRESP  ! return-code\r
+!\r
+!\r
+!*      0.2   Declarations of local variables\r
+!\r
+CHARACTER(LEN=JPFINL)               :: YFNLFI\r
+INTEGER                             :: IERR\r
+TYPE(FD_ll), POINTER                :: TZFD\r
+INTEGER                             :: IRESP\r
+REAL,DIMENSION(:,:,:,:,:,:),POINTER :: ZFIELDP\r
+LOGICAL                             :: GALLOC\r
+TYPE(FMHEADER)                      :: TZFMH\r
+!\r
+!*      1.1   THE NAME OF LFIFM\r
+!\r
+GALLOC = .FALSE.\r
+IRESP = 0\r
+YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'\r
+!------------------------------------------------------------------\r
+TZFD=>GETFD(YFNLFI)\r
+IF (ASSOCIATED(TZFD)) THEN\r
+  IF (GSMONOPROC) THEN ! sequential execution\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,PFIELD,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)\r
+      END IF\r
+    IF (IRESP /= 0) GOTO 1000\r
+  ELSE ! multiprocessor execution\r
+    IF (ISP == TZFD%OWNER)  THEN\r
+      CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,ZFIELDP,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&\r
+           & ,IRESP)\r
+      END IF\r
+    ELSE\r
+      ALLOCATE(ZFIELDP(0,0,0,0,0,0))\r
+      GALLOC = .TRUE.\r
+    END IF\r
+    !\r
+    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    IF (IRESP /= 0) GOTO 1000\r
+    !\r
+    CALL BCAST_HEADER(TZFD,TZFMH)\r
+    !\r
+    IF (HDIR == 'XX' .OR. HDIR =='YY') THEN\r
+      ! XX or YY Scatter Field\r
+      CALL SCATTER_XXFIELD(HDIR,ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM) \r
+    ELSE IF (HDIR == 'XY') THEN\r
+      ! XY Scatter Field\r
+      CALL SCATTER_XYFIELD(ZFIELDP,PFIELD,TZFD%OWNER,TZFD%COMM)\r
+    ELSE\r
+      ! Broadcast Field\r
+      CALL MPI_BCAST(PFIELD,SIZE(PFIELD),MPI_FLOAT,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    END IF\r
+  END IF\r
+  KGRID  = TZFMH%GRID\r
+  KLENCH = TZFMH%COMLEN\r
+  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)\r
+ELSE \r
+  IRESP = -61\r
+END IF\r
+!----------------------------------------------------------------\r
+1000 CONTINUE\r
+!! Error handler\r
+IF (IRESP.NE.0) THEN\r
+  CALL FM_READ_ERR("FMREADX6_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)\r
+ENDIF\r
+IF (GALLOC) DEALLOCATE (ZFIELDP)\r
+KRESP = IRESP\r
+RETURN\r
+!------------------------------------------------------------------\r
+END SUBROUTINE FMREADX6_ll\r
+\r
+SUBROUTINE FMREADN0_ll(HFILEM,HRECFM,HFIPRI,HDIR,KFIELD,KGRID,&\r
+     KLENCH,HCOMMENT,KRESP)\r
+USE MODD_IO_ll, ONLY : ISP,GSMONOPROC \r
+USE MODD_FM\r
+USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL\r
+\r
+!\r
+!*      0.    DECLARATIONS\r
+!             ------------\r
+!\r
+!\r
+!*      0.1   Declarations of arguments\r
+!\r
+CHARACTER(LEN=*),          INTENT(IN) ::HFILEM   ! FM-file name\r
+CHARACTER(LEN=*),          INTENT(IN) ::HRECFM   ! name of the article to read\r
+CHARACTER(LEN=*),          INTENT(IN) ::HFIPRI   ! output file for error messages\r
+CHARACTER(LEN=*),          INTENT(IN) ::HDIR     ! Field form\r
+INTEGER,                   INTENT(INOUT)::KFIELD ! array containing the data field     \r
+INTEGER,                   INTENT(INOUT)::KGRID    ! C-grid indicator (u,v,w,T)\r
+INTEGER,                   INTENT(INOUT)::KLENCH   ! length of comment string\r
+CHARACTER(LEN=*),          INTENT(INOUT)::HCOMMENT ! comment string\r
+INTEGER,                   INTENT(INOUT)::KRESP    ! return-code\r
+!\r
+!*      0.2   Declarations of local variables\r
+!\r
+CHARACTER(LEN=JPFINL)        :: YFNLFI\r
+INTEGER                      :: IERR\r
+TYPE(FD_ll), POINTER         :: TZFD\r
+INTEGER                      :: IRESP\r
+TYPE(FMHEADER)               :: TZFMH\r
+\r
+!\r
+!*      1.1   THE NAME OF LFIFM\r
+!\r
+IRESP = 0\r
+YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'\r
+!  \r
+TZFD=>GETFD(YFNLFI)\r
+IF (ASSOCIATED(TZFD)) THEN\r
+  IF (GSMONOPROC) THEN ! sequential execution\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,KFIELD,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,1,KFIELD,TZFMH,IRESP)\r
+      END IF\r
+    IF (IRESP /= 0) GOTO 1000\r
+  ELSE\r
+    IF (ISP == TZFD%OWNER)  THEN\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,KFIELD,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,1,KFIELD,TZFMH,IRESP)\r
+      END IF\r
+    END IF\r
+    !\r
+    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    IF (IRESP /= 0) GOTO 1000\r
+    !\r
+    CALL BCAST_HEADER(TZFD,TZFMH)       \r
+    !\r
+    CALL MPI_BCAST(KFIELD,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+  END IF\r
+  KGRID  = TZFMH%GRID\r
+  KLENCH = TZFMH%COMLEN\r
+  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)\r
+ELSE \r
+  IRESP = -61\r
+END IF\r
+!----------------------------------------------------------------\r
+1000 CONTINUE\r
+!! Error handler\r
+IF (IRESP.NE.0) THEN\r
+  CALL FM_READ_ERR("FMREADN0_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)\r
+ENDIF\r
+KRESP = IRESP\r
+RETURN\r
+\r
+END SUBROUTINE FMREADN0_ll\r
+\r
+SUBROUTINE FMREADN1_ll(HFILEM,HRECFM,HFIPRI,HDIR,KFIELD,KGRID,&\r
+     KLENCH,HCOMMENT,KRESP)\r
+USE MODD_IO_ll, ONLY : ISP,GSMONOPROC\r
+USE MODD_FM\r
+USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL\r
+USE MODE_SCATTER_ll\r
+USE MODE_ALLOCBUFFER_ll\r
+\r
+!*      0.    DECLARATIONS\r
+!             ------------\r
+!\r
+!\r
+!*      0.1   Declarations of arguments\r
+!\r
+CHARACTER(LEN=*),           INTENT(IN) ::HFILEM   ! FM-file name\r
+CHARACTER(LEN=*),           INTENT(IN) ::HRECFM   ! name of the article to read\r
+CHARACTER(LEN=*),           INTENT(IN) ::HFIPRI   ! output file for error messages\r
+CHARACTER(LEN=*),           INTENT(IN) ::HDIR     ! Field form\r
+INTEGER,DIMENSION(:),TARGET,INTENT(INOUT)::KFIELD ! array containing the data field     \r
+INTEGER,                    INTENT(INOUT)::KGRID    ! C-grid indicator (u,v,w,T)\r
+INTEGER,                    INTENT(INOUT)::KLENCH   ! length of comment string\r
+CHARACTER(LEN=*),           INTENT(INOUT)::HCOMMENT ! comment string\r
+INTEGER,                    INTENT(INOUT)::KRESP    ! return-code\r
+!\r
+!*      0.2   Declarations of local variables\r
+!\r
+CHARACTER(LEN=JPFINL)            :: YFNLFI\r
+INTEGER                          :: IERR\r
+TYPE(FD_ll), POINTER             :: TZFD\r
+INTEGER                          :: IRESP\r
+INTEGER,DIMENSION(:),POINTER     :: IFIELDP\r
+LOGICAL                          :: GALLOC\r
+TYPE(FMHEADER)                   :: TZFMH\r
+!\r
+!*      1.1   THE NAME OF LFIFM\r
+!\r
+GALLOC = .FALSE.\r
+IRESP = 0\r
+YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'\r
+!------------------------------------------------------------------\r
+TZFD=>GETFD(YFNLFI)\r
+IF (ASSOCIATED(TZFD)) THEN\r
+  IF (GSMONOPROC) THEN ! sequential execution\r
+    IF (ASSOCIATED(TZFD%CDF)) THEN\r
+       CALL NCREAD(TZFD%CDF%NCID,HRECFM,KFIELD,TZFMH,IRESP)\r
+    ELSE\r
+       CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(KFIELD),KFIELD,TZFMH,IRESP)\r
+    END IF\r
+    IF (IRESP /= 0) GOTO 1000\r
+  ELSE\r
+    IF (ISP == TZFD%OWNER)  THEN\r
+      CALL ALLOCBUFFER_ll(IFIELDP,KFIELD,HDIR,GALLOC)\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,IFIELDP,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELDP),IFIELDP,TZFMH&\r
+           & ,IRESP)\r
+      END IF\r
+    ELSE\r
+      ALLOCATE(IFIELDP(0))\r
+      GALLOC = .TRUE.\r
+    END IF\r
+    !\r
+    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    IF (IRESP /= 0) GOTO 1000\r
+    !\r
+    CALL BCAST_HEADER(TZFD,TZFMH)\r
+    !\r
+    IF (HDIR /= 'XX' .AND. HDIR /='YY') THEN\r
+      ! Broadcast Field\r
+      CALL MPI_BCAST(KFIELD,SIZE(KFIELD),MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    ELSE \r
+      !Scatter Field\r
+      CALL SCATTER_XXFIELD(HDIR,IFIELDP,KFIELD,TZFD%OWNER,TZFD%COMM) \r
+    END IF\r
+  END IF\r
+  KGRID  = TZFMH%GRID\r
+  KLENCH = TZFMH%COMLEN\r
+  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)\r
+ELSE \r
+  IRESP = -61\r
+END IF\r
+!----------------------------------------------------------------\r
+1000 CONTINUE\r
+!! Error handler\r
+IF (IRESP.NE.0) THEN\r
+  CALL FM_READ_ERR("FMREADN1_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)\r
+ENDIF\r
+IF (GALLOC) DEALLOCATE (IFIELDP)\r
+KRESP = IRESP\r
+RETURN\r
+  \r
+END SUBROUTINE FMREADN1_ll\r
+\r
+SUBROUTINE FMREADN2_ll(HFILEM,HRECFM,HFIPRI,HDIR,KFIELD,KGRID,&\r
+     KLENCH,HCOMMENT,KRESP)\r
+USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LPACK,L1D,L2D \r
+USE MODD_PARAMETERS_ll,ONLY : JPHEXT\r
+USE MODD_FM\r
+USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL\r
+USE MODE_SCATTER_ll\r
+USE MODE_ALLOCBUFFER_ll\r
+\r
+CHARACTER(LEN=*),              INTENT(IN) ::HFILEM ! FM-file name\r
+CHARACTER(LEN=*),              INTENT(IN) ::HRECFM ! name of the article to read\r
+CHARACTER(LEN=*),              INTENT(IN) ::HFIPRI ! output file for error messages\r
+CHARACTER(LEN=*),              INTENT(IN) ::HDIR   ! field form\r
+INTEGER, DIMENSION(:,:),TARGET,INTENT(INOUT)::KFIELD ! array containing the data field\r
+INTEGER,                       INTENT(INOUT)::KGRID  ! C-grid indicator (u,v,w,T)\r
+INTEGER,                       INTENT(INOUT)::KLENCH ! length of comment string\r
+CHARACTER(LEN=*),              INTENT(INOUT)::HCOMMENT ! comment string\r
+INTEGER,                       INTENT(INOUT)::KRESP  ! return-code\r
+!\r
+!\r
+!*      0.2   Declarations of local variables\r
+!\r
+CHARACTER(LEN=JPFINL)          :: YFNLFI\r
+INTEGER                        :: IERR\r
+TYPE(FD_ll), POINTER           :: TZFD\r
+INTEGER                        :: IRESP\r
+INTEGER,DIMENSION(:,:),POINTER :: IFIELDP\r
+LOGICAL                        :: GALLOC\r
+TYPE(FMHEADER)                 :: TZFMH\r
+INTEGER                        :: IHEXTOT\r
+!\r
+!*      1.1   THE NAME OF LFIFM\r
+!\r
+GALLOC = .FALSE.\r
+IRESP = 0\r
+YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'\r
+!------------------------------------------------------------------\r
+IHEXTOT = 2*JPHEXT+1\r
+TZFD=>GETFD(YFNLFI)\r
+IF (ASSOCIATED(TZFD)) THEN\r
+  IF (GSMONOPROC) THEN ! sequential execution\r
+!    IF (LPACK .AND. L1D .AND. HDIR=='XY') THEN \r
+    IF (LPACK .AND. L1D .AND. SIZE(KFIELD,1)==IHEXTOT .AND. SIZE(KFIELD,2)==IHEXTOT) THEN\r
+      IFIELDP=>KFIELD(JPHEXT+1:JPHEXT+1,JPHEXT+1:JPHEXT+1)\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,IFIELDP,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELDP),IFIELDP,TZFMH,IRESP)\r
+      END IF\r
+      KFIELD(:,:)=SPREAD(SPREAD(KFIELD(JPHEXT+1,JPHEXT+1),DIM=1,NCOPIES=IHEXTOT),DIM=2,NCOPIES=IHEXTOT)\r
+!    ELSE IF (LPACK .AND. L2D .AND. HDIR=='XY') THEN\r
+    ELSE IF (LPACK .AND. L2D .AND. SIZE(KFIELD,2)==IHEXTOT) THEN\r
+      IFIELDP=>KFIELD(:,JPHEXT+1:JPHEXT+1)\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,IFIELDP,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELDP),IFIELDP,TZFMH,IRESP)\r
+      END IF\r
+      KFIELD(:,:)=SPREAD(KFIELD(:,JPHEXT+1),DIM=2,NCOPIES=IHEXTOT)\r
+    ELSE\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,KFIELD,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(KFIELD),KFIELD,TZFMH,IRESP)\r
+      END IF\r
+    END IF\r
+    IF (IRESP /= 0) GOTO 1000\r
+  ELSE\r
+    IF (ISP == TZFD%OWNER)  THEN\r
+      CALL ALLOCBUFFER_ll(IFIELDP,KFIELD,HDIR,GALLOC)\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,IFIELDP,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELDP),IFIELDP&\r
+           & ,TZFMH,IRESP)\r
+      END IF\r
+    ELSE\r
+      ALLOCATE(IFIELDP(0,0))\r
+      GALLOC = .TRUE.\r
+    END IF\r
+    !\r
+    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    IF (IRESP /= 0) GOTO 1000\r
+    !\r
+    CALL BCAST_HEADER(TZFD,TZFMH)\r
+    !\r
+    IF (HDIR == 'XX' .OR. HDIR =='YY') THEN\r
+      ! XX or YY Scatter Field\r
+      CALL SCATTER_XXFIELD(HDIR,IFIELDP,KFIELD,TZFD%OWNER,TZFD&\r
+           & %COMM) \r
+    ELSE IF (HDIR == 'XY') THEN\r
+      IF (LPACK .AND. L2D) THEN\r
+        ! 2D compact case\r
+        CALL SCATTER_XXFIELD('XX',IFIELDP(:,1),KFIELD(:,JPHEXT+1),TZFD%OWNER,TZFD%COMM)\r
+        KFIELD(:,:) = SPREAD(KFIELD(:,JPHEXT+1),DIM=2,NCOPIES=IHEXTOT)\r
+      ELSE\r
+        ! XY Scatter Field\r
+        CALL SCATTER_XYFIELD(IFIELDP,KFIELD,TZFD%OWNER,TZFD%COMM)\r
+      END IF\r
+    ELSE\r
+      ! Broadcast Field\r
+      IF (ISP == TZFD%OWNER) KFIELD = IFIELDP\r
+      CALL MPI_BCAST(KFIELD,SIZE(KFIELD),MPI_INTEGER,TZFD%OWNER-1&\r
+           & ,TZFD%COMM,IERR)\r
+    END IF\r
+  END IF\r
+  KGRID  = TZFMH%GRID\r
+  KLENCH = TZFMH%COMLEN\r
+  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)\r
+ELSE \r
+  IRESP = -61\r
+END IF\r
+!----------------------------------------------------------------\r
+1000 CONTINUE\r
+!! Error handler\r
+IF (IRESP.NE.0) THEN\r
+  CALL FM_READ_ERR("FMREADN2_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)\r
+ENDIF\r
+!\r
+IF (GALLOC) DEALLOCATE (IFIELDP)\r
+KRESP = IRESP\r
+RETURN\r
+!------------------------------------------------------------------\r
+END SUBROUTINE FMREADN2_ll\r
+\r
+\r
+SUBROUTINE FMREADL0_ll(HFILEM,HRECFM,HFIPRI,HDIR,OFIELD,KGRID,&\r
+     KLENCH,HCOMMENT,KRESP)\r
+USE MODD_IO_ll, ONLY : ISP,GSMONOPROC \r
+USE MODD_FM\r
+USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL\r
+\r
+!*      0.    DECLARATIONS\r
+!             ------------\r
+!\r
+!\r
+!*      0.1   Declarations of arguments\r
+!\r
+CHARACTER(LEN=*),          INTENT(IN) ::HFILEM ! FM-file name\r
+CHARACTER(LEN=*),          INTENT(IN) ::HRECFM ! name of the article to read\r
+CHARACTER(LEN=*),          INTENT(IN) ::HFIPRI ! output file for error messages\r
+CHARACTER(LEN=*),          INTENT(IN) ::HDIR   ! field form\r
+LOGICAL,                   INTENT(INOUT)::OFIELD ! array containing the data field\r
+INTEGER,                   INTENT(INOUT)::KGRID  ! C-grid indicator (u,v,w,T)\r
+INTEGER,                   INTENT(INOUT)::KLENCH ! length of comment string\r
+CHARACTER(LEN=*),          INTENT(INOUT)::HCOMMENT ! comment string\r
+INTEGER,                   INTENT(INOUT)::KRESP    ! return-code\r
+!\r
+!*      0.2   Declarations of local variables\r
+!\r
+CHARACTER(LEN=JPFINL)        :: YFNLFI\r
+INTEGER                      :: IERR\r
+TYPE(FD_ll), POINTER         :: TZFD\r
+INTEGER                      :: IRESP\r
+INTEGER                      :: IFIELD\r
+TYPE(FMHEADER)               :: TZFMH\r
+\r
+!\r
+!*      1.1   THE NAME OF LFIFM\r
+!\r
+IRESP = 0\r
+YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'\r
+!------------------------------------------------------------------\r
+TZFD=>GETFD(YFNLFI)\r
+IF (ASSOCIATED(TZFD)) THEN\r
+  IF (GSMONOPROC) THEN ! sequential execution\r
+    IF (ASSOCIATED(TZFD%CDF)) THEN\r
+       CALL NCREAD(TZFD%CDF%NCID,HRECFM,IFIELD,TZFMH,IRESP)\r
+    ELSE\r
+       CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,1,IFIELD,TZFMH,IRESP)\r
+    END IF\r
+    IF (IRESP /= 0) GOTO 1000\r
+  ELSE\r
+    IF (ISP == TZFD%OWNER)  THEN\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,IFIELD,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,1,IFIELD,TZFMH,IRESP)\r
+      END IF\r
+    END IF\r
+    !\r
+    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    IF (IRESP /= 0) GOTO 1000\r
+    !\r
+    CALL BCAST_HEADER(TZFD,TZFMH)\r
+    !\r
+    CALL MPI_BCAST(IFIELD,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,&\r
+         & IERR)\r
+  END IF\r
+  IF (IFIELD==1) THEN\r
+    OFIELD=.TRUE.\r
+  ELSE\r
+    OFIELD=.FALSE.\r
+  END IF\r
+  KGRID  = TZFMH%GRID\r
+  KLENCH = TZFMH%COMLEN\r
+  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)\r
+ELSE \r
+  IRESP = -61\r
+END IF\r
+!----------------------------------------------------------------\r
+1000 CONTINUE\r
+!! Error handler\r
+IF (IRESP.NE.0) THEN\r
+  CALL FM_READ_ERR("FMREADL0_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)\r
+ENDIF\r
+KRESP = IRESP\r
+RETURN\r
+\r
+END SUBROUTINE FMREADL0_ll\r
+\r
+SUBROUTINE FMREADL1_ll(HFILEM,HRECFM,HFIPRI,HDIR,OFIELD,KGRID,&\r
+     KLENCH,HCOMMENT,KRESP)\r
+USE MODD_IO_ll, ONLY : ISP,GSMONOPROC \r
+USE MODD_FM\r
+USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL\r
+!\r
+!*      0.    DECLARATIONS\r
+!             ------------\r
+!\r
+IMPLICIT NONE\r
+!\r
+!*      0.1   Declarations of arguments\r
+!\r
+CHARACTER(LEN=*),          INTENT(IN) ::HFILEM  ! FM-file name\r
+CHARACTER(LEN=*),          INTENT(IN) ::HRECFM  ! name of the article to read\r
+CHARACTER(LEN=*),          INTENT(IN) ::HFIPRI  ! output file for error messages\r
+CHARACTER(LEN=*),          INTENT(IN) ::HDIR    ! Field form\r
+LOGICAL, DIMENSION(:),     INTENT(INOUT)::OFIELD  ! array containing the data field\r
+INTEGER,                   INTENT(INOUT)::KGRID    ! C-grid indicator (u,v,w,T)\r
+INTEGER,                   INTENT(INOUT)::KLENCH   ! length of comment string\r
+CHARACTER(LEN=*),          INTENT(INOUT)::HCOMMENT ! comment string\r
+INTEGER,                   INTENT(INOUT)::KRESP    ! return-code\r
+!\r
+!*      0.2   Declarations of local variables\r
+!\r
+\r
+CHARACTER(LEN=JPFINL)            :: YFNLFI\r
+INTEGER                          :: IERR\r
+TYPE(FD_ll), POINTER             :: TZFD\r
+INTEGER                          :: IRESP\r
+INTEGER, DIMENSION(SIZE(OFIELD)) :: IFIELD\r
+TYPE(FMHEADER)                   :: TZFMH\r
+\r
+!\r
+!*      1.1   THE NAME OF LFIFM\r
+!\r
+IRESP = 0\r
+YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'\r
+!\r
+TZFD=>GETFD(YFNLFI)\r
+IF (ASSOCIATED(TZFD)) THEN\r
+  IF (GSMONOPROC) THEN ! sequential execution\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,IFIELD,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELD),IFIELD,TZFMH&\r
+         & ,IRESP)\r
+      END IF\r
+    IF (IRESP /= 0) GOTO 1000\r
+  ELSE\r
+    IF (ISP == TZFD%OWNER)  THEN\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,IFIELD,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELD),IFIELD,TZFMH&\r
+           & ,IRESP)\r
+      END IF\r
+    END IF\r
+    !\r
+    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    IF (IRESP /= 0) GOTO 1000\r
+    !\r
+    CALL BCAST_HEADER(TZFD,TZFMH)\r
+    !\r
+    CALL MPI_BCAST(IFIELD,SIZE(IFIELD),MPI_INTEGER,TZFD%OWNER-1,TZFD&\r
+       & %COMM,IERR)\r
+  END IF\r
+  WHERE (IFIELD==1)\r
+    OFIELD=.TRUE.\r
+  ELSEWHERE\r
+    OFIELD=.FALSE.\r
+  END WHERE\r
+  KGRID  = TZFMH%GRID\r
+  KLENCH = TZFMH%COMLEN\r
+  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)\r
+ELSE \r
+  IRESP = -61\r
+END IF\r
+!----------------------------------------------------------------\r
+1000 CONTINUE\r
+!! Error handler\r
+IF (IRESP.NE.0) THEN\r
+  CALL FM_READ_ERR("FMREADL1_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)\r
+ENDIF\r
+KRESP = IRESP\r
+RETURN\r
+\r
+END SUBROUTINE FMREADL1_ll\r
+\r
+SUBROUTINE FMREADC0_ll(HFILEM,HRECFM,HFIPRI,HDIR,HFIELD,KGRID,&\r
+     KLENCH,HCOMMENT,KRESP)\r
+USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIREAD\r
+USE MODD_FM\r
+USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL\r
+!\r
+!*      0.    DECLARATIONS\r
+!             ------------\r
+!\r
+!\r
+!*      0.1   Declarations of arguments\r
+!\r
+CHARACTER(LEN=*),          INTENT(IN) ::HFILEM   ! FM-file name\r
+CHARACTER(LEN=*),          INTENT(IN) ::HRECFM   ! name of the article to read\r
+CHARACTER(LEN=*),          INTENT(IN) ::HFIPRI   ! output file for error messages\r
+CHARACTER(LEN=*),          INTENT(IN) ::HDIR     ! Field form\r
+CHARACTER(LEN=*),          INTENT(INOUT)::HFIELD   ! array containing the data field    \r
+INTEGER,                   INTENT(INOUT)::KGRID    ! C-grid indicator (u,v,w,T)\r
+INTEGER,                   INTENT(INOUT)::KLENCH   ! length of comment string\r
+CHARACTER(LEN=*),          INTENT(INOUT)::HCOMMENT ! comment string\r
+INTEGER,                   INTENT(INOUT)::KRESP    ! return-code\r
+!\r
+!*      0.2   Declarations of local variables\r
+!\r
+CHARACTER(LEN=JPFINL)             :: YFNLFI\r
+INTEGER                           :: IERR\r
+TYPE(FD_ll), POINTER              :: TZFD\r
+INTEGER                           :: IRESP\r
+INTEGER                           :: JLOOP\r
+INTEGER, DIMENSION(LEN(HFIELD))   :: IFIELD\r
+CHARACTER(LEN(HFIELD))            :: YFIELD\r
+INTEGER                           :: ILENG\r
+TYPE(FMHEADER)                    :: TZFMH\r
+\r
+!\r
+!*      1.1   THE NAME OF LFIFM\r
+!\r
+IRESP = 0\r
+YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'\r
+ILENG=LEN(HFIELD)\r
+!\r
+TZFD=>GETFD(YFNLFI)\r
+IF (ASSOCIATED(TZFD)) THEN\r
+  IF (GSMONOPROC) THEN  ! sequential execution\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,YFIELD,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,ILENG,IFIELD,TZFMH,IRESP)\r
+      END IF\r
+    IF (IRESP /= 0) GOTO 1000\r
+  ELSE ! parallel execution\r
+    IF (ISP == TZFD%OWNER)  THEN\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,YFIELD,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.FALSE.,ILENG,IFIELD,TZFMH,IRESP)\r
+      END IF\r
+    END IF\r
+    !\r
+    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    IF (IRESP /= 0) GOTO 1000\r
+    !\r
+    CALL BCAST_HEADER(TZFD,TZFMH)\r
+    !\r
+    IF (LIOCDF4 .AND. .NOT. LLFIREAD) THEN\r
+       ! NetCDF\r
+       CALL MPI_BCAST(YFIELD,ILENG,MPI_CHARACTER,TZFD%OWNER-1,TZFD%COMM,&\r
+            &IERR)\r
+    ELSE \r
+       ! LFI\r
+       CALL MPI_BCAST(IFIELD,ILENG,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,&\r
+            & IERR)\r
+    END IF\r
+  END IF ! parallel execution\r
+  !\r
+  IF (LIOCDF4 .AND. .NOT. LLFIREAD) THEN\r
+     ! NetCDF\r
+     HFIELD = YFIELD\r
+  ELSE\r
+     ! LFI Case\r
+     DO JLOOP=1,ILENG\r
+        HFIELD(JLOOP:JLOOP)=ACHAR(IFIELD(JLOOP))\r
+     END DO\r
+  END IF\r
+  KGRID  = TZFMH%GRID\r
+  KLENCH = TZFMH%COMLEN\r
+  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)\r
+ELSE \r
+  IRESP = -61\r
+END IF\r
+!----------------------------------------------------------------\r
+1000 CONTINUE\r
+!! Error handler\r
+IF (IRESP.NE.0) THEN\r
+  CALL FM_READ_ERR("FMREADC0_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)\r
+ENDIF\r
+KRESP = IRESP\r
+RETURN\r
+\r
+END SUBROUTINE FMREADC0_ll\r
+\r
+SUBROUTINE FMREADT0_ll(HFILEM,HRECFM,HFIPRI,HDIR,TFIELD,KGRID,&\r
+                           KLENCH,HCOMMENT,KRESP)\r
+!*      0.    DECLARATIONS\r
+!             ------------\r
+!\r
+USE MODD_IO_ll, ONLY : ISP,GSMONOPROC \r
+USE MODD_TYPE_DATE\r
+USE MODD_FM\r
+USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL\r
+!\r
+!*      0.1   Declarations of arguments\r
+!\r
+CHARACTER(LEN=*),          INTENT(IN) ::HFILEM   ! FM-file name\r
+CHARACTER(LEN=*),          INTENT(IN) ::HRECFM   ! name of the article to read\r
+CHARACTER(LEN=*),          INTENT(IN) ::HFIPRI   ! output file for error messages\r
+CHARACTER(LEN=*),          INTENT(IN) ::HDIR     ! Field form\r
+TYPE (DATE_TIME),          INTENT(INOUT)::TFIELD ! array containing the data field\r
+INTEGER,                   INTENT(INOUT)::KGRID    ! C-grid indicator (u,v,w,T)\r
+INTEGER,                   INTENT(INOUT)::KLENCH   ! length of comment string\r
+CHARACTER(LEN=*),          INTENT(INOUT)::HCOMMENT ! comment string\r
+INTEGER,                   INTENT(INOUT)::KRESP    ! return-code\r
+!\r
+!\r
+!*      0.2   Declarations of local variables\r
+!\r
+!-------------------------------------------------------------------------------\r
+\r
+\r
+CHARACTER(LEN=JPFINL)        :: YFNLFI\r
+INTEGER                      :: IERR\r
+TYPE(FD_ll), POINTER         :: TZFD\r
+INTEGER                      :: IRESP\r
+INTEGER,DIMENSION(3)         :: ITDATE\r
+REAL                         :: ZTIME\r
+TYPE(FMHEADER)               :: TZFMH\r
+\r
+!\r
+!*      1.1   THE NAME OF LFIFM\r
+!\r
+IRESP = 0\r
+\r
+YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'\r
+\r
+TZFD=>GETFD(YFNLFI)\r
+IF (ASSOCIATED(TZFD)) THEN\r
+  IF (GSMONOPROC) THEN ! sequential execution\r
+    IF (ASSOCIATED(TZFD%CDF)) THEN\r
+       CALL NCREAD(TZFD%CDF%NCID,TRIM(HRECFM)//'%TDATE',ITDATE,TZFMH,IRESP)\r
+       CALL NCREAD(TZFD%CDF%NCID,TRIM(HRECFM)//'%TIME',ZTIME,TZFMH,IRESP)\r
+    ELSE\r
+       CALL FM_READ_ll(TZFD%FLU,TRIM(HRECFM)//'%TDATE',.FALSE.,3,ITDATE&\r
+       & ,TZFMH,IRESP)\r
+       CALL FM_READ_ll(TZFD%FLU,TRIM(HRECFM)//'%TIME',.TRUE.,1,ZTIME&\r
+       & ,TZFMH,IRESP)\r
+    END IF\r
+    IF (IRESP /= 0) GOTO 1000\r
+  ELSE\r
+    IF (ISP == TZFD%OWNER)  THEN\r
+       IF (ASSOCIATED(TZFD%CDF)) THEN\r
+          CALL NCREAD(TZFD%CDF%NCID,TRIM(HRECFM)//'%TDATE',ITDATE,TZFMH,IRESP)\r
+          CALL NCREAD(TZFD%CDF%NCID,TRIM(HRECFM)//'%TIME',ZTIME,TZFMH,IRESP)\r
+       ELSE\r
+          CALL FM_READ_ll(TZFD%FLU,TRIM(HRECFM)//'%TDATE',.FALSE.,3,ITDATE&\r
+               & ,TZFMH,IRESP)\r
+          CALL FM_READ_ll(TZFD%FLU,TRIM(HRECFM)//'%TIME',.TRUE.,1,ZTIME&\r
+               & ,TZFMH,IRESP)\r
+\r
+       END IF\r
+    END IF\r
+    !\r
+    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    IF (IRESP /= 0) GOTO 1000\r
+    ! Last header is significant\r
+    CALL BCAST_HEADER(TZFD,TZFMH)      \r
+    !\r
+    CALL MPI_BCAST(ITDATE,3,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    CALL MPI_BCAST(ZTIME,1,MPI_FLOAT,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+  END IF\r
+  TFIELD%TDATE = DATE(ITDATE(1),ITDATE(2),ITDATE(3))\r
+  TFIELD%TIME = ZTIME\r
+  KGRID  = TZFMH%GRID\r
+  KLENCH = TZFMH%COMLEN\r
+  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)\r
+ELSE \r
+  IRESP = -61\r
+END IF\r
+!----------------------------------------------------------------\r
+1000 CONTINUE\r
+!! Error handler\r
+IF (IRESP.NE.0) THEN\r
+  CALL FM_READ_ERR("FMREADT0_ll",HFILEM,HFIPRI,HRECFM,HDIR,IRESP)\r
+ENDIF\r
+KRESP = IRESP\r
+RETURN\r
+\r
+END SUBROUTINE FMREADT0_ll\r
+\r
+SUBROUTINE FMREAD_LB(HFILEM,HRECFM,HFIPRI,HLBTYPE,PLB,KRIM,KL3D,&\r
+     & KGRID,KLENCH,HCOMMENT,KRESP)\r
+USE MODD_FM\r
+USE MODD_IO_ll,        ONLY : ISP,ISNPROC,GSMONOPROC,LPACK,L2D \r
+USE MODD_PARAMETERS_ll,ONLY : JPHEXT\r
+USE MODE_DISTRIB_LB\r
+USE MODE_TOOLS_ll,     ONLY : GET_GLOBALDIMS_ll\r
+USE MODE_FD_ll,        ONLY : GETFD,JPFINL,FD_LL\r
+!JUANZ\r
+USE MODD_TIMEZ, ONLY : TIMEZ\r
+USE MODE_MNH_TIMING, ONLY : SECOND_MNH2\r
+!JUANZ\r
+USE MODD_VAR_ll, ONLY : MNH_STATUSES_IGNORE\r
+\r
+CHARACTER(LEN=*),     INTENT(IN) ::HFILEM   ! file name\r
+CHARACTER(LEN=*),     INTENT(IN) ::HRECFM   ! name of the article to be written\r
+CHARACTER(LEN=*),     INTENT(IN) ::HFIPRI   ! file for prints\r
+CHARACTER(LEN=*),     INTENT(IN) ::HLBTYPE  ! 'LBX','LBXU','LBY' or 'LBYV'\r
+REAL, DIMENSION(:,:,:),TARGET, INTENT(INOUT)::PLB ! array containing the LB field\r
+INTEGER,              INTENT(IN) :: KRIM  ! size of the LB area\r
+INTEGER,              INTENT(IN) :: KL3D  ! size of the LB array in FM\r
+INTEGER,              INTENT(INOUT)::KGRID  ! C-grid indicator (u,v,w,T)\r
+INTEGER,              INTENT(INOUT)::KLENCH ! length of comment string\r
+CHARACTER(LEN=*),     INTENT(INOUT)::HCOMMENT ! comment string\r
+INTEGER,              INTENT(INOUT)::KRESP  ! return-code \r
+!\r
+!*      0.2   Declarations of local variables\r
+!\r
+CHARACTER(LEN=JPFINL)        :: YFNLFI\r
+INTEGER                      :: IERR\r
+TYPE(FD_ll), POINTER         :: TZFD\r
+INTEGER                      :: IRESP\r
+REAL,DIMENSION(:,:,:),ALLOCATABLE,TARGET :: Z3D\r
+REAL,DIMENSION(:,:,:), POINTER           :: TX3DP\r
+TYPE(FMHEADER)               :: TZFMH\r
+INTEGER :: IIMAX_ll,IJMAX_ll\r
+INTEGER :: IIB,IIE,IJB,IJE\r
+INTEGER :: JI\r
+INTEGER, DIMENSION(MPI_STATUS_SIZE) :: STATUS\r
+INTEGER, ALLOCATABLE,DIMENSION(:,:)   :: STATUSES\r
+!JUANZIO\r
+!JUAN INTEGER,SAVE,DIMENSION(100000)    :: REQ_TAB\r
+INTEGER,ALLOCATABLE,DIMENSION(:)    :: REQ_TAB\r
+INTEGER                           :: NB_REQ,IKU\r
+TYPE TX_3DP\r
+REAL,DIMENSION(:,:,:), POINTER    :: X\r
+END TYPE\r
+TYPE(TX_3DP),ALLOCATABLE,DIMENSION(:) :: T_TX3DP\r
+REAL*8,DIMENSION(2) :: T0,T1,T2,T3\r
+REAL*8,DIMENSION(2) :: T11,T22\r
+!JUANZIO\r
+INTEGER             :: IHEXTOT\r
+\r
+!\r
+!*      1.1   THE NAME OF LFIFM\r
+!\r
+CALL SECOND_MNH2(T11)\r
+IRESP = 0\r
+YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'\r
+!------------------------------------------------------------------\r
+IHEXTOT = 2*JPHEXT+1\r
+TZFD=>GETFD(YFNLFI)\r
+IF (ASSOCIATED(TZFD)) THEN\r
+  IF (GSMONOPROC) THEN ! sequential execution\r
+    IF (HLBTYPE == 'LBX' .OR. HLBTYPE == 'LBXU') THEN \r
+      ALLOCATE(Z3D(KL3D,SIZE(PLB,2),SIZE(PLB,3)))\r
+      Z3D = 0.0\r
+      IF (LPACK .AND. L2D) THEN\r
+        TX3DP=>Z3D(:,JPHEXT+1:JPHEXT+1,:)\r
+        IF (ASSOCIATED(TZFD%CDF)) THEN\r
+           CALL NCREAD(TZFD%CDF%NCID,HRECFM,TX3DP,TZFMH,IRESP)\r
+        ELSE\r
+           CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(TX3DP),TX3DP,TZFMH,IRESP)\r
+        END IF\r
+        Z3D(:,:,:) = SPREAD(Z3D(:,JPHEXT+1,:),DIM=2,NCOPIES=IHEXTOT)\r
+      ELSE\r
+         IF (ASSOCIATED(TZFD%CDF)) THEN\r
+            CALL NCREAD(TZFD%CDF%NCID,HRECFM,Z3D,TZFMH,IRESP)\r
+         ELSE\r
+            CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(Z3D),Z3D,TZFMH,IRESP)\r
+         END IF\r
+      END IF\r
+      PLB(1:KRIM+JPHEXT,:,:)          = Z3D(1:KRIM+JPHEXT,:,:)\r
+      PLB(KRIM+JPHEXT+1:2*(KRIM+JPHEXT),:,:) = Z3D(KL3D-KRIM-JPHEXT+1:KL3D,:,:)\r
+    ELSE !(HLBTYPE == 'LBY' .OR. HLBTYPE == 'LBYV') \r
+      ALLOCATE(Z3D(SIZE(PLB,1),KL3D,SIZE(PLB,3)))\r
+      Z3D = 0.0\r
+      IF (ASSOCIATED(TZFD%CDF)) THEN\r
+         CALL NCREAD(TZFD%CDF%NCID,HRECFM,Z3D,TZFMH,IRESP)\r
+      ELSE\r
+         CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(Z3D),Z3D,TZFMH,IRESP)\r
+      END IF\r
+      PLB(:,1:KRIM+JPHEXT,:)          = Z3D(:,1:KRIM+JPHEXT,:)\r
+      PLB(:,KRIM+JPHEXT+1:2*(KRIM+JPHEXT),:) = Z3D(:,KL3D-KRIM-JPHEXT+1:KL3D,:)\r
+    END IF\r
+    IF (IRESP /= 0) GOTO 1000\r
+  ELSE                 ! multiprocessor execution\r
+    IF (ISP == TZFD%OWNER)  THEN\r
+      CALL SECOND_MNH2(T0)\r
+      CALL GET_GLOBALDIMS_ll(IIMAX_ll,IJMAX_ll)\r
+      IF (HLBTYPE == 'LBX' .OR. HLBTYPE == 'LBXU') THEN \r
+        ALLOCATE(Z3D(KL3D,IJMAX_ll+2*JPHEXT,SIZE(PLB,3)))\r
+        Z3D = 0.0\r
+        IF (LPACK .AND. L2D) THEN\r
+          TX3DP=>Z3D(:,JPHEXT+1:JPHEXT+1,:)\r
+          IF (ASSOCIATED(TZFD%CDF)) THEN\r
+             CALL NCREAD(TZFD%CDF%NCID,HRECFM,TX3DP,TZFMH,IRESP)\r
+          ELSE\r
+             CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(TX3DP),TX3DP,TZFMH,IRESP)\r
+          END IF\r
+          Z3D(:,:,:) = SPREAD(Z3D(:,JPHEXT+1,:),DIM=2,NCOPIES=IHEXTOT)\r
+        ELSE\r
+           IF (ASSOCIATED(TZFD%CDF)) THEN\r
+              CALL NCREAD(TZFD%CDF%NCID,HRECFM,Z3D,TZFMH,IRESP)\r
+           ELSE\r
+              CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(Z3D),Z3D,TZFMH,IRESP)\r
+           END IF\r
+        END IF\r
+        ! erase gap in LB field\r
+        Z3D(KRIM+JPHEXT+1:2*(KRIM+JPHEXT),:,:) = Z3D(KL3D-KRIM-JPHEXT+1:KL3D,:,:)\r
+      ELSE !(HLBTYPE == 'LBY' .OR. HLBTYPE == 'LBYV') \r
+        ALLOCATE(Z3D(IIMAX_ll+2*JPHEXT,KL3D,SIZE(PLB,3)))\r
+        Z3D = 0.0\r
+        IF (ASSOCIATED(TZFD%CDF)) THEN\r
+           CALL NCREAD(TZFD%CDF%NCID,HRECFM,Z3D,TZFMH,IRESP)\r
+        ELSE\r
+           CALL FM_READ_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(Z3D),Z3D,TZFMH,IRESP)\r
+        END IF\r
+        ! erase gap in LB field\r
+        Z3D(:,KRIM+JPHEXT+1:2*(KRIM+JPHEXT),:) = Z3D(:,KL3D-KRIM-JPHEXT+1:KL3D,:)\r
+      END IF\r
+      CALL SECOND_MNH2(T1)\r
+      TIMEZ%T_READLB_READ=TIMEZ%T_READLB_READ + T1 - T0\r
+    END IF\r
+    !  \r
+    CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+    IF (IRESP /= 0) GOTO 1000\r
+    !  \r
+    CALL BCAST_HEADER(TZFD,TZFMH)\r
+    ! \r
+    NB_REQ=0\r
+    ALLOCATE(REQ_TAB(ISNPROC-1))\r
+    !REQ_TAB=MPI_REQUEST_NULL\r
+    IF (ISP == TZFD%OWNER)  THEN\r
+       CALL SECOND_MNH2(T1)\r
+      !ALLOCATE(REQ_TAB(ISNPROC-1))\r
+      !REQ_TAB=MPI_REQUEST_NULL\r
+      ALLOCATE(T_TX3DP(ISNPROC-1))\r
+      IKU = SIZE(Z3D,3)\r
+      DO JI = 1,ISNPROC\r
+        CALL GET_DISTRIB_LB(HLBTYPE,JI,'FM','READ',KRIM,IIB,IIE,IJB,IJE)\r
+        IF (IIB /= 0) THEN\r
+          TX3DP=>Z3D(IIB:IIE,IJB:IJE,:)\r
+          IF (ISP /= JI) THEN \r
+            NB_REQ = NB_REQ + 1\r
+            ALLOCATE(T_TX3DP(NB_REQ)%X(IIB:IIE,IJB:IJE,IKU))           \r
+            T_TX3DP(NB_REQ)%X=Z3D(IIB:IIE,IJB:IJE,:)\r
+            CALL MPI_ISEND(T_TX3DP(NB_REQ)%X,SIZE(TX3DP),MPI_FLOAT,JI-1,99,TZFD%COMM,REQ_TAB(NB_REQ),IERR)\r
+            !CALL MPI_BSEND(T_TX3DP(NB_REQ)%X,SIZE(TX3DP),MPI_FLOAT,JI-1,99,TZFD%COMM,IERR)\r
+          ELSE\r
+            CALL GET_DISTRIB_LB(HLBTYPE,JI,'LOC','READ',KRIM,IIB,IIE,IJB,IJE)\r
+            PLB(IIB:IIE,IJB:IJE,:) = TX3DP(:,:,:)\r
+          END IF\r
+        END IF\r
+      END DO\r
+      CALL SECOND_MNH2(T2)\r
+      TIMEZ%T_READLB_SEND=TIMEZ%T_READLB_SEND + T2 - T1      \r
+      IF (NB_REQ .GT.0 ) THEN\r
+         !ALLOCATE(STATUSES(MPI_STATUS_SIZE,NB_REQ))\r
+         !CALL MPI_WAITALL(NB_REQ,REQ_TAB,STATUSES,IERR)\r
+         CALL MPI_WAITALL(NB_REQ,REQ_TAB,MNH_STATUSES_IGNORE,IERR)\r
+         !DEALLOCATE(STATUSES)\r
+         DO JI=1,NB_REQ ;  DEALLOCATE(T_TX3DP(JI)%X) ; ENDDO\r
+      END IF\r
+      DEALLOCATE(T_TX3DP)\r
+      !DEALLOCATE(REQ_TAB)\r
+      CALL SECOND_MNH2(T3)\r
+      TIMEZ%T_READLB_WAIT=TIMEZ%T_READLB_WAIT + T3 - T2\r
+    ELSE\r
+       CALL SECOND_MNH2(T0)\r
+      !ALLOCATE(REQ_TAB(1))\r
+      !REQ_TAB=MPI_REQUEST_NULL\r
+      CALL GET_DISTRIB_LB(HLBTYPE,ISP,'LOC','READ',KRIM,IIB,IIE,IJB,IJE)\r
+      IF (IIB /= 0) THEN\r
+        TX3DP=>PLB(IIB:IIE,IJB:IJE,:)\r
+        CALL MPI_RECV(TX3DP,SIZE(TX3DP),MPI_FLOAT,TZFD%OWNER-1,99,TZFD%COMM,STATUS,IERR)\r
+        !NB_REQ = NB_REQ + 1\r
+        !CALL MPI_IRECV(TX3DP,SIZE(TX3DP),MPI_FLOAT,TZFD%OWNER-1,99,TZFD%COMM,REQ_TAB(NB_REQ),IERR)\r
+        !IF (NB_REQ .GT.0 ) CALL MPI_WAITALL(NB_REQ,REQ_TAB,MNH_STATUSES_IGNORE,IERR)\r
+      END IF\r
+      CALL SECOND_MNH2(T1)\r
+      TIMEZ%T_READLB_RECV=TIMEZ%T_READLB_RECV + T1 - T0 \r
+    END IF\r
+    DEALLOCATE(REQ_TAB)\r
+  END IF !(GSMONOPROC)\r
+  KGRID  = TZFMH%GRID\r
+  KLENCH = TZFMH%COMLEN\r
+  HCOMMENT = TZFMH%COMMENT(1:TZFMH%COMLEN)\r
+ELSE \r
+  IRESP = -61          \r
+END IF\r
+!----------------------------------------------------------------\r
+1000 CONTINUE\r
+!! Error handler\r
+IF (IRESP.NE.0) THEN\r
+  CALL FM_READ_ERR("FMREAD_LB",HFILEM,HFIPRI,HRECFM,HLBTYPE,IRESP)\r
+ENDIF\r
+!\r
+IF (ALLOCATED(Z3D)) DEALLOCATE (Z3D)\r
+KRESP = IRESP\r
+!\r
+!CALL MPI_BARRIER(TZFD%COMM,IERR)\r
+CALL SECOND_MNH2(T22)\r
+TIMEZ%T_READLB_ALL=TIMEZ%T_READLB_ALL + T22 - T11\r
+END SUBROUTINE FMREAD_LB\r
+\r
+END MODULE MODE_FMREAD\r
+\r
+\r
+!\r
index 6e2feec..70025f6 100644 (file)
-!MNH_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
-!MNH_LIC This is part of the Meso-NH software governed by the CeCILL-C licence
-!MNH_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt  
-!MNH_LIC for details. version 1.
-!-----------------------------------------------------------------
-!--------------- special set of characters for CVS information
-!-----------------------------------------------------------------
-! $Source$
-! $Name$ 
-! $Revision$ 
-! $Date$
-!-----------------------------------------------------------------
-!Correction :
-!  J.Escobar : 15/09/2015 : WENO5 & JPHEXT <> 1 
-!  D.Gazen   : avril 2016 bug dimensions 2D cases
-!-----------------------------------------------------------------
-
-#ifdef MNH_MPI_DOUBLE_PRECISION
-#define MPI_FLOAT MPI_DOUBLE_PRECISION
-#else
-#define MPI_FLOAT MPI_REAL
-#endif
-
-#ifdef MNH_GA
-MODULE MODE_GA 
-#include "mafdecls.fh"
-#include "global.fh"
-    !
-    !  Global Array Variables
-    !
-    INTEGER, PARAMETER                              :: jpix=1 , jpiy = 2 , jpiz = 3
-    !
-    INTEGER                                         :: NIMAX_ll,NJMAX_ll, IIU_ll,IJU_ll,IKU_ll
-    integer                                         :: heap=5*10**6, stack
-    logical                                         :: gstatus_ga
-    INTEGER, PARAMETER                              :: ndim_GA = 3
-    INTEGER, DIMENSION(ndim_GA)                     :: dims_GA , chunk_GA 
-    INTEGER,PARAMETER                               :: CI=1 ,CJ=-1 ,CK=-1
-    INTEGER                                         :: g_a
-    integer, DIMENSION(ndim_GA)                     :: lo_col, hi_col , ld_col
-    integer, DIMENSION(ndim_GA)                     :: lo_zplan , hi_zplan , ld_zplan   
-    INTEGER                                         :: NIXO_L,NIXE_L,NIYO_L,NIYE_L
-    INTEGER                                         :: NIXO_G,NIXE_G,NIYO_G,NIYE_G
-    LOGICAL,SAVE                                    :: GFIRST_GA  = .TRUE.
-    INTEGER                                         :: IIU_ll_MAX = -1, IJU_ll_MAX = -1, IKU_ll_MAX = -1
-
-  CONTAINS 
-    
-    SUBROUTINE MNH_INIT_GA(MY_NI,MY_NJ,MY_NK,HRECFM,HRW_MODE)
-
-!
-!  Modification 
-!  J.Escobar 5/02/2015 : use JPHEXT from MODD_PARAMETERS_ll
-
-      USE MODE_TOOLS_ll,       ONLY : GET_GLOBALDIMS_ll
-      USE MODD_PARAMETERS_ll,  ONLY : JPHEXT
-      USE MODD_IO_ll,          ONLY : ISP
-      USE MODE_GATHER_ll,      ONLY : GET_DOMWRITE_ll
-      USE MODE_SCATTER_ll,     ONLY : GET_DOMREAD_ll
-
-      IMPLICIT NONE
-
-      INTEGER,          INTENT(IN) :: MY_NI,MY_NJ,MY_NK
-      CHARACTER(LEN=*), INTENT(IN) :: HRECFM   ! name of the article to write
-      CHARACTER(LEN=*), INTENT(IN) :: HRW_MODE 
-      
-      IF ( GFIRST_GA ) THEN
-         GFIRST_GA = .FALSE.
-         !
-         !   Allocate memory for GA library
-         !
-         stack = heap
-         !gstatus_ga = ma_init(MT_F_DBL, stack/ISNPROC, heap/ISNPROC)
-         gstatus_ga = ma_init(MT_F_DBL, stack, heap)
-         if ( .not. gstatus_ga ) STOP " MA_INIT FAILED "
-         !
-         !   Initialize GA library
-         !
-         !call ga_initialize_ltd(100000000)
-         call ga_initialize()
-      END IF
-      
-      CALL GET_GLOBALDIMS_ll (NIMAX_ll,NJMAX_ll)
-      IIU_ll = NIMAX_ll + 2*JPHEXT
-      IJU_ll = NJMAX_ll + 2*JPHEXT
-      IKU_ll = MY_NK   
-      !
-      !   configure Global array dimensions
-      !
-      dims_GA(JPIX) = IIU_ll
-      dims_GA(JPIY) = IJU_ll
-      dims_GA(JPIZ) = IKU_ll
-      chunk_GA(JPIX)   = CI
-      chunk_GA(JPIY)   = CJ
-      chunk_GA(JPIZ)   = CK 
-      IF ( CI .EQ. 1 ) chunk_GA(JPIX)   = dims_GA(JPIX) ! 1 block in X direction
-      IF ( CJ .EQ. 1 ) chunk_GA(JPIY)   = dims_GA(JPIY) ! 1 block in Y direction
-      IF ( CK .EQ. 1 ) chunk_GA(JPIZ)   = dims_GA(JPIZ) ! 1 block in Z direction
-      !
-      !   (re)create global array g_a ( if to small create it ... )
-      !
-      IF ( ( IIU_ll .GT. IIU_ll_MAX ) .OR. ( IJU_ll .GT. IJU_ll_MAX ) .OR. ( IKU_ll .GT. IKU_ll_MAX ) ) THEN
-         !
-         ! reallocate the g_a , if need with bigger Z size 
-         !
-         IF ( IKU_ll_MAX .NE. -1 ) gstatus_ga =  ga_destroy(g_a)
-         IIU_ll_MAX = IIU_ll
-         IJU_ll_MAX = IJU_ll
-         IKU_ll_MAX = IKU_ll
-         gstatus_ga = nga_create(MT_F_DBL, ndim_GA, dims_GA, HRECFM ,chunk_GA, g_a)
-         call ga_sync()
-      END IF
-      !----------------------------------------------------------------------!
-      !                                                                      !
-      ! Define/describe local column data owned by this processor to write   !
-      !                                                                      !
-      !----------------------------------------------------------------------!
-      IF ( HRW_MODE .EQ. "WRITE" ) THEN
-      CALL GET_DOMWRITE_ll(ISP,'local',NIXO_L,NIXE_L,NIYO_L,NIYE_L)
-      CALL GET_DOMWRITE_ll(ISP,'global',NIXO_G,NIXE_G,NIYO_G,NIYE_G)
-      ELSE
-      CALL GET_DOMREAD_ll(ISP,NIXO_L,NIXE_L,NIYO_L,NIYE_L)
-      CALL GET_DOMREAD_ll(ISP,NIXO_G,NIXE_G,NIYO_G,NIYE_G)
-      END IF
-      !
-      ! portion of data to write/put | read/get by this proc
-      !
-      lo_col(JPIX) = NIXO_G
-      hi_col(JPIX) = NIXE_G
-      
-      lo_col(JPIY) = NIYO_G
-      hi_col(JPIY) = NIYE_G
-      
-      lo_col(JPIZ) = 1
-      hi_col(JPIZ) = IKU_ll
-      !
-      ! declaration size of this local input column array
-      !
-      ld_col(JPIX) = MY_NI
-      ld_col(JPIY) = MY_NJ
-      ld_col(JPIZ) = MY_NK
-      !
-      !-----------------------------------------------------!
-      !                                                     !
-      !  Size of local ZSLIDE_ll Write buffer on I/O proc   !
-      !                                                     !
-      !-----------------------------------------------------!
-      !
-      ! declared dimension 
-      !
-      ld_zplan(JPIX) = IIU_ll
-      ld_zplan(JPIY) = IJU_ll
-      ld_zplan(JPIZ) = 1
-      !
-      ! write data by Z slide by I/O proc
-      !
-      lo_zplan(JPIX:JPIY) = 1
-      hi_zplan(JPIX) = IIU_ll 
-      hi_zplan(JPIY) = IJU_ll   
-      !call ga_sync()
-      !
-    END SUBROUTINE MNH_INIT_GA
-    
-END MODULE MODE_GA
-
-#endif
-
-MODULE MODE_FMWRIT
-
-  USE MODD_MPIF
-#if defined(MNH_IOCDF4)
-  USE MODE_NETCDF
-#endif
-
-  IMPLICIT NONE 
-
-  PRIVATE
-
-  INTERFACE FMWRIT
-     MODULE PROCEDURE FMWRITX0_ll,FMWRITX1_ll,FMWRITX2_ll,FMWRITX3_ll,&
-          & FMWRITX4_ll,FMWRITX5_ll,FMWRITX6_ll,&
-          & FMWRITN0_ll,FMWRITN1_ll,FMWRITN2_ll,&
-          & FMWRITL0_ll,FMWRITL1_ll,FMWRITC0_ll,&
-          & FMWRITC1_ll,FMWRITT0_ll
-  END INTERFACE
-
-  INTERFACE FMWRITBOX
-     MODULE PROCEDURE FMWRITBOXX2_ll,FMWRITBOXX3_ll,FMWRITBOXX4_ll,&
-          & FMWRITBOXX5_ll,FMWRITBOXX6_ll
-  END INTERFACE
-
-  PUBLIC FMWRIT_LB,FMWRITBOX,FMWRIT,FMWRITX0_ll,FMWRITX1_ll,FMWRITX2_ll,FMWRITX3_ll,&
-       & FMWRITX4_ll,FMWRITX5_ll,FMWRITX6_ll,FMWRITN0_ll,FMWRITN1_ll,FMWRITN2_ll,&
-       & FMWRITL0_ll,FMWRITL1_ll,FMWRITC0_ll,FMWRITC1_ll,FMWRITT0_ll,FMWRITBOXX2_ll,&
-       & FMWRITBOXX3_ll,FMWRITBOXX4_ll,FMWRITBOXX5_ll,FMWRITBOXX6_ll
-
-  !INCLUDE 'mpif.h'
-
-CONTAINS 
-
-  SUBROUTINE FM_WRIT_ERR(HFUNC,HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH&
-       & ,KRESP)
-    USE MODE_FM, ONLY : FMLOOK_ll
-
-    CHARACTER(LEN=*) :: HFUNC 
-    CHARACTER(LEN=*) :: HFILEM
-    CHARACTER(LEN=*) :: HFIPRI
-    CHARACTER(LEN=*) :: HRECFM
-    CHARACTER(LEN=*) :: HDIR
-    INTEGER          :: KGRID
-    INTEGER          :: KLENCH
-    INTEGER          :: KRESP
-
-    INTEGER          :: ILUPRI
-    INTEGER          :: IRESP
-
-    CALL FMLOOK_ll(HFIPRI,HFIPRI,ILUPRI,IRESP)
-    WRITE (ILUPRI,*) ' exit from ',HFUNC,' with RESP:',KRESP
-    WRITE (ILUPRI,*) '   | HFILEM = ',HFILEM
-    WRITE (ILUPRI,*) '   | HRECFM = ',HRECFM
-    WRITE (ILUPRI,*) '   | HDIR  = ',HDIR
-    WRITE (ILUPRI,*) '   | KGRID  = ',KGRID
-    WRITE (ILUPRI,*) '   | KLENCH = ',KLENCH
-
-  END SUBROUTINE FM_WRIT_ERR
-
-
-
-  SUBROUTINE FMWRITX0_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&
-       KLENCH,HCOMMENT,KRESP)
-!
-!  Modification 
-!  J.Escobar 15/04/2014 : add write to all Z files for all FMWRITX0_ll variables
-!  J.Escobar 23/06/2014 : bug , replace .FALSE. to .TRUE. = OREAL type transmetted to FM_WRIT_ll
-!
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-#ifdef MNH_NCWRIT
-    USE MODD_GRID
-    USE MODD_DIM_n, ONLY: NIMAX
-    USE MODD_NCOUT
-    USE MODE_UTIL
-#endif
-    !
-    !*      0.    DECLARATIONS
-    !             ------------
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),        INTENT(IN) ::HFILEM  ! FM-file name
-    CHARACTER(LEN=*),        INTENT(IN) ::HRECFM  ! name of the article to write
-    CHARACTER(LEN=*),        INTENT(IN) ::HFIPRI  ! output file for error messages
-    CHARACTER(LEN=*),        INTENT(IN) ::HDIR    ! field form
-    REAL,                    INTENT(IN) ::PFIELD  ! array containing the data field
-    INTEGER,                 INTENT(IN) ::KGRID   ! C-grid indicator (u,v,w,T)
-    INTEGER,                 INTENT(IN) ::KLENCH  ! length of comment string
-    CHARACTER(LEN=*),        INTENT(IN) ::HCOMMENT! comment string
-    INTEGER,                 INTENT(OUT)::KRESP   ! return-code 
-    !
-    !*      0.2   Declarations of local variables
-    !
-    !----------------------------------------------------------------
-    CHARACTER(LEN=JPFINL)        :: YFNLFI
-    INTEGER                      :: IERR
-    TYPE(FD_ll), POINTER         :: TZFD
-    INTEGER                      :: IRESP
-    TYPE(FMHEADER)               :: TZFMH
-    !JUANZIO
-    INTEGER                                  :: IK_FILE,IK_rank
-    CHARACTER(len=5)                         :: YK_FILE  
-    CHARACTER(len=128)                       :: YFILE_IOZ  
-    TYPE(FD_ll), POINTER                     :: TZFD_IOZ 
-    !JUANZIO
-    !
-    !*      1.1   THE NAME OF LFIFM
-    !
-    IRESP = 0
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-    !print * , ' Writing Article 0 ' , HRECFM
-    !
-    TZFD=>GETFD(YFNLFI)
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN ! sequential execution
-          TZFMH%GRID=KGRID
-          TZFMH%COMLEN=KLENCH
-          TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-          IF ( DEF_NC .AND. LLFIFM ) THEN
-          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,1,PFIELD,TZFMH,IRESP)    
-          END IF
-          IF ( LNETCDF .AND. NIMAX == 0 ) THEN
-!    PRINT * , ' SAVE MAP PARAMETER IF PGD '
-          IF ( trim(hrecfm) == "RPK" ) THEN
-            XRPK=PFIELD
-          ELSEIF ( trim(hrecfm) == "BETA" ) THEN
-            XBETA=PFIELD
-          ELSEIF (trim(hrecfm) == "LATORI" ) THEN
-            XLATORI=PFIELD
-          ELSEIF (trim(hrecfm) == "LONORI" ) THEN
-            XLONORI=PFIELD
-          ELSEIF (trim(hrecfm) == "LAT0" ) THEN
-            XLAT0=PFIELD
-          ELSEIF (trim(hrecfm) == "LON0" ) THEN
-            XLON0=PFIELD
-          END IF
-          END IF
-#else
-          IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,1,PFIELD,TZFMH,IRESP)
-          IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,PFIELD,TZFMH,IRESP)
-#endif
-       ELSE
-          IF (ISP == TZFD%OWNER)  THEN
-             TZFMH%GRID=KGRID
-             TZFMH%COMLEN=KLENCH
-             TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,1,PFIELD,TZFMH,IRESP)
-               END IF
-             IF ( LNETCDF .AND. NIMAX == 0 ) THEN
-!                  print * , ' SAVE MAP PARAMETER IF PGD '
-               IF ( trim(hrecfm) == "RPK" ) THEN
-                 XRPK=PFIELD
-               ELSEIF ( trim(hrecfm) == "BETA" ) THEN
-                 XBETA=PFIELD
-               ELSEIF (trim(hrecfm) == "LATORI" ) THEN
-                 XLATORI=PFIELD
-               ELSEIF (trim(hrecfm) == "LONORI" ) THEN
-                 XLONORI=PFIELD
-               ELSEIF (trim(hrecfm) == "LAT0" ) THEN
-                 XLAT0=PFIELD
-               ELSEIF (trim(hrecfm) == "LON0" ) THEN
-                 XLON0=PFIELD
-               END IF
-             END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,1,PFIELD,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,PFIELD,TZFMH,IRESP)
-#endif
-          END IF
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-       END IF ! multiprocessor execution
-       IF (TZFD%nb_procio.gt.1) THEN
-          ! write the data in all Z files
-          DO IK_FILE=1,TZFD%nb_procio
-             write(YK_FILE ,'(".Z",i3.3)')  IK_FILE
-             YFILE_IOZ =  TRIM(HFILEM)//YK_FILE//".lfi"
-             TZFD_IOZ => GETFD(YFILE_IOZ)   
-             IK_RANK = TZFD_IOZ%OWNER
-             IF ( ISP == IK_RANK )  THEN
-                TZFMH%GRID=KGRID
-                TZFMH%COMLEN=KLENCH
-                TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-                CALL FM_WRIT_ll(TZFD_IOZ%FLU,HRECFM,.TRUE.,1,PFIELD,TZFMH,IRESP)
-               END IF
-#else
-               IF (LLFIOUT) CALL FM_WRIT_ll(TZFD_IOZ%FLU,HRECFM,.TRUE.,1,PFIELD,TZFMH,IRESP)
-               IF (LIOCDF4) CALL NCWRIT(TZFD_IOZ%CDF,HRECFM,HDIR,PFIELD,TZFMH,IRESP)
-#endif
-             END IF
-          END DO
-       ENDIF
-    ELSE
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITX0_ll",HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH,IRESP)
-    END IF
-    KRESP = IRESP
-  END SUBROUTINE FMWRITX0_ll
-
-  SUBROUTINE FMWRITX1_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&
-       KLENCH,HCOMMENT,KRESP)
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-    USE MODE_ALLOCBUFFER_ll
-    USE MODE_GATHER_ll
-#ifdef MNH_NCWRIT
-    USE MODE_UTIL
-    USE MODE_DIMLIST
-    USE MODD_DIM_n, ONLY: NIMAX
-    USE MODD_NCOUT
-#endif
-    !
-    !*      0.    DECLARATIONS
-    !             ------------
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),        INTENT(IN) ::HFILEM   ! FM-file name
-    CHARACTER(LEN=*),        INTENT(IN) ::HRECFM   ! name of the article to write
-    CHARACTER(LEN=*),        INTENT(IN) ::HFIPRI   ! output file for error messages
-    CHARACTER(LEN=*),        INTENT(IN) ::HDIR     ! field form
-    REAL,DIMENSION(:),TARGET,INTENT(IN) ::PFIELD   ! array containing the data field
-    INTEGER,                 INTENT(IN) ::KGRID    ! C-grid indicator (u,v,w,T)
-    INTEGER,                 INTENT(IN) ::KLENCH   ! length of comment string
-    CHARACTER(LEN=*),        INTENT(IN) ::HCOMMENT ! comment string
-    INTEGER,                 INTENT(OUT)::KRESP    ! return-code 
-    !
-    !*      0.2   Declarations of local variables
-    !
-    !----------------------------------------------------------------
-    CHARACTER(LEN=JPFINL)        :: YFNLFI
-    INTEGER                      :: IERR
-    TYPE(FD_ll), POINTER         :: TZFD
-    INTEGER                      :: IRESP
-    TYPE(FMHEADER)               :: TZFMH
-    REAL,DIMENSION(:),POINTER    :: ZFIELDP
-    LOGICAL                      :: GALLOC
-#ifdef MNH_NCWRIT
-    TYPE(workfield), DIMENSION(:), POINTER   :: TZRECLIST
-    INTEGER,DIMENSION(6)         :: TABDIM
-#endif
-    !
-    !*      1.1   THE NAME OF LFIFM
-    !
-    IRESP = 0
-    GALLOC = .FALSE.
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-#ifdef MNH_NCWRIT
-    TABDIM(:)=1
-    TABDIM(1)=SIZE(PFIELD,1)
-    !print * , ' Writing Article 1 ' , HRECFM
-#endif
-    !------------------------------------------------------------------    
-    TZFD=>GETFD(YFNLFI)
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN ! sequential execution
-          TZFMH%GRID=KGRID
-          TZFMH%COMLEN=KLENCH
-          TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-         IF ( DEF_NC .AND. LLFIFM ) THEN
-          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-         END IF
-         ! ------- WRITE NETCDF
-         IF ( LNETCDF .AND. NC_WRITE ) THEN
-          CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,PFIELD,.TRUE.,TZRECLIST, &
-!          CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,PFIELD, &
-                  & KLENCH,HCOMMENT)
-            IF ( NC_FILE == 'phy' ) THEN
-!!!!! CAS WRITE_PHYS_PARAM ... l'ecriture lfi ne peut pas se faire en meme temps
-              CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE., &
-                 SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-            END IF
-         END IF
-#else
-          IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-          IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,PFIELD,TZFMH,IRESP)
-#endif
-       ELSE
-          IF (ISP == TZFD%OWNER)  THEN
-             CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)
-          ELSE
-             ALLOCATE(ZFIELDP(0))
-             GALLOC = .TRUE.
-          END IF
-          !
-          IF (HDIR == 'XX' .OR. HDIR =='YY') THEN
-             CALL GATHER_XXFIELD(HDIR,PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM)
-          END IF
-          !
-          IF (ISP == TZFD%OWNER)  THEN
-             TZFMH%GRID=KGRID
-             TZFMH%COMLEN=KLENCH
-             TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-           IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-           END IF
-           IF ( LNETCDF .AND. NC_WRITE ) THEN
-            TABDIM(1)=SIZE(ZFIELDP,1)
-            CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP,.TRUE.,TZRECLIST, &
-              & KLENCH,HCOMMENT)
-             IF ( NC_FILE == 'phy' ) THEN
-               CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-             END IF
-           END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)
-#endif
-          END IF
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-       END IF
-    ELSE
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITX1_ll",HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH,IRESP)
-    END IF
-    IF (GALLOC) DEALLOCATE(ZFIELDP)
-    KRESP = IRESP
-  END SUBROUTINE FMWRITX1_ll
-
-  SUBROUTINE FMWRITX2_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&
-       KLENCH,HCOMMENT,KRESP)
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT,LPACK,L1D,L2D
-    USE MODD_PARAMETERS_ll,ONLY : JPHEXT
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-    USE MODE_ALLOCBUFFER_ll
-    USE MODE_GATHER_ll
-    !JUANZ
-    USE MODD_TIMEZ, ONLY : TIMEZ
-    USE MODE_MNH_TIMING, ONLY : SECOND_MNH2
-    !JUANZ 
-#ifdef MNH_NCWRIT
-    USE MODE_UTIL
-    USE MODE_DIMLIST
-    USE MODD_DIM_n, ONLY: NIMAX
-    USE MODD_NCOUT
-#endif
-#ifdef MNH_GA
-    !JUAN_IOGA
-    USE MODE_GA
-#endif 
-    !
-    IMPLICIT NONE
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),          INTENT(IN) ::HFILEM   ! FM-file name
-    CHARACTER(LEN=*),          INTENT(IN) ::HRECFM   ! name of the article to write
-    CHARACTER(LEN=*),          INTENT(IN) ::HFIPRI   ! output file for error messages
-    CHARACTER(LEN=*),          INTENT(IN) ::HDIR     ! field form
-    REAL,DIMENSION(:,:),TARGET,INTENT(IN) ::PFIELD   ! array containing the data field
-    INTEGER,                   INTENT(IN) ::KGRID    ! C-grid indicator (u,v,w,T)
-    INTEGER,                   INTENT(IN) ::KLENCH   ! length of comment string
-    CHARACTER(LEN=*),          INTENT(IN) ::HCOMMENT ! comment string
-    INTEGER,                   INTENT(OUT)::KRESP    ! return-code 
-    !
-    !*      0.2   Declarations of local variables
-    !
-    CHARACTER(LEN=JPFINL)                  :: YFNLFI
-    INTEGER                                :: IERR
-    TYPE(FD_ll), POINTER                   :: TZFD
-    INTEGER                                :: IRESP
-    REAL,DIMENSION(:,:),POINTER            :: ZFIELDP
-    TYPE(FMHEADER)                         :: TZFMH
-    LOGICAL                                :: GALLOC
-#ifdef MNH_NCWRIT
-    TYPE(workfield), DIMENSION(:), POINTER   :: TZRECLIST
-    INTEGER,DIMENSION(6)         :: TABDIM
-    LOGICAL                      :: NCWR
-    INTEGER                      :: LHREC_BEG,LHRECFM 
-#endif
-    !
-    !JUANZ
-    REAL*8,DIMENSION(2) :: T0,T1,T2
-    REAL*8,DIMENSION(2) :: T11,T22
-    !JUANZ
-#ifdef MNH_GA
-    REAL,DIMENSION(:,:),POINTER            :: ZFIELDP_GA , ZFIELD_GA
-    REAL                                   :: ERROR
-    INTEGER                                :: JI
-#endif
-    !
-    !*      1.1   THE NAME OF LFIFM
-    !
-    CALL SECOND_MNH2(T11)
-    IRESP = 0
-    GALLOC = .FALSE.
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-#ifdef MNH_NCWRIT
-    NCWR=.TRUE.
-    TABDIM(:)=1
-    TABDIM(1)=SIZE(PFIELD,1)
-    TABDIM(2)=SIZE(PFIELD,2)
-    !print * , ' Writing Article 2 ' , HRECFM
-#endif
-    !------------------------------------------------------------------
-    TZFD=>GETFD(YFNLFI)
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN ! sequential execution
-          TZFMH%GRID=KGRID
-          TZFMH%COMLEN=KLENCH
-          TZFMH%COMMENT=HCOMMENT
-          !    IF (LPACK .AND. L1D .AND. HDIR=='XY') THEN 
-          IF (LPACK .AND. L1D .AND. SIZE(PFIELD,1)==2*JPHEXT+1 .AND. SIZE(PFIELD,2)==2*JPHEXT+1) THEN 
-             ZFIELDP=>PFIELD(2:2,2:2)
-#ifdef MNH_NCWRIT
-      IF ( DEF_NC .AND. LLFIFM ) THEN
-       CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-      END IF
-      IF ( LNETCDF .AND. NC_WRITE ) THEN
-         TABDIM(1)=1
-         TABDIM(2)=1
-        CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP,.TRUE.,TZRECLIST,&
-                  & KLENCH,HCOMMENT)
-      END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)
-#endif
-             !    ELSE IF (LPACK .AND. L2D .AND. HDIR=='XY') THEN
-          ELSEIF (LPACK .AND. L2D .AND. SIZE(PFIELD,2)==2*JPHEXT+1) THEN
-             ZFIELDP=>PFIELD(:,2:2)
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-               END IF
-             LHRECFM = LEN_TRIM(ADJUSTL(HRECFM))
-             IF ( LHRECFM > 5 ) THEN
-               LHREC_BEG =LHRECFM-4
-               IF ( ADJUSTL(HRECFM(LHREC_BEG:LHRECFM)) == 'DATIM') THEN
-                  NCWR = .FALSE.
-               END IF
-             END IF
-             IF ( LNETCDF .AND. NC_WRITE .AND. NCWR ) THEN
-                 TABDIM(2)=1
-              IF ( NC_FILE == 'phy' ) THEN
-                  CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE., &
-                     SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-              END IF
-                  CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP,.TRUE.,TZRECLIST,&
-                  & KLENCH,HCOMMENT)
-             END IF
-               NCWR = .TRUE.
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)
-#endif
-          ELSE
-#ifdef MNH_NCWRIT
-             IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-             END IF
-             LHRECFM = LEN_TRIM(ADJUSTL(HRECFM))
-             IF ( LHRECFM > 5 ) THEN
-               LHREC_BEG =LHRECFM-4
-               IF ( ADJUSTL(HRECFM(LHREC_BEG:LHRECFM)) == 'DATIM') THEN
-                   NCWR = .FALSE.
-               END IF
-             END IF
-!             IF ( NIMAX /= 0 ) THEN
-               IF ( LNETCDF .AND. NC_WRITE .AND. NCWR ) THEN
-              IF ( NC_FILE == 'phy' ) THEN
-               CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE., &
-               SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-              END IF
-                 CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,PFIELD,.TRUE.,TZRECLIST, &
-                 & KLENCH,HCOMMENT)
-               END IF
-               NCWR = .TRUE.
-!             END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,PFIELD,TZFMH,IRESP)
-#endif
-          END IF
-       ELSE ! multiprocessor execution
-          CALL SECOND_MNH2(T0)
-          IF (ISP == TZFD%OWNER)  THEN
-             ! I/O processor case
-             CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)
-          ELSE
-             ALLOCATE(ZFIELDP(0,0))
-             GALLOC = .TRUE.
-          END IF
-          !   
-          IF (HDIR == 'XX' .OR. HDIR =='YY') THEN
-             CALL GATHER_XXFIELD(HDIR,PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM)
-          ELSEIF (HDIR == 'XY') THEN
-             IF (LPACK .AND. L2D) THEN
-                CALL GATHER_XXFIELD('XX',PFIELD(:,2),ZFIELDP(:,1),TZFD%OWNER,TZFD%COMM)
-             ELSE
-#ifdef MNH_GA
-          !
-          ! init/create the ga , dim3 = 1
-          !
-          CALL MNH_INIT_GA(SIZE(PFIELD,1),SIZE(PFIELD,2),1,HRECFM,"WRITE")
-         !
-         !   copy columun data to global arrays g_a 
-         !
-         ALLOCATE (ZFIELD_GA (SIZE(PFIELD,1),SIZE(PFIELD,2)))
-         ZFIELD_GA = PFIELD
-         call nga_put(g_a, lo_col, hi_col,ZFIELD_GA(NIXO_L,NIYO_L) , ld_col)  
-!!$         print*," nga_put =",HRECFM,g_a," lo_col=",lo_col," hi_col=",hi_col,ZFIELD_GA(NIXO_L,NIYO_L), &
-!!$          " NIXO_L=",NIXO_L,"NIYO_L=",NIYO_L," ld_col=",ld_col," ISP=",ISP
-         call ga_sync
-         DEALLOCATE (ZFIELD_GA)
-         IF (ISP == TZFD%OWNER)  THEN      
-            !
-            ! this proc get the  Z slide to write
-            !
-            lo_zplan(JPIZ) = 1
-            hi_zplan(JPIZ) = 1
-!!$            ALLOCATE (ZFIELDP_GA(IIU_ll,IJU_ll))
-            call nga_get(g_a, lo_zplan, hi_zplan,ZFIELDP, ld_zplan)
-!!$            print*,"nga_get=",HRECFM,g_a," lo_zplan=",lo_zplan," hi_zplan=",hi_zplan &
-!!$                 ,ZFIELDP(1,1)," ld_zplan=",ld_zplan
-         END IF
-!!$         call ga_sync
-#else
-         CALL GATHER_XYFIELD(PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM)
-!!$         IF (ISP == TZFD%OWNER)  THEN   
-!!$            print*,HRECFM, "ERR=", MAXVAL (ZFIELDP_GA - ZFIELDP)
-!!$            DO JI=1,IJU_ll
-!!$            !print*,HRECFM, "ERR=", ZFIELDP_GA(:,JI) - ZFIELDP(:,JI)
-!!$            print*,HRECFM, "WX2::GA =", ZFIELDP_GA(:,JI) 
-!!$            print*,HRECFM, "WX2::MNH=", ZFIELDP(:,JI)
-!!$         END DO
-!!$         END IF
-#endif
-             END IF
-          END IF
-          CALL SECOND_MNH2(T1)
-          TIMEZ%T_WRIT2D_GATH=TIMEZ%T_WRIT2D_GATH + T1 - T0
-          !
-          IF (ISP == TZFD%OWNER)  THEN             
-             TZFMH%GRID=KGRID
-             TZFMH%COMLEN=KLENCH
-             TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-             IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-             END IF
-             LHRECFM = LEN_TRIM(ADJUSTL(HRECFM))
-             IF ( LHRECFM > 5 ) THEN
-               LHREC_BEG =LHRECFM-4
-               IF ( ADJUSTL(HRECFM(LHREC_BEG:LHRECFM)) == 'DATIM') THEN
-                   NCWR = .FALSE.
-               END IF
-             END IF
-               IF ( LNETCDF .AND. NC_WRITE .AND. NCWR ) THEN
-              TABDIM(1)=SIZE(ZFIELDP,1)
-              TABDIM(2)=SIZE(ZFIELDP,2)
-                 CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP,.TRUE.,TZRECLIST, &
-!                 CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP, &
-                 & KLENCH,HCOMMENT)
-              END IF
-                NCWR=.TRUE.
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)
-#endif
-          END IF
-#ifdef MNH_GA
-!!$         IF (ISP .EQ. 1 ) THEN
-!!$         call ga_print_stats()
-!!$         call ga_summarize(1) 
-!!$         ENDIF
-         call ga_sync
-!!$         gstatus_ga =  ga_destroy(g_a)
-#endif     
-          CALL SECOND_MNH2(T2)
-          TIMEZ%T_WRIT2D_WRIT=TIMEZ%T_WRIT2D_WRIT + T2 - T1
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD&
-               & %COMM,IERR)
-       END IF
-    ELSE
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITX2_ll",HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH,IRESP)
-    END IF
-    IF (GALLOC) DEALLOCATE(ZFIELDP)
-    KRESP = IRESP
-    IF (ASSOCIATED(TZFD)) CALL MPI_BARRIER(TZFD%COMM,IERR)
-    CALL SECOND_MNH2(T22)
-    TIMEZ%T_WRIT2D_ALL=TIMEZ%T_WRIT2D_ALL + T22 - T11
-  END SUBROUTINE FMWRITX2_ll
-
-  SUBROUTINE FMWRITX3_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&
-       KLENCH,HCOMMENT,KRESP)
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT,LPACK,L1D,L2D
-    USE MODD_PARAMETERS_ll,ONLY : JPHEXT
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-    USE MODE_ALLOCBUFFER_ll
-    USE MODE_GATHER_ll
-    !JUANZ    
-    USE MODD_IO_ll, ONLY : ISNPROC
-    USE MODE_IO_ll, ONLY : io_file,io_rank
-    USE MODD_TIMEZ, ONLY : TIMEZ
-    USE MODE_MNH_TIMING, ONLY : SECOND_MNH2
-    !JUANZ 
-#ifdef MNH_NCWRIT
-    USE MODE_UTIL
-    USE MODD_DIM_n, ONLY: NIMAX
-    USE MODD_NCOUT
-#endif
-#ifdef MNH_GA
-    USE MODE_GA
-#endif
-    USE MODD_VAR_ll, ONLY : MNH_STATUSES_IGNORE
-    !
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),            INTENT(IN) ::HFILEM   ! FM-file name
-    CHARACTER(LEN=*),            INTENT(IN) ::HRECFM   ! name of the article to write
-    CHARACTER(LEN=*),            INTENT(IN) ::HFIPRI   ! output file for error messages
-    CHARACTER(LEN=*),            INTENT(IN) ::HDIR     ! field form
-    REAL,DIMENSION(:,:,:),TARGET,INTENT(IN) ::PFIELD   ! array containing the data field
-    INTEGER,                     INTENT(IN) ::KGRID    ! C-grid indicator (u,v,w,T)
-    INTEGER,                     INTENT(IN) ::KLENCH   ! length of comment string
-    CHARACTER(LEN=*),            INTENT(IN) ::HCOMMENT ! comment string
-    INTEGER,                     INTENT(OUT)::KRESP    ! return-code 
-    !
-    !*      0.2   Declarations of local variables
-    !
-    CHARACTER(LEN=JPFINL)                    :: YFNLFI
-    INTEGER                                  :: IERR
-    TYPE(FD_ll), POINTER                     :: TZFD
-    INTEGER                                  :: IRESP
-    REAL,DIMENSION(:,:,:),POINTER            :: ZFIELDP
-    TYPE(FMHEADER)                           :: TZFMH
-    LOGICAL                                  :: GALLOC
-    !JUAN
-    INTEGER                                  :: JK,JKK
-    CHARACTER(LEN=LEN(HRECFM))               :: YK,YRECZSLIDE
-    REAL,DIMENSION(:,:),POINTER              :: ZSLIDE_ll,ZSLIDE
-    INTEGER                                  :: IK_FILE,IK_rank,inb_proc_real,JK_MAX
-    CHARACTER(len=5)                         :: YK_FILE  
-    CHARACTER(len=128)                       :: YFILE_IOZ  
-    TYPE(FD_ll), POINTER                     :: TZFD_IOZ 
-    INTEGER                                  :: JI,IXO,IXE,IYO,IYE
-    REAL,DIMENSION(:,:),POINTER              :: TX2DP
-    INTEGER, DIMENSION(MPI_STATUS_SIZE)      :: STATUS
-    INTEGER, ALLOCATABLE,DIMENSION(:,:)      :: STATUSES
-    LOGICAL                                  :: GALLOC_ll
-    !JUANZIO
-    !INTEGER,SAVE,DIMENSION(100000)    :: REQ_TAB
-    INTEGER,ALLOCATABLE,DIMENSION(:)         :: REQ_TAB
-    INTEGER                                  :: NB_REQ
-    TYPE TX_2DP
-       REAL,DIMENSION(:,:), POINTER    :: X
-    END TYPE TX_2DP
-    TYPE(TX_2DP),ALLOCATABLE,DIMENSION(:) :: T_TX2DP
-    REAL*8,DIMENSION(2) :: T0,T1,T2
-    REAL*8,DIMENSION(2) :: T11,T22
-    !JUANZIO
-    !JUAN
-#ifdef MNH_NCWRIT
-    TYPE(workfield), DIMENSION(:), POINTER   :: TZRECLIST
-    INTEGER,DIMENSION(6)                     :: TABDIM
-    CHARACTER(LEN=LEN(HRECFM))               :: HRECT
-    INTEGER                                  :: LHRECT
-#endif
-#ifdef MNH_GA
-    REAL,DIMENSION(:,:,:),POINTER          :: ZFIELD_GA
-#endif
-    !
-    !*      1.1   THE NAME OF LFIFM
-    !
-    CALL SECOND_MNH2(T11)
-    IRESP = 0
-    GALLOC    = .FALSE.
-    GALLOC_ll = .FALSE.
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-    !print * , ' Writing Article 3 ' , HRECFM
-!
-#ifdef MNH_NCWRIT
-    HRECT=TRIM(HRECFM)
-    LHRECT=LEN(TRIM(HRECT))
-    TABDIM(:)=1
-    TABDIM(1)=SIZE(PFIELD,1)
-    TABDIM(2)=SIZE(PFIELD,2)
-    TABDIM(3)=SIZE(PFIELD,3)
-   IF ( LHRECT .gt. 4 ) THEN
-      IF ( HRECT(LHRECT-4:LHRECT) == 'TRAJZ' ) THEN
-           TABDIM(3)=SIZE(PFIELD,1)
-           TABDIM(1)=1
-      END IF
-   END IF
-    IF ( TRIM(HRECFM)  == 'AVION.TRAJX' ) THEN
-         TABDIM(1)=SIZE(PFIELD,2)
-         TABDIM(2)=1
-    ELSEIF ( TRIM(HRECFM)  == 'AVION.TRAJY' ) THEN
-         TABDIM(1)=SIZE(PFIELD,2)
-         TABDIM(2)=1
-    ELSEIF ( TRIM(HRECFM)  == 'AVION.TRAJZ' ) THEN
-         TABDIM(1)=SIZE(PFIELD,2)
-         TABDIM(2)=1
-  END IF 
-#endif
-    !------------------------------------------------------------------
-    TZFD=>GETFD(YFNLFI)
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC .AND.  (TZFD%nb_procio.eq.1) ) THEN ! sequential execution
-          TZFMH%GRID=KGRID
-          TZFMH%COMLEN=KLENCH
-          TZFMH%COMMENT=HCOMMENT
-          !    IF (LPACK .AND. L1D .AND. HDIR=='XY') THEN 
-          IF (LPACK .AND. L1D .AND. SIZE(PFIELD,1)==2*JPHEXT+1 .AND. SIZE(PFIELD,2)==2*JPHEXT+1) THEN 
-             ZFIELDP=>PFIELD(2:2,2:2,:)
-#ifdef MNH_NCWRIT
-        IF ( DEF_NC .AND. LLFIFM ) THEN
-          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-        END IF
-        IF ( LNETCDF .AND. NC_WRITE ) THEN
-          TABDIM(1)=1
-          TABDIM(2)=1
-          CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP,.TRUE.,TZRECLIST, &
-             & KLENCH,HCOMMENT)
-        END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)
-#endif
-             !    ELSE IF (LPACK .AND. L2D .AND. HDIR=='XY') THEN
-          ELSEIF (LPACK .AND. L2D .AND. SIZE(PFIELD,2)==2*JPHEXT+1) THEN
-             ZFIELDP=>PFIELD(:,2:2,:)
-#ifdef MNH_NCWRIT
-        IF ( DEF_NC .AND. LLFIFM ) THEN
-          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-        END IF
-        IF ( LNETCDF .AND. NC_WRITE ) THEN
-           TABDIM(2)=1
-          IF ( NC_FILE == 'phy' ) THEN
-            CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-          END IF
-           CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP,.TRUE.,TZRECLIST, &
-!            CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP, &
-               & KLENCH,HCOMMENT)
-        END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)
-#endif
-          ELSE
-#ifdef MNH_NCWRIT
-        IF ( DEF_NC .AND. LLFIFM ) THEN
-          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-        END IF
-        IF ( LNETCDF .AND. NC_WRITE ) THEN
-          IF ( NC_FILE == 'phy' ) THEN
-            CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-          END IF
-            CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,PFIELD,.TRUE.,TZRECLIST, &
-!             CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,PFIELD, &
-                & KLENCH,HCOMMENT)
-        END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,PFIELD,TZFMH,IRESP)
-#endif
-          END IF
-       ELSEIF ( (TZFD%nb_procio .eq. 1 ) .OR. ( HDIR == '--' ) ) THEN  ! multiprocessor execution & 1 proc IO
-          ! write 3D field in 1 time = output for graphique
-          IF (ISP == TZFD%OWNER)  THEN
-             CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)
-          ELSE
-             ALLOCATE(ZFIELDP(0,0,0))
-             GALLOC = .TRUE.
-          END IF
-          !
-          IF (HDIR == 'XX' .OR. HDIR =='YY') THEN
-             CALL GATHER_XXFIELD(HDIR,PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM)
-          ELSEIF (HDIR == 'XY') THEN
-             IF (LPACK .AND. L2D) THEN
-                CALL GATHER_XXFIELD('XX',PFIELD(:,2,:),ZFIELDP(:,1,:),TZFD%OWNER,TZFD%COMM)
-             ELSE
-                CALL GATHER_XYFIELD(PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM)
-             END IF
-          END IF
-          !
-          IF (ISP == TZFD%OWNER)  THEN
-             TZFMH%GRID=KGRID
-             TZFMH%COMLEN=KLENCH
-             TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-        IF ( DEF_NC .AND. LLFIFM ) THEN
-          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-               & ,IRESP)
-        END IF
-        IF ( LNETCDF .AND. NC_WRITE ) THEN
-           TABDIM(1)=SIZE(ZFIELDP,1)
-           TABDIM(2)=SIZE(ZFIELDP,2)
-           TABDIM(3)=SIZE(ZFIELDP,3)
-           IF ( NC_FILE == ' phy' ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-          END IF
-             CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP,.TRUE.,TZRECLIST, &
-!                CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP, &
-               & KLENCH,HCOMMENT)
-        END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)
-#endif
-       END IF
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD&
-               & %COMM,IERR)
-          !
-       ELSE ! multiprocessor execution & // IO
-          !
-          !JUAN BG Z SLIDE 
-          !
-          !
-#ifdef MNH_GA
-          !
-          ! init/create the ga
-          !
-          CALL SECOND_MNH2(T0)
-          CALL MNH_INIT_GA(SIZE(PFIELD,1),SIZE(PFIELD,2),SIZE(PFIELD,3),HRECFM,"WRITE")
-         !
-         !   copy columun data to global arrays g_a 
-         !
-         ALLOCATE (ZFIELD_GA (SIZE(PFIELD,1),SIZE(PFIELD,2),SIZE(PFIELD,3)))
-         ZFIELD_GA = PFIELD
-         call nga_put(g_a, lo_col, hi_col,ZFIELD_GA(NIXO_L,NIYO_L,1) , ld_col)  
-         DEALLOCATE(ZFIELD_GA)
-!!$         print*," nga_put =",HRECFM,g_a," lo_col=",lo_col," hi_col=",hi_col,PFIELD(NIXO_L,NIYO_L,1) &
-!!$          ," ld_col=",ld_col
-         call ga_sync
-         CALL SECOND_MNH2(T1)
-         TIMEZ%T_WRIT3D_SEND=TIMEZ%T_WRIT3D_SEND + T1 - T0
-         !
-         ! write the data
-         !
-         ALLOCATE(ZSLIDE_ll(0,0)) ! to avoid bug on test of size
-         GALLOC_ll = .TRUE.
-         !
-         DO JKK=1,IKU_ll
-            !
-            IK_FILE   =  io_file(JKK,TZFD%nb_procio)
-            write(YK_FILE ,'(".Z",i3.3)') IK_FILE+1
-            YFILE_IOZ =  TRIM(HFILEM)//YK_FILE//".lfi"
-            TZFD_IOZ => GETFD(YFILE_IOZ)
-            !
-            IK_RANK   =  TZFD_IOZ%OWNER
-            !IK_RANK   =  1 + io_rank(IK_FILE,ISNPROC,TZFD%nb_procio)
-            !
-            IF (ISP == IK_RANK )  THEN 
-               CALL SECOND_MNH2(T0)
-               TZFMH%GRID=KGRID
-               TZFMH%COMLEN=KLENCH
-               TZFMH%COMMENT=HCOMMENT
-               WRITE(YK,'(I4.4)')  JKK
-               YRECZSLIDE = TRIM(HRECFM)//YK
-               !
-               IF ( SIZE(ZSLIDE_ll) .EQ. 0 ) THEN
-                  DEALLOCATE(ZSLIDE_ll)
-                  CALL ALLOCBUFFER_ll(ZSLIDE_ll,ZSLIDE,HDIR,GALLOC_ll)
-               END IF
-               !
-               ! this proc get this JKK slide
-               !
-               lo_zplan(JPIZ) = JKK
-               hi_zplan(JPIZ) = JKK
-               call nga_get(g_a, lo_zplan, hi_zplan,ZSLIDE_ll, ld_zplan)
-               CALL SECOND_MNH2(T1)
-               TIMEZ%T_WRIT3D_RECV=TIMEZ%T_WRIT3D_RECV + T1 - T0
-               !
-               IF (LLFIOUT) CALL FM_WRIT_ll(TZFD_IOZ%FLU,YRECZSLIDE,.TRUE.,SIZE(ZSLIDE_ll),&
-                    &ZSLIDE_ll,TZFMH,IRESP)
-               IF (LIOCDF4) CALL NCWRIT(TZFD_IOZ%CDF,YRECZSLIDE,HDIR,ZSLIDE_ll,TZFMH,IRESP)
-               CALL SECOND_MNH2(T2)
-               TIMEZ%T_WRIT3D_WRIT=TIMEZ%T_WRIT3D_WRIT + T2 - T1
-            END IF
-         END DO
-         !call ga_sync
-         !
-         ! destroy the global array 
-         !
-!!$         IF (ISP .EQ. 1 ) THEN
-!!$         call ga_print_stats()
-!!$         call ga_summarize(1) 
-!!$         ENDIF
-         CALL SECOND_MNH2(T0) 
-         call ga_sync
-!!$         gstatus_ga =  ga_destroy(g_a)
-         CALL SECOND_MNH2(T1) 
-         TIMEZ%T_WRIT3D_WAIT=TIMEZ%T_WRIT3D_WAIT + T1 - T0     
-#else
-          !
-          ALLOCATE(ZSLIDE_ll(0,0))
-          GALLOC_ll = .TRUE.
-          inb_proc_real = min(TZFD%nb_procio,ISNPROC)
-          Z_SLIDE: DO JK=1,SIZE(PFIELD,3),inb_proc_real
-             !
-             ! collecte the data
-             !
-             JK_MAX=min(SIZE(PFIELD,3),JK+inb_proc_real-1)
-             !
-             NB_REQ=0
-             ALLOCATE(REQ_TAB(inb_proc_real))
-             ALLOCATE(T_TX2DP(inb_proc_real))
-             DO JKK=JK,JK_MAX
-                !
-                ! get the file & rank to write this level
-                !
-                IF (TZFD%NB_PROCIO .GT. 1 ) THEN
-                   IK_FILE   =  io_file(JKK,TZFD%nb_procio)
-                   write(YK_FILE ,'(".Z",i3.3)') IK_FILE+1
-                   YFILE_IOZ =  TRIM(HFILEM)//YK_FILE//".lfi"
-                   TZFD_IOZ => GETFD(YFILE_IOZ)
-                ELSE
-                   TZFD_IOZ => TZFD
-                END IF
-                !
-                !IK_RANK   =  1 + io_rank(IK_FILE,ISNPROC,TZFD%nb_procio)
-                IK_RANK   =  TZFD_IOZ%OWNER
-                !
-                IF (HDIR == 'XX' .OR. HDIR =='YY') THEN
-                   STOP " XX NON PREVU SUR BG POUR LE MOMENT "
-                   CALL GATHER_XXFIELD(HDIR,PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM)
-                ELSEIF (HDIR == 'XY') THEN
-                   IF (LPACK .AND. L2D) THEN
-                      STOP " L2D NON PREVU SUR BG POUR LE MOMENT "
-                      CALL GATHER_XXFIELD('XX',PFIELD(:,2,:),ZFIELDP(:,1,:),TZFD%OWNER,TZFD%COMM)
-                   ELSE
-                      !CALL GATHER_XYFIELD(ZSLIDE,ZSLIDE_ll,TZFD_IOZ%OWNER,TZFD_IOZ%COMM)
-                      !JUANIOZ
-                      CALL SECOND_MNH2(T0)
-                      IF ( ISP /= IK_RANK )  THEN
-                         ! Other processors
-                         CALL GET_DOMWRITE_ll(ISP,'local',IXO,IXE,IYO,IYE)
-                         IF (IXO /= 0) THEN ! intersection is not empty
-                            NB_REQ = NB_REQ + 1
-                            ALLOCATE(T_TX2DP(NB_REQ)%X(IXO:IXE,IYO:IYE))
-                            ZSLIDE => PFIELD(:,:,JKK)
-                            TX2DP=>ZSLIDE(IXO:IXE,IYO:IYE)
-                            T_TX2DP(NB_REQ)%X=ZSLIDE(IXO:IXE,IYO:IYE)
-                            CALL MPI_ISEND(T_TX2DP(NB_REQ)%X,SIZE(TX2DP),MPI_FLOAT,IK_RANK-1,99+IK_RANK &
-                                          & ,TZFD_IOZ%COMM,REQ_TAB(NB_REQ),IERR)
-                            !CALL MPI_BSEND(TX2DP,SIZE(TX2DP),MPI_FLOAT,IK_RANK-1,99+IK_RANK,TZFD_IOZ%COMM,IERR)                       
-                         END IF
-                      END IF
-                      CALL SECOND_MNH2(T1)
-                      TIMEZ%T_WRIT3D_SEND=TIMEZ%T_WRIT3D_SEND + T1 - T0
-                      !JUANIOZ
-                   END IF
-                END IF
-             END DO
-             !
-             ! write the data
-             !
-             DO JKK=JK,JK_MAX
-                IF (TZFD%NB_PROCIO .GT. 1 ) THEN
-                   IK_FILE   =  io_file(JKK,TZFD%nb_procio)
-                   write(YK_FILE ,'(".Z",i3.3)') IK_FILE+1
-                   YFILE_IOZ =  TRIM(HFILEM)//YK_FILE//".lfi"
-                   TZFD_IOZ => GETFD(YFILE_IOZ)
-                ELSE
-                   TZFD_IOZ => TZFD
-                ENDIF
-                IK_RANK   =  TZFD_IOZ%OWNER
-                !IK_RANK   =  1 + io_rank(IK_FILE,ISNPROC,TZFD%nb_procio)
-                !
-                IF (ISP == IK_RANK )  THEN
-                   !JUANIOZ
-                   CALL SECOND_MNH2(T0)
-                   ! I/O proc case
-                   IF ( SIZE(ZSLIDE_ll) .EQ. 0 ) THEN
-                      DEALLOCATE(ZSLIDE_ll)
-                      CALL ALLOCBUFFER_ll(ZSLIDE_ll,ZSLIDE,HDIR,GALLOC_ll)
-                   END IF
-                   DO JI=1,ISNPROC
-                      CALL GET_DOMWRITE_ll(JI,'global',IXO,IXE,IYO,IYE)
-                      IF (IXO /= 0) THEN ! intersection is not empty
-                         TX2DP=>ZSLIDE_ll(IXO:IXE,IYO:IYE)
-                         IF (ISP == JI) THEN 
-                            CALL GET_DOMWRITE_ll(JI,'local',IXO,IXE,IYO,IYE)
-                            ZSLIDE => PFIELD(:,:,JKK)
-                            TX2DP = ZSLIDE(IXO:IXE,IYO:IYE)
-                         ELSE 
-                            CALL MPI_RECV(TX2DP,SIZE(TX2DP),MPI_FLOAT,JI-1,99+IK_RANK,TZFD_IOZ%COMM,STATUS,IERR)
-                         END IF
-                      END IF
-                   END DO
-                   CALL SECOND_MNH2(T1)
-                   TIMEZ%T_WRIT3D_RECV=TIMEZ%T_WRIT3D_RECV + T1 - T0
-                   !JUANIOZ 
-                   TZFMH%GRID=KGRID
-                   TZFMH%COMLEN=KLENCH
-                   TZFMH%COMMENT=HCOMMENT
-                   WRITE(YK,'(I4.4)')  JKK
-                   YRECZSLIDE = TRIM(HRECFM)//YK
-                   IF (LLFIOUT) CALL FM_WRIT_ll(TZFD_IOZ%FLU,YRECZSLIDE,.TRUE.,SIZE(ZSLIDE_ll),ZSLIDE_ll,TZFMH&
-                        & ,IRESP)
-                   IF (LIOCDF4) CALL NCWRIT(TZFD_IOZ%CDF,YRECZSLIDE,HDIR,ZSLIDE_ll,TZFMH,IRESP)
-                   CALL SECOND_MNH2(T2)
-                   TIMEZ%T_WRIT3D_WRIT=TIMEZ%T_WRIT3D_WRIT + T2 - T1
-                END IF
-!!$           CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD_IOZ%OWNER-1,TZFD_IOZ%COMM,IERR)
-             END DO
-             !CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD_IOZ%OWNER-1,TZFD_IOZ%COMM,IERR)
-             !CALL MPI_BARRIER(TZFD_IOZ%COMM,IERR)
-             !
-             CALL SECOND_MNH2(T0) 
-             IF (NB_REQ .GT.0 ) THEN
-                !ALLOCATE(STATUSES(MPI_STATUS_SIZE,NB_REQ))
-                CALL MPI_WAITALL(NB_REQ,REQ_TAB,MNH_STATUSES_IGNORE,IERR)
-                !CALL MPI_WAITALL(NB_REQ,REQ_TAB,STATUSES,IERR)
-                !DEALLOCATE(STATUSES)
-                DO JI=1,NB_REQ ;  DEALLOCATE(T_TX2DP(JI)%X) ; ENDDO
-             END IF
-             DEALLOCATE(T_TX2DP)
-             DEALLOCATE(REQ_TAB)
-             CALL SECOND_MNH2(T1) 
-             TIMEZ%T_WRIT3D_WAIT=TIMEZ%T_WRIT3D_WAIT + T1 - T0
-          END DO Z_SLIDE
-          !JUAN BG Z SLIDE  
-! end of MNH_GA
-#endif
-       END IF ! multiprocessor execution
-    ELSE
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITX3_ll",HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH,IRESP)
-    END IF
-    IF (GALLOC) DEALLOCATE(ZFIELDP)
-    IF (GALLOC_ll) DEALLOCATE(ZSLIDE_ll)
-    !IF (Associated(ZSLIDE_ll)) DEALLOCATE(ZSLIDE_ll)
-    KRESP = IRESP
-    IF (ASSOCIATED(TZFD)) CALL MPI_BARRIER(TZFD%COMM,IERR)
-    CALL SECOND_MNH2(T22)
-    TIMEZ%T_WRIT3D_ALL=TIMEZ%T_WRIT3D_ALL + T22 - T11
-  END SUBROUTINE FMWRITX3_ll
-
-  SUBROUTINE FMWRITX4_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&
-       KLENCH,HCOMMENT,KRESP)
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT,LPACK,L1D,L2D
-    USE MODD_PARAMETERS_ll,ONLY : JPHEXT
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-    USE MODE_ALLOCBUFFER_ll
-    USE MODE_GATHER_ll
-!!!!! MOD SB
-#ifdef MNH_NCWRIT
-    USE MODD_NCOUT
-    USE MODE_UTIL
-#endif
-!!!!! MOD SB
-    !
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),              INTENT(IN) ::HFILEM   ! FM-file name
-    CHARACTER(LEN=*),              INTENT(IN) ::HRECFM   ! name of the article to write
-    CHARACTER(LEN=*),              INTENT(IN) ::HFIPRI   ! output file for error messages
-    CHARACTER(LEN=*),              INTENT(IN) ::HDIR     ! field form
-    REAL,DIMENSION(:,:,:,:),TARGET,INTENT(IN) ::PFIELD   ! array containing the data field
-    INTEGER,                       INTENT(IN) ::KGRID    ! C-grid indicator (u,v,w,T)
-    INTEGER,                       INTENT(IN) ::KLENCH   ! length of comment string
-    CHARACTER(LEN=*),              INTENT(IN) ::HCOMMENT ! comment string
-    INTEGER,                       INTENT(OUT)::KRESP    ! return-code 
-    !
-    !*      0.2   Declarations of local variables
-    !
-    CHARACTER(LEN=JPFINL)                    :: YFNLFI
-    INTEGER                                  :: IERR
-    TYPE(FD_ll), POINTER                     :: TZFD
-    INTEGER                                  :: IRESP
-    REAL,DIMENSION(:,:,:,:),POINTER          :: ZFIELDP
-    TYPE(FMHEADER)                           :: TZFMH
-    LOGICAL                                  :: GALLOC
-    !
-    !*      1.1   THE NAME OF LFIFM
-    !
-    IRESP = 0
-    GALLOC = .FALSE.
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-    !print * , ' Writing Article 4 ' , HRECFM
-    !------------------------------------------------------------------
-    TZFD=>GETFD(YFNLFI)
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN ! sequential execution
-          TZFMH%GRID=KGRID
-          TZFMH%COMLEN=KLENCH
-          TZFMH%COMMENT=HCOMMENT
-          !    IF (LPACK .AND. L1D .AND. HDIR=='XY') THEN 
-          IF (LPACK .AND. L1D .AND. SIZE(PFIELD,1)==2*JPHEXT+1 .AND. SIZE(PFIELD,2)==2*JPHEXT+1) THEN 
-             ZFIELDP=>PFIELD(2:2,2:2,:,:)
-#ifdef MNH_NCWRIT
-           IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-           END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)
-#endif
-             !    ELSE IF (LPACK .AND. L2D .AND. HDIR=='XY') THEN
-          ELSEIF (LPACK .AND. L2D  .AND. SIZE(PFIELD,2)==2*JPHEXT+1) THEN
-             ZFIELDP=>PFIELD(:,2:2,:,:)
-#ifdef MNH_NCWRIT
-          IF ( DEF_NC .AND. LLFIFM ) THEN
-            CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-          END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)
-#endif
-          ELSE
-#ifdef MNH_NCWRIT
-          IF ( DEF_NC .AND. LLFIFM ) THEN
-            CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-          END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,PFIELD,TZFMH,IRESP)
-#endif
-          END IF
-       ELSE
-          IF (ISP == TZFD%OWNER)  THEN
-             CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)
-          ELSE
-             ALLOCATE(ZFIELDP(0,0,0,0))
-             GALLOC = .TRUE.
-          END IF
-          !
-          IF (HDIR == 'XX' .OR. HDIR =='YY') THEN
-             CALL GATHER_XXFIELD(HDIR,PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM)
-          ELSEIF (HDIR == 'XY') THEN
-             IF (LPACK .AND. L2D) THEN
-                CALL GATHER_XXFIELD('XX',PFIELD(:,2,:,:),ZFIELDP(:,1,:,:),TZFD%OWNER,TZFD%COMM)
-             ELSE
-                CALL GATHER_XYFIELD(PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM)
-             END IF
-          END IF
-          !
-          IF (ISP == TZFD%OWNER)  THEN
-             TZFMH%GRID=KGRID
-             TZFMH%COMLEN=KLENCH
-             TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-           IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-           END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)
-#endif
-          END IF
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-       END IF ! multiprocessor execution
-    ELSE 
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITX4_ll",HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH,IRESP)
-    END IF
-    IF (GALLOC) DEALLOCATE(ZFIELDP)
-    KRESP = IRESP
-  END SUBROUTINE FMWRITX4_ll
-
-  SUBROUTINE FMWRITX5_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&
-       KLENCH,HCOMMENT,KRESP)
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT,LPACK,L1D,L2D
-    USE MODD_PARAMETERS_ll,ONLY : JPHEXT
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-    USE MODE_ALLOCBUFFER_ll
-    USE MODE_GATHER_ll
-#ifdef MNH_NCWRIT
-    USE MODE_UTIL
-    USE MODD_DIM_n
-    USE MODD_NCOUT
-#endif
-    !
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),                INTENT(IN) ::HFILEM   ! FM-file name
-    CHARACTER(LEN=*),                INTENT(IN) ::HRECFM   ! name of the article to write
-    CHARACTER(LEN=*),                INTENT(IN) ::HFIPRI   ! output file for error messages
-    CHARACTER(LEN=*),                INTENT(IN) ::HDIR     ! field form
-    REAL,DIMENSION(:,:,:,:,:),TARGET,INTENT(IN) ::PFIELD ! array containing the data field
-    INTEGER,                         INTENT(IN) ::KGRID    ! C-grid indicator (u,v,w,T)
-    INTEGER,                         INTENT(IN) ::KLENCH   ! length of comment string
-    CHARACTER(LEN=*),                INTENT(IN) ::HCOMMENT ! comment string
-    INTEGER,                         INTENT(OUT)::KRESP    ! return-code 
-    !
-    !*      0.2   Declarations of local variables
-    !
-    CHARACTER(LEN=JPFINL)                    :: YFNLFI
-    INTEGER                                  :: IERR
-    TYPE(FD_ll), POINTER                     :: TZFD
-    INTEGER                                  :: IRESP
-    REAL,DIMENSION(:,:,:,:,:),POINTER        :: ZFIELDP
-    TYPE(FMHEADER)                           :: TZFMH
-    LOGICAL                                  :: GALLOC
-#ifdef MNH_NCWRIT
-    TYPE(workfield), DIMENSION(:), POINTER   :: TZRECLIST
-    INTEGER,DIMENSION(6)         :: TABDIM
-#endif
-    !
-    !*      1.1   THE NAME OF LFIFM
-    !
-    IRESP = 0
-    GALLOC = .FALSE.
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-#ifdef MNH_NCWRIT
-    TABDIM(:)=1
-    TABDIM(1)=SIZE(PFIELD,1)
-    TABDIM(2)=SIZE(PFIELD,2)
-    TABDIM(3)=SIZE(PFIELD,3)
-    TABDIM(4)=SIZE(PFIELD,4)
-    TABDIM(5)=SIZE(PFIELD,5)
-    !print * , ' Writing Article 5 ' , HRECFM
-#endif
-    !------------------------------------------------------------------
-    TZFD=>GETFD(YFNLFI)
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN ! sequential execution
-          TZFMH%GRID=KGRID
-          TZFMH%COMLEN=KLENCH
-          TZFMH%COMMENT=HCOMMENT
-          !    IF (LPACK .AND. L1D .AND. HDIR=='XY') THEN 
-          IF (LPACK .AND. L1D .AND. SIZE(PFIELD,1)==2*JPHEXT+1 .AND. SIZE(PFIELD,2)==2*JPHEXT+1) THEN 
-             ZFIELDP=>PFIELD(2:2,2:2,:,:,:)
-#ifdef MNH_NCWRIT
-            IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-            END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)
-#endif
-             !    ELSE IF (LPACK .AND. L2D .AND. HDIR=='XY') THEN
-     ELSEIF (LPACK .AND. L2D .AND. SIZE(PFIELD,2)==2*JPHEXT+1) THEN
-             ZFIELDP=>PFIELD(:,2:2,:,:,:)
-#ifdef MNH_NCWRIT
-            IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-            END IF
-            IF ( LNETCDF .AND. NC_WRITE ) THEN
-             TABDIM(2)=1
-              IF ( NC_FILE == 'phy' ) THEN
-                 CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP), &
-                 ZFIELDP,TZFMH,IRESP)
-              END IF
-               CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP,.TRUE.,TZRECLIST, &
-!               CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP, &
-               & KLENCH,HCOMMENT)
-             END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)
-#endif
-          ELSE
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-               END IF
-             IF ( LNETCDF .AND. NC_WRITE ) THEN
-              IF ( NC_FILE == 'phy' ) THEN
-                 CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD), &
-                     PFIELD,TZFMH,IRESP)
-              END IF
-               CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,PFIELD,.TRUE.,TZRECLIST, &
-!               CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,PFIELD, &
-               & KLENCH,HCOMMENT)
-             END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,PFIELD,TZFMH,IRESP)
-#endif
-          END IF
-       ELSE
-          IF (ISP == TZFD%OWNER)  THEN
-             CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)
-          ELSE
-             ALLOCATE(ZFIELDP(0,0,0,0,0))
-             GALLOC = .TRUE.
-          END IF
-          !
-          IF (HDIR == 'XX' .OR. HDIR =='YY') THEN
-             CALL GATHER_XXFIELD(HDIR,PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM)
-          ELSEIF (HDIR == 'XY') THEN
-             IF (LPACK .AND. L2D) THEN
-                CALL GATHER_XXFIELD('XX',PFIELD(:,2,:,:,:),ZFIELDP(:,1,:,:,:),&
-                     & TZFD%OWNER,TZFD%COMM)
-             ELSE
-                CALL GATHER_XYFIELD(PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM)
-             END IF
-          END IF
-          !
-          IF (ISP == TZFD%OWNER)  THEN
-             TZFMH%GRID=KGRID
-             TZFMH%COMLEN=KLENCH
-             TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-                END IF
-             IF ( LNETCDF .AND. NC_WRITE ) THEN
-              IF ( NC_FILE == 'phy' ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-              END IF
-         CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP,.TRUE.,TZRECLIST, &
-!               CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP, &
-               & KLENCH,HCOMMENT)
-             END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)
-#endif
-          END IF
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-       END IF ! multiprocessor execution
-    ELSE 
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITX5_ll",HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH,IRESP)
-    END IF
-    IF (GALLOC) DEALLOCATE(ZFIELDP)
-    KRESP = IRESP
-  END SUBROUTINE FMWRITX5_ll
-
-  SUBROUTINE FMWRITX6_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&
-       KLENCH,HCOMMENT,KRESP)
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-    USE MODE_ALLOCBUFFER_ll
-    USE MODE_GATHER_ll
-    !
-!!!! MOD SB
-#ifdef MNH_NCWRIT
-    USE MODD_NCOUT
-    USE MODE_UTIL
-#endif
-!!!! MOD SB
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),                INTENT(IN) ::HFILEM   ! FM-file name
-    CHARACTER(LEN=*),                INTENT(IN) ::HRECFM   ! name of the article to write
-    CHARACTER(LEN=*),                INTENT(IN) ::HFIPRI   ! output file for error messages
-    CHARACTER(LEN=*),                INTENT(IN) ::HDIR     ! field form
-    REAL,DIMENSION(:,:,:,:,:,:),TARGET,INTENT(IN) ::PFIELD ! array containing the data field
-    INTEGER,                         INTENT(IN) ::KGRID    ! C-grid indicator (u,v,w,T)
-    INTEGER,                         INTENT(IN) ::KLENCH   ! length of comment string
-    CHARACTER(LEN=*),                INTENT(IN) ::HCOMMENT ! comment string
-    INTEGER,                         INTENT(OUT)::KRESP    ! return-code 
-    !
-    !*      0.2   Declarations of local variables
-    !
-    CHARACTER(LEN=JPFINL)                    :: YFNLFI
-    INTEGER                                  :: IERR
-    TYPE(FD_ll), POINTER                     :: TZFD
-    INTEGER                                  :: IRESP
-    REAL,DIMENSION(:,:,:,:,:,:),POINTER        :: ZFIELDP
-    TYPE(FMHEADER)                           :: TZFMH
-    LOGICAL                                  :: GALLOC
-    !
-    !*      1.1   THE NAME OF LFIFM
-    !
-    IRESP = 0
-    GALLOC = .FALSE.
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-    !print * , ' Writing Article 6 ' , HRECFM
-    !------------------------------------------------------------------
-    TZFD=>GETFD(YFNLFI)
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN ! sequential execution
-          TZFMH%GRID=KGRID
-          TZFMH%COMLEN=KLENCH
-          TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-               END IF
-#else
-          IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)
-          IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,PFIELD,TZFMH,IRESP)
-#endif
-       ELSE ! multiprocessor execution
-          IF (ISP == TZFD%OWNER)  THEN
-             CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)
-          ELSE
-             ALLOCATE(ZFIELDP(0,0,0,0,0,0))
-             GALLOC = .TRUE.
-          END IF
-          !
-          IF (HDIR == 'XX' .OR. HDIR =='YY') THEN
-             CALL GATHER_XXFIELD(HDIR,PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM)
-          ELSEIF (HDIR == 'XY') THEN
-             CALL GATHER_XYFIELD(PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM)
-          END IF
-          !
-          IF (ISP == TZFD%OWNER)  THEN
-             TZFMH%GRID=KGRID
-             TZFMH%COMLEN=KLENCH
-             TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-               END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)
-#endif
-          END IF
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-       END IF ! multiprocessor execution
-    ELSE 
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITX6_ll",HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH,IRESP)
-    END IF
-    IF (GALLOC) DEALLOCATE(ZFIELDP)
-    KRESP = IRESP
-  END SUBROUTINE FMWRITX6_ll
-
-  SUBROUTINE FMWRITN0_ll(HFILEM,HRECFM,HFIPRI,HDIR,KFIELD,KGRID,&
-       KLENCH,HCOMMENT,KRESP)
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-    !*      0.    DECLARATIONS
-    !             ------------
-!!!! MOD SB
-#ifdef MNH_NCWRIT
-    USE MODD_NCOUT
-    USE MODE_UTIL 
-#endif
-!!!! MOD SB
-    !
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),   INTENT(IN) ::HFILEM  ! FM-file name
-    CHARACTER(LEN=*),   INTENT(IN) ::HRECFM  ! name of the article to read
-    CHARACTER(LEN=*),   INTENT(IN) ::HFIPRI  ! output file for error messages
-    CHARACTER(LEN=*),   INTENT(IN) ::HDIR    ! field form
-    INTEGER,            INTENT(IN) ::KFIELD  ! array containing the data field
-    INTEGER,            INTENT(IN) ::KGRID   ! C-grid indicator (u,v,w,T)
-    INTEGER,            INTENT(IN) ::KLENCH  ! length of comment string
-    CHARACTER(LEN=*),   INTENT(IN) ::HCOMMENT! comment string
-    INTEGER,            INTENT(OUT)::KRESP   ! return-code
-    !
-    !*      0.2   Declarations of local variables
-    !
-    CHARACTER(LEN=JPFINL)        :: YFNLFI
-    INTEGER                      :: IERR
-    TYPE(FD_ll), POINTER         :: TZFD
-    INTEGER                      :: IRESP
-    TYPE(FMHEADER)               :: TZFMH
-
-    !JUANZIO
-    INTEGER                                  :: IK_FILE,IK_rank
-    CHARACTER(len=5)                         :: YK_FILE  
-    CHARACTER(len=128)                       :: YFILE_IOZ  
-    TYPE(FD_ll), POINTER                     :: TZFD_IOZ 
-    !JUANZIO
-    !----------------------------------------------------------------
-    !
-    !*      1.1   THE NAME OF LFIFM
-    !
-    IRESP = 0
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-    !print * , ' Writing Article N0 ' , HRECFM
-    !------------------------------------------------------------------
-    TZFD=>GETFD(YFNLFI)
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN ! sequential execution
-          TZFMH%GRID=KGRID
-          TZFMH%COMLEN=KLENCH
-          TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,1,KFIELD,TZFMH,IRESP)
-               END IF
-#else
-          IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,1,KFIELD,TZFMH,IRESP)
-          IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,KFIELD,TZFMH,IRESP)
-#endif
-       ELSE 
-          IF (ISP == TZFD%OWNER)  THEN
-             TZFMH%GRID=KGRID
-             TZFMH%COMLEN=KLENCH
-             TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,1,KFIELD,TZFMH,IRESP)
-               END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,1,KFIELD,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,KFIELD,TZFMH,IRESP)
-#endif
-          END IF
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-
-       END IF ! multiprocessor execution
-       IF (TZFD%nb_procio.gt.1) THEN
-          ! write the data in all Z files
-          DO IK_FILE=1,TZFD%nb_procio
-             write(YK_FILE ,'(".Z",i3.3)')  IK_FILE
-             YFILE_IOZ =  TRIM(HFILEM)//YK_FILE//".lfi"
-             TZFD_IOZ => GETFD(YFILE_IOZ)   
-             IK_RANK = TZFD_IOZ%OWNER
-             IF ( ISP == IK_RANK )  THEN
-                TZFMH%GRID=KGRID
-                TZFMH%COMLEN=KLENCH
-                TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-                CALL FM_WRIT_ll(TZFD_IOZ%FLU,HRECFM,.FALSE.,1,KFIELD,TZFMH,IRESP)
-               END IF
-#else
-                IF (LLFIOUT) CALL FM_WRIT_ll(TZFD_IOZ%FLU,HRECFM,.FALSE.,1,KFIELD,TZFMH,IRESP)
-                IF (LIOCDF4) CALL NCWRIT(TZFD_IOZ%CDF,HRECFM,HDIR,KFIELD,TZFMH,IRESP)
-#endif
-             END IF
-          END DO
-       ENDIF
-    ELSE 
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITN0_ll",HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH&
-            & ,IRESP)
-    END IF
-    KRESP = IRESP
-  END SUBROUTINE FMWRITN0_ll
-
-  SUBROUTINE FMWRITN1_ll(HFILEM,HRECFM,HFIPRI,HDIR,KFIELD,KGRID,&
-       KLENCH,HCOMMENT,KRESP)
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-    USE MODE_ALLOCBUFFER_ll
-    USE MODE_GATHER_ll
-    !*      0.    DECLARATIONS
-    !             ------------
-!!!! MOD SB
-#ifdef MNH_NCWRIT
-    USE MODD_NCOUT
-    USE MODE_UTIL
-#endif
-!!!! MOD SB
-    !
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),           INTENT(IN) ::HFILEM   ! FM-file name
-    CHARACTER(LEN=*),           INTENT(IN) ::HRECFM   ! name of the article to write
-    CHARACTER(LEN=*),           INTENT(IN) ::HFIPRI   ! output file for error messages
-    CHARACTER(LEN=*),           INTENT(IN) ::HDIR     ! field form
-    INTEGER,DIMENSION(:),TARGET,INTENT(IN) ::KFIELD   ! array containing the data field
-    INTEGER,                    INTENT(IN) ::KGRID    ! C-grid indicator (u,v,w,T)
-    INTEGER,                    INTENT(IN) ::KLENCH   ! length of comment string
-    CHARACTER(LEN=*),           INTENT(IN) ::HCOMMENT ! comment string
-    INTEGER,                    INTENT(OUT)::KRESP    ! return-code 
-    !
-    !*      0.2   Declarations of local variables
-    !
-    CHARACTER(LEN=JPFINL)        :: YFNLFI
-    INTEGER                      :: IERR
-    TYPE(FD_ll), POINTER         :: TZFD
-    INTEGER                      :: IRESP
-    TYPE(FMHEADER)               :: TZFMH
-    INTEGER,DIMENSION(:),POINTER :: IFIELDP
-    LOGICAL                      :: GALLOC
-#ifdef MNH_NCWRIT
-    REAL,DIMENSION(SIZE(KFIELD)) ::WFIELD
-    TYPE(workfield), DIMENSION(:), POINTER   :: TZRECLIST
-    INTEGER,DIMENSION(6)         :: TABDIM
-#endif
-    !----------------------------------------------------------------
-    !
-    !*      1.1   THE NAME OF LFIFM
-    !
-    IRESP = 0
-    GALLOC = .FALSE.
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-    !print * , ' Writing Article N1 ' , HRECFM
-#ifdef MNH_NCWRIT
-    WFIELD = KFIELD
-    TABDIM(:)=1
-#endif
-    !------------------------------------------------------------------
-    TZFD=>GETFD(YFNLFI)
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN ! sequential execution
-          TZFMH%GRID=KGRID
-          TZFMH%COMLEN=KLENCH
-          TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(KFIELD),KFIELD,TZFMH,IRESP)
-               END IF
-               IF ( LNETCDF .AND. NC_WRITE ) THEN
-          CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,WFIELD, &
-          & .TRUE.,TZRECLIST,KLENCH,HCOMMENT)
-               END IF
-#else
-          IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(KFIELD),KFIELD,TZFMH,IRESP)
-          IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,KFIELD,TZFMH,IRESP)
-#endif
-       ELSE
-          IF (ISP == TZFD%OWNER)  THEN
-             CALL ALLOCBUFFER_ll(IFIELDP,KFIELD,HDIR,GALLOC)
-          ELSE
-             ALLOCATE(IFIELDP(0))
-             GALLOC = .TRUE.
-          END IF
-          !
-          IF (HDIR == 'XX' .OR. HDIR =='YY') THEN
-             CALL GATHER_XXFIELD(HDIR,KFIELD,IFIELDP,TZFD%OWNER,TZFD%COMM)
-          END IF
-          !
-          IF (ISP == TZFD%OWNER)  THEN
-             TZFMH%GRID=KGRID
-             TZFMH%COMLEN=KLENCH
-             TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELDP),IFIELDP,TZFMH&
-                  & ,IRESP)
-               END IF
-               IF ( LNETCDF .AND. NC_WRITE ) THEN
-          CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,WFIELD, &
-          .TRUE.,TZRECLIST,&
-                   & KLENCH,HCOMMENT)
-               END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELDP),IFIELDP,TZFMH&
-                  & ,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,IFIELDP,TZFMH,IRESP)
-#endif
-          END IF
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-       END IF
-    ELSE 
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITN1_ll",HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH&
-            & ,IRESP)
-    END IF
-    IF (GALLOC) DEALLOCATE(IFIELDP)
-    KRESP = IRESP
-  END SUBROUTINE FMWRITN1_ll
-
-  SUBROUTINE FMWRITN2_ll(HFILEM,HRECFM,HFIPRI,HDIR,KFIELD,KGRID,&
-       KLENCH,HCOMMENT,KRESP)
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT,LPACK,L1D,L2D
-    USE MODD_PARAMETERS_ll,ONLY : JPHEXT
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-    USE MODE_ALLOCBUFFER_ll
-    USE MODE_GATHER_ll
-    !
-!!!! MOD SB
-#ifdef MNH_NCWRIT
-    USE MODD_NCOUT
-    USE MODE_UTIL
-#endif
-!!!! MOD SB
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),             INTENT(IN) ::HFILEM   ! FM-file name
-    CHARACTER(LEN=*),             INTENT(IN) ::HRECFM   ! name of the article to write
-    CHARACTER(LEN=*),             INTENT(IN) ::HFIPRI   ! output file for error messages
-    CHARACTER(LEN=*),             INTENT(IN) ::HDIR     ! field form
-    INTEGER,DIMENSION(:,:),TARGET,INTENT(IN) ::KFIELD ! array containing the data field
-    INTEGER,                      INTENT(IN) ::KGRID    ! C-grid indicator (u,v,w,T)
-    INTEGER,                      INTENT(IN) ::KLENCH   ! length of comment string
-    CHARACTER(LEN=*),             INTENT(IN) ::HCOMMENT ! comment string
-    INTEGER,                      INTENT(OUT)::KRESP    ! return-code 
-    !
-    !*      0.2   Declarations of local variables
-    !
-    CHARACTER(LEN=JPFINL)                    :: YFNLFI
-    INTEGER                                  :: IERR
-    TYPE(FD_ll), POINTER                     :: TZFD
-    INTEGER                                  :: IRESP
-    INTEGER,DIMENSION(:,:),POINTER           :: IFIELDP
-    TYPE(FMHEADER)                           :: TZFMH
-    LOGICAL                                  :: GALLOC
-
-    !
-    !*      1.1   THE NAME OF LFIFM
-    !
-    IRESP = 0
-    GALLOC = .FALSE.
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-    !print * , ' Writing Article N2 ' , HRECFM
-    !
-    TZFD=>GETFD(YFNLFI)
-!    IF (ASSOCIATED(TZFD) .OR. .not.LLFIFM) THEN
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN ! sequential execution
-          TZFMH%GRID=KGRID
-          TZFMH%COMLEN=KLENCH
-          TZFMH%COMMENT=HCOMMENT
-          !    IF (LPACK .AND. L1D .AND. HDIR=='XY') THEN 
-          IF (LPACK .AND. L1D .AND. SIZE(KFIELD,1)==2*JPHEXT+1 .AND. SIZE(KFIELD,2)==2*JPHEXT+1) THEN 
-             IFIELDP=>KFIELD(2:2,2:2)
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELDP),IFIELDP,TZFMH,IRESP)
-               END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELDP),IFIELDP,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,IFIELDP,TZFMH,IRESP)
-#endif
-             !    ELSE IF (LPACK .AND. L2D .AND. HDIR=='XY') THEN
-          ELSEIF (LPACK .AND. L2D .AND. SIZE(KFIELD,2)==2*JPHEXT+1) THEN
-             IFIELDP=>KFIELD(:,2:2)
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELDP),IFIELDP,TZFMH,IRESP)
-               END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELDP),IFIELDP,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,IFIELDP,TZFMH,IRESP)
-#endif
-          ELSE
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(KFIELD),KFIELD,TZFMH,IRESP)
-               END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(KFIELD),KFIELD,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,KFIELD,TZFMH,IRESP)
-#endif
-          END IF
-       ELSE
-          IF (ISP == TZFD%OWNER)  THEN
-             CALL ALLOCBUFFER_ll(IFIELDP,KFIELD,HDIR,GALLOC)
-          ELSE
-             ALLOCATE(IFIELDP(0,0))
-             GALLOC = .TRUE.
-          END IF
-          !
-          IF (HDIR == 'XX' .OR. HDIR =='YY') THEN
-             CALL GATHER_XXFIELD(HDIR,KFIELD,IFIELDP,TZFD%OWNER,TZFD%COMM)
-          ELSEIF (HDIR == 'XY') THEN
-             IF (LPACK .AND. L2D) THEN
-                CALL GATHER_XXFIELD('XX',KFIELD(:,2),IFIELDP(:,1),TZFD%OWNER,TZFD%COMM)
-             ELSE
-                CALL GATHER_XYFIELD(KFIELD,IFIELDP,TZFD%OWNER,TZFD%COMM)
-             END IF
-          END IF
-          !
-          IF (ISP == TZFD%OWNER)  THEN
-             TZFMH%GRID=KGRID
-             TZFMH%COMLEN=KLENCH
-             TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELDP),IFIELDP,TZFMH&
-                  & ,IRESP)
-                END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELDP),IFIELDP,TZFMH&
-                  & ,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,IFIELDP,TZFMH,IRESP)
-#endif
-          END IF
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-       END IF
-
-    ELSE
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITN2_ll",HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH,IRESP)
-    END IF
-    IF (GALLOC) DEALLOCATE(IFIELDP)
-    KRESP = IRESP
-  END SUBROUTINE FMWRITN2_ll
-
-
-  SUBROUTINE FMWRITL0_ll(HFILEM,HRECFM,HFIPRI,HDIR,OFIELD,KGRID,&
-       KLENCH,HCOMMENT,KRESP)
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-
-!!!! MOD SB
-#ifdef MNH_NCWRIT
-    USE MODD_NCOUT
-    USE MODE_UTIL
-#endif
-!!!! MOD SB
-    !
-    !*      0.    DECLARATIONS
-    !             ------------
-    !
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*), INTENT(IN) ::HFILEM ! FM-file name
-    CHARACTER(LEN=*), INTENT(IN) ::HRECFM ! name of the article to read
-    CHARACTER(LEN=*), INTENT(IN) ::HFIPRI ! output file for error messages
-    CHARACTER(LEN=*), INTENT(IN) ::HDIR   ! field form
-    LOGICAL,          INTENT(IN) ::OFIELD ! array containing the data field
-    INTEGER,          INTENT(IN)::KGRID  ! C-grid indicator (u,v,w,T)
-    INTEGER,          INTENT(IN)::KLENCH ! length of comment string
-    CHARACTER(LEN=*), INTENT(IN)::HCOMMENT ! comment string
-    INTEGER,          INTENT(OUT)::KRESP    ! return-code
-    !
-    !*      0.2   Declarations of local variables
-    !
-    INTEGER                      :: IFIELD
-    CHARACTER(LEN=JPFINL)        :: YFNLFI
-    INTEGER                      :: IERR
-    TYPE(FD_ll), POINTER         :: TZFD
-    INTEGER                      :: IRESP
-    TYPE(FMHEADER)               :: TZFMH
-
-    !----------------------------------------------------------------
-    !
-    !*      1.1   THE NAME OF LFIFM
-    !
-    IRESP = 0
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-    !print * , ' Writing Article L0 ' , HRECFM
-    IF (OFIELD) THEN
-       IFIELD=1
-    ELSE
-       IFIELD=0
-    END IF
-    !----------------------------------------------------------------
-    TZFD=>GETFD(YFNLFI)
-!    IF (ASSOCIATED(TZFD) .OR. .not.LLFIFM) THEN
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN ! sequential execution
-          TZFMH%GRID=KGRID
-          TZFMH%COMLEN=KLENCH
-          TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,1,IFIELD,TZFMH,IRESP)
-               END IF
-#else
-          IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,1,IFIELD,TZFMH,IRESP)
-          IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,IFIELD,TZFMH,IRESP)
-#endif 
-       ELSE
-          IF (ISP == TZFD%OWNER)  THEN
-             TZFMH%GRID=KGRID
-             TZFMH%COMLEN=KLENCH
-             TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,1,IFIELD,TZFMH,IRESP)
-               END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,1,IFIELD,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,IFIELD,TZFMH,IRESP)
-#endif
-          END IF
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-       END IF
-    ELSE
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITL0_ll",HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH&
-            & ,IRESP)
-    END IF
-    KRESP = IRESP
-  END SUBROUTINE FMWRITL0_ll
-
-  SUBROUTINE FMWRITL1_ll(HFILEM,HRECFM,HFIPRI,HDIR,OFIELD,KGRID,&
-       KLENCH,HCOMMENT,KRESP)
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-
-    !*      0.    DECLARATIONS
-    !             ------------
-!!!! MOD SB
-#ifdef MNH_NCWRIT
-    USE MODD_NCOUT
-    USE MODE_UTIL
-#endif
-!!!! MOD SB
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),    INTENT(IN) ::HFILEM ! FM-file name
-    CHARACTER(LEN=*),    INTENT(IN) ::HRECFM ! name of the article to read
-    CHARACTER(LEN=*),    INTENT(IN) ::HFIPRI ! output file for error messages
-    CHARACTER(LEN=*),    INTENT(IN) ::HDIR   ! field form
-    LOGICAL,DIMENSION(:),INTENT(IN) ::OFIELD ! array containing the data field
-    INTEGER,             INTENT(IN)::KGRID  ! C-grid indicator (u,v,w,T)
-    INTEGER,             INTENT(IN)::KLENCH ! length of comment string
-    CHARACTER(LEN=*),    INTENT(IN)::HCOMMENT ! comment string
-    INTEGER,             INTENT(OUT)::KRESP    ! return-code
-    !
-    !*      0.2   Declarations of local variables
-    !
-    INTEGER, DIMENSION(SIZE(OFIELD)) :: IFIELD
-    CHARACTER(LEN=JPFINL)            :: YFNLFI
-    INTEGER                          :: IERR
-    TYPE(FD_ll), POINTER             :: TZFD
-    INTEGER                          :: IRESP
-    TYPE(FMHEADER)                   :: TZFMH
-
-    !----------------------------------------------------------------
-    !
-    !*      1.1   THE NAME OF LFIFM
-    !
-    IRESP = 0
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-    !print * , ' Writing Article L1 ' , HRECFM
-    WHERE (OFIELD)
-       IFIELD=1
-    ELSEWHERE
-       IFIELD=0
-    END WHERE
-    !----------------------------------------------------------------
-    TZFD=>GETFD(YFNLFI)
-!    IF (ASSOCIATED(TZFD) .OR. .not.LLFIFM) THEN
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN ! sequential execution
-          TZFMH%GRID=KGRID
-          TZFMH%COMLEN=KLENCH
-          TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELD),IFIELD,TZFMH,IRESP)
-               END IF
-#else
-          IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELD),IFIELD,TZFMH,IRESP)
-          IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,IFIELD,TZFMH,IRESP)
-#endif
-       ELSE
-          IF (ISP == TZFD%OWNER)  THEN
-             TZFMH%GRID=KGRID
-             TZFMH%COMLEN=KLENCH
-             TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELD),IFIELD,TZFMH,IRESP)
-               END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,SIZE(IFIELD),IFIELD,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,IFIELD,TZFMH,IRESP)
-#endif
-          END IF
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-       END IF
-    ELSE
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITL1_ll",HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH&
-            & ,IRESP)
-    END IF
-    KRESP = IRESP
-  END SUBROUTINE FMWRITL1_ll
-
-  SUBROUTINE FMWRITC0_ll(HFILEM,HRECFM,HFIPRI,HDIR,HFIELD,KGRID,&
-       KLENCH,HCOMMENT,KRESP)
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-    !
-    !*      0.    DECLARATIONS
-    !             ------------
-    !
-!!!! MOD SB
-#ifdef MNH_NCWRIT
-    USE MODD_NCOUT
-    USE MODE_UTIL
-#endif
-!!! MOD SB
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),  INTENT(IN) ::HFILEM ! FM-file name
-    CHARACTER(LEN=*),  INTENT(IN) ::HRECFM ! name of the article to read
-    CHARACTER(LEN=*),  INTENT(IN) ::HFIPRI ! output file for error messages
-    CHARACTER(LEN=*),  INTENT(IN) ::HDIR   ! field form
-    CHARACTER(LEN=*),  INTENT(IN) ::HFIELD ! array containing the data field
-    INTEGER,           INTENT(IN)::KGRID  ! C-grid indicator (u,v,w,T)
-    INTEGER,           INTENT(IN)::KLENCH ! length of comment string
-    CHARACTER(LEN=*),  INTENT(IN)::HCOMMENT ! comment string
-    INTEGER,           INTENT(OUT)::KRESP    ! return-code
-    !
-    !*      0.2   Declarations of local variables
-    !
-    INTEGER                          :: JLOOP
-    INTEGER,DIMENSION(:),ALLOCATABLE :: IFIELD
-    INTEGER                          :: ILENG
-    CHARACTER(LEN=JPFINL)            :: YFNLFI
-    INTEGER                          :: IERR
-    TYPE(FD_ll), POINTER             :: TZFD
-    INTEGER                          :: IRESP
-    TYPE(FMHEADER)                   :: TZFMH
-#ifdef MNH_NCWRIT
-    TYPE(workfield), DIMENSION(:), POINTER   :: TZRECLIST
-    INTEGER,DIMENSION(6)                     :: TABDIM
-#endif
-
-    !----------------------------------------------------------------
-    !*      1.1   THE NAME OF LFIFM
-    !
-    IRESP = 0
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-    !print * , ' Writing Article C0 ' , HRECFM
-    ILENG=LEN(HFIELD)
-#ifdef MNH_NCWRIT
-    TABDIM(:)=1
-    TABDIM(1)=ILENG
-#endif
-    !
-    IF (ILENG==0) THEN
-       ILENG=1
-       ALLOCATE(IFIELD(1))
-       IFIELD(1)=IACHAR(' ')
-    ELSE
-       ALLOCATE(IFIELD(ILENG))
-       DO JLOOP=1,ILENG
-          IFIELD(JLOOP)=IACHAR(HFIELD(JLOOP:JLOOP))
-       END DO
-    END IF
-    !----------------------------------------------------------------
-    TZFD=>GETFD(YFNLFI)
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN  ! sequential execution
-          TZFMH%GRID=KGRID
-          TZFMH%COMLEN=KLENCH
-          TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,ILENG,IFIELD,TZFMH,KRESP)
-               END IF
-#else
-          IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,ILENG,IFIELD,TZFMH,IRESP)
-          IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,HFIELD,TZFMH,IRESP)
-#endif
-       ELSE
-          IF (ISP == TZFD%OWNER)  THEN
-             TZFMH%GRID=KGRID
-             TZFMH%COMLEN=KLENCH
-             TZFMH%COMMENT=HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,ILENG,IFIELD,TZFMH,KRESP)
-               END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,ILENG,IFIELD,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,HFIELD,TZFMH,IRESP)
-#endif
-          END IF
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-       END IF
-    ELSE 
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITC0_ll",HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH&
-            & ,IRESP)
-    END IF
-    IF (ALLOCATED(IFIELD)) DEALLOCATE(IFIELD)
-    KRESP = IRESP
-  END SUBROUTINE FMWRITC0_ll
-
-  SUBROUTINE FMWRITC1_ll(HFILEM,HRECFM,HFIPRI,HDIR,HFIELD,KGRID,&
-       KLENCH,HCOMMENT,KRESP)
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-    !
-    !*      0.    DECLARATIONS
-    !             ------------
-    !
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),             INTENT(IN) ::HFILEM ! FM-file name
-    CHARACTER(LEN=*),             INTENT(IN) ::HRECFM ! name of the article to read
-    CHARACTER(LEN=*),             INTENT(IN) ::HFIPRI ! output file for error messages
-    CHARACTER(LEN=*),             INTENT(IN) ::HDIR   ! field form
-    CHARACTER(LEN=*),DIMENSION(:),INTENT(IN) ::HFIELD ! array containing the data field
-    INTEGER,                      INTENT(IN) ::KGRID  ! C-grid indicator (u,v,w,T)
-    INTEGER,                      INTENT(IN) ::KLENCH ! length of comment string
-    CHARACTER(LEN=*),             INTENT(IN) ::HCOMMENT ! comment string
-    INTEGER,                      INTENT(OUT)::KRESP    ! return-code
-    !
-    !*      0.2   Declarations of local variables
-    !
-    INTEGER                          :: J,JJ
-    INTEGER                          :: ILE, IP
-    INTEGER,DIMENSION(:),ALLOCATABLE :: IFIELD
-    INTEGER                          :: ILENG
-    CHARACTER(LEN=JPFINL)            :: YFNLFI
-    INTEGER                          :: IERR
-    TYPE(FD_ll), POINTER             :: TZFD
-    INTEGER                          :: IRESP
-    TYPE(FMHEADER)                   :: TZFMH
-    !----------------------------------------------------------------
-    !*      1.1   THE NAME OF LFIFM
-    !
-    IRESP = 0
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-    !print * , ' Writing Article C1 ' , HRECFM
-    ILE=LEN(HFIELD)
-    IP=SIZE(HFIELD)
-    ILENG=ILE*IP
-    !
-    IF (ILENG==0) THEN
-       IP=1
-       ILE=1
-       ILENG=1
-       ALLOCATE(IFIELD(1))
-       IFIELD(1)=IACHAR(' ')
-    ELSE
-       ALLOCATE(IFIELD(ILENG))
-       DO JJ=1,IP
-          DO J=1,ILE
-             IFIELD(ILE*(JJ-1)+J)=IACHAR(HFIELD(JJ)(J:J))
-          END DO
-       END DO
-    END IF
-    !----------------------------------------------------------------
-    TZFD=>GETFD(YFNLFI)
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN  ! sequential execution
-          TZFMH%GRID=KGRID
-          TZFMH%COMLEN=KLENCH
-          TZFMH%COMMENT=HCOMMENT
-          IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,ILENG,IFIELD,TZFMH,IRESP)
-          IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,HFIELD,TZFMH,IRESP)
-       ELSE
-          IF (ISP == TZFD%OWNER)  THEN
-             TZFMH%GRID=KGRID
-             TZFMH%COMLEN=KLENCH
-             TZFMH%COMMENT=HCOMMENT
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.FALSE.,ILENG,IFIELD,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,HFIELD,TZFMH,IRESP)
-          END IF
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-       END IF
-    ELSE 
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITC1_ll",HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH&
-            & ,IRESP)
-    END IF
-    IF (ALLOCATED(IFIELD)) DEALLOCATE(IFIELD)
-    KRESP = IRESP
-  END SUBROUTINE FMWRITC1_ll
-
-  SUBROUTINE FMWRITT0_ll(HFILEM,HRECFM,HFIPRI,HDIR,TFIELD,KGRID,&
-       KLENCH,HCOMMENT,KRESP)
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT
-    USE MODD_TYPE_DATE
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-    !
-!!!! MOD SB
-#ifdef MNH_NCWRIT
-    USE MODD_NCOUT
-    USE MODE_UTIL
-#endif
-!!!! MOD SB
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),    INTENT(IN) ::HFILEM ! FM-file name
-    CHARACTER(LEN=*),    INTENT(IN) ::HRECFM ! name of the article to read
-    CHARACTER(LEN=*),    INTENT(IN) ::HFIPRI ! output file for error messages
-    CHARACTER(LEN=*),    INTENT(IN) ::HDIR   ! field form
-    TYPE (DATE_TIME),    INTENT(IN) ::TFIELD ! array containing the data field
-    INTEGER,             INTENT(IN) ::KGRID  ! C-grid indicator (u,v,w,T)
-    INTEGER,             INTENT(IN) ::KLENCH ! length of comment string
-    CHARACTER(LEN=*),    INTENT(IN) ::HCOMMENT ! comment string
-    INTEGER,             INTENT(OUT)::KRESP    ! return-code
-    !--------------------------------------------------------------------
-    !
-    !*      0.2   Declarations of local variables
-    !
-    CHARACTER(LEN=JPFINL)        :: YFNLFI
-    INTEGER                      :: IERR
-    TYPE(FD_ll), POINTER         :: TZFD
-    INTEGER                      :: IRESP
-    TYPE(FMHEADER)               :: TZFMH
-    INTEGER, DIMENSION(3)        :: ITDATE    ! date array
-    !
-    !-------------------------------------------------------------------------------
-    IRESP = 0
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-    !print * , ' Writing Article T0 ' , HRECFM
-    ITDATE(1)=TFIELD%TDATE%YEAR
-    ITDATE(2)=TFIELD%TDATE%MONTH
-    ITDATE(3)=TFIELD%TDATE%DAY
-    !-------------------------------------------------------------------------------
-    TZFD=>GETFD(YFNLFI)
-!    IF (ASSOCIATED(TZFD) .OR. .not.LLFIFM) THEN
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN ! sequential execution
-          TZFMH%GRID=KGRID
-          TZFMH%COMMENT='YYYYMMDD'
-          TZFMH%COMLEN=LEN_TRIM(TZFMH%COMMENT)
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-          CALL FM_WRIT_ll(TZFD%FLU,TRIM(HRECFM)//'%TDATE',.FALSE.,3,ITDATE&
-               & ,TZFMH,IRESP)
-               END IF
-#else
-          IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,TRIM(HRECFM)//'%TDATE',.FALSE.,3,ITDATE&
-               & ,TZFMH,IRESP)
-          IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,TRIM(HRECFM)//'%TDATE',HDIR,ITDATE,TZFMH,IRESP)
-#endif
-          TZFMH%COMMENT='SECONDS'
-          TZFMH%COMLEN=LEN_TRIM(TZFMH%COMMENT)
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-          CALL FM_WRIT_ll(TZFD%FLU,TRIM(HRECFM)//'%TIME',.TRUE.,1,TFIELD%TIME&
-               & ,TZFMH,IRESP)
-               END IF
-#else
-          IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,TRIM(HRECFM)//'%TIME',.TRUE.,1,TFIELD%TIME&
-               & ,TZFMH,IRESP)
-          IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,TRIM(HRECFM)//'%TIME',HDIR,TFIELD%TIME,TZFMH,IRESP)
-#endif
-       ELSE
-          IF (ISP == TZFD%OWNER)  THEN
-             TZFMH%GRID=KGRID
-             TZFMH%COMMENT='YYYYMMDD'
-             TZFMH%COMLEN=LEN_TRIM(TZFMH%COMMENT)
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,TRIM(HRECFM)//'%TDATE',.FALSE.,3,ITDATE&
-                  & ,TZFMH,IRESP)
-               END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,TRIM(HRECFM)//'%TDATE',.FALSE.,3,ITDATE&
-                  & ,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,TRIM(HRECFM)//'%TDATE',HDIR,ITDATE,TZFMH,IRESP)
-#endif
-             TZFMH%COMMENT='SECONDS'
-             TZFMH%COMLEN=LEN_TRIM(TZFMH%COMMENT)
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,TRIM(HRECFM)//'%TIME',.TRUE.,1,TFIELD%TIME&
-                  & ,TZFMH,IRESP)
-               END IF
-#else
-
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,TRIM(HRECFM)//'%TIME',.TRUE.,1,TFIELD%TIME&
-                  & ,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,TRIM(HRECFM)//'%TIME',HDIR,TFIELD%TIME,TZFMH,IRESP)
-#endif
-          END IF
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)
-       END IF
-    ELSE 
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITT0_ll",HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH&
-            & ,IRESP)
-    END IF
-    KRESP = IRESP
-  END SUBROUTINE FMWRITT0_ll
-
-  SUBROUTINE FMWRIT_LB(HFILEM,HRECFM,HFIPRI,HLBTYPE,PLB,KRIM,KL3D,&
-       & KGRID,KLENCH,HCOMMENT,KRESP)
-    USE MODD_IO_ll,        ONLY : ISP,ISNPROC,GSMONOPROC,LIOCDF4,LLFIOUT,LPACK,L2D
-    USE MODD_PARAMETERS_ll,ONLY : JPHEXT
-    USE MODD_FM
-    USE MODE_DISTRIB_LB
-    USE MODE_TOOLS_ll,     ONLY : GET_GLOBALDIMS_ll
-    USE MODE_FD_ll,        ONLY : GETFD,JPFINL,FD_LL
-    !
-!!!! MOD SB
-#ifdef MNH_NCWRIT
-    USE MODD_NCOUT
-    USE MODE_UTIL
-#endif
-!!!! MOD SB
-    USE MODD_VAR_ll, ONLY : MNH_STATUSES_IGNORE
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),       INTENT(IN) ::HFILEM ! file name
-    CHARACTER(LEN=*),       INTENT(IN) ::HRECFM ! name of the article to be written
-    CHARACTER(LEN=*),       INTENT(IN) ::HFIPRI ! file for prints in FM
-    CHARACTER(LEN=*),       INTENT(IN) ::HLBTYPE! 'LBX','LBXU','LBY' or 'LBYV'
-    REAL,DIMENSION(:,:,:),TARGET,INTENT(IN) ::PLB ! array containing the LB field
-    INTEGER,                INTENT(IN) ::KRIM  ! size of the LB area
-    INTEGER,                INTENT(IN) ::KL3D  ! size of the LB array in FM
-    INTEGER,                INTENT(IN) ::KGRID ! C-grid indicator (u,v,w,T)
-    INTEGER,                INTENT(IN) ::KLENCH ! length of comment string
-    CHARACTER(LEN=*),       INTENT(IN) ::HCOMMENT ! comment string
-    INTEGER,                INTENT(OUT)::KRESP  ! return-code
-    !
-    !*      0.2   Declarations of local variables
-    !
-    CHARACTER(LEN=JPFINL)                    :: YFNLFI
-    INTEGER                                  :: IERR
-    TYPE(FD_ll), POINTER                     :: TZFD
-    INTEGER                                  :: IRESP
-    REAL,DIMENSION(:,:,:),ALLOCATABLE,TARGET :: Z3D
-    REAL,DIMENSION(:,:,:), POINTER           :: TX3DP
-    TYPE(FMHEADER)                           :: TZFMH
-    INTEGER                                  :: IIMAX_ll,IJMAX_ll
-    INTEGER                                  :: JI
-    INTEGER :: IIB,IIE,IJB,IJE
-    INTEGER, DIMENSION(MPI_STATUS_SIZE) :: STATUS
-    INTEGER,ALLOCATABLE,DIMENSION(:)    :: REQ_TAB
-    INTEGER                           :: NB_REQ,IKU
-    TYPE TX_3DP
-       REAL,DIMENSION(:,:,:), POINTER    :: X
-    END TYPE TX_3DP
-    TYPE(TX_3DP),ALLOCATABLE,DIMENSION(:) :: T_TX3DP
-    !
-    !*      1.1   THE NAME OF LFIFM
-    !
-    IRESP = 0
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-    !print * , ' Writing Article LB ' , HRECFM
-    IF (KL3D /= 2*(KRIM+JPHEXT)) THEN
-       IRESP = -30
-       GOTO 1000
-    END IF
-    !
-    TZFD=>GETFD(YFNLFI)
-!    IF (ASSOCIATED(TZFD) .OR. .not.LLFIFM) THEN
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN  ! sequential execution
-          TZFMH%GRID=KGRID
-          TZFMH%COMLEN=KLENCH
-          TZFMH%COMMENT=HCOMMENT
-          IF (LPACK .AND. L2D) THEN
-             TX3DP=>PLB(:,JPHEXT+1:JPHEXT+1,:)
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(TX3DP),TX3DP,TZFMH,IRESP)
-               END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(TX3DP),TX3DP,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,'XY',TX3DP,TZFMH,IRESP)
-#endif
-          ELSE
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PLB),PLB,TZFMH,IRESP)
-               END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PLB),PLB,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,'XY',PLB,TZFMH,IRESP)
-#endif
-          END IF
-       ELSE
-          IF (ISP == TZFD%OWNER)  THEN
-             ! I/O proc case
-             CALL GET_GLOBALDIMS_ll(IIMAX_ll,IJMAX_ll)
-             IF (HLBTYPE == 'LBX' .OR. HLBTYPE == 'LBXU') THEN 
-                ALLOCATE(Z3D((KRIM+JPHEXT)*2,IJMAX_ll+2*JPHEXT,SIZE(PLB,3)))
-             ELSE ! HLBTYPE == 'LBY' .OR. HLBTYPE == 'LBYV' 
-                ALLOCATE(Z3D(IIMAX_ll+2*JPHEXT,(KRIM+JPHEXT)*2,SIZE(PLB,3)))
-             END IF
-             DO JI = 1,ISNPROC
-                CALL GET_DISTRIB_LB(HLBTYPE,JI,'FM','WRITE',KRIM,IIB,IIE,IJB,IJE)
-                IF (IIB /= 0) THEN
-                   TX3DP=>Z3D(IIB:IIE,IJB:IJE,:)
-                   IF (ISP /= JI) THEN
-                      CALL MPI_RECV(TX3DP,SIZE(TX3DP),MPI_FLOAT,JI-1,99,TZFD%COMM,STATUS,IERR) 
-                   ELSE
-                      CALL GET_DISTRIB_LB(HLBTYPE,JI,'LOC','WRITE',KRIM,IIB,IIE,IJB,IJE)
-                      TX3DP = PLB(IIB:IIE,IJB:IJE,:)
-                   END IF
-                END IF
-             END DO
-             TZFMH%GRID=KGRID
-             TZFMH%COMLEN=KLENCH
-             TZFMH%COMMENT=HCOMMENT
-             IF (LPACK .AND. L2D) THEN
-                TX3DP=>Z3D(:,2:2,:)
-             ELSE
-                TX3DP=>Z3D
-             END IF
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(TX3DP),TX3DP,TZFMH,IRESP)
-               END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(TX3DP),TX3DP,TZFMH,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,'XY',TX3DP,TZFMH,IRESP)
-#endif
-          ELSE
-             NB_REQ=0
-             ALLOCATE(REQ_TAB(1))
-             ALLOCATE(T_TX3DP(1))
-             IKU = SIZE(PLB,3)
-             ! Other processors
-             CALL GET_DISTRIB_LB(HLBTYPE,ISP,'LOC','WRITE',KRIM,IIB,IIE,IJB,IJE)
-             IF (IIB /= 0) THEN
-                TX3DP=>PLB(IIB:IIE,IJB:IJE,:)
-                NB_REQ = NB_REQ + 1
-                ALLOCATE(T_TX3DP(NB_REQ)%X(IIB:IIE,IJB:IJE,IKU))  
-                T_TX3DP(NB_REQ)%X=PLB(IIB:IIE,IJB:IJE,:)
-                CALL MPI_ISEND(T_TX3DP(NB_REQ)%X,SIZE(TX3DP),MPI_FLOAT,TZFD%OWNER-1,99,TZFD%COMM,REQ_TAB(NB_REQ),IERR)
-                !CALL MPI_BSEND(TX3DP,SIZE(TX3DP),MPI_FLOAT,TZFD%OWNER-1,99,TZFD%COMM,IERR)
-             END IF
-             IF (NB_REQ .GT.0 ) THEN
-                CALL MPI_WAITALL(NB_REQ,REQ_TAB,MNH_STATUSES_IGNORE,IERR)
-                DEALLOCATE(T_TX3DP(1)%X) 
-             END IF
-             DEALLOCATE(T_TX3DP,REQ_TAB)
-          END IF
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD&
-               & %COMM,IERR)
-       END IF !(GSMONOPROC)
-    ELSE
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-1000 CONTINUE
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRIT_LB",HFILEM,HFIPRI,HRECFM,HLBTYPE,KGRID,KLENCH,IRESP)
-    END IF
-    !
-    IF (ALLOCATED(Z3D)) DEALLOCATE(Z3D)
-    KRESP = IRESP
-  END SUBROUTINE FMWRIT_LB
-
-  SUBROUTINE FMWRITBOXX2_ll(HFILEM,HRECFM,HFIPRI,HBUDGET,PFIELD,KGRID,&
-       HCOMMENT,KXOBOX,KXEBOX,KYOBOX,KYEBOX,KRESP)
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-    USE MODE_GATHER_ll
-    !
-!!!! MOD SB
-#ifdef MNH_NCWRIT
-    USE MODD_NCOUT
-    USE MODE_UTIL
-#endif
-!!!! MOD SB
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),            INTENT(IN) ::HFILEM   ! FM-file name
-    CHARACTER(LEN=*),            INTENT(IN) ::HRECFM   ! name of the article to write
-    CHARACTER(LEN=*),            INTENT(IN) ::HFIPRI   ! output file for error messages
-    CHARACTER(LEN=*),            INTENT(IN) ::HBUDGET  ! 'BUDGET' (budget)  or 'OTHER' (MesoNH field)
-    REAL,DIMENSION(:,:),TARGET,  INTENT(IN) ::PFIELD   ! array containing the data field
-    INTEGER,                     INTENT(IN) ::KGRID    ! C-grid indicator (u,v,w,T)
-    CHARACTER(LEN=*),            INTENT(IN) ::HCOMMENT ! comment string
-    INTEGER,                     INTENT(IN) ::KXOBOX   ! 
-    INTEGER,                     INTENT(IN) ::KXEBOX   ! Global coordinates of the box
-    INTEGER,                     INTENT(IN) ::KYOBOX   ! 
-    INTEGER,                     INTENT(IN) ::KYEBOX   ! 
-    INTEGER,                     INTENT(OUT)::KRESP    ! return-code 
-    !
-    !*      0.2   Declarations of local variables
-    !
-    CHARACTER(LEN=JPFINL)            :: YFNLFI
-    INTEGER                          :: IERR
-    TYPE(FD_ll), POINTER             :: TZFD
-    INTEGER                          :: IRESP
-    REAL,DIMENSION(:,:),POINTER      :: ZFIELDP
-    TYPE(FMHEADER)                   :: TZFMH
-    LOGICAL                          :: GALLOC
-
-    !
-    !*      1.1   THE NAME OF LFIFM
-    !
-    IRESP = 0
-    GALLOC = .FALSE.
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-    !print * , ' Writing Article BOXX2 ' , HRECFM
-    !------------------------------------------------------------------
-    TZFD=>GETFD(YFNLFI)
-!    IF (ASSOCIATED(TZFD) .OR. .not.LLFIFM) THEN
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN ! sequential execution
-          TZFMH%GRID    = KGRID
-          TZFMH%COMLEN  = LEN_TRIM(HCOMMENT)
-          TZFMH%COMMENT = HCOMMENT
-          IF (HBUDGET /= 'BUDGET') THEN
-             ! take the sub-section of PFIELD defined by the box
-             ZFIELDP=>PFIELD(KXOBOX:KXEBOX,KYOBOX:KYEBOX)
-          ELSE
-             ! take the field as a budget
-             ZFIELDP=>PFIELD
-          END IF
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-               END IF
-#else
-          IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-          IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,'XY',ZFIELDP,TZFMH,IRESP)
-#endif
-       ELSE ! multiprocessor execution
-          IF (ISP == TZFD%OWNER)  THEN
-             ! Allocate the box
-             ALLOCATE(ZFIELDP(KXEBOX-KXOBOX+1,KYEBOX-KYOBOX+1))
-             GALLOC = .TRUE.
-          ELSE
-             ALLOCATE(ZFIELDP(0,0))
-             GALLOC = .TRUE.
-          END IF
-          !
-          CALL GATHER_XYFIELD(PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM,&
-               & KXOBOX,KXEBOX,KYOBOX,KYEBOX,HBUDGET)
-          !
-          IF (ISP == TZFD%OWNER) THEN
-             TZFMH%GRID    = KGRID
-             TZFMH%COMLEN  = LEN_TRIM(HCOMMENT)
-             TZFMH%COMMENT = HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-               END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,'XY',ZFIELDP,TZFMH,IRESP)
-#endif
-          END IF
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD&
-               & %COMM,IERR)
-       END IF ! multiprocessor execution
-    ELSE
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITBOXX2_ll",HFILEM,HFIPRI,HRECFM,'XY',KGRID,LEN(HCOMMENT),IRESP)
-    END IF
-    IF (GALLOC) DEALLOCATE(ZFIELDP)
-    KRESP = IRESP
-  END SUBROUTINE FMWRITBOXX2_ll
-
-  SUBROUTINE FMWRITBOXX3_ll(HFILEM,HRECFM,HFIPRI,HBUDGET,PFIELD,KGRID,&
-       HCOMMENT,KXOBOX,KXEBOX,KYOBOX,KYEBOX,KRESP)
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-    USE MODE_GATHER_ll
-    !
-!!!! MOD SB
-#ifdef MNH_NCWRIT
-    USE MODD_NCOUT
-    USE MODE_UTIL
-#endif
-!!!! MOD SB
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),            INTENT(IN) ::HFILEM   ! FM-file name
-    CHARACTER(LEN=*),            INTENT(IN) ::HRECFM   ! name of the article to write
-    CHARACTER(LEN=*),            INTENT(IN) ::HFIPRI   ! output file for error messages
-    CHARACTER(LEN=*),            INTENT(IN) ::HBUDGET  ! 'BUDGET' (budget)  or 'OTHER' (MesoNH field)
-    REAL,DIMENSION(:,:,:),TARGET,INTENT(IN) ::PFIELD   ! array containing the data field
-    INTEGER,                     INTENT(IN) ::KGRID    ! C-grid indicator (u,v,w,T)
-    CHARACTER(LEN=*),            INTENT(IN) ::HCOMMENT ! comment string
-    INTEGER,                     INTENT(IN) ::KXOBOX   ! 
-    INTEGER,                     INTENT(IN) ::KXEBOX   ! Global coordinates of the box
-    INTEGER,                     INTENT(IN) ::KYOBOX   ! 
-    INTEGER,                     INTENT(IN) ::KYEBOX   ! 
-    INTEGER,                     INTENT(OUT)::KRESP    ! return-code 
-    !
-    !*      0.2   Declarations of local variables
-    !
-    CHARACTER(LEN=JPFINL)               :: YFNLFI
-    INTEGER                             :: IERR
-    TYPE(FD_ll), POINTER                :: TZFD
-    INTEGER                             :: IRESP
-    REAL,DIMENSION(:,:,:),POINTER       :: ZFIELDP
-    TYPE(FMHEADER)                      :: TZFMH
-    LOGICAL                             :: GALLOC
-
-    !
-    !*      1.1   THE NAME OF LFIFM
-    !
-    IRESP = 0
-    GALLOC = .FALSE.
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-    !print * , ' Writing Article BOXX3 ' , HRECFM
-    !------------------------------------------------------------------
-    TZFD=>GETFD(YFNLFI)
-!    IF (ASSOCIATED(TZFD) .OR. .not.LLFIFM) THEN
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN ! sequential execution
-          TZFMH%GRID    = KGRID
-          TZFMH%COMLEN  = LEN_TRIM(HCOMMENT)
-          TZFMH%COMMENT = HCOMMENT
-          IF (HBUDGET /= 'BUDGET') THEN
-             ! take the sub-section of PFIELD defined by the box
-             ZFIELDP=>PFIELD(KXOBOX:KXEBOX,KYOBOX:KYEBOX,:)
-          ELSE
-             ! take the field as a budget
-             ZFIELDP=>PFIELD
-          END IF
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-               END IF
-#else
-          IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-          IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,'XY',ZFIELDP,TZFMH,IRESP)
-#endif
-       ELSE ! multiprocessor execution
-          IF (ISP == TZFD%OWNER)  THEN
-             ! Allocate the box
-             ALLOCATE(ZFIELDP(KXEBOX-KXOBOX+1,KYEBOX-KYOBOX+1,SIZE(PFIELD,3)))
-             GALLOC = .TRUE.
-          ELSE
-             ALLOCATE(ZFIELDP(0,0,0))
-             GALLOC = .TRUE.
-          END IF
-          !
-          CALL GATHER_XYFIELD(PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM,&
-               & KXOBOX,KXEBOX,KYOBOX,KYEBOX,HBUDGET)
-          !
-          IF (ISP == TZFD%OWNER)  THEN
-             TZFMH%GRID    = KGRID
-             TZFMH%COMLEN  = LEN_TRIM(HCOMMENT)
-             TZFMH%COMMENT = HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-               END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,'XY',ZFIELDP,TZFMH,IRESP)
-#endif
-          END IF
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD&
-               & %COMM,IERR)
-       END IF ! multiprocessor execution
-    ELSE
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITBOXX3_ll",HFILEM,HFIPRI,HRECFM,'XY',KGRID,LEN(HCOMMENT),IRESP)
-    END IF
-    IF (GALLOC) DEALLOCATE(ZFIELDP)
-    KRESP = IRESP
-  END SUBROUTINE FMWRITBOXX3_ll
-
-  SUBROUTINE FMWRITBOXX4_ll(HFILEM,HRECFM,HFIPRI,HBUDGET,PFIELD,KGRID,&
-       HCOMMENT,KXOBOX,KXEBOX,KYOBOX,KYEBOX,KRESP)
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-    USE MODE_GATHER_ll
-    !
-!!!! MOD SB
-#ifdef MNH_NCWRIT
-    USE MODD_NCOUT
-    USE MODE_UTIL
-#endif
-!!!! MOD SB
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),              INTENT(IN) ::HFILEM   ! FM-file name
-    CHARACTER(LEN=*),              INTENT(IN) ::HRECFM   ! name of the article to write
-    CHARACTER(LEN=*),              INTENT(IN) ::HFIPRI   ! output file for error messages
-    CHARACTER(LEN=*),              INTENT(IN) ::HBUDGET  ! 'BUDGET' (budget)  or 'OTHER' (MesoNH field)
-    REAL,DIMENSION(:,:,:,:),TARGET,INTENT(IN) ::PFIELD   ! array containing the data field
-    INTEGER,                       INTENT(IN) ::KGRID    ! C-grid indicator (u,v,w,T)
-    CHARACTER(LEN=*),              INTENT(IN) ::HCOMMENT ! comment string
-    INTEGER,                       INTENT(IN) ::KXOBOX   ! 
-    INTEGER,                       INTENT(IN) ::KXEBOX   ! Global coordinates of the box
-    INTEGER,                       INTENT(IN) ::KYOBOX   ! 
-    INTEGER,                       INTENT(IN) ::KYEBOX   ! 
-    INTEGER,                       INTENT(OUT)::KRESP    ! return-code 
-    !
-    !*      0.2   Declarations of local variables
-    !
-    CHARACTER(LEN=JPFINL)               :: YFNLFI
-    INTEGER                             :: IERR
-    TYPE(FD_ll), POINTER                :: TZFD
-    INTEGER                             :: IRESP
-    REAL,DIMENSION(:,:,:,:),POINTER     :: ZFIELDP
-    TYPE(FMHEADER)                      :: TZFMH
-    LOGICAL                             :: GALLOC
-
-    !
-    !*      1.1   THE NAME OF LFIFM
-    !
-    IRESP = 0
-    GALLOC = .FALSE.
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-    !print * , ' Writing Article BOXX4 ' , HRECFM
-    !------------------------------------------------------------------
-    TZFD=>GETFD(YFNLFI)
-!    IF (ASSOCIATED(TZFD) .OR. .not.LLFIFM) THEN
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN ! sequential execution
-          TZFMH%GRID    = KGRID
-          TZFMH%COMLEN  = LEN_TRIM(HCOMMENT)
-          TZFMH%COMMENT = HCOMMENT
-          IF (HBUDGET /= 'BUDGET') THEN
-             ! take the sub-section of PFIELD defined by the box
-             ZFIELDP=>PFIELD(KXOBOX:KXEBOX,KYOBOX:KYEBOX,:,:)
-          ELSE
-             ! take the field as a budget
-             ZFIELDP=>PFIELD
-          END IF
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-               END IF
-#else
-          IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-          IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,'XY',ZFIELDP,TZFMH,IRESP)
-#endif
-       ELSE ! multiprocessor execution
-          IF (ISP == TZFD%OWNER)  THEN
-             ! Allocate the box
-             ALLOCATE(ZFIELDP(KXEBOX-KXOBOX+1,KYEBOX-KYOBOX+1,SIZE(PFIELD,3),SIZE(PFIELD,4)))
-             GALLOC = .TRUE.
-          ELSE
-             ALLOCATE(ZFIELDP(0,0,0,0))
-             GALLOC = .TRUE.
-          END IF
-          !
-          CALL GATHER_XYFIELD(PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM,&
-               & KXOBOX,KXEBOX,KYOBOX,KYEBOX,HBUDGET)
-          !
-          IF (ISP == TZFD%OWNER)  THEN
-             TZFMH%GRID    = KGRID
-             TZFMH%COMLEN  = LEN_TRIM(HCOMMENT)
-             TZFMH%COMMENT = HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-               END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,'XY',ZFIELDP,TZFMH,IRESP)
-#endif
-          END IF
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD&
-               & %COMM,IERR)
-       END IF ! multiprocessor execution
-    ELSE
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITBOXX4_ll",HFILEM,HFIPRI,HRECFM,'XY',KGRID,LEN(HCOMMENT),IRESP)
-    END IF
-    IF (GALLOC) DEALLOCATE(ZFIELDP)
-    KRESP = IRESP
-  END SUBROUTINE FMWRITBOXX4_ll
-
-  SUBROUTINE FMWRITBOXX5_ll(HFILEM,HRECFM,HFIPRI,HBUDGET,PFIELD,KGRID,&
-       HCOMMENT,KXOBOX,KXEBOX,KYOBOX,KYEBOX,KRESP)
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-    USE MODE_GATHER_ll
-    !
-!!!! MOD SB
-#ifdef MNH_NCWRIT
-    USE MODD_NCOUT
-    USE MODE_UTIL
-#endif
-!!!! MOD SB
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),              INTENT(IN) ::HFILEM   ! FM-file name
-    CHARACTER(LEN=*),              INTENT(IN) ::HRECFM   ! name of the article to write
-    CHARACTER(LEN=*),              INTENT(IN) ::HFIPRI   ! output file for error messages
-    CHARACTER(LEN=*),              INTENT(IN) ::HBUDGET  ! 'BUDGET' (budget)  or 'OTHER' (MesoNH field)
-    REAL,DIMENSION(:,:,:,:,:),TARGET,INTENT(IN) ::PFIELD   ! array containing the data field
-    INTEGER,                       INTENT(IN) ::KGRID    ! C-grid indicator (u,v,w,T)
-    CHARACTER(LEN=*),              INTENT(IN) ::HCOMMENT ! comment string
-    INTEGER,                       INTENT(IN) ::KXOBOX   ! 
-    INTEGER,                       INTENT(IN) ::KXEBOX   ! Global coordinates of the box
-    INTEGER,                       INTENT(IN) ::KYOBOX   ! 
-    INTEGER,                       INTENT(IN) ::KYEBOX   ! 
-    INTEGER,                       INTENT(OUT)::KRESP    ! return-code 
-    !
-    !*      0.2   Declarations of local variables
-    !
-    CHARACTER(LEN=JPFINL)               :: YFNLFI
-    INTEGER                             :: IERR
-    TYPE(FD_ll), POINTER                :: TZFD
-    INTEGER                             :: IRESP
-    REAL,DIMENSION(:,:,:,:,:),POINTER   :: ZFIELDP
-    TYPE(FMHEADER)                      :: TZFMH
-    LOGICAL                             :: GALLOC
-
-    !
-    !*      1.1   THE NAME OF LFIFM
-    !
-    IRESP = 0
-    GALLOC = .FALSE.
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-    !print * , ' Writing Article BOXX5 ' , HRECFM
-    !------------------------------------------------------------------
-    TZFD=>GETFD(YFNLFI)
-!    IF (ASSOCIATED(TZFD) .OR. .not.LLFIFM) THEN
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN ! sequential execution
-          TZFMH%GRID    = KGRID
-          TZFMH%COMLEN  = LEN_TRIM(HCOMMENT)
-          TZFMH%COMMENT = HCOMMENT
-          IF (HBUDGET /= 'BUDGET') THEN
-             ! take the sub-section of PFIELD defined by the box
-             ZFIELDP=>PFIELD(KXOBOX:KXEBOX,KYOBOX:KYEBOX,:,:,:)
-          ELSE
-             ! take the field as a budget
-             ZFIELDP=>PFIELD
-          END IF
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-               END IF
-#else
-          IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-          IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,'XY',ZFIELDP,TZFMH,IRESP)
-#endif
-       ELSE ! multiprocessor execution
-          IF (ISP == TZFD%OWNER)  THEN
-             ! Allocate the box
-             ALLOCATE(ZFIELDP(KXEBOX-KXOBOX+1,KYEBOX-KYOBOX+1,SIZE(PFIELD,3),&
-                  & SIZE(PFIELD,4),SIZE(PFIELD,5)))
-             GALLOC = .TRUE.
-          ELSE
-             ALLOCATE(ZFIELDP(0,0,0,0,0))
-             GALLOC = .TRUE.
-          END IF
-          !
-          CALL GATHER_XYFIELD(PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM,&
-               & KXOBOX,KXEBOX,KYOBOX,KYEBOX,HBUDGET)
-          !
-          IF (ISP == TZFD%OWNER)  THEN
-             TZFMH%GRID    = KGRID
-             TZFMH%COMLEN  = LEN_TRIM(HCOMMENT)
-             TZFMH%COMMENT = HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-               END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,'XY',ZFIELDP,TZFMH,IRESP)
-#endif
-          END IF
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD&
-               & %COMM,IERR)
-       END IF ! multiprocessor execution
-    ELSE
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITBOXX5_ll",HFILEM,HFIPRI,HRECFM,'XY',KGRID,LEN(HCOMMENT),IRESP)
-    END IF
-    IF (GALLOC) DEALLOCATE(ZFIELDP)
-    KRESP = IRESP
-  END SUBROUTINE FMWRITBOXX5_ll
-
-  SUBROUTINE FMWRITBOXX6_ll(HFILEM,HRECFM,HFIPRI,HBUDGET,PFIELD,KGRID,&
-       HCOMMENT,KXOBOX,KXEBOX,KYOBOX,KYEBOX,KRESP)
-    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT
-    USE MODD_FM
-    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL
-    USE MODE_GATHER_ll
-    !
-!!!! MOD SB
-#ifdef MNH_NCWRIT
-    USE MODD_NCOUT
-    USE MODE_UTIL
-#endif
-!!!! MOD SB
-    !
-    !*      0.1   Declarations of arguments
-    !
-    CHARACTER(LEN=*),              INTENT(IN) ::HFILEM   ! FM-file name
-    CHARACTER(LEN=*),              INTENT(IN) ::HRECFM   ! name of the article to write
-    CHARACTER(LEN=*),              INTENT(IN) ::HFIPRI   ! output file for error messages
-    CHARACTER(LEN=*),              INTENT(IN) ::HBUDGET  ! 'BUDGET' (budget)  or 'OTHER' (MesoNH field)
-    REAL,DIMENSION(:,:,:,:,:,:),TARGET,INTENT(IN) ::PFIELD   ! array containing the data field
-    INTEGER,                       INTENT(IN) ::KGRID    ! C-grid indicator (u,v,w,T)
-    CHARACTER(LEN=*),              INTENT(IN) ::HCOMMENT ! comment string
-    INTEGER,                       INTENT(IN) ::KXOBOX   ! 
-    INTEGER,                       INTENT(IN) ::KXEBOX   ! Global coordinates of the box
-    INTEGER,                       INTENT(IN) ::KYOBOX   ! 
-    INTEGER,                       INTENT(IN) ::KYEBOX   ! 
-    INTEGER,                       INTENT(OUT)::KRESP    ! return-code 
-    !
-    !*      0.2   Declarations of local variables
-    !
-    CHARACTER(LEN=JPFINL)               :: YFNLFI
-    INTEGER                             :: IERR
-    TYPE(FD_ll), POINTER                :: TZFD
-    INTEGER                             :: IRESP
-    REAL,DIMENSION(:,:,:,:,:,:),POINTER :: ZFIELDP
-    TYPE(FMHEADER)                      :: TZFMH
-    LOGICAL                             :: GALLOC
-
-    !
-    !*      1.1   THE NAME OF LFIFM
-    !
-    IRESP = 0
-    GALLOC = .FALSE.
-    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'
-    !print * , ' Writing Article BOXX6 ' , HRECFM
-    !------------------------------------------------------------------
-    TZFD=>GETFD(YFNLFI)
-!    IF (ASSOCIATED(TZFD) .OR. .not.LLFIFM) THEN
-    IF (ASSOCIATED(TZFD)) THEN
-       IF (GSMONOPROC) THEN ! sequential execution
-          TZFMH%GRID    = KGRID
-          TZFMH%COMLEN  = LEN_TRIM(HCOMMENT)
-          TZFMH%COMMENT = HCOMMENT
-          IF (HBUDGET /= 'BUDGET') THEN
-             ! take the sub-section of PFIELD defined by the box
-             ZFIELDP=>PFIELD(KXOBOX:KXEBOX,KYOBOX:KYEBOX,:,:,:,:)
-          ELSE
-             ! take the field as a budget
-             ZFIELDP=>PFIELD
-          END IF
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-               END IF
-#else
-          IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)
-          IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,'XY',ZFIELDP,TZFMH,IRESP)
-#endif
-       ELSE ! multiprocessor execution
-          IF (ISP == TZFD%OWNER)  THEN
-             ! Allocate the box
-             ALLOCATE(ZFIELDP(KXEBOX-KXOBOX+1,KYEBOX-KYOBOX+1,SIZE(PFIELD,3),&
-                  & SIZE(PFIELD,4),SIZE(PFIELD,5),SIZE(PFIELD,6)))
-             GALLOC = .TRUE.
-          ELSE
-             ALLOCATE(ZFIELDP(0,0,0,0,0,0))
-             GALLOC = .TRUE.
-          END IF
-          !
-          CALL GATHER_XYFIELD(PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM,&
-               & KXOBOX,KXEBOX,KYOBOX,KYEBOX,HBUDGET)
-          !
-          IF (ISP == TZFD%OWNER)  THEN
-             TZFMH%GRID    = KGRID
-             TZFMH%COMLEN  = LEN_TRIM(HCOMMENT)
-             TZFMH%COMMENT = HCOMMENT
-#ifdef MNH_NCWRIT
-               IF ( DEF_NC .AND. LLFIFM ) THEN
-             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-               END IF
-#else
-             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&
-                  & ,IRESP)
-             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,'XY',ZFIELDP,TZFMH,IRESP)
-#endif
-          END IF
-          !
-          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD&
-               & %COMM,IERR)
-       END IF ! multiprocessor execution
-    ELSE
-       IRESP = -61
-    END IF
-    !----------------------------------------------------------------
-    IF (IRESP.NE.0) THEN
-       CALL FM_WRIT_ERR("FMWRITBOXX6_ll",HFILEM,HFIPRI,HRECFM,'XY',KGRID,LEN(HCOMMENT),IRESP)
-    END IF
-    IF (GALLOC) DEALLOCATE(ZFIELDP)
-    KRESP = IRESP
-  END SUBROUTINE FMWRITBOXX6_ll
-
-END MODULE MODE_FMWRIT
-
-
+!MNH_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier\r
+!MNH_LIC This is part of the Meso-NH software governed by the CeCILL-C licence\r
+!MNH_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt  \r
+!MNH_LIC for details. version 1.\r
+!-----------------------------------------------------------------\r
+!--------------- special set of characters for CVS information\r
+!-----------------------------------------------------------------\r
+! $Source$\r
+! $Name$ \r
+! $Revision$ \r
+! $Date$\r
+!-----------------------------------------------------------------\r
+!Correction :\r
+!  J.Escobar : 15/09/2015 : WENO5 & JPHEXT <> 1 \r
+!-----------------------------------------------------------------\r
+\r
+#ifdef MNH_MPI_DOUBLE_PRECISION\r
+#define MPI_FLOAT MPI_DOUBLE_PRECISION\r
+#else\r
+#define MPI_FLOAT MPI_REAL\r
+#endif\r
+\r
+#ifdef MNH_GA\r
+MODULE MODE_GA \r
+#include "mafdecls.fh"\r
+#include "global.fh"\r
+    !\r
+    !  Global Array Variables\r
+    !\r
+    INTEGER, PARAMETER                              :: jpix=1 , jpiy = 2 , jpiz = 3\r
+    !\r
+    INTEGER                                         :: NIMAX_ll,NJMAX_ll, IIU_ll,IJU_ll,IKU_ll\r
+    integer                                         :: heap=5*10**6, stack\r
+    logical                                         :: gstatus_ga\r
+    INTEGER, PARAMETER                              :: ndim_GA = 3\r
+    INTEGER, DIMENSION(ndim_GA)                     :: dims_GA , chunk_GA \r
+    INTEGER,PARAMETER                               :: CI=1 ,CJ=-1 ,CK=-1\r
+    INTEGER                                         :: g_a\r
+    integer, DIMENSION(ndim_GA)                     :: lo_col, hi_col , ld_col\r
+    integer, DIMENSION(ndim_GA)                     :: lo_zplan , hi_zplan , ld_zplan   \r
+    INTEGER                                         :: NIXO_L,NIXE_L,NIYO_L,NIYE_L\r
+    INTEGER                                         :: NIXO_G,NIXE_G,NIYO_G,NIYE_G\r
\r
+    LOGICAL,SAVE                                    :: GFIRST_GA  = .TRUE.\r
+    INTEGER                                         :: IIU_ll_MAX = -1, IJU_ll_MAX = -1, IKU_ll_MAX = -1\r
+\r
+  CONTAINS \r
+    \r
+    SUBROUTINE MNH_INIT_GA(MY_NI,MY_NJ,MY_NK,HRECFM,HRW_MODE)\r
+\r
+!\r
+!  Modification \r
+!  J.Escobar 5/02/2015 : use JPHEXT from MODD_PARAMETERS_ll\r
+\r
+      USE MODE_TOOLS_ll,       ONLY : GET_GLOBALDIMS_ll\r
+      USE MODD_PARAMETERS_ll,  ONLY : JPHEXT\r
+      USE MODD_IO_ll,          ONLY : ISP\r
+      USE MODE_GATHER_ll,      ONLY : GET_DOMWRITE_ll\r
+      USE MODE_SCATTER_ll,     ONLY : GET_DOMREAD_ll\r
+\r
+      IMPLICIT NONE\r
+\r
+      INTEGER,          INTENT(IN) :: MY_NI,MY_NJ,MY_NK\r
+      CHARACTER(LEN=*), INTENT(IN) :: HRECFM   ! name of the article to write\r
+      CHARACTER(LEN=*), INTENT(IN) :: HRW_MODE \r
+      \r
+      IF ( GFIRST_GA ) THEN\r
+         GFIRST_GA = .FALSE.\r
+         !\r
+         !   Allocate memory for GA library\r
+         !\r
+         stack = heap\r
+         !gstatus_ga = ma_init(MT_F_DBL, stack/ISNPROC, heap/ISNPROC)\r
+         gstatus_ga = ma_init(MT_F_DBL, stack, heap)\r
+         if ( .not. gstatus_ga ) STOP " MA_INIT FAILED "\r
+         !\r
+         !   Initialize GA library\r
+         !\r
+         !call ga_initialize_ltd(100000000)\r
+         call ga_initialize()\r
+      END IF\r
+      \r
+      CALL GET_GLOBALDIMS_ll (NIMAX_ll,NJMAX_ll)\r
+      IIU_ll = NIMAX_ll + 2*JPHEXT\r
+      IJU_ll = NJMAX_ll + 2*JPHEXT\r
+      IKU_ll = MY_NK   \r
+      !\r
+      !   configure Global array dimensions\r
+      !\r
+      dims_GA(JPIX) = IIU_ll\r
+      dims_GA(JPIY) = IJU_ll\r
+      dims_GA(JPIZ) = IKU_ll\r
+      chunk_GA(JPIX)   = CI\r
+      chunk_GA(JPIY)   = CJ\r
+      chunk_GA(JPIZ)   = CK \r
+      IF ( CI .EQ. 1 ) chunk_GA(JPIX)   = dims_GA(JPIX) ! 1 block in X direction\r
+      IF ( CJ .EQ. 1 ) chunk_GA(JPIY)   = dims_GA(JPIY) ! 1 block in Y direction\r
+      IF ( CK .EQ. 1 ) chunk_GA(JPIZ)   = dims_GA(JPIZ) ! 1 block in Z direction\r
+      !\r
+      !   (re)create global array g_a ( if to small create it ... )\r
+      !\r
+      IF ( ( IIU_ll .GT. IIU_ll_MAX ) .OR. ( IJU_ll .GT. IJU_ll_MAX ) .OR. ( IKU_ll .GT. IKU_ll_MAX ) ) THEN\r
+         !\r
+         ! reallocate the g_a , if need with bigger Z size \r
+         !\r
+         IF ( IKU_ll_MAX .NE. -1 ) gstatus_ga =  ga_destroy(g_a)\r
+         IIU_ll_MAX = IIU_ll\r
+         IJU_ll_MAX = IJU_ll\r
+         IKU_ll_MAX = IKU_ll\r
+         gstatus_ga = nga_create(MT_F_DBL, ndim_GA, dims_GA, HRECFM ,chunk_GA, g_a)\r
+         call ga_sync()\r
+      END IF\r
+      !----------------------------------------------------------------------!\r
+      !                                                                      !\r
+      ! Define/describe local column data owned by this processor to write   !\r
+      !                                                                      !\r
+      !----------------------------------------------------------------------!\r
+      IF ( HRW_MODE .EQ. "WRITE" ) THEN\r
+      CALL GET_DOMWRITE_ll(ISP,'local',NIXO_L,NIXE_L,NIYO_L,NIYE_L)\r
+      CALL GET_DOMWRITE_ll(ISP,'global',NIXO_G,NIXE_G,NIYO_G,NIYE_G)\r
+      ELSE\r
+      CALL GET_DOMREAD_ll(ISP,NIXO_L,NIXE_L,NIYO_L,NIYE_L)\r
+      CALL GET_DOMREAD_ll(ISP,NIXO_G,NIXE_G,NIYO_G,NIYE_G)\r
+      END IF\r
+      !\r
+      ! portion of data to write/put | read/get by this proc\r
+      !\r
+      lo_col(JPIX) = NIXO_G\r
+      hi_col(JPIX) = NIXE_G\r
+      \r
+      lo_col(JPIY) = NIYO_G\r
+      hi_col(JPIY) = NIYE_G\r
+      \r
+      lo_col(JPIZ) = 1\r
+      hi_col(JPIZ) = IKU_ll\r
+      !\r
+      ! declaration size of this local input column array\r
+      !\r
+      ld_col(JPIX) = MY_NI\r
+      ld_col(JPIY) = MY_NJ\r
+      ld_col(JPIZ) = MY_NK\r
+      !\r
+      !-----------------------------------------------------!\r
+      !                                                     !\r
+      !  Size of local ZSLIDE_ll Write buffer on I/O proc   !\r
+      !                                                     !\r
+      !-----------------------------------------------------!\r
+      !\r
+      ! declared dimension \r
+      !\r
+      ld_zplan(JPIX) = IIU_ll\r
+      ld_zplan(JPIY) = IJU_ll\r
+      ld_zplan(JPIZ) = 1\r
+      !\r
+      ! write data by Z slide by I/O proc\r
+      !\r
+      lo_zplan(JPIX:JPIY) = 1\r
+      hi_zplan(JPIX) = IIU_ll \r
+      hi_zplan(JPIY) = IJU_ll   \r
+      !call ga_sync()\r
+      !\r
+    END SUBROUTINE MNH_INIT_GA\r
+    \r
+END MODULE MODE_GA\r
+\r
+#endif\r
+\r
+MODULE MODE_FMWRIT\r
+\r
+  USE MODD_MPIF\r
+#if defined(MNH_IOCDF4)\r
+  USE MODE_NETCDF\r
+#endif\r
+\r
+  IMPLICIT NONE \r
+\r
+  PRIVATE\r
+\r
+  INTERFACE FMWRIT\r
+     MODULE PROCEDURE FMWRITX0_ll,FMWRITX1_ll,FMWRITX2_ll,FMWRITX3_ll,&\r
+          & FMWRITX4_ll,FMWRITX5_ll,FMWRITX6_ll,&\r
+          & FMWRITN0_ll,FMWRITN1_ll,FMWRITN2_ll,&\r
+          & FMWRITL0_ll,FMWRITL1_ll,FMWRITC0_ll,&\r
+          & FMWRITC1_ll,FMWRITT0_ll\r
+  END INTERFACE\r
+\r
+  INTERFACE FMWRITBOX\r
+     MODULE PROCEDURE FMWRITBOXX2_ll,FMWRITBOXX3_ll,FMWRITBOXX4_ll,&\r
+          & FMWRITBOXX5_ll,FMWRITBOXX6_ll\r
+  END INTERFACE\r
+\r
+  PUBLIC FMWRIT_LB,FMWRITBOX,FMWRIT,FMWRITX0_ll,FMWRITX1_ll,FMWRITX2_ll,FMWRITX3_ll,&\r
+       & FMWRITX4_ll,FMWRITX5_ll,FMWRITX6_ll,FMWRITN0_ll,FMWRITN1_ll,FMWRITN2_ll,&\r
+       & FMWRITL0_ll,FMWRITL1_ll,FMWRITC0_ll,FMWRITC1_ll,FMWRITT0_ll,FMWRITBOXX2_ll,&\r
+       & FMWRITBOXX3_ll,FMWRITBOXX4_ll,FMWRITBOXX5_ll,FMWRITBOXX6_ll\r
+\r
+  !INCLUDE 'mpif.h'\r
+\r
+CONTAINS \r
+\r
+  SUBROUTINE FM_WRIT_ERR(HFUNC,HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH&\r
+       & ,KRESP)\r
+    USE MODE_FM, ONLY : FMLOOK_ll\r
+\r
+    CHARACTER(LEN=*) :: HFUNC \r
+    CHARACTER(LEN=*) :: HFILEM\r
+    CHARACTER(LEN=*) :: HFIPRI\r
+    CHARACTER(LEN=*) :: HRECFM\r
+    CHARACTER(LEN=*) :: HDIR\r
+    INTEGER          :: KGRID\r
+    INTEGER          :: KLENCH\r
+    INTEGER          :: KRESP\r
+\r
+    INTEGER          :: ILUPRI\r
+    INTEGER          :: IRESP\r
+\r
+    CALL FMLOOK_ll(HFIPRI,HFIPRI,ILUPRI,IRESP)\r
+    WRITE (ILUPRI,*) ' exit from ',HFUNC,' with RESP:',KRESP\r
+    WRITE (ILUPRI,*) '   | HFILEM = ',HFILEM\r
+    WRITE (ILUPRI,*) '   | HRECFM = ',HRECFM\r
+    WRITE (ILUPRI,*) '   | HDIR  = ',HDIR\r
+    WRITE (ILUPRI,*) '   | KGRID  = ',KGRID\r
+    WRITE (ILUPRI,*) '   | KLENCH = ',KLENCH\r
+\r
+  END SUBROUTINE FM_WRIT_ERR\r
+\r
+\r
+\r
+  SUBROUTINE FMWRITX0_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&\r
+       KLENCH,HCOMMENT,KRESP)\r
+!\r
+!  Modification \r
+!  J.Escobar 15/04/2014 : add write to all Z files for all FMWRITX0_ll variables\r
+!  J.Escobar 23/06/2014 : bug , replace .FALSE. to .TRUE. = OREAL type transmetted to FM_WRIT_ll\r
+!\r
+    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT\r
+    USE MODD_FM\r
+    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL\r
+#ifdef MNH_NCWRIT\r
+    USE MODD_GRID\r
+    USE MODD_DIM_n, ONLY: NIMAX\r
+    USE MODD_NCOUT\r
+    USE MODE_UTIL\r
+#endif\r
+    !\r
+    !*      0.    DECLARATIONS\r
+    !             ------------\r
+    !\r
+    !*      0.1   Declarations of arguments\r
+    !\r
+    CHARACTER(LEN=*),        INTENT(IN) ::HFILEM  ! FM-file name\r
+    CHARACTER(LEN=*),        INTENT(IN) ::HRECFM  ! name of the article to write\r
+    CHARACTER(LEN=*),        INTENT(IN) ::HFIPRI  ! output file for error messages\r
+    CHARACTER(LEN=*),        INTENT(IN) ::HDIR    ! field form\r
+    REAL,                    INTENT(IN) ::PFIELD  ! array containing the data field\r
+    INTEGER,                 INTENT(IN) ::KGRID   ! C-grid indicator (u,v,w,T)\r
+    INTEGER,                 INTENT(IN) ::KLENCH  ! length of comment string\r
+    CHARACTER(LEN=*),        INTENT(IN) ::HCOMMENT! comment string\r
+    INTEGER,                 INTENT(OUT)::KRESP   ! return-code \r
+    !\r
+    !*      0.2   Declarations of local variables\r
+    !\r
+    !----------------------------------------------------------------\r
+    CHARACTER(LEN=JPFINL)        :: YFNLFI\r
+    INTEGER                      :: IERR\r
+    TYPE(FD_ll), POINTER         :: TZFD\r
+    INTEGER                      :: IRESP\r
+    TYPE(FMHEADER)               :: TZFMH\r
+    !JUANZIO\r
+    INTEGER                                  :: IK_FILE,IK_rank\r
+    CHARACTER(len=5)                         :: YK_FILE  \r
+    CHARACTER(len=128)                       :: YFILE_IOZ  \r
+    TYPE(FD_ll), POINTER                     :: TZFD_IOZ \r
+    !JUANZIO\r
+    !\r
+    !*      1.1   THE NAME OF LFIFM\r
+    !\r
+    IRESP = 0\r
+    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'\r
+    !print * , ' Writing Article 0 ' , HRECFM\r
+    !\r
+    TZFD=>GETFD(YFNLFI)\r
+    IF (ASSOCIATED(TZFD)) THEN\r
+       IF (GSMONOPROC) THEN ! sequential execution\r
+          TZFMH%GRID=KGRID\r
+          TZFMH%COMLEN=KLENCH\r
+          TZFMH%COMMENT=HCOMMENT\r
+#ifdef MNH_NCWRIT\r
+          IF ( DEF_NC .AND. LLFIFM ) THEN\r
+          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,1,PFIELD,TZFMH,IRESP)    \r
+          END IF\r
+          IF ( LNETCDF .AND. NIMAX == 0 ) THEN\r
+!    PRINT * , ' SAVE MAP PARAMETER IF PGD '\r
+          IF ( trim(hrecfm) == "RPK" ) THEN\r
+            XRPK=PFIELD\r
+          ELSEIF ( trim(hrecfm) == "BETA" ) THEN\r
+            XBETA=PFIELD\r
+          ELSEIF (trim(hrecfm) == "LATORI" ) THEN\r
+            XLATORI=PFIELD\r
+          ELSEIF (trim(hrecfm) == "LONORI" ) THEN\r
+            XLONORI=PFIELD\r
+          ELSEIF (trim(hrecfm) == "LAT0" ) THEN\r
+            XLAT0=PFIELD\r
+          ELSEIF (trim(hrecfm) == "LON0" ) THEN\r
+            XLON0=PFIELD\r
+          END IF\r
+          END IF\r
+#else\r
+          IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,1,PFIELD,TZFMH,IRESP)\r
+          IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,PFIELD,TZFMH,IRESP)\r
+#endif\r
+       ELSE\r
+          IF (ISP == TZFD%OWNER)  THEN\r
+             TZFMH%GRID=KGRID\r
+             TZFMH%COMLEN=KLENCH\r
+             TZFMH%COMMENT=HCOMMENT\r
+#ifdef MNH_NCWRIT\r
+               IF ( DEF_NC .AND. LLFIFM ) THEN\r
+             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,1,PFIELD,TZFMH,IRESP)\r
+               END IF\r
+             IF ( LNETCDF .AND. NIMAX == 0 ) THEN\r
+!                  print * , ' SAVE MAP PARAMETER IF PGD '\r
+               IF ( trim(hrecfm) == "RPK" ) THEN\r
+                 XRPK=PFIELD\r
+               ELSEIF ( trim(hrecfm) == "BETA" ) THEN\r
+                 XBETA=PFIELD\r
+               ELSEIF (trim(hrecfm) == "LATORI" ) THEN\r
+                 XLATORI=PFIELD\r
+               ELSEIF (trim(hrecfm) == "LONORI" ) THEN\r
+                 XLONORI=PFIELD\r
+               ELSEIF (trim(hrecfm) == "LAT0" ) THEN\r
+                 XLAT0=PFIELD\r
+               ELSEIF (trim(hrecfm) == "LON0" ) THEN\r
+                 XLON0=PFIELD\r
+               END IF\r
+             END IF\r
+#else\r
+             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,1,PFIELD,TZFMH,IRESP)\r
+             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,PFIELD,TZFMH,IRESP)\r
+#endif\r
+          END IF\r
+          !\r
+          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+       END IF ! multiprocessor execution\r
+       IF (TZFD%nb_procio.gt.1) THEN\r
+          ! write the data in all Z files\r
+          DO IK_FILE=1,TZFD%nb_procio\r
+             write(YK_FILE ,'(".Z",i3.3)')  IK_FILE\r
+             YFILE_IOZ =  TRIM(HFILEM)//YK_FILE//".lfi"\r
+             TZFD_IOZ => GETFD(YFILE_IOZ)   \r
+             IK_RANK = TZFD_IOZ%OWNER\r
+             IF ( ISP == IK_RANK )  THEN\r
+                TZFMH%GRID=KGRID\r
+                TZFMH%COMLEN=KLENCH\r
+                TZFMH%COMMENT=HCOMMENT\r
+#ifdef MNH_NCWRIT\r
+               IF ( DEF_NC .AND. LLFIFM ) THEN\r
+                CALL FM_WRIT_ll(TZFD_IOZ%FLU,HRECFM,.TRUE.,1,PFIELD,TZFMH,IRESP)\r
+               END IF\r
+#else\r
+               IF (LLFIOUT) CALL FM_WRIT_ll(TZFD_IOZ%FLU,HRECFM,.TRUE.,1,PFIELD,TZFMH,IRESP)\r
+               IF (LIOCDF4) CALL NCWRIT(TZFD_IOZ%CDF,HRECFM,HDIR,PFIELD,TZFMH,IRESP)\r
+#endif\r
+             END IF\r
+          END DO\r
+       ENDIF\r
+    ELSE\r
+       IRESP = -61\r
+    END IF\r
+    !----------------------------------------------------------------\r
+    IF (IRESP.NE.0) THEN\r
+       CALL FM_WRIT_ERR("FMWRITX0_ll",HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH,IRESP)\r
+    END IF\r
+    KRESP = IRESP\r
+  END SUBROUTINE FMWRITX0_ll\r
+\r
+  SUBROUTINE FMWRITX1_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&\r
+       KLENCH,HCOMMENT,KRESP)\r
+    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT\r
+    USE MODD_FM\r
+    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL\r
+    USE MODE_ALLOCBUFFER_ll\r
+    USE MODE_GATHER_ll\r
+#ifdef MNH_NCWRIT\r
+    USE MODE_UTIL\r
+    USE MODE_DIMLIST\r
+    USE MODD_DIM_n, ONLY: NIMAX\r
+    USE MODD_NCOUT\r
+#endif\r
+    !\r
+    !*      0.    DECLARATIONS\r
+    !             ------------\r
+    !\r
+    !*      0.1   Declarations of arguments\r
+    !\r
+    CHARACTER(LEN=*),        INTENT(IN) ::HFILEM   ! FM-file name\r
+    CHARACTER(LEN=*),        INTENT(IN) ::HRECFM   ! name of the article to write\r
+    CHARACTER(LEN=*),        INTENT(IN) ::HFIPRI   ! output file for error messages\r
+    CHARACTER(LEN=*),        INTENT(IN) ::HDIR     ! field form\r
+    REAL,DIMENSION(:),TARGET,INTENT(IN) ::PFIELD   ! array containing the data field\r
+    INTEGER,                 INTENT(IN) ::KGRID    ! C-grid indicator (u,v,w,T)\r
+    INTEGER,                 INTENT(IN) ::KLENCH   ! length of comment string\r
+    CHARACTER(LEN=*),        INTENT(IN) ::HCOMMENT ! comment string\r
+    INTEGER,                 INTENT(OUT)::KRESP    ! return-code \r
+    !\r
+    !*      0.2   Declarations of local variables\r
+    !\r
+    !----------------------------------------------------------------\r
+    CHARACTER(LEN=JPFINL)        :: YFNLFI\r
+    INTEGER                      :: IERR\r
+    TYPE(FD_ll), POINTER         :: TZFD\r
+    INTEGER                      :: IRESP\r
+    TYPE(FMHEADER)               :: TZFMH\r
+    REAL,DIMENSION(:),POINTER    :: ZFIELDP\r
+    LOGICAL                      :: GALLOC\r
+#ifdef MNH_NCWRIT\r
+    TYPE(workfield), DIMENSION(:), POINTER   :: TZRECLIST\r
+    INTEGER,DIMENSION(6)         :: TABDIM\r
+#endif\r
+    !\r
+    !*      1.1   THE NAME OF LFIFM\r
+    !\r
+    IRESP = 0\r
+    GALLOC = .FALSE.\r
+    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'\r
+#ifdef MNH_NCWRIT\r
+    TABDIM(:)=1\r
+    TABDIM(1)=SIZE(PFIELD,1)\r
+    !print * , ' Writing Article 1 ' , HRECFM\r
+#endif\r
+    !------------------------------------------------------------------    \r
+    TZFD=>GETFD(YFNLFI)\r
+    IF (ASSOCIATED(TZFD)) THEN\r
+       IF (GSMONOPROC) THEN ! sequential execution\r
+          TZFMH%GRID=KGRID\r
+          TZFMH%COMLEN=KLENCH\r
+          TZFMH%COMMENT=HCOMMENT\r
+#ifdef MNH_NCWRIT\r
+         IF ( DEF_NC .AND. LLFIFM ) THEN\r
+          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)\r
+         END IF\r
+         ! ------- WRITE NETCDF\r
+         IF ( LNETCDF .AND. NC_WRITE ) THEN\r
+          CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,PFIELD,.TRUE.,TZRECLIST, &\r
+!          CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,PFIELD, &\r
+                  & KLENCH,HCOMMENT)\r
+            IF ( NC_FILE == 'phy' ) THEN\r
+!!!!! CAS WRITE_PHYS_PARAM ... l'ecriture lfi ne peut pas se faire en meme temps\r
+              CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE., &\r
+                 SIZE(PFIELD),PFIELD,TZFMH,IRESP)\r
+            END IF\r
+         END IF\r
+#else\r
+          IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)\r
+          IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,PFIELD,TZFMH,IRESP)\r
+#endif\r
+       ELSE\r
+          IF (ISP == TZFD%OWNER)  THEN\r
+             CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)\r
+          ELSE\r
+             ALLOCATE(ZFIELDP(0))\r
+             GALLOC = .TRUE.\r
+          END IF\r
+          !\r
+          IF (HDIR == 'XX' .OR. HDIR =='YY') THEN\r
+             CALL GATHER_XXFIELD(HDIR,PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM)\r
+          END IF\r
+          !\r
+          IF (ISP == TZFD%OWNER)  THEN\r
+             TZFMH%GRID=KGRID\r
+             TZFMH%COMLEN=KLENCH\r
+             TZFMH%COMMENT=HCOMMENT\r
+#ifdef MNH_NCWRIT\r
+           IF ( DEF_NC .AND. LLFIFM ) THEN\r
+             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&\r
+                  & ,IRESP)\r
+           END IF\r
+           IF ( LNETCDF .AND. NC_WRITE ) THEN\r
+            TABDIM(1)=SIZE(ZFIELDP,1)\r
+            CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP,.TRUE.,TZRECLIST, &\r
+              & KLENCH,HCOMMENT)\r
+             IF ( NC_FILE == 'phy' ) THEN\r
+               CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&\r
+                  & ,IRESP)\r
+             END IF\r
+           END IF\r
+#else\r
+             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&\r
+                  & ,IRESP)\r
+             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)\r
+#endif\r
+          END IF\r
+          !\r
+          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD%COMM,IERR)\r
+       END IF\r
+    ELSE\r
+       IRESP = -61\r
+    END IF\r
+    !----------------------------------------------------------------\r
+    IF (IRESP.NE.0) THEN\r
+       CALL FM_WRIT_ERR("FMWRITX1_ll",HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH,IRESP)\r
+    END IF\r
+    IF (GALLOC) DEALLOCATE(ZFIELDP)\r
+    KRESP = IRESP\r
+  END SUBROUTINE FMWRITX1_ll\r
+\r
+  SUBROUTINE FMWRITX2_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&\r
+       KLENCH,HCOMMENT,KRESP)\r
+    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT,LPACK,L1D,L2D\r
+    USE MODD_PARAMETERS_ll,ONLY : JPHEXT\r
+    USE MODD_FM\r
+    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL\r
+    USE MODE_ALLOCBUFFER_ll\r
+    USE MODE_GATHER_ll\r
+    !JUANZ\r
+    USE MODD_TIMEZ, ONLY : TIMEZ\r
+    USE MODE_MNH_TIMING, ONLY : SECOND_MNH2\r
+    !JUANZ \r
+#ifdef MNH_NCWRIT\r
+    USE MODE_UTIL\r
+    USE MODE_DIMLIST\r
+    USE MODD_DIM_n, ONLY: NIMAX\r
+    USE MODD_NCOUT\r
+#endif\r
+#ifdef MNH_GA\r
+    !JUAN_IOGA\r
+    USE MODE_GA\r
+#endif \r
+    !\r
+    IMPLICIT NONE\r
+    !\r
+    !*      0.1   Declarations of arguments\r
+    !\r
+    CHARACTER(LEN=*),          INTENT(IN) ::HFILEM   ! FM-file name\r
+    CHARACTER(LEN=*),          INTENT(IN) ::HRECFM   ! name of the article to write\r
+    CHARACTER(LEN=*),          INTENT(IN) ::HFIPRI   ! output file for error messages\r
+    CHARACTER(LEN=*),          INTENT(IN) ::HDIR     ! field form\r
+    REAL,DIMENSION(:,:),TARGET,INTENT(IN) ::PFIELD   ! array containing the data field\r
+    INTEGER,                   INTENT(IN) ::KGRID    ! C-grid indicator (u,v,w,T)\r
+    INTEGER,                   INTENT(IN) ::KLENCH   ! length of comment string\r
+    CHARACTER(LEN=*),          INTENT(IN) ::HCOMMENT ! comment string\r
+    INTEGER,                   INTENT(OUT)::KRESP    ! return-code \r
+    !\r
+    !*      0.2   Declarations of local variables\r
+    !\r
+    CHARACTER(LEN=JPFINL)                  :: YFNLFI\r
+    INTEGER                                :: IERR\r
+    TYPE(FD_ll), POINTER                   :: TZFD\r
+    INTEGER                                :: IRESP\r
+    REAL,DIMENSION(:,:),POINTER            :: ZFIELDP\r
+    TYPE(FMHEADER)                         :: TZFMH\r
+    LOGICAL                                :: GALLOC\r
+#ifdef MNH_NCWRIT\r
+    TYPE(workfield), DIMENSION(:), POINTER   :: TZRECLIST\r
+    INTEGER,DIMENSION(6)         :: TABDIM\r
+    LOGICAL                      :: NCWR\r
+    INTEGER                      :: LHREC_BEG,LHRECFM \r
+#endif\r
+    !\r
+    !JUANZ\r
+    REAL*8,DIMENSION(2) :: T0,T1,T2\r
+    REAL*8,DIMENSION(2) :: T11,T22\r
+    !JUANZ\r
+#ifdef MNH_GA\r
+    REAL,DIMENSION(:,:),POINTER            :: ZFIELDP_GA , ZFIELD_GA\r
+    REAL                                   :: ERROR\r
+    INTEGER                                :: JI\r
+#endif\r
+    INTEGER                      :: IHEXTOT\r
+    !\r
+    !*      1.1   THE NAME OF LFIFM\r
+    !\r
+    CALL SECOND_MNH2(T11)\r
+    IRESP = 0\r
+    GALLOC = .FALSE.\r
+    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'\r
+#ifdef MNH_NCWRIT\r
+    NCWR=.TRUE.\r
+    TABDIM(:)=1\r
+    TABDIM(1)=SIZE(PFIELD,1)\r
+    TABDIM(2)=SIZE(PFIELD,2)\r
+    !print * , ' Writing Article 2 ' , HRECFM\r
+#endif\r
+    !------------------------------------------------------------------\r
+    IHEXTOT = 2*JPHEXT+1\r
+    TZFD=>GETFD(YFNLFI)\r
+    IF (ASSOCIATED(TZFD)) THEN\r
+       IF (GSMONOPROC) THEN ! sequential execution\r
+          TZFMH%GRID=KGRID\r
+          TZFMH%COMLEN=KLENCH\r
+          TZFMH%COMMENT=HCOMMENT\r
+          !    IF (LPACK .AND. L1D .AND. HDIR=='XY') THEN \r
+          IF (LPACK .AND. L1D .AND. SIZE(PFIELD,1)==IHEXTOT .AND. SIZE(PFIELD,2)==IHEXTOT) THEN \r
+             ZFIELDP=>PFIELD(JPHEXT+1:JPHEXT+1,JPHEXT+1:JPHEXT+1)\r
+#ifdef MNH_NCWRIT\r
+      IF ( DEF_NC .AND. LLFIFM ) THEN\r
+       CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)\r
+      END IF\r
+      IF ( LNETCDF .AND. NC_WRITE ) THEN\r
+         TABDIM(1)=1\r
+         TABDIM(2)=1\r
+        CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP,.TRUE.,TZRECLIST,&\r
+                  & KLENCH,HCOMMENT)\r
+      END IF\r
+#else\r
+             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)\r
+             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)\r
+#endif\r
+             !    ELSE IF (LPACK .AND. L2D .AND. HDIR=='XY') THEN\r
+          ELSEIF (LPACK .AND. L2D .AND. SIZE(PFIELD,2)==IHEXTOT) THEN\r
+             ZFIELDP=>PFIELD(:,JPHEXT+1:JPHEXT+1)\r
+#ifdef MNH_NCWRIT\r
+               IF ( DEF_NC .AND. LLFIFM ) THEN\r
+             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)\r
+               END IF\r
+             LHRECFM = LEN_TRIM(ADJUSTL(HRECFM))\r
+             IF ( LHRECFM > 5 ) THEN\r
+               LHREC_BEG =LHRECFM-4\r
+               IF ( ADJUSTL(HRECFM(LHREC_BEG:LHRECFM)) == 'DATIM') THEN\r
+                  NCWR = .FALSE.\r
+               END IF\r
+             END IF\r
+             IF ( LNETCDF .AND. NC_WRITE .AND. NCWR ) THEN\r
+                 TABDIM(2)=1\r
+              IF ( NC_FILE == 'phy' ) THEN\r
+                  CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE., &\r
+                     SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)\r
+              END IF\r
+                  CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP,.TRUE.,TZRECLIST,&\r
+                  & KLENCH,HCOMMENT)\r
+             END IF\r
+               NCWR = .TRUE.\r
+#else\r
+             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)\r
+             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)\r
+#endif\r
+          ELSE\r
+#ifdef MNH_NCWRIT\r
+             IF ( DEF_NC .AND. LLFIFM ) THEN\r
+             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)\r
+             END IF\r
+             LHRECFM = LEN_TRIM(ADJUSTL(HRECFM))\r
+             IF ( LHRECFM > 5 ) THEN\r
+               LHREC_BEG =LHRECFM-4\r
+               IF ( ADJUSTL(HRECFM(LHREC_BEG:LHRECFM)) == 'DATIM') THEN\r
+                   NCWR = .FALSE.\r
+               END IF\r
+             END IF\r
+!             IF ( NIMAX /= 0 ) THEN\r
+               IF ( LNETCDF .AND. NC_WRITE .AND. NCWR ) THEN\r
+              IF ( NC_FILE == 'phy' ) THEN\r
+               CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE., &\r
+               SIZE(PFIELD),PFIELD,TZFMH,IRESP)\r
+              END IF\r
+                 CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,PFIELD,.TRUE.,TZRECLIST, &\r
+                 & KLENCH,HCOMMENT)\r
+               END IF\r
+               NCWR = .TRUE.\r
+!             END IF\r
+#else\r
+             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)\r
+             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,PFIELD,TZFMH,IRESP)\r
+#endif\r
+          END IF\r
+       ELSE ! multiprocessor execution\r
+          CALL SECOND_MNH2(T0)\r
+          IF (ISP == TZFD%OWNER)  THEN\r
+             ! I/O processor case\r
+             CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,HDIR,GALLOC)\r
+          ELSE\r
+             ALLOCATE(ZFIELDP(0,0))\r
+             GALLOC = .TRUE.\r
+          END IF\r
+          !   \r
+          IF (HDIR == 'XX' .OR. HDIR =='YY') THEN\r
+             CALL GATHER_XXFIELD(HDIR,PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM)\r
+          ELSEIF (HDIR == 'XY') THEN\r
+             IF (LPACK .AND. L2D) THEN\r
+                CALL GATHER_XXFIELD('XX',PFIELD(:,JPHEXT+1),ZFIELDP(:,1),TZFD%OWNER,TZFD%COMM)\r
+             ELSE\r
+#ifdef MNH_GA\r
+          !\r
+          ! init/create the ga , dim3 = 1\r
+          !\r
+          CALL MNH_INIT_GA(SIZE(PFIELD,1),SIZE(PFIELD,2),1,HRECFM,"WRITE")\r
+         !\r
+         !   copy columun data to global arrays g_a \r
+         !\r
+         ALLOCATE (ZFIELD_GA (SIZE(PFIELD,1),SIZE(PFIELD,2)))\r
+         ZFIELD_GA = PFIELD\r
+         call nga_put(g_a, lo_col, hi_col,ZFIELD_GA(NIXO_L,NIYO_L) , ld_col)  \r
+!!$         print*," nga_put =",HRECFM,g_a," lo_col=",lo_col," hi_col=",hi_col,ZFIELD_GA(NIXO_L,NIYO_L), &\r
+!!$          " NIXO_L=",NIXO_L,"NIYO_L=",NIYO_L," ld_col=",ld_col," ISP=",ISP\r
+         call ga_sync\r
+         DEALLOCATE (ZFIELD_GA)\r
+         IF (ISP == TZFD%OWNER)  THEN      \r
+            !\r
+            ! this proc get the  Z slide to write\r
+            !\r
+            lo_zplan(JPIZ) = 1\r
+            hi_zplan(JPIZ) = 1\r
+!!$            ALLOCATE (ZFIELDP_GA(IIU_ll,IJU_ll))\r
+            call nga_get(g_a, lo_zplan, hi_zplan,ZFIELDP, ld_zplan)\r
+!!$            print*,"nga_get=",HRECFM,g_a," lo_zplan=",lo_zplan," hi_zplan=",hi_zplan &\r
+!!$                 ,ZFIELDP(1,1)," ld_zplan=",ld_zplan\r
+         END IF\r
+!!$         call ga_sync\r
+#else\r
+         CALL GATHER_XYFIELD(PFIELD,ZFIELDP,TZFD%OWNER,TZFD%COMM)\r
+!!$         IF (ISP == TZFD%OWNER)  THEN   \r
+!!$            print*,HRECFM, "ERR=", MAXVAL (ZFIELDP_GA - ZFIELDP)\r
+!!$            DO JI=1,IJU_ll\r
+!!$            !print*,HRECFM, "ERR=", ZFIELDP_GA(:,JI) - ZFIELDP(:,JI)\r
+!!$            print*,HRECFM, "WX2::GA =", ZFIELDP_GA(:,JI) \r
+!!$            print*,HRECFM, "WX2::MNH=", ZFIELDP(:,JI)\r
+!!$         END DO\r
+!!$         END IF\r
+#endif\r
+             END IF\r
+          END IF\r
+          CALL SECOND_MNH2(T1)\r
+          TIMEZ%T_WRIT2D_GATH=TIMEZ%T_WRIT2D_GATH + T1 - T0\r
+          !\r
+          IF (ISP == TZFD%OWNER)  THEN             \r
+             TZFMH%GRID=KGRID\r
+             TZFMH%COMLEN=KLENCH\r
+             TZFMH%COMMENT=HCOMMENT\r
+#ifdef MNH_NCWRIT\r
+             IF ( DEF_NC .AND. LLFIFM ) THEN\r
+             CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&\r
+                  & ,IRESP)\r
+             END IF\r
+             LHRECFM = LEN_TRIM(ADJUSTL(HRECFM))\r
+             IF ( LHRECFM > 5 ) THEN\r
+               LHREC_BEG =LHRECFM-4\r
+               IF ( ADJUSTL(HRECFM(LHREC_BEG:LHRECFM)) == 'DATIM') THEN\r
+                   NCWR = .FALSE.\r
+               END IF\r
+             END IF\r
+               IF ( LNETCDF .AND. NC_WRITE .AND. NCWR ) THEN\r
+              TABDIM(1)=SIZE(ZFIELDP,1)\r
+              TABDIM(2)=SIZE(ZFIELDP,2)\r
+                 CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP,.TRUE.,TZRECLIST, &\r
+!                 CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP, &\r
+                 & KLENCH,HCOMMENT)\r
+              END IF\r
+                NCWR=.TRUE.\r
+#else\r
+             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH&\r
+                  & ,IRESP)\r
+             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)\r
+#endif\r
+          END IF\r
+#ifdef MNH_GA\r
+!!$         IF (ISP .EQ. 1 ) THEN\r
+!!$         call ga_print_stats()\r
+!!$         call ga_summarize(1) \r
+!!$         ENDIF\r
+         call ga_sync\r
+!!$         gstatus_ga =  ga_destroy(g_a)\r
+#endif     \r
+          CALL SECOND_MNH2(T2)\r
+          TIMEZ%T_WRIT2D_WRIT=TIMEZ%T_WRIT2D_WRIT + T2 - T1\r
+          !\r
+          CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TZFD%OWNER-1,TZFD&\r
+               & %COMM,IERR)\r
+       END IF\r
+    ELSE\r
+       IRESP = -61\r
+    END IF\r
+    !----------------------------------------------------------------\r
+    IF (IRESP.NE.0) THEN\r
+       CALL FM_WRIT_ERR("FMWRITX2_ll",HFILEM,HFIPRI,HRECFM,HDIR,KGRID,KLENCH,IRESP)\r
+    END IF\r
+    IF (GALLOC) DEALLOCATE(ZFIELDP)\r
+    KRESP = IRESP\r
+    IF (ASSOCIATED(TZFD)) CALL MPI_BARRIER(TZFD%COMM,IERR)\r
+    CALL SECOND_MNH2(T22)\r
+    TIMEZ%T_WRIT2D_ALL=TIMEZ%T_WRIT2D_ALL + T22 - T11\r
+  END SUBROUTINE FMWRITX2_ll\r
+\r
+  SUBROUTINE FMWRITX3_ll(HFILEM,HRECFM,HFIPRI,HDIR,PFIELD,KGRID,&\r
+       KLENCH,HCOMMENT,KRESP)\r
+    USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT,LPACK,L1D,L2D\r
+    USE MODD_PARAMETERS_ll,ONLY : JPHEXT\r
+    USE MODD_FM\r
+    USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL\r
+    USE MODE_ALLOCBUFFER_ll\r
+    USE MODE_GATHER_ll\r
+    !JUANZ    \r
+    USE MODD_IO_ll, ONLY : ISNPROC\r
+    USE MODE_IO_ll, ONLY : io_file,io_rank\r
+    USE MODD_TIMEZ, ONLY : TIMEZ\r
+    USE MODE_MNH_TIMING, ONLY : SECOND_MNH2\r
+    !JUANZ \r
+#ifdef MNH_NCWRIT\r
+    USE MODE_UTIL\r
+    USE MODD_DIM_n, ONLY: NIMAX\r
+    USE MODD_NCOUT\r
+#endif\r
+#ifdef MNH_GA\r
+    USE MODE_GA\r
+#endif\r
+    USE MODD_VAR_ll, ONLY : MNH_STATUSES_IGNORE\r
+    !\r
+    !\r
+    !*      0.1   Declarations of arguments\r
+    !\r
+    CHARACTER(LEN=*),            INTENT(IN) ::HFILEM   ! FM-file name\r
+    CHARACTER(LEN=*),            INTENT(IN) ::HRECFM   ! name of the article to write\r
+    CHARACTER(LEN=*),            INTENT(IN) ::HFIPRI   ! output file for error messages\r
+    CHARACTER(LEN=*),            INTENT(IN) ::HDIR     ! field form\r
+    REAL,DIMENSION(:,:,:),TARGET,INTENT(IN) ::PFIELD   ! array containing the data field\r
+    INTEGER,                     INTENT(IN) ::KGRID    ! C-grid indicator (u,v,w,T)\r
+    INTEGER,                     INTENT(IN) ::KLENCH   ! length of comment string\r
+    CHARACTER(LEN=*),            INTENT(IN) ::HCOMMENT ! comment string\r
+    INTEGER,                     INTENT(OUT)::KRESP    ! return-code \r
+    !\r
+    !*      0.2   Declarations of local variables\r
+    !\r
+    CHARACTER(LEN=JPFINL)                    :: YFNLFI\r
+    INTEGER                                  :: IERR\r
+    TYPE(FD_ll), POINTER                     :: TZFD\r
+    INTEGER                                  :: IRESP\r
+    REAL,DIMENSION(:,:,:),POINTER            :: ZFIELDP\r
+    TYPE(FMHEADER)                           :: TZFMH\r
+    LOGICAL                                  :: GALLOC\r
+    !JUAN\r
+    INTEGER                                  :: JK,JKK\r
+    CHARACTER(LEN=LEN(HRECFM))               :: YK,YRECZSLIDE\r
+    REAL,DIMENSION(:,:),POINTER              :: ZSLIDE_ll,ZSLIDE\r
+    INTEGER                                  :: IK_FILE,IK_rank,inb_proc_real,JK_MAX\r
+    CHARACTER(len=5)                         :: YK_FILE  \r
+    CHARACTER(len=128)                       :: YFILE_IOZ  \r
+    TYPE(FD_ll), POINTER                     :: TZFD_IOZ \r
+    INTEGER                                  :: JI,IXO,IXE,IYO,IYE\r
+    REAL,DIMENSION(:,:),POINTER              :: TX2DP\r
+    INTEGER, DIMENSION(MPI_STATUS_SIZE)      :: STATUS\r
+    INTEGER, ALLOCATABLE,DIMENSION(:,:)      :: STATUSES\r
+    LOGICAL                                  :: GALLOC_ll\r
+    !JUANZIO\r
+    !INTEGER,SAVE,DIMENSION(100000)    :: REQ_TAB\r
+    INTEGER,ALLOCATABLE,DIMENSION(:)         :: REQ_TAB\r
+    INTEGER                                  :: NB_REQ\r
+    TYPE TX_2DP\r
+       REAL,DIMENSION(:,:), POINTER    :: X\r
+    END TYPE TX_2DP\r
+    TYPE(TX_2DP),ALLOCATABLE,DIMENSION(:) :: T_TX2DP\r
+    REAL*8,DIMENSION(2) :: T0,T1,T2\r
+    REAL*8,DIMENSION(2) :: T11,T22\r
+    !JUANZIO\r
+    !JUAN\r
+#ifdef MNH_NCWRIT\r
+    TYPE(workfield), DIMENSION(:), POINTER   :: TZRECLIST\r
+    INTEGER,DIMENSION(6)                     :: TABDIM\r
+    CHARACTER(LEN=LEN(HRECFM))               :: HRECT\r
+    INTEGER                                  :: LHRECT\r
+#endif\r
+#ifdef MNH_GA\r
+    REAL,DIMENSION(:,:,:),POINTER          :: ZFIELD_GA\r
+#endif\r
+    INTEGER                                  :: IHEXTOT\r
+    !\r
+    !*      1.1   THE NAME OF LFIFM\r
+    !\r
+    CALL SECOND_MNH2(T11)\r
+    IRESP = 0\r
+    GALLOC    = .FALSE.\r
+    GALLOC_ll = .FALSE.\r
+    YFNLFI=TRIM(ADJUSTL(HFILEM))//'.lfi'\r
+    !print * , ' Writing Article 3 ' , HRECFM\r
+!\r
+#ifdef MNH_NCWRIT\r
+    HRECT=TRIM(HRECFM)\r
+    LHRECT=LEN(TRIM(HRECT))\r
+    TABDIM(:)=1\r
+    TABDIM(1)=SIZE(PFIELD,1)\r
+    TABDIM(2)=SIZE(PFIELD,2)\r
+    TABDIM(3)=SIZE(PFIELD,3)\r
+   IF ( LHRECT .gt. 4 ) THEN\r
+      IF ( HRECT(LHRECT-4:LHRECT) == 'TRAJZ' ) THEN\r
+           TABDIM(3)=SIZE(PFIELD,1)\r
+           TABDIM(1)=1\r
+      END IF\r
+   END IF\r
+    IF ( TRIM(HRECFM)  == 'AVION.TRAJX' ) THEN\r
+         TABDIM(1)=SIZE(PFIELD,2)\r
+         TABDIM(2)=1\r
+    ELSEIF ( TRIM(HRECFM)  == 'AVION.TRAJY' ) THEN\r
+         TABDIM(1)=SIZE(PFIELD,2)\r
+         TABDIM(2)=1\r
+    ELSEIF ( TRIM(HRECFM)  == 'AVION.TRAJZ' ) THEN\r
+         TABDIM(1)=SIZE(PFIELD,2)\r
+         TABDIM(2)=1\r
+  END IF \r
+#endif\r
+    !------------------------------------------------------------------\r
+    IHEXTOT = 2*JPHEXT+1\r
+    TZFD=>GETFD(YFNLFI)\r
+    IF (ASSOCIATED(TZFD)) THEN\r
+       IF (GSMONOPROC .AND.  (TZFD%nb_procio.eq.1) ) THEN ! sequential execution\r
+          TZFMH%GRID=KGRID\r
+          TZFMH%COMLEN=KLENCH\r
+          TZFMH%COMMENT=HCOMMENT\r
+          !    IF (LPACK .AND. L1D .AND. HDIR=='XY') THEN \r
+          IF (LPACK .AND. L1D .AND. SIZE(PFIELD,1)==IHEXTOT .AND. SIZE(PFIELD,2)==IHEXTOT) THEN \r
+             ZFIELDP=>PFIELD(JPHEXT+1:JPHEXT+1,JPHEXT+1:JPHEXT+1,:)\r
+#ifdef MNH_NCWRIT\r
+        IF ( DEF_NC .AND. LLFIFM ) THEN\r
+          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)\r
+        END IF\r
+        IF ( LNETCDF .AND. NC_WRITE ) THEN\r
+          TABDIM(1)=1\r
+          TABDIM(2)=1\r
+          CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP,.TRUE.,TZRECLIST, &\r
+             & KLENCH,HCOMMENT)\r
+        END IF\r
+#else\r
+             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)\r
+             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)\r
+#endif\r
+             !    ELSE IF (LPACK .AND. L2D .AND. HDIR=='XY') THEN\r
+          ELSEIF (LPACK .AND. L2D .AND. SIZE(PFIELD,2)==IHEXTOT) THEN\r
+             ZFIELDP=>PFIELD(:,JPHEXT+1:JPHEXT+1,:)\r
+#ifdef MNH_NCWRIT\r
+        IF ( DEF_NC .AND. LLFIFM ) THEN\r
+          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)\r
+        END IF\r
+        IF ( LNETCDF .AND. NC_WRITE ) THEN\r
+           TABDIM(2)=1\r
+          IF ( NC_FILE == 'phy' ) THEN\r
+            CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)\r
+          END IF\r
+           CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP,.TRUE.,TZRECLIST, &\r
+!            CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,ZFIELDP, &\r
+               & KLENCH,HCOMMENT)\r
+        END IF\r
+#else\r
+             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(ZFIELDP),ZFIELDP,TZFMH,IRESP)\r
+             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,ZFIELDP,TZFMH,IRESP)\r
+#endif\r
+          ELSE\r
+#ifdef MNH_NCWRIT\r
+        IF ( DEF_NC .AND. LLFIFM ) THEN\r
+          CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)\r
+        END IF\r
+        IF ( LNETCDF .AND. NC_WRITE ) THEN\r
+          IF ( NC_FILE == 'phy' ) THEN\r
+            CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)\r
+          END IF\r
+            CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,PFIELD,.TRUE.,TZRECLIST, &\r
+!             CALL NC_WRIT_ll(HRECFM,HFILEM,KGRID,TABDIM,PFIELD, &\r
+                & KLENCH,HCOMMENT)\r
+        END IF\r
+#else\r
+             IF (LLFIOUT) CALL FM_WRIT_ll(TZFD%FLU,HRECFM,.TRUE.,SIZE(PFIELD),PFIELD,TZFMH,IRESP)\r
+             IF (LIOCDF4) CALL NCWRIT(TZFD%CDF,HRECFM,HDIR,PFIELD,TZFMH,IRESP)\r
+#endif\r
+          END IF\r
+       ELSEIF ( (TZFD%nb_procio .eq. 1 ) .OR. ( HDIR == '--' ) ) THEN  ! multiprocessor execution & 1 proc IO\r
+          ! write 3D field in 1 time = output for graphique\r
+          IF (ISP ==&