diff --git a/MY_RUN/KTEST/004_Reunion/003_mesonh/EXSEG1.nam b/MY_RUN/KTEST/004_Reunion/003_mesonh/EXSEG1.nam index cf7a2603a080289cefaba14ffb173946b753c5a4..22a053af29e78a45507182fb7c24bfc113a71d64 100644 --- a/MY_RUN/KTEST/004_Reunion/003_mesonh/EXSEG1.nam +++ b/MY_RUN/KTEST/004_Reunion/003_mesonh/EXSEG1.nam @@ -26,8 +26,9 @@ &NAM_DYN XSEGLEN = 40., LCORIO = F, LNUMDIFU = F, XALKTOP = 0.01, XALZBOT = 14000. / -&NAM_FMOUT XFMOUT(1,1) = 10., XFMOUT(1,2) = 20., - XFMOUT(1,3) = 30., XFMOUT(1,4) = 40. / +&NAM_FMOUT + XBAK_TIME(1,1) = 40., XBAK_TIME(1,2) = 10., + XBAK_TIME(1,3) = 20., XBAK_TIME(1,4) = 30. / &NAM_BUDGET CBUTYPE='CART', XBULEN=200., NBUKL=2, NBUKH=51, NBUIL=15, NBUIH=64, NBUJL=15, NBUJH=68, LBU_KCP=.TRUE., LBU_ICP=.FALSE., LBU_JCP=.FALSE. / diff --git a/src/MNH/default_desfmn.f90 b/src/MNH/default_desfmn.f90 index 6ec7ad809f8020b5f2f758d3d6e9ae805e9a7abf..2bdc04b316d42806098e466c0a8c08bdff41f60f 100644 --- a/src/MNH/default_desfmn.f90 +++ b/src/MNH/default_desfmn.f90 @@ -492,7 +492,7 @@ XTNUDGING = 21600. !* 9. SET DEFAULT VALUES FOR MODD_FMOUT and MODD_OUT_n : ! ------------------------------------------------ ! -IF (KMI == 1) XFMOUT (:,:) = XUNDEF +IF (KMI == 1) XBAK_TIME (:,:) = XNEGUNDEF ! ! !------------------------------------------------------------------------------- diff --git a/src/MNH/modd_fmout.f90 b/src/MNH/modd_fmout.f90 index 23a3613585af574e224fede1b36ea89d2513a581..03d0a6f3251b0e20ec897244e409dac07516a8d2 100644 --- a/src/MNH/modd_fmout.f90 +++ b/src/MNH/modd_fmout.f90 @@ -47,7 +47,8 @@ USE MODD_PARAMETERS ! IMPLICIT NONE ! -REAL,SAVE, DIMENSION(JPMODELMAX,JPOUTMAX) :: XFMOUT ! XFMOUT(m,i) array of +REAL,SAVE, DIMENSION(JPMODELMAX,JPOUTMAX) :: XBAK_TIME = XNEGUNDEF +! XBAK_TIME(m,i) array of ! the increments in seconds from the beginning of the segment to the ! instant where the i-th fields output on FM-files is realized by model "m" ! diff --git a/src/MNH/modd_parameters.f90 b/src/MNH/modd_parameters.f90 index 4b8fbdc60dfa2674516c543e0f317bc6bcec5541..d7036cb8f64eca5ba7c10f84d6a94011726ce96d 100644 --- a/src/MNH/modd_parameters.f90 +++ b/src/MNH/modd_parameters.f90 @@ -69,6 +69,8 @@ INTEGER, PARAMETER :: JPSVMAX = 200 ! Maximum number of scalar variables ! REAL, PARAMETER :: XUNDEF = 999. ! default value for undefined or unused ! ! field. +REAL, PARAMETER :: XNEGUNDEF = -999. ! default value for undefined or unused +! ! field (negative value guaranteed) INTEGER, PARAMETER :: NUNDEF = 999 ! default value for undefined or unused ! ! field. INTEGER, PARAMETER :: JPDUMMY = 20 ! Size of dummy array diff --git a/src/MNH/modeln.f90 b/src/MNH/modeln.f90 index f32518126e3c04405c488f7fc2da977f85754e74..73b44d1748d3a741f34d50f3976ae8d557a433d8 100644 --- a/src/MNH/modeln.f90 +++ b/src/MNH/modeln.f90 @@ -921,9 +921,10 @@ DO JOUT = 1,NOUT_NUMB YDADFILE=YFMFILE ELSE IOUTDAD=0 +!PW: TODO/TOCHECK: est-ce que cela fait la meme chose qu'avant? DO JOUTDAD =1,JPOUTMAX - IF ( XFMOUT(NDAD(IMI),JOUTDAD) /= XUNDEF .AND. & - XFMOUT(NDAD(IMI),JOUTDAD) <= (XFMOUT(IMI,JOUT)+1.E-10) ) & + IF ( XBAK_TIME(NDAD(IMI),JOUTDAD) >=0. .AND. & + XBAK_TIME(NDAD(IMI),JOUTDAD) <= (XBAK_TIME(IMI,JOUT)+1.E-10) ) & IOUTDAD=IOUTDAD+1 END DO IF(IOUTDAD>0) THEN diff --git a/src/MNH/modn_fmout.f90 b/src/MNH/modn_fmout.f90 index 2168e596643d2b90d97bf6254a7829018d449dcd..78748b2dd155255a755081ac4f89faee51f81ed8 100644 --- a/src/MNH/modn_fmout.f90 +++ b/src/MNH/modn_fmout.f90 @@ -48,6 +48,6 @@ USE MODD_FMOUT ! IMPLICIT NONE ! -NAMELIST/NAM_FMOUT/XFMOUT +NAMELIST/NAM_FMOUT/XBAK_TIME ! END MODULE MODN_FMOUT diff --git a/src/MNH/read_desfmn.f90 b/src/MNH/read_desfmn.f90 index c7e9cd86956f58c058226b14b1fb9e511e2b1eb2..11ec3ca57c4db4dc98409bf35d7892550313d2dd 100644 --- a/src/MNH/read_desfmn.f90 +++ b/src/MNH/read_desfmn.f90 @@ -425,7 +425,7 @@ IF (KMI == 1) THEN CALL POSNAM(ILUDES,'NAM_FMOUT',GFOUND) IF (GFOUND) READ(UNIT=ILUDES,NML=NAM_FMOUT) ! - XFMOUT (:,:) = XUNDEF + XBAK_TIME(:,:) = XNEGUNDEF ! CALL POSNAM(ILUDES,'NAM_BUDGET',GFOUND) IF (GFOUND) READ(UNIT=ILUDES,NML=NAM_BUDGET) diff --git a/src/MNH/set_grid.f90 b/src/MNH/set_grid.f90 index 64af97f943f8f6e451ddd6de484b7b0b59bdddf2..95aeaf726f534dfc5ac9dc09592d89b0627bd6fa 100644 --- a/src/MNH/set_grid.f90 +++ b/src/MNH/set_grid.f90 @@ -329,6 +329,8 @@ REAL, DIMENSION(:), ALLOCATABLE :: ZYHAT_ll ! Position y in the conformal ! plane (array on the complete domain) REAL :: ZXHATM,ZYHATM ! coordinates of mass point REAL :: ZLATORI, ZLONORI ! lat and lon of left-bottom point +REAL :: ZTEMP ! Intermediate variable +INTEGER :: IPOS INTEGER :: IGRID,ILENCH,IRESP ! File CHARACTER (LEN=16) :: YRECFM ! management CHARACTER (LEN=100) :: YCOMMENT ! variables @@ -337,7 +339,7 @@ INTEGER, DIMENSION(3) :: ITDATE ! date array CHARACTER (LEN=40) :: YTITLE ! Title for date print INTEGER :: ILUOUT ! Logical unit number for ! output-listing -INTEGER :: JKLOOP,JOUT ! Loop index +INTEGER :: JKLOOP,JOUT,IDX ! Loop index INTEGER :: IIUP,IJUP ,ISUP=1 ! size of working ! window arrays, ! supp. time steps @@ -514,27 +516,78 @@ KSTOP = NINT(PSEGLEN/PTSTEP) ! !* 2.3 Temporal grid - outputs managment ! -!* 2.3.1 a) synchronization between nested models through XFMOUT arrays (MODD_FMOUT) +!* 2.3.1 Synchronization between nested models through XBAK_TIME arrays (MODD_FMOUT) ! DO JOUT = 1,JPOUTMAX - IF (XFMOUT(KMI,JOUT) /= XUNDEF) THEN - XFMOUT(KMI,JOUT) = NINT(XFMOUT(KMI,JOUT)/PTSTEP) * PTSTEP - DO JKLOOP = KMI,JPMODELMAX - XFMOUT(JKLOOP,JOUT) = XFMOUT(KMI,JOUT) + IF (XBAK_TIME(KMI,JOUT) >= 0.) THEN + !Value is rounded to nearest timestep + XBAK_TIME(KMI,JOUT) = NINT(XBAK_TIME(KMI,JOUT)/PTSTEP) * PTSTEP + !Output/backup time is propagated to nested models (with higher numbers) + !PW: TODO: BUG?: what happens if 2 dissociated models? + DO JKLOOP = KMI+1,JPMODELMAX + IDX = 1 + !Find first non 'allocated' element + DO WHILE ( XBAK_TIME(JKLOOP,IDX) >= 0. ) + IDX = IDX + 1 + END DO + IF (IDX > JPOUTMAX) THEN + PRINT *,'Error in SET_GRID when treating output list' + CALL ABORT + STOP + END IF + XBAK_TIME(JKLOOP,IDX) = XBAK_TIME(KMI,JOUT) END DO END IF END DO ! +!* 2.3.2 Find duplicated entries ! -!* 2.3.2 counting the output number of model KMI +DO JOUT = 1,JPOUTMAX + DO JKLOOP = JOUT+1,JPOUTMAX + IF ( XBAK_TIME(KMI,JKLOOP) == XBAK_TIME(KMI,JOUT) .AND. XBAK_TIME(KMI,JKLOOP) >= 0. ) THEN + print *,'WARNING: found duplicated backup (removed extra one)' + XBAK_TIME(KMI,JKLOOP) = -1. + END IF + END DO +END DO +! +!* 2.3.3 Sort entries ! -KOUT_NUMB =0 DO JOUT = 1,JPOUTMAX - IF (XFMOUT(KMI,JOUT) /= XUNDEF) THEN + ZTEMP = XBAK_TIME(KMI,JOUT) + IF (ZTEMP<0.) ZTEMP = 1e99 + IPOS = -1 + DO JKLOOP = JOUT+1,JPOUTMAX + IF ( XBAK_TIME(KMI,JKLOOP) < ZTEMP .AND. XBAK_TIME(KMI,JKLOOP) >= 0. ) THEN + ZTEMP = XBAK_TIME(KMI,JKLOOP) + IPOS = JKLOOP + END IF + END DO + IF (IPOS >= JOUT) THEN + XBAK_TIME(KMI,IPOS) = XBAK_TIME(KMI,JOUT) + XBAK_TIME(KMI,JOUT) = ZTEMP + END IF +END DO +! +!* 2.3.4 counting the output number of model KMI +! +KOUT_NUMB = 0 +DO JOUT = 1,JPOUTMAX + IF (XBAK_TIME(KMI,JOUT) >= 0.) THEN KOUT_NUMB = KOUT_NUMB + 1 - KOUT_TIMES(KOUT_NUMB) = NINT(XFMOUT(KMI,JOUT)/PTSTEP) + 1 + KOUT_TIMES(KOUT_NUMB) = NINT(XBAK_TIME(KMI,JOUT)/PTSTEP) + 1 END IF END DO +! +PRINT *,'-------------------------' +PRINT *,'Model number: ',KMI +PRINT *,'Number of backups: ',KOUT_NUMB +PRINT *,'Timestep Time' +DO JOUT = 1,KOUT_NUMB + WRITE(*,'( I9 F12.3 )' ) KOUT_TIMES(JOUT),XBAK_TIME(KMI,JOUT) +END DO +PRINT *,'-------------------------' + ! !------------------------------------------------------------------------------- !