source: LMDZ6/trunk/libf/phylmd/phyaqua_mod.F90 @ 3479

Last change on this file since 3479 was 3435, checked in by Laurent Fairhead, 5 years ago

"Historic" :-) commit merging the physics branch used for DYNAMICO with the LMDZ trunk.
The same physics branch can now be used seamlessly with the traditional lon-lat LMDZ
dynamical core and DYNAMICO.
Testing consisted in running a lon-lat LMDZ bucket simulation with the NPv6.1 physics package
with the original trunk sources and the merged sources. Tests were succesful in the sense that
numeric continuity was preserved in the restart files from both simulation. Further tests
included running both versions of the physics codes for one year in a LMDZOR setting in which
the restart files also came out identical.

Caution:

  • as the physics package now manages unstructured grids, grid information needs to be transmitted

to the surface scheme ORCHIDEE. This means that the interface defined in surf_land_orchidee_mod.F90
is only compatible with ORCHIDEE version orchidee2.1 and later versions. If previous versions of
ORCHIDEE need to be used, the CPP key ORCHIDEE_NOUNSTRUCT needs to be set at compilation time.
This is done automatically if makelmdz/makelmdz_fcm are called with the veget orchidee2.0 switch

  • due to a limitation in XIOS, the time at which limit conditions will be read in by DYNAMICO will be

delayed by one physic timestep with respect to the time it is read in by the lon-lat model. This is caused
by the line

IF (MOD(itime-1, lmt_pas) == 0 .OR. (jour_lu /= jour .AND. grid_type /= unstructured)) THEN ! time to read

in limit_read_mod.F90

Work still needed on COSP integration and XML files for DYNAMICO

