Juan 12/06/2017:ini_prog_var.f90, Mai 2017 (M. Leriche) read aerosol namelists before...
authorJuan Escobar <escj@aero.obs-mip.fr>
Mon, 12 Jun 2017 08:16:54 +0000 (10:16 +0200)
committerJuan Escobar <escj@aero.obs-mip.fr>
Mon, 12 Jun 2017 08:16:54 +0000 (10:16 +0200)
                                  Mai 2017 (M. Leriche) Get wet dep. sv in Meso-NH init file

src/MNH/ini_prog_var.f90

index 6f36ce8..7494a0f 100644 (file)
@@ -95,6 +95,8 @@ END MODULE MODI_INI_PROG_VAR
 !!                  Aug 2012 (J.-P. Chaboureau) read the chem-file descriptor
 !!                  Fev 2015  (J.-P. Chaboureau) read instant T insteed of M
 !!                  J.Escobar : 15/09/2015 : WENO5 & JPHEXT <> 1 
+!!                  Mai 2017 (M. Leriche) read aerosol namelists before call ini_nsv
+!!                  Mai 2017 (M. Leriche) Get wet dep. sv in Meso-NH init file
 !-------------------------------------------------------------------------------
 !
 !*       0.    DECLARATIONS
@@ -119,6 +121,7 @@ USE MODD_SALT
 !
 USE MODN_DUST
 USE MODN_SALT
+USE MODN_CH_ORILAM
 !
 USE MODI_PGDFILTER
 USE MODI_CH_INIT_SCHEME_n
@@ -126,6 +129,7 @@ USE MODI_CH_AER_INIT_SOA
 !
 USE MODE_POS
 USE MODE_FM
+USE MODE_MODELN_HANDLER
 USE MODE_IO_ll
 USE MODE_FMREAD
 USE MODD_DIM_n
@@ -157,12 +161,14 @@ INTEGER :: IIU_ll, IJU_ll
 INTEGER :: IKU
 INTEGER :: ILBX,ILBY
 INTEGER :: JSV   ! Loop index
-INTEGER :: JMOM, IMOMENTS, JMODE, ISV_NAME_IDX  ! dust modes
+INTEGER :: JMOM, IMOMENTS, JMODE, ISV_NAME_IDX, IMODEIDX  ! dust and salt modes
 INTEGER :: ILUDES                         !  logical unit numbers of DESFM file
 LOGICAL :: GFOUND                         ! Return code when searching namelist
 !-------------------------------------------------------------------------------
 !
-CALL GET_MODEL_NUMBER_ll(IMI)
+! get model index
+IMI = GET_CURRENT_MODEL_INDEX()
+!
 CALL FMLOOK_ll(HLUOUT,HLUOUT,ILUOUT,IRESP)
 !
 CALL GET_INDICE_ll (IIB,IJB,IIE,IJE)
@@ -209,22 +215,6 @@ END IF
 ALLOCATE(XSVT(0,0,0,0))
 IF(PRESENT(HCHEMFILE)) THEN
   WRITE(ILUOUT,*) 'Routine INI_PROG_VAR: CHEMical species read in ',TRIM(HCHEMFILE)
-
-  IF (.NOT.LDUST) THEN
-  ! Always initialize chemical scheme variables before INI_NSV call !
-    CALL CH_INIT_SCHEME_n(IMI,LUSECHAQ,LUSECHIC,LCH_PH,ILUOUT,NVERB)
-! Question CL : Maud a supprime l appel a CH_INIT_CCS ?
-    LUSECHEM = .TRUE.
-  END IF
-  IF (LORILAM) THEN
-    CORGANIC = "MPMPO"
-    LVARSIGI = .TRUE.
-    LVARSIGJ = .TRUE.
-    CALL CH_AER_INIT_SOA(ILUOUT,NVERB)
-  END IF ! lorilam
-  ! initialise NSV_* variables
-  CALL INI_NSV(1)
-  ALLOCATE(XSVT(IIU,IJU,IKU,NSV))
   ! Read dimensions in chem file and checks with output file
   CALL FMOPEN_ll(HCHEMFILE,'READ',HLUOUT,0,2,NVERB,ININAR,IRESP)
   YRECFM='IMAX'
@@ -275,8 +265,40 @@ IF(PRESENT(HCHEMFILE)) THEN
     CALL ABORT
     STOP
   END IF ! IIMAX
