Index: LMDZ6/trunk/libf/dyn3dmem/guide_loc_mod.F90
===================================================================
--- LMDZ6/trunk/libf/dyn3dmem/guide_loc_mod.F90	(revision 3984)
+++ LMDZ6/trunk/libf/dyn3dmem/guide_loc_mod.F90	(revision 3995)
@@ -9,10 +9,10 @@
 !=======================================================================
 
-  USE getparam
+  USE getparam, only: ini_getparam, fin_getparam, getpar
   USE Write_Field_loc
   use netcdf, only: nf90_nowrite, nf90_open, nf90_inq_varid, nf90_close, &
                     nf90_inq_dimid, nf90_inquire_dimension
   USE parallel_lmdz
-  USE pres2lev_mod
+  USE pres2lev_mod, only: pres2lev
 
   IMPLICIT NONE
@@ -63,5 +63,5 @@
   REAL, ALLOCATABLE, DIMENSION(:),   PRIVATE, SAVE   :: psgui1,psgui2
   
-  INTEGER,SAVE,PRIVATE :: ijbu,ijbv,ijeu,ijev,ijnu,ijnv
+  INTEGER,SAVE,PRIVATE :: ijbu,ijbv,ijeu,ijev !,ijnu,ijnv
   INTEGER,SAVE,PRIVATE :: jjbu,jjbv,jjeu,jjev,jjnu,jjnv
 
@@ -175,5 +175,5 @@
           rcod=nf90_open('apbp.nc',Nf90_NOWRITe, ncidpl)
           if (rcod.NE.NF_NOERR) THEN
-             print *,'Guide: probleme -> pas de fichier apbp.nc'
+             abort_message=' Nudging error -> no file apbp.nc'
              CALL abort_gcm(modname,abort_message,1)
           endif
@@ -183,5 +183,5 @@
           rcod=nf90_open('P.nc',Nf90_NOWRITe,ncidpl)
           if (rcod.NE.NF_NOERR) THEN
-             print *,'Guide: probleme -> pas de fichier P.nc'
+             abort_message=' Nudging error -> no file P.nc'
              CALL abort_gcm(modname,abort_message,1)
           endif
@@ -192,5 +192,5 @@
           rcod=nf90_open('u.nc',Nf90_NOWRITe,ncidpl)
           if (rcod.NE.NF_NOERR) THEN
-             print *,'Guide: probleme -> pas de fichier u.nc'
+             abort_message=' Nudging error -> no file u.nc'
              CALL abort_gcm(modname,abort_message,1)
           endif
@@ -203,5 +203,5 @@
           rcod=nf90_open('v.nc',nf90_nowrite,ncidpl)
           if (rcod.NE.NF_NOERR) THEN
-             print *,'Guide: probleme -> pas de fichier v.nc'
+             abort_message=' Nudging error -> no file v.nc'
              CALL abort_gcm(modname,abort_message,1)
           endif
@@ -213,5 +213,5 @@
           rcod=nf90_open('T.nc',nf90_nowrite,ncidpl)
           if (rcod.NE.NF_NOERR) THEN
-             print *,'Guide: probleme -> pas de fichier T.nc'
+             abort_message=' Nudging error -> no file T.nc'
              CALL abort_gcm(modname,abort_message,1)
           endif
@@ -224,5 +224,5 @@
           rcod=nf90_open('hur.nc',nf90_nowrite, ncidpl)
           if (rcod.NE.NF_NOERR) THEN
-             print *,'Guide: probleme -> pas de fichier hur.nc'
+             abort_message=' Nudging error -> no file hur.nc'
              CALL abort_gcm(modname,abort_message,1)
           endif
@@ -234,9 +234,9 @@
     IF (error.NE.NF_NOERR) error=NF_INQ_DIMID(ncidpl,'PRESSURE',rid)
     IF (error.NE.NF_NOERR) THEN
-        print *,'Guide: probleme lecture niveaux pression'
+        abort_message='Nudging: error reading pressure levels'
         CALL abort_gcm(modname,abort_message,1)
     ENDIF
     error=NF_INQ_DIMLEN(ncidpl,rid,nlevnc)
-    print *,'Guide: nombre niveaux vert. nlevnc', nlevnc 
+    write(*,*)trim(modname)//' : number of vertical levels nlevnc', nlevnc
     rcod = nf90_close(ncidpl)
 
@@ -244,5 +244,5 @@
 ! Allocation des variables
 ! ---------------------------------------------
-    abort_message='pb in allocation guide'
+    abort_message='nudging allocation error'
 
     ALLOCATE(apnc(nlevnc), stat = error)
