| 1 | c======================================================================= |
|---|
| 2 | subroutine write_archive(nid,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 | USE control_mod |
|---|
| 35 | USE comvert_mod, ONLY: ap,bp,presnivs,pa,preff,nivsigs,nivsig, |
|---|
| 36 | . aps,bps,scaleheight,pseudoalt, |
|---|
| 37 | . disvert_type,pressure_exner |
|---|
| 38 | |
|---|
| 39 | implicit none |
|---|
| 40 | |
|---|
| 41 | #include "dimensions.h" |
|---|
| 42 | #include "paramet.h" |
|---|
| 43 | #include "comgeom.h" |
|---|
| 44 | #include "description.h" |
|---|
| 45 | #include "netcdf.inc" |
|---|
| 46 | |
|---|
| 47 | c----------------------------------------------------------------------- |
|---|
| 48 | c Declarations |
|---|
| 49 | c----------------------------------------------------------------------- |
|---|
| 50 | |
|---|
| 51 | c Arguments: |
|---|
| 52 | |
|---|
| 53 | INTEGER nid,ntime,dim |
|---|
| 54 | REAL px(iip1,jjp1,llm) |
|---|
| 55 | |
|---|
| 56 | CHARACTER*(*) nom, titre, unite |
|---|
| 57 | |
|---|
| 58 | integer ierr |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | c local |
|---|
| 62 | integer, dimension(4) :: edges,corner,id |
|---|
| 63 | integer :: varid,i,j,l |
|---|
| 64 | |
|---|
| 65 | ntime = 1 |
|---|
| 66 | |
|---|
| 67 | c----------------------------------------------------------------------- |
|---|
| 68 | c Ecriture du champs dans le fichier (3 cas) |
|---|
| 69 | c----------------------------------------------------------------------- |
|---|
| 70 | |
|---|
| 71 | !Cas Variable 3D |
|---|
| 72 | !--------------- |
|---|
| 73 | if (dim.eq.3) then |
|---|
| 74 | |
|---|
| 75 | ! Ecriture du champs |
|---|
| 76 | |
|---|
| 77 | ! nom de la variable |
|---|
| 78 | ierr= NF_INQ_VARID(nid,nom,varid) |
|---|
| 79 | if (ierr /= NF_NOERR) then |
|---|
| 80 | ! choix du nom des coordonnees |
|---|
| 81 | ierr= NF_INQ_DIMID(nid,"rlonv",id(1)) |
|---|
| 82 | ierr= NF_INQ_DIMID(nid,"rlatu",id(2)) |
|---|
| 83 | ierr= NF_INQ_DIMID(nid,"sigs",id(3)) |
|---|
| 84 | ierr= NF_INQ_DIMID(nid,"Time",id(4)) |
|---|
| 85 | |
|---|
| 86 | ! Creation de la variable si elle n'existait pas |
|---|
| 87 | |
|---|
| 88 | write (*,*) "=====================" |
|---|
| 89 | write (*,*) "creation de ",nom |
|---|
| 90 | call def_var(nid,nom,titre,unite,4,id,varid,ierr) |
|---|
| 91 | |
|---|
| 92 | endif |
|---|
| 93 | |
|---|
| 94 | corner(1)=1 |
|---|
| 95 | corner(2)=1 |
|---|
| 96 | corner(3)=1 |
|---|
| 97 | corner(4)=ntime |
|---|
| 98 | |
|---|
| 99 | edges(1)=iip1 |
|---|
| 100 | edges(2)=jjp1 |
|---|
| 101 | edges(3)=llm |
|---|
| 102 | edges(4)=1 |
|---|
| 103 | #ifdef NC_DOUBLE |
|---|
| 104 | ierr= NF_PUT_VARA_DOUBLE(nid,varid,corner,edges,px) |
|---|
| 105 | #else |
|---|
| 106 | ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,px) |
|---|
| 107 | #endif |
|---|
| 108 | |
|---|
| 109 | if (ierr.ne.NF_NOERR) then |
|---|
| 110 | write(*,*) "***** PUT_VAR matter in write_archive" |
|---|
| 111 | write(*,*) "***** with ",nom," ",nf_STRERROR(ierr) |
|---|
| 112 | call abort |
|---|
| 113 | endif |
|---|
| 114 | |
|---|
| 115 | !Cas Variable 2D |
|---|
| 116 | !--------------- |
|---|
| 117 | |
|---|
| 118 | else if (dim.eq.2) then |
|---|
| 119 | |
|---|
| 120 | ! Ecriture du champs |
|---|
| 121 | |
|---|
| 122 | ierr= NF_INQ_VARID(nid,nom,varid) |
|---|
| 123 | if (ierr /= NF_NOERR) then |
|---|
| 124 | ! choix du nom des coordonnees |
|---|
| 125 | ierr= NF_INQ_DIMID(nid,"rlonv",id(1)) |
|---|
| 126 | ierr= NF_INQ_DIMID(nid,"rlatu",id(2)) |
|---|
| 127 | ierr= NF_INQ_DIMID(nid,"Time",id(3)) |
|---|
| 128 | |
|---|
| 129 | ! Creation de la variable si elle n'existait pas |
|---|
| 130 | |
|---|
| 131 | write (*,*) "=====================" |
|---|
| 132 | write (*,*) "creation de ",nom |
|---|
| 133 | |
|---|
| 134 | call def_var(nid,nom,titre,unite,3,id,varid,ierr) |
|---|
| 135 | |
|---|
| 136 | endif |
|---|
| 137 | |
|---|
| 138 | corner(1)=1 |
|---|
| 139 | corner(2)=1 |
|---|
| 140 | corner(3)=ntime |
|---|
| 141 | edges(1)=iip1 |
|---|
| 142 | edges(2)=jjp1 |
|---|
| 143 | edges(3)=1 |
|---|
| 144 | |
|---|
| 145 | |
|---|
| 146 | #ifdef NC_DOUBLE |
|---|
| 147 | ierr = NF_PUT_VARA_DOUBLE (nid,varid,corner,edges,px) |
|---|
| 148 | #else |
|---|
| 149 | ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,px) |
|---|
| 150 | #endif |
|---|
| 151 | |
|---|
| 152 | if (ierr.ne.NF_NOERR) then |
|---|
| 153 | write(*,*) "***** PUT_VAR matter in write_archive" |
|---|
| 154 | write(*,*) "***** with ",nom,nf_STRERROR(ierr) |
|---|
| 155 | call abort |
|---|
| 156 | endif |
|---|
| 157 | |
|---|
| 158 | |
|---|
| 159 | !Cas Variable 0D (scalaire dependant du temps) |
|---|
| 160 | !--------------------------------------------- |
|---|
| 161 | |
|---|
| 162 | else if (dim.eq.0) then |
|---|
| 163 | |
|---|
| 164 | ! Ecriture du champs |
|---|
| 165 | |
|---|
| 166 | ierr= NF_INQ_VARID(nid,nom,varid) |
|---|
| 167 | if (ierr /= NF_NOERR) then |
|---|
| 168 | ! choix du nom des coordonnees |
|---|
| 169 | ierr= NF_INQ_DIMID(nid,"temps",id(1)) |
|---|
| 170 | |
|---|
| 171 | ! Creation de la variable si elle n'existait pas |
|---|
| 172 | |
|---|
| 173 | write (*,*) "=====================" |
|---|
| 174 | write (*,*) "creation de ",nom |
|---|
| 175 | |
|---|
| 176 | call def_var(nid,nom,titre,unite,1,id,varid,ierr) |
|---|
| 177 | |
|---|
| 178 | endif |
|---|
| 179 | |
|---|
| 180 | corner(1)=ntime |
|---|
| 181 | edges(1)=1 |
|---|
| 182 | |
|---|
| 183 | #ifdef NC_DOUBLE |
|---|
| 184 | ierr = NF_PUT_VARA_DOUBLE (nid,varid,corner,edges,px) |
|---|
| 185 | #else |
|---|
| 186 | ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,px) |
|---|
| 187 | #endif |
|---|
| 188 | if (ierr.ne.NF_NOERR) then |
|---|
| 189 | write(*,*) "***** PUT_VAR matter in write_archive" |
|---|
| 190 | write(*,*) "***** with ",nom,nf_STRERROR(ierr) |
|---|
| 191 | call abort |
|---|
| 192 | endif |
|---|
| 193 | |
|---|
| 194 | endif |
|---|
| 195 | |
|---|
| 196 | return |
|---|
| 197 | end |
|---|
| 198 | |
|---|