Blame view

src/write_output.f90 5.47 KB
4e5b4414   Jérémy Baudry   ajout commentaire...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

!________________________________________________________________________________

                        !DESCRIPTION: This routine create the NETCDF output
                        !file. You must have the FORTRAN NETCDF libraries
                        !installed on your computer  to use this routine.


!________________________________________________________________________________

                        !INTERFACE:
                        subroutine write_output

                        !MODULE USES:
                        use netcdf
                        use parameters

                    

                        !LOCAL PARAMETERS:

                        implicit none

                         !INCLUDES:
                        include 'netcdf.inc'

                        integer :: ncid
                        integer :: omID
                        integer :: xID
                        integer :: tID
                        integer :: SpectreID
                        integer :: om_varID
                        integer :: x_varID
                        integer :: t_varID
                        integer :: stat
                        integer :: Dmax_varID
                        integer :: Dave_varID
                        integer :: c_varID
                        integer :: h_varID
                        integer :: floeID
                        integer :: fsdID
                        integer :: floe_varID
                        integer :: SrcID
68586e03   Jérémy Baudry   new release
44
45
46
47
                        integer :: HsID
                        integer :: thickcatID
                        integer :: thickcat_varID
                        integer :: idtID
4e5b4414   Jérémy Baudry   ajout commentaire...
48
49

!_________________________________________________________________________________
d380ec6c   Jérémy Baudry   second commit
50
51
stat=nf90_create(namefile,nf90_clobber,ncid)
call handle_err(stat)
4508a952   Jérémy Baudry   new version
52
!__________________dimensions_______________________________
68586e03   Jérémy Baudry   new release
53

d380ec6c   Jérémy Baudry   second commit
54
55
        stat=nf90_def_dim(ncid,"omega", nfreq, omID)
        call handle_err(stat)
81dede1c   Jérémy Baudry   first commit
56

d380ec6c   Jérémy Baudry   second commit
57
58
        stat=nf90_def_dim(ncid,"x_axis", nbin, xID)
        call handle_err(stat)
68586e03   Jérémy Baudry   new release
59

d380ec6c   Jérémy Baudry   second commit
60
61
        stat=nf90_def_dim(ncid,"time", nsteps, tID)
        call handle_err(stat)
81dede1c   Jérémy Baudry   first commit
62

4508a952   Jérémy Baudry   new version
63
64
65
66

        stat=nf90_def_dim(ncid,"floe size",nbcat, floeID)
        call handle_err(stat)

68586e03   Jérémy Baudry   new release
67
68
69
        stat=nf90_def_dim(ncid,"thickness categories",nbcat_h, thickcatID)
        call handle_err(stat)

4508a952   Jérémy Baudry   new version
70
!_____________variables__________________________________________
d380ec6c   Jérémy Baudry   second commit
71
72
73
74
75
76
        stat=nf90_def_var(ncid,"omega",nf90_double,omID,om_varID)
        call handle_err(stat)
        stat=nf90_def_var(ncid,"x_axis",nf90_double,xID,x_varID)
        call handle_err(stat)
        stat=nf90_def_var(ncid,"time",nf90_double,tID,t_varID)
        call handle_err(stat)
4508a952   Jérémy Baudry   new version
77

68586e03   Jérémy Baudry   new release
78
79
80
        stat=nf90_def_var(ncid,"thickness categories",nf90_double,thickcatID,thickcat_varID)
        call handle_err(stat)

4508a952   Jérémy Baudry   new version
81
82
83
        stat=nf90_def_var(ncid,"floe size",nf90_double,floeID,floe_varID)
        call handle_err(stat)

68586e03   Jérémy Baudry   new release
84

d380ec6c   Jérémy Baudry   second commit
85
86
        stat=nf90_def_var(ncid,"Spectrum",nf90_double,(/ tID, xID, omID /),SpectreID)
        call handle_err(stat)
4e5b4414   Jérémy Baudry   ajout commentaire...
87
88
89
90

        stat=nf90_def_var(ncid,"att src term",nf90_double,(/ tID, xID, omID /),SrcID)
        call handle_err(stat)

