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