main.f90 2.23 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 read_namelist              !read parameters from namelists
        call array_allocation           ! allocate memory for arrays
        call initialization             ! initialize the model



!________________________________________________________________________________
!                DO THE TIME LOOP

        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 floe_breaking
                call fsd_build
                end do
        end do
!______________________OUTPUTS_________________________________________________

        namefile=trim(root)//trim(name_sim)//'.nc'
        call write_output                       ! Write outputs in NETCDF
        
      


contains
!______________________________________________________________________________
subroutine progress(j,jmax)
  implicit none
  integer::j,k,jmax
  character(len=15)::bar="processing ???%"
  write(unit=bar(12:14),fmt="(i3)")ceiling((real(j)/real(jmax))*100)
  write(unit=6,fmt="(a1,a17)",advance="no") char(13), bar
  if (ceiling((real(j)/real(jmax))*100).eq.100) then
  write(unit=6,fmt=*)
  write(*,*)'simulation completed!'
  
  endif
end subroutine progress
!_______________________________________________________________________________

END PROGRAM WIM2