SCALE-RM
scale.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
8 #include "scalelib.h"
9 module scale
10  !-----------------------------------------------------------------------------
11  !
12  !++ used modules
13  !
14  use scale_precision
15  use scale_io
16  use scale_prof
17 
18  use scale_prc, only: &
19  prc_abort
20  !-----------------------------------------------------------------------------
21  implicit none
22  private
23  !-----------------------------------------------------------------------------
24  !
25  !++ Public procedure
26  !
27  public :: scale_init
28  public :: scale_finalize
29 
30  ! from scale_process
31  public :: prc_abort
32 
33  !-----------------------------------------------------------------------------
34  !
35  !++ Public parameters & variables
36  !
37  ! from scale_precision
38  public :: rp
39  public :: dp
40  public :: sp
41 
42  ! from scale_io
43  public :: h_short
44  public :: h_mid
45  public :: h_long
46  public :: io_fid_conf
47  public :: io_fid_log
48  public :: io_fid_nml
49  public :: io_l
50  public :: io_nml
51  !-----------------------------------------------------------------------------
52  !
53  !++ Private procedure
54  !
55  !-----------------------------------------------------------------------------
56  !
57  !++ Private parameters & variables
58  !
59  !-----------------------------------------------------------------------------
60 contains
61  !-----------------------------------------------------------------------------
63  subroutine scale_init( &
64  app_name )
65  use scale_prc, only: &
66  prc_mpistart, &
69  use scale_const, only: &
71  implicit none
72 
73  character(len=*), optional :: app_name
74 
75  character(len=H_SHORT) :: name
76 
77  ! for prc setup
78  integer :: comm
79  integer :: nprocs
80  integer :: myrank
81  logical :: ismaster
82  !---------------------------------------------------------------------------
83 
84  if ( present(app_name) ) then
85  name = app_name
86  else
87  name = "SCALE APPLICATION"
88  end if
89 
90  ! start MPI
91  call prc_mpistart( comm ) ! [OUT]
92 
93  ! setup MPI communicator
94  call prc_singlecom_setup( comm, & ! [IN]
95  nprocs, & ! [OUT]
96  myrank, & ! [OUT]
97  ismaster ) ! [OUT]
98 
99  ! setup errhandler
100  call prc_errhandler_setup( .false., & ! [IN]
101  ismaster ) ! [IN]
102 
103  ! setup scale_io
104  call io_setup( name, allow_noconf = .true. )
105 
106  ! setup log
107  call io_log_setup( myrank, ismaster )
108 
109  ! setup profiler
110  call prof_setup
111 
112  ! setup constants
113  call const_setup
114 
115  call prof_rapstart( 'Main', 0 )
116 
117  return
118  end subroutine scale_init
119 
120  !-----------------------------------------------------------------------------
122  subroutine scale_finalize
123  use scale_file, only: &
125  use scale_prc, only: &
127  implicit none
128  !---------------------------------------------------------------------------
129 
130  call prof_rapend( 'Main', 0 )
131 
132  call file_close_all
133 
134  call prof_rapreport
135 
136  ! stop mpi
137  call prc_mpifinish
138 
139  return
140  end subroutine scale_finalize
141 
142 end module scale
subroutine, public file_close_all(skip_abort)
subroutine, public prof_setup
Definition: scale_prof.F90:103
subroutine, public prc_mpistart(comm)
Start MPI.
Definition: scale_prc.F90:121
integer, public io_fid_nml
Log file ID (only for output namelist)
Definition: scale_io.F90:57
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:55
integer, parameter, public h_mid
Character length (short=64)
Definition: scale_io.F90:44
module file
Definition: scale_file.F90:15
logical, public io_l
output log or not? (this process)
Definition: scale_io.F90:61
module PROCESS
Definition: scale_prc.F90:11
subroutine, public const_setup
Setup.
subroutine, public scale_init(app_name)
Initialization.
Definition: scale.F90:65
subroutine, public prc_singlecom_setup(comm, nprocs, myrank, ismaster)
Setup MPI single communicator (not use universal-global-local setting)
Definition: scale_prc.F90:252
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:338
subroutine, public scale_finalize
Finalize.
Definition: scale.F90:123
module CONSTANT
Definition: scale_const.F90:11
subroutine, public io_setup(APPNAME, conf_name, allow_noconf)
Setup.
Definition: scale_io.F90:87
integer, parameter, public h_short
Character length (short=16)
Definition: scale_io.F90:43
subroutine, public prof_rapstart(rapname_base, level)
Start raptime.
Definition: scale_prof.F90:157
module profiler
Definition: scale_prof.F90:11
subroutine, public prc_errhandler_setup(use_fpm, master)
Setup MPI error handler.
Definition: scale_prc.F90:301
integer, parameter, public h_long
Character length (short=256)
Definition: scale_io.F90:45
subroutine, public prc_mpifinish
Stop MPI peacefully.
Definition: scale_prc.F90:354
module PRECISION
subroutine, public io_log_setup(myrank, is_master)
Setup LOG.
Definition: scale_io.F90:142
module SCALE
Definition: scale.F90:9
integer, parameter, public sp
logical, public io_nml
output log or not? (for namelist, this process)
Definition: scale_io.F90:62
module STDIO
Definition: scale_io.F90:10
subroutine, public prof_rapend(rapname_base, level)
Save raptime.
Definition: scale_prof.F90:210
integer, public io_fid_log
Log file ID.
Definition: scale_io.F90:56
integer, parameter, public rp
integer, parameter, public dp
subroutine, public prof_rapreport
Report raptime.
Definition: scale_prof.F90:258