Changeset 3008


Ignore:
Timestamp:
Jul 22, 2023, 12:54:11 PM (16 months ago)
Author:
emillour
Message:

Mars PCM:
Some code cleanup around microphysics. Turn microphys.h into module
microphys_h.F90, and while at it also turn nuclea.F, growthrate.F90 and
massflowrateco2.F90 into modules.
EM

Location:
trunk/LMDZ.MARS
Files:
11 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.MARS/changelog.txt

    r3007 r3008  
    41204120Fix OpenMP bug in paleoclimate_mod; saved variables should be threadprivate.
    41214121
     4122== 22/07/2023 == EM
     4123Some code cleanup around microphysics. Turn microphys.h into module
     4124microphys_h.F90, and while at it also turn nuclea.F, growthrate.F90 and
     4125massflowrateco2.F90 into modules.
  • trunk/LMDZ.MARS/libf/phymars/co2cloud.F90

    r2932 r3008  
    108108
    109109  use improvedCO2clouds_mod, only: improvedCO2clouds
     110  use microphys_h, only: nbinco2_cld, rad_cldco2, mco2
    110111  use write_output_mod, only: write_output
    111112#ifndef MESOSCALE
     
    116117
    117118  include "callkeys.h"
    118   include "microphys.h"
    119119!----------------------------------------------------------------------------------------------------------------------!
    120120! VARIABLES DECLARATION
  • trunk/LMDZ.MARS/libf/phymars/conf_phys.F

    r2999 r3008  
    5555      USE mod_phys_lmdz_transfert_para, ONLY: bcast
    5656      USE paleoclimate_mod,ONLY: paleoclimate,albedo_perenialco2
     57      use microphys_h, only: mteta
     58
    5759      IMPLICIT NONE
     60
    5861      include "callkeys.h"
    59       include "microphys.h"
    6062
    6163      INTEGER,INTENT(IN) :: ngrid,nlayer,nq
     64
    6265      INTEGER ierr,j
    6366      character(len=20),parameter :: modname="conf_phys"
  • trunk/LMDZ.MARS/libf/phymars/growthrate.F

    r2407 r3008  
     1      MODULE growthrate_mod
     2     
     3      IMPLICIT NONE
     4     
     5      CONTAINS
     6
    17      subroutine growthrate(temp,pmid,psat,rcrystal,res,Dv)
    28
    39      use tracer_mod, only: rho_ice
    4       USE comcstfi_h
     10      use comcstfi_h, only: pi
     11      use microphys_h, only: kbz, mh2o, mco2, molco2, molh2o
     12      use microphys_h, only: nav, rgp, To
     13     
    514      IMPLICIT NONE
    615
     
    2029c   -------------
    2130
    22 #include "microphys.h"
    23 
    2431c
    2532c   arguments:
     
    2734
    2835c     Input
    29       REAL temp     ! temperature in the middle of the layer (K)
    30       REAL pmid     ! pressure in the middle of the layer (K)
    31       REAL psat   ! water vapor saturation pressure (Pa)
    32       REAL rcrystal ! crystal radius before condensation (m)
     36      REAL, INTENT(IN) :: temp     ! temperature in the middle of the layer (K)
     37      REAL, INTENT(IN) :: pmid     ! pressure in the middle of the layer (K)
     38      REAL, INTENT(IN) :: psat   ! water vapor saturation pressure (Pa)
     39      REAL, INTENT(IN) :: rcrystal ! crystal radius before condensation (m)
    3340
    3441c     Output
    35       REAL res      ! growth resistance (res=Rk+Rd)
    36       REAL Dv       ! water vapor diffusion coefficient
     42      REAL, INTENT(OUT) :: res      ! growth resistance (res=Rk+Rd)
     43      REAL, INTENT(OUT) :: Dv       ! water vapor diffusion coefficient
    3744
    3845c   local:
     
    100107c      dr   = rf-r
    101108
    102       RETURN
    103       END
     109      end subroutine growthrate
     110     
     111      END MODULE growthrate_mod
    104112
  • trunk/LMDZ.MARS/libf/phymars/hdo_surfex_mod.F

    r2932 r3008  
    1616      use geometry_mod, only: longitude_deg,latitude_deg
    1717      use comcstfi_h, only: pi
     18      use microphys_h, only: nav, kbz, mh2o, mco2, mhdo
     19      use microphys_h, only: molco2, molh2o, molhdo
    1820      use write_output_mod, only: write_output
    1921
     
    2527c------------------------------------------------------------------
    2628      include "callkeys.h"
    27       include "microphys.h"
    2829c------------------------------------------------------------------
    2930c     Arguments:
  • trunk/LMDZ.MARS/libf/phymars/improvedclouds_mod.F

    r2988 r3008  
    1818      use conc_mod, only: mmean
    1919      use comcstfi_h, only: pi, cpp
     20      use microphys_h, only: nbin_cld, rad_cld, mteta, kbz, nav, rgp
     21      use microphys_h, only: mco2, vo1, mh2o, mhdo, molco2, molhdo, To
     22      use nuclea_mod, only: nuclea
     23      use growthrate_mod, only: growthrate
    2024      use write_output_mod, only: write_output
    2125      implicit none
     
    4347c           J. Naar, adaptative subtimestep now done here (June 2023)
    4448c------------------------------------------------------------------
    45 #include "callkeys.h"
    46 #include "microphys.h"
     49      include "callkeys.h"
    4750c------------------------------------------------------------------
    4851c     Inputs/outputs:
     
    6669c     Local variables:
    6770
    68       LOGICAL firstcall
    69       DATA firstcall/.true./
    70       SAVE firstcall
    71      
     71      LOGICAL, SAVE ::  firstcall = .true.
    7272!$OMP THREADPRIVATE(firstcall)
    7373
     
    116116      DOUBLE PRECISION, PARAMETER :: rbmax_cld = 1.e-2 ! Maximum boundary radius (m)
    117117      DOUBLE PRECISION vrat_cld ! Volume ratio
    118       DOUBLE PRECISION rb_cld(nbin_cld+1)! boundary values of each rad_cld bin (m)
    119       SAVE rb_cld
     118      DOUBLE PRECISION, SAVE :: rb_cld(nbin_cld+1)! boundary values of each rad_cld bin (m)
     119!$OMP THREADPRIVATE(rb_cld)
     120
    120121      DOUBLE PRECISION dr_cld(nbin_cld)   ! width of each rad_cld bin (m)
    121122      DOUBLE PRECISION vol_cld(nbin_cld)  ! particle volume for each bin (m3)
    122      
    123 !$OMP THREADPRIVATE(rb_cld)
    124 
    125 
    126       REAL sigma_ice ! Variance of the ice and CCN distributions
    127       SAVE sigma_ice
    128      
     123
     124      REAL, SAVE :: sigma_ice ! Variance of the ice and CCN distributions
    129125!$OMP THREADPRIVATE(sigma_ice)
    130126
     
    152148      INTEGER countcells
    153149     
    154       LOGICAL test_flag    ! flag for test/debuging outputs
    155       SAVE    test_flag   
    156      
     150      LOGICAL, SAVE :: test_flag    ! flag for test/debuging outputs
    157151!$OMP THREADPRIVATE(test_flag)
    158152
     
    221215c       Contact parameter of water ice on dust ( m=cos(theta) )
    222216c       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    223 !       mteta  = 0.95
     217!       mteta is initialized in conf_phys
    224218        write(*,*) 'water_param contact parameter:', mteta
    225219
  • trunk/LMDZ.MARS/libf/phymars/improvedco2clouds_mod.F90

    r2660 r3008  
    7676  use nucleaco2_mod, only: nucleaco2
    7777  use datafile_mod, only: datadir
    78 
     78  use massflowrateco2_mod, only: massflowrateco2
    7979  use density_co2_ice_mod, only: density_co2_ice
     80  use microphys_h, only: nbinco2_cld, rad_cldco2, m0co2, mco2
     81  use microphys_h, only: mteta, mtetaco2
    8082
    8183  implicit none
    8284
    8385  include "callkeys.h"
    84   include "microphys.h"
     86
    8587!----------------------------------------------------------------------------------------------------------------------!
    8688! VARIABLES DECLARATION
  • trunk/LMDZ.MARS/libf/phymars/massflowrateco2.F90

    r2389 r3008  
     1MODULE massflowrateco2_mod
     2
     3IMPLICIT NONE
     4
     5CONTAINS
     6
    17  subroutine massflowrateco2(P,T,Sat,Radius,Matm,Ic)
    28!======================================================================================================================!
     
    1824  implicit none
    1925
    20   include "microphys.h"
    2126!----------------------------------------------------------------------------------------------------------------------!
    2227! VARIABLES DECLARATION
     
    8489  use tracer_mod, only: rho_ice_co2
    8590  use comcstfi_h, only: pi
     91  use microphys_h, only: kbz, mco2, nav, rgp, sigco2
    8692
    8793  implicit none
    88   include "microphys.h"
     94
    8995!----------------------------------------------------------------------------------------------------------------------!
    9096! VARIABLES DECLARATION
     
    211217! Compute diffusion coefficient CO2/N2 cited in Ilona's lecture - from Reid et al. 1987
    212218!======================================================================================================================!
     219  use microphys_h, only: mco2, mn2
     220
    213221  implicit none
    214222
    215   include "microphys.h"
    216223!----------------------------------------------------------------------------------------------------------------------!
    217224! VARIABLES DECLARATION
     
    250257  Diff  = 0.00143 * dble(T)**(1.75) / (dble(Pbar) * sqrt(Mab) * (dble(dva)**(1./3.) + dble(dvb)**(1./3.))**2.)
    251258
    252   return
    253259!======================================================================================================================!
    254260! END =================================================================================================================!
     
    266272! Compute thermal conductivity of CO2/N2 mixture (***WITHOUT*** USE OF VISCOSITY (Mason & Saxena 1958 - Wassiljeva 1904)
    267273!======================================================================================================================!
     274  use microphys_h, only: mco2, mn2
     275
    268276  implicit none
    269277
    270   include "microphys.h"
    271278!----------------------------------------------------------------------------------------------------------------------!
    272279! VARIABLES DECLARATION
     
    360367! Compute thermal cond of N2 (Lemmon and Jacobsen, 2003) WITH viscosity
    361368!======================================================================================================================!
     369  use microphys_h, only: mn2
     370
    362371  implicit none
    363372
    364   include "microphys.h"
    365373!----------------------------------------------------------------------------------------------------------------------!
    366374! VARIABLES DECLARATION
     
    475483! Compute viscosity of N2 (Lemmon and Jacobsen, 2003)
    476484!======================================================================================================================!
     485  use microphys_h, only: mn2
     486
    477487  implicit none
    478488
    479   include "microphys.h"
    480489!----------------------------------------------------------------------------------------------------------------------!
    481490! VARIABLES DECLARATION
     
    617626!======================================================================================================================!
    618627  end subroutine KthCO2Scalab
     628
     629END MODULE massflowrateco2_mod
  • trunk/LMDZ.MARS/libf/phymars/microphys_h.F90

    r3007 r3008  
     1MODULE microphys_h
     2
     3IMPLICIT NONE
    14!-----------------------------------------------------------------------
    2 ! INCLUDE 'microphys.h'
    3 ! Parameters and physical constants used by the microphysal scheme;
     5! Parameters and physical constants used by the microphysal schemes;
    46! Parameters for CO2 microphysics are also in this file
    57!-----------------------------------------------------------------------
     
    4850!     Contact parameter ( m=cos(theta) )
    4951!       (initialized in improvedclouds.F)
    50       REAL mteta
     52      REAL, SAVE :: mteta
     53!$OMP THREADPRIVATE(mteta)
    5154
    5255!     Volume of a water molecule (m3)
    53       DOUBLE PRECISION vo1
     56      DOUBLE PRECISION, SAVE :: vo1
     57!$OMP THREADPRIVATE(vo1)
    5458!     Radius used by the microphysical scheme (m)
    55       DOUBLE PRECISION rad_cld(nbin_cld)
     59      DOUBLE PRECISION, SAVE :: rad_cld(nbin_cld)
     60!$OMP THREADPRIVATE(rad_cld)
    5661
    5762
    5863
     64!!!!!!!!!!!!!!!! CO2 part
    5965
    60 !CO2 part
    6166!      number of bins for nucleation
    6267      INTEGER, PARAMETER :: nbinco2_cld=100
     
    7883      DOUBLE PRECISION, PARAMETER :: m0co2 = mco2 / nav
    7984!     Contact parameter ( m=cos(theta) )
    80 !       (initialized in improvedCO2clouds.F)
    8185!    bachnar 2016 value :0.78
    8286!old value 0.95
    8387      REAL, parameter :: mtetaco2 = 0.95
     88
    8489!     Volume of a co2 molecule (m3)
    85        DOUBLE PRECISION :: vo1co2
     90      DOUBLE PRECISION, SAVE :: vo1co2
     91!$OMP THREADPRIVATE(vo1co2)
     92
    8693!     Radius used by the microphysical scheme (m)
    87       DOUBLE PRECISION :: rad_cldco2(nbinco2_cld)
    88        REAL, parameter :: threshJA = 1
    89 !     COMMON/microphys/vo1co2,rad_cldco2
     94      DOUBLE PRECISION, SAVE :: rad_cldco2(nbinco2_cld)
     95!$OMP THREADPRIVATE(rad_cldco2)
    9096
    91 ! NB: to keep commons aligned:
    92 !     split them in groups (reals, integers and characters)
    93 
    94       COMMON/microphys/rad_cld,vo1,rad_cldco2,vo1co2
    95                   COMMON/microphys_2/mteta
    96 !$OMP THREADPRIVATE(/microphys/)
    97 !$OMP THREADPRIVATE(/microphys_2/)
    98 
     97      REAL, parameter :: threshJA = 1
    9998     
    100 !     EXAMPLE:
    101 !     COMMON/tracer/radius,rho_q,alpha_lift,alpha_devil,mmol,           &
    102 !    & varian,r3n_q,rho_dust,rho_ice,nuice_ref,nuice_sed,               &
    103 !    & ref_r0,dryness
    104 !-----------------------------------------------------------------------
     99END MODULE microphys_h
  • trunk/LMDZ.MARS/libf/phymars/nuclea.F

    r2616 r3008  
    1 *******************************************************
    2 *                                                     *
     1      MODULE nuclea_mod
     2     
     3      IMPLICIT NONE
     4     
     5      CONTAINS
     6
    37      subroutine nuclea(ph2o,temp,sat,n_ccn,nucrate)
    4       USE comcstfi_h
     8      use comcstfi_h, only: pi
     9      use microphys_h, only: nbin_cld, rad_cld, nav, mteta, m0
     10      use microphys_h, only: desorp, kbz, nus, rgp, surfdif, vo1
    511      implicit none
    612*                                                     *
     
    1521*******************************************************
    1622
    17 #include "microphys.h"
    1823      include "callkeys.h"
    1924
    2025c     Inputs
    21       DOUBLE PRECISION ph2o,sat
    22       DOUBLE PRECISION n_ccn(nbin_cld)
    23       REAL temp
     26      DOUBLE PRECISION, INTENT(IN) :: ph2o,sat
     27      DOUBLE PRECISION, INTENT(IN) :: n_ccn(nbin_cld)
     28      REAL, INTENT(IN) :: temp
    2429
    2530c     Output
    2631   !   DOUBLE PRECISION nucrate(nbin_cld)
    27       REAL nucrate(nbin_cld)
     32      REAL, INTENT(OUT) :: nucrate(nbin_cld)
    2833
    2934c     Local variables
     
    3540      DOUBLE PRECISION fistar   ! Activation energy required to form a critical embryo (J)
    3641!      DOUBLE PRECISION zeldov   ! Zeldovitch factor (no dim)
    37       DOUBLE PRECISION fshape   ! function defined at the end of the file
    3842      DOUBLE PRECISION deltaf
    3943
     
    4852      integer i
    4953     
    50       LOGICAL firstcall
    51      
     54      LOGICAL, SAVE :: firstcall = .true.
    5255!$OMP THREADPRIVATE(firstcall)
    53      
    54       DATA firstcall/.true./
    55       SAVE firstcall
    5656
    5757c     *************************************************
     
    110110
    111111c       Loop over size bins
    112         do 200 i=1,nbin_cld
     112        do i=1,nbin_cld
    113113
    114114          if ( n_ccn(i) .lt. 1e-10 ) then
    115115c           no dust, no need to compute nucleation!
    116116            nucrate(i)=0.
    117             goto 200
     117            ! move on to next bin
     118            cycle
    118119          endif
    119120
     
    143144          endif
    144145
    145 200     continue
     146        enddo ! of do i=1,nbin_cld
    146147
    147148      else
     
    151152        enddo
    152153
    153       endif
     154      endif ! of if (sat .gt. 1.)
    154155
    155       return
    156       end
     156      end subroutine nuclea
    157157
    158158*********************************************************
     
    163163*********************************************************
    164164
    165       double precision cost,rap
     165      double precision, intent(in) :: cost,rap
    166166      double precision yeah
    167167
     
    181181          fshape = 0.5*fshape
    182182
    183       return
    184       end
     183      end function fshape
     184
     185
     186      END MODULE nuclea_mod
  • trunk/LMDZ.MARS/libf/phymars/nucleaco2.F90

    r2562 r3008  
    22  implicit none
    33  contains
     4
    45subroutine nucleaco2(pco2,temp,sat,n_ccn,nucrate,vo2co2, teta)
    5 USE comcstfi_h
     6
     7use comcstfi_h, only: pi
     8use microphys_h, only: nbinco2_cld, rad_cldco2, desorpco2, m0co2, kbz
     9use microphys_h, only: nusco2, sigco2, surfdifco2
    610
    711implicit none
     
    2630!nucleation sur dust et h2o separement ici
    2731
    28 include "microphys.h"
    2932include "callkeys.h"
    3033
     
    9497!*********************************************************
    9598
    96 double precision cost,rap
     99double precision, intent(in) :: cost,rap
    97100double precision yeah
    98101
  • trunk/LMDZ.MARS/libf/phymars/vdifc_mod.F

    r2953 r3008  
    3131      use comslope_mod, ONLY: nslope,def_slope,def_slope_mean,
    3232     &                      subslope_dist,major_slope,iflat
     33      use microphys_h, only: To
    3334
    3435      IMPLICIT NONE
     
    5556
    5657      include "callkeys.h"
    57       include "microphys.h"
    5858
    5959c
Note: See TracChangeset for help on using the changeset viewer.