Blame view

src/write_output.f90 1.97 KB
81dede1c   Jérémy Baudry   first commit
1
2
3
4
5
6
7
subroutine write_output

use netcdf
use parameters
implicit none
include 'netcdf.inc'
	integer :: ncid,omID,xID,tID,SpectreID
d380ec6c   Jérémy Baudry   second commit
8
9
	integer :: om_varID,x_varID,t_varID,stat
	integer :: Dmax_varID,Dave_varID
81dede1c   Jérémy Baudry   first commit
10

d380ec6c   Jérémy Baudry   second commit
11
12
stat=nf90_create(namefile,nf90_clobber,ncid)
call handle_err(stat)
81dede1c   Jérémy Baudry   first commit
13

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

d380ec6c   Jérémy Baudry   second commit
17
18
19
20
        stat=nf90_def_dim(ncid,"x_axis", nbin, xID)
        call handle_err(stat)
        stat=nf90_def_dim(ncid,"time", nsteps, tID)
        call handle_err(stat)
81dede1c   Jérémy Baudry   first commit
21

d380ec6c   Jérémy Baudry   second commit
22
23
24
25
26
27
28
29
30
31
32
33
        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)
        stat=nf90_def_var(ncid,"Spectrum",nf90_double,(/ tID, xID, omID /),SpectreID)
        call handle_err(stat)
        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)
81dede1c   Jérémy Baudry   first commit
34

d380ec6c   Jérémy Baudry   second commit
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

        !stat=nf90_put_att(ncid,ID,"units", values)
        stat=nf90_enddef(ncid)
        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)
        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)




stat=nf90_close(ncid)
call handle_err(stat)
        
contains

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
68
69
70
71



end subroutine write_output