main.f90 3.98 KB
!
!_________________________________________________________________________________        
        !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.
!_________________________________________________________________________________

        !INTERFACE:
        PROGRAM WIM2

        !MODULE USES:
        use parameters

        

        
        call message(1)

        call read_namelist              !read parameters from namelists
        call message(2)
        
        call array_allocation           ! allocate memory for arrays
        call message(3)

        call initialization             ! initialize the model
        call message(4)

           dirout=trim(root)//trim(name_sim)
        open(25,file='src/tmp.txt')
        write(25,*)trim(dirout)
        close(25)
        call system('src/OUT_DIR.sh')


!________________________________________________________________________________
!                DO THE TIME LOOP
        
        call message(5)
        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
                                                ! compute floe breaking
                call ice_fracture
                call statistics
                end do
        end do
!______________________OUTPUTS_________________________________________________
        namefile=trim(root)//trim(name_sim)//'/'//trim(name_sim)//'.nc'
        call message(6)
        call write_output                       ! Write outputs in NETCDF
        call message(7)
        
      


contains
!______________________________________________________________________________
subroutine progress(j,jmax)
  implicit none
  integer::j,k,jmax
  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
end subroutine progress
!_______________________________________________________________________________
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
!_______________________________________________________________________________


END PROGRAM WIM2