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  use scale_const, only: &
129  implicit none
130  !---------------------------------------------------------------------------
131 
132  call prof_rapend( 'Main', 0 )
133 
134  call file_close_all
135 
136  call const_finalize
137 
138  call prof_rapreport
139 
140  ! stop mpi
141  call prc_mpifinish
142 
143  return
144  end subroutine scale_finalize
145 
146 end module scale
scale_precision::sp
integer, parameter, public sp
Definition: scale_precision.F90:31
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:350
scale::scale_finalize
subroutine, public scale_finalize
Finalize.
Definition: scale.F90:123
scale_file::file_close_all
subroutine, public file_close_all(skip_abort)
Definition: scale_file.F90:6287
scale_precision
module PRECISION
Definition: scale_precision.F90:14
scale::scale_init
subroutine, public scale_init(app_name)
Initialization.
Definition: scale.F90:65
scale_prof::prof_rapstart
subroutine, public prof_rapstart(rapname_base, level, disable_barrier)
Start raptime.
Definition: scale_prof.F90:174
scale_prc::prc_mpistart
subroutine, public prc_mpistart(comm)
Start MPI.
Definition: scale_prc.F90:128
scale_file
module file
Definition: scale_file.F90:15
scale_prc
module PROCESS
Definition: scale_prc.F90:11
scale_const::const_finalize
subroutine, public const_finalize
Finalize.
Definition: scale_const.F90:285
scale_precision::rp
integer, parameter, public rp
Definition: scale_precision.F90:41
scale_io::h_mid
integer, parameter, public h_mid
Character length (short=64)
Definition: scale_io.F90:46
scale_io
module STDIO
Definition: scale_io.F90:10
scale_const
module CONSTANT
Definition: scale_const.F90:11
scale_prc::prc_errhandler_setup
subroutine, public prc_errhandler_setup(use_fpm, master)
Setup MPI error handler.
Definition: scale_prc.F90:313
scale_io::io_fid_log
integer, public io_fid_log
Log file ID.
Definition: scale_io.F90:58
scale_io::h_short
integer, parameter, public h_short
Character length (short=16)
Definition: scale_io.F90:45
scale_prof
module profiler
Definition: scale_prof.F90:11
scale_io::h_long
integer, parameter, public h_long
Character length (short=256)
Definition: scale_io.F90:47
scale_precision::dp
integer, parameter, public dp
Definition: scale_precision.F90:32
scale_prof::prof_setup
subroutine, public prof_setup
Definition: scale_prof.F90:107
scale_io::io_l
logical, public io_l
output log or not? (this process)
Definition: scale_io.F90:63
scale_prof::prof_rapend
subroutine, public prof_rapend(rapname_base, level, disable_barrier)
Save raptime.
Definition: scale_prof.F90:246
scale_io::io_fid_nml
integer, public io_fid_nml
Log file ID (only for output namelist)
Definition: scale_io.F90:59
scale_io::io_nml
logical, public io_nml
output log or not? (for namelist, this process)
Definition: scale_io.F90:64
scale_prc::prc_singlecom_setup
subroutine, public prc_singlecom_setup(comm, nprocs, myrank, ismaster)
Setup MPI single communicator (not use universal-global-local setting)
Definition: scale_prc.F90:263
scale_io::io_log_setup
subroutine, public io_log_setup(myrank, is_master)
Setup LOG.
Definition: scale_io.F90:161
scale_prc::prc_mpifinish
subroutine, public prc_mpifinish
Stop MPI peacefully.
Definition: scale_prc.F90:366
scale_io::io_fid_conf
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:57
scale_io::io_setup
subroutine, public io_setup(APPNAME, conf_name, prefix, allow_noconf)
Setup.
Definition: scale_io.F90:99
scale_prof::prof_rapreport
subroutine, public prof_rapreport
Report raptime.
Definition: scale_prof.F90:315
scale
module SCALE
Definition: scale.F90:9
scale_const::const_setup
subroutine, public const_setup
Setup.
Definition: scale_const.F90:128