Changeset 5091 for LMDZ6


Ignore:
Timestamp:
Jul 20, 2024, 11:17:09 PM (5 months ago)
Author:
abarral
Message:

Move lmdz_netcdf_format.F90 -> lmdz_cppkeys_wrapper.F90 to handle other CPP keys
Replace all (except wrapper) use of CPP_PHYS by fortran logical
Refactor makelmdz_fcm (put blocks into functions, use modern bash)

Location:
LMDZ6/branches/Amaury_dev
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/branches/Amaury_dev/libf/dyn3d/dynetat0.F90

    r5088 r5091  
    1919  USE temps_mod, ONLY: annee_ref, day_ini, day_ref, itau_dyn, start_time
    2020  USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
     21  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA
    2122
    2223  IMPLICIT NONE
     
    140141    ix = strIdx(newHNO3, var); IF(ix /= 0) oldVar = oldHNO3(ix)                          !--- REPROBUS HNO3 exceptions
    141142#endif
    142 #ifdef INCA
    143     IF(var == 'O3') oldVar = 'OX'                                                        !--- DEAL WITH INCA OZONE EXCEPTION
    144 #endif
     143    IF (CPPKEY_INCA) THEN
     144      IF(var == 'O3') oldVar = 'OX'                                                        !--- DEAL WITH INCA OZONE EXCEPTION
     145    END IF
    145146    !--------------------------------------------------------------------------------------------------------------------------
    146147    IF(NF90_INQ_VARID(fID, var, vID) == NF90_NoErr .AND. .NOT.lSkip) THEN                !=== REGULAR CASE: AVAILABLE VARIABLE
  • LMDZ6/branches/Amaury_dev/libf/dyn3d/integrd.F

    r5082 r5091  
    182182c$$$      IF( iadv(1).NE.3.AND.iadv(2).NE.3 )    THEN
    183183c$$$c
    184 c$$$       IF( forward. OR . leapf )  THEN
     184c$$$       IF( forward .OR. leapf )  THEN
    185185c$$$        DO iq = 1,2
    186186c$$$        DO  l = 1,llm
  • LMDZ6/branches/Amaury_dev/libf/dyn3d/leapfrog.F

    r5090 r5091  
    344344     &           'leapfrog 686: avant caladvtrac')
    345345
    346       IF( forward. OR . leapf )  THEN
     346      IF( forward .OR. leapf )  THEN
    347347! Ehouarn: NB: fields sent to advtrac are those at the beginning of the time step
    348348         CALL caladvtrac(q,pbaru,pbarv,
     
    363363         ENDIF ! of IF (offline)
    364364c
    365       ENDIF ! of IF( forward. OR . leapf )
     365      ENDIF ! of IF( forward .OR. leapf )
    366366
    367367
     
    390390          IF( itau==itaufin.AND..NOT.forward ) lafin = .TRUE.
    391391       ELSE
    392           IF( itau+1. EQ. itaufin )              lafin = .TRUE.
     392          IF( itau+1 == itaufin )              lafin = .TRUE.
    393393       ENDIF
    394394c
     
    634634c       ........................................................
    635635
    636             IF(forward. OR. leapf) THEN
     636            IF(forward .OR. leapf) THEN
    637637              itau= itau + 1
    638638c              iday= day_ini+itau/day_step
     
    645645
    646646
    647             IF( itau. EQ. itaufinp1 ) then 
     647            IF( itau == itaufinp1 ) then
    648648              if (flag_verif) then
    649649                write(79,*) 'ucov',ucov
     
    746746            IF( MOD(itau,iperiod)==0 )    THEN
    747747                    GO TO 1
    748             ELSE IF ( MOD(itau-1,iperiod). EQ. 0 ) THEN
     748            ELSE IF ( MOD(itau-1,iperiod) == 0 ) THEN
    749749
    750750                   IF( forward )  THEN
     
    791791
    792792               forward =  .FALSE.
    793                IF( itau. EQ. itaufinp1 ) then 
     793               IF( itau == itaufinp1 ) then
    794794                 abort_message = 'Simulation finished'
    795795                 call abort_gcm(modname,abort_message,0)
     
    801801              call check_isotopes_seq(q,ip1jmp1,'leapfrog 1698')
    802802
    803               IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin) THEN
    804                IF(itau.EQ.itaufin) THEN
     803              IF(MOD(itau,iperiod)==0 .OR. itau==itaufin) THEN
     804               IF(itau==itaufin) THEN
    805805                  iav=1
    806806               ELSE
     
    826826              ENDIF ! of IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin)
    827827
    828               IF(MOD(itau,iecri         ).EQ.0) THEN
     828              IF(MOD(itau,iecri         )==0) THEN
    829829c              IF(MOD(itau,iecri*day_step).EQ.0) THEN
    830830                CALL geopot(ip1jmp1,teta,pk,pks,phis,phi)
     
    848848              ENDIF ! of IF(MOD(itau,iecri         ).EQ.0)
    849849
    850               IF(itau.EQ.itaufin) THEN
     850              IF(itau==itaufin) THEN
    851851!                if (planet_type.eq."earth") then
    852852                  CALL dynredem1("restart.nc",start_time,
  • LMDZ6/branches/Amaury_dev/libf/dyn3d_common/infotrac.F90

    r5082 r5091  
    117117   USE CHEM_REP,    ONLY: Init_chem_rep_trac
    118118#endif
     119   USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA
    119120   IMPLICIT NONE
    120121!==============================================================================================================================
     
    143144! Local variables
    144145   INTEGER, ALLOCATABLE :: hadv(:), vadv(:)                          !--- Horizontal/vertical transport scheme number
    145 #ifdef INCA
    146146   INTEGER, ALLOCATABLE :: had (:), hadv_inca(:), conv_flg_inca(:), &!--- Variables specific to INCA
    147147                           vad (:), vadv_inca(:),  pbl_flg_inca(:)
    148148   CHARACTER(LEN=8), ALLOCATABLE :: solsym_inca(:)                   !--- Tracers names for INCA
    149149   INTEGER :: nqINCA
    150 #endif
    151150   CHARACTER(LEN=2)      ::   suff(9)                                !--- Suffixes for schemes of order 3 or 4 (Prather)
    152151   CHARACTER(LEN=3)      :: descrq(30)                               !--- Advection scheme description tags
     
    197196   SELECT CASE(type_trac)
    198197      CASE('inca', 'inco')
    199 #ifndef INCA
     198      IF (CPPKEY_INCA) THEN
    200199         CALL abort_gcm(modname, 'You must add cpp key INCA and compile with INCA code', 1)
    201 #endif
     200      END IF
    202201      CASE('repr')
    203202#ifndef REPROBUS
     
    229228   IF(fType == 1 .AND. ANY(['inca','inco']==type_trac)) THEN         !=== FOUND OLD STYLE INCA "traceur.def"
    230229   !---------------------------------------------------------------------------------------------------------------------------
    231 #ifdef INCA
     230   IF (CPPKEY_INCA) THEN
    232231      nqo = SIZE(tracers) - nqCO2
    233232      CALL Init_chem_inca_trac(nqINCA)                               !--- Get nqINCA from INCA
     
    260259      IF(setGeneration(tracers)) CALL abort_gcm(modname,'See above',1) !- SET FIELDS %iGeneration, %gen0Name
    261260      DEALLOCATE(had, hadv_inca, vad, vadv_inca, conv_flg_inca, pbl_flg_inca, solsym_inca)
    262 #endif
     261   END IF
    263262   !---------------------------------------------------------------------------------------------------------------------------
    264263   ELSE                                                              !=== OTHER CASES (OLD OR NEW FORMAT, NO INCA MODULE)
     
    269268      nbtr   = nqtrue-COUNT(delPhase(tracers(:)%gen0Name) == 'H2O' &
    270269                               .AND. tracers(:)%component == 'lmdz') !--- Number of tracers passed to phytrac
    271 #ifdef INCA
     270   IF (CPPKEY_INCA) THEN
    272271      nqINCA = COUNT(tracers(:)%component == 'inca')
    273 #endif
     272   END IF
    274273      lerr = getKey('hadv', hadv, ky=tracers(:)%keys)
    275274      lerr = getKey('vadv', vadv, ky=tracers(:)%keys)
     
    400399   CALL msg('niso   = '//TRIM(int2str(niso)),   modname)
    401400   CALL msg('ntiso  = '//TRIM(int2str(ntiso)),  modname)
    402 #ifdef INCA
    403    CALL msg('nqCO2  = '//TRIM(int2str(nqCO2)),  modname)
    404    CALL msg('nqINCA = '//TRIM(int2str(nqINCA)), modname)
    405 #endif
     401   IF (CPPKEY_INCA) THEN
     402      CALL msg('nqCO2  = '//TRIM(int2str(nqCO2)),  modname)
     403      CALL msg('nqINCA = '//TRIM(int2str(nqINCA)), modname)
     404   END IF
    406405   t => tracers
    407406   CALL msg('Information stored in infotrac :', modname)
  • LMDZ6/branches/Amaury_dev/libf/dyn3d_common/inigeom.F

    r5086 r5091  
    348348      DO j = 1, jjp1
    349349c
    350       IF ( j. eq. 1 )  THEN
     350      IF ( j == 1 )  THEN
    351351c
    352352      yprm           = yprimu1(j)
     
    378378      END IF
    379379c
    380       IF ( j. eq. jjp1 )  THEN
     380      IF ( j == jjp1 )  THEN
    381381       yprp               = yprimu2(j-1)
    382382       rlatp              = rlatu2 (j-1)
  • LMDZ6/branches/Amaury_dev/libf/dyn3dmem/dynetat0_loc.F90

    r5088 r5091  
    2020  USE temps_mod, ONLY: annee_ref, day_ini, day_ref, itau_dyn, start_time
    2121  USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
     22  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA
    2223
    2324  IMPLICIT NONE
     
    165166    ix = strIdx(newHNO3, var); IF(ix /= 0) oldVar = oldHNO3(ix)                          !--- REPROBUS HNO3 exceptions
    166167#endif
    167 #ifdef INCA
    168     IF(var == 'O3') oldVar = 'OX'                                                        !--- DEAL WITH INCA OZONE EXCEPTION
    169 #endif
     168    IF (CPPKEY_INCA) THEN
     169      IF(var == 'O3') oldVar = 'OX'                                                        !--- DEAL WITH INCA OZONE EXCEPTION
     170    END IF
    170171    !--------------------------------------------------------------------------------------------------------------------------
    171172    IF(NF90_INQ_VARID(fID, var, vID) == NF90_NoErr .AND. .NOT.lSkip) THEN                !=== REGULAR CASE: AVAILABLE VARIABLE
  • LMDZ6/branches/Amaury_dev/libf/dyn3dmem/filtreg_p.F

    r5082 r5091  
    361361
    362362            IF (jdfil<=jffil) THEN
    363                IF( ifiltre. EQ. -2 )   THEN
     363               IF( ifiltre == -2 )   THEN
    364364                  CALL Filtre_inv_fft(champ_fft,nlat,jdfil,jffil,nbniv)
    365365               ELSE IF ( griscal )     THEN
  • LMDZ6/branches/Amaury_dev/libf/dyn3dmem/leapfrog_loc.F

    r5082 r5091  
    4646     &                      xios_set_current_context,
    4747     &                      using_xios
     48       USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA
    4849       
    4950      IMPLICIT NONE
     
    313314c   -----
    314315
    315       jD_cur = jD_ref + day_ini - day_ref +                             &
     316      jD_cur = jD_ref + day_ini - day_ref +
    316317     &          (itau+1)/day_step
    317       jH_cur = jH_ref + start_time +                                    &
     318      jH_cur = jH_ref + start_time +
    318319     &         mod(itau+1,day_step)/float(day_step)
    319320      if (jH_cur > 1.0 ) then
     
    494495      if (Adjust) then
    495496        AdjustCount=AdjustCount+1
    496 !        if (iapptrac==iapp_tracvl .and. (forward. OR . leapf)
     497!        if (iapptrac==iapp_tracvl .and. (forward .OR. leapf)
    497498!     &         .and. itau/iphysiq>2 .and. Adjustcount>30) then
    498499        if (Adjustcount>1) then
     
    714715     &           'leapfrog 686: avant caladvtrac')
    715716     
    716       IF( forward. OR . leapf )  THEN
     717      IF( forward .OR. leapf )  THEN
    717718! Ehouarn: NB: fields sent to advtrac are those at the beginning of the time step
    718719        !write(*,*) 'leapfrog 679: avant CALL caladvtrac_loc'
     
    736737! Ehouarn: Storage of mass flux for off-line tracers... not implemented...
    737738
    738       ENDIF ! of IF( forward. OR . leapf )
     739      ENDIF ! of IF( forward .OR. leapf )
    739740
    740741
     
    808809          IF( itau==itaufin.AND..NOT.forward ) lafin = .TRUE.
    809810       ELSE
    810           IF( itau+1. EQ. itaufin )              lafin = .TRUE.
     811          IF( itau+1 == itaufin )              lafin = .TRUE.
    811812       ENDIF
    812813
     
    15191520         endif
    15201521
    1521 #ifdef INCA
     1522         IF (CPPKEY_INCA) THEN
    15221523         IF (ANY(type_trac == ['inca','inco'])) THEN
    15231524            CALL finalize_inca
     
    15291530!$OMP END MASTER
    15301531         ENDIF
    1531 #endif
     1532         END IF
    15321533#ifdef REPROBUS
    15331534         if (type_trac == 'repr') CALL finalize_reprobus
     
    15481549c       ........................................................
    15491550
    1550             IF(forward. OR. leapf) THEN
     1551            IF(forward .OR. leapf) THEN
    15511552              itau= itau + 1
    15521553!              iday= day_ini+itau/day_step
     
    15591560
    15601561
    1561             IF( itau. EQ. itaufinp1 ) then
     1562            IF( itau == itaufinp1 ) then
    15621563
    15631564              if (flag_verif) then
     
    15761577c$OMP END MASTER
    15771578
    1578 #ifdef INCA
     1579              IF (CPPKEY_INCA) THEN
    15791580              IF (ANY(type_trac == ['inca','inco'])) THEN
    15801581                 CALL finalize_inca
     
    15861587!$OMP END MASTER
    15871588              ENDIF
    1588 #endif
     1589              END IF
    15891590#ifdef REPROBUS
    15901591              if (type_trac == 'repr') CALL finalize_reprobus
     
    16971698            IF( MOD(itau,iperiod)==0 )    THEN
    16981699                    GO TO 1
    1699             ELSE IF ( MOD(itau-1,iperiod). EQ. 0 ) THEN
     1700            ELSE IF ( MOD(itau-1,iperiod) == 0 ) THEN
    17001701
    17011702                   IF( forward )  THEN
     
    17441745
    17451746               forward =  .FALSE.
    1746                IF( itau. EQ. itaufinp1 ) then 
     1747               IF( itau == itaufinp1 ) then
    17471748c$OMP MASTER
    17481749                 call fin_getparam
    17491750c$OMP END MASTER
    17501751
    1751 #ifdef INCA
     1752                 IF (CPPKEY_INCA) THEN
    17521753                 IF (ANY(type_trac == ['inca','inco'])) THEN
    17531754                    CALL finalize_inca
     
    17601761                 ENDIF
    17611762
    1762 #endif
     1763                 END IF
    17631764#ifdef REPROBUS
    17641765                 if (type_trac == 'repr') CALL finalize_reprobus
     
    17791780              call check_isotopes(q,ijb_u,ije_u,'leapfrog 1698')
    17801781
    1781               IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin) THEN
    1782                IF(itau.EQ.itaufin) THEN
     1782              IF(MOD(itau,iperiod)==0 .OR. itau==itaufin) THEN
     1783               IF(itau==itaufin) THEN
    17831784                  iav=1
    17841785               ELSE
     
    18091810
    18101811
    1811                IF(MOD(itau,iecri         ).EQ.0) THEN
     1812               IF(MOD(itau,iecri         )==0) THEN
    18121813
    18131814c$OMP BARRIER
     
    18371838             
    18381839
    1839               IF(itau.EQ.itaufin) THEN
     1840              IF(itau==itaufin) THEN
    18401841!                if (planet_type.eq."earth") then
    18411842                   CALL dynredem1_loc("restart.nc",0.0,
     
    18631864c$OMP END MASTER
    18641865
    1865 #ifdef INCA
     1866      IF (CPPKEY_INCA) THEN
    18661867      IF (ANY(type_trac == ['inca','inco'])) THEN
    18671868         CALL finalize_inca
     
    18731874!$OMP END MASTER
    18741875      ENDIF
    1875 
    1876 #endif
     1876      END IF
    18771877#ifdef REPROBUS
    18781878      if (type_trac == 'repr') CALL finalize_reprobus
  • LMDZ6/branches/Amaury_dev/libf/dyn3dmem/mod_filtreg_p.F

    r5082 r5091  
    369369
    370370            IF (jdfil<=jffil) THEN
    371                IF( ifiltre. EQ. -2 )   THEN
     371               IF( ifiltre == -2 )   THEN
    372372                CALL Filtre_inv_fft(champ_fft,jjb,jje,jdfil,jffil,nbniv)
    373373               ELSE IF ( griscal )     THEN
  • LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/etat0dyn_netcdf.F90

    r5087 r5091  
    7777  USE infotrac,       ONLY: nqtot, tracers
    7878  USE filtreg_mod
     79  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA
    7980  IMPLICIT NONE
    8081!-------------------------------------------------------------------------------
     
    145146!*******************************************************************************
    146147! Look for ozone tracer:
    147 #ifndef INCA
     148IF (CPPKEY_INCA) THEN
    148149  DO iq=1,nqtot; IF(strLower(tracers(iq)%name)=="o3") EXIT; END DO
    149150  IF(iq/=nqtot+1) THEN
     
    153154    q3d(:,:,:,iq)=q3d(:,:,:,iq)*48./ 29.                !--- Mole->mass fraction         
    154155  END IF
    155 #endif
     156END IF
    156157  q3d(iip1,:,:,:)=q3d(1,:,:,:)
    157158
  • LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/iniphysiq_mod.F90

    r5082 r5091  
    3838  USE phyaqua_mod, ONLY: iniaqua
    3939  USE comconst_mod, ONLY: omeg, rad
    40 #ifdef INCA
    4140  USE indice_sol_mod, ONLY: nbsrf, is_oce, is_sic, is_ter, is_lic
    4241#ifdef CPP_PARA
     
    4544#endif
    4645  USE mod_phys_lmdz_omp_data, ONLY: klon_omp
    47 #endif
    4846  USE ioipsl_getin_p_mod, ONLY: getin_p
    4947  USE slab_heat_transp_mod, ONLY: ini_slab_transp_geom
     48  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA
    5049  IMPLICIT NONE
    5150
     
    167166
    168167  IF (ANY(type_trac == ['inca','inco'])) THEN
    169 #ifdef INCA
     168  IF (CPPKEY_INCA) THEN
    170169     CALL init_inca_dim_reg(nbp_lon, nbp_lat - 1, &
    171170          rlonudyn, rlatudyn, rlonvdyn, rlatvdyn)
    172 #endif
     171  END IF
    173172  END IF
    174173
  • LMDZ6/branches/Amaury_dev/libf/filtrez/filtreg.F

    r5082 r5091  
    181181         END DO
    182182         
    183          IF( hemisph. EQ. 1 )      THEN
    184            
    185             IF( ifiltre. EQ. -2 )   THEN
     183         IF( hemisph == 1 )      THEN
     184           
     185            IF( ifiltre == -2 )   THEN
    186186               
    187187               DO j = jdfil,jffil
     
    229229         ELSE
    230230           
    231             IF( ifiltre. EQ. -2 )   THEN
     231            IF( ifiltre == -2 )   THEN
    232232               
    233233               DO j = jdfil,jffil
  • LMDZ6/branches/Amaury_dev/libf/misc/lmdz_cppkeys_wrapper.F90

    r5090 r5091  
    77!      NC_DOUBLE -> nf90_format
    88!      CPP_PHYS  -> CPPKEY_PHYS
     9!      INCA      -> CPPKEY_INCA
    910! ---------------------------------------------
    1011
     
    1314  USE netcdf, ONLY: nf90_float, nf90_double
    1415  IMPLICIT NONE; PRIVATE
    15   PUBLIC nf90_format, CPPKEY_PHYS
     16  PUBLIC nf90_format, CPPKEY_PHYS, CPPKEY_INCA
    1617
    1718#ifdef NC_DOUBLE
     
    2728#endif
    2829
     30#ifdef INCA
     31  LOGICAL, PARAMETER :: CPPKEY_INCA = .TRUE.
     32#else
     33  LOGICAL, PARAMETER :: CPPKEY_INCA = .FALSE.
     34#endif
     35
    2936END MODULE lmdz_cppkeys_wrapper
  • LMDZ6/branches/Amaury_dev/libf/phy_common/mod_phys_lmdz_mpi_data.F90

    r5082 r5091  
    4949  SUBROUTINE init_phys_lmdz_mpi_data(nbp, nbp_lon, nbp_lat, nbp_lev, grid_type, nvertex, communicator)
    5050  USE lmdz_mpi
     51  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA
    5152  IMPLICIT NONE
    5253    INTEGER,INTENT(IN) :: nbp
     
    174175    CALL Print_module_data
    175176
    176 #ifdef INCA
     177  IF (CPPKEY_INCA) THEN
    177178       CALL init_inca_para( &
    178179            nbp_lon,nbp_lat,nbp_lev,klon_glo,mpi_size, &
    179180            distrib,nvertex, grid_type,communicator)
    180 #endif
     181  END IF
    181182   
    182183  END SUBROUTINE Init_phys_lmdz_mpi_data
  • LMDZ6/branches/Amaury_dev/libf/phy_common/physics_distribution_mod.F90

    r4389 r5091  
    1717  USE CHEM_REP, ONLY : Init_chem_rep_phys
    1818#endif
    19 
     19  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA
    2020  IMPLICIT NONE
    2121    INTEGER,INTENT(IN) :: grid_type
     
    3333    CALL init_dimphy(klon_omp,nbp_lev)
    3434
    35 #ifdef INCA
     35  IF (CPPKEY_INCA) THEN
    3636       CALL Init_inca_dim(klon_omp,nbp_lev)
    37 #endif
     37  END IF
    3838
    3939#ifdef REPROBUS
  • LMDZ6/branches/Amaury_dev/libf/phylmd/infotrac_phy.F90

    r5082 r5091  
    136136   USE CHEM_REP, ONLY: Init_chem_rep_trac
    137137#endif
     138   USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA
    138139   IMPLICIT NONE
    139140!==============================================================================================================================
     
    162163! Local variables
    163164   INTEGER, ALLOCATABLE :: hadv(:), vadv(:)                          !--- Horizontal/vertical transport scheme number
    164 #ifdef INCA
    165165   INTEGER, ALLOCATABLE :: had (:), hadv_inca(:), conv_flg_inca(:), &!--- Variables specific to INCA
    166166                           vad (:), vadv_inca(:),  pbl_flg_inca(:)
    167167   CHARACTER(LEN=8), ALLOCATABLE :: solsym_inca(:)                   !--- Tracers names for INCA
    168168   INTEGER :: nqINCA
    169 #endif
    170169#ifdef CPP_StratAer
    171170   CHARACTER(LEN=maxlen), ALLOCATABLE :: tnames(:)
     
    224223   SELECT CASE(type_trac)
    225224      CASE('inca', 'inco')
    226 #ifndef INCA
     225   IF (CPPKEY_INCA) THEN
    227226         CALL abort_physic(modname, 'You must add cpp key INCA and compile with INCA code', 1)
    228 #endif
     227   END IF
    229228      CASE('repr')
    230229#ifndef REPROBUS
     
    267266   IF(fType == 1 .AND. ANY(['inca','inco']==type_trac) .AND. lInit) THEN  !=== FOUND OLD STYLE INCA "traceur.def"
    268267   !---------------------------------------------------------------------------------------------------------------------------
    269 #ifdef INCA
     268   IF (CPPKEY_INCA) THEN
    270269      nqo = SIZE(tracers) - nqCO2
    271270      CALL Init_chem_inca_trac(nqINCA)                               !--- Get nqINCA from INCA
     
    298297      IF(setGeneration(tracers)) CALL abort_physic(modname,'See below',1) !- SET FIELDS %iGeneration, %gen0Name
    299298      DEALLOCATE(had, hadv_inca, vad, vadv_inca, conv_flg_inca, pbl_flg_inca, solsym_inca)
    300 #endif
     299   END IF
    301300   !---------------------------------------------------------------------------------------------------------------------------
    302301   ELSE                                                              !=== OTHER CASES (OLD OR NEW FORMAT, NO INCA MODULE)
     
    307306      nbtr   = nqtrue-COUNT(delPhase(tracers(:)%gen0Name) == 'H2O' &
    308307                               .AND. tracers(:)%component == 'lmdz') !--- Number of tracers passed to phytrac
    309 #ifdef INCA
     308   IF (CPPKEY_INCA) THEN
    310309      nqINCA = COUNT(tracers(:)%component == 'inca')
    311 #endif
     310   END IF
    312311      lerr = getKey('hadv', hadv, ky=tracers(:)%keys)
    313312      lerr = getKey('vadv', vadv, ky=tracers(:)%keys)
     
    419418   CALL msg('niso   = '//TRIM(int2str(niso)),   modname)
    420419   CALL msg('ntiso  = '//TRIM(int2str(ntiso)),  modname)
    421 #ifdef INCA
    422    CALL msg('nqCO2  = '//TRIM(int2str(nqCO2)),  modname)
    423    CALL msg('nqINCA = '//TRIM(int2str(nqINCA)), modname)
    424 #endif
     420   IF (CPPKEY_INCA) THEN
     421      CALL msg('nqCO2  = '//TRIM(int2str(nqCO2)),  modname)
     422      CALL msg('nqINCA = '//TRIM(int2str(nqINCA)), modname)
     423   END IF
    425424   t => tracers
    426425   CALL msg('Information stored in infotrac_phy :', modname)
  • LMDZ6/branches/Amaury_dev/libf/phylmd/oasis.F90

    r4754 r5091  
    122122    USE mod_phys_lmdz_mpi_data, ONLY: klon_mpi_para_nb
    123123    use config_ocean_skin_m, only: activate_ocean_skin
     124    USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA
    124125
    125126! Local variables
     
    356357
    357358
    358 #ifdef INCA
     359  IF (CPPKEY_INCA) THEN
    359360    IF (dms_cycle_cpl .OR. n2o_cycle_cpl) THEN
    360361       CALL init_inca_oasis(inforecv(idr_ocedms:idr_ocen2o))
    361362    ENDIF
    362 #endif
     363  END IF
    363364 
    364365!************************************************************************************
  • LMDZ6/branches/Amaury_dev/libf/phylmd/physiq_mod.F90

    r5088 r5091  
    111111
    112112
    113 #ifdef INCA
    114113    USE geometry_mod,      ONLY: longitude, latitude, boundslon, boundslat, ind_cell_glo
    115114    USE time_phylmdz_mod,  ONLY: ndays
    116115    USE infotrac_phy,      ONLY: nqCO2
    117 #endif
    118116#ifdef REPROBUS
    119117    USE chem_rep, ONLY: Init_chem_rep_xjour, d_q_rep, d_ql_rep, d_qi_rep, &
     
    122120    USE strataer_emiss_mod, ONLY: strataer_emiss_init
    123121#endif
    124 #if defined INCA || defined REPROBUS
    125122    USE time_phylmdz_mod,    ONLY: annee_ref, day_ini, day_ref, start_time
    126123    USE vertical_layers_mod, ONLY: aps, bps, ap, bp
    127 #endif
    128124
    129125
     
    367363       reffclwc, cldnvi, lcc3d, lcc3dcon, lcc3dstra, icc3dcon, icc3dstra
    368364       USE output_physiqex_mod, ONLY: output_physiqex
     365    USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA
    369366
    370367
     
    12381235    REAL, dimension(klon, klev) :: cldfrarad   ! fraction nuageuse
    12391236
    1240 #ifdef INCA
    12411237    REAL :: calday, zxsnow_dummy(klon)
    12421238    ! set de variables utilisees pour l'initialisation des valeurs provenant de INCA
     
    12451241    REAL, DIMENSION(klon,klev,naero_grp,nbands) :: init_cginca
    12461242    REAL, DIMENSION(klon,klev,nbands) :: init_ccminca
    1247 #endif
    12481243    REAL, DIMENSION(klon,nbtr) :: init_source
    12491244
     
    21812176       !
    21822177       IF (ANY(type_trac == ['inca','inco'])) THEN ! ModThL
    2183 #ifdef INCA
     2178IF (CPPKEY_INCA) THEN
    21842179          CALL VTe(VTphysiq)
    21852180          CALL VTb(VTinca)
     
    22592254          CALL VTe(VTinca)
    22602255          CALL VTb(VTphysiq)
    2261 #endif
     2256END IF
    22622257       ENDIF
    22632258       !
     
    26362631             B=Z2-fac*alog(pplay(i,itroprep(i)))
    26372632             ttrop(i)= fac*alog(ptrop(i))+B
    2638 !       
     2633!
    26392634             Z1= 1.e-3 * ( pphi(i,itroprep(i)+1)+pphis(i) ) / gravit
    26402635             Z2= 1.e-3 * ( pphi(i,itroprep(i))  +pphis(i) ) / gravit
     
    41564151
    41574152    IF (ANY(type_trac == ['inca','inco'])) THEN ! ModThL
    4158 #ifdef INCA
     4153IF (CPPKEY_INCA) THEN
    41594154       CALL VTe(VTphysiq)
    41604155       CALL VTb(VTinca)
     
    42094204       CALL VTe(VTinca)
    42104205       CALL VTb(VTphysiq)
    4211 #endif
     4206END IF
    42124207    ENDIF !type_trac = inca or inco
    42134208    IF (type_trac == 'repr') THEN
     
    45004495
    45014496       IF (aerosol_couple.AND.config_inca=='aero') THEN
    4502 #ifdef INCA
     4497IF (CPPKEY_INCA) THEN
    45034498          CALL radlwsw_inca  &
    45044499               (chemistry_couple, kdlon,kflev,dist, rmu0, fract, solaire, &
     
    45204515               cldtaupirad, &
    45214516               topswai_aero, solswai_aero)
    4522 #endif
     4517END IF
    45234518       ELSE
    45244519          !
     
    55055500    !
    55065501    IF (ANY(type_trac == ['inca','inco'])) THEN
    5507 #ifdef INCA
     5502IF (CPPKEY_INCA) THEN
    55085503       CALL VTe(VTphysiq)
    55095504       CALL VTb(VTinca)
     
    55255520       CALL VTe(VTinca)
    55265521       CALL VTb(VTphysiq)
    5527 #endif
     5522END IF
    55285523    ENDIF
    55295524
     
    57815776       IF (using_xios) THEN
    57825777
    5783 #ifdef INCA
     5778IF (CPPKEY_INCA) THEN
    57845779          IF (type_trac == 'inca') THEN
    57855780             IF (is_omp_master .AND. grid_type==unstructured) THEN
     
    57875782             ENDIF
    57885783          ENDIF
    5789 #endif
     5784END IF
    57905785
    57915786          IF (is_omp_master .and. grid_type==unstructured) CALL xios_context_finalize
  • LMDZ6/branches/Amaury_dev/libf/phylmd/phytrac_mod.F90

    r5087 r5091  
    10731073
    10741074          ! *********   end old version
    1075        ENDIF  !  iflag_lscav . EQ. 1, 2, 3 or 4
     1075       ENDIF  !  iflag_lscav  .EQ. 1, 2, 3 or 4
    10761076       !
    10771077    ENDIF !  lessivage
  • LMDZ6/branches/Amaury_dev/libf/phylmd/tracinca_mod.F90

    r4500 r5091  
    6262    USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
    6363    USE aero_mod, ONLY : naero_grp
     64    USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA
    6465    IMPLICIT NONE
    6566   
     
    145146    END DO
    146147 
    147 #ifdef INCA
     148IF (CPPKEY_INCA) THEN
    148149    IF (config_inca == 'aero' .OR. config_inca == 'chem') THEN
    149150       zpmfu(:,:)=pmfu(:,:)       
     
    159160         rh,tau_aero,piz_aero,cg_aero,   &
    160161         rfname,ccm,lafin)
    161 #endif
    162 
    163 
    164 #ifdef INCA
     162
    165163    CALL chemmain (tr_seri, &   !mmr
    166164         nstep,      & !nstep
     
    198196         nbp_lat,    & !ny
    199197         source )
    200 #endif
     198END IF
    201199   
    202200    CALL VTe(VTinca)
  • LMDZ6/branches/Amaury_dev/libf/phylmdiso/physiq_mod.F90

    r5088 r5091  
    9393    USE phys_output_var_mod, ONLY :      cloudth_sth,cloudth_senv,cloudth_sigmath,cloudth_sigmaenv
    9494    USE phys_output_var_mod, ONLY : cloud_cover_sw, cloud_cover_sw_s2
     95    USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA
    9596
    9697
     
    111112
    112113
    113 #ifdef INCA
    114114    USE geometry_mod,      ONLY: longitude, latitude, boundslon, boundslat, ind_cell_glo
    115115    USE time_phylmdz_mod,  ONLY: ndays
    116116    USE infotrac_phy,      ONLY: nqCO2
    117 #endif
    118117#ifdef REPROBUS
    119118    USE chem_rep, ONLY: Init_chem_rep_xjour, d_q_rep, d_ql_rep, d_qi_rep, &
     
    122121    USE strataer_emiss_mod, ONLY: strataer_emiss_init
    123122#endif
    124 #if defined INCA || defined REPROBUS
    125123    USE time_phylmdz_mod,    ONLY: annee_ref, day_ini, day_ref, start_time
    126124    USE vertical_layers_mod, ONLY: aps, bps, ap, bp
    127 #endif
    128125
    129126
     
    13431340    REAL, dimension(klon, klev) :: cldfrarad   ! fraction nuageuse
    13441341
    1345 #ifdef INCA
    13461342    REAL :: calday, zxsnow_dummy(klon)
    13471343    ! set de variables utilisees pour l'initialisation des valeurs provenant de INCA
     
    13501346    REAL, DIMENSION(klon,klev,naero_grp,nbands) :: init_cginca
    13511347    REAL, DIMENSION(klon,klev,nbands) :: init_ccminca
    1352 #endif
    13531348    REAL, DIMENSION(klon,nbtr) :: init_source
    13541349
     
    23412336       !
    23422337       IF (ANY(type_trac == ['inca','inco'])) THEN ! ModThL
    2343 #ifdef INCA
     2338IF (CPPKEY_INCA) THEN
    23442339          CALL VTe(VTphysiq)
    23452340          CALL VTb(VTinca)
     
    24192414          CALL VTe(VTinca)
    24202415          CALL VTb(VTphysiq)
    2421 #endif
     2416END IF
    24222417       ENDIF
    24232418       !
     
    29952990             B=Z2-fac*alog(pplay(i,itroprep(i)))
    29962991             ttrop(i)= fac*alog(ptrop(i))+B
    2997 !       
     2992!
    29982993             Z1= 1.e-3 * ( pphi(i,itroprep(i)+1)+pphis(i) ) / gravit
    29992994             Z2= 1.e-3 * ( pphi(i,itroprep(i))  +pphis(i) ) / gravit
     
    56115606
    56125607    IF (ANY(type_trac == ['inca','inco'])) THEN ! ModThL
    5613 #ifdef INCA
     5608IF (CPPKEY_INCA) THEN
    56145609       CALL VTe(VTphysiq)
    56155610       CALL VTb(VTinca)
     
    56645659       CALL VTe(VTinca)
    56655660       CALL VTb(VTphysiq)
    5666 #endif
     5661END IF
    56675662    ENDIF !type_trac = inca or inco
    56685663    IF (type_trac == 'repr') THEN
     
    59545949
    59555950       IF (aerosol_couple.AND.config_inca=='aero') THEN
    5956 #ifdef INCA
     5951IF (CPPKEY_INCA) THEN
    59575952          CALL radlwsw_inca  &
    59585953               (chemistry_couple, kdlon,kflev,dist, rmu0, fract, solaire, &
     
    59745969               cldtaupirad, &
    59755970               topswai_aero, solswai_aero)
    5976 #endif
     5971END IF
    59775972       ELSE
    59785973          !
     
    70857080    !
    70867081    IF (ANY(type_trac == ['inca','inco'])) THEN
    7087 #ifdef INCA
     7082IF (CPPKEY_INCA) THEN
    70887083       CALL VTe(VTphysiq)
    70897084       CALL VTb(VTinca)
     
    71057100       CALL VTe(VTinca)
    71067101       CALL VTb(VTphysiq)
    7107 #endif
     7102END IF
    71087103    ENDIF
    71097104
     
    74127407       IF (using_xios) THEN
    74137408
    7414 #ifdef INCA
     7409IF (CPPKEY_INCA) THEN
    74157410          IF (type_trac == 'inca') THEN
    74167411             IF (is_omp_master .AND. grid_type==unstructured) THEN
     
    74187413             ENDIF
    74197414          ENDIF
    7420 #endif
     7415END IF
    74217416
    74227417          IF (is_omp_master .and. grid_type==unstructured) CALL xios_context_finalize
  • LMDZ6/branches/Amaury_dev/makelmdz_fcm

    r5089 r5091  
    5050  arch_default_path="arch"
    5151
    52   LMDGCM=$(/bin/pwd)
     52  LMDGCM=$(pwd)
    5353  LIBOGCM=$LMDGCM/libo
    5454  LIBFGCM=$LMDGCM/libf
     
    278278  mkdir .void_dir
    279279
    280   if [[ "$arch_defined" == "TRUE" ]]; then
     280  if [[ "$arch_defined" = "TRUE" ]]; then
    281281    local i
    282282    for i in "path" "fcm" "env"; do
     
    300300}
    301301
    302 init_vars
    303 read_cmdline_options "$@"
    304 init_arch
    305 
    306302function cpp_keys_and_include_mod_path() {
    307303  ########################################################################
     
    336332  fi
    337333
    338   if [[ "$filtre" = "filtrez" ]]; then
     334  if [[ $filtre = "filtrez" ]]; then
    339335     FILTRE_PATH=${LIBFGCM}/$filtre
    340336  fi
    341337
    342   if [[ "$chimie" = "INCA" ]]; then
     338  if [[ $chimie = "INCA" ]]; then
    343339     CPP_KEY="$CPP_KEY INCA"
    344340     INCLUDE="$INCLUDE ${INCA_INCDIR}"
     
    346342  fi
    347343
    348   if [[ "$isotopes" = "true" ]]; then
     344  if [[ $isotopes = "true" ]]; then
    349345     CPP_KEY="$CPP_KEY ISO"
    350346  fi
    351347
    352   if [[ "$isoverif" = "true" ]]; then
     348  if [[ $isoverif = "true" ]]; then
    353349     CPP_KEY="$CPP_KEY ISOVERIF"
    354350  fi
    355351
    356   if [[ "$diagiso" = "true" ]]; then
     352  if [[ $diagiso = "true" ]]; then
    357353     CPP_KEY="$CPP_KEY DIAGISO"
    358354  fi
    359355
    360   if [[ "$isotrac" = "true" ]]; then
     356  if [[ $isotrac = "true" ]]; then
    361357     CPP_KEY="$CPP_KEY ISOTRAC"
    362358  fi
    363359
    364   if [[ "$couple" != "false" ]]; then
    365       if [[ "$couple" = "MPI1" ]]; then
     360  if [[ $couple != "false" ]]; then
     361      if [[ $couple = "MPI1" ]]; then
    366362        CPP_KEY="$CPP_KEY CPP_COUPLE"
    367363        export OASIS_INCDIR=$LMDGCM/../../prism/X64/build/lib/psmile.MPI1
     
    376372  fi
    377373
    378   if [[ "$parallel" = "mpi" ]]; then
     374  if [[ $parallel = "mpi" ]]; then
    379375     CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI"
    380376     PARA_FFLAGS="%MPI_FFLAGS"
    381377     PARA_LD="%MPI_LD"
    382   elif [[ "$parallel" = "omp" ]]; then
     378  elif [[ $parallel = "omp" ]]; then
    383379     CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP"
    384380     PARA_FFLAGS="%OMP_FFLAGS"
    385381     PARA_LD="%OMP_LD"
    386   elif [[ "$parallel" = "mpi_omp" ]]; then
     382  elif [[ $parallel = "mpi_omp" ]]; then
    387383     CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP"
    388384     PARA_FFLAGS="%MPI_FFLAGS %OMP_FFLAGS"
     
    390386  fi
    391387
    392   if [[ ( "$parallel" = "omp" || "$parallel" = "mpi_omp" ) && "$compil_mod" = "debug" ]]; then
     388  if [[ ( $parallel = "omp" || $parallel = "mpi_omp" ) && $compil_mod = "debug" ]]; then
    393389      echo "Usually, parallelization with OpenMP requires some optimization."
    394390      echo "We suggest switching to \"-dev\"."
    395391  fi
    396392
    397 if [[ "$veget" = "true" || "$veget" = "orchidee1.9" || "$veget" = "orchidee2.0" \
    398    || "$veget" = "orchidee2.1" || "$veget" = "orchideetrunk" ]]; then
     393if [[ $veget = "true" || $veget = "orchidee1.9" || $veget = "orchidee2.0" \
     394   || $veget = "orchidee2.1" || $veget = "orchideetrunk" ]]; then
    399395        echo "doing orchidee"
    400396#NB: option 'true': for backward compatibility. To be used with ORCHIDEE tag 1.9-1.9.6
     
    404400   CPP_KEY="$CPP_KEY CPP_VEGET"
    405401# temporary, for Orchidee versions 1.9.* (before openmp activation)
    406    if [[ "$veget" == "orchidee1.9" ]] ; then
     402   if [[ "$veget" = "orchidee1.9" ]]; then
    407403      CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP"
    408404    fi
     
    421417    echo "orchidee lib"
    422418    echo "${LIB}"
    423   elif [[ "$veget" != "false" ]]; then
     419  elif [[ $veget != "false" ]]; then
    424420    echo "Option -v $veget does not exist"
    425421    echo "Use ./makelmdz_fcm -h for more information"
     
    427423  fi
    428424
    429   if [[ "$inlandsis" = "true" ]]; then
     425  if [[ $inlandsis = "true" ]]; then
    430426     CPP_KEY="$CPP_KEY CPP_INLANDSIS"
    431427     INLANDSIS_PATH="$LIBFGCM/phy${physique}/inlandsis"
    432428  fi
    433429
    434   if [[ "$rad" = "rrtm" ]]; then
     430  if [[ $rad = "rrtm" ]]; then
    435431     CPP_KEY="$CPP_KEY CPP_RRTM"
    436432     RAD_PATH="$LIBFGCM/phy${physique}/rrtm"
    437   fi
    438   if [[ "$rad" = "ecrad" ]]; then
     433  elif [[ $rad = "ecrad" ]]; then
    439434     CPP_KEY="$CPP_KEY CPP_ECRAD"
    440435     RAD_PATH="$LIBFGCM/phy${physique}/ecrad"
    441436  fi
    442437
    443   if [[ "$dust" = "true" ]]; then
     438  if [[ $dust = "true" ]]; then
    444439     CPP_KEY="$CPP_KEY CPP_Dust"
    445440     DUST_PATH="$LIBFGCM/phy${physique}/Dust"
    446441  fi
    447442
    448   if [[ "$strataer" = "true" ]]; then
     443  if [[ $strataer = "true" ]]; then
    449444     CPP_KEY="$CPP_KEY CPP_StratAer"
    450445     STRATAER_PATH="$LIBFGCM/phy${physique}/StratAer"
     
    454449  LIB="$LIB ${NETCDF95_LIBDIR} ${NETCDF95_LIB}"
    455450
    456   if [[ $io = ioipsl ]]; then
     451  if [[ $io = "ioipsl" ]]; then
    457452     CPP_KEY="$CPP_KEY CPP_IOIPSL"
    458453     INCLUDE="$INCLUDE ${IOIPSL_INCDIR}"
    459454     LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB}"
    460   elif [[ $io = mix ]]; then
    461      # For now, xios implies also using ioipsl
     455  elif [[ $io = "mix" ]]; then
    462456     CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS"
    463457     INCLUDE="$INCLUDE ${IOIPSL_INCDIR} ${XIOS_INCDIR}"
    464458     LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB} ${XIOS_LIBDIR} ${XIOS_LIB}"
    465   elif [[ $io = xios ]]; then
    466      # For now, xios implies also using ioipsl
     459  elif [[ $io = "xios" ]]; then
    467460     CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT"
    468461     INCLUDE="$INCLUDE ${IOIPSL_INCDIR} ${XIOS_INCDIR}"
     
    470463  fi
    471464
    472   if [[ "$cosp" = "true" ]]; then
     465  if [[ $cosp = "true" ]]; then
    473466     CPP_KEY="$CPP_KEY CPP_COSP"
    474467     COSP_PATH="$LIBFGCM/phylmd/cosp"
    475468  fi
    476469
    477   if [[ "$cosp2" = "true" ]]; then
     470  if [[ $cosp2 = "true" ]]; then
    478471     CPP_KEY="$CPP_KEY CPP_COSP2"
    479472     COSP_PATH="$LIBFGCM/phylmd/cosp2"
    480473  fi
    481474
    482   if [[ "$cospv2" = "true" ]]; then
     475  if [[ $cospv2 = "true" ]]; then
    483476     CPP_KEY="$CPP_KEY CPP_COSPV2"
    484477     COSP_PATH="$LIBFGCM/phylmd/cospv2"
    485478  fi
    486479
    487   if [[ "$cplocninca" = "TRUE" ]]; then
     480  if [[ $cplocninca = "TRUE" ]]; then
    488481      CPP_KEY="${CPP_KEY} CPP_CPLOCNINCA"
    489482  fi
     
    494487}
    495488
    496 cpp_keys_and_include_mod_path
    497 
    498 
    499 ########################################################################
    500 # calcul du nombre de dimensions
    501 ########################################################################
    502 
    503 
    504 dim_full=$dim
    505 dim=`echo $dim | sed -e 's/[^0-9]/ /g'`
    506 set $dim
    507 dimc=$#
    508 echo calcul de la dimension
    509 echo dim $dim
    510 echo dimc $dimc
    511 
    512 
    513 ########################################################################
    514 # Gestion des dimensions du modele.
    515 # on cree ou remplace le fichier des dimensions
    516 ########################################################################
    517 
    518 cd $LIBFGCM/grid
    519 if [[ -f dimensions.h ]]
    520 then
    521     if [[ $force_compile == true ]]
    522     then
    523         \rm -f $LIBFGCM/grid/dimensions.h
     489function handle_dimension() {
     490  ########################################################################
     491  # calcul du nombre de dimensions
     492  ########################################################################
     493
     494  dim_full=$dim
     495  dim=$(echo "$dim" | sed -e 's/[^0-9]/ /g')
     496  dimc=$(awk -F" " '{print NF}' <<< "$dim")
     497  echo "calcul de la dimension: dim=$dim, dimc=$dimc"
     498 
     499  ########################################################################
     500  # Gestion des dimensions du modele.
     501  # on cree ou remplace le fichier des dimensions
     502  ########################################################################
     503 
     504  cd "$LIBFGCM/grid"
     505  if [[ -f dimensions.h ]]; then
     506      if [[ $force_compile = "true" ]]; then
     507          rm -f "$LIBFGCM/grid/dimensions.h"
     508      else
     509          echo "WARNING: you are probably already compiling the model somewhere else."
     510          echo "Wait until the first compilation is finished before launching this one."
     511          echo "If you are sure that you are not compiling elsewhere, "
     512          echo "If you are sure that you are not compiling elsewhere, then"
     513          echo "rm -f \"$LIBFGCM/grid/dimensions.h\""
     514          echo "before reruning the compilation"
     515          echo "or run makelmdz_fcm with option -force_compile"
     516          exit 1
     517      fi
     518  fi
     519 
     520  cd "$LIBFGCM/grid/dimension"
     521  # shellcheck disable=SC2086
     522  ./makdim $dim
     523  cat "$LIBFGCM/grid/dimensions.h"
     524  cd "$LMDGCM"
     525}
     526
     527function different_dynamics() {
     528  ########################################################################
     529  # Differentes dynamiques (3d, 2d, 1d)
     530  ########################################################################
     531
     532  if [[ $dimc = 3 ]]; then
     533    cd "$LIBFGCM/grid"
     534    rm fxyprim.h
     535    cp -p "fxy_${grille}.h" fxyprim.h
     536  fi
     537
     538  if [[ $dimc = 1 ]]; then
     539    CPP_KEY="$CPP_KEY CPP_1D"
     540    ## no filtre in 1d:
     541    FILTRE_PATH="$LMDGCM/.void_dir"
     542    ## no need to compile all routines in dyn3d_common either:
     543    DYN_COMMON_PATH="$LMDGCM/.void_dir"
     544    ## no need to compile all routines in dynlmdz_phy...;
     545    ## (because key ones are included in 1D main program)
     546    DYN_PHYS_PATH="$LMDGCM/.void_dir"
     547    DYN_PHYS_SUB_PATH="$LMDGCM/.void_dir"
     548  fi
     549
     550  ######################################################################
     551  # Gestion du filtre qui n'existe qu'en 3d.
     552  ######################################################################
     553  if [[ $dimc -gt 2 ]]; then
     554     filtre="FILTRE=$filtre"
     555  else
     556     filtre="FILTRE= L_FILTRE= "
     557  fi
     558  echo "MACRO FILTRE $filtre (dimc=$dimc)"
     559}
     560
     561function create_config_suffix() {
     562  ######################################################################
     563  # Creation du suffixe de la configuration
     564  ######################################################################
     565
     566  SUFF_NAME=_${dim_full}
     567  SUFF_NAME=${SUFF_NAME}_phy${physique}_${rad}
     568
     569  if [[ $parallel != "none" ]]; then
     570    SUFF_NAME=${SUFF_NAME}_para
     571    DYN=dyn${dimc}d${paramem}
     572    if [[ $paramem = "mem" ]]; then
     573        SUFF_NAME=${SUFF_NAME}_${paramem}
    524574    else
    525         echo "WARNING: you are probably already compiling the model somewhere else."
    526         echo "Wait until the first compilation is finished before launching this one."
    527         echo "If you are sure that you are not compiling elsewhere, "
    528         echo "If you are sure that you are not compiling elsewhere, then"
    529         echo rm -f $LIBFGCM/grid/dimensions.h
    530         echo "before reruning the compilation"
    531         echo "or run makelmdz_fcm with option -force_compile"
     575        echo "The version of the dynamics in dyn3dpar is no longer updated."
     576        echo "You should use option \"-mem\"."
    532577        exit 1
    533578    fi
    534 fi
    535 
    536 
    537 
    538 cd $LIBFGCM/grid/dimension
    539 ./makdim $dim
    540 cat $LIBFGCM/grid/dimensions.h
    541 cd $LMDGCM
    542 
    543 
    544 ########################################################################
    545 # Differentes dynamiques (3d, 2d, 1d)
    546 ########################################################################
    547 
    548 dimension=`echo $dim | wc -w`
    549 echo dimension $dimension
    550 
    551 if (( $dimension == 3 ))
    552 then
    553   cd $LIBFGCM/grid
    554   \rm fxyprim.h
    555   cp -p fxy_${grille}.h fxyprim.h
    556 #else
    557 #  echo "Probleme dans les dimensions de la dynamique !!"
    558 #  echo "Non reactive pour l'instant !!!"
    559 fi
    560 
    561 if (( $dimension == 1 ))
    562 then
    563   CPP_KEY="$CPP_KEY CPP_1D"
    564 ## no filtre in 1d:
    565   FILTRE_PATH=$LMDGCM/.void_dir
    566 ## no need to compile all routines in dyn3d_common either:
    567   DYN_COMMON_PATH=$LMDGCM/.void_dir
    568 ## no need to compile all routines in dynlmdz_phy... ;
    569 ## (because key ones are included in 1D main program)
    570   DYN_PHYS_PATH=$LMDGCM/.void_dir
    571   DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir
    572 fi
    573 
    574 ######################################################################
    575 #   Traitement special pour le nouveau rayonnement de Laurent Li.
    576 #   ---> YM desactive pour le traitemement en parallele
    577 ######################################################################
    578 
    579 #if [[ -f $libf/phy$physique/raddim.h ]]
    580 #then
    581 # if [[ -f $libf/phy$physique/raddim.$dimh.h ]]
    582 #then
    583 #  \rm -f $libf/phy$physique/raddim.h
    584 #  cp -p $libf/phy$physique/raddim.$dimh.h $libf/phy$physique/raddim.h
    585 #  echo $libf/phy$physique/raddim.$dimh.h
    586 #  cat $libf/phy$physique/raddim.h
    587 # else
    588 #  echo On peut diminuer la taille de l executable en creant
    589 #  echo le fichier $libf/phy$physique/raddim.$dimh.h
    590 #  \cp -p $libf/phy$physique/raddim.defaut.h $libf/phy$physique/raddim.h
    591 # fi
    592 #fi
    593 
    594 ######################################################################
    595 # Gestion du filtre qui n'existe qu'en 3d.
    596 ######################################################################
    597 
    598 if (( `expr $dimc \> 2` == 1 ))
    599 then
    600    filtre="FILTRE=$filtre"
    601 else
    602    filtre="FILTRE= L_FILTRE= "
    603 fi
    604 echo MACRO FILTRE $filtre
    605 
    606 echo $dimc
    607 
    608 
    609 
    610 ######################################################################
    611 # Creation du suffixe de la configuration
    612 ######################################################################
    613 
    614 
    615 SUFF_NAME=_${dim_full}
    616 SUFF_NAME=${SUFF_NAME}_phy${physique}_${rad}
    617 
    618 if [[ "$parallel" != "none" ]]
    619 then
    620   SUFF_NAME=${SUFF_NAME}_para
    621   DYN=dyn${dimc}d${paramem}
    622   if [[ "$paramem" == "mem" ]]
    623   then
    624       SUFF_NAME=${SUFF_NAME}_${paramem}
    625579  else
    626       echo "The version of the dynamics in dyn3dpar is no longer updated."
    627       echo "You should use option \"-mem\"."
    628       exit 1
    629   fi
    630 else
    631   SUFF_NAME=${SUFF_NAME}_seq
    632   if (( $dimension == 1 ))
    633   then
    634     # dynamics-related routines in"dyn1d" subdirectory of phy${physique}
    635     DYN=phy${physique}/dyn1d
     580    SUFF_NAME=${SUFF_NAME}_seq
     581    if [[ $dimc = 1 ]]; then
     582      # dynamics-related routines in"dyn1d" subdirectory of phy${physique}
     583      DYN=phy${physique}/dyn1d
     584    else
     585      DYN=dyn${dimc}d
     586    fi
     587  fi
     588
     589  if [[ $veget != "false" ]]; then
     590    SUFF_NAME=${SUFF_NAME}_orch
     591  fi
     592
     593  if [[ $dust = "true" ]]; then
     594    SUFF_NAME=${SUFF_NAME}_spla
     595  fi
     596
     597  if [[ $couple != "false" ]]; then
     598    SUFF_NAME=${SUFF_NAME}_couple
     599  fi
     600
     601  if [[ $chimie = "INCA" ]]; then
     602    SUFF_NAME=${SUFF_NAME}_inca
     603  fi
     604
     605  if [[ "$isotopes" = "true" ]]; then
     606    SUFF_NAME=${SUFF_NAME}_iso
     607  fi
     608  if [[ "$isoverif" = "true" ]]; then
     609    SUFF_NAME=${SUFF_NAME}_isoverif
     610  fi
     611  if [[ "$isotrac" = "true" ]]; then
     612    SUFF_NAME=${SUFF_NAME}_isotrac
     613  fi
     614  if [[ "$diagiso" = "true" ]]; then
     615    SUFF_NAME=${SUFF_NAME}_diagiso
     616  fi
     617
     618  if [[ $libphy = "true" ]]; then
     619    # special case where we compile only the physics
     620    DYN=$LMDGCM/.void_dir
     621    DYN_COMMON_PATH=$LMDGCM/.void_dir
     622    FILTRE_PATH=$LMDGCM/.void_dir
     623    DYN_PHYS_PATH=$LMDGCM/.void_dir
     624    DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir
     625    #and there is no main program to generate
     626    code=""
     627    SUFF_NAME=""
    636628  else
    637     DYN=dyn${dimc}d
    638   fi
    639 fi
    640 
    641 if [[ $veget != "false" ]]
    642 then
    643   SUFF_NAME=${SUFF_NAME}_orch
    644 fi
    645 
    646 if [[ $dust == "true" ]]
    647 then
    648   SUFF_NAME=${SUFF_NAME}_spla
    649 fi
    650 
    651 if [[ $couple != "false" ]]
    652 then
    653   SUFF_NAME=${SUFF_NAME}_couple
    654 fi
    655 
    656 if [[ $chimie == "INCA" ]]
    657 then
    658   SUFF_NAME=${SUFF_NAME}_inca
    659 fi
    660 
    661 if [[ "$isotopes" == "true" ]]
    662 then
    663   SUFF_NAME=${SUFF_NAME}_iso
    664 fi
    665 if [[ "$isoverif" == "true" ]]
    666 then
    667   SUFF_NAME=${SUFF_NAME}_isoverif
    668 fi
    669 if [[ "$isotrac" == "true" ]]
    670 then
    671   SUFF_NAME=${SUFF_NAME}_isotrac
    672 fi
    673 if [[ "$diagiso" == "true" ]]
    674 then
    675   SUFF_NAME=${SUFF_NAME}_diagiso
    676 fi
    677 
    678 if [[ $libphy == "true" ]]
    679 then
    680   # special case where we compile only the physics
    681   DYN=$LMDGCM/.void_dir
    682   DYN_COMMON_PATH=$LMDGCM/.void_dir
    683   FILTRE_PATH=$LMDGCM/.void_dir
    684   DYN_PHYS_PATH=$LMDGCM/.void_dir
    685   DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir
    686   #and there is no main program to generate
    687   code=""
    688   SUFF_NAME=""
    689 else
    690   SUFF_NAME=${SUFF_NAME}.e
    691 fi
    692 
    693 cd $LMDGCM
    694 config_fcm="config.fcm"
    695 rm -f $config_fcm
    696 touch $config_fcm
    697 rm -f bin/${code}${SUFF_NAME}.e
    698 rm -f arch.fcm
    699 rm -f arch.opt
    700 
    701 echo "%ARCH          $arch"          >> $config_fcm
    702 echo "%INCDIR        $INCLUDE"       >> $config_fcm
    703 echo "%LIB           $LIB"           >> $config_fcm
    704 echo "%ROOT_PATH     $PWD"           >> $config_fcm
    705 echo "%LIBF          $LIBFGCM"       >> $config_fcm
    706 echo "%LIBO          $LIBOGCM"       >> $config_fcm
    707 echo "%DYN           $DYN"           >> $config_fcm
    708 echo "%DYN_COMMON    $DYN_COMMON_PATH" >> $config_fcm
    709 echo "%PHY_COMMON    $PHY_COMMON_PATH" >> $config_fcm
    710 echo "%FILTRE        $FILTRE_PATH"   >> $config_fcm
    711 echo "%PHYS          phy${physique}" >> $config_fcm
    712 echo "%DYN_PHYS      $DYN_PHYS_PATH" >> $config_fcm
    713 echo "%DYN_PHYS_SUB  $DYN_PHYS_SUB_PATH" >> $config_fcm
    714 echo "%RAD           $RAD_PATH"     >> $config_fcm
    715 echo "%DUST          $DUST_PATH"     >> $config_fcm
    716 echo "%STRATAER      $STRATAER_PATH" >> $config_fcm
    717 echo "%INLANDSIS     $INLANDSIS_PATH" >> $config_fcm
    718 echo "%COSP          $COSP_PATH"     >> $config_fcm
    719 echo "%CPP_KEY       $CPP_KEY"       >> $config_fcm
    720 echo "%EXEC          $code"          >> $config_fcm
    721 echo "%SUFF_NAME     $SUFF_NAME"     >> $config_fcm
    722 echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> $config_fcm
    723 echo "%PARA_FFLAGS   $PARA_FFLAGS"   >> $config_fcm
    724 echo "%PARA_LD       $PARA_LD"       >> $config_fcm
    725 echo "%EXT_SRC       $EXT_SRC"       >> $config_fcm
    726 
    727 if [[ "$rad" == "ecrad" ]]
    728 then
    729 \cp bld.cfg.ecrad bld.cfg
    730 else
    731 \cp bld.cfg.rrtm bld.cfg
    732 fi
    733 
    734 ln -s arch/arch-${arch}.fcm arch.fcm
    735 if test -f arch/arch-${arch}.opt &&  [ $compil_mod = "prod" ]
    736   then
    737   ln -s arch/arch-${arch}.opt arch.opt
    738 else
    739   ln -s .void_file arch.opt
    740 fi
    741 
    742 set +e
    743 
    744 rm -f $LIBOGCM/${arch}${SUFF_NAME}/.config/fcm.bld.lock
    745 ./build_gcm ${fcm_path} -j $job $full
    746 build_status=$?
    747 
    748 rm -rf tmp_src
    749 rm -rf config
    750 ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config config
    751 ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config/ppsrc tmp_src
    752 
    753 if [[ -r $LIBFGCM/grid/dimensions.h ]]
    754 then
    755   # Cleanup: remove dimension.h file
    756   \rm -f $LIBFGCM/grid/dimensions.h
    757 fi
    758 
    759 # build netcdf95 library necessary for the makelmdz script
    760 if [[ $build_status = 0 ]]
    761 then
    762   if [[ ! -d tools/netcdf95/include ]]
    763   then
    764       mkdir tools/netcdf95/include tools/netcdf95/lib
    765       cp config/inc/netcdf95.mod config/inc/nf95_*mod tools/netcdf95/include
    766       cp config/obj/netcdf95.o config/obj/nf95_*o config/obj/check_start_count_m.o tools/netcdf95/lib
    767       cd tools/netcdf95/lib; ar rv libnetcdf95.a *.o; ranlib libnetcdf95.a
    768       cd -
    769     fi
    770 fi
    771 
    772 exit $build_status
     629    SUFF_NAME=${SUFF_NAME}.e
     630  fi
     631}
     632
     633function create_fcm_conf() {
     634  cd "$LMDGCM"
     635  config_fcm="config.fcm"
     636  rm -f "bin/${code}${SUFF_NAME}.e"
     637  rm -f arch.fcm
     638  rm -f arch.opt
     639
     640  {
     641    echo "%ARCH          $arch"
     642    echo "%INCDIR        $INCLUDE"
     643    echo "%LIB           $LIB"
     644    echo "%ROOT_PATH     $PWD"
     645    echo "%LIBF          $LIBFGCM"
     646    echo "%LIBO          $LIBOGCM"
     647    echo "%DYN           $DYN"
     648    echo "%DYN_COMMON    $DYN_COMMON_PATH"
     649    echo "%PHY_COMMON    $PHY_COMMON_PATH"
     650    echo "%FILTRE        $FILTRE_PATH"
     651    echo "%PHYS          phy${physique}"
     652    echo "%DYN_PHYS      $DYN_PHYS_PATH"
     653    echo "%DYN_PHYS_SUB  $DYN_PHYS_SUB_PATH"
     654    echo "%RAD           $RAD_PATH"
     655    echo "%DUST          $DUST_PATH"
     656    echo "%STRATAER      $STRATAER_PATH"
     657    echo "%INLANDSIS     $INLANDSIS_PATH"
     658    echo "%COSP          $COSP_PATH"
     659    echo "%CPP_KEY       $CPP_KEY"
     660    echo "%EXEC          $code"
     661    echo "%SUFF_NAME     $SUFF_NAME"
     662    echo "%COMPIL_FFLAGS $COMPIL_FFLAGS"
     663    echo "%PARA_FFLAGS   $PARA_FFLAGS"
     664    echo "%PARA_LD       $PARA_LD"
     665    echo "%EXT_SRC       $EXT_SRC"
     666  } > $config_fcm
     667
     668  # ecrad conf
     669  if [[ $rad = "ecrad" ]]; then
     670    cp bld.cfg.ecrad bld.cfg
     671  else
     672    cp bld.cfg.rrtm bld.cfg
     673  fi
     674
     675  # arch.fcm and arch.opt
     676  ln -s "arch/arch-$arch.fcm" arch.fcm
     677  if [[ -f arch/arch-$arch.opt && $compil_mod = "prod" ]]; then
     678    ln -s "arch/arch-$arch.opt" arch.opt
     679  else
     680    ln -s .void_file arch.opt
     681  fi
     682}
     683
     684function build_gcm() {
     685  set +e
     686
     687  rm -f "$LIBOGCM/$arch$SUFF_NAME/.config/fcm.bld.lock"
     688  ./build_gcm "$fcm_path" -j "$job" $full
     689  build_status=$?
     690
     691  rm -rf tmp_src
     692  rm -rf config
     693  ln -s "$LIBOGCM/$arch$SUFF_NAME/.config" config
     694  ln -s "$LIBOGCM/$arch$SUFF_NAME/.config/ppsrc" tmp_src
     695
     696  if [[ -r $LIBFGCM/grid/dimensions.h ]]; then
     697    # Cleanup: remove dimension.h file
     698    rm -f "$LIBFGCM/grid/dimensions.h"
     699  fi
     700
     701  # build netcdf95 library necessary for the makelmdz script
     702  if [[ $build_status = 0 ]]; then
     703    if [[ ! -d tools/netcdf95/include ]]; then
     704        mkdir tools/netcdf95/include tools/netcdf95/lib
     705        cp config/inc/netcdf95.mod config/inc/nf95_*mod tools/netcdf95/include
     706        cp config/obj/netcdf95.o config/obj/nf95_*o config/obj/check_start_count_m.o tools/netcdf95/lib
     707        cd tools/netcdf95/lib; ar rv libnetcdf95.a -- *.o; ranlib libnetcdf95.a
     708        cd -
     709      fi
     710  fi
     711
     712  exit $build_status
     713}
     714
     715init_vars
     716read_cmdline_options "$@"
     717init_arch
     718cpp_keys_and_include_mod_path
     719handle_dimension
     720different_dynamics
     721create_config_suffix
     722create_fcm_conf
     723build_gcm
Note: See TracChangeset for help on using the changeset viewer.