Changeset 3406


Ignore:
Timestamp:
Oct 23, 2018, 11:16:41 AM (6 years ago)
Author:
jghattas
Message:

Added all modifications in the model code that were used for the simulations with DYANMICO during the Grand Challeng 2018. Modifications done by Y. Meurdesoif, L. Fairhead and A.K. Traore

Location:
LMDZ6/branches/DYNAMICO-conv-GC
Files:
2 added
22 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/branches/DYNAMICO-conv-GC/build_gcm

    r1907 r3406  
    4545# run "fcm build" command
    4646${dirname}fcm build $*
     47status=$?
    4748
    4849# cleanup
    4950\rm -f '.lock'
    5051
     52if [ $status -ne 0 ]; then
     53  exit $status
     54fi
     55
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/dyn3dmem/caladvtrac_mod.F90

    r1907 r3406  
    4444    CALL allocate_u(massem,llm,d)
    4545    CALL allocate_u(pbaruc,llm,d)
     46    pbaruc(:,:)=0
    4647    CALL allocate_v(pbarvc,llm,d)
     48    pbarvc(:,:)=0
    4749    CALL allocate_u(pbarug,llm,d)
    4850    CALL allocate_v(pbarvg,llm,d)
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/dyn3dmem/call_calfis_mod.F90

    r2603 r3406  
    5252    CALL allocate_u(p,llmp1,d)
    5353    CALL allocate_u(pks,d)
     54    pks(:)=0
    5455    CALL allocate_u(pk,llm,d)
     56    pk(:,:)=0
    5557    CALL allocate_u(pkf,llm,d)
    5658    CALL allocate_u(phi,llm,d)
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/dyn3dmem/call_dissip_mod.F90

    r1987 r3406  
    3131
    3232    CALL allocate_u(ucov,llm,d)
     33    ucov(:,:)=0
    3334    CALL allocate_v(vcov,llm,d)
     35    vcov(:,:)=0
    3436    CALL allocate_u(teta,llm,d)
    3537    CALL allocate_u(p,llmp1,d)
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/dyn3dmem/integrd_mod.F90

    r1907 r3406  
    2323    CALL allocate_u(deltap,llm,d)
    2424    CALL allocate_u(ps,d)
     25    ps(:)=0
    2526
    2627   
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/misc/wxios.F90

    r3322 r3406  
    1515   
    1616    INTEGER, SAVE :: g_comm
    17     CHARACTER(len=100), SAVE :: g_ctx_name
     17    CHARACTER(len=100), SAVE :: g_ctx_name ="LMDZ"
    1818    TYPE(xios_context), SAVE :: g_ctx
    1919!$OMP THREADPRIVATE(g_comm,g_cts_name,g_ctx)
     
    145145    SUBROUTINE wxios_context_init()
    146146        USE print_control_mod, ONLY : prt_level, lunout
    147 !        USE mod_phys_lmdz_mpi_data, ONLY : COMM_LMDZ_PHY
     147        USE mod_phys_lmdz_mpi_data, ONLY : COMM_LMDZ_PHY
    148148        IMPLICIT NONE
    149149
     
    152152!$OMP MASTER
    153153        !Initialisation du contexte:
    154         CALL xios_context_initialize(g_ctx_name, g_comm)
     154        !!CALL xios_context_initialize(g_ctx_name, g_comm)
     155        CALL xios_context_initialize(g_ctx_name, COMM_LMDZ_PHY)
    155156        CALL xios_get_handle(g_ctx_name, xios_ctx)    !Récupération
    156157        CALL xios_set_current_context(xios_ctx)            !Activation
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/phylmd/coef_diff_turb_mod.F90

    r2952 r3406  
    6565
    6666
     67    ykmm = 0 !ym missing init
     68    ykmn = 0 !ym missing init
     69    ykmq = 0 !ym missing init
     70   
     71   
    6772!****************************************************************************************   
    6873! Calcul de coefficients de diffusion turbulent de l'atmosphere :
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/phylmd/cv3_routines.F90

    r2908 r3406  
    37473747    END DO ! cld
    37483748
     3749!ym BIG Warning : it seems that the k loop is missing !!!
     3750!ym Strong advice to check this
     3751!ym add a k loop temporary
     3752
    37493753! (particular case: no detraining level is found)                              ! cld
    3750     DO il = 1, ncum                                                            ! cld
    3751       IF (i<=inb(il) .AND. nent(il,i)==0 .AND. iflag(il)<=1) THEN              ! cld
    3752         qcond(il, i) = qcond(il, i) + (1.-ep(il,i))*clw(il, i)                 ! cld
    3753         qtment(il, i) = qent(il,k,i) + qtment(il,i)                          ! cld
    3754         nqcond(il, i) = nqcond(il, i) + 1.                                     ! cld
    3755       END IF                                                                   ! cld
    3756     END DO                                                                     ! cld
     3754    DO k = i + 1, nl
     3755      DO il = 1, ncum        !ym k loop added                                                      ! cld
     3756        IF (i<=inb(il) .AND. nent(il,i)==0 .AND. iflag(il)<=1) THEN              ! cld
     3757          qcond(il, i) = qcond(il, i) + (1.-ep(il,i))*clw(il, i)                 ! cld
     3758          qtment(il, i) = qent(il,k,i) + qtment(il,i)                          ! cld
     3759          nqcond(il, i) = nqcond(il, i) + 1.                                     ! cld
     3760        END IF                                                                   ! cld
     3761      END DO
     3762    ENDDO                                                                     ! cld
    37573763
    37583764    DO il = 1, ncum                                                            ! cld
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/phylmd/cva_driver.F90

    r2902 r3406  
    613613  asupmaxmin1(:) = 0.
    614614
     615  tvp(:, :) = 0. !ym missing init, need to have a look by developpers
     616  tv(:, :) = 0. !ym missing init, need to have a look by developpers
     617   
    615618  DO il = 1, len
    616619    cin1(il) = -100000.
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/phylmd/limit_read_mod.F90

    r3312 r3406  
    258258          ENDIF
    259259          ierr=NF90_INQUIRE_DIMENSION(nid, ndimid, len=nn)
    260           WRITE(abort_message,'(a,2(i3,a))')'limit.nc records number (',nn,') does no'//&
     260          WRITE(abort_message,'(a,2(i0,a))')'limit.nc records number (',nn,') does no'//&
    261261            't match year length (',year_len,')'
    262262          IF(nn/=year_len) CALL abort_physic(modname,abort_message,1)
     
    288288
    289289    is_modified = .FALSE.
    290     IF (MOD(itime-1, lmt_pas) == 0 .OR. jour_lu /= jour ) THEN   ! time to read
     290!ym    IF (MOD(itime-1, lmt_pas) == 0 .OR. jour_lu /= jour ) THEN   ! time to read
     291!  not REALLY PERIODIC
     292    IF (MOD(itime-1, lmt_pas) == 0) THEN   ! time to read
    291293       jour_lu = jour
    292294       is_modified = .TRUE.
     
    334336
    335337!$OMP MASTER  ! Only master thread
    336        IF (is_mpi_root) THEN ! Only master processus
     338       IF (is_mpi_root) THEN ! Only master processus!
    337339
    338340          ierr = NF90_OPEN ('limit.nc', NF90_NOWRITE, nid)
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/phylmd/pbl_surface_mod.F90

    r3055 r3406  
    18951895               ywindsp, rmu0, yfder, yts, &
    18961896               itap, dtime, jour, knon, ni, &
    1897                ypplay(:,1), zgeo1/RG, ycdragh, ycdragm, yrain_f, ysnow_f, yt(:,1), yq(:,1),&
     1897               ypplay(:,1), zgeo1(1:knon)/RG, ycdragh, ycdragm, yrain_f, ysnow_f, yt(:,1), yq(:,1),&    ! ym missing init
    18981898               AcoefH, AcoefQ, BcoefH, BcoefQ, &
    18991899               AcoefU, AcoefV, BcoefU, BcoefV, &
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/phylmd/phys_cal_mod.F90

    r2802 r3406  
    3737  SUBROUTINE phys_cal_init(annee_ref,day_ref)
    3838
    39     USE IOIPSL, ONLY:  ymds2ju
     39    USE IOIPSL, ONLY:  ymds2ju, ioconf_calendar
     40    USE mod_phys_lmdz_para, ONLY:  is_master,is_omp_master
    4041    USE ioipsl_getin_p_mod, ONLY: getin_p
    4142
     
    4748    calend = 'earth_360d' ! default
    4849    CALL getin_p("calend",calend)
     50
     51    IF (is_omp_master) THEN
     52      IF (calend == 'earth_360d') THEN
     53        CALL ioconf_calendar('360d')
     54      ELSE IF (calend == 'earth_365d') THEN
     55        CALL ioconf_calendar('noleap')
     56      ELSE IF (calend == 'earth_366d') THEN
     57        CALL ioconf_calendar('gregorian')
     58      ELSE
     59        CALL abort_physic('phys_cal_init','Mauvais choix de calendrier',1)
     60      ENDIF
     61    ENDIF
     62!$OMP BARRIER
    4963     
    5064    CALL ymds2ju(annee_ref, 1, day_ref, 0., jD_ref)
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/phylmd/phys_local_var_mod.F90

    r3050 r3406  
    573573      ALLOCATE(dv_gwd_rando(klon,klev),dv_gwd_front(klon,klev))
    574574      ALLOCATE(east_gwstress(klon,klev),west_gwstress(klon,klev))
     575      east_gwstress(:,:)=0 !ym missing init
     576      west_gwstress(:,:)=0 !ym missing init
    575577      ALLOCATE(d_t_hin(klon,klev))
    576578      ALLOCATE(d_q_ch4(klon,klev))
     
    688690!>jyg
    689691      ALLOCATE(dtvdf_x(klon,klev), dtvdf_w(klon,klev))
     692      dtvdf_x = 0 ; dtvdf_w=0 ;   !ym missing init
    690693      ALLOCATE(dqvdf_x(klon,klev), dqvdf_w(klon,klev))
     694      dqvdf_x = 0 ; dqvdf_w=0 ;   !ym missing init
    691695      ALLOCATE(pbl_tke_input(klon,klev+1,nbsrf))
    692696      ALLOCATE(t_therm(klon,klev), q_therm(klon,klev),u_therm(klon,klev), v_therm(klon,klev))
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/phylmd/phys_output_write_mod.F90

    r3003 r3406  
    348348    ! ug Pour les sorties XIOS
    349349    USE xios
    350     USE wxios, ONLY: wxios_closedef, missing_val
     350    USE wxios, ONLY: wxios_closedef, missing_val, wxios_set_context
    351351#endif
    352352    USE phys_cal_mod, ONLY : mth_len
     
    417417    CALL set_itau_iophy(itau_w)
    418418
    419     IF (.NOT.vars_defined) THEN
    420        iinitend = 2
    421     ELSE
     419 !   IF (.NOT.vars_defined) THEN
    422420       iinitend = 1
    423     ENDIF
     421 !   ELSE
     422 !      iinitend = 1
     423 !   ENDIF
     424
     425#ifdef CPP_XIOS
     426    CALL wxios_set_context
     427#endif
    424428
    425429    DO ilev=1,klev
     
    687691       CALL histwrite_phy(o_fsnow, zfra_o)
    688692       CALL histwrite_phy(o_evap, evap)
    689        CALL histwrite_phy(o_tops, topsw*swradcorr)
    690        CALL histwrite_phy(o_tops0, topsw0*swradcorr)
     693
     694       IF (vars_defined) THEN
     695         zx_tmp_fi2d = topsw*swradcorr
     696       ENDIF
     697       CALL histwrite_phy(o_tops, zx_tmp_fi2d)
     698
     699       IF (vars_defined) THEN
     700         zx_tmp_fi2d = topsw0*swradcorr
     701       ENDIF
     702       CALL histwrite_phy(o_tops0, zx_tmp_fi2d)
     703
    691704       CALL histwrite_phy(o_topl, toplw)
    692705       CALL histwrite_phy(o_topl0, toplw0)
     
    716729       ENDIF
    717730       CALL histwrite_phy(o_nettop, zx_tmp_fi2d)
    718        CALL histwrite_phy(o_SWup200, SWup200*swradcorr)
    719        CALL histwrite_phy(o_SWup200clr, SWup200clr*swradcorr)
    720        CALL histwrite_phy(o_SWdn200, SWdn200*swradcorr)
    721        CALL histwrite_phy(o_SWdn200clr, SWdn200clr*swradcorr)
     731       
     732       IF (vars_defined) THEN
     733          zx_tmp_fi2d = SWup200*swradcorr
     734       ENDIF
     735       CALL histwrite_phy(o_SWup200, zx_tmp_fi2d)
     736       
     737       IF (vars_defined) THEN
     738          zx_tmp_fi2d = SWup200clr*swradcorr
     739       ENDIF
     740       CALL histwrite_phy(o_SWup200clr, zx_tmp_fi2d)
     741       
     742       IF (vars_defined) THEN
     743          zx_tmp_fi2d = SWdn200*swradcorr
     744       ENDIF
     745       CALL histwrite_phy(o_SWdn200, zx_tmp_fi2d)
     746       
     747       
     748       IF (vars_defined) THEN
     749          zx_tmp_fi2d = SWdn200clr*swradcorr
     750       ENDIF
     751       CALL histwrite_phy(o_SWdn200clr, zx_tmp_fi2d)
     752       
    722753       CALL histwrite_phy(o_LWup200, LWup200)
    723754       CALL histwrite_phy(o_LWup200clr, LWup200clr)
    724755       CALL histwrite_phy(o_LWdn200, LWdn200)
    725756       CALL histwrite_phy(o_LWdn200clr, LWdn200clr)
    726        CALL histwrite_phy(o_sols, solsw*swradcorr)
    727        CALL histwrite_phy(o_sols0, solsw0*swradcorr)
     757       
     758       IF (vars_defined) THEN
     759          zx_tmp_fi2d = solsw*swradcorr
     760       ENDIF
     761       CALL histwrite_phy(o_sols, zx_tmp_fi2d)
     762       
     763       
     764       IF (vars_defined) THEN
     765          zx_tmp_fi2d = solsw0*swradcorr
     766       ENDIF
     767       CALL histwrite_phy(o_sols0, zx_tmp_fi2d)
    728768       CALL histwrite_phy(o_soll, sollw)
    729769       CALL histwrite_phy(o_soll0, sollw0)
     
    896936       CALL histwrite_phy(o_cldt, cldt)
    897937       CALL histwrite_phy(o_JrNt, JrNt)
    898        CALL histwrite_phy(o_cldljn, cldl*JrNt)
    899        CALL histwrite_phy(o_cldmjn, cldm*JrNt)
    900        CALL histwrite_phy(o_cldhjn, cldh*JrNt)
    901        CALL histwrite_phy(o_cldtjn, cldt*JrNt)
     938       
     939       IF (vars_defined)  zx_tmp_fi2d=cldl*JrNt     
     940       CALL histwrite_phy(o_cldljn, zx_tmp_fi2d)
     941       
     942       IF (vars_defined)  zx_tmp_fi2d=cldm*JrNt     
     943       CALL histwrite_phy(o_cldmjn, zx_tmp_fi2d)
     944       
     945       IF (vars_defined)  zx_tmp_fi2d=cldh*JrNt
     946       CALL histwrite_phy(o_cldhjn, zx_tmp_fi2d)
     947       
     948       IF (vars_defined)  zx_tmp_fi2d=cldt*JrNt
     949       CALL histwrite_phy(o_cldtjn, zx_tmp_fi2d)
     950       
    902951       CALL histwrite_phy(o_cldq, cldq)
    903952       IF (vars_defined)       zx_tmp_fi2d(1:klon) = flwp(1:klon)
     
    10501099             CALL histwrite_phy(o_alp_wk, alp_wake)
    10511100             IF (iflag_pbl_split>=1) THEN
     1101               !ym warning : dtvdf_x, dtvdf_w, dqvdf_x, dqvdf_w are not defined by model
     1102               !ym => init to 0 in phys_local_var_mod
    10521103               IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=dtvdf_x(1:klon,1:klev)/pdtphys
    10531104               CALL histwrite_phy(o_dtvdf_x    ,zx_tmp_fi3d)
     
    10851136             IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_wake(1:klon,1:klev)/pdtphys
    10861137             CALL histwrite_phy(o_dqwak, zx_tmp_fi3d)
    1087              CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
     1138             IF (vars_defined) CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
    10881139             CALL histwrite_phy(o_dqwak2d, zx_tmp_fi2d)
    10891140          ENDIF ! iflag_wake>=1
     
    12511302
    12521303! ThL -- In the following, we assume read_climoz == 1
    1253        zx_tmp_fi2d = 0.0    ! Computation for strato, added ThL
    1254        DO k=1, klev
    1255           zx_tmp_fi2d(:) = zx_tmp_fi2d(:) + wo(:,k,1) * stratomask(:,k) * 1.e3
    1256        END DO
     1304       IF (vars_defined) THEN
     1305         zx_tmp_fi2d = 0.0    ! Computation for strato, added ThL
     1306         DO k=1, klev
     1307            zx_tmp_fi2d(:) = zx_tmp_fi2d(:) + wo(:,k,1) * stratomask(:,k) * 1.e3
     1308         END DO
     1309       ENDIF
    12571310       CALL histwrite_phy(o_col_O3_strato, zx_tmp_fi2d) ! Added ThL
    1258        zx_tmp_fi2d = 0.0    ! Computation for tropo, added ThL
    1259        DO k=1, klev
    1260           zx_tmp_fi2d(:) = zx_tmp_fi2d(:) + wo(:,k,1) * (1.0-stratomask(:,k)) * 1.e3
    1261        END DO
     1311
     1312       IF (vars_defined) THEN
     1313         zx_tmp_fi2d = 0.0    ! Computation for tropo, added ThL
     1314         DO k=1, klev
     1315            zx_tmp_fi2d(:) = zx_tmp_fi2d(:) + wo(:,k,1) * (1.0-stratomask(:,k)) * 1.e3
     1316         END DO
     1317       ENDIF
    12621318       CALL histwrite_phy(o_col_O3_tropo, zx_tmp_fi2d)   ! Added ThL
    12631319! end add ThL
     
    12961352#endif
    12971353       IF (ok_ade) THEN
    1298           CALL histwrite_phy(o_topswad, topswad_aero*swradcorr)
    1299           CALL histwrite_phy(o_topswad0, topswad0_aero*swradcorr)
    1300           CALL histwrite_phy(o_solswad, solswad_aero*swradcorr)
    1301           CALL histwrite_phy(o_solswad0, solswad0_aero*swradcorr)
     1354          IF (vars_defined) zx_tmp_fi2d(:)=topswad_aero*swradcorr
     1355          CALL histwrite_phy(o_topswad, zx_tmp_fi2d)
     1356         
     1357          IF (vars_defined) zx_tmp_fi2d(:)=topswad0_aero*swradcorr
     1358          CALL histwrite_phy(o_topswad0, zx_tmp_fi2d)
     1359                   
     1360          IF (vars_defined) zx_tmp_fi2d(:)=solswad_aero*swradcorr
     1361          CALL histwrite_phy(o_solswad, zx_tmp_fi2d)
     1362                   
     1363          IF (vars_defined) zx_tmp_fi2d(:)=solswad0_aero*swradcorr
     1364          CALL histwrite_phy(o_solswad0, zx_tmp_fi2d)
     1365         
    13021366          IF (type_trac .ne. 'inca') THEN
    13031367             IF (config_inca .ne. 'aeNP') THEN
     
    13101374          !====MS forcing diagnostics
    13111375          IF (new_aod) THEN
    1312              zx_tmp_fi2d(:)=topsw_aero(:,1)*swradcorr(:)
     1376          !ym warning : topsw_aero, solsw_aero, topsw0_aero, solsw0_aero are not defined by model
     1377          !ym => init to 0 in radlwsw_m.F90 ztopsw_aero, zsolsw_aero, ztopsw0_aero, zsolsw0_aero
     1378
     1379             IF (vars_defined) zx_tmp_fi2d(:)=topsw_aero(:,1)*swradcorr(:)
    13131380             CALL histwrite_phy(o_swtoaas_nat,zx_tmp_fi2d)
    1314              zx_tmp_fi2d(:)=solsw_aero(:,1)*swradcorr(:)
     1381             IF (vars_defined) zx_tmp_fi2d(:)=solsw_aero(:,1)*swradcorr(:)
    13151382             CALL histwrite_phy(o_swsrfas_nat,zx_tmp_fi2d)
    1316              zx_tmp_fi2d(:)=topsw0_aero(:,1)*swradcorr(:)
     1383             IF (vars_defined) zx_tmp_fi2d(:)=topsw0_aero(:,1)*swradcorr(:)
    13171384             CALL histwrite_phy(o_swtoacs_nat,zx_tmp_fi2d)
    1318              zx_tmp_fi2d(:)=solsw0_aero(:,1)*swradcorr(:)
     1385             IF (vars_defined) zx_tmp_fi2d(:)=solsw0_aero(:,1)*swradcorr(:)
    13191386             CALL histwrite_phy(o_swsrfcs_nat,zx_tmp_fi2d)
    13201387             !ant
    1321              zx_tmp_fi2d(:)=topsw_aero(:,2)*swradcorr(:)
     1388             IF (vars_defined) zx_tmp_fi2d(:)=topsw_aero(:,2)*swradcorr(:)
    13221389             CALL histwrite_phy(o_swtoaas_ant,zx_tmp_fi2d)
    1323              zx_tmp_fi2d(:)=solsw_aero(:,2)*swradcorr(:)
     1390             IF (vars_defined) zx_tmp_fi2d(:)=solsw_aero(:,2)*swradcorr(:)
    13241391             CALL histwrite_phy(o_swsrfas_ant,zx_tmp_fi2d)
    1325              zx_tmp_fi2d(:)=topsw0_aero(:,2)*swradcorr(:)
     1392             IF (vars_defined) zx_tmp_fi2d(:)=topsw0_aero(:,2)*swradcorr(:)
    13261393             CALL histwrite_phy(o_swtoacs_ant,zx_tmp_fi2d)
    1327              zx_tmp_fi2d(:)=solsw0_aero(:,2)*swradcorr(:)
     1394             IF (vars_defined) zx_tmp_fi2d(:)=solsw0_aero(:,2)*swradcorr(:)
    13281395             CALL histwrite_phy(o_swsrfcs_ant,zx_tmp_fi2d)
    13291396             !cf
    13301397             IF (.not. aerosol_couple) THEN
    1331                 zx_tmp_fi2d(:)=topswcf_aero(:,1)*swradcorr(:)
     1398                IF (vars_defined) zx_tmp_fi2d(:)=topswcf_aero(:,1)*swradcorr(:)
    13321399                CALL histwrite_phy(o_swtoacf_nat,zx_tmp_fi2d)
    1333                 zx_tmp_fi2d(:)=solswcf_aero(:,1)*swradcorr(:)
     1400                IF (vars_defined) zx_tmp_fi2d(:)=solswcf_aero(:,1)*swradcorr(:)
    13341401                CALL histwrite_phy(o_swsrfcf_nat,zx_tmp_fi2d)
    1335                 zx_tmp_fi2d(:)=topswcf_aero(:,2)*swradcorr(:)
     1402                IF (vars_defined) zx_tmp_fi2d(:)=topswcf_aero(:,2)*swradcorr(:)
    13361403                CALL histwrite_phy(o_swtoacf_ant,zx_tmp_fi2d)
    1337                 zx_tmp_fi2d(:)=solswcf_aero(:,2)*swradcorr(:)
     1404                IF (vars_defined) zx_tmp_fi2d(:)=solswcf_aero(:,2)*swradcorr(:)
    13381405                CALL histwrite_phy(o_swsrfcf_ant,zx_tmp_fi2d)
    1339                 zx_tmp_fi2d(:)=topswcf_aero(:,3)*swradcorr(:)
     1406                IF (vars_defined) zx_tmp_fi2d(:)=topswcf_aero(:,3)*swradcorr(:)
    13401407                CALL histwrite_phy(o_swtoacf_zero,zx_tmp_fi2d)
    1341                 zx_tmp_fi2d(:)=solswcf_aero(:,3)*swradcorr(:)
     1408                IF (vars_defined) zx_tmp_fi2d(:)=solswcf_aero(:,3)*swradcorr(:)
    13421409                CALL histwrite_phy(o_swsrfcf_zero,zx_tmp_fi2d)
    13431410             ENDIF
     
    13461413       ENDIF
    13471414       IF (ok_aie) THEN
    1348           CALL histwrite_phy(o_topswai, topswai_aero*swradcorr)
    1349           CALL histwrite_phy(o_toplwai, toplwai_aero*swradcorr)
    1350           CALL histwrite_phy(o_solswai, solswai_aero*swradcorr)
    1351           CALL histwrite_phy(o_sollwai, sollwai_aero*swradcorr)
     1415          IF (vars_defined) zx_tmp_fi2d(:)= topswai_aero*swradcorr
     1416          CALL histwrite_phy(o_topswai, zx_tmp_fi2d)
     1417         
     1418          IF (vars_defined) zx_tmp_fi2d(:)=toplwai_aero*swradcorr
     1419          CALL histwrite_phy(o_toplwai, zx_tmp_fi2d)
     1420         
     1421          IF (vars_defined) zx_tmp_fi2d(:)=solswai_aero*swradcorr
     1422          CALL histwrite_phy(o_solswai, zx_tmp_fi2d)
     1423         
     1424          IF (vars_defined) zx_tmp_fi2d(:)=sollwai_aero*swradcorr
     1425          CALL histwrite_phy(o_sollwai, zx_tmp_fi2d)
    13521426       ENDIF
    13531427       IF (flag_aerosol.GT.0.AND.ok_cdnc) THEN
     
    13741448       CALL histwrite_phy(o_ovap, q_seri)
    13751449       CALL histwrite_phy(o_oliq, ql_seri)
    1376        CALL histwrite_phy(o_ocond, ql_seri+qs_seri)
     1450
     1451       IF (vars_defined) zx_tmp_fi3d = ql_seri+qs_seri
     1452       CALL histwrite_phy(o_ocond, zx_tmp_fi3d)
     1453
    13771454       CALL histwrite_phy(o_geop, zphi)
    13781455       CALL histwrite_phy(o_vitu, u_seri)
     
    13811458       CALL histwrite_phy(o_pres, pplay)
    13821459       CALL histwrite_phy(o_paprs, paprs(:,1:klev))
    1383        CALL histwrite_phy(o_zfull,zphi/RG)
     1460       
     1461       IF (vars_defined) zx_tmp_fi3d = zphi/RG
     1462       CALL histwrite_phy(o_zfull,zx_tmp_fi3d)
    13841463
    13851464       IF (flag_aerosol_strat.EQ.2) THEN
     
    14111490       CALL histwrite_phy(o_rnebjn, zx_tmp_fi3d)
    14121491       CALL histwrite_phy(o_rhum, zx_rh)
    1413        CALL histwrite_phy(o_ozone, &
    1414             wo(:, :, 1) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
     1492       
     1493       IF (vars_defined) zx_tmp_fi3d = wo(:, :, 1) * dobson_u * 1e3 / zmasse / rmo3 * rmd
     1494       CALL histwrite_phy(o_ozone, zx_tmp_fi3d)
    14151495
    14161496       IF (read_climoz == 2) THEN
    1417           CALL histwrite_phy(o_ozone_light, &
    1418                wo(:, :, 2) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
     1497         IF (vars_defined) zx_tmp_fi3d = wo(:, :, 2) * dobson_u * 1e3 / zmasse / rmo3 * rmd
     1498         CALL histwrite_phy(o_ozone_light, zx_tmp_fi3d)
    14191499       ENDIF
    14201500
     
    14241504
    14251505       CALL histwrite_phy(o_dqphy,  d_qx(:,:,ivap))
    1426        CALL water_int(klon,klev,d_qx(:,:,ivap),zmasse,zx_tmp_fi2d)
     1506       IF (vars_defined) CALL water_int(klon,klev,d_qx(:,:,ivap),zmasse,zx_tmp_fi2d)
    14271507       CALL histwrite_phy(o_dqphy2d,  zx_tmp_fi2d)
    14281508
    14291509       CALL histwrite_phy(o_dqlphy,  d_qx(:,:,iliq))
    1430        CALL water_int(klon,klev,d_qx(:,:,iliq),zmasse,zx_tmp_fi2d)
     1510       IF (vars_defined) CALL water_int(klon,klev,d_qx(:,:,iliq),zmasse,zx_tmp_fi2d)
    14311511       CALL histwrite_phy(o_dqlphy2d,  zx_tmp_fi2d)
    14321512
    14331513       IF (nqo.EQ.3) THEN
    14341514       CALL histwrite_phy(o_dqsphy,  d_qx(:,:,isol))
    1435        CALL water_int(klon,klev,d_qx(:,:,isol),zmasse,zx_tmp_fi2d)
     1515       IF (vars_defined) CALL water_int(klon,klev,d_qx(:,:,isol),zmasse,zx_tmp_fi2d)
    14361516       CALL histwrite_phy(o_dqsphy2d,  zx_tmp_fi2d)
    14371517       ELSE
     
    15181598       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
    15191599       CALL histwrite_phy(o_dqcon, zx_tmp_fi3d)
    1520        CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
     1600       IF (vars_defined) CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
    15211601       CALL histwrite_phy(o_dqcon2d, zx_tmp_fi2d)
    15221602
     
    15401620       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys
    15411621       CALL histwrite_phy(o_dqlsc, zx_tmp_fi3d)
    1542        CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
     1622       IF (vars_defined) CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
    15431623       CALL histwrite_phy(o_dqlsc2d, zx_tmp_fi2d)
    15441624       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=beta_prec(1:klon,1:klev)
     
    15531633          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_lscth(1:klon,1:klev)/pdtphys
    15541634          CALL histwrite_phy(o_dqlscth, zx_tmp_fi3d)
    1555           CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
     1635          IF (vars_defined) CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
    15561636          CALL histwrite_phy(o_dqlscth2d, zx_tmp_fi2d)
    15571637          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_lscst(1:klon,1:klev)/pdtphys
    15581638          CALL histwrite_phy(o_dqlscst, zx_tmp_fi3d)
    1559           CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
     1639          IF (vars_defined) CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
    15601640          CALL histwrite_phy(o_dqlscst2d, zx_tmp_fi2d)
    15611641          CALL histwrite_phy(o_plulth, plul_th)
     
    15871667       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_vdf(1:klon,1:klev)/pdtphys
    15881668       CALL histwrite_phy(o_dqvdf, zx_tmp_fi3d)
    1589        CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
     1669       IF (vars_defined) CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
    15901670       CALL histwrite_phy(o_dqvdf2d, zx_tmp_fi2d)
    15911671       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_eva(1:klon,1:klev)/pdtphys
     
    15931673       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_eva(1:klon,1:klev)/pdtphys
    15941674       CALL histwrite_phy(o_dqeva, zx_tmp_fi3d)
    1595        CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
     1675       IF (vars_defined) CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
    15961676       CALL histwrite_phy(o_dqeva2d, zx_tmp_fi2d)
    15971677       zpt_conv = 0.
     
    16341714          ENDIF
    16351715          CALL histwrite_phy(o_dqthe, zx_tmp_fi3d)
    1636           CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
     1716          IF (vars_defined) CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
    16371717          CALL histwrite_phy(o_dqthe2d, zx_tmp_fi2d)
    16381718       ENDIF !iflag_thermals
     
    16411721       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_ajsb(1:klon,1:klev)/pdtphys
    16421722       CALL histwrite_phy(o_dqajs, zx_tmp_fi3d)
    1643        CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
     1723       IF (vars_defined) CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
    16441724       CALL histwrite_phy(o_dqajs2d, zx_tmp_fi2d)
    16451725       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_swr(1:klon,1:klev)/pdtphys
     
    16771757
    16781758       IF (ok_hines) THEN
    1679           CALL histwrite_phy(o_du_gwd_hines, du_gwd_hines/pdtphys)
    1680           CALL histwrite_phy(o_dv_gwd_hines, dv_gwd_hines/pdtphys)
     1759          IF (vars_defined) zx_tmp_fi3d=du_gwd_hines/pdtphys
     1760          CALL histwrite_phy(o_du_gwd_hines, zx_tmp_fi3d)
     1761
     1762          IF (vars_defined) zx_tmp_fi3d= dv_gwd_hines/pdtphys         
     1763          CALL histwrite_phy(o_dv_gwd_hines, zx_tmp_fi3d)
     1764         
    16811765          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_hin(1:klon,1:klev)/pdtphys
    16821766          CALL histwrite_phy(o_dthin, zx_tmp_fi3d)
     
    16861770
    16871771       IF (.not. ok_hines .and. ok_gwd_rando) THEN
    1688           CALL histwrite_phy(o_du_gwd_front, du_gwd_front / pdtphys)
    1689           CALL histwrite_phy(o_dv_gwd_front, dv_gwd_front / pdtphys)
     1772          IF (vars_defined)  zx_tmp_fi3d=du_gwd_front / pdtphys
     1773          CALL histwrite_phy(o_du_gwd_front, zx_tmp_fi3d)
     1774         
     1775          IF (vars_defined)  zx_tmp_fi3d=dv_gwd_front / pdtphys
     1776          CALL histwrite_phy(o_dv_gwd_front, zx_tmp_fi3d)
     1777         
    16901778          CALL histwrite_phy(o_ustr_gwd_front, zustr_gwd_front)
    16911779          CALL histwrite_phy(o_vstr_gwd_front, zvstr_gwd_front)
     
    16931781
    16941782       IF (ok_gwd_rando) THEN
    1695           CALL histwrite_phy(o_du_gwd_rando, du_gwd_rando / pdtphys)
    1696           CALL histwrite_phy(o_dv_gwd_rando, dv_gwd_rando / pdtphys)
     1783          IF (vars_defined)  zx_tmp_fi3d=du_gwd_rando / pdtphys
     1784          CALL histwrite_phy(o_du_gwd_rando, zx_tmp_fi3d)
     1785         
     1786          IF (vars_defined)  zx_tmp_fi3d=dv_gwd_rando / pdtphys
     1787          CALL histwrite_phy(o_dv_gwd_rando, zx_tmp_fi3d)
    16971788          CALL histwrite_phy(o_ustr_gwd_rando, zustr_gwd_rando)
    16981789          CALL histwrite_phy(o_vstr_gwd_rando, zvstr_gwd_rando)
     
    17021793
    17031794       IF (ok_qch4) THEN
    1704           CALL histwrite_phy(o_dqch4, d_q_ch4 / pdtphys)
    1705        ENDIF
    1706 
    1707        DO k=1, klevp1
    1708          zx_tmp_fi3d1(:,k)=swup(:,k)*swradcorr(:)
    1709        ENDDO
     1795          IF (vars_defined) zx_tmp_fi3d=d_q_ch4 / pdtphys
     1796          CALL histwrite_phy(o_dqch4, zx_tmp_fi3d)
     1797       ENDIF
     1798       
     1799       IF (vars_defined) THEN
     1800         DO k=1, klevp1
     1801           zx_tmp_fi3d1(:,k)=swup(:,k)*swradcorr(:)
     1802         ENDDO
     1803       ENDIF
     1804       
    17101805       CALL histwrite_phy(o_rsu, zx_tmp_fi3d1)
    1711        DO k=1, klevp1
    1712          zx_tmp_fi3d1(:,k)=swdn(:,k)*swradcorr(:)
    1713        ENDDO
     1806
     1807
     1808       IF (vars_defined) THEN
     1809         DO k=1, klevp1
     1810           zx_tmp_fi3d1(:,k)=swdn(:,k)*swradcorr(:)
     1811         ENDDO
     1812       ENDIF
     1813       
    17141814       CALL histwrite_phy(o_rsd, zx_tmp_fi3d1)
    1715        DO k=1, klevp1
    1716          zx_tmp_fi3d1(:,k)=swup0(:,k)*swradcorr(:)
    1717        ENDDO
     1815
     1816       IF (vars_defined) THEN
     1817         DO k=1, klevp1
     1818           zx_tmp_fi3d1(:,k)=swup0(:,k)*swradcorr(:)
     1819         ENDDO
     1820       ENDIF
     1821       
    17181822       CALL histwrite_phy(o_rsucs, zx_tmp_fi3d1)
    1719        DO k=1, klevp1
    1720          zx_tmp_fi3d1(:,k)=swdn0(:,k)*swradcorr(:)
    1721        ENDDO
     1823
     1824       IF (vars_defined) THEN
     1825         DO k=1, klevp1
     1826           zx_tmp_fi3d1(:,k)=swdn0(:,k)*swradcorr(:)
     1827         ENDDO
     1828       ENDIF
    17221829       CALL histwrite_phy(o_rsdcs, zx_tmp_fi3d1)
    17231830
     
    17731880       ELSE IF (iflag_con == 2) THEN
    17741881          CALL histwrite_phy(o_mcd,  pmfd)
    1775           CALL histwrite_phy(o_dmc,  pmfu + pmfd)
     1882          IF (vars_defined) zx_tmp_fi3d = pmfu + pmfd
     1883          CALL histwrite_phy(o_dmc,  zx_tmp_fi3d)
    17761884       ENDIF
    17771885       CALL histwrite_phy(o_ref_liq, ref_liq)
     
    19542062            IF (type_trac == 'lmdz' .OR. type_trac == 'repr' .OR. type_trac == 'coag') THEN
    19552063             !--3D fields
    1956              CALL histwrite_phy(o_trac(iq-nqo), tr_seri(:,:,iq-nqo))
    1957              CALL histwrite_phy(o_dtr_vdf(iq-nqo),d_tr_cl(:,:,iq-nqo))
    1958              CALL histwrite_phy(o_dtr_the(iq-nqo),d_tr_th(:,:,iq-nqo))
    1959              CALL histwrite_phy(o_dtr_con(iq-nqo),d_tr_cv(:,:,iq-nqo))
    1960              CALL histwrite_phy(o_dtr_lessi_impa(iq-nqo),d_tr_lessi_impa(:,:,iq-nqo))
    1961              CALL histwrite_phy(o_dtr_lessi_nucl(iq-nqo),d_tr_lessi_nucl(:,:,iq-nqo))
    1962              CALL histwrite_phy(o_dtr_insc(iq-nqo),d_tr_insc(:,:,iq-nqo))
    1963              CALL histwrite_phy(o_dtr_bcscav(iq-nqo),d_tr_bcscav(:,:,iq-nqo))
    1964              CALL histwrite_phy(o_dtr_evapls(iq-nqo),d_tr_evapls(:,:,iq-nqo))
    1965              CALL histwrite_phy(o_dtr_ls(iq-nqo),d_tr_ls(:,:,iq-nqo))
    1966              CALL histwrite_phy(o_dtr_trsp(iq-nqo),d_tr_trsp(:,:,iq-nqo))
    1967              CALL histwrite_phy(o_dtr_sscav(iq-nqo),d_tr_sscav(:,:,iq-nqo))
    1968              CALL histwrite_phy(o_dtr_sat(iq-nqo),d_tr_sat(:,:,iq-nqo))
    1969              CALL histwrite_phy(o_dtr_uscav(iq-nqo),d_tr_uscav(:,:,iq-nqo))
     2064!             CALL histwrite_phy(o_trac(iq-nqo), tr_seri(:,:,iq-nqo))
     2065!             CALL histwrite_phy(o_dtr_vdf(iq-nqo),d_tr_cl(:,:,iq-nqo))
     2066!             CALL histwrite_phy(o_dtr_the(iq-nqo),d_tr_th(:,:,iq-nqo))
     2067!             CALL histwrite_phy(o_dtr_con(iq-nqo),d_tr_cv(:,:,iq-nqo))
     2068!             CALL histwrite_phy(o_dtr_lessi_impa(iq-nqo),d_tr_lessi_impa(:,:,iq-nqo))
     2069!             CALL histwrite_phy(o_dtr_lessi_nucl(iq-nqo),d_tr_lessi_nucl(:,:,iq-nqo))
     2070!             CALL histwrite_phy(o_dtr_insc(iq-nqo),d_tr_insc(:,:,iq-nqo))
     2071!             CALL histwrite_phy(o_dtr_bcscav(iq-nqo),d_tr_bcscav(:,:,iq-nqo))
     2072!             CALL histwrite_phy(o_dtr_evapls(iq-nqo),d_tr_evapls(:,:,iq-nqo))
     2073!             CALL histwrite_phy(o_dtr_ls(iq-nqo),d_tr_ls(:,:,iq-nqo))
     2074!             CALL histwrite_phy(o_dtr_trsp(iq-nqo),d_tr_trsp(:,:,iq-nqo))
     2075!             CALL histwrite_phy(o_dtr_sscav(iq-nqo),d_tr_sscav(:,:,iq-nqo))
     2076!             CALL histwrite_phy(o_dtr_sat(iq-nqo),d_tr_sat(:,:,iq-nqo))
     2077!             CALL histwrite_phy(o_dtr_uscav(iq-nqo),d_tr_uscav(:,:,iq-nqo))
    19702078             !--2D fields
    1971              CALL histwrite_phy(o_dtr_dry(iq-nqo), flux_tr_dry(:,iq-nqo))
     2079!             CALL histwrite_phy(o_dtr_dry(iq-nqo), flux_tr_dry(:,iq-nqo))
    19722080             zx_tmp_fi2d=0.
    19732081             IF (vars_defined) THEN
     
    19762084                ENDDO
    19772085             ENDIF
    1978              CALL histwrite_phy(o_trac_cum(iq-nqo), zx_tmp_fi2d)
     2086!             CALL histwrite_phy(o_trac_cum(iq-nqo), zx_tmp_fi2d)
    19792087            ENDIF
    19802088          ENDDO
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/phylmd/phys_state_var_mod.F90

    r3312 r3406  
    607607        du_gwd_rando(:,:)=0.
    608608      ENDIF
    609       if (.not. ok_hines .and. ok_gwd_rando) allocate(du_gwd_front(klon, klev))
    610 
     609      IF (.not. ok_hines .and. ok_gwd_rando) THEN
     610        ALLOCATE(du_gwd_front(klon, klev))
     611        du_gwd_front(:,:) = 0 !ym missing init   
     612      ENDIF
    611613END SUBROUTINE phys_state_var_init
    612614
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/phylmd/physiq_mod.F90

    r3322 r3406  
    2525    USE dimphy
    2626    USE infotrac_phy, ONLY: nqtot, nbtr, nqo, type_trac
    27     USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev, klon_glo
     27    USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev, klon_glo, grid1dTo2d_glo, grid_type, unstructured
    2828    USE mod_phys_lmdz_para
    2929    USE iophy
     
    252252    use ACAMA_GWD_rando_m, only: ACAMA_GWD_rando
    253253    USE VERTICAL_LAYERS_MOD, ONLY: aps,bps
     254    USE etat0_limit_unstruct_mod
     255#ifdef CPP_XIOS
     256    USE xios, ONLY: xios_update_calendar, xios_context_finalize
     257#endif
     258    USE climoz_mod
     259    USE limit_read_mod, ONLY : init_limit_read
     260    USE regr_horiz_time_climoz_m, ONLY: regr_horiz_time_climoz
    254261
    255262
     
    11291136    CALL update_time(pdtphys)
    11301137    phys_tstep=NINT(pdtphys)
     1138#ifdef CPP_XIOS
     1139    IF (.NOT. debut .AND. is_omp_master) CALL xios_update_calendar(itap+1)
     1140#endif
    11311141
    11321142    !======================================================================
     
    11611171
    11621172    IF (first) THEN
     1173       CALL init_etat0_limit_unstruct
     1174       IF (.NOT. create_etat0_limit) CALL init_limit_read(days_elapsed)
    11631175       !CR:nvelles variables convection/poches froides
    11641176
     
    11841196       CALL phys_state_var_init(read_climoz)
    11851197       CALL phys_output_var_init
     1198       IF(read_climoz>=1 .AND. create_etat0_limit) CALL regr_horiz_time_climoz(read_climoz,ok_daily_climoz)
     1199
    11861200       print*, '================================================='
    11871201       !
     
    13941408       CALL init_iophy_new(latitude_deg,longitude_deg)
    13951409
    1396 
     1410          !===================================================================
     1411          !IM stations CFMIP
     1412          nCFMIP=npCFMIP
     1413          OPEN(98,file='npCFMIP_param.data',status='old', &
     1414               form='formatted',iostat=iostat)
     1415          IF (iostat == 0) THEN
     1416             READ(98,*,end=998) nCFMIP
     1417998          CONTINUE
     1418             CLOSE(98)
     1419             CONTINUE
     1420             IF(nCFMIP.GT.npCFMIP) THEN
     1421                print*,'nCFMIP > npCFMIP : augmenter npCFMIP et recompiler'
     1422                CALL abort_physic("physiq", "", 1)
     1423             ELSE
     1424                print*,'physiq npCFMIP=',npCFMIP,'nCFMIP=',nCFMIP
     1425             ENDIF
     1426
     1427             !
     1428             ALLOCATE(tabCFMIP(nCFMIP))
     1429             ALLOCATE(lonCFMIP(nCFMIP), latCFMIP(nCFMIP))
     1430             ALLOCATE(tabijGCM(nCFMIP))
     1431             ALLOCATE(lonGCM(nCFMIP), latGCM(nCFMIP))
     1432             ALLOCATE(iGCM(nCFMIP), jGCM(nCFMIP))
     1433             !
     1434             ! lecture des nCFMIP stations CFMIP, de leur numero
     1435             ! et des coordonnees geographiques lonCFMIP, latCFMIP
     1436             !
     1437             CALL read_CFMIP_point_locations(nCFMIP, tabCFMIP,  &
     1438                  lonCFMIP, latCFMIP)
     1439             !
     1440             ! identification des
     1441             ! 1) coordonnees lonGCM, latGCM des points CFMIP dans la
     1442             ! grille de LMDZ
     1443             ! 2) indices points tabijGCM de la grille physique 1d sur
     1444             ! klon points
     1445             ! 3) indices iGCM, jGCM de la grille physique 2d
     1446             !
     1447             CALL LMDZ_CFMIP_point_locations(nCFMIP, lonCFMIP, latCFMIP, &
     1448                  tabijGCM, lonGCM, latGCM, iGCM, jGCM)
     1449             !
     1450          ELSE
     1451             ALLOCATE(tabijGCM(0))
     1452             ALLOCATE(lonGCM(0), latGCM(0))
     1453             ALLOCATE(iGCM(0), jGCM(0))
     1454          ENDIF
     1455
     1456#ifdef CPP_IOIPSL
     1457
     1458       !$OMP MASTER
     1459       ! FH : if ok_sync=.true. , the time axis is written at each time step
     1460       ! in the output files. Only at the end in the opposite case
     1461       ok_sync_omp=.false.
     1462       CALL getin('ok_sync',ok_sync_omp)
     1463       CALL phys_output_open(longitude_deg,latitude_deg,nCFMIP,tabijGCM, &
     1464            iGCM,jGCM,lonGCM,latGCM, &
     1465            jjmp1,nlevSTD,clevSTD,rlevSTD, phys_tstep,ok_veget, &
     1466            type_ocean,iflag_pbl,iflag_pbl_split,ok_mensuel,ok_journe, &
     1467            ok_hf,ok_instan,ok_LES,ok_ade,ok_aie, &
     1468            read_climoz, phys_out_filestations, &
     1469            new_aod, aerosol_couple, &
     1470            flag_aerosol_strat, pdtphys, paprs, pphis,  &
     1471            pplay, lmax_th, ptconv, ptconvth, ivap,  &
     1472            d_u, d_t, qx, d_qx, zmasse, ok_sync_omp)
     1473       !$OMP END MASTER
     1474       !$OMP BARRIER
     1475       ok_sync=ok_sync_omp
     1476
     1477       freq_outNMC(1) = ecrit_files(7)
     1478       freq_outNMC(2) = ecrit_files(8)
     1479       freq_outNMC(3) = ecrit_files(9)
     1480       WRITE(lunout,*)'OK freq_outNMC(1)=',freq_outNMC(1)
     1481       WRITE(lunout,*)'OK freq_outNMC(2)=',freq_outNMC(2)
     1482       WRITE(lunout,*)'OK freq_outNMC(3)=',freq_outNMC(3)
     1483
     1484#ifndef CPP_XIOS
     1485       CALL ini_paramLMDZ_phy(phys_tstep,nid_ctesGCM)
     1486#endif
     1487
     1488#endif
     1489       ecrit_reg = ecrit_reg * un_jour
     1490       ecrit_tra = ecrit_tra * un_jour
     1491
     1492       !XXXPB Positionner date0 pour initialisation de ORCHIDEE
     1493       date0 = jD_ref
     1494       WRITE(*,*) 'physiq date0 : ',date0
     1495       !
     1496
     1497!       CALL create_climoz(read_climoz)
     1498
     1499       CALL phys_output_write(itap, pdtphys, paprs, pphis,                    &
     1500                              pplay, lmax_th, aerosol_couple,                 &
     1501                              ok_ade, ok_aie, ivap, iliq, isol, new_aod, ok_sync,&
     1502                              ptconv, read_climoz, clevSTD,                   &
     1503                              ptconvth, d_u, d_t, qx, d_qx, zmasse,           &
     1504                              flag_aerosol, flag_aerosol_strat, ok_cdnc)
     1505
     1506#ifdef CPP_XIOS
     1507       IF (is_omp_master) CALL xios_update_calendar(1)
     1508#endif
     1509       IF(read_climoz>=1 .AND. create_etat0_limit) CALL regr_horiz_time_climoz(read_climoz,ok_daily_climoz)
     1510       CALL create_etat0_limit_unstruct
    13971511       CALL phyetat0 ("startphy.nc",clesphy0,tabcntr0)
     1512
    13981513!jyg<
    13991514       IF (klon_glo==1) THEN
     
    14051520            ENDDO
    14061521          ENDDO
     1522        ELSE
     1523          pbl_tke(:,:,is_ave) = 0. !ym missing init : maybe must be initialized in the same way that for klon_glo==1 ??
    14071524!>jyg
    14081525       ENDIF
     
    14211538       ENDIF
    14221539
    1423        CALL printflag( tabcntr0,radpas,ok_journe, &
    1424             ok_instan, ok_region )
    1425        !
    14261540!       IF (ABS(phys_tstep-pdtphys).GT.0.001) THEN
    14271541!          WRITE(lunout,*) 'Pas physique n est pas correct',phys_tstep, &
     
    15061620          !        enddo
    15071621
    1508           !===================================================================
    1509           !IM stations CFMIP
    1510           nCFMIP=npCFMIP
    1511           OPEN(98,file='npCFMIP_param.data',status='old', &
    1512                form='formatted',iostat=iostat)
    1513           IF (iostat == 0) THEN
    1514              READ(98,*,end=998) nCFMIP
    1515 998          CONTINUE
    1516              CLOSE(98)
    1517              CONTINUE
    1518              IF(nCFMIP.GT.npCFMIP) THEN
    1519                 print*,'nCFMIP > npCFMIP : augmenter npCFMIP et recompiler'
    1520                 CALL abort_physic("physiq", "", 1)
    1521              ELSE
    1522                 print*,'physiq npCFMIP=',npCFMIP,'nCFMIP=',nCFMIP
    1523              ENDIF
    1524 
    1525              !
    1526              ALLOCATE(tabCFMIP(nCFMIP))
    1527              ALLOCATE(lonCFMIP(nCFMIP), latCFMIP(nCFMIP))
    1528              ALLOCATE(tabijGCM(nCFMIP))
    1529              ALLOCATE(lonGCM(nCFMIP), latGCM(nCFMIP))
    1530              ALLOCATE(iGCM(nCFMIP), jGCM(nCFMIP))
    1531              !
    1532              ! lecture des nCFMIP stations CFMIP, de leur numero
    1533              ! et des coordonnees geographiques lonCFMIP, latCFMIP
    1534              !
    1535              CALL read_CFMIP_point_locations(nCFMIP, tabCFMIP,  &
    1536                   lonCFMIP, latCFMIP)
    1537              !
    1538              ! identification des
    1539              ! 1) coordonnees lonGCM, latGCM des points CFMIP dans la
    1540              ! grille de LMDZ
    1541              ! 2) indices points tabijGCM de la grille physique 1d sur
    1542              ! klon points
    1543              ! 3) indices iGCM, jGCM de la grille physique 2d
    1544              !
    1545              CALL LMDZ_CFMIP_point_locations(nCFMIP, lonCFMIP, latCFMIP, &
    1546                   tabijGCM, lonGCM, latGCM, iGCM, jGCM)
    1547              !
    1548           ELSE
    1549              ALLOCATE(tabijGCM(0))
    1550              ALLOCATE(lonGCM(0), latGCM(0))
    1551              ALLOCATE(iGCM(0), jGCM(0))
    1552           ENDIF
    1553        ELSE
    1554           ALLOCATE(tabijGCM(0))
    1555           ALLOCATE(lonGCM(0), latGCM(0))
    1556           ALLOCATE(iGCM(0), jGCM(0))
     1622       !ELSE
     1623       !   ALLOCATE(tabijGCM(0))
     1624       !   ALLOCATE(lonGCM(0), latGCM(0))
     1625       !   ALLOCATE(iGCM(0), jGCM(0))
    15571626       ENDIF
    15581627
     
    16421711#endif
    16431712
    1644 #ifdef CPP_IOIPSL
    1645 
    1646        !$OMP MASTER
    1647        ! FH : if ok_sync=.true. , the time axis is written at each time step
    1648        ! in the output files. Only at the end in the opposite case
    1649        ok_sync_omp=.false.
    1650        CALL getin('ok_sync',ok_sync_omp)
    1651        CALL phys_output_open(longitude_deg,latitude_deg,nCFMIP,tabijGCM, &
    1652             iGCM,jGCM,lonGCM,latGCM, &
    1653             jjmp1,nlevSTD,clevSTD,rlevSTD, phys_tstep,ok_veget, &
    1654             type_ocean,iflag_pbl,iflag_pbl_split,ok_mensuel,ok_journe, &
    1655             ok_hf,ok_instan,ok_LES,ok_ade,ok_aie, &
    1656             read_climoz, phys_out_filestations, &
    1657             new_aod, aerosol_couple, &
    1658             flag_aerosol_strat, pdtphys, paprs, pphis,  &
    1659             pplay, lmax_th, ptconv, ptconvth, ivap,  &
    1660             d_u, d_t, qx, d_qx, zmasse, ok_sync_omp)
    1661        !$OMP END MASTER
    1662        !$OMP BARRIER
    1663        ok_sync=ok_sync_omp
    1664 
    1665        freq_outNMC(1) = ecrit_files(7)
    1666        freq_outNMC(2) = ecrit_files(8)
    1667        freq_outNMC(3) = ecrit_files(9)
    1668        WRITE(lunout,*)'OK freq_outNMC(1)=',freq_outNMC(1)
    1669        WRITE(lunout,*)'OK freq_outNMC(2)=',freq_outNMC(2)
    1670        WRITE(lunout,*)'OK freq_outNMC(3)=',freq_outNMC(3)
    1671 
    1672 #ifndef CPP_XIOS
    1673        CALL ini_paramLMDZ_phy(phys_tstep,nid_ctesGCM)
    1674 #endif
    1675 
    1676 #endif
    1677        ecrit_reg = ecrit_reg * un_jour
    1678        ecrit_tra = ecrit_tra * un_jour
    1679 
    1680        !XXXPB Positionner date0 pour initialisation de ORCHIDEE
    1681        date0 = jD_ref
    1682        WRITE(*,*) 'physiq date0 : ',date0
     1713
     1714       CALL printflag( tabcntr0,radpas,ok_journe, &
     1715            ok_instan, ok_region )
    16831716       !
    16841717       !
     
    22072240       !
    22082241       !-------gustiness calculation-------!
     2242       !ym : Warning gustiness non inialized for iflag_gusts=2 & iflag_gusts=3
     2243       gustiness=0  !ym missing init
     2244       
    22092245       IF (iflag_gusts==0) THEN
    22102246          gustiness(1:klon)=0
     
    40344070
    40354071    IF (.not. ok_hines .and. ok_gwd_rando) then
     4072       ! ym missing init for east_gwstress & west_gwstress -> added in phys_local_var_mod
    40364073       CALL acama_GWD_rando(PHYS_TSTEP, pplay, latitude_deg, t_seri, u_seri, &
    40374074            v_seri, rot, zustr_gwd_front, zvstr_gwd_front, du_gwd_front, &
     
    46964733       !         write(97) u_seri,v_seri,t_seri,q_seri
    46974734       !         close(97)
    4698        !$OMP MASTER
     4735!       !$OMP MASTER
    46994736       IF (read_climoz >= 1) THEN
    47004737          IF (is_mpi_root) THEN
     
    47044741          DEALLOCATE(press_cen_climoz) ! pointer
    47054742       ENDIF
    4706        !$OMP END MASTER
     4743!       !$OMP END MASTER
     4744#ifdef CPP_XIOS
     4745       IF (is_omp_master) CALL xios_context_finalize
     4746#endif
    47074747    ENDIF
    47084748
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/phylmd/radlwsw_m.F90

    r2611 r3406  
    384384  cgaero(:,:,:,:)=0.
    385385  lldebug=.FALSE.
     386
     387  ztopsw_aero(:,:)  = 0. !ym missing init : warning : not initialized in SW_AEROAR4
     388  ztopsw0_aero(:,:) = 0. !ym missing init : warning : not initialized in SW_AEROAR4
     389  zsolsw_aero(:,:)  = 0. !ym missing init : warning : not initialized in SW_AEROAR4
     390  zsolsw0_aero(:,:) = 0. !ym missing init : warning : not initialized in SW_AEROAR4
    386391 
    387392  !
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/phylmd/regr_horiz_time_climoz_m.F90

    r2963 r3406  
    22
    33  USE interpolation,     ONLY: locate
    4   USE mod_grid_phy_lmdz, ONLY: nlon_ou => nbp_lon, nlat_ou => nbp_lat
     4  USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, grid_type, unstructured
    55  USE nrtype,            ONLY: pi
    66  USE netcdf,   ONLY: NF90_CLOBBER, NF90_FLOAT,     NF90_GET_VAR, NF90_OPEN,   &
     
    1111          NF95_CLOSE, NF95_ENDDEF,  NF95_PUT_ATT,   NF95_PUT_VAR, NF95_COPY_ATT
    1212  USE print_control_mod, ONLY: lunout
     13  USE dimphy
    1314  IMPLICIT NONE
    1415  PRIVATE
     
    1617  REAL, PARAMETER :: deg2rad=pi/180.
    1718  CHARACTER(LEN=13), PARAMETER :: vars_in(2)=['tro3         ','tro3_daylight']
     19
     20  INTEGER :: nlat_ou, nlon_ou
    1821
    1922CONTAINS
     
    5255  USE assert_m,           ONLY: assert
    5356  USE cal_tools_m,        ONLY: year_len, mid_month
    54   USE control_mod,        ONLY: anneeref
     57!!  USE control_mod,        ONLY: anneeref
     58  USE time_phylmdz_mod,   ONLY: annee_ref
    5559  USE ioipsl,             ONLY: ioget_year_len, ioget_calendar
    5660  USE regr_conserv_m,     ONLY: regr_conserv
     
    5862  USE regular_lonlat_mod, ONLY: boundslon_reg, boundslat_reg, south, west, east
    5963  USE slopes_m,           ONLY: slopes
     64  USE xios
     65  USE mod_phys_lmdz_mpi_data, only: is_mpi_root
     66  USE mod_phys_lmdz_para, ONLY: gather, bcast
    6067!-------------------------------------------------------------------------------
    6168! Arguments:
     
    8390  CHARACTER(LEN=20) :: cal_in              ! Calendar
    8491  REAL, ALLOCATABLE :: o3_in3(:,:,:,:,:)   ! Ozone climatologies
     92  REAL, ALLOCATABLE :: o3_in3bis(:,:,:,:,:)   ! Ozone climatologies
    8593  REAL, ALLOCATABLE :: o3_in2  (:,:,:,:)   ! Ozone climatologies
     94  REAL, ALLOCATABLE :: o3_in2bis(:,:,:,:,:)   ! Ozone climatologies
    8695  ! last index: 1 for the day-night average, 2 for the daylight field.
    8796  REAL :: NaN
     
    91100  REAL, ALLOCATABLE :: o3_regr_lonlat(:,:,:,:,:) ! (nlon_ou,nlat_ou,:,0:13   ,:)
    92101  REAL, ALLOCATABLE :: o3_out3       (:,:,:,:,:) ! (nlon_ou,nlat_ou,:,ntim_ou,:)
     102  REAL, ALLOCATABLE :: o3_out3_glo   (:,:,:,:) !   (nbp_lat,:,ntim_ou,:)
    93103  REAL, ALLOCATABLE :: o3_regr_lat     (:,:,:,:) !         (nlat_in,:,0:13   ,:)
    94104  REAL, ALLOCATABLE :: o3_out2         (:,:,:,:) !         (nlat_ou,:,ntim_ou,:)
     105  REAL, ALLOCATABLE :: o3_out2_glo     (:,:,:,:) !         (nbp_lat,:,ntim_ou,:)
    95106! Dimension number  | Interval                | Contains  | For variables:
    96107!   1 (longitude)   | [rlonu(i-1), rlonu(i)]  | rlonv(i)  | all
     
    116127  INTEGER, ALLOCATABLE :: sta(:), cnt(:)
    117128  CHARACTER(LEN=80) :: sub, dim_nam, msg
    118 !-------------------------------------------------------------------------------
    119   sub="regr_horiz_time_climoz"
    120   WRITE(lunout,*)"Call sequence information: "//TRIM(sub)
    121   CALL assert(read_climoz == 1 .OR. read_climoz == 2, "regr_lat_time_climoz")
    122 
    123   CALL  NF95_OPEN("climoz.nc"  , NF90_NOWRITE, fID_in)
    124   lprev=NF90_OPEN("climoz_m.nc", NF90_NOWRITE, fID_in_m)==NF90_NOERR
    125   lnext=NF90_OPEN("climoz_p.nc", NF90_NOWRITE, fID_in_p)==NF90_NOERR
    126 
    127   !--- Get coordinates from the input file. Converts lon/lat in radians.
    128   !    Few inversions because "regr_conserv" and gcm need ascending vectors.
    129   CALL NF95_INQ_VARID(fID_in, vars_in(1), varid)
    130   CALL NF95_INQUIRE_VARIABLE(fID_in, varid, dimids=dIDs, ndims=ndims)
    131   l3D=ndims==4; l2D=ndims==3
    132   IF(l3D) WRITE(lunout,*)"Input files contain full 3D ozone fields."
    133   IF(l2D) WRITE(lunout,*)"Input files contain zonal 2D ozone fields."
    134   DO i=1,ndims
    135     CALL NF95_INQUIRE_DIMENSION(fID_in, dIDs(i), name=dim_nam, nclen=dln)
    136     CALL NF95_INQ_VARID(fID_in, dim_nam, varid)
    137     ii=i; IF(l2D) ii=i+1                              !--- ndims==3:NO LONGITUDE
    138     SELECT CASE(ii)
    139       CASE(1)                                         !--- LONGITUDE
    140         CALL NF95_GW_VAR(fID_in, varid, lon_in)
    141         ldec_lon=lon_in(1)>lon_in(dln); IF(ldec_lon) lon_in=lon_in(dln:1:-1)
    142         nlon_in=dln; lon_in=lon_in*deg2rad
    143       CASE(2)                                         !--- LATITUDE
    144         CALL NF95_GW_VAR(fID_in, varid, lat_in)
    145         ldec_lat=lat_in(1)>lat_in(dln); IF(ldec_lat) lat_in=lat_in(dln:1:-1)
    146         nlat_in=dln; lat_in=lat_in*deg2rad
    147       CASE(3)                                         !--- PRESSURE LEVELS
    148         CALL NF95_GW_VAR(fID_in, varid, lev_in)
    149         ldec_lev=lev_in(1)>lev_in(dln); IF(ldec_lev) lev_in=lev_in(dln:1:-1)
    150         nlev_in=dln
    151         CALL NF95_GET_ATT(fID_in, varid, "units", press_unit)
    152         k=LEN_TRIM(press_unit)
    153         DO WHILE(ICHAR(press_unit(k:k))==0)
    154           press_unit(k:k)=' '; k=LEN_TRIM(press_unit) !--- REMOVE NULL END CHAR
    155         END DO
    156         IF(press_unit ==  "Pa") THEN
    157           lev_in = lev_in/100.                        !--- CONVERT TO hPa
    158         ELSE IF(press_unit /= "hPa") THEN
    159           CALL abort_physic(sub, "the only recognized units are Pa and hPa.",1)
    160         END IF
    161       CASE(4)                                         !--- TIME
    162         CALL NF95_INQUIRE_DIMENSION(fID_in, dIDs(i), nclen=nmth_in)
    163         cal_in='gregorian'
    164         IF(NF90_GET_ATT(fID_in, varid, 'calendar', cal_in)/=NF90_NOERR)        &
     129  REAL :: null_array(0)
     130  LOGICAL,SAVE :: first=.TRUE.
     131!$OMP THREADPRIVATE(first) 
     132  REAL, ALLOCATABLE :: test_o3_in(:,:)
     133  REAL, ALLOCATABLE :: test_o3_out(:)
     134 
     135  nlat_ou=nbp_lat
     136  nlon_ou=nbp_lon
     137 
     138!-------------------------------------------------------------------------------
     139  IF (is_mpi_root) THEN
     140    sub="regr_horiz_time_climoz"
     141    WRITE(lunout,*)"Call sequence information: "//TRIM(sub)
     142    CALL assert(read_climoz == 1 .OR. read_climoz == 2, "regr_lat_time_climoz")
     143
     144    CALL  NF95_OPEN("climoz.nc"  , NF90_NOWRITE, fID_in)
     145    lprev=NF90_OPEN("climoz_m.nc", NF90_NOWRITE, fID_in_m)==NF90_NOERR
     146    lnext=NF90_OPEN("climoz_p.nc", NF90_NOWRITE, fID_in_p)==NF90_NOERR
     147
     148    !--- Get coordinates from the input file. Converts lon/lat in radians.
     149    !    Few inversions because "regr_conserv" and gcm need ascending vectors.
     150    CALL NF95_INQ_VARID(fID_in, vars_in(1), varid)
     151    CALL NF95_INQUIRE_VARIABLE(fID_in, varid, dimids=dIDs, ndims=ndims)
     152    l3D=ndims==4; l2D=ndims==3
     153    IF(l3D) WRITE(lunout,*)"Input files contain full 3D ozone fields."
     154    IF(l2D) WRITE(lunout,*)"Input files contain zonal 2D ozone fields."
     155    DO i=1,ndims
     156      CALL NF95_INQUIRE_DIMENSION(fID_in, dIDs(i), name=dim_nam, nclen=dln)
     157      CALL NF95_INQ_VARID(fID_in, dim_nam, varid)
     158      ii=i; IF(l2D) ii=i+1                              !--- ndims==3:NO LONGITUDE
     159      SELECT CASE(ii)
     160        CASE(1)                                         !--- LONGITUDE
     161          CALL NF95_GW_VAR(fID_in, varid, lon_in)
     162          ldec_lon=lon_in(1)>lon_in(dln); IF(ldec_lon) lon_in=lon_in(dln:1:-1)
     163          nlon_in=dln; lon_in=lon_in*deg2rad
     164        CASE(2)                                         !--- LATITUDE
     165          CALL NF95_GW_VAR(fID_in, varid, lat_in)
     166          ldec_lat=lat_in(1)>lat_in(dln); IF(ldec_lat) lat_in=lat_in(dln:1:-1)
     167          nlat_in=dln; lat_in=lat_in*deg2rad
     168        CASE(3)                                         !--- PRESSURE LEVELS
     169          CALL NF95_GW_VAR(fID_in, varid, lev_in)
     170          ldec_lev=lev_in(1)>lev_in(dln); IF(ldec_lev) lev_in=lev_in(dln:1:-1)
     171          nlev_in=dln
     172          CALL NF95_GET_ATT(fID_in, varid, "units", press_unit)
     173          k=LEN_TRIM(press_unit)
     174          DO WHILE(ICHAR(press_unit(k:k))==0)
     175            press_unit(k:k)=' '; k=LEN_TRIM(press_unit) !--- REMOVE NULL END CHAR
     176          END DO
     177          IF(press_unit ==  "Pa") THEN
     178            lev_in = lev_in/100.                        !--- CONVERT TO hPa
     179          ELSE IF(press_unit /= "hPa") THEN
     180            CALL abort_physic(sub, "the only recognized units are Pa and hPa.",1)
     181          END IF
     182        CASE(4)                                         !--- TIME
     183          CALL NF95_INQUIRE_DIMENSION(fID_in, dIDs(i), nclen=nmth_in)
     184          cal_in='gregorian'
     185          IF(NF90_GET_ATT(fID_in, varid, 'calendar', cal_in)/=NF90_NOERR)        & 
    165186          WRITE(lunout,*)'WARNING: missing "calendar" attribute for "'//       &
    166187          TRIM(dim_nam)//'" in "climoz.nc". Choosing default: "gregorian".'
    167         k=LEN_TRIM(cal_in)
    168         DO WHILE(ICHAR(cal_in(k:k))==0)
    169           cal_in(k:k)=' '; k=LEN_TRIM(cal_in)         !--- REMOVE NULL END CHAR
     188          k=LEN_TRIM(cal_in)
     189          DO WHILE(ICHAR(cal_in(k:k))==0)
     190            cal_in(k:k)=' '; k=LEN_TRIM(cal_in)         !--- REMOVE NULL END CHAR
     191          END DO
     192      END SELECT
     193    END DO
     194
     195    !--- Prepare quantities for time interpolation
     196    tmidmonth=mid_month(annee_ref, cal_in)
     197    IF(interpt) THEN
     198      ntim_ou=ioget_year_len(annee_ref)
     199      ALLOCATE(tmidday(ntim_ou))
     200      tmidday=[(REAL(k)-0.5,k=1,ntim_ou)]
     201      CALL ioget_calendar(cal_ou)
     202    ELSE
     203      ntim_ou=14
     204      cal_ou=cal_in
     205    END IF
     206  ENDIF
     207
     208  IF (grid_type==unstructured) THEN
     209    CALL bcast(nlon_in)
     210    CALL bcast(nlat_in)
     211    CALL bcast(nlev_in)
     212    CALL bcast(l3d)
     213    CALL bcast(tmidmonth)
     214    CALL bcast(tmidday)
     215    CALL bcast(ntim_ou)
     216  ENDIF 
     217 
     218  IF (is_mpi_root) THEN
     219    CALL xios_set_domain_attr("domain_climoz",nj_glo=nlat_in, nj=nlat_in, jbegin=0, latvalue_1d=lat_in/deg2rad)
     220    IF (l3D) THEN
     221      CALL xios_set_domain_attr("domain_climoz",ni_glo=nlon_in, ni=nlon_in, ibegin=0, lonvalue_1d=lon_in/deg2rad)
     222    ELSE
     223      CALL xios_set_domain_attr("domain_climoz",ni_glo=8, ni=8, ibegin=0, lonvalue_1d = (/ 0.,45.,90.,135.,180.,225.,270., 315. /))
     224    ENDIF
     225  ELSE
     226    CALL xios_set_domain_attr("domain_climoz",nj_glo=nlat_in, nj=0, jbegin=0, latvalue_1d=null_array )
     227    IF (l3D) THEN
     228      CALL xios_set_domain_attr("domain_climoz",ni_glo=nlon_in, ni=0, ibegin=0, lonvalue_1d=null_array)
     229    ELSE
     230      CALL xios_set_domain_attr("domain_climoz",ni_glo=8, ni=0, ibegin=0, lonvalue_1d=null_array)
     231    ENDIF
     232  ENDIF
     233  CALL  xios_set_axis_attr("axis_climoz", n_glo=nlev_in)
     234  CALL  xios_set_axis_attr("time_axis_climoz", n_glo=ntim_ou)
     235  CALL  xios_set_axis_attr("time_axis_climoz", n_glo=ntim_ou)
     236  CALL  xios_set_axis_attr("tr_climoz", n_glo=read_climoz)
     237  CALL  xios_set_field_attr("tro3_out", enabled=.TRUE.)
     238  CALL  xios_set_field_attr("tro3_out", enabled=.TRUE.)
     239     
     240  IF (first .AND. grid_type==unstructured) THEN
     241    first=.FALSE.
     242    RETURN
     243  ENDIF
     244 
     245 
     246  IF (is_mpi_root) THEN     
     247    !--- Longitudes management:
     248    !    * Need to shift data if the origin of input file longitudes /= -pi
     249    !    * Need to add some margin in longitude to ensure input interval contains
     250    !      all the output intervals => at least one longitudes slice has to be
     251    !      duplicated, possibly more for undersampling.
     252    IF(l3D) THEN
     253      IF (grid_type==unstructured) THEN
     254        dx2=0
     255      ELSE
     256        !--- Compute input edges longitudes vector (no end point yet)
     257        ALLOCATE(v1(nlon_in+1))
     258        v1(1)=(lon_in(nlon_in)+lon_in(1))/2.-pi
     259        FORALL(i=2:nlon_in) v1(i)=(lon_in(i-1)+lon_in(i))/2.
     260        v1(nlon_in+1)=v1(1)+2.*pi
     261        DEALLOCATE(lon_in)
     262
     263        !--- Shift input longitudes vector until it contains first output point boundslon_reg(1,west)
     264        v1=v1+2*pi*REAL(FLOOR((boundslon_reg(1,west)-v1(1))/(2.*pi)))
     265
     266        !--- Ensure first input longitudes interval contains first output point boundslon_reg(1,west)
     267        dx1=locate(v1,boundslon_reg(1,west))-1
     268        v1=CSHIFT(v1,SHIFT=dx1,DIM=1); v1(nlon_in-dx1+1:)=v1(nlon_in-dx1+1:)+2.*pi
     269 
     270        !--- Extend input longitudes vector until last interval contains boundslon_reg(nlat_ou,east)
     271        dx2=0; DO WHILE(v1(1+dx2)+2.*pi<boundslon_reg(nlon_ou,east)); dx2=dx2+1; END DO
     272
     273        !--- Final edges longitudes vector (with margin and end point)
     274        ALLOCATE(lon_in_edge(nlon_in+dx2+1)); lon_in_edge=[v1,v1(2:1+dx2)+2.*pi]
     275        DEALLOCATE(v1)
     276      ENDIF
     277    END IF
     278
     279    !--- Compute sinus of intervals edges latitudes:
     280    ALLOCATE(sinlat_in_edge(nlat_in+1))
     281    sinlat_in_edge(1) = -1. ; sinlat_in_edge(nlat_in+1) = 1.
     282    FORALL(j=2:nlat_in) sinlat_in_edge(j)=SIN((lat_in(j-1)+lat_in(j))/2.)
     283    DEALLOCATE(lat_in)
     284
     285
     286
     287    !--- Check for contiguous years:
     288    ib=0; ie=13
     289    IF(nmth_in == 14) THEN; lprev=.FALSE.; lnext=.FALSE.
     290      WRITE(lunout,*)'Using 14 months ozone climatology "climoz.nc"...'
     291    ELSE 
     292      IF(     lprev) WRITE(lunout,*)'Using "climoz_m.nc" last record (previous year).'
     293      IF(.NOT.lprev) WRITE(lunout,*)"No previous year file ; assuming periodicity."
     294      IF(     lnext) WRITE(lunout,*)'Using "climoz_p.nc" first record (next year).'
     295      IF(.NOT.lnext) WRITE(lunout,*)"No next year file ; assuming periodicity."
     296      IF(.NOT.lprev) ib=1
     297      IF(.NOT.lnext) ie=12
     298    END IF
     299    ALLOCATE(sta(ndims),cnt(ndims)); sta(:)=1 
     300    IF(l3D) cnt=[nlon_in,nlat_in,nlev_in,1]
     301    IF(l2D) cnt=[        nlat_in,nlev_in,1] 
     302    IF(l3D) ALLOCATE(o3_in3(nlon_in+dx2,nlat_in,nlev_in,ib:ie,read_climoz))
     303    IF(l2D) ALLOCATE(o3_in2(            nlat_in,nlev_in,ib:ie,read_climoz))
     304
     305    !--- Read full current file and one record each available contiguous file
     306    DO iv=1,read_climoz
     307      msg=TRIM(sub)//" NF90_GET_VAR "//TRIM(vars_in(iv))
     308      CALL NF95_INQ_VARID(fID_in, vars_in(1), vID_in(iv))
     309      IF(l3D) ncerr=NF90_GET_VAR(fID_in, vID_in(iv), o3_in3(1:nlon_in,:,:,1:12,iv))
     310      IF(l2D) ncerr=NF90_GET_VAR(fID_in, vID_in(iv), o3_in2(          :,:,1:12,iv))
     311      CALL handle_err(TRIM(msg), ncerr, fID_in)
     312      IF(lprev) THEN; sta(ndims)=12 
     313        CALL NF95_INQ_VARID(fID_in_m, vars_in(1), vID_in(iv))
     314        IF(l3D) ncerr=NF90_GET_VAR(fID_in_m,vID_in(iv),o3_in3(1:nlon_in,:,:, 0,iv),sta,cnt)
     315        IF(l2d) ncerr=NF90_GET_VAR(fID_in_m,vID_in(iv),o3_in2(          :,:, 0,iv),sta,cnt)
     316        CALL handle_err(TRIM(msg)//" previous", ncerr, fID_in_m)
     317      END IF
     318      IF(lnext) THEN; sta(ndims)=1 
     319        CALL NF95_INQ_VARID(fID_in_p, vars_in(1), vID_in(iv))
     320        IF(l3D) ncerr=NF90_GET_VAR(fID_in_p,vID_in(iv),o3_in3(1:nlon_in,:,:,13,iv),sta,cnt)
     321        IF(l2D) ncerr=NF90_GET_VAR(fID_in_p,vID_in(iv),o3_in2(          :,:,13,iv),sta,cnt)
     322        CALL handle_err(TRIM(msg)//" next", ncerr, fID_in_p)
     323      END IF
     324    END DO
     325    IF(lprev.OR.lnext) DEALLOCATE(sta,cnt)
     326    IF(lprev) CALL NF95_CLOSE(fID_in_m)
     327    IF(lnext) CALL NF95_CLOSE(fID_in_p)
     328
     329    !--- Revert decreasing coordinates vector
     330    IF(l3D) THEN
     331      IF(ldec_lon) o3_in3(1:nlon_in,:,:,:,:) = o3_in3(nlon_in:1:-1,:,:,:,:)
     332      IF(ldec_lat) o3_in3 = o3_in3(:,nlat_in:1:-1,:,:,:)
     333      IF(ldec_lev) o3_in3 = o3_in3(:,:,nlev_in:1:-1,:,:)
     334     
     335      IF (grid_type /= unstructured) THEN
     336        !--- Shift values for longitude and duplicate some longitudes slices
     337        o3_in3(1:nlon_in,:,:,:,:)=CSHIFT(o3_in3(1:nlon_in,:,:,:,:),SHIFT=dx1,DIM=1)
     338        o3_in3(nlon_in+1:nlon_in+dx2,:,:,:,:)=o3_in3(1:dx2,:,:,:,:)
     339      ENDIF
     340    ELSE
     341      IF(ldec_lat) o3_in2 = o3_in2(  nlat_in:1:-1,:,:,:)
     342      IF(ldec_lev) o3_in2 = o3_in2(  :,nlev_in:1:-1,:,:)
     343    END IF
     344
     345   !--- Deal with missing values
     346    DO m=1, read_climoz
     347      WRITE(msg,'(a,i0)')"regr_lat_time_climoz: field Nr.",m
     348      IF(NF90_GET_ATT(fID_in,vID_in(m),"missing_value",NaN)/= NF90_NOERR) THEN
     349        IF(NF90_GET_ATT(fID_in, vID_in(m),"_FillValue",NaN)/= NF90_NOERR) THEN
     350          WRITE(lunout,*)TRIM(msg)//": no missing value attribute found."; CYCLE
     351        END IF
     352      END IF
     353      WRITE(lunout,*)TRIM(msg)//": missing value attribute found."
     354      WRITE(lunout,*)"Trying to fill in NaNs ; a full field would be better."
     355
     356      !--- Check top layer contains no NaNs & search NaNs from top to ground
     357      msg=TRIM(sub)//": NaNs in top layer !"
     358      IF(l3D) THEN
     359        IF(ANY(o3_in3(:,:,1,:,m)==NaN)) CALL abort_physic(sub,msg,1)
     360        DO k = 2,nlev_in
     361          WHERE(o3_in3(:,:,k,:,m)==NaN) o3_in3(:,:,k,:,m)=o3_in3(:,:,k-1,:,m)
    170362        END DO
    171     END SELECT
    172   END DO
    173 
    174   !--- Longitudes management:
    175   !    * Need to shift data if the origin of input file longitudes /= -pi
    176   !    * Need to add some margin in longitude to ensure input interval contains
    177   !      all the output intervals => at least one longitudes slice has to be
    178   !      duplicated, possibly more for undersampling.
    179   IF(l3D) THEN
    180     !--- Compute input edges longitudes vector (no end point yet)
    181     ALLOCATE(v1(nlon_in+1))
    182     v1(1)=(lon_in(nlon_in)+lon_in(1))/2.-pi
    183     FORALL(i=2:nlon_in) v1(i)=(lon_in(i-1)+lon_in(i))/2.
    184     v1(nlon_in+1)=v1(1)+2.*pi
    185     DEALLOCATE(lon_in)
    186 
    187     !--- Shift input longitudes vector until it contains first output point boundslon_reg(1,west)
    188     v1=v1+2*pi*REAL(FLOOR((boundslon_reg(1,west)-v1(1))/(2.*pi)))
    189 
    190     !--- Ensure first input longitudes interval contains first output point boundslon_reg(1,west)
    191     dx1=locate(v1,boundslon_reg(1,west))-1
    192     v1=CSHIFT(v1,SHIFT=dx1,DIM=1); v1(nlon_in-dx1+1:)=v1(nlon_in-dx1+1:)+2.*pi
    193 
    194     !--- Extend input longitudes vector until last interval contains boundslon_reg(nlat_ou,east)
    195     dx2=0; DO WHILE(v1(1+dx2)+2.*pi<boundslon_reg(nlon_ou,east)); dx2=dx2+1; END DO
    196 
    197     !--- Final edges longitudes vector (with margin and end point)
    198     ALLOCATE(lon_in_edge(nlon_in+dx2+1)); lon_in_edge=[v1,v1(2:1+dx2)+2.*pi]
    199     DEALLOCATE(v1)
    200   END IF
    201 
    202   !--- Compute sinus of intervals edges latitudes:
    203   ALLOCATE(sinlat_in_edge(nlat_in+1))
    204   sinlat_in_edge(1) = -1. ; sinlat_in_edge(nlat_in+1) = 1.
    205   FORALL(j=2:nlat_in) sinlat_in_edge(j)=SIN((lat_in(j-1)+lat_in(j))/2.)
    206   DEALLOCATE(lat_in)
    207 
    208   !--- Prepare quantities for time interpolation
    209   tmidmonth=mid_month(anneeref, cal_in)
    210   IF(interpt) THEN
    211     ntim_ou=ioget_year_len(anneeref)
    212     ALLOCATE(tmidday(ntim_ou))
    213     tmidday=[(REAL(k)-0.5,k=1,ntim_ou)]
    214     CALL ioget_calendar(cal_ou)
    215   ELSE
    216     ntim_ou=14
    217     cal_ou=cal_in
    218   END IF
     363      ELSE
     364        IF(ANY(o3_in2(  :,1,:,m)==NaN)) THEN
     365          WRITE(lunout,*)msg
     366          !--- Fill in latitudes where all values are missing
     367          DO l=1,nmth_in
     368            !--- Next to south pole
     369            j=1;       DO WHILE(o3_in2(j,1,l,m)==NaN); j=j+1; END DO
     370            IF(j>1) &
     371              o3_in2(:j-1,:,l,m)=SPREAD(o3_in2(j,:,l,m),DIM=1,ncopies=j-1)
     372            !--- Next to north pole
     373            j=nlat_in; DO WHILE(o3_in2(j,1,l,m)==NaN); j=j+1; END DO
     374            IF(j<nlat_in) &
     375              o3_in2(j+1:,:,l,m)=SPREAD(o3_in2(j,:,l,m),DIM=1,ncopies=nlat_in-j)
     376          END DO
     377        END IF
     378
     379        !--- Fill in high latitudes missing values
     380        !--- Highest level been filled-in, so has always valid values.
     381        DO k = 2,nlev_in
     382          WHERE(o3_in2(:,k,:,m)==NaN) o3_in2(:,k,:,m)=o3_in2(:,k-1,:,m)
     383        END DO
     384      END IF
     385    END DO
     386
     387  ENDIF
     388 
     389  !=============================================================================
     390  IF(l3D) THEN                                                   !=== 3D FIELDS
     391  !=============================================================================
     392   IF (grid_type==unstructured) THEN
     393     nlat_ou=klon
     394     
     395     IF (is_mpi_root) THEN
     396       ALLOCATE(o3_in3bis(nlon_in,nlat_in,nlev_in,0:13,read_climoz))
     397       o3_in3bis(:,:,:,ib:ie,:)=o3_in3(1:nlon_in,:,:,ib:ie,:)
     398     ELSE
     399       ALLOCATE(o3_in3bis(0,0,0,0,read_climoz))
     400     ENDIF
     401     ALLOCATE(o3_regr_lonlat(1, nlat_ou, nlev_in, 0:13, read_climoz))
     402     
     403     CALL xios_send_field("tro3_in",o3_in3bis(:,:,:,:,:))
     404     CALL xios_recv_field("tro3_out",o3_regr_lonlat(1,:,:,:,:))
     405
     406   ELSE
     407       
     408     !--- Regrid in longitude
     409      ALLOCATE(o3_regr_lon(nlon_ou, nlat_in, nlev_in, ie-ib+1, read_climoz))
     410      CALL regr_conserv(1, o3_in3, xs = lon_in_edge,                             &
     411                          xt = [boundslon_reg(1,west),boundslon_reg(:,east)],    &
     412                          vt = o3_regr_lon, slope = slopes(1,o3_in3, lon_in_edge))
     413      DEALLOCATE(o3_in3)
     414
     415      !--- Regrid in latitude: averaging with respect to SIN(lat) is
     416      !                        equivalent to weighting by COS(lat)
     417      !--- (inverted indices in "o3_regr_lonlat" because "rlatu" is decreasing)
     418      ALLOCATE(o3_regr_lonlat(nlon_ou, nlat_ou, nlev_in, 0:13, read_climoz))
     419      CALL regr_conserv(2, o3_regr_lon, xs = sinlat_in_edge,                     &
     420                      xt = [- 1., SIN(boundslat_reg(nlat_ou-1:1:-1,south)), 1.], &
     421                      vt = o3_regr_lonlat(:,nlat_ou:1:- 1,:,ib:ie,:),            &
     422                 slope = slopes(2,o3_regr_lon, sinlat_in_edge))
     423      DEALLOCATE(o3_regr_lon)
     424
     425   ENDIF
     426
     427   !--- Duplicate previous/next record(s) if they are not available
     428   IF(.NOT.lprev) o3_regr_lonlat(:,:,:, 0,:) = o3_regr_lonlat(:,:,:,12,:)
     429   IF(.NOT.lnext) o3_regr_lonlat(:,:,:,13,:) = o3_regr_lonlat(:,:,:, 1,:)
     430   
     431   !--- Regrid in time by linear interpolation:
     432   ALLOCATE(o3_out3(nlon_ou, nlat_ou, nlev_in, ntim_ou, read_climoz))
     433   IF(     interpt) CALL regr_lint(4,o3_regr_lonlat,tmidmonth,tmidday,o3_out3)
     434   IF(.NOT.interpt) o3_out3=o3_regr_lonlat
     435   DEALLOCATE(o3_regr_lonlat)
     436
     437   nlat_ou=nbp_lat
     438   IF (grid_type==unstructured) THEN
     439     CALL xios_send_field('o3_out',o3_out3)
     440     ndims=3
     441     ALLOCATE(o3_out3_glo(nlat_ou, nlev_in, ntim_ou, read_climoz))
     442     CALL gather(o3_out3(1,:,:,:,:), o3_out3_glo)
     443   ENDIF
    219444
    220445  !--- Create the output file and get the variable IDs:
     
    222447                   ndims, cal_ou)
    223448
    224   !--- Write remaining coordinate variables:
    225   CALL NF95_PUT_VAR(fID_ou, levID_ou, lev_in); DEALLOCATE(lev_in)
    226   IF(     interpt) CALL NF95_PUT_VAR(fID_ou, timID_ou, tmidday)
    227   IF(.NOT.interpt) CALL NF95_PUT_VAR(fID_ou, timID_ou, tmidmonth)
    228 
    229   !--- Check for contiguous years:
    230   ib=0; ie=13
    231   IF(nmth_in == 14) THEN; lprev=.FALSE.; lnext=.FALSE.
    232     WRITE(lunout,*)'Using 14 months ozone climatology "climoz.nc"...'
    233   ELSE
    234     IF(     lprev) WRITE(lunout,*)'Using "climoz_m.nc" last record (previous year).'
    235     IF(.NOT.lprev) WRITE(lunout,*)"No previous year file ; assuming periodicity."
    236     IF(     lnext) WRITE(lunout,*)'Using "climoz_p.nc" first record (next year).'
    237     IF(.NOT.lnext) WRITE(lunout,*)"No next year file ; assuming periodicity."
    238     IF(.NOT.lprev) ib=1
    239     IF(.NOT.lnext) ie=12
    240   END IF
    241   ALLOCATE(sta(ndims),cnt(ndims)); sta(:)=1
    242   IF(l3D) cnt=[nlon_in,nlat_in,nlev_in,1]
    243   IF(l2D) cnt=[        nlat_in,nlev_in,1]
    244   IF(l3D) ALLOCATE(o3_in3(nlon_in+dx2,nlat_in,nlev_in,ib:ie,read_climoz))
    245   IF(l2D) ALLOCATE(o3_in2(            nlat_in,nlev_in,ib:ie,read_climoz))
    246 
    247   !--- Read full current file and one record each available contiguous file
    248   DO iv=1,read_climoz
    249     msg=TRIM(sub)//" NF90_GET_VAR "//TRIM(vars_in(iv))
    250     CALL NF95_INQ_VARID(fID_in, vars_in(1), vID_in(iv))
    251     IF(l3D) ncerr=NF90_GET_VAR(fID_in, vID_in(iv), o3_in3(1:nlon_in,:,:,1:12,iv))
    252     IF(l2D) ncerr=NF90_GET_VAR(fID_in, vID_in(iv), o3_in2(          :,:,1:12,iv))
    253     CALL handle_err(TRIM(msg), ncerr, fID_in)
    254     IF(lprev) THEN; sta(ndims)=12
    255       CALL NF95_INQ_VARID(fID_in_m, vars_in(1), vID_in(iv))
    256       IF(l3D) ncerr=NF90_GET_VAR(fID_in_m,vID_in(iv),o3_in3(1:nlon_in,:,:, 0,iv),sta,cnt)
    257       IF(l2d) ncerr=NF90_GET_VAR(fID_in_m,vID_in(iv),o3_in2(          :,:, 0,iv),sta,cnt)
    258       CALL handle_err(TRIM(msg)//" previous", ncerr, fID_in_m)
    259     END IF
    260     IF(lnext) THEN; sta(ndims)=1
    261       CALL NF95_INQ_VARID(fID_in_p, vars_in(1), vID_in(iv))
    262       IF(l3D) ncerr=NF90_GET_VAR(fID_in_p,vID_in(iv),o3_in3(1:nlon_in,:,:,13,iv),sta,cnt)
    263       IF(l2D) ncerr=NF90_GET_VAR(fID_in_p,vID_in(iv),o3_in2(          :,:,13,iv),sta,cnt)
    264       CALL handle_err(TRIM(msg)//" next", ncerr, fID_in_p)
    265     END IF
    266   END DO
    267   IF(lprev.OR.lnext) DEALLOCATE(sta,cnt)
    268   IF(lprev) CALL NF95_CLOSE(fID_in_m)
    269   IF(lnext) CALL NF95_CLOSE(fID_in_p)
    270 
    271   !--- Revert decreasing coordinates vector
    272   IF(l3D) THEN
    273     IF(ldec_lon) o3_in3(1:nlon_in,:,:,:,:) = o3_in3(nlon_in:1:-1,:,:,:,:)
    274     IF(ldec_lat) o3_in3 = o3_in3(:,nlat_in:1:-1,:,:,:)
    275     IF(ldec_lev) o3_in3 = o3_in3(:,:,nlev_in:1:-1,:,:)
    276     !--- Shift values for longitude and duplicate some longitudes slices
    277     o3_in3(1:nlon_in,:,:,:,:)=CSHIFT(o3_in3(1:nlon_in,:,:,:,:),SHIFT=dx1,DIM=1)
    278     o3_in3(nlon_in+1:nlon_in+dx2,:,:,:,:)=o3_in3(1:dx2,:,:,:,:)
    279   ELSE
    280     IF(ldec_lat) o3_in2 = o3_in2(  nlat_in:1:-1,:,:,:)
    281     IF(ldec_lev) o3_in2 = o3_in2(  :,nlev_in:1:-1,:,:)
    282   END IF
    283 
    284  !--- Deal with missing values
    285   DO m=1, read_climoz
    286     WRITE(msg,'(a,i0)')"regr_lat_time_climoz: field Nr.",m
    287     IF(NF90_GET_ATT(fID_in,vID_in(m),"missing_value",NaN)/= NF90_NOERR) THEN
    288       IF(NF90_GET_ATT(fID_in, vID_in(m),"_FillValue",NaN)/= NF90_NOERR) THEN
    289         WRITE(lunout,*)TRIM(msg)//": no missing value attribute found."; CYCLE
    290       END IF
    291     END IF
    292     WRITE(lunout,*)TRIM(msg)//": missing value attribute found."
    293     WRITE(lunout,*)"Trying to fill in NaNs ; a full field would be better."
    294 
    295     !--- Check top layer contains no NaNs & search NaNs from top to ground
    296     msg=TRIM(sub)//": NaNs in top layer !"
    297     IF(l3D) THEN
    298       IF(ANY(o3_in3(:,:,1,:,m)==NaN)) CALL abort_physic(sub,msg,1)
    299       DO k = 2,nlev_in
    300         WHERE(o3_in3(:,:,k,:,m)==NaN) o3_in3(:,:,k,:,m)=o3_in3(:,:,k-1,:,m)
    301       END DO
    302     ELSE
    303       IF(ANY(o3_in2(  :,1,:,m)==NaN)) THEN
    304         WRITE(lunout,*)msg
    305         !--- Fill in latitudes where all values are missing
    306         DO l=1,nmth_in
    307           !--- Next to south pole
    308           j=1;       DO WHILE(o3_in2(j,1,l,m)==NaN); j=j+1; END DO
    309           IF(j>1) &
    310             o3_in2(:j-1,:,l,m)=SPREAD(o3_in2(j,:,l,m),DIM=1,ncopies=j-1)
    311           !--- Next to north pole
    312           j=nlat_in; DO WHILE(o3_in2(j,1,l,m)==NaN); j=j+1; END DO
    313           IF(j<nlat_in) &
    314             o3_in2(j+1:,:,l,m)=SPREAD(o3_in2(j,:,l,m),DIM=1,ncopies=nlat_in-j)
     449  IF (is_mpi_root) THEN
     450    !--- Write remaining coordinate variables:
     451    CALL NF95_PUT_VAR(fID_ou, levID_ou, lev_in); DEALLOCATE(lev_in)
     452    IF(     interpt) CALL NF95_PUT_VAR(fID_ou, timID_ou, tmidday)
     453    IF(.NOT.interpt) CALL NF95_PUT_VAR(fID_ou, timID_ou, tmidmonth)
     454
     455    !--- Write to file (the order of "rlatu" is inverted in the output file):
     456      IF (grid_type==unstructured) THEN
     457        DO m = 1, read_climoz
     458          CALL NF95_PUT_VAR(fID_ou, vID_ou(m), o3_out3_glo(nlat_ou:1:-1,:,:,m))
    315459        END DO
    316       END IF
    317 
    318       !--- Fill in high latitudes missing values
    319       !--- Highest level been filled-in, so has always valid values.
    320       DO k = 2,nlev_in
    321         WHERE(o3_in2(:,k,:,m)==NaN) o3_in2(:,k,:,m)=o3_in2(:,k-1,:,m)
    322       END DO
    323     END IF
    324   END DO
    325   CALL NF95_CLOSE(fID_in)
    326 
    327   !=============================================================================
    328   IF(l3D) THEN                                                   !=== 3D FIELDS
    329   !=============================================================================
    330     !--- Regrid in longitude
    331     ALLOCATE(o3_regr_lon(nlon_ou, nlat_in, nlev_in, ie-ib+1, read_climoz))
    332     CALL regr_conserv(1, o3_in3, xs = lon_in_edge,                             &
    333                         xt = [boundslon_reg(1,west),boundslon_reg(:,east)],    &
    334                         vt = o3_regr_lon, slope = slopes(1,o3_in3, lon_in_edge))
    335     DEALLOCATE(o3_in3)
    336 
    337     !--- Regrid in latitude: averaging with respect to SIN(lat) is
    338     !                        equivalent to weighting by COS(lat)
    339     !--- (inverted indices in "o3_regr_lonlat" because "rlatu" is decreasing)
    340     ALLOCATE(o3_regr_lonlat(nlon_ou, nlat_ou, nlev_in, 0:13, read_climoz))
    341     CALL regr_conserv(2, o3_regr_lon, xs = sinlat_in_edge,                     &
    342                     xt = [- 1., SIN(boundslat_reg(nlat_ou-1:1:-1,south)), 1.], &
    343                     vt = o3_regr_lonlat(:,nlat_ou:1:- 1,:,ib:ie,:),            &
    344                  slope = slopes(2,o3_regr_lon, sinlat_in_edge))
    345     DEALLOCATE(o3_regr_lon)
    346 
    347     !--- Duplicate previous/next record(s) if they are not available
    348     IF(.NOT.lprev) o3_regr_lonlat(:,:,:, 0,:) = o3_regr_lonlat(:,:,:,12,:)
    349     IF(.NOT.lnext) o3_regr_lonlat(:,:,:,13,:) = o3_regr_lonlat(:,:,:, 1,:)
    350 
    351     !--- Regrid in time by linear interpolation:
    352     ALLOCATE(o3_out3(nlon_ou, nlat_ou, nlev_in, ntim_ou, read_climoz))
    353     IF(     interpt) CALL regr_lint(4,o3_regr_lonlat,tmidmonth,tmidday,o3_out3)
    354     IF(.NOT.interpt) o3_out3=o3_regr_lonlat
    355     DEALLOCATE(o3_regr_lonlat)
    356 
    357     !--- Write to file (the order of "rlatu" is inverted in the output file):
    358     DO m = 1, read_climoz
    359       CALL NF95_PUT_VAR(fID_ou, vID_ou(m), o3_out3(:,nlat_ou:1:-1,:,:,m))
    360     END DO
     460      ELSE
     461        DO m = 1, read_climoz
     462          CALL NF95_PUT_VAR(fID_ou, vID_ou(m), o3_out3(:,nlat_ou:1:-1,:,:,m))
     463        END DO
     464    ENDIF
     465    CALL NF95_CLOSE(fID_ou)
     466
     467
     468  ENDIF
     469
     470
     471
     472
     473
     474
     475
     476
    361477
    362478  !=============================================================================
    363479  ELSE                                                         !=== ZONAL FIELDS
    364480  !=============================================================================
    365     !--- Regrid in latitude: averaging with respect to SIN(lat) is
    366     !                        equivalent to weighting by COS(lat)
    367     !--- (inverted indices in "o3_regr_lat" because "rlatu" is decreasing)
    368     ALLOCATE(o3_regr_lat(nlat_ou, nlev_in, 0:13, read_climoz))
    369     CALL regr_conserv(1, o3_in2, xs = sinlat_in_edge,                          &
    370                     xt = [- 1., SIN(boundslat_reg(nlat_ou-1:1:-1,south)), 1.], &
    371                     vt = o3_regr_lat(nlat_ou:1:- 1,:,ib:ie,:),                 &
    372                  slope = slopes(1,o3_in2, sinlat_in_edge))
    373     DEALLOCATE(o3_in2)
    374 
    375     !--- Duplicate previous/next record(s) if they are not available
    376     IF(.NOT.lprev) o3_regr_lat(:,:, 0,:) = o3_regr_lat(:,:,12,:)
    377     IF(.NOT.lnext) o3_regr_lat(:,:,13,:) = o3_regr_lat(:,:, 1,:)
    378 
     481 
     482   IF (grid_type==unstructured) THEN
     483     nlat_ou=klon
     484
     485     IF (is_mpi_root) THEN
     486       ALLOCATE(o3_in2bis(8,nlat_in,nlev_in,0:13,read_climoz))
     487       o3_in2bis(:,:,:,ib:ie,:)=SPREAD(o3_in2,1,8)
     488     ELSE
     489       ALLOCATE(o3_in2bis(0,0,0,0,read_climoz))
     490     ENDIF
     491     ALLOCATE(o3_regr_lat(nlat_ou, nlev_in, 0:13, read_climoz))
     492     CALL xios_send_field("tro3_in",o3_in2bis(:,:,:,:,:))
     493     CALL xios_recv_field("tro3_out",o3_regr_lat(:,:,:,:))
     494     IF(.NOT.lprev) o3_regr_lat(:,:, 0, :) = o3_regr_lat(:,:,12,:)
     495     IF(.NOT.lnext) o3_regr_lat(:,:,13, :) = o3_regr_lat(:,:, 1,:)
     496     
     497   
     498   ELSE
     499      !--- Regrid in latitude: averaging with respect to SIN(lat) is
     500      !                        equivalent to weighting by COS(lat)
     501      !--- (inverted indices in "o3_regr_lat" because "rlatu" is decreasing)
     502      ALLOCATE(o3_regr_lat(nlat_ou, nlev_in, 0:13, read_climoz))
     503      CALL regr_conserv(1, o3_in2, xs = sinlat_in_edge,                          &
     504                      xt = [- 1., SIN(boundslat_reg(nlat_ou-1:1:-1,south)), 1.], &
     505                      vt = o3_regr_lat(nlat_ou:1:- 1,:,ib:ie,:),                 &
     506                   slope = slopes(1,o3_in2, sinlat_in_edge))
     507      DEALLOCATE(o3_in2)
     508
     509      !--- Duplicate previous/next record(s) if they are not available
     510      IF(.NOT.lprev) o3_regr_lat(:,:, 0,:) = o3_regr_lat(:,:,12,:)
     511      IF(.NOT.lnext) o3_regr_lat(:,:,13,:) = o3_regr_lat(:,:, 1,:)
     512
     513   ENDIF
     514   
    379515    !--- Regrid in time by linear interpolation:
    380516    ALLOCATE(o3_out2(nlat_ou, nlev_in, ntim_ou, read_climoz))
     
    383519    DEALLOCATE(o3_regr_lat)
    384520
    385     !--- Write to file (the order of "rlatu" is inverted in the output file):
    386     DO m = 1, read_climoz
    387       CALL NF95_PUT_VAR(fID_ou, vID_ou(m), o3_out2(nlat_ou:1:-1,:,:,m))
    388     END DO
     521    nlat_ou=nbp_lat
     522!    ALLOCATE(o3_out2_glo(nlat_ou, nlev_in, ntim_ou, read_climoz))
     523!    CALL gather(o3_out2, o3_out2_glo)
     524!    CALL xios_send_field('o3_out',o3_out2)
     525 
     526    IF (grid_type==unstructured) THEN
     527      ndims=3
     528      ALLOCATE(o3_out2_glo(nlat_ou, nlev_in, ntim_ou, read_climoz))
     529      CALL gather(o3_out2, o3_out2_glo)
     530    ENDIF
     531   
     532    !--- Create the output file and get the variable IDs:
     533    CALL prepare_out(fID_in,nlev_in,ntim_ou, fID_ou,levID_ou,timID_ou,vID_ou, &
     534                       ndims, cal_ou)
     535
     536    IF (is_mpi_root) THEN
     537   
     538      !--- Write remaining coordinate variables:
     539      CALL NF95_PUT_VAR(fID_ou, levID_ou, lev_in); DEALLOCATE(lev_in)
     540      IF(     interpt) CALL NF95_PUT_VAR(fID_ou, timID_ou, tmidday)
     541      IF(.NOT.interpt) CALL NF95_PUT_VAR(fID_ou, timID_ou, tmidmonth)
     542
     543      IF (grid_type==unstructured) THEN
     544        DO m = 1, read_climoz
     545          CALL NF95_PUT_VAR(fID_ou, vID_ou(m), o3_out2_glo(nlat_ou:1:-1,:,:,m))
     546        END DO
     547      ELSE
     548        !--- Write to file (the order of "rlatu" is inverted in the output file):
     549        DO m = 1, read_climoz
     550          CALL NF95_PUT_VAR(fID_ou, vID_ou(m), o3_out2(nlat_ou:1:-1,:,:,m))
     551        END DO
     552      ENDIF
     553     
     554      CALL NF95_CLOSE(fID_ou)
     555   
     556    ENDIF
    389557
    390558  !=============================================================================
     
    392560  !=============================================================================
    393561
    394   CALL NF95_CLOSE(fID_ou)
     562  IF (is_mpi_root) CALL NF95_CLOSE(fID_in)
    395563
    396564END SUBROUTINE regr_horiz_time_climoz
     
    408576!-------------------------------------------------------------------------------
    409577  USE regular_lonlat_mod, ONLY: lon_reg, lat_reg
     578  USE regular_lonlat_mod, ONLY: lon_reg, lat_reg
     579  USE geometry_mod, ONLY : latitude_deg
     580  USE mod_grid_phy_lmdz, ONLY: klon_glo
     581  USE mod_phys_lmdz_mpi_data, only: is_mpi_root
     582  USE mod_phys_lmdz_para, ONLY: gather
     583!
    410584!-------------------------------------------------------------------------------
    411585! Arguments:
     
    420594  INTEGER :: vlonID, vlatID, ncerr,  is
    421595  CHARACTER(LEN=80) :: sub
    422 !-------------------------------------------------------------------------------
    423   sub="prepare_out"
    424   WRITE(lunout,*)"CALL sequence information: "//TRIM(sub)
    425   CALL NF95_CREATE("climoz_LMDZ.nc", NF90_clobber, fID_ou)
     596  REAL :: latitude_glo(klon_glo)
     597
     598!-------------------------------------------------------------------------------
     599
     600  IF (grid_type==unstructured) CALL gather(latitude_deg,  latitude_glo)
     601 
     602  IF (is_mpi_root) THEN 
     603    sub="prepare_out"
     604    WRITE(lunout,*)"CALL sequence information: "//TRIM(sub)
     605    CALL NF95_CREATE("climoz_LMDZ.nc", NF90_clobber, fID_ou)
    426606
    427607  !--- Dimensions:
    428   IF(ndims==4) &
    429   CALL NF95_DEF_DIM(fID_ou, "rlonv", nlon_ou, dlonID)
    430   CALL NF95_DEF_DIM(fID_ou, "rlatu", nlat_ou, dlatID)
    431   CALL NF95_DEF_DIM(fID_ou, "plev",  nlev_in, dlevID)
    432   CALL NF95_DEF_DIM(fID_ou, "time",  ntim_ou, dtimID)
    433 
    434   !--- Define coordinate variables:
    435   IF(ndims==4) &
    436   CALL NF95_DEF_VAR(fID_ou, "rlonv", NF90_FLOAT, dlonID, vlonID)
    437   CALL NF95_DEF_VAR(fID_ou, "rlatu", NF90_FLOAT, dlatID, vlatID)
    438   CALL NF95_DEF_VAR(fID_ou, "plev",  NF90_FLOAT, dlevID, vlevID)
    439   CALL NF95_DEF_VAR(fID_ou, "time",  NF90_FLOAT, dtimID, vtimID)
    440   IF(ndims==4) &
    441   CALL NF95_PUT_ATT(fID_ou, vlonID, "units", "degrees_east")
    442   CALL NF95_PUT_ATT(fID_ou, vlatID, "units", "degrees_north")
    443   CALL NF95_PUT_ATT(fID_ou, vlevID, "units", "millibar")
    444   CALL NF95_PUT_ATT(fID_ou, vtimID, "units", "days since 2000-1-1")
    445   IF(ndims==4) &
    446   CALL NF95_PUT_ATT(fID_ou, vlonID, "standard_name", "longitude")
    447   CALL NF95_PUT_ATT(fID_ou, vlatID, "standard_name", "latitude")
    448   CALL NF95_PUT_ATT(fID_ou, vlevID, "standard_name", "air_pressure")
    449   CALL NF95_PUT_ATT(fID_ou, vtimID, "standard_name", "time")
    450   CALL NF95_PUT_ATT(fID_ou, vlevID, "long_name",     "air pressure")
    451   CALL NF95_PUT_ATT(fID_ou, vtimID, "calendar",      cal_ou)
     608    IF(ndims==4) &
     609    CALL NF95_DEF_DIM(fID_ou, "rlonv", nlon_ou, dlonID)
     610    CALL NF95_DEF_DIM(fID_ou, "rlatu", nlat_ou, dlatID)
     611    CALL NF95_DEF_DIM(fID_ou, "plev",  nlev_in, dlevID)
     612    CALL NF95_DEF_DIM(fID_ou, "time",  ntim_ou, dtimID)
     613
     614    !--- Define coordinate variables:
     615    IF(ndims==4) &
     616    CALL NF95_DEF_VAR(fID_ou, "rlonv", NF90_FLOAT, dlonID, vlonID)
     617    CALL NF95_DEF_VAR(fID_ou, "rlatu", NF90_FLOAT, dlatID, vlatID)
     618    CALL NF95_DEF_VAR(fID_ou, "plev",  NF90_FLOAT, dlevID, vlevID)
     619    CALL NF95_DEF_VAR(fID_ou, "time",  NF90_FLOAT, dtimID, vtimID)
     620    IF(ndims==4) &
     621    CALL NF95_PUT_ATT(fID_ou, vlonID, "units", "degrees_east")
     622    CALL NF95_PUT_ATT(fID_ou, vlatID, "units", "degrees_north")
     623    CALL NF95_PUT_ATT(fID_ou, vlevID, "units", "millibar")
     624    CALL NF95_PUT_ATT(fID_ou, vtimID, "units", "days since 2000-1-1")
     625    IF(ndims==4) &
     626    CALL NF95_PUT_ATT(fID_ou, vlonID, "standard_name", "longitude")
     627    CALL NF95_PUT_ATT(fID_ou, vlatID, "standard_name", "latitude")
     628    CALL NF95_PUT_ATT(fID_ou, vlevID, "standard_name", "air_pressure")
     629    CALL NF95_PUT_ATT(fID_ou, vtimID, "standard_name", "time")
     630    CALL NF95_PUT_ATT(fID_ou, vlevID, "long_name",     "air pressure")
     631    CALL NF95_PUT_ATT(fID_ou, vtimID, "calendar",      cal_ou)
    452632
    453633  !--- Define the main variables:
    454   IF(ndims==3) dIDs(1:3) = [ dlatID, dlevID, dtimID]
    455   IF(ndims==4) dIDs=[dlonID, dlatID, dlevID, dtimID]
    456   CALL NF95_DEF_VAR(fID_ou, vars_in(1), NF90_FLOAT, dIDs(1:ndims), vID_ou(1))
    457   CALL NF95_PUT_ATT(fID_ou, vID_ou(1), "long_name", "ozone mole fraction")
    458   CALL NF95_PUT_ATT(fID_ou, vID_ou(1), "standard_name", "mole_fraction_of_ozone&
     634    IF(ndims==3) dIDs(1:3) = [ dlatID, dlevID, dtimID]
     635    IF(ndims==4) dIDs=[dlonID, dlatID, dlevID, dtimID]
     636    CALL NF95_DEF_VAR(fID_ou, vars_in(1), NF90_FLOAT, dIDs(1:ndims), vID_ou(1))
     637    CALL NF95_PUT_ATT(fID_ou, vID_ou(1), "long_name", "ozone mole fraction")
     638    CALL NF95_PUT_ATT(fID_ou, vID_ou(1), "standard_name", "mole_fraction_of_ozone&
    459639      &_in_air")
    460   IF(SIZE(vID_ou) == 2) THEN
    461     CALL NF95_DEF_VAR(fID_ou, vars_in(2), NF90_FLOAT, dIDs(1:ndims), vID_ou(2))
    462     CALL NF95_PUT_ATT(fID_ou, vID_ou(2), "long_name","ozone mole fraction in da&
    463       &ylight")
    464   END IF
     640    IF(SIZE(vID_ou) == 2) THEN
     641      CALL NF95_DEF_VAR(fID_ou, vars_in(2), NF90_FLOAT, dIDs(1:ndims), vID_ou(2))
     642      CALL NF95_PUT_ATT(fID_ou, vID_ou(2), "long_name","ozone mole fraction in da&
     643        &ylight")
     644    END IF
    465645
    466646  !--- Global attributes:
    467647  ! The following commands, copying attributes, may fail. That is OK.
    468648  ! It should just mean that the attribute is not defined in the input file.
    469   CALL NF95_COPY_ATT(fID_in,NF90_GLOBAL,"Conventions",fID_ou,NF90_GLOBAL, ncerr)
    470   CALL handle_err_copy_att("Conventions")
    471   CALL NF95_COPY_ATT(fID_in,NF90_GLOBAL,"title",      fID_ou,NF90_GLOBAL, ncerr)
    472   CALL handle_err_copy_att("title")
    473   CALL NF95_COPY_ATT(fID_in,NF90_GLOBAL,"institution",fID_ou,NF90_GLOBAL, ncerr)
    474   CALL handle_err_copy_att("institution")
    475   CALL NF95_COPY_ATT(fID_in,NF90_GLOBAL,"source",     fID_ou,NF90_GLOBAL, ncerr)
    476   CALL handle_err_copy_att("source")
    477   CALL NF95_PUT_ATT (fID_ou,NF90_GLOBAL,"comment", "Regridded for LMDZ")
    478   CALL NF95_ENDDEF(fID_ou)
    479 
    480   !--- Write one of the coordinate variables:
    481   IF(ndims==4) CALL NF95_PUT_VAR(fID_ou, vlonID, lon_reg/deg2rad)
    482   CALL NF95_PUT_VAR(fID_ou, vlatID, lat_reg(nlat_ou:1:-1)/deg2rad)
    483   !    (convert from rad to degrees and sort in ascending order)
    484 
     649    CALL NF95_COPY_ATT(fID_in,NF90_GLOBAL,"Conventions",fID_ou,NF90_GLOBAL, ncerr)
     650    CALL handle_err_copy_att("Conventions")
     651    CALL NF95_COPY_ATT(fID_in,NF90_GLOBAL,"title",      fID_ou,NF90_GLOBAL, ncerr)
     652    CALL handle_err_copy_att("title")
     653    CALL NF95_COPY_ATT(fID_in,NF90_GLOBAL,"institution",fID_ou,NF90_GLOBAL, ncerr)
     654    CALL handle_err_copy_att("institution")
     655    CALL NF95_COPY_ATT(fID_in,NF90_GLOBAL,"source",     fID_ou,NF90_GLOBAL, ncerr)
     656    CALL handle_err_copy_att("source")
     657    CALL NF95_PUT_ATT (fID_ou,NF90_GLOBAL,"comment", "Regridded for LMDZ")
     658    CALL NF95_ENDDEF(fID_ou)
     659
     660    IF (grid_type==unstructured) THEN
     661      CALL NF95_PUT_VAR(fID_ou, vlatID, latitude_glo)
     662    ELSE
     663      !--- Write one of the coordinate variables:
     664      IF(ndims==4) CALL NF95_PUT_VAR(fID_ou, vlonID, lon_reg/deg2rad)
     665      CALL NF95_PUT_VAR(fID_ou, vlatID, lat_reg(nlat_ou:1:-1)/deg2rad)
     666    !    (convert from rad to degrees and sort in ascending order)
     667    ENDIF
     668  ENDIF
     669 
    485670CONTAINS
    486671
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/phylmd/regr_pr_time_av_m.F90

    r2981 r3406  
    106106  USE assert_m,       ONLY: assert
    107107  USE assert_eq_m,    ONLY: assert_eq
    108   USE comvert_mod,    ONLY: scaleheight
     108!!  USE comvert_mod,    ONLY: scaleheight
    109109  USE interpolation,  ONLY: locate
    110110  USE regr_conserv_m, ONLY: regr_conserv
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/phylmd/rrtm/suinit.F90

    r1990 r3406  
    126126ALLOCATE(VDELA  (MAX(JPMXLE,NFLEVG)))
    127127ALLOCATE(VDELB  (MAX(JPMXLE,NFLEVG)))
     128VDELB = 0  !ym missing init
    128129ALLOCATE( VC      (NFLEVG) )
     130VC = 0    !ym missing init
    129131ALLOCATE( NLOEN   (NPROMA) )
    130132ALLOCATE( NLOENG   (NPROMA) )
  • LMDZ6/branches/DYNAMICO-conv-GC/libf/phylmd/slab_heat_transp_mod.F90

    r3002 r3406  
    8484                                  aire_,apoln_,apols_, &
    8585                                  aireu_,airev_,rlatv)
    86     USE comconst_mod, ONLY: omeg, rad
     86    !!USE comconst_mod, ONLY: omeg, rad
    8787    ! number of points in lon, lat
    8888    IMPLICIT NONE
     
    104104    REAL,INTENT(IN) :: airev_(ip1jm)
    105105    REAL,INTENT(IN) :: rlatv(nbp_lat-1)
     106    REAL            :: omeg = 7.272205e-05
     107    REAL            :: rad = 6371229.
    106108
    107109    ! Sanity check on dimensions
  • LMDZ6/branches/DYNAMICO-conv-GC/makelmdz_fcm

    r2743 r3406  
    267267  fi
    268268  # source architecture PATH and ENV files
     269  set +e
    269270  source arch.env
    270271  source arch.path
     272  set -e
    271273else
    272274  echo "You must define a target architecture"
     
    324326   CPP_KEY="$CPP_KEY INCA"
    325327   INCLUDE="$INCLUDE -I${INCA_INCDIR}"
    326    LIB="$LIB -L${INCA_LIBDIR} -lchimie"
     328   LIB="$LIB -L${INCA_LIBDIR} ${INCA_LIB}"
    327329fi
    328330
     
    335337        export OASIS_LIBDIR=$LMDGCM/../../prism/X64/lib
    336338        INCLUDE="$INCLUDE -I${OASIS_INCDIR}"
    337         LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.MPI1 -lmpp_io"
     339        LIB="$LIB -L${OASIS_LIBDIR} ${OASIS_LIB}"
    338340    else
    339341        CPP_KEY="$CPP_KEY CPP_COUPLE CPP_OMCT"
    340342        INCLUDE="$INCLUDE -I${OASIS_INCDIR}"
    341         LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.MPI1 -lscrip -lmct -lmpeu"
     343        LIB="$LIB -L${OASIS_LIBDIR} ${OASIS_LIB}"
    342344    fi
    343345fi
     
    372374#    For this case, cpp flag ORCHIDEE_NOOPENMP must be added to the makelmdz_fcm arguments
    373375#    option orchidee1.9 : Compile with ORCHIDEE version up to the inclusion of OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6
    374    INCLUDE="${INCLUDE} -I${ORCH_INCDIR}"
     376   INCLUDE="${INCLUDE} ${ORCHIDEE_INCDIR}"
    375377   CPP_KEY="$CPP_KEY CPP_VEGET"
    376378# temporary, for Orchidee versions 1.9.* (before openmp activation)
     
    383385      orch_libs="sechiba parameters stomate parallel orglob"
    384386   fi
    385    LIB="${LIB} -L${ORCH_LIBDIR}"
    386    for lib in ${orch_libs} ; do
    387       if [ -f ${ORCH_LIBDIR}/lib${LIBPREFIX}$lib.a ] ; then
    388          LIB="${LIB} -l${LIBPREFIX}$lib "
    389       fi
    390    done
     387   LIB="${LIB} -L${ORCHIDEE_LIBDIR} ${ORCHIDEE_LIB}"
    391388elif [[ "$veget" != "false" ]] ; then
    392389   echo "Option -v $veget does not exist"
     
    422419then
    423420   CPP_KEY="$CPP_KEY CPP_IOIPSL"
    424    INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}"
    425    LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl"
     421   INCLUDE="$INCLUDE ${IOIPSL_INCDIR}"
     422   LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB}"
    426423elif [[ $io == mix ]]
    427424then
    428425   # For now, xios implies also using ioipsl
    429426   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS"
    430    INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}"
    431    LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios"
     427   INCLUDE="$INCLUDE ${IOIPSL_INCDIR} ${XIOS_INCDIR}"
     428   LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB} ${XIOS_LIBDIR} ${XIOS_LIB}"
    432429elif [[ $io == xios ]]
    433430then
    434431   # For now, xios implies also using ioipsl
    435432   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT"
    436    INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}"
    437    LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios"
     433   INCLUDE="$INCLUDE ${IOIPSL_INCDIR} ${XIOS_INCDIR}"
     434   LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB} ${XIOS_LIBDIR} ${XIOS_LIB}"
    438435fi
    439436
     
    445442fi
    446443
     444# NETCDF library include/library paths
    447445INCLUDE="$INCLUDE ${NETCDF_INCDIR}"
    448 LIB="$LIB ${NETCDF_LIBDIR}"
     446LIB="$LIB ${NETCDF_LIBDIR} ${NETCDF_LIB}"
    449447
    450448########################################################################
     
    671669
    672670rm -f $LIBOGCM/${arch}${SUFF_NAME}/.config/fcm.bld.lock
     671set +e
    673672./build_gcm ${fcm_path} -j $job $full
     673status=$?
    674674
    675675rm -rf tmp_src
     
    684684  \rm -f $LIBFGCM/grid/dimensions.h
    685685fi
     686
     687if [ $status -ne 0 ]; then
     688  exit $status
     689fi
Note: See TracChangeset for help on using the changeset viewer.