+! check nsv to be read  
+  IF (.NOT.LDUST) THEN
+  ! Always initialize chemical scheme variables before INI_NSV call !
+    CALL CH_INIT_SCHEME_n(IMI,LUSECHAQ,LUSECHIC,LCH_PH,ILUOUT,NVERB)
+    LUSECHEM = .TRUE.
+  END IF
+  IF (LORILAM) THEN
+    YDESFM=TRIM(ADJUSTL(HCHEMFILE))//'.des'
+    CALL FMLOOK_ll(YDESFM,HLUOUT,ILUDES,IRESP)
+    CALL POSNAM(ILUDES,'NAM_CH_ORILAM',GFOUND,ILUOUT)
+    IF (GFOUND) READ(UNIT=ILUDES,NML=NAM_CH_ORILAM)
+  ENDIF
+  IF (LDUST) THEN
+    LDSTINIT=.TRUE.
+    LDSTPRES=.FALSE.
+    YDESFM=TRIM(ADJUSTL(HCHEMFILE))//'.des'
+    CALL FMLOOK_ll(YDESFM,HLUOUT,ILUDES,IRESP)
+    CALL POSNAM(ILUDES,'NAM_DUST',GFOUND,ILUOUT)
+    IF (GFOUND) READ(UNIT=ILUDES,NML=NAM_DUST)
+  ENDIF
+  IF (LSALT) THEN
+    LSLTINIT=.TRUE.
+    LSLTPRES=.FALSE.
+    YDESFM=TRIM(ADJUSTL(HCHEMFILE))//'.des'
+    CALL FMLOOK_ll(YDESFM,HLUOUT,ILUDES,IRESP)
+    CALL POSNAM(ILUDES,'NAM_SALT',GFOUND,ILUOUT)
+    IF (GFOUND) READ(UNIT=ILUDES,NML=NAM_SALT)
+  ! initialise NSV_* variables
+  ENDIF
+  CALL INI_NSV(1)
+  ALLOCATE(XSVT(IIU,IJU,IKU,NSV))
+  
+  ! Read scalars in chem file   
   IF (.NOT.LDUST) THEN
-  ! Read scalars in chem file 
     DO JSV = NSV_CHEMBEG,NSV_CHEMEND
       YRECFM=TRIM(CNAMES(JSV-NSV_CHEMBEG+1))//'T'
       YDIR='XY'
@@ -293,14 +315,45 @@ IF(PRESENT(HCHEMFILE)) THEN
     END IF
   END IF
 
+  IF (LORILAM) THEN
+    CALL CH_AER_INIT_SOA(ILUOUT,NVERB)
+    DO JSV = NSV_AERBEG,NSV_AEREND
+      YRECFM=TRIM(CAERONAMES(JSV-NSV_AERBEG+1))//'T'
+      YDIR='XY'
+      CALL FMREAD(HCHEMFILE,YRECFM,HLUOUT,YDIR,XSVT(:,:,:,JSV),IGRID,ILENCH,  &
+                YCOMMENT,IRESP)
+      IF (IRESP/=0) THEN
+      WRITE(ILUOUT,FMT=9000) 
+      WRITE(ILUOUT,*) TRIM(YRECFM),'NOT FOUND IN THE CHEM FILE ',HCHEMFILE
+!callabortstop
+!CALL ABORT
+!      STOP
+        LORILAM=.FALSE.
+      END IF !IRESP
+    END DO ! JSV    
+    IF (LDEPOS_AER(IMI)) THEN   
+      IF(.NOT.ALLOCATED(CDEAERNAMES)) THEN
+        ALLOCATE(CDEAERNAMES(JPMODE*2))
+        CDEAERNAMES(:) = YPDEAER_INI(:)
+      ENDIF    
+      DO JSV = NSV_AERDEPBEG,NSV_AERDEPEND
+        YRECFM=TRIM(CDEAERNAMES(JSV-NSV_AERDEPBEG+1))//'T'
+        YDIR='XY'
+        CALL FMREAD(HCHEMFILE,YRECFM,HLUOUT,YDIR,XSVT(:,:,:,JSV),IGRID,ILENCH,  &
+                YCOMMENT,IRESP)
+        IF (IRESP/=0) THEN
+          WRITE(ILUOUT,FMT=9000) 
+          WRITE(ILUOUT,*) TRIM(YRECFM),'NOT FOUND IN THE CHEM FILE ',HCHEMFILE
+!callabortstop
+!CALL ABORT
+!      STOP
+          LDEPOS_AER(IMI)=.FALSE.
+        END IF !IRESP
+      END DO ! JSV
+    END IF ! ldepos_aer
+  END IF ! lorilam
+  
   IF (LDUST) THEN
-    LDSTINIT=.TRUE.
-    LDSTPRES=.FALSE.
-    YDESFM=TRIM(ADJUSTL(HCHEMFILE))//'.des'
-    CALL FMLOOK_ll(YDESFM,HLUOUT,ILUDES,IRESP)
-    CALL POSNAM(ILUDES,'NAM_DUST',GFOUND,ILUOUT)
-    IF (GFOUND) READ(UNIT=ILUDES,NML=NAM_DUST)
-    CALL INI_NSV(1)
     IMOMENTS = INT(NSV_DSTEND - NSV_DSTBEG+1)/NMODE_DST
     IF (IMOMENTS == 1) THEN
       DO JMODE=1, NMODE_DST
@@ -339,15 +392,34 @@ IF(PRESENT(HCHEMFILE)) THEN
           END IF !IRESP
         END DO ! JMOM
       END DO !JMOD
