From f3fb6b733fff899c512e2d6f0c58ff4c9072777c Mon Sep 17 00:00:00 2001
From: Evgeny Mortikov <evgeny.mortikov@gmail.com>
Date: Sun, 17 Dec 2023 21:38:45 +0300
Subject: [PATCH] major code update

---
 COMP_DRAG.txt                                 |  7 ---
 DRAG.F                                        |  4 +-
 compile.sh                                    |  8 +++
 compile2.sh                                   | 10 ----
 inputdata.f90                                 | 30 -----------
 makefile                                      | 20 ++++---
 sfx_esm.f90 => srcF/sfx_esm.f90               |  0
 sfx_esm_param.f90 => srcF/sfx_esm_param.f90   |  0
 sfx_main.f90 => srcF/sfx_main.f90             | 54 ++++---------------
 sfx_phys_const.f90 => srcF/sfx_phys_const.f90 |  0
 10 files changed, 30 insertions(+), 103 deletions(-)
 delete mode 100644 COMP_DRAG.txt
 create mode 100755 compile.sh
 delete mode 100755 compile2.sh
 delete mode 100644 inputdata.f90
 rename sfx_esm.f90 => srcF/sfx_esm.f90 (100%)
 rename sfx_esm_param.f90 => srcF/sfx_esm_param.f90 (100%)
 rename sfx_main.f90 => srcF/sfx_main.f90 (70%)
 rename sfx_phys_const.f90 => srcF/sfx_phys_const.f90 (100%)

diff --git a/COMP_DRAG.txt b/COMP_DRAG.txt
deleted file mode 100644
index 0dd43a3..0000000
--- a/COMP_DRAG.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-fort -c inputdata.f90
-ifort -c param.f90
-ifort -c prmt.f90
-ifort -c drag3.F 
-ifort -c DRAG.F
-ifort -o drag.exe DRAG.o drag3.o inputdata.o param.o prmt.o 
-
diff --git a/DRAG.F b/DRAG.F
index 439623c..4d0d594 100644
--- a/DRAG.F
+++ b/DRAG.F
@@ -1,5 +1,7 @@
       PROGRAM DRAG
-      USE INPUTDATA
+      !USE INPUTDATA
+      REAL, DIMENSION(6) :: AR1
+      REAL, DIMENSION(11) :: AR2
       USE PARAM
       open (1, file= '2016_inp.txt', status ='old')
       open (2, file='2016_outDRAG.txt', status='new')