@@ -395,16 +395,20 @@
     
     INTEGER       :: i,j,l
-    INTEGER,EXTERNAL :: OMP_GET_THREAD_NUM
+    CHARACTER(LEN=20) :: modname="guide_main"
        
 !$OMP MASTER    
-    ijbu=ij_begin ; ijeu=ij_end ; ijnu=ijeu-ijbu+1  
+    ijbu=ij_begin ; ijeu=ij_end
     jjbu=jj_begin ; jjeu=jj_end ; jjnu=jjeu-jjbu+1 
-    ijbv=ij_begin ; ijev=ij_end ; ijnv=ijev-ijbv+1   
+    ijbv=ij_begin ; ijev=ij_end
     jjbv=jj_begin ; jjev=jj_end ; jjnv=jjev-jjbv+1 
     IF (pole_sud) THEN
+      ijeu=ij_end-iip1
       ijev=ij_end-iip1
       jjev=jj_end-1
-      ijnv=ijev-ijbv+1
       jjnv=jjev-jjbv+1 
+    ENDIF
+    IF (pole_nord) THEN
+      ijbu=ij_begin+iip1
+      ijbv=ij_begin
     ENDIF
 !$OMP END MASTER
@@ -493,6 +497,7 @@
       IF (reste.EQ.0.) THEN
           IF (itau_test.EQ.itau) THEN
-              write(*,*)'deuxieme passage de advreel a itau=',itau
-              stop
+            write(*,*)trim(modname)//' second pass in advreel at itau=',&
+            itau
+            stop
           ELSE
 !$OMP MASTER
@@ -507,6 +512,8 @@
               step_rea=step_rea+1
               itau_test=itau
-              print*,'Lecture fichiers guidage, pas ',step_rea, &
-                    'apres ',count_no_rea,' non lectures'
+              if (is_master) then
+                write(*,*)trim(modname)//' Reading nudging files, step ',&
+                    step_rea,'after ',count_no_rea,' skips'
+              endif
               IF (guide_2D) THEN
 !$OMP MASTER
@@ -547,5 +554,5 @@
     
     
-        !-----------------------------------------------------------------------
+!-----------------------------------------------------------------------
 !   Ajout des champs de guidage 
 !-----------------------------------------------------------------------
@@ -576,13 +583,4 @@
         ENDDO
 
-!!$OMP MASTER
-!     DO l=1,llm,5
-!         print*,'avant dump2d l=',l,mpi_rank,OMP_GET_THREAD_NUM()
-!         print*,'avant dump2d l=',l,mpi_rank
-!         CALL dump2d(iip1,jjnb_u,p(:,l),'ppp   ')
-!      ENDDO
-!!$OMP END MASTER
-!!$OMP BARRIER
-
         CALL guide_out("SP",jjp1,llm,p(ijb_u:ije_u,1:llm),1.)
     ENDIF
@@ -605,8 +603,12 @@
         if (guide_zon) CALL guide_zonave_u(1,llm,f_addu)
         CALL guide_addfield_u(llm,f_addu,alpha_u)
-!       IF (f_out) CALL guide_out("ua",jjp1,llm,ugui1(ijb_u:ije_u,:),factt)
         IF (f_out) CALL guide_out("ua",jjp1,llm,(1.-tau)*ugui1(ijb_u:ije_u,:)+tau*ugui2(ijb_u:ije_u,:),factt)
         IF (f_out) CALL guide_out("u",jjp1,llm,ucov(ijb_u:ije_u,:),factt)
-        IF (f_out) CALL guide_out("ucov",jjp1,llm,f_addu(ijb_u:ije_u,:)/factt,factt)
+        IF (f_out) THEN
+         ! Ehouarn: fill the gaps adequately...
+         IF (ijbu>ijb_u) f_addu(ijb_u:ijbu-1,:)=0
+         IF (ijeu<ije_u) f_addu(ijeu+1:ije_u,:)=0
+         CALL guide_out("ucov",jjp1,llm,f_addu(ijb_u:ije_u,:)/factt,factt)
+        ENDIF
 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
         DO l=1,llm
@@ -703,5 +705,10 @@
         IF (f_out) CALL guide_out("v",jjm,llm,vcov(ijb_v:ije_v,:),factt)
         IF (f_out) CALL guide_out("va",jjm,llm,(1.-tau)*vgui1(ijb_v:ije_v,:)+tau*vgui2(ijb_v:ije_v,:),factt)
