Changeset 3094


Ignore:
Timestamp:
Oct 22, 2023, 1:42:30 PM (14 months ago)
Author:
emillour
Message:

Mars PCM:
Fix issues with dates when in parallel with OpenMP (missing copyin
statement when opening parallel section in iniphysiq). Added some threadprivate
clauses in saved module variables in comcstfi_h.F90 and planete_h.F90.
Prettyfied solarlong.F and made it a module. Likewise for conf_phys.F
EM

Location:
trunk/LMDZ.MARS
Files:
8 edited

Legend:

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

    r3092 r3094  
    42664266    - Addition of the file "start1D.txt" as an example in the directory deftank/;
    42674267    - Some "cosmetic" modifications in "improvedclouds_mod.F", "write_output_mod.F90" and "testphys1d.F90".
     4268
     4269== 22/10/2023 == EM
     4270Fix issues with dates when in parallel with OpenMP (missing copyin
     4271statement when opening parallel section in iniphysiq). Added some threadprivate
     4272clauses in saved module variables in comcstfi_h.F90 and planete_h.F90.
     4273Prettyfied solarlong.F and made it a module. Likewise for conf_phys.F
  • trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/iniphysiq_mod.F90

    r2511 r3094  
    1010                     prad,pg,pr,pcpp,iflag_phys)
    1111
     12! Modules from the dynamics:
    1213use infotrac, only : nqtot, & ! number of advected tracers
    1314                     tname, & ! tracer names
    1415                     nqperes,nqfils! MVals: variables isotopes
     16use temps_mod, only: day_ini, day_end, hour_ini
     17
     18! Modules from the dynamics-physics interface:
     19use inigeomphy_mod, only: inigeomphy
     20
     21! Modules from the physics:
    1522use comgeomfi_h, only: ini_fillgeom
    16 use temps_mod, only: day_ini, day_end, hour_ini
    17 use phys_state_var_init_mod, only: phys_state_var_init
    18 use inigeomphy_mod, only: inigeomphy
    1923use geometry_mod, only: cell_area, & ! physics grid area (m2)
    2024                        longitude, & ! longitudes (rad)
    2125                        latitude ! latitudes (rad)
    22 ! necessary to get klon_omp
    23 USE mod_phys_lmdz_para, ONLY: klon_omp ! number of columns (on local omp grid)
    24 USE dimphy, ONLY: init_dimphy
     26use phys_state_var_init_mod, only: phys_state_var_init
     27use mod_phys_lmdz_para, only: klon_omp ! number of columns (on local omp grid)
     28use conf_phys_mod, only: conf_phys
    2529
    2630implicit none
     
    6266  !------------------------------------------
    6367
    64 !$OMP PARALLEL
    65  
    6668! copy some fundamental parameters to physics
    6769! and do some initializations
    68 
    69 ! Initialize dimphy module => Now done in physics_distribution_mod
    70 !call init_dimphy(klon_omp,nlayer)
     70! Note that for OpenMP threadprivate variables a COPYIN clause is required
     71!$OMP PARALLEL COPYIN(day_ini,day_end,hour_ini)
    7172
    7273call phys_state_var_init(klon_omp,nlayer,nqtot,tname, &
     
    8081call conf_phys(klon_omp,nlayer,nqtot)
    8182
    82 ! Initialize some "temporal and calendar" related variables
    83 !CALL init_time(day_ini,hour_ini,punjours,ptimestep)
    84 
    8583!$OMP END PARALLEL
    8684
  • trunk/LMDZ.MARS/libf/phymars/comcstfi_h.F90

    r1524 r3094  
    22      IMPLICIT NONE
    33
    4       REAL pi ! something like 3.14159
    5       REAL rad ! radius of the planet (m)
    6       REAL g ! gravity (m/s2)
    7       REAL r ! reduced gas constant (r=8.314511/(mugaz/1000.0))
    8       REAL cpp ! Cp of the atmosphere
    9       REAL rcp ! r/cpp
    10       REAL mugaz ! molar mass of the atmosphere (g/mol)
    11       REAL omeg ! planet rotation rate (rad/s)
    12 
     4      REAL,SAVE :: pi ! something like 3.14159
     5      REAL,SAVE :: rad ! radius of the planet (m)
     6      REAL,SAVE :: g ! gravity (m/s2)
     7!$OMP THREADPRIVATE(pi,rad,g)
     8      REAL,SAVE :: r ! reduced gas constant (r=8.314511/(mugaz/1000.0))
     9      REAL,SAVE :: cpp ! Cp of the atmosphere
     10      REAL,SAVE :: rcp ! r/cpp
     11!$OMP THREADPRIVATE(r,cpp,rcp)
     12      REAL,SAVE :: mugaz ! molar mass of the atmosphere (g/mol)
     13      REAL,SAVE :: omeg ! planet rotation rate (rad/s)
     14!$OMP THREADPRIVATE(mugaz,omeg)
     15     
    1316      END MODULE comcstfi_h
  • trunk/LMDZ.MARS/libf/phymars/conf_phys.F

    r3064 r3094  
     1      MODULE conf_phys_mod
     2     
     3      IMPLICIT NONE
     4     
     5      CONTAINS
     6
    17      SUBROUTINE conf_phys(ngrid,nlayer,nq)
    28 
     
    612!   -------
    713!
    8 !   Initialisation for the physical parametrisations of the LMD
    9 !   martian atmospheric general circulation modele.
    10 !
    11 !   author: Frederic Hourdin 15 / 10 /93
    12 !   -------
    13 !   modified: Sebastien Lebonnois 11/06/2003 (new callphys.def)
    14 !             Ehouarn Millour (oct. 2008) tracers are now identified
    15 !              by their names and may not be contiguously
    16 !              stored in the q(:,:,:,:) array
    17 !             E.M. (june 2009) use getin routine to load parameters
    18 !             adapted to the mesoscale use - Aymeric Spiga - 01/2007-07/2011
    19 !             separated inifis into conf_phys and phys_state_var_init (A. Spiga)
    20 !
    21 !
    22 !   arguments:
    23 !   ----------
    24 !
    25 !   input:
    26 !   ------
    27 !
    28 !    nq                    Number of tracers
    29 !
    30 !=======================================================================
    31 !
     14!   Initialisation for the physical parametrisations
     15!   flags (i.e. run-time options) of the Mars PCM
    3216!-----------------------------------------------------------------------
    33 !   declarations:
    34 !   -------------
     17
    3518      USE ioipsl_getin_p_mod, ONLY : getin_p
    3619      use tracer_mod, only : nuice_sed, ccn_factor, nuiceco2_sed,
     
    6144      include "callkeys.h"
    6245
    63       INTEGER,INTENT(IN) :: ngrid,nlayer,nq
     46      INTEGER,INTENT(IN) :: ngrid ! number of atmospheric columns
     47      INTEGER,INTENT(IN) :: nlayer ! number of atmospheric layers
     48      INTEGER,INTENT(IN) :: nq ! number of tracers
    6449
    6550      INTEGER ierr,j
     
    12261211      call bcast(semi)
    12271212
    1228       END
     1213      END SUBROUTINE conf_phys
     1214
     1215      END MODULE conf_phys_mod
  • trunk/LMDZ.MARS/libf/phymars/dyn1d/init_testphys1d_mod.F90

    r3080 r3094  
    3939use turb_mod,                 only: q2
    4040use nonoro_gwd_ran_mod, only: du_nonoro_gwd, dv_nonoro_gwd
     41use conf_phys_mod, only: conf_phys
    4142! Mostly for XIOS outputs:
    4243use mod_const_mpi,            only: COMM_LMDZ
  • trunk/LMDZ.MARS/libf/phymars/physiq_mod.F

    r3078 r3094  
    6161      use comsaison_h, only: dist_sol, declin, zls,
    6262     &                       mu0, fract, local_time
     63      use solarlong_mod, only: solarlong
    6364      use nirdata_mod, only: NIR_leedat
    6465      use nirco2abs_mod, only: nirco2abs
     
    26052606           ELSE ! IF LMDZ
    26062607
    2607           if (ecritstart.GT.0) then !IF MULTIPLE RESTARTS nothing change
    2608           ztime_fin = pday - day_ini + ptime 
    2609      .               + ptimestep/(float(iphysiq)*daysec)
    2610           else !IF ONE RESTART final time in top of day_end
    2611           ztime_fin = pday - day_ini-(day_end-day_ini)
    2612      .               + ptime  + ptimestep/(float(iphysiq)*daysec)
    2613           endif
     2608            if (ecritstart.GT.0) then !IF MULTIPLE RESTARTS nothing change
     2609              ztime_fin = pday - day_ini + ptime 
     2610     &                    + ptimestep/(float(iphysiq)*daysec)
     2611            else !IF ONE RESTART final time in top of day_end
     2612              ztime_fin = pday - day_ini-(day_end-day_ini)
     2613     &                    + ptime  + ptimestep/(float(iphysiq)*daysec)
     2614            endif
    26142615
    26152616           ENDIF ! of IF (grid_type==unstructured)
  • trunk/LMDZ.MARS/libf/phymars/planete_h.F90

    r3040 r3094  
    22      IMPLICIT NONE
    33
    4       REAL aphelie   ! Aphelion, in Mkm
    5       REAL periheli  ! Perihelion, in Mkm
    6       REAL year_day  ! Number of days in the year
    7       REAL peri_day  ! Date of perihelion, in days
    8       REAL obliquit  ! Obliquity of the planet, in degrees
    9       REAL lmixmin
    10       REAL emin_turb
    11       REAL coefvis
    12       REAL coefir
    13       REAL lsperi    ! Solar longitude of the perihelion, angle in rad
    14       REAL e_elips   ! Orbit eccentricity
    15       REAL p_elips   ! Ellipse semi-latus rectum
    16       REAL unitastr  ! Astronomical unit AU, in Mkm
     4      REAL,SAVE :: aphelie   ! Aphelion, in Mkm
     5      REAL,SAVE :: periheli  ! Perihelion, in Mkm
     6      REAL,SAVE :: year_day  ! Number of days in the year
     7!$OMP THREADPRIVATE(aphelie,periheli,year_day)
     8      REAL,SAVE :: peri_day  ! Date of perihelion, in days
     9      REAL,SAVE :: obliquit  ! Obliquity of the planet, in degrees
     10      REAL,SAVE :: lmixmin
     11!$OMP THREADPRIVATE(peri_day,obliquit,lmixmin)
     12      REAL,SAVE :: emin_turb
     13      REAL,SAVE :: coefvis
     14      REAL,SAVE :: coefir
     15!$OMP THREADPRIVATE(emin_turb,coefvis,coefir)
     16      REAL,SAVE :: lsperi    ! Solar longitude of the perihelion, angle in rad
     17      REAL,SAVE :: e_elips   ! Orbit eccentricity
     18      REAL,SAVE :: p_elips   ! Ellipse semi-latus rectum
     19      REAL,SAVE :: unitastr  ! Astronomical unit AU, in Mkm
     20!$OMP THREADPRIVATE(lsperi,e_elips,p_elips,unitastr)
    1721
    1822      END MODULE planete_h
  • trunk/LMDZ.MARS/libf/phymars/solarlong.F

    r3040 r3094  
     1      MODULE solarlong_mod
     2
     3      IMPLICIT NONE
     4
     5      CONTAINS
     6     
    17      SUBROUTINE solarlong(pday,psollong)
    2       use planete_h
    3       USE comcstfi_h
     8      use planete_h, only: lsperi, peri_day, year_day, e_elips
     9      use comcstfi_h, only: pi
    410      IMPLICIT NONE
    511
    612c=======================================================================
    7 c
    8 c   Objet:
    9 c   ------
    10 c
    11 c      Calcul de la distance soleil-planete et de la declinaison
    12 c   en fonction du jour de l'annee.
    13 c
    14 c
    15 c   Methode:
    16 c   --------
    17 c
    18 c      Calcul complet de l'elipse
    19 c
    20 c   Interface:
    21 c   ----------
    22 c
    23 c      Uncommon comprenant les parametres orbitaux.
    24 c
    25 c   Arguments:
    26 c   ----------
    27 c
    28 c   Input:
    29 c   ------
    30 c   pday          jour de l'annee (le jour 0 correspondant a l'equinoxe)
    31 c   lwrite        clef logique pour sorties de controle
    32 c
    33 c   Output:
    34 c   -------
    35 c   pdist_sol     distance entre le soleil et la planete
    36 c                 ( en unite astronomique pour utiliser la constante
    37 c                  solaire terrestre 1370 Wm-2 )
    38 c   pdecli        declinaison ( en radians )
    39 c
     13c   Compute solar longitude psollong (in radians) for a given Mars date
     14c   pday (where pday==0 at northern Spring Equinox and pday in sols
     15c   and fractions thereof)
    4016c=======================================================================
    41 c-----------------------------------------------------------------------
    42 c   Declarations:
    43 c   -------------
    4417
    4518c arguments:
    4619c ----------
    4720
    48       REAL pday,pdist_sol,pdecli,psollong
    49       LOGICAL lwrite
     21      REAL,INTENT(IN) :: pday
     22      REAL,INTENT(OUT) :: psollong
     23     
     24c Local variables:
     25c ----------------
    5026
    51 c Local:
    52 c ------
    53 
    54       REAL zanom,xref,zx0,zdx,zteta,zz
    55       INTEGER iter
     27      REAL :: xref ! mean anomaly
     28      REAL :: zx0 ! eccentric anomaly
     29      REAL :: zteta ! true anomaly
     30      REAL :: zanom,zdx,zz
     31      INTEGER :: iter
    5632
    5733
    58 c-----------------------------------------------------------------------
    59 c calcul de l'angle polaire et de la distance au soleil :
    60 c -------------------------------------------------------
    61 
    62 c  calcul de l'zanomalie moyenne
     34c  compute mean anomaly
    6335
    6436      zz=(pday-peri_day)/year_day
     
    6739      xref=abs(zanom)
    6840
    69 resolution de l'equation horaire  zx0 - e * sin (zx0) = xref
    70 methode de Newton
     41solve equation  zx0 - e * sin (zx0) = xref
     42using Newton method
    7143
    7244      zx0=xref+e_elips*sin(xref)
    73       DO 110 iter=1,10
     45      DO iter=1,10 ! 10 is overkill, typically converges in 1-3 iterations
    7446         zdx=-(zx0-e_elips*sin(zx0)-xref)/(1.-e_elips*cos(zx0))
    75          if(abs(zdx).le.(1.e-7)) goto 120
     47         if(abs(zdx).le.(1.e-7)) exit
    7648         zx0=zx0+zdx
    77 110   continue
    78 120   continue
     49      ENDDO
     50
    7951      zx0=zx0+zdx
    8052      if(zanom.lt.0.) zx0=-zx0
    8153
    82 c zteta est la longitude solaire
     54c compute true anomaly zteta, now that eccentric anomaly zx0 is known
    8355
    8456      zteta=2.*atan(sqrt((1.+e_elips)/(1.-e_elips))*tan(zx0/2.))
    8557
     58c compute solar longitude from zteta
    8659      psollong=zteta+lsperi
    8760
     61c handle limit cases where psollong lands outside [0:2*pi]
    8862      IF(psollong.LT.0.) psollong=psollong+2.*pi
    8963      IF(psollong.GT.2.*pi) psollong=psollong-2.*pi
    90 c-----------------------------------------------------------------------
    91 c   sorties eventuelles:
    92 c   ---------------------
    9364
    94 c     IF (lwrite) THEN
    95 c        PRINT*,'jour de l"annee   :',pday
    96 c        PRINT*,'distance au soleil (en unite astronomique) :',pdist_sol
    97 c        PRINT*,'declinaison (en degres) :',pdecli*180./pi
    98 c     ENDIF
     65      END SUBROUTINE solarlong
    9966
    100       RETURN
    101       END
     67      END MODULE solarlong_mod
Note: See TracChangeset for help on using the changeset viewer.