main.f90 3.98 KB
Newer Older
Jérémy Baudry's avatar
new  
Jérémy Baudry committed
1 2 3 4 5 6 7 8
!
!_________________________________________________________________________________        
        !DESCRIPTION:
!       This is the main program of WIM. This routine merely calls other
!       subroutines and do the main time loop. It also contains the subroutine
!       progress which display a progress bar in the terminal while the model is
!       running.
!_________________________________________________________________________________
Jérémy Baudry's avatar
Jérémy Baudry committed
9

Jérémy Baudry's avatar
new  
Jérémy Baudry committed
10 11
        !INTERFACE:
        PROGRAM WIM2
Jérémy Baudry's avatar
Jérémy Baudry committed
12

Jérémy Baudry's avatar
new  
Jérémy Baudry committed
13 14
        !MODULE USES:
        use parameters
Jérémy Baudry's avatar
Jérémy Baudry committed
15

Jérémy Baudry's avatar
new  
Jérémy Baudry committed
16
        
17 18 19 20

        
        call message(1)

Jérémy Baudry's avatar
new  
Jérémy Baudry committed
21
        call read_namelist              !read parameters from namelists
22 23
        call message(2)
        
Jérémy Baudry's avatar
new  
Jérémy Baudry committed
24
        call array_allocation           ! allocate memory for arrays
25 26
        call message(3)

Jérémy Baudry's avatar
new  
Jérémy Baudry committed
27
        call initialization             ! initialize the model
28
        call message(4)
Jérémy Baudry's avatar
Jérémy Baudry committed
29

Jérémy Baudry's avatar
Jérémy Baudry committed
30 31 32 33 34
           dirout=trim(root)//trim(name_sim)
        open(25,file='src/tmp.txt')
        write(25,*)trim(dirout)
        close(25)
        call system('src/OUT_DIR.sh')
Jérémy Baudry's avatar
Jérémy Baudry committed
35

Jérémy Baudry's avatar
new  
Jérémy Baudry committed
36 37 38

!________________________________________________________________________________
!                DO THE TIME LOOP
39 40
        
        call message(5)
Jérémy Baudry's avatar
new  
Jérémy Baudry committed
41 42 43 44 45 46 47 48 49 50 51
        do n=2,nsteps

                call progress(n,nsteps)         !display progress bar
                do ii=1,nfreq                   !do advection for each frequency
                                                !band
                        call advection
                end do

                do i=1,nbin                     !spatial calculations

                call attenuation                ! compute spectrum attenuation
52
                                                ! compute floe breaking
Jérémy Baudry's avatar
Jérémy Baudry committed
53 54
                call ice_fracture
                call statistics
Jérémy Baudry's avatar
new  
Jérémy Baudry committed
55
                end do
Jérémy Baudry's avatar
Jérémy Baudry committed
56
        end do
Jérémy Baudry's avatar
new  
Jérémy Baudry committed
57
!______________________OUTPUTS_________________________________________________
Jérémy Baudry's avatar
Jérémy Baudry committed
58
        namefile=trim(root)//trim(name_sim)//'/'//trim(name_sim)//'.nc'
59
        call message(6)
Jérémy Baudry's avatar
new  
Jérémy Baudry committed
60
        call write_output                       ! Write outputs in NETCDF
61
        call message(7)
62 63
        
      
Jérémy Baudry's avatar
Jérémy Baudry committed
64 65 66


contains
Jérémy Baudry's avatar
new  
Jérémy Baudry committed
67
!______________________________________________________________________________
Jérémy Baudry's avatar
Jérémy Baudry committed
68 69 70
subroutine progress(j,jmax)
  implicit none
  integer::j,k,jmax
71 72 73 74 75 76 77 78 79 80 81
  character(len=20)::bar="     processing ???%"
        write(unit=bar(17:19),fmt="(i3)")ceiling((real(j)/real(jmax))*100)
        write(unit=6,fmt="(a1,a22)",advance="no") char(13), bar
        if (real(j)/real(jmax).eq.1) then
        write(unit=6,fmt=*)
        write(*,*)''
        write(*,*)'     simulation completed!'
        write(*,*)''
        write(*,*)'     -------------------------------------------'
        write(*,*)''
        endif
Jérémy Baudry's avatar
Jérémy Baudry committed
82
end subroutine progress
Jérémy Baudry's avatar
new  
Jérémy Baudry committed
83
!_______________________________________________________________________________
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
subroutine message(info)

        implicit none
        integer,intent(in)::info


        if(info.eq.1) then
        write(*,*)'     ___________________________________________'
        write(*,*)'                  Welcome in WIM'
        write(*,*)'     ___________________________________________'
        write(*,*)''
        end if


        if(info.eq.2) then
        write(*,*)'     Read parameters from namelists...       Done!'
        end if

        if(info.eq.3) then
        write(*,*)'     Allocate memory...                      Done!'
        end if

        if(info.eq.4) then
        write(*,*)'     Initialize arrays and variables...      Done!'
        write(*,*)''
        write(*,*)'     --------------------------------------------'
        write(*,*)''
        end if

         if(info.eq.5) then
        write(*,*)'     Time loop starting...'
        write(*,*)''
        end if

        if(info.eq.6) then
        write(*,*)'     Writing NETCDF output file...'
        write(*,*)''
        end if

        if(info.eq.7) then
        write(*,*)'     Done!'
        write(*,*)''
        end if

        






        
end subroutine message
!_______________________________________________________________________________

Jérémy Baudry's avatar
Jérémy Baudry committed
139 140

END PROGRAM WIM2