-        IF (f_out) CALL guide_out("vcov",jjm,llm,f_addv(:,:)/factt,factt)
+        IF (f_out) THEN
+          ! Ehouarn: Fill in the gaps adequately
+          IF (ijbv>ijb_v) f_addv(ijb_v:ijbv-1,:)=0 
+          IF (ijev<ije_v) f_addv(ijev+1:ije_v,:)=0
+          CALL guide_out("vcov",jjm,llm,f_addv(ijb_v:ije_v,:)/factt,factt)
+        ENDIF
 
 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
@@ -939,7 +946,9 @@
   
   INTEGER                            :: i,j,l,ij
+  CHARACTER(LEN=20),PARAMETER :: modname="guide_interp"
   TYPE(Request),SAVE :: Req  
 !$OMP THREADPRIVATE(Req)
-    print *,'Guide: conversion variables guidage'
+    
+    if (is_master) write(*,*)trim(modname)//': interpolate nudging variables'
 ! -----------------------------------------------------------------
 ! Calcul des niveaux de pression champs guidage (pour T et Q)
@@ -986,38 +995,39 @@
         first=.FALSE.
 !$OMP MASTER
-        print*,'Guide: verification ordre niveaux verticaux'
-        print*,'LMDZ :'
+        write(*,*)trim(modname)//' : check vertical level order'
+        write(*,*)trim(modname)//' LMDZ :'
         do l=1,llm
-            print*,'PL(',l,')=',(ap(l)+ap(l+1))/2. &
+          write(*,*)trim(modname)//' PL(',l,')=',(ap(l)+ap(l+1))/2. &
                   +psi(1,jjeu)*(bp(l)+bp(l+1))/2.
         enddo
-        print*,'Fichiers guidage'
+        write(*,*)trim(modname)//' nudging file :'
         SELECT CASE (guide_plevs)
         CASE (0) 
             do l=1,nlevnc
-                 print*,'PL(',l,')=',plnc2(1,jjbu,l)
+              write(*,*)trim(modname)//' PL(',l,')=',plnc2(1,jjbu,l)
             enddo
         CASE (1)
             DO l=1,nlevnc
-                 print*,'PL(',l,')=',apnc(l)+bpnc(l)*psnat2(i,jjbu)
-             ENDDO
+              write(*,*)trim(modname)//' PL(',l,')=',&
+                        apnc(l)+bpnc(l)*psnat2(i,jjbu)
+            ENDDO
         CASE (2)
             do l=1,nlevnc
-                 print*,'PL(',l,')=',pnat2(1,jjbu,l)
+              write(*,*)trim(modname)//' PL(',l,')=',pnat2(1,jjbu,l)
             enddo
         END SELECT
-        print *,'inversion de l''ordre: invert_p=',invert_p
+        write(*,*)trim(modname)//' invert ordering: invert_p=',invert_p
         if (guide_u) then
             do l=1,nlevnc
-                print*,'U(',l,')=',unat2(1,jjbu,l)
+              write(*,*)trim(modname)//' U(',l,')=',unat2(1,jjbu,l)
             enddo
         endif
         if (guide_T) then
             do l=1,nlevnc
-                print*,'T(',l,')=',tnat2(1,jjbu,l)
+              write(*,*)trim(modname)//' T(',l,')=',tnat2(1,jjbu,l)
             enddo
         endif
 !$OMP END MASTER
-    endif
+    endif ! of if (first)
     
 ! -----------------------------------------------------------------
@@ -1415,4 +1425,5 @@
     real alphamin,alphamax,xi
     integer i,j,ilon,ilat
+    character(len=20),parameter :: modname="tau2alpha"
 
 
@@ -1503,19 +1514,19 @@
             ! Calcul de gamma
             if (abs(grossismx-1.).lt.0.1.or.abs(grossismy-1.).lt.0.1) then
-                 print*,'ATTENTION modele peu zoome'
-                 print*,'ATTENTION on prend une constante de guidage cste'
-                 gamma=0.
+              write(*,*)trim(modname)//' ATTENTION modele peu zoome'
+              write(*,*)trim(modname)//' ATTENTION on prend une constante de guidage cste'
+              gamma=0.
             else
-                gamma=(dxdy_max-2.*dxdy_min)/(dxdy_max-dxdy_min)
-                print*,'gamma=',gamma
-                if (gamma.lt.1.e-5) then
-                  print*,'gamma =',gamma,'<1e-5'
-                  stop
-                endif
-                gamma=log(0.5)/log(gamma)
-                if (gamma4) then 
-                  gamma=min(gamma,4.)
-                endif
-                print*,'gamma=',gamma
+              gamma=(dxdy_max-2.*dxdy_min)/(dxdy_max-dxdy_min)
+              write(*,*)trim(modname)//' gamma=',gamma
+              if (gamma.lt.1.e-5) then
+                write(*,*)trim(modname)//' gamma =',gamma,'<1e-5'
+                stop
+              endif
+              gamma=log(0.5)/log(gamma)
+              if (gamma4) then 
+                gamma=min(gamma,4.)
+              endif
+              write(*,*)trim(modname)//' gamma=',gamma
             endif
         ENDIF !first
