Changeset 5090


Ignore:
Timestamp:
Jul 20, 2024, 6:08:57 PM (3 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

Location:
LMDZ6/branches/Amaury_dev/libf
Files:
15 edited
1 moved

Legend:

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

    r5088 r5090  
    33  USE netcdf, ONLY: nf90_strerror,nf90_noerr,nf90_redef,nf90_put_var,nf90_enddef,nf90_put_att,&
    44          nf90_inq_varid,nf90_get_var,nf90_def_var
    5   USE lmdz_netcdf_format, ONLY: nf90_format
     5  USE lmdz_cppkeys_wrapper, ONLY: nf90_format
    66  IMPLICIT NONE; PRIVATE
    77  PUBLIC :: dynredem_write_u, dynredem_write_v, dynredem_read_u, err
  • LMDZ6/branches/Amaury_dev/libf/dyn3d/gcm.F90

    r5082 r5090  
    2626  USE logic_mod, ONLY: ecripar, iflag_phys, read_start
    2727
     28  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_PHYS
     29
    2830!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    2931  ! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
    3032  ! A nettoyer. On ne veut qu'une ou deux routines d'interface
    3133  ! dynamique -> physique pour l'initialisation
    32 #ifdef CPP_PHYS
     34  ! AB 2024/07/20: remplace CPP key by fortran logical, but ^ still relevant, see later use of iniphys later on
    3335  USE iniphysiq_mod, ONLY: iniphysiq
    34 #endif
    3536!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    3637
     
    406407
    407408  IF ((iflag_phys==1).or.(iflag_phys>=100)) THEN
    408      ! Physics:
    409 #ifdef CPP_PHYS
    410      CALL iniphysiq(iim,jjm,llm, &
     409    ! Physics:
     410    IF (CPPKEY_PHYS) THEN
     411      CALL iniphysiq(iim,jjm,llm, &
    411412          (jjm-1)*iim+2,comm_lmdz, &
    412413          daysec,day_ini,dtphys/nsplit_phys, &
    413414          rlatu,rlatv,rlonu,rlonv,aire,cu,cv,rad,g,r,cpp, &
    414415          iflag_phys)
    415 #endif
     416    END IF
    416417  ENDIF ! of IF ((iflag_phys==1).or.(iflag_phys>=100))
    417418
  • LMDZ6/branches/Amaury_dev/libf/dyn3d/leapfrog.F

    r5081 r5090  
    2727     &                        start_time,dt
    2828      USE strings_mod, ONLY: msg
     29      USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_PHYS
    2930
    3031      IMPLICIT NONE
     
    462463#endif
    463464! #endif of #ifdef CPP_IOIPSL
    464 #ifdef CPP_PHYS
    465          CALL calfis( lafin , jD_cur, jH_cur,
     465         IF (CPPKEY_PHYS) THEN
     466           CALL calfis( lafin , jD_cur, jH_cur,
    466467     $               ucov,vcov,teta,q,masse,ps,p,pk,phis,phi ,
    467468     $               du,dv,dteta,dq,
    468469     $               flxw,dufi,dvfi,dtetafi,dqfi,dpfi  )
    469 #endif
     470         END IF
    470471c      ajout des tendances physiques:
    471472c      ------------------------------
  • LMDZ6/branches/Amaury_dev/libf/dyn3d/replay3d.F90

    r4589 r5090  
    2222  USE mod_const_mpi, ONLY: comm_lmdz
    2323
    24 
    25 
    26 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    27   ! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
    28   ! A nettoyer. On ne veut qu'une ou deux routines d'interface
    29   ! dynamique -> physique pour l'initialisation
    30 #ifdef CPP_PHYS
    31   USE iniphysiq_mod, ONLY: iniphysiq
    32 #endif
    33 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    34 
    3524  IMPLICIT NONE
    3625
    3726  !      ......   Version  du 10/01/98    ..........
    3827
    39   !             avec  coordonnees  verticales hybrides 
     28  !             avec  coordonnees  verticales hybrides
    4029  !   avec nouveaux operat. dissipation * ( gradiv2,divgrad2,nxgraro2 )
    4130
  • LMDZ6/branches/Amaury_dev/libf/dyn3dmem/bands.F90

    r2771 r5090  
    381381    subroutine AdjustBands_physic
    382382      use times
    383 #ifdef CPP_PHYS
    384 ! Ehouarn: what follows is only related to // physics
     383
     384      ! Ehouarn: what follows is only related to // physics
     385      USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_PHYS
    385386      USE mod_phys_lmdz_para, only : klon_mpi_para_nb
    386 #endif
     387
    387388      USE parallel_lmdz
    388389      implicit none
     
    408409      medium=medium/mpi_size     
    409410      NbTot=0
    410 #ifdef CPP_PHYS
     411      IF (CPPKEY_PHYS) THEN
    411412      do i=0,mpi_size-1
    412413        Inc(i)=nint(klon_mpi_para_nb(i)*(medium-value(i))/value(i))
     
    431432        distrib_phys(i)=klon_mpi_para_nb(i)+inc(i)
    432433      enddo
    433 #endif 
     434     END IF
    434435         
    435436    end subroutine AdjustBands_physic
  • LMDZ6/branches/Amaury_dev/libf/dyn3dmem/dynredem_mod.F90

    r5088 r5090  
    66  USE netcdf, ONLY: nf90_strerror,nf90_noerr,nf90_redef,nf90_put_var,nf90_inquire_dimension,&
    77          nf90_inq_varid,nf90_get_var,nf90_def_var,nf90_enddef,nf90_put_att
    8   USE lmdz_netcdf_format, ONLY: nf90_format
     8  USE lmdz_cppkeys_wrapper, ONLY: nf90_format
    99  PRIVATE
    1010  PUBLIC :: dynredem_write_u, dynredem_write_v, dynredem_read_u, err
  • LMDZ6/branches/Amaury_dev/libf/dyn3dmem/gcm.F90

    r5082 r5090  
    1212  USE parallel_lmdz
    1313  USE infotrac, ONLY: nqtot, init_infotrac
    14 !#ifdef CPP_PHYS
    15 !  USE mod_interface_dyn_phys, ONLY: init_interface_dyn_phys
    16 !#endif
    1714  USE mod_hallo
    1815  USE Bands
     
    2017  USE control_mod
    2118
    22 #ifdef CPP_PHYS
     19
    2320  USE iniphysiq_mod, ONLY: iniphysiq
    24 #endif
     21  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_PHYS
     22
    2523  USE comconst_mod, ONLY: cpp, daysec, dtphys, dtvr, g, r, rad
    2624  USE logic_mod ! all of it, because of copyin clause when calling leapfrog
     
    415413  IF ((iflag_phys==1).or.(iflag_phys>=100)) THEN
    416414     ! Physics:
    417 #ifdef CPP_PHYS
    418      CALL iniphysiq(iim,jjm,llm, &
    419           distrib_phys(mpi_rank),comm_lmdz, &
    420           daysec,day_ini,dtphys/nsplit_phys, &
    421           rlatu,rlatv,rlonu,rlonv,aire,cu,cv,rad,g,r,cpp, &
    422           iflag_phys)
    423 #endif
     415    IF (CPPKEY_PHYS) THEN
     416      CALL iniphysiq(iim,jjm,llm, &
     417            distrib_phys(mpi_rank),comm_lmdz, &
     418            daysec,day_ini,dtphys/nsplit_phys, &
     419            rlatu,rlatv,rlonu,rlonv,aire,cu,cv,rad,g,r,cpp, &
     420            iflag_phys)
     421    END IF
    424422  ENDIF ! of IF ((iflag_phys==1).or.(iflag_phys>=100))
    425423
  • LMDZ6/branches/Amaury_dev/libf/dyn3dmem/lmdz_call_calfis.F90

    r5087 r5090  
    8888  USE comvert_mod, ONLY: ap, bp, pressure_exner
    8989  USE temps_mod, ONLY: day_ini, day_ref, jd_ref, jh_ref, start_time
    90 #ifdef CPP_PHYS
    9190  USE lmdz_calfis_loc
    92 #endif
     91  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_PHYS
    9392
    9493  IMPLICIT NONE
     
    233232  !$OMP BARRIER
    234233
    235 #ifdef CPP_PHYS
    236     CALL calfis_loc(lafin ,jD_cur, jH_cur,                       &
     234    IF (CPPKEY_PHYS) THEN
     235      CALL calfis_loc(lafin ,jD_cur, jH_cur,                       &
    237236                     ucov,vcov,teta,q,masse,ps,p,pk,phis,phi ,   &
    238237                     du,dv,dteta,dq,                             &
    239238                     flxw, dufi,dvfi,dtetafi,dqfi,dpfi  )
    240 #endif
     239    END IF
    241240    ijb=ij_begin
    242241    ije=ij_end 
  • LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/calfis.F

    r5086 r5090  
    2727     $                  pdpsfi)
    2828c
    29 c    Auteur :  P. Le Van, F. Hourdin 
     29c    Auteur :  P. Le Van, F. Hourdin
    3030c   .........
    3131      USE infotrac, ONLY: nqtot, tracers
    3232      USE control_mod, ONLY: planet_type, nsplit_phys
    33 #ifdef CPP_PHYS
    3433      USE callphysiq_mod, ONLY: call_physiq
    35 #endif
     34      USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_PHYS
    3635      USE comconst_mod, ONLY: cpp, daysec, dtphys, dtvr, kappa, pi
    3736      USE comvert_mod, ONLY: preff, presnivs
    38      
     37
    3938      IMPLICIT NONE
    4039c=======================================================================
     
    4847c   ----------
    4948c
    50 c    - les vents sont donnes dans la physique par leurs composantes 
     49c    - les vents sont donnes dans la physique par leurs composantes
    5150c      naturelles.
    5251c    - la variable thermodynamique de la physique est une variable
    53 c      intensive :   T 
     52c      intensive :   T
    5453c      pour la dynamique on prend    T * ( preff / p(l) ) **kappa
    5554c    - les deux seules variables dependant de la geometrie necessaires
    56 c      pour la physique sont la latitude pour le rayonnement et 
    57 c      l'aire de la maille quand on veut integrer une grandeur 
     55c      pour la physique sont la latitude pour le rayonnement et
     56c      l'aire de la maille quand on veut integrer une grandeur
    5857c      horizontalement.
    59 c    - les points de la physique sont les points scalaires de la 
     58c    - les points de la physique sont les points scalaires de la
    6059c      la dynamique; numerotation:
    6160c          1 pour le pole nord
     
    6766c     -------
    6867c       pucov           covariant zonal velocity
    69 c       pvcov           covariant meridional velocity 
     68c       pvcov           covariant meridional velocity
    7069c       pteta           potential temperature
    7170c       pps             surface pressure
     
    7776c    --------
    7877c        pdufi          tendency for the natural zonal velocity (ms-1)
    79 c        pdvfi          tendency for the natural meridional velocity 
     78c        pdvfi          tendency for the natural meridional velocity
    8079c        pdhfi          tendency for the potential temperature
    8180c        pdtsfi         tendency for the surface temperature
     
    165164      REAL flxwfi(ngridmx,llm)  ! Flux de masse verticale sur la grille physiq
    166165c
    167      
     166
    168167      REAL SSUM
    169168
     
    201200c   ----------------------------------
    202201
    203        
     202
    204203      zpsrf(1) = pps(1,1)
    205204
     
    217216c   -----------------------------------------------------------------
    218217c     .... zplev  definis aux (llm +1) interfaces des couches  ....
    219 c     .... zplay  definis aux (  llm )    milieux des couches  .... 
     218c     .... zplay  definis aux (  llm )    milieux des couches  ....
    220219c   -----------------------------------------------------------------
    221220
     
    329328
    330329c   ....  Calcul de la vitesse  verticale  ( en Pa*m*s  ou Kg/s )  ....
    331 c JG : ancien calcule de omega utilise dans physiq.F. Maintenant le flux 
    332 c    de masse est calclue dans advtrac.F 
     330c JG : ancien calcule de omega utilise dans physiq.F. Maintenant le flux
     331c    de masse est calclue dans advtrac.F
    333332c      DO l=1,llm
    334333c        pvervel(1,l)=pw(1,1,l) * g /apoln
     
    351350         DO j=2,jjm
    352351            ig0 = 1+(j-2)*iim
    353             zufi(ig0+1,l)= 0.5 * 
     352            zufi(ig0+1,l)= 0.5 *
    354353     $      ( pucov(iim,j,l)/cu(iim,j) + pucov(1,j,l)/cu(1,j) )
    355             pcvgu(ig0+1,l)= 0.5 * 
     354            pcvgu(ig0+1,l)= 0.5 *
    356355     $      ( pducov(iim,j,l)/cu(iim,j) + pducov(1,j,l)/cu(1,j) )
    357356            DO i=2,iim
     
    373372          do j=1,jjm
    374373            zrot(i,j,l) = (pvcov(i+1,j,l) - pvcov(i,j,l)
    375      $                   + pucov(i,j+1,l) - pucov(i,j,l)) 
    376      $                   / (cu(i,j)+cu(i,j+1)) 
     374     $                   + pucov(i,j+1,l) - pucov(i,j,l))
     375     $                   / (cu(i,j)+cu(i,j+1))
    377376     $                   / (cv(i+1,j)+cv(i,j)) *4
    378377          enddo
     
    402401
    403402
    404 c   47. champs de vents aux pole nord   
     403c   47. champs de vents aux pole nord
    405404c   ------------------------------
    406405c        U = 1 / pi  *  integrale [ v * cos(long) * d long ]
     
    475474      zdqfic(:,:,:)=0.
    476475
    477 #ifdef CPP_PHYS
     476       IF (CPPKEY_PHYS) THEN
    478477
    479478       do isplit=1,nsplit_phys
     
    500499!     .             nqtot,          !! nq
    501500!     .             tracers(:)%name,!! tracer names from dynamical core (given in infotrac)
    502 !     .             debut_split,    !! firstcall 
     501!     .             debut_split,    !! firstcall
    503502!     .             lafin_split,    !! lastcall
    504503!     .             jD_cur,         !! pday. see leapfrog
     
    534533       enddo ! of do isplit=1,nsplit_phys
    535534
    536 #endif
    537 ! of #ifdef CPP_PHYS
     535       END IF
    538536
    539537      zdufi(:,:)=zdufic(:,:)/nsplit_phys
     
    541539      zdtfi(:,:)=zdtfic(:,:)/nsplit_phys
    542540      zdqfi(:,:,:)=zdqfic(:,:,:)/nsplit_phys
    543 
    544 
    545 500   CONTINUE
    546541
    547542c-----------------------------------------------------------------------
     
    681676
    682677c-----------------------------------------------------------------------
    683 
    684 700   CONTINUE
    685  
    686678      firstcal = .FALSE.
    687679
  • LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/lmdz_calfis_loc.F90

    r5066 r5090  
    2828          pdqfi, &
    2929          pdpsfi)
    30 #ifdef CPP_PHYS
    31     ! If using physics
    32     !
    33     !    Auteur :  P. Le Van, F. Hourdin
    34     !   .........
     30
    3531    USE dimphy
    3632    USE mod_phys_lmdz_mpi_data, mpi_root_xx=>mpi_master
     
    3935    USE mod_interface_dyn_phys
    4036    USE IOPHY
    41 #endif
     37
    4238    USE lmdz_mpi
    4339
     
    4945    USE infotrac, ONLY : nqtot, tracers
    5046    USE control_mod, ONLY : planet_type, nsplit_phys
    51 #ifdef CPP_PHYS
    5247    USE callphysiq_mod, ONLY: call_physiq
    53 #endif
     48    USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_PHYS
     49
    5450    USE comvert_mod, ONLY : preff, presnivs
    5551    USE comconst_mod, ONLY : cpp, daysec, dtphys, dtvr, kappa, pi
     
    146142    REAL, INTENT(OUT) :: pdpsfi(iip1, jjb_u:jje_u) ! tendency on surface pressure (Pa/s)
    147143
    148 #ifdef CPP_PHYS
     144
    149145  ! Ehouarn: for now calfis_p needs some informations from physics to compile
    150146  !    Local variables :
     
    237233  INTEGER :: jjb,jje
    238234
     235    IF (CPPKEY_PHYS) THEN
     236
    239237  !
    240238  !-----------------------------------------------------------------------
     
    249247  IF ( firstcal )  THEN
    250248    debut = .TRUE.
    251     IF (ngridmx.NE.2+(jjm-1)*iim) THEN
     249    IF (ngridmx/=2+(jjm-1)*iim) THEN
    252250      write(lunout,*) 'STOP dans calfis'
    253251      write(lunout,*) &
     
    719717  zdqfic_omp(:,:,:)=0.
    720718
    721 #ifdef CPP_PHYS
    722719  do isplit=1,nsplit_phys
    723720
     
    750747  enddo
    751748
    752 #endif
    753   ! of #ifdef CPP_PHYS
    754 
    755749
    756750  zdufi_omp(:,:)=zdufic_omp(:,:)/nsplit_phys
     
    847841
    848842  klon=klon_mpi
    849 500   CONTINUE
    850843!$OMP BARRIER
    851844
     
    12041197  !-----------------------------------------------------------------------
    12051198
    1206 700   CONTINUE
    1207 
    12081199  firstcal = .FALSE.
    1209 #endif
    1210   ! of #ifdef CPP_PHYS
     1200END IF
    12111201  END SUBROUTINE calfis_loc
    12121202
  • LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/limit_netcdf.F90

    r5088 r5090  
    7676                  NF90_CLOBBER, NF90_ENDDEF,  NF90_UNLIMITED, NF90_FLOAT,      &
    7777                  NF90_64BIT_OFFSET
    78   USE lmdz_netcdf_format, ONLY: nf90_format
     78  USE lmdz_cppkeys_wrapper, ONLY: nf90_format
    7979  USE inter_barxy_m,      ONLY: inter_barxy
    8080  USE netcdf95,           ONLY: nf95_def_var, nf95_put_att, nf95_put_var
  • LMDZ6/branches/Amaury_dev/libf/misc/lmdz_cppkeys_wrapper.F90

    r5089 r5090  
    11! ---------------------------------------------
    2 ! This module serves as a wrapper around netcdf.
    3 ! It serves two primary functions:
    4 !  1) Turn netcdf into a "real" fortran module, without the INCLUDE call
    5 !  2) Handle the NC_DOUBLE CPP key. This key should ONLY be used here.
    6 ! The "real" netcdf module/headers should ONLY be called here.
     2! This file is part of an effort to replace most uses of preprocessor CPP keys by fortran variables,
     3! to improve readability, compilation coverage, and linting.
     4! CPP keys used here should ONLY be used here,
     5! and imported through USE ..., ONLY: ... elsewhere
     6! CPP keys supported (key -> fortran variables associated):
     7!      NC_DOUBLE -> nf90_format
     8!      CPP_PHYS  -> CPPKEY_PHYS
    79! ---------------------------------------------
    810
    9 MODULE lmdz_netcdf_format
     11MODULE lmdz_cppkeys_wrapper
    1012  USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY : REAL64, REAL32
    1113  USE netcdf, ONLY: nf90_float, nf90_double
    1214  IMPLICIT NONE; PRIVATE
    13   PUBLIC nf90_format
     15  PUBLIC nf90_format, CPPKEY_PHYS
    1416
    1517#ifdef NC_DOUBLE
     
    1820  INTEGER, PARAMETER :: nf90_format = nf90_float
    1921#endif
    20 END MODULE lmdz_netcdf_format
     22
     23#ifdef CPP_PHYS
     24  LOGICAL, PARAMETER :: CPPKEY_PHYS = .TRUE.
     25#else
     26  LOGICAL, PARAMETER :: CPPKEY_PHYS = .FALSE.
     27#endif
     28
     29END MODULE lmdz_cppkeys_wrapper
  • LMDZ6/branches/Amaury_dev/libf/misc/write_field.F90

    r5088 r5090  
    22  USE netcdf, ONLY: nf90_sync, nf90_put_var, nf90_enddef, nf90_def_dim, nf90_unlimited, &
    33      nf90_clobber, nf90_create, nf90_def_var
    4   USE lmdz_netcdf_format, ONLY: nf90_format
     4  USE lmdz_cppkeys_wrapper, ONLY: nf90_format
    55
    66  implicit none
  • LMDZ6/branches/Amaury_dev/libf/phylmd/iostart.F90

    r5088 r5090  
    387387  SUBROUTINE put_field_rgen(pass, field_name,title,field,field_size)
    388388  USE netcdf, ONLY: nf90_def_var,nf90_put_att,nf90_inq_varid,nf90_put_var
    389   USE lmdz_netcdf_format, ONLY: nf90_format
     389  USE lmdz_cppkeys_wrapper, ONLY: nf90_format
    390390  USE dimphy
    391391  USE geometry_mod
     
    511511  SUBROUTINE put_var_rgen(pass, var_name,title,var,var_size)
    512512  USE netcdf, ONLY: nf90_def_var,nf90_put_var,nf90_inq_varid,nf90_put_att
    513   USE lmdz_netcdf_format, ONLY: nf90_format
     513  USE lmdz_cppkeys_wrapper, ONLY: nf90_format
    514514  USE dimphy
    515515  USE mod_phys_lmdz_para
  • LMDZ6/branches/Amaury_dev/libf/phylmd/phyaqua_mod.F90

    r5088 r5090  
    573573            nf90_enddef, nf90_put_att, nf90_unlimited, nf90_noerr, nf90_global, nf90_clobber, &
    574574            nf90_64bit_offset, nf90_def_dim, nf90_create
    575     USE lmdz_netcdf_format, ONLY: nf90_format
     575    USE lmdz_cppkeys_wrapper, ONLY: nf90_format
    576576    IMPLICIT NONE
    577577
  • LMDZ6/branches/Amaury_dev/libf/phylmdiso/phyaqua_mod.F90

    r5088 r5090  
    594594            nf90_def_dim,nf90_create,nf90_put_var,nf90_unlimited,nf90_global,nf90_64bit_offset,&
    595595            nf90_enddef
    596     USE lmdz_netcdf_format, ONLY: nf90_format
     596    USE lmdz_cppkeys_wrapper, ONLY: nf90_format
    597597    IMPLICIT NONE
    598598
Note: See TracChangeset for help on using the changeset viewer.