My Project
 All Classes Files Functions Variables Macros
condsurf.F
Go to the documentation of this file.
1 c $Header$
2 c
3  SUBROUTINE condsurf( jour, jourvrai, lmt_bils )
4  USE dimphy
7  IMPLICIT none
8 c
9 c I. Musat 05.2005
10 c
11 c Lire chaque jour le bilan de chaleur au sol issu
12 c d'un run atmospherique afin de l'utiliser dans
13 c dans un run "slab" ocean
14 c -----------------------------------------
15 c jour : input , numero du jour a lire
16 c jourvrai : input , vrai jour de la simulation
17 c
18 c lmt_bils: bilan chaleur au sol (a utiliser pour "slab-ocean")
19 c
20 #include "netcdf.inc"
21  INTEGER nid, nvarid
22  INTEGER debut(2)
23  INTEGER epais(2)
24 c
25 cym#include "dimensions.h"
26 cym#include "dimphy.h"
27 #include "indicesol.h"
28 #include "temps.h"
29 #include "clesphys.h"
30 c
31  INTEGER nannemax
32  parameter( nannemax = 60 )
33 c
34  INTEGER jour, jourvrai
35  REAL lmt_bils(klon) !bilan chaleur au sol
36 c
37 c Variables locales:
38  INTEGER ig, i, kt, ierr
39  LOGICAL ok
40  INTEGER anneelim,anneemax
41  CHARACTER*20 fich
42 
43  REAL :: lmt_bils_glo(klon_glo)
44 
45 cc
46 cc .....................................................................
47 cc
48 cc Pour lire le fichier limit correspondant vraiment a l'annee de la
49 cc simulation en cours , il suffit de mettre ok_limitvrai = .TRUE.
50 cc
51 cc ......................................................................
52 c
53 c
54 
55  IF (jour.LT.0 .OR. jour.GT.(360-1)) THEN
56  print*,'Le jour demande n est pas correct: ', jour
57  CALL abort
58  ENDIF
59 c
60  anneelim = annee_ref
61  anneemax = annee_ref + nannemax
62 c
63 c
64  IF( ok_limitvrai ) THEN
65  DO kt = 1, nannemax
66  IF(jourvrai.LE. (kt-1)*360 + 359 ) THEN
67  WRITE(fich,'("limit",i4,".nc")') anneelim
68 c PRINT *,' Fichier Limite ',fich
69  go to 100
70  ENDIF
71  anneelim = anneelim + 1
72  ENDDO
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
77  CALL EXIT(1)
78 c
79 100 CONTINUE
80 c
81  ELSE
82 
83  WRITE(fich,'("limitNEW.nc")')
84 c PRINT *,' Fichier Limite ',fich
85  ENDIF
86 c
87 c Ouvrir le fichier en format NetCDF:
88 c
89 c$OMP MASTER
90  IF (is_mpi_root) THEN
91  ierr = nf_open(fich, nf_nowrite,nid)
92  IF (ierr.NE.nf_noerr) THEN
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
97  CALL EXIT(1)
98  ENDIF
99 c DO k = 1, jour
100 c La tranche de donnees a lire:
101 c
102  debut(1) = 1
103  debut(2) = jourvrai
104  epais(1) = klon_glo
105  epais(2) = 1
106 c Bilan flux de chaleur au sol:
107 c
108  ierr = nf_inq_varid(nid, "BILS", nvarid)
109  IF (ierr .NE. nf_noerr) THEN
110  print*, "condsurf: Le champ <BILS> est absent"
111  CALL abort
112  ENDIF
113  print*,'debut,epais',debut,epais,'jour,jourvrai',jour,jourvrai
114 #ifdef NC_DOUBLE
115  ierr = nf_get_vara_double(nid, nvarid,debut,epais,lmt_bils_glo)
116 #else
117  ierr = nf_get_vara_real(nid, nvarid,debut,epais,lmt_bils_glo)
118 #endif
119  IF (ierr .NE. nf_noerr) THEN
120  print*, "condsurf: Lecture echouee pour <BILS>"
121  CALL abort
122  ENDIF
123 c ENDDO !k = 1, jour
124 c
125 c Fermer le fichier:
126 c
127  ierr = nf_close(nid)
128 
129  ENDIF ! is_mpi_root==0
130 
131 c$OMP END MASTER
132  CALL scatter(lmt_bils_glo,lmt_bils)
133 
134 c
135 c
136 c PRINT*, 'lmt_bils est lu pour jour: ', jour
137 c
138  RETURN
139  END