source: trunk/src/SIMULS_IRCAAM/progfiltrage_simulation.F90 @ 82

Last change on this file since 82 was 82, checked in by pinsard, 14 years ago

modif. of headers for manuals hyperlinks improvements

File size: 6.2 KB
Line 
1      PROGRAM progfiltrage_simulation
2C+
3C 
4C .. _progfiltrage_simulation.F90:
5C
6C ===========================
7C progfiltrage_simulation.F90
8C ===========================
9C
10C SYNOPSIS
11C ========
12C
13C ``progfiltrage_simulation.x``
14C
15C DESCRIPTION
16C ===========
17C
18C filtrage sur olr JAN-DEC de 1968
19C +todo+
20C
21C From olr_nofiltre_arpege\_ \ *simulation*\ .dat.
22C ``progfiltrage_simulation.x`` compute +todo+.
23C
24C ``progfiltrage_simulation.x`` write
25C olr_filtre\_\ *period1*\ -\ *period2*\ d_arpege\_ \ *simulation*\ .dat.
26C
27C
28C CAUTIONS
29C ========
30C
31C On MAC ppc, this program must be compile with ``-fendian=little``
32C for g95
33C according to machineformat used in :ref:`prepare_olr_filtre_simulation.m`.
34C
35C EXAMPLES
36C ========
37C
38C Following line read ``olr_nofiltre_arpege_AfNQIVIV.dat``,
39C compute ++,
40C write ``olr_filtre_10-30d_arpege_AfNQIVIV.dat``
41C ::
42C
43C $ echo "arpege AfNQIVIV 10 30" | progfiltrage_simulation.x -
44C
45C SEE ALSO
46C ========
47C
48C :ref:`prepare_olr_filtre_simulation.m`
49C
50C :ref:`forfilter.f`
51C
52C TODO
53C ====
54C
55C underflow tracking (see ifort failure)
56C
57C REAL ou DOUBLE PRECISION dans les fichiers matlab
58C
59C improve description
60C
61C improve file pb (err in open/read/write)
62C
63C F90 modules
64C
65C portability check because of getenv : now (20090203) written for
66C working on zeus using g95 (GCC 4.0.3 (g95!) Jun 18 2006)
67C
68C use PT fortran tool box ?! when public ...
69C
70C direct access file ? seems to work but see also
71C http://objectmix.com/fortran/305264-read-binaries-matlab.html
72C
73C EVOLUTIONS
74C ==========
75C
76C $Id$
77C
78C - fplod 2009-02-11T11:28:01Z aedon.locean-ipsl.upmc.fr (Darwin)
79C
80C   * bug fix for getenv using Nag compiler
81C
82C - fplod 2009-02-10T13:57:29Z aedon.locean-ipsl.upmc.fr (Darwin)
83C
84C   * bug fix on output file name to be compatible to convention
85C     (not fixed period number of digits)
86C
87C - fplod 2009-02-02T13:45:57Z aedon.locean-ipsl.upmc.fr (Darwin)
88C
89C   * created from progfiltrage_10_30.f  to replace it as well as
90C     progfiltrage_30_100.f
91C
92C   * Subroutines externalized in forfilter.f
93C
94C   * add parameters ircaam_dataset and simulation according to
95C     prepare_olr_filtre_simulation.m
96C
97C   * consolidation : implicit none, inquire iolength, force
98C     LITTLE ENDIAN
99C
100C-
101C
102#ifdef NAGf90Fortran
103      USE F90_UNIX_ENV
104#endif
105
106      IMPLICIT NONE
107
108      EXTERNAL FILTRE
109
110      INTEGER, PARAMETER :: nb = 3660
111      INTEGER :: period1
112      INTEGER :: period2
113C
114      INTEGER :: i
115      INTEGER :: j
116      INTEGER :: k
117      INTEGER :: l
118      INTEGER :: lon0
119      INTEGER :: lat0
120C
121      REAL :: olr(24,15,nb),vb(nb)
122      REAL :: vvb(nb),vvvb(nb),olrf(24,15,nb)
123C
124      CHARACTER (LEN=255) :: ircaam_id
125      CHARACTER (LEN=255) :: ircaam_od
126C
127      CHARACTER (LEN=255) :: fullfilename
128      CHARACTER (LEN=255) :: fullfilename_format
129      INTEGER :: record_length = 0
130C
131      CHARACTER (LEN=6) :: ircaam_dataset
132      CHARACTER (LEN=8) :: simulation
133      LOGICAL           :: vsel = .TRUE.
134
135      write (*,*) 'enter ircaam_dataset simulation period1 period2'
136      read (*,*) ircaam_dataset,simulation,period1,period2
137
138      write (*,*) 'ircaam_dataset : ', ircaam_dataset
139      write (*,*) 'simulation : ', simulation
140      write (*,*) 'period1 : ', period1
141      write (*,*) 'period2 : ', period2
142
143C validation of ircaam_dataset
144      IF (ircaam_dataset /= 'arpege') THEN
145       vsel = .FALSE.
146       WRITE(*,*)' eee : pb validation ircaam_dataset'
147      ENDIF
148
149C validation of simulation
150      IF ((simulation /= 'AfNQIVIV') .AND.
151     +    (simulation /= 'TrNQIVIV') .AND.
152     +    (simulation /= 'AsNQIVIV') .AND.
153     +    (simulation /= 'CtIV') .AND.
154     +    (simulation /= 'CtCl ')) THEN
155       vsel = .FALSE.
156       WRITE(*,*)' eee : pb validation simulation'
157      ENDIF
158
159C validation of period1 and period2
160
161      IF (period1 >= period2) THEN
162       vsel = .FALSE.
163       WRITE(*,*)' eee : pb validation period1 vs period2'
164      ENDIF
165C
166      IF (.NOT. vsel) THEN
167       GOTO 994
168      ENDIF
169
170      CALL GETENV('IRCAAM_ID',ircaam_id)
171      CALL GETENV('IRCAAM_OD',ircaam_od)
172
173      WRITE(fullfilename,'(A,A,A,A,A,A)')
174     +TRIM(ircaam_id),
175     +'olr_nofiltre_',
176     +TRIM(ircaam_dataset),
177     +'_',
178     +TRIM(simulation),
179     +'.dat'
180
181C ask for record length
182      INQUIRE (IOLENGTH=record_length)
183     +(((olr(i,j,k),i=1,24),j=1,15),k=1,nb)
184
185      open(1,file=fullfilename
186     +,status='old'
187     +,form='unformatted',access='direct',recl=record_length)
188
189      read(1,rec=1)
190     +(((olr(i,j,k),i=1,24),j=1,15),k=1,nb)
191
192      CLOSE(1)
193
194c  l'ordre maximal du filtrage est tel que 2*MOR+1 < nb
195c  veuillez changer dans la subroutine FILTRE le parameter MOR
196
197      do lon0=1,24
198       do lat0=1,15
199        do i=1,nb
200         vb(i)=olr(lon0,lat0,i)
201        enddo
202        call filtre(vb,vvb,REAL(period1),nb)
203        call filtre(vb,vvvb,REAL(period2),nb)
204        do i=1,nb
205         olrf(lon0,lat0,i)=vvb(i)-vvvb(i)
206        enddo
207       enddo
208      enddo
209C      print*,(olrf(1,1,j),j=1,nb)
210
211C adjust format of output filename according to period1 and period2 values
212      fullfilename_format = '(A,A,'
213      IF (period1 < 10 ) THEN
214       fullfilename_format = TRIM(fullfilename_format)//'I1,'
215      ENDIF
216      IF ((period1 >= 10) .AND. (period1 < 100)) THEN
217       fullfilename_format = TRIM(fullfilename_format)//'I2,'
218      ENDIF
219      IF (period1 >= 100 ) THEN
220       fullfilename_format = TRIM(fullfilename_format)//'I3,'
221      ENDIF
222      fullfilename_format = TRIM(fullfilename_format) //'A,'
223      IF (period2 < 10 ) THEN
224       fullfilename_format = TRIM(fullfilename_format)//'I1,'
225      ENDIF
226      IF ((period2 >= 10) .AND. (period2 < 100)) THEN
227       fullfilename_format = TRIM(fullfilename_format)//'I2,'
228      ENDIF
229      IF (period2 >= 100 ) THEN
230       fullfilename_format = TRIM(fullfilename_format)//'I3,'
231      ENDIF
232
233      fullfilename_format = TRIM(fullfilename_format)//'A,A,A,A,A)'
234
235      WRITE(fullfilename,fullfilename_format)
236     +TRIM(ircaam_od),
237     +'olr_filtre_',
238     +period1,
239     +'-',
240     +period2,
241     +'d_',
242     +TRIM(ircaam_dataset),
243     +'_',
244     +TRIM(simulation),
245     +'.dat'
246
247      open(2,file=fullfilename
248     +,status='replace'
249     +,form='unformatted',access='direct',recl=24*15*nb*4)
250
251      write(2,rec=1)(((olrf(lon0,lat0,l),lon0=1,24),
252     +                lat0=1,15),l=1,nb)
253      close(2)
254
255994   CONTINUE
256      STOP
257      END
Note: See TracBrowser for help on using the repository browser.