@@ -1558,7 +1569,7 @@
     IMPLICIT NONE
 
-#include "netcdf.inc"
-#include "dimensions.h"
-#include "paramet.h"
+    include "netcdf.inc"
+    include "dimensions.h"
+    include "paramet.h"
 
     INTEGER, INTENT(IN)   :: timestep
@@ -1582,24 +1593,24 @@
     if (first) then
          ncidpl=-99
-         print*,'Guide: ouverture des fichiers guidage '
+         write(*,*),trim(modname)//': opening nudging files '
 ! Ap et Bp si Niveaux de pression hybrides
          if (guide_plevs.EQ.1) then
-             print *,'Lecture du guidage sur niveaux modele'
+             write(*,*),trim(modname)//' Reading nudging on model levels'
              rcode = nf90_open('apbp.nc', nf90_nowrite, ncidpl)
              IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de fichier apbp.nc'
+              abort_message='Nudging: error -> no file apbp.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
              rcode = nf90_inq_varid(ncidpl, 'AP', varidap)
              IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de variable AP, fichier apbp.nc'
+              abort_message='Nudging: error -> no AP variable in file apbp.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
              rcode = nf90_inq_varid(ncidpl, 'BP', varidbp)
              IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de variable BP, fichier apbp.nc'
+              abort_message='Nudging: error -> no BP variable in file apbp.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
-             print*,'ncidpl,varidap',ncidpl,varidap
+             write(*,*),trim(modname)//' ncidpl,varidap',ncidpl,varidap
          endif
          
@@ -1608,13 +1619,13 @@
              rcode = nf90_open('P.nc', nf90_nowrite, ncidp)
              IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de fichier P.nc'
+              abort_message='Nudging: error -> no file P.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
              rcode = nf90_inq_varid(ncidp, 'PRES', varidp)
              IF (rcode.NE.NF_NOERR) THEN 
-              print *,'Guide: probleme -> pas de variable PRES, fichier P.nc'
+              abort_message='Nudging: error -> no PRES variable in file P.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
-             print*,'ncidp,varidp',ncidp,varidp
+             write(*,*),trim(modname)//' ncidp,varidp',ncidp,varidp
              if (ncidpl.eq.-99) ncidpl=ncidp
          endif
@@ -1624,13 +1635,13 @@
              rcode = nf90_open('u.nc', nf90_nowrite, ncidu)
              IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de fichier u.nc'
+              abort_message='Nudging: error -> no file u.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
              rcode = nf90_inq_varid(ncidu, 'UWND', varidu)
              IF (rcode.NE.NF_NOERR) THEN 
-              print *,'Guide: probleme -> pas de variable UWND, fichier u.nc'
+              abort_message='Nudging: error -> no UWND variable in file u.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
-             print*,'ncidu,varidu',ncidu,varidu
+             write(*,*),trim(modname)//' ncidu,varidu',ncidu,varidu
              if (ncidpl.eq.-99) ncidpl=ncidu
 
@@ -1639,5 +1650,5 @@
              status=NF90_INQUIRE_DIMENSION(ncidu,dimid,namedim,lendim)
              IF (lendim .NE. iip1) THEN
-                print *,'dimension LONU different from iip1 in u.nc'
+                abort_message='dimension LONU different from iip1 in u.nc'
                 CALL abort_gcm(modname,abort_message,1)
              ENDIF
@@ -1646,5 +1657,5 @@
              status=NF90_INQUIRE_DIMENSION(ncidu,dimid,namedim,lendim)
              IF (lendim .NE. jjp1) THEN
-                print *,'dimension LATU different from jjp1 in u.nc'
+                abort_message='dimension LATU different from jjp1 in u.nc'
                 CALL abort_gcm(modname,abort_message,1)
              ENDIF
@@ -1656,13 +1667,13 @@
              rcode = nf90_open('v.nc', nf90_nowrite, ncidv)
              IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de fichier v.nc'
+              abort_message='Nudging: error -> no file v.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
              rcode = nf90_inq_varid(ncidv, 'VWND', varidv)
              IF (rcode.NE.NF_NOERR) THEN 
-              print *,'Guide: probleme -> pas de variable VWND, fichier v.nc'
+              abort_message='Nudging: error -> no VWND variable in file v.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
-             print*,'ncidv,varidv',ncidv,varidv
+             write(*,*),trim(modname)//' ncidv,varidv',ncidv,varidv
              if (ncidpl.eq.-99) ncidpl=ncidv
              