EM, YM, LF

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
File size: 30.6 KB
RevLine 
[1992]1MODULE phyaqua_mod
2  ! Routines complementaires pour la physique planetaire.
3  IMPLICIT NONE
[1529]4
[1992]5CONTAINS
[1529]6
[2351]7  SUBROUTINE iniaqua(nlon, iflag_phys)
[1529]8
[1992]9    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10    ! Creation d'un etat initial et de conditions aux limites
11    ! (resp startphy.nc et limit.nc) pour des configurations idealisees
12    ! du modele LMDZ dans sa version terrestre.
13    ! iflag_phys est un parametre qui controle
14    ! iflag_phys = N
15    ! de 100 a 199 : aqua planetes avec SST forcees
16    ! N-100 determine le type de SSTs
17    ! de 200 a 299 : terra planetes avec Ts calcule
[1529]18
[1992]19    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[1529]20
[1992]21    USE dimphy, ONLY: klon
[2351]22    USE geometry_mod, ONLY : latitude
[1992]23    USE surface_data, ONLY: type_ocean, ok_veget
24    USE pbl_surface_mod, ONLY: pbl_surface_init
25    USE fonte_neige_mod, ONLY: fonte_neige_init
26    USE phys_state_var_mod
[2344]27    USE time_phylmdz_mod, ONLY: day_ref, ndays, pdtphys, &
28                                day_ini,day_end
[1992]29    USE indice_sol_mod
[2344]30    USE nrtype, ONLY: pi
[3435]31!    USE ioipsl
32    USE mod_phys_lmdz_para, ONLY: is_master
33    USE mod_phys_lmdz_transfert_para, ONLY: bcast
34    USE mod_grid_phy_lmdz
35    USE ioipsl_getin_p_mod, ONLY : getin_p
[1992]36    IMPLICIT NONE
[1529]37
[2344]38    include "YOMCST.h"
[1992]39    include "clesphys.h"
40    include "dimsoil.h"
[1671]41
[1992]42    INTEGER, INTENT (IN) :: nlon, iflag_phys
43    ! IM ajout latfi, lonfi
[2351]44!    REAL, INTENT (IN) :: lonfi(nlon), latfi(nlon)
[1529]45
[1992]46    INTEGER type_profil, type_aqua
[1529]47
[1992]48    ! Ajouts initialisation des surfaces
49    REAL :: run_off_lic_0(nlon)
50    REAL :: qsolsrf(nlon, nbsrf), snsrf(nlon, nbsrf)
51    REAL :: tsoil(nlon, nsoilmx, nbsrf)
52    REAL :: tslab(nlon), seaice(nlon)
[2243]53    REAL fder(nlon)
[1529]54
55
56
[1992]57    ! Arguments :
58    ! -----------
[1529]59
[1992]60    ! integer radpas
61    INTEGER it, unit, i, k, itap
[1529]62
[1992]63    REAL rugos, albedo
64    REAL tsurf
65    REAL time, timestep, day, day0
[2243]66    REAL qsol_f
[1992]67    REAL rugsrel(nlon)
68    LOGICAL alb_ocean
[1529]69
[1992]70    CHARACTER *80 ans, file_forctl, file_fordat, file_start
71    CHARACTER *100 file, var
72    CHARACTER *2 cnbl
[1529]73
[1992]74    REAL phy_nat(nlon, 360)
75    REAL phy_alb(nlon, 360)
76    REAL phy_sst(nlon, 360)
77    REAL phy_bil(nlon, 360)
78    REAL phy_rug(nlon, 360)
79    REAL phy_ice(nlon, 360)
80    REAL phy_fter(nlon, 360)
81    REAL phy_foce(nlon, 360)
82    REAL phy_fsic(nlon, 360)
83    REAL phy_flic(nlon, 360)
[1529]84
[1992]85    INTEGER, SAVE :: read_climoz = 0 ! read ozone climatology
[3435]86!$OMP THREADPRIVATE(read_climoz)
[1529]87
[1992]88    ! -------------------------------------------------------------------------
89    ! declaration pour l'appel a phyredem
90    ! -------------------------------------------------------------------------
[1529]91
[1992]92    ! real pctsrf(nlon,nbsrf),ftsol(nlon,nbsrf)
93    REAL falbe(nlon, nbsrf), falblw(nlon, nbsrf)
94    ! real pbl_tke(nlon,llm,nbsrf)
95    ! real rain_fall(nlon),snow_fall(nlon)
96    ! real solsw(nlon), sollw(nlon),radsol(nlon)
97    ! real t_ancien(nlon,llm),q_ancien(nlon,llm),rnebcon(nlon,llm)
98    ! real ratqs(nlon,llm)
99    ! real clwcon(nlon,llm)
[1529]100
[1992]101    INTEGER longcles
102    PARAMETER (longcles=20)
103    REAL clesphy0(longcles)
[1529]104
105
[1992]106    ! -----------------------------------------------------------------------
107    ! dynamial tendencies :
108    ! ---------------------
[1529]109
[1992]110    INTEGER l, ierr, aslun
[1529]111
[1992]112    REAL paire
[1529]113
114
[1992]115    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
116    ! INITIALISATIONS
117    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[1529]118
[1992]119    ! -----------------------------------------------------------------------
120    ! Initialisations  des constantes
121    ! -------------------------------
[1529]122
123
[1992]124    type_aqua = iflag_phys/100
125    type_profil = iflag_phys - type_aqua*100
126    PRINT *, 'iniaqua:type_aqua, type_profil', type_aqua, type_profil
[1529]127
[1992]128    IF (klon/=nlon) THEN
129      WRITE (*, *) 'iniaqua: klon=', klon, ' nlon=', nlon
130      STOP 'probleme de dimensions dans iniaqua'
131    END IF
132    CALL phys_state_var_init(read_climoz)
[1529]133
134
[1992]135    read_climoz = 0
136    day0 = 217.
137    day = day0
138    it = 0
139    time = 0.
[1529]140
[1992]141    ! -----------------------------------------------------------------------
142    ! initialisations de la physique
143    ! -----------------------------------------------------------------------
[1529]144
[2344]145    day_ini = day_ref
146    day_end = day_ini + ndays
[1759]147
[3435]148    nbapp_rad = 24
149    CALL getin_p('nbapp_rad', nbapp_rad)
150
[1992]151    ! ---------------------------------------------------------------------
152    ! Creation des conditions aux limites:
153    ! ------------------------------------
154    ! Initialisations des constantes
155    ! Ajouter les manquants dans planete.def... (albedo etc)
[3435]156    co2_ppm = 348.
157    CALL getin_p('co2_ppm', co2_ppm)
158
159    solaire = 1365.
160    CALL getin_p('solaire', solaire)
161 
[1992]162    ! CALL getin('albedo',albedo) ! albedo is set below, depending on
163    ! type_aqua
[3435]164    alb_ocean = .TRUE.
165    CALL getin_p('alb_ocean', alb_ocean)
166
[1992]167    WRITE (*, *) 'iniaqua: co2_ppm=', co2_ppm
168    WRITE (*, *) 'iniaqua: solaire=', solaire
169    WRITE (*, *) 'iniaqua: alb_ocean=', alb_ocean
[1529]170
[1992]171    radsol = 0.
172    qsol_f = 10.
[1529]173
[1992]174    ! Conditions aux limites:
175    ! -----------------------
[1529]176
[1992]177    qsol(:) = qsol_f
178    rugsrel = 0.0 ! (rugsrel = rugoro)
179    rugoro = 0.0
180    u_ancien = 0.0
181    v_ancien = 0.0
182    agesno = 50.0
183    ! Relief plat
184    zmea = 0.
185    zstd = 0.
186    zsig = 0.
187    zgam = 0.
188    zthe = 0.
189    zpic = 0.
190    zval = 0.
[1529]191
[1992]192    ! Une seule surface
193    pctsrf = 0.
194    IF (type_aqua==1) THEN
195      rugos = 1.E-4
196      albedo = 0.19
197      pctsrf(:, is_oce) = 1.
198    ELSE IF (type_aqua==2) THEN
199      rugos = 0.03
200      albedo = 0.1
201      pctsrf(:, is_ter) = 1.
202    END IF
[1529]203
[3435]204    CALL getin_p('rugos', rugos)
205
[1992]206    WRITE (*, *) 'iniaqua: rugos=', rugos
[2209]207    zmasq(:) = pctsrf(:, is_ter)
[1529]208
[1992]209    ! pctsrf_pot(:,is_oce) = 1. - zmasq(:)
210    ! pctsrf_pot(:,is_sic) = 1. - zmasq(:)
[1529]211
[1992]212    ! Si alb_ocean on calcule un albedo oceanique moyen
213    ! if (alb_ocean) then
214    ! Voir pourquoi on avait ca.
215    ! CALL ini_alb_oce(phy_alb)
216    ! else
217    phy_alb(:, :) = albedo ! albedo land only (old value condsurf_jyg=0.3)
218    ! endif !alb_ocean
[1529]219
[1992]220    DO i = 1, 360
221      ! IM Terraplanete   phy_sst(:,i) = 260.+50.*cos(rlatd(:))**2
222      ! IM ajout calcul profil sst selon le cas considere (cf. FBr)
[1529]223
[1992]224      phy_nat(:, i) = 1.0 ! 0=ocean libre, 1=land, 2=glacier, 3=banquise
225      phy_bil(:, i) = 1.0 ! ne sert que pour les slab_ocean
226      phy_rug(:, i) = rugos ! longueur rugosite utilisee sur land only
227      phy_ice(:, i) = 0.0 ! fraction de glace (?)
228      phy_fter(:, i) = pctsrf(:, is_ter) ! fraction de glace (?)
229      phy_foce(:, i) = pctsrf(:, is_oce) ! fraction de glace (?)
230      phy_fsic(:, i) = pctsrf(:, is_sic) ! fraction de glace (?)
231      phy_flic(:, i) = pctsrf(:, is_lic) ! fraction de glace (?)
232    END DO
233    ! IM calcul profil sst
[2351]234    CALL profil_sst(nlon, latitude, type_profil, phy_sst)
[1529]235
[3435]236    IF (grid_type==unstructured) THEN
237      CALL writelim_unstruct(klon, phy_nat, phy_alb, phy_sst, phy_bil, phy_rug, phy_ice, &
238                             phy_fter, phy_foce, phy_flic, phy_fsic)
239    ELSE
240     
241       CALL writelim(klon, phy_nat, phy_alb, phy_sst, phy_bil, phy_rug, phy_ice, &
242                     phy_fter, phy_foce, phy_flic, phy_fsic)
243    ENDIF
[1529]244
[1992]245    ! ---------------------------------------------------------------------
246    ! Ecriture de l'etat initial:
247    ! ---------------------------
[1529]248
249
[1992]250    ! Ecriture etat initial physique
[1529]251
[2344]252    timestep = pdtphys
253    radpas = nint(rday/timestep/float(nbapp_rad))
[1529]254
[1992]255    DO i = 1, longcles
256      clesphy0(i) = 0.
257    END DO
258    clesphy0(1) = float(iflag_con)
259    clesphy0(2) = float(nbapp_rad)
260    ! IF( cycle_diurne  ) clesphy0(3) =  1.
261    clesphy0(3) = 1. ! cycle_diurne
262    clesphy0(4) = 1. ! soil_model
263    clesphy0(5) = 1. ! new_oliq
264    clesphy0(6) = 0. ! ok_orodr
265    clesphy0(7) = 0. ! ok_orolf
266    clesphy0(8) = 0. ! ok_limitvrai
[1529]267
268
[1992]269    ! =======================================================================
270    ! Profils initiaux
271    ! =======================================================================
[1529]272
[1992]273    ! On initialise les temperatures de surfaces comme les sst
274    DO i = 1, nlon
275      ftsol(i, :) = phy_sst(i, 1)
276      tsoil(i, :, :) = phy_sst(i, 1)
277      tslab(i) = phy_sst(i, 1)
278    END DO
[1529]279
[1992]280    falbe(:, :) = albedo
281    falblw(:, :) = albedo
282    rain_fall(:) = 0.
283    snow_fall(:) = 0.
284    solsw(:) = 0.
285    sollw(:) = 0.
286    radsol(:) = 0.
[1529]287
[1992]288    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
289    ! intialisation bidon mais pas grave
290    t_ancien(:, :) = 0.
291    q_ancien(:, :) = 0.
292    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
293    rnebcon = 0.
294    ratqs = 0.
295    clwcon = 0.
296    pbl_tke = 1.E-8
[1529]297
[1992]298    ! variables supplementaires pour appel a plb_surface_init
299    fder(:) = 0.
300    seaice(:) = 0.
301    run_off_lic_0 = 0.
[2243]302    fevap = 0.
[1529]303
304
[1992]305    ! Initialisations necessaires avant phyredem
306    type_ocean = 'force'
307    CALL fonte_neige_init(run_off_lic_0)
308    qsolsrf(:, :) = qsol(1) ! humidite du sol des sous surface
309    snsrf(:, :) = 0. ! couverture de neige des sous surface
[2243]310    z0m(:, :) = rugos ! couverture de neige des sous surface
311    z0h=z0m
[1530]312
313
[2243]314    CALL pbl_surface_init(fder, snsrf, qsolsrf, tsoil)
[1529]315
[1992]316    PRINT *, 'iniaqua: before phyredem'
[1529]317
[3435]318    pbl_tke(:,:,:) = 1.e-8
[1992]319    falb1 = albedo
320    falb2 = albedo
321    zmax0 = 0.
322    f0 = 0.
323    sig1 = 0.
324    w01 = 0.
325    wake_deltat = 0.
326    wake_deltaq = 0.
327    wake_s = 0.
[3435]328    wake_dens = 0.
[1992]329    wake_cstar = 0.
330    wake_pe = 0.
331    wake_fip = 0.
332    fm_therm = 0.
333    entr_therm = 0.
334    detr_therm = 0.
[2827]335    ale_bl = 0.
336    ale_bl_trig =0.
337    alp_bl =0.
[2979]338    treedrg(:,:,:)=0.
[1529]339
[3435]340!ym error : the sub surface dimension is the third not second : forgotten for iniaqua
341!    falb_dir(:,is_ter,:)=0.08; falb_dir(:,is_lic,:)=0.6
342!    falb_dir(:,is_oce,:)=0.5;  falb_dir(:,is_sic,:)=0.6
343    falb_dir(:,:,is_ter)=0.08; falb_dir(:,:,is_lic)=0.6
344    falb_dir(:,:,is_oce)=0.5;  falb_dir(:,:,is_sic)=0.6
[1529]345
[3435]346!ym falb_dif has been forgotten, initialize with defaukt value found in phyetat0 or 0 ?
347!ym probably the uninitialized value was 0 for standard (regular grid) case
348    falb_dif(:,:,:)=0
349
350
[1992]351    CALL phyredem('startphy.nc')
[1529]352
[1992]353    PRINT *, 'iniaqua: after phyredem'
354    CALL phys_state_var_end
[1529]355
[1992]356    RETURN
357  END SUBROUTINE iniaqua
[1529]358
359
[1992]360  ! ====================================================================
361  ! ====================================================================
362  SUBROUTINE zenang_an(cycle_diurne, gmtime, rlat, rlon, rmu0, fract)
363    USE dimphy
364    IMPLICIT NONE
365    ! ====================================================================
366    ! =============================================================
367    ! CALL zenang(cycle_diurne,gmtime,rlat,rlon,rmu0,fract)
368    ! Auteur : A. Campoy et F. Hourdin
369    ! Objet  : calculer les valeurs moyennes du cos de l'angle zenithal
370    ! et l'ensoleillement moyen entre gmtime1 et gmtime2
371    ! connaissant la declinaison, la latitude et la longitude.
[1529]372
[1992]373    ! Dans cette version particuliere, on calcule le rayonnement
374    ! moyen sur l'année à chaque latitude.
375    ! angle zenithal calculé pour obtenir un
376    ! Fit polynomial de  l'ensoleillement moyen au sommet de l'atmosphere
377    ! en moyenne annuelle.
378    ! Spécifique de la terre. Utilisé pour les aqua planetes.
[1529]379
[1992]380    ! Rque   : Different de la routine angle en ce sens que zenang
381    ! fournit des moyennes de pmu0 et non des valeurs
382    ! instantanees, du coup frac prend toutes les valeurs
383    ! entre 0 et 1.
384    ! Date   : premiere version le 13 decembre 1994
385    ! revu pour  GCM  le 30 septembre 1996
386    ! ===============================================================
387    ! longi----INPUT : la longitude vraie de la terre dans son plan
388    ! solaire a partir de l'equinoxe de printemps (degre)
389    ! gmtime---INPUT : temps universel en fraction de jour
390    ! pdtrad---INPUT : pas de temps du rayonnement (secondes)
391    ! lat------INPUT : latitude en degres
392    ! long-----INPUT : longitude en degres
393    ! pmu0-----OUTPUT: angle zenithal moyen entre gmtime et gmtime+pdtrad
394    ! frac-----OUTPUT: ensoleillement moyen entre gmtime et gmtime+pdtrad
395    ! ================================================================
396    include "YOMCST.h"
397    ! ================================================================
398    LOGICAL cycle_diurne
399    REAL gmtime
400    REAL rlat(klon), rlon(klon), rmu0(klon), fract(klon)
401    ! ================================================================
402    INTEGER i
403    REAL gmtime1, gmtime2
404    REAL pi_local
[1529]405
406
[1992]407    REAL rmu0m(klon), rmu0a(klon)
[1529]408
409
[1992]410    pi_local = 4.0*atan(1.0)
[1529]411
[1992]412    ! ================================================================
413    ! Calcul de l'angle zenithal moyen sur la journee
414    ! ================================================================
415
416    DO i = 1, klon
417      fract(i) = 1.
418      ! Calcule du flux moyen
419      IF (abs(rlat(i))<=28.75) THEN
420        rmu0m(i) = (210.1924+206.6059*cos(0.0174533*rlat(i))**2)/1365.
421      ELSE IF (abs(rlat(i))<=43.75) THEN
422        rmu0m(i) = (187.4562+236.1853*cos(0.0174533*rlat(i))**2)/1365.
423      ELSE IF (abs(rlat(i))<=71.25) THEN
424        rmu0m(i) = (162.4439+284.1192*cos(0.0174533*rlat(i))**2)/1365.
[1529]425      ELSE
[1992]426        rmu0m(i) = (172.8125+183.7673*cos(0.0174533*rlat(i))**2)/1365.
427      END IF
428    END DO
[1529]429
[1992]430    ! ================================================================
431    ! Avec ou sans cycle diurne
432    ! ================================================================
[1529]433
[1992]434    IF (cycle_diurne) THEN
[1529]435
[1992]436      ! On redecompose flux  au sommet suivant un cycle diurne idealise
437      ! identique a toutes les latitudes.
[1671]438
[1992]439      DO i = 1, klon
440        rmu0a(i) = 2.*rmu0m(i)*sqrt(2.)*pi_local/(4.-pi_local)
441        rmu0(i) = rmu0a(i)*abs(sin(pi_local*gmtime+pi_local*rlon(i)/360.)) - &
442          rmu0a(i)/sqrt(2.)
443      END DO
[1671]444
[1992]445      DO i = 1, klon
446        IF (rmu0(i)<=0.) THEN
447          rmu0(i) = 0.
448          fract(i) = 0.
449        ELSE
450          fract(i) = 1.
451        END IF
452      END DO
[1671]453
[1992]454      ! Affichage de l'angel zenitale
455      ! print*,'************************************'
456      ! print*,'************************************'
457      ! print*,'************************************'
458      ! print*,'latitude=',rlat(i),'longitude=',rlon(i)
459      ! print*,'rmu0m=',rmu0m(i)
460      ! print*,'rmu0a=',rmu0a(i)
461      ! print*,'rmu0=',rmu0(i)
[1529]462
[1992]463    ELSE
[1671]464
[1992]465      DO i = 1, klon
466        fract(i) = 0.5
467        rmu0(i) = rmu0m(i)*2.
468      END DO
469
470    END IF
471
472    RETURN
473  END SUBROUTINE zenang_an
474
475  ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
476
[3435]477  SUBROUTINE writelim_unstruct(klon, phy_nat, phy_alb, phy_sst, phy_bil, phy_rug, &
478      phy_ice, phy_fter, phy_foce, phy_flic, phy_fsic)
479
480    USE mod_phys_lmdz_para, ONLY: is_omp_master, klon_mpi
481    USE mod_phys_lmdz_transfert_para, ONLY: gather_omp
482#ifdef CPP_XIOS
483    USE xios
484#endif
485    IMPLICIT NONE
486
487    include "netcdf.inc"
488
489    INTEGER, INTENT (IN) :: klon
490    REAL, INTENT (IN) :: phy_nat(klon, 360)
491    REAL, INTENT (IN) :: phy_alb(klon, 360)
492    REAL, INTENT (IN) :: phy_sst(klon, 360)
493    REAL, INTENT (IN) :: phy_bil(klon, 360)
494    REAL, INTENT (IN) :: phy_rug(klon, 360)
495    REAL, INTENT (IN) :: phy_ice(klon, 360)
496    REAL, INTENT (IN) :: phy_fter(klon, 360)
497    REAL, INTENT (IN) :: phy_foce(klon, 360)
498    REAL, INTENT (IN) :: phy_flic(klon, 360)
499    REAL, INTENT (IN) :: phy_fsic(klon, 360)
500
501    REAL :: phy_mpi(klon_mpi, 360) ! temporary variable, to store phy_***(:)
502      ! on the whole physics grid
503 
504#ifdef CPP_XIOS
505    PRINT *, 'writelim: Ecriture du fichier limit'
506
507    CALL gather_omp(phy_foce, phy_mpi)
508    IF (is_omp_master) CALL xios_send_field('foce_limout',phy_mpi)
509
510    CALL gather_omp(phy_fsic, phy_mpi)
511    IF (is_omp_master) CALL xios_send_field('fsic_limout',phy_mpi)
512     
513    CALL gather_omp(phy_fter, phy_mpi)
514    IF (is_omp_master) CALL xios_send_field('fter_limout',phy_mpi)
515     
516    CALL gather_omp(phy_flic, phy_mpi)
517    IF (is_omp_master) CALL xios_send_field('flic_limout',phy_mpi)
518
519    CALL gather_omp(phy_sst, phy_mpi)
520    IF (is_omp_master) CALL xios_send_field('sst_limout',phy_mpi)
521
522    CALL gather_omp(phy_bil, phy_mpi)
523    IF (is_omp_master) CALL xios_send_field('bils_limout',phy_mpi)
524
525    CALL gather_omp(phy_alb, phy_mpi)
526    IF (is_omp_master) CALL xios_send_field('alb_limout',phy_mpi)
527
528    CALL gather_omp(phy_rug, phy_mpi)
529    IF (is_omp_master) CALL xios_send_field('rug_limout',phy_mpi)
530#endif
531  END SUBROUTINE writelim_unstruct
532
533
534
[1992]535  SUBROUTINE writelim(klon, phy_nat, phy_alb, phy_sst, phy_bil, phy_rug, &
536      phy_ice, phy_fter, phy_foce, phy_flic, phy_fsic)
537
[3435]538    USE mod_phys_lmdz_para, ONLY: is_master
[1992]539    USE mod_grid_phy_lmdz, ONLY: klon_glo
540    USE mod_phys_lmdz_transfert_para, ONLY: gather
541    IMPLICIT NONE
542    include "netcdf.inc"
543
544    INTEGER, INTENT (IN) :: klon
545    REAL, INTENT (IN) :: phy_nat(klon, 360)
546    REAL, INTENT (IN) :: phy_alb(klon, 360)
547    REAL, INTENT (IN) :: phy_sst(klon, 360)
548    REAL, INTENT (IN) :: phy_bil(klon, 360)
549    REAL, INTENT (IN) :: phy_rug(klon, 360)
550    REAL, INTENT (IN) :: phy_ice(klon, 360)
551    REAL, INTENT (IN) :: phy_fter(klon, 360)
552    REAL, INTENT (IN) :: phy_foce(klon, 360)
553    REAL, INTENT (IN) :: phy_flic(klon, 360)
554    REAL, INTENT (IN) :: phy_fsic(klon, 360)
555
556    REAL :: phy_glo(klon_glo, 360) ! temporary variable, to store phy_***(:)
557      ! on the whole physics grid
558    INTEGER :: k
559    INTEGER ierr
560    INTEGER dimfirst(3)
561    INTEGER dimlast(3)
562
563    INTEGER nid, ndim, ntim
564    INTEGER dims(2), debut(2), epais(2)
565    INTEGER id_tim
566    INTEGER id_nat, id_sst, id_bils, id_rug, id_alb
567    INTEGER id_fter, id_foce, id_fsic, id_flic
568
[3435]569    IF (is_master) THEN
[1992]570
571      PRINT *, 'writelim: Ecriture du fichier limit'
572
[3401]573      ierr = nf_create('limit.nc', IOR(NF_CLOBBER,NF_64BIT_OFFSET), nid)
[1992]574
575      ierr = nf_put_att_text(nid, nf_global, 'title', 30, &
576        'Fichier conditions aux limites')
577      ! !        ierr = NF_DEF_DIM (nid, "points_physiques", klon, ndim)
578      ierr = nf_def_dim(nid, 'points_physiques', klon_glo, ndim)
579      ierr = nf_def_dim(nid, 'time', nf_unlimited, ntim)
580
581      dims(1) = ndim
582      dims(2) = ntim
583
[2198]584#ifdef NC_DOUBLE
585      ierr = nf_def_var(nid, 'TEMPS', nf_double, 1, ntim, id_tim)
586#else
[1992]587      ierr = nf_def_var(nid, 'TEMPS', nf_float, 1, ntim, id_tim)
[2198]588#endif
[1992]589      ierr = nf_put_att_text(nid, id_tim, 'title', 17, 'Jour dans l annee')
[2198]590
591#ifdef NC_DOUBLE
592      ierr = nf_def_var(nid, 'NAT', nf_double, 2, dims, id_nat)
593#else
[1992]594      ierr = nf_def_var(nid, 'NAT', nf_float, 2, dims, id_nat)
[2198]595#endif
[1992]596      ierr = nf_put_att_text(nid, id_nat, 'title', 23, &
597        'Nature du sol (0,1,2,3)')
[2198]598
599#ifdef NC_DOUBLE
600      ierr = nf_def_var(nid, 'SST', nf_double, 2, dims, id_sst)
601#else
[1992]602      ierr = nf_def_var(nid, 'SST', nf_float, 2, dims, id_sst)
[2198]603#endif
[1992]604      ierr = nf_put_att_text(nid, id_sst, 'title', 35, &
605        'Temperature superficielle de la mer')
[2198]606
607#ifdef NC_DOUBLE
608      ierr = nf_def_var(nid, 'BILS', nf_double, 2, dims, id_bils)
609#else
[1992]610      ierr = nf_def_var(nid, 'BILS', nf_float, 2, dims, id_bils)
[2198]611#endif
[1992]612      ierr = nf_put_att_text(nid, id_bils, 'title', 32, &
613        'Reference flux de chaleur au sol')
[2198]614
615#ifdef NC_DOUBLE
616      ierr = nf_def_var(nid, 'ALB', nf_double, 2, dims, id_alb)
617#else
[1992]618      ierr = nf_def_var(nid, 'ALB', nf_float, 2, dims, id_alb)
[2198]619#endif
[1992]620      ierr = nf_put_att_text(nid, id_alb, 'title', 19, 'Albedo a la surface')
[2198]621
622#ifdef NC_DOUBLE
623      ierr = nf_def_var(nid, 'RUG', nf_double, 2, dims, id_rug)
624#else
[1992]625      ierr = nf_def_var(nid, 'RUG', nf_float, 2, dims, id_rug)
[2198]626#endif
[1992]627      ierr = nf_put_att_text(nid, id_rug, 'title', 8, 'Rugosite')
628
[2198]629#ifdef NC_DOUBLE
630      ierr = nf_def_var(nid, 'FTER', nf_double, 2, dims, id_fter)
631#else
[1992]632      ierr = nf_def_var(nid, 'FTER', nf_float, 2, dims, id_fter)
[2198]633#endif
634      ierr = nf_put_att_text(nid, id_fter, 'title',10,'Frac. Land')
635#ifdef NC_DOUBLE
636      ierr = nf_def_var(nid, 'FOCE', nf_double, 2, dims, id_foce)
637#else
[1992]638      ierr = nf_def_var(nid, 'FOCE', nf_float, 2, dims, id_foce)
[2198]639#endif
640      ierr = nf_put_att_text(nid, id_foce, 'title',11,'Frac. Ocean')
641#ifdef NC_DOUBLE
642      ierr = nf_def_var(nid, 'FSIC', nf_double, 2, dims, id_fsic)
643#else
[1992]644      ierr = nf_def_var(nid, 'FSIC', nf_float, 2, dims, id_fsic)
[2198]645#endif
646      ierr = nf_put_att_text(nid, id_fsic, 'title',13,'Frac. Sea Ice')
647#ifdef NC_DOUBLE
648      ierr = nf_def_var(nid, 'FLIC', nf_double, 2, dims, id_flic)
649#else
[1992]650      ierr = nf_def_var(nid, 'FLIC', nf_float, 2, dims, id_flic)
[2198]651#endif
652      ierr = nf_put_att_text(nid, id_flic, 'title',14,'Frac. Land Ice')
[1992]653
654      ierr = nf_enddef(nid)
655      IF (ierr/=nf_noerr) THEN
656        WRITE (*, *) 'writelim error: failed to end define mode'
657        WRITE (*, *) nf_strerror(ierr)
658      END IF
659
660
661      ! write the 'times'
662      DO k = 1, 360
[1529]663#ifdef NC_DOUBLE
[1992]664        ierr = nf_put_var1_double(nid, id_tim, k, dble(k))
[1529]665#else
[1992]666        ierr = nf_put_var1_real(nid, id_tim, k, float(k))
[1671]667#endif
[1992]668        IF (ierr/=nf_noerr) THEN
669          WRITE (*, *) 'writelim error with temps(k),k=', k
670          WRITE (*, *) nf_strerror(ierr)
671        END IF
672      END DO
[1529]673
[3435]674    END IF ! of if (is_master)
[1671]675
[1992]676    ! write the fields, after having collected them on master
[1671]677
[1992]678    CALL gather(phy_nat, phy_glo)
[3435]679    IF (is_master) THEN
[1671]680#ifdef NC_DOUBLE
[1992]681      ierr = nf_put_var_double(nid, id_nat, phy_glo)
[1671]682#else
[1992]683      ierr = nf_put_var_real(nid, id_nat, phy_glo)
[1529]684#endif
[1992]685      IF (ierr/=nf_noerr) THEN
686        WRITE (*, *) 'writelim error with phy_nat'
687        WRITE (*, *) nf_strerror(ierr)
688      END IF
689    END IF
[1671]690
[1992]691    CALL gather(phy_sst, phy_glo)
[3435]692    IF (is_master) THEN
[1671]693#ifdef NC_DOUBLE
[1992]694      ierr = nf_put_var_double(nid, id_sst, phy_glo)
[1671]695#else
[1992]696      ierr = nf_put_var_real(nid, id_sst, phy_glo)
[1671]697#endif
[1992]698      IF (ierr/=nf_noerr) THEN
699        WRITE (*, *) 'writelim error with phy_sst'
700        WRITE (*, *) nf_strerror(ierr)
701      END IF
702    END IF
[1671]703
[1992]704    CALL gather(phy_bil, phy_glo)
[3435]705    IF (is_master) THEN
[1671]706#ifdef NC_DOUBLE
[1992]707      ierr = nf_put_var_double(nid, id_bils, phy_glo)
[1671]708#else
[1992]709      ierr = nf_put_var_real(nid, id_bils, phy_glo)
[1671]710#endif
[1992]711      IF (ierr/=nf_noerr) THEN
712        WRITE (*, *) 'writelim error with phy_bil'
713        WRITE (*, *) nf_strerror(ierr)
714      END IF
715    END IF
[1671]716
[1992]717    CALL gather(phy_alb, phy_glo)
[3435]718    IF (is_master) THEN
[1671]719#ifdef NC_DOUBLE
[1992]720      ierr = nf_put_var_double(nid, id_alb, phy_glo)
[1671]721#else
[1992]722      ierr = nf_put_var_real(nid, id_alb, phy_glo)
[1671]723#endif
[1992]724      IF (ierr/=nf_noerr) THEN
725        WRITE (*, *) 'writelim error with phy_alb'
726        WRITE (*, *) nf_strerror(ierr)
727      END IF
728    END IF
[1671]729
[1992]730    CALL gather(phy_rug, phy_glo)
[3435]731    IF (is_master) THEN
[1671]732#ifdef NC_DOUBLE
[1992]733      ierr = nf_put_var_double(nid, id_rug, phy_glo)
[1671]734#else
[1992]735      ierr = nf_put_var_real(nid, id_rug, phy_glo)
[1671]736#endif
[1992]737      IF (ierr/=nf_noerr) THEN
738        WRITE (*, *) 'writelim error with phy_rug'
739        WRITE (*, *) nf_strerror(ierr)
740      END IF
741    END IF
[1671]742
[1992]743    CALL gather(phy_fter, phy_glo)
[3435]744    IF (is_master) THEN
[1671]745#ifdef NC_DOUBLE
[1992]746      ierr = nf_put_var_double(nid, id_fter, phy_glo)
[1671]747#else
[1992]748      ierr = nf_put_var_real(nid, id_fter, phy_glo)
[1671]749#endif
[1992]750      IF (ierr/=nf_noerr) THEN
751        WRITE (*, *) 'writelim error with phy_fter'
752        WRITE (*, *) nf_strerror(ierr)
753      END IF
754    END IF
[1671]755
[1992]756    CALL gather(phy_foce, phy_glo)
[3435]757    IF (is_master) THEN
[1671]758#ifdef NC_DOUBLE
[1992]759      ierr = nf_put_var_double(nid, id_foce, phy_glo)
[1671]760#else
[1992]761      ierr = nf_put_var_real(nid, id_foce, phy_glo)
[1671]762#endif
[1992]763      IF (ierr/=nf_noerr) THEN
764        WRITE (*, *) 'writelim error with phy_foce'
765        WRITE (*, *) nf_strerror(ierr)
766      END IF
767    END IF
[1671]768
[1992]769    CALL gather(phy_fsic, phy_glo)
[3435]770    IF (is_master) THEN
[1671]771#ifdef NC_DOUBLE
[1992]772      ierr = nf_put_var_double(nid, id_fsic, phy_glo)
[1671]773#else
[1992]774      ierr = nf_put_var_real(nid, id_fsic, phy_glo)
[1671]775#endif
[1992]776      IF (ierr/=nf_noerr) THEN
777        WRITE (*, *) 'writelim error with phy_fsic'
778        WRITE (*, *) nf_strerror(ierr)
779      END IF
780    END IF
[1671]781
[1992]782    CALL gather(phy_flic, phy_glo)
[3435]783    IF (is_master) THEN
[1671]784#ifdef NC_DOUBLE
[1992]785      ierr = nf_put_var_double(nid, id_flic, phy_glo)
[1671]786#else
[1992]787      ierr = nf_put_var_real(nid, id_flic, phy_glo)
[1671]788#endif
[1992]789      IF (ierr/=nf_noerr) THEN
790        WRITE (*, *) 'writelim error with phy_flic'
791        WRITE (*, *) nf_strerror(ierr)
792      END IF
793    END IF
[1671]794
[1992]795    ! close file:
[3435]796    IF (is_master) THEN
[1992]797      ierr = nf_close(nid)
798    END IF
[1671]799
[1992]800  END SUBROUTINE writelim
[1529]801
[1992]802  ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[1671]803
[1992]804  SUBROUTINE profil_sst(nlon, rlatd, type_profil, phy_sst)
805    USE dimphy
806    IMPLICIT NONE
[1529]807
[1992]808    INTEGER nlon, type_profil, i, k, j
809    REAL :: rlatd(nlon), phy_sst(nlon, 360)
810    INTEGER imn, imx, amn, amx, kmn, kmx
811    INTEGER p, pplus, nlat_max
812    PARAMETER (nlat_max=72)
813    REAL x_anom_sst(nlat_max)
[1529]814
[1992]815    IF (klon/=nlon) STOP 'probleme de dimensions dans iniaqua'
816    WRITE (*, *) ' profil_sst: type_profil=', type_profil
817    DO i = 1, 360
818      ! phy_sst(:,i) = 260.+50.*cos(rlatd(:))**2
[1529]819
[1992]820      ! Rajout fbrlmd
[1529]821
[1992]822      IF (type_profil==1) THEN
823        ! Méthode 1 "Control" faible plateau à l'Equateur
824        DO j = 1, klon
825          phy_sst(j, i) = 273. + 27.*(1-sin(1.5*rlatd(j))**2)
826          ! PI/3=1.047197551
827          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
828            phy_sst(j, i) = 273.
829          END IF
830        END DO
831      END IF
832      IF (type_profil==2) THEN
833        ! Méthode 2 "Flat" fort plateau à l'Equateur
834        DO j = 1, klon
835          phy_sst(j, i) = 273. + 27.*(1-sin(1.5*rlatd(j))**4)
836          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
837            phy_sst(j, i) = 273.
838          END IF
839        END DO
840      END IF
[1529]841
842
[1992]843      IF (type_profil==3) THEN
844        ! Méthode 3 "Qobs" plateau réel à l'Equateur
845        DO j = 1, klon
846          phy_sst(j, i) = 273. + 0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5* &
847            rlatd(j))**4)
848          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
849            phy_sst(j, i) = 273.
850          END IF
851        END DO
852      END IF
[1529]853
[1992]854      IF (type_profil==4) THEN
855        ! Méthode 4 : Méthode 3 + SST+2 "Qobs" plateau réel à l'Equateur
856        DO j = 1, klon
857          phy_sst(j, i) = 273. + 0.5*29.*(2-sin(1.5*rlatd(j))**2-sin(1.5* &
858            rlatd(j))**4)
859          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
860            phy_sst(j, i) = 273.
861          END IF
862        END DO
863      END IF
[1529]864
[1992]865      IF (type_profil==5) THEN
866        ! Méthode 5 : Méthode 3 + +2K "Qobs" plateau réel à l'Equateur
867        DO j = 1, klon
868          phy_sst(j, i) = 273. + 2. + 0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5 &
869            *rlatd(j))**4)
870          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
871            phy_sst(j, i) = 273. + 2.
872          END IF
[1529]873
[1992]874        END DO
875      END IF
[1529]876
[1992]877      IF (type_profil==6) THEN
878        ! Méthode 6 "cst" valeur constante de SST
879        DO j = 1, klon
880          phy_sst(j, i) = 288.
881        END DO
882      END IF
[1529]883
884
[1992]885      IF (type_profil==7) THEN
886        ! Méthode 7 "cst" valeur constante de SST +2
887        DO j = 1, klon
888          phy_sst(j, i) = 288. + 2.
889        END DO
890      END IF
[1529]891
[1992]892      p = 0
893      IF (type_profil==8) THEN
894        ! Méthode 8 profil anomalies SST du modèle couplé AR4
895        DO j = 1, klon
896          IF (rlatd(j)==rlatd(j-1)) THEN
897            phy_sst(j, i) = 273. + x_anom_sst(pplus) + &
898              0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5*rlatd(j))**4)
899            IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
900              phy_sst(j, i) = 273. + x_anom_sst(pplus)
901            END IF
902          ELSE
903            p = p + 1
904            pplus = 73 - p
905            phy_sst(j, i) = 273. + x_anom_sst(pplus) + &
906              0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5*rlatd(j))**4)
907            IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
908              phy_sst(j, i) = 273. + x_anom_sst(pplus)
909            END IF
910            WRITE (*, *) rlatd(j), x_anom_sst(pplus), phy_sst(j, i)
911          END IF
912        END DO
913      END IF
[1529]914
[1992]915      IF (type_profil==9) THEN
916        ! Méthode 5 : Méthode 3 + -2K "Qobs" plateau réel à l'Equateur
917        DO j = 1, klon
918          phy_sst(j, i) = 273. - 2. + 0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5 &
919            *rlatd(j))**4)
920          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
921            phy_sst(j, i) = 273. - 2.
922          END IF
923        END DO
924      END IF
[1529]925
926
[1992]927      IF (type_profil==10) THEN
928        ! Méthode 10 : Méthode 3 + +4K "Qobs" plateau réel à l'Equateur
929        DO j = 1, klon
930          phy_sst(j, i) = 273. + 4. + 0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5 &
931            *rlatd(j))**4)
932          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
933            phy_sst(j, i) = 273. + 4.
934          END IF
935        END DO
936      END IF
[1529]937
[1992]938      IF (type_profil==11) THEN
939        ! Méthode 11 : Méthode 3 + 4CO2 "Qobs" plateau réel à l'Equateur
940        DO j = 1, klon
941          phy_sst(j, i) = 273. + 0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5* &
942            rlatd(j))**4)
943          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
944            phy_sst(j, i) = 273.
945          END IF
946        END DO
947      END IF
[1529]948
[1992]949      IF (type_profil==12) THEN
950        ! Méthode 12 : Méthode 10 + 4CO2 "Qobs" plateau réel à l'Equateur
951        DO j = 1, klon
952          phy_sst(j, i) = 273. + 4. + 0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5 &
953            *rlatd(j))**4)
954          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
955            phy_sst(j, i) = 273. + 4.
956          END IF
957        END DO
958      END IF
[1529]959
[1992]960      IF (type_profil==13) THEN
961        ! Méthode 13 "Qmax" plateau réel à l'Equateur augmenté !
962        DO j = 1, klon
963          phy_sst(j, i) = 273. + 0.5*29.*(2-sin(1.5*rlatd(j))**2-sin(1.5* &
964            rlatd(j))**4)
965          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
966            phy_sst(j, i) = 273.
967          END IF
968        END DO
969      END IF
[1529]970
[1992]971      IF (type_profil==14) THEN
972        ! Méthode 13 "Qmax2K" plateau réel à l'Equateur augmenté +2K !
973        DO j = 1, klon
974          phy_sst(j, i) = 273. + 2. + 0.5*29.*(2-sin(1.5*rlatd(j))**2-sin(1.5 &
975            *rlatd(j))**4)
976          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
977            phy_sst(j, i) = 273.
978          END IF
979        END DO
980      END IF
[1529]981
[2107]982      if (type_profil.EQ.20) then
983      print*,'Profile SST 20'
984!     Méthode 13 "Qmax2K" plateau réel �|  l'Equateur augmenté +2K
985
986      do j=1,klon
987        phy_sst(j,i)=248.+55.*(1-sin(rlatd(j))**2)
988      enddo
989      endif
990
991      if (type_profil.EQ.21) then
992      print*,'Profile SST 21'
993!     Méthode 13 "Qmax2K" plateau réel �|  l'Equateur augmenté +2K
994      do j=1,klon
995        phy_sst(j,i)=252.+55.*(1-sin(rlatd(j))**2)
996      enddo
997      endif
998
999
1000
[1992]1001    END DO
1002
1003    ! IM beg : verif profil SST: phy_sst
1004    amn = min(phy_sst(1,1), 1000.)
1005    amx = max(phy_sst(1,1), -1000.)
1006    imn = 1
1007    kmn = 1
1008    imx = 1
1009    kmx = 1
1010    DO k = 1, 360
1011      DO i = 2, nlon
1012        IF (phy_sst(i,k)<amn) THEN
1013          amn = phy_sst(i, k)
1014          imn = i
1015          kmn = k
1016        END IF
1017        IF (phy_sst(i,k)>amx) THEN
1018          amx = phy_sst(i, k)
1019          imx = i
1020          kmx = k
1021        END IF
1022      END DO
1023    END DO
1024
1025    PRINT *, 'profil_sst: imn, kmn, phy_sst(imn,kmn) ', imn, kmn, amn
1026    PRINT *, 'profil_sst: imx, kmx, phy_sst(imx,kmx) ', imx, kmx, amx
1027    ! IM end : verif profil SST: phy_sst
1028
1029    RETURN
1030  END SUBROUTINE profil_sst
1031
1032END MODULE phyaqua_mod
Note: See TracBrowser for help on using the repository browser.