Se ha incluido el Hamiltoniano en la base de Chuang. Ademas los perfiles de las
[ptslat.git] / aux_proc.f90
blob40378191f4023fd82c49c17ce129f5fa8c1048c7
2 MODULE Auxiliar_Procedures
4 INTEGER, SAVE :: AISO !AISO=0, Anisotropic EZZ and ESUM
5 INTEGER, SAVE :: MTYPE !MTYPE: 1-> ZBI, 2-> WZI, 3-> WZA
7 CONTAINS
9 SUBROUTINE Param_Var(Ind_Par,Dep_Par,Step,Relation)
10 IMPLICIT NONE
12 REAL, INTENT(INOUT) :: Ind_Par
13 REAL, OPTIONAL, INTENT(INOUT) :: Dep_Par
14 REAL, INTENT(IN) :: Step
15 CHARACTER (LEN = * ), INTENT(IN) :: Relation
18 SELECT CASE (TRIM(Relation))
20 CASE('Single')
22 Ind_Par = Ind_Par + Step
23 CASE('Ratio')
25 IF(.NOT. PRESENT(Dep_Par) ) THEN
26 write(6,*)"Box_Size error. Optional argument Dep_Par Needed!"
27 STOP
28 END IF
29 Dep_Par = Dep_Par/Ind_Par * (Ind_Par+Step)
30 Ind_Par = Ind_Par + Step
32 CASE('Both')
34 IF(.NOT. PRESENT(Dep_Par) ) THEN
35 write(6,*)"Box_Size error. Optional argument Dep_Par Needed!"
36 STOP
37 END IF
38 Dep_Par = Dep_Par + Step
39 Ind_Par = Ind_Par + Step
41 END SELECT
43 RETURN
45 END SUBROUTINE Param_Var
48 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
49 ! Integration: Simpson's method (version REAL) !
50 ! NX mus be even !
51 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
53 REAL FUNCTION RSIMPSON(F,XINC,NX)
54 IMPLICIT NONE
56 !!!!! variables 'dummy' y variables internas !!!!!!!!!!!!!!!!!!!!!!!!!!!
58 INTEGER NX,I
59 REAL F(0:NX),XINC
61 RSIMPSON = 0.E0
62 DO I = 1,NX-1,2
63 RSIMPSON = RSIMPSON+F(I)
64 END DO
66 RSIMPSON = 2.E0*RSIMPSON
68 DO I = 2,NX-2,2
69 RSIMPSON = RSIMPSON+F(I)
70 END DO
72 RSIMPSON = 2.E0*RSIMPSON+F(0)+F(NX)
73 RSIMPSON = XINC*RSIMPSON/3.E0
75 RETURN
76 END FUNCTION RSIMPSON
79 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
80 ! Kronecker's delta !
81 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
83 INTEGER FUNCTION IDELTA(I,J)
84 IMPLICIT NONE
86 !!!!! 'dummy' and local variables !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
88 INTEGER I,J
90 IDELTA = 0
91 IF (I.EQ.J) THEN
92 IDELTA = 1
93 END IF
94 RETURN
95 END FUNCTION IDELTA
97 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
99 ! Internal subroutine - checks error status after each netcdf, prints out text message each time
100 ! an error code is returned.
101 SUBROUTINE check(status)
102 USE NETCDF, ONLY: nf90_noerr, nf90_strerror
103 integer, intent ( in) :: status
105 if(status /= nf90_noerr) then
106 print *, trim(nf90_strerror(status))
107 end if
108 END SUBROUTINE check
110 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
111 !! !!
112 !! Subrutina para cambiar el nombre de un archivo existente y asi evitar !!
113 !! sobrescribirlo. !!
114 !! !!
115 !! ARCH: cadena con el nombre de archivo original. !!
116 !! Mira la longitud de la variable por si admite un contador de cuatro !!
117 !! digitos "_XXX". Si lo admite le añade al nombre de archivo ese contador. !!
118 !! Si no lo admite sustrae un caracter y le añade un contador simple "X". !!
119 !! !!
120 !! Ver: 1.0 Date: 17/04/03 !!
121 !! !!
122 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
124 SUBROUTINE OPEN_OVER(ARCH)
125 IMPLICIT NONE
127 CHARACTER (LEN=*) :: ARCH
128 CHARACTER (LEN=120) :: ARCH_TMP
129 LOGICAL :: EX_FILE
130 INTEGER :: I
132 INQUIRE(FILE=TRIM(ARCH),EXIST=EX_FILE)
133 IF (.NOT.EX_FILE) RETURN
135 IF(LEN(ARCH).LT.(LEN_TRIM(ARCH)+4)) THEN
137 DO WHILE (.TRUE.)
139 WRITE(ARCH_TMP,'(A,I1)')ARCH(1:LEN(ARCH)-1),I
140 INQUIRE(FILE=TRIM(ARCH_TMP),EXIST=EX_FILE)
141 IF (.NOT.EX_FILE) THEN
142 ARCH=TRIM(ARCH_TMP)
143 WRITE(0,*)"Error. Trying to overwrite a file"
144 WRITE(0,'(T5,A,A)')"FILE NAME CHANGED TO: ",TRIM(ARCH)
145 EXIT
146 ELSE
147 I=I+1
148 ENDIF
150 END DO
151 END IF
154 DO WHILE (.TRUE.)
156 WRITE(ARCH_TMP,'(A,"_",I3.3)')TRIM(ARCH),I
157 INQUIRE(FILE=TRIM(ARCH_TMP),EXIST=EX_FILE)
158 IF (.NOT.EX_FILE) THEN
159 ARCH=TRIM(ARCH_TMP)
160 WRITE(0,*)"Error. Trying to overwrite a file"
161 WRITE(0,'(T5,A,A)')"FILE NAME CHANGED TO: ",TRIM(ARCH)
162 EXIT
163 ELSE
164 I=I+1
165 ENDIF
167 END DO
169 RETURN
171 END SUBROUTINE OPEN_OVER
173 END MODULE Auxiliar_Procedures