@@ -1671,5 +1682,5 @@
              
                 IF (lendim .NE. iip1) THEN
-                print *,'dimension LONV different from iip1 in v.nc'
+                abort_message='dimension LONV different from iip1 in v.nc'
                 CALL abort_gcm(modname,abort_message,1)
              ENDIF
@@ -1679,5 +1690,5 @@
              status=NF90_INQUIRE_DIMENSION(ncidv,dimid,namedim,lendim)
              IF (lendim .NE. jjm) THEN
-                print *,'dimension LATV different from jjm in v.nc'
+                abort_message='dimension LATV different from jjm in v.nc'
                 CALL abort_gcm(modname,abort_message,1)
              ENDIF
@@ -1689,13 +1700,13 @@
              rcode = nf90_open('T.nc', nf90_nowrite, ncidt)
              IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de fichier T.nc'
+              abort_message='Nudging: error -> no file T.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
              rcode = nf90_inq_varid(ncidt, 'AIR', varidt)
              IF (rcode.NE.NF_NOERR) THEN 
-              print *,'Guide: probleme -> pas de variable AIR, fichier T.nc'
+              abort_message='Nudging: error -> no AIR variable in file T.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
-             print*,'ncidT,varidT',ncidt,varidt
+             write(*,*),trim(modname)//' ncidT,varidT',ncidt,varidt
              if (ncidpl.eq.-99) ncidpl=ncidt
 
@@ -1703,5 +1714,5 @@
              status=NF90_INQUIRE_DIMENSION(ncidt,dimid,namedim,lendim)
              IF (lendim .NE. iip1) THEN
-                print *,'dimension LONV different from iip1 in T.nc'
+                abort_message='dimension LONV different from iip1 in T.nc'
                 CALL abort_gcm(modname,abort_message,1)
              ENDIF
@@ -1710,5 +1721,5 @@
              status=NF90_INQUIRE_DIMENSION(ncidt,dimid,namedim,lendim)
              IF (lendim .NE. jjp1) THEN
-                print *,'dimension LATU different from jjp1 in T.nc'
+                abort_message='dimension LATU different from jjp1 in T.nc'
                 CALL abort_gcm(modname,abort_message,1)
              ENDIF
@@ -1720,13 +1731,13 @@
              rcode = nf90_open('hur.nc', nf90_nowrite, ncidQ)
              IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de fichier hur.nc'
+              abort_message='Nudging: error -> no file hur.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
              rcode = nf90_inq_varid(ncidQ, 'RH', varidQ)
              IF (rcode.NE.NF_NOERR) THEN 
-              print *,'Guide: probleme -> pas de variable RH, fichier hur.nc'
+              abort_message='Nudging: error -> no RH variable in file hur.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
-             print*,'ncidQ,varidQ',ncidQ,varidQ
+             write(*,*),trim(modname)//' ncidQ,varidQ',ncidQ,varidQ
              if (ncidpl.eq.-99) ncidpl=ncidQ
 
@@ -1735,5 +1746,5 @@
              status=NF90_INQUIRE_DIMENSION(ncidQ,dimid,namedim,lendim)
              IF (lendim .NE. iip1) THEN
-                print *,'dimension LONV different from iip1 in hur.nc'
+                abort_message='dimension LONV different from iip1 in hur.nc'
                 CALL abort_gcm(modname,abort_message,1)
              ENDIF
@@ -1742,5 +1753,5 @@
              status=NF90_INQUIRE_DIMENSION(ncidQ,dimid,namedim,lendim)
              IF (lendim .NE. jjp1) THEN
-                print *,'dimension LATU different from jjp1 in hur.nc'
+                abort_message='dimension LATU different from jjp1 in hur.nc'
                 CALL abort_gcm(modname,abort_message,1)
              ENDIF
@@ -1752,13 +1763,13 @@
              rcode = nf90_open('ps.nc', nf90_nowrite, ncidps)
              IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de fichier ps.nc'
+              abort_message='Nudging: error -> no file ps.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
              rcode = nf90_inq_varid(ncidps, 'SP', varidps)
              IF (rcode.NE.NF_NOERR) THEN 
-              print *,'Guide: probleme -> pas de variable SP, fichier ps.nc'
+              abort_message='Nudging: error -> no SP variable in file ps.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
-             print*,'ncidps,varidps',ncidps,varidps
+             write(*,*),trim(modname)//' ncidps,varidps',ncidps,varidps
          endif
 ! Coordonnee verticale
