1 |
c $Header: /home/cvsroot/LMDZ4/libf/phylmd/condsurf.F,v 1.2 2005/12/01 11:27:29 fairhead Exp $ |
! $Header: /home/cvsroot/LMDZ4/libf/phylmd/condsurf.F,v 1.2 2005/12/01 |
2 |
c |
! 11:27:29 fairhead Exp $ |
3 |
SUBROUTINE condsurf( jour, jourvrai, lmt_bils ) |
|
4 |
use dimens_m |
SUBROUTINE condsurf(jour, jourvrai, lmt_bils) |
5 |
use indicesol |
USE dimens_m |
6 |
use dimphy |
USE indicesol |
7 |
use temps |
USE dimphy |
8 |
use clesphys2, only: ok_limitvrai |
USE temps |
9 |
use netcdf |
USE clesphys2, ONLY: ok_limitvrai |
10 |
IMPLICIT none |
USE netcdf |
11 |
c |
IMPLICIT NONE |
12 |
c I. Musat 05.2005 |
|
13 |
c |
! I. Musat 05.2005 |
14 |
c Lire chaque jour le bilan de chaleur au sol issu |
|
15 |
c d'un run atmospherique afin de l'utiliser dans |
! Lire chaque jour le bilan de chaleur au sol issu |
16 |
c dans un run "slab" ocean |
! d'un run atmospherique afin de l'utiliser dans |
17 |
c ----------------------------------------- |
! dans un run "slab" ocean |
18 |
c jour : input , numero du jour a lire |
! ----------------------------------------- |
19 |
c jourvrai : input , vrai jour de la simulation |
! jour : input , numero du jour a lire |
20 |
c |
! jourvrai : input , vrai jour de la simulation |
21 |
c lmt_bils: bilan chaleur au sol (a utiliser pour "slab-ocean") |
|
22 |
c |
! lmt_bils: bilan chaleur au sol (a utiliser pour "slab-ocean") |
23 |
INTEGER nid, nvarid |
|
24 |
INTEGER debut(2) |
INTEGER nid, nvarid |
25 |
INTEGER epais(2) |
INTEGER debut(2) |
26 |
c |
INTEGER epais(2) |
27 |
c |
|
28 |
INTEGER nannemax |
|
29 |
PARAMETER ( nannemax = 60 ) |
INTEGER nannemax |
30 |
c |
PARAMETER (nannemax=60) |
31 |
INTEGER jour |
|
32 |
INTEGER jourvrai |
INTEGER jour |
33 |
REAL lmt_bils(klon) !bilan chaleur au sol |
INTEGER jourvrai |
34 |
c |
REAL lmt_bils(klon) !bilan chaleur au sol |
35 |
c Variables locales: |
|
36 |
INTEGER ig, i, kt, ierr |
! Variables locales: |
37 |
LOGICAL ok |
INTEGER ig, i, kt, ierr |
38 |
INTEGER anneelim,anneemax |
LOGICAL ok |
39 |
CHARACTER*20 fich |
INTEGER anneelim, anneemax |
40 |
cc |
CHARACTER *20 fich |
41 |
cc ..................................................................... |
! c |
42 |
cc |
! c ..................................................................... |
43 |
cc Pour lire le fichier limit correspondant vraiment a l'annee de la |
! c |
44 |
cc simulation en cours , il suffit de mettre ok_limitvrai = .TRUE. |
! c Pour lire le fichier limit correspondant vraiment a l'annee de la |
45 |
cc |
! c simulation en cours , il suffit de mettre ok_limitvrai = .TRUE. |
46 |
cc ...................................................................... |
! c |
47 |
c |
! c |
48 |
c |
! ...................................................................... |
49 |
IF (jour.LT.0 .OR. jour.GT.(360-1)) THEN |
|
50 |
PRINT*,'Le jour demande n est pas correct: ', jour |
|
51 |
STOP 1 |
IF (jour<0 .OR. jour>(360-1)) THEN |
52 |
ENDIF |
PRINT *, 'Le jour demande n est pas correct: ', jour |
53 |
c |
STOP 1 |
54 |
anneelim = annee_ref |
END IF |
55 |
anneemax = annee_ref + nannemax |
|
56 |
c |
anneelim = annee_ref |
57 |
c |
anneemax = annee_ref + nannemax |
58 |
IF( ok_limitvrai ) THEN |
|
59 |
DO kt = 1, nannemax |
|
60 |
IF(jourvrai.LE. (kt-1)*360 + 359 ) THEN |
IF (ok_limitvrai) THEN |
61 |
WRITE(fich,'("limit",i4,".nc")') anneelim |
DO kt = 1, nannemax |
62 |
c PRINT *,' Fichier Limite ',fich |
IF (jourvrai<=(kt-1)*360+359) THEN |
63 |
GO TO 100 |
WRITE (fich, '("limit",i4,".nc")') anneelim |
64 |
ENDIF |
! PRINT *,' Fichier Limite ',fich |
65 |
anneelim = anneelim + 1 |
GO TO 100 |
66 |
ENDDO |
END IF |
67 |
|
anneelim = anneelim + 1 |
68 |
PRINT *,' PBS ! Le jour a lire sur le fichier limit ne se ' |
END DO |
69 |
PRINT *,' trouve pas sur les ',nannemax,' annees a partir de ' |
|
70 |
PRINT *,' l annee de debut', annee_ref |
PRINT *, ' PBS ! Le jour a lire sur le fichier limit ne se ' |
71 |
stop 1 |
PRINT *, ' trouve pas sur les ', nannemax, ' annees a partir de ' |
72 |
c |
PRINT *, ' l annee de debut', annee_ref |
73 |
100 CONTINUE |
STOP 1 |
74 |
c |
|
75 |
ELSE |
100 CONTINUE |
76 |
|
|
77 |
WRITE(fich,'("limitNEW.nc")') |
ELSE |
78 |
c PRINT *,' Fichier Limite ',fich |
|
79 |
ENDIF |
WRITE (fich, '("limitNEW.nc")') |
80 |
c |
! PRINT *,' Fichier Limite ',fich |
81 |
c Ouvrir le fichier en format NetCDF: |
END IF |
82 |
c |
|
83 |
ierr = NF90_OPEN (fich, NF90_NOWRITE,nid) |
! Ouvrir le fichier en format NetCDF: |
84 |
IF (ierr.NE.NF90_NOERR) THEN |
|
85 |
WRITE(6,*)' Pb d''ouverture du fichier ', fich |
ierr = nf90_open(fich, nf90_nowrite, nid) |
86 |
WRITE(6,*)' Le fichier limit ',fich,' (avec 4 chiffres , pour' |
IF (ierr/=nf90_noerr) THEN |
87 |
WRITE(6,*)' l an 2000 ) , n existe pas ! ' |
WRITE (6, *) ' Pb d''ouverture du fichier ', fich |
88 |
WRITE(6,*)' ierr = ', ierr |
WRITE (6, *) ' Le fichier limit ', fich, ' (avec 4 chiffres , pour' |
89 |
stop 1 |
WRITE (6, *) ' l an 2000 ) , n existe pas ! ' |
90 |
ENDIF |
WRITE (6, *) ' ierr = ', ierr |
91 |
c DO k = 1, jour |
STOP 1 |
92 |
c La tranche de donnees a lire: |
END IF |
93 |
c |
! DO k = 1, jour |
94 |
debut(1) = 1 |
! La tranche de donnees a lire: |
95 |
debut(2) = jour |
|
96 |
epais(1) = klon |
debut(1) = 1 |
97 |
epais(2) = 1 |
debut(2) = jour |
98 |
c |
epais(1) = klon |
99 |
c Bilan flux de chaleur au sol: |
epais(2) = 1 |
100 |
c |
|
101 |
ierr = NF90_INQ_VARID (nid, "BILS", nvarid) |
! Bilan flux de chaleur au sol: |
102 |
IF (ierr .NE. NF90_NOERR) THEN |
|
103 |
PRINT*, "condsurf: Le champ <BILS> est absent" |
ierr = nf90_inq_varid(nid, 'BILS', nvarid) |
104 |
stop 1 |
IF (ierr/=nf90_noerr) THEN |
105 |
ENDIF |
PRINT *, 'condsurf: Le champ <BILS> est absent' |
106 |
c PRINT*,'debut,epais',debut,epais |
STOP 1 |
107 |
ierr = NF90_GET_VAR(nid, nvarid,lmt_bils,debut,epais) |
END IF |
108 |
IF (ierr .NE. NF90_NOERR) THEN |
! PRINT*,'debut,epais',debut,epais |
109 |
PRINT*, "condsurf: Lecture echouee pour <BILS>" |
ierr = nf90_get_var(nid, nvarid, lmt_bils, debut, epais) |
110 |
stop 1 |
IF (ierr/=nf90_noerr) THEN |
111 |
ENDIF |
PRINT *, 'condsurf: Lecture echouee pour <BILS>' |
112 |
c ENDDO !k = 1, jour |
STOP 1 |
113 |
c |
END IF |
114 |
c Fermer le fichier: |
! ENDDO !k = 1, jour |
115 |
c |
|
116 |
ierr = NF90_CLOSE(nid) |
! Fermer le fichier: |
117 |
c |
|
118 |
c |
ierr = nf90_close(nid) |
119 |
c PRINT*, 'lmt_bils est lu pour jour: ', jour |
|
120 |
c |
|
121 |
RETURN |
! PRINT*, 'lmt_bils est lu pour jour: ', jour |
122 |
END |
|
123 |
|
RETURN |
124 |
|
END SUBROUTINE condsurf |