diff --git a/compile.sh b/compile.sh
new file mode 100755
index 0000000..f0c5bf9
--- /dev/null
+++ b/compile.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+gfortran -c -cpp -Wuninitialized srcF/sfx_phys_const.f90
+gfortran -c -cpp -Wuninitialized srcF/sfx_esm_param.f90
+gfortran -c -cpp -Wuninitialized srcF/sfx_esm.f90
+gfortran -c -cpp -Wuninitialized srcF/sfx_main.f90
+gfortran -o sfx.exe sfx_main.o sfx_esm.o sfx_esm_param.o sfx_phys_const.o
+rm *.o *.mod
diff --git a/compile2.sh b/compile2.sh
deleted file mode 100755
index 0e6d889..0000000
--- a/compile2.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-
-rm drag_ddt.exe *.o
-gfortran -c -cpp -Wuninitialized inputdata.f90
-gfortran -c -cpp -Wuninitialized sfx_phys_const.f90
-gfortran -c -cpp -Wuninitialized sfx_esm_param.f90
-gfortran -c -cpp -Wuninitialized sfx_esm.f90
-gfortran -c -Wuninitialized sfx_main.f90
-gfortran -o drag_ddt.exe sfx_main.o sfx_esm.o inputdata.o sfx_esm_param.o sfx_phys_const.o
-
diff --git a/inputdata.f90 b/inputdata.f90
deleted file mode 100644
index 1e9a006..0000000
--- a/inputdata.f90
+++ /dev/null
@@ -1,30 +0,0 @@
-module INPUTDATA
-   REAl, DIMENSION (6) :: AR1
-   REAl, DIMENSION (11) :: AR2
-   INTEGER, PARAMETER :: TEST=1 ! probably IT before renaming
-   !INTEGER nums,ioer,mk
-   !REAL HFX, MFX, zL, betta
-   !REAL U, T4,c0,c4, T1,H,z0h
-   !REAL ws, deltaT, semisumT, D00, Z0, ZT, deltaQ
-   !REAL R6,R1
-   !REAL AN5, Y10, X10, P1, P0
-
-!C*====================================================================
-!C*     .....DEFENITION OF DRAG AND HEAT EXCHANGE COEFFICIENTS......  =
-!C*     DETAILS OF ALGORITM ARE GIVEN IN:                             =
-!C*     A.L.KAZAKOV,V.N.LYKOSSOV,"TRUDY ZAP.SIB.NII",1982,N.55,3-20   =
-!C*                    INPUT DATA:
-!C*     AR1(1) - ABS(WIND VELOCITY) AT CONSTANT FLUX LAYER            =
-!C*                                 (CFL) HIGHT (M/S)                 =
-!C*     AR1(2) - DIFFERENCE BETWEEN POTENTIAL TEMPERATURE AT CFL HIGHT=
-!C!*                             AND AT SURFACE  ( DEG. K)             =
-!C*     AR1(3) - SEMI-SUM OF POTENTIAL TEMPERATURE AT CFL HIGHT AND   =
-!C*                             AND AT SURFACE  ( DEG. K)             =
-!C*     AR1(4) - DIFFERENCE BETWEEN HUMIDITY AT CFL HIGHT             =
-!C*                             AND A SURFACE   ( GR/GR )             =
-!C*     AR1(5) - CFL HIGHT ( M )                                      =
-!C*     AR1(6) - ROUGHNESS OF SURFACE ( M ); FOR SEA SURFACE PUT -1   =
-!C*      IT    - NUMBER OF ITERATIONS                                 =
-!C*====================================================================      
-
-end module INPUTDATA
\ No newline at end of file
diff --git a/makefile b/makefile
index bd4ab1b..4a0e47b 100644
--- a/makefile
+++ b/makefile
@@ -1,6 +1,6 @@
-RUN = sfx
+RUN = sfx.exe
 COMPILER ?= gnu
-FC_KEYS ?= 
+FC_KEYS ?= -cpp -Wuninitialized
 
 # set compiler
 ifeq ($(COMPILER),intel)
@@ -10,20 +10,18 @@ ifeq ($(COMPILER),gnu)
   FC = gfortran
 endif 
 
-OBJ_F90 = sfx_phys_const.o sfx_esm_param.o sfx_esm.o
-OBJ_F = DRAG.o drag3.o
+OBJ_F90 = sfx_phys_const.o sfx_esm_param.o sfx_esm.o sfx_main.o
+OBJ_F =
 OBJ = $(OBJ_F90) $(OBJ_F)
 
 $(RUN): $(OBJ)
 	$(FC) $(FC_KEYS) $(OBJ) -o $(RUN)
 
-$(OBJ_F90): %.o: %.f90
-	$(FC) $(FC_KEYS) -o $@ -c $<
+$(OBJ_F90): %.o: srcF/%.f90
+	$(FC) $(FC_KEYS) -cpp -o $@ -c $<
 
-$(OBJ_F): %.o: %.F
-	$(FC) $(FC_KEYS) -o $@ -c $<
+$(OBJ_F): %.o: srcF/%.F
+	$(FC) $(FC_KEYS) -cpp -o $@ -c $<
 
 clean: 
-	rm -f $(OBJ) $(RUN)
-
-
+	rm -f $(OBJ) $(RUN) *.mod
diff --git a/sfx_esm.f90 b/srcF/sfx_esm.f90
similarity index 100%
rename from sfx_esm.f90
rename to srcF/sfx_esm.f90
diff --git a/sfx_esm_param.f90 b/srcF/sfx_esm_param.f90
similarity index 100%
rename from sfx_esm_param.f90
rename to srcF/sfx_esm_param.f90
diff --git a/sfx_main.f90 b/srcF/sfx_main.f90
similarity index 70%
rename from sfx_main.f90
rename to srcF/sfx_main.f90
index 40ac4b8..3c0eb26 100644
--- a/sfx_main.f90
+++ b/srcF/sfx_main.f90
@@ -1,15 +1,17 @@
-   PROGRAM main_ddt
+PROGRAM main_ddt
 
     use sfx_phys_const
