main.F90 4.79 KB
Newer Older
gotm's avatar
gotm committed
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
#include "cppdefs.h"
!!-----------------------------------------------------------------------
!!BOI
!!
!! !TITLE: Documentation of getm
!!
!! !AUTHORS: Hans Burchard and Karsten Bolding
!!
!! !DATE:
!!
!! !INTRODUCTION:
!!
!!EOI
!-----------------------------------------------------------------------
!BOP
!
! !ROUTINE: getm - main program
!
! !INTERFACE:
   program getm
!
! !DESCRIPTION:
!
! !USES:
   use initialise, only: init_model,runtype,dryrun
kbk's avatar
kbk committed
26 27 28
   use time, only: simtime
   use domain, only: calc_points
   use m2d, only: mem2d
bjb's avatar
bjb committed
29
   use getm_timers, only: write_getm_timers
kbk's avatar
kbk committed
30
#ifndef NO_3D
kbk's avatar
kbk committed
31
   use m3d, only: mem3d
kbk's avatar
kbk committed
32
#endif
gotm's avatar
gotm committed
33
   use integration
34 35 36
#ifdef GETM_PARALLEL
   use halo_mpi, only: all_2d_exchange, all_3d_exchange
#endif
gotm's avatar
gotm committed
37 38 39 40 41 42
   IMPLICIT NONE
!
! !REVISION HISTORY:
!  Original author(s): Karsten Bolding & Hans Burchard
!
! ! LOCAL VARIABLES
kbk's avatar
kbk committed
43 44 45 46
   character(len=8)          :: datestr
   character(len=10)         :: timestr
   real                      :: t1=-1,t2=-1,secs
   integer                   :: ierr
gotm's avatar
gotm committed
47 48 49
!EOP
!-----------------------------------------------------------------------
!BOC
50 51
   call cmdline

gotm's avatar
gotm committed
52 53 54 55 56
#ifdef FORTRAN95
   call CPU_Time(t1)
#endif
   call Date_And_Time(datestr,timestr)

kbk's avatar
kbk committed
57
   call init_model(datestr,timestr)
gotm's avatar
gotm committed
58 59 60
   if ( .not. dryrun ) then
      call time_loop(runtype)
   end if
61
   call clean_up(dryrun,runtype,MaxN)
gotm's avatar
gotm committed
62 63 64 65 66 67 68 69

#ifdef FORTRAN95
   call CPU_Time(t2)
#endif
   call Date_And_Time(datestr,timestr)
   secs = t2-t1
   STDERR LINE
   if( dryrun ) then
70
      LEVEL1 'getm just did a dry run'
gotm's avatar
gotm committed
71 72 73
      LEVEL1 'Number of calc-points: ',Calc_Points
      LEVEL1 'Space requirements (global 2D and 3D arrays):'
      LEVEL2 '2D: ',mem2d/1024,' kbytes'
kbk's avatar
kbk committed
74 75
#ifndef NO_3D
      if(runtype .ge. 2) then
gotm's avatar
gotm committed
76 77
         LEVEL2 '3D: ',mem3d/1024,' kbytes'
      end if
kbk's avatar
kbk committed
78
#endif
gotm's avatar
gotm committed
79
   else
80
      LEVEL1 'getm: Completed on ',datestr,' ',timestr
gotm's avatar
gotm committed
81 82
      LEVEL1 'Memory used (global 2D and 3D arrays):'
      LEVEL2 '2D: ',mem2d/1024,' kbytes'
kbk's avatar
kbk committed
83 84
#ifndef NO_3D
      if(runtype .ge. 2) then
gotm's avatar
gotm committed
85 86
         LEVEL2 '3D: ',mem3d/1024,' kbytes'
      end if
kbk's avatar
kbk committed
87
#endif
88
      LEVEL1 'Total CPU-time was:    ',secs,' seconds'
gotm's avatar
gotm committed
89 90
      LEVEL1 'Number of time steps:  ',MaxN-MinN+1
      LEVEL1 'Number of calc-points: ',Calc_Points
91
      if(MaxN-MinN+1 .gt. _ZERO_) then
gotm's avatar
gotm committed
92 93 94
         LEVEL1 'CPU-time/calc-point:   ',secs/(MaxN-MinN+1)/Calc_Points,' seconds'
         LEVEL1 'Sim-time/CPU-time:     ',simtime/secs
      end if
bjb's avatar
bjb committed
95 96 97
#ifndef NO_TIMERS
      STDERR LINE
      call write_getm_timers
98
#endif
gotm's avatar
gotm committed
99 100
   endif
   STDERR LINE
101 102 103 104 105 106
#ifdef GETM_PARALLEL
   LEVEL1 "Communication with other sub-domains:"
   LEVEL2 "2D data exchange: ",all_2d_exchange/(1024*1024)," MB"
   LEVEL2 "3D data exchange: ",all_3d_exchange/(1024*1024)," MB"
   STDERR LINE
#endif
Karsten Bolding's avatar
Karsten Bolding committed
107
   LEVEL1 'Copyright (C) Karsten Bolding and Hans Burchard.'
gotm's avatar
gotm committed
108 109 110
   LEVEL1 'under the General Public License (GPL) - http://www.gnu.org '
   STDERR LINE

Knut's avatar
Knut committed
111
   !call compilation_options
gotm's avatar
gotm committed
112 113 114 115

   end program getm

!EOC
116

gotm's avatar
gotm committed
117
!-----------------------------------------------------------------------
118 119 120 121 122
   subroutine cmdline
   use initialise, only: dryrun
   IMPLICIT NONE
   character(len=64)    :: arg
   integer              :: i
gotm's avatar
gotm committed
123

124 125 126 127 128 129 130
   if (command_argument_count() .eq. 0) return

   do i = 1, command_argument_count()
      call get_command_argument(i, arg)

      select case (arg)
      case ('-v', '--version')
131 132
         LEVEL0 'GETM www.getm.eu'
         call print_version()
133 134
         stop
      case ('-c', '--compile')
135 136 137
         LEVEL0 'GETM www.getm.eu'
         call print_version()
         call compilation_options()
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
         LEVEL0
         stop
      case ('-h', '--help')
         call print_help()
         stop
!KB      case ('--dryrun')
!KB         dryrun=.true.
      case default
         LEVEL0
         LEVEL0 'Unrecognized command-line option: ', arg
         LEVEL0
         call print_help()
         stop
      end select
   end do
   return
   end
gotm's avatar
gotm committed
155

156 157
!-----------------------------------------------------------------------
   subroutine print_help()
Karsten Bolding's avatar
Karsten Bolding committed
158 159 160 161 162
     character(len=255) :: cmd
     call get_command_argument(0, cmd)

     print '(a)', ''
     print '(a,a,a)', 'usage: ',trim(cmd),' [OPTIONS]'
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
     print '(a)', ''
     print '(a)', 'Without any options, getm will continue execution.'
     print '(a)', ''
     print '(a)', 'cmdline options:'
     print '(a)', ''
     print '(a)', '  -v, --version     print version information and exit'
     print '(a)', '  -c, --compile     print compilation options'
     print '(a)', '  -h, --help        print usage information and exit'
     print '(a)', ''
     print '(a)', 'visit getm.eu for further info'
     print '(a)', 'consider subscribing to getm-users@googlegroups.com'
     print '(a)', ''
  end subroutine print_help

!-----------------------------------------------------------------------
! Copyright (C) 2001 - Hans Burchard and Karsten Bolding               !
!-----------------------------------------------------------------------