-    END IF !if IMOMENTS    
+    END IF !if IMOMENTS   
+    IF (LDEPOS_DST(IMI)) THEN   
+      IF(.NOT.ALLOCATED(CDEDSTNAMES)) THEN
+        ALLOCATE(CDEDSTNAMES(NMODE_DST*2))
+        DO JMODE=1,NMODE_DST  
+          IMODEIDX=JPDUSTORDER(JMODE)
+          CDEDSTNAMES(JMODE) = YPDEDST_INI(IMODEIDX)
+          CDEDSTNAMES(NMODE_DST+JMODE) = YPDEDST_INI(NMODE_DST+IMODEIDX)
+        ENDDO
+      ENDIF    
+    DO JSV = NSV_DSTDEPBEG,NSV_DSTDEPEND
+        YRECFM=TRIM(CDEDSTNAMES(JSV-NSV_DSTDEPBEG+1))//'T'
+        YDIR='XY'
+        CALL FMREAD(HCHEMFILE,YRECFM,HLUOUT,YDIR,XSVT(:,:,:,JSV),IGRID,ILENCH,  &
+                YCOMMENT,IRESP)
+        IF (IRESP/=0) THEN
+          WRITE(ILUOUT,FMT=9000) 
+          WRITE(ILUOUT,*) TRIM(YRECFM),'NOT FOUND IN THE CHEM FILE ',HCHEMFILE
+!callabortstop
+!CALL ABORT
+!      STOP
+          LDEPOS_DST(IMI)=.FALSE.
+        END IF !IRESP
+      END DO ! JSV
+    END IF ! ldepos_dst
   END IF  ! LDUST
 
   IF (LSALT) THEN
-    LSLTINIT=.TRUE.
-    LSLTPRES=.FALSE.
-    CALL POSNAM(ILUDES,'NAM_SALT',GFOUND,ILUOUT)
-    IF (GFOUND) READ(UNIT=ILUDES,NML=NAM_SALT)
-    CALL INI_NSV(1)
     IMOMENTS = INT(NSV_SLTEND - NSV_SLTBEG+1)/NMODE_SLT
     IF (IMOMENTS == 1) THEN
       DO JMODE=1, NMODE_SLT
@@ -386,23 +458,33 @@ IF(PRESENT(HCHEMFILE)) THEN
           END IF !IRESP
         END DO ! JMOM
       END DO !JMOD
-    END IF !if IMOMENTS    
-  END IF  ! LSALT
-
-  DO JSV = NSV_AERBEG,NSV_AEREND
-    YRECFM=TRIM(CAERONAMES(JSV-NSV_AERBEG+1))//'T'
-    YDIR='XY'
-    CALL FMREAD(HCHEMFILE,YRECFM,HLUOUT,YDIR,XSVT(:,:,:,JSV),IGRID,ILENCH,  &
+    END IF !if IMOMENTS  
+    IF (LDEPOS_SLT(IMI)) THEN
+      IF(.NOT.ALLOCATED(CDESLTNAMES)) THEN
+        ALLOCATE(CDESLTNAMES(NMODE_SLT*2))
+        DO JMODE=1,NMODE_SLT  
+          IMODEIDX=JPDUSTORDER(JMODE)
+          CDESLTNAMES(JMODE) = YPDESLT_INI(IMODEIDX)
+          CDESLTNAMES(NMODE_SLT+JMODE) = YPDESLT_INI(NMODE_SLT+IMODEIDX)
+        ENDDO
+      ENDIF
+      DO JSV = NSV_SLTDEPBEG,NSV_SLTDEPEND
+        YRECFM=TRIM(CDESLTNAMES(JSV-NSV_SLTDEPBEG+1))//'T'
+        YDIR='XY'
+        CALL FMREAD(HCHEMFILE,YRECFM,HLUOUT,YDIR,XSVT(:,:,:,JSV),IGRID,ILENCH,  &
                 YCOMMENT,IRESP)
-    IF (IRESP/=0) THEN
-      WRITE(ILUOUT,FMT=9000) 
-      WRITE(ILUOUT,*) TRIM(YRECFM),'NOT FOUND IN THE CHEM FILE ',HCHEMFILE
+        IF (IRESP/=0) THEN
+          WRITE(ILUOUT,FMT=9000) 
+          WRITE(ILUOUT,*) TRIM(YRECFM),'NOT FOUND IN THE CHEM FILE ',HCHEMFILE
 !callabortstop
 !CALL ABORT
 !      STOP
-      LORILAM=.FALSE.
-    END IF !IRESP
-  END DO ! JSV
+          LDEPOS_SLT(IMI)=.FALSE.
+        END IF !IRESP
+      END DO ! JSV      
+    ENDIF ! ldepos_slt 
+  END IF  ! LSALT
+
   CALL FMCLOS_ll(HCHEMFILE,'KEEP',HLUOUT,IRESP)
 
 ELSE ! HCHEMFILE