[3977] | 1 | SUBROUTINE iotd_ini(fichnom,iim,jjm,llm,prlon,prlat,pcoordv,jour0,mois0,an0,t0,timestep,calendrier) |
---|
[5088] | 2 | USE netcdf, ONLY: nf90_enddef,nf90_put_att,nf90_float,nf90_def_var,nf90_redef,& |
---|
| 3 | nf90_global,nf90_def_dim,nf90_create,nf90_clobber,nf90_unlimited,nf90_put_var |
---|
[1980] | 4 | IMPLICIT NONE |
---|
| 5 | |
---|
| 6 | !======================================================================= |
---|
| 7 | ! |
---|
| 8 | ! Auteur: F. Hourdin |
---|
| 9 | ! ------- |
---|
| 10 | ! |
---|
| 11 | ! Objet: |
---|
| 12 | ! ------ |
---|
| 13 | ! Light interface for netcdf outputs. can be used outside LMDZ |
---|
| 14 | ! |
---|
| 15 | !======================================================================= |
---|
| 16 | !----------------------------------------------------------------------- |
---|
| 17 | ! Declarations: |
---|
| 18 | ! ------------- |
---|
| 19 | |
---|
[4593] | 20 | INCLUDE "iotd.h" |
---|
[1980] | 21 | |
---|
| 22 | ! Arguments: |
---|
| 23 | ! ---------- |
---|
| 24 | |
---|
| 25 | integer iim,jjm,llm |
---|
[3977] | 26 | real prlon(iim),prlat(jjm),pcoordv(llm),timestep,t0 |
---|
[1980] | 27 | INTEGER id_FOCE |
---|
[3977] | 28 | INTEGER jour0,mois0,an0 |
---|
| 29 | CHARACTER*(*) calendrier |
---|
[1980] | 30 | |
---|
| 31 | integer corner(4),edges(4),ndim |
---|
| 32 | real px(1000) |
---|
| 33 | character (len=10) :: nom |
---|
[5075] | 34 | real(kind=4) rlon(iim),rlat(jjm),coordv(llm) |
---|
[1980] | 35 | |
---|
| 36 | ! Local: |
---|
| 37 | ! ------ |
---|
[3977] | 38 | CHARACTER*3,DIMENSION(12) :: cmois=(/'JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC'/) |
---|
| 39 | CHARACTER*10 date0 |
---|
| 40 | CHARACTER*11 date0b |
---|
| 41 | |
---|
[3978] | 42 | INTEGER :: ierr |
---|
[1980] | 43 | |
---|
| 44 | integer :: nvarid |
---|
| 45 | integer, dimension(2) :: id |
---|
| 46 | |
---|
[3977] | 47 | character*(*) fichnom |
---|
[1980] | 48 | |
---|
| 49 | real pi |
---|
| 50 | |
---|
[3977] | 51 | iotd_ts=timestep |
---|
| 52 | iotd_t0=t0 |
---|
| 53 | print*,'iotd_ini, ',timestep,iotd_ts |
---|
[1980] | 54 | imax=iim |
---|
| 55 | jmax=jjm |
---|
| 56 | lmax=llm |
---|
[3977] | 57 | ! Utile pour passer en real*4 pour les ecritures |
---|
| 58 | rlon=prlon |
---|
| 59 | rlat=prlat |
---|
[1980] | 60 | coordv=pcoordv |
---|
| 61 | |
---|
[3977] | 62 | |
---|
[3978] | 63 | !----------------------------------------------------------------------- |
---|
| 64 | ! Possibilité de spécifier une liste de variables à sortir |
---|
| 65 | ! dans iotd.def |
---|
| 66 | ! Si iotd.def existe et est non vide, |
---|
| 67 | ! seules les variables faisant à la fois l'objet d'un call iotd_ecrit |
---|
| 68 | ! et étant spécifiées dans iotd.def sont sorties. |
---|
| 69 | ! Sinon, toutes les variables faisant l'objet d'un call iotd_ecrit |
---|
| 70 | ! sont sorties |
---|
| 71 | !----------------------------------------------------------------------- |
---|
| 72 | n_names_iotd_def=0 |
---|
| 73 | open(99,file='iotd.def',form='formatted',status='old',iostat=ierr) |
---|
[5075] | 74 | if ( ierr==0 ) then |
---|
[3978] | 75 | ierr=0 |
---|
| 76 | do while (ierr==0) |
---|
| 77 | read(99,*,iostat=ierr) un_nom |
---|
| 78 | if (ierr==0) then |
---|
| 79 | n_names_iotd_def=n_names_iotd_def+1 |
---|
| 80 | names_iotd_def(n_names_iotd_def)=un_nom |
---|
| 81 | endif |
---|
| 82 | enddo |
---|
| 83 | endif |
---|
| 84 | print*,n_names_iotd_def,names_iotd_def(1:n_names_iotd_def) |
---|
| 85 | close(99) |
---|
[1980] | 86 | |
---|
| 87 | |
---|
| 88 | pi=2.*asin(1.) |
---|
| 89 | |
---|
| 90 | ! Define dimensions |
---|
| 91 | |
---|
[3977] | 92 | ! Create the NetCDF file |
---|
[5088] | 93 | ierr=nf90_create(fichnom, nf90_clobber, nid) |
---|
| 94 | ierr=nf90_def_dim(nid, "lon", iim, dim_coord(1)) |
---|
| 95 | ierr=nf90_def_dim(nid, "lat", jjm, dim_coord(2)) |
---|
| 96 | ierr=nf90_def_dim(nid, "lev", llm, dim_coord(3)) |
---|
| 97 | ierr=nf90_def_dim(nid,"time",nf90_unlimited,dim_coord(4)) |
---|
| 98 | ierr = nf90_put_att(nid,nf90_global,'Conventions',"CF-1.1") |
---|
| 99 | !ierr = nf90_put_att(nid,nf90_global,'file_name',TRIM(fname)) |
---|
| 100 | ierr=nf90_enddef(nid) |
---|
[1980] | 101 | |
---|
[3977] | 102 | ! Switch out of NetCDF Define mode |
---|
[1980] | 103 | |
---|
| 104 | |
---|
[5088] | 105 | ierr=nf90_enddef(nid) |
---|
[1980] | 106 | ! |
---|
| 107 | ! Contol parameters for this run |
---|
[3977] | 108 | ! ---- longitude ----------- |
---|
[1980] | 109 | |
---|
[5088] | 110 | ierr=nf90_redef(nid) |
---|
| 111 | ierr=nf90_def_var(nid,"lon", nf90_float, dim_coord(1),nvarid) |
---|
| 112 | ierr = nf90_put_att(nid,nvarid,'axis','X') |
---|
| 113 | ierr=nf90_put_att(nid,nvarid,'units',"degrees_east") |
---|
| 114 | ierr=nf90_enddef(nid) |
---|
[5075] | 115 | ierr=nf90_put_var(nid,nvarid,rlon) |
---|
[1980] | 116 | print*,ierr |
---|
| 117 | |
---|
[3977] | 118 | ! ---- latitude ------------ |
---|
[5088] | 119 | ierr=nf90_redef(nid) |
---|
| 120 | ierr=nf90_def_var(nid, "lat", nf90_float, dim_coord(2),nvarid) |
---|
| 121 | ierr = nf90_put_att(nid,nvarid,'axis','Y') |
---|
| 122 | ierr=nf90_put_att(nid,nvarid,'units',"degrees_north") |
---|
| 123 | ierr=nf90_enddef(nid) |
---|
[5075] | 124 | ierr=nf90_put_var(nid,nvarid,rlat) |
---|
[1980] | 125 | ! |
---|
[3977] | 126 | ! ---- vertical ------------ |
---|
[5088] | 127 | ierr=nf90_redef(nid) |
---|
| 128 | ierr=nf90_def_var(nid, "lev", nf90_float,dim_coord(3),nvarid) |
---|
| 129 | ierr=nf90_put_att(nid,nvarid,"long_name","vert level") |
---|
[3977] | 130 | if ( coordv(2)>coordv(1) ) then |
---|
[5088] | 131 | ierr=nf90_put_att(nid,nvarid,"long_name","pseudo-alt") |
---|
| 132 | ierr=nf90_put_att(nid,nvarid,'positive',"up") |
---|
[1980] | 133 | else |
---|
[5088] | 134 | ierr=nf90_put_att(nid,nvarid,"long_name","pressure") |
---|
| 135 | ierr = nf90_put_att(nid,nvarid,'positive',"down") |
---|
[1980] | 136 | endif |
---|
[5088] | 137 | ierr=nf90_enddef(nid) |
---|
[5075] | 138 | ierr=nf90_put_var(nid,nvarid,coordv) |
---|
[1980] | 139 | |
---|
| 140 | ! |
---|
[3977] | 141 | ! ---- time ---------------- |
---|
[5088] | 142 | ierr=nf90_redef(nid) |
---|
[3977] | 143 | ! Define the 'time' variable |
---|
[5088] | 144 | ierr=nf90_def_var(nid, "time", nf90_float, dim_coord(4),nvarid) |
---|
[3977] | 145 | ! ! Add attributes |
---|
[5088] | 146 | ierr = nf90_put_att(nid,nvarid,'axis','T') |
---|
| 147 | ierr = nf90_put_att(nid,nvarid,'standard_name','time') |
---|
[3977] | 148 | WRITE(date0,'(i4.4,"-",i2.2,"-",i2.2)') an0,mois0,jour0 |
---|
[5088] | 149 | ierr=nf90_put_att(nid, nvarid,'units', & |
---|
[5087] | 150 | "seconds since "//date0//" 00:00:00") |
---|
[5088] | 151 | ierr = nf90_put_att(nid,nvarid,'calendar',calendrier) |
---|
| 152 | !ierr = nf90_put_att(nid,nvarid,'calendar','360d') |
---|
| 153 | ierr = nf90_put_att(nid,nvarid,'title','Time') |
---|
| 154 | ierr = nf90_put_att(nid,nvarid,'long_name','Time axis') |
---|
[3977] | 155 | WRITE(date0b,'(i4.4,"-",a3,"-",i2.2)') an0,cmois(mois0),jour0 |
---|
[5088] | 156 | ierr = nf90_put_att(nid,nvarid,'time_origin', & |
---|
[5087] | 157 | date0b//' 00:00:00') |
---|
[5088] | 158 | ierr=nf90_enddef(nid) |
---|
[3977] | 159 | |
---|
| 160 | |
---|
[1980] | 161 | END |
---|