Changeset 1992 for LMDZ5/trunk/libf/phylmd/condsurf.F90
- Timestamp:
- Mar 5, 2014, 2:19:12 PM (10 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
LMDZ5/trunk/libf/phylmd/condsurf.F90
r1988 r1992 1 c $Header$ 2 c 3 SUBROUTINE condsurf( jour, jourvrai, lmt_bils ) 4 USE dimphy 5 USE mod_grid_phy_lmdz 6 USE mod_phys_lmdz_para 7 USE indice_sol_mod 8 IMPLICIT none 9 c 10 c I. Musat 05.2005 11 c 12 c Lire chaque jour le bilan de chaleur au sol issu 13 c d'un run atmospherique afin de l'utiliser dans 14 c dans un run "slab" ocean 15 c ----------------------------------------- 16 c jour : input , numero du jour a lire 17 c jourvrai : input , vrai jour de la simulation 18 c 19 c lmt_bils: bilan chaleur au sol (a utiliser pour "slab-ocean") 20 c 21 #include "netcdf.inc" 22 INTEGER nid, nvarid 23 INTEGER debut(2) 24 INTEGER epais(2) 25 c 26 cym#include "dimensions.h" 27 cym#include "dimphy.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_gcm("condsurf", "", 1) 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 1 ! $Header$ 73 2 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 abort_gcm("condsurf", "", 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 abort_gcm("condsurf", "", 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 CALL abort_gcm("cond_surf", "Le champ <BILS> est absent", 1) 111 ENDIF 112 PRINT*,'debut,epais',debut,epais,'jour,jourvrai',jour,jourvrai 3 SUBROUTINE condsurf(jour, jourvrai, lmt_bils) 4 USE dimphy 5 USE mod_grid_phy_lmdz 6 USE mod_phys_lmdz_para 7 USE indice_sol_mod 8 IMPLICIT NONE 9 10 ! I. Musat 05.2005 11 12 ! Lire chaque jour le bilan de chaleur au sol issu 13 ! d'un run atmospherique afin de l'utiliser dans 14 ! dans un run "slab" ocean 15 ! ----------------------------------------- 16 ! jour : input , numero du jour a lire 17 ! jourvrai : input , vrai jour de la simulation 18 19 ! lmt_bils: bilan chaleur au sol (a utiliser pour "slab-ocean") 20 21 include "netcdf.inc" 22 INTEGER nid, nvarid 23 INTEGER debut(2) 24 INTEGER epais(2) 25 26 ! ym#include "dimensions.h" 27 ! ym#include "dimphy.h" 28 include "temps.h" 29 include "clesphys.h" 30 31 INTEGER nannemax 32 PARAMETER (nannemax=60) 33 34 INTEGER jour, jourvrai 35 REAL lmt_bils(klon) !bilan chaleur au sol 36 37 ! 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 ! c 46 ! c ..................................................................... 47 ! c 48 ! c Pour lire le fichier limit correspondant vraiment a l'annee de la 49 ! c simulation en cours , il suffit de mettre ok_limitvrai = .TRUE. 50 ! c 51 ! c 52 ! ...................................................................... 53 54 55 56 IF (jour<0 .OR. jour>(360-1)) THEN 57 PRINT *, 'Le jour demande n est pas correct: ', jour 58 CALL abort_gcm('condsurf', '', 1) 59 END IF 60 61 anneelim = annee_ref 62 anneemax = annee_ref + nannemax 63 64 65 IF (ok_limitvrai) THEN 66 DO kt = 1, nannemax 67 IF (jourvrai<=(kt-1)*360+359) THEN 68 WRITE (fich, '("limit",i4,".nc")') anneelim 69 ! PRINT *,' Fichier Limite ',fich 70 GO TO 100 71 END IF 72 anneelim = anneelim + 1 73 END DO 74 75 PRINT *, ' PBS ! Le jour a lire sur le fichier limit ne se ' 76 PRINT *, ' trouve pas sur les ', nannemax, ' annees a partir de ' 77 PRINT *, ' l annee de debut', annee_ref 78 CALL abort_gcm('condsurf', '', 1) 79 80 100 CONTINUE 81 82 ELSE 83 84 WRITE (fich, '("limitNEW.nc")') 85 ! PRINT *,' Fichier Limite ',fich 86 END IF 87 88 ! Ouvrir le fichier en format NetCDF: 89 90 !$OMP MASTER 91 IF (is_mpi_root) THEN 92 ierr = nf_open(fich, nf_nowrite, nid) 93 IF (ierr/=nf_noerr) THEN 94 WRITE (6, *) ' Pb d''ouverture du fichier ', fich 95 WRITE (6, *) ' Le fichier limit ', fich, ' (avec 4 chiffres , pour' 96 WRITE (6, *) ' l an 2000 ) , n existe pas ! ' 97 WRITE (6, *) ' ierr = ', ierr 98 CALL abort_gcm('condsurf', '', 1) 99 END IF 100 ! DO k = 1, jour 101 ! La tranche de donnees a lire: 102 103 debut(1) = 1 104 debut(2) = jourvrai 105 epais(1) = klon_glo 106 epais(2) = 1 107 ! Bilan flux de chaleur au sol: 108 109 ierr = nf_inq_varid(nid, 'BILS', nvarid) 110 IF (ierr/=nf_noerr) THEN 111 CALL abort_gcm('cond_surf', 'Le champ <BILS> est absent', 1) 112 END IF 113 PRINT *, 'debut,epais', debut, epais, 'jour,jourvrai', jour, jourvrai 113 114 #ifdef NC_DOUBLE 114 ierr = NF_GET_VARA_DOUBLE(nid, nvarid,debut,epais,lmt_bils_glo)115 ierr = nf_get_vara_double(nid, nvarid, debut, epais, lmt_bils_glo) 115 116 #else 116 ierr = NF_GET_VARA_REAL(nid, nvarid,debut,epais,lmt_bils_glo)117 ierr = nf_get_vara_real(nid, nvarid, debut, epais, lmt_bils_glo) 117 118 #endif 118 IF (ierr .NE. NF_NOERR) THEN 119 CALL abort_gcm("condsurf", "Lecture echouee pour <BILS>", 1) 120 ENDIF 121 c ENDDO !k = 1, jour 122 c 123 c Fermer le fichier: 124 c 125 ierr = NF_CLOSE(nid) 126 127 ENDIF ! is_mpi_root==0 119 IF (ierr/=nf_noerr) THEN 120 CALL abort_gcm('condsurf', 'Lecture echouee pour <BILS>', 1) 121 END IF 122 ! ENDDO !k = 1, jour 128 123 129 c$OMP END MASTER 130 CALL scatter(lmt_bils_glo,lmt_bils) 131 132 c 133 c 134 c PRINT*, 'lmt_bils est lu pour jour: ', jour 135 c 136 RETURN 137 END 124 ! Fermer le fichier: 125 126 ierr = nf_close(nid) 127 128 END IF ! is_mpi_root==0 129 130 !$OMP END MASTER 131 CALL scatter(lmt_bils_glo, lmt_bils) 132 133 134 135 ! PRINT*, 'lmt_bils est lu pour jour: ', jour 136 137 RETURN 138 END SUBROUTINE condsurf
Note: See TracChangeset
for help on using the changeset viewer.