@@ -1766,5 +1777,5 @@
               rcode = nf90_inq_varid(ncidpl, 'LEVEL', varidpl)
               IF (rcode.NE.0) rcode = nf90_inq_varid(ncidpl, 'PRESSURE', varidpl)
-              print*,'ncidpl,varidpl',ncidpl,varidpl
+              write(*,*),trim(modname)//' ncidpl,varidpl',ncidpl,varidpl
          endif
 ! Coefs ap, bp pour calcul de la pression aux differents niveaux
@@ -1911,7 +1922,7 @@
     IMPLICIT NONE
 
-#include "netcdf.inc"
-#include "dimensions.h"
-#include "paramet.h"
+    include "netcdf.inc"
+    include "dimensions.h"
+    include "paramet.h"
 
     INTEGER, INTENT(IN)   :: timestep
@@ -1938,120 +1949,120 @@
     if (first) then
          ncidpl=-99
-         print*,'Guide: ouverture des fichiers guidage '
+         write(*,*)trim(modname)//' : opening nudging files '
 ! Ap et Bp si niveaux de pression hybrides
          if (guide_plevs.EQ.1) then
-             print *,'Lecture du guidage sur niveaux mod�le'
-             rcode = nf90_open('apbp.nc', nf90_nowrite, ncidpl)
-             IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de fichier apbp.nc'
-              CALL abort_gcm(modname,abort_message,1)
-             ENDIF
-             rcode = nf90_inq_varid(ncidpl, 'AP', varidap)
-             IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de variable AP, fichier apbp.nc'
-              CALL abort_gcm(modname,abort_message,1)
-             ENDIF
-             rcode = nf90_inq_varid(ncidpl, 'BP', varidbp)
-             IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de variable BP, fichier apbp.nc'
-              CALL abort_gcm(modname,abort_message,1)
-             ENDIF
-             print*,'ncidpl,varidap',ncidpl,varidap
+           write(*,*)trim(modname)//' Reading nudging on model levels'
+           rcode = nf90_open('apbp.nc', nf90_nowrite, ncidpl)
+           IF (rcode.NE.NF_NOERR) THEN
+             abort_message='Nudging: error -> no file apbp.nc'
+           CALL abort_gcm(modname,abort_message,1)
+           ENDIF
+           rcode = nf90_inq_varid(ncidpl, 'AP', varidap)
+           IF (rcode.NE.NF_NOERR) THEN
+             abort_message='Nudging: error -> no AP variable in file apbp.nc'
+           CALL abort_gcm(modname,abort_message,1)
+           ENDIF
+           rcode = nf90_inq_varid(ncidpl, 'BP', varidbp)
+           IF (rcode.NE.NF_NOERR) THEN
+             abort_message='Nudging: error -> no BP variable in file apbp.nc'
+             CALL abort_gcm(modname,abort_message,1)
+           ENDIF
+           write(*,*)trim(modname)//'ncidpl,varidap',ncidpl,varidap
          endif
 ! Pression
          if (guide_plevs.EQ.2) then
-             rcode = nf90_open('P.nc', nf90_nowrite, ncidp)
-             IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de fichier P.nc'
-              CALL abort_gcm(modname,abort_message,1)
-             ENDIF
-             rcode = nf90_inq_varid(ncidp, 'PRES', varidp)
-             IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de variable PRES, fichier P.nc'
-              CALL abort_gcm(modname,abort_message,1)
-             ENDIF
-             print*,'ncidp,varidp',ncidp,varidp
-             if (ncidpl.eq.-99) ncidpl=ncidp
+           rcode = nf90_open('P.nc', nf90_nowrite, ncidp)
+           IF (rcode.NE.NF_NOERR) THEN
+             abort_message='Nudging: error -> no file P.nc'
+             CALL abort_gcm(modname,abort_message,1)
+           ENDIF
+           rcode = nf90_inq_varid(ncidp, 'PRES', varidp)
+           IF (rcode.NE.NF_NOERR) THEN
+             abort_message='Nudging: error -> no PRES variable in file P.nc'
+             CALL abort_gcm(modname,abort_message,1)
+           ENDIF
+           write(*,*)trim(modname)//' ncidp,varidp',ncidp,varidp
+           if (ncidpl.eq.-99) ncidpl=ncidp
          endif
 ! Vent zonal
          if (guide_u) then
