Line data Source code
1 : ! ***********************************************************************
2 : !
3 : ! Copyright (C) 2010 The MESA Team
4 : !
5 : ! This program is free software: you can redistribute it and/or modify
6 : ! it under the terms of the GNU Lesser General Public License
7 : ! as published by the Free Software Foundation,
8 : ! either version 3 of the License, or (at your option) any later version.
9 : !
10 : ! This program is distributed in the hope that it will be useful,
11 : ! but WITHOUT ANY WARRANTY; without even the implied warranty of
12 : ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 : ! See the GNU Lesser General Public License for more details.
14 : !
15 : ! You should have received a copy of the GNU Lesser General Public License
16 : ! along with this program. If not, see <https://www.gnu.org/licenses/>.
17 : !
18 : ! ***********************************************************************
19 :
20 : module eos_initialize
21 :
22 : implicit none
23 :
24 : contains
25 :
26 15 : subroutine Init_eos( &
27 : eosDT_cache_dir_in, &
28 : use_cache, ierr)
29 : use eos_def
30 : use helm_alloc
31 : use utils_lib, only : mkdir
32 : use const_def, only: mesa_data_dir, mesa_caches_dir, mesa_temp_caches_dir
33 : character(*), intent(IN) :: eosDT_cache_dir_in
34 : logical, intent(in) :: use_cache
35 : integer, intent(OUT) :: ierr ! 0 means AOK.
36 : !integer, parameter :: imax = 261, jmax = 101
37 : ! dimensions of small version of helm table
38 : !integer, parameter :: imax = 1081, jmax = 401
39 : ! dimensions of medium version of helm table; 40 points per decade
40 : integer, parameter :: imax = 2701, jmax = 1001
41 : ! dimensions of large version of helm table; 100 points per decade
42 : ! helm table lives in eosDT_data
43 : character (len=256) :: eosDT_data_dir
44 15 : ierr = 0
45 15 : if (eos_root_is_initialized) return
46 13 : use_cache_for_eos = use_cache
47 13 : eosDT_data_dir = trim(mesa_data_dir) // '/eosDT_data'
48 13 : if (use_cache_for_eos) then
49 12 : if (len_trim(eosDT_cache_dir_in) > 0) then
50 0 : eosDT_cache_dir = eosDT_cache_dir_in
51 12 : else if (len_trim(mesa_caches_dir) > 0) then
52 0 : eosDT_cache_dir = trim(mesa_caches_dir) // '/eosDT_cache'
53 : else
54 12 : eosDT_cache_dir = trim(eosDT_data_dir) // '/cache'
55 : end if
56 12 : call mkdir(eosDT_cache_dir)
57 12 : eosDT_temp_cache_dir = trim(mesa_temp_caches_dir) // '/eosDT_cache'
58 12 : if(use_mesa_temp_cache) call mkdir(eosDT_temp_cache_dir)
59 : end if
60 :
61 13 : call alloc_helm_table(eos_ht, imax, jmax, ierr)
62 13 : if (ierr /= 0) return
63 :
64 : call read_helm_table(eos_ht, &
65 13 : eosDT_data_dir, eosDT_cache_dir, eosDT_temp_cache_dir, use_cache_for_eos, ierr)
66 13 : if (ierr /= 0) return
67 :
68 13 : call eos_def_init
69 : ! replace defaults from eos_def_init by argument
70 :
71 13 : eos_root_is_initialized = .true.
72 :
73 28 : end subroutine Init_eos
74 :
75 : end module eos_initialize
|