[92fab65] | 1 | ! SPDX-FileCopyrightText: FLEXPART 1998-2019, see flexpart_license.txt |
---|
| 2 | ! SPDX-License-Identifier: GPL-3.0-or-later |
---|
[332fbbd] | 3 | |
---|
[2eefa58] | 4 | subroutine readpaths |
---|
[e200b7a] | 5 | |
---|
| 6 | !***************************************************************************** |
---|
| 7 | ! * |
---|
| 8 | ! Reads the pathnames, where input/output files are expected to be. * |
---|
| 9 | ! The file pathnames must be available in the current working directory. * |
---|
| 10 | ! * |
---|
| 11 | ! Author: A. Stohl * |
---|
| 12 | ! * |
---|
| 13 | ! 1 February 1994 * |
---|
[f13406c] | 14 | ! last modified * |
---|
| 15 | ! HS, 7.9.2012 * |
---|
| 16 | ! option to give pathnames file as command line option * |
---|
[e200b7a] | 17 | ! * |
---|
| 18 | !***************************************************************************** |
---|
| 19 | ! * |
---|
| 20 | ! Variables: * |
---|
| 21 | ! length(numpath) lengths of the path names * |
---|
| 22 | ! path(numpath) pathnames of input/output files * |
---|
| 23 | ! * |
---|
| 24 | ! Constants: * |
---|
| 25 | ! numpath number of pathnames to be read in * |
---|
| 26 | ! * |
---|
| 27 | !***************************************************************************** |
---|
| 28 | |
---|
| 29 | use par_mod |
---|
| 30 | use com_mod |
---|
| 31 | |
---|
| 32 | implicit none |
---|
| 33 | |
---|
[f13406c] | 34 | integer :: i |
---|
| 35 | character(256) :: string_test |
---|
| 36 | character(1) :: character_test |
---|
[e200b7a] | 37 | |
---|
| 38 | ! Read the pathname information stored in unitpath |
---|
| 39 | !************************************************* |
---|
| 40 | |
---|
[f13406c] | 41 | open(unitpath,file=trim(pathfile),status='old',err=999) |
---|
[e200b7a] | 42 | |
---|
| 43 | do i=1,numpath |
---|
| 44 | read(unitpath,'(a)',err=998) path(i) |
---|
| 45 | length(i)=index(path(i),' ')-1 |
---|
[f13406c] | 46 | |
---|
| 47 | |
---|
| 48 | string_test = path(i) |
---|
| 49 | character_test = string_test(length(i):length(i)) |
---|
[8a65cb0] | 50 | !print*, 'character_test, string_test ', character_test, string_test |
---|
| 51 | if ((character_test .NE. '/') .AND. (i .LT. 4)) then |
---|
| 52 | print*, 'WARNING: path not ending in /' |
---|
[f13406c] | 53 | print*, path(i) |
---|
| 54 | path(i) = string_test(1:length(i)) // '/' |
---|
| 55 | length(i)=length(i)+1 |
---|
| 56 | print*, 'fix: padded with /' |
---|
| 57 | print*, path(i) |
---|
[8a65cb0] | 58 | print*, 'length(i) increased 1' |
---|
[f13406c] | 59 | endif |
---|
[8a65cb0] | 60 | end do |
---|
[e200b7a] | 61 | |
---|
| 62 | ! Check whether any nested subdomains are to be used |
---|
| 63 | !*************************************************** |
---|
| 64 | |
---|
| 65 | do i=1,maxnests |
---|
[62e65c7] | 66 | ! ESO 2016 Added 'end'/'err' in case user forgot '====' at end of file and |
---|
| 67 | ! maxnests > numbnests |
---|
| 68 | read(unitpath,'(a)', end=30, err=30) path(numpath+2*(i-1)+1) |
---|
| 69 | read(unitpath,'(a)', end=30, err=30) path(numpath+2*(i-1)+2) |
---|
[e200b7a] | 70 | if (path(numpath+2*(i-1)+1)(1:5).eq.'=====') goto 30 |
---|
| 71 | length(numpath+2*(i-1)+1)=index(path(numpath+2*(i-1)+1),' ')-1 |
---|
| 72 | length(numpath+2*(i-1)+2)=index(path(numpath+2*(i-1)+2),' ')-1 |
---|
| 73 | end do |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | ! Determine number of available nested domains |
---|
| 77 | !********************************************* |
---|
| 78 | |
---|
| 79 | 30 numbnests=i-1 |
---|
| 80 | |
---|
| 81 | close(unitpath) |
---|
| 82 | return |
---|
| 83 | |
---|
| 84 | 998 write(*,*) ' #### TRAJECTORY MODEL ERROR! ERROR WHILE #### ' |
---|
| 85 | write(*,*) ' #### READING FILE PATHNAMES. #### ' |
---|
| 86 | stop |
---|
| 87 | |
---|
| 88 | 999 write(*,*) ' #### TRAJECTORY MODEL ERROR! FILE "pathnames"#### ' |
---|
| 89 | write(*,*) ' #### CANNOT BE OPENED IN THE CURRENT WORKING #### ' |
---|
| 90 | write(*,*) ' #### DIRECTORY. #### ' |
---|
| 91 | stop |
---|
| 92 | |
---|
| 93 | end subroutine readpaths |
---|