source: LMDZ6/branches/Amaury_dev/libf/phylmd/condsurf.F90 @ 5209

Last change on this file since 5209 was 5137, checked in by abarral, 8 weeks ago

Put gradsdef.h, tracstoke.h, clesphys.h into modules

  • 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
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
RevLine 
[1992]1! $Header$
[644]2
[1992]3SUBROUTINE condsurf(jour, jourvrai, lmt_bils)
4  USE dimphy
[5110]5  USE lmdz_grid_phy
6  USE lmdz_phys_para
[1992]7  USE indice_sol_mod
[2344]8  USE time_phylmdz_mod, ONLY: annee_ref
[5088]9  USE netcdf, ONLY: nf90_get_var,nf90_open,nf90_inq_varid,nf90_noerr,nf90_close,nf90_nowrite
[5111]10  USE lmdz_abort_physic, ONLY: abort_physic
[5137]11  USE lmdz_clesphys
12
[1992]13  IMPLICIT NONE
14
15  ! I. Musat 05.2005
16
17  ! Lire chaque jour le bilan de chaleur au sol issu
18  ! d'un run atmospherique afin de l'utiliser dans
19  ! dans un run "slab" ocean
20  ! -----------------------------------------
21  ! jour     : input  , numero du jour a lire
22  ! jourvrai : input  , vrai jour de la simulation
23
24  ! lmt_bils: bilan chaleur au sol (a utiliser pour "slab-ocean")
25
26  INTEGER nid, nvarid
27  INTEGER debut(2)
28  INTEGER epais(2)
29
30  INTEGER nannemax
31  PARAMETER (nannemax=60)
32
33  INTEGER jour, jourvrai
34  REAL lmt_bils(klon) !bilan chaleur au sol
35
36  ! Variables locales:
37  INTEGER ig, i, kt, ierr
38  LOGICAL ok
39  INTEGER anneelim, anneemax
40  CHARACTER *20 fich
41
42  REAL :: lmt_bils_glo(klon_glo)
43
44  ! c
45  ! c   .....................................................................
46  ! c
47  ! c    Pour lire le fichier limit correspondant vraiment  a l'annee de la
48  ! c     simulation en cours , il suffit de mettre  ok_limitvrai = .TRUE.
49  ! c
50  ! c
51  ! ......................................................................
52
53
54
55  IF (jour<0 .OR. jour>(360-1)) THEN
56    PRINT *, 'Le jour demande n est pas correct: ', jour
[2311]57    CALL abort_physic('condsurf', '', 1)
[1992]58  END IF
59
60  anneelim = annee_ref
61  anneemax = annee_ref + nannemax
62
63
64  IF (ok_limitvrai) THEN
65    DO kt = 1, nannemax
66      IF (jourvrai<=(kt-1)*360+359) THEN
67        WRITE (fich, '("limit",i4,".nc")') anneelim
68        ! PRINT *,' Fichier  Limite ',fich
69        GO TO 100
70      END IF
71      anneelim = anneelim + 1
72    END DO
73
74    PRINT *, ' PBS ! Le jour a lire sur le fichier limit ne se '
75    PRINT *, ' trouve pas sur les ', nannemax, ' annees a partir de '
76    PRINT *, ' l annee de debut', annee_ref
[2311]77    CALL abort_physic('condsurf', '', 1)
[1992]78
79100 CONTINUE
80
81  ELSE
82
83    WRITE (fich, '("limitNEW.nc")')
84    ! PRINT *,' Fichier  Limite ',fich
85  END IF
86
87  ! Ouvrir le fichier en format NetCDF:
88
89  !$OMP MASTER
90  IF (is_mpi_root) THEN
[5088]91    ierr = nf90_open(fich, nf90_nowrite, nid)
92    IF (ierr/=nf90_noerr) THEN
[1992]93      WRITE (6, *) ' Pb d''ouverture du fichier ', fich
94      WRITE (6, *) ' Le fichier limit ', fich, ' (avec 4 chiffres , pour'
95      WRITE (6, *) '       l an 2000 )  ,  n existe  pas !  '
96      WRITE (6, *) ' ierr = ', ierr
[2311]97      CALL abort_physic('condsurf', '', 1)
[1992]98    END IF
99    ! DO k = 1, jour
100    ! La tranche de donnees a lire:
101
102    debut(1) = 1
103    debut(2) = jourvrai
104    epais(1) = klon_glo
105    epais(2) = 1
106    ! Bilan flux de chaleur au sol:
107
[5088]108    ierr = nf90_inq_varid(nid, 'BILS', nvarid)
109    IF (ierr/=nf90_noerr) THEN
[2311]110      CALL abort_physic('cond_surf', 'Le champ <BILS> est absent', 1)
[1992]111    END IF
112    PRINT *, 'debut,epais', debut, epais, 'jour,jourvrai', jour, jourvrai
[5073]113    ierr = nf90_get_var(nid, nvarid,  lmt_bils_glo, debut, epais)
[5088]114    IF (ierr/=nf90_noerr) THEN
[2311]115      CALL abort_physic('condsurf', 'Lecture echouee pour <BILS>', 1)
[1992]116    END IF
117    ! ENDDO !k = 1, jour
[766]118
[1992]119    ! Fermer le fichier:
120
[5088]121    ierr = nf90_close(nid)
[1992]122
123  END IF ! is_mpi_root==0
124
125  !$OMP END MASTER
126  CALL scatter(lmt_bils_glo, lmt_bils)
127
128
129
130  ! PRINT*, 'lmt_bils est lu pour jour: ', jour
131
[5105]132
[1992]133END SUBROUTINE condsurf
Note: See TracBrowser for help on using the repository browser.