Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/elmerice/UserFunctions/USF_proj.F90
3196 views
1
!/*****************************************************************************/
2
! *
3
! * Elmer, A Finite Element Software for Multiphysical Problems
4
! *
5
! * Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland
6
! *
7
! * This library is free software; you can redistribute it and/or
8
! * modify it under the terms of the GNU Lesser General Public
9
! * License as published by the Free Software Foundation; either
10
! * version 2.1 of the License, or (at your option) any later version.
11
! *
12
! * This library is distributed in the hope that it will be useful,
13
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
! * Lesser General Public License for more details.
16
! *
17
! * You should have received a copy of the GNU Lesser General Public
18
! * License along with this library (in file ../LGPL-2.1); if not, write
19
! * to the Free Software Foundation, Inc., 51 Franklin Street,
20
! * Fifth Floor, Boston, MA 02110-1301 USA
21
! *
22
! *****************************************************************************/
23
!
24
!/******************************************************************************
25
! *
26
! * Authors: fabien Gillet-Chaulet
27
! * Email: [email protected]
28
! * Web: http://elmerice.elmerfem.org
29
! *
30
! * Original Date: 3 May 2022
31
! *
32
! ******************************************************************************/
33
!--------------------------------------------------------------------------------
34
!> Generic ElmerIce user function for geographic projections
35
!> Use ProjUtils in under elmerice/Utils
36
!--------------------------------------------------------------------------------
37
FUNCTION xy2Lon(Model,nodenumber,VarIn) RESULT(VarOut)
38
USE ProjUtils
39
implicit none
40
!-----------------
41
TYPE(Model_t) :: Model
42
INTEGER :: nodenumber
43
REAL(kind=dp) :: VarIn(2) !x,y
44
REAL(kind=dp) :: VarOut !Longitude
45
REAL(kind=dp) :: x,y,Lon,Lat
46
47
x=VarIn(1)
48
y=VarIn(2)
49
CALL xy2LonLat(x,y,Lon,Lat)
50
VarOut=Lon
51
52
End FUNCTION xy2Lon
53
54
FUNCTION xy2Lat(Model,nodenumber,VarIn) RESULT(VarOut)
55
USE ProjUtils
56
implicit none
57
!-----------------
58
TYPE(Model_t) :: Model
59
INTEGER :: nodenumber
60
REAL(kind=dp) :: VarIn(2) !x,y
61
REAL(kind=dp) :: VarOut !Latitude
62
REAL(kind=dp) :: x,y,Lon,Lat
63
64
x=VarIn(1)
65
y=VarIn(2)
66
CALL xy2LonLat(x,y,Lon,Lat)
67
VarOut=Lat
68
69
End FUNCTION xy2Lat
70
71
FUNCTION LonLat2x(Model,nodenumber,VarIn) RESULT(VarOut)
72
USE ProjUtils
73
implicit none
74
!-----------------
75
TYPE(Model_t) :: Model
76
INTEGER :: nodenumber
77
REAL(kind=dp) :: VarIn(2) !Lon,Lat
78
REAL(kind=dp) :: VarOut ! x
79
REAL(kind=dp) :: x,y,Lon,Lat
80
81
Lon=VarIn(1)
82
Lat=VarIn(2)
83
CALL LonLat2xy(Lon,Lat,x,y)
84
VarOut=x
85
86
End FUNCTION LonLat2x
87
88
FUNCTION LonLat2y(Model,nodenumber,VarIn) RESULT(VarOut)
89
USE ProjUtils
90
implicit none
91
!-----------------
92
TYPE(Model_t) :: Model
93
INTEGER :: nodenumber
94
REAL(kind=dp) :: VarIn(2) !Lon,Lat
95
REAL(kind=dp) :: VarOut !y
96
REAL(kind=dp) :: x,y,Lon,Lat
97
98
Lon=VarIn(1)
99
Lat=VarIn(2)
100
CALL LonLat2xy(Lon,Lat,x,y)
101
VarOut=y
102
103
End FUNCTION LonLat2y
104
105