-             rcode = nf90_open('u.nc', nf90_nowrite, ncidu)
-             IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de fichier u.nc'
-              CALL abort_gcm(modname,abort_message,1)
-             ENDIF
-             rcode = nf90_inq_varid(ncidu, 'UWND', varidu)
-             IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de variable UWND, fichier u.nc'
-              CALL abort_gcm(modname,abort_message,1)
-             ENDIF
-             print*,'ncidu,varidu',ncidu,varidu
-             if (ncidpl.eq.-99) ncidpl=ncidu
+           rcode = nf90_open('u.nc', nf90_nowrite, ncidu)
+           IF (rcode.NE.NF_NOERR) THEN
+             abort_message='Nudging: error -> no file u.nc'
+             CALL abort_gcm(modname,abort_message,1)
+           ENDIF
+           rcode = nf90_inq_varid(ncidu, 'UWND', varidu)
+           IF (rcode.NE.NF_NOERR) THEN
+             abort_message='Nudging: error -> no UWND variable in file u.nc'
+             CALL abort_gcm(modname,abort_message,1)
+           ENDIF
+           write(*,*)trim(modname)//' ncidu,varidu',ncidu,varidu
+           if (ncidpl.eq.-99) ncidpl=ncidu
          endif
 
 ! Vent meridien
          if (guide_v) then
-             rcode = nf90_open('v.nc', nf90_nowrite, ncidv)
-             IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de fichier v.nc'
-              CALL abort_gcm(modname,abort_message,1)
-             ENDIF
-             rcode = nf90_inq_varid(ncidv, 'VWND', varidv)
-             IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de variable VWND, fichier v.nc'
-              CALL abort_gcm(modname,abort_message,1)
-             ENDIF
-             print*,'ncidv,varidv',ncidv,varidv
-             if (ncidpl.eq.-99) ncidpl=ncidv
-         endif
+           rcode = nf90_open('v.nc', nf90_nowrite, ncidv)
+           IF (rcode.NE.NF_NOERR) THEN
+             abort_message='Nudging: error -> no file v.nc'
+             CALL abort_gcm(modname,abort_message,1)
+           ENDIF
+           rcode = nf90_inq_varid(ncidv, 'VWND', varidv)
+           IF (rcode.NE.NF_NOERR) THEN
+             abort_message='Nudging: error -> no VWND variable in file v.nc'
+             CALL abort_gcm(modname,abort_message,1)
+           ENDIF
+           write(*,*)trim(modname)//' ncidv,varidv',ncidv,varidv
+           if (ncidpl.eq.-99) ncidpl=ncidv
+        endif
 ! Temperature
          if (guide_T) then
-             rcode = nf90_open('T.nc', nf90_nowrite, ncidt)
-             IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de fichier T.nc'
-              CALL abort_gcm(modname,abort_message,1)
-             ENDIF
-             rcode = nf90_inq_varid(ncidt, 'AIR', varidt)
-             IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de variable AIR, fichier T.nc'
-              CALL abort_gcm(modname,abort_message,1)
-             ENDIF
-             print*,'ncidT,varidT',ncidt,varidt
-             if (ncidpl.eq.-99) ncidpl=ncidt
+           rcode = nf90_open('T.nc', nf90_nowrite, ncidt)
+           IF (rcode.NE.NF_NOERR) THEN
+             abort_message='Nudging: error -> no file T.nc'
+             CALL abort_gcm(modname,abort_message,1)
+           ENDIF
+           rcode = nf90_inq_varid(ncidt, 'AIR', varidt)
+           IF (rcode.NE.NF_NOERR) THEN
+             abort_message='Nudging: error -> no AIR variable in file T.nc'
+             CALL abort_gcm(modname,abort_message,1)
+           ENDIF
+           write(*,*)trim(modname)//' ncidT,varidT',ncidt,varidt
+           if (ncidpl.eq.-99) ncidpl=ncidt
          endif
 ! Humidite
          if (guide_Q) then
-             rcode = nf90_open('hur.nc', nf90_nowrite, ncidQ)
-             IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de fichier hur.nc'
-              CALL abort_gcm(modname,abort_message,1)
-             ENDIF
-             rcode = nf90_inq_varid(ncidQ, 'RH', varidQ)
-             IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de variable RH, fichier hur.nc'
-              CALL abort_gcm(modname,abort_message,1)
-             ENDIF
-             print*,'ncidQ,varidQ',ncidQ,varidQ
-             if (ncidpl.eq.-99) ncidpl=ncidQ
+           rcode = nf90_open('hur.nc', nf90_nowrite, ncidQ)
+           IF (rcode.NE.NF_NOERR) THEN
+             abort_message='Nudging: error -> no file hur.nc'
+             CALL abort_gcm(modname,abort_message,1)
+           ENDIF
+           rcode = nf90_inq_varid(ncidQ, 'RH', varidQ)
+           IF (rcode.NE.NF_NOERR) THEN
+             abort_message='Nudging: error -> no RH,variable in file hur.nc'
+             CALL abort_gcm(modname,abort_message,1)
+           ENDIF
+           write(*,*)trim(modname)//' ncidQ,varidQ',ncidQ,varidQ
+           if (ncidpl.eq.-99) ncidpl=ncidQ
          endif
 ! Pression de surface
          if ((guide_P).OR.(guide_plevs.EQ.1)) then
