[57] | 1 | c======================================================================= |
---|
| 2 | subroutine write_archive(nid,ntime,nom,titre,unite,dim,px) |
---|
| 3 | c======================================================================= |
---|
| 4 | c |
---|
| 5 | c |
---|
| 6 | c Date: 01/1997 |
---|
| 7 | c ---- |
---|
| 8 | c |
---|
| 9 | c Objet: Ecriture de champs sur grille scalaire (iip1*jjp1) |
---|
| 10 | c ----- dans un fichier DRS nomme "start_archive" |
---|
| 11 | c |
---|
| 12 | c Il faut au prealable avoir cree un entete avec un "call ini_archive". |
---|
| 13 | c Ces variables peuvent etre 3d (ex: temperature), 2d (ex: temperature |
---|
| 14 | c de surface), ou 0d (pour un scalaire qui ne depend que du temps) |
---|
| 15 | c (ex: la longitude solaire) |
---|
| 16 | c |
---|
| 17 | c |
---|
| 18 | c Arguments: |
---|
| 19 | c ---------- |
---|
| 20 | c |
---|
| 21 | c Inputs: |
---|
| 22 | c ------ |
---|
| 23 | c |
---|
| 24 | c nid Unite logique du fichier "start_archive" |
---|
| 25 | c nom nom du champ a ecrire dans le fichier "start_archive" |
---|
| 26 | c titre titre de la variable dans le fichier DRS "start_archive" |
---|
| 27 | c unite unite de la variable .... |
---|
| 28 | c dim dimension de la variable a ecrire |
---|
| 29 | c px tableau contenant la variable a ecrire |
---|
| 30 | c |
---|
| 31 | c |
---|
| 32 | c======================================================================= |
---|
| 33 | |
---|
| 34 | implicit none |
---|
| 35 | |
---|
| 36 | #include "dimensions.h" |
---|
| 37 | #include "paramet.h" |
---|
| 38 | #include "control.h" |
---|
| 39 | #include "comvert.h" |
---|
| 40 | #include "comgeom.h" |
---|
| 41 | #include "description.h" |
---|
| 42 | #include "temps.h" |
---|
| 43 | #include "netcdf.inc" |
---|
| 44 | |
---|
| 45 | c----------------------------------------------------------------------- |
---|
| 46 | c Declarations |
---|
| 47 | c----------------------------------------------------------------------- |
---|
| 48 | |
---|
| 49 | c Arguments: |
---|
| 50 | |
---|
| 51 | INTEGER nid,ntime,dim |
---|
| 52 | REAL px(iip1,jjp1,llm) |
---|
| 53 | |
---|
| 54 | CHARACTER*(*) nom, titre, unite |
---|
| 55 | |
---|
| 56 | integer ierr |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | c local |
---|
| 60 | integer, dimension(4) :: edges,corner,id |
---|
| 61 | integer :: varid,i,j,l |
---|
| 62 | c----------------------------------------------------------------------- |
---|
| 63 | c Ecriture du champs dans le fichier (3 cas) |
---|
| 64 | c----------------------------------------------------------------------- |
---|
| 65 | |
---|
| 66 | !Cas Variable 3D |
---|
| 67 | !--------------- |
---|
| 68 | if (dim.eq.3) then |
---|
| 69 | |
---|
| 70 | ! Ecriture du champs |
---|
| 71 | |
---|
| 72 | ! nom de la variable |
---|
| 73 | ierr= NF_INQ_VARID(nid,nom,varid) |
---|
| 74 | if (ierr /= NF_NOERR) then |
---|
| 75 | ! choix du nom des coordonnees |
---|
| 76 | ierr= NF_INQ_DIMID(nid,"longitude",id(1)) |
---|
| 77 | ierr= NF_INQ_DIMID(nid,"latitude",id(2)) |
---|
| 78 | ierr= NF_INQ_DIMID(nid,"altitude",id(3)) |
---|
| 79 | ierr= NF_INQ_DIMID(nid,"Time",id(4)) |
---|
| 80 | |
---|
| 81 | ! Creation de la variable si elle n'existait pas |
---|
| 82 | |
---|
| 83 | write (*,*) "=====================" |
---|
| 84 | write (*,*) "creation de ",nom |
---|
| 85 | call def_var(nid,nom,titre,unite,4,id,varid,ierr) |
---|
| 86 | |
---|
| 87 | endif |
---|
| 88 | |
---|
| 89 | ! mars s'arranger pour qu'il n'y ai plus besoin de ca |
---|
| 90 | |
---|
| 91 | c do l=1,llm |
---|
| 92 | c do j=1,jjp1 |
---|
| 93 | c do i=1,iip1 |
---|
| 94 | c pxbis(i,j,l)=px(i,j,llm-l+1) |
---|
| 95 | c enddo |
---|
| 96 | c enddo |
---|
| 97 | c enddo |
---|
| 98 | corner(1)=1 |
---|
| 99 | corner(2)=1 |
---|
| 100 | corner(3)=1 |
---|
| 101 | corner(4)=ntime |
---|
| 102 | |
---|
| 103 | edges(1)=iip1 |
---|
| 104 | edges(2)=jjp1 |
---|
| 105 | edges(3)=llm |
---|
| 106 | edges(4)=1 |
---|
| 107 | #ifdef NC_DOUBLE |
---|
| 108 | ierr= NF_PUT_VARA_DOUBLE(nid,varid,corner,edges,px) |
---|
| 109 | #else |
---|
| 110 | ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,px) |
---|
| 111 | #endif |
---|
| 112 | |
---|
| 113 | if (ierr.ne.NF_NOERR) then |
---|
| 114 | write(*,*) "***** PUT_VAR matter in write_archive" |
---|
| 115 | write(*,*) "***** with ",nom," ",nf_STRERROR(ierr) |
---|
| 116 | call abort |
---|
| 117 | endif |
---|
| 118 | |
---|
| 119 | !Cas Variable 2D |
---|
| 120 | !--------------- |
---|
| 121 | |
---|
| 122 | else if (dim.eq.2) then |
---|
| 123 | |
---|
| 124 | ! Ecriture du champs |
---|
| 125 | |
---|
| 126 | ierr= NF_INQ_VARID(nid,nom,varid) |
---|
| 127 | if (ierr /= NF_NOERR) then |
---|
| 128 | ! choix du nom des coordonnees |
---|
| 129 | ierr= NF_INQ_DIMID(nid,"longitude",id(1)) |
---|
| 130 | ierr= NF_INQ_DIMID(nid,"latitude",id(2)) |
---|
| 131 | ierr= NF_INQ_DIMID(nid,"Time",id(3)) |
---|
| 132 | |
---|
| 133 | ! Creation de la variable si elle n'existait pas |
---|
| 134 | |
---|
| 135 | write (*,*) "=====================" |
---|
| 136 | write (*,*) "creation de ",nom |
---|
| 137 | |
---|
| 138 | call def_var(nid,nom,titre,unite,3,id,varid,ierr) |
---|
| 139 | |
---|
| 140 | endif |
---|
| 141 | |
---|
| 142 | corner(1)=1 |
---|
| 143 | corner(2)=1 |
---|
| 144 | corner(3)=ntime |
---|
| 145 | edges(1)=iip1 |
---|
| 146 | edges(2)=jjp1 |
---|
| 147 | edges(3)=1 |
---|
| 148 | |
---|
| 149 | |
---|
| 150 | #ifdef NC_DOUBLE |
---|
| 151 | ierr = NF_PUT_VARA_DOUBLE (nid,varid,corner,edges,px) |
---|
| 152 | #else |
---|
| 153 | ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,px) |
---|
| 154 | #endif |
---|
| 155 | |
---|
| 156 | if (ierr.ne.NF_NOERR) then |
---|
| 157 | write(*,*) "***** PUT_VAR matter in write_archive" |
---|
| 158 | write(*,*) "***** with ",nom,nf_STRERROR(ierr) |
---|
| 159 | call abort |
---|
| 160 | endif |
---|
| 161 | |
---|
| 162 | |
---|
| 163 | !Cas Variable 0D (scalaire dependant du temps) |
---|
| 164 | !--------------------------------------------- |
---|
| 165 | |
---|
| 166 | else if (dim.eq.0) then |
---|
| 167 | |
---|
| 168 | ! Ecriture du champs |
---|
| 169 | |
---|
| 170 | ierr= NF_INQ_VARID(nid,nom,varid) |
---|
| 171 | if (ierr /= NF_NOERR) then |
---|
| 172 | ! choix du nom des coordonnees |
---|
| 173 | ierr= NF_INQ_DIMID(nid,"temps",id(1)) |
---|
| 174 | |
---|
| 175 | ! Creation de la variable si elle n'existait pas |
---|
| 176 | |
---|
| 177 | write (*,*) "=====================" |
---|
| 178 | write (*,*) "creation de ",nom |
---|
| 179 | |
---|
| 180 | call def_var(nid,nom,titre,unite,1,id,varid,ierr) |
---|
| 181 | |
---|
| 182 | endif |
---|
| 183 | |
---|
| 184 | corner(1)=ntime |
---|
| 185 | edges(1)=1 |
---|
| 186 | |
---|
| 187 | #ifdef NC_DOUBLE |
---|
| 188 | ierr = NF_PUT_VARA_DOUBLE (nid,varid,corner,edges,px) |
---|
| 189 | #else |
---|
| 190 | ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,px) |
---|
| 191 | #endif |
---|
| 192 | if (ierr.ne.NF_NOERR) then |
---|
| 193 | write(*,*) "***** PUT_VAR matter in write_archive" |
---|
| 194 | write(*,*) "***** with ",nom,nf_STRERROR(ierr) |
---|
| 195 | call abort |
---|
| 196 | endif |
---|
| 197 | |
---|
| 198 | endif |
---|
| 199 | |
---|
| 200 | return |
---|
| 201 | end |
---|
| 202 | |
---|