-    USE sfx_esm_param
-    USE inputdata
-	USE sfx_esm
+    use sfx_esm_param
+    use sfx_esm
 
-    type (meteoDataType):: data_in1
-       
-	type (sfxDataType) :: data_outdef1
+    integer, parameter :: test = 1
 
-	type (numericsType) :: data_par1
+
+    type(meteoDataType):: data_in1
+    type(meteoDataVecType) :: meteo
+	type(sfxDataType) :: data_outdef1
+    type(sfxDataVecType) :: data_outMAS
+    type(numericsType) :: data_par1
 
 
     integer :: numst, i
@@ -18,16 +20,6 @@
     character(len = 50) :: filename_out
     character(len = 50) :: filename_in2
 
-    !type :: datatype_inMAS1
-    !    real, allocatable :: mas_w(:)    !
-    !    real, allocatable :: mas_dt(:)
-    !    real, allocatable :: mas_st(:)
-    !    real, allocatable :: mas_dq(:)
-    !    real, allocatable :: mas_cflh(:)
-    !    real, allocatable :: mas_z0in(:)
-    !end type
-    type(meteoDataVecType) :: meteo
-
     !input
     !  mas_w - abs(wind velocity) at constant flux layer (cfl) hight (m/s)
     !  mas_dt - difference between potential temperature at cfl hight and at surface  ( deg. k)
@@ -39,21 +31,6 @@
     !  lu_indx -  1 for land, 2 for sea, 3 for lake
     !  test - file input
 
-    !type :: datatype_outMAS1
-    !    real, allocatable :: masout_zl(:)
-    !    real, allocatable :: masout_ri(:)
-    !    real, allocatable :: masout_re(:)
-    !    real, allocatable :: masout_lnzuzt(:)
-    !    real, allocatable :: masout_zu(:)
-    !    real, allocatable :: masout_ztout(:)
-    !    real, allocatable :: masout_rith(:)
-    !    real, allocatable :: masout_cm(:)
-    !    real, allocatable :: masout_ch(:)
-    !    real, allocatable :: masout_ct(:)
-    !    real, allocatable :: masout_ckt(:)
-    !end type
-
-    type(sfxDataVecType) :: data_outMAS
 
     !output
     !masout_zl - non-dimensional cfl hight
@@ -128,25 +105,14 @@
     enddo
 
     CALL get_surface_fluxes_vec(data_outMAS, meteo, &
-            !data_outMAS%zeta, data_outMAS%Rib, data_outMAS%Re, data_outMAS%B,&
-            !data_outMAS%z0_m,data_outMAS%z0_t,data_outMAS%Rib_conv_lim,data_outMAS%Cm,&
-            !data_outMAS%Ct,data_outMAS%Km,data_outMAS%Pr_t_inv,&
             data_par1, numst)
 
-    !CALL surf_fluxMAS(meteo%mas_w, meteo%mas_dt, meteo%mas_st, meteo%mas_dq,&
-    !        meteo%mas_cflh, meteo%mas_z0in,&
-    !        data_outMAS%masout_zl, data_outMAS%masout_ri, data_outMAS%masout_re, data_outMAS%masout_lnzuzt,&
-    !        data_outMAS%masout_zu,data_outMAS%masout_ztout,data_outMAS%masout_rith,data_outMAS%masout_cm,&
-    !        data_outMAS%masout_ch,data_outMAS%masout_ct,data_outMAS%masout_ckt,&
-    !        data_par1, data_lutyp1,numst)
-
     do i=1,numst
         write (2,20) data_outMAS%zeta(i), data_outMAS%Rib(i), data_outMAS%Re(i), data_outMAS%B(i),&
                 data_outMAS%z0_m(i), data_outMAS%z0_t(i), data_outMAS%Rib_conv_lim(i), data_outMAS%Cm(i),&
                 data_outMAS%Ct(i), data_outMAS%Km(i), data_outMAS%Pr_t_inv(i)
     enddo
 
-
     deallocate(meteo%h)
     deallocate(meteo%U)
     deallocate(meteo%dT)
diff --git a/sfx_phys_const.f90 b/srcF/sfx_phys_const.f90
similarity index 100%
rename from sfx_phys_const.f90
rename to srcF/sfx_phys_const.f90
-- 
GitLab