d380ec6c   Jérémy Baudry   second commit
91
92
93
94
        stat=nf90_def_var(ncid,"Dave",nf90_double,xID,Dave_varID)
        call handle_err(stat)
        stat=nf90_def_var(ncid,"Dmax",nf90_double,xID,Dmax_varID)
        call handle_err(stat)
4508a952   Jérémy Baudry   new version
95
96
97
98
         stat=nf90_def_var(ncid,"Ice concentration",nf90_double,xID,c_varID)
        call handle_err(stat)
        stat=nf90_def_var(ncid,"Ice thickness",nf90_double,xID,h_varID)
        call handle_err(stat)
68586e03   Jérémy Baudry   new release
99
100
101
102
103
        stat=nf90_def_var(ncid,"Floe size distribution",nf90_double,(/ tID, xID,floeID,thickcatID /),fsdID)
        call handle_err(stat)
        stat=nf90_def_var(ncid,"significant height",nf90_double,(/ tID,xID /),HsID)
        call handle_err(stat)
        stat=nf90_def_var(ncid,"Ice Thickness Distribution",nf90_double,(/ xID,thickcatID /),idtID)
4508a952   Jérémy Baudry   new version
104
        call handle_err(stat)
81dede1c   Jérémy Baudry   first commit
105

d380ec6c   Jérémy Baudry   second commit
106
        stat=nf90_enddef(ncid)
68586e03   Jérémy Baudry   new release
107

d380ec6c   Jérémy Baudry   second commit
108
109
110
111
112
        call handle_err(stat)
        stat=nf90_put_var(ncid,om_varID,omega)
        call handle_err(stat)
        stat=nf90_put_var(ncid,spectreID,E)
        call handle_err(stat)
4e5b4414   Jérémy Baudry   ajout commentaire...
113
114
        stat=nf90_put_var(ncid,SrcID,S_ice)
        call handle_err(stat)
d380ec6c   Jérémy Baudry   second commit
115
116
117
118
119
120
121
122
        stat=nf90_put_var(ncid,Dmax_varID,Dmax)
        call handle_err(stat)
        stat=nf90_put_var(ncid,Dave_varID,Dave)
        call handle_err(stat)
        stat=nf90_put_var(ncid,t_varID,time)
        call handle_err(stat)
        stat=nf90_put_var(ncid,x_varID,x_axis)
        call handle_err(stat)
4508a952   Jérémy Baudry   new version
123
124
125
126
127
128
129
130
        stat=nf90_put_var(ncid,c_varID,C_ice)
        call handle_err(stat)
        stat=nf90_put_var(ncid,h_varID,h)
        call handle_err(stat)
        stat=nf90_put_var(ncid,fsdID,FSD)
        call handle_err(stat)
        stat=nf90_put_var(ncid,floe_varID,middle_floe_cat)
        call handle_err(stat)
68586e03   Jérémy Baudry   new release
131
132
133
134
135
136
137
        stat=nf90_put_var(ncid,thickcat_varID,middle_h_cat)
        call handle_err(stat)

         stat=nf90_put_var(ncid,HsID,h_sign)
        call handle_err(stat)
        stat=nf90_put_var(ncid,idtID,IDT)
        call handle_err(stat)
4508a952   Jérémy Baudry   new version
138

d380ec6c   Jérémy Baudry   second commit
139
140
141
142




4e5b4414   Jérémy Baudry   ajout commentaire...
143
144
        stat=nf90_close(ncid)
        call handle_err(stat)
d380ec6c   Jérémy Baudry   second commit
145
146
147
        
contains

4e5b4414   Jérémy Baudry   ajout commentaire...
148
!____________________________________________________________________________________
d380ec6c   Jérémy Baudry   second commit
149
150
151
152
153
154
155
156
subroutine handle_err(stat)
        integer, intent(in) :: stat

        if(stat /=nf90_noerr) then
        write(*,*)trim(nf90_strerror(stat))
        STOP 'unable de write the netcdf output' 
        end if
end subroutine handle_err
81dede1c   Jérémy Baudry   first commit
157

4e5b4414   Jérémy Baudry   ajout commentaire...
158
!____________________________________________________________________________________
81dede1c   Jérémy Baudry   first commit
159
160

end subroutine write_output