[38] | 1 | SUBROUTINE iniav(fichnom,pday0,pyear0,pfrac0,pperiod,phis,nq) |
---|
| 2 | IMPLICIT NONE |
---|
| 3 | |
---|
| 4 | c======================================================================= |
---|
| 5 | c |
---|
| 6 | c pday0 jour de reference pour le stockage |
---|
| 7 | c pfrac0 decalage du debut du stockage par rapport a pday0 (en jour) |
---|
| 8 | c pperiod period de stockage en secondes |
---|
| 9 | c phis geopotentiel au sol |
---|
| 10 | c |
---|
| 11 | c initialisation de l'ecriture des moyennes temporelles. |
---|
| 12 | c |
---|
| 13 | c======================================================================= |
---|
| 14 | |
---|
| 15 | #include "dimensions.h" |
---|
| 16 | #include "paramet.h" |
---|
| 17 | #include "comav.h" |
---|
| 18 | #include "netcdf.inc" |
---|
| 19 | #include "comvert.h" |
---|
| 20 | #include "comgeom.h" |
---|
| 21 | |
---|
| 22 | REAL pperiod |
---|
| 23 | |
---|
| 24 | INTEGER*4 pday0,pyear0 |
---|
| 25 | REAL pfrac0 |
---|
| 26 | CHARACTER*(*) fichnom |
---|
| 27 | REAL phis(ip1jmp1) |
---|
| 28 | c |
---|
| 29 | CHARACTER str3*3 |
---|
| 30 | c |
---|
| 31 | INTEGER nq |
---|
| 32 | INTEGER ierr, nid, nvarid, iq |
---|
| 33 | INTEGER idim_rlonu, idim_rlonv, idim_rlatu, idim_rlatv |
---|
| 34 | INTEGER idim_s, idim_sig |
---|
| 35 | INTEGER idim_tim |
---|
| 36 | INTEGER dims2(2), dims3(3), dims4(4) |
---|
| 37 | |
---|
| 38 | period_av=pperiod |
---|
| 39 | time0_av=pfrac0 |
---|
| 40 | c |
---|
[410] | 41 | ierr = NF_CREATE(fichnom, IOR(NF_CLOBBER,NF_64BIT_OFFSET), nid) |
---|
[38] | 42 | IF (ierr.NE.NF_NOERR) THEN |
---|
| 43 | WRITE(6,*)" Pb d ouverture du fichier "//fichnom |
---|
| 44 | WRITE(6,*)' ierr = ', ierr |
---|
| 45 | CALL ABORT |
---|
| 46 | ENDIF |
---|
| 47 | c |
---|
| 48 | c Preciser quelques attributs globaux: |
---|
| 49 | c |
---|
| 50 | ierr = NF_PUT_ATT_TEXT (nid, NF_GLOBAL, "title", 32, |
---|
| 51 | . "Fichier moyen histoire dynamique") |
---|
| 52 | c |
---|
| 53 | c Definir les dimensions du fichiers: |
---|
| 54 | c |
---|
| 55 | ierr = NF_DEF_DIM (nid, "rlonu", iip1, idim_rlonu) |
---|
| 56 | ierr = NF_DEF_DIM (nid, "rlatu", jjp1, idim_rlatu) |
---|
| 57 | ierr = NF_DEF_DIM (nid, "rlonv", iip1, idim_rlonv) |
---|
| 58 | ierr = NF_DEF_DIM (nid, "rlatv", jjm, idim_rlatv) |
---|
| 59 | ierr = NF_DEF_DIM (nid, "sigs", llm, idim_s) |
---|
| 60 | ierr = NF_DEF_DIM (nid, "sig", llmp1, idim_sig) |
---|
| 61 | ierr = NF_DEF_DIM (nid, "temps", NF_UNLIMITED, idim_tim) |
---|
| 62 | c |
---|
| 63 | ierr = NF_ENDDEF(nid) ! sortir du mode de definition |
---|
| 64 | c |
---|
| 65 | c Definir et enregistrer certains champs invariants: |
---|
| 66 | c |
---|
| 67 | c |
---|
| 68 | ierr = NF_REDEF (nid) |
---|
| 69 | ccc ierr = NF_DEF_VAR (nid,"rlonu",NF_DOUBLE,1,idim_rlonu,nvarid) |
---|
| 70 | ierr = NF_DEF_VAR (nid,"rlonu",NF_FLOAT,1,idim_rlonu,nvarid) |
---|
| 71 | ierr = NF_ENDDEF(nid) |
---|
| 72 | #ifdef NC_DOUBLE |
---|
| 73 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonu) |
---|
| 74 | #else |
---|
| 75 | ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonu) |
---|
| 76 | #endif |
---|
| 77 | c |
---|
| 78 | ierr = NF_REDEF (nid) |
---|
| 79 | ccc ierr = NF_DEF_VAR (nid,"rlatu",NF_DOUBLE,1,idim_rlatu,nvarid) |
---|
| 80 | ierr = NF_DEF_VAR (nid,"rlatu",NF_FLOAT,1,idim_rlatu,nvarid) |
---|
| 81 | ierr = NF_ENDDEF(nid) |
---|
| 82 | #ifdef NC_DOUBLE |
---|
| 83 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatu) |
---|
| 84 | #else |
---|
| 85 | ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatu) |
---|
| 86 | #endif |
---|
| 87 | c |
---|
| 88 | ierr = NF_REDEF (nid) |
---|
| 89 | ccc ierr = NF_DEF_VAR (nid,"rlonv",NF_DOUBLE,1,idim_rlonv,nvarid) |
---|
| 90 | ierr = NF_DEF_VAR (nid,"rlonv",NF_FLOAT,1,idim_rlonv,nvarid) |
---|
| 91 | ierr = NF_ENDDEF(nid) |
---|
| 92 | #ifdef NC_DOUBLE |
---|
| 93 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonv) |
---|
| 94 | #else |
---|
| 95 | ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonv) |
---|
| 96 | #endif |
---|
| 97 | c |
---|
| 98 | ierr = NF_REDEF (nid) |
---|
| 99 | ccc ierr = NF_DEF_VAR (nid,"rlatv",NF_DOUBLE,1,idim_rlatv,nvarid) |
---|
| 100 | ierr = NF_DEF_VAR (nid,"rlatv",NF_FLOAT,1,idim_rlatv,nvarid) |
---|
| 101 | ierr = NF_ENDDEF(nid) |
---|
| 102 | #ifdef NC_DOUBLE |
---|
| 103 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatv) |
---|
| 104 | #else |
---|
| 105 | ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatv) |
---|
| 106 | #endif |
---|
| 107 | c |
---|
| 108 | ierr = NF_REDEF (nid) |
---|
| 109 | ccc ierr = NF_DEF_VAR (nid,"nivsigs",NF_DOUBLE,1,idim_s,nvarid) |
---|
| 110 | ierr = NF_DEF_VAR (nid,"nivsigs",NF_FLOAT,1,idim_s,nvarid) |
---|
| 111 | ierr = NF_ENDDEF(nid) |
---|
| 112 | #ifdef NC_DOUBLE |
---|
| 113 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,nivsigs) |
---|
| 114 | #else |
---|
| 115 | ierr = NF_PUT_VAR_REAL (nid,nvarid,nivsigs) |
---|
| 116 | #endif |
---|
| 117 | c |
---|
| 118 | ierr = NF_REDEF (nid) |
---|
| 119 | ccc ierr = NF_DEF_VAR (nid,"nivsig",NF_DOUBLE,1,idim_sig,nvarid) |
---|
| 120 | ierr = NF_DEF_VAR (nid,"nivsig",NF_FLOAT,1,idim_sig,nvarid) |
---|
| 121 | ierr = NF_ENDDEF(nid) |
---|
| 122 | #ifdef NC_DOUBLE |
---|
| 123 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,nivsig) |
---|
| 124 | #else |
---|
| 125 | ierr = NF_PUT_VAR_REAL (nid,nvarid,nivsig) |
---|
| 126 | #endif |
---|
| 127 | c |
---|
| 128 | ierr = NF_REDEF (nid) |
---|
| 129 | ccc ierr = NF_DEF_VAR (nid,"ap",NF_DOUBLE,1,idim_sig,nvarid) |
---|
| 130 | ierr = NF_DEF_VAR (nid,"ap",NF_FLOAT,1,idim_sig,nvarid) |
---|
| 131 | ierr = NF_ENDDEF(nid) |
---|
| 132 | #ifdef NC_DOUBLE |
---|
| 133 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,ap) |
---|
| 134 | #else |
---|
| 135 | ierr = NF_PUT_VAR_REAL (nid,nvarid,ap) |
---|
| 136 | #endif |
---|
| 137 | c |
---|
| 138 | ierr = NF_REDEF (nid) |
---|
| 139 | ccc ierr = NF_DEF_VAR (nid,"bp",NF_DOUBLE,1,idim_sig,nvarid) |
---|
| 140 | ierr = NF_DEF_VAR (nid,"bp",NF_FLOAT,1,idim_sig,nvarid) |
---|
| 141 | ierr = NF_ENDDEF(nid) |
---|
| 142 | #ifdef NC_DOUBLE |
---|
| 143 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bp) |
---|
| 144 | #else |
---|
| 145 | ierr = NF_PUT_VAR_REAL (nid,nvarid,bp) |
---|
| 146 | #endif |
---|
| 147 | c |
---|
| 148 | ierr = NF_REDEF (nid) |
---|
| 149 | ccc ierr = NF_DEF_VAR (nid,"presnivs",NF_DOUBLE,1,idim_s,nvarid) |
---|
| 150 | ierr = NF_DEF_VAR (nid,"presnivs",NF_FLOAT,1,idim_s,nvarid) |
---|
| 151 | ierr = NF_ENDDEF(nid) |
---|
| 152 | #ifdef NC_DOUBLE |
---|
| 153 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,presnivs) |
---|
| 154 | #else |
---|
| 155 | ierr = NF_PUT_VAR_REAL (nid,nvarid,presnivs) |
---|
| 156 | #endif |
---|
| 157 | c |
---|
| 158 | c Geopentiel au sol: |
---|
| 159 | c |
---|
| 160 | ierr = NF_REDEF (nid) |
---|
| 161 | dims2(1) = idim_rlonv |
---|
| 162 | dims2(2) = idim_rlatu |
---|
| 163 | ccc ierr = NF_DEF_VAR (nid,"phisinit",NF_DOUBLE,2,dims2,nvarid) |
---|
| 164 | ierr = NF_DEF_VAR (nid,"phisinit",NF_FLOAT,2,dims2,nvarid) |
---|
| 165 | ierr = NF_ENDDEF(nid) |
---|
| 166 | #ifdef NC_DOUBLE |
---|
| 167 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,phis) |
---|
| 168 | #else |
---|
| 169 | ierr = NF_PUT_VAR_REAL (nid,nvarid,phis) |
---|
| 170 | #endif |
---|
| 171 | c |
---|
| 172 | c Definir les variables pour pouvoir les enregistrer plus tard: |
---|
| 173 | c |
---|
| 174 | ierr = NF_REDEF (nid) ! entrer dans le mode de definition |
---|
| 175 | c |
---|
| 176 | ccc ierr = NF_DEF_VAR (nid,"temps",NF_DOUBLE,1,idim_tim,nvarid) |
---|
| 177 | ierr = NF_DEF_VAR (nid,"temps",NF_FLOAT,1,idim_tim,nvarid) |
---|
| 178 | IF (ierr .NE. NF_NOERR) THEN |
---|
| 179 | PRINT*, "iniav: Erreur pour definir <temps>" |
---|
| 180 | CALL abort |
---|
| 181 | ENDIF |
---|
| 182 | c |
---|
| 183 | dims4(1) = idim_rlonu |
---|
| 184 | dims4(2) = idim_rlatu |
---|
| 185 | dims4(3) = idim_s |
---|
| 186 | dims4(4) = idim_tim |
---|
| 187 | ccc ierr = NF_DEF_VAR (nid,"vitu",NF_DOUBLE,4,dims4,nvarid) |
---|
| 188 | ierr = NF_DEF_VAR (nid,"vitu",NF_FLOAT,4,dims4,nvarid) |
---|
| 189 | c |
---|
| 190 | dims4(1) = idim_rlonv |
---|
| 191 | dims4(2) = idim_rlatv |
---|
| 192 | dims4(3) = idim_s |
---|
| 193 | dims4(4) = idim_tim |
---|
| 194 | ccc ierr = NF_DEF_VAR (nid,"vitv",NF_DOUBLE,4,dims4,nvarid) |
---|
| 195 | ierr = NF_DEF_VAR (nid,"vitv",NF_FLOAT,4,dims4,nvarid) |
---|
| 196 | c |
---|
| 197 | dims4(1) = idim_rlonv |
---|
| 198 | dims4(2) = idim_rlatu |
---|
| 199 | dims4(3) = idim_s |
---|
| 200 | dims4(4) = idim_tim |
---|
| 201 | ccc ierr = NF_DEF_VAR (nid,"temp",NF_DOUBLE,4,dims4,nvarid) |
---|
| 202 | ierr = NF_DEF_VAR (nid,"temp",NF_FLOAT,4,dims4,nvarid) |
---|
| 203 | c |
---|
| 204 | dims4(1) = idim_rlonv |
---|
| 205 | dims4(2) = idim_rlatu |
---|
| 206 | dims4(3) = idim_s |
---|
| 207 | dims4(4) = idim_tim |
---|
| 208 | IF(nq.GE.1) THEN |
---|
| 209 | DO iq=1,nq |
---|
| 210 | IF (iq.GT.99) THEN |
---|
| 211 | PRINT*, "Trop de traceurs" |
---|
| 212 | CALL abort |
---|
| 213 | ELSE |
---|
| 214 | str3(1:1)='q' |
---|
| 215 | WRITE(str3(2:3),'(i2.2)') iq |
---|
| 216 | ccc ierr = NF_DEF_VAR (nid,str3,NF_DOUBLE,4,dims4,nvarid) |
---|
| 217 | ierr = NF_DEF_VAR (nid,str3,NF_FLOAT,4,dims4,nvarid) |
---|
| 218 | ENDIF |
---|
| 219 | ENDDO |
---|
| 220 | ENDIF |
---|
| 221 | c |
---|
| 222 | dims3(1) = idim_rlonv |
---|
| 223 | dims3(2) = idim_rlatu |
---|
| 224 | dims3(3) = idim_tim |
---|
| 225 | ccc ierr = NF_DEF_VAR (nid,"ps",NF_DOUBLE,3,dims3,nvarid) |
---|
| 226 | ierr = NF_DEF_VAR (nid,"ps",NF_FLOAT,3,dims3,nvarid) |
---|
| 227 | c |
---|
| 228 | ierr = NF_ENDDEF(nid) ! sortir du mode de definition |
---|
| 229 | ierr = NF_CLOSE(nid) ! fermer le fichier |
---|
| 230 | |
---|
| 231 | PRINT*,'le fichier hist.moy stoke les variables toutes' |
---|
| 232 | PRINT*,'les ',period_av,'s' |
---|
| 233 | PRINT*,'A partir du jour de reference day0' |
---|
| 234 | RETURN |
---|
| 235 | END |
---|