diff --git a/src/LIB/SURCOUCHE/src/fmread_ll.f90 b/src/LIB/SURCOUCHE/src/fmread_ll.f90 index 4021ea21a16a0f76fd649dea34654f6b79f5a7e9..b568776033d9afe2136a47d2b88a1c9e3538d74d 100644 --- a/src/LIB/SURCOUCHE/src/fmread_ll.f90 +++ b/src/LIB/SURCOUCHE/src/fmread_ll.f90 @@ -146,8 +146,6 @@ SUBROUTINE IO_READ_FIELD_BYFIELD_X0(TPFILE,TPFIELD,PFIELD,KRESP) ! USE MODD_IO_ll, ONLY : ISP,GSMONOPROC ! -USE MODE_FD_ll, ONLY : GETFD,FD_ll -! TYPE(TFILEDATA), INTENT(IN) :: TPFILE TYPE(TFIELDDATA), INTENT(INOUT) :: TPFIELD REAL, INTENT(INOUT) :: PFIELD ! data field @@ -233,7 +231,6 @@ USE MODD_STRUCTURE_ll, ONLY : ZONE_ll ! USE MODE_SCATTER_ll USE MODE_ALLOCBUFFER_ll -USE MODE_FD_ll, ONLY : GETFD,FD_LL ! TYPE(TFILEDATA), INTENT(IN) :: TPFILE TYPE(TFIELDDATA), INTENT(INOUT) :: TPFIELD @@ -340,7 +337,6 @@ USE MODD_STRUCTURE_ll, ONLY : ZONE_ll USE MODD_TIMEZ, ONLY : TIMEZ ! USE MODE_ALLOCBUFFER_ll -USE MODE_FD_ll, ONLY : GETFD,FD_LL USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 USE MODE_SCATTER_ll ! @@ -394,7 +390,7 @@ IF (IRESP==0) THEN ELSE CALL SECOND_MNH2(T0) IF (ISP == TPFILE%NMASTER_RANK) THEN - ! I/O processor case + ! I/O process case CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,TPFIELD%CDIR,GALLOC, KIMAX_ll, KJMAX_ll) IF (TPFILE%CFORMAT=='NETCDF4') THEN CALL IO_READ_FIELD_NC4(TPFILE,TPFIELD,ZFIELDP,IRESP) @@ -500,7 +496,6 @@ USE MODD_TIMEZ, ONLY : TIMEZ USE MODD_VAR_ll, ONLY : MNH_STATUSES_IGNORE ! USE MODE_ALLOCBUFFER_ll -USE MODE_FD_ll, ONLY : GETFD,FD_LL USE MODE_IO_ll, ONLY : IO_FILE USE MODE_IO_MANAGE_STRUCT, ONLY : IO_FILE_FIND_BYNAME USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 @@ -530,13 +525,9 @@ REAL,DIMENSION(:,:,:),POINTER :: ZFIELDP REAL(KIND=8),DIMENSION(2) :: T0,T1,T2 REAL(KIND=8),DIMENSION(2) :: T11,T22 CHARACTER(LEN=2) :: YDIR -CHARACTER(LEN=128) :: YFILE_IOZ CHARACTER(LEN=4) :: YK -CHARACTER(LEN=5) :: YK_FILE CHARACTER(LEN=NMNHNAMELGTMAX+4) :: YRECZSLICE CHARACTER(LEN=4) :: YSUFFIX -TYPE(FD_ll), POINTER :: TZFD -TYPE(FD_ll), POINTER :: TZFD_IOZ TYPE(TFILEDATA),POINTER :: TZFILE TYPE(TFIELDDATA) :: TZFIELD TYPE(TX_2DP),ALLOCATABLE,DIMENSION(:) :: T_TX2DP @@ -544,6 +535,8 @@ TYPE(TX_2DP),ALLOCATABLE,DIMENSION(:) :: T_TX2DP CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_READ_FIELD_BYFIELD_X3',TRIM(TPFILE%CNAME)//': reading '//TRIM(TPFIELD%CMNHNAME)) ! CALL SECOND_MNH2(T11) +! +TZFILE => NULL() GALLOC = .FALSE. GALLOC_ll = .FALSE. IRESP = 0 @@ -551,11 +544,11 @@ ZFIELDP => NULL() YDIR = TPFIELD%CDIR ! IHEXTOT = 2*JPHEXT+1 -TZFD=>GETFD(TRIM(ADJUSTL(TPFILE%CNAME))//'.lfi') +! CALL IO_FILE_READ_CHECK(TPFILE,'IO_READ_FIELD_BYFIELD_X3',IRESP) ! IF (IRESP==0) THEN - IF (GSMONOPROC .AND. (TZFD%NB_PROCIO==1) ) THEN ! sequential execution + IF (GSMONOPROC .AND. TPFILE%NSUBFILES_IOZ==0 ) THEN ! sequential execution IF (LPACK .AND. L1D .AND. SIZE(PFIELD,1)==IHEXTOT .AND. SIZE(PFIELD,2)==IHEXTOT) THEN ZFIELDP=>PFIELD(JPHEXT+1:JPHEXT+1,JPHEXT+1:JPHEXT+1,:) ELSE IF (LPACK .AND. L2D .AND. SIZE(PFIELD,2)==IHEXTOT) THEN @@ -576,7 +569,7 @@ IF (IRESP==0) THEN ELSE IF (LPACK .AND. L2D .AND. SIZE(PFIELD,2)==IHEXTOT) THEN PFIELD(:,:,:)=SPREAD(ZFIELDP(:,1,:),DIM=2,NCOPIES=IHEXTOT) END IF - ELSE IF ( TZFD%NB_PROCIO==1 .OR. YDIR == '--' ) THEN ! multiprocesses execution & 1 IO proc + ELSE IF ( TPFILE%NSUBFILES_IOZ==0 .OR. YDIR == '--' ) THEN ! multiprocesses execution & 1 IO proc IF (ISP == TPFILE%NMASTER_RANK) THEN ! I/O process case CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,YDIR,GALLOC) @@ -631,16 +624,13 @@ IF (IRESP==0) THEN ALLOCATE(ZSLICE_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(TPFILE%CNAME)//YK_FILE//".lfi" - TZFD_IOZ => GETFD(YFILE_IOZ) - CALL IO_FILE_FIND_BYNAME(TRIM(TPFILE%CNAME)//TRIM(YK_FILE),TZFILE,IRESP) + IK_FILE = IO_FILE(JKK,TPFILE%NSUBFILES_IOZ) + TZFILE => TPFILE%TFILES_IOZ(IK_FILE+1)%TFILE TZFIELD = TPFIELD WRITE(YSUFFIX,'(I4.4)') JKK TZFIELD%CMNHNAME = TRIM(TPFIELD%CMNHNAME)//TRIM(YSUFFIX) ! - IK_RANK = TZFILE%NMASTER_RANK + IK_RANK = TZFILE%NMASTER_RANK ! IF (ISP == IK_RANK ) THEN IF ( SIZE(ZSLICE_ll) .EQ. 0 ) THEN @@ -667,6 +657,7 @@ IF (IRESP==0) THEN HI_ZPLAN(JPIZ) = JKK CALL NGA_PUT(G_A, LO_ZPLAN, HI_ZPLAN,ZSLICE_LL, LD_ZPLAN) END IF + TZFILE => NULL() END DO CALL GA_SYNC ! @@ -680,7 +671,7 @@ IF (IRESP==0) THEN #else ALLOCATE(ZSLICE_ll(0,0)) GALLOC_ll = .TRUE. - INB_PROC_REAL = MIN(TZFD%NB_PROCIO,ISNPROC) + INB_PROC_REAL = MIN(TPFILE%NSUBFILES_IOZ,ISNPROC) Z_SLICE: DO JK=1,SIZE(PFIELD,3),INB_PROC_REAL ! ! read the data @@ -691,27 +682,22 @@ IF (IRESP==0) THEN 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(TPFILE%CNAME)//YK_FILE//".lfi" - TZFD_IOZ => GETFD(YFILE_IOZ) - CALL IO_FILE_FIND_BYNAME(TRIM(TPFILE%CNAME)//TRIM(YK_FILE),TZFILE,IRESP) + IF (TPFILE%NSUBFILES_IOZ .GT. 1 ) THEN + IK_FILE = IO_FILE(JKK,TPFILE%NSUBFILES_IOZ) + TZFILE => TPFILE%TFILES_IOZ(IK_FILE+1)%TFILE TZFIELD = TPFIELD WRITE(YSUFFIX,'(I4.4)') JKK TZFIELD%CMNHNAME = TRIM(TPFIELD%CMNHNAME)//TRIM(YSUFFIX) ELSE - TZFD_IOZ => TZFD TZFILE => TPFILE TZFIELD = TPFIELD END IF - IK_RANK = TZFILE%NMASTER_RANK + IK_RANK = TZFILE%NMASTER_RANK IF (ISP == IK_RANK ) THEN IF ( SIZE(ZSLICE_ll) .EQ. 0 ) THEN DEALLOCATE(ZSLICE_ll) CALL ALLOCBUFFER_ll(ZSLICE_ll,ZSLICE,YDIR,GALLOC_ll) END IF - !JUAN CALL SECOND_MNH2(T0) WRITE(YK,'(I4.4)') JKK YRECZSLICE = TRIM(TPFIELD%CMNHNAME)//YK @@ -722,7 +708,6 @@ IF (IRESP==0) THEN ELSE IF (TPFILE%CFORMAT=='LFICDF4') THEN CALL IO_READ_FIELD_NC4(TZFILE,TZFIELD,ZSLICE_ll,IRESP) END IF - !JUANIOZ CALL SECOND_MNH2(T1) TIMEZ%T_READ3D_READ=TIMEZ%T_READ3D_READ + T1 - T0 DO JI = 1,ISNPROC @@ -732,17 +717,17 @@ IF (IRESP==0) 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) + CALL MPI_ISEND(T_TX2DP(NB_REQ)%X,SIZE(TX2DP),MPI_FLOAT,JI-1,199+IK_RANK, & + TZFILE%NMPICOMM,REQ_TAB(NB_REQ),IERR) + !CALL MPI_BSEND(TX2DP,SIZE(TX2DP),MPI_FLOAT,JI-1,199+IK_RANK,TZFILE%NMPICOMM,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 + TZFILE => NULL() END DO ! ! broadcast the data @@ -766,26 +751,22 @@ IF (IRESP==0) THEN ! ! 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(TPFILE%CNAME)//YK_FILE//".lfi" - TZFD_IOZ => GETFD(YFILE_IOZ) + IF (TPFILE%NSUBFILES_IOZ .GT. 1 ) THEN + IK_FILE = IO_FILE(JKK,TPFILE%NSUBFILES_IOZ) + TZFILE => TPFILE%TFILES_IOZ(IK_FILE+1)%TFILE ELSE - TZFD_IOZ => TZFD + TZFILE => TPFILE END IF ! - !IK_RANK = 1 + io_rank(IK_FILE,ISNPROC,TZFD%nb_procio) - IK_RANK = TZFD_IOZ%OWNER + IK_RANK = TZFILE%NMASTER_RANK ! ZSLICE => PFIELD(:,:,JKK) -!JUANIOZ - !CALL SCATTER_XYFIELD(ZSLICE_ll,ZSLICE,TZFD_IOZ%OWNER,TZFD_IOZ%COMM) + !CALL SCATTER_XYFIELD(ZSLICE_ll,ZSLICE,TZFILE%NMASTER_RANK,TZFILE%NMPICOMM) IF (ISP .NE. IK_RANK) THEN - CALL MPI_RECV(ZSLICE,SIZE(ZSLICE),MPI_FLOAT,IK_RANK-1,199+IK_RANK,TZFD_IOZ%COMM& - & ,STATUS,IERR) + CALL MPI_RECV(ZSLICE,SIZE(ZSLICE),MPI_FLOAT,IK_RANK-1,199+IK_RANK, & + TZFILE%NMPICOMM,STATUS,IERR) END IF -!JUAN IOZ + TZFILE => NULL() END DO CALL SECOND_MNH2(T1) TIMEZ%T_READ3D_RECV=TIMEZ%T_READ3D_RECV + T1 - T0 @@ -859,7 +840,6 @@ USE MODD_STRUCTURE_ll, ONLY : ZONE_ll USE MODD_TIMEZ, ONLY : TIMEZ ! USE MODE_ALLOCBUFFER_ll -USE MODE_FD_ll, ONLY : GETFD,FD_LL USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 USE MODE_SCATTER_ll ! @@ -906,7 +886,7 @@ IF (IRESP==0) THEN END IF ELSE IF (ISP == TPFILE%NMASTER_RANK) THEN - ! I/O processor case + ! I/O process case CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,TPFIELD%CDIR,GALLOC) IF (TPFILE%CFORMAT=='NETCDF4') THEN CALL IO_READ_FIELD_NC4(TPFILE,TPFIELD,ZFIELDP,IRESP) @@ -985,7 +965,6 @@ USE MODD_STRUCTURE_ll, ONLY : ZONE_ll USE MODD_TIMEZ, ONLY : TIMEZ ! USE MODE_ALLOCBUFFER_ll -USE MODE_FD_ll, ONLY : GETFD,FD_LL USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 USE MODE_SCATTER_ll ! @@ -1032,7 +1011,7 @@ IF (IRESP==0) THEN END IF ELSE IF (ISP == TPFILE%NMASTER_RANK) THEN - ! I/O processor case + ! I/O process case CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,TPFIELD%CDIR,GALLOC) IF (TPFILE%CFORMAT=='NETCDF4') THEN CALL IO_READ_FIELD_NC4(TPFILE,TPFIELD,ZFIELDP,IRESP) @@ -1111,7 +1090,6 @@ USE MODD_STRUCTURE_ll, ONLY : ZONE_ll USE MODD_TIMEZ, ONLY : TIMEZ ! USE MODE_ALLOCBUFFER_ll -USE MODE_FD_ll, ONLY : GETFD,FD_LL USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 USE MODE_SCATTER_ll ! @@ -1146,7 +1124,7 @@ IF (IRESP==0) THEN END IF ELSE IF (ISP == TPFILE%NMASTER_RANK) THEN - ! I/O processor case + ! I/O process case CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,TPFIELD%CDIR,GALLOC) IF (TPFILE%CFORMAT=='NETCDF4') THEN CALL IO_READ_FIELD_NC4(TPFILE,TPFIELD,ZFIELDP,IRESP) @@ -1211,7 +1189,6 @@ END SUBROUTINE IO_READ_FIELD_BYNAME_N0 SUBROUTINE IO_READ_FIELD_BYFIELD_N0(TPFILE,TPFIELD,KFIELD,KRESP) ! USE MODD_IO_ll, ONLY : ISP,GSMONOPROC -USE MODE_FD_ll, ONLY : GETFD,FD_LL ! TYPE(TFILEDATA), INTENT(IN) :: TPFILE TYPE(TFIELDDATA), INTENT(INOUT) :: TPFIELD @@ -1289,7 +1266,6 @@ SUBROUTINE IO_READ_FIELD_BYFIELD_N1(TPFILE,TPFIELD,KFIELD,KRESP) USE MODD_IO_ll, ONLY : ISP,GSMONOPROC ! USE MODE_ALLOCBUFFER_ll -USE MODE_FD_ll, ONLY : GETFD,FD_LL USE MODE_SCATTER_ll ! TYPE(TFILEDATA), INTENT(IN) :: TPFILE @@ -1391,7 +1367,6 @@ USE MODD_STRUCTURE_ll, ONLY : ZONE_ll USE MODD_TIMEZ, ONLY : TIMEZ ! USE MODE_ALLOCBUFFER_ll -USE MODE_FD_ll, ONLY : GETFD,FD_LL USE MODE_SCATTER_ll ! TYPE(TFILEDATA), INTENT(IN) :: TPFILE @@ -1437,7 +1412,7 @@ IF (IRESP==0) THEN END IF ELSE IF (ISP == TPFILE%NMASTER_RANK) THEN - ! I/O processor case + ! I/O process case CALL ALLOCBUFFER_ll(IFIELDP,KFIELD,TPFIELD%CDIR,GALLOC) IF (TPFILE%CFORMAT=='NETCDF4') THEN CALL IO_READ_FIELD_NC4(TPFILE,TPFIELD,IFIELDP,IRESP) @@ -1511,7 +1486,6 @@ END SUBROUTINE IO_READ_FIELD_BYNAME_L0 SUBROUTINE IO_READ_FIELD_BYFIELD_L0(TPFILE,TPFIELD,OFIELD,KRESP) ! USE MODD_IO_ll, ONLY : ISP,GSMONOPROC -USE MODE_FD_ll, ONLY : GETFD,FD_LL ! TYPE(TFILEDATA), INTENT(IN) :: TPFILE TYPE(TFIELDDATA), INTENT(INOUT) :: TPFIELD @@ -1587,7 +1561,6 @@ END SUBROUTINE IO_READ_FIELD_BYNAME_L1 SUBROUTINE IO_READ_FIELD_BYFIELD_L1(TPFILE,TPFIELD,OFIELD,KRESP) ! USE MODD_IO_ll, ONLY : ISP,GSMONOPROC -USE MODE_FD_ll, ONLY : GETFD,FD_LL ! TYPE(TFILEDATA), INTENT(IN) :: TPFILE TYPE(TFIELDDATA), INTENT(INOUT) :: TPFIELD @@ -1663,7 +1636,6 @@ END SUBROUTINE IO_READ_FIELD_BYNAME_C0 SUBROUTINE IO_READ_FIELD_BYFIELD_C0(TPFILE,TPFIELD,HFIELD,KRESP) ! USE MODD_IO_ll, ONLY : ISP,GSMONOPROC -USE MODE_FD_ll, ONLY : GETFD,FD_LL ! TYPE(TFILEDATA), INTENT(IN) :: TPFILE TYPE(TFIELDDATA), INTENT(INOUT) :: TPFIELD @@ -1739,7 +1711,6 @@ END SUBROUTINE IO_READ_FIELD_BYNAME_T0 SUBROUTINE IO_READ_FIELD_BYFIELD_T0(TPFILE,TPFIELD,TPDATA,KRESP) ! USE MODD_IO_ll, ONLY : ISP,GSMONOPROC -USE MODE_FD_ll, ONLY : GETFD,FD_LL ! TYPE(TFILEDATA), INTENT(IN) :: TPFILE TYPE(TFIELDDATA), INTENT(INOUT) :: TPFIELD @@ -1830,7 +1801,6 @@ USE MODD_TIMEZ, ONLY : TIMEZ USE MODD_VAR_ll, ONLY : MNH_STATUSES_IGNORE ! USE MODE_DISTRIB_LB -USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 USE MODE_TOOLS_ll, ONLY : GET_GLOBALDIMS_ll ! @@ -1911,7 +1881,7 @@ IF (IRESP==0) THEN PLB(:,1:KRIM+JPHEXT,:) = Z3D(:,1:KRIM+JPHEXT,:) PLB(:,KRIM+JPHEXT+1:2*(KRIM+JPHEXT),:) = Z3D(:,KL3D-KRIM-JPHEXT+1:KL3D,:) END IF - ELSE ! multiprocessor execution + ELSE ! multiprocesses execution IF (ISP == TPFILE%NMASTER_RANK) THEN CALL SECOND_MNH2(T0) CALL GET_GLOBALDIMS_ll(IIMAX_ll,IJMAX_ll) diff --git a/src/LIB/SURCOUCHE/src/fmwrit_ll.f90 b/src/LIB/SURCOUCHE/src/fmwrit_ll.f90 index d7d0de5f3fde27d3babb19f35e3afc6036c53ce7..136ed1c4ec2853464296abca424b422e4947a538 100644 --- a/src/LIB/SURCOUCHE/src/fmwrit_ll.f90 +++ b/src/LIB/SURCOUCHE/src/fmwrit_ll.f90 @@ -112,7 +112,7 @@ MODULE MODE_GA END IF !----------------------------------------------------------------------! ! ! - ! Define/describe local column data owned by this processor to write ! + ! Define/describe local column data owned by this process to write ! ! ! !----------------------------------------------------------------------! IF ( HRW_MODE .EQ. "WRITE" ) THEN @@ -142,7 +142,7 @@ MODULE MODE_GA ! !-----------------------------------------------------! ! ! - ! Size of local ZSLIDE_ll Write buffer on I/O proc ! + ! Size of local ZSLICE_ll Write buffer on I/O proc ! ! ! !-----------------------------------------------------! ! @@ -263,6 +263,37 @@ CONTAINS END SUBROUTINE FIELD_METADATA_CHECK + SUBROUTINE IO_FILE_WRITE_CHECK(TPFILE,HSUBR,KRESP) + TYPE(TFILEDATA), INTENT(IN) :: TPFILE + CHARACTER(LEN=*), INTENT(IN) :: HSUBR + INTEGER, INTENT(OUT) :: KRESP + ! + KRESP = 0 + ! + !Check if file is opened + IF (.NOT.TPFILE%LOPENED) THEN + CALL PRINT_MSG(NVERB_ERROR,'IO',HSUBR,TRIM(TPFILE%CNAME)//' is not opened') + KRESP = -201 + RETURN + END IF + ! + !Check if file is in the right opening mode + IF (TPFILE%CMODE/='WRITE') THEN + CALL PRINT_MSG(NVERB_WARNING,'IO',HSUBR,& + TRIM(TPFILE%CNAME)//': writing in a file opened in '//TRIM(TPFILE%CMODE)//' mode') + END IF + ! + !Check fileformat + IF (TPFILE%CFORMAT/='NETCDF4' .AND. TPFILE%CFORMAT=='LFI' .AND. TPFILE%CFORMAT=='LFICDF4') THEN + CALL PRINT_MSG(NVERB_FATAL,'IO',HSUBR,& + TRIM(TPFILE%CNAME)//': invalid fileformat ('//TRIM(TPFILE%CFORMAT)//')') + KRESP = -202 + RETURN + END IF + ! + END SUBROUTINE IO_FILE_WRITE_CHECK + + SUBROUTINE IO_WRITE_HEADER(TPFILE,HDAD_NAME) ! USE MODD_CONF @@ -330,7 +361,7 @@ CONTAINS SUBROUTINE IO_WRITE_FIELD_BYFIELD_X0(TPFILE,TPFIELD,PFIELD,KRESP) USE MODD_IO_ll - USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL + ! USE MODE_IO_MANAGE_STRUCT, ONLY: IO_FILE_FIND_BYNAME ! IMPLICIT NONE @@ -347,15 +378,10 @@ CONTAINS CHARACTER(LEN=28) :: YFILEM ! FM-file name CHARACTER(LEN=NMNHNAMELGTMAX) :: YRECFM ! name of the article to write CHARACTER(LEN=2) :: YDIR ! field form - CHARACTER(LEN=JPFINL) :: YFNLFI INTEGER :: IERR - TYPE(FD_ll), POINTER :: TZFD INTEGER :: IRESP ! - INTEGER :: IK_FILE,IK_RANK - CHARACTER(len=5) :: YK_FILE - CHARACTER(len=128) :: YFILE_IOZ - TYPE(FD_ll), POINTER :: TZFD_IOZ + INTEGER :: IK_FILE TYPE(TFILEDATA),POINTER :: TZFILE CHARACTER(LEN=:),ALLOCATABLE :: YMSG CHARACTER(LEN=6) :: YRESP @@ -364,51 +390,39 @@ CONTAINS YRECFM = TPFIELD%CMNHNAME YDIR = TPFIELD%CDIR ! + IRESP = 0 + TZFILE => NULL() + ! CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_WRITE_FIELD_BYFIELD_X0',TRIM(YFILEM)//': writing '//TRIM(YRECFM)) ! CALL FIELD_METADATA_CHECK(TPFIELD,TYPEREAL,0,'IO_WRITE_FIELD_BYFIELD_X0') ! - !* 1.1 THE NAME OF LFIFM + CALL IO_FILE_WRITE_CHECK(TPFILE,'IO_WRITE_FIELD_BYFIELD_X0',IRESP) ! - IRESP = 0 - YFNLFI=TRIM(ADJUSTL(YFILEM))//'.lfi' - !------------------------------------------------------------------ - TZFD=>GETFD(YFNLFI) - IF (ASSOCIATED(TZFD)) THEN + IF (IRESP==0) THEN IF (GSMONOPROC) THEN ! sequential execution IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,PFIELD,IRESP) IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,PFIELD,IRESP) - ELSE ! multiprocessor execution + ELSE ! multiprocesses execution IF (ISP == TPFILE%NMASTER_RANK) THEN IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,PFIELD,IRESP) IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,PFIELD,IRESP) END IF ! CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TPFILE%NMASTER_RANK-1,TPFILE%NMPICOMM,IERR) - END IF ! multiprocessor execution - IF (TZFD%nb_procio.gt.1) THEN + END IF ! multiprocesses execution + IF (TPFILE%NSUBFILES_IOZ>0) 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(YFILEM)//YK_FILE//".lfi" - TZFD_IOZ => GETFD(YFILE_IOZ) - IK_RANK = TZFD_IOZ%OWNER - IF ( ISP == IK_RANK ) THEN - CALL IO_FILE_FIND_BYNAME(TRIM(TPFILE%CNAME)//YK_FILE,TZFILE,IRESP) - IF (IRESP/=0) THEN - CALL PRINT_MSG(NVERB_FATAL,'IO','IO_WRITE_FIELD_BYFIELD_X0','file '//TRIM(TRIM(TPFILE%CNAME)//YK_FILE)//& - ' not found in list') - END IF + DO IK_FILE=1,TPFILE%NSUBFILES_IOZ + TZFILE => TPFILE%TFILES_IOZ(IK_FILE)%TFILE + IF ( ISP == TZFILE%NMASTER_RANK ) THEN IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TZFILE,TPFIELD,PFIELD,IRESP) IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TZFILE,TPFIELD,PFIELD,IRESP) END IF END DO ENDIF - ELSE - IRESP = -61 - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BYFIELD_X0','file '//TRIM(TPFILE%CNAME)//' not found') END IF - !---------------------------------------------------------------- + ! IF (IRESP.NE.0) THEN WRITE(YRESP, '( I6 )') IRESP YMSG = 'RESP='//YRESP//' when writing '//TRIM(YRECFM)//' in '//TRIM(TPFILE%CNAME) @@ -447,7 +461,7 @@ CONTAINS SUBROUTINE IO_WRITE_FIELD_BYFIELD_X1(TPFILE,TPFIELD,PFIELD,KRESP) USE MODD_IO_ll - USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL + ! USE MODE_ALLOCBUFFER_ll USE MODE_GATHER_ll USE MODE_IO_MANAGE_STRUCT, ONLY: IO_FILE_FIND_BYNAME @@ -466,20 +480,18 @@ CONTAINS CHARACTER(LEN=28) :: YFILEM ! FM-file name CHARACTER(LEN=NMNHNAMELGTMAX) :: YRECFM ! name of the article to write CHARACTER(LEN=2) :: YDIR ! field form - CHARACTER(LEN=JPFINL) :: YFNLFI INTEGER :: IERR - TYPE(FD_ll), POINTER :: TZFD INTEGER :: IRESP INTEGER :: ISIZEMAX REAL,DIMENSION(:),POINTER :: ZFIELDP LOGICAL :: GALLOC ! - INTEGER :: IK_FILE,IK_RANK - CHARACTER(len=5) :: YK_FILE - CHARACTER(len=128) :: YFILE_IOZ CHARACTER(LEN=:),ALLOCATABLE :: YMSG CHARACTER(LEN=6) :: YRESP ! + IRESP = 0 + GALLOC = .FALSE. + ! YFILEM = TPFILE%CNAME YRECFM = TPFIELD%CMNHNAME YDIR = TPFIELD%CDIR @@ -488,19 +500,13 @@ CONTAINS ! CALL FIELD_METADATA_CHECK(TPFIELD,TYPEREAL,1,'IO_WRITE_FIELD_BYFIELD_X1') ! + CALL IO_FILE_WRITE_CHECK(TPFILE,'IO_WRITE_FIELD_BYFIELD_X1',IRESP) ! - !* 1.1 THE NAME OF LFIFM - ! - IRESP = 0 - GALLOC = .FALSE. - YFNLFI=TRIM(ADJUSTL(YFILEM))//'.lfi' - !------------------------------------------------------------------ - TZFD=>GETFD(YFNLFI) - IF (ASSOCIATED(TZFD)) THEN + IF (IRESP==0) THEN IF (GSMONOPROC) THEN ! sequential execution IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,PFIELD,IRESP) IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,PFIELD,IRESP) - ELSE ! multiprocessor execution + ELSE ! multiprocesses execution #ifndef MNH_INT8 CALL MPI_ALLREDUCE(SIZE(PFIELD),ISIZEMAX,1,MPI_INTEGER,MPI_MAX,TPFILE%NMPICOMM,IRESP) #else @@ -529,12 +535,9 @@ CONTAINS END IF ! CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TPFILE%NMASTER_RANK-1,TPFILE%NMPICOMM,IERR) - END IF ! multiprocessor execution - ELSE - IRESP = -61 - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BYFIELD_X1','file '//TRIM(TPFILE%CNAME)//' not found') + END IF ! multiprocesses execution END IF - !---------------------------------------------------------------- + ! IF (IRESP.NE.0) THEN WRITE(YRESP, '( I6 )') IRESP YMSG = 'RESP='//YRESP//' when writing '//TRIM(YRECFM)//' in '//TRIM(TPFILE%CNAME) @@ -574,17 +577,15 @@ CONTAINS SUBROUTINE IO_WRITE_FIELD_BYFIELD_X2(TPFILE,TPFIELD,PFIELD,KRESP) USE MODD_IO_ll - USE MODD_PARAMETERS_ll,ONLY : JPHEXT - USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL + USE MODD_PARAMETERS_ll, ONLY : JPHEXT + USE MODD_TIMEZ, ONLY : TIMEZ + ! USE MODE_ALLOCBUFFER_ll - USE MODE_GATHER_ll - !JUANZ - USE MODD_TIMEZ, ONLY : TIMEZ - USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 - !JUANZ #ifdef MNH_GA USE MODE_GA #endif + USE MODE_GATHER_ll + USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 ! IMPLICIT NONE ! @@ -600,22 +601,16 @@ CONTAINS CHARACTER(LEN=28) :: YFILEM ! FM-file name CHARACTER(LEN=NMNHNAMELGTMAX) :: YRECFM ! name of the article to write CHARACTER(LEN=2) :: YDIR ! field form - CHARACTER(LEN=JPFINL) :: YFNLFI INTEGER :: IERR INTEGER :: ISIZEMAX - TYPE(FD_ll), POINTER :: TZFD INTEGER :: IRESP REAL,DIMENSION(:,:),POINTER :: ZFIELDP LOGICAL :: GALLOC ! - !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 + REAL,DIMENSION(:,:),POINTER :: ZFIELD_GA #endif INTEGER :: IHEXTOT CHARACTER(LEN=:),ALLOCATABLE :: YMSG @@ -625,20 +620,19 @@ CONTAINS YRECFM = TPFIELD%CMNHNAME YDIR = TPFIELD%CDIR ! + IRESP = 0 + GALLOC = .FALSE. + IHEXTOT = 2*JPHEXT+1 + ! + CALL SECOND_MNH2(T11) + ! CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_WRITE_FIELD_BYFIELD_X2',TRIM(YFILEM)//': writing '//TRIM(YRECFM)) ! CALL FIELD_METADATA_CHECK(TPFIELD,TYPEREAL,2,'IO_WRITE_FIELD_BYFIELD_X2') ! - !* 1.1 THE NAME OF LFIFM + CALL IO_FILE_WRITE_CHECK(TPFILE,'IO_WRITE_FIELD_BYFIELD_X2',IRESP) ! - CALL SECOND_MNH2(T11) - IRESP = 0 - GALLOC = .FALSE. - YFNLFI=TRIM(ADJUSTL(YFILEM))//'.lfi' - !------------------------------------------------------------------ - IHEXTOT = 2*JPHEXT+1 - TZFD=>GETFD(YFNLFI) - IF (ASSOCIATED(TZFD)) THEN + IF (IRESP==0) THEN IF (GSMONOPROC) THEN ! sequential execution ! IF (LPACK .AND. L1D .AND. YDIR=='XY') THEN IF (LPACK .AND. L1D .AND. SIZE(PFIELD,1)==IHEXTOT .AND. SIZE(PFIELD,2)==IHEXTOT) THEN @@ -654,7 +648,7 @@ CONTAINS IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,PFIELD,IRESP) IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,PFIELD,IRESP) END IF - ELSE ! multiprocessor execution + ELSE ! multiprocesses execution CALL SECOND_MNH2(T0) #ifndef MNH_INT8 CALL MPI_ALLREDUCE(SIZE(PFIELD),ISIZEMAX,1,MPI_INTEGER,MPI_MAX,TPFILE%NMPICOMM,IRESP) @@ -668,7 +662,7 @@ CONTAINS END IF IF (ISP == TPFILE%NMASTER_RANK) THEN - ! I/O processor case + ! I/O process case CALL ALLOCBUFFER_ll(ZFIELDP,PFIELD,YDIR,GALLOC) ELSE ALLOCATE(ZFIELDP(0,0)) @@ -692,8 +686,6 @@ CONTAINS 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 =",YRECFM,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 == TPFILE%NMASTER_RANK) THEN @@ -702,22 +694,10 @@ CONTAINS ! 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=",YRECFM,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,TPFILE%NMASTER_RANK,TPFILE%NMPICOMM) -!!$ IF (ISP == TPFILE%NMASTER_RANK) THEN -!!$ print*,YRECFM, "ERR=", MAXVAL (ZFIELDP_GA - ZFIELDP) -!!$ DO JI=1,IJU_ll -!!$ !print*,YRECFM, "ERR=", ZFIELDP_GA(:,JI) - ZFIELDP(:,JI) -!!$ print*,YRECFM, "WX2::GA =", ZFIELDP_GA(:,JI) -!!$ print*,YRECFM, "WX2::MNH=", ZFIELDP(:,JI) -!!$ END DO -!!$ END IF #endif END IF END IF @@ -729,23 +709,15 @@ CONTAINS IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,ZFIELDP,IRESP) 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,TPFILE%NMASTER_RANK-1,TPFILE%NMPICOMM,IERR) END IF - ELSE - IRESP = -61 - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BYFIELD_X2','file '//TRIM(TPFILE%CNAME)//' not found') END IF - !---------------------------------------------------------------- + ! IF (IRESP.NE.0) THEN WRITE(YRESP, '( I6 )') IRESP YMSG = 'RESP='//YRESP//' when writing '//TRIM(YRECFM)//' in '//TRIM(TPFILE%CNAME) @@ -753,7 +725,6 @@ CONTAINS END IF IF (GALLOC) DEALLOCATE(ZFIELDP) IF (PRESENT(KRESP)) KRESP = IRESP - IF (ASSOCIATED(TZFD)) CALL MPI_BARRIER(TPFILE%NMPICOMM,IERR) CALL SECOND_MNH2(T22) TIMEZ%T_WRIT2D_ALL=TIMEZ%T_WRIT2D_ALL + T22 - T11 END SUBROUTINE IO_WRITE_FIELD_BYFIELD_X2 @@ -788,16 +759,14 @@ CONTAINS SUBROUTINE IO_WRITE_FIELD_BYFIELD_X3(TPFILE,TPFIELD,PFIELD,KRESP) USE MODD_IO_ll - USE MODD_PARAMETERS_ll,ONLY : JPHEXT - USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL + USE MODD_PARAMETERS_ll, ONLY : JPHEXT + USE MODD_TIMEZ, ONLY : TIMEZ + ! USE MODE_ALLOCBUFFER_ll USE MODE_GATHER_ll - !JUANZ - USE MODE_IO_ll, ONLY : io_file,io_rank - USE MODE_IO_MANAGE_STRUCT, ONLY: IO_FILE_FIND_BYNAME - USE MODD_TIMEZ, ONLY : TIMEZ - USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 - !JUANZ + USE MODE_IO_ll, ONLY : IO_FILE + USE MODE_IO_MANAGE_STRUCT, ONLY : IO_FILE_FIND_BYNAME + USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 #ifdef MNH_GA USE MODE_GA #endif @@ -816,27 +785,18 @@ CONTAINS CHARACTER(LEN=28) :: YFILEM ! FM-file name CHARACTER(LEN=NMNHNAMELGTMAX) :: YRECFM ! name of the article to write CHARACTER(LEN=2) :: YDIR ! field form - CHARACTER(LEN=JPFINL) :: YFNLFI INTEGER :: IERR INTEGER :: ISIZEMAX - TYPE(FD_ll), POINTER :: TZFD INTEGER :: IRESP REAL,DIMENSION(:,:,:),POINTER :: ZFIELDP LOGICAL :: GALLOC - !JUAN INTEGER :: JK,JKK - 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 + REAL,DIMENSION(:,:),POINTER :: ZSLICE_ll,ZSLICE + INTEGER :: IK_FILE,IK_RANK,INB_PROC_REAL,JK_MAX 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 @@ -845,8 +805,6 @@ CONTAINS TYPE(TX_2DP),ALLOCATABLE,DIMENSION(:) :: T_TX2DP REAL*8,DIMENSION(2) :: T0,T1,T2 REAL*8,DIMENSION(2) :: T11,T22 - !JUANZIO - !JUAN #ifdef MNH_GA REAL,DIMENSION(:,:,:),POINTER :: ZFIELD_GA #endif @@ -861,23 +819,21 @@ CONTAINS YRECFM = TPFIELD%CMNHNAME YDIR = TPFIELD%CDIR ! + IRESP = 0 + GALLOC = .FALSE. + GALLOC_ll = .FALSE. + IHEXTOT = 2*JPHEXT+1 + ! CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_WRITE_FIELD_BYFIELD_X3',TRIM(YFILEM)//': writing '//TRIM(YRECFM)) ! + CALL SECOND_MNH2(T11) + ! CALL FIELD_METADATA_CHECK(TPFIELD,TYPEREAL,3,'IO_WRITE_FIELD_BYFIELD_X3') ! - !* 1.1 THE NAME OF LFIFM + CALL IO_FILE_WRITE_CHECK(TPFILE,'IO_WRITE_FIELD_BYFIELD_X3',IRESP) ! - CALL SECOND_MNH2(T11) - IRESP = 0 - GALLOC = .FALSE. - GALLOC_ll = .FALSE. - YFNLFI=TRIM(ADJUSTL(YFILEM))//'.lfi' -! - !------------------------------------------------------------------ - IHEXTOT = 2*JPHEXT+1 - TZFD=>GETFD(YFNLFI) - IF (ASSOCIATED(TZFD)) THEN - IF (GSMONOPROC .AND. (TZFD%nb_procio.eq.1) ) THEN ! sequential execution + IF (IRESP==0) THEN + IF (GSMONOPROC .AND. TPFILE%NSUBFILES_IOZ==0 ) THEN ! sequential execution ! IF (LPACK .AND. L1D .AND. YDIR=='XY') THEN IF (LPACK .AND. L1D .AND. SIZE(PFIELD,1)==IHEXTOT .AND. SIZE(PFIELD,2)==IHEXTOT) THEN ZFIELDP=>PFIELD(JPHEXT+1:JPHEXT+1,JPHEXT+1:JPHEXT+1,:) @@ -892,7 +848,7 @@ CONTAINS IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,PFIELD,IRESP) IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,PFIELD,IRESP) END IF - ELSEIF ( (TZFD%nb_procio .eq. 1 ) .OR. ( YDIR == '--' ) ) THEN ! multiprocessor execution & 1 proc IO + ELSEIF ( TPFILE%NSUBFILES_IOZ==0 .OR. YDIR=='--' ) THEN ! multiprocesses execution & 1 proc IO #ifndef MNH_INT8 CALL MPI_ALLREDUCE(SIZE(PFIELD),ISIZEMAX,1,MPI_INTEGER,MPI_MAX,TPFILE%NMPICOMM,IRESP) #else @@ -929,7 +885,7 @@ CONTAINS ! CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TPFILE%NMASTER_RANK-1,TPFILE%NMPICOMM,IERR) ! - ELSE ! multiprocessor execution & // IO + ELSE ! multiprocesses execution & // IO #ifndef MNH_INT8 CALL MPI_ALLREDUCE(SIZE(PFIELD),ISIZEMAX,1,MPI_INTEGER,MPI_MAX,TPFILE%NMPICOMM,IRESP) #else @@ -941,7 +897,7 @@ CONTAINS RETURN END IF ! - !JUAN BG Z SLIDE + !JUAN BG Z SLICE ! ! #ifdef MNH_GA @@ -957,102 +913,75 @@ CONTAINS 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 =",YRECFM,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 + ALLOCATE(ZSLICE_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(YFILEM)//YK_FILE//".lfi" - TZFD_IOZ => GETFD(YFILE_IOZ) - CALL IO_FILE_FIND_BYNAME(TRIM(YFILEM)//YK_FILE,TZFILE,IRESP) - IF (IRESP/=0) THEN - CALL PRINT_MSG(NVERB_FATAL,'IO','IO_WRITE_FIELD_BYFIELD_X3','file '//TRIM(YFILE_IOZ)//& - ' not found in list') - END IF + IK_FILE = IO_FILE(JKK,TPFILE%NSUBFILES_IOZ) + TZFILE => TPFILE%TFILES_IOZ(IK_FILE+1)%TFILE ! - IK_RANK = TZFD_IOZ%OWNER - !IK_RANK = 1 + io_rank(IK_FILE,ISNPROC,TZFD%nb_procio) + IK_RANK = TZFILE%NMASTER_RANK ! IF (ISP == IK_RANK ) THEN CALL SECOND_MNH2(T0) ! - IF ( SIZE(ZSLIDE_ll) .EQ. 0 ) THEN - DEALLOCATE(ZSLIDE_ll) - CALL ALLOCBUFFER_ll(ZSLIDE_ll,ZSLIDE,YDIR,GALLOC_ll) + IF ( SIZE(ZSLICE_ll) .EQ. 0 ) THEN + DEALLOCATE(ZSLICE_ll) + CALL ALLOCBUFFER_ll(ZSLICE_ll,ZSLICE,YDIR,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 nga_get(g_a, lo_zplan, hi_zplan,ZSLICE_ll, ld_zplan) CALL SECOND_MNH2(T1) TIMEZ%T_WRIT3D_RECV=TIMEZ%T_WRIT3D_RECV + T1 - T0 ! - IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,ZSLIDE_ll,IRESP,KVERTLEVEL=JKK,KZFILE=IK_FILE+1) - IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,ZSLIDE_ll,IRESP,KVERTLEVEL=JKK,KZFILE=IK_FILE+1) + IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,ZSLICE_ll,IRESP,KVERTLEVEL=JKK,KZFILE=IK_FILE+1) + IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,ZSLICE_ll,IRESP,KVERTLEVEL=JKK,KZFILE=IK_FILE+1) 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)) + ALLOCATE(ZSLICE_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 + INB_PROC_REAL = MIN(TPFILE%NSUBFILES_IOZ,ISNPROC) + Z_SLICE: DO JK=1,SIZE(PFIELD,3),INB_PROC_REAL ! - ! collecte the data + ! collect the data ! - JK_MAX=min(SIZE(PFIELD,3),JK+inb_proc_real-1) + 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)) + 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(YFILEM)//YK_FILE//".lfi" - TZFD_IOZ => GETFD(YFILE_IOZ) - CALL IO_FILE_FIND_BYNAME(TRIM(YFILEM)//YK_FILE,TZFILE,IRESP) - IF (IRESP/=0) THEN - CALL PRINT_MSG(NVERB_FATAL,'IO','IO_WRITE_FIELD_BYFIELD_X3','file '//TRIM(YFILE_IOZ)//& - ' not found in list') - END IF + IF (TPFILE%NSUBFILES_IOZ .GT. 1 ) THEN + IK_FILE = IO_FILE(JKK,TPFILE%NSUBFILES_IOZ) + TZFILE => TPFILE%TFILES_IOZ(IK_FILE+1)%TFILE ELSE - TZFD_IOZ => TZFD TZFILE => TPFILE END IF ! - !IK_RANK = 1 + io_rank(IK_FILE,ISNPROC,TZFD%nb_procio) - IK_RANK = TZFD_IOZ%OWNER + IK_RANK = TZFILE%NMASTER_RANK ! IF (YDIR == 'XX' .OR. YDIR =='YY') THEN STOP " XX NON PREVU SUR BG POUR LE MOMENT " @@ -1062,26 +991,23 @@ CONTAINS STOP " L2D NON PREVU SUR BG POUR LE MOMENT " CALL GATHER_XXFIELD('XX',PFIELD(:,JPHEXT+1,:),ZFIELDP(:,1,:),TPFILE%NMASTER_RANK,TPFILE%NMPICOMM) 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 + ! Other processes 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) + ZSLICE => PFIELD(:,:,JKK) + TX2DP=>ZSLICE(IXO:IXE,IYO:IYE) + T_TX2DP(NB_REQ)%X=ZSLICE(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) + & ,TZFILE%NMPICOMM,REQ_TAB(NB_REQ),IERR) + !CALL MPI_BSEND(TX2DP,SIZE(TX2DP),MPI_FLOAT,IK_RANK-1,99+IK_RANK,TZFILE%NMPICOMM,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 @@ -1089,90 +1015,67 @@ CONTAINS ! 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(YFILEM)//YK_FILE//".lfi" - TZFD_IOZ => GETFD(YFILE_IOZ) - CALL IO_FILE_FIND_BYNAME(TRIM(YFILEM)//YK_FILE,TZFILE,IRESP) - IF (IRESP/=0) THEN - CALL PRINT_MSG(NVERB_FATAL,'IO','IO_WRITE_FIELD_BYFIELD_X3','file '//TRIM(YFILE_IOZ)//& - ' not found in list') - END IF + IF (TPFILE%NSUBFILES_IOZ .GT. 1 ) THEN + IK_FILE = IO_FILE(JKK,TPFILE%NSUBFILES_IOZ) + TZFILE => TPFILE%TFILES_IOZ(IK_FILE+1)%TFILE ELSE - TZFD_IOZ => TZFD TZFILE => TPFILE ENDIF - IK_RANK = TZFD_IOZ%OWNER - !IK_RANK = 1 + io_rank(IK_FILE,ISNPROC,TZFD%nb_procio) + IK_RANK = TZFILE%NMASTER_RANK ! 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,YDIR,GALLOC_ll) + IF ( SIZE(ZSLICE_ll) .EQ. 0 ) THEN + DEALLOCATE(ZSLICE_ll) + CALL ALLOCBUFFER_ll(ZSLICE_ll,ZSLICE,YDIR,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) + TX2DP=>ZSLICE_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) + ZSLICE => PFIELD(:,:,JKK) + TX2DP = ZSLICE(IXO:IXE,IYO:IYE) ELSE - CALL MPI_RECV(TX2DP,SIZE(TX2DP),MPI_FLOAT,JI-1,99+IK_RANK,TZFD_IOZ%COMM,STATUS,IERR) + CALL MPI_RECV(TX2DP,SIZE(TX2DP),MPI_FLOAT,JI-1,99+IK_RANK,TZFILE%NMPICOMM,STATUS,IERR) END IF END IF END DO CALL SECOND_MNH2(T1) TIMEZ%T_WRIT3D_RECV=TIMEZ%T_WRIT3D_RECV + T1 - T0 - !JUANIOZ - IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,ZSLIDE_ll,IRESP,KVERTLEVEL=JKK,KZFILE=IK_FILE+1) - IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,ZSLIDE_ll,IRESP, & - KVERTLEVEL=JKK,KZFILE=IK_FILE+1) + IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,ZSLICE_ll,IRESP,KVERTLEVEL=JKK,KZFILE=IK_FILE+1) + IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,ZSLICE_ll,IRESP,KVERTLEVEL=JKK,KZFILE=IK_FILE+1) 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 DO Z_SLICE + !JUAN BG Z SLICE ! end of MNH_GA #endif - END IF ! multiprocessor execution - ELSE - IRESP = -61 - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BYFIELD_X3','file '//TRIM(TPFILE%CNAME)//' not found') + END IF ! multiprocesses execution END IF - !---------------------------------------------------------------- + ! IF (IRESP.NE.0) THEN WRITE(YRESP, '( I6 )') IRESP YMSG = 'RESP='//YRESP//' when writing '//TRIM(YRECFM)//' in '//TRIM(TPFILE%CNAME) CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BYFIELD_X3',YMSG) END IF - IF (GALLOC) DEALLOCATE(ZFIELDP) - IF (GALLOC_ll) DEALLOCATE(ZSLIDE_ll) - !IF (Associated(ZSLIDE_ll)) DEALLOCATE(ZSLIDE_ll) + IF (GALLOC) DEALLOCATE(ZFIELDP) + IF (GALLOC_ll) DEALLOCATE(ZSLICE_ll) IF (PRESENT(KRESP)) KRESP = IRESP - IF (ASSOCIATED(TZFD)) CALL MPI_BARRIER(TPFILE%NMPICOMM,IERR) CALL SECOND_MNH2(T22) TIMEZ%T_WRIT3D_ALL=TIMEZ%T_WRIT3D_ALL + T22 - T11 END SUBROUTINE IO_WRITE_FIELD_BYFIELD_X3 @@ -1207,16 +1110,14 @@ CONTAINS SUBROUTINE IO_WRITE_FIELD_BYFIELD_X4(TPFILE,TPFIELD,PFIELD,KRESP) USE MODD_IO_ll - USE MODD_PARAMETERS_ll,ONLY : JPHEXT - USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL + USE MODD_PARAMETERS_ll, ONLY : JPHEXT + USE MODD_TIMEZ, ONLY : TIMEZ + ! USE MODE_ALLOCBUFFER_ll USE MODE_GATHER_ll - !JUANZ - USE MODE_IO_ll, ONLY : io_file,io_rank - USE MODD_TIMEZ, ONLY : TIMEZ - USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 - !JUANZ - USE MODD_VAR_ll, ONLY : MNH_STATUSES_IGNORE + USE MODE_IO_ll, ONLY : IO_FILE,IO_RANK + USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 + USE MODD_VAR_ll, ONLY : MNH_STATUSES_IGNORE ! ! !* 0.1 Declarations of arguments @@ -1231,10 +1132,8 @@ CONTAINS CHARACTER(LEN=28) :: YFILEM ! FM-file name CHARACTER(LEN=NMNHNAMELGTMAX) :: YRECFM ! name of the article to write CHARACTER(LEN=2) :: YDIR ! field form - CHARACTER(LEN=JPFINL) :: YFNLFI INTEGER :: IERR INTEGER :: ISIZEMAX - TYPE(FD_ll), POINTER :: TZFD INTEGER :: IRESP REAL,DIMENSION(:,:,:,:),POINTER :: ZFIELDP LOGICAL :: GALLOC @@ -1246,18 +1145,18 @@ CONTAINS YRECFM = TPFIELD%CMNHNAME YDIR = TPFIELD%CDIR ! + IRESP = 0 + GALLOC = .FALSE. + ! + IHEXTOT = 2*JPHEXT+1 + ! CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_WRITE_FIELD_BYFIELD_X4',TRIM(YFILEM)//': writing '//TRIM(YRECFM)) ! CALL FIELD_METADATA_CHECK(TPFIELD,TYPEREAL,4,'IO_WRITE_FIELD_BYFIELD_X4') ! - IRESP = 0 - GALLOC = .FALSE. - YFNLFI=TRIM(ADJUSTL(YFILEM))//'.lfi' -! - !------------------------------------------------------------------ - IHEXTOT = 2*JPHEXT+1 - TZFD=>GETFD(YFNLFI) - IF (ASSOCIATED(TZFD)) THEN + CALL IO_FILE_WRITE_CHECK(TPFILE,'IO_WRITE_FIELD_BYFIELD_X4',IRESP) + ! + IF (IRESP==0) THEN IF (GSMONOPROC) THEN ! sequential execution ! IF (LPACK .AND. L1D .AND. YDIR=='XY') THEN IF (LPACK .AND. L1D .AND. SIZE(PFIELD,1)==IHEXTOT .AND. SIZE(PFIELD,2)==IHEXTOT) THEN @@ -1306,12 +1205,9 @@ CONTAINS END IF ! CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TPFILE%NMASTER_RANK-1,TPFILE%NMPICOMM,IERR) - END IF ! multiprocessor execution - ELSE - IRESP = -61 - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BYFIELD_X4','file '//TRIM(TPFILE%CNAME)//' not found') + END IF ! multiprocess execution END IF - !---------------------------------------------------------------- + ! IF (IRESP.NE.0) THEN WRITE(YRESP, '( I6 )') IRESP YMSG = 'RESP='//YRESP//' when writing '//TRIM(YRECFM)//' in '//TRIM(TPFILE%CNAME) @@ -1351,16 +1247,14 @@ CONTAINS SUBROUTINE IO_WRITE_FIELD_BYFIELD_X5(TPFILE,TPFIELD,PFIELD,KRESP) USE MODD_IO_ll - USE MODD_PARAMETERS_ll,ONLY : JPHEXT - USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL + USE MODD_PARAMETERS_ll, ONLY : JPHEXT + USE MODD_TIMEZ, ONLY : TIMEZ + ! USE MODE_ALLOCBUFFER_ll USE MODE_GATHER_ll - !JUANZ - USE MODE_IO_ll, ONLY : io_file,io_rank - USE MODD_TIMEZ, ONLY : TIMEZ - USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 - !JUANZ - USE MODD_VAR_ll, ONLY : MNH_STATUSES_IGNORE + USE MODE_IO_ll, ONLY : IO_FILE,IO_RANK + USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 + USE MODD_VAR_ll, ONLY : MNH_STATUSES_IGNORE ! ! !* 0.1 Declarations of arguments @@ -1375,10 +1269,8 @@ CONTAINS CHARACTER(LEN=28) :: YFILEM ! FM-file name CHARACTER(LEN=NMNHNAMELGTMAX) :: YRECFM ! name of the article to write CHARACTER(LEN=2) :: YDIR ! field form - CHARACTER(LEN=JPFINL) :: YFNLFI INTEGER :: IERR INTEGER :: ISIZEMAX - TYPE(FD_ll), POINTER :: TZFD INTEGER :: IRESP REAL,DIMENSION(:,:,:,:,:),POINTER :: ZFIELDP LOGICAL :: GALLOC @@ -1390,18 +1282,18 @@ CONTAINS YRECFM = TPFIELD%CMNHNAME YDIR = TPFIELD%CDIR ! + IRESP = 0 + GALLOC = .FALSE. + ! + IHEXTOT = 2*JPHEXT+1 + ! CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_WRITE_FIELD_BYFIELD_X5',TRIM(YFILEM)//': writing '//TRIM(YRECFM)) ! CALL FIELD_METADATA_CHECK(TPFIELD,TYPEREAL,5,'IO_WRITE_FIELD_BYFIELD_X5') ! - IRESP = 0 - GALLOC = .FALSE. - YFNLFI=TRIM(ADJUSTL(YFILEM))//'.lfi' -! - !------------------------------------------------------------------ - IHEXTOT = 2*JPHEXT+1 - TZFD=>GETFD(YFNLFI) - IF (ASSOCIATED(TZFD)) THEN + CALL IO_FILE_WRITE_CHECK(TPFILE,'IO_WRITE_FIELD_BYFIELD_X5',IRESP) + ! + IF (IRESP==0) THEN IF (GSMONOPROC) THEN ! sequential execution ! IF (LPACK .AND. L1D .AND. YDIR=='XY') THEN IF (LPACK .AND. L1D .AND. SIZE(PFIELD,1)==IHEXTOT .AND. SIZE(PFIELD,2)==IHEXTOT) THEN @@ -1451,12 +1343,9 @@ CONTAINS END IF ! CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TPFILE%NMASTER_RANK-1,TPFILE%NMPICOMM,IERR) - END IF ! multiprocessor execution - ELSE - IRESP = -61 - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BYFIELD_X5','file '//TRIM(TPFILE%CNAME)//' not found') + END IF ! multiprocess execution END IF - !---------------------------------------------------------------- + ! IF (IRESP.NE.0) THEN WRITE(YRESP, '( I6 )') IRESP YMSG = 'RESP='//YRESP//' when writing '//TRIM(YRECFM)//' in '//TRIM(TPFILE%CNAME) @@ -1495,16 +1384,14 @@ CONTAINS SUBROUTINE IO_WRITE_FIELD_BYFIELD_X6(TPFILE,TPFIELD,PFIELD,KRESP) USE MODD_IO_ll - USE MODD_PARAMETERS_ll,ONLY : JPHEXT - USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL + USE MODD_PARAMETERS_ll, ONLY : JPHEXT + USE MODD_TIMEZ, ONLY : TIMEZ + ! USE MODE_ALLOCBUFFER_ll USE MODE_GATHER_ll - !JUANZ - USE MODE_IO_ll, ONLY : io_file,io_rank - USE MODD_TIMEZ, ONLY : TIMEZ - USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 - !JUANZ - USE MODD_VAR_ll, ONLY : MNH_STATUSES_IGNORE + USE MODE_IO_ll, ONLY : IO_FILE,IO_RANK + USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 + USE MODD_VAR_ll, ONLY : MNH_STATUSES_IGNORE ! ! !* 0.1 Declarations of arguments @@ -1519,10 +1406,8 @@ CONTAINS CHARACTER(LEN=28) :: YFILEM ! FM-file name CHARACTER(LEN=NMNHNAMELGTMAX) :: YRECFM ! name of the article to write CHARACTER(LEN=2) :: YDIR ! field form - CHARACTER(LEN=JPFINL) :: YFNLFI INTEGER :: IERR INTEGER :: ISIZEMAX - TYPE(FD_ll), POINTER :: TZFD INTEGER :: IRESP REAL,DIMENSION(:,:,:,:,:,:),POINTER :: ZFIELDP LOGICAL :: GALLOC @@ -1534,18 +1419,18 @@ CONTAINS YRECFM = TPFIELD%CMNHNAME YDIR = TPFIELD%CDIR ! + IRESP = 0 + GALLOC = .FALSE. + ! + IHEXTOT = 2*JPHEXT+1 + ! CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_WRITE_FIELD_BYFIELD_X6',TRIM(YFILEM)//': writing '//TRIM(YRECFM)) ! CALL FIELD_METADATA_CHECK(TPFIELD,TYPEREAL,6,'IO_WRITE_FIELD_BYFIELD_X6') ! - IRESP = 0 - GALLOC = .FALSE. - YFNLFI=TRIM(ADJUSTL(YFILEM))//'.lfi' -! - !------------------------------------------------------------------ - IHEXTOT = 2*JPHEXT+1 - TZFD=>GETFD(YFNLFI) - IF (ASSOCIATED(TZFD)) THEN + CALL IO_FILE_WRITE_CHECK(TPFILE,'IO_WRITE_FIELD_BYFIELD_X6',IRESP) + ! + IF (IRESP==0) THEN IF (GSMONOPROC) THEN ! sequential execution IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,PFIELD,IRESP) IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,PFIELD,IRESP) @@ -1580,12 +1465,9 @@ CONTAINS END IF ! CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TPFILE%NMASTER_RANK-1,TPFILE%NMPICOMM,IERR) - END IF ! multiprocessor execution - ELSE - IRESP = -61 - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BYFIELD_X6','file '//TRIM(TPFILE%CNAME)//' not found') + END IF ! multiprocess execution END IF - !---------------------------------------------------------------- + ! IF (IRESP.NE.0) THEN WRITE(YRESP, '( I6 )') IRESP YMSG = 'RESP='//YRESP//' when writing '//TRIM(YRECFM)//' in '//TRIM(TPFILE%CNAME) @@ -1625,8 +1507,6 @@ CONTAINS SUBROUTINE IO_WRITE_FIELD_BYFIELD_N0(TPFILE,TPFIELD,KFIELD,KRESP) USE MODD_IO_ll - USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL - USE MODE_IO_MANAGE_STRUCT, ONLY: IO_FILE_FIND_BYNAME !* 0. DECLARATIONS ! ------------ ! @@ -1641,25 +1521,22 @@ CONTAINS !* 0.2 Declarations of local variables ! INTEGER :: IERR - TYPE(FD_ll), POINTER :: TZFD INTEGER :: IRESP - !JUANZIO - INTEGER :: IK_FILE,IK_RANK - CHARACTER(len=5) :: YK_FILE - CHARACTER(len=128) :: YFILE_IOZ - TYPE(FD_ll), POINTER :: TZFD_IOZ - TYPE(TFILEDATA),POINTER :: TZFILE - CHARACTER(LEN=:),ALLOCATABLE :: YMSG - CHARACTER(LEN=6) :: YRESP + INTEGER :: IK_FILE + TYPE(TFILEDATA),POINTER :: TZFILE + CHARACTER(LEN=:),ALLOCATABLE :: YMSG + CHARACTER(LEN=6) :: YRESP + ! + IRESP = 0 + TZFILE => NULL() ! CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_WRITE_FIELD_BYFIELD_N0',TRIM(TPFILE%CNAME)//': writing '//TRIM(TPFIELD%CMNHNAME)) ! CALL FIELD_METADATA_CHECK(TPFIELD,TYPEINT,0,'IO_WRITE_FIELD_BYFIELD_N0') ! - IRESP = 0 - !------------------------------------------------------------------ - TZFD=>GETFD(TRIM(ADJUSTL(TPFILE%CNAME))//'.lfi') - IF (ASSOCIATED(TZFD)) THEN + CALL IO_FILE_WRITE_CHECK(TPFILE,'IO_WRITE_FIELD_BYFIELD_N0',IRESP) + ! + IF (IRESP==0) THEN IF (GSMONOPROC) THEN ! sequential execution IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,KFIELD,IRESP) IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,KFIELD,IRESP) @@ -1670,30 +1547,19 @@ CONTAINS END IF ! CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TPFILE%NMASTER_RANK-1,TPFILE%NMPICOMM,IERR) - END IF ! multiprocessor execution - IF (TZFD%nb_procio.gt.1) THEN + END IF ! multiprocess execution + IF (TPFILE%NSUBFILES_IOZ>0) 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(TPFILE%CNAME)//YK_FILE//".lfi" - TZFD_IOZ => GETFD(YFILE_IOZ) - IK_RANK = TZFD_IOZ%OWNER - IF ( ISP == IK_RANK ) THEN - CALL IO_FILE_FIND_BYNAME(TRIM(TPFILE%CNAME)//YK_FILE,TZFILE,IRESP) - IF (IRESP/=0) THEN - CALL PRINT_MSG(NVERB_FATAL,'IO','IO_WRITE_FIELD_BYFIELD_N0','file '//TRIM(TRIM(TPFILE%CNAME)//YK_FILE)//& - ' not found in list') - END IF + DO IK_FILE=1,TPFILE%NSUBFILES_IOZ + TZFILE => TPFILE%TFILES_IOZ(IK_FILE)%TFILE + IF ( ISP == TZFILE%NMASTER_RANK ) THEN IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TZFILE,TPFIELD,KFIELD,IRESP) IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TZFILE,TPFIELD,KFIELD,IRESP) END IF END DO ENDIF - ELSE - IRESP = -61 - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BYFIELD_N0','file '//TRIM(TPFILE%CNAME)//' not found') END IF - !---------------------------------------------------------------- + ! IF (IRESP.NE.0) THEN WRITE(YRESP, '( I6 )') IRESP YMSG = 'RESP='//YRESP//' when writing '//TRIM(TPFIELD%CMNHNAME)//' in '//TRIM(TPFILE%CNAME) @@ -1733,7 +1599,7 @@ CONTAINS SUBROUTINE IO_WRITE_FIELD_BYFIELD_N1(TPFILE,TPFIELD,KFIELD,KRESP) ! USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT,TFILEDATA - USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL + ! USE MODE_ALLOCBUFFER_ll USE MODE_GATHER_ll ! @@ -1751,10 +1617,8 @@ CONTAINS CHARACTER(LEN=28) :: YFILEM ! FM-file name CHARACTER(LEN=NMNHNAMELGTMAX) :: YRECFM ! name of the article to write CHARACTER(LEN=2) :: YDIR ! field form - CHARACTER(LEN=JPFINL) :: YFNLFI INTEGER :: IERR INTEGER :: ISIZEMAX - TYPE(FD_ll), POINTER :: TZFD INTEGER :: IRESP INTEGER,DIMENSION(:),POINTER :: IFIELDP LOGICAL :: GALLOC @@ -1765,22 +1629,20 @@ CONTAINS YRECFM = TPFIELD%CMNHNAME YDIR = TPFIELD%CDIR ! + IRESP = 0 + GALLOC = .FALSE. + ! CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_WRITE_FIELD_BYFIELD_N1',TRIM(YFILEM)//': writing '//TRIM(YRECFM)) ! CALL FIELD_METADATA_CHECK(TPFIELD,TYPEINT,1,'IO_WRITE_FIELD_BYFIELD_N1') ! - !* 1.1 THE NAME OF LFIFM + CALL IO_FILE_WRITE_CHECK(TPFILE,'IO_WRITE_FIELD_BYFIELD_N1',IRESP) ! - IRESP = 0 - GALLOC = .FALSE. - YFNLFI=TRIM(ADJUSTL(YFILEM))//'.lfi' - !------------------------------------------------------------------ - TZFD=>GETFD(YFNLFI) - IF (ASSOCIATED(TZFD)) THEN + IF (IRESP==0) THEN IF (GSMONOPROC) THEN ! sequential execution IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,KFIELD,IRESP) IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,KFIELD,IRESP) - ELSE ! multiprocessor execution + ELSE ! multiprocesses execution #ifndef MNH_INT8 CALL MPI_ALLREDUCE(SIZE(KFIELD),ISIZEMAX,1,MPI_INTEGER,MPI_MAX,TPFILE%NMPICOMM,IRESP) #else @@ -1810,11 +1672,8 @@ CONTAINS ! CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TPFILE%NMASTER_RANK-1,TPFILE%NMPICOMM,IERR) END IF - ELSE - IRESP = -61 - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BYFIELD_N1','file '//TRIM(TPFILE%CNAME)//' not found') END IF - !---------------------------------------------------------------- + ! IF (IRESP.NE.0) THEN WRITE(YRESP, '( I6 )') IRESP YMSG = 'RESP='//YRESP//' when writing '//TRIM(YRECFM)//' in '//TRIM(TPFILE%CNAME) @@ -1822,7 +1681,6 @@ CONTAINS END IF IF (GALLOC) DEALLOCATE(IFIELDP) IF (PRESENT(KRESP)) KRESP = IRESP - IF (ASSOCIATED(TZFD)) CALL MPI_BARRIER(TPFILE%NMPICOMM,IERR) ! END SUBROUTINE IO_WRITE_FIELD_BYFIELD_N1 @@ -1856,12 +1714,12 @@ CONTAINS SUBROUTINE IO_WRITE_FIELD_BYFIELD_N2(TPFILE,TPFIELD,KFIELD,KRESP) USE MODD_IO_ll - USE MODD_PARAMETERS_ll,ONLY : JPHEXT - USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL + USE MODD_PARAMETERS_ll, ONLY : JPHEXT + USE MODD_TIMEZ, ONLY : TIMEZ + ! USE MODE_ALLOCBUFFER_ll USE MODE_GATHER_ll - USE MODD_TIMEZ, ONLY : TIMEZ - USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 + USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 ! IMPLICIT NONE ! @@ -1877,18 +1735,14 @@ CONTAINS CHARACTER(LEN=28) :: YFILEM ! FM-file name CHARACTER(LEN=NMNHNAMELGTMAX) :: YRECFM ! name of the article to write CHARACTER(LEN=2) :: YDIR ! field form - CHARACTER(LEN=JPFINL) :: YFNLFI INTEGER :: IERR INTEGER :: ISIZEMAX - TYPE(FD_ll), POINTER :: TZFD INTEGER :: IRESP INTEGER,DIMENSION(:,:),POINTER :: IFIELDP LOGICAL :: GALLOC ! - !JUANZ REAL*8,DIMENSION(2) :: T0,T1,T2 REAL*8,DIMENSION(2) :: T11,T22 - !JUANZ INTEGER :: IHEXTOT CHARACTER(LEN=:),ALLOCATABLE :: YMSG CHARACTER(LEN=6) :: YRESP @@ -1897,20 +1751,20 @@ CONTAINS YRECFM = TPFIELD%CMNHNAME YDIR = TPFIELD%CDIR ! + IRESP = 0 + GALLOC = .FALSE. + ! + IHEXTOT = 2*JPHEXT+1 + ! CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_WRITE_FIELD_BYFIELD_N2',TRIM(YFILEM)//': writing '//TRIM(YRECFM)) ! + CALL SECOND_MNH2(T11) + ! CALL FIELD_METADATA_CHECK(TPFIELD,TYPEINT,2,'IO_WRITE_FIELD_BYFIELD_N2') ! - !* 1.1 THE NAME OF LFIFM + CALL IO_FILE_WRITE_CHECK(TPFILE,'IO_WRITE_FIELD_BYFIELD_N2',IRESP) ! - CALL SECOND_MNH2(T11) - IRESP = 0 - GALLOC = .FALSE. - YFNLFI=TRIM(ADJUSTL(YFILEM))//'.lfi' - !------------------------------------------------------------------ - IHEXTOT = 2*JPHEXT+1 - TZFD=>GETFD(YFNLFI) - IF (ASSOCIATED(TZFD)) THEN + IF (IRESP==0) THEN IF (GSMONOPROC) THEN ! sequential execution IF (LPACK .AND. L1D .AND. SIZE(KFIELD,1)==IHEXTOT .AND. SIZE(KFIELD,2)==IHEXTOT) THEN IFIELDP=>KFIELD(JPHEXT+1:JPHEXT+1,JPHEXT+1:JPHEXT+1) @@ -1925,7 +1779,7 @@ CONTAINS IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,KFIELD,IRESP) IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,KFIELD,IRESP) END IF - ELSE ! multiprocessor execution + ELSE ! multiprocesses execution #ifndef MNH_INT8 CALL MPI_ALLREDUCE(SIZE(KFIELD),ISIZEMAX,1,MPI_INTEGER,MPI_MAX,TPFILE%NMPICOMM,IRESP) #else @@ -1939,7 +1793,7 @@ CONTAINS CALL SECOND_MNH2(T0) IF (ISP == TPFILE%NMASTER_RANK) THEN - ! I/O processor case + ! I/O process case CALL ALLOCBUFFER_ll(IFIELDP,KFIELD,YDIR,GALLOC) ELSE ALLOCATE(IFIELDP(0,0)) @@ -1967,11 +1821,8 @@ CONTAINS ! CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TPFILE%NMASTER_RANK-1,TPFILE%NMPICOMM,IERR) END IF - ELSE - IRESP = -61 - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BYFIELD_N2','file '//TRIM(TPFILE%CNAME)//' not found') END IF - !---------------------------------------------------------------- + ! IF (IRESP.NE.0) THEN WRITE(YRESP, '( I6 )') IRESP YMSG = 'RESP='//YRESP//' when writing '//TRIM(YRECFM)//' in '//TRIM(TPFILE%CNAME) @@ -1979,7 +1830,6 @@ CONTAINS END IF IF (GALLOC) DEALLOCATE(IFIELDP) IF (PRESENT(KRESP)) KRESP = IRESP - IF (ASSOCIATED(TZFD)) CALL MPI_BARRIER(TPFILE%NMPICOMM,IERR) CALL SECOND_MNH2(T22) TIMEZ%T_WRIT2D_ALL=TIMEZ%T_WRIT2D_ALL + T22 - T11 ! @@ -2014,12 +1864,12 @@ CONTAINS SUBROUTINE IO_WRITE_FIELD_BYFIELD_N3(TPFILE,TPFIELD,KFIELD,KRESP) USE MODD_IO_ll - USE MODD_PARAMETERS_ll,ONLY : JPHEXT - USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL + USE MODD_PARAMETERS_ll, ONLY : JPHEXT + USE MODD_TIMEZ, ONLY : TIMEZ + ! USE MODE_ALLOCBUFFER_ll USE MODE_GATHER_ll - USE MODD_TIMEZ, ONLY : TIMEZ - USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 + USE MODE_MNH_TIMING, ONLY : SECOND_MNH2 ! IMPLICIT NONE ! @@ -2035,17 +1885,13 @@ CONTAINS CHARACTER(LEN=28) :: YFILEM ! FM-file name CHARACTER(LEN=NMNHNAMELGTMAX) :: YRECFM ! name of the article to write CHARACTER(LEN=2) :: YDIR ! field form - CHARACTER(LEN=JPFINL) :: YFNLFI INTEGER :: IERR INTEGER :: ISIZEMAX - TYPE(FD_ll), POINTER :: TZFD INTEGER :: IRESP INTEGER,DIMENSION(:,:,:),POINTER :: IFIELDP LOGICAL :: GALLOC ! - !JUANZ REAL*8,DIMENSION(2) :: T11,T22 - !JUANZ INTEGER :: IHEXTOT CHARACTER(LEN=:),ALLOCATABLE :: YMSG CHARACTER(LEN=6) :: YRESP @@ -2054,18 +1900,20 @@ CONTAINS YRECFM = TPFIELD%CMNHNAME YDIR = TPFIELD%CDIR ! - CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_WRITE_FIELD_BYFIELD_N3',TRIM(YFILEM)//': writing '//TRIM(YRECFM)) - ! - !* 1.1 THE NAME OF LFIFM - ! - CALL SECOND_MNH2(T11) IRESP = 0 GALLOC = .FALSE. - YFNLFI=TRIM(ADJUSTL(YFILEM))//'.lfi' - !------------------------------------------------------------------ + ! IHEXTOT = 2*JPHEXT+1 - TZFD=>GETFD(YFNLFI) - IF (ASSOCIATED(TZFD)) THEN + ! + CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_WRITE_FIELD_BYFIELD_N3',TRIM(YFILEM)//': writing '//TRIM(YRECFM)) + ! + CALL SECOND_MNH2(T11) + ! + CALL FIELD_METADATA_CHECK(TPFIELD,TYPEINT,3,'IO_WRITE_FIELD_BYFIELD_N3') + ! + CALL IO_FILE_WRITE_CHECK(TPFILE,'IO_WRITE_FIELD_BYFIELD_N3',IRESP) + ! + IF (IRESP==0) THEN IF (GSMONOPROC) THEN ! sequential execution IF (LPACK .AND. L1D .AND. SIZE(KFIELD,1)==IHEXTOT .AND. SIZE(KFIELD,2)==IHEXTOT) THEN IFIELDP=>KFIELD(JPHEXT+1:JPHEXT+1,JPHEXT+1:JPHEXT+1,:) @@ -2080,7 +1928,7 @@ CONTAINS IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,KFIELD,IRESP) IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,KFIELD,IRESP) END IF - ELSE ! multiprocessor execution + ELSE ! multiprocesses execution #ifndef MNH_INT8 CALL MPI_ALLREDUCE(SIZE(KFIELD),ISIZEMAX,1,MPI_INTEGER,MPI_MAX,TPFILE%NMPICOMM,IRESP) #else @@ -2093,7 +1941,7 @@ CONTAINS END IF IF (ISP == TPFILE%NMASTER_RANK) THEN - ! I/O processor case + ! I/O process case CALL ALLOCBUFFER_ll(IFIELDP,KFIELD,YDIR,GALLOC) ELSE ALLOCATE(IFIELDP(0,0,0)) @@ -2117,11 +1965,8 @@ CONTAINS ! CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TPFILE%NMASTER_RANK-1,TPFILE%NMPICOMM,IERR) END IF - ELSE - IRESP = -61 - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BYFIELD_N3','file '//TRIM(TPFILE%CNAME)//' not found') END IF - !---------------------------------------------------------------- + ! IF (IRESP.NE.0) THEN WRITE(YRESP, '( I6 )') IRESP YMSG = 'RESP='//YRESP//' when writing '//TRIM(YRECFM)//' in '//TRIM(TPFILE%CNAME) @@ -2129,7 +1974,6 @@ CONTAINS END IF IF (GALLOC) DEALLOCATE(IFIELDP) IF (PRESENT(KRESP)) KRESP = IRESP - IF (ASSOCIATED(TZFD)) CALL MPI_BARRIER(TPFILE%NMPICOMM,IERR) CALL SECOND_MNH2(T22) TIMEZ%T_WRIT3D_ALL=TIMEZ%T_WRIT3D_ALL + T22 - T11 ! @@ -2164,7 +2008,7 @@ CONTAINS SUBROUTINE IO_WRITE_FIELD_BYFIELD_L0(TPFILE,TPFIELD,OFIELD,KRESP) USE MODD_IO_ll - USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL + ! USE MODE_IO_MANAGE_STRUCT, ONLY: IO_FILE_FIND_BYNAME !* 0. DECLARATIONS ! ------------ @@ -2180,25 +2024,22 @@ CONTAINS !* 0.2 Declarations of local variables ! INTEGER :: IERR - TYPE(FD_ll), POINTER :: TZFD INTEGER :: IRESP - !JUANZIO - INTEGER :: IK_FILE,IK_RANK - CHARACTER(len=5) :: YK_FILE - CHARACTER(len=128) :: YFILE_IOZ - TYPE(FD_ll), POINTER :: TZFD_IOZ - TYPE(TFILEDATA),POINTER :: TZFILE - CHARACTER(LEN=:),ALLOCATABLE :: YMSG - CHARACTER(LEN=6) :: YRESP + INTEGER :: IK_FILE + TYPE(TFILEDATA),POINTER :: TZFILE + CHARACTER(LEN=:),ALLOCATABLE :: YMSG + CHARACTER(LEN=6) :: YRESP + ! + IRESP = 0 + TZFILE => NULL() ! CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_WRITE_FIELD_BYFIELD_L0',TRIM(TPFILE%CNAME)//': writing '//TRIM(TPFIELD%CMNHNAME)) ! CALL FIELD_METADATA_CHECK(TPFIELD,TYPELOG,0,'IO_WRITE_FIELD_BYFIELD_L0') ! - IRESP = 0 - !------------------------------------------------------------------ - TZFD=>GETFD(TRIM(ADJUSTL(TPFILE%CNAME))//'.lfi') - IF (ASSOCIATED(TZFD)) THEN + CALL IO_FILE_WRITE_CHECK(TPFILE,'IO_WRITE_FIELD_BYFIELD_L0',IRESP) + ! + IF (IRESP==0) THEN IF (GSMONOPROC) THEN ! sequential execution IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,OFIELD,IRESP) IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,OFIELD,IRESP) @@ -2209,30 +2050,19 @@ CONTAINS END IF ! CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TPFILE%NMASTER_RANK-1,TPFILE%NMPICOMM,IERR) - END IF ! multiprocessor execution - IF (TZFD%nb_procio.gt.1) THEN + END IF ! multiprocesses execution + IF (TPFILE%NSUBFILES_IOZ>0) 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(TPFILE%CNAME)//YK_FILE//".lfi" - TZFD_IOZ => GETFD(YFILE_IOZ) - IK_RANK = TZFD_IOZ%OWNER - IF ( ISP == IK_RANK ) THEN - CALL IO_FILE_FIND_BYNAME(TRIM(TPFILE%CNAME)//YK_FILE,TZFILE,IRESP) - IF (IRESP/=0) THEN - CALL PRINT_MSG(NVERB_FATAL,'IO','IO_WRITE_FIELD_BYFIELD_L0','file '//TRIM(TRIM(TPFILE%CNAME)//YK_FILE)//& - ' not found in list') - END IF + DO IK_FILE=1,TPFILE%NSUBFILES_IOZ + TZFILE => TPFILE%TFILES_IOZ(IK_FILE)%TFILE + IF ( ISP == TZFILE%NMASTER_RANK ) THEN IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TZFILE,TPFIELD,OFIELD,IRESP) IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TZFILE,TPFIELD,OFIELD,IRESP) END IF END DO ENDIF - ELSE - IRESP = -61 - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BYFIELD_L0','file '//TRIM(TPFILE%CNAME)//' not found') END IF - !---------------------------------------------------------------- + ! IF (IRESP.NE.0) THEN WRITE(YRESP, '( I6 )') IRESP YMSG = 'RESP='//YRESP//' when writing '//TRIM(TPFIELD%CMNHNAME)//' in '//TRIM(TPFILE%CNAME) @@ -2272,7 +2102,7 @@ CONTAINS SUBROUTINE IO_WRITE_FIELD_BYFIELD_L1(TPFILE,TPFIELD,OFIELD,KRESP) ! USE MODD_IO_ll, ONLY : ISP,GSMONOPROC,LIOCDF4,LLFIOUT,TFILEDATA - USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL + ! USE MODE_ALLOCBUFFER_ll USE MODE_GATHER_ll ! @@ -2290,10 +2120,8 @@ CONTAINS CHARACTER(LEN=28) :: YFILEM ! FM-file name CHARACTER(LEN=NMNHNAMELGTMAX) :: YRECFM ! name of the article to write CHARACTER(LEN=2) :: YDIR ! field form - CHARACTER(LEN=JPFINL) :: YFNLFI INTEGER :: IERR INTEGER :: ISIZEMAX - TYPE(FD_ll), POINTER :: TZFD INTEGER :: IRESP LOGICAL,DIMENSION(:),POINTER :: GFIELDP LOGICAL :: GALLOC @@ -2304,22 +2132,20 @@ CONTAINS YRECFM = TPFIELD%CMNHNAME YDIR = TPFIELD%CDIR ! + IRESP = 0 + GALLOC = .FALSE. + ! CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_WRITE_FIELD_BYFIELD_L1',TRIM(YFILEM)//': writing '//TRIM(YRECFM)) ! CALL FIELD_METADATA_CHECK(TPFIELD,TYPELOG,1,'IO_WRITE_FIELD_BYFIELD_L1') ! - !* 1.1 THE NAME OF LFIFM + CALL IO_FILE_WRITE_CHECK(TPFILE,'IO_WRITE_FIELD_BYFIELD_L1',IRESP) ! - IRESP = 0 - GALLOC = .FALSE. - YFNLFI=TRIM(ADJUSTL(YFILEM))//'.lfi' - !------------------------------------------------------------------ - TZFD=>GETFD(YFNLFI) - IF (ASSOCIATED(TZFD)) THEN + IF (IRESP==0) THEN IF (GSMONOPROC) THEN ! sequential execution IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,OFIELD,IRESP) IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,OFIELD,IRESP) - ELSE ! multiprocessor execution + ELSE ! multiprocesses execution #ifndef MNH_INT8 CALL MPI_ALLREDUCE(SIZE(OFIELD),ISIZEMAX,1,MPI_INTEGER,MPI_MAX,TPFILE%NMPICOMM,IRESP) #else @@ -2349,11 +2175,8 @@ CONTAINS ! CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TPFILE%NMASTER_RANK-1,TPFILE%NMPICOMM,IERR) END IF - ELSE - IRESP = -61 - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BYFIELD_L1','file '//TRIM(TPFILE%CNAME)//' not found') END IF - !---------------------------------------------------------------- + ! IF (IRESP.NE.0) THEN WRITE(YRESP, '( I6 )') IRESP YMSG = 'RESP='//YRESP//' when writing '//TRIM(YRECFM)//' in '//TRIM(TPFILE%CNAME) @@ -2361,7 +2184,6 @@ CONTAINS END IF IF (GALLOC) DEALLOCATE(GFIELDP) IF (PRESENT(KRESP)) KRESP = IRESP - IF (ASSOCIATED(TZFD)) CALL MPI_BARRIER(TPFILE%NMPICOMM,IERR) ! END SUBROUTINE IO_WRITE_FIELD_BYFIELD_L1 @@ -2395,7 +2217,7 @@ CONTAINS SUBROUTINE IO_WRITE_FIELD_BYFIELD_C0(TPFILE,TPFIELD,HFIELD,KRESP) USE MODD_IO_ll - USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL + ! !* 0. DECLARATIONS ! ------------ ! @@ -2410,24 +2232,24 @@ CONTAINS !* 0.2 Declarations of local variables ! INTEGER :: IERR - TYPE(FD_ll), POINTER :: TZFD INTEGER :: IRESP CHARACTER(LEN=:),ALLOCATABLE :: YMSG CHARACTER(LEN=6) :: YRESP ! + IRESP = 0 + ! CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_WRITE_FIELD_BYFIELD_C0',TRIM(TPFILE%CNAME)//': writing '//TRIM(TPFIELD%CMNHNAME)) ! CALL FIELD_METADATA_CHECK(TPFIELD,TYPECHAR,0,'IO_WRITE_FIELD_BYFIELD_C0') ! - IRESP = 0 - ! IF (LEN(HFIELD)==0 .AND. LLFIOUT) THEN CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BYFIELD_C0',& 'zero-size string not allowed if LFI output for '//TRIM(TPFIELD%CMNHNAME)) END IF - !------------------------------------------------------------------ - TZFD=>GETFD(TRIM(ADJUSTL(TPFILE%CNAME))//'.lfi') - IF (ASSOCIATED(TZFD)) THEN + ! + CALL IO_FILE_WRITE_CHECK(TPFILE,'IO_WRITE_FIELD_BYFIELD_C0',IRESP) + ! + IF (IRESP==0) THEN IF (GSMONOPROC) THEN ! sequential execution IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,HFIELD,IRESP) IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,HFIELD,IRESP) @@ -2439,11 +2261,8 @@ CONTAINS ! CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TPFILE%NMASTER_RANK-1,TPFILE%NMPICOMM,IERR) END IF - ELSE - IRESP = -61 - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BYFIELD_C0','file '//TRIM(TPFILE%CNAME)//' not found') END IF - !---------------------------------------------------------------- + ! IF (IRESP.NE.0) THEN WRITE(YRESP, '( I6 )') IRESP YMSG = 'RESP='//YRESP//' when writing '//TRIM(TPFIELD%CMNHNAME)//' in '//TRIM(TPFILE%CNAME) @@ -2482,7 +2301,7 @@ CONTAINS SUBROUTINE IO_WRITE_FIELD_BYFIELD_C1(TPFILE,TPFIELD,HFIELD,KRESP) USE MODD_IO_ll - USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL + ! !* 0. DECLARATIONS ! ------------ ! @@ -2497,7 +2316,6 @@ CONTAINS !* 0.2 Declarations of local variables ! INTEGER :: IERR - TYPE(FD_ll), POINTER :: TZFD INTEGER :: IRESP INTEGER :: J,JJ INTEGER :: ILE, IP @@ -2532,9 +2350,10 @@ CONTAINS END DO END IF END IF - !------------------------------------------------------------------ - TZFD=>GETFD(TRIM(ADJUSTL(TPFILE%CNAME))//'.lfi') - IF (ASSOCIATED(TZFD)) THEN + ! + CALL IO_FILE_WRITE_CHECK(TPFILE,'IO_WRITE_FIELD_BYFIELD_C1',IRESP) + ! + IF (IRESP==0) THEN IF (GSMONOPROC) THEN ! sequential execution IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,IFIELD,IRESP) IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,HFIELD,IRESP) @@ -2546,11 +2365,8 @@ CONTAINS ! CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TPFILE%NMASTER_RANK-1,TPFILE%NMPICOMM,IERR) END IF - ELSE - IRESP = -61 - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BYFIELD_C1','file '//TRIM(TPFILE%CNAME)//' not found') END IF - !---------------------------------------------------------------- + ! IF (IRESP.NE.0) THEN WRITE(YRESP, '( I6 )') IRESP YMSG = 'RESP='//YRESP//' when writing '//TRIM(TPFIELD%CMNHNAME)//' in '//TRIM(TPFILE%CNAME) @@ -2591,7 +2407,7 @@ CONTAINS SUBROUTINE IO_WRITE_FIELD_BYFIELD_T0(TPFILE,TPFIELD,TFIELD,KRESP) USE MODD_IO_ll USE MODD_TYPE_DATE - USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL + ! !* 0. DECLARATIONS ! ------------ ! @@ -2606,7 +2422,6 @@ CONTAINS !* 0.2 Declarations of local variables ! INTEGER :: IERR - TYPE(FD_ll), POINTER :: TZFD INTEGER :: IRESP CHARACTER(LEN=:),ALLOCATABLE :: YMSG CHARACTER(LEN=6) :: YRESP @@ -2617,9 +2432,9 @@ CONTAINS ! IRESP = 0 ! - !------------------------------------------------------------------ - TZFD=>GETFD(TRIM(ADJUSTL(TPFILE%CNAME))//'.lfi') - IF (ASSOCIATED(TZFD)) THEN + CALL IO_FILE_WRITE_CHECK(TPFILE,'IO_WRITE_FIELD_BYFIELD_T0',IRESP) + ! + IF (IRESP==0) THEN IF (GSMONOPROC) THEN ! sequential execution IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,TFIELD,IRESP) IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,TFIELD,IRESP) @@ -2631,11 +2446,8 @@ CONTAINS ! CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TPFILE%NMASTER_RANK-1,TPFILE%NMPICOMM,IERR) END IF - ELSE - IRESP = -61 - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BYFIELD_T0','file '//TRIM(TPFILE%CNAME)//' not found') END IF - !---------------------------------------------------------------- + ! IF (IRESP.NE.0) THEN WRITE(YRESP, '( I6 )') IRESP YMSG = 'RESP='//YRESP//' when writing '//TRIM(TPFIELD%CMNHNAME)//' in '//TRIM(TPFILE%CNAME) @@ -2655,7 +2467,7 @@ CONTAINS CHARACTER(LEN=*), INTENT(IN) :: HNAME ! name of the field to write INTEGER, INTENT(IN) :: KL3D ! size of the LB array in FM REAL,DIMENSION(:,:,:), INTENT(IN) :: PLB ! array containing the LB field - INTEGER,OPTIONAL, INTENT(OUT):: KRESP ! return-code + INTEGER,OPTIONAL, INTENT(OUT):: KRESP ! return-code ! !* 0.2 Declarations of local variables ! @@ -2676,12 +2488,12 @@ CONTAINS SUBROUTINE IO_WRITE_FIELD_BYFIELD_LB(TPFILE,TPFIELD,KL3D,PLB,KRESP) ! USE MODD_IO_ll - USE MODD_PARAMETERS_ll,ONLY : JPHEXT + USE MODD_PARAMETERS_ll, ONLY : JPHEXT + USE MODD_VAR_ll, ONLY : MNH_STATUSES_IGNORE + ! USE MODE_DISTRIB_LB - USE MODE_TOOLS_ll, ONLY : GET_GLOBALDIMS_ll - USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_ll + USE MODE_TOOLS_ll, ONLY : GET_GLOBALDIMS_ll ! - USE MODD_VAR_ll, ONLY : MNH_STATUSES_IGNORE ! !* 0.1 Declarations of arguments ! @@ -2689,30 +2501,28 @@ CONTAINS TYPE(TFIELDDATA), INTENT(INOUT) :: TPFIELD INTEGER, INTENT(IN) :: KL3D ! size of the LB array in FM REAL,DIMENSION(:,:,:),TARGET,INTENT(IN) :: PLB ! array containing the LB field - INTEGER,OPTIONAL, INTENT(OUT):: KRESP ! return-code + INTEGER,OPTIONAL, INTENT(OUT) :: KRESP ! return-code ! !* 0.2 Declarations of local variables ! CHARACTER(LEN=28) :: YFILEM ! FM-file name CHARACTER(LEN=NMNHNAMELGTMAX) :: YRECFM ! name of the article to write CHARACTER(LEN=4) :: YLBTYPE ! 'LBX','LBXU','LBY' or 'LBYV' - CHARACTER(LEN=JPFINL) :: YFNLFI INTEGER :: IRIM ! size of the LB area INTEGER :: IERR - TYPE(FD_ll), POINTER :: TZFD INTEGER :: IRESP REAL,DIMENSION(:,:,:),ALLOCATABLE,TARGET :: Z3D REAL,DIMENSION(:,:,:), POINTER :: TX3DP 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 + 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 + TYPE(TX_3DP),ALLOCATABLE,DIMENSION(:) :: T_TX3DP CHARACTER(LEN=:),ALLOCATABLE :: YMSG CHARACTER(LEN=6) :: YRESP ! @@ -2720,6 +2530,8 @@ CONTAINS YRECFM = TPFIELD%CMNHNAME YLBTYPE = TPFIELD%CLBTYPE ! + IRESP = 0 + ! CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_WRITE_FIELD_BYFIELD_LB',TRIM(YFILEM)//': writing '//TRIM(YRECFM)) ! IF (YLBTYPE/='LBX' .AND. YLBTYPE/='LBXU' .AND. YLBTYPE/='LBY' .AND. YLBTYPE/='LBYV') THEN @@ -2732,19 +2544,15 @@ CONTAINS TPFIELD%CDIR='XY' END IF ! - !* 1.1 THE NAME OF LFIFM - ! - IRESP = 0 - YFNLFI=TRIM(ADJUSTL(YFILEM))//'.lfi' - ! IRIM = (KL3D-2*JPHEXT)/2 IF (KL3D /= 2*(IRIM+JPHEXT)) THEN IRESP = -30 GOTO 1000 END IF ! - TZFD=>GETFD(YFNLFI) - IF (ASSOCIATED(TZFD)) THEN + CALL IO_FILE_WRITE_CHECK(TPFILE,'IO_WRITE_FIELD_BYFIELD_LB',IRESP) + ! + IF (IRESP==0) THEN IF (GSMONOPROC) THEN ! sequential execution IF (LPACK .AND. L2D) THEN TX3DP=>PLB(:,JPHEXT+1:JPHEXT+1,:) @@ -2787,7 +2595,7 @@ CONTAINS ALLOCATE(REQ_TAB(1)) ALLOCATE(T_TX3DP(1)) IKU = SIZE(PLB,3) - ! Other processors + ! Other processes CALL GET_DISTRIB_LB(YLBTYPE,ISP,'LOC','WRITE',IRIM,IIB,IIE,IJB,IJE) IF (IIB /= 0) THEN TX3DP=>PLB(IIB:IIE,IJB:IJE,:) @@ -2805,14 +2613,10 @@ CONTAINS DEALLOCATE(T_TX3DP,REQ_TAB) END IF ! - CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TPFILE%NMASTER_RANK-1,TZFD& - & %COMM,IERR) - END IF !(GSMONOPROC) - ELSE - IRESP = -61 - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BYFIELD_LB','file '//TRIM(TPFILE%CNAME)//' not found') + CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TPFILE%NMASTER_RANK-1,TPFILE%NMPICOMM,IERR) + END IF END IF - !---------------------------------------------------------------- + ! 1000 CONTINUE IF (IRESP.NE.0) THEN WRITE(YRESP, '( I6 )') IRESP @@ -2828,7 +2632,7 @@ CONTAINS SUBROUTINE IO_WRITE_FIELD_BOX_BYFIELD_X5(TPFILE,TPFIELD,HBUDGET,PFIELD,KXOBOX,KXEBOX,KYOBOX,KYEBOX,KRESP) ! USE MODD_IO_ll - USE MODE_FD_ll, ONLY : GETFD,JPFINL,FD_LL + ! USE MODE_GATHER_ll ! ! @@ -2846,9 +2650,7 @@ CONTAINS ! !* 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 @@ -2857,14 +2659,12 @@ CONTAINS ! CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_WRITE_FIELD_BOX_BYFIELD_X5',TRIM(TPFILE%CNAME)//': writing '//TRIM(TPFIELD%CMNHNAME)) ! - !* 1.1 THE NAME OF LFIFM - ! IRESP = 0 GALLOC = .FALSE. - YFNLFI=TRIM(ADJUSTL(TPFILE%CNAME))//'.lfi' - !------------------------------------------------------------------ - TZFD=>GETFD(YFNLFI) - IF (ASSOCIATED(TZFD)) THEN + ! + CALL IO_FILE_WRITE_CHECK(TPFILE,'IO_WRITE_FIELD_BOX_BYFIELD_X5',IRESP) + ! + IF (IRESP==0) THEN IF (GSMONOPROC) THEN ! sequential execution IF (HBUDGET /= 'BUDGET') THEN ! take the sub-section of PFIELD defined by the box @@ -2875,7 +2675,7 @@ CONTAINS END IF IF (LLFIOUT) CALL IO_WRITE_FIELD_LFI(TPFILE,TPFIELD,ZFIELDP,IRESP) IF (LIOCDF4) CALL IO_WRITE_FIELD_NC4(TPFILE,TPFIELD,ZFIELDP,IRESP) - ELSE ! multiprocessor execution + ELSE ! multiprocesses execution IF (ISP == TPFILE%NMASTER_RANK) THEN ! Allocate the box ALLOCATE(ZFIELDP(KXEBOX-KXOBOX+1,KYEBOX-KYOBOX+1,SIZE(PFIELD,3),& @@ -2895,12 +2695,9 @@ CONTAINS END IF ! CALL MPI_BCAST(IRESP,1,MPI_INTEGER,TPFILE%NMASTER_RANK-1,TPFILE%NMPICOMM,IERR) - END IF ! multiprocessor execution - ELSE - IRESP = -61 - CALL PRINT_MSG(NVERB_ERROR,'IO','IO_WRITE_FIELD_BOX_BYFIELD_X5','file '//TRIM(TPFILE%CNAME)//' not found') + END IF ! multiprocesses execution END IF - !---------------------------------------------------------------- + ! IF (IRESP.NE.0) THEN WRITE(YRESP, '( I6 )') IRESP YMSG = 'RESP='//YRESP//' when writing '//TRIM(TPFIELD%CMNHNAME)//' in '//TRIM(TPFILE%CNAME) diff --git a/src/LIB/SURCOUCHE/src/modd_io.f90 b/src/LIB/SURCOUCHE/src/modd_io.f90 index 1a2a243732bae982e053b98b429d8ed4bd3d969f..fdfdb66181bf5375e7f5d1a34f2c42c1eab65483 100644 --- a/src/LIB/SURCOUCHE/src/modd_io.f90 +++ b/src/LIB/SURCOUCHE/src/modd_io.f90 @@ -26,7 +26,7 @@ INTEGER, SAVE :: ISTDOUT, ISTDERR INTEGER, SAVE :: ISIOP !! IOproc number INTEGER, SAVE :: ISP !! Actual proc number -INTEGER, SAVE :: ISNPROC !! Total number of allocated processors +INTEGER, SAVE :: ISNPROC !! Total number of allocated processes LOGICAL, SAVE :: GSMONOPROC = .FALSE. !! True if sequential execution (ISNPROC = 1) LOGICAL, SAVE :: L1D = .FALSE. ! TRUE if 1D model version @@ -78,11 +78,16 @@ TYPE TFILEDATA INTEGER :: NOPEN = 0 !Number of times the file has been opened (during the current execution) INTEGER :: NCLOSE = 0 !Number of times the file has been closed (during the current execution) ! - INTEGER :: NMPICOMM = -1 !MPI communicator used for IO on this file INTEGER :: NMASTER_RANK = -1 !Rank of the master process (no meaning if LMULTIMASTERS=.T.) + INTEGER :: NMPICOMM = -1 !MPI communicator used for IO on this file LOGICAL :: LMASTER = .FALSE. !True if process is master of the file (process that open/read/write/close) LOGICAL :: LMULTIMASTERS = .FALSE. !True if several processes may access the file ! + INTEGER :: NSUBFILES_IOZ = 0 !Number of sub-files (Z-splitted files based on this file) + !For example if 2 sub-files and this file is abcd, + !the 2 sub-files are abcd.Z001 and abcd.Z002 + TYPE(TFILE_ELT),DIMENSION(:),ALLOCATABLE :: TFILES_IOZ !Corresponding Z-splitted files + ! ! Fields for LFI files INTEGER(KIND=LFI_INT) :: NLFINPRAR = 0 !Number of predicted articles of the LFI file (non crucial) INTEGER :: NLFITYPE = -1 !Type of the file (used to generate list of files to transfers) diff --git a/src/LIB/SURCOUCHE/src/mode_fm.f90 b/src/LIB/SURCOUCHE/src/mode_fm.f90 index ad4a9b116c385d83f2ff712f4744d94893ce9d06..54bdc03d9576c8d4776a1675d6a097a658b18191 100644 --- a/src/LIB/SURCOUCHE/src/mode_fm.f90 +++ b/src/LIB/SURCOUCHE/src/mode_fm.f90 @@ -743,7 +743,6 @@ IF (ISP == TPFILE%NMASTER_RANK) THEN CALL LFIFER(IRESP8,TPFILE%NLFIFLU,YSTATU) IRESP = IRESP8 END IF -! IF (ASSOCIATED(TZFDLFI%CDF)) CALL CLEANIOCDF(TZFDLFI%CDF) IF (ASSOCIATED(TPFILE%TNCDIMS)) CALL CLEANIOCDF(TPFILE%TNCDIMS) IF (IRESP == 0) THEN !! Write in pipe diff --git a/src/LIB/SURCOUCHE/src/mode_io.f90 b/src/LIB/SURCOUCHE/src/mode_io.f90 index 32602066cb967e9aebdb2faf31319495f8492180..83fb6ab6922214253b9b90256edb09154301f4a0 100644 --- a/src/LIB/SURCOUCHE/src/mode_io.f90 +++ b/src/LIB/SURCOUCHE/src/mode_io.f90 @@ -429,6 +429,7 @@ CONTAINS TPFILE%LMULTIMASTERS = .FALSE. END IF END IF + TPFILE%NSUBFILES_IOZ = 0 IF (ISP == TZFD%OWNER) THEN !! I/O processor case @@ -545,6 +546,7 @@ CONTAINS TPFILE%NMASTER_RANK = -1 TPFILE%LMASTER = .TRUE. !Every process use the file TPFILE%LMULTIMASTERS = .TRUE. + TPFILE%NSUBFILES_IOZ = 0 #ifdef MNH_VPP OPEN(UNIT=TZFD%FLU, & @@ -628,6 +630,7 @@ CONTAINS TPFILE%NMASTER_RANK = ISIOP TPFILE%LMASTER = (ISP == ISIOP) TPFILE%LMULTIMASTERS = .FALSE. + TPFILE%NSUBFILES_IOZ = 0 IF (ISP == TZFD%OWNER) THEN TZFD%FLU = IONEWFLU() @@ -642,6 +645,12 @@ CONTAINS TPFILE%NMASTER_RANK = ISIOP TPFILE%LMASTER = (ISP == ISIOP) TPFILE%LMULTIMASTERS = .FALSE. + TPFILE%NSUBFILES_IOZ = 0 + IF ( GPARALLELIO .AND. PRESENT(KNB_PROCIO) ) THEN + IF (KNB_PROCIO>1) THEN + TPFILE%NSUBFILES_IOZ = KNB_PROCIO + END IF + END IF TZFD%OWNER = ISIOP TZFD%NAME = TRIM(TPFILE%CNAME)//".lfi" @@ -668,6 +677,11 @@ CONTAINS TZFD%FLU = -1 END IF IF (TZFD%NB_PROCIO .GT. 1 ) THEN + IF (.NOT.ALLOCATED(TPFILE%TFILES_IOZ)) THEN + ALLOCATE(TPFILE%TFILES_IOZ(TPFILE%NSUBFILES_IOZ)) + ELSE IF ( SIZE(TPFILE%TFILES_IOZ) /= TPFILE%NSUBFILES_IOZ ) THEN + CALL PRINT_MSG(NVERB_FATAL,'IO','OPEN_ll','SIZE(PFILE%TFILES_IOZ) /= TPFILE%NSUBFILES_IOZ for '//TRIM(TPFILE%CNAME)) + END IF DO ifile=0,TZFD%NB_PROCIO-1 irank_procio = 1 + io_rank(ifile,ISNPROC,TZFD%NB_PROCIO) write(cfile ,'(".Z",i3.3)') ifile+1 @@ -687,11 +701,13 @@ CONTAINS CALL IO_FILE_ADD2LIST(TZSPLITFILE,TRIM(TPFILE%CNAME)//TRIM(CFILE),TPFILE%CTYPE,TPFILE%CMODE, & KLFINPRAR=TPFILE%NLFINPRAR,KLFITYPE=TPFILE%NLFITYPE,KLFIVERB=TPFILE%NLFIVERB) END IF + TPFILE%TFILES_IOZ(ifile+1)%TFILE => TZSPLITFILE !Done outside of the previous IF to prevent problems with .OUT files TZSPLITFILE%NMPICOMM = ICOMM TZSPLITFILE%NMASTER_RANK = irank_procio TZSPLITFILE%LMASTER = (ISP == irank_procio) TZSPLITFILE%LMULTIMASTERS = .FALSE. + TZSPLITFILE%NSUBFILES_IOZ = 0 IF ( irank_procio .EQ. ISP ) THEN #if defined(MNH_IOCDF4) @@ -769,7 +785,6 @@ CONTAINS END SELECT -print *,'PW: TPFILE%CNAME=',TPFILE%CNAME,'master,multimasters=',TPFILE%LMASTER,TPFILE%LMULTIMASTERS ! CALL UPDATE_METADATA(TPFILE) diff --git a/src/LIB/SURCOUCHE/src/mode_io_manage_struct.f90 b/src/LIB/SURCOUCHE/src/mode_io_manage_struct.f90 index 1c5f8a82af97525e75582340d732331611dfe371..44e18762db746d9d5819f9716e3d6176e2fa49db 100644 --- a/src/LIB/SURCOUCHE/src/mode_io_manage_struct.f90 +++ b/src/LIB/SURCOUCHE/src/mode_io_manage_struct.f90 @@ -524,7 +524,8 @@ SUBROUTINE POPULATE_STRUCT(TPFILE_FIRST,TPFILE_LAST,KSTEPS,HFILETYPE,TPBAKOUTN) ! !Create file structures if Z-splitted files IF (NB_PROCIO_W>1) THEN - ALLOCATE(TPBAKOUTN(IPOS)%TFILE_IOZ(NB_PROCIO_W)) + ALLOCATE(TPBAKOUTN(IPOS)%TFILE%TFILES_IOZ(NB_PROCIO_W)) +! ALLOCATE(TPBAKOUTN(IPOS)%TFILE_IOZ(NB_PROCIO_W)) IF (NB_PROCIO_W>999) THEN CALL PRINT_MSG(NVERB_FATAL,'IO','POPULATE_STRUCT','more than 999 z-levels') END IF @@ -532,34 +533,34 @@ SUBROUTINE POPULATE_STRUCT(TPFILE_FIRST,TPFILE_LAST,KSTEPS,HFILETYPE,TPBAKOUTN) ALLOCATE(TPFILE_LAST%TFILE_NEXT) TPFILE_LAST%TFILE_NEXT%TFILE_PREV => TPFILE_LAST TPFILE_LAST => TPFILE_LAST%TFILE_NEXT - TPBAKOUTN(IPOS)%TFILE_IOZ(JI)%TFILE => TPFILE_LAST - TPBAKOUTN(IPOS)%TFILE_IOZ(JI)%TFILE%CTYPE=HFILETYPE - TPBAKOUTN(IPOS)%TFILE_IOZ(JI)%TFILE%CMODE="WRITE" + TPBAKOUTN(IPOS)%TFILE%TFILES_IOZ(JI)%TFILE => TPFILE_LAST + TPBAKOUTN(IPOS)%TFILE%TFILES_IOZ(JI)%TFILE%CTYPE=HFILETYPE + TPBAKOUTN(IPOS)%TFILE%TFILES_IOZ(JI)%TFILE%CMODE="WRITE" WRITE (YNUMBER,FMT="(I3.3)") JI - TPBAKOUTN(IPOS)%TFILE_IOZ(JI)%TFILE%CNAME = TRIM(TPBAKOUTN(IPOS)%TFILE%CNAME)//'.Z'//YNUMBER + TPBAKOUTN(IPOS)%TFILE%TFILES_IOZ(JI)%TFILE%CNAME = TRIM(TPBAKOUTN(IPOS)%TFILE%CNAME)//'.Z'//YNUMBER IF (TRIM(HFILETYPE)=='OUTPUT') THEN !Reduce the float precision if asked - TPBAKOUTN(IPOS)%TFILE_IOZ(JI)%TFILE%LNCREDUCE_FLOAT_PRECISION = LOUT_REDUCE_FLOAT_PRECISION(IMI) + TPBAKOUTN(IPOS)%TFILE%TFILES_IOZ(JI)%TFILE%LNCREDUCE_FLOAT_PRECISION = LOUT_REDUCE_FLOAT_PRECISION(IMI) !Set compression if asked - TPBAKOUTN(IPOS)%TFILE_IOZ(JI)%TFILE%LNCCOMPRESS = LOUT_COMPRESS(IMI) + TPBAKOUTN(IPOS)%TFILE%TFILES_IOZ(JI)%TFILE%LNCCOMPRESS = LOUT_COMPRESS(IMI) IF ( NOUT_COMPRESS_LEVEL(IMI)<0 .OR. NOUT_COMPRESS_LEVEL(IMI)>9 ) THEN PRINT *,'ERROR: NOUT_COMPRESS_LEVEL must be in the [0..9] range. Value forced to 4' NOUT_COMPRESS_LEVEL(IMI) = 4 END IF - TPBAKOUTN(IPOS)%TFILE_IOZ(JI)%TFILE%NNCCOMPRESS_LEVEL = NOUT_COMPRESS_LEVEL(IMI) + TPBAKOUTN(IPOS)%TFILE%TFILES_IOZ(JI)%TFILE%NNCCOMPRESS_LEVEL = NOUT_COMPRESS_LEVEL(IMI) END IF - TPBAKOUTN(IPOS)%TFILE_IOZ(JI)%TFILE%NLFITYPE=1 !1: to be transfered + TPBAKOUTN(IPOS)%TFILE%TFILES_IOZ(JI)%TFILE%NLFITYPE=1 !1: to be transfered !PW: TODO: set NLFIVERB only when useful (only if LFI file...) - TPBAKOUTN(IPOS)%TFILE_IOZ(JI)%TFILE%NLFIVERB=NVERB + TPBAKOUTN(IPOS)%TFILE%TFILES_IOZ(JI)%TFILE%NLFIVERB=NVERB IF (LIOCDF4) THEN IF (.NOT.LLFIOUT) THEN - TPBAKOUTN(IPOS)%TFILE_IOZ(JI)%TFILE%CFORMAT='NETCDF4' + TPBAKOUTN(IPOS)%TFILE%TFILES_IOZ(JI)%TFILE%CFORMAT='NETCDF4' ELSE - TPBAKOUTN(IPOS)%TFILE_IOZ(JI)%TFILE%CFORMAT='LFICDF4' + TPBAKOUTN(IPOS)%TFILE%TFILES_IOZ(JI)%TFILE%CFORMAT='LFICDF4' END IF ELSE IF (LLFIOUT) THEN - TPBAKOUTN(IPOS)%TFILE_IOZ(JI)%TFILE%CFORMAT='LFI' - !TPBAKOUTN(IPOS)%TFILE_IOZ(JI)%TFILE%NLFINPRAR= 0 + TPBAKOUTN(IPOS)%TFILE%TFILES_IOZ(JI)%TFILE%CFORMAT='LFI' + !TPBAKOUTN(IPOS)%TFILE%TFILES_IOZ(JI)%TFILE%NLFINPRAR= 0 ELSE CALL PRINT_MSG(NVERB_FATAL,'IO','POPULATE_STRUCT','unknown backup/output fileformat') ENDIF