/[lmdze]/trunk/dyn3d/wrgrads.f
ViewVC logotype

Contents of /trunk/dyn3d/wrgrads.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 81 - (show annotations)
Wed Mar 5 14:38:41 2014 UTC (10 years, 2 months ago) by guez
Original Path: trunk/dyn3d/wrgrads.f90
File size: 3583 byte(s)
 Converted to free source form files which were still in fixed source
form. The conversion was done using the polish mode of the NAG Fortran
Compiler.

In addition to converting to free source form, the processing of the
files also:

-- indented the code (including comments);

-- set Fortran keywords to uppercase, and set all other identifiers
to lower case;

-- added qualifiers to end statements (for example "end subroutine
conflx", instead of "end");

-- changed the terminating statements of all DO loops so that each
loop ends with an ENDDO statement (instead of a labeled continue).

1
2 ! $Header: /home/cvsroot/LMDZ4/libf/dyn3d/wrgrads.F,v 1.2 2004/06/22 11:45:30
3 ! lmdzadmin Exp $
4
5 SUBROUTINE wrgrads(if, nl, field, name, titlevar)
6 USE gradsdef
7 IMPLICIT NONE
8
9 ! Declarations
10 ! if indice du fichier
11 ! nl nombre de couches
12 ! field champ
13 ! name petit nom
14 ! titlevar Titre
15
16
17 ! arguments
18 INTEGER if, nl
19 REAL, INTENT (IN) :: field(imx*jmx*lmx)
20 CHARACTER *10 name, file
21 CHARACTER *10 titlevar
22
23 ! local
24
25 INTEGER im, jm, lm, i, j, l, lnblnk, iv, iii, iji, iif, ijf
26
27 LOGICAL writectl
28
29
30 writectl = .FALSE.
31
32 PRINT *, if, iid(if), jid(if), ifd(if), jfd(if)
33 iii = iid(if)
34 iji = jid(if)
35 iif = ifd(if)
36 ijf = jfd(if)
37 im = iif - iii + 1
38 jm = ijf - iji + 1
39 lm = lmd(if)
40
41 PRINT *, 'im,jm,lm,name,firsttime(if)'
42 PRINT *, im, jm, lm, name, firsttime(if)
43
44 IF (firsttime(if)) THEN
45 IF (name==var(1,if)) THEN
46 firsttime(if) = .FALSE.
47 ivar(if) = 1
48 PRINT *, 'fin de l initialiation de l ecriture du fichier'
49 PRINT *, file
50 PRINT *, 'fichier no: ', if
51 PRINT *, 'unit ', unit(if)
52 PRINT *, 'nvar ', nvar(if)
53 PRINT *, 'vars ', (var(iv,if), iv=1, nvar(if))
54 ELSE
55 ivar(if) = ivar(if) + 1
56 nvar(if) = ivar(if)
57 var(ivar(if), if) = name
58 tvar(ivar(if), if) = titlevar(1:lnblnk(titlevar))
59 nld(ivar(if), if) = nl
60 PRINT *, 'initialisation ecriture de ', var(ivar(if), if)
61 PRINT *, 'if ivar(if) nld ', if, ivar(if), nld(ivar(if), if)
62 END IF
63 writectl = .TRUE.
64 itime(if) = 1
65 ELSE
66 ivar(if) = mod(ivar(if), nvar(if)) + 1
67 IF (ivar(if)==nvar(if)) THEN
68 writectl = .TRUE.
69 itime(if) = itime(if) + 1
70 END IF
71
72 IF (var(ivar(if),if)/=name) THEN
73 PRINT *, 'Il faut stoker la meme succession de champs a chaque'
74 PRINT *, 'pas de temps'
75 PRINT *, 'fichier no: ', if
76 PRINT *, 'unit ', unit(if)
77 PRINT *, 'nvar ', nvar(if)
78 PRINT *, 'vars ', (var(iv,if), iv=1, nvar(if))
79
80 STOP
81 END IF
82 END IF
83
84 PRINT *, 'ivar(if),nvar(if),var(ivar(if),if),writectl'
85 PRINT *, ivar(if), nvar(if), var(ivar(if), if), writectl
86 DO l = 1, nl
87 irec(if) = irec(if) + 1
88 ! print*,'Ecrit rec=',irec(if),iii,iif,iji,ijf,
89 ! s (l-1)*imd(if)*jmd(if)+(iji-1)*imd(if)+iii
90 ! s ,(l-1)*imd(if)*jmd(if)+(ijf-1)*imd(if)+iif
91 WRITE (unit(if)+1, REC=irec(if))((field((l-1)*imd(if)*jmd(if)+ &
92 (j-1)*imd(if)+i),i=iii,iif), j=iji, ijf)
93 END DO
94 IF (writectl) THEN
95
96 file = fichier(if)
97 ! WARNING! on reecrase le fichier .ctl a chaque ecriture
98 OPEN (unit(if), FILE=file(1:lnblnk(file))//'.ctl', FORM='formatted', &
99 STATUS='unknown')
100 WRITE (unit(if), '(a5,1x,a40)') 'DSET ', '^' // file(1:lnblnk(file)) // &
101 '.dat'
102
103 WRITE (unit(if), '(a12)') 'UNDEF 1.0E30'
104 WRITE (unit(if), '(a5,1x,a40)') 'TITLE ', title(if)
105 CALL formcoord(unit(if), im, xd(iii,if), 1., .FALSE., 'XDEF')
106 CALL formcoord(unit(if), jm, yd(iji,if), 1., .TRUE., 'YDEF')
107 CALL formcoord(unit(if), lm, zd(1,if), 1., .FALSE., 'ZDEF')
108 WRITE (unit(if), '(a4,i10,a30)') 'TDEF ', itime(if), &
109 ' LINEAR 02JAN1987 1MO '
110 WRITE (unit(if), '(a4,2x,i5)') 'VARS', nvar(if)
111 DO iv = 1, nvar(if)
112 ! print*,'if,var(iv,if),nld(iv,if),nld(iv,if)-1/nld(iv,if)'
113 ! print*,if,var(iv,if),nld(iv,if),nld(iv,if)-1/nld(iv,if)
114 WRITE (unit(if), 1000) var(iv, if), nld(iv, if) - 1/nld(iv, if), 99, &
115 tvar(iv, if)
116 END DO
117 WRITE (unit(if), '(a7)') 'ENDVARS'
118
119 1000 FORMAT (A5, 3X, I4, I3, 1X, A39)
120
121 CLOSE (unit(if))
122
123 END IF ! writectl
124
125 RETURN
126
127 END SUBROUTINE wrgrads
128

  ViewVC Help
Powered by ViewVC 1.1.21