New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
2019WP/KERNEL-02_Storkey_Coward_IMMERSE_first_steps (diff) – NEMO

Changes between Version 14 and Version 15 of 2019WP/KERNEL-02_Storkey_Coward_IMMERSE_first_steps


Ignore:
Timestamp:
2019-03-04T16:10:39+01:00 (5 years ago)
Author:
nicolasmartin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • 2019WP/KERNEL-02_Storkey_Coward_IMMERSE_first_steps

    v14 v15  
    8989Perl is used in a 'edit in place' mode so the original files will be overwritten. Step 1 is therefore to create copies of the test files: 
    9090 
    91 {{{ 
     91{{{#!bash 
    9292#!/bin/bash 
    9393mkdir TEST_FILES 
     
    9898'''The refactoring script''' 
    9999 
    100 {{{ 
     100{{{#!bash 
    101101#!/bin/bash 
    102102# 
     
    123123'''The refactoring script explained''' 
    124124 
    125 {{{ 
     125{{{#!bash 
    126126# Some bash arrays to list the old names, new names and associated time-level index.  
    127127# The choice of names here is not meant to reflect a desired choice. Note all three arrays  
     
    183183''' Some contrived tests:''' 
    184184 
    185 {{{ 
    186 cat TEST_FILES_ORG/contrived_tests.F90 
     185{{{#!f 
     186!cat TEST_FILES_ORG/contrived_tests.F90 
    187187  un(:,:,:)                    ! The simplest test. Should ==> uu(:,:,:,jtn) 
    188188   un ( ji   , jj,   : )        ! Check alternative simple case ==> uu ( ji   , jj,   :,jtn) 
     
    203203'''Result of the script on the contrived tests:''' 
    204204 
    205 {{{ 
     205{{{#!f 
    206206   uu(:,:,:,Nii)                    ! The simplest test. Should ==> uu(:,:,:,jtn) 
    207207   uu ( ji   , jj,   : ,Nii)        ! Check alternative simple case ==> uu ( ji   , jj,   :,jtn) 
     
    566566 
    567567Here is a almost complete attempt at automating the loop changes. Earlier versions (now superceded) maintained the DO loop ranges as arguments to the macros. These arguments are now interptreted and converted to the binary representative form suggested by Gurvan. The logic for this is basic at present and possibly easily fooled (but works on the examples used so far). I've persisted with a two-stage conversion with a script to convert 2D loops and then a second script to convert 3D loops. This makes the scripts readable and allows easier verification. The two scripts are named `do2dfinder.pl` and `do3dfinder.pl` and are included below. Firstly here is an example of the scripts in action on the following test file: 
    568 {{{ 
     568{{{#!f 
    569569cat TESTDO_FILES/testdo.F90 
    570570!   some random text 
     
    985985}}} 
    986986And finally the two scripts that achieve this. Note the logic that may need tightening at sections 5 and 6 in the first script: 
    987 {{{ 
    988 cat do2dfinder.pl 
     987{{{#!perl 
     988#cat do2dfinder.pl 
    989989# 
    990990open(F,$ARGV[0]) || die "Cannot open $ARGV[0]: $!"; 
     
    11091109}}} 
    11101110and 
    1111 {{{ 
    1112 cat do3dfinder.pl 
     1111{{{#!perl 
     1112#cat do3dfinder.pl 
    11131113# 
    11141114use IO::Scalar;