-             rcode = nf90_open('ps.nc', nf90_nowrite, ncidps)
-             IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de fichier ps.nc'
-              CALL abort_gcm(modname,abort_message,1)
-             ENDIF
-             rcode = nf90_inq_varid(ncidps, 'SP', varidps)
-             IF (rcode.NE.NF_NOERR) THEN
-              print *,'Guide: probleme -> pas de variable SP, fichier ps.nc'
-              CALL abort_gcm(modname,abort_message,1)
-             ENDIF
-             print*,'ncidps,varidps',ncidps,varidps
+           rcode = nf90_open('ps.nc', nf90_nowrite, ncidps)
+           IF (rcode.NE.NF_NOERR) THEN
+             abort_message='Nudging: error -> no file ps.nc'
+             CALL abort_gcm(modname,abort_message,1)
+           ENDIF
+           rcode = nf90_inq_varid(ncidps, 'SP', varidps)
+           IF (rcode.NE.NF_NOERR) THEN
+             abort_message='Nudging: error -> no SP variable in file ps.nc'
+             CALL abort_gcm(modname,abort_message,1)
+           ENDIF
+           write(*,*)trim(modname)//' ncidps,varidps',ncidps,varidps
          endif
 ! Coordonnee verticale
          if (guide_plevs.EQ.0) then
-              rcode = nf90_inq_varid(ncidpl, 'LEVEL', varidpl)
-              IF (rcode.NE.0) rcode = nf90_inq_varid(ncidpl, 'PRESSURE', varidpl)
-              print*,'ncidpl,varidpl',ncidpl,varidpl
+           rcode = nf90_inq_varid(ncidpl, 'LEVEL', varidpl)
+           IF (rcode.NE.0) rcode = nf90_inq_varid(ncidpl, 'PRESSURE', varidpl)
+           write(*,*)trim(modname)//' ncidpl,varidpl',ncidpl,varidpl
          endif
 ! Coefs ap, bp pour calcul de la pression aux differents niveaux
@@ -2247,4 +2258,5 @@
     REAL zu(ip1jmp1),zv(ip1jm), zt(iip1, jjp1), zq(iip1, jjp1)
     REAL, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: field_glo
+    CHARACTER(LEN=20),PARAMETER :: modname="guide_out"
     
 !$OMP MASTER
@@ -2253,5 +2265,5 @@
 !$OMP BARRIER
 
-    print*,'gvide_out apres allocation ',hsize,vsize
+!    write(*,*)trim(modname)//' after allocation ',hsize,vsize
 
     IF (hsize==jjp1) THEN
@@ -2261,5 +2273,5 @@
     ENDIF
 
-    print*,'guide_out apres gather '
+!    write(*,*)trim(modname)//' after gather '
     CALL Gather_field_u(alpha_u,zu,1)
     CALL Gather_field_u(alpha_t,zt,1)
@@ -2431,6 +2443,4 @@
 !$OMP BARRIER
 
-    RETURN
-
   END SUBROUTINE guide_out
     
Index: LMDZ6/trunk/libf/dyn3dmem/parallel_lmdz.F90
===================================================================
--- LMDZ6/trunk/libf/dyn3dmem/parallel_lmdz.F90	(revision 3984)
+++ LMDZ6/trunk/libf/dyn3dmem/parallel_lmdz.F90	(revision 3995)
@@ -12,6 +12,8 @@
     INTEGER,PARAMETER :: halo_max=3
     
-    LOGICAL,SAVE :: using_mpi
-    LOGICAL,SAVE :: using_omp
+    LOGICAL,SAVE :: using_mpi ! .true. if using MPI
+    LOGICAL,SAVE :: using_omp ! .true. if using OpenMP
+    LOGICAL,SAVE :: is_master ! .true. if the core is both MPI & OpenMP master
+!$OMP THREADPRIVATE(is_master)
     
     integer, save :: mpi_size
@@ -248,4 +250,10 @@
 !$OMP END PARALLEL         
       CALL create_distrib(jj_nb_para,current_dist)
+      
+      IF ((mpi_rank==0).and.(omp_rank==0)) THEN
+        is_master=.true.
+      ELSE
+        is_master=.false.
+      ENDIF
       
     